@babylonjs/core 8.37.0 → 8.37.2
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/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +58 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +157 -0
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +11 -9
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +17 -21
- package/Cameras/Inputs/geospatialCameraPointersInput.js +49 -71
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
- package/Cameras/Limits/geospatialLimits.d.ts +60 -0
- package/Cameras/Limits/geospatialLimits.js +89 -0
- package/Cameras/Limits/geospatialLimits.js.map +1 -0
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js +2 -2
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- package/Cameras/deviceOrientationCamera.js +5 -3
- package/Cameras/deviceOrientationCamera.js.map +1 -1
- package/Cameras/flyCamera.d.ts +2 -1
- package/Cameras/flyCamera.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +78 -49
- package/Cameras/geospatialCamera.js +210 -191
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
- package/Cameras/geospatialCameraInputsManager.js +9 -0
- package/Cameras/geospatialCameraInputsManager.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +66 -0
- package/Cameras/geospatialCameraMovement.js +199 -0
- package/Cameras/geospatialCameraMovement.js.map +1 -0
- package/Cameras/targetCamera.d.ts +1 -1
- package/Cameras/targetCamera.js +2 -2
- package/Cameras/targetCamera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -7
- package/Decorators/nodeDecorator.js +9 -7
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +2 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
- package/FlowGraph/flowGraphMath.d.ts +25 -0
- package/FlowGraph/flowGraphMath.js +40 -0
- package/FlowGraph/flowGraphMath.js.map +1 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
- package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
- package/FrameGraph/Passes/objectListPass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +6 -2
- package/FrameGraph/Passes/renderPass.js +14 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +10 -4
- package/FrameGraph/frameGraph.js +22 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +3 -3
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -1
- package/FrameGraph/index.js +1 -1
- package/FrameGraph/index.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +9 -0
- package/Materials/shaderMaterial.js +39 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +5 -24
- package/Maths/math.vector.functions.js +32 -35
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +15 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/tools.d.ts +3 -0
- package/Misc/tools.js +43 -4
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +9 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +43 -12
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +3 -3
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
- package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +20 -12
- package/Particles/Node/Blocks/systemBlock.js +26 -22
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +11 -7
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +524 -147
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/particle.d.ts +4 -0
- package/Particles/particle.js +2 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +3 -7
- package/Particles/thinParticleSystem.function.d.ts +1 -1
- package/Particles/thinParticleSystem.function.js +9 -6
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +5 -7
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/XR/webXRCamera.d.ts +5 -1
- package/XR/webXRCamera.js +2 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRExperienceHelper.js +1 -1
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/package.json +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -3,85 +3,114 @@ import { Vector3, Matrix } from "../Maths/math.vector.js";
|
|
|
3
3
|
import { Camera } from "./camera.js";
|
|
4
4
|
import type { Scene } from "../scene.js";
|
|
5
5
|
import type { MeshPredicate } from "../Culling/ray.core.js";
|
|
6
|
-
import
|
|
6
|
+
import { GeospatialLimits } from "./Limits/geospatialLimits.js";
|
|
7
|
+
import { GeospatialCameraMovement } from "./geospatialCameraMovement.js";
|
|
8
|
+
import type { IVector3Like } from "../Maths/math.like.js";
|
|
9
|
+
import type { EasingFunction } from "../Animations/easing.js";
|
|
7
10
|
type CameraOptions = {
|
|
8
11
|
planetRadius: number;
|
|
9
|
-
minAltitude?: number;
|
|
10
|
-
maxAltitude?: number;
|
|
11
|
-
restingAltitude?: number;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* @experimental
|
|
15
15
|
* This camera's movements are limited to a camera orbiting a globe, and as the API evolves it will introduce conversions between cartesian coordinates and true lat/long/alt
|
|
16
16
|
*
|
|
17
17
|
* Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag
|
|
18
|
-
*
|
|
19
|
-
* Still TODO:
|
|
20
|
-
* - Pitch/yaw limits, input speeds
|
|
21
|
-
* - ZoomToPoint
|
|
22
|
-
* - Conversion between lat/long/alt and cartesian coordinates
|
|
23
18
|
*/
|
|
24
19
|
export declare class GeospatialCamera extends Camera {
|
|
25
20
|
inputs: GeospatialCameraInputsManager;
|
|
26
|
-
/** @internal */
|
|
27
|
-
_perFrameGeocentricTranslation: Vector3;
|
|
28
|
-
/** @internal */
|
|
29
|
-
_perFrameGeocentricRotation: Vector3;
|
|
30
|
-
/** @internal */
|
|
31
|
-
_perFrameZoom: number;
|
|
32
21
|
/** If supplied, will be used when picking the globe */
|
|
33
22
|
pickPredicate?: MeshPredicate;
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
_alternateRotationPt: Nullable<Vector3>;
|
|
39
|
-
/** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/
|
|
40
|
-
get center(): Vector3;
|
|
41
|
-
private _tempGeocentricNormal;
|
|
42
|
-
private _tempRotationAxis;
|
|
43
|
-
private _tempRotationMatrix;
|
|
44
|
-
private _tempPickingRay;
|
|
23
|
+
/** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/
|
|
24
|
+
readonly movement: GeospatialCameraMovement;
|
|
45
25
|
private _tempPosition;
|
|
46
26
|
private _viewMatrix;
|
|
47
27
|
private _isViewMatrixDirty;
|
|
48
28
|
private _lookAtVector;
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
private
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
/**
|
|
55
|
-
|
|
29
|
+
/** Behavior used for smooth flying animations */
|
|
30
|
+
private _flyingBehavior;
|
|
31
|
+
private _flyToTargets;
|
|
32
|
+
constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate);
|
|
33
|
+
private _center;
|
|
34
|
+
/** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/
|
|
35
|
+
get center(): Vector3;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the camera position to orbit around a new center point
|
|
38
|
+
* @param center The world position (ECEF) to orbit around
|
|
39
|
+
*/
|
|
40
|
+
set center(center: IVector3Like);
|
|
41
|
+
private _yaw;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the camera's yaw (rotation around the geocentric normal) in radians
|
|
44
|
+
*/
|
|
45
|
+
get yaw(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Sets the camera's yaw (rotation around the geocentric normal)
|
|
48
|
+
* @param yaw The desired yaw angle in radians (0 = north, π/2 = east)
|
|
49
|
+
*/
|
|
50
|
+
set yaw(yaw: number);
|
|
51
|
+
private _pitch;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the camera's pitch (angle from looking straight at globe)
|
|
54
|
+
* Pitch is measured from looking straight down at planet center:
|
|
55
|
+
* - zero pitch = looking straight at planet center (down)
|
|
56
|
+
* - positive pitch = tilting up away from planet
|
|
57
|
+
* - π/2 pitch = looking at horizon (perpendicular to geocentric normal)
|
|
58
|
+
*/
|
|
59
|
+
get pitch(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the camera's pitch (angle from looking straight at globe)
|
|
62
|
+
* @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)
|
|
63
|
+
*/
|
|
64
|
+
set pitch(pitch: number);
|
|
65
|
+
private _radius;
|
|
66
|
+
get radius(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the camera's distance from the current center point
|
|
69
|
+
* @param radius The desired radius
|
|
70
|
+
*/
|
|
71
|
+
set radius(radius: number);
|
|
72
|
+
protected _checkLimits(): void;
|
|
73
|
+
private _tempVect;
|
|
74
|
+
private _tempEast;
|
|
75
|
+
private _tempNorth;
|
|
76
|
+
private _tempUp;
|
|
77
|
+
private _setOrientation;
|
|
56
78
|
/** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */
|
|
57
79
|
private get _geocentricRotationPt();
|
|
58
|
-
|
|
80
|
+
/**
|
|
81
|
+
* If camera is actively in flight, will update the target properties and use up the remaining duration from original flyTo call
|
|
82
|
+
*
|
|
83
|
+
* To start a new flyTo curve entirely, call into flyToAsync again (it will stop the inflight animation)
|
|
84
|
+
* @param targetYaw
|
|
85
|
+
* @param targetPitch
|
|
86
|
+
* @param targetRadius
|
|
87
|
+
* @param targetCenter
|
|
88
|
+
*/
|
|
89
|
+
updateFlyToDestination(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3): void;
|
|
90
|
+
/**
|
|
91
|
+
* Animate camera towards passed in property values. If undefined, will use current value
|
|
92
|
+
* @param targetYaw
|
|
93
|
+
* @param targetPitch
|
|
94
|
+
* @param targetRadius
|
|
95
|
+
* @param targetCenter
|
|
96
|
+
* @param flightDurationMs
|
|
97
|
+
* @param easingFunction
|
|
98
|
+
* @returns Promise that will return when the animation is complete (or interuppted by pointer input)
|
|
99
|
+
*/
|
|
100
|
+
flyToAsync(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3, flightDurationMs?: number, easingFunction?: EasingFunction): Promise<void>;
|
|
101
|
+
private _limits;
|
|
102
|
+
get limits(): GeospatialLimits;
|
|
59
103
|
private _resetToDefault;
|
|
60
104
|
/** @internal */
|
|
61
105
|
_getViewMatrix(): Matrix;
|
|
62
106
|
/** @internal */
|
|
63
107
|
_isSynchronizedViewMatrix(): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Applies rotation correction to the camera by calculating a changeOfBasis matrix from the camera's current position to the new position
|
|
66
|
-
* and transforming the lookAt and up vectors by that matrix before updating the camera position and marking the view matrix as dirty
|
|
67
|
-
* @param newPos The camera's desired position, before correction is applied
|
|
68
|
-
*/
|
|
69
|
-
private _applyRotationCorrectionAndSetPos;
|
|
70
|
-
/**
|
|
71
|
-
* When the geocentric normal has any translation change (due to dragging), we must ensure the camera remains orbiting around the world origin
|
|
72
|
-
* We thus need to perform 2 correction steps
|
|
73
|
-
* 1. Translation correction that keeps the camera at the same radius as before the drag
|
|
74
|
-
* 2. Rotation correction that keeps the camera facing the globe (so that as we pan, the globe stays centered on screen)
|
|
75
|
-
*/
|
|
76
108
|
private _applyGeocentricTranslation;
|
|
77
109
|
/**
|
|
78
110
|
* This rotation keeps the camera oriented towards the globe as it orbits around it. This is different from cameraCentricRotation which is when the camera rotates around its own axis
|
|
79
111
|
*/
|
|
80
112
|
private _applyGeocentricRotation;
|
|
81
|
-
private _clampZoomDistance;
|
|
82
113
|
private _applyZoom;
|
|
83
|
-
private _moveCameraAlongVectorByDistance;
|
|
84
|
-
private get _pickAlongLook();
|
|
85
114
|
_checkInputs(): void;
|
|
86
115
|
attachControl(noPreventDefault?: boolean): void;
|
|
87
116
|
detachControl(): void;
|
|
@@ -1,66 +1,193 @@
|
|
|
1
1
|
import { GeospatialCameraInputsManager } from "./geospatialCameraInputsManager.js";
|
|
2
2
|
import { Vector3, Matrix, TmpVectors } from "../Maths/math.vector.js";
|
|
3
3
|
import { Epsilon } from "../Maths/math.constants.js";
|
|
4
|
-
import { Scalar } from "../Maths/math.scalar.js";
|
|
5
4
|
import { Camera } from "./camera.js";
|
|
6
|
-
import {
|
|
5
|
+
import { GeospatialLimits } from "./Limits/geospatialLimits.js";
|
|
6
|
+
import { ComputeLocalBasisToRefs, GeospatialCameraMovement } from "./geospatialCameraMovement.js";
|
|
7
|
+
import { Vector3CopyToRef, Vector3Dot } from "../Maths/math.vector.functions.js";
|
|
8
|
+
import { Clamp } from "../Maths/math.scalar.functions.js";
|
|
9
|
+
import { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
|
|
7
10
|
/**
|
|
8
11
|
* @experimental
|
|
9
12
|
* 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
13
|
*
|
|
11
14
|
* 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
15
|
*/
|
|
18
16
|
export class GeospatialCamera extends Camera {
|
|
17
|
+
constructor(name, scene, options, pickPredicate) {
|
|
18
|
+
super(name, new Vector3(), scene);
|
|
19
|
+
// Temp vars
|
|
20
|
+
this._tempPosition = new Vector3();
|
|
21
|
+
this._viewMatrix = new Matrix();
|
|
22
|
+
this._lookAtVector = new Vector3();
|
|
23
|
+
this._flyToTargets = new Map();
|
|
24
|
+
this._center = new Vector3();
|
|
25
|
+
this._yaw = 0;
|
|
26
|
+
this._pitch = 0;
|
|
27
|
+
this._radius = 0;
|
|
28
|
+
this._tempVect = new Vector3();
|
|
29
|
+
this._tempEast = new Vector3();
|
|
30
|
+
this._tempNorth = new Vector3();
|
|
31
|
+
this._tempUp = new Vector3();
|
|
32
|
+
this._limits = new GeospatialLimits(options.planetRadius);
|
|
33
|
+
this._resetToDefault(this._limits);
|
|
34
|
+
this._flyingBehavior = new InterpolatingBehavior();
|
|
35
|
+
this.addBehavior(this._flyingBehavior);
|
|
36
|
+
this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate);
|
|
37
|
+
this.pickPredicate = pickPredicate;
|
|
38
|
+
this.inputs = new GeospatialCameraInputsManager(this);
|
|
39
|
+
this.inputs.addMouse().addMouseWheel().addKeyboard();
|
|
40
|
+
}
|
|
19
41
|
/** 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
42
|
get center() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
return this._center;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets the camera position to orbit around a new center point
|
|
47
|
+
* @param center The world position (ECEF) to orbit around
|
|
48
|
+
*/
|
|
49
|
+
set center(center) {
|
|
50
|
+
this._center.copyFromFloats(center.x, center.y, center.z);
|
|
51
|
+
this._setOrientation(this._yaw, this._pitch, this._radius, this._center);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets the camera's yaw (rotation around the geocentric normal) in radians
|
|
55
|
+
*/
|
|
56
|
+
get yaw() {
|
|
57
|
+
return this._yaw;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sets the camera's yaw (rotation around the geocentric normal)
|
|
61
|
+
* @param yaw The desired yaw angle in radians (0 = north, π/2 = east)
|
|
62
|
+
*/
|
|
63
|
+
set yaw(yaw) {
|
|
64
|
+
this._setOrientation(yaw, this.pitch, this.radius, this.center);
|
|
24
65
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Gets the camera's pitch (angle from looking straight at globe)
|
|
68
|
+
* Pitch is measured from looking straight down at planet center:
|
|
69
|
+
* - zero pitch = looking straight at planet center (down)
|
|
70
|
+
* - positive pitch = tilting up away from planet
|
|
71
|
+
* - π/2 pitch = looking at horizon (perpendicular to geocentric normal)
|
|
72
|
+
*/
|
|
73
|
+
get pitch() {
|
|
74
|
+
return this._pitch;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Sets the camera's pitch (angle from looking straight at globe)
|
|
78
|
+
* @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)
|
|
79
|
+
*/
|
|
80
|
+
set pitch(pitch) {
|
|
81
|
+
this._setOrientation(this.yaw, pitch, this.radius, this.center);
|
|
82
|
+
}
|
|
83
|
+
get radius() {
|
|
84
|
+
return this._radius;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Sets the camera's distance from the current center point
|
|
88
|
+
* @param radius The desired radius
|
|
89
|
+
*/
|
|
90
|
+
set radius(radius) {
|
|
91
|
+
this._setOrientation(this.yaw, this.pitch, radius, this.center);
|
|
92
|
+
}
|
|
93
|
+
_checkLimits() {
|
|
94
|
+
const limits = this.limits;
|
|
95
|
+
this._yaw = Clamp(this._yaw, limits.yawMin, limits.yawMax);
|
|
96
|
+
this._pitch = Clamp(this._pitch, limits.pitchMin, limits.pitchMax);
|
|
97
|
+
this._radius = Clamp(this._radius, limits.radiusMin, limits.radiusMax);
|
|
98
|
+
}
|
|
99
|
+
_setOrientation(yaw, pitch, radius, center) {
|
|
100
|
+
this._yaw = yaw;
|
|
101
|
+
this._pitch = pitch;
|
|
102
|
+
this._radius = radius;
|
|
103
|
+
Vector3CopyToRef(center, this._center);
|
|
104
|
+
// Clamp to limits
|
|
105
|
+
this._checkLimits();
|
|
106
|
+
// Refresh local basis at center (treat these as read-only for the whole call)
|
|
107
|
+
ComputeLocalBasisToRefs(this._center, this._tempEast, this._tempNorth, this._tempUp);
|
|
108
|
+
// Trig
|
|
109
|
+
const yawScale = this._scene.useRightHandedSystem ? 1 : -1;
|
|
110
|
+
const cosYaw = Math.cos(this._yaw * yawScale);
|
|
111
|
+
const sinYaw = Math.sin(this._yaw * yawScale);
|
|
112
|
+
const sinPitch = Math.sin(this._pitch); // horizontal weight
|
|
113
|
+
const cosPitch = Math.cos(this._pitch); // vertical weight (toward center)
|
|
114
|
+
// Temps
|
|
115
|
+
const horiz = TmpVectors.Vector3[0];
|
|
116
|
+
const t1 = TmpVectors.Vector3[1];
|
|
117
|
+
const t2 = TmpVectors.Vector3[2];
|
|
118
|
+
const right = TmpVectors.Vector3[3];
|
|
119
|
+
// horizontalDirection = North*cosYaw + East*sinYaw (avoids mutating _temp basis vectors)
|
|
120
|
+
horiz.copyFrom(this._tempNorth).scaleInPlace(cosYaw).addInPlace(t1.copyFrom(this._tempEast).scaleInPlace(sinYaw));
|
|
121
|
+
// look = horiz*sinPitch - Up*cosPitch
|
|
122
|
+
this._lookAtVector.copyFrom(horiz).scaleInPlace(sinPitch).addInPlace(t2.copyFrom(this._tempUp).scaleInPlace(-cosPitch)).normalize(); // keep it unit
|
|
123
|
+
// Build an orthonormal up aligned with geocentric Up
|
|
124
|
+
// right = normalize(cross(upRef, look))
|
|
125
|
+
Vector3.CrossToRef(this._tempUp, this._lookAtVector, right);
|
|
126
|
+
// up = normalize(cross(look, right))
|
|
127
|
+
Vector3.CrossToRef(this._lookAtVector, right, this.upVector);
|
|
128
|
+
// Position = center - look * radius (preserve unit look)
|
|
129
|
+
this._tempVect.copyFrom(this._lookAtVector).scaleInPlace(-this._radius);
|
|
130
|
+
this._tempPosition.copyFrom(this._center).addInPlace(this._tempVect);
|
|
131
|
+
this._position.copyFrom(this._tempPosition);
|
|
132
|
+
this._isViewMatrixDirty = true;
|
|
28
133
|
}
|
|
29
134
|
/** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */
|
|
30
135
|
get _geocentricRotationPt() {
|
|
31
|
-
return this.
|
|
136
|
+
return this.movement.alternateRotationPt ?? this.center;
|
|
32
137
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
138
|
+
/**
|
|
139
|
+
* If camera is actively in flight, will update the target properties and use up the remaining duration from original flyTo call
|
|
140
|
+
*
|
|
141
|
+
* To start a new flyTo curve entirely, call into flyToAsync again (it will stop the inflight animation)
|
|
142
|
+
* @param targetYaw
|
|
143
|
+
* @param targetPitch
|
|
144
|
+
* @param targetRadius
|
|
145
|
+
* @param targetCenter
|
|
146
|
+
*/
|
|
147
|
+
updateFlyToDestination(targetYaw, targetPitch, targetRadius, targetCenter) {
|
|
148
|
+
this._flyToTargets.clear();
|
|
149
|
+
this._flyToTargets.set("yaw", targetYaw);
|
|
150
|
+
this._flyToTargets.set("pitch", targetPitch);
|
|
151
|
+
this._flyToTargets.set("radius", targetRadius);
|
|
152
|
+
this._flyToTargets.set("center", targetCenter);
|
|
153
|
+
this._flyingBehavior.updateProperties(this._flyToTargets);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Animate camera towards passed in property values. If undefined, will use current value
|
|
157
|
+
* @param targetYaw
|
|
158
|
+
* @param targetPitch
|
|
159
|
+
* @param targetRadius
|
|
160
|
+
* @param targetCenter
|
|
161
|
+
* @param flightDurationMs
|
|
162
|
+
* @param easingFunction
|
|
163
|
+
* @returns Promise that will return when the animation is complete (or interuppted by pointer input)
|
|
164
|
+
*/
|
|
165
|
+
async flyToAsync(targetYaw, targetPitch, targetRadius, targetCenter, flightDurationMs = 1000, easingFunction) {
|
|
166
|
+
this._flyToTargets.clear();
|
|
167
|
+
this._flyToTargets.set("yaw", targetYaw);
|
|
168
|
+
this._flyToTargets.set("pitch", targetPitch);
|
|
169
|
+
this._flyToTargets.set("radius", targetRadius);
|
|
170
|
+
this._flyToTargets.set("center", targetCenter);
|
|
171
|
+
return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction);
|
|
172
|
+
}
|
|
173
|
+
get limits() {
|
|
174
|
+
return this._limits;
|
|
39
175
|
}
|
|
40
|
-
_resetToDefault(
|
|
176
|
+
_resetToDefault(limits) {
|
|
41
177
|
// Camera configuration vars
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
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;
|
|
178
|
+
const maxCameraRadius = limits.altitudeMax !== undefined ? limits.planetRadius + limits.altitudeMax : undefined;
|
|
179
|
+
const restingAltitude = maxCameraRadius ?? limits.planetRadius * 4;
|
|
180
|
+
this.position.copyFromFloats(restingAltitude, 0, 0);
|
|
181
|
+
this._center.copyFromFloats(limits.planetRadius, 0, 0);
|
|
182
|
+
this._radius = Vector3.Distance(this.position, this.center);
|
|
52
183
|
// Temp vars
|
|
53
|
-
this._tempPosition = Vector3
|
|
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();
|
|
184
|
+
this._tempPosition = new Vector3();
|
|
59
185
|
// 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
186
|
this._viewMatrix = Matrix.Identity();
|
|
187
|
+
this._center.subtractToRef(this._position, this._lookAtVector).normalize(); // Lookat vector of the camera
|
|
188
|
+
this.upVector = Vector3.Up(); // Up vector of the camera (does work for -X look at)
|
|
63
189
|
this._isViewMatrixDirty = true;
|
|
190
|
+
this._setOrientation(this._yaw, this._pitch, this._radius, this._center);
|
|
64
191
|
}
|
|
65
192
|
/** @internal */
|
|
66
193
|
_getViewMatrix() {
|
|
@@ -71,12 +198,12 @@ export class GeospatialCamera extends Camera {
|
|
|
71
198
|
// Ensure vectors are normalized
|
|
72
199
|
this.upVector.normalize();
|
|
73
200
|
this._lookAtVector.normalize();
|
|
74
|
-
// Calculate view matrix with camera position and
|
|
201
|
+
// Calculate view matrix with camera position and center
|
|
75
202
|
if (this.getScene().useRightHandedSystem) {
|
|
76
|
-
Matrix.LookAtRHToRef(this.position, this.
|
|
203
|
+
Matrix.LookAtRHToRef(this.position, this._center, this.upVector, this._viewMatrix);
|
|
77
204
|
}
|
|
78
205
|
else {
|
|
79
|
-
Matrix.LookAtLHToRef(this.position, this.
|
|
206
|
+
Matrix.LookAtLHToRef(this.position, this._center, this.upVector, this._viewMatrix);
|
|
80
207
|
}
|
|
81
208
|
return this._viewMatrix;
|
|
82
209
|
}
|
|
@@ -87,133 +214,65 @@ export class GeospatialCamera extends Camera {
|
|
|
87
214
|
}
|
|
88
215
|
return true;
|
|
89
216
|
}
|
|
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
217
|
_applyGeocentricTranslation() {
|
|
112
218
|
// Store pending position (without any corrections applied)
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this._tempPosition
|
|
120
|
-
// 2. Calculate the rotation correction to keep camera facing globe
|
|
121
|
-
this._applyRotationCorrectionAndSetPos(this._tempPosition);
|
|
219
|
+
this.center.addToRef(this.movement.panDeltaCurrentFrame, this._tempPosition);
|
|
220
|
+
if (!this.movement.isInterpolating) {
|
|
221
|
+
// Calculate the position correction to keep camera at the same radius when applying translation
|
|
222
|
+
this._tempPosition.normalize().scaleInPlace(this.center.length());
|
|
223
|
+
}
|
|
224
|
+
// Set center which will call _setOrientation
|
|
225
|
+
this.center = this._tempPosition;
|
|
122
226
|
}
|
|
123
227
|
/**
|
|
124
228
|
* 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
229
|
*/
|
|
126
230
|
_applyGeocentricRotation() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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);
|
|
231
|
+
const rotationDeltaCurrentFrame = this.movement.rotationDeltaCurrentFrame;
|
|
232
|
+
if (rotationDeltaCurrentFrame.x !== 0 || rotationDeltaCurrentFrame.y !== 0) {
|
|
233
|
+
const pitch = rotationDeltaCurrentFrame.x !== 0 ? Clamp(this._pitch + rotationDeltaCurrentFrame.x, 0, 0.5 * Math.PI - Epsilon) : this._pitch;
|
|
234
|
+
const yaw = rotationDeltaCurrentFrame.y !== 0 ? this._yaw + rotationDeltaCurrentFrame.y : this._yaw;
|
|
235
|
+
// TODO: If _geocentricRotationPt is not the center, this will need to be adjusted.
|
|
236
|
+
this._setOrientation(yaw, pitch, this._radius, this._geocentricRotationPt);
|
|
147
237
|
}
|
|
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
238
|
}
|
|
180
|
-
_applyZoom(distance) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
239
|
+
_applyZoom(zoomVector, distance) {
|
|
240
|
+
// TODO this function will be re-worked shortly after checkin, becuase today it breaks down if you zoom to a point past the center
|
|
241
|
+
// (ex: tilted view zooming towards cursor near horizon where the center is closer than the cursor point).
|
|
242
|
+
// Project zoom vector onto lookAt vector to find the amount the camera-to-center distance should change.
|
|
243
|
+
// - zoom vector is normalized
|
|
244
|
+
// - distance is how much to move in this call
|
|
245
|
+
const directionDotLookAt = Vector3Dot(zoomVector, this._lookAtVector);
|
|
246
|
+
const hasRadialComponent = Math.abs(directionDotLookAt) > Epsilon;
|
|
247
|
+
const requestedRadius = hasRadialComponent ? this._radius - distance * directionDotLookAt : this._radius;
|
|
248
|
+
const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);
|
|
249
|
+
const actualRadiusChange = newRadius - this._radius;
|
|
250
|
+
const actualDistanceChange = hasRadialComponent ? actualRadiusChange / directionDotLookAt : 0;
|
|
251
|
+
// Use this to compute new camera position and new center position.
|
|
252
|
+
const newCameraPosition = this._position.add(zoomVector.scale(-actualDistanceChange));
|
|
253
|
+
const newCenter = newCameraPosition.add(this._lookAtVector.scaleToRef(newRadius, TmpVectors.Vector3[3]));
|
|
254
|
+
// Rescale new center to maintain same altitude as the old center.
|
|
255
|
+
const currentCenterRadius = this._center.length();
|
|
256
|
+
const newCenterRadius = newCenter.length();
|
|
257
|
+
const newCenterRescale = currentCenterRadius / newCenterRadius;
|
|
258
|
+
newCenter.scaleInPlace(newCenterRescale);
|
|
259
|
+
// Apply changes
|
|
260
|
+
this._setOrientation(this._yaw, this._pitch, newRadius, newCenter);
|
|
201
261
|
}
|
|
202
262
|
_checkInputs() {
|
|
203
263
|
this.inputs.checkInputs();
|
|
204
|
-
|
|
264
|
+
// Let movement class handle all per-frame logic
|
|
265
|
+
this.movement.computeCurrentFrameDeltas();
|
|
266
|
+
if (this.movement.panDeltaCurrentFrame.lengthSquared() > 0) {
|
|
205
267
|
this._applyGeocentricTranslation();
|
|
206
|
-
this._perFrameGeocentricTranslation.setAll(0);
|
|
207
268
|
this._isViewMatrixDirty = true;
|
|
208
269
|
}
|
|
209
|
-
if (this.
|
|
270
|
+
if (this.movement.rotationDeltaCurrentFrame.lengthSquared() > 0) {
|
|
210
271
|
this._applyGeocentricRotation();
|
|
211
|
-
this._perFrameGeocentricRotation.setAll(0);
|
|
212
272
|
this._isViewMatrixDirty = true;
|
|
213
273
|
}
|
|
214
|
-
if (this.
|
|
215
|
-
this._applyZoom(this.
|
|
216
|
-
this._perFrameZoom = 0;
|
|
274
|
+
if (Math.abs(this.movement.zoomDeltaCurrentFrame) > Epsilon) {
|
|
275
|
+
this._applyZoom(this.movement.computedPerFrameZoomVector, this.movement.zoomDeltaCurrentFrame);
|
|
217
276
|
this._isViewMatrixDirty = true;
|
|
218
277
|
}
|
|
219
278
|
super._checkInputs();
|
|
@@ -225,44 +284,4 @@ export class GeospatialCamera extends Camera {
|
|
|
225
284
|
this.inputs.detachElement();
|
|
226
285
|
}
|
|
227
286
|
}
|
|
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
287
|
//# sourceMappingURL=geospatialCamera.js.map
|