@onerjs/core 8.30.9 → 8.31.1

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.
Files changed (124) hide show
  1. package/Animations/animationGroup.js +1 -4
  2. package/Animations/animationGroup.js.map +1 -1
  3. package/Behaviors/Cameras/interpolatingBehavior.d.ts +52 -0
  4. package/Behaviors/Cameras/interpolatingBehavior.js +105 -0
  5. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
  6. package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
  7. package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
  8. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  9. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
  10. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
  11. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
  12. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
  13. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
  14. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +16 -21
  15. package/Cameras/Inputs/geospatialCameraPointersInput.js +43 -73
  16. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  17. package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
  18. package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
  19. package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
  20. package/Cameras/Limits/geospatialLimits.d.ts +60 -0
  21. package/Cameras/Limits/geospatialLimits.js +89 -0
  22. package/Cameras/Limits/geospatialLimits.js.map +1 -0
  23. package/Cameras/cameraMovement.d.ts +150 -0
  24. package/Cameras/cameraMovement.js +190 -0
  25. package/Cameras/cameraMovement.js.map +1 -0
  26. package/Cameras/geospatialCamera.d.ts +53 -49
  27. package/Cameras/geospatialCamera.js +172 -192
  28. package/Cameras/geospatialCamera.js.map +1 -1
  29. package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
  30. package/Cameras/geospatialCameraInputsManager.js +9 -0
  31. package/Cameras/geospatialCameraInputsManager.js.map +1 -1
  32. package/Cameras/geospatialCameraMovement.d.ts +66 -0
  33. package/Cameras/geospatialCameraMovement.js +199 -0
  34. package/Cameras/geospatialCameraMovement.js.map +1 -0
  35. package/Engines/Native/nativeInterfaces.d.ts +14 -6
  36. package/Engines/Native/nativeInterfaces.js +6 -1
  37. package/Engines/Native/nativeInterfaces.js.map +1 -1
  38. package/Engines/nativeEngine.js +2 -2
  39. package/Engines/nativeEngine.js.map +1 -1
  40. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
  41. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
  42. package/FlowGraph/flowGraphMath.d.ts +25 -0
  43. package/FlowGraph/flowGraphMath.js +40 -0
  44. package/FlowGraph/flowGraphMath.js.map +1 -0
  45. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
  46. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  47. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
  48. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
  49. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
  50. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
  51. package/Materials/shaderMaterial.js +4 -2
  52. package/Materials/shaderMaterial.js.map +1 -1
  53. package/Maths/math.vector.functions.d.ts +5 -24
  54. package/Maths/math.vector.functions.js +32 -35
  55. package/Maths/math.vector.functions.js.map +1 -1
  56. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
  57. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
  58. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  59. package/Meshes/csg2.js +1 -1
  60. package/Meshes/csg2.js.map +1 -1
  61. package/Meshes/thinInstanceMesh.js +15 -0
  62. package/Meshes/thinInstanceMesh.js.map +1 -1
  63. package/Misc/fileTools.js.map +1 -1
  64. package/Misc/tools.d.ts +3 -0
  65. package/Misc/tools.js +43 -4
  66. package/Misc/tools.js.map +1 -1
  67. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
  68. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
  69. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
  70. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
  71. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +3 -3
  72. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  73. package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
  74. package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
  75. package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
  76. package/Particles/Node/Blocks/index.d.ts +1 -0
  77. package/Particles/Node/Blocks/index.js +1 -0
  78. package/Particles/Node/Blocks/index.js.map +1 -1
  79. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  80. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  81. package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
  82. package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
  83. package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
  84. package/Particles/Node/Blocks/systemBlock.d.ts +8 -0
  85. package/Particles/Node/Blocks/systemBlock.js +8 -0
  86. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  87. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  88. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  89. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  90. package/Particles/Node/nodeParticleBuildState.js +6 -4
  91. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  92. package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
  93. package/Particles/Node/nodeParticleSystemSet.helper.js +279 -161
  94. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  95. package/Particles/particle.d.ts +4 -0
  96. package/Particles/particle.js +2 -0
  97. package/Particles/particle.js.map +1 -1
  98. package/Particles/thinParticleSystem.d.ts +3 -7
  99. package/Particles/thinParticleSystem.function.d.ts +1 -1
  100. package/Particles/thinParticleSystem.function.js +9 -6
  101. package/Particles/thinParticleSystem.function.js.map +1 -1
  102. package/Particles/thinParticleSystem.js +4 -6
  103. package/Particles/thinParticleSystem.js.map +1 -1
  104. package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
  105. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  106. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
  107. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  108. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
  109. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  110. package/Shaders/gaussianSplatting.vertex.js +3 -3
  111. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  112. package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
  113. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  114. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
  115. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  116. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
  117. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  118. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
  119. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  120. package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
  121. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  122. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  123. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  124. package/package.json +1 -1
