@babylonjs/core 8.28.3 → 8.29.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 (162) hide show
  1. package/Buffers/buffer.d.ts +4 -3
  2. package/Buffers/buffer.js +4 -3
  3. package/Buffers/buffer.js.map +1 -1
  4. package/Cameras/Inputs/BaseCameraPointersInput.js +2 -0
  5. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  6. package/Cameras/Inputs/geospatialCameraMouseWheelInput.d.ts +18 -0
  7. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +21 -0
  8. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -0
  9. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +45 -0
  10. package/Cameras/Inputs/geospatialCameraPointersInput.js +119 -0
  11. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -0
  12. package/Cameras/Inputs/index.d.ts +2 -0
  13. package/Cameras/Inputs/index.js +2 -0
  14. package/Cameras/Inputs/index.js.map +1 -1
  15. package/Cameras/arcRotateCamera.js +7 -5
  16. package/Cameras/arcRotateCamera.js.map +1 -1
  17. package/Cameras/camera.d.ts +2 -2
  18. package/Cameras/camera.js +2 -2
  19. package/Cameras/camera.js.map +1 -1
  20. package/Cameras/geospatialCamera.d.ts +89 -0
  21. package/Cameras/geospatialCamera.js +268 -0
  22. package/Cameras/geospatialCamera.js.map +1 -0
  23. package/Cameras/geospatialCameraInputsManager.d.ts +23 -0
  24. package/Cameras/geospatialCameraInputsManager.js +33 -0
  25. package/Cameras/geospatialCameraInputsManager.js.map +1 -0
  26. package/Cameras/index.d.ts +1 -0
  27. package/Cameras/index.js +1 -0
  28. package/Cameras/index.js.map +1 -1
  29. package/Cameras/targetCamera.d.ts +12 -0
  30. package/Cameras/targetCamera.js +19 -5
  31. package/Cameras/targetCamera.js.map +1 -1
  32. package/Decorators/nodeDecorator.d.ts +7 -5
  33. package/Decorators/nodeDecorator.js +7 -5
  34. package/Decorators/nodeDecorator.js.map +1 -1
  35. package/Engines/abstractEngine.js +2 -2
  36. package/Engines/abstractEngine.js.map +1 -1
  37. package/Events/pointerEvents.d.ts +4 -0
  38. package/Events/pointerEvents.js.map +1 -1
  39. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
  40. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
  41. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
  42. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
  43. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
  44. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
  45. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
  46. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +19 -2
  47. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +72 -4
  48. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  49. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +3 -3
  50. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
  51. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +8 -3
  52. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +56 -34
  53. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  54. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +0 -12
  55. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +0 -45
  56. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
  57. package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.d.ts +7 -3
  58. package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +18 -32
  59. package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -1
  60. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +1 -1
  61. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  62. package/FrameGraph/Node/Blocks/index.js +1 -0
  63. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  64. package/FrameGraph/Node/nodeRenderGraph.js +2 -1
  65. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  66. package/FrameGraph/frameGraphTextureManager.d.ts +4 -0
  67. package/FrameGraph/frameGraphTextureManager.js +7 -1
  68. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  69. package/Layers/layerSceneComponent.js +3 -3
  70. package/Layers/layerSceneComponent.js.map +1 -1
  71. package/Lights/Clustered/clusteredLightContainer.d.ts +4 -1
  72. package/Lights/Clustered/clusteredLightContainer.js +17 -2
  73. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  74. package/Lights/index.d.ts +1 -0
  75. package/Lights/index.js +1 -0
  76. package/Lights/index.js.map +1 -1
  77. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
  78. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +4 -4
  79. package/Materials/Node/Blocks/conditionalBlock.js +1 -1
  80. package/Materials/Node/Blocks/curveBlock.js +1 -1
  81. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +1 -1
  82. package/Materials/Node/Blocks/trigonometryBlock.js +1 -1
  83. package/Materials/Node/Blocks/waveBlock.js +1 -1
  84. package/Materials/PBR/openPbrMaterial.d.ts +2 -0
  85. package/Materials/PBR/openPbrMaterial.js +9 -6
  86. package/Materials/PBR/openPbrMaterial.js.map +1 -1
  87. package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
  88. package/Materials/PBR/pbrBaseMaterial.js +2 -0
  89. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  90. package/Materials/Textures/renderTargetTexture.d.ts +2 -0
  91. package/Materials/Textures/renderTargetTexture.js +3 -0
  92. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  93. package/Materials/materialHelper.functions.js +1 -0
  94. package/Materials/materialHelper.functions.js.map +1 -1
  95. package/Materials/standardMaterial.d.ts +2 -0
  96. package/Materials/standardMaterial.js +2 -0
  97. package/Materials/standardMaterial.js.map +1 -1
  98. package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -1
  99. package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -1
  100. package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
  101. package/Meshes/Node/Blocks/conditionBlock.js +1 -1
  102. package/Meshes/Node/Blocks/geometryCurveBlock.js +1 -1
  103. package/Meshes/Node/Blocks/geometryEaseBlock.js +1 -1
  104. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +1 -1
  105. package/Meshes/Node/Blocks/mappingBlock.js +1 -1
  106. package/Meshes/Node/Blocks/mathBlock.js +1 -1
  107. package/Meshes/Node/Blocks/randomBlock.js +1 -1
  108. package/Meshes/geometry.js +26 -25
  109. package/Meshes/geometry.js.map +1 -1
  110. package/Misc/index.d.ts +1 -0
  111. package/Misc/index.js +1 -0
  112. package/Misc/index.js.map +1 -1
  113. package/Navigation/INavigationEngine.d.ts +17 -5
  114. package/Navigation/INavigationEngine.js.map +1 -1
  115. package/Navigation/Plugins/recastJSPlugin.d.ts +3 -2
  116. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  117. package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +1 -1
  118. package/Particles/Node/Blocks/particleLocalVariableBlock.js +1 -1
  119. package/Particles/Node/Blocks/particleMathBlock.js +1 -1
  120. package/Particles/Node/Blocks/particleRandomBlock.js +1 -1
  121. package/Particles/Node/Blocks/particleTrigonometryBlock.js +1 -1
  122. package/Particles/Node/Blocks/systemBlock.js +1 -1
  123. package/Particles/gpuParticleSystem.js +1 -0
  124. package/Particles/gpuParticleSystem.js.map +1 -1
  125. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +4 -0
  126. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +10 -1
  127. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  128. package/PostProcesses/motionBlurPostProcess.d.ts +3 -1
  129. package/PostProcesses/motionBlurPostProcess.js +13 -4
  130. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  131. package/Rendering/geometryBufferRenderer.js +58 -0
  132. package/Rendering/geometryBufferRenderer.js.map +1 -1
  133. package/Rendering/objectRenderer.d.ts +2 -0
  134. package/Rendering/objectRenderer.js +13 -0
  135. package/Rendering/objectRenderer.js.map +1 -1
  136. package/Shaders/ShadersInclude/lightFragment.js +1 -1
  137. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  138. package/Shaders/geometry.fragment.js +14 -0
  139. package/Shaders/geometry.fragment.js.map +1 -1
  140. package/Shaders/geometry.vertex.js +20 -0
  141. package/Shaders/geometry.vertex.js.map +1 -1
  142. package/Shaders/openpbr.vertex.js +1 -1
  143. package/Shaders/openpbr.vertex.js.map +1 -1
  144. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +1 -1
  145. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  146. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
  147. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  148. package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +1 -1
  149. package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
  150. package/ShadersWGSL/default.fragment.js +1 -1
  151. package/ShadersWGSL/default.fragment.js.map +1 -1
  152. package/ShadersWGSL/default.vertex.js +2 -2
  153. package/ShadersWGSL/default.vertex.js.map +1 -1
  154. package/ShadersWGSL/geometry.fragment.js +14 -0
  155. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  156. package/ShadersWGSL/geometry.vertex.js +20 -0
  157. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  158. package/ShadersWGSL/openpbr.vertex.js +1 -1
  159. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  160. package/ShadersWGSL/pbr.vertex.js +2 -2
  161. package/ShadersWGSL/pbr.vertex.js.map +1 -1
  162. package/package.json +1 -1
