@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,10 +1,8 @@
|
|
|
1
|
-
import { Plane } from "../../Maths/math.plane.js";
|
|
2
|
-
import { TmpVectors, Vector3 } from "../../Maths/math.vector.js";
|
|
3
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
|
|
@@ -15,59 +13,50 @@ import { OrbitCameraPointersInput } from "./orbitCameraPointersInput.js";
|
|
|
15
13
|
*
|
|
16
14
|
*/
|
|
17
15
|
export class GeospatialCameraPointersInput extends OrbitCameraPointersInput {
|
|
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
|
-
}
|
|
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
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Move camera from multitouch (pinch) zoom distances.
|
|
54
|
+
* @param previousPinchSquaredDistance
|
|
55
|
+
* @param pinchSquaredDistance
|
|
56
|
+
*/
|
|
57
|
+
_computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance) {
|
|
58
|
+
this.camera.radius = (this.camera.radius * Math.sqrt(previousPinchSquaredDistance)) / Math.sqrt(pinchSquaredDistance);
|
|
59
|
+
}
|
|
71
60
|
/**
|
|
72
61
|
* Move camera from multi touch panning positions.
|
|
73
62
|
* In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)
|
|
@@ -81,57 +70,28 @@ export class GeospatialCameraPointersInput extends OrbitCameraPointersInput {
|
|
|
81
70
|
this._handleTilt(moveDeltaX, moveDeltaY);
|
|
82
71
|
}
|
|
83
72
|
}
|
|
73
|
+
onDoubleTap(type) {
|
|
74
|
+
const scene = this.camera.getScene();
|
|
75
|
+
const pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);
|
|
76
|
+
if (pickResult.hit && pickResult.pickedPoint) {
|
|
77
|
+
const newRadius = this.camera.radius * 0.5; // Zoom to 50% of current distance
|
|
78
|
+
void this.camera.flyToAsync(undefined, undefined, newRadius, pickResult.pickedPoint);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
84
81
|
onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
85
|
-
this._shouldStartPinchZoom =
|
|
82
|
+
this._shouldStartPinchZoom =
|
|
83
|
+
this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.limits.pinchToPanMax;
|
|
86
84
|
super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
87
85
|
}
|
|
88
86
|
onButtonUp(_evt) {
|
|
89
|
-
this.
|
|
90
|
-
this.camera.
|
|
87
|
+
this.camera.movement.stopDrag();
|
|
88
|
+
this.camera.movement.alternateRotationPt = undefined;
|
|
89
|
+
this.camera.movement.activeInput = false;
|
|
91
90
|
super.onButtonUp(_evt);
|
|
92
91
|
}
|
|
93
|
-
/**
|
|
94
|
-
* The DragPlaneOffsetVector represents the vector between the dragPlane hit point and the dragPlane origin point.
|
|
95
|
-
* 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
|
|
96
|
-
* @param hitPointRadius The distance between the world origin (center of globe) and the initial drag hit point
|
|
97
|
-
* @param ray The ray from the camera to the new cursor location
|
|
98
|
-
* @param ref The offset vector between the drag plane's hitPoint and originPoint
|
|
99
|
-
*/
|
|
100
|
-
_recalculateDragPlaneOffsetVectorToRef(hitPointRadius, ray, ref) {
|
|
101
|
-
// Use the camera's geocentric normal to find the dragPlaneOriginPoint which lives at hitPointRadius along the camera's geocentric normal
|
|
102
|
-
this.camera.position.normalizeToRef(this._dragPlaneNormal);
|
|
103
|
-
this._dragPlaneNormal.scaleToRef(hitPointRadius, this._dragPlaneOriginPoint);
|
|
104
|
-
// Now create a plane at that point, perpendicular to the camera's geocentric normal
|
|
105
|
-
Plane.FromPositionAndNormalToRef(this._dragPlaneOriginPoint, this._dragPlaneNormal, this._dragPlane);
|
|
106
|
-
// Lastly, find the _dragPlaneHitPoint where the ray intersects the _dragPlane
|
|
107
|
-
IntersectRayWithPlaneToRef(ray, this._dragPlane, this._dragPlaneHitPoint);
|
|
108
|
-
// Store the new offset between the drag plane's hitPoint and originPoint
|
|
109
|
-
this._dragPlaneHitPoint.subtractToRef(this._dragPlaneOriginPoint, ref);
|
|
110
|
-
}
|
|
111
|
-
_handleDrag(hitPointRadius) {
|
|
112
|
-
const scene = this.camera.getScene();
|
|
113
|
-
const pickResult = scene.pick(scene.pointerX, scene.pointerY);
|
|
114
|
-
if (pickResult.ray) {
|
|
115
|
-
const newDragPlaneOffsetVector = TmpVectors.Vector3[5];
|
|
116
|
-
this._recalculateDragPlaneOffsetVectorToRef(hitPointRadius, pickResult.ray, newDragPlaneOffsetVector);
|
|
117
|
-
const delta = TmpVectors.Vector3[6];
|
|
118
|
-
newDragPlaneOffsetVector.subtractToRef(this._dragPlaneOffsetVector, delta);
|
|
119
|
-
this._dragPlaneOffsetVector.copyFrom(newDragPlaneOffsetVector);
|
|
120
|
-
this.camera._perFrameGeocentricTranslation.subtractInPlace(delta); // ???
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
92
|
_handleTilt(deltaX, deltaY) {
|
|
124
|
-
this.camera.
|
|
125
|
-
this.camera.
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function IntersectRayWithPlaneToRef(ray, plane, ref) {
|
|
129
|
-
// Distance along the ray to the plane; null if no hit
|
|
130
|
-
const dist = ray.intersectsPlane(plane);
|
|
131
|
-
if (dist !== null && dist >= 0) {
|
|
132
|
-
ray.origin.addToRef(ray.direction.scaleToRef(dist, TmpVectors.Vector3[0]), ref);
|
|
133
|
-
return true;
|
|
93
|
+
this.camera.movement.rotationAccumulatedPixels.y -= deltaX; // yaw - looking side to side
|
|
94
|
+
this.camera.movement.rotationAccumulatedPixels.x -= deltaY; // pitch - look up towards sky / down towards ground
|
|
134
95
|
}
|
|
135
|
-
return false;
|
|
136
96
|
}
|
|
137
97
|
//# 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,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,6BAA8B,SAAQ,wBAAwB;IAA3E;;QAGI;;WAEG;QACI,uBAAkB,GAAG,KAAK,CAAC;QAE1B,eAAU,GAAU,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1C,qBAAgB,GA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\";\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 { 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 * 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 OrbitCameraPointersInput {\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 /**\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 = this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > 20; // move to limits once limits exist\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._hitPointRadius = undefined;\r\n this.camera._alternateRotationPt = null;\r\n super.onButtonUp(_evt);\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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,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;QACzF,CAAC;IACL,CAAC;IAEe,YAAY,CACxB,MAA8B,EAC9B,MAA8B,EAC9B,4BAAoC,EACpC,oBAA4B,EAC5B,6BAAqD,EACrD,qBAA6C;QAE7C,IAAI,CAAC,qBAAqB;YACtB,IAAI,CAAC,uBAAuB,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QAChK,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;IACjJ,CAAC;IAEe,UAAU,CAAC,IAAmB;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,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 onDoubleTap(type: string): void {\r\n const scene = this.camera.getScene();\r\n const pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n\r\n if (pickResult.hit && pickResult.pickedPoint) {\r\n const newRadius = this.camera.radius * 0.5; // Zoom to 50% of current distance\r\n void this.camera.flyToAsync(undefined, undefined, newRadius, pickResult.pickedPoint);\r\n }\r\n }\r\n\r\n public override onMultiTouch(\r\n pointA: Nullable<PointerTouch>,\r\n pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n 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,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,CA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FAAwF;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"]}
|
|
@@ -74,7 +74,7 @@ export class StereoscopicScreenUniversalCamera extends UniversalCamera {
|
|
|
74
74
|
cam.maxZ = this.maxZ;
|
|
75
75
|
cam.fov = this.fov;
|
|
76
76
|
cam.upVector.copyFrom(this.upVector);
|
|
77
|
-
if (cam.rotationQuaternion) {
|
|
77
|
+
if (cam.rotationQuaternion && this.rotationQuaternion) {
|
|
78
78
|
cam.rotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stereoscopicScreenUniversalCamera.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAA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CAAC;IAED;;OAEG;IACa,eAAe,CAAC,IAAY;QACxC,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,KAAK,GAAG,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAC1B,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACa,iBAAiB;QAC7B,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC;YAC7E,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAiB,CAAC;YAC1D,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACrB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACrB,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;YACnB,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,GAAG,CAAC,kBAAkB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"stereoscopicScreenUniversalCamera.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,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AC;QAC9D,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC;YAC7E,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAiB,EAAE,WAAW,CAAC,CAAC;QACnF,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Camera } from \"../../Cameras/camera\";\r\nimport { UniversalCamera } from \"../../Cameras/universalCamera\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { TargetCamera } from \"../targetCamera\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Viewport } from \"../../Maths/math.viewport\";\r\n\r\n/**\r\n * Camera used to simulate stereoscopic rendering on real screens (based on UniversalCamera)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras\r\n */\r\nexport class StereoscopicScreenUniversalCamera extends UniversalCamera {\r\n private _distanceToProjectionPlane: number;\r\n private _distanceBetweenEyes: number;\r\n\r\n public set distanceBetweenEyes(newValue: number) {\r\n this._distanceBetweenEyes = newValue;\r\n }\r\n\r\n /**\r\n * distance between the eyes\r\n */\r\n public get distanceBetweenEyes(): number {\r\n return this._distanceBetweenEyes;\r\n }\r\n\r\n public set distanceToProjectionPlane(newValue: number) {\r\n this._distanceToProjectionPlane = newValue;\r\n }\r\n\r\n /**\r\n * Distance to projection plane (should be the same units the like distance between the eyes)\r\n */\r\n public get distanceToProjectionPlane(): number {\r\n return this._distanceToProjectionPlane;\r\n }\r\n /**\r\n * Creates a new StereoscopicScreenUniversalCamera\r\n * @param name defines camera name\r\n * @param position defines initial position\r\n * @param scene defines the hosting scene\r\n * @param distanceToProjectionPlane defines distance between each color axis. The rig cameras will receive this as their negative z position!\r\n * @param distanceBetweenEyes defines is stereoscopic is done side by side or over under\r\n */\r\n constructor(name: string, position: Vector3, scene?: Scene, distanceToProjectionPlane: number = 1, distanceBetweenEyes: number = 0.065) {\r\n super(name, position, scene);\r\n this._distanceBetweenEyes = distanceBetweenEyes;\r\n this._distanceToProjectionPlane = distanceToProjectionPlane;\r\n this.setCameraRigMode(Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, {\r\n stereoHalfAngle: 0,\r\n });\r\n this._cameraRigParams.stereoHalfAngle = 0;\r\n this._cameraRigParams.interaxialDistance = distanceBetweenEyes;\r\n }\r\n\r\n /**\r\n * Gets camera class name\r\n * @returns StereoscopicScreenUniversalCamera\r\n */\r\n public override getClassName(): string {\r\n return \"StereoscopicUniversalCamera\";\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override createRigCamera(name: string): Nullable<Camera> {\r\n const camera = new TargetCamera(name, Vector3.Zero(), this.getScene());\r\n const transform = new TransformNode(\"tm_\" + name, this.getScene());\r\n camera.parent = transform;\r\n transform.setPivotMatrix(Matrix.Identity(), false);\r\n camera.isRigCamera = true;\r\n camera.rigParent = this;\r\n return camera;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _updateRigCameras() {\r\n for (let cameraIndex = 0; cameraIndex < this._rigCameras.length; cameraIndex++) {\r\n const cam = this._rigCameras[cameraIndex] as TargetCamera;\r\n cam.minZ = this.minZ;\r\n cam.maxZ = this.maxZ;\r\n cam.fov = this.fov;\r\n cam.upVector.copyFrom(this.upVector);\r\n if (cam.rotationQuaternion && this.rotationQuaternion) {\r\n cam.rotationQuaternion.copyFrom(this.rotationQuaternion);\r\n } else {\r\n cam.rotation.copyFrom(this.rotation);\r\n }\r\n this._updateCamera(this._rigCameras[cameraIndex] as TargetCamera, cameraIndex);\r\n }\r\n }\r\n\r\n private _updateCamera(camera: TargetCamera, cameraIndex: number) {\r\n const b = this.distanceBetweenEyes / 2;\r\n const z = b / this.distanceToProjectionPlane;\r\n camera.position.copyFrom(this.position);\r\n camera.position.addInPlaceFromFloats(cameraIndex === 0 ? -b : b, 0, -this._distanceToProjectionPlane);\r\n const transform = camera.parent as TransformNode;\r\n const m = transform.getPivotMatrix();\r\n m.setTranslationFromFloats(cameraIndex === 0 ? b : -b, 0, 0);\r\n m.setRowFromFloats(2, cameraIndex === 0 ? z : -z, 0, 1, 0);\r\n transform.setPivotMatrix(m, false);\r\n }\r\n\r\n protected override _setRigMode() {\r\n this._rigCameras[0].viewport = new Viewport(0, 0, 0.5, 1);\r\n this._rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);\r\n for (let cameraIndex = 0; cameraIndex < this._rigCameras.length; cameraIndex++) {\r\n this._updateCamera(this._rigCameras[cameraIndex] as TargetCamera, cameraIndex);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -430,10 +430,10 @@ export class VRExperienceHelper {
|
|
|
430
430
|
if (this._scene.activeCamera instanceof TargetCamera && this._scene.activeCamera.rotation) {
|
|
431
431
|
const targetCamera = this._scene.activeCamera;
|
|
432
432
|
if (targetCamera.rotationQuaternion) {
|
|
433
|
-
this._deviceOrientationCamera.rotationQuaternion
|
|
433
|
+
this._deviceOrientationCamera.rotationQuaternion?.copyFrom(targetCamera.rotationQuaternion);
|
|
434
434
|
}
|
|
435
435
|
else {
|
|
436
|
-
this._deviceOrientationCamera.rotationQuaternion
|
|
436
|
+
this._deviceOrientationCamera.rotationQuaternion?.copyFrom(Quaternion.RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
|
|
437
437
|
}
|
|
438
438
|
this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
|
|
439
439
|
}
|