@woosh/meep-engine 3.80.2 → 3.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/build/bundle-worker-terrain.js +1 -1
- package/editor/Editor.d.ts +10 -2
- package/editor/Editor.d.ts.map +1 -1
- package/editor/Editor.js +33 -23
- package/editor/EditorCameraNavigation.d.ts +3 -4
- package/editor/EditorCameraNavigation.d.ts.map +1 -1
- package/editor/EditorCameraNavigation.js +29 -8
- package/editor/prototypeEditorShell.d.ts.map +1 -1
- package/editor/prototypeEditorShell.js +10 -2
- package/editor/tools/GridPaintTool.d.ts.map +1 -1
- package/editor/tools/GridPaintTool.js +12 -7
- package/package.json +1 -1
- package/src/core/geom/3d/quaternion/quat3_slerp.d.ts +25 -0
- package/src/core/geom/3d/quaternion/quat3_slerp.d.ts.map +1 -0
- package/src/core/geom/3d/quaternion/quat3_slerp.js +66 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_cluster_compute_normal_bounding_cone.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_face_cluster_compute_normal_bounding_cone.js +9 -5
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_bounding_sphere.d.ts +3 -3
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_bounding_sphere.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_compute_bounding_sphere.js +5 -14
- package/src/core/geom/packing/miniball/Miniball.d.ts +8 -181
- package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
- package/src/core/geom/packing/miniball/Miniball.js +10 -452
- package/src/core/geom/packing/miniball/PointSet.d.ts +13 -39
- package/src/core/geom/packing/miniball/PointSet.d.ts.map +1 -1
- package/src/core/geom/packing/miniball/PointSet.js +14 -54
- package/src/core/geom/packing/sphere_compute_bounding_of_points.d.ts +20 -0
- package/src/core/geom/packing/sphere_compute_bounding_of_points.d.ts.map +1 -0
- package/src/core/geom/packing/sphere_compute_bounding_of_points.js +66 -0
- package/src/core/geom/packing/sphere_compute_bounding_of_spheres.d.ts.map +1 -1
- package/src/core/geom/packing/sphere_compute_bounding_of_spheres.js +0 -1
- package/src/core/math/exponential_approach.d.ts +23 -0
- package/src/core/math/exponential_approach.d.ts.map +1 -0
- package/src/core/math/exponential_approach.js +31 -0
- package/src/core/math/physics/spring/Spring.d.ts.map +1 -0
- package/src/core/math/physics/spring/criticallyDampedSpring.d.ts.map +1 -0
- package/src/core/math/physics/spring/dampedSpringStep.d.ts.map +1 -0
- package/src/engine/EngineHarness.d.ts +1 -3
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +13 -10
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +9 -15
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +9 -10
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +68 -14
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +196 -184
- package/src/engine/ecs/gui/hud/testHudEdgeStick.js +4 -2
- package/src/engine/ecs/parent/parent_entity_root_of.d.ts +11 -0
- package/src/engine/ecs/parent/parent_entity_root_of.d.ts.map +1 -0
- package/src/engine/ecs/parent/parent_entity_root_of.js +32 -0
- package/src/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +130 -130
- package/src/engine/graphics/camera/makeOrbitalCameraController.d.ts +3 -2
- package/src/engine/graphics/camera/makeOrbitalCameraController.d.ts.map +1 -1
- package/src/engine/graphics/camera/makeOrbitalCameraController.js +18 -11
- package/src/engine/graphics/camera/orbital/OrbitalCameraRig.d.ts +4 -5
- package/src/engine/graphics/camera/orbital/OrbitalCameraRig.d.ts.map +1 -1
- package/src/engine/graphics/camera/orbital/OrbitalCameraRig.js +6 -6
- package/src/engine/graphics/camera/rig/CameraRig.d.ts +55 -0
- package/src/engine/graphics/camera/rig/CameraRig.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/CameraRig.js +65 -0
- package/src/engine/graphics/camera/rig/CameraRigContext.d.ts +58 -0
- package/src/engine/graphics/camera/rig/CameraRigContext.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/CameraRigContext.js +51 -0
- package/src/engine/graphics/camera/rig/CameraRigDriver.d.ts +36 -0
- package/src/engine/graphics/camera/rig/CameraRigDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/CameraRigDriver.js +39 -0
- package/src/engine/graphics/camera/rig/CameraRigSystem.d.ts +30 -0
- package/src/engine/graphics/camera/rig/CameraRigSystem.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/CameraRigSystem.js +81 -0
- package/src/engine/graphics/camera/rig/CameraState.d.ts +59 -0
- package/src/engine/graphics/camera/rig/CameraState.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/CameraState.js +76 -0
- package/src/engine/graphics/camera/rig/camera_rig_output.d.ts +17 -0
- package/src/engine/graphics/camera/rig/camera_rig_output.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/camera_rig_output.js +80 -0
- package/src/engine/graphics/camera/rig/camera_rig_update.d.ts +38 -0
- package/src/engine/graphics/camera/rig/camera_rig_update.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/camera_rig_update.js +102 -0
- package/src/engine/graphics/camera/rig/camera_state_read_entity.d.ts +17 -0
- package/src/engine/graphics/camera/rig/camera_state_read_entity.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/camera_state_read_entity.js +71 -0
- package/src/engine/graphics/camera/rig/drivers/CameraBlendDriver.d.ts +95 -0
- package/src/engine/graphics/camera/rig/drivers/CameraBlendDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraBlendDriver.js +290 -0
- package/src/engine/graphics/camera/rig/drivers/CameraCollideDriver.d.ts +37 -0
- package/src/engine/graphics/camera/rig/drivers/CameraCollideDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraCollideDriver.js +158 -0
- package/src/engine/graphics/camera/rig/drivers/CameraFollowDriver.d.ts +28 -0
- package/src/engine/graphics/camera/rig/drivers/CameraFollowDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraFollowDriver.js +66 -0
- package/src/engine/graphics/camera/rig/drivers/CameraFovDriver.d.ts +29 -0
- package/src/engine/graphics/camera/rig/drivers/CameraFovDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraFovDriver.js +65 -0
- package/src/engine/graphics/camera/rig/drivers/CameraImpulseDriver.d.ts +113 -0
- package/src/engine/graphics/camera/rig/drivers/CameraImpulseDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraImpulseDriver.js +442 -0
- package/src/engine/graphics/camera/rig/drivers/CameraLookAtDriver.d.ts +32 -0
- package/src/engine/graphics/camera/rig/drivers/CameraLookAtDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraLookAtDriver.js +78 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOffsetDriver.d.ts +36 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOffsetDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOffsetDriver.js +54 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOffsetFrame.d.ts +10 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOffsetFrame.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOffsetFrame.js +22 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOrbitDriver.d.ts +182 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOrbitDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraOrbitDriver.js +455 -0
- package/src/engine/graphics/camera/rig/drivers/CameraPositionDriver.d.ts +31 -0
- package/src/engine/graphics/camera/rig/drivers/CameraPositionDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraPositionDriver.js +57 -0
- package/src/engine/graphics/camera/rig/drivers/CameraShakeDriver.d.ts +62 -0
- package/src/engine/graphics/camera/rig/drivers/CameraShakeDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraShakeDriver.js +174 -0
- package/src/engine/graphics/camera/rig/drivers/CameraSmoothDriver.d.ts +29 -0
- package/src/engine/graphics/camera/rig/drivers/CameraSmoothDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraSmoothDriver.js +82 -0
- package/src/engine/graphics/camera/rig/drivers/CameraYawPitchRollDriver.d.ts +40 -0
- package/src/engine/graphics/camera/rig/drivers/CameraYawPitchRollDriver.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/CameraYawPitchRollDriver.js +66 -0
- package/src/engine/graphics/camera/rig/drivers/camera_state_add_offset.d.ts +22 -0
- package/src/engine/graphics/camera/rig/drivers/camera_state_add_offset.d.ts.map +1 -0
- package/src/engine/graphics/camera/rig/drivers/camera_state_add_offset.js +81 -0
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts +6 -131
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -378
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.d.ts +4 -2
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.js +16 -27
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.d.ts +4 -0
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.js +4 -0
- package/src/engine/graphics/ecs/light/Light.d.ts +10 -5
- package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/Light.js +15 -24
- package/src/engine/graphics/geometry/computeBoundingSphereFromVertexData.d.ts +0 -4
- package/src/engine/graphics/geometry/computeBoundingSphereFromVertexData.d.ts.map +1 -1
- package/src/engine/graphics/geometry/computeBoundingSphereFromVertexData.js +12 -11
- package/src/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.js +5 -5
- package/src/engine/graphics3/LightSystem.js +0 -3
- package/src/engine/input/ecs/controllers/KeyboardCameraController.d.ts +2 -2
- package/src/engine/input/ecs/controllers/KeyboardCameraController.d.ts.map +1 -1
- package/src/engine/input/ecs/controllers/KeyboardCameraController.js +3 -3
- package/src/engine/physics/ecs/ContactProbeSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/ContactProbeSystem.js +3 -25
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/playground/foliage_wind/foliage_world.d.ts.map +1 -1
- package/src/shade/playground/foliage_wind/foliage_world.js +0 -1
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/camera/orbital/OrbitalCameraController.d.ts +4 -4
- package/src/shade/renderer/camera/orbital/OrbitalCameraController.d.ts.map +1 -1
- package/src/shade/renderer/camera/orbital/OrbitalCameraController.js +26 -11
- package/src/shade/renderer/geometry/Geometry.d.ts.map +1 -1
- package/src/shade/renderer/geometry/Geometry.js +2 -11
- package/src/shade/renderer/geometry/virtual/build/sphere/vgeo_bounding_sphere.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/sphere/vgeo_bounding_sphere.js +3 -6
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/core/geom/packing/miniball/Quality.d.ts +0 -92
- package/src/core/geom/packing/miniball/Quality.d.ts.map +0 -1
- package/src/core/geom/packing/miniball/Quality.js +0 -114
- package/src/core/geom/packing/miniball/Subspan.d.ts +0 -191
- package/src/core/geom/packing/miniball/Subspan.d.ts.map +0 -1
- package/src/core/geom/packing/miniball/Subspan.js +0 -529
- package/src/core/geom/packing/miniball/miniball_compute_quality.d.ts +0 -10
- package/src/core/geom/packing/miniball/miniball_compute_quality.d.ts.map +0 -1
- package/src/core/geom/packing/miniball/miniball_compute_quality.js +0 -60
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +0 -146
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +0 -1
- package/src/engine/control/first-person/composer/EyeOffsetStack.js +0 -395
- package/src/engine/control/first-person/math/Spring.d.ts.map +0 -1
- package/src/engine/control/first-person/math/criticallyDampedSpring.d.ts.map +0 -1
- package/src/engine/control/first-person/math/dampedSpringStep.d.ts.map +0 -1
- package/src/engine/graphics/camera/CameraShake.d.ts +0 -32
- package/src/engine/graphics/camera/CameraShake.d.ts.map +0 -1
- package/src/engine/graphics/camera/CameraShake.js +0 -68
- package/src/engine/graphics/camera/CameraShakeBehavior.d.ts +0 -41
- package/src/engine/graphics/camera/CameraShakeBehavior.d.ts.map +0 -1
- package/src/engine/graphics/camera/CameraShakeBehavior.js +0 -91
- package/src/engine/graphics/camera/CameraShakeTraumaBehavior.d.ts +0 -19
- package/src/engine/graphics/camera/CameraShakeTraumaBehavior.d.ts.map +0 -1
- package/src/engine/graphics/camera/CameraShakeTraumaBehavior.js +0 -37
- package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.d.ts +0 -21
- package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.js +0 -79
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.d.ts +0 -28
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +0 -100
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.d.ts +0 -36
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.d.ts.map +0 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +0 -160
- /package/src/{engine/control/first-person/math → core/math/physics/spring}/Spring.d.ts +0 -0
- /package/src/{engine/control/first-person/math → core/math/physics/spring}/Spring.js +0 -0
- /package/src/{engine/control/first-person/math → core/math/physics/spring}/criticallyDampedSpring.d.ts +0 -0
- /package/src/{engine/control/first-person/math → core/math/physics/spring}/criticallyDampedSpring.js +0 -0
- /package/src/{engine/control/first-person/math → core/math/physics/spring}/dampedSpringStep.d.ts +0 -0
- /package/src/{engine/control/first-person/math → core/math/physics/spring}/dampedSpringStep.js +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @typedef {import("../../../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset */
|
|
2
|
+
/** @typedef {import("../../../../core/geom/3d/ray/Ray3.js").Ray3} Ray3 */
|
|
3
|
+
/** @typedef {import("../../../physics/queries/PhysicsSurfacePoint.js").PhysicsSurfacePoint} PhysicsSurfacePoint */
|
|
4
|
+
/**
|
|
5
|
+
* The world queries a driver may run, as {@link PhysicsSystem} answers them: a ray, and a convex shape
|
|
6
|
+
* swept along a ray, each finding the nearest hit that `filter` accepts.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} CameraRigPhysics
|
|
9
|
+
* @property {function(Ray3, PhysicsSurfacePoint, function(number, *):boolean):boolean} raycast
|
|
10
|
+
* @property {function(Ray3, *, ArrayLike<number>, PhysicsSurfacePoint, function(number, *):boolean):boolean} shapeCast
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* What a {@link CameraRigDriver#update} may look at besides the state it is handed.
|
|
14
|
+
*
|
|
15
|
+
* @author Alex Goldring
|
|
16
|
+
* @copyright Company Named Limited (c) 2026
|
|
17
|
+
*/
|
|
18
|
+
export class CameraRigContext {
|
|
19
|
+
/**
|
|
20
|
+
* The dataset the rig's entity lives in.
|
|
21
|
+
* @type {EntityComponentDataset|null}
|
|
22
|
+
*/
|
|
23
|
+
ecd: EntityComponentDataset | null;
|
|
24
|
+
/**
|
|
25
|
+
* The entity whose rig is being updated.
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
entity: number;
|
|
29
|
+
/**
|
|
30
|
+
* Seconds since the previous update, at render rate.
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
33
|
+
dt: number;
|
|
34
|
+
/**
|
|
35
|
+
* Update stamp. A rig records the stamp it was last updated at, so one that several others read is
|
|
36
|
+
* updated once per stamp. Whoever drives the updates advances it once per frame.
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
frame: number;
|
|
40
|
+
/**
|
|
41
|
+
* For drivers that cast against the world: the {@link PhysicsSystem}. `null` when there is no
|
|
42
|
+
* physics, and such a driver then leaves the pose as it finds it.
|
|
43
|
+
* @type {CameraRigPhysics|null}
|
|
44
|
+
*/
|
|
45
|
+
physics: CameraRigPhysics | null;
|
|
46
|
+
}
|
|
47
|
+
export type EntityComponentDataset = import("../../../ecs/EntityComponentDataset.js").EntityComponentDataset;
|
|
48
|
+
export type Ray3 = import("../../../../core/geom/3d/ray/Ray3.js").Ray3;
|
|
49
|
+
export type PhysicsSurfacePoint = import("../../../physics/queries/PhysicsSurfacePoint.js").PhysicsSurfacePoint;
|
|
50
|
+
/**
|
|
51
|
+
* The world queries a driver may run, as {@link PhysicsSystem } answers them: a ray, and a convex shape
|
|
52
|
+
* swept along a ray, each finding the nearest hit that `filter` accepts.
|
|
53
|
+
*/
|
|
54
|
+
export type CameraRigPhysics = {
|
|
55
|
+
raycast: (arg0: Ray3, arg1: PhysicsSurfacePoint, arg2: (arg0: number, arg1: any) => boolean) => boolean;
|
|
56
|
+
shapeCast: (arg0: Ray3, arg1: any, arg2: ArrayLike<number>, arg3: PhysicsSurfacePoint, arg4: (arg0: number, arg1: any) => boolean) => boolean;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=CameraRigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraRigContext.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/camera/rig/CameraRigContext.js"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,0EAA0E;AAC1E,mHAAmH;AAEnH;;;;;;;GAOG;AACH;;;;;GAKG;AACH;IACI;;;OAGG;IACH,KAFU,sBAAsB,GAAC,IAAI,CAE1B;IAEX;;;OAGG;IACH,QAFU,MAAM,CAEJ;IAEZ;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;;OAIG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,SAFU,gBAAgB,GAAC,IAAI,CAEhB;CAClB;qCAlDa,OAAO,wCAAwC,EAAE,sBAAsB;mBACvE,OAAO,sCAAsC,EAAE,IAAI;kCACnD,OAAO,iDAAiD,EAAE,mBAAmB;;;;;;oBAOpE,IAAI,QAAE,mBAAmB,eAAW,MAAM,gBAAK,OAAO,KAAE,OAAO;sBAC/D,IAAI,mBAAK,UAAU,MAAM,CAAC,QAAE,mBAAmB,eAAW,MAAM,gBAAK,OAAO,KAAE,OAAO"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @typedef {import("../../../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset */
|
|
2
|
+
/** @typedef {import("../../../../core/geom/3d/ray/Ray3.js").Ray3} Ray3 */
|
|
3
|
+
/** @typedef {import("../../../physics/queries/PhysicsSurfacePoint.js").PhysicsSurfacePoint} PhysicsSurfacePoint */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The world queries a driver may run, as {@link PhysicsSystem} answers them: a ray, and a convex shape
|
|
7
|
+
* swept along a ray, each finding the nearest hit that `filter` accepts.
|
|
8
|
+
*
|
|
9
|
+
* @typedef {Object} CameraRigPhysics
|
|
10
|
+
* @property {function(Ray3, PhysicsSurfacePoint, function(number, *):boolean):boolean} raycast
|
|
11
|
+
* @property {function(Ray3, *, ArrayLike<number>, PhysicsSurfacePoint, function(number, *):boolean):boolean} shapeCast
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* What a {@link CameraRigDriver#update} may look at besides the state it is handed.
|
|
15
|
+
*
|
|
16
|
+
* @author Alex Goldring
|
|
17
|
+
* @copyright Company Named Limited (c) 2026
|
|
18
|
+
*/
|
|
19
|
+
export class CameraRigContext {
|
|
20
|
+
/**
|
|
21
|
+
* The dataset the rig's entity lives in.
|
|
22
|
+
* @type {EntityComponentDataset|null}
|
|
23
|
+
*/
|
|
24
|
+
ecd = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The entity whose rig is being updated.
|
|
28
|
+
* @type {number}
|
|
29
|
+
*/
|
|
30
|
+
entity = -1;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Seconds since the previous update, at render rate.
|
|
34
|
+
* @type {number}
|
|
35
|
+
*/
|
|
36
|
+
dt = 0;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Update stamp. A rig records the stamp it was last updated at, so one that several others read is
|
|
40
|
+
* updated once per stamp. Whoever drives the updates advances it once per frame.
|
|
41
|
+
* @type {number}
|
|
42
|
+
*/
|
|
43
|
+
frame = 0;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* For drivers that cast against the world: the {@link PhysicsSystem}. `null` when there is no
|
|
47
|
+
* physics, and such a driver then leaves the pose as it finds it.
|
|
48
|
+
* @type {CameraRigPhysics|null}
|
|
49
|
+
*/
|
|
50
|
+
physics = null;
|
|
51
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @typedef {import("./CameraRigContext.js").CameraRigContext} CameraRigContext */
|
|
2
|
+
/**
|
|
3
|
+
* One step of a {@link CameraRig}: reads the {@link CameraState} the drivers before it left and writes
|
|
4
|
+
* it back.
|
|
5
|
+
*
|
|
6
|
+
* A driver's public fields are what input and gameplay write (an orbit's yaw, a shake's trauma). What it
|
|
7
|
+
* remembers between frames to do its job (a smoothed pose, a spring's velocity) is history: it lives on
|
|
8
|
+
* the driver, is never saved, and is dropped by {@link reset}.
|
|
9
|
+
*
|
|
10
|
+
* Drivers are plain objects held in {@link CameraRig#drivers}, not components; whoever builds a rig keeps
|
|
11
|
+
* the drivers it writes to.
|
|
12
|
+
*
|
|
13
|
+
* @author Alex Goldring
|
|
14
|
+
* @copyright Company Named Limited (c) 2026
|
|
15
|
+
*/
|
|
16
|
+
export class CameraRigDriver {
|
|
17
|
+
/**
|
|
18
|
+
* Advance one frame.
|
|
19
|
+
*
|
|
20
|
+
* @param {Float64Array} state {@link CameraState}, read and written in place
|
|
21
|
+
* @param {CameraRigContext} context
|
|
22
|
+
*/
|
|
23
|
+
update(state: Float64Array, context: CameraRigContext): void;
|
|
24
|
+
/**
|
|
25
|
+
* Forget history, so the next {@link update} lands on its goal instead of moving towards it. Runs
|
|
26
|
+
* on a cut. A driver without history has nothing to do.
|
|
27
|
+
*/
|
|
28
|
+
reset(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @readonly
|
|
31
|
+
* @type {boolean}
|
|
32
|
+
*/
|
|
33
|
+
readonly isCameraRigDriver: boolean;
|
|
34
|
+
}
|
|
35
|
+
export type CameraRigContext = import("./CameraRigContext.js").CameraRigContext;
|
|
36
|
+
//# sourceMappingURL=CameraRigDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraRigDriver.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/camera/rig/CameraRigDriver.js"],"names":[],"mappings":"AAAA,mFAAmF;AACnF;;;;;;;;;;;;;GAaG;AACH;IACI;;;;;OAKG;IACH,cAHW,YAAY,WACZ,gBAAgB,QAI1B;IAED;;;OAGG;IACH,cACC;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;+BAhCa,OAAO,uBAAuB,EAAE,gBAAgB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @typedef {import("./CameraRigContext.js").CameraRigContext} CameraRigContext */
|
|
2
|
+
/**
|
|
3
|
+
* One step of a {@link CameraRig}: reads the {@link CameraState} the drivers before it left and writes
|
|
4
|
+
* it back.
|
|
5
|
+
*
|
|
6
|
+
* A driver's public fields are what input and gameplay write (an orbit's yaw, a shake's trauma). What it
|
|
7
|
+
* remembers between frames to do its job (a smoothed pose, a spring's velocity) is history: it lives on
|
|
8
|
+
* the driver, is never saved, and is dropped by {@link reset}.
|
|
9
|
+
*
|
|
10
|
+
* Drivers are plain objects held in {@link CameraRig#drivers}, not components; whoever builds a rig keeps
|
|
11
|
+
* the drivers it writes to.
|
|
12
|
+
*
|
|
13
|
+
* @author Alex Goldring
|
|
14
|
+
* @copyright Company Named Limited (c) 2026
|
|
15
|
+
*/
|
|
16
|
+
export class CameraRigDriver {
|
|
17
|
+
/**
|
|
18
|
+
* Advance one frame.
|
|
19
|
+
*
|
|
20
|
+
* @param {Float64Array} state {@link CameraState}, read and written in place
|
|
21
|
+
* @param {CameraRigContext} context
|
|
22
|
+
*/
|
|
23
|
+
update(state, context) {
|
|
24
|
+
throw new Error(`${this.constructor.name} does not implement update`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Forget history, so the next {@link update} lands on its goal instead of moving towards it. Runs
|
|
29
|
+
* on a cut. A driver without history has nothing to do.
|
|
30
|
+
*/
|
|
31
|
+
reset() {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @readonly
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
CameraRigDriver.prototype.isCameraRigDriver = true;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates every {@link CameraRig} once a render frame and writes each result onto its entity's
|
|
3
|
+
* {@link Transform64} and {@link Camera}. A rig that others read (followed, looked at, blended to) is
|
|
4
|
+
* updated when first read, and once per frame however many read it.
|
|
5
|
+
*
|
|
6
|
+
* Declared access, which is what orders this against everything else:
|
|
7
|
+
* - **Read** {@link CameraRig}. Driver history changes inside an update, but nothing outside the update
|
|
8
|
+
* reads it, so for ordering this system reads the rig. Whatever writes driver fields declares Write on
|
|
9
|
+
* {@link CameraRig} and so runs first.
|
|
10
|
+
* - **Read and Write** {@link Transform64} and {@link Camera}: drivers read other entities' poses and
|
|
11
|
+
* lenses, and the output reads its own transform to tell a move from a rewrite before writing it.
|
|
12
|
+
*
|
|
13
|
+
* @author Alex Goldring
|
|
14
|
+
* @copyright Company Named Limited (c) 2026
|
|
15
|
+
*/
|
|
16
|
+
export class CameraRigSystem extends System<any> {
|
|
17
|
+
constructor();
|
|
18
|
+
enabled: ObservedValue<boolean>;
|
|
19
|
+
dependencies: (typeof CameraRig)[];
|
|
20
|
+
components_used: (ResourceAccessSpecification<typeof Transform64> | ResourceAccessSpecification<typeof CameraRig> | ResourceAccessSpecification<typeof Camera>)[];
|
|
21
|
+
update(time_delta: any): void;
|
|
22
|
+
#private;
|
|
23
|
+
}
|
|
24
|
+
import { System } from "../../../ecs/System.js";
|
|
25
|
+
import ObservedValue from "../../../../core/model/ObservedValue.js";
|
|
26
|
+
import { CameraRig } from "./CameraRig.js";
|
|
27
|
+
import { Transform64 } from "../../../ecs/transform/Transform64.js";
|
|
28
|
+
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
29
|
+
import { Camera } from "../../ecs/camera/Camera.js";
|
|
30
|
+
//# sourceMappingURL=CameraRigSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraRigSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/camera/rig/CameraRigSystem.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH;;IACI,gCAAkC;IAElC,mCAA2B;IAE3B,kKAIE;IAqBF,8BAsBC;;CACJ;uBA7EsB,wBAAwB;0BAHrB,yCAAyC;0BASzC,gBAAgB;4BALd,uCAAuC;4CAFvB,uDAAuD;uBAI5E,4BAA4B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import ObservedValue from "../../../../core/model/ObservedValue.js";
|
|
2
|
+
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
3
|
+
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
4
|
+
import { System } from "../../../ecs/System.js";
|
|
5
|
+
import { Transform64 } from "../../../ecs/transform/Transform64.js";
|
|
6
|
+
import { PhysicsSystem } from "../../../physics/ecs/PhysicsSystem.js";
|
|
7
|
+
import { Camera } from "../../ecs/camera/Camera.js";
|
|
8
|
+
import { camera_rig_output } from "./camera_rig_output.js";
|
|
9
|
+
import { camera_rig_ensure_updated } from "./camera_rig_update.js";
|
|
10
|
+
import { CameraRig } from "./CameraRig.js";
|
|
11
|
+
import { CameraRigContext } from "./CameraRigContext.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Updates every {@link CameraRig} once a render frame and writes each result onto its entity's
|
|
15
|
+
* {@link Transform64} and {@link Camera}. A rig that others read (followed, looked at, blended to) is
|
|
16
|
+
* updated when first read, and once per frame however many read it.
|
|
17
|
+
*
|
|
18
|
+
* Declared access, which is what orders this against everything else:
|
|
19
|
+
* - **Read** {@link CameraRig}. Driver history changes inside an update, but nothing outside the update
|
|
20
|
+
* reads it, so for ordering this system reads the rig. Whatever writes driver fields declares Write on
|
|
21
|
+
* {@link CameraRig} and so runs first.
|
|
22
|
+
* - **Read and Write** {@link Transform64} and {@link Camera}: drivers read other entities' poses and
|
|
23
|
+
* lenses, and the output reads its own transform to tell a move from a rewrite before writing it.
|
|
24
|
+
*
|
|
25
|
+
* @author Alex Goldring
|
|
26
|
+
* @copyright Company Named Limited (c) 2026
|
|
27
|
+
*/
|
|
28
|
+
export class CameraRigSystem extends System {
|
|
29
|
+
enabled = new ObservedValue(true);
|
|
30
|
+
|
|
31
|
+
dependencies = [CameraRig];
|
|
32
|
+
|
|
33
|
+
components_used = [
|
|
34
|
+
ResourceAccessSpecification.from(CameraRig, ResourceAccessKind.Read),
|
|
35
|
+
ResourceAccessSpecification.from(Transform64, ResourceAccessKind.Read | ResourceAccessKind.Write),
|
|
36
|
+
ResourceAccessSpecification.from(Camera, ResourceAccessKind.Read | ResourceAccessKind.Write),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @type {CameraRigContext}
|
|
41
|
+
*/
|
|
42
|
+
#context = new CameraRigContext();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {CameraRig} rig
|
|
46
|
+
* @param {number} entity
|
|
47
|
+
*/
|
|
48
|
+
#visit = (rig, entity) => {
|
|
49
|
+
const context = this.#context;
|
|
50
|
+
|
|
51
|
+
context.entity = entity;
|
|
52
|
+
|
|
53
|
+
camera_rig_ensure_updated(rig, context);
|
|
54
|
+
|
|
55
|
+
camera_rig_output(rig, context.ecd, entity);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
update(time_delta) {
|
|
59
|
+
if (!this.enabled.getValue()) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const em = this.entityManager;
|
|
64
|
+
const dataset = em.dataset;
|
|
65
|
+
|
|
66
|
+
if (dataset === null || dataset === undefined) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const context = this.#context;
|
|
71
|
+
|
|
72
|
+
context.ecd = dataset;
|
|
73
|
+
context.dt = time_delta;
|
|
74
|
+
context.frame++;
|
|
75
|
+
context.physics = em.getSystem(PhysicsSystem);
|
|
76
|
+
|
|
77
|
+
dataset.traverseComponents(CameraRig, this.#visit);
|
|
78
|
+
|
|
79
|
+
context.entity = -1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start a state over: at the origin, unturned, the pivot at the origin, with the given field of view.
|
|
3
|
+
*
|
|
4
|
+
* @param {CameraState} state
|
|
5
|
+
* @param {number} fov degrees
|
|
6
|
+
*/
|
|
7
|
+
export function camera_state_clear(state: CameraState, fov: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* Put a state's pose onto a transform: translation, rotation, and the matrix after them. Scale is
|
|
10
|
+
* left as it is.
|
|
11
|
+
*
|
|
12
|
+
* @param {Transform64} transform
|
|
13
|
+
* @param {CameraState} state
|
|
14
|
+
*/
|
|
15
|
+
export function camera_state_to_transform(transform: Transform64, state: CameraState): void;
|
|
16
|
+
/**
|
|
17
|
+
* The value every {@link CameraRigDriver} reads and writes: a camera's pose, the point the view is
|
|
18
|
+
* about, and its field of view, as eleven doubles.
|
|
19
|
+
*
|
|
20
|
+
* The first seven floats are a rigid pose in the layout `t64_read_pose_array` produces,
|
|
21
|
+
* `[tx, ty, tz, qx, qy, qz, qw]`.
|
|
22
|
+
*
|
|
23
|
+
* @typedef {Float64Array} CameraState
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Doubles in a {@link CameraState}.
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
export const CAMERA_STATE_SIZE: number;
|
|
30
|
+
/**
|
|
31
|
+
* World position, 3 doubles.
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
export const CAMERA_STATE_POSITION: number;
|
|
35
|
+
/**
|
|
36
|
+
* World rotation as a unit quaternion `x, y, z, w`, 4 doubles. The camera looks along its +Z.
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
export const CAMERA_STATE_ROTATION: number;
|
|
40
|
+
/**
|
|
41
|
+
* The point the view is about, 3 doubles: what a follow driver follows, what an orbit swings around,
|
|
42
|
+
* what a look-at driver looks at. Source drivers set it; drivers that only shape the pose leave it.
|
|
43
|
+
* @type {number}
|
|
44
|
+
*/
|
|
45
|
+
export const CAMERA_STATE_PIVOT: number;
|
|
46
|
+
/**
|
|
47
|
+
* Vertical field of view in degrees, as {@link Camera#fov} holds it.
|
|
48
|
+
* @type {number}
|
|
49
|
+
*/
|
|
50
|
+
export const CAMERA_STATE_FOV: number;
|
|
51
|
+
/**
|
|
52
|
+
* The value every {@link CameraRigDriver } reads and writes: a camera's pose, the point the view is
|
|
53
|
+
* about, and its field of view, as eleven doubles.
|
|
54
|
+
*
|
|
55
|
+
* The first seven floats are a rigid pose in the layout `t64_read_pose_array` produces,
|
|
56
|
+
* `[tx, ty, tz, qx, qy, qz, qw]`.
|
|
57
|
+
*/
|
|
58
|
+
export type CameraState = Float64Array;
|
|
59
|
+
//# sourceMappingURL=CameraState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraState.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/camera/rig/CameraState.js"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,0CAHW,WAAW,OACX,MAAM,QAiBhB;AAED;;;;;;GAMG;AACH,yEAFW,WAAW,QAMrB;AA3ED;;;;;;;;GAQG;AAEH;;;GAGG;AACH,gCAFU,MAAM,CAEoB;AAEpC;;;GAGG;AACH,oCAFU,MAAM,CAEuB;AAEvC;;;GAGG;AACH,oCAFU,MAAM,CAEuB;AAEvC;;;;GAIG;AACH,iCAFU,MAAM,CAEoB;AAEpC;;;GAGG;AACH,+BAFU,MAAM,CAEmB;;;;;;;;0BAhCtB,YAAY"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value every {@link CameraRigDriver} reads and writes: a camera's pose, the point the view is
|
|
3
|
+
* about, and its field of view, as eleven doubles.
|
|
4
|
+
*
|
|
5
|
+
* The first seven floats are a rigid pose in the layout `t64_read_pose_array` produces,
|
|
6
|
+
* `[tx, ty, tz, qx, qy, qz, qw]`.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Float64Array} CameraState
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Doubles in a {@link CameraState}.
|
|
13
|
+
* @type {number}
|
|
14
|
+
*/
|
|
15
|
+
export const CAMERA_STATE_SIZE = 11;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* World position, 3 doubles.
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
export const CAMERA_STATE_POSITION = 0;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* World rotation as a unit quaternion `x, y, z, w`, 4 doubles. The camera looks along its +Z.
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
export const CAMERA_STATE_ROTATION = 3;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The point the view is about, 3 doubles: what a follow driver follows, what an orbit swings around,
|
|
31
|
+
* what a look-at driver looks at. Source drivers set it; drivers that only shape the pose leave it.
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
export const CAMERA_STATE_PIVOT = 7;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Vertical field of view in degrees, as {@link Camera#fov} holds it.
|
|
38
|
+
* @type {number}
|
|
39
|
+
*/
|
|
40
|
+
export const CAMERA_STATE_FOV = 10;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Start a state over: at the origin, unturned, the pivot at the origin, with the given field of view.
|
|
44
|
+
*
|
|
45
|
+
* @param {CameraState} state
|
|
46
|
+
* @param {number} fov degrees
|
|
47
|
+
*/
|
|
48
|
+
export function camera_state_clear(state, fov) {
|
|
49
|
+
state[0] = 0;
|
|
50
|
+
state[1] = 0;
|
|
51
|
+
state[2] = 0;
|
|
52
|
+
|
|
53
|
+
state[3] = 0;
|
|
54
|
+
state[4] = 0;
|
|
55
|
+
state[5] = 0;
|
|
56
|
+
state[6] = 1;
|
|
57
|
+
|
|
58
|
+
state[7] = 0;
|
|
59
|
+
state[8] = 0;
|
|
60
|
+
state[9] = 0;
|
|
61
|
+
|
|
62
|
+
state[10] = fov;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Put a state's pose onto a transform: translation, rotation, and the matrix after them. Scale is
|
|
67
|
+
* left as it is.
|
|
68
|
+
*
|
|
69
|
+
* @param {Transform64} transform
|
|
70
|
+
* @param {CameraState} state
|
|
71
|
+
*/
|
|
72
|
+
export function camera_state_to_transform(transform, state) {
|
|
73
|
+
transform.setTranslation(state[0], state[1], state[2]);
|
|
74
|
+
transform.setRotation(state[3], state[4], state[5], state[6]);
|
|
75
|
+
transform.updateMatrix();
|
|
76
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write a rig's state onto its entity: the pose onto its {@link Transform64}, the field of view onto
|
|
3
|
+
* its {@link Camera}.
|
|
4
|
+
*
|
|
5
|
+
* A transform cannot say it was written, so this announces it, and only when the pose changed: a still
|
|
6
|
+
* camera wakes nothing. After a cut the pose is also announced as a placement,
|
|
7
|
+
* {@link TRANSFORM64_EVENT_PLACED}, so whatever keeps history against the camera treats it as a jump.
|
|
8
|
+
* Announcements go out after both writes, so a listener sees the finished pose and lens.
|
|
9
|
+
*
|
|
10
|
+
* @param {CameraRig} rig
|
|
11
|
+
* @param {EntityComponentDataset} ecd
|
|
12
|
+
* @param {number} entity the rig's entity
|
|
13
|
+
*/
|
|
14
|
+
export function camera_rig_output(rig: CameraRig, ecd: EntityComponentDataset, entity: number): void;
|
|
15
|
+
export type CameraRig = import("./CameraRig.js").CameraRig;
|
|
16
|
+
export type EntityComponentDataset = import("../../../ecs/EntityComponentDataset.js").EntityComponentDataset;
|
|
17
|
+
//# sourceMappingURL=camera_rig_output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera_rig_output.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/camera/rig/camera_rig_output.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;GAYG;AACH,uCAJW,SAAS,OACT,sBAAsB,UACtB,MAAM,QA+ChB;wBAxEa,OAAO,gBAAgB,EAAE,SAAS;qCAClC,OAAO,wCAAwC,EAAE,sBAAsB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { t64_announce_change } from "../../../ecs/transform/t64_announce_change.js";
|
|
2
|
+
import { t64_read_pose_array } from "../../../ecs/transform/t64_read_pose_array.js";
|
|
3
|
+
import { Transform64 } from "../../../ecs/transform/Transform64.js";
|
|
4
|
+
import { TRANSFORM64_EVENT_PLACED } from "../../../ecs/transform/TRANSFORM64_EVENT_PLACED.js";
|
|
5
|
+
import { Camera } from "../../ecs/camera/Camera.js";
|
|
6
|
+
import { CAMERA_STATE_FOV, camera_state_to_transform } from "./CameraState.js";
|
|
7
|
+
|
|
8
|
+
/** @typedef {import("./CameraRig.js").CameraRig} CameraRig */
|
|
9
|
+
/** @typedef {import("../../../ecs/EntityComponentDataset.js").EntityComponentDataset} EntityComponentDataset */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The transform's pose before the write, to tell a move from a rewrite of the same pose.
|
|
13
|
+
* @type {Float64Array}
|
|
14
|
+
*/
|
|
15
|
+
const POSE_BEFORE = new Float64Array(7);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {Float64Array}
|
|
19
|
+
*/
|
|
20
|
+
const POSE_AFTER = new Float64Array(7);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Write a rig's state onto its entity: the pose onto its {@link Transform64}, the field of view onto
|
|
24
|
+
* its {@link Camera}.
|
|
25
|
+
*
|
|
26
|
+
* A transform cannot say it was written, so this announces it, and only when the pose changed: a still
|
|
27
|
+
* camera wakes nothing. After a cut the pose is also announced as a placement,
|
|
28
|
+
* {@link TRANSFORM64_EVENT_PLACED}, so whatever keeps history against the camera treats it as a jump.
|
|
29
|
+
* Announcements go out after both writes, so a listener sees the finished pose and lens.
|
|
30
|
+
*
|
|
31
|
+
* @param {CameraRig} rig
|
|
32
|
+
* @param {EntityComponentDataset} ecd
|
|
33
|
+
* @param {number} entity the rig's entity
|
|
34
|
+
*/
|
|
35
|
+
export function camera_rig_output(rig, ecd, entity) {
|
|
36
|
+
const state = rig.state;
|
|
37
|
+
|
|
38
|
+
const placed = rig.placement_pending;
|
|
39
|
+
|
|
40
|
+
rig.placement_pending = false;
|
|
41
|
+
|
|
42
|
+
const transform = ecd.getComponent(entity, Transform64);
|
|
43
|
+
|
|
44
|
+
let moved = false;
|
|
45
|
+
|
|
46
|
+
if (transform !== undefined) {
|
|
47
|
+
t64_read_pose_array(POSE_BEFORE, 0, transform);
|
|
48
|
+
|
|
49
|
+
camera_state_to_transform(transform, state);
|
|
50
|
+
|
|
51
|
+
t64_read_pose_array(POSE_AFTER, 0, transform);
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < 7; i++) {
|
|
54
|
+
if (POSE_BEFORE[i] !== POSE_AFTER[i]) {
|
|
55
|
+
moved = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const camera = ecd.getComponent(entity, Camera);
|
|
62
|
+
|
|
63
|
+
if (camera !== undefined) {
|
|
64
|
+
const fov = state[CAMERA_STATE_FOV];
|
|
65
|
+
|
|
66
|
+
if (camera.fov.getValue() !== fov) {
|
|
67
|
+
camera.fov.set(fov);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (transform === undefined || !(moved || placed)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
t64_announce_change(ecd, entity);
|
|
76
|
+
|
|
77
|
+
if (placed && ecd.entityExists(entity) && ecd.getComponent(entity, Transform64) === transform) {
|
|
78
|
+
ecd.sendEvent(entity, TRANSFORM64_EVENT_PLACED);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @typedef {import("./CameraRig.js").CameraRig} CameraRig */
|
|
2
|
+
/** @typedef {import("./CameraRigContext.js").CameraRigContext} CameraRigContext */
|
|
3
|
+
/**
|
|
4
|
+
* Run a rig's drivers once: start the state over at the origin with the entity's own field of view,
|
|
5
|
+
* then hand it to each driver in order. A pending cut resets every driver first.
|
|
6
|
+
*
|
|
7
|
+
* Does not write the entity; see {@link camera_rig_output}.
|
|
8
|
+
*
|
|
9
|
+
* @param {CameraRig} rig
|
|
10
|
+
* @param {CameraRigContext} context `entity` names the rig's own entity
|
|
11
|
+
*/
|
|
12
|
+
export function camera_rig_update(rig: CameraRig, context: CameraRigContext): void;
|
|
13
|
+
/**
|
|
14
|
+
* {@link camera_rig_update} unless the rig was already updated at `context.frame`.
|
|
15
|
+
*
|
|
16
|
+
* @param {CameraRig} rig
|
|
17
|
+
* @param {CameraRigContext} context `entity` names the rig's own entity
|
|
18
|
+
*/
|
|
19
|
+
export function camera_rig_ensure_updated(rig: CameraRig, context: CameraRigContext): void;
|
|
20
|
+
/**
|
|
21
|
+
* Cut: the rig's next update drops every driver's history, so smoothing snaps, springs settle and
|
|
22
|
+
* transitions finish, and the pose it writes is announced as a placement, not a move.
|
|
23
|
+
*
|
|
24
|
+
* @param {CameraRig} rig
|
|
25
|
+
*/
|
|
26
|
+
export function camera_rig_cut(rig: CameraRig): void;
|
|
27
|
+
/**
|
|
28
|
+
* The first driver in a rig that is an instance of `Klass`, for code that did not build the rig.
|
|
29
|
+
*
|
|
30
|
+
* @template T
|
|
31
|
+
* @param {CameraRig} rig
|
|
32
|
+
* @param {Class<T>} Klass
|
|
33
|
+
* @returns {T|null}
|
|
34
|
+
*/
|
|
35
|
+
export function camera_rig_find_driver<T>(rig: CameraRig, Klass: Class<T>): T;
|
|
36
|
+
export type CameraRig = import("./CameraRig.js").CameraRig;
|
|
37
|
+
export type CameraRigContext = import("./CameraRigContext.js").CameraRigContext;
|
|
38
|
+
//# sourceMappingURL=camera_rig_update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera_rig_update.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/camera/rig/camera_rig_update.js"],"names":[],"mappings":"AAIA,8DAA8D;AAC9D,mFAAmF;AAEnF;;;;;;;;GAQG;AACH,uCAHW,SAAS,WACT,gBAAgB,QAwC1B;AAED;;;;;GAKG;AACH,+CAHW,SAAS,WACT,gBAAgB,QAQ1B;AAED;;;;;GAKG;AACH,oCAFW,SAAS,QAInB;AAED;;;;;;;GAOG;AACH,+CAJW,SAAS,sBAiBnB;wBAjGa,OAAO,gBAAgB,EAAE,SAAS;+BAClC,OAAO,uBAAuB,EAAE,gBAAgB"}
|