@@ -0,0 +1,268 @@
1
+ import { GeospatialCameraInputsManager } from "./geospatialCameraInputsManager.js";
2
+ import { Vector3, Matrix, TmpVectors } from "../Maths/math.vector.js";
3
+ import { Epsilon } from "../Maths/math.constants.js";
4
+ import { Scalar } from "../Maths/math.scalar.js";
5
+ import { Camera } from "./camera.js";
6
+ import { Ray } from "../Culling/ray.js";
7
+ /**
8
+ * @experimental
9
+ * 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
10
+ *
11
+ * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag
12
+ *
13
+ * Still TODO:
14
+ * - Pitch/yaw limits, input speeds
15
+ * - ZoomToPoint
16
+ * - Conversion between lat/long/alt and cartesian coordinates
17
+ */
18
+ export class GeospatialCamera extends Camera {
19
+ /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/
20
+ get center() {
21
+ // NOTE that for now we are falling back to target if no pick on globe (because that shouldn't happen with current implemented inputs)
22
+ // but eventually we want to return a point on the globe even if the camera is looking off into space
23
+ return this._pickAlongLook?.pickedPoint ?? this._target;
24
+ }
25
+ /** Target of camera when looking along lookAtVector from current position. This does not necessarily represent a point on the globe */
26
+ get _target() {
27
+ return this.position.addToRef(this._lookAtVector, this._tempPosition);
28
+ }
29
+ /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */
30
+ get _geocentricRotationPt() {
31
+ return this._alternateRotationPt ?? this.center;
32
+ }
33
+ constructor(name, scene, options, pickPredicate) {
34
+ super(name, Vector3.Zero(), scene);
35
+ this._resetToDefault(options);
36
+ this.pickPredicate = pickPredicate;
37
+ this.inputs = new GeospatialCameraInputsManager(this);
38
+ this.inputs.addMouse().addMouseWheel();
39
+ }
40
+ _resetToDefault(options) {
41
+ // Camera configuration vars
42
+ this._minAltitude = options.minAltitude ?? 5;
43
+ this._maxAltitude = options.maxAltitude;
44
+ this._planetRadius = options.planetRadius;
45
+ this._maxCameraRadius = this._maxAltitude ? this._planetRadius + this._maxAltitude : undefined;
46
+ this._restingAltitude = options.restingAltitude ?? this._maxCameraRadius ?? this._planetRadius * 4;
47
+ this.position.copyFromFloats(0, 0, -this._restingAltitude);
48
+ // Input vars
49
+ this._perFrameGeocentricRotation = Vector3.Zero();
50
+ this._perFrameGeocentricTranslation = Vector3.Zero();
51
+ this._perFrameZoom = 0;
52
+ // Temp vars
53
+ this._tempPosition = Vector3.Zero();
54
+ this._tempRotationAxis = Vector3.Right(); // starting axis used to calculate pitch rotation matrix
55
+ this._tempRotationMatrix = Matrix.Identity();
56
+ this._tempGeocentricNormal = Vector3.Zero();
57
+ this._tempPickingRay = new Ray(this.position, this._lookAtVector);
58
+ this._tempPickingRay.direction = Vector3.Zero();
59
+ // View matrix calculation vars
60
+ this.upVector = Vector3.Up(); // Up vector of the camera
61
+ this._lookAtVector = this.position.negate().normalize(); // Lookat vector of the camera
62
+ this._viewMatrix = Matrix.Identity();
63
+ this._isViewMatrixDirty = true;
64
+ }
65
+ /** @internal */
66
+ _getViewMatrix() {
67
+ if (!this._isViewMatrixDirty) {
68
+ return this._viewMatrix;
69
+ }
70
+ this._isViewMatrixDirty = false;
71
+ // Ensure vectors are normalized
72
+ this.upVector.normalize();
73
+ this._lookAtVector.normalize();
74
+ // Calculate view matrix with camera position and target
75
+ if (this.getScene().useRightHandedSystem) {
76
+ Matrix.LookAtRHToRef(this.position, this._target, this.upVector, this._viewMatrix);
77
+ }
78
+ else {
79
+ Matrix.LookAtLHToRef(this.position, this._target, this.upVector, this._viewMatrix);
80
+ }
81
+ return this._viewMatrix;
82
+ }
83
+ /** @internal */
84
+ _isSynchronizedViewMatrix() {
85
+ if (!super._isSynchronizedViewMatrix() || this._isViewMatrixDirty) {
86
+ return false;
87
+ }
88
+ return true;
89
+ }
90
+ /**
91
+ * Applies rotation correction to the camera by calculating a changeOfBasis matrix from the camera's current position to the new position
92
+ * and transforming the lookAt and up vectors by that matrix before updating the camera position and marking the view matrix as dirty
93
+ * @param newPos The camera's desired position, before correction is applied
94
+ */
95
+ _applyRotationCorrectionAndSetPos(newPos) {
96
+ // Compute changeOfBasis between current camera position and new position
97
+ ComputeChangeOfBasisToRef(this.position, newPos, this._tempRotationMatrix);
98
+ // Apply rotation correction to lookat/up vectors
99
+ Vector3.TransformNormalToRef(this._lookAtVector, this._tempRotationMatrix, this._lookAtVector);
100
+ Vector3.TransformNormalToRef(this.upVector, this._tempRotationMatrix, this.upVector);
101
+ // Apply position change and mark viewMatrix as dirty
102
+ this.position.copyFrom(newPos);
103
+ this._isViewMatrixDirty = true;
104
+ }
105
+ /**
106
+ * When the geocentric normal has any translation change (due to dragging), we must ensure the camera remains orbiting around the world origin
107
+ * We thus need to perform 2 correction steps
108
+ * 1. Translation correction that keeps the camera at the same radius as before the drag
109
+ * 2. Rotation correction that keeps the camera facing the globe (so that as we pan, the globe stays centered on screen)
110
+ */
111
+ _applyGeocentricTranslation() {
112
+ // Store pending position (without any corrections applied)
113
+ this.position.addToRef(this._perFrameGeocentricTranslation, this._tempPosition);
114
+ // 1. Calculate the altitude correction to keep camera at the same radius when applying translation
115
+ const tempPositionScaled = TmpVectors.Vector3[2];
116
+ const offset = TmpVectors.Vector3[3];
117
+ this._tempPosition.normalizeToRef(tempPositionScaled).scaleInPlace(this.position.length()); // what would tempPosition be if it were scaled to same radius as before
118
+ this._tempPosition.subtractToRef(tempPositionScaled, offset); // find offset between tempPosition and the tempScaledPosition
119
+ this._tempPosition.subtractInPlace(offset); // reduce tempPosition by that offset
120
+ // 2. Calculate the rotation correction to keep camera facing globe
121
+ this._applyRotationCorrectionAndSetPos(this._tempPosition);
122
+ }
123
+ /**
124
+ * 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
125
+ */
126
+ _applyGeocentricRotation() {
127
+ // Normalize key vectors
128
+ this._geocentricRotationPt.normalizeToRef(this._tempGeocentricNormal);
129
+ this.upVector.normalize();
130
+ this._lookAtVector.normalize();
131
+ const pitchRotationMatrix = Matrix.Identity();
132
+ const yawRotationMatrix = Matrix.Identity();
133
+ // First apply pitch
134
+ if (this._perFrameGeocentricRotation.x !== 0) {
135
+ // Compute a rotation axis that is perpendicular to both the upVector and the geocentricNormalOfPitchPoint
136
+ Vector3.CrossToRef(this.upVector, this._tempGeocentricNormal, this._tempRotationAxis);
137
+ // If upVector and geocentricNormalOfPitchPoint are parallel, fall back to cross(lookAtDirection, geocentricNormalOfPitchPoint)
138
+ if (this._tempRotationAxis.lengthSquared() <= Epsilon) {
139
+ Vector3.CrossToRef(this._lookAtVector, this._tempGeocentricNormal, this._tempRotationAxis);
140
+ }
141
+ const pitchSign = Math.sign(Vector3.Dot(this._tempGeocentricNormal, this.upVector)); // If negative, camera is upside down
142
+ // Since these are pointed in opposite directions, we must negate the dot product to get the proper angle
143
+ const currentPitch = pitchSign * Math.acos(Scalar.Clamp(-Vector3.Dot(this._lookAtVector, this._tempGeocentricNormal), -1, 1));
144
+ const newPitch = Scalar.Clamp(currentPitch + this._perFrameGeocentricRotation.x, 0, 0.5 * Math.PI - Epsilon);
145
+ // Build rotation matrix around normalized axis
146
+ Matrix.RotationAxisToRef(this._tempRotationAxis.normalize(), newPitch - currentPitch, pitchRotationMatrix);
147
+ }
148
+ // Then apply yaw
149
+ if (this._perFrameGeocentricRotation.y !== 0) {
150
+ Matrix.RotationAxisToRef(this._tempGeocentricNormal, this._perFrameGeocentricRotation.y, yawRotationMatrix); // this axis changes if we aren't using center of screen for tilt
151
+ }
152
+ pitchRotationMatrix.multiplyToRef(yawRotationMatrix, this._tempRotationMatrix);
153
+ // Offset camera to be (position-pitchPoint) distance from geocentricOrigin, apply rotation to position/up/lookat vectors, then add back the pitchPoint offset
154
+ this.position.subtractInPlace(this._geocentricRotationPt);
155
+ Vector3.TransformCoordinatesToRef(this.position, this._tempRotationMatrix, this.position);
156
+ Vector3.TransformNormalToRef(this.upVector, this._tempRotationMatrix, this.upVector);
157
+ Vector3.TransformNormalToRef(this._lookAtVector, this._tempRotationMatrix, this._lookAtVector);
158
+ this.position.addInPlace(this._geocentricRotationPt);
159
+ }
160
+ _clampZoomDistance(requestedDistance, pickResultDistance) {
161
+ // If pickResult is defined
162
+ if (requestedDistance > 0) {
163
+ if (pickResultDistance !== undefined) {
164
+ // If there is a pick, allow movement up to pick - minAltitude
165
+ if (pickResultDistance - this._minAltitude < 0) {
166
+ return 0;
167
+ }
168
+ return Math.min(requestedDistance, pickResultDistance - this._minAltitude);
169
+ }
170
+ else {
171
+ return requestedDistance;
172
+ }
173
+ }
174
+ if (requestedDistance < 0) {
175
+ const maxZoomOut = this._maxCameraRadius ? this._maxCameraRadius - this.position.length() : Number.POSITIVE_INFINITY;
176
+ return Math.max(requestedDistance, -maxZoomOut);
177
+ }
178
+ return 0;
179
+ }
180
+ _applyZoom(distance) {
181
+ const pickResult = this._scene.pick(this._scene.pointerX, this._scene.pointerY, this.pickPredicate);
182
+ if (pickResult.hit && pickResult.ray) {
183
+ // Zoom to cursor
184
+ this._moveCameraAlongVectorByDistance(pickResult.ray.direction, this._clampZoomDistance(distance, pickResult.distance));
185
+ }
186
+ else {
187
+ // If no hit under cursor, zoom along lookVector instead
188
+ this._moveCameraAlongVectorByDistance(this._lookAtVector, this._clampZoomDistance(distance, this._pickAlongLook?.distance));
189
+ }
190
+ }
191
+ _moveCameraAlongVectorByDistance(vector, distance) {
192
+ if (distance) {
193
+ vector.scaleAndAddToRef(distance, this._tempPosition);
194
+ this._applyRotationCorrectionAndSetPos(this._tempPosition);
195
+ }
196
+ }
197
+ get _pickAlongLook() {
198
+ this._tempPickingRay.origin.copyFrom(this.position);
199
+ this._tempPickingRay.direction.copyFrom(this._lookAtVector);
200
+ return this._scene.pickWithRay(this._tempPickingRay, this.pickPredicate);
201
+ }
202
+ _checkInputs() {
203
+ this.inputs.checkInputs();
204
+ if (this._perFrameGeocentricTranslation.lengthSquared() > 0) {
205
+ this._applyGeocentricTranslation();
206
+ this._perFrameGeocentricTranslation.setAll(0);
207
+ this._isViewMatrixDirty = true;
208
+ }
209
+ if (this._perFrameGeocentricRotation.lengthSquared() > 0) {
210
+ this._applyGeocentricRotation();
211
+ this._perFrameGeocentricRotation.setAll(0);
212
+ this._isViewMatrixDirty = true;
213
+ }
214
+ if (this._perFrameZoom !== 0) {
215
+ this._applyZoom(this._perFrameZoom);
216
+ this._perFrameZoom = 0;
217
+ this._isViewMatrixDirty = true;
218
+ }
219
+ super._checkInputs();
220
+ }
221
+ attachControl(noPreventDefault) {
222
+ this.inputs.attachElement(noPreventDefault);
223
+ }
224
+ detachControl() {
225
+ this.inputs.detachElement();
226
+ }
227
+ }
228
+ // Helper to build east/north/up basis vectors at a world position
229
+ function ComputeLocalBasisToRefs(worldPos, refEast, refNorth, refUp) {
230
+ // up = normalized position (geocentric normal)
231
+ refUp.copyFrom(worldPos).normalize();
232
+ // east = normalize(up × worldUp)
233
+ // (cross product of up with world Y gives east except at poles)
234
+ const worldUp = Vector3.Up(); // (0,1,0)
235
+ Vector3.CrossToRef(refUp, worldUp, refEast);
236
+ // at poles, cross with worldForward instead
237
+ if (refEast.lengthSquared() < Epsilon) {
238
+ Vector3.CrossToRef(refUp, Vector3.Forward(), refEast);
239
+ }
240
+ refEast.normalize();
241
+ // north = up × east (completes right-handed basis)
242
+ Vector3.CrossToRef(refUp, refEast, refNorth);
243
+ refNorth.normalize();
244
+ }
245
+ /**
246
+ * Calculates changeOfBasis matrix from currentPos to newPos and stores it in ref
247
+ * @param currentPos
248
+ * @param newPos
249
+ * @param ref
250
+ * @returns The changeOfBasis matrix from currentPos to newPos
251
+ */
252
+ function ComputeChangeOfBasisToRef(currentPos, newPos, ref) {
253
+ const currentBasis = TmpVectors.Matrix[5];
254
+ const newBasis = TmpVectors.Matrix[6];
255
+ const inverse = TmpVectors.Matrix[7];
256
+ const east = TmpVectors.Vector3[3];
257
+ const north = TmpVectors.Vector3[4];
258
+ const up = TmpVectors.Vector3[5];
259
+ ComputeLocalBasisToRefs(currentPos, east, north, up);
260
+ Matrix.FromXYZAxesToRef(east, north, up, currentBasis);
261
+ ComputeLocalBasisToRefs(newPos, east, north, up);
262
+ Matrix.FromXYZAxesToRef(east, north, up, newBasis);
263
+ // Change of basis matrix = basis2 * basis1.inverse()
264
+ // (since orthonormal, inverse = transpose)
265
+ currentBasis.transposeToRef(inverse).multiplyToRef(newBasis, ref);
266
+ return ref;
267
+ }
268
+ //# sourceMappingURL=geospatialCamera.js.map
@@ -0,0 +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,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAYrC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IAoBxC,+IAA+I;IAC/I,IAAW,MAAM;QACb,sIAAsI;QACtI,qGAAqG;QACrG,OAAO,IAAI,CAAC,cAAc,EAAE,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC;IAC5D,CAAC;IAoBD,uIAAuI;IACvI,IAAY,OAAO;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,QA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import { GeospatialCameraInputsManager } from \"./geospatialCameraInputsManager\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\nimport { Camera } from \"./camera\";\r\nimport { Ray } from \"../Culling/ray\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { MeshPredicate } from \"../Culling/ray.core\";\r\nimport type { Nullable } from \"../types\";\r\n\r\ntype CameraOptions = {\r\n planetRadius: number; // Radius of the planet\r\n minAltitude?: number; // Minimum altitude of the camera above the planet surface\r\n maxAltitude?: number; // Maximum altitude of the camera above the planet surface\r\n restingAltitude?: number; // The altitude the camera will return to when not being actively zoomed in or out\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\n * Still TODO:\r\n * - Pitch/yaw limits, input speeds\r\n * - ZoomToPoint\r\n * - Conversion between lat/long/alt and cartesian coordinates\r\n */\r\nexport class GeospatialCamera extends Camera {\r\n override inputs: GeospatialCameraInputsManager;\r\n\r\n // Changed by the inputs, reset on every frame\r\n /** @internal */\r\n public _perFrameGeocentricTranslation: Vector3; // Translation that keeps camera at the same radius from the center of the globe\r\n /** @internal */\r\n public _perFrameGeocentricRotation: Vector3; // Rotation around center (distinct from rotation around camera that can cause looking off into space)\r\n /** @internal */\r\n public _perFrameZoom: number;\r\n\r\n /** If supplied, will be used when picking the globe */\r\n public pickPredicate?: MeshPredicate;\r\n\r\n /**\r\n * Enables rotation around a specific point, instead of default rotation around center\r\n * @internal\r\n */\r\n public _alternateRotationPt: Nullable<Vector3>;\r\n\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 // NOTE that for now we are falling back to target if no pick on globe (because that shouldn't happen with current implemented inputs)\r\n // but eventually we want to return a point on the globe even if the camera is looking off into space\r\n return this._pickAlongLook?.pickedPoint ?? this._target;\r\n }\r\n\r\n // Temp vars\r\n private _tempGeocentricNormal: Vector3;\r\n private _tempRotationAxis: Vector3;\r\n private _tempRotationMatrix: Matrix;\r\n private _tempPickingRay: Ray;\r\n private _tempPosition: Vector3;\r\n\r\n private _viewMatrix: Matrix;\r\n private _isViewMatrixDirty: boolean;\r\n private _lookAtVector: Vector3;\r\n\r\n // Camera configuration vars\r\n private _planetRadius: number;\r\n private _minAltitude: number;\r\n private _maxAltitude?: number;\r\n private _maxCameraRadius?: number;\r\n private _restingAltitude: number;\r\n\r\n /** Target of camera when looking along lookAtVector from current position. This does not necessarily represent a point on the globe */\r\n private get _target(): Vector3 {\r\n return this.position.addToRef(this._lookAtVector, this._tempPosition);\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._alternateRotationPt ?? this.center;\r\n }\r\n\r\n constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate) {\r\n super(name, Vector3.Zero(), scene);\r\n this._resetToDefault(options);\r\n this.pickPredicate = pickPredicate;\r\n this.inputs = new GeospatialCameraInputsManager(this);\r\n this.inputs.addMouse().addMouseWheel();\r\n }\r\n\r\n private _resetToDefault(options: CameraOptions): void {\r\n // Camera configuration vars\r\n this._minAltitude = options.minAltitude ?? 5;\r\n this._maxAltitude = options.maxAltitude;\r\n this._planetRadius = options.planetRadius;\r\n this._maxCameraRadius = this._maxAltitude ? this._planetRadius + this._maxAltitude : undefined;\r\n this._restingAltitude = options.restingAltitude ?? this._maxCameraRadius ?? this._planetRadius * 4;\r\n this.position.copyFromFloats(0, 0, -this._restingAltitude);\r\n\r\n // Input vars\r\n this._perFrameGeocentricRotation = Vector3.Zero();\r\n this._perFrameGeocentricTranslation = Vector3.Zero();\r\n this._perFrameZoom = 0;\r\n\r\n // Temp vars\r\n this._tempPosition = Vector3.Zero();\r\n this._tempRotationAxis = Vector3.Right(); // starting axis used to calculate pitch rotation matrix\r\n this._tempRotationMatrix = Matrix.Identity();\r\n this._tempGeocentricNormal = Vector3.Zero();\r\n this._tempPickingRay = new Ray(this.position, this._lookAtVector);\r\n this._tempPickingRay.direction = Vector3.Zero();\r\n\r\n // View matrix calculation vars\r\n this.upVector = Vector3.Up(); // Up vector of the camera\r\n this._lookAtVector = this.position.negate().normalize(); // Lookat vector of the camera\r\n this._viewMatrix = Matrix.Identity();\r\n this._isViewMatrixDirty = true;\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 target\r\n if (this.getScene().useRightHandedSystem) {\r\n Matrix.LookAtRHToRef(this.position, this._target, this.upVector, this._viewMatrix);\r\n } else {\r\n Matrix.LookAtLHToRef(this.position, this._target, 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 /**\r\n * Applies rotation correction to the camera by calculating a changeOfBasis matrix from the camera's current position to the new position\r\n * and transforming the lookAt and up vectors by that matrix before updating the camera position and marking the view matrix as dirty\r\n * @param newPos The camera's desired position, before correction is applied\r\n */\r\n private _applyRotationCorrectionAndSetPos(newPos: Vector3): void {\r\n // Compute changeOfBasis between current camera position and new position\r\n ComputeChangeOfBasisToRef(this.position, newPos, this._tempRotationMatrix);\r\n\r\n // Apply rotation correction to lookat/up vectors\r\n Vector3.TransformNormalToRef(this._lookAtVector, this._tempRotationMatrix, this._lookAtVector);\r\n Vector3.TransformNormalToRef(this.upVector, this._tempRotationMatrix, this.upVector);\r\n\r\n // Apply position change and mark viewMatrix as dirty\r\n this.position.copyFrom(newPos);\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n /**\r\n * When the geocentric normal has any translation change (due to dragging), we must ensure the camera remains orbiting around the world origin\r\n * We thus need to perform 2 correction steps\r\n * 1. Translation correction that keeps the camera at the same radius as before the drag\r\n * 2. Rotation correction that keeps the camera facing the globe (so that as we pan, the globe stays centered on screen)\r\n */\r\n private _applyGeocentricTranslation() {\r\n // Store pending position (without any corrections applied)\r\n this.position.addToRef(this._perFrameGeocentricTranslation, this._tempPosition);\r\n\r\n // 1. Calculate the altitude correction to keep camera at the same radius when applying translation\r\n const tempPositionScaled = TmpVectors.Vector3[2];\r\n const offset = TmpVectors.Vector3[3];\r\n this._tempPosition.normalizeToRef(tempPositionScaled).scaleInPlace(this.position.length()); // what would tempPosition be if it were scaled to same radius as before\r\n this._tempPosition.subtractToRef(tempPositionScaled, offset); // find offset between tempPosition and the tempScaledPosition\r\n this._tempPosition.subtractInPlace(offset); // reduce tempPosition by that offset\r\n\r\n // 2. Calculate the rotation correction to keep camera facing globe\r\n this._applyRotationCorrectionAndSetPos(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 // Normalize key vectors\r\n this._geocentricRotationPt.normalizeToRef(this._tempGeocentricNormal);\r\n this.upVector.normalize();\r\n this._lookAtVector.normalize();\r\n\r\n const pitchRotationMatrix = Matrix.Identity();\r\n const yawRotationMatrix = Matrix.Identity();\r\n // First apply pitch\r\n if (this._perFrameGeocentricRotation.x !== 0) {\r\n // Compute a rotation axis that is perpendicular to both the upVector and the geocentricNormalOfPitchPoint\r\n Vector3.CrossToRef(this.upVector, this._tempGeocentricNormal, this._tempRotationAxis);\r\n\r\n // If upVector and geocentricNormalOfPitchPoint are parallel, fall back to cross(lookAtDirection, geocentricNormalOfPitchPoint)\r\n if (this._tempRotationAxis.lengthSquared() <= Epsilon) {\r\n Vector3.CrossToRef(this._lookAtVector, this._tempGeocentricNormal, this._tempRotationAxis);\r\n }\r\n\r\n const pitchSign = Math.sign(Vector3.Dot(this._tempGeocentricNormal, this.upVector)); // If negative, camera is upside down\r\n // Since these are pointed in opposite directions, we must negate the dot product to get the proper angle\r\n const currentPitch = pitchSign * Math.acos(Scalar.Clamp(-Vector3.Dot(this._lookAtVector, this._tempGeocentricNormal), -1, 1));\r\n const newPitch = Scalar.Clamp(currentPitch + this._perFrameGeocentricRotation.x, 0, 0.5 * Math.PI - Epsilon);\r\n // Build rotation matrix around normalized axis\r\n Matrix.RotationAxisToRef(this._tempRotationAxis.normalize(), newPitch - currentPitch, pitchRotationMatrix);\r\n }\r\n\r\n // Then apply yaw\r\n if (this._perFrameGeocentricRotation.y !== 0) {\r\n Matrix.RotationAxisToRef(this._tempGeocentricNormal, this._perFrameGeocentricRotation.y, yawRotationMatrix); // this axis changes if we aren't using center of screen for tilt\r\n }\r\n pitchRotationMatrix.multiplyToRef(yawRotationMatrix, this._tempRotationMatrix);\r\n\r\n // Offset camera to be (position-pitchPoint) distance from geocentricOrigin, apply rotation to position/up/lookat vectors, then add back the pitchPoint offset\r\n this.position.subtractInPlace(this._geocentricRotationPt);\r\n\r\n Vector3.TransformCoordinatesToRef(this.position, this._tempRotationMatrix, this.position);\r\n Vector3.TransformNormalToRef(this.upVector, this._tempRotationMatrix, this.upVector);\r\n Vector3.TransformNormalToRef(this._lookAtVector, this._tempRotationMatrix, this._lookAtVector);\r\n\r\n this.position.addInPlace(this._geocentricRotationPt);\r\n }\r\n\r\n private _clampZoomDistance(requestedDistance: number, pickResultDistance: number | undefined): number {\r\n // If pickResult is defined\r\n if (requestedDistance > 0) {\r\n if (pickResultDistance !== undefined) {\r\n // If there is a pick, allow movement up to pick - minAltitude\r\n if (pickResultDistance - this._minAltitude < 0) {\r\n return 0;\r\n }\r\n return Math.min(requestedDistance, pickResultDistance - this._minAltitude);\r\n } else {\r\n return requestedDistance;\r\n }\r\n }\r\n\r\n if (requestedDistance < 0) {\r\n const maxZoomOut = this._maxCameraRadius ? this._maxCameraRadius - this.position.length() : Number.POSITIVE_INFINITY;\r\n return Math.max(requestedDistance, -maxZoomOut);\r\n }\r\n return 0;\r\n }\r\n\r\n private _applyZoom(distance: number) {\r\n const pickResult = this._scene.pick(this._scene.pointerX, this._scene.pointerY, this.pickPredicate);\r\n if (pickResult.hit && pickResult.ray) {\r\n // Zoom to cursor\r\n this._moveCameraAlongVectorByDistance(pickResult.ray.direction, this._clampZoomDistance(distance, pickResult.distance));\r\n } else {\r\n // If no hit under cursor, zoom along lookVector instead\r\n this._moveCameraAlongVectorByDistance(this._lookAtVector, this._clampZoomDistance(distance, this._pickAlongLook?.distance));\r\n }\r\n }\r\n\r\n private _moveCameraAlongVectorByDistance(vector: Vector3, distance: number) {\r\n if (distance) {\r\n vector.scaleAndAddToRef(distance, this._tempPosition);\r\n this._applyRotationCorrectionAndSetPos(this._tempPosition);\r\n }\r\n }\r\n\r\n private get _pickAlongLook() {\r\n this._tempPickingRay.origin.copyFrom(this.position);\r\n this._tempPickingRay.direction.copyFrom(this._lookAtVector);\r\n return this._scene.pickWithRay(this._tempPickingRay, this.pickPredicate);\r\n }\r\n\r\n override _checkInputs(): void {\r\n this.inputs.checkInputs();\r\n if (this._perFrameGeocentricTranslation.lengthSquared() > 0) {\r\n this._applyGeocentricTranslation();\r\n this._perFrameGeocentricTranslation.setAll(0);\r\n this._isViewMatrixDirty = true;\r\n }\r\n if (this._perFrameGeocentricRotation.lengthSquared() > 0) {\r\n this._applyGeocentricRotation();\r\n this._perFrameGeocentricRotation.setAll(0);\r\n this._isViewMatrixDirty = true;\r\n }\r\n if (this._perFrameZoom !== 0) {\r\n this._applyZoom(this._perFrameZoom);\r\n this._perFrameZoom = 0;\r\n this._isViewMatrixDirty = true;\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\r\n// Helper to build east/north/up basis vectors at a world position\r\nfunction ComputeLocalBasisToRefs(worldPos: Vector3, refEast: Vector3, refNorth: Vector3, refUp: Vector3) {\r\n // up = normalized position (geocentric normal)\r\n refUp.copyFrom(worldPos).normalize();\r\n\r\n // east = normalize(up × worldUp)\r\n // (cross product of up with world Y gives east except at poles)\r\n const worldUp = Vector3.Up(); // (0,1,0)\r\n Vector3.CrossToRef(refUp, worldUp, refEast);\r\n\r\n // at poles, cross with worldForward instead\r\n if (refEast.lengthSquared() < Epsilon) {\r\n Vector3.CrossToRef(refUp, Vector3.Forward(), refEast);\r\n }\r\n refEast.normalize();\r\n\r\n // north = up × east (completes right-handed basis)\r\n Vector3.CrossToRef(refUp, refEast, refNorth);\r\n refNorth.normalize();\r\n}\r\n\r\n/**\r\n * Calculates changeOfBasis matrix from currentPos to newPos and stores it in ref\r\n * @param currentPos\r\n * @param newPos\r\n * @param ref\r\n * @returns The changeOfBasis matrix from currentPos to newPos\r\n */\r\nfunction ComputeChangeOfBasisToRef(currentPos: Vector3, newPos: Vector3, ref: Matrix): Matrix {\r\n const currentBasis = TmpVectors.Matrix[5];\r\n const newBasis = TmpVectors.Matrix[6];\r\n const inverse = TmpVectors.Matrix[7];\r\n const east = TmpVectors.Vector3[3];\r\n const north = TmpVectors.Vector3[4];\r\n const up = TmpVectors.Vector3[5];\r\n\r\n ComputeLocalBasisToRefs(currentPos, east, north, up);\r\n Matrix.FromXYZAxesToRef(east, north, up, currentBasis);\r\n\r\n ComputeLocalBasisToRefs(newPos, east, north, up);\r\n Matrix.FromXYZAxesToRef(east, north, up, newBasis);\r\n\r\n // Change of basis matrix = basis2 * basis1.inverse()\r\n // (since orthonormal, inverse = transpose)\r\n currentBasis.transposeToRef(inverse).multiplyToRef(newBasis, ref);\r\n\r\n return ref;\r\n}\r\n"]}
@@ -0,0 +1,23 @@
1
+ import { CameraInputsManager } from "./cameraInputsManager.js";
2
+ import type { GeospatialCamera } from "./geospatialCamera.js";
3
+ /**
4
+ * Default Inputs manager for the GeospatialCamera.
5
+ * It groups all the default supported inputs for ease of use.
6
+ */
7
+ export declare class GeospatialCameraInputsManager extends CameraInputsManager<GeospatialCamera> {
8
+ /**
9
+ * Instantiates a new GeospatialCameraInputsManager.
10
+ * @param camera Defines the camera the inputs belong to
11
+ */
12
+ constructor(camera: GeospatialCamera);
13
+ /**
14
+ * Add mouse input support to the input manager
15
+ * @returns the current input manager
16
+ */
17
+ addMouse(): GeospatialCameraInputsManager;
18
+ /**
19
+ * Add mouse wheel input support to the input manager
20
+ * @returns the current input manager
21
+ */
22
+ addMouseWheel(): GeospatialCameraInputsManager;
23
+ }
@@ -0,0 +1,33 @@
1
+ import { CameraInputsManager } from "./cameraInputsManager.js";
2
+ import { GeospatialCameraPointersInput } from "./Inputs/geospatialCameraPointersInput.js";
3
+ import { GeospatialCameraMouseWheelInput } from "./Inputs/geospatialCameraMouseWheelInput.js";
4
+ /**
5
+ * Default Inputs manager for the GeospatialCamera.
6
+ * It groups all the default supported inputs for ease of use.
7
+ */
8
+ export class GeospatialCameraInputsManager extends CameraInputsManager {
9
+ /**
10
+ * Instantiates a new GeospatialCameraInputsManager.
11
+ * @param camera Defines the camera the inputs belong to
12
+ */
13
+ constructor(camera) {
14
+ super(camera);
15
+ }
16
+ /**
17
+ * Add mouse input support to the input manager
18
+ * @returns the current input manager
19
+ */
20
+ addMouse() {
21
+ this.add(new GeospatialCameraPointersInput());
22
+ return this;
23
+ }
24
+ /**
25
+ * Add mouse wheel input support to the input manager
26
+ * @returns the current input manager
27
+ */
28
+ addMouseWheel() {
29
+ this.add(new GeospatialCameraMouseWheelInput());
30
+ return this;
31
+ }
32
+ }
33
+ //# sourceMappingURL=geospatialCameraInputsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geospatialCameraInputsManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/geospatialCameraInputsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAE3F;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,mBAAqC;IACpF;;;OAGG;IACH,YAAY,MAAwB;QAChC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,QAAQ;QACX,IAAI,CAAC,GAAG,CAAC,IAAI,6BAA6B,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,IAAI,CAAC,GAAG,CAAC,IAAI,+BAA+B,EAAE,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import { CameraInputsManager } from \"./cameraInputsManager\";\r\nimport type { GeospatialCamera } from \"./geospatialCamera\";\r\nimport { GeospatialCameraPointersInput } from \"./Inputs/geospatialCameraPointersInput\";\r\nimport { GeospatialCameraMouseWheelInput } from \"./Inputs/geospatialCameraMouseWheelInput\";\r\n\r\n/**\r\n * Default Inputs manager for the GeospatialCamera.\r\n * It groups all the default supported inputs for ease of use.\r\n */\r\nexport class GeospatialCameraInputsManager extends CameraInputsManager<GeospatialCamera> {\r\n /**\r\n * Instantiates a new GeospatialCameraInputsManager.\r\n * @param camera Defines the camera the inputs belong to\r\n */\r\n constructor(camera: GeospatialCamera) {\r\n super(camera);\r\n }\r\n\r\n /**\r\n * Add mouse input support to the input manager\r\n * @returns the current input manager\r\n */\r\n public addMouse(): GeospatialCameraInputsManager {\r\n this.add(new GeospatialCameraPointersInput());\r\n return this;\r\n }\r\n\r\n /**\r\n * Add mouse wheel input support to the input manager\r\n * @returns the current input manager\r\n */\r\n public addMouseWheel(): GeospatialCameraInputsManager {\r\n this.add(new GeospatialCameraMouseWheelInput());\r\n return this;\r\n }\r\n}\r\n"]}
@@ -18,3 +18,4 @@ export * from "./universalCamera.js";
18
18
  export * from "./virtualJoysticksCamera.js";
