@babylonjs/core 8.38.0 → 8.39.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 (235) hide show
  1. package/Animations/animation.d.ts +2 -1
  2. package/Animations/animation.js +3 -2
  3. package/Animations/animation.js.map +1 -1
  4. package/Audio/Interfaces/ISoundOptions.d.ts +1 -1
  5. package/Audio/Interfaces/ISoundOptions.js.map +1 -1
  6. package/Audio/audioEngine.d.ts +3 -4
  7. package/Audio/audioEngine.js +9 -6
  8. package/Audio/audioEngine.js.map +1 -1
  9. package/Audio/sound.d.ts +33 -54
  10. package/Audio/sound.js +450 -718
  11. package/Audio/sound.js.map +1 -1
  12. package/AudioV2/abstractAudio/abstractAudioOutNode.d.ts +1 -1
  13. package/AudioV2/abstractAudio/abstractAudioOutNode.js +1 -1
  14. package/AudioV2/abstractAudio/abstractAudioOutNode.js.map +1 -1
  15. package/AudioV2/abstractAudio/abstractSound.d.ts +1 -1
  16. package/AudioV2/abstractAudio/abstractSound.js +2 -2
  17. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  18. package/AudioV2/abstractAudio/abstractSoundSource.d.ts +11 -3
  19. package/AudioV2/abstractAudio/abstractSoundSource.js +37 -1
  20. package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
  21. package/AudioV2/abstractAudio/audioBus.d.ts +8 -3
  22. package/AudioV2/abstractAudio/audioBus.js +24 -1
  23. package/AudioV2/abstractAudio/audioBus.js.map +1 -1
  24. package/AudioV2/abstractAudio/staticSound.d.ts +1 -1
  25. package/AudioV2/abstractAudio/staticSound.js +2 -2
  26. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  27. package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
  28. package/AudioV2/abstractAudio/streamingSound.js +2 -2
  29. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  30. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +1 -1
  31. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +3 -0
  32. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
  33. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +1 -0
  34. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +1 -0
  35. package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
  36. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +12 -2
  37. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +2 -0
  38. package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
  39. package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +6 -0
  40. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +25 -0
  41. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  42. package/AudioV2/webAudio/components/webAudioParameterComponent.js +2 -2
  43. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
  44. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +3 -0
  45. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +14 -17
  46. package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
  47. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +1 -0
  48. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
  49. package/AudioV2/webAudio/subProperties/spatialWebAudio.js +1 -0
  50. package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
  51. package/AudioV2/webAudio/webAudioBus.d.ts +2 -7
  52. package/AudioV2/webAudio/webAudioBus.js +4 -24
  53. package/AudioV2/webAudio/webAudioBus.js.map +1 -1
  54. package/AudioV2/webAudio/webAudioEngine.js +1 -0
  55. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  56. package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -7
  57. package/AudioV2/webAudio/webAudioSoundSource.js +3 -24
  58. package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
  59. package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -7
  60. package/AudioV2/webAudio/webAudioStaticSound.js +13 -26
  61. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  62. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -7
  63. package/AudioV2/webAudio/webAudioStreamingSound.js +6 -23
  64. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  65. package/Behaviors/Cameras/autoRotationBehavior.d.ts +4 -0
  66. package/Behaviors/Cameras/autoRotationBehavior.js +7 -0
  67. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  68. package/Behaviors/Cameras/bouncingBehavior.d.ts +5 -0
  69. package/Behaviors/Cameras/bouncingBehavior.js +8 -0
  70. package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
  71. package/Behaviors/Cameras/framingBehavior.d.ts +4 -0
  72. package/Behaviors/Cameras/framingBehavior.js +7 -0
  73. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  74. package/Behaviors/Cameras/interpolatingBehavior.d.ts +7 -1
  75. package/Behaviors/Cameras/interpolatingBehavior.js +11 -3
  76. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  77. package/Behaviors/Meshes/attachToBoxBehavior.d.ts +5 -0
  78. package/Behaviors/Meshes/attachToBoxBehavior.js +8 -1
  79. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  80. package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +5 -2
  81. package/Behaviors/Meshes/baseSixDofDragBehavior.js +8 -0
  82. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  83. package/Behaviors/Meshes/fadeInOutBehavior.d.ts +5 -0
  84. package/Behaviors/Meshes/fadeInOutBehavior.js +6 -0
  85. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  86. package/Behaviors/Meshes/handConstraintBehavior.d.ts +5 -0
  87. package/Behaviors/Meshes/handConstraintBehavior.js +8 -0
  88. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  89. package/Behaviors/Meshes/multiPointerScaleBehavior.d.ts +5 -0
  90. package/Behaviors/Meshes/multiPointerScaleBehavior.js +8 -0
  91. package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
  92. package/Behaviors/Meshes/sixDofDragBehavior.js +1 -1
  93. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  94. package/Behaviors/Meshes/surfaceMagnetismBehavior.d.ts +5 -0
  95. package/Behaviors/Meshes/surfaceMagnetismBehavior.js +7 -0
  96. package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
  97. package/Behaviors/behavior.d.ts +4 -0
  98. package/Behaviors/behavior.js.map +1 -1
  99. package/Cameras/geospatialCamera.d.ts +13 -5
  100. package/Cameras/geospatialCamera.js +116 -48
  101. package/Cameras/geospatialCamera.js.map +1 -1
  102. package/Cameras/geospatialCameraMovement.d.ts +6 -2
  103. package/Cameras/geospatialCameraMovement.js +11 -11
  104. package/Cameras/geospatialCameraMovement.js.map +1 -1
  105. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
  106. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -2
  107. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  108. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
  109. package/Engines/WebGPU/webgpuTextureHelper.js +11 -0
  110. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  111. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -0
  112. package/Engines/WebGPU/webgpuTextureManager.js +100 -9
  113. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  114. package/Engines/abstractEngine.d.ts +2 -2
  115. package/Engines/abstractEngine.js +2 -2
  116. package/Engines/abstractEngine.js.map +1 -1
  117. package/Engines/renderTargetWrapper.js +6 -1
  118. package/Engines/renderTargetWrapper.js.map +1 -1
  119. package/Engines/thinEngine.js +1 -1
  120. package/Engines/thinEngine.js.map +1 -1
  121. package/Engines/webgpuEngine.d.ts +7 -4
  122. package/Engines/webgpuEngine.js +53 -25
  123. package/Engines/webgpuEngine.js.map +1 -1
  124. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.d.ts +74 -0
  125. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.js +179 -0
  126. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.js.map +1 -0
  127. package/FrameGraph/Node/Blocks/index.d.ts +2 -0
  128. package/FrameGraph/Node/Blocks/index.js +2 -0
  129. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  130. package/FrameGraph/Node/Blocks/lightingVolumeBlock.d.ts +46 -0
  131. package/FrameGraph/Node/Blocks/lightingVolumeBlock.js +106 -0
  132. package/FrameGraph/Node/Blocks/lightingVolumeBlock.js.map +1 -0
  133. package/FrameGraph/Node/nodeRenderGraph.d.ts +22 -5
  134. package/FrameGraph/Node/nodeRenderGraph.js +39 -18
  135. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  136. package/FrameGraph/Passes/pass.d.ts +2 -0
  137. package/FrameGraph/Passes/pass.js +2 -0
  138. package/FrameGraph/Passes/pass.js.map +1 -1
  139. package/FrameGraph/Passes/renderPass.d.ts +2 -0
  140. package/FrameGraph/Passes/renderPass.js +4 -0
  141. package/FrameGraph/Passes/renderPass.js.map +1 -1
  142. package/FrameGraph/Tasks/Misc/lightingVolumeTask.d.ts +31 -0
  143. package/FrameGraph/Tasks/Misc/lightingVolumeTask.js +56 -0
  144. package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -0
  145. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +2 -2
  146. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  147. package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.d.ts +30 -0
  148. package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js +57 -0
  149. package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js.map +1 -0
  150. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +91 -0
  151. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +210 -0
  152. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -0
  153. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +1 -1
  154. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  155. package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -1
  156. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  157. package/FrameGraph/frameGraph.d.ts +13 -4
  158. package/FrameGraph/frameGraph.js +45 -5
  159. package/FrameGraph/frameGraph.js.map +1 -1
  160. package/FrameGraph/frameGraphRenderContext.d.ts +2 -2
  161. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  162. package/FrameGraph/frameGraphRenderTarget.d.ts +1 -0
  163. package/FrameGraph/frameGraphRenderTarget.js +3 -0
  164. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  165. package/FrameGraph/frameGraphTask.d.ts +6 -0
  166. package/FrameGraph/frameGraphTask.js +17 -2
  167. package/FrameGraph/frameGraphTask.js.map +1 -1
  168. package/FrameGraph/frameGraphTypes.d.ts +2 -0
  169. package/FrameGraph/frameGraphTypes.js.map +1 -1
  170. package/FrameGraph/index.d.ts +2 -0
  171. package/FrameGraph/index.js +2 -0
  172. package/FrameGraph/index.js.map +1 -1
  173. package/Helpers/sceneHelpers.js +1 -1
  174. package/Helpers/sceneHelpers.js.map +1 -1
  175. package/Lights/index.d.ts +1 -0
  176. package/Lights/index.js +1 -0
  177. package/Lights/index.js.map +1 -1
  178. package/Lights/lightingVolume.d.ts +89 -0
  179. package/Lights/lightingVolume.js +435 -0
  180. package/Lights/lightingVolume.js.map +1 -0
  181. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +7 -0
  182. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +19 -5
  183. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  184. package/Materials/Node/nodeMaterial.js +8 -2
  185. package/Materials/Node/nodeMaterial.js.map +1 -1
  186. package/Materials/floatingOriginMatrixOverrides.js +6 -5
  187. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  188. package/Materials/uniformBuffer.d.ts +1 -0
  189. package/Materials/uniformBuffer.js +8 -1
  190. package/Materials/uniformBuffer.js.map +1 -1
  191. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +5 -2
  192. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +138 -45
  193. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  194. package/Meshes/mesh.js +1 -1
  195. package/Meshes/mesh.js.map +1 -1
  196. package/Misc/screenshotTools.js +2 -8
  197. package/Misc/screenshotTools.js.map +1 -1
  198. package/Particles/solidParticle.d.ts +9 -0
  199. package/Particles/solidParticle.js +11 -0
  200. package/Particles/solidParticle.js.map +1 -1
  201. package/Particles/solidParticleSystem.d.ts +28 -0
  202. package/Particles/solidParticleSystem.js +75 -0
  203. package/Particles/solidParticleSystem.js.map +1 -1
  204. package/Physics/v2/characterController.d.ts +42 -2
  205. package/Physics/v2/characterController.js +140 -46
  206. package/Physics/v2/characterController.js.map +1 -1
  207. package/Shaders/volumetricLightingBlendVolume.fragment.d.ts +5 -0
  208. package/Shaders/volumetricLightingBlendVolume.fragment.js +21 -0
  209. package/Shaders/volumetricLightingBlendVolume.fragment.js.map +1 -0
  210. package/Shaders/volumetricLightingRenderVolume.fragment.d.ts +7 -0
  211. package/Shaders/volumetricLightingRenderVolume.fragment.js +25 -0
  212. package/Shaders/volumetricLightingRenderVolume.fragment.js.map +1 -0
  213. package/Shaders/volumetricLightingRenderVolume.vertex.d.ts +9 -0
  214. package/Shaders/volumetricLightingRenderVolume.vertex.js +18 -0
  215. package/Shaders/volumetricLightingRenderVolume.vertex.js.map +1 -0
  216. package/ShadersWGSL/gaussianSplattingDepth.fragment.d.ts +0 -1
  217. package/ShadersWGSL/gaussianSplattingDepth.fragment.js +0 -2
  218. package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
  219. package/ShadersWGSL/lightingVolume.compute.d.ts +5 -0
  220. package/ShadersWGSL/lightingVolume.compute.js +27 -0
  221. package/ShadersWGSL/lightingVolume.compute.js.map +1 -0
  222. package/ShadersWGSL/volumetricLightingBlendVolume.fragment.d.ts +5 -0
  223. package/ShadersWGSL/volumetricLightingBlendVolume.fragment.js +22 -0
  224. package/ShadersWGSL/volumetricLightingBlendVolume.fragment.js.map +1 -0
  225. package/ShadersWGSL/volumetricLightingRenderVolume.fragment.d.ts +7 -0
  226. package/ShadersWGSL/volumetricLightingRenderVolume.fragment.js +27 -0
  227. package/ShadersWGSL/volumetricLightingRenderVolume.fragment.js.map +1 -0
  228. package/ShadersWGSL/volumetricLightingRenderVolume.vertex.d.ts +7 -0
  229. package/ShadersWGSL/volumetricLightingRenderVolume.vertex.js +17 -0
  230. package/ShadersWGSL/volumetricLightingRenderVolume.vertex.js.map +1 -0
  231. package/States/IStencilState.d.ts +48 -2
  232. package/States/IStencilState.js.map +1 -1
  233. package/package.json +1 -1
  234. package/scene.js +6 -4
  235. package/scene.js.map +1 -1
