PhysicsCamera
new PhysicsCamera(physics : Object, options : Object)PhysicsCamera - Abstract base class for physics-integrated cameras
Extends THREE.PerspectiveCamera to add physics worker synchronization. Use directly with renderer.render(scene, camera).
Usage
Constructor Parameters
physicsObjectPhysics instance
optionsoptionalObjectCamera options
Default is
Default is
{}.fovoptionalnumberField of view in degrees
Default is70.aspectoptionalnumberAspect ratio (updated on resize)
Default is1.nearoptionalnumberNear clipping plane
Default is0.1.faroptionalnumberFar clipping plane
Default is1000.targetoptionalTHREE.Object3DTarget object to follow
Default isnull.playerBodyIndexoptionalnumberExplicit body index to follow (overrides auto-detection from target)
Example
// Subclass to create specific camera types
class MyCamera extends PhysicsCamera {
update(delta) {
this._syncFromWorker();
}
}
Properties
# .physics : Object
Reference to Physics instance.
# .target : THREE.Object3D|null
Target object the camera follows.
Methods
update#
update(delta : number)Update camera state. Must be called each frame. Implement in subclass.
Parameters
deltanumberTime delta in seconds
setTarget#
setTarget(target : THREE.Object3D) : thisSet the target object the camera follows. Automatically syncs playerBodyIndex if target has a dynamic physics body.
Parameters
targetTHREE.Object3DObject to follow
Returns
this — For chainingresize#
resize(width : number, height : number) : thisHandle window resize. Updates aspect ratio and projection matrix.
Parameters
widthoptionalnumberNew width
Default is
Default is
window.innerWidth.heightoptionalnumberNew height
Default is
Default is
window.innerHeight.Returns
this — For chainingdispose#
dispose()Clean up resources and event listeners. Call when camera is no longer needed.