@@ -0,0 +1,150 @@
1
+ import type { Scene } from "../scene.js";
2
+ import { Vector3 } from "../Maths/math.vector.js";
3
+ import type { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
4
+ /**
5
+ * @experimental
6
+ * This class is subject to change as geospatial camera evolves.
7
+ *
8
+ * It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
9
+ * to ensure smooth frame-rate-independent movement
10
+ */
11
+ export declare class CameraMovement {
12
+ protected _cameraPosition: Vector3;
13
+ protected _behavior?: InterpolatingBehavior | undefined;
14
+ protected _scene: Scene;
15
+ /**
16
+ * Should be set by input classes to indicates whether there is active input this frame
17
+ * This helps us differentiate between 0 pixel delta due to no input vs user actively holding still
18
+ */
19
+ activeInput: boolean;
20
+ /**
21
+ * ------------ Speed ----------------
22
+ * Speed defines the amount of camera movement expected per input pixel movement
23
+ * -----------------------------------
24
+ */
25
+ /**
26
+ * Desired coordinate unit movement per input pixel when zooming
27
+ */
28
+ zoomSpeed: number;
29
+ /**
30
+ * Desired coordinate unit movement per input pixel when panning
31
+ */
32
+ panSpeed: number;
33
+ /**
34
+ * Desired radians movement per input pixel when rotating along x axis
35
+ */
36
+ rotationXSpeed: number;
37
+ /**
38
+ * Desired radians movement per input pixel when rotating along y axis
39
+ */
40
+ rotationYSpeed: number;
41
+ /**
42
+ * ----------- Speed multipliers ---------------
43
+ * Multipliers allow movement classes to modify the effective speed dynamically per-frame
44
+ * (ex: scale zoom based on distance from target)
45
+ * -----------------------------------
46
+ */
47
+ /**
48
+ * Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)
49
+ */
50
+ protected _zoomSpeedMultiplier: number;
51
+ /**
52
+ * Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)
53
+ */
54
+ protected _panSpeedMultiplier: number;
55
+ /**
56
+ * ---------- Inertia ----------------
57
+ * Inertia represents the decay factor per-frame applied to the velocity when there is no user input.
58
+ * 0 = No inertia, instant stop (velocity immediately becomes 0)
59
+ * 0.5 = Strong decay, velocity halves every frame at 60fps
60
+ * 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps
61
+ * 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps
62
+ * 1 = Infinite inertia, never stops (velocity never decays)
63
+ * -----------------------------------
64
+ */
65
+ /**
66
+ * Inertia applied to the zoom velocity when there is no user input.
67
+ * Higher inertia === slower decay, velocity retains more of its value each frame
68
+ */
69
+ zoomInertia: number;
70
+ /**
71
+ * Inertia applied to the panning velocity when there is no user input.
72
+ * Higher inertia === slower decay, velocity retains more of its value each frame
73
+ */
74
+ panInertia: number;
75
+ /**
76
+ * Inertia applied to the rotation velocity when there is no user input.
77
+ * Higher inertia === slower decay, velocity retains more of its value each frame
78
+ */
79
+ rotationInertia: number;
80
+ /**
81
+ * ---------- Accumulated Pixel Deltas -----------
82
+ * Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)
83
+ * -----------------------------------
84
+ */
85
+ /**
86
+ * Accumulated pixel delta (by input classes) for zoom this frame
87
+ * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
88
+ * Reset to zero after each frame
89
+ */
90
+ zoomAccumulatedPixels: number;
91
+ /**
92
+ * Accumulated pixel delta (by input classes) for panning this frame
93
+ * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
94
+ * Reset to zero after each frame
95
+ */
96
+ panAccumulatedPixels: Vector3;
97
+ /**
98
+ * Accumulated pixel delta (by input classes) for rotation this frame
99
+ * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
100
+ * Reset to zero after each frame
101
+ */
102
+ rotationAccumulatedPixels: Vector3;
103
+ /**
104
+ * ---------- Current Frame Movement Deltas -----------
105
+ * Deltas read on each frame by camera class in order to move the camera
106
+ * -----------------------------------
107
+ */
108
+ /**
109
+ * Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)
110
+ */
111
+ zoomDeltaCurrentFrame: number;
112
+ /**
113
+ * Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)
114
+ */
115
+ panDeltaCurrentFrame: Vector3;
116
+ /**
117
+ * Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)
118
+ */
119
+ rotationDeltaCurrentFrame: Vector3;
120
+ /**
121
+ * ---------- Velocity -----------
122
+ * Used to track velocity between frames for inertia calculation
123
+ * -----------------------------------
124
+ */
125
+ /**
126
+ * Zoom velocity used for inertia calculations (movement / time)
127
+ */
128
+ protected _zoomVelocity: number;
129
+ /**
130
+ * Pan velocity used for inertia calculations (movement / time)
131
+ */
132
+ private _panVelocity;
133
+ /**
134
+ * Rotation velocity used for inertia calculations (movement / time)
135
+ */
136
+ private _rotationVelocity;
137
+ /**
138
+ * Used when calculating inertial decay. Default to 60fps
139
+ */
140
+ private _prevFrameTimeMs;
141
+ constructor(scene: Scene, _cameraPosition: Vector3, _behavior?: InterpolatingBehavior | undefined);
142
+ /**
143
+ * When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties
144
+ * Takes speed, scaling, inertia, and framerate into account to ensure smooth movement
145
+ * Zeros out pixelDeltas before returning
146
+ */
147
+ computeCurrentFrameDeltas(): void;
148
+ get isInterpolating(): boolean;
149
+ private _calculateCurrentVelocity;
150
+ }
@@ -0,0 +1,190 @@
1
+ import { Vector3 } from "../Maths/math.vector.js";
2
+ import { Epsilon } from "../Maths/math.constants.js";
3
+ const FrameDurationAt60FPS = 1000 / 60;
4
+ /**
5
+ * @experimental
6
+ * This class is subject to change as geospatial camera evolves.
7
+ *
8
+ * It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
9
+ * to ensure smooth frame-rate-independent movement
10
+ */
11
+ export class CameraMovement {
12
+ constructor(scene, _cameraPosition, _behavior) {
13
+ this._cameraPosition = _cameraPosition;
14
+ this._behavior = _behavior;
15
+ /**
16
+ * Should be set by input classes to indicates whether there is active input this frame
17
+ * This helps us differentiate between 0 pixel delta due to no input vs user actively holding still
18
+ */
19
+ this.activeInput = false;
20
+ /**
21
+ * ------------ Speed ----------------
22
+ * Speed defines the amount of camera movement expected per input pixel movement
23
+ * -----------------------------------
24
+ */
25
+ /**
26
+ * Desired coordinate unit movement per input pixel when zooming
27
+ */
28
+ this.zoomSpeed = 1;
29
+ /**
30
+ * Desired coordinate unit movement per input pixel when panning
31
+ */
32
+ this.panSpeed = 1;
33
+ /**
34
+ * Desired radians movement per input pixel when rotating along x axis
35
+ */
36
+ this.rotationXSpeed = 1;
37
+ /**
38
+ * Desired radians movement per input pixel when rotating along y axis
39
+ */
40
+ this.rotationYSpeed = 1;
41
+ /**
42
+ * ----------- Speed multipliers ---------------
43
+ * Multipliers allow movement classes to modify the effective speed dynamically per-frame
44
+ * (ex: scale zoom based on distance from target)
45
+ * -----------------------------------
46
+ */
47
+ /**
48
+ * Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)
49
+ */
50
+ this._zoomSpeedMultiplier = 1;
51
+ /**
52
+ * Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)
53
+ */
54
+ this._panSpeedMultiplier = 1;
55
+ /**
56
+ * ---------- Inertia ----------------
57
+ * Inertia represents the decay factor per-frame applied to the velocity when there is no user input.
58
+ * 0 = No inertia, instant stop (velocity immediately becomes 0)
59
+ * 0.5 = Strong decay, velocity halves every frame at 60fps
60
+ * 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps
61
+ * 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps
62
+ * 1 = Infinite inertia, never stops (velocity never decays)
63
+ * -----------------------------------
64
+ */
65
+ /**
66
+ * Inertia applied to the zoom velocity when there is no user input.
67
+ * Higher inertia === slower decay, velocity retains more of its value each frame
68
+ */
69
+ this.zoomInertia = 0.9;
70
+ /**
71
+ * Inertia applied to the panning velocity when there is no user input.
72
+ * Higher inertia === slower decay, velocity retains more of its value each frame
73
+ */
74
+ this.panInertia = 0.9;
75
+ /**
76
+ * Inertia applied to the rotation velocity when there is no user input.
77
+ * Higher inertia === slower decay, velocity retains more of its value each frame
78
+ */
79
+ this.rotationInertia = 0.9;
80
+ /**
81
+ * ---------- Accumulated Pixel Deltas -----------
82
+ * Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)
83
+ * -----------------------------------
84
+ */
85
+ /**
86
+ * Accumulated pixel delta (by input classes) for zoom this frame
87
+ * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
88
+ * Reset to zero after each frame
89
+ */
90
+ this.zoomAccumulatedPixels = 0;
91
+ /**
92
+ * Accumulated pixel delta (by input classes) for panning this frame
93
+ * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
94
+ * Reset to zero after each frame
95
+ */
96
+ this.panAccumulatedPixels = new Vector3();
97
+ /**
98
+ * Accumulated pixel delta (by input classes) for rotation this frame
99
+ * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)
100
+ * Reset to zero after each frame
101
+ */
102
+ this.rotationAccumulatedPixels = new Vector3();
103
+ /**
104
+ * ---------- Current Frame Movement Deltas -----------
105
+ * Deltas read on each frame by camera class in order to move the camera
106
+ * -----------------------------------
107
+ */
108
+ /**
109
+ * Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)
110
+ */
111
+ this.zoomDeltaCurrentFrame = 0;
112
+ /**
113
+ * Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)
114
+ */
115
+ this.panDeltaCurrentFrame = Vector3.Zero();
116
+ /**
117
+ * Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)
118
+ */
119
+ this.rotationDeltaCurrentFrame = Vector3.Zero();
120
+ /**
121
+ * ---------- Velocity -----------
122
+ * Used to track velocity between frames for inertia calculation
123
+ * -----------------------------------
124
+ */
125
+ /**
126
+ * Zoom velocity used for inertia calculations (movement / time)
127
+ */
128
+ this._zoomVelocity = 0;
129
+ /**
130
+ * Pan velocity used for inertia calculations (movement / time)
131
+ */
132
+ this._panVelocity = new Vector3();
133
+ /**
134
+ * Rotation velocity used for inertia calculations (movement / time)
135
+ */
136
+ this._rotationVelocity = new Vector3();
137
+ /**
138
+ * Used when calculating inertial decay. Default to 60fps
139
+ */
140
+ this._prevFrameTimeMs = FrameDurationAt60FPS;
141
+ this._scene = scene;
142
+ }
143
+ /**
144
+ * When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties
145
+ * Takes speed, scaling, inertia, and framerate into account to ensure smooth movement
146
+ * Zeros out pixelDeltas before returning
147
+ */
148
+ computeCurrentFrameDeltas() {
149
+ const deltaTimeMs = this._scene.getEngine().getDeltaTime();
150
+ this.panDeltaCurrentFrame.setAll(0);
151
+ this.rotationDeltaCurrentFrame.setAll(0);
152
+ this.zoomDeltaCurrentFrame = 0;
153
+ const hasUserInput = this.panAccumulatedPixels.lengthSquared() > 0 || this.rotationAccumulatedPixels.lengthSquared() > 0 || this.zoomAccumulatedPixels !== 0;
154
+ if (hasUserInput && this._behavior?.isInterpolating) {
155
+ this._behavior.stopAllAnimations();
156
+ }
157
+ this._panVelocity.copyFromFloats(this._calculateCurrentVelocity(this._panVelocity.x, this.panAccumulatedPixels.x, this.panSpeed * this._panSpeedMultiplier, this.panInertia), this._calculateCurrentVelocity(this._panVelocity.y, this.panAccumulatedPixels.y, this.panSpeed * this._panSpeedMultiplier, this.panInertia), this._calculateCurrentVelocity(this._panVelocity.z, this.panAccumulatedPixels.z, this.panSpeed * this._panSpeedMultiplier, this.panInertia));
158
+ this._panVelocity.scaleToRef(deltaTimeMs, this.panDeltaCurrentFrame);
159
+ this._rotationVelocity.copyFromFloats(this._calculateCurrentVelocity(this._rotationVelocity.x, this.rotationAccumulatedPixels.x, this.rotationXSpeed, this.rotationInertia), this._calculateCurrentVelocity(this._rotationVelocity.y, this.rotationAccumulatedPixels.y, this.rotationYSpeed, this.rotationInertia), this._calculateCurrentVelocity(this._rotationVelocity.z, this.rotationAccumulatedPixels.z, this.rotationYSpeed, this.rotationInertia));
160
+ this._rotationVelocity.scaleToRef(deltaTimeMs, this.rotationDeltaCurrentFrame);
161
+ this._zoomVelocity = this._calculateCurrentVelocity(this._zoomVelocity, this.zoomAccumulatedPixels, this.zoomSpeed * this._zoomSpeedMultiplier, this.zoomInertia);
162
+ this.zoomDeltaCurrentFrame = this._zoomVelocity * deltaTimeMs;
163
+ this._prevFrameTimeMs = deltaTimeMs;
164
+ this.zoomAccumulatedPixels = 0;
165
+ this.panAccumulatedPixels.setAll(0);
166
+ this.rotationAccumulatedPixels.setAll(0);
167
+ }
168
+ get isInterpolating() {
169
+ return !!this._behavior?.isInterpolating;
170
+ }
171
+ _calculateCurrentVelocity(velocityRef, pixelDelta, speedFactor, inertialDecayFactor) {
172
+ let inputVelocity = velocityRef;
173
+ const deltaTimeMs = this._scene.getEngine().getDeltaTime();
174
+ // If we are actively recieving input or have accumulated some pixel delta since last frame, calculate inputVelocity (inertia doesn't kickin yet)
175
+ if (pixelDelta !== 0 || this.activeInput) {
176
+ const pixelsPerMs = pixelDelta / deltaTimeMs;
177
+ inputVelocity = pixelsPerMs * speedFactor;
178
+ }
179
+ else if (!this.activeInput && inputVelocity !== 0) {
180
+ // If we are not receiving input and velocity isn't already zero, apply inertial decay to decelerate velocity
181
+ const frameIndependentDecay = Math.pow(inertialDecayFactor, this._prevFrameTimeMs / FrameDurationAt60FPS);
182
+ inputVelocity *= frameIndependentDecay;
183
+ if (Math.abs(inputVelocity) <= Epsilon) {
184
+ inputVelocity = 0;
185
+ }
186
+ }
187
+ return inputVelocity;
188
+ }
189
+ }
190
+ //# sourceMappingURL=cameraMovement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cameraMovement.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/cameraMovement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;AACvC;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAyIvB,YACI,KAAY,EACF,eAAwB,EACxB,SAAiC;QADjC,oBAAe,GAAf,eAAe,CAAS;QACxB,cAAS,GAAT,SAAS,CAAwB;QAzI/C;;;WAGG;QACI,gBAAW,GAAY,KAAK,CAAC;QAEpC;;;;WAIG;QACH;;WAEG;QACI,cAAS,GAAW,CAAC,CAAC;QAC7B;;WAEG;QACI,aAAQ,GAAW,CAAC,CAAC;QAC5B;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAClC;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAElC;;;;;WAKG;QACH;;WAEG;QACO,yBAAoB,GAAW,CAAC,CAAC;QAC3C;;WAEG;QACO,wBAAmB,GAAW,CAAC,CAAC;QAE1C;;;;;;;;;WASG;QACH;;;WAGG;QACI,gBAAW,GAAW,GAAG,CAAC;QACjC;;;WAGG;QACI,eAAU,GAAW,GAAG,CAAC;QAChC;;;WAGG;QACI,oBAAe,GAAW,GAAG,CAAC;QAErC;;;;WAIG;QACH;;;;WAIG;QACI,0BAAqB,GAAW,CAAC,CAAC;QACzC;;;;WAIG;QACI,yBAAoB,GAAY,IAAI,OAAO,EAAE,CAAC;QACrD;;;;WAIG;QACI,8BAAyB,GAAY,IAAI,OAAO,EAAE,CAAC;QAE1D;;;;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cesContent":["import type { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\n\r\nconst FrameDurationAt60FPS = 1000 / 60;\r\n/**\r\n * @experimental\r\n * This class is subject to change as geospatial camera evolves.\r\n *\r\n * It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account\r\n * to ensure smooth frame-rate-independent movement\r\n */\r\nexport class CameraMovement {\r\n protected _scene: Scene;\r\n\r\n /**\r\n * Should be set by input classes to indicates whether there is active input this frame\r\n * This helps us differentiate between 0 pixel delta due to no input vs user actively holding still\r\n */\r\n public activeInput: boolean = false;\r\n\r\n /**\r\n * ------------ Speed ----------------\r\n * Speed defines the amount of camera movement expected per input pixel movement\r\n * -----------------------------------\r\n */\r\n /**\r\n * Desired coordinate unit movement per input pixel when zooming\r\n */\r\n public zoomSpeed: number = 1;\r\n /**\r\n * Desired coordinate unit movement per input pixel when panning\r\n */\r\n public panSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along x axis\r\n */\r\n public rotationXSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along y axis\r\n */\r\n public rotationYSpeed: number = 1;\r\n\r\n /**\r\n * ----------- Speed multipliers ---------------\r\n * Multipliers allow movement classes to modify the effective speed dynamically per-frame\r\n * (ex: scale zoom based on distance from target)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)\r\n */\r\n protected _zoomSpeedMultiplier: number = 1;\r\n /**\r\n * Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)\r\n */\r\n protected _panSpeedMultiplier: number = 1;\r\n\r\n /**\r\n * ---------- Inertia ----------------\r\n * Inertia represents the decay factor per-frame applied to the velocity when there is no user input.\r\n * 0 = No inertia, instant stop (velocity immediately becomes 0)\r\n * 0.5 = Strong decay, velocity halves every frame at 60fps\r\n * 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps\r\n * 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps\r\n * 1 = Infinite inertia, never stops (velocity never decays)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Inertia applied to the zoom velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public zoomInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the panning velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public panInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the rotation velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public rotationInertia: number = 0.9;\r\n\r\n /**\r\n * ---------- Accumulated Pixel Deltas -----------\r\n * Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Accumulated pixel delta (by input classes) for zoom this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public zoomAccumulatedPixels: number = 0;\r\n /**\r\n * Accumulated pixel delta (by input classes) for panning this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public panAccumulatedPixels: Vector3 = new Vector3();\r\n /**\r\n * Accumulated pixel delta (by input classes) for rotation this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into currentFrameTranslationDelta (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public rotationAccumulatedPixels: Vector3 = new Vector3();\r\n\r\n /**\r\n * ---------- Current Frame Movement Deltas -----------\r\n * Deltas read on each frame by camera class in order to move the camera\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)\r\n */\r\n public zoomDeltaCurrentFrame: number = 0;\r\n /**\r\n * Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)\r\n */\r\n public panDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n /**\r\n * Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)\r\n */\r\n public rotationDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * ---------- Velocity -----------\r\n * Used to track velocity between frames for inertia calculation\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom velocity used for inertia calculations (movement / time)\r\n */\r\n protected _zoomVelocity: number = 0;\r\n /**\r\n * Pan velocity used for inertia calculations (movement / time)\r\n */\r\n private _panVelocity: Vector3 = new Vector3();\r\n /**\r\n * Rotation velocity used for inertia calculations (movement / time)\r\n */\r\n private _rotationVelocity: Vector3 = new Vector3();\r\n\r\n /**\r\n * Used when calculating inertial decay. Default to 60fps\r\n */\r\n private _prevFrameTimeMs: number = FrameDurationAt60FPS;\r\n\r\n constructor(\r\n scene: Scene,\r\n protected _cameraPosition: Vector3,\r\n protected _behavior?: InterpolatingBehavior\r\n ) {\r\n this._scene = scene;\r\n }\r\n\r\n /**\r\n * When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties\r\n * Takes speed, scaling, inertia, and framerate into account to ensure smooth movement\r\n * Zeros out pixelDeltas before returning\r\n */\r\n public computeCurrentFrameDeltas(): void {\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n this.panDeltaCurrentFrame.setAll(0);\r\n this.rotationDeltaCurrentFrame.setAll(0);\r\n this.zoomDeltaCurrentFrame = 0;\r\n\r\n const hasUserInput = this.panAccumulatedPixels.lengthSquared() > 0 || this.rotationAccumulatedPixels.lengthSquared() > 0 || this.zoomAccumulatedPixels !== 0;\r\n\r\n if (hasUserInput && this._behavior?.isInterpolating) {\r\n this._behavior.stopAllAnimations();\r\n }\r\n\r\n this._panVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._panVelocity.x, this.panAccumulatedPixels.x, this.panSpeed * this._panSpeedMultiplier, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.y, this.panAccumulatedPixels.y, this.panSpeed * this._panSpeedMultiplier, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.z, this.panAccumulatedPixels.z, this.panSpeed * this._panSpeedMultiplier, this.panInertia)\r\n );\r\n this._panVelocity.scaleToRef(deltaTimeMs, this.panDeltaCurrentFrame);\r\n\r\n this._rotationVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._rotationVelocity.x, this.rotationAccumulatedPixels.x, this.rotationXSpeed, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.y, this.rotationAccumulatedPixels.y, this.rotationYSpeed, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.z, this.rotationAccumulatedPixels.z, this.rotationYSpeed, this.rotationInertia)\r\n );\r\n this._rotationVelocity.scaleToRef(deltaTimeMs, this.rotationDeltaCurrentFrame);\r\n\r\n this._zoomVelocity = this._calculateCurrentVelocity(this._zoomVelocity, this.zoomAccumulatedPixels, this.zoomSpeed * this._zoomSpeedMultiplier, this.zoomInertia);\r\n this.zoomDeltaCurrentFrame = this._zoomVelocity * deltaTimeMs;\r\n\r\n this._prevFrameTimeMs = deltaTimeMs;\r\n this.zoomAccumulatedPixels = 0;\r\n this.panAccumulatedPixels.setAll(0);\r\n this.rotationAccumulatedPixels.setAll(0);\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return !!this._behavior?.isInterpolating;\r\n }\r\n\r\n private _calculateCurrentVelocity(velocityRef: number, pixelDelta: number, speedFactor: number, inertialDecayFactor: number): number {\r\n let inputVelocity = velocityRef;\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n // If we are actively recieving input or have accumulated some pixel delta since last frame, calculate inputVelocity (inertia doesn't kickin yet)\r\n if (pixelDelta !== 0 || this.activeInput) {\r\n const pixelsPerMs = pixelDelta / deltaTimeMs;\r\n inputVelocity = pixelsPerMs * speedFactor;\r\n } else if (!this.activeInput && inputVelocity !== 0) {\r\n // If we are not receiving input and velocity isn't already zero, apply inertial decay to decelerate velocity\r\n const frameIndependentDecay = Math.pow(inertialDecayFactor, this._prevFrameTimeMs / FrameDurationAt60FPS);\r\n inputVelocity *= frameIndependentDecay;\r\n if (Math.abs(inputVelocity) <= Epsilon) {\r\n inputVelocity = 0;\r\n }\r\n }\r\n\r\n return inputVelocity;\r\n }\r\n}\r\n"]}
@@ -3,85 +3,89 @@ import { Vector3, Matrix } from "../Maths/math.vector.js";
3
3
  import { Camera } from "./camera.js";
4
4
  import type { Scene } from "../scene.js";
5
5
  import type { MeshPredicate } from "../Culling/ray.core.js";
6
- import type { Nullable } from "../types.js";
6
+ import { GeospatialLimits } from "./Limits/geospatialLimits.js";
7
+ import { GeospatialCameraMovement } from "./geospatialCameraMovement.js";
8
+ import type { IVector3Like } from "../Maths/math.like.js";
7
9
  type CameraOptions = {
8
10
  planetRadius: number;
9
- minAltitude?: number;
10
- maxAltitude?: number;
11
- restingAltitude?: number;
12
11
  };
13
12
  /**
14
13
  * @experimental
15
14
  * This camera's movements are limited to a camera orbiting a globe, and as the API evolves it will introduce conversions between cartesian coordinates and true lat/long/alt
16
15
  *
17
16
  * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag
18
- *
19
- * Still TODO:
20
- * - Pitch/yaw limits, input speeds
21
- * - ZoomToPoint
22
- * - Conversion between lat/long/alt and cartesian coordinates
23
17
  */
24
18
  export declare class GeospatialCamera extends Camera {
25
19
  inputs: GeospatialCameraInputsManager;
26
- /** @internal */
27
- _perFrameGeocentricTranslation: Vector3;
28
- /** @internal */
29
- _perFrameGeocentricRotation: Vector3;
30
- /** @internal */
31
- _perFrameZoom: number;
32
20
  /** If supplied, will be used when picking the globe */
33
21
  pickPredicate?: MeshPredicate;
34
- /**
35
- * Enables rotation around a specific point, instead of default rotation around center
36
- * @internal
37
- */
38
- _alternateRotationPt: Nullable<Vector3>;
39
- /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/
40
- get center(): Vector3;
41
- private _tempGeocentricNormal;
42
- private _tempRotationAxis;
43
- private _tempRotationMatrix;
44
- private _tempPickingRay;
22
+ /** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/
23
+ readonly movement: GeospatialCameraMovement;
45
24
  private _tempPosition;
46
25
  private _viewMatrix;
47
26
  private _isViewMatrixDirty;
48
27
  private _lookAtVector;
49
- private _planetRadius;
50
- private _minAltitude;
51
- private _maxAltitude?;
52
- private _maxCameraRadius?;
53
- private _restingAltitude;
54
- /** Target of camera when looking along lookAtVector from current position. This does not necessarily represent a point on the globe */
55
- private get _target();
28
+ constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate);
29
+ private _center;
30
+ /** The point on the globe that we are anchoring around. If no alternate rotation point is present, this will represent the center of screen*/
31
+ get center(): Vector3;
32
+ /**
33
+ * Sets the camera position to orbit around a new center point
34
+ * @param center The world position (ECEF) to orbit around
35
+ */
36
+ set center(center: IVector3Like);
37
+ private _yaw;
38
+ /**
39
+ * Gets the camera's yaw (rotation around the geocentric normal) in radians
40
+ */
41
+ get yaw(): number;
42
+ /**
43
+ * Sets the camera's yaw (rotation around the geocentric normal)
44
+ * @param yaw The desired yaw angle in radians (0 = north, π/2 = east)
45
+ */
46
+ set yaw(yaw: number);
47
+ private _pitch;
48
+ /**
49
+ * Gets the camera's pitch (angle from looking straight at globe)
50
+ * Pitch is measured from looking straight down at planet center:
51
+ * - zero pitch = looking straight at planet center (down)
52
+ * - positive pitch = tilting up away from planet
53
+ * - π/2 pitch = looking at horizon (perpendicular to geocentric normal)
54
+ */
55
+ get pitch(): number;
56
+ /**
57
+ * Sets the camera's pitch (angle from looking straight at globe)
58
+ * @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)
59
+ */
60
+ set pitch(pitch: number);
61
+ private _radius;
62
+ get radius(): number;
63
+ /**
64
+ * Sets the camera's distance from the current center point
65
+ * @param radius The desired radius
66
+ */
67
+ set radius(radius: number);
68
+ protected _checkLimits(): void;
69
+ private _tempVect;
70
+ private _tempEast;
71
+ private _tempNorth;
72
+ private _tempUp;
73
+ private _setOrientation;
56
74
  /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */
57
75
  private get _geocentricRotationPt();
58
- constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate);
76
+ private _limits;
77
+ get limits(): GeospatialLimits;
59
78
  private _resetToDefault;