@@ -4,8 +4,8 @@ import { Epsilon } from "../Maths/math.constants.js";
4
4
  import { Camera } from "./camera.js";
5
5
  import { GeospatialLimits } from "./Limits/geospatialLimits.js";
6
6
  import { ClampCenterFromPolesInPlace, ComputeLocalBasisToRefs, GeospatialCameraMovement } from "./geospatialCameraMovement.js";
7
- import { Vector3CopyToRef, Vector3Dot } from "../Maths/math.vector.functions.js";
8
- import { Clamp } from "../Maths/math.scalar.functions.js";
7
+ import { Vector3CopyToRef, Vector3Distance } from "../Maths/math.vector.functions.js";
8
+ import { Clamp, NormalizeRadians } from "../Maths/math.scalar.functions.js";
9
9
  import { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
10
10
  /**
11
11
  * @experimental
@@ -34,7 +34,7 @@ export class GeospatialCamera extends Camera {
34
34
  this._resetToDefault(this._limits);
35
35
  this._flyingBehavior = new InterpolatingBehavior();
36
36
  this.addBehavior(this._flyingBehavior);
37
- this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate);
37
+ this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate, this._flyingBehavior);
38
38
  this.pickPredicate = pickPredicate;
39
39
  this.inputs = new GeospatialCameraInputsManager(this);
40
40
  this.inputs.addMouse().addMouseWheel().addKeyboard();
@@ -58,11 +58,11 @@ export class GeospatialCamera extends Camera {
58
58
  return this._yaw;
59
59
  }
60
60
  /**
61
- * Sets the camera's yaw (rotation around the geocentric normal)
61
+ * Sets the camera's yaw (rotation around the geocentric normal). Will wrap value to [-π, π)
62
62
  * @param yaw The desired yaw angle in radians (0 = north, π/2 = east)
63
63
  */
64
64
  set yaw(yaw) {
65
- this._setOrientation(yaw, this.pitch, this.radius, this.center);
65
+ yaw !== this._yaw && this._setOrientation(yaw, this.pitch, this.radius, this.center);
66
66
  }
67
67
  /**
68
68
  * Gets the camera's pitch (angle from looking straight at globe)
@@ -75,11 +75,11 @@ export class GeospatialCamera extends Camera {
75
75
  return this._pitch;
76
76
  }
77
77
  /**
78
- * Sets the camera's pitch (angle from looking straight at globe)
78
+ * Sets the camera's pitch (angle from looking straight at globe). Will wrap value to [-π, π)
79
79
  * @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)
80
80
  */
81
81
  set pitch(pitch) {
82
- this._setOrientation(this.yaw, pitch, this.radius, this.center);
82
+ pitch !== this._pitch && this._setOrientation(this.yaw, pitch, this.radius, this.center);
83
83
  }
84
84
  get radius() {
85
85
  return this._radius;
@@ -89,7 +89,7 @@ export class GeospatialCamera extends Camera {
89
89
  * @param radius The desired radius
90
90
  */
91
91
  set radius(radius) {
92
- this._setOrientation(this.yaw, this.pitch, radius, this.center);
92
+ radius !== this._radius && this._setOrientation(this.yaw, this.pitch, radius, this.center);
93
93
  }
94
94
  _checkLimits() {
95
95
  const limits = this.limits;
@@ -99,8 +99,9 @@ export class GeospatialCamera extends Camera {
99
99
  this._center = ClampCenterFromPolesInPlace(this._center);
100
100
  }
101
101
  _setOrientation(yaw, pitch, radius, center) {
102
- this._yaw = yaw;
103
- this._pitch = pitch;
102
+ // Wrap yaw and pitch to [-π, π)
103
+ this._yaw = NormalizeRadians(yaw);
104
+ this._pitch = NormalizeRadians(pitch);
104
105
  this._radius = radius;
105
106
  Vector3CopyToRef(center, this._center);
106
107
  // Clamp to limits
@@ -148,8 +149,8 @@ export class GeospatialCamera extends Camera {
148
149
  */
149
150
  updateFlyToDestination(targetYaw, targetPitch, targetRadius, targetCenter) {
150
151
  this._flyToTargets.clear();
151
- this._flyToTargets.set("yaw", targetYaw);
152
- this._flyToTargets.set("pitch", targetPitch);
152
+ this._flyToTargets.set("yaw", targetYaw != undefined ? NormalizeRadians(targetYaw) : undefined);
153
+ this._flyToTargets.set("pitch", targetPitch != undefined ? NormalizeRadians(targetPitch) : undefined);
153
154
  this._flyToTargets.set("radius", targetRadius);
154
155
  this._flyToTargets.set("center", targetCenter);
155
156
  this._flyingBehavior.updateProperties(this._flyToTargets);
@@ -162,15 +163,42 @@ export class GeospatialCamera extends Camera {
162
163
  * @param targetCenter
163
164
  * @param flightDurationMs
164
165
  * @param easingFunction
166
+ * @param centerHopScale If supplied, will define the parabolic hop height scale for center animation to create a "bounce" effect
165
167
  * @returns Promise that will return when the animation is complete (or interuppted by pointer input)
166
168
  */
167
- async flyToAsync(targetYaw, targetPitch, targetRadius, targetCenter, flightDurationMs = 1000, easingFunction) {
169
+ async flyToAsync(targetYaw, targetPitch, targetRadius, targetCenter, flightDurationMs = 1000, easingFunction, centerHopScale) {
168
170
  this._flyToTargets.clear();
169
- this._flyToTargets.set("yaw", targetYaw);
170
- this._flyToTargets.set("pitch", targetPitch);
171
+ this._flyToTargets.set("yaw", targetYaw !== undefined ? NormalizeRadians(targetYaw) : undefined);
172
+ this._flyToTargets.set("pitch", targetPitch !== undefined ? NormalizeRadians(targetPitch) : undefined);
171
173
  this._flyToTargets.set("radius", targetRadius);
172
174
  this._flyToTargets.set("center", targetCenter);
173
- return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction);
175
+ let overrideAnimationFunction;
176
+ if (targetCenter !== undefined && !targetCenter.equals(this.center)) {
177
+ // Animate center directly with custom interpolation
178
+ const start = this.center.clone();
179
+ const end = targetCenter.clone();
180
+ overrideAnimationFunction = (key, animation) => {
181
+ if (key === "center") {
182
+ // Override the Vector3 interpolation to use SLERP + hop
183
+ animation.vector3InterpolateFunction = (startValue, endValue, gradient) => {
184
+ // gradient is the eased value (0 to 1) after easing function is applied
185
+ // Slerp between start and end
186
+ const newCenter = Vector3.SlerpToRef(start, end, gradient, this._tempCenter);
187
+ // Apply parabolic hop if requested
188
+ if (centerHopScale && centerHopScale > 0) {
189
+ // Parabolic formula: peaks at t=0.5, returns to 0 at gradient=0 and gradient=1
190
+ // if hopPeakT = .5 the denominator would be hopPeakT * hopPeakT - hopPeakT, which = -.25
191
+ const hopPeakOffset = centerHopScale * Vector3Distance(start, end);
192
+ const hopOffset = hopPeakOffset * Clamp((gradient * gradient - gradient) / -0.25);
193
+ // Scale the center outward (away from origin)
194
+ newCenter.scaleInPlace(1 + hopOffset / newCenter.length());
195
+ }
196
+ return newCenter;
197
+ };
198
+ }
199
+ };
200
+ }
201
+ return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction, overrideAnimationFunction);
174
202
  }
175
203
  /**
176
204
  * Helper function to move camera towards a given point by radiusScale% of radius (by default 50%)
@@ -178,12 +206,13 @@ export class GeospatialCamera extends Camera {
178
206
  * @param radiusScale value between 0 and 1, % of radius to move
179
207
  * @param durationMs duration of flight, default 1s
180
208
  * @param easingFn optional easing function for flight interpolation of properties
209
+ * @param overshootRadiusScale optional scale to apply to the current radius to achieve a 'hop' animation
181
210
  */
182
- async flyToPointAsync(destination, radiusScale = 0.5, durationMs = 1000, easingFn) {
183
- const direction = destination.subtractToRef(this.position, this._tempPosition).normalize();
211
+ async flyToPointAsync(destination, radiusScale = 0.5, durationMs = 1000, easingFn, overshootRadiusScale) {
184
212
  // Zoom to radiusScale% of radius towards the given destination point
185
- const newRadius = this._getRadiusAndCenterFromZoomTowards(direction, this.radius * radiusScale, this._tempCenter);
186
- await this.flyToAsync(undefined, undefined, newRadius, this._tempCenter, durationMs, easingFn);
213
+ const zoomDistance = this.radius * radiusScale;
214
+ const newRadius = this._getCenterAndRadiusFromZoomToPoint(destination, zoomDistance, this._tempCenter);
215
+ await this.flyToAsync(undefined, undefined, newRadius, this._tempCenter, durationMs, easingFn, overshootRadiusScale);
187
216
  }
188
217
  get limits() {
189
218
  return this._limits;
@@ -251,54 +280,93 @@ export class GeospatialCamera extends Camera {
251
280
  this._setOrientation(yaw, pitch, this._radius, this._geocentricRotationPt);
252
281
  }
253
282
  }
254
- _getRadiusAndCenterFromZoomTowards(zoomVector, distance, centerRef) {
255
- // TODO this function will be re-worked shortly after checkin, becuase today it breaks down if you zoom to a point past the center
256
- // (ex: tilted view zooming towards cursor near horizon where the center is closer than the cursor point).
257
- // Project zoom vector onto lookAt vector to find the amount the camera-to-center distance should change.
258
- // - zoom vector is normalized
259
- // - distance is how much to move in this call
260
- const directionDotLookAt = Vector3Dot(zoomVector, this._lookAtVector);
261
- const hasRadialComponent = Math.abs(directionDotLookAt) > Epsilon;
262
- const requestedRadius = hasRadialComponent ? this._radius - distance * directionDotLookAt : this._radius;
283
+ _getCenterAndRadiusFromZoomToPoint(targetPoint, distance, newCenter) {
284
+ // Clamp new radius to limits
285
+ const requestedRadius = this._radius - distance;
263
286
  const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);
264
- const actualRadiusChange = newRadius - this._radius;
265
- const actualDistanceChange = hasRadialComponent ? actualRadiusChange / directionDotLookAt : 0;
266
- // Use this to compute new camera position and new center position.
267
- const newCameraPosition = this._position.add(zoomVector.scale(-actualDistanceChange));
268
- const newCenter = newCameraPosition.add(this._lookAtVector.scaleToRef(newRadius, TmpVectors.Vector3[3]));
269
- // Rescale new center to maintain same altitude as the old center.
287
+ const actualDistance = this._radius - newRadius;
288
+ const actualRatio = actualDistance / this._radius;
289
+ // Direction from current center to target point
290
+ const directionToTarget = TmpVectors.Vector3[0];
291
+ targetPoint.subtractToRef(this._center, directionToTarget);
292
+ // Move center toward target by the ratio amount
293
+ const centerOffset = TmpVectors.Vector3[1];
294
+ directionToTarget.scaleToRef(actualRatio, centerOffset);
295
+ // Calculate new center
296
+ this._center.addToRef(centerOffset, newCenter);
297
+ // Preserve center altitude (distance from planet origin)
270
298
  const currentCenterRadius = this._center.length();
271
299
  const newCenterRadius = newCenter.length();
272
- const newCenterRescale = currentCenterRadius / newCenterRadius;
273
- newCenter.scaleInPlace(newCenterRescale);
274
- // Copy new center to ref
275
- Vector3CopyToRef(newCenter, centerRef);
276
- // Return new radius
300
+ if (newCenterRadius > Epsilon) {
301
+ newCenter.scaleInPlace(currentCenterRadius / newCenterRadius);
302
+ }
277
303
  return newRadius;
278
304
  }
279
- _applyZoom(zoomVector, distance) {
280
- const newRadius = this._getRadiusAndCenterFromZoomTowards(zoomVector, distance, this._tempVect);
281
- // Apply changes
282
- this._setOrientation(this._yaw, this._pitch, newRadius, this._tempVect);
305
+ /**
306
+ * Apply zoom by moving the camera toward/away from a target point.
307
+ */
308
+ _applyZoom() {
309
+ const zoomDelta = this.movement.zoomDeltaCurrentFrame;
310
+ const pickedPoint = this.movement.computedPerFrameZoomPickPoint;
311
+ if (pickedPoint) {
312
+ // Zoom toward the picked point under cursor
313
+ this._zoomToPoint(pickedPoint, zoomDelta);
314
+ }
315
+ else {
316
+ // Zoom along lookAt vector (fallback when no surface under cursor)
317
+ this._zoomAlongLookAt(zoomDelta);
318
+ }
319
+ }
320
+ _zoomToPoint(targetPoint, distance) {
321
+ const newRadius = this._getCenterAndRadiusFromZoomToPoint(targetPoint, distance, this._tempCenter);
322
+ // Apply the new orientation
323
+ this._setOrientation(this._yaw, this._pitch, newRadius, this._tempCenter);
324
+ }
325
+ _zoomAlongLookAt(distance) {
326
+ // Clamp radius to limits
327
+ const requestedRadius = this._radius - distance;
328
+ const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);
329
+ // Simply change radius without moving center
330
+ this._setOrientation(this._yaw, this._pitch, newRadius, this._center);
283
331
  }
284
332
  _checkInputs() {
285
333
  this.inputs.checkInputs();
286
334
  // Let movement class handle all per-frame logic
287
335
  this.movement.computeCurrentFrameDeltas();
336
+ let recalculateCenter = false;
288
337
  if (this.movement.panDeltaCurrentFrame.lengthSquared() > 0) {
289
338
  this._applyGeocentricTranslation();
290
- this._isViewMatrixDirty = true;
339
+ recalculateCenter = true;
291
340
  }
292
341
  if (this.movement.rotationDeltaCurrentFrame.lengthSquared() > 0) {
293
342
  this._applyGeocentricRotation();
294
- this._isViewMatrixDirty = true;
295
343
  }
296
344
  if (Math.abs(this.movement.zoomDeltaCurrentFrame) > Epsilon) {
297
- this._applyZoom(this.movement.computedPerFrameZoomVector, this.movement.zoomDeltaCurrentFrame);
298
- this._isViewMatrixDirty = true;
345
+ this._applyZoom();
346
+ recalculateCenter = true;
299
347
  }
348
+ // After a movement impacting center or radius, recalculate the center point to ensure it's still on the surface.
349
+ recalculateCenter && this._recalculateCenter();
300
350
  super._checkInputs();
301
351
  }
352
+ _recalculateCenter() {
353
+ // Wait until dragging is complete to avoid wasted raycasting
354
+ if (!this.movement.isDragging) {
355
+ const newCenter = this.movement.pickAlongVector(this._lookAtVector);
356
+ if (newCenter?.pickedPoint) {
357
+ // Direction from new center to origin
358
+ const centerToOrigin = TmpVectors.Vector3[4];
359
+ centerToOrigin.copyFrom(newCenter.pickedPoint).negateInPlace().normalize();
360
+ // Check if this direction aligns with camera's lookAt vector
361
+ const dotProduct = Vector3.Dot(this._lookAtVector, centerToOrigin);
362
+ // Only update if the center is looking toward the origin (dot product > 0) to avoid a center on the opposite side of globe
363
+ if (dotProduct > 0) {
364
+ const newRadius = Vector3.Distance(this.position, newCenter.pickedPoint);
365
+ this._setOrientation(this._yaw, this._pitch, newRadius, newCenter.pickedPoint);
366
+ }
367
+ }
368
+ }
369
+ }
302
370
  attachControl(noPreventDefault) {
303
371
  this.inputs.attachElement(noPreventDefault);
304
372
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geospatialCamera.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/geospatialCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE5H,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAOnF;;;;;GAKG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IAqBxC,YAAY,IAAY,EAAE,KAAY,EAAE,OAAsB,EAAE,aAA6B;QACzF,KAAK,CAAC,IAAI,EAAE,IAAI,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QAbtC,YAAY;QACJ,kBAAa,GAAY,IAAI,OAAO,EAAE,CAA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AC,GAAG,OAAO,EAAE,CAAC;YAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,0BAA0B,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;YAC/F,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QACnC,CAAC;QAED,KAAK,CAAC,YAAY,EAAE,CAAC;IACzB,CAAC;IAEQ,aAAa,CAAC,gBAA0B;QAC7C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAEQ,aAAa;QAClB,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["import { GeospatialCameraInputsManager } from \"./geospatialCameraInputsManager\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Camera } from \"./camera\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { MeshPredicate } from \"../Culling/ray.core\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { GeospatialLimits } from \"./Limits/geospatialLimits\";\r\nimport { ClampCenterFromPolesInPlace, ComputeLocalBasisToRefs, GeospatialCameraMovement } from \"./geospatialCameraMovement\";\r\nimport type { IVector3Like } from \"../Maths/math.like\";\r\nimport { Vector3CopyToRef, Vector3Dot } from \"../Maths/math.vector.functions\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\nimport type { AllowedAnimValue } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\nimport { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\nimport type { EasingFunction } from \"../Animations/easing\";\r\n\r\ntype CameraOptions = {\r\n planetRadius: number; // Radius of the planet\r\n};\r\n\r\n/**\r\n * @experimental\r\n * 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\r\n *\r\n * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag\r\n */\r\nexport class GeospatialCamera extends Camera {\r\n override inputs: GeospatialCameraInputsManager;\r\n\r\n /** If supplied, will be used when picking the globe */\r\n public pickPredicate?: MeshPredicate;\r\n\r\n /** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/\r\n public readonly movement: GeospatialCameraMovement;\r\n\r\n // Temp vars\r\n private _tempPosition: Vector3 = new Vector3();\r\n private _tempCenter = new Vector3();\r\n\r\n private _viewMatrix = new Matrix();\r\n private _isViewMatrixDirty: boolean;\r\n private _lookAtVector: Vector3 = new Vector3();\r\n\r\n /** Behavior used for smooth flying animations */\r\n private _flyingBehavior: InterpolatingBehavior<GeospatialCamera>;\r\n private _flyToTargets: Map<keyof GeospatialCamera, AllowedAnimValue> = new Map();\r\n\r\n constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate) {\r\n super(name, new Vector3(), scene);\r\n\r\n this._limits = new GeospatialLimits(options.planetRadius);\r\n this._resetToDefault(this._limits);\r\n\r\n this._flyingBehavior = new InterpolatingBehavior();\r\n this.addBehavior(this._flyingBehavior);\r\n\r\n this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate);\r\n\r\n this.pickPredicate = pickPredicate;\r\n this.inputs = new GeospatialCameraInputsManager(this);\r\n this.inputs.addMouse().addMouseWheel().addKeyboard();\r\n }\r\n\r\n private _center: Vector3 = new Vector3();\r\n /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/\r\n public get center(): Vector3 {\r\n return this._center;\r\n }\r\n\r\n /**\r\n * Sets the camera position to orbit around a new center point\r\n * @param center The world position (ECEF) to orbit around\r\n */\r\n public set center(center: IVector3Like) {\r\n this._center.copyFromFloats(center.x, center.y, center.z);\r\n this._setOrientation(this._yaw, this._pitch, this._radius, this._center);\r\n }\r\n\r\n private _yaw: number = 0;\r\n /**\r\n * Gets the camera's yaw (rotation around the geocentric normal) in radians\r\n */\r\n public get yaw(): number {\r\n return this._yaw;\r\n }\r\n\r\n /**\r\n * Sets the camera's yaw (rotation around the geocentric normal)\r\n * @param yaw The desired yaw angle in radians (0 = north, π/2 = east)\r\n */\r\n public set yaw(yaw: number) {\r\n this._setOrientation(yaw, this.pitch, this.radius, this.center);\r\n }\r\n\r\n private _pitch: number = 0;\r\n\r\n /**\r\n * Gets the camera's pitch (angle from looking straight at globe)\r\n * Pitch is measured from looking straight down at planet center:\r\n * - zero pitch = looking straight at planet center (down)\r\n * - positive pitch = tilting up away from planet\r\n * - π/2 pitch = looking at horizon (perpendicular to geocentric normal)\r\n */\r\n public get pitch(): number {\r\n return this._pitch;\r\n }\r\n\r\n /**\r\n * Sets the camera's pitch (angle from looking straight at globe)\r\n * @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)\r\n */\r\n public set pitch(pitch: number) {\r\n this._setOrientation(this.yaw, pitch, this.radius, this.center);\r\n }\r\n\r\n private _radius: number = 0;\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n /**\r\n * Sets the camera's distance from the current center point\r\n * @param radius The desired radius\r\n */\r\n public set radius(radius: number) {\r\n this._setOrientation(this.yaw, this.pitch, radius, this.center);\r\n }\r\n\r\n protected _checkLimits() {\r\n const limits = this.limits;\r\n this._yaw = Clamp(this._yaw, limits.yawMin, limits.yawMax);\r\n this._pitch = Clamp(this._pitch, limits.pitchMin, limits.pitchMax);\r\n this._radius = Clamp(this._radius, limits.radiusMin, limits.radiusMax);\r\n this._center = ClampCenterFromPolesInPlace(this._center);\r\n }\r\n\r\n private _tempVect = new Vector3();\r\n private _tempEast = new Vector3();\r\n private _tempNorth = new Vector3();\r\n private _tempUp = new Vector3();\r\n\r\n private _setOrientation(yaw: number, pitch: number, radius: number, center: DeepImmutable<IVector3Like>): void {\r\n this._yaw = yaw;\r\n this._pitch = pitch;\r\n this._radius = radius;\r\n\r\n Vector3CopyToRef(center, this._center);\r\n\r\n // Clamp to limits\r\n this._checkLimits();\r\n\r\n // Refresh local basis at center (treat these as read-only for the whole call)\r\n ComputeLocalBasisToRefs(this._center, this._tempEast, this._tempNorth, this._tempUp);\r\n\r\n // Trig\r\n const yawScale = this._scene.useRightHandedSystem ? 1 : -1;\r\n const cosYaw = Math.cos(this._yaw * yawScale);\r\n const sinYaw = Math.sin(this._yaw * yawScale);\r\n const sinPitch = Math.sin(this._pitch); // horizontal weight\r\n const cosPitch = Math.cos(this._pitch); // vertical weight (toward center)\r\n\r\n // Temps\r\n const horiz = TmpVectors.Vector3[0];\r\n const t1 = TmpVectors.Vector3[1];\r\n const t2 = TmpVectors.Vector3[2];\r\n const right = TmpVectors.Vector3[3];\r\n\r\n // horizontalDirection = North*cosYaw + East*sinYaw (avoids mutating _temp basis vectors)\r\n horiz.copyFrom(this._tempNorth).scaleInPlace(cosYaw).addInPlace(t1.copyFrom(this._tempEast).scaleInPlace(sinYaw));\r\n\r\n // look = horiz*sinPitch - Up*cosPitch\r\n this._lookAtVector.copyFrom(horiz).scaleInPlace(sinPitch).addInPlace(t2.copyFrom(this._tempUp).scaleInPlace(-cosPitch)).normalize(); // keep it unit\r\n\r\n // Build an orthonormal up aligned with geocentric Up\r\n // right = normalize(cross(upRef, look))\r\n Vector3.CrossToRef(this._tempUp, this._lookAtVector, right);\r\n\r\n // up = normalize(cross(look, right))\r\n Vector3.CrossToRef(this._lookAtVector, right, this.upVector);\r\n\r\n // Position = center - look * radius (preserve unit look)\r\n this._tempVect.copyFrom(this._lookAtVector).scaleInPlace(-this._radius);\r\n this._tempPosition.copyFrom(this._center).addInPlace(this._tempVect);\r\n\r\n this._position.copyFrom(this._tempPosition);\r\n\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */\r\n private get _geocentricRotationPt(): Vector3 {\r\n return this.movement.alternateRotationPt ?? this.center;\r\n }\r\n\r\n /**\r\n * If camera is actively in flight, will update the target properties and use up the remaining duration from original flyTo call\r\n *\r\n * To start a new flyTo curve entirely, call into flyToAsync again (it will stop the inflight animation)\r\n * @param targetYaw\r\n * @param targetPitch\r\n * @param targetRadius\r\n * @param targetCenter\r\n */\r\n public updateFlyToDestination(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3): void {\r\n this._flyToTargets.clear();\r\n\r\n this._flyToTargets.set(\"yaw\", targetYaw);\r\n this._flyToTargets.set(\"pitch\", targetPitch);\r\n this._flyToTargets.set(\"radius\", targetRadius);\r\n this._flyToTargets.set(\"center\", targetCenter);\r\n\r\n this._flyingBehavior.updateProperties(this._flyToTargets);\r\n }\r\n\r\n /**\r\n * Animate camera towards passed in property values. If undefined, will use current value\r\n * @param targetYaw\r\n * @param targetPitch\r\n * @param targetRadius\r\n * @param targetCenter\r\n * @param flightDurationMs\r\n * @param easingFunction\r\n * @returns Promise that will return when the animation is complete (or interuppted by pointer input)\r\n */\r\n public async flyToAsync(\r\n targetYaw?: number,\r\n targetPitch?: number,\r\n targetRadius?: number,\r\n targetCenter?: Vector3,\r\n flightDurationMs: number = 1000,\r\n easingFunction?: EasingFunction\r\n ): Promise<void> {\r\n this._flyToTargets.clear();\r\n\r\n this._flyToTargets.set(\"yaw\", targetYaw);\r\n this._flyToTargets.set(\"pitch\", targetPitch);\r\n this._flyToTargets.set(\"radius\", targetRadius);\r\n this._flyToTargets.set(\"center\", targetCenter);\r\n\r\n return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction);\r\n }\r\n\r\n /**\r\n * Helper function to move camera towards a given point by radiusScale% of radius (by default 50%)\r\n * @param destination point to move towards\r\n * @param radiusScale value between 0 and 1, % of radius to move\r\n * @param durationMs duration of flight, default 1s\r\n * @param easingFn optional easing function for flight interpolation of properties\r\n */\r\n public async flyToPointAsync(destination: Vector3, radiusScale: number = 0.5, durationMs: number = 1000, easingFn?: EasingFunction) {\r\n const direction = destination.subtractToRef(this.position, this._tempPosition).normalize();\r\n // Zoom to radiusScale% of radius towards the given destination point\r\n const newRadius = this._getRadiusAndCenterFromZoomTowards(direction, this.radius * radiusScale, this._tempCenter);\r\n await this.flyToAsync(undefined, undefined, newRadius, this._tempCenter, durationMs, easingFn);\r\n }\r\n\r\n private _limits: GeospatialLimits;\r\n public get limits(): GeospatialLimits {\r\n return this._limits;\r\n }\r\n\r\n private _resetToDefault(limits: GeospatialLimits): void {\r\n // Camera configuration vars\r\n const maxCameraRadius = limits.altitudeMax !== undefined ? limits.planetRadius + limits.altitudeMax : undefined;\r\n const restingAltitude = maxCameraRadius ?? limits.planetRadius * 4;\r\n this.position.copyFromFloats(restingAltitude, 0, 0);\r\n this._center.copyFromFloats(limits.planetRadius, 0, 0);\r\n this._radius = Vector3.Distance(this.position, this.center);\r\n\r\n // Temp vars\r\n this._tempPosition = new Vector3();\r\n\r\n // View matrix calculation vars\r\n this._viewMatrix = Matrix.Identity();\r\n this._center.subtractToRef(this._position, this._lookAtVector).normalize(); // Lookat vector of the camera\r\n this.upVector = Vector3.Up(); // Up vector of the camera (does work for -X look at)\r\n this._isViewMatrixDirty = true;\r\n\r\n this._setOrientation(this._yaw, this._pitch, this._radius, this._center);\r\n }\r\n\r\n /** @internal */\r\n override _getViewMatrix() {\r\n if (!this._isViewMatrixDirty) {\r\n return this._viewMatrix;\r\n }\r\n this._isViewMatrixDirty = false;\r\n\r\n // Ensure vectors are normalized\r\n this.upVector.normalize();\r\n this._lookAtVector.normalize();\r\n\r\n // Calculate view matrix with camera position and center\r\n if (this.getScene().useRightHandedSystem) {\r\n Matrix.LookAtRHToRef(this.position, this._center, this.upVector, this._viewMatrix);\r\n } else {\r\n Matrix.LookAtLHToRef(this.position, this._center, this.upVector, this._viewMatrix);\r\n }\r\n\r\n return this._viewMatrix;\r\n }\r\n\r\n /** @internal */\r\n override _isSynchronizedViewMatrix(): boolean {\r\n if (!super._isSynchronizedViewMatrix() || this._isViewMatrixDirty) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n private _applyGeocentricTranslation() {\r\n // Store pending position (without any corrections applied)\r\n this.center.addToRef(this.movement.panDeltaCurrentFrame, this._tempPosition);\r\n\r\n if (!this.movement.isInterpolating) {\r\n // Calculate the position correction to keep camera at the same radius when applying translation\r\n this._tempPosition.normalize().scaleInPlace(this.center.length());\r\n }\r\n // Set center which will call _setOrientation\r\n this.center = this._tempPosition;\r\n }\r\n\r\n /**\r\n * 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\r\n */\r\n private _applyGeocentricRotation(): void {\r\n const rotationDeltaCurrentFrame = this.movement.rotationDeltaCurrentFrame;\r\n if (rotationDeltaCurrentFrame.x !== 0 || rotationDeltaCurrentFrame.y !== 0) {\r\n const pitch = rotationDeltaCurrentFrame.x !== 0 ? Clamp(this._pitch + rotationDeltaCurrentFrame.x, 0, 0.5 * Math.PI - Epsilon) : this._pitch;\r\n const yaw = rotationDeltaCurrentFrame.y !== 0 ? this._yaw + rotationDeltaCurrentFrame.y : this._yaw;\r\n\r\n // TODO: If _geocentricRotationPt is not the center, this will need to be adjusted.\r\n this._setOrientation(yaw, pitch, this._radius, this._geocentricRotationPt);\r\n }\r\n }\r\n\r\n private _getRadiusAndCenterFromZoomTowards(zoomVector: Vector3, distance: number, centerRef: Vector3): number {\r\n // TODO this function will be re-worked shortly after checkin, becuase today it breaks down if you zoom to a point past the center\r\n // (ex: tilted view zooming towards cursor near horizon where the center is closer than the cursor point).\r\n\r\n // Project zoom vector onto lookAt vector to find the amount the camera-to-center distance should change.\r\n // - zoom vector is normalized\r\n // - distance is how much to move in this call\r\n const directionDotLookAt = Vector3Dot(zoomVector, this._lookAtVector);\r\n const hasRadialComponent = Math.abs(directionDotLookAt) > Epsilon;\r\n const requestedRadius = hasRadialComponent ? this._radius - distance * directionDotLookAt : this._radius;\r\n const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);\r\n const actualRadiusChange = newRadius - this._radius;\r\n const actualDistanceChange = hasRadialComponent ? actualRadiusChange / directionDotLookAt : 0;\r\n\r\n // Use this to compute new camera position and new center position.\r\n const newCameraPosition = this._position.add(zoomVector.scale(-actualDistanceChange));\r\n const newCenter = newCameraPosition.add(this._lookAtVector.scaleToRef(newRadius, TmpVectors.Vector3[3]));\r\n\r\n // Rescale new center to maintain same altitude as the old center.\r\n const currentCenterRadius = this._center.length();\r\n const newCenterRadius = newCenter.length();\r\n const newCenterRescale = currentCenterRadius / newCenterRadius;\r\n newCenter.scaleInPlace(newCenterRescale);\r\n\r\n // Copy new center to ref\r\n Vector3CopyToRef(newCenter, centerRef);\r\n\r\n // Return new radius\r\n return newRadius;\r\n }\r\n\r\n private _applyZoom(zoomVector: Vector3, distance: number) {\r\n const newRadius = this._getRadiusAndCenterFromZoomTowards(zoomVector, distance, this._tempVect);\r\n\r\n // Apply changes\r\n this._setOrientation(this._yaw, this._pitch, newRadius, this._tempVect);\r\n }\r\n\r\n override _checkInputs(): void {\r\n this.inputs.checkInputs();\r\n\r\n // Let movement class handle all per-frame logic\r\n this.movement.computeCurrentFrameDeltas();\r\n\r\n if (this.movement.panDeltaCurrentFrame.lengthSquared() > 0) {\r\n this._applyGeocentricTranslation();\r\n this._isViewMatrixDirty = true;\r\n }\r\n if (this.movement.rotationDeltaCurrentFrame.lengthSquared() > 0) {\r\n this._applyGeocentricRotation();\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n if (Math.abs(this.movement.zoomDeltaCurrentFrame) > Epsilon) {\r\n this._applyZoom(this.movement.computedPerFrameZoomVector, this.movement.zoomDeltaCurrentFrame);\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n super._checkInputs();\r\n }\r\n\r\n override attachControl(noPreventDefault?: boolean): void {\r\n this.inputs.attachElement(noPreventDefault);\r\n }\r\n\r\n override detachControl(): void {\r\n this.inputs.detachElement();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"geospatialCamera.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/geospatialCamera.ts"],"names":[],"m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AAC,QAAQ,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;oBACzE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;gBACnF,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACQ,aAAa,CAAC,gBAA0B;QAC7C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAEQ,aAAa;QAClB,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["import { GeospatialCameraInputsManager } from \"./geospatialCameraInputsManager\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Camera } from \"./camera\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { MeshPredicate } from \"../Culling/ray.core\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { GeospatialLimits } from \"./Limits/geospatialLimits\";\r\nimport { ClampCenterFromPolesInPlace, ComputeLocalBasisToRefs, GeospatialCameraMovement } from \"./geospatialCameraMovement\";\r\nimport type { IVector3Like } from \"../Maths/math.like\";\r\nimport { Vector3CopyToRef, Vector3Distance } from \"../Maths/math.vector.functions\";\r\nimport { Clamp, NormalizeRadians } from \"../Maths/math.scalar.functions\";\r\nimport type { AllowedAnimValue } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\nimport { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\nimport type { EasingFunction } from \"../Animations/easing\";\r\nimport type { Animation } from \"../Animations/animation\";\r\n\r\ntype CameraOptions = {\r\n planetRadius: number; // Radius of the planet\r\n};\r\n\r\n/**\r\n * @experimental\r\n * 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\r\n *\r\n * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag\r\n */\r\nexport class GeospatialCamera extends Camera {\r\n override inputs: GeospatialCameraInputsManager;\r\n\r\n /** If supplied, will be used when picking the globe */\r\n public pickPredicate?: MeshPredicate;\r\n\r\n /** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/\r\n public readonly movement: GeospatialCameraMovement;\r\n\r\n // Temp vars\r\n private _tempPosition: Vector3 = new Vector3();\r\n private _tempCenter: Vector3 = new Vector3();\r\n\r\n private _viewMatrix = new Matrix();\r\n private _isViewMatrixDirty: boolean;\r\n private _lookAtVector: Vector3 = new Vector3();\r\n\r\n /** Behavior used for smooth flying animations */\r\n private _flyingBehavior: InterpolatingBehavior<GeospatialCamera>;\r\n private _flyToTargets: Map<keyof GeospatialCamera, AllowedAnimValue> = new Map();\r\n\r\n constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate) {\r\n super(name, new Vector3(), scene);\r\n\r\n this._limits = new GeospatialLimits(options.planetRadius);\r\n this._resetToDefault(this._limits);\r\n\r\n this._flyingBehavior = new InterpolatingBehavior();\r\n this.addBehavior(this._flyingBehavior);\r\n\r\n this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate, this._flyingBehavior);\r\n\r\n this.pickPredicate = pickPredicate;\r\n this.inputs = new GeospatialCameraInputsManager(this);\r\n this.inputs.addMouse().addMouseWheel().addKeyboard();\r\n }\r\n\r\n private _center: Vector3 = new Vector3();\r\n /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/\r\n public get center(): Vector3 {\r\n return this._center;\r\n }\r\n\r\n /**\r\n * Sets the camera position to orbit around a new center point\r\n * @param center The world position (ECEF) to orbit around\r\n */\r\n public set center(center: IVector3Like) {\r\n this._center.copyFromFloats(center.x, center.y, center.z);\r\n this._setOrientation(this._yaw, this._pitch, this._radius, this._center);\r\n }\r\n\r\n private _yaw: number = 0;\r\n /**\r\n * Gets the camera's yaw (rotation around the geocentric normal) in radians\r\n */\r\n public get yaw(): number {\r\n return this._yaw;\r\n }\r\n\r\n /**\r\n * Sets the camera's yaw (rotation around the geocentric normal). Will wrap value to [-π, π)\r\n * @param yaw The desired yaw angle in radians (0 = north, π/2 = east)\r\n */\r\n public set yaw(yaw: number) {\r\n yaw !== this._yaw && this._setOrientation(yaw, this.pitch, this.radius, this.center);\r\n }\r\n\r\n private _pitch: number = 0;\r\n\r\n /**\r\n * Gets the camera's pitch (angle from looking straight at globe)\r\n * Pitch is measured from looking straight down at planet center:\r\n * - zero pitch = looking straight at planet center (down)\r\n * - positive pitch = tilting up away from planet\r\n * - π/2 pitch = looking at horizon (perpendicular to geocentric normal)\r\n */\r\n public get pitch(): number {\r\n return this._pitch;\r\n }\r\n\r\n /**\r\n * Sets the camera's pitch (angle from looking straight at globe). Will wrap value to [-π, π)\r\n * @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)\r\n */\r\n public set pitch(pitch: number) {\r\n pitch !== this._pitch && this._setOrientation(this.yaw, pitch, this.radius, this.center);\r\n }\r\n\r\n private _radius: number = 0;\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n /**\r\n * Sets the camera's distance from the current center point\r\n * @param radius The desired radius\r\n */\r\n public set radius(radius: number) {\r\n radius !== this._radius && this._setOrientation(this.yaw, this.pitch, radius, this.center);\r\n }\r\n\r\n protected _checkLimits() {\r\n const limits = this.limits;\r\n this._yaw = Clamp(this._yaw, limits.yawMin, limits.yawMax);\r\n this._pitch = Clamp(this._pitch, limits.pitchMin, limits.pitchMax);\r\n this._radius = Clamp(this._radius, limits.radiusMin, limits.radiusMax);\r\n this._center = ClampCenterFromPolesInPlace(this._center);\r\n }\r\n\r\n private _tempVect = new Vector3();\r\n private _tempEast = new Vector3();\r\n private _tempNorth = new Vector3();\r\n private _tempUp = new Vector3();\r\n\r\n private _setOrientation(yaw: number, pitch: number, radius: number, center: DeepImmutable<IVector3Like>): void {\r\n // Wrap yaw and pitch to [-π, π)\r\n this._yaw = NormalizeRadians(yaw);\r\n this._pitch = NormalizeRadians(pitch);\r\n this._radius = radius;\r\n\r\n Vector3CopyToRef(center, this._center);\r\n\r\n // Clamp to limits\r\n this._checkLimits();\r\n\r\n // Refresh local basis at center (treat these as read-only for the whole call)\r\n ComputeLocalBasisToRefs(this._center, this._tempEast, this._tempNorth, this._tempUp);\r\n\r\n // Trig\r\n const yawScale = this._scene.useRightHandedSystem ? 1 : -1;\r\n const cosYaw = Math.cos(this._yaw * yawScale);\r\n const sinYaw = Math.sin(this._yaw * yawScale);\r\n const sinPitch = Math.sin(this._pitch); // horizontal weight\r\n const cosPitch = Math.cos(this._pitch); // vertical weight (toward center)\r\n\r\n // Temps\r\n const horiz = TmpVectors.Vector3[0];\r\n const t1 = TmpVectors.Vector3[1];\r\n const t2 = TmpVectors.Vector3[2];\r\n const right = TmpVectors.Vector3[3];\r\n\r\n // horizontalDirection = North*cosYaw + East*sinYaw (avoids mutating _temp basis vectors)\r\n horiz.copyFrom(this._tempNorth).scaleInPlace(cosYaw).addInPlace(t1.copyFrom(this._tempEast).scaleInPlace(sinYaw));\r\n\r\n // look = horiz*sinPitch - Up*cosPitch\r\n this._lookAtVector.copyFrom(horiz).scaleInPlace(sinPitch).addInPlace(t2.copyFrom(this._tempUp).scaleInPlace(-cosPitch)).normalize(); // keep it unit\r\n\r\n // Build an orthonormal up aligned with geocentric Up\r\n // right = normalize(cross(upRef, look))\r\n Vector3.CrossToRef(this._tempUp, this._lookAtVector, right);\r\n\r\n // up = normalize(cross(look, right))\r\n Vector3.CrossToRef(this._lookAtVector, right, this.upVector);\r\n\r\n // Position = center - look * radius (preserve unit look)\r\n this._tempVect.copyFrom(this._lookAtVector).scaleInPlace(-this._radius);\r\n this._tempPosition.copyFrom(this._center).addInPlace(this._tempVect);\r\n\r\n this._position.copyFrom(this._tempPosition);\r\n\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */\r\n private get _geocentricRotationPt(): Vector3 {\r\n return this.movement.alternateRotationPt ?? this.center;\r\n }\r\n\r\n /**\r\n * If camera is actively in flight, will update the target properties and use up the remaining duration from original flyTo call\r\n *\r\n * To start a new flyTo curve entirely, call into flyToAsync again (it will stop the inflight animation)\r\n * @param targetYaw\r\n * @param targetPitch\r\n * @param targetRadius\r\n * @param targetCenter\r\n */\r\n public updateFlyToDestination(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3): void {\r\n this._flyToTargets.clear();\r\n\r\n this._flyToTargets.set(\"yaw\", targetYaw != undefined ? NormalizeRadians(targetYaw) : undefined);\r\n this._flyToTargets.set(\"pitch\", targetPitch != undefined ? NormalizeRadians(targetPitch) : undefined);\r\n this._flyToTargets.set(\"radius\", targetRadius);\r\n this._flyToTargets.set(\"center\", targetCenter);\r\n\r\n this._flyingBehavior.updateProperties(this._flyToTargets);\r\n }\r\n\r\n /**\r\n * Animate camera towards passed in property values. If undefined, will use current value\r\n * @param targetYaw\r\n * @param targetPitch\r\n * @param targetRadius\r\n * @param targetCenter\r\n * @param flightDurationMs\r\n * @param easingFunction\r\n * @param centerHopScale If supplied, will define the parabolic hop height scale for center animation to create a \"bounce\" effect\r\n * @returns Promise that will return when the animation is complete (or interuppted by pointer input)\r\n */\r\n public async flyToAsync(\r\n targetYaw?: number,\r\n targetPitch?: number,\r\n targetRadius?: number,\r\n targetCenter?: Vector3,\r\n flightDurationMs: number = 1000,\r\n easingFunction?: EasingFunction,\r\n centerHopScale?: number\r\n ): Promise<void> {\r\n this._flyToTargets.clear();\r\n\r\n this._flyToTargets.set(\"yaw\", targetYaw !== undefined ? NormalizeRadians(targetYaw) : undefined);\r\n this._flyToTargets.set(\"pitch\", targetPitch !== undefined ? NormalizeRadians(targetPitch) : undefined);\r\n this._flyToTargets.set(\"radius\", targetRadius);\r\n this._flyToTargets.set(\"center\", targetCenter);\r\n\r\n let overrideAnimationFunction;\r\n if (targetCenter !== undefined && !targetCenter.equals(this.center)) {\r\n // Animate center directly with custom interpolation\r\n const start = this.center.clone();\r\n const end = targetCenter.clone();\r\n\r\n overrideAnimationFunction = (key: string, animation: Animation): void => {\r\n if (key === \"center\") {\r\n // Override the Vector3 interpolation to use SLERP + hop\r\n animation.vector3InterpolateFunction = (startValue, endValue, gradient) => {\r\n // gradient is the eased value (0 to 1) after easing function is applied\r\n\r\n // Slerp between start and end\r\n const newCenter = Vector3.SlerpToRef(start, end, gradient, this._tempCenter);\r\n\r\n // Apply parabolic hop if requested\r\n if (centerHopScale && centerHopScale > 0) {\r\n // Parabolic formula: peaks at t=0.5, returns to 0 at gradient=0 and gradient=1\r\n // if hopPeakT = .5 the denominator would be hopPeakT * hopPeakT - hopPeakT, which = -.25\r\n const hopPeakOffset = centerHopScale * Vector3Distance(start, end);\r\n const hopOffset = hopPeakOffset * Clamp((gradient * gradient - gradient) / -0.25);\r\n // Scale the center outward (away from origin)\r\n newCenter.scaleInPlace(1 + hopOffset / newCenter.length());\r\n }\r\n\r\n return newCenter;\r\n };\r\n }\r\n };\r\n }\r\n\r\n return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction, overrideAnimationFunction);\r\n }\r\n\r\n /**\r\n * Helper function to move camera towards a given point by radiusScale% of radius (by default 50%)\r\n * @param destination point to move towards\r\n * @param radiusScale value between 0 and 1, % of radius to move\r\n * @param durationMs duration of flight, default 1s\r\n * @param easingFn optional easing function for flight interpolation of properties\r\n * @param overshootRadiusScale optional scale to apply to the current radius to achieve a 'hop' animation\r\n */\r\n public async flyToPointAsync(destination: Vector3, radiusScale: number = 0.5, durationMs: number = 1000, easingFn?: EasingFunction, overshootRadiusScale?: number) {\r\n // Zoom to radiusScale% of radius towards the given destination point\r\n const zoomDistance = this.radius * radiusScale;\r\n const newRadius = this._getCenterAndRadiusFromZoomToPoint(destination, zoomDistance, this._tempCenter);\r\n await this.flyToAsync(undefined, undefined, newRadius, this._tempCenter, durationMs, easingFn, overshootRadiusScale);\r\n }\r\n\r\n private _limits: GeospatialLimits;\r\n public get limits(): GeospatialLimits {\r\n return this._limits;\r\n }\r\n\r\n private _resetToDefault(limits: GeospatialLimits): void {\r\n // Camera configuration vars\r\n const maxCameraRadius = limits.altitudeMax !== undefined ? limits.planetRadius + limits.altitudeMax : undefined;\r\n const restingAltitude = maxCameraRadius ?? limits.planetRadius * 4;\r\n this.position.copyFromFloats(restingAltitude, 0, 0);\r\n this._center.copyFromFloats(limits.planetRadius, 0, 0);\r\n this._radius = Vector3.Distance(this.position, this.center);\r\n\r\n // Temp vars\r\n this._tempPosition = new Vector3();\r\n\r\n // View matrix calculation vars\r\n this._viewMatrix = Matrix.Identity();\r\n this._center.subtractToRef(this._position, this._lookAtVector).normalize(); // Lookat vector of the camera\r\n this.upVector = Vector3.Up(); // Up vector of the camera (does work for -X look at)\r\n this._isViewMatrixDirty = true;\r\n\r\n this._setOrientation(this._yaw, this._pitch, this._radius, this._center);\r\n }\r\n\r\n /** @internal */\r\n override _getViewMatrix() {\r\n if (!this._isViewMatrixDirty) {\r\n return this._viewMatrix;\r\n }\r\n this._isViewMatrixDirty = false;\r\n\r\n // Ensure vectors are normalized\r\n this.upVector.normalize();\r\n this._lookAtVector.normalize();\r\n\r\n // Calculate view matrix with camera position and center\r\n if (this.getScene().useRightHandedSystem) {\r\n Matrix.LookAtRHToRef(this.position, this._center, this.upVector, this._viewMatrix);\r\n } else {\r\n Matrix.LookAtLHToRef(this.position, this._center, this.upVector, this._viewMatrix);\r\n }\r\n\r\n return this._viewMatrix;\r\n }\r\n\r\n /** @internal */\r\n override _isSynchronizedViewMatrix(): boolean {\r\n if (!super._isSynchronizedViewMatrix() || this._isViewMatrixDirty) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n private _applyGeocentricTranslation() {\r\n // Store pending position (without any corrections applied)\r\n this.center.addToRef(this.movement.panDeltaCurrentFrame, this._tempPosition);\r\n\r\n if (!this.movement.isInterpolating) {\r\n // Calculate the position correction to keep camera at the same radius when applying translation\r\n this._tempPosition.normalize().scaleInPlace(this.center.length());\r\n }\r\n // Set center which will call _setOrientation\r\n this.center = this._tempPosition;\r\n }\r\n\r\n /**\r\n * 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\r\n */\r\n private _applyGeocentricRotation(): void {\r\n const rotationDeltaCurrentFrame = this.movement.rotationDeltaCurrentFrame;\r\n if (rotationDeltaCurrentFrame.x !== 0 || rotationDeltaCurrentFrame.y !== 0) {\r\n const pitch = rotationDeltaCurrentFrame.x !== 0 ? Clamp(this._pitch + rotationDeltaCurrentFrame.x, 0, 0.5 * Math.PI - Epsilon) : this._pitch;\r\n const yaw = rotationDeltaCurrentFrame.y !== 0 ? this._yaw + rotationDeltaCurrentFrame.y : this._yaw;\r\n\r\n // TODO: If _geocentricRotationPt is not the center, this will need to be adjusted.\r\n this._setOrientation(yaw, pitch, this._radius, this._geocentricRotationPt);\r\n }\r\n }\r\n\r\n private _getCenterAndRadiusFromZoomToPoint(targetPoint: Vector3, distance: number, newCenter: Vector3): number {\r\n // Clamp new radius to limits\r\n const requestedRadius = this._radius - distance;\r\n const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);\r\n const actualDistance = this._radius - newRadius;\r\n const actualRatio = actualDistance / this._radius;\r\n\r\n // Direction from current center to target point\r\n const directionToTarget = TmpVectors.Vector3[0];\r\n targetPoint.subtractToRef(this._center, directionToTarget);\r\n\r\n // Move center toward target by the ratio amount\r\n const centerOffset = TmpVectors.Vector3[1];\r\n directionToTarget.scaleToRef(actualRatio, centerOffset);\r\n\r\n // Calculate new center\r\n this._center.addToRef(centerOffset, newCenter);\r\n\r\n // Preserve center altitude (distance from planet origin)\r\n const currentCenterRadius = this._center.length();\r\n const newCenterRadius = newCenter.length();\r\n if (newCenterRadius > Epsilon) {\r\n newCenter.scaleInPlace(currentCenterRadius / newCenterRadius);\r\n }\r\n\r\n return newRadius;\r\n }\r\n\r\n /**\r\n * Apply zoom by moving the camera toward/away from a target point.\r\n */\r\n private _applyZoom() {\r\n const zoomDelta = this.movement.zoomDeltaCurrentFrame;\r\n const pickedPoint = this.movement.computedPerFrameZoomPickPoint;\r\n\r\n if (pickedPoint) {\r\n // Zoom toward the picked point under cursor\r\n this._zoomToPoint(pickedPoint, zoomDelta);\r\n } else {\r\n // Zoom along lookAt vector (fallback when no surface under cursor)\r\n this._zoomAlongLookAt(zoomDelta);\r\n }\r\n }\r\n\r\n private _zoomToPoint(targetPoint: Vector3, distance: number) {\r\n const newRadius = this._getCenterAndRadiusFromZoomToPoint(targetPoint, distance, this._tempCenter);\r\n // Apply the new orientation\r\n this._setOrientation(this._yaw, this._pitch, newRadius, this._tempCenter);\r\n }\r\n\r\n private _zoomAlongLookAt(distance: number) {\r\n // Clamp radius to limits\r\n const requestedRadius = this._radius - distance;\r\n const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);\r\n\r\n // Simply change radius without moving center\r\n this._setOrientation(this._yaw, this._pitch, newRadius, this._center);\r\n }\r\n\r\n override _checkInputs(): void {\r\n this.inputs.checkInputs();\r\n\r\n // Let movement class handle all per-frame logic\r\n this.movement.computeCurrentFrameDeltas();\r\n\r\n let recalculateCenter = false;\r\n if (this.movement.panDeltaCurrentFrame.lengthSquared() > 0) {\r\n this._applyGeocentricTranslation();\r\n recalculateCenter = true;\r\n }\r\n if (this.movement.rotationDeltaCurrentFrame.lengthSquared() > 0) {\r\n this._applyGeocentricRotation();\r\n }\r\n\r\n if (Math.abs(this.movement.zoomDeltaCurrentFrame) > Epsilon) {\r\n this._applyZoom();\r\n recalculateCenter = true;\r\n }\r\n\r\n // After a movement impacting center or radius, recalculate the center point to ensure it's still on the surface.\r\n recalculateCenter && this._recalculateCenter();\r\n\r\n super._checkInputs();\r\n }\r\n\r\n private _recalculateCenter() {\r\n // Wait until dragging is complete to avoid wasted raycasting\r\n if (!this.movement.isDragging) {\r\n const newCenter = this.movement.pickAlongVector(this._lookAtVector);\r\n if (newCenter?.pickedPoint) {\r\n // Direction from new center to origin\r\n const centerToOrigin = TmpVectors.Vector3[4];\r\n centerToOrigin.copyFrom(newCenter.pickedPoint).negateInPlace().normalize();\r\n\r\n // Check if this direction aligns with camera's lookAt vector\r\n const dotProduct = Vector3.Dot(this._lookAtVector, centerToOrigin);\r\n\r\n // Only update if the center is looking toward the origin (dot product > 0) to avoid a center on the opposite side of globe\r\n if (dotProduct > 0) {\r\n const newRadius = Vector3.Distance(this.position, newCenter.pickedPoint);\r\n this._setOrientation(this._yaw, this._pitch, newRadius, newCenter.pickedPoint);\r\n }\r\n }\r\n }\r\n }\r\n override attachControl(noPreventDefault?: boolean): void {\r\n this.inputs.attachElement(noPreventDefault);\r\n }\r\n\r\n override detachControl(): void {\r\n this.inputs.detachElement();\r\n }\r\n}\r\n"]}
@@ -5,6 +5,8 @@ import type { MeshPredicate } from "../Culling/ray.core.js";
5
5
  import type { Scene } from "../scene.js";
6
6
  import type { PickingInfo } from "../Collisions/pickingInfo.js";
7
7
  import type { Nullable } from "../types.js";
8
+ import type { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
9
+ import type { GeospatialCamera } from "./geospatialCamera.js";
8
10
  /**
9
11
  * @experimental
10
12
  * This class is subject to change as the geospatial camera evolves.
@@ -26,7 +28,8 @@ export declare class GeospatialCameraMovement extends CameraMovement {
26
28
  private _cameraLookAt;
27
29
  /** Predicate function to determine which meshes to pick against (e.g., globe mesh) */
28
30
  pickPredicate?: MeshPredicate;
29
- computedPerFrameZoomVector: Vector3;
31
+ /** World-space picked point under cursor for zoom-to-cursor behavior (may be undefined) */
32
+ computedPerFrameZoomPickPoint?: Vector3;
30
33
  zoomToCursor: boolean;
31
34
  /**
32
35
  * Enables rotation around a specific point, instead of default rotation around center
@@ -41,7 +44,7 @@ export declare class GeospatialCameraMovement extends CameraMovement {
41
44
  private _dragPlaneOriginPointEcef;
42
45
  private _dragPlaneHitPointLocal;
43
46
  private _previousDragPlaneHitPointLocal;
44
- constructor(scene: Scene, limits: GeospatialLimits, cameraPosition: Vector3, _cameraCenter: Vector3, _cameraLookAt: Vector3, pickPredicate?: MeshPredicate);
47
+ constructor(scene: Scene, limits: GeospatialLimits, cameraPosition: Vector3, _cameraCenter: Vector3, _cameraLookAt: Vector3, pickPredicate?: MeshPredicate, behavior?: InterpolatingBehavior<GeospatialCamera>);
45
48
  startDrag(pointerX: number, pointerY: number): void;
46
49
  stopDrag(): void;
47
50
  /**
@@ -55,6 +58,7 @@ export declare class GeospatialCameraMovement extends CameraMovement {
55
58
  handleDrag(pointerX: number, pointerY: number): void;
56
59
  /** @override */
57
60
  computeCurrentFrameDeltas(): void;
61
+ get isDragging(): boolean;
58
62
  private _handleZoom;
59
63
  private _clampZoomDistance;
60
64
  pickAlongVector(vector: Vector3): Nullable<PickingInfo>;
@@ -21,12 +21,11 @@ import { Clamp } from "../Maths/math.scalar.functions.js";
21
21
  * - Zoom direction calculation (towards cursor vs along look vector)
22
22
  */
23
23
  export class GeospatialCameraMovement extends CameraMovement {
24
- constructor(scene, limits, cameraPosition, _cameraCenter, _cameraLookAt, pickPredicate) {
25
- super(scene, cameraPosition);
24
+ constructor(scene, limits, cameraPosition, _cameraCenter, _cameraLookAt, pickPredicate, behavior) {
25
+ super(scene, cameraPosition, behavior);
26
26
  this.limits = limits;
27
27
  this._cameraCenter = _cameraCenter;
28
28
  this._cameraLookAt = _cameraLookAt;
29
- this.computedPerFrameZoomVector = new Vector3();
30
29
  this.zoomToCursor = true;
31
30
  this._hitPointRadius = undefined;
32
31
  this._dragPlane = new Plane(0, 0, 0, 0);
@@ -34,7 +33,6 @@ export class GeospatialCameraMovement extends CameraMovement {
34
33
  this._dragPlaneOriginPointEcef = Vector3.Zero();
35
34
  this._dragPlaneHitPointLocal = Vector3.Zero();
36
35
  this._previousDragPlaneHitPointLocal = Vector3.Zero();
37
- this.computedPerFrameZoomVector.copyFrom(this._cameraLookAt);
38
36
  this.pickPredicate = pickPredicate;
39
37
  this._tempPickingRay = new Ray(this._cameraPosition, this._cameraLookAt);
40
38
  this.panInertia = 0;
@@ -115,8 +113,7 @@ export class GeospatialCameraMovement extends CameraMovement {
115
113
  this._panSpeedMultiplier = 1;
116
114
  }
117
115
  // If a pan drag is occurring, stop zooming.
118
- const isDragging = this._hitPointRadius !== undefined;
119
- if (isDragging) {
116
+ if (this.isDragging) {
120
117
  this._zoomSpeedMultiplier = 0;
121
118
  this._zoomVelocity = 0;
122
119
  }
@@ -129,6 +126,9 @@ export class GeospatialCameraMovement extends CameraMovement {
129
126
  super.computeCurrentFrameDeltas();
130
127
  this._handleZoom(activeZoom);
131
128
  }
129
+ get isDragging() {
130
+ return this._hitPointRadius !== undefined;
131
+ }
132
132
  _handleZoom(activeZoom) {
133
133
  if (Math.abs(this.zoomDeltaCurrentFrame) > Epsilon) {
134
134
  let pickDistance;
@@ -141,17 +141,17 @@ export class GeospatialCameraMovement extends CameraMovement {
141
141
  // Active zoom - pick and store the distance
142
142
  const pickResult = this._scene.pick(this._scene.pointerX, this._scene.pointerY, this.pickPredicate);
143
143
  if (pickResult.hit && pickResult.pickedPoint && pickResult.ray && this.zoomToCursor) {
144
- // Store both the zoom direction and the pick distance for use during inertia
145
- pickResult.ray.direction.normalizeToRef(this.computedPerFrameZoomVector);
144
+ // Store both the zoom picked point and the pick distance for use during inertia
146
145
  pickDistance = pickResult.distance;
147
146
  this._storedZoomPickDistance = pickDistance;
147
+ this.computedPerFrameZoomPickPoint = pickResult.pickedPoint;
148
148
  }
149
149
  else {
150
150
  // If no hit under cursor, zoom along lookVector instead
151
- this._cameraLookAt.normalizeToRef(this.computedPerFrameZoomVector);
152
- const lookPickResult = this.pickAlongVector(this.computedPerFrameZoomVector);
151
+ const lookPickResult = this.pickAlongVector(this._cameraLookAt);
153
152
  pickDistance = lookPickResult?.distance;
154
153
  this._storedZoomPickDistance = pickDistance;
154
+ this.computedPerFrameZoomPickPoint = undefined;
155
155
  }
156
156
  }
157
157
  // Clamp distance based on limits and update center
@@ -185,7 +185,7 @@ export class GeospatialCameraMovement extends CameraMovement {
185
185
  }
186
186
  }
187
187
  export function ClampCenterFromPolesInPlace(center) {
188
- const sineOfSphericalLatitudeLimit = 0.9999; // ~89.95 degrees
188
+ const sineOfSphericalLatitudeLimit = 0.998749218; // ~90 degrees
189
189
  const centerMagnitude = center.length(); // distance from planet origin
190
190
  if (centerMagnitude > Epsilon) {
191
191
  const sineSphericalLat = centerMagnitude === 0 ? 0 : center.z / centerMagnitude;