@onerjs/core 8.31.0 → 8.31.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 +8 -2
- package/Behaviors/Cameras/interpolatingBehavior.js +58 -6
- package/Behaviors/Cameras/interpolatingBehavior.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 +8 -20
- package/Cameras/Inputs/geospatialCameraPointersInput.js +35 -75
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- 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.js +1 -1
- package/Cameras/cameraMovement.js.map +1 -1
- 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/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.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/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.js +4 -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/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +8 -8
- package/Particles/Node/Blocks/systemBlock.js +12 -12
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +9 -7
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +288 -149
- 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 +0 -4
- 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 +1 -3
- 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
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geospatialCamera.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/geospatialCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAYrC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IAoBxC,+IAA+I;IAC/I,IAAW,MAAM;QACb,sIAAsI;QACtI,qGAAqG;QACrG,OAAO,IAAI,CAAC,cAAc,EAAE,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC;IAC5D,CAAC;IAoBD,uIAAuI;IACvI,IAAY,OAAO;QACf,OAA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AG,CAAC;AACf,CAAC","sourcesContent":["import { GeospatialCameraInputsManager } from \"./geospatialCameraInputsManager\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\nimport { Camera } from \"./camera\";\r\nimport { Ray } from \"../Culling/ray\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { MeshPredicate } from \"../Culling/ray.core\";\r\nimport type { Nullable } from \"../types\";\r\n\r\ntype CameraOptions = {\r\n planetRadius: number; // Radius of the planet\r\n minAltitude?: number; // Minimum altitude of the camera above the planet surface\r\n maxAltitude?: number; // Maximum altitude of the camera above the planet surface\r\n restingAltitude?: number; // The altitude the camera will return to when not being actively zoomed in or out\r\n};\r\n\r\n/**\r\n * @experimental\r\n * This camera's movements are limited to a camera orbiting a globe, and as the API evolves it will introduce conversions between cartesian coordinates and true lat/long/alt\r\n *\r\n * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag\r\n *\r\n * Still TODO:\r\n * - Pitch/yaw limits, input speeds\r\n * - ZoomToPoint\r\n * - Conversion between lat/long/alt and cartesian coordinates\r\n */\r\nexport class GeospatialCamera extends Camera {\r\n override inputs: GeospatialCameraInputsManager;\r\n\r\n // Changed by the inputs, reset on every frame\r\n /** @internal */\r\n public _perFrameGeocentricTranslation: Vector3; // Translation that keeps camera at the same radius from the center of the globe\r\n /** @internal */\r\n public _perFrameGeocentricRotation: Vector3; // Rotation around center (distinct from rotation around camera that can cause looking off into space)\r\n /** @internal */\r\n public _perFrameZoom: number;\r\n\r\n /** If supplied, will be used when picking the globe */\r\n public pickPredicate?: MeshPredicate;\r\n\r\n /**\r\n * Enables rotation around a specific point, instead of default rotation around center\r\n * @internal\r\n */\r\n public _alternateRotationPt: Nullable<Vector3>;\r\n\r\n /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/\r\n public get center(): Vector3 {\r\n // NOTE that for now we are falling back to target if no pick on globe (because that shouldn't happen with current implemented inputs)\r\n // but eventually we want to return a point on the globe even if the camera is looking off into space\r\n return this._pickAlongLook?.pickedPoint ?? this._target;\r\n }\r\n\r\n // Temp vars\r\n private _tempGeocentricNormal: Vector3;\r\n private _tempRotationAxis: Vector3;\r\n private _tempRotationMatrix: Matrix;\r\n private _tempPickingRay: Ray;\r\n private _tempPosition: Vector3;\r\n\r\n private _viewMatrix: Matrix;\r\n private _isViewMatrixDirty: boolean;\r\n private _lookAtVector: Vector3;\r\n\r\n // Camera configuration vars\r\n private _planetRadius: number;\r\n private _minAltitude: number;\r\n private _maxAltitude?: number;\r\n private _maxCameraRadius?: number;\r\n private _restingAltitude: number;\r\n\r\n /** Target of camera when looking along lookAtVector from current position. This does not necessarily represent a point on the globe */\r\n private get _target(): Vector3 {\r\n return this.position.addToRef(this._lookAtVector, this._tempPosition);\r\n }\r\n\r\n /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */\r\n private get _geocentricRotationPt(): Vector3 {\r\n return this._alternateRotationPt ?? this.center;\r\n }\r\n\r\n constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate) {\r\n super(name, Vector3.Zero(), scene);\r\n this._resetToDefault(options);\r\n this.pickPredicate = pickPredicate;\r\n this.inputs = new GeospatialCameraInputsManager(this);\r\n this.inputs.addMouse().addMouseWheel();\r\n }\r\n\r\n private _resetToDefault(options: CameraOptions): void {\r\n // Camera configuration vars\r\n this._minAltitude = options.minAltitude ?? 5;\r\n this._maxAltitude = options.maxAltitude;\r\n this._planetRadius = options.planetRadius;\r\n this._maxCameraRadius = this._maxAltitude ? this._planetRadius + this._maxAltitude : undefined;\r\n this._restingAltitude = options.restingAltitude ?? this._maxCameraRadius ?? this._planetRadius * 4;\r\n this.position.copyFromFloats(0, 0, -this._restingAltitude);\r\n\r\n // Input vars\r\n this._perFrameGeocentricRotation = Vector3.Zero();\r\n this._perFrameGeocentricTranslation = Vector3.Zero();\r\n this._perFrameZoom = 0;\r\n\r\n // Temp vars\r\n this._tempPosition = Vector3.Zero();\r\n this._tempRotationAxis = Vector3.Right(); // starting axis used to calculate pitch rotation matrix\r\n this._tempRotationMatrix = Matrix.Identity();\r\n this._tempGeocentricNormal = Vector3.Zero();\r\n this._tempPickingRay = new Ray(this.position, this._lookAtVector);\r\n this._tempPickingRay.direction = Vector3.Zero();\r\n\r\n // View matrix calculation vars\r\n this.upVector = Vector3.Up(); // Up vector of the camera\r\n this._lookAtVector = this.position.negate().normalize(); // Lookat vector of the camera\r\n this._viewMatrix = Matrix.Identity();\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n /** @internal */\r\n override _getViewMatrix() {\r\n if (!this._isViewMatrixDirty) {\r\n return this._viewMatrix;\r\n }\r\n this._isViewMatrixDirty = false;\r\n\r\n // Ensure vectors are normalized\r\n this.upVector.normalize();\r\n this._lookAtVector.normalize();\r\n\r\n // Calculate view matrix with camera position and target\r\n if (this.getScene().useRightHandedSystem) {\r\n Matrix.LookAtRHToRef(this.position, this._target, this.upVector, this._viewMatrix);\r\n } else {\r\n Matrix.LookAtLHToRef(this.position, this._target, this.upVector, this._viewMatrix);\r\n }\r\n\r\n return this._viewMatrix;\r\n }\r\n\r\n /** @internal */\r\n override _isSynchronizedViewMatrix(): boolean {\r\n if (!super._isSynchronizedViewMatrix() || this._isViewMatrixDirty) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Applies rotation correction to the camera by calculating a changeOfBasis matrix from the camera's current position to the new position\r\n * and transforming the lookAt and up vectors by that matrix before updating the camera position and marking the view matrix as dirty\r\n * @param newPos The camera's desired position, before correction is applied\r\n */\r\n private _applyRotationCorrectionAndSetPos(newPos: Vector3): void {\r\n // Compute changeOfBasis between current camera position and new position\r\n ComputeChangeOfBasisToRef(this.position, newPos, this._tempRotationMatrix);\r\n\r\n // Apply rotation correction to lookat/up vectors\r\n Vector3.TransformNormalToRef(this._lookAtVector, this._tempRotationMatrix, this._lookAtVector);\r\n Vector3.TransformNormalToRef(this.upVector, this._tempRotationMatrix, this.upVector);\r\n\r\n // Apply position change and mark viewMatrix as dirty\r\n this.position.copyFrom(newPos);\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n /**\r\n * When the geocentric normal has any translation change (due to dragging), we must ensure the camera remains orbiting around the world origin\r\n * We thus need to perform 2 correction steps\r\n * 1. Translation correction that keeps the camera at the same radius as before the drag\r\n * 2. Rotation correction that keeps the camera facing the globe (so that as we pan, the globe stays centered on screen)\r\n */\r\n private _applyGeocentricTranslation() {\r\n // Store pending position (without any corrections applied)\r\n this.position.addToRef(this._perFrameGeocentricTranslation, this._tempPosition);\r\n\r\n // 1. Calculate the altitude correction to keep camera at the same radius when applying translation\r\n const tempPositionScaled = TmpVectors.Vector3[2];\r\n const offset = TmpVectors.Vector3[3];\r\n this._tempPosition.normalizeToRef(tempPositionScaled).scaleInPlace(this.position.length()); // what would tempPosition be if it were scaled to same radius as before\r\n this._tempPosition.subtractToRef(tempPositionScaled, offset); // find offset between tempPosition and the tempScaledPosition\r\n this._tempPosition.subtractInPlace(offset); // reduce tempPosition by that offset\r\n\r\n // 2. Calculate the rotation correction to keep camera facing globe\r\n this._applyRotationCorrectionAndSetPos(this._tempPosition);\r\n }\r\n\r\n /**\r\n * This rotation keeps the camera oriented towards the globe as it orbits around it. This is different from cameraCentricRotation which is when the camera rotates around its own axis\r\n */\r\n private _applyGeocentricRotation(): void {\r\n // Normalize key vectors\r\n this._geocentricRotationPt.normalizeToRef(this._tempGeocentricNormal);\r\n this.upVector.normalize();\r\n this._lookAtVector.normalize();\r\n\r\n const pitchRotationMatrix = Matrix.Identity();\r\n const yawRotationMatrix = Matrix.Identity();\r\n // First apply pitch\r\n if (this._perFrameGeocentricRotation.x !== 0) {\r\n // Compute a rotation axis that is perpendicular to both the upVector and the geocentricNormalOfPitchPoint\r\n Vector3.CrossToRef(this.upVector, this._tempGeocentricNormal, this._tempRotationAxis);\r\n\r\n // If upVector and geocentricNormalOfPitchPoint are parallel, fall back to cross(lookAtDirection, geocentricNormalOfPitchPoint)\r\n if (this._tempRotationAxis.lengthSquared() <= Epsilon) {\r\n Vector3.CrossToRef(this._lookAtVector, this._tempGeocentricNormal, this._tempRotationAxis);\r\n }\r\n\r\n const pitchSign = Math.sign(Vector3.Dot(this._tempGeocentricNormal, this.upVector)); // If negative, camera is upside down\r\n // Since these are pointed in opposite directions, we must negate the dot product to get the proper angle\r\n const currentPitch = pitchSign * Math.acos(Scalar.Clamp(-Vector3.Dot(this._lookAtVector, this._tempGeocentricNormal), -1, 1));\r\n const newPitch = Scalar.Clamp(currentPitch + this._perFrameGeocentricRotation.x, 0, 0.5 * Math.PI - Epsilon);\r\n // Build rotation matrix around normalized axis\r\n Matrix.RotationAxisToRef(this._tempRotationAxis.normalize(), newPitch - currentPitch, pitchRotationMatrix);\r\n }\r\n\r\n // Then apply yaw\r\n if (this._perFrameGeocentricRotation.y !== 0) {\r\n Matrix.RotationAxisToRef(this._tempGeocentricNormal, this._perFrameGeocentricRotation.y, yawRotationMatrix); // this axis changes if we aren't using center of screen for tilt\r\n }\r\n pitchRotationMatrix.multiplyToRef(yawRotationMatrix, this._tempRotationMatrix);\r\n\r\n // Offset camera to be (position-pitchPoint) distance from geocentricOrigin, apply rotation to position/up/lookat vectors, then add back the pitchPoint offset\r\n this.position.subtractInPlace(this._geocentricRotationPt);\r\n\r\n Vector3.TransformCoordinatesToRef(this.position, this._tempRotationMatrix, this.position);\r\n Vector3.TransformNormalToRef(this.upVector, this._tempRotationMatrix, this.upVector);\r\n Vector3.TransformNormalToRef(this._lookAtVector, this._tempRotationMatrix, this._lookAtVector);\r\n\r\n this.position.addInPlace(this._geocentricRotationPt);\r\n }\r\n\r\n private _clampZoomDistance(requestedDistance: number, pickResultDistance: number | undefined): number {\r\n // If pickResult is defined\r\n if (requestedDistance > 0) {\r\n if (pickResultDistance !== undefined) {\r\n // If there is a pick, allow movement up to pick - minAltitude\r\n if (pickResultDistance - this._minAltitude < 0) {\r\n return 0;\r\n }\r\n return Math.min(requestedDistance, pickResultDistance - this._minAltitude);\r\n } else {\r\n return requestedDistance;\r\n }\r\n }\r\n\r\n if (requestedDistance < 0) {\r\n const maxZoomOut = this._maxCameraRadius ? this._maxCameraRadius - this.position.length() : Number.POSITIVE_INFINITY;\r\n return Math.max(requestedDistance, -maxZoomOut);\r\n }\r\n return 0;\r\n }\r\n\r\n private _applyZoom(distance: number) {\r\n const pickResult = this._scene.pick(this._scene.pointerX, this._scene.pointerY, this.pickPredicate);\r\n if (pickResult.hit && pickResult.ray) {\r\n // Zoom to cursor\r\n this._moveCameraAlongVectorByDistance(pickResult.ray.direction, this._clampZoomDistance(distance, pickResult.distance));\r\n } else {\r\n // If no hit under cursor, zoom along lookVector instead\r\n this._moveCameraAlongVectorByDistance(this._lookAtVector, this._clampZoomDistance(distance, this._pickAlongLook?.distance));\r\n }\r\n }\r\n\r\n private _moveCameraAlongVectorByDistance(vector: Vector3, distance: number) {\r\n if (distance) {\r\n vector.scaleAndAddToRef(distance, this._tempPosition);\r\n this._applyRotationCorrectionAndSetPos(this._tempPosition);\r\n }\r\n }\r\n\r\n private get _pickAlongLook() {\r\n this._tempPickingRay.origin.copyFrom(this.position);\r\n this._tempPickingRay.direction.copyFrom(this._lookAtVector);\r\n return this._scene.pickWithRay(this._tempPickingRay, this.pickPredicate);\r\n }\r\n\r\n override _checkInputs(): void {\r\n this.inputs.checkInputs();\r\n if (this._perFrameGeocentricTranslation.lengthSquared() > 0) {\r\n this._applyGeocentricTranslation();\r\n this._perFrameGeocentricTranslation.setAll(0);\r\n this._isViewMatrixDirty = true;\r\n }\r\n if (this._perFrameGeocentricRotation.lengthSquared() > 0) {\r\n this._applyGeocentricRotation();\r\n this._perFrameGeocentricRotation.setAll(0);\r\n this._isViewMatrixDirty = true;\r\n }\r\n if (this._perFrameZoom !== 0) {\r\n this._applyZoom(this._perFrameZoom);\r\n this._perFrameZoom = 0;\r\n this._isViewMatrixDirty = true;\r\n }\r\n super._checkInputs();\r\n }\r\n\r\n override attachControl(noPreventDefault?: boolean): void {\r\n this.inputs.attachElement(noPreventDefault);\r\n }\r\n\r\n override detachControl(): void {\r\n this.inputs.detachElement();\r\n }\r\n}\r\n\r\n// Helper to build east/north/up basis vectors at a world position\r\nfunction ComputeLocalBasisToRefs(worldPos: Vector3, refEast: Vector3, refNorth: Vector3, refUp: Vector3) {\r\n // up = normalized position (geocentric normal)\r\n refUp.copyFrom(worldPos).normalize();\r\n\r\n // east = normalize(up × worldUp)\r\n // (cross product of up with world Y gives east except at poles)\r\n const worldUp = Vector3.Up(); // (0,1,0)\r\n Vector3.CrossToRef(refUp, worldUp, refEast);\r\n\r\n // at poles, cross with worldForward instead\r\n if (refEast.lengthSquared() < Epsilon) {\r\n Vector3.CrossToRef(refUp, Vector3.Forward(), refEast);\r\n }\r\n refEast.normalize();\r\n\r\n // north = up × east (completes right-handed basis)\r\n Vector3.CrossToRef(refUp, refEast, refNorth);\r\n refNorth.normalize();\r\n}\r\n\r\n/**\r\n * Calculates changeOfBasis matrix from currentPos to newPos and stores it in ref\r\n * @param currentPos\r\n * @param newPos\r\n * @param ref\r\n * @returns The changeOfBasis matrix from currentPos to newPos\r\n */\r\nfunction ComputeChangeOfBasisToRef(currentPos: Vector3, newPos: Vector3, ref: Matrix): Matrix {\r\n const currentBasis = TmpVectors.Matrix[5];\r\n const newBasis = TmpVectors.Matrix[6];\r\n const inverse = TmpVectors.Matrix[7];\r\n const east = TmpVectors.Vector3[3];\r\n const north = TmpVectors.Vector3[4];\r\n const up = TmpVectors.Vector3[5];\r\n\r\n ComputeLocalBasisToRefs(currentPos, east, north, up);\r\n Matrix.FromXYZAxesToRef(east, north, up, currentBasis);\r\n\r\n ComputeLocalBasisToRefs(newPos, east, north, up);\r\n Matrix.FromXYZAxesToRef(east, north, up, newBasis);\r\n\r\n // Change of basis matrix = basis2 * basis1.inverse()\r\n // (since orthonormal, inverse = transpose)\r\n currentBasis.transposeToRef(inverse).multiplyToRef(newBasis, ref);\r\n\r\n return ref;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"geospatialCamera.js","sourceRoot":"","sources":["../../../../dev/core/src/Cameras/geospatialCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAOnF;;;;;GAKG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM;IAoBxC,YAAY,IAAY,EAAE,KAAY,EAAE,OAAsB,EAAE,aAA6B;QACzF,KAAK,CAAC,IAAI,EAAE,IAAI,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QAZtC,YAAY;QACJ,kBAAa,GAAY,IAAI,OAAO,EAAE,CAAC;QAEvC,gBAAW,GAAG,IAAI,MAAM,EAAE,CAAC;QAE3B,kBAAa,GAAY,IAAI,OAAO,EAAE,CAAC;QAIvC,kBAAa,GAAkD,IAAI,GAAG,EAAE,CAAC;QAkBzE,YAAO,GAAY,IAAI,OAAO,EAAE,CAAC;QAejC,SAAI,GAAW,CAAC,CAAC;QAgBjB,WAAM,GAAW,CAAC,CAAC;QAqBnB,YAAO,GAAW,CAAC,CAAC;QAoBpB,cAAS,GAAG,IAAI,OAAO,EAAE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,GAAG,OAAO,EAAE,CAAC;YAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,0BAA0B,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;YAC/F,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QACnC,CAAC;QAED,KAAK,CAAC,YAAY,EAAE,CAAC;IACzB,CAAC;IAEQ,aAAa,CAAC,gBAA0B;QAC7C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAEQ,aAAa;QAClB,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;CACJ","sourcesContent":["import { GeospatialCameraInputsManager } from \"./geospatialCameraInputsManager\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Camera } from \"./camera\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { MeshPredicate } from \"../Culling/ray.core\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { GeospatialLimits } from \"./Limits/geospatialLimits\";\r\nimport { ComputeLocalBasisToRefs, GeospatialCameraMovement } from \"./geospatialCameraMovement\";\r\nimport type { IVector3Like } from \"../Maths/math.like\";\r\nimport { Vector3CopyToRef, Vector3Dot } from \"../Maths/math.vector.functions\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\nimport type { AllowedAnimValue } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\nimport { InterpolatingBehavior } from \"../Behaviors/Cameras/interpolatingBehavior\";\r\nimport type { EasingFunction } from \"../Animations/easing\";\r\n\r\ntype CameraOptions = {\r\n planetRadius: number; // Radius of the planet\r\n};\r\n\r\n/**\r\n * @experimental\r\n * This camera's movements are limited to a camera orbiting a globe, and as the API evolves it will introduce conversions between cartesian coordinates and true lat/long/alt\r\n *\r\n * Please note this is marked as experimental and the API (including the constructor!) will change until we remove that flag\r\n */\r\nexport class GeospatialCamera extends Camera {\r\n override inputs: GeospatialCameraInputsManager;\r\n\r\n /** If supplied, will be used when picking the globe */\r\n public pickPredicate?: MeshPredicate;\r\n\r\n /** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/\r\n public readonly movement: GeospatialCameraMovement;\r\n\r\n // Temp vars\r\n private _tempPosition: Vector3 = new Vector3();\r\n\r\n private _viewMatrix = new Matrix();\r\n private _isViewMatrixDirty: boolean;\r\n private _lookAtVector: Vector3 = new Vector3();\r\n\r\n /** Behavior used for smooth flying animations */\r\n private _flyingBehavior: InterpolatingBehavior<GeospatialCamera>;\r\n private _flyToTargets: Map<keyof GeospatialCamera, AllowedAnimValue> = new Map();\r\n\r\n constructor(name: string, scene: Scene, options: CameraOptions, pickPredicate?: MeshPredicate) {\r\n super(name, new Vector3(), scene);\r\n\r\n this._limits = new GeospatialLimits(options.planetRadius);\r\n this._resetToDefault(this._limits);\r\n\r\n this._flyingBehavior = new InterpolatingBehavior();\r\n this.addBehavior(this._flyingBehavior);\r\n\r\n this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate);\r\n\r\n this.pickPredicate = pickPredicate;\r\n this.inputs = new GeospatialCameraInputsManager(this);\r\n this.inputs.addMouse().addMouseWheel().addKeyboard();\r\n }\r\n\r\n private _center: Vector3 = new Vector3();\r\n /** The point on the globe that we are anchoring around. If no alternate rotation point is supplied, this will represent the center of screen*/\r\n public get center(): Vector3 {\r\n return this._center;\r\n }\r\n\r\n /**\r\n * Sets the camera position to orbit around a new center point\r\n * @param center The world position (ECEF) to orbit around\r\n */\r\n public set center(center: IVector3Like) {\r\n this._center.copyFromFloats(center.x, center.y, center.z);\r\n this._setOrientation(this._yaw, this._pitch, this._radius, this._center);\r\n }\r\n\r\n private _yaw: number = 0;\r\n /**\r\n * Gets the camera's yaw (rotation around the geocentric normal) in radians\r\n */\r\n public get yaw(): number {\r\n return this._yaw;\r\n }\r\n\r\n /**\r\n * Sets the camera's yaw (rotation around the geocentric normal)\r\n * @param yaw The desired yaw angle in radians (0 = north, π/2 = east)\r\n */\r\n public set yaw(yaw: number) {\r\n this._setOrientation(yaw, this.pitch, this.radius, this.center);\r\n }\r\n\r\n private _pitch: number = 0;\r\n\r\n /**\r\n * Gets the camera's pitch (angle from looking straight at globe)\r\n * Pitch is measured from looking straight down at planet center:\r\n * - zero pitch = looking straight at planet center (down)\r\n * - positive pitch = tilting up away from planet\r\n * - π/2 pitch = looking at horizon (perpendicular to geocentric normal)\r\n */\r\n public get pitch(): number {\r\n return this._pitch;\r\n }\r\n\r\n /**\r\n * Sets the camera's pitch (angle from looking straight at globe)\r\n * @param pitch The desired pitch angle in radians (0 = looking at planet center, π/2 = looking at horizon)\r\n */\r\n public set pitch(pitch: number) {\r\n this._setOrientation(this.yaw, pitch, this.radius, this.center);\r\n }\r\n\r\n private _radius: number = 0;\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n /**\r\n * Sets the camera's distance from the current center point\r\n * @param radius The desired radius\r\n */\r\n public set radius(radius: number) {\r\n this._setOrientation(this.yaw, this.pitch, radius, this.center);\r\n }\r\n\r\n protected _checkLimits() {\r\n const limits = this.limits;\r\n this._yaw = Clamp(this._yaw, limits.yawMin, limits.yawMax);\r\n this._pitch = Clamp(this._pitch, limits.pitchMin, limits.pitchMax);\r\n this._radius = Clamp(this._radius, limits.radiusMin, limits.radiusMax);\r\n }\r\n\r\n private _tempVect = new Vector3();\r\n private _tempEast = new Vector3();\r\n private _tempNorth = new Vector3();\r\n private _tempUp = new Vector3();\r\n\r\n private _setOrientation(yaw: number, pitch: number, radius: number, center: DeepImmutable<IVector3Like>): void {\r\n this._yaw = yaw;\r\n this._pitch = pitch;\r\n this._radius = radius;\r\n\r\n Vector3CopyToRef(center, this._center);\r\n\r\n // Clamp to limits\r\n this._checkLimits();\r\n\r\n // Refresh local basis at center (treat these as read-only for the whole call)\r\n ComputeLocalBasisToRefs(this._center, this._tempEast, this._tempNorth, this._tempUp);\r\n\r\n // Trig\r\n const yawScale = this._scene.useRightHandedSystem ? 1 : -1;\r\n const cosYaw = Math.cos(this._yaw * yawScale);\r\n const sinYaw = Math.sin(this._yaw * yawScale);\r\n const sinPitch = Math.sin(this._pitch); // horizontal weight\r\n const cosPitch = Math.cos(this._pitch); // vertical weight (toward center)\r\n\r\n // Temps\r\n const horiz = TmpVectors.Vector3[0];\r\n const t1 = TmpVectors.Vector3[1];\r\n const t2 = TmpVectors.Vector3[2];\r\n const right = TmpVectors.Vector3[3];\r\n\r\n // horizontalDirection = North*cosYaw + East*sinYaw (avoids mutating _temp basis vectors)\r\n horiz.copyFrom(this._tempNorth).scaleInPlace(cosYaw).addInPlace(t1.copyFrom(this._tempEast).scaleInPlace(sinYaw));\r\n\r\n // look = horiz*sinPitch - Up*cosPitch\r\n this._lookAtVector.copyFrom(horiz).scaleInPlace(sinPitch).addInPlace(t2.copyFrom(this._tempUp).scaleInPlace(-cosPitch)).normalize(); // keep it unit\r\n\r\n // Build an orthonormal up aligned with geocentric Up\r\n // right = normalize(cross(upRef, look))\r\n Vector3.CrossToRef(this._tempUp, this._lookAtVector, right);\r\n\r\n // up = normalize(cross(look, right))\r\n Vector3.CrossToRef(this._lookAtVector, right, this.upVector);\r\n\r\n // Position = center - look * radius (preserve unit look)\r\n this._tempVect.copyFrom(this._lookAtVector).scaleInPlace(-this._radius);\r\n this._tempPosition.copyFrom(this._center).addInPlace(this._tempVect);\r\n\r\n this._position.copyFrom(this._tempPosition);\r\n\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n /** The point around which the camera will geocentrically rotate. Uses center (pt we are anchored to) if no alternateRotationPt is defined */\r\n private get _geocentricRotationPt(): Vector3 {\r\n return this.movement.alternateRotationPt ?? this.center;\r\n }\r\n\r\n /**\r\n * If camera is actively in flight, will update the target properties and use up the remaining duration from original flyTo call\r\n *\r\n * To start a new flyTo curve entirely, call into flyToAsync again (it will stop the inflight animation)\r\n * @param targetYaw\r\n * @param targetPitch\r\n * @param targetRadius\r\n * @param targetCenter\r\n */\r\n public updateFlyToDestination(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3): void {\r\n this._flyToTargets.clear();\r\n\r\n this._flyToTargets.set(\"yaw\", targetYaw);\r\n this._flyToTargets.set(\"pitch\", targetPitch);\r\n this._flyToTargets.set(\"radius\", targetRadius);\r\n this._flyToTargets.set(\"center\", targetCenter);\r\n\r\n this._flyingBehavior.updateProperties(this._flyToTargets);\r\n }\r\n\r\n /**\r\n * Animate camera towards passed in property values. If undefined, will use current value\r\n * @param targetYaw\r\n * @param targetPitch\r\n * @param targetRadius\r\n * @param targetCenter\r\n * @param flightDurationMs\r\n * @param easingFunction\r\n * @returns Promise that will return when the animation is complete (or interuppted by pointer input)\r\n */\r\n public async flyToAsync(\r\n targetYaw?: number,\r\n targetPitch?: number,\r\n targetRadius?: number,\r\n targetCenter?: Vector3,\r\n flightDurationMs: number = 1000,\r\n easingFunction?: EasingFunction\r\n ): Promise<void> {\r\n this._flyToTargets.clear();\r\n\r\n this._flyToTargets.set(\"yaw\", targetYaw);\r\n this._flyToTargets.set(\"pitch\", targetPitch);\r\n this._flyToTargets.set(\"radius\", targetRadius);\r\n this._flyToTargets.set(\"center\", targetCenter);\r\n\r\n return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction);\r\n }\r\n\r\n private _limits: GeospatialLimits;\r\n public get limits(): GeospatialLimits {\r\n return this._limits;\r\n }\r\n\r\n private _resetToDefault(limits: GeospatialLimits): void {\r\n // Camera configuration vars\r\n const maxCameraRadius = limits.altitudeMax !== undefined ? limits.planetRadius + limits.altitudeMax : undefined;\r\n const restingAltitude = maxCameraRadius ?? limits.planetRadius * 4;\r\n this.position.copyFromFloats(restingAltitude, 0, 0);\r\n this._center.copyFromFloats(limits.planetRadius, 0, 0);\r\n this._radius = Vector3.Distance(this.position, this.center);\r\n\r\n // Temp vars\r\n this._tempPosition = new Vector3();\r\n\r\n // View matrix calculation vars\r\n this._viewMatrix = Matrix.Identity();\r\n this._center.subtractToRef(this._position, this._lookAtVector).normalize(); // Lookat vector of the camera\r\n this.upVector = Vector3.Up(); // Up vector of the camera (does work for -X look at)\r\n this._isViewMatrixDirty = true;\r\n\r\n this._setOrientation(this._yaw, this._pitch, this._radius, this._center);\r\n }\r\n\r\n /** @internal */\r\n override _getViewMatrix() {\r\n if (!this._isViewMatrixDirty) {\r\n return this._viewMatrix;\r\n }\r\n this._isViewMatrixDirty = false;\r\n\r\n // Ensure vectors are normalized\r\n this.upVector.normalize();\r\n this._lookAtVector.normalize();\r\n\r\n // Calculate view matrix with camera position and center\r\n if (this.getScene().useRightHandedSystem) {\r\n Matrix.LookAtRHToRef(this.position, this._center, this.upVector, this._viewMatrix);\r\n } else {\r\n Matrix.LookAtLHToRef(this.position, this._center, this.upVector, this._viewMatrix);\r\n }\r\n\r\n return this._viewMatrix;\r\n }\r\n\r\n /** @internal */\r\n override _isSynchronizedViewMatrix(): boolean {\r\n if (!super._isSynchronizedViewMatrix() || this._isViewMatrixDirty) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n private _applyGeocentricTranslation() {\r\n // Store pending position (without any corrections applied)\r\n this.center.addToRef(this.movement.panDeltaCurrentFrame, this._tempPosition);\r\n\r\n if (!this.movement.isInterpolating) {\r\n // Calculate the position correction to keep camera at the same radius when applying translation\r\n this._tempPosition.normalize().scaleInPlace(this.center.length());\r\n }\r\n // Set center which will call _setOrientation\r\n this.center = this._tempPosition;\r\n }\r\n\r\n /**\r\n * This rotation keeps the camera oriented towards the globe as it orbits around it. This is different from cameraCentricRotation which is when the camera rotates around its own axis\r\n */\r\n private _applyGeocentricRotation(): void {\r\n const rotationDeltaCurrentFrame = this.movement.rotationDeltaCurrentFrame;\r\n if (rotationDeltaCurrentFrame.x !== 0 || rotationDeltaCurrentFrame.y !== 0) {\r\n const pitch = rotationDeltaCurrentFrame.x !== 0 ? Clamp(this._pitch + rotationDeltaCurrentFrame.x, 0, 0.5 * Math.PI - Epsilon) : this._pitch;\r\n const yaw = rotationDeltaCurrentFrame.y !== 0 ? this._yaw + rotationDeltaCurrentFrame.y : this._yaw;\r\n\r\n // TODO: If _geocentricRotationPt is not the center, this will need to be adjusted.\r\n this._setOrientation(yaw, pitch, this._radius, this._geocentricRotationPt);\r\n }\r\n }\r\n\r\n private _applyZoom(zoomVector: Vector3, distance: number) {\r\n // TODO this function will be re-worked shortly after checkin, becuase today it breaks down if you zoom to a point past the center\r\n // (ex: tilted view zooming towards cursor near horizon where the center is closer than the cursor point).\r\n\r\n // Project zoom vector onto lookAt vector to find the amount the camera-to-center distance should change.\r\n // - zoom vector is normalized\r\n // - distance is how much to move in this call\r\n const directionDotLookAt = Vector3Dot(zoomVector, this._lookAtVector);\r\n const hasRadialComponent = Math.abs(directionDotLookAt) > Epsilon;\r\n const requestedRadius = hasRadialComponent ? this._radius - distance * directionDotLookAt : this._radius;\r\n const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);\r\n const actualRadiusChange = newRadius - this._radius;\r\n const actualDistanceChange = hasRadialComponent ? actualRadiusChange / directionDotLookAt : 0;\r\n\r\n // Use this to compute new camera position and new center position.\r\n const newCameraPosition = this._position.add(zoomVector.scale(-actualDistanceChange));\r\n const newCenter = newCameraPosition.add(this._lookAtVector.scaleToRef(newRadius, TmpVectors.Vector3[3]));\r\n\r\n // Rescale new center to maintain same altitude as the old center.\r\n const currentCenterRadius = this._center.length();\r\n const newCenterRadius = newCenter.length();\r\n const newCenterRescale = currentCenterRadius / newCenterRadius;\r\n newCenter.scaleInPlace(newCenterRescale);\r\n\r\n // Apply changes\r\n this._setOrientation(this._yaw, this._pitch, newRadius, newCenter);\r\n }\r\n\r\n override _checkInputs(): void {\r\n this.inputs.checkInputs();\r\n\r\n // Let movement class handle all per-frame logic\r\n this.movement.computeCurrentFrameDeltas();\r\n\r\n if (this.movement.panDeltaCurrentFrame.lengthSquared() > 0) {\r\n this._applyGeocentricTranslation();\r\n this._isViewMatrixDirty = true;\r\n }\r\n if (this.movement.rotationDeltaCurrentFrame.lengthSquared() > 0) {\r\n this._applyGeocentricRotation();\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n if (Math.abs(this.movement.zoomDeltaCurrentFrame) > Epsilon) {\r\n this._applyZoom(this.movement.computedPerFrameZoomVector, this.movement.zoomDeltaCurrentFrame);\r\n this._isViewMatrixDirty = true;\r\n }\r\n\r\n super._checkInputs();\r\n }\r\n\r\n override attachControl(noPreventDefault?: boolean): void {\r\n this.inputs.attachElement(noPreventDefault);\r\n }\r\n\r\n override detachControl(): void {\r\n this.inputs.detachElement();\r\n }\r\n}\r\n"]}
|
|
@@ -20,4 +20,9 @@ export declare class GeospatialCameraInputsManager extends CameraInputsManager<G
|
|
|
20
20
|
* @returns the current input manager
|
|
21
21
|
*/
|
|
22
22
|
addMouseWheel(): GeospatialCameraInputsManager;
|
|
23
|
+
/**
|
|
24
|
+
* Add mouse wheel input support to the input manager
|
|
25
|
+
* @returns the current input manager
|
|
26
|
+
*/
|
|
27
|
+
addKeyboard(): GeospatialCameraInputsManager;
|
|
23
28
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CameraInputsManager } from "./cameraInputsManager.js";
|
|
2
2
|
import { GeospatialCameraPointersInput } from "./Inputs/geospatialCameraPointersInput.js";
|
|
3
3
|
import { GeospatialCameraMouseWheelInput } from "./Inputs/geospatialCameraMouseWheelInput.js";
|
|
4
|
+
import { GeospatialCameraKeyboardInput } from "./Inputs/geospatialCameraKeyboardInput.js";
|
|
4
5
|
/**
|
|
5
6
|
* Default Inputs manager for the GeospatialCamera.
|
|
6
7
|
* It groups all the default supported inputs for ease of use.
|
|
@@ -29,5 +30,13 @@ export class GeospatialCameraInputsManager extends CameraInputsManager {
|
|
|
29
30
|
this.add(new GeospatialCameraMouseWheelInput());
|
|
30
31
|
return this;
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Add mouse wheel input support to the input manager
|
|
35
|
+
* @returns the current input manager
|
|
36
|
+
*/
|
|
37
|
+
addKeyboard() {
|
|
38
|
+
this.add(new GeospatialCameraKeyboardInput());
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
//# sourceMappingURL=geospatialCameraInputsManager.js.map
|