OrthographicPhysicsCamera

@three-blocks/proPhysicsCamera2DOrthographicWebGPUWebGL
new OrthographicPhysicsCamera(physics : Object, options : Object)
Extends
THREE.OrthographicCamera

OrthographicPhysicsCamera - Base class for orthographic physics-integrated cameras

Extends THREE.OrthographicCamera to add physics worker synchronization. Use directly with renderer.render(scene, camera).

The camera uses a zoom property (in world units) to define the visible area. This is more intuitive than setting left/right/top/bottom directly.

Usage

Constructor Parameters
physicsObject
Physics instance
optionsoptionalObject
Camera options
Default is {}.
  • zoomoptionalnumber
    Visible area half-height in world units
    Default is 10.
  • nearoptionalnumber
    Near clipping plane
    Default is 0.1.
  • faroptionalnumber
    Far clipping plane
    Default is 1000.
  • targetoptionalTHREE.Object3D
    Target object to follow
    Default is null.
  • playerBodyIndexoptionalnumber
    Explicit body index to follow
Example
// Subclass to create specific camera types
class My2DCamera extends OrthographicPhysicsCamera {
  update(delta) {
    this._ensureActive();
    // Update camera position
    this._syncToSharedCamera();
  }
}

Properties

.physics : Object

Reference to Physics instance.

.target : THREE.Object3D|null

Target object the camera follows.

.orthoZoom : number

Get the zoom level (visible area half-height in world units).

.orthoZoom : number

Set the zoom level (visible area half-height in world units). Automatically updates the frustum and projection matrix.

Methods

update#

update(delta : number)

Update camera state. Must be called each frame. Implement in subclass.

Parameters
deltanumber
Time delta in seconds

setTarget#

setTarget(target : THREE.Object3D) : this

Set the target object the camera follows. Automatically syncs playerBodyIndex if target has a dynamic physics body.

Parameters
targetTHREE.Object3D
Object to follow
Returns
this — For chaining

resize#

resize(width : number, height : number) : this

Handle window resize. Updates frustum and projection matrix.

Parameters
widthoptionalnumber
New width
Default is window.innerWidth.
heightoptionalnumber
New height
Default is window.innerHeight.
Returns
this — For chaining

dispose#

dispose()

Clean up resources and event listeners. Call when camera is no longer needed.