60
79
  /** @internal */
61
80
  _getViewMatrix(): Matrix;
62
81
  /** @internal */
63
82
  _isSynchronizedViewMatrix(): boolean;
64
- /**
65
- * Applies rotation correction to the camera by calculating a changeOfBasis matrix from the camera's current position to the new position
66
- * and transforming the lookAt and up vectors by that matrix before updating the camera position and marking the view matrix as dirty
67
- * @param newPos The camera's desired position, before correction is applied
68
- */
69
- private _applyRotationCorrectionAndSetPos;
70
- /**
71
- * When the geocentric normal has any translation change (due to dragging), we must ensure the camera remains orbiting around the world origin
72
- * We thus need to perform 2 correction steps
73
- * 1. Translation correction that keeps the camera at the same radius as before the drag
74
- * 2. Rotation correction that keeps the camera facing the globe (so that as we pan, the globe stays centered on screen)
75
- */
76
83
  private _applyGeocentricTranslation;
77
84
  /**
78
85
  * This rotation keeps the camera oriented towards the globe as it orbits around it. This is different from cameraCentricRotation which is when the camera rotates around its own axis
79
86
  */
80
87
  private _applyGeocentricRotation;
81
- private _clampZoomDistance;
82
88
  private _applyZoom;
83
- private _moveCameraAlongVectorByDistance;
84
- private get _pickAlongLook();
85
89
  _checkInputs(): void;
86
90
  attachControl(noPreventDefault?: boolean): void;
87
91
  detachControl(): void;