CameraSyncSystem
Syncs CameraComponent authoring values to the live THREE.js camera object each frame, handling both perspective and orthographic projection modes.
Overview
CameraSyncSystem runs every frame and is responsible for:
- Updating
fov,near,far, andzoomonTHREE.PerspectiveCamerafrom the component values. - Updating
left,right,top,bottom,near,far, andzoomonTHREE.OrthographicCamera. - Clamping all values to safe ranges (
near ≥ 0.001,far > near,fovin[1, 179],zoom ≥ 0.001) so an invalid inspector value never breaks the camera projection matrix. - Normalizing orthographic bounds so that
right > leftandtop > bottomare always satisfied. - Calling
updateProjectionMatrix()whenever a change is detected.
Queried components
| Component | Access |
|---|---|
CameraComponent | Read + sanitize (clamps written back to component fields) |
Object3DRef | Read (the live THREE.js camera object) |
Behavior notes
- Projection type — the system checks the concrete type of the object in
Object3DRef(instanceof THREE.PerspectiveCamera/THREE.OrthographicCamera) and applies the matching update path. If neither type matches, the entity is skipped. - Aspect ratio — perspective cameras auto-update aspect from
window.innerWidth / window.innerHeighteach frame when a window is available. - Change detection — property values are compared before writing to avoid redundant
updateProjectionMatrix()calls on every frame.
API reference
- Class:
CameraComponent - Source:
core/systems/CameraSyncSystem.ts

