@onerjs/core 8.30.9 → 8.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +52 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +105 -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/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 +16 -21
- package/Cameras/Inputs/geospatialCameraPointersInput.js +43 -73
- 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/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- package/Cameras/geospatialCamera.d.ts +53 -49
- package/Cameras/geospatialCamera.js +172 -192
- 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/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.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/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 +1 -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 +8 -0
- package/Particles/Node/Blocks/systemBlock.js +8 -0
- 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.js +6 -4
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +279 -161
- 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 +4 -6
- 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/package.json +1 -1
|
@@ -2,11 +2,11 @@ import type { GeospatialCamera } from "../../Cameras/geospatialCamera.js";
|
|
|
2
2
|
import type { IPointerEvent } from "../../Events/deviceInputEvents.js";
|
|
3
3
|
import type { PointerTouch } from "../../Events/pointerEvents.js";
|
|
4
4
|
import type { Nullable } from "../../types.js";
|
|
5
|
-
import {
|
|
5
|
+
import { OrbitCameraPointersInput } from "./orbitCameraPointersInput.js";
|
|
6
6
|
/**
|
|
7
7
|
* @experimental
|
|
8
8
|
* Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe
|
|
9
|
-
*
|
|
9
|
+
* This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately
|
|
10
10
|
*
|
|
11
11
|
* As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix
|
|
12
12
|
* As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit
|
|
@@ -16,30 +16,25 @@ import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
|
16
16
|
* Right mouse button: tilt globe around center of screen
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
|
-
export declare class GeospatialCameraPointersInput extends
|
|
19
|
+
export declare class GeospatialCameraPointersInput extends OrbitCameraPointersInput {
|
|
20
20
|
camera: GeospatialCamera;
|
|
21
|
-
/**
|
|
22
|
-
* Mouse sensitivity for rotation (lower = more sensitive)
|
|
23
|
-
*/
|
|
24
|
-
angularSensibility: number;
|
|
25
|
-
private _dragPlane;
|
|
26
|
-
private _dragPlaneNormal;
|
|
27
|
-
private _dragPlaneOriginPoint;
|
|
28
|
-
private _dragPlaneHitPoint;
|
|
29
|
-
private _dragPlaneOffsetVector;
|
|
30
|
-
private _hitPointRadius?;
|
|
31
21
|
getClassName(): string;
|
|
32
22
|
onButtonDown(evt: IPointerEvent): void;
|
|
33
23
|
onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
|
|
34
|
-
onButtonUp(_evt: IPointerEvent): void;
|
|
35
24
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
39
|
-
* @param ray The ray from the camera to the new cursor location
|
|
40
|
-
* @param ref The offset vector between the drag plane's hitPoint and originPoint
|
|
25
|
+
* Move camera from multitouch (pinch) zoom distances.
|
|
26
|
+
* @param previousPinchSquaredDistance
|
|
27
|
+
* @param pinchSquaredDistance
|
|
41
28
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
protected _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Move camera from multi touch panning positions.
|
|
32
|
+
* In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)
|
|
33
|
+
* @param previousMultiTouchPanPosition
|
|
34
|
+
* @param multiTouchPanPosition
|
|
35
|
+
*/
|
|
36
|
+
protected _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
37
|
+
onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
38
|
+
onButtonUp(_evt: IPointerEvent): void;
|
|
44
39
|
private _handleTilt;
|
|
45
40
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TmpVectors, Vector3 } from "../../Maths/math.vector.js";
|
|
3
|
-
import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
1
|
+
import { OrbitCameraPointersInput } from "./orbitCameraPointersInput.js";
|
|
4
2
|
/**
|
|
5
3
|
* @experimental
|
|
6
4
|
* Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe
|
|
7
|
-
*
|
|
5
|
+
* This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately
|
|
8
6
|
*
|
|
9
7
|
* As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix
|
|
10
8
|
* As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit
|
|
@@ -14,106 +12,78 @@ import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
|
14
12
|
* Right mouse button: tilt globe around center of screen
|
|
15
13
|
*
|
|
16
14
|
*/
|
|
17
|
-
export class GeospatialCameraPointersInput extends
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
/**
|
|
21
|
-
* Mouse sensitivity for rotation (lower = more sensitive)
|
|
22
|
-
*/
|
|
23
|
-
this.angularSensibility = 200.0;
|
|
24
|
-
this._dragPlane = new Plane(0, 0, 0, 0);
|
|
25
|
-
this._dragPlaneNormal = Vector3.Zero();
|
|
26
|
-
this._dragPlaneOriginPoint = Vector3.Zero();
|
|
27
|
-
this._dragPlaneHitPoint = Vector3.Zero();
|
|
28
|
-
this._dragPlaneOffsetVector = Vector3.Zero();
|
|
29
|
-
}
|
|
15
|
+
export class GeospatialCameraPointersInput extends OrbitCameraPointersInput {
|
|
30
16
|
getClassName() {
|
|
31
17
|
return "GeospatialCameraPointersInput";
|
|
32
18
|
}
|
|
33
19
|
onButtonDown(evt) {
|
|
20
|
+
this.camera.movement.activeInput = true;
|
|
34
21
|
const scene = this.camera.getScene();
|
|
35
22
|
let pickResult;
|
|
36
23
|
switch (evt.button) {
|
|
37
24
|
case 0: // Left button - drag/pan globe under cursor
|
|
38
|
-
|
|
39
|
-
if (pickResult.pickedPoint && pickResult.ray) {
|
|
40
|
-
// Store radius from earth center to pickedPoint, used when calculating drag plane
|
|
41
|
-
this._hitPointRadius = pickResult.pickedPoint.length();
|
|
42
|
-
// The dragPlaneOffsetVector will later be recalculated when drag occurs, and the delta between the offset vectors will be applied to localTranslation
|
|
43
|
-
this._recalculateDragPlaneOffsetVectorToRef(this._hitPointRadius, pickResult.ray, this._dragPlaneOffsetVector);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this._hitPointRadius = undefined; // can't drag without a hit on the globe
|
|
47
|
-
}
|
|
25
|
+
this.camera.movement.startDrag(scene.pointerX, scene.pointerY);
|
|
48
26
|
break;
|
|
49
27
|
case 1: // Middle button - tilt camera around cursor
|
|
50
28
|
pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);
|
|
51
|
-
pickResult.pickedPoint && (this.camera.
|
|
29
|
+
pickResult.pickedPoint && (this.camera.movement.alternateRotationPt = pickResult.pickedPoint);
|
|
52
30
|
break;
|
|
53
31
|
case 2: // Right button - tilt camera around center of screen, already the default
|
|
54
|
-
this.camera.
|
|
32
|
+
this.camera.movement.alternateRotationPt = this.camera.center;
|
|
55
33
|
break;
|
|
56
34
|
default:
|
|
57
35
|
return;
|
|
58
36
|
}
|
|
59
37
|
}
|
|
60
38
|
onTouch(point, offsetX, offsetY) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
// Single finger touch (no button property) or left button (button 0) = drag
|
|
40
|
+
const button = point?.button ?? 0; // Default to button 0 (drag) if undefined
|
|
41
|
+
const scene = this.camera.getScene();
|
|
42
|
+
switch (button) {
|
|
43
|
+
case 0: // Left button / single touch - drag/pan globe under cursor
|
|
44
|
+
this.camera.movement.handleDrag(scene.pointerX, scene.pointerY);
|
|
64
45
|
break;
|
|
65
|
-
case 1: // Middle button - tilt camera
|
|
46
|
+
case 1: // Middle button - tilt camera
|
|
66
47
|
case 2: // Right button - tilt camera
|
|
67
48
|
this._handleTilt(offsetX, offsetY);
|
|
68
49
|
break;
|
|
69
50
|
}
|
|
70
51
|
}
|
|
71
|
-
onButtonUp(_evt) {
|
|
72
|
-
this._hitPointRadius = undefined;
|
|
73
|
-
this.camera._alternateRotationPt = null;
|
|
74
|
-
}
|
|
75
52
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param ray The ray from the camera to the new cursor location
|
|
80
|
-
* @param ref The offset vector between the drag plane's hitPoint and originPoint
|
|
53
|
+
* Move camera from multitouch (pinch) zoom distances.
|
|
54
|
+
* @param previousPinchSquaredDistance
|
|
55
|
+
* @param pinchSquaredDistance
|
|
81
56
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.camera.position.normalizeToRef(this._dragPlaneNormal);
|
|
85
|
-
this._dragPlaneNormal.scaleToRef(hitPointRadius, this._dragPlaneOriginPoint);
|
|
86
|
-
// Now create a plane at that point, perpendicular to the camera's geocentric normal
|
|
87
|
-
Plane.FromPositionAndNormalToRef(this._dragPlaneOriginPoint, this._dragPlaneNormal, this._dragPlane);
|
|
88
|
-
// Lastly, find the _dragPlaneHitPoint where the ray intersects the _dragPlane
|
|
89
|
-
IntersectRayWithPlaneToRef(ray, this._dragPlane, this._dragPlaneHitPoint);
|
|
90
|
-
// Store the new offset between the drag plane's hitPoint and originPoint
|
|
91
|
-
this._dragPlaneHitPoint.subtractToRef(this._dragPlaneOriginPoint, ref);
|
|
57
|
+
_computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance) {
|
|
58
|
+
this.camera.radius = (this.camera.radius * Math.sqrt(previousPinchSquaredDistance)) / Math.sqrt(pinchSquaredDistance);
|
|
92
59
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Move camera from multi touch panning positions.
|
|
62
|
+
* In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)
|
|
63
|
+
* @param previousMultiTouchPanPosition
|
|
64
|
+
* @param multiTouchPanPosition
|
|
65
|
+
*/
|
|
66
|
+
_computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
67
|
+
if (previousMultiTouchPanPosition && multiTouchPanPosition) {
|
|
68
|
+
const moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
|
|
69
|
+
const moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
|
|
70
|
+
this._handleTilt(moveDeltaX, moveDeltaY);
|
|
103
71
|
}
|
|
104
72
|
}
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
73
|
+
onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
74
|
+
this._shouldStartPinchZoom =
|
|
75
|
+
this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.limits.pinchToPanMax;
|
|
76
|
+
super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
108
77
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
78
|
+
onButtonUp(_evt) {
|
|
79
|
+
this.camera.movement.stopDrag();
|
|
80
|
+
this.camera.movement.alternateRotationPt = undefined;
|
|
81
|
+
this.camera.movement.activeInput = false;
|
|
82
|
+
super.onButtonUp(_evt);
|
|
83
|
+
}
|
|
84
|
+
_handleTilt(deltaX, deltaY) {
|
|
85
|
+
this.camera.movement.rotationAccumulatedPixels.y -= deltaX; // yaw - looking side to side
|
|
86
|
+
this.camera.movement.rotationAccumulatedPixels.x -= deltaY; // pitch - look up towards sky / down towards ground
|
|
116
87
|
}
|
|
117
|
-
return false;
|
|
118
88
|
}
|
|
119
89
|
//# sourceMappingURL=geospatialCameraPointersInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geospatialCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraPointersInput.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EA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AA2B,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,6BAA6B;QAC7G,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,oDAAoD;IACxI,CAAC;CACJ;AAED,SAAS,0BAA0B,CAAC,GAAQ,EAAE,KAAY,EAAE,GAAY;IACpE,sDAAsD;IACtD,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QAC7B,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import type { GeospatialCamera } from \"../../Cameras/geospatialCamera\";\r\nimport type { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport { Plane } from \"../../Maths/math.plane\";\r\nimport { TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { BaseCameraPointersInput } from \"./BaseCameraPointersInput\";\r\n\r\n/**\r\n * @experimental\r\n * Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe\r\n * The input will update the camera's localTranslation or localRotation values, and the camera is responsible for using these updates to calculate viewMatrix appropriately\r\n *\r\n * As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix\r\n * As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit\r\n *\r\n * Left mouse button: drag globe\r\n * Middle mouse button: tilt globe around cursor location\r\n * Right mouse button: tilt globe around center of screen\r\n *\r\n */\r\nexport class GeospatialCameraPointersInput extends BaseCameraPointersInput {\r\n public camera: GeospatialCamera;\r\n\r\n /**\r\n * Mouse sensitivity for rotation (lower = more sensitive)\r\n */\r\n public angularSensibility = 200.0;\r\n\r\n private _dragPlane: Plane = new Plane(0, 0, 0, 0);\r\n private _dragPlaneNormal: Vector3 = Vector3.Zero();\r\n private _dragPlaneOriginPoint: Vector3 = Vector3.Zero();\r\n private _dragPlaneHitPoint: Vector3 = Vector3.Zero();\r\n private _dragPlaneOffsetVector: Vector3 = Vector3.Zero();\r\n\r\n private _hitPointRadius?: number; // Distance between world origin (center of globe) and the hitPoint (where initial drag started)\r\n\r\n public override getClassName(): string {\r\n return \"GeospatialCameraPointersInput\";\r\n }\r\n\r\n public override onButtonDown(evt: IPointerEvent): void {\r\n const scene = this.camera.getScene();\r\n let pickResult: Nullable<PickingInfo>;\r\n switch (evt.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n if (pickResult.pickedPoint && pickResult.ray) {\r\n // Store radius from earth center to pickedPoint, used when calculating drag plane\r\n this._hitPointRadius = pickResult.pickedPoint.length();\r\n\r\n // The dragPlaneOffsetVector will later be recalculated when drag occurs, and the delta between the offset vectors will be applied to localTranslation\r\n this._recalculateDragPlaneOffsetVectorToRef(this._hitPointRadius, pickResult.ray, this._dragPlaneOffsetVector);\r\n } else {\r\n this._hitPointRadius = undefined; // can't drag without a hit on the globe\r\n }\r\n break;\r\n case 1: // Middle button - tilt camera around cursor\r\n pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n pickResult.pickedPoint && (this.camera._alternateRotationPt = pickResult.pickedPoint);\r\n break;\r\n case 2: // Right button - tilt camera around center of screen, already the default\r\n this.camera._alternateRotationPt = this.camera.center;\r\n break;\r\n default:\r\n return;\r\n }\r\n }\r\n\r\n public override onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {\r\n switch (point?.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n this._hitPointRadius !== undefined && this._handleDrag(this._hitPointRadius);\r\n break;\r\n case 1: // Middle button - tilt camera around cursor\r\n case 2: // Right button - tilt camera\r\n this._handleTilt(offsetX, offsetY);\r\n break;\r\n }\r\n }\r\n\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this._hitPointRadius = undefined;\r\n this.camera._alternateRotationPt = null;\r\n }\r\n\r\n /**\r\n * The DragPlaneOffsetVector represents the vector between the dragPlane hit point and the dragPlane origin point.\r\n * As the drag movement occurs, we will continuously recalculate this vector. The delta between the offsetVectors is the delta we will apply to the camera's localtranslation\r\n * @param hitPointRadius The distance between the world origin (center of globe) and the initial drag hit point\r\n * @param ray The ray from the camera to the new cursor location\r\n * @param ref The offset vector between the drag plane's hitPoint and originPoint\r\n */\r\n private _recalculateDragPlaneOffsetVectorToRef(hitPointRadius: number, ray: Ray, ref: Vector3) {\r\n // Use the camera's geocentric normal to find the dragPlaneOriginPoint which lives at hitPointRadius along the camera's geocentric normal\r\n this.camera.position.normalizeToRef(this._dragPlaneNormal);\r\n this._dragPlaneNormal.scaleToRef(hitPointRadius, this._dragPlaneOriginPoint);\r\n\r\n // Now create a plane at that point, perpendicular to the camera's geocentric normal\r\n Plane.FromPositionAndNormalToRef(this._dragPlaneOriginPoint, this._dragPlaneNormal, this._dragPlane);\r\n\r\n // Lastly, find the _dragPlaneHitPoint where the ray intersects the _dragPlane\r\n IntersectRayWithPlaneToRef(ray, this._dragPlane, this._dragPlaneHitPoint);\r\n\r\n // Store the new offset between the drag plane's hitPoint and originPoint\r\n this._dragPlaneHitPoint.subtractToRef(this._dragPlaneOriginPoint, ref);\r\n }\r\n\r\n private _handleDrag(hitPointRadius: number): void {\r\n const scene = this.camera.getScene();\r\n const pickResult = scene.pick(scene.pointerX, scene.pointerY);\r\n if (pickResult.ray) {\r\n const newDragPlaneOffsetVector = TmpVectors.Vector3[5];\r\n this._recalculateDragPlaneOffsetVectorToRef(hitPointRadius, pickResult.ray, newDragPlaneOffsetVector);\r\n const delta = TmpVectors.Vector3[6];\r\n newDragPlaneOffsetVector.subtractToRef(this._dragPlaneOffsetVector, delta);\r\n\r\n this._dragPlaneOffsetVector.copyFrom(newDragPlaneOffsetVector);\r\n\r\n this.camera._perFrameGeocentricTranslation.subtractInPlace(delta); // ???\r\n }\r\n }\r\n\r\n private _handleTilt(deltaX: number, deltaY: number): void {\r\n this.camera._perFrameGeocentricRotation.y += -deltaX / this.angularSensibility; // yaw - looking side to side\r\n this.camera._perFrameGeocentricRotation.x += -deltaY / this.angularSensibility; // pitch - look up towards sky / down towards ground\r\n }\r\n}\r\n\r\nfunction IntersectRayWithPlaneToRef(ray: Ray, plane: Plane, ref: Vector3): boolean {\r\n // Distance along the ray to the plane; null if no hit\r\n const dist = ray.intersectsPlane(plane);\r\n\r\n if (dist !== null && dist >= 0) {\r\n ray.origin.addToRef(ray.direction.scaleToRef(dist, TmpVectors.Vector3[0]), ref);\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"geospatialCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraPointersInput.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,6BAA8B,SAAQ,wBAAwB;IAGvD,YAAY;QACxB,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAEe,YAAY,CAAC,GAAkB;QAC3C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,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AC,QAAQ,CAAC,mBAAmB,GAAG,SAAS,CAAC;QACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC;QACzC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEO,WAAW,CAAC,MAAc,EAAE,MAAc;QAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,6BAA6B;QACzF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,oDAAoD;IACpH,CAAC;CACJ","sourcesContent":["import type { GeospatialCamera } from \"../../Cameras/geospatialCamera\";\r\nimport type { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { OrbitCameraPointersInput } from \"./orbitCameraPointersInput\";\r\n\r\n/**\r\n * @experimental\r\n * Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe\r\n * This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately\r\n *\r\n * As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix\r\n * As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit\r\n *\r\n * Left mouse button: drag globe\r\n * Middle mouse button: tilt globe around cursor location\r\n * Right mouse button: tilt globe around center of screen\r\n *\r\n */\r\nexport class GeospatialCameraPointersInput extends OrbitCameraPointersInput {\r\n public camera: GeospatialCamera;\r\n\r\n public override getClassName(): string {\r\n return \"GeospatialCameraPointersInput\";\r\n }\r\n\r\n public override onButtonDown(evt: IPointerEvent): void {\r\n this.camera.movement.activeInput = true;\r\n const scene = this.camera.getScene();\r\n let pickResult: Nullable<PickingInfo>;\r\n switch (evt.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n this.camera.movement.startDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera around cursor\r\n pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n pickResult.pickedPoint && (this.camera.movement.alternateRotationPt = pickResult.pickedPoint);\r\n break;\r\n case 2: // Right button - tilt camera around center of screen, already the default\r\n this.camera.movement.alternateRotationPt = this.camera.center;\r\n break;\r\n default:\r\n return;\r\n }\r\n }\r\n\r\n public override onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {\r\n // Single finger touch (no button property) or left button (button 0) = drag\r\n const button = point?.button ?? 0; // Default to button 0 (drag) if undefined\r\n const scene = this.camera.getScene();\r\n switch (button) {\r\n case 0: // Left button / single touch - drag/pan globe under cursor\r\n this.camera.movement.handleDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera\r\n case 2: // Right button - tilt camera\r\n this._handleTilt(offsetX, offsetY);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Move camera from multitouch (pinch) zoom distances.\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n */\r\n protected override _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void {\r\n this.camera.radius = (this.camera.radius * Math.sqrt(previousPinchSquaredDistance)) / Math.sqrt(pinchSquaredDistance);\r\n }\r\n\r\n /**\r\n * Move camera from multi touch panning positions.\r\n * In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n protected override _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void {\r\n if (previousMultiTouchPanPosition && multiTouchPanPosition) {\r\n const moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;\r\n const moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;\r\n this._handleTilt(moveDeltaX, moveDeltaY);\r\n }\r\n }\r\n\r\n public override onMultiTouch(\r\n pointA: Nullable<PointerTouch>,\r\n pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n this._shouldStartPinchZoom =\r\n this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.limits.pinchToPanMax;\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this.camera.movement.stopDrag();\r\n this.camera.movement.alternateRotationPt = undefined;\r\n this.camera.movement.activeInput = false;\r\n super.onButtonUp(_evt);\r\n }\r\n\r\n private _handleTilt(deltaX: number, deltaY: number): void {\r\n this.camera.movement.rotationAccumulatedPixels.y -= deltaX; // yaw - looking side to side\r\n this.camera.movement.rotationAccumulatedPixels.x -= deltaY; // pitch - look up towards sky / down towards ground\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Nullable } from "../../types.js";
|
|
2
|
+
import type { PointerTouch } from "../../Events/pointerEvents.js";
|
|
3
|
+
import type { IPointerEvent } from "../../Events/deviceInputEvents.js";
|
|
4
|
+
import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
5
|
+
/**
|
|
6
|
+
* Used by both arcrotatecamera and geospatialcamera, OrbitCameraPointersInputs handle pinchToZoom and multiTouchPanning
|
|
7
|
+
* as though you are orbiting around a target point
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class OrbitCameraPointersInput extends BaseCameraPointersInput {
|
|
10
|
+
/**
|
|
11
|
+
* Defines whether zoom (2 fingers pinch) is enabled through multitouch
|
|
12
|
+
*/
|
|
13
|
+
pinchZoom: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Defines whether panning (2 fingers swipe) is enabled through multitouch.
|
|
16
|
+
*/
|
|
17
|
+
multiTouchPanning: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Defines whether panning is enabled for both pan (2 fingers swipe) and
|
|
20
|
+
* zoom (pinch) through multitouch.
|
|
21
|
+
*/
|
|
22
|
+
multiTouchPanAndZoom: boolean;
|
|
23
|
+
protected _isPinching: boolean;
|
|
24
|
+
protected _twoFingerActivityCount: number;
|
|
25
|
+
protected _shouldStartPinchZoom: boolean;
|
|
26
|
+
protected _computePinchZoom(_previousPinchSquaredDistance: number, _pinchSquaredDistance: number): void;
|
|
27
|
+
protected _computeMultiTouchPanning(_previousMultiTouchPanPosition: Nullable<PointerTouch>, _multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Called on pointer POINTERMOVE event if multiple touches are active.
|
|
30
|
+
* Override this method to provide functionality.
|
|
31
|
+
* @param _pointA First point in the pair
|
|
32
|
+
* @param _pointB Second point in the pair
|
|
33
|
+
* @param previousPinchSquaredDistance Sqr Distance between the points the last time this event was fired (by this input)
|
|
34
|
+
* @param pinchSquaredDistance Sqr Distance between the points this time
|
|
35
|
+
* @param previousMultiTouchPanPosition Previous center point between the points
|
|
36
|
+
* @param multiTouchPanPosition Current center point between the points
|
|
37
|
+
*/
|
|
38
|
+
onMultiTouch(_pointA: Nullable<PointerTouch>, _pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Called each time a new POINTERUP event occurs. Ie, for each button
|
|
41
|
+
* release.
|
|
42
|
+
* @param _evt Defines the event to track
|
|
43
|
+
*/
|
|
44
|
+
onButtonUp(_evt: IPointerEvent): void;
|
|
45
|
+
/**
|
|
46
|
+
* Called when window becomes inactive.
|
|
47
|
+
*/
|
|
48
|
+
onLostFocus(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { __decorate } from "../../tslib.es6.js";
|
|
2
|
+
import { serialize } from "../../Misc/decorators.js";
|
|
3
|
+
import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
4
|
+
/**
|
|
5
|
+
* Used by both arcrotatecamera and geospatialcamera, OrbitCameraPointersInputs handle pinchToZoom and multiTouchPanning
|
|
6
|
+
* as though you are orbiting around a target point
|
|
7
|
+
*/
|
|
8
|
+
export class OrbitCameraPointersInput extends BaseCameraPointersInput {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
/**
|
|
12
|
+
* Defines whether zoom (2 fingers pinch) is enabled through multitouch
|
|
13
|
+
*/
|
|
14
|
+
this.pinchZoom = true;
|
|
15
|
+
/**
|
|
16
|
+
* Defines whether panning (2 fingers swipe) is enabled through multitouch.
|
|
17
|
+
*/
|
|
18
|
+
this.multiTouchPanning = true;
|
|
19
|
+
/**
|
|
20
|
+
* Defines whether panning is enabled for both pan (2 fingers swipe) and
|
|
21
|
+
* zoom (pinch) through multitouch.
|
|
22
|
+
*/
|
|
23
|
+
this.multiTouchPanAndZoom = true;
|
|
24
|
+
this._isPinching = false;
|
|
25
|
+
this._twoFingerActivityCount = 0;
|
|
26
|
+
this._shouldStartPinchZoom = false;
|
|
27
|
+
}
|
|
28
|
+
_computePinchZoom(_previousPinchSquaredDistance, _pinchSquaredDistance) { }
|
|
29
|
+
_computeMultiTouchPanning(_previousMultiTouchPanPosition, _multiTouchPanPosition) { }
|
|
30
|
+
/**
|
|
31
|
+
* Called on pointer POINTERMOVE event if multiple touches are active.
|
|
32
|
+
* Override this method to provide functionality.
|
|
33
|
+
* @param _pointA First point in the pair
|
|
34
|
+
* @param _pointB Second point in the pair
|
|
35
|
+
* @param previousPinchSquaredDistance Sqr Distance between the points the last time this event was fired (by this input)
|
|
36
|
+
* @param pinchSquaredDistance Sqr Distance between the points this time
|
|
37
|
+
* @param previousMultiTouchPanPosition Previous center point between the points
|
|
38
|
+
* @param multiTouchPanPosition Current center point between the points
|
|
39
|
+
*/
|
|
40
|
+
onMultiTouch(_pointA, _pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
41
|
+
if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
|
|
42
|
+
// First time this method is called for new pinch.
|
|
43
|
+
// Next time this is called there will be a
|
|
44
|
+
// previousPinchSquaredDistance and pinchSquaredDistance to compare.
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
|
|
48
|
+
// Last time this method is called at the end of a pinch.
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Zoom and panning enabled together
|
|
52
|
+
if (this.multiTouchPanAndZoom) {
|
|
53
|
+
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
54
|
+
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
55
|
+
// Zoom and panning enabled but only one at a time
|
|
56
|
+
}
|
|
57
|
+
else if (this.multiTouchPanning && this.pinchZoom) {
|
|
58
|
+
this._twoFingerActivityCount++;
|
|
59
|
+
if (this._isPinching || this._shouldStartPinchZoom) {
|
|
60
|
+
// Since pinch has not been active long, assume we intend to zoom.
|
|
61
|
+
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
62
|
+
// Since we are pinching, remain pinching on next iteration.
|
|
63
|
+
this._isPinching = true;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Pause between pinch starting and moving implies not a zoom event. Pan instead.
|
|
67
|
+
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
68
|
+
}
|
|
69
|
+
// Panning enabled, zoom disabled
|
|
70
|
+
}
|
|
71
|
+
else if (this.multiTouchPanning) {
|
|
72
|
+
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
73
|
+
// Zoom enabled, panning disabled
|
|
74
|
+
}
|
|
75
|
+
else if (this.pinchZoom) {
|
|
76
|
+
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Called each time a new POINTERUP event occurs. Ie, for each button
|
|
81
|
+
* release.
|
|
82
|
+
* @param _evt Defines the event to track
|
|
83
|
+
*/
|
|
84
|
+
onButtonUp(_evt) {
|
|
85
|
+
this._twoFingerActivityCount = 0;
|
|
86
|
+
this._isPinching = false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Called when window becomes inactive.
|
|
90
|
+
*/
|
|
91
|
+
onLostFocus() {
|
|
92
|
+
this._twoFingerActivityCount = 0;
|
|
93
|
+
this._isPinching = false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
__decorate([
|
|
97
|
+
serialize()
|
|
98
|
+
], OrbitCameraPointersInput.prototype, "pinchZoom", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
serialize()
|
|
101
|
+
], OrbitCameraPointersInput.prototype, "multiTouchPanning", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
serialize()
|
|
104
|
+
], OrbitCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
|
|
105
|
+
//# sourceMappingURL=orbitCameraPointersInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orbitCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/orbitCameraPointersInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,uBAAuB,EAAE,MAAM,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E,IAAI,CAAC,iBAAiB,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAC;gBAE3E,4DAA4D;gBAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACJ,iFAAiF;gBACjF,IAAI,CAAC,yBAAyB,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;YACzF,CAAC;YAED,iCAAiC;QACrC,CAAC;aAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAChC,IAAI,CAAC,yBAAyB,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;YAErF,iCAAiC;QACrC,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,iBAAiB,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAC;QAC/E,CAAC;IACL,CAAC;IAED;;;;OAIG;IACa,UAAU,CAAC,IAAmB;QAC1C,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED;;OAEG;IACa,WAAW;QACvB,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;CACJ;AAnGU;IADN,SAAS,EAAE;2DACqB;AAM1B;IADN,SAAS,EAAE;mEAC6B;AAOlC;IADN,SAAS,EAAE;sEACgC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport { BaseCameraPointersInput } from \"./BaseCameraPointersInput\";\r\n\r\n/**\r\n * Used by both arcrotatecamera and geospatialcamera, OrbitCameraPointersInputs handle pinchToZoom and multiTouchPanning\r\n * as though you are orbiting around a target point\r\n */\r\nexport abstract class OrbitCameraPointersInput extends BaseCameraPointersInput {\r\n /**\r\n * Defines whether zoom (2 fingers pinch) is enabled through multitouch\r\n */\r\n @serialize()\r\n public pinchZoom: boolean = true;\r\n\r\n /**\r\n * Defines whether panning (2 fingers swipe) is enabled through multitouch.\r\n */\r\n @serialize()\r\n public multiTouchPanning: boolean = true;\r\n\r\n /**\r\n * Defines whether panning is enabled for both pan (2 fingers swipe) and\r\n * zoom (pinch) through multitouch.\r\n */\r\n @serialize()\r\n public multiTouchPanAndZoom: boolean = true;\r\n\r\n protected _isPinching: boolean = false;\r\n protected _twoFingerActivityCount: number = 0;\r\n protected _shouldStartPinchZoom: boolean = false;\r\n\r\n protected _computePinchZoom(_previousPinchSquaredDistance: number, _pinchSquaredDistance: number): void {}\r\n\r\n protected _computeMultiTouchPanning(_previousMultiTouchPanPosition: Nullable<PointerTouch>, _multiTouchPanPosition: Nullable<PointerTouch>): void {}\r\n\r\n /**\r\n * Called on pointer POINTERMOVE event if multiple touches are active.\r\n * Override this method to provide functionality.\r\n * @param _pointA First point in the pair\r\n * @param _pointB Second point in the pair\r\n * @param previousPinchSquaredDistance Sqr Distance between the points the last time this event was fired (by this input)\r\n * @param pinchSquaredDistance Sqr Distance between the points this time\r\n * @param previousMultiTouchPanPosition Previous center point between the points\r\n * @param multiTouchPanPosition Current center point between the points\r\n */\r\n public override onMultiTouch(\r\n _pointA: Nullable<PointerTouch>,\r\n _pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {\r\n // First time this method is called for new pinch.\r\n // Next time this is called there will be a\r\n // previousPinchSquaredDistance and pinchSquaredDistance to compare.\r\n return;\r\n }\r\n if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {\r\n // Last time this method is called at the end of a pinch.\r\n return;\r\n }\r\n\r\n // Zoom and panning enabled together\r\n if (this.multiTouchPanAndZoom) {\r\n this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);\r\n this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);\r\n\r\n // Zoom and panning enabled but only one at a time\r\n } else if (this.multiTouchPanning && this.pinchZoom) {\r\n this._twoFingerActivityCount++;\r\n\r\n if (this._isPinching || this._shouldStartPinchZoom) {\r\n // Since pinch has not been active long, assume we intend to zoom.\r\n this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);\r\n\r\n // Since we are pinching, remain pinching on next iteration.\r\n this._isPinching = true;\r\n } else {\r\n // Pause between pinch starting and moving implies not a zoom event. Pan instead.\r\n this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n // Panning enabled, zoom disabled\r\n } else if (this.multiTouchPanning) {\r\n this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);\r\n\r\n // Zoom enabled, panning disabled\r\n } else if (this.pinchZoom) {\r\n this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);\r\n }\r\n }\r\n\r\n /**\r\n * Called each time a new POINTERUP event occurs. Ie, for each button\r\n * release.\r\n * @param _evt Defines the event to track\r\n */\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this._twoFingerActivityCount = 0;\r\n this._isPinching = false;\r\n }\r\n\r\n /**\r\n * Called when window becomes inactive.\r\n */\r\n public override onLostFocus(): void {\r\n this._twoFingerActivityCount = 0;\r\n this._isPinching = false;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limits for geospatial cameras with altitude/radius synchronization
|
|
3
|
+
*/
|
|
4
|
+
export declare class GeospatialLimits {
|
|
5
|
+
private _altitudeMin;
|
|
6
|
+
private _altitudeMax;
|
|
7
|
+
private _planetRadius;
|
|
8
|
+
private _radiusMin;
|
|
9
|
+
private _radiusMax;
|
|
10
|
+
/** Gets the minimum pitch angle (angle from horizon) -- 0 means looking straight down at planet */
|
|
11
|
+
pitchMin: number;
|
|
12
|
+
/** Gets the maximum pitch angle (angle from horizon) -- Pi/1 means looking at horizon */
|
|
13
|
+
pitchMax: number;
|
|
14
|
+
/** Gets the minimum yaw angle (rotation around up axis) */
|
|
15
|
+
yawMin: number;
|
|
16
|
+
/** Gets the maximum yaw angle (rotation around up axis) */
|
|
17
|
+
yawMax: number;
|
|
18
|
+
/**
|
|
19
|
+
* Defines the distance used to consider the camera in pan mode vs pinch/zoom.
|
|
20
|
+
* Basically if your fingers moves away from more than this distance you will be considered
|
|
21
|
+
* in pinch mode.
|
|
22
|
+
*/
|
|
23
|
+
pinchToPanMax: number;
|
|
24
|
+
/**
|
|
25
|
+
* @param planetRadius The radius of the planet (used for altitude/radius conversions)
|
|
26
|
+
*/
|
|
27
|
+
constructor(planetRadius: number);
|
|
28
|
+
/**
|
|
29
|
+
* Gets the minimum altitude (height above planet surface)
|
|
30
|
+
*/
|
|
31
|
+
get altitudeMin(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the minimum altitude and syncs it with radius
|
|
34
|
+
*/
|
|
35
|
+
set altitudeMin(value: number);
|
|
36
|
+
/**
|
|
37
|
+
* Gets the maximum altitude (height above planet surface)
|
|
38
|
+
*/
|
|
39
|
+
get altitudeMax(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the maximum altitude and syncs it with radius
|
|
42
|
+
*/
|
|
43
|
+
set altitudeMax(value: number);
|
|
44
|
+
get radiusMin(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the minimum radius and syncs it with altitude
|
|
47
|
+
*/
|
|
48
|
+
set radiusMin(value: number);
|
|
49
|
+
get radiusMax(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the maximum radius and syncs it with altitude
|
|
52
|
+
*/
|
|
53
|
+
set radiusMax(value: number);
|
|
54
|
+
/**
|
|
55
|
+
* Gets the planet radius used for altitude/radius conversions
|
|
56
|
+
*/
|
|
57
|
+
get planetRadius(): number;
|
|
58
|
+
/** Sets the planet radius and updates the radius limits to maintain current altitude */
|
|
59
|
+
set planetRadius(value: number);
|
|
60
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Epsilon } from "../../Maths/math.constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Limits for geospatial cameras with altitude/radius synchronization
|
|
4
|
+
*/
|
|
5
|
+
export class GeospatialLimits {
|
|
6
|
+
/**
|
|
7
|
+
* @param planetRadius The radius of the planet (used for altitude/radius conversions)
|
|
8
|
+
*/
|
|
9
|
+
constructor(planetRadius) {
|
|
10
|
+
this._altitudeMin = Epsilon;
|
|
11
|
+
this._radiusMin = Epsilon;
|
|
12
|
+
this._radiusMax = Infinity;
|
|
13
|
+
/** Gets the minimum pitch angle (angle from horizon) -- 0 means looking straight down at planet */
|
|
14
|
+
this.pitchMin = Epsilon;
|
|
15
|
+
/** Gets the maximum pitch angle (angle from horizon) -- Pi/1 means looking at horizon */
|
|
16
|
+
this.pitchMax = Math.PI / 2;
|
|
17
|
+
/** Gets the minimum yaw angle (rotation around up axis) */
|
|
18
|
+
this.yawMin = -Infinity;
|
|
19
|
+
/** Gets the maximum yaw angle (rotation around up axis) */
|
|
20
|
+
this.yawMax = Infinity;
|
|
21
|
+
/**
|
|
22
|
+
* Defines the distance used to consider the camera in pan mode vs pinch/zoom.
|
|
23
|
+
* Basically if your fingers moves away from more than this distance you will be considered
|
|
24
|
+
* in pinch mode.
|
|
25
|
+
*/
|
|
26
|
+
this.pinchToPanMax = 20;
|
|
27
|
+
this._planetRadius = planetRadius;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Gets the minimum altitude (height above planet surface)
|
|
31
|
+
*/
|
|
32
|
+
get altitudeMin() {
|
|
33
|
+
return this._altitudeMin;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets the minimum altitude and syncs it with radius
|
|
37
|
+
*/
|
|
38
|
+
set altitudeMin(value) {
|
|
39
|
+
this._altitudeMin = value;
|
|
40
|
+
this._radiusMin = this._planetRadius + value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the maximum altitude (height above planet surface)
|
|
44
|
+
*/
|
|
45
|
+
get altitudeMax() {
|
|
46
|
+
return this._altitudeMax;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets the maximum altitude and syncs it with radius
|
|
50
|
+
*/
|
|
51
|
+
set altitudeMax(value) {
|
|
52
|
+
this._altitudeMax = value;
|
|
53
|
+
this._radiusMax = this._planetRadius + value;
|
|
54
|
+
}
|
|
55
|
+
get radiusMin() {
|
|
56
|
+
return this._radiusMin;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets the minimum radius and syncs it with altitude
|
|
60
|
+
*/
|
|
61
|
+
set radiusMin(value) {
|
|
62
|
+
this._radiusMin = value;
|
|
63
|
+
this._altitudeMin = value - this._planetRadius;
|
|
64
|
+
}
|
|
65
|
+
get radiusMax() {
|
|
66
|
+
return this._radiusMax;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets the maximum radius and syncs it with altitude
|
|
70
|
+
*/
|
|
71
|
+
set radiusMax(value) {
|
|
72
|
+
this._radiusMax = value;
|
|
73
|
+
this._altitudeMax = value - this._planetRadius;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the planet radius used for altitude/radius conversions
|
|
77
|
+
*/
|
|
78
|
+
get planetRadius() {
|
|
79
|
+
return this._planetRadius;
|
|
80
|
+
}
|
|
81
|
+
/** Sets the planet radius and updates the radius limits to maintain current altitude */
|
|
82
|
+
set planetRadius(value) {
|
|
83
|
+
this._planetRadius = value;
|
|
84
|
+
// Update radius limits to maintain current altitude
|
|
85
|
+
this._radiusMin = value + this._altitudeMin;
|
|
86
|
+
this._radiusMax = value + this._altitudeMax;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=geospatialLimits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geospatialLimits.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Limits/geospatialLimits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAyBzB;;OAEG;IACH,YAAY,YAAoB;QA3BxB,iBAAY,GAAW,OAAO,CAAC;QAG/B,eAAU,GAAW,OAAO,CAAC;QAC7B,eAAU,GAAW,QAAQ,CAAC;QAEtC,mGAAmG;QAC5F,aAAQ,GAAW,OAAO,CAAC;QAElC,0FAA0F;QACnF,aAAQ,GAAW,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAEtC,2DAA2D;QACpD,WAAM,GAAW,CAAC,QAAQ,CAAC;QAElC,2DAA2D;QACpD,WAAM,GAAW,QAAQ,CAAC;QACjC;;;;WAIG;QACI,kBAAa,GAAW,EAAE,CAAC;QAM9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW,CAAC,KAAa;QAChC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IACjD,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC;IACnD,CAAC;IAED,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,wFAAwF;IACxF,IAAW,YAAY,CAAC,KAAa;QACjC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,oDAAoD;QACpD,IAAI,CAAC,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;IAChD,CAAC;CACJ","sourcesContent":["import { Epsilon } from \"../../Maths/math.constants\";\r\n/**\r\n * Limits for geospatial cameras with altitude/radius synchronization\r\n */\r\nexport class GeospatialLimits {\r\n private _altitudeMin: number = Epsilon;\r\n private _altitudeMax: number;\r\n private _planetRadius: number;\r\n private _radiusMin: number = Epsilon;\r\n private _radiusMax: number = Infinity;\r\n\r\n /** Gets the minimum pitch angle (angle from horizon) -- 0 means looking straight down at planet */\r\n public pitchMin: number = Epsilon;\r\n\r\n /** Gets the maximum pitch angle (angle from horizon) -- Pi/1 means looking at horizon */\r\n public pitchMax: number = Math.PI / 2;\r\n\r\n /** Gets the minimum yaw angle (rotation around up axis) */\r\n public yawMin: number = -Infinity;\r\n\r\n /** Gets the maximum yaw angle (rotation around up axis) */\r\n public yawMax: number = Infinity;\r\n /**\r\n * Defines the distance used to consider the camera in pan mode vs pinch/zoom.\r\n * Basically if your fingers moves away from more than this distance you will be considered\r\n * in pinch mode.\r\n */\r\n public pinchToPanMax: number = 20;\r\n\r\n /**\r\n * @param planetRadius The radius of the planet (used for altitude/radius conversions)\r\n */\r\n constructor(planetRadius: number) {\r\n this._planetRadius = planetRadius;\r\n }\r\n\r\n /**\r\n * Gets the minimum altitude (height above planet surface)\r\n */\r\n public get altitudeMin(): number {\r\n return this._altitudeMin;\r\n }\r\n\r\n /**\r\n * Sets the minimum altitude and syncs it with radius\r\n */\r\n public set altitudeMin(value: number) {\r\n this._altitudeMin = value;\r\n this._radiusMin = this._planetRadius + value;\r\n }\r\n\r\n /**\r\n * Gets the maximum altitude (height above planet surface)\r\n */\r\n public get altitudeMax(): number {\r\n return this._altitudeMax;\r\n }\r\n\r\n /**\r\n * Sets the maximum altitude and syncs it with radius\r\n */\r\n public set altitudeMax(value: number) {\r\n this._altitudeMax = value;\r\n this._radiusMax = this._planetRadius + value;\r\n }\r\n\r\n public get radiusMin(): number {\r\n return this._radiusMin;\r\n }\r\n\r\n /**\r\n * Sets the minimum radius and syncs it with altitude\r\n */\r\n public set radiusMin(value: number) {\r\n this._radiusMin = value;\r\n this._altitudeMin = value - this._planetRadius;\r\n }\r\n\r\n public get radiusMax(): number {\r\n return this._radiusMax;\r\n }\r\n\r\n /**\r\n * Sets the maximum radius and syncs it with altitude\r\n */\r\n public set radiusMax(value: number) {\r\n this._radiusMax = value;\r\n this._altitudeMax = value - this._planetRadius;\r\n }\r\n\r\n /**\r\n * Gets the planet radius used for altitude/radius conversions\r\n */\r\n public get planetRadius(): number {\r\n return this._planetRadius;\r\n }\r\n\r\n /** Sets the planet radius and updates the radius limits to maintain current altitude */\r\n public set planetRadius(value: number) {\r\n this._planetRadius = value;\r\n // Update radius limits to maintain current altitude\r\n this._radiusMin = value + this._altitudeMin;\r\n this._radiusMax = value + this._altitudeMax;\r\n }\r\n}\r\n"]}
|