@babylonjs/core 8.37.0 → 8.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +58 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +157 -0
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +11 -9
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +17 -21
- package/Cameras/Inputs/geospatialCameraPointersInput.js +49 -71
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
- package/Cameras/Limits/geospatialLimits.d.ts +60 -0
- package/Cameras/Limits/geospatialLimits.js +89 -0
- package/Cameras/Limits/geospatialLimits.js.map +1 -0
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js +2 -2
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- package/Cameras/deviceOrientationCamera.js +5 -3
- package/Cameras/deviceOrientationCamera.js.map +1 -1
- package/Cameras/flyCamera.d.ts +2 -1
- package/Cameras/flyCamera.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +78 -49
- package/Cameras/geospatialCamera.js +210 -191
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
- package/Cameras/geospatialCameraInputsManager.js +9 -0
- package/Cameras/geospatialCameraInputsManager.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +66 -0
- package/Cameras/geospatialCameraMovement.js +199 -0
- package/Cameras/geospatialCameraMovement.js.map +1 -0
- package/Cameras/targetCamera.d.ts +1 -1
- package/Cameras/targetCamera.js +2 -2
- package/Cameras/targetCamera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -7
- package/Decorators/nodeDecorator.js +9 -7
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +2 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
- package/FlowGraph/flowGraphMath.d.ts +25 -0
- package/FlowGraph/flowGraphMath.js +40 -0
- package/FlowGraph/flowGraphMath.js.map +1 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
- package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
- package/FrameGraph/Passes/objectListPass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +6 -2
- package/FrameGraph/Passes/renderPass.js +14 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +10 -4
- package/FrameGraph/frameGraph.js +22 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +3 -3
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -1
- package/FrameGraph/index.js +1 -1
- package/FrameGraph/index.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +9 -0
- package/Materials/shaderMaterial.js +39 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +5 -24
- package/Maths/math.vector.functions.js +32 -35
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +15 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/tools.d.ts +3 -0
- package/Misc/tools.js +43 -4
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +9 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +43 -12
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +3 -3
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
- package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +20 -12
- package/Particles/Node/Blocks/systemBlock.js +26 -22
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +11 -7
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +524 -147
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/particle.d.ts +4 -0
- package/Particles/particle.js +2 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +3 -7
- package/Particles/thinParticleSystem.function.d.ts +1 -1
- package/Particles/thinParticleSystem.function.js +9 -6
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +5 -7
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/XR/webXRCamera.d.ts +5 -1
- package/XR/webXRCamera.js +2 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRExperienceHelper.js +1 -1
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/package.json +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { __decorate } from "../../tslib.es6.js";
|
|
2
|
+
import { serialize } from "../../Misc/decorators.js";
|
|
3
|
+
import { CameraInputTypes } from "../cameraInputsManager.js";
|
|
4
|
+
import { KeyboardEventTypes } from "../../Events/keyboardEvents.js";
|
|
5
|
+
import { Tools } from "../../Misc/tools.js";
|
|
6
|
+
/**
|
|
7
|
+
* Manage the keyboard inputs to control the movement of a geospatial camera.
|
|
8
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
|
|
9
|
+
*/
|
|
10
|
+
export class GeospatialCameraKeyboardInput {
|
|
11
|
+
constructor() {
|
|
12
|
+
/**
|
|
13
|
+
* Defines the list of key codes associated with the up action (pan up)
|
|
14
|
+
*/
|
|
15
|
+
this.keysUp = [38];
|
|
16
|
+
/**
|
|
17
|
+
* Defines the list of key codes associated with the down action (pan down)
|
|
18
|
+
*/
|
|
19
|
+
this.keysDown = [40];
|
|
20
|
+
/**
|
|
21
|
+
* Defines the list of key codes associated with the left action (pan left)
|
|
22
|
+
*/
|
|
23
|
+
this.keysLeft = [37];
|
|
24
|
+
/**
|
|
25
|
+
* Defines the list of key codes associated with the right action (pan right)
|
|
26
|
+
*/
|
|
27
|
+
this.keysRight = [39];
|
|
28
|
+
/**
|
|
29
|
+
* Defines the list of key codes associated with zoom in (+ or =)
|
|
30
|
+
*/
|
|
31
|
+
this.keysZoomIn = [187, 107]; // 187 = + key, 107 = numpad +
|
|
32
|
+
/**
|
|
33
|
+
* Defines the list of key codes associated with zoom out (-)
|
|
34
|
+
*/
|
|
35
|
+
this.keysZoomOut = [189, 109]; // 189 = - key, 109 = numpad -
|
|
36
|
+
/**
|
|
37
|
+
* Defines the rotation sensitivity of the inputs.
|
|
38
|
+
* (How many pixels of pointer input to apply per keypress, before rotation speed factor is applied by movement class)
|
|
39
|
+
*/
|
|
40
|
+
this.rotationSensitivity = 1.0;
|
|
41
|
+
/**
|
|
42
|
+
* Defines the panning sensitivity of the inputs.
|
|
43
|
+
* (How many pixels of pointer input to apply per keypress, before pan speed factor is applied by movement class)
|
|
44
|
+
*/
|
|
45
|
+
this.panSensitivity = 1.0;
|
|
46
|
+
/**
|
|
47
|
+
* Defines the zooming sensitivity of the inputs.
|
|
48
|
+
* (How many pixels of pointer input to apply per keypress, before zoom speed factor is applied by movement class)
|
|
49
|
+
*/
|
|
50
|
+
this.zoomSensitivity = 1.0;
|
|
51
|
+
this._keys = new Array();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Attach the input controls to a specific dom element to get the input from.
|
|
55
|
+
* @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
|
|
56
|
+
*/
|
|
57
|
+
attachControl(noPreventDefault) {
|
|
58
|
+
// was there a second variable defined?
|
|
59
|
+
noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);
|
|
60
|
+
if (this._onCanvasBlurObserver) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(() => {
|
|
64
|
+
this._keys.length = 0;
|
|
65
|
+
});
|
|
66
|
+
this._onKeyboardObserver = this._scene.onKeyboardObservable.add((info) => {
|
|
67
|
+
const evt = info.event;
|
|
68
|
+
if (!evt.metaKey) {
|
|
69
|
+
if (info.type === KeyboardEventTypes.KEYDOWN) {
|
|
70
|
+
this._ctrlPressed = evt.ctrlKey;
|
|
71
|
+
if (this.keysUp.indexOf(evt.keyCode) !== -1 ||
|
|
72
|
+
this.keysDown.indexOf(evt.keyCode) !== -1 ||
|
|
73
|
+
this.keysLeft.indexOf(evt.keyCode) !== -1 ||
|
|
74
|
+
this.keysRight.indexOf(evt.keyCode) !== -1 ||
|
|
75
|
+
this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||
|
|
76
|
+
this.keysZoomOut.indexOf(evt.keyCode) !== -1) {
|
|
77
|
+
const index = this._keys.indexOf(evt.keyCode);
|
|
78
|
+
if (index === -1) {
|
|
79
|
+
this._keys.push(evt.keyCode);
|
|
80
|
+
}
|
|
81
|
+
if (evt.preventDefault) {
|
|
82
|
+
if (!noPreventDefault) {
|
|
83
|
+
evt.preventDefault();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (this.keysUp.indexOf(evt.keyCode) !== -1 ||
|
|
90
|
+
this.keysDown.indexOf(evt.keyCode) !== -1 ||
|
|
91
|
+
this.keysLeft.indexOf(evt.keyCode) !== -1 ||
|
|
92
|
+
this.keysRight.indexOf(evt.keyCode) !== -1 ||
|
|
93
|
+
this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||
|
|
94
|
+
this.keysZoomOut.indexOf(evt.keyCode) !== -1) {
|
|
95
|
+
const index = this._keys.indexOf(evt.keyCode);
|
|
96
|
+
if (index >= 0) {
|
|
97
|
+
this._keys.splice(index, 1);
|
|
98
|
+
}
|
|
99
|
+
if (evt.preventDefault) {
|
|
100
|
+
if (!noPreventDefault) {
|
|
101
|
+
evt.preventDefault();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Detach the current controls from the specified dom element.
|
|
111
|
+
*/
|
|
112
|
+
detachControl() {
|
|
113
|
+
if (this._scene) {
|
|
114
|
+
if (this._onKeyboardObserver) {
|
|
115
|
+
this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
|
|
116
|
+
}
|
|
117
|
+
if (this._onCanvasBlurObserver) {
|
|
118
|
+
this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
|
|
119
|
+
}
|
|
120
|
+
this._onKeyboardObserver = null;
|
|
121
|
+
this._onCanvasBlurObserver = null;
|
|
122
|
+
}
|
|
123
|
+
this._keys.length = 0;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Update the current camera state depending on the inputs that have been used this frame.
|
|
127
|
+
* This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
|
|
128
|
+
*/
|
|
129
|
+
checkInputs() {
|
|
130
|
+
if (this._onKeyboardObserver) {
|
|
131
|
+
const camera = this.camera;
|
|
132
|
+
for (let index = 0; index < this._keys.length; index++) {
|
|
133
|
+
const keyCode = this._keys[index];
|
|
134
|
+
if (this._ctrlPressed) {
|
|
135
|
+
// Rotation
|
|
136
|
+
if (this.keysLeft.indexOf(keyCode) !== -1) {
|
|
137
|
+
camera.movement.rotationAccumulatedPixels.y -= this.rotationSensitivity;
|
|
138
|
+
}
|
|
139
|
+
else if (this.keysRight.indexOf(keyCode) !== -1) {
|
|
140
|
+
camera.movement.rotationAccumulatedPixels.y += this.rotationSensitivity;
|
|
141
|
+
}
|
|
142
|
+
else if (this.keysUp.indexOf(keyCode) !== -1) {
|
|
143
|
+
camera.movement.rotationAccumulatedPixels.x -= this.rotationSensitivity;
|
|
144
|
+
}
|
|
145
|
+
else if (this.keysDown.indexOf(keyCode) !== -1) {
|
|
146
|
+
camera.movement.rotationAccumulatedPixels.x += this.rotationSensitivity;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Zoom
|
|
151
|
+
if (this.keysZoomIn.indexOf(keyCode) !== -1) {
|
|
152
|
+
camera.movement.zoomAccumulatedPixels += this.zoomSensitivity;
|
|
153
|
+
}
|
|
154
|
+
else if (this.keysZoomOut.indexOf(keyCode) !== -1) {
|
|
155
|
+
camera.movement.zoomAccumulatedPixels -= this.zoomSensitivity;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Call into movement class handleDrag so that behavior matches that of pointer input, simulating drag from center of screen
|
|
159
|
+
const centerX = this._engine.getRenderWidth() / 2;
|
|
160
|
+
const centerY = this._engine.getRenderHeight() / 2;
|
|
161
|
+
camera.movement.startDrag(centerX, centerY);
|
|
162
|
+
if (this.keysLeft.indexOf(keyCode) !== -1) {
|
|
163
|
+
camera.movement.handleDrag(centerX - this.panSensitivity, centerY);
|
|
164
|
+
}
|
|
165
|
+
else if (this.keysRight.indexOf(keyCode) !== -1) {
|
|
166
|
+
camera.movement.handleDrag(centerX + this.panSensitivity, centerY);
|
|
167
|
+
}
|
|
168
|
+
else if (this.keysUp.indexOf(keyCode) !== -1) {
|
|
169
|
+
camera.movement.handleDrag(centerX, centerY + this.panSensitivity);
|
|
170
|
+
}
|
|
171
|
+
else if (this.keysDown.indexOf(keyCode) !== -1) {
|
|
172
|
+
camera.movement.handleDrag(centerX, centerY - this.panSensitivity);
|
|
173
|
+
}
|
|
174
|
+
camera.movement.stopDrag();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Gets the class name of the current input.
|
|
182
|
+
* @returns the class name
|
|
183
|
+
*/
|
|
184
|
+
getClassName() {
|
|
185
|
+
return "GeospatialCameraKeyboardInput";
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get the friendly name associated with the input class.
|
|
189
|
+
* @returns the input friendly name
|
|
190
|
+
*/
|
|
191
|
+
getSimpleName() {
|
|
192
|
+
return "keyboard";
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
__decorate([
|
|
196
|
+
serialize()
|
|
197
|
+
], GeospatialCameraKeyboardInput.prototype, "keysUp", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
serialize()
|
|
200
|
+
], GeospatialCameraKeyboardInput.prototype, "keysDown", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
serialize()
|
|
203
|
+
], GeospatialCameraKeyboardInput.prototype, "keysLeft", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
serialize()
|
|
206
|
+
], GeospatialCameraKeyboardInput.prototype, "keysRight", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
serialize()
|
|
209
|
+
], GeospatialCameraKeyboardInput.prototype, "keysZoomIn", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
serialize()
|
|
212
|
+
], GeospatialCameraKeyboardInput.prototype, "keysZoomOut", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
serialize()
|
|
215
|
+
], GeospatialCameraKeyboardInput.prototype, "rotationSensitivity", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
serialize()
|
|
218
|
+
], GeospatialCameraKeyboardInput.prototype, "panSensitivity", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
serialize()
|
|
221
|
+
], GeospatialCameraKeyboardInput.prototype, "zoomSensitivity", void 0);
|
|
222
|
+
CameraInputTypes["GeospatialCameraKeyboardInput"] = GeospatialCameraKeyboardInput;
|
|
223
|
+
//# sourceMappingURL=geospatialCameraKeyboardInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geospatialCameraKeyboardInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraKeyboardInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IAA1C;QAMI;;WAEG;QAEI,WAAM,GAAG,CAAC,EAAE,CAAC,CAAC;QAErB;;WAEG;QAEI,aAAQ,GAAG,CAAC,EAAE,CAAC,CAAC;QAEvB;;WAEG;QAEI,aAAQ,GAAG,CAAC,EAAE,CAAC,CAAC;QAEvB;;WAEG;QAEI,cAAS,GAAG,CAAC,EAAE,CAAC,CAAC;QAExB;;WAEG;QAEI,eAAU,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,8BAA8B;QAE9D;;WAEG;QAEI,gBAAW,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,8BAA8B;QAE/D;;;WAGG;QAEI,wBAAmB,GAAG,GAAG,CAAC;QAEjC;;;WAGG;QAEI,mBAAc,GAAW,GAAG,CAAC;QAEpC;;;WAGG;QAEI,oBAAe,GAAW,GAAG,CAAC;QAE7B,UAAK,GAAG,IAAI,KAAK,EAAU,CAAC;IA4JxC,CAAC;IArJG;;;OAGG;IACI,aAAa,CAAC,gBAA0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AAE;qEACwB;AAO7B;IADN,SAAS,EAAE;sEACyB;AAgKnC,gBAAiB,CAAC,+BAA+B,CAAC,GAAG,6BAA6B,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { GeospatialCamera } from \"../geospatialCamera\";\r\nimport type { ICameraInput } from \"../cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../cameraInputsManager\";\r\nimport type { KeyboardInfo } from \"../../Events/keyboardEvents\";\r\nimport { KeyboardEventTypes } from \"../../Events/keyboardEvents\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\n/**\r\n * Manage the keyboard inputs to control the movement of a geospatial camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class GeospatialCameraKeyboardInput implements ICameraInput<GeospatialCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: GeospatialCamera;\r\n\r\n /**\r\n * Defines the list of key codes associated with the up action (pan up)\r\n */\r\n @serialize()\r\n public keysUp = [38];\r\n\r\n /**\r\n * Defines the list of key codes associated with the down action (pan down)\r\n */\r\n @serialize()\r\n public keysDown = [40];\r\n\r\n /**\r\n * Defines the list of key codes associated with the left action (pan left)\r\n */\r\n @serialize()\r\n public keysLeft = [37];\r\n\r\n /**\r\n * Defines the list of key codes associated with the right action (pan right)\r\n */\r\n @serialize()\r\n public keysRight = [39];\r\n\r\n /**\r\n * Defines the list of key codes associated with zoom in (+ or =)\r\n */\r\n @serialize()\r\n public keysZoomIn = [187, 107]; // 187 = + key, 107 = numpad +\r\n\r\n /**\r\n * Defines the list of key codes associated with zoom out (-)\r\n */\r\n @serialize()\r\n public keysZoomOut = [189, 109]; // 189 = - key, 109 = numpad -\r\n\r\n /**\r\n * Defines the rotation sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before rotation speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public rotationSensitivity = 1.0;\r\n\r\n /**\r\n * Defines the panning sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before pan speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public panSensitivity: number = 1.0;\r\n\r\n /**\r\n * Defines the zooming sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before zoom speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public zoomSensitivity: number = 1.0;\r\n\r\n private _keys = new Array<number>();\r\n private _ctrlPressed: boolean;\r\n private _onCanvasBlurObserver: Nullable<Observer<AbstractEngine>>;\r\n private _onKeyboardObserver: Nullable<Observer<KeyboardInfo>>;\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // was there a second variable defined?\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n\r\n if (this._onCanvasBlurObserver) {\r\n return;\r\n }\r\n\r\n this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(() => {\r\n this._keys.length = 0;\r\n });\r\n\r\n this._onKeyboardObserver = this._scene.onKeyboardObservable.add((info) => {\r\n const evt = info.event;\r\n if (!evt.metaKey) {\r\n if (info.type === KeyboardEventTypes.KEYDOWN) {\r\n this._ctrlPressed = evt.ctrlKey;\r\n\r\n if (\r\n this.keysUp.indexOf(evt.keyCode) !== -1 ||\r\n this.keysDown.indexOf(evt.keyCode) !== -1 ||\r\n this.keysLeft.indexOf(evt.keyCode) !== -1 ||\r\n this.keysRight.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomOut.indexOf(evt.keyCode) !== -1\r\n ) {\r\n const index = this._keys.indexOf(evt.keyCode);\r\n\r\n if (index === -1) {\r\n this._keys.push(evt.keyCode);\r\n }\r\n\r\n if (evt.preventDefault) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n } else {\r\n if (\r\n this.keysUp.indexOf(evt.keyCode) !== -1 ||\r\n this.keysDown.indexOf(evt.keyCode) !== -1 ||\r\n this.keysLeft.indexOf(evt.keyCode) !== -1 ||\r\n this.keysRight.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomOut.indexOf(evt.keyCode) !== -1\r\n ) {\r\n const index = this._keys.indexOf(evt.keyCode);\r\n\r\n if (index >= 0) {\r\n this._keys.splice(index, 1);\r\n }\r\n\r\n if (evt.preventDefault) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._scene) {\r\n if (this._onKeyboardObserver) {\r\n this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);\r\n }\r\n if (this._onCanvasBlurObserver) {\r\n this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);\r\n }\r\n this._onKeyboardObserver = null;\r\n this._onCanvasBlurObserver = null;\r\n }\r\n\r\n this._keys.length = 0;\r\n }\r\n\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n public checkInputs(): void {\r\n if (this._onKeyboardObserver) {\r\n const camera = this.camera;\r\n\r\n for (let index = 0; index < this._keys.length; index++) {\r\n const keyCode = this._keys[index];\r\n if (this._ctrlPressed) {\r\n // Rotation\r\n if (this.keysLeft.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.y -= this.rotationSensitivity;\r\n } else if (this.keysRight.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.y += this.rotationSensitivity;\r\n } else if (this.keysUp.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.x -= this.rotationSensitivity;\r\n } else if (this.keysDown.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.x += this.rotationSensitivity;\r\n }\r\n } else {\r\n // Zoom\r\n if (this.keysZoomIn.indexOf(keyCode) !== -1) {\r\n camera.movement.zoomAccumulatedPixels += this.zoomSensitivity;\r\n } else if (this.keysZoomOut.indexOf(keyCode) !== -1) {\r\n camera.movement.zoomAccumulatedPixels -= this.zoomSensitivity;\r\n } else {\r\n // Call into movement class handleDrag so that behavior matches that of pointer input, simulating drag from center of screen\r\n const centerX = this._engine.getRenderWidth() / 2;\r\n const centerY = this._engine.getRenderHeight() / 2;\r\n camera.movement.startDrag(centerX, centerY);\r\n if (this.keysLeft.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX - this.panSensitivity, centerY);\r\n } else if (this.keysRight.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX + this.panSensitivity, centerY);\r\n } else if (this.keysUp.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX, centerY + this.panSensitivity);\r\n } else if (this.keysDown.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX, centerY - this.panSensitivity);\r\n }\r\n camera.movement.stopDrag();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"GeospatialCameraKeyboardInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"keyboard\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"GeospatialCameraKeyboardInput\"] = GeospatialCameraKeyboardInput;\r\n"]}
|
|
@@ -13,7 +13,7 @@ export class GeospatialCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
13
13
|
return "GeospatialCameraMouseWheelInput";
|
|
14
14
|
}
|
|
15
15
|
checkInputs() {
|
|
16
|
-
this.camera.
|
|
16
|
+
this.camera.movement.zoomAccumulatedPixels = this._wheelDeltaY;
|
|
17
17
|
super.checkInputs();
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geospatialCameraMouseWheelInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraMouseWheelInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;GAGG;AACH,MAAM,OAAO,+BAAgC,SAAQ,yBAAyB;IAM1E;;;OAGG;IACa,YAAY;QACxB,OAAO,iCAAiC,CAAC;IAC7C,CAAC;IAEe,WAAW;QACvB,IAAI,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"geospatialCameraMouseWheelInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraMouseWheelInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;GAGG;AACH,MAAM,OAAO,+BAAgC,SAAQ,yBAAyB;IAM1E;;;OAGG;IACa,YAAY;QACxB,OAAO,iCAAiC,CAAC;IAC7C,CAAC;IAEe,WAAW;QACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,GAAG,IAAI,CAAC,YAAY,CAAC;QAC/D,KAAK,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;CACJ;AAEK,gBAAiB,CAAC,iCAAiC,CAAC,GAAG,+BAA+B,CAAC","sourcesContent":["import type { GeospatialCamera } from \"../../Cameras/geospatialCamera\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport { BaseCameraMouseWheelInput } from \"./BaseCameraMouseWheelInput\";\r\n\r\n/**\r\n * @experimental\r\n * Manage the mouse wheel inputs to control a geospatial camera. As this feature is experimental the API will evolve\r\n */\r\nexport class GeospatialCameraMouseWheelInput extends BaseCameraMouseWheelInput {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: GeospatialCamera;\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"GeospatialCameraMouseWheelInput\";\r\n }\r\n\r\n public override checkInputs(): void {\r\n this.camera.movement.zoomAccumulatedPixels = this._wheelDeltaY;\r\n super.checkInputs();\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"GeospatialCameraMouseWheelInput\"] = GeospatialCameraMouseWheelInput;\r\n"]}
|
|
@@ -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,26 @@ 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
|
+
onDoubleTap(type: string): void;
|
|
38
|
+
onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
39
|
+
onButtonUp(_evt: IPointerEvent): void;
|
|
44
40
|
private _handleTilt;
|
|
45
41
|
}
|
|
@@ -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,86 @@ 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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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);
|
|
74
59
|
}
|
|
75
60
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @param ref The offset vector between the drag plane's hitPoint and originPoint
|
|
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
|
|
81
65
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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);
|
|
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);
|
|
71
|
+
}
|
|
92
72
|
}
|
|
93
|
-
|
|
73
|
+
onDoubleTap(type) {
|
|
94
74
|
const scene = this.camera.getScene();
|
|
95
|
-
const pickResult = scene.pick(scene.pointerX, scene.pointerY);
|
|
96
|
-
if (pickResult.
|
|
97
|
-
const
|
|
98
|
-
this.
|
|
99
|
-
const delta = TmpVectors.Vector3[6];
|
|
100
|
-
newDragPlaneOffsetVector.subtractToRef(this._dragPlaneOffsetVector, delta);
|
|
101
|
-
this._dragPlaneOffsetVector.copyFrom(newDragPlaneOffsetVector);
|
|
102
|
-
this.camera._perFrameGeocentricTranslation.subtractInPlace(delta); // ???
|
|
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);
|
|
103
79
|
}
|
|
104
80
|
}
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
81
|
+
onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
82
|
+
this._shouldStartPinchZoom =
|
|
83
|
+
this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.limits.pinchToPanMax;
|
|
84
|
+
super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
108
85
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
86
|
+
onButtonUp(_evt) {
|
|
87
|
+
this.camera.movement.stopDrag();
|
|
88
|
+
this.camera.movement.alternateRotationPt = undefined;
|
|
89
|
+
this.camera.movement.activeInput = false;
|
|
90
|
+
super.onButtonUp(_evt);
|
|
91
|
+
}
|
|
92
|
+
_handleTilt(deltaX, deltaY) {
|
|
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
|
|
116
95
|
}
|
|
117
|
-
return false;
|
|
118
96
|
}
|
|
119
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,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,6BAA8B,SAAQ,uBAAuB;IAA1E;;QAGI;;WAEG;QACI,uBAAkB,GAAG,KAAK,CAAC;QAE1B,eAAU,GAAU,IAAI,KAAK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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,CAAC;QACrC,IAAI,UAAiC,CAAC;QACtC,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,EAAE,4CAA4C;gBAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC/D,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G,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,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
|
+
}
|