@onerjs/core 8.42.6 → 8.42.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatorAvatar.d.ts +5 -2
- package/Animations/animatorAvatar.js +40 -27
- package/Animations/animatorAvatar.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.d.ts +1 -2
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -2
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +0 -4
- package/Cameras/Inputs/geospatialCameraPointersInput.js +1 -5
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/cameraMovement.d.ts +1 -4
- package/Cameras/cameraMovement.js +1 -4
- package/Cameras/cameraMovement.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +22 -4
- package/Cameras/geospatialCamera.js +27 -9
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +3 -3
- package/Cameras/geospatialCameraMovement.js +18 -18
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.js +35 -13
- package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineFeatures.d.ts +0 -2
- package/Engines/engineFeatures.js.map +1 -1
- package/Engines/nullEngine.js +0 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +0 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/thinNativeEngine.js +0 -1
- package/Engines/thinNativeEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +9 -4
- package/Engines/thinWebGPUEngine.js +32 -32
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -0
- package/Engines/webgpuEngine.js +24 -165
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +0 -3
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +5 -29
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +3 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.js +1 -1
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +0 -2
- package/FrameGraph/frameGraphTask.js +15 -17
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +1 -1
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +2 -2
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.d.ts +1 -1
- package/Gizmos/cameraGizmo.js +1 -1
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.d.ts +4 -4
- package/Gizmos/gizmo.js +5 -5
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.d.ts +2 -2
- package/Gizmos/gizmoManager.js +1 -1
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +2 -2
- package/Gizmos/planeRotationGizmo.js +2 -3
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +1 -1
- package/Gizmos/positionGizmo.js +2 -2
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +1 -1
- package/Gizmos/rotationGizmo.js +3 -3
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +1 -1
- package/Gizmos/scaleGizmo.js +1 -1
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +44 -14
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +12 -3
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +33 -8
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +0 -4
- package/Materials/uniformBuffer.js +0 -8
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/index.d.ts +2 -0
- package/Maths/index.js +2 -0
- package/Maths/index.js.map +1 -1
- package/Maths/math.geospatial.d.ts +12 -0
- package/Maths/math.geospatial.functions.d.ts +19 -0
- package/Maths/math.geospatial.functions.js +27 -0
- package/Maths/math.geospatial.functions.js.map +1 -0
- package/Maths/math.geospatial.js +2 -0
- package/Maths/math.geospatial.js.map +1 -0
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Navigation/INavigationEngine.d.ts +2 -2
- package/Navigation/INavigationEngine.js.map +1 -1
- package/Navigation/Plugins/recastJSPlugin.d.ts +2 -2
- package/Navigation/Plugins/recastJSPlugin.js +14 -5
- package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
- package/Physics/castingResult.d.ts +4 -1
- package/Physics/castingResult.js +1 -1
- package/Physics/castingResult.js.map +1 -1
- package/Physics/joinedPhysicsEngineComponent.js +1 -1
- package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
- package/Physics/physicsHelper.d.ts +8 -8
- package/Physics/physicsHelper.js +7 -7
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/shapeCastResult.d.ts +4 -0
- package/Physics/shapeCastResult.js +7 -0
- package/Physics/shapeCastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +51 -4
- package/Physics/v2/IPhysicsEnginePlugin.js +12 -12
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/characterController.js.map +1 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +1 -1
- package/Physics/v2/physicsConstraint.js +1 -1
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +0 -5
- package/Physics/v2/physicsEngine.js +0 -5
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Physics/v2/physicsEngineComponent.d.ts +1 -1
- package/Physics/v2/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/physicsMaterial.d.ts +6 -0
- package/Physics/v2/physicsMaterial.js +2 -2
- package/Physics/v2/physicsMaterial.js.map +1 -1
- package/Physics/v2/ragdoll.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +1 -0
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/objectRenderer.js +8 -4
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/renderingGroup.d.ts +1 -1
- package/Rendering/renderingGroup.js +1 -1
- package/Rendering/renderingGroup.js.map +1 -1
- package/Rendering/renderingManager.d.ts +1 -1
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/iblVoxelGrid.fragment.js +4 -1
- package/Shaders/iblVoxelGrid.fragment.js.map +1 -1
- package/ShadersWGSL/background.vertex.js +8 -8
- package/ShadersWGSL/background.vertex.js.map +1 -1
- package/ShadersWGSL/boundingBoxRenderer.vertex.js +2 -2
- package/ShadersWGSL/boundingBoxRenderer.vertex.js.map +1 -1
- package/ShadersWGSL/clearQuad.vertex.js +1 -1
- package/ShadersWGSL/clearQuad.vertex.js.map +1 -1
- package/ShadersWGSL/color.vertex.js +1 -1
- package/ShadersWGSL/color.vertex.js.map +1 -1
- package/ShadersWGSL/depth.vertex.js +3 -3
- package/ShadersWGSL/depth.vertex.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js +2 -2
- package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleDiffuse.vertex.js +2 -2
- package/ShadersWGSL/fluidRenderingParticleDiffuse.vertex.js.map +1 -1
- package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js +2 -2
- package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js.map +1 -1
- package/ShadersWGSL/fxaa.vertex.js +1 -1
- package/ShadersWGSL/fxaa.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +4 -4
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/glowMapGeneration.vertex.js +4 -4
- package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -1
- package/ShadersWGSL/glowMapMerge.vertex.js +1 -1
- package/ShadersWGSL/glowMapMerge.vertex.js.map +1 -1
- package/ShadersWGSL/greasedLine.vertex.js +10 -4
- package/ShadersWGSL/greasedLine.vertex.js.map +1 -1
- package/ShadersWGSL/hdrFiltering.vertex.js +1 -1
- package/ShadersWGSL/hdrFiltering.vertex.js.map +1 -1
- package/ShadersWGSL/hdrIrradianceFiltering.vertex.js +1 -1
- package/ShadersWGSL/hdrIrradianceFiltering.vertex.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +2 -2
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js +1 -1
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js.map +1 -1
- package/ShadersWGSL/kernelBlur.vertex.js +2 -2
- package/ShadersWGSL/kernelBlur.vertex.js.map +1 -1
- package/ShadersWGSL/layer.vertex.js +1 -1
- package/ShadersWGSL/layer.vertex.js.map +1 -1
- package/ShadersWGSL/lensFlare.vertex.js +1 -1
- package/ShadersWGSL/lensFlare.vertex.js.map +1 -1
- package/ShadersWGSL/line.vertex.js +2 -2
- package/ShadersWGSL/line.vertex.js.map +1 -1
- package/ShadersWGSL/meshUVSpaceRenderer.vertex.js +2 -2
- package/ShadersWGSL/meshUVSpaceRenderer.vertex.js.map +1 -1
- package/ShadersWGSL/meshUVSpaceRendererFinaliser.vertex.js +1 -1
- package/ShadersWGSL/meshUVSpaceRendererFinaliser.vertex.js.map +1 -1
- package/ShadersWGSL/meshUVSpaceRendererMasker.vertex.js +1 -1
- package/ShadersWGSL/meshUVSpaceRendererMasker.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +9 -9
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +2 -2
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/ShadersWGSL/procedural.vertex.js +1 -1
- package/ShadersWGSL/procedural.vertex.js.map +1 -1
- package/ShadersWGSL/shadowMap.vertex.js +4 -4
- package/ShadersWGSL/shadowMap.vertex.js.map +1 -1
- package/ShadersWGSL/sprites.vertex.js +3 -3
- package/ShadersWGSL/sprites.vertex.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js +0 -2
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +3 -6
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +2 -1
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geospatialCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraPointersInput.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,6BAA8B,SAAQ,wBAAwB;IAA3E;;QAGY,iCAA4B,GAAW,CAAC,CAAC;QACzC,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,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEe,WAAW;QACvB,IAAI,CAAC,4BAA4B,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,KAAK,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;IAEO,WAAW,CAAC,MAAc,EAAE,MAAc;QAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,6BAA6B;QAC/G,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,oDAAoD;IAC5I,CAAC;CACJ","sourcesContent":["import type { GeospatialCamera } from \"../../Cameras/geospatialCamera\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { OrbitCameraPointersInput } from \"./orbitCameraPointersInput\";\r\n\r\n/**\r\n * @experimental\r\n * Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe\r\n * This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately\r\n *\r\n * As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix\r\n * As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit\r\n *\r\n * Left mouse button: drag globe\r\n * Middle mouse button: tilt globe\r\n * Right mouse button: tilt globe\r\n *\r\n */\r\nexport class GeospatialCameraPointersInput extends OrbitCameraPointersInput {\r\n public camera: GeospatialCamera;\r\n\r\n private _initialPinchSquaredDistance: number = 0;\r\n private _pinchCentroid: Nullable<PointerTouch> = null;\r\n\r\n /**\r\n * Defines the rotation sensitivity of the pointer when rotating camera around the x axis (pitch)\r\n * (Multiplied by the true pixel delta of pointer input, before rotation speed factor is applied by movement class)\r\n */\r\n public pitchSensitivity = 1.0;\r\n\r\n /**\r\n * Defines the rotation sensitivity of the pointer when rotating the camera around the Y axis (yaw)\r\n * (Multiplied by the true pixel delta of pointer input, before rotation speed factor is applied by movement class)\r\n */\r\n public yawSensitivity: number = 1.0;\r\n\r\n /**\r\n * Defines the distance used to consider the camera in pan mode vs pinch/zoom.\r\n * Basically if your fingers moves away from more than this distance you will be considered\r\n * in pinch mode.\r\n */\r\n public pinchToPanMax: number = 20;\r\n\r\n public override getClassName(): string {\r\n return \"GeospatialCameraPointersInput\";\r\n }\r\n\r\n public override onButtonDown(evt: IPointerEvent): void {\r\n this.camera.movement.activeInput = true;\r\n const scene = this.camera.getScene();\r\n switch (evt.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n this.camera.movement.startDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n public override onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {\r\n // Single finger touch (no button property) or left button (button 0) = drag\r\n const button = point?.button ?? 0; // Default to button 0 (drag) if undefined\r\n const scene = this.camera.getScene();\r\n switch (button) {\r\n case 0: // Left button / single touch - drag/pan globe under cursor\r\n this.camera.movement.handleDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera\r\n case 2: // Right button - tilt camera\r\n this._handleTilt(offsetX, offsetY);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Move camera from multitouch (pinch) zoom distances.\r\n * Zooms towards the centroid (midpoint between the two fingers).\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n */\r\n protected override _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void {\r\n // Calculate zoom distance based on pinch delta\r\n const previousDistance = Math.sqrt(previousPinchSquaredDistance);\r\n const currentDistance = Math.sqrt(pinchSquaredDistance);\r\n const pinchDelta = currentDistance - previousDistance;\r\n\r\n // Try to zoom towards centroid if we have it\r\n if (this._pinchCentroid) {\r\n const scene = this.camera.getScene();\r\n const engine = scene.getEngine();\r\n const canvasRect = engine.getInputElementClientRect();\r\n\r\n if (canvasRect) {\r\n // Convert centroid from clientX/Y to canvas-relative coordinates (same as scene.pointerX/Y)\r\n const canvasX = this._pinchCentroid.x - canvasRect.left;\r\n const canvasY = this._pinchCentroid.y - canvasRect.top;\r\n\r\n // Pick at centroid\r\n const pickResult = scene.pick(canvasX, canvasY, this.camera.movement.pickPredicate);\r\n if (pickResult?.pickedPoint) {\r\n // Scale zoom by distance to picked point\r\n const distanceToPoint = this.camera.position.subtract(pickResult.pickedPoint).length();\r\n const zoomDistance = pinchDelta * distanceToPoint * 0.005;\r\n const clampedZoom = this.camera.limits.clampZoomDistance(zoomDistance, this.camera.radius, distanceToPoint);\r\n this.camera.zoomToPoint(pickResult.pickedPoint, clampedZoom);\r\n return;\r\n }\r\n }\r\n }\r\n\r\n // Fallback: scale zoom by camera radius along lookat vector\r\n const zoomDistance = pinchDelta * this.camera.radius * 0.005;\r\n const clampedZoom = this.camera.limits.clampZoomDistance(zoomDistance, this.camera.radius);\r\n this.camera.zoomAlongLookAt(clampedZoom);\r\n }\r\n\r\n /**\r\n * Move camera from multi touch panning positions.\r\n * In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n protected override _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void {\r\n if (previousMultiTouchPanPosition && multiTouchPanPosition) {\r\n const moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;\r\n const moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;\r\n this._handleTilt(moveDeltaX, moveDeltaY);\r\n }\r\n }\r\n\r\n public override onDoubleTap(type: string): void {\r\n const pickResult = this.camera._scene.pick(this.camera._scene.pointerX, this.camera._scene.pointerY, this.camera.movement.pickPredicate);\r\n if (pickResult.pickedPoint) {\r\n void this.camera.flyToPointAsync(pickResult.pickedPoint);\r\n }\r\n }\r\n\r\n public override onMultiTouch(\r\n pointA: Nullable<PointerTouch>,\r\n pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n // Store centroid for use in _computePinchZoom (it's already calculated by parent)\r\n this._pinchCentroid = multiTouchPanPosition;\r\n\r\n // Reset on gesture end\r\n if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {\r\n this._initialPinchSquaredDistance = 0;\r\n this._pinchCentroid = null;\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n return;\r\n }\r\n\r\n // Track initial distance at gesture start for cumulative threshold detection\r\n if (this._initialPinchSquaredDistance === 0 && pinchSquaredDistance !== 0) {\r\n this._initialPinchSquaredDistance = pinchSquaredDistance;\r\n }\r\n\r\n // Use cumulative delta from gesture start for threshold detection (more forgiving than frame-to-frame)\r\n const cumulativeDelta = Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(this._initialPinchSquaredDistance));\r\n this._shouldStartPinchZoom = this._twoFingerActivityCount < 20 && cumulativeDelta > this.pinchToPanMax;\r\n\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this.camera.movement.stopDrag();\r\n this.camera.movement.activeInput = false;\r\n this._initialPinchSquaredDistance = 0;\r\n this._pinchCentroid = null;\r\n super.onButtonUp(_evt);\r\n }\r\n\r\n public override onLostFocus(): void {\r\n this._initialPinchSquaredDistance = 0;\r\n this._pinchCentroid = null;\r\n super.onLostFocus();\r\n }\r\n\r\n private _handleTilt(deltaX: number, deltaY: number): void {\r\n this.camera.movement.rotationAccumulatedPixels.y -= deltaX * this.yawSensitivity; // yaw - looking side to side\r\n this.camera.movement.rotationAccumulatedPixels.x -= deltaY * this.pitchSensitivity; // pitch - look up towards sky / down towards ground\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"geospatialCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraPointersInput.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,OAAO,6BAA8B,SAAQ,wBAAwB;IAA3E;;QAGY,iCAA4B,GAAW,CAAC,CAAC;QACzC,mBAAc,GAA2B,IAAI,CAAC;QAEtD;;;WAGG;QACI,qBAAgB,GAAG,GAAG,CAAC;QAE9B;;;WAGG;QACI,mBAAc,GAAW,GAAG,CAAC;QAEpC;;;;WAIG;QACI,kBAAa,GAAW,EAAE,CAAC;IAiJtC,CAAC;IA/ImB,YAAY;QACxB,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAEe,YAAY,CAAC,GAAkB;QAC3C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrC,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,EAAE,4CAA4C;gBAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC/D,MAAM;YACV;gBACI,MAAM;QACd,CAAC;IACL,CAAC;IAEe,OAAO,CAAC,KAA6B,EAAE,OAAe,EAAE,OAAe;QACnF,4EAA4E;QAC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IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC;QACjH,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,uBAAuB,GAAG,EAAE,IAAI,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC;QAEvG,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;IACjJ,CAAC;IAEe,UAAU,CAAC,IAAmB;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC;QACzC,IAAI,CAAC,4BAA4B,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEe,WAAW;QACvB,IAAI,CAAC,4BAA4B,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,KAAK,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;IAEO,WAAW,CAAC,MAAc,EAAE,MAAc;QAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,6BAA6B;QAC/G,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,oDAAoD;IAC5I,CAAC;CACJ","sourcesContent":["import type { GeospatialCamera } from \"../../Cameras/geospatialCamera\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { OrbitCameraPointersInput } from \"./orbitCameraPointersInput\";\r\n\r\n/**\r\n * Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe\r\n * This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately\r\n *\r\n * Left mouse button: drag globe\r\n * Middle mouse button: tilt globe\r\n * Right mouse button: tilt globe\r\n *\r\n */\r\nexport class GeospatialCameraPointersInput extends OrbitCameraPointersInput {\r\n public camera: GeospatialCamera;\r\n\r\n private _initialPinchSquaredDistance: number = 0;\r\n private _pinchCentroid: Nullable<PointerTouch> = null;\r\n\r\n /**\r\n * Defines the rotation sensitivity of the pointer when rotating camera around the x axis (pitch)\r\n * (Multiplied by the true pixel delta of pointer input, before rotation speed factor is applied by movement class)\r\n */\r\n public pitchSensitivity = 1.0;\r\n\r\n /**\r\n * Defines the rotation sensitivity of the pointer when rotating the camera around the Y axis (yaw)\r\n * (Multiplied by the true pixel delta of pointer input, before rotation speed factor is applied by movement class)\r\n */\r\n public yawSensitivity: number = 1.0;\r\n\r\n /**\r\n * Defines the distance used to consider the camera in pan mode vs pinch/zoom.\r\n * Basically if your fingers moves away from more than this distance you will be considered\r\n * in pinch mode.\r\n */\r\n public pinchToPanMax: number = 20;\r\n\r\n public override getClassName(): string {\r\n return \"GeospatialCameraPointersInput\";\r\n }\r\n\r\n public override onButtonDown(evt: IPointerEvent): void {\r\n this.camera.movement.activeInput = true;\r\n const scene = this.camera.getScene();\r\n switch (evt.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n this.camera.movement.startDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n public override onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {\r\n // Single finger touch (no button property) or left button (button 0) = drag\r\n const button = point?.button ?? 0; // Default to button 0 (drag) if undefined\r\n const scene = this.camera.getScene();\r\n switch (button) {\r\n case 0: // Left button / single touch - drag/pan globe under cursor\r\n this.camera.movement.handleDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera\r\n case 2: // Right button - tilt camera\r\n this._handleTilt(offsetX, offsetY);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Move camera from multitouch (pinch) zoom distances.\r\n * Zooms towards the centroid (midpoint between the two fingers).\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n */\r\n protected override _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void {\r\n // Calculate zoom distance based on pinch delta\r\n const previousDistance = Math.sqrt(previousPinchSquaredDistance);\r\n const currentDistance = Math.sqrt(pinchSquaredDistance);\r\n const pinchDelta = currentDistance - previousDistance;\r\n\r\n // Try to zoom towards centroid if we have it\r\n if (this._pinchCentroid) {\r\n const scene = this.camera.getScene();\r\n const engine = scene.getEngine();\r\n const canvasRect = engine.getInputElementClientRect();\r\n\r\n if (canvasRect) {\r\n // Convert centroid from clientX/Y to canvas-relative coordinates (same as scene.pointerX/Y)\r\n const canvasX = this._pinchCentroid.x - canvasRect.left;\r\n const canvasY = this._pinchCentroid.y - canvasRect.top;\r\n\r\n // Pick at centroid\r\n const pickResult = scene.pick(canvasX, canvasY, this.camera.movement.pickPredicate);\r\n if (pickResult?.pickedPoint) {\r\n // Scale zoom by distance to picked point\r\n const distanceToPoint = this.camera.position.subtract(pickResult.pickedPoint).length();\r\n const zoomDistance = pinchDelta * distanceToPoint * 0.005;\r\n const clampedZoom = this.camera.limits.clampZoomDistance(zoomDistance, this.camera.radius, distanceToPoint);\r\n this.camera.zoomToPoint(pickResult.pickedPoint, clampedZoom);\r\n return;\r\n }\r\n }\r\n }\r\n\r\n // Fallback: scale zoom by camera radius along lookat vector\r\n const zoomDistance = pinchDelta * this.camera.radius * 0.005;\r\n const clampedZoom = this.camera.limits.clampZoomDistance(zoomDistance, this.camera.radius);\r\n this.camera.zoomAlongLookAt(clampedZoom);\r\n }\r\n\r\n /**\r\n * Move camera from multi touch panning positions.\r\n * In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n protected override _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void {\r\n if (previousMultiTouchPanPosition && multiTouchPanPosition) {\r\n const moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;\r\n const moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;\r\n this._handleTilt(moveDeltaX, moveDeltaY);\r\n }\r\n }\r\n\r\n public override onDoubleTap(type: string): void {\r\n const pickResult = this.camera._scene.pick(this.camera._scene.pointerX, this.camera._scene.pointerY, this.camera.movement.pickPredicate);\r\n if (pickResult.pickedPoint) {\r\n void this.camera.flyToPointAsync(pickResult.pickedPoint);\r\n }\r\n }\r\n\r\n public override onMultiTouch(\r\n pointA: Nullable<PointerTouch>,\r\n pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n // Store centroid for use in _computePinchZoom (it's already calculated by parent)\r\n this._pinchCentroid = multiTouchPanPosition;\r\n\r\n // Reset on gesture end\r\n if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {\r\n this._initialPinchSquaredDistance = 0;\r\n this._pinchCentroid = null;\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n return;\r\n }\r\n\r\n // Track initial distance at gesture start for cumulative threshold detection\r\n if (this._initialPinchSquaredDistance === 0 && pinchSquaredDistance !== 0) {\r\n this._initialPinchSquaredDistance = pinchSquaredDistance;\r\n }\r\n\r\n // Use cumulative delta from gesture start for threshold detection (more forgiving than frame-to-frame)\r\n const cumulativeDelta = Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(this._initialPinchSquaredDistance));\r\n this._shouldStartPinchZoom = this._twoFingerActivityCount < 20 && cumulativeDelta > this.pinchToPanMax;\r\n\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this.camera.movement.stopDrag();\r\n this.camera.movement.activeInput = false;\r\n this._initialPinchSquaredDistance = 0;\r\n this._pinchCentroid = null;\r\n super.onButtonUp(_evt);\r\n }\r\n\r\n public override onLostFocus(): void {\r\n this._initialPinchSquaredDistance = 0;\r\n this._pinchCentroid = null;\r\n super.onLostFocus();\r\n }\r\n\r\n private _handleTilt(deltaX: number, deltaY: number): void {\r\n this.camera.movement.rotationAccumulatedPixels.y += deltaX * this.yawSensitivity; // yaw - looking side to side\r\n this.camera.movement.rotationAccumulatedPixels.x -= deltaY * this.pitchSensitivity; // pitch - look up towards sky / down towards ground\r\n }\r\n}\r\n"]}
|
|
@@ -2,10 +2,7 @@ import type { Scene } from "../scene.js";
|
|
|
2
2
|
import { Vector3 } from "../Maths/math.vector.js";
|
|
3
3
|
import type { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* This class is subject to change as geospatial camera evolves.
|
|
7
|
-
*
|
|
8
|
-
* It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
|
|
5
|
+
* Holds all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
|
|
9
6
|
* to ensure smooth frame-rate-independent movement
|
|
10
7
|
*/
|
|
11
8
|
export declare class CameraMovement {
|
|
@@ -2,10 +2,7 @@ import { Vector3 } from "../Maths/math.vector.js";
|
|
|
2
2
|
import { Epsilon } from "../Maths/math.constants.js";
|
|
3
3
|
const FrameDurationAt60FPS = 1000 / 60;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* This class is subject to change as geospatial camera evolves.
|
|
7
|
-
*
|
|
8
|
-
* It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
|
|
5
|
+
* Holds all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account
|
|
9
6
|
* to ensure smooth frame-rate-independent movement
|
|
10
7
|
*/
|
|
11
8
|
export class CameraMovement {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraMovement.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/cameraMovement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;AACvC;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IAyIvB,YACI,KAAY,EACF,eAAwB,EACxB,SAAiC;QADjC,oBAAe,GAAf,eAAe,CAAS;QACxB,cAAS,GAAT,SAAS,CAAwB;QAzI/C;;;WAGG;QACI,gBAAW,GAAY,KAAK,CAAC;QAEpC;;;;WAIG;QACH;;WAEG;QACI,cAAS,GAAW,CAAC,CAAC;QAC7B;;WAEG;QACI,aAAQ,GAAW,CAAC,CAAC;QAC5B;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAClC;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAElC;;;;;WAKG;QACH;;WAEG;QACO,yBAAoB,GAAW,CAAC,CAAC;QAC3C;;WAEG;QACO,wBAAmB,GAAW,CAAC,CAAC;QAE1C;;;;;;;;;WASG;QACH;;;WAGG;QACI,gBAAW,GAAW,GAAG,CAAC;QACjC;;;WAGG;QACI,eAAU,GAAW,GAAG,CAAC;QAChC;;;WAGG;QACI,oBAAe,GAAW,GAAG,CAAC;QAErC;;;;WAIG;QACH;;;;WAIG;QACI,0BAAqB,GAAW,CAAC,CAAC;QACzC;;;;WAIG;QACI,yBAAoB,GAAY,IAAI,OAAO,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ED,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\n\r\nconst FrameDurationAt60FPS = 1000 / 60;\r\n/**\r\n * @experimental\r\n * This class is subject to change as geospatial camera evolves.\r\n *\r\n * It is intended to hold all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account\r\n * to ensure smooth frame-rate-independent movement\r\n */\r\nexport class CameraMovement {\r\n protected _scene: Scene;\r\n\r\n /**\r\n * Should be set by input classes to indicates whether there is active input this frame\r\n * This helps us differentiate between 0 pixel delta due to no input vs user actively holding still\r\n */\r\n public activeInput: boolean = false;\r\n\r\n /**\r\n * ------------ Speed ----------------\r\n * Speed defines the amount of camera movement expected per input pixel movement\r\n * -----------------------------------\r\n */\r\n /**\r\n * Desired coordinate unit movement per input pixel when zooming\r\n */\r\n public zoomSpeed: number = 1;\r\n /**\r\n * Desired coordinate unit movement per input pixel when panning\r\n */\r\n public panSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along x axis\r\n */\r\n public rotationXSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along y axis\r\n */\r\n public rotationYSpeed: number = 1;\r\n\r\n /**\r\n * ----------- Speed multipliers ---------------\r\n * Multipliers allow movement classes to modify the effective speed dynamically per-frame\r\n * (ex: scale zoom based on distance from target)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)\r\n */\r\n protected _zoomSpeedMultiplier: number = 1;\r\n /**\r\n * Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)\r\n */\r\n protected _panSpeedMultiplier: number = 1;\r\n\r\n /**\r\n * ---------- Inertia ----------------\r\n * Inertia represents the decay factor per-frame applied to the velocity when there is no user input.\r\n * 0 = No inertia, instant stop (velocity immediately becomes 0)\r\n * 0.5 = Strong decay, velocity halves every frame at 60fps\r\n * 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps\r\n * 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps\r\n * 1 = Infinite inertia, never stops (velocity never decays)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Inertia applied to the zoom velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public zoomInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the panning velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public panInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the rotation velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public rotationInertia: number = 0.9;\r\n\r\n /**\r\n * ---------- Accumulated Pixel Deltas -----------\r\n * Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Accumulated pixel delta (by input classes) for zoom this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into zoomDeltaCurrentFrame (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public zoomAccumulatedPixels: number = 0;\r\n /**\r\n * Accumulated pixel delta (by input classes) for panning this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into panDeltaCurrentFrame (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public panAccumulatedPixels: Vector3 = new Vector3();\r\n /**\r\n * Accumulated pixel delta (by input classes) for rotation this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into rotationDeltaCurrentFrame (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public rotationAccumulatedPixels: Vector3 = new Vector3();\r\n\r\n /**\r\n * ---------- Current Frame Movement Deltas -----------\r\n * Deltas read on each frame by camera class in order to move the camera\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)\r\n */\r\n public zoomDeltaCurrentFrame: number = 0;\r\n /**\r\n * Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)\r\n */\r\n public panDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n /**\r\n * Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)\r\n */\r\n public rotationDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * ---------- Velocity -----------\r\n * Used to track velocity between frames for inertia calculation\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom pixel velocity used for inertia calculations (pixels / ms).\r\n */\r\n protected _zoomVelocity: number = 0;\r\n /**\r\n * Pan velocity used for inertia calculations (movement / time)\r\n */\r\n private _panVelocity: Vector3 = new Vector3();\r\n /**\r\n * Rotation velocity used for inertia calculations (movement / time)\r\n */\r\n private _rotationVelocity: Vector3 = new Vector3();\r\n\r\n /**\r\n * Used when calculating inertial decay. Default to 60fps\r\n */\r\n private _prevFrameTimeMs: number = FrameDurationAt60FPS;\r\n\r\n constructor(\r\n scene: Scene,\r\n protected _cameraPosition: Vector3,\r\n protected _behavior?: InterpolatingBehavior\r\n ) {\r\n this._scene = scene;\r\n }\r\n\r\n /**\r\n * When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties\r\n * Takes speed, scaling, inertia, and framerate into account to ensure smooth movement\r\n * Zeros out pixelDeltas before returning\r\n */\r\n public computeCurrentFrameDeltas(): void {\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n this.panDeltaCurrentFrame.setAll(0);\r\n this.rotationDeltaCurrentFrame.setAll(0);\r\n this.zoomDeltaCurrentFrame = 0;\r\n\r\n const hasUserInput = this.panAccumulatedPixels.lengthSquared() > 0 || this.rotationAccumulatedPixels.lengthSquared() > 0 || this.zoomAccumulatedPixels !== 0;\r\n\r\n if (hasUserInput && this._behavior?.isInterpolating) {\r\n this._behavior.stopAllAnimations();\r\n }\r\n\r\n this._panVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._panVelocity.x, this.panAccumulatedPixels.x, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.y, this.panAccumulatedPixels.y, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.z, this.panAccumulatedPixels.z, this.panInertia)\r\n );\r\n this._panVelocity.scaleToRef(this.panSpeed * this._panSpeedMultiplier * deltaTimeMs, this.panDeltaCurrentFrame);\r\n\r\n this._rotationVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._rotationVelocity.x, this.rotationAccumulatedPixels.x, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.y, this.rotationAccumulatedPixels.y, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.z, this.rotationAccumulatedPixels.z, this.rotationInertia)\r\n );\r\n this.rotationDeltaCurrentFrame.copyFromFloats(\r\n this._rotationVelocity.x * this.rotationXSpeed * deltaTimeMs,\r\n this._rotationVelocity.y * this.rotationYSpeed * deltaTimeMs,\r\n this._rotationVelocity.z * this.rotationYSpeed * deltaTimeMs\r\n );\r\n\r\n this._zoomVelocity = this._calculateCurrentVelocity(this._zoomVelocity, this.zoomAccumulatedPixels, this.zoomInertia);\r\n this.zoomDeltaCurrentFrame = this._zoomVelocity * (this.zoomSpeed * this._zoomSpeedMultiplier) * deltaTimeMs;\r\n\r\n this._prevFrameTimeMs = deltaTimeMs;\r\n this.zoomAccumulatedPixels = 0;\r\n this.panAccumulatedPixels.setAll(0);\r\n this.rotationAccumulatedPixels.setAll(0);\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return !!this._behavior?.isInterpolating;\r\n }\r\n\r\n private _calculateCurrentVelocity(velocityRef: number, pixelDelta: number, inertialDecayFactor: number): number {\r\n let inputVelocity = velocityRef;\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n // If we are actively receiving input or have accumulated some pixel delta since last frame, calculate inputVelocity (inertia doesn't kick in yet)\r\n if (pixelDelta !== 0 || this.activeInput) {\r\n inputVelocity = pixelDelta / deltaTimeMs;\r\n } else if (!this.activeInput && inputVelocity !== 0) {\r\n // If we are not receiving input and velocity isn't already zero, apply inertial decay to decelerate velocity\r\n const frameIndependentDecay = Math.pow(inertialDecayFactor, this._prevFrameTimeMs / FrameDurationAt60FPS);\r\n inputVelocity *= frameIndependentDecay;\r\n if (Math.abs(inputVelocity) <= Epsilon) {\r\n inputVelocity = 0;\r\n }\r\n }\r\n\r\n return inputVelocity;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"cameraMovement.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/cameraMovement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;AACvC;;;GAGG;AACH,MAAM,OAAO,cAAc;IAyIvB,YACI,KAAY,EACF,eAAwB,EACxB,SAAiC;QADjC,oBAAe,GAAf,eAAe,CAAS;QACxB,cAAS,GAAT,SAAS,CAAwB;QAzI/C;;;WAGG;QACI,gBAAW,GAAY,KAAK,CAAC;QAEpC;;;;WAIG;QACH;;WAEG;QACI,cAAS,GAAW,CAAC,CAAC;QAC7B;;WAEG;QACI,aAAQ,GAAW,CAAC,CAAC;QAC5B;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAClC;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAElC;;;;;WAKG;QACH;;WAEG;QACO,yBAAoB,GAAW,CAAC,CAAC;QAC3C;;WAEG;QACO,wBAAmB,GAAW,CAAC,CAAC;QAE1C;;;;;;;;;WASG;QACH;;;WAGG;QACI,gBAAW,GAAW,GAAG,CAAC;QACjC;;;WAGG;QACI,e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,CAAC,CAAC;YAC1G,aAAa,IAAI,qBAAqB,CAAC;YACvC,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,EAAE,CAAC;gBACrC,aAAa,GAAG,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\n\r\nconst FrameDurationAt60FPS = 1000 / 60;\r\n/**\r\n * Holds all logic related to converting input pixel deltas into current frame deltas, taking speed / framerate into account\r\n * to ensure smooth frame-rate-independent movement\r\n */\r\nexport class CameraMovement {\r\n protected _scene: Scene;\r\n\r\n /**\r\n * Should be set by input classes to indicates whether there is active input this frame\r\n * This helps us differentiate between 0 pixel delta due to no input vs user actively holding still\r\n */\r\n public activeInput: boolean = false;\r\n\r\n /**\r\n * ------------ Speed ----------------\r\n * Speed defines the amount of camera movement expected per input pixel movement\r\n * -----------------------------------\r\n */\r\n /**\r\n * Desired coordinate unit movement per input pixel when zooming\r\n */\r\n public zoomSpeed: number = 1;\r\n /**\r\n * Desired coordinate unit movement per input pixel when panning\r\n */\r\n public panSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along x axis\r\n */\r\n public rotationXSpeed: number = 1;\r\n /**\r\n * Desired radians movement per input pixel when rotating along y axis\r\n */\r\n public rotationYSpeed: number = 1;\r\n\r\n /**\r\n * ----------- Speed multipliers ---------------\r\n * Multipliers allow movement classes to modify the effective speed dynamically per-frame\r\n * (ex: scale zoom based on distance from target)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Multiplied atop zoom speed. Used to dynamically adjust zoom speed based on per-frame context (ex: zoom faster when further from target)\r\n */\r\n protected _zoomSpeedMultiplier: number = 1;\r\n /**\r\n * Multiplied atop pan speed. Used to dynamically adjust pan speed based on per-frame context (ex: pan slowly when close to target)\r\n */\r\n protected _panSpeedMultiplier: number = 1;\r\n\r\n /**\r\n * ---------- Inertia ----------------\r\n * Inertia represents the decay factor per-frame applied to the velocity when there is no user input.\r\n * 0 = No inertia, instant stop (velocity immediately becomes 0)\r\n * 0.5 = Strong decay, velocity halves every frame at 60fps\r\n * 0.9 = Moderate inertia, velocity retains 90% per frame at 60fps\r\n * 0.95 = High inertia, smooth glide, velocity retains 95% per frame at 60fps\r\n * 1 = Infinite inertia, never stops (velocity never decays)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Inertia applied to the zoom velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public zoomInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the panning velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public panInertia: number = 0.9;\r\n /**\r\n * Inertia applied to the rotation velocity when there is no user input.\r\n * Higher inertia === slower decay, velocity retains more of its value each frame\r\n */\r\n public rotationInertia: number = 0.9;\r\n\r\n /**\r\n * ---------- Accumulated Pixel Deltas -----------\r\n * Pixel inputs accumulated throughout the frame by input classes (reset each frame after processing)\r\n * -----------------------------------\r\n */\r\n /**\r\n * Accumulated pixel delta (by input classes) for zoom this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into zoomDeltaCurrentFrame (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public zoomAccumulatedPixels: number = 0;\r\n /**\r\n * Accumulated pixel delta (by input classes) for panning this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into panDeltaCurrentFrame (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public panAccumulatedPixels: Vector3 = new Vector3();\r\n /**\r\n * Accumulated pixel delta (by input classes) for rotation this frame\r\n * Read by computeCurrentFrameDeltas() function and converted into rotationDeltaCurrentFrame (taking speed into account)\r\n * Reset to zero after each frame\r\n */\r\n public rotationAccumulatedPixels: Vector3 = new Vector3();\r\n\r\n /**\r\n * ---------- Current Frame Movement Deltas -----------\r\n * Deltas read on each frame by camera class in order to move the camera\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from zoomPixelDelta (taking speed into account)\r\n */\r\n public zoomDeltaCurrentFrame: number = 0;\r\n /**\r\n * Pan delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from panPixelDelta (taking speed into account)\r\n */\r\n public panDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n /**\r\n * Rotation delta to apply to camera this frame, computed by computeCurrentFrameDeltas() from rotationPixelDelta (taking speed into account)\r\n */\r\n public rotationDeltaCurrentFrame: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * ---------- Velocity -----------\r\n * Used to track velocity between frames for inertia calculation\r\n * -----------------------------------\r\n */\r\n /**\r\n * Zoom pixel velocity used for inertia calculations (pixels / ms).\r\n */\r\n protected _zoomVelocity: number = 0;\r\n /**\r\n * Pan velocity used for inertia calculations (movement / time)\r\n */\r\n private _panVelocity: Vector3 = new Vector3();\r\n /**\r\n * Rotation velocity used for inertia calculations (movement / time)\r\n */\r\n private _rotationVelocity: Vector3 = new Vector3();\r\n\r\n /**\r\n * Used when calculating inertial decay. Default to 60fps\r\n */\r\n private _prevFrameTimeMs: number = FrameDurationAt60FPS;\r\n\r\n constructor(\r\n scene: Scene,\r\n protected _cameraPosition: Vector3,\r\n protected _behavior?: InterpolatingBehavior\r\n ) {\r\n this._scene = scene;\r\n }\r\n\r\n /**\r\n * When called, will take the accumulated pixel deltas set by input classes and convert them into current frame deltas, stored in currentFrameMovementDelta properties\r\n * Takes speed, scaling, inertia, and framerate into account to ensure smooth movement\r\n * Zeros out pixelDeltas before returning\r\n */\r\n public computeCurrentFrameDeltas(): void {\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n this.panDeltaCurrentFrame.setAll(0);\r\n this.rotationDeltaCurrentFrame.setAll(0);\r\n this.zoomDeltaCurrentFrame = 0;\r\n\r\n const hasUserInput = this.panAccumulatedPixels.lengthSquared() > 0 || this.rotationAccumulatedPixels.lengthSquared() > 0 || this.zoomAccumulatedPixels !== 0;\r\n\r\n if (hasUserInput && this._behavior?.isInterpolating) {\r\n this._behavior.stopAllAnimations();\r\n }\r\n\r\n this._panVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._panVelocity.x, this.panAccumulatedPixels.x, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.y, this.panAccumulatedPixels.y, this.panInertia),\r\n this._calculateCurrentVelocity(this._panVelocity.z, this.panAccumulatedPixels.z, this.panInertia)\r\n );\r\n this._panVelocity.scaleToRef(this.panSpeed * this._panSpeedMultiplier * deltaTimeMs, this.panDeltaCurrentFrame);\r\n\r\n this._rotationVelocity.copyFromFloats(\r\n this._calculateCurrentVelocity(this._rotationVelocity.x, this.rotationAccumulatedPixels.x, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.y, this.rotationAccumulatedPixels.y, this.rotationInertia),\r\n this._calculateCurrentVelocity(this._rotationVelocity.z, this.rotationAccumulatedPixels.z, this.rotationInertia)\r\n );\r\n this.rotationDeltaCurrentFrame.copyFromFloats(\r\n this._rotationVelocity.x * this.rotationXSpeed * deltaTimeMs,\r\n this._rotationVelocity.y * this.rotationYSpeed * deltaTimeMs,\r\n this._rotationVelocity.z * this.rotationYSpeed * deltaTimeMs\r\n );\r\n\r\n this._zoomVelocity = this._calculateCurrentVelocity(this._zoomVelocity, this.zoomAccumulatedPixels, this.zoomInertia);\r\n this.zoomDeltaCurrentFrame = this._zoomVelocity * (this.zoomSpeed * this._zoomSpeedMultiplier) * deltaTimeMs;\r\n\r\n this._prevFrameTimeMs = deltaTimeMs;\r\n this.zoomAccumulatedPixels = 0;\r\n this.panAccumulatedPixels.setAll(0);\r\n this.rotationAccumulatedPixels.setAll(0);\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return !!this._behavior?.isInterpolating;\r\n }\r\n\r\n private _calculateCurrentVelocity(velocityRef: number, pixelDelta: number, inertialDecayFactor: number): number {\r\n let inputVelocity = velocityRef;\r\n const deltaTimeMs = this._scene.getEngine().getDeltaTime();\r\n\r\n // If we are actively receiving input or have accumulated some pixel delta since last frame, calculate inputVelocity (inertia doesn't kick in yet)\r\n if (pixelDelta !== 0 || this.activeInput) {\r\n inputVelocity = pixelDelta / deltaTimeMs;\r\n } else if (!this.activeInput && inputVelocity !== 0) {\r\n // If we are not receiving input and velocity isn't already zero, apply inertial decay to decelerate velocity\r\n const frameIndependentDecay = Math.pow(inertialDecayFactor, this._prevFrameTimeMs / FrameDurationAt60FPS);\r\n inputVelocity *= frameIndependentDecay;\r\n if (Math.abs(inputVelocity) <= Epsilon) {\r\n inputVelocity = 0;\r\n }\r\n }\r\n\r\n return inputVelocity;\r\n }\r\n}\r\n"]}
|
|
@@ -74,6 +74,9 @@ export declare class GeospatialCamera extends Camera {
|
|
|
74
74
|
*/
|
|
75
75
|
set pitch(pitch: number);
|
|
76
76
|
private _radius;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the camera's distance from the current center point. This is distinct from planetRadius supplied at construction.
|
|
79
|
+
*/
|
|
77
80
|
get radius(): number;
|
|
78
81
|
/**
|
|
79
82
|
* Sets the camera's distance from the current center point
|
|
@@ -118,6 +121,9 @@ export declare class GeospatialCamera extends Camera {
|
|
|
118
121
|
*/
|
|
119
122
|
flyToPointAsync(destination: Vector3, distanceScale?: number, durationMs?: number, easingFn?: EasingFunction, centerHopScale?: number): Promise<void>;
|
|
120
123
|
private _limits;
|
|
124
|
+
/**
|
|
125
|
+
* Gets the limits for this camera
|
|
126
|
+
*/
|
|
121
127
|
get limits(): GeospatialLimits;
|
|
122
128
|
private _resetToDefault;
|
|
123
129
|
/** @internal */
|
|
@@ -135,8 +141,18 @@ export declare class GeospatialCamera extends Camera {
|
|
|
135
141
|
*/
|
|
136
142
|
private _applyZoom;
|
|
137
143
|
private _clampZoomDelta;
|
|
144
|
+
/**
|
|
145
|
+
* Zoom towards a specific point on the globe
|
|
146
|
+
* @param targetPoint The point to zoom towards
|
|
147
|
+
* @param distance The distance to move
|
|
148
|
+
*/
|
|
138
149
|
zoomToPoint(targetPoint: DeepImmutable<IVector3Like>, distance: number): void;
|
|
150
|
+
/**
|
|
151
|
+
* Zoom along the camera's lookAt direction
|
|
152
|
+
* @param distance The distance to zoom
|
|
153
|
+
*/
|
|
139
154
|
zoomAlongLookAt(distance: number): void;
|
|
155
|
+
/** @internal */
|
|
140
156
|
_checkInputs(): void;
|
|
141
157
|
private _wasCenterMovingLastFrame;
|
|
142
158
|
private _recalculateCenter;
|
|
@@ -146,7 +162,9 @@ export declare class GeospatialCamera extends Camera {
|
|
|
146
162
|
* @returns
|
|
147
163
|
*/
|
|
148
164
|
protected _getCollisionOffset(newPosition: Vector3): Vector3;
|
|
165
|
+
/** @internal */
|
|
149
166
|
attachControl(noPreventDefault?: boolean): void;
|
|
167
|
+
/** @internal */
|
|
150
168
|
detachControl(): void;
|
|
151
169
|
/**
|
|
152
170
|
* Gets the class name of the camera.
|
|
@@ -162,10 +180,10 @@ export declare class GeospatialCamera extends Camera {
|
|
|
162
180
|
* @param center - The center point on the globe
|
|
163
181
|
* @param useRightHandedSystem - Whether the scene uses a right-handed coordinate system
|
|
164
182
|
* @param result - The vector to store the result in
|
|
165
|
-
* @param
|
|
183
|
+
* @param calculateUpVectorFromPointToRef - Optional function to calculate the up vector from a point, allowing for non-spherical planets. If not supplied, a perfect sphere is assumed and the up vector is just the normalized center point.
|
|
166
184
|
* @returns The normalized lookAt direction vector (same as result)
|
|
167
185
|
*/
|
|
168
|
-
export declare function ComputeLookAtFromYawPitchToRef(yaw: number, pitch: number, center: Vector3, useRightHandedSystem: boolean, result: Vector3,
|
|
186
|
+
export declare function ComputeLookAtFromYawPitchToRef(yaw: number, pitch: number, center: Vector3, useRightHandedSystem: boolean, result: Vector3, calculateUpVectorFromPointToRef?: (point: Vector3, result: Vector3) => Vector3): Vector3;
|
|
169
187
|
/**
|
|
170
188
|
* Given a lookAt direction and center, compute the yaw and pitch angles that would produce that lookAt.
|
|
171
189
|
* This is the inverse of ComputeLookAtFromYawPitchToRef.
|
|
@@ -174,7 +192,7 @@ export declare function ComputeLookAtFromYawPitchToRef(yaw: number, pitch: numbe
|
|
|
174
192
|
* @param useRightHandedSystem - Whether the scene uses a right-handed coordinate system
|
|
175
193
|
* @param currentYaw - The current yaw value to use as fallback when pitch is near 0 (looking straight down/up)
|
|
176
194
|
* @param result - The Vector2 to store the result in (x = yaw, y = pitch)
|
|
177
|
-
* @param
|
|
195
|
+
* @param calculateUpVectorFromPointToRef - Optional function to calculate the up vector from a point. If supplied, this function will be used instead of assuming a spherical geocentric normal, allowing support for non-spherical planets or custom up vector logic.
|
|
178
196
|
* @returns The result Vector2
|
|
179
197
|
*/
|
|
180
|
-
export declare function ComputeYawPitchFromLookAtToRef(lookAt: Vector3, center: Vector3, useRightHandedSystem: boolean, currentYaw: number, result: Vector2,
|
|
198
|
+
export declare function ComputeYawPitchFromLookAtToRef(lookAt: Vector3, center: Vector3, useRightHandedSystem: boolean, currentYaw: number, result: Vector2, calculateUpVectorFromPointToRef?: (point: Vector3, result: Vector3) => Vector3): Vector2;
|
|
@@ -86,6 +86,9 @@ export class GeospatialCamera extends Camera {
|
|
|
86
86
|
set pitch(pitch) {
|
|
87
87
|
pitch !== this._pitch && this._setOrientation(this.yaw, pitch, this.radius, this.center);
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets the camera's distance from the current center point. This is distinct from planetRadius supplied at construction.
|
|
91
|
+
*/
|
|
89
92
|
get radius() {
|
|
90
93
|
return this._radius;
|
|
91
94
|
}
|
|
@@ -113,9 +116,9 @@ export class GeospatialCamera extends Camera {
|
|
|
113
116
|
// Clamp to limits
|
|
114
117
|
this._checkLimits();
|
|
115
118
|
// Refresh local basis at center (treat these as read-only for the whole call)
|
|
116
|
-
ComputeLocalBasisToRefs(this._center, this._tempEast, this._tempNorth, this._tempUp, this._scene.useRightHandedSystem, this.movement.
|
|
119
|
+
ComputeLocalBasisToRefs(this._center, this._tempEast, this._tempNorth, this._tempUp, this._scene.useRightHandedSystem, this.movement.calculateUpVectorFromPointToRef);
|
|
117
120
|
// Compute lookAt from yaw/pitch
|
|
118
|
-
ComputeLookAtFromYawPitchToRef(this._yaw, this._pitch, this._center, this._scene.useRightHandedSystem, this._lookAtVector, this.movement.
|
|
121
|
+
ComputeLookAtFromYawPitchToRef(this._yaw, this._pitch, this._center, this._scene.useRightHandedSystem, this._lookAtVector, this.movement.calculateUpVectorFromPointToRef);
|
|
119
122
|
// Build an orthonormal up aligned with geocentric Up
|
|
120
123
|
// When looking straight down (pitch ≈ 0), lookAt is parallel to Up, so use the horizontal direction as the camera's up.
|
|
121
124
|
const right = TmpVectors.Vector3[10];
|
|
@@ -225,6 +228,9 @@ export class GeospatialCamera extends Camera {
|
|
|
225
228
|
await this.flyToAsync(undefined, undefined, newRadius, this._tempCenter, durationMs, easingFn, centerHopScale);
|
|
226
229
|
!this.isDisposed() && this._recalculateCenter(false, true /** force */);
|
|
227
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Gets the limits for this camera
|
|
233
|
+
*/
|
|
228
234
|
get limits() {
|
|
229
235
|
return this._limits;
|
|
230
236
|
}
|
|
@@ -340,11 +346,20 @@ export class GeospatialCamera extends Camera {
|
|
|
340
346
|
const distanceToTarget = pickedPoint ? Vector3Distance(this._position, pickedPoint) : undefined;
|
|
341
347
|
return this.limits.clampZoomDistance(zoomDelta, this._radius, distanceToTarget);
|
|
342
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Zoom towards a specific point on the globe
|
|
351
|
+
* @param targetPoint The point to zoom towards
|
|
352
|
+
* @param distance The distance to move
|
|
353
|
+
*/
|
|
343
354
|
zoomToPoint(targetPoint, distance) {
|
|
344
355
|
const newRadius = this._getCenterAndRadiusFromZoomToPoint(targetPoint, distance, this._tempCenter);
|
|
345
356
|
// Apply the new orientation
|
|
346
357
|
this._setOrientation(this._yaw, this._pitch, newRadius, this._tempCenter);
|
|
347
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Zoom along the camera's lookAt direction
|
|
361
|
+
* @param distance The distance to zoom
|
|
362
|
+
*/
|
|
348
363
|
zoomAlongLookAt(distance) {
|
|
349
364
|
// Clamp radius to limits
|
|
350
365
|
const requestedRadius = this._radius - distance;
|
|
@@ -352,6 +367,7 @@ export class GeospatialCamera extends Camera {
|
|
|
352
367
|
// Simply change radius without moving center
|
|
353
368
|
this._setOrientation(this._yaw, this._pitch, newRadius, this._center);
|
|
354
369
|
}
|
|
370
|
+
/** @internal */
|
|
355
371
|
_checkInputs() {
|
|
356
372
|
this.inputs.checkInputs();
|
|
357
373
|
this.perFrameCollisionOffset.setAll(0);
|
|
@@ -394,7 +410,7 @@ export class GeospatialCamera extends Camera {
|
|
|
394
410
|
if (newRadius > Epsilon) {
|
|
395
411
|
// Compute yaw/pitch that correspond to current lookAt at new center
|
|
396
412
|
const yawPitch = TmpVectors.Vector2[0];
|
|
397
|
-
ComputeYawPitchFromLookAtToRef(this._lookAtVector, newCenter.pickedPoint, this._scene.useRightHandedSystem, this._yaw, yawPitch, this.movement.
|
|
413
|
+
ComputeYawPitchFromLookAtToRef(this._lookAtVector, newCenter.pickedPoint, this._scene.useRightHandedSystem, this._yaw, yawPitch, this.movement.calculateUpVectorFromPointToRef);
|
|
398
414
|
// Call _setOrientation with the computed yaw/pitch and new center
|
|
399
415
|
this._setOrientation(yawPitch.x, yawPitch.y, newRadius, newCenter.pickedPoint);
|
|
400
416
|
}
|
|
@@ -428,9 +444,11 @@ export class GeospatialCamera extends Camera {
|
|
|
428
444
|
adjustedPosition.subtractToRef(newPosition, collisionOffset);
|
|
429
445
|
return collisionOffset;
|
|
430
446
|
}
|
|
447
|
+
/** @internal */
|
|
431
448
|
attachControl(noPreventDefault) {
|
|
432
449
|
this.inputs.attachElement(noPreventDefault);
|
|
433
450
|
}
|
|
451
|
+
/** @internal */
|
|
434
452
|
detachControl() {
|
|
435
453
|
this.inputs.detachElement();
|
|
436
454
|
}
|
|
@@ -467,14 +485,14 @@ RegisterClass("BABYLON.GeospatialCamera", GeospatialCamera);
|
|
|
467
485
|
* @param center - The center point on the globe
|
|
468
486
|
* @param useRightHandedSystem - Whether the scene uses a right-handed coordinate system
|
|
469
487
|
* @param result - The vector to store the result in
|
|
470
|
-
* @param
|
|
488
|
+
* @param calculateUpVectorFromPointToRef - Optional function to calculate the up vector from a point, allowing for non-spherical planets. If not supplied, a perfect sphere is assumed and the up vector is just the normalized center point.
|
|
471
489
|
* @returns The normalized lookAt direction vector (same as result)
|
|
472
490
|
*/
|
|
473
|
-
export function ComputeLookAtFromYawPitchToRef(yaw, pitch, center, useRightHandedSystem, result,
|
|
491
|
+
export function ComputeLookAtFromYawPitchToRef(yaw, pitch, center, useRightHandedSystem, result, calculateUpVectorFromPointToRef) {
|
|
474
492
|
const east = TmpVectors.Vector3[0];
|
|
475
493
|
const north = TmpVectors.Vector3[1];
|
|
476
494
|
const up = TmpVectors.Vector3[2];
|
|
477
|
-
ComputeLocalBasisToRefs(center, east, north, up, useRightHandedSystem,
|
|
495
|
+
ComputeLocalBasisToRefs(center, east, north, up, useRightHandedSystem, calculateUpVectorFromPointToRef);
|
|
478
496
|
const sinPitch = Math.sin(pitch);
|
|
479
497
|
const cosPitch = Math.cos(pitch);
|
|
480
498
|
// horiz = north * cos(yaw) + east * sin(yaw)
|
|
@@ -498,15 +516,15 @@ export function ComputeLookAtFromYawPitchToRef(yaw, pitch, center, useRightHande
|
|
|
498
516
|
* @param useRightHandedSystem - Whether the scene uses a right-handed coordinate system
|
|
499
517
|
* @param currentYaw - The current yaw value to use as fallback when pitch is near 0 (looking straight down/up)
|
|
500
518
|
* @param result - The Vector2 to store the result in (x = yaw, y = pitch)
|
|
501
|
-
* @param
|
|
519
|
+
* @param calculateUpVectorFromPointToRef - Optional function to calculate the up vector from a point. If supplied, this function will be used instead of assuming a spherical geocentric normal, allowing support for non-spherical planets or custom up vector logic.
|
|
502
520
|
* @returns The result Vector2
|
|
503
521
|
*/
|
|
504
|
-
export function ComputeYawPitchFromLookAtToRef(lookAt, center, useRightHandedSystem, currentYaw, result,
|
|
522
|
+
export function ComputeYawPitchFromLookAtToRef(lookAt, center, useRightHandedSystem, currentYaw, result, calculateUpVectorFromPointToRef) {
|
|
505
523
|
// Compute local basis at center
|
|
506
524
|
const east = TmpVectors.Vector3[6];
|
|
507
525
|
const north = TmpVectors.Vector3[7];
|
|
508
526
|
const up = TmpVectors.Vector3[8];
|
|
509
|
-
ComputeLocalBasisToRefs(center, east, north, up, useRightHandedSystem,
|
|
527
|
+
ComputeLocalBasisToRefs(center, east, north, up, useRightHandedSystem, calculateUpVectorFromPointToRef);
|
|
510
528
|
// lookAt = horiz*sinPitch - up*cosPitch
|
|
511
529
|
// where horiz = north*cos(yaw) + east*sin(yaw)
|
|
512
530
|
//
|