ProtectedcfgProtectednameReadonlyobjThe THREE.Camera instance used for rendering the scene. It can represent different camera types, such as perspective or orthographic.
Reference to the original THREE.Camera loaded from the GLTF scene.
Target object used as the camera look-at target.
The active Three.js renderer used by this object. It is exposed for advanced use cases that require renderer-dependent Three.js APIs, such as reading the canvas size, pixel ratio, drawing buffer size, or updating renderer-based helper objects like cube cameras.
The THREE.Scene instance this object belongs to.
Reference to the original target THREE.Object3D loaded from the GLTF scene.
Registers a listener that is called whenever the specified event occurs.
The event type to listen for.
Callback invoked when the event occurs.
A function that unsubscribes the listener.
Returns the object's screen position in canvas coordinates.
Camera used for projection to canvas coordinates.
The projected screen position in canvas coordinates, or null if no THREE.Object3D is assigned.
Called once after the THREE.Scene, the THREE.WebGLRenderer or THREE.WebGPURenderer, the EnvCtrls are initialized and an existing GLTF model has been loaded and traversed.
Called once after the THREE.Scene is initialized, before an existing GLTF model is loaded.
Called once for a camera found while traversing a GLTF scene. Copies the traversed camera type, projection settings, and world transform to obj.
The GLTF THREE.Camera object.
Example
import { Object3D, PerspectiveCamera, Bone } from 'three';
import { Cam3D } from 'illutions';
export class DollyCamera extends Cam3D {
private offsetGltf: Bone | null = null;
public override onTraverse(objGltf: PerspectiveCamera): void {
const dollyRig = this.scene.getObjectByName('Dolly_Rig');
if (!dollyRig) { return; }
dollyRig.traverse((child: Object3D) => {
if (child instanceof Bone && child.isBone) {
if (child.name === 'Camera_Offset') {
this.offsetGltf = child;
} else if (child.name === 'Aim') {
this.targetGltf = child;
}
}
});
if (objGltf && this.offsetGltf && this.targetGltf) {
objGltf.updateMatrixWorld(true);
// near, far, fov, zoom, frustum,...
this.obj.copy(objGltf);
// Override local with world pose
this.offsetGltf.getWorldPosition(this.obj.position);
this.targetGltf.getWorldPosition(this.objTarget.position);
// Set FOV from GLTF camera
if (this.obj instanceof PerspectiveCamera) {
this.obj.updateProjectionMatrix();
}
// Camera looks at aim
this.obj.lookAt(this.objTarget.position);
}
this.objGltf = objGltf;
}
}
Called on every animation frame update.
Time elapsed since the previous frame in seconds.
Removes a previously registered listener for the specified event.
The event type to remove the listener from.
Callback to remove from the event listeners.
Wraps a
THREE.Cameraand provides a structured interface for configuring and controlling camera settings.