PhysicsCamera

@three-blocks/pro
new PhysicsCamera(physics : Object, options : Object)
Extends
THREE.PerspectiveCamera

Create a PhysicsCamera.

Constructor Parameters
physicsObject
Physics instance
optionsoptionalObject
Camera options
Default is {}.
  • fovoptionalnumber
    Field of view in degrees
    Default is 70.
  • aspectoptionalnumber
    Aspect ratio (updated on resize)
    Default is 1.
  • nearoptionalnumber
    Near clipping plane
    Default is 0.1.
  • faroptionalnumber
    Far clipping plane
    Default is 1000.
  • targetoptionalTHREE.Object3D
    Target object to follow
    Default is null.

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
deltanumber
Time delta in seconds

setTarget#

setTarget(target : THREE.Object3D) : this

Set the target object the camera follows.

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

resize#

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

Handle window resize. Updates aspect ratio 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.