OrthographicPhysicsCamera
new OrthographicPhysicsCamera(physics : Object, options : Object)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
physicsObjectoptionsoptionalObjectDefault is
{}.zoomoptionalnumberVisible area half-height in world units
Default is10.nearoptionalnumberNear clipping plane
Default is0.1.faroptionalnumberFar clipping plane
Default is1000.targetoptionalTHREE.Object3DTarget object to follow
Default isnull.playerBodyIndexoptionalnumberExplicit 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
deltanumbersetTarget#
setTarget(target : THREE.Object3D) : thisSet the target object the camera follows. Automatically syncs playerBodyIndex if target has a dynamic physics body.
Parameters
targetTHREE.Object3DReturns
this — For chainingresize#
resize(width : number, height : number) : thisHandle window resize. Updates frustum and projection matrix.
Parameters
widthoptionalnumberDefault is
window.innerWidth.heightoptionalnumberDefault is
window.innerHeight.Returns
this — For chainingdispose#
dispose()Clean up resources and event listeners. Call when camera is no longer needed.