19
19
  export * from "./VR/index.js";
20
20
  export * from "./RigModes/index.js";
21
+ export * from "./geospatialCamera.js";
package/Cameras/index.js CHANGED
@@ -19,4 +19,5 @@ export * from "./universalCamera.js";
19
19
  export * from "./virtualJoysticksCamera.js";
20
20
  export * from "./VR/index.js";
21
21
  export * from "./RigModes/index.js";
22
+ export * from "./geospatialCamera.js";
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./Inputs/index\";\r\nexport * from \"./cameraInputsManager\";\r\nexport * from \"./camera\";\r\nexport * from \"./targetCamera\";\r\nexport * from \"./freeCamera\";\r\nexport * from \"./freeCameraInputsManager\";\r\nexport * from \"./touchCamera\";\r\nexport * from \"./arcRotateCamera\";\r\nexport * from \"./arcRotateCameraInputsManager\";\r\nexport * from \"./deviceOrientationCamera\";\r\nexport * from \"./flyCamera\";\r\nexport * from \"./flyCameraInputsManager\";\r\nexport * from \"./followCamera\";\r\nexport * from \"./followCameraInputsManager\";\r\nexport * from \"./gamepadCamera\";\r\nexport * from \"./Stereoscopic/index\";\r\nexport * from \"./universalCamera\";\r\nexport * from \"./virtualJoysticksCamera\";\r\nexport * from \"./VR/index\";\r\nexport * from \"./RigModes/index\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./Inputs/index\";\r\nexport * from \"./cameraInputsManager\";\r\nexport * from \"./camera\";\r\nexport * from \"./targetCamera\";\r\nexport * from \"./freeCamera\";\r\nexport * from \"./freeCameraInputsManager\";\r\nexport * from \"./touchCamera\";\r\nexport * from \"./arcRotateCamera\";\r\nexport * from \"./arcRotateCameraInputsManager\";\r\nexport * from \"./deviceOrientationCamera\";\r\nexport * from \"./flyCamera\";\r\nexport * from \"./flyCameraInputsManager\";\r\nexport * from \"./followCamera\";\r\nexport * from \"./followCameraInputsManager\";\r\nexport * from \"./gamepadCamera\";\r\nexport * from \"./Stereoscopic/index\";\r\nexport * from \"./universalCamera\";\r\nexport * from \"./virtualJoysticksCamera\";\r\nexport * from \"./VR/index\";\r\nexport * from \"./RigModes/index\";\r\nexport * from \"./geospatialCamera\";\r\n"]}
@@ -49,6 +49,18 @@ export declare class TargetCamera extends Camera {
49
49
  * Speed multiplier for inverse camera panning
50
50
  */
51
51
  inverseRotationSpeed: number;
52
+ /**
53
+ * @internal
54
+ * @experimental
55
+ * Can be used to change clamping behavior for inertia. Hook into onBeforeRenderObservable to change the value per-frame
56
+ */
57
+ _panningEpsilon: number;
58
+ /**
59
+ * @internal
60
+ * @experimental
61
+ * Can be used to change clamping behavior for inertia. Hook into onBeforeRenderObservable to change the value per-frame
62
+ */
63
+ _rotationEpsilon: number;
52
64
  /**
53
65
  * Define the current target of the camera as an object or a position.
54
66
  * Please note that locking a target will disable panning.
@@ -58,6 +58,18 @@ export class TargetCamera extends Camera {
58
58
  * Speed multiplier for inverse camera panning
59
59
  */
60
60
  this.inverseRotationSpeed = 0.2;
61
+ /**
62
+ * @internal
63
+ * @experimental
64
+ * Can be used to change clamping behavior for inertia. Hook into onBeforeRenderObservable to change the value per-frame
65
+ */
66
+ this._panningEpsilon = Epsilon;
67
+ /**
68
+ * @internal
69
+ * @experimental
70
+ * Can be used to change clamping behavior for inertia. Hook into onBeforeRenderObservable to change the value per-frame
71
+ */
72
+ this._rotationEpsilon = Epsilon;
61
73
  /**
62
74
  * Define the current target of the camera as an object or a position.
63
75
  * Please note that locking a target will disable panning.
@@ -307,24 +319,26 @@ export class TargetCamera extends Camera {
307
319
  }
308
320
  }
309
321
  }
322
+ const inertialPanningLimit = this.speed * this._panningEpsilon;
323
+ const inertialRotationLimit = this.speed * this._rotationEpsilon;
310
324
  // Inertia
311
325
  if (needToMove) {
312
- if (Math.abs(this.cameraDirection.x) < this.speed * Epsilon) {
326
+ if (Math.abs(this.cameraDirection.x) < inertialPanningLimit) {
313
327
  this.cameraDirection.x = 0;
314
328
  }
315
- if (Math.abs(this.cameraDirection.y) < this.speed * Epsilon) {
329
+ if (Math.abs(this.cameraDirection.y) < inertialPanningLimit) {
316
330
  this.cameraDirection.y = 0;
317
331
  }
318
- if (Math.abs(this.cameraDirection.z) < this.speed * Epsilon) {
332
+ if (Math.abs(this.cameraDirection.z) < inertialPanningLimit) {
319
333
  this.cameraDirection.z = 0;
320
334
  }
321
335
  this.cameraDirection.scaleInPlace(this.inertia);
322
336
  }
323
337
  if (needToRotate) {
324
- if (Math.abs(this.cameraRotation.x) < this.speed * Epsilon) {
338
+ if (Math.abs(this.cameraRotation.x) < inertialRotationLimit) {
325
339
  this.cameraRotation.x = 0;
326
340
  }
327
- if (Math.abs(this.cameraRotation.y) < this.speed * Epsilon) {
341
+ if (Math.abs(this.cameraRotation.y) < inertialRotationLimit) {
328
342
  this.cameraRotation.y = 0;
329
343
  }
330
344
  this.cameraRotation.scaleInPlace(this.inertia);