@babylonjs/core 8.28.3 → 8.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buffers/buffer.d.ts +4 -3
- package/Buffers/buffer.js +4 -3
- package/Buffers/buffer.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js +2 -0
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.d.ts +18 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +21 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -0
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +45 -0
- package/Cameras/Inputs/geospatialCameraPointersInput.js +119 -0
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -0
- package/Cameras/Inputs/index.d.ts +2 -0
- package/Cameras/Inputs/index.js +2 -0
- package/Cameras/Inputs/index.js.map +1 -1
- package/Cameras/arcRotateCamera.js +7 -5
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +2 -2
- package/Cameras/camera.js +2 -2
- package/Cameras/camera.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +89 -0
- package/Cameras/geospatialCamera.js +268 -0
- package/Cameras/geospatialCamera.js.map +1 -0
- package/Cameras/geospatialCameraInputsManager.d.ts +23 -0
- package/Cameras/geospatialCameraInputsManager.js +33 -0
- package/Cameras/geospatialCameraInputsManager.js.map +1 -0
- package/Cameras/index.d.ts +1 -0
- package/Cameras/index.js +1 -0
- package/Cameras/index.js.map +1 -1
- package/Cameras/targetCamera.d.ts +12 -0
- package/Cameras/targetCamera.js +19 -5
- package/Cameras/targetCamera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +7 -5
- package/Decorators/nodeDecorator.js +7 -5
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Events/pointerEvents.d.ts +4 -0
- package/Events/pointerEvents.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +19 -2
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +72 -4
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +8 -3
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +56 -34
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +0 -12
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +0 -45
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.d.ts +7 -3
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +18 -32
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +4 -0
- package/FrameGraph/frameGraphTextureManager.js +7 -1
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Layers/layerSceneComponent.js +3 -3
- package/Layers/layerSceneComponent.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +4 -1
- package/Lights/Clustered/clusteredLightContainer.js +17 -2
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +4 -4
- package/Materials/Node/Blocks/conditionalBlock.js +1 -1
- package/Materials/Node/Blocks/curveBlock.js +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js +1 -1
- package/Materials/Node/Blocks/waveBlock.js +1 -1
- package/Materials/PBR/openPbrMaterial.d.ts +2 -0
- package/Materials/PBR/openPbrMaterial.js +9 -6
- package/Materials/PBR/openPbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.js +2 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +2 -0
- package/Materials/Textures/renderTargetTexture.js +3 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialHelper.functions.js +1 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -0
- package/Materials/standardMaterial.js +2 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +1 -1
- package/Meshes/Node/Blocks/mappingBlock.js +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +1 -1
- package/Meshes/Node/Blocks/randomBlock.js +1 -1
- package/Meshes/geometry.js +26 -25
- package/Meshes/geometry.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Navigation/INavigationEngine.d.ts +17 -5
- package/Navigation/INavigationEngine.js.map +1 -1
- package/Navigation/Plugins/recastJSPlugin.d.ts +3 -2
- package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +1 -1
- package/Particles/Node/Blocks/particleMathBlock.js +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.js +1 -1
- package/Particles/Node/Blocks/particleTrigonometryBlock.js +1 -1
- package/Particles/Node/Blocks/systemBlock.js +1 -1
- package/Particles/gpuParticleSystem.js +1 -0
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +4 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +10 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.d.ts +3 -1
- package/PostProcesses/motionBlurPostProcess.js +13 -4
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +58 -0
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +2 -0
- package/Rendering/objectRenderer.js +13 -0
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +1 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/geometry.fragment.js +14 -0
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/geometry.vertex.js +20 -0
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/openpbr.vertex.js +1 -1
- package/Shaders/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +2 -2
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +14 -0
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +20 -0
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/openpbr.vertex.js +1 -1
- package/ShadersWGSL/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +2 -2
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Plane } from "../../Maths/math.plane.js";
|
|
2
|
+
import { TmpVectors, Vector3 } from "../../Maths/math.vector.js";
|
|
3
|
+
import { BaseCameraPointersInput } from "./BaseCameraPointersInput.js";
|
|
4
|
+
/**
|
|
5
|
+
* @experimental
|
|
6
|
+
* Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe
|
|
7
|
+
* The input will update the camera's localTranslation or localRotation values, and the camera is responsible for using these updates to calculate viewMatrix appropriately
|
|
8
|
+
*
|
|
9
|
+
* 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
|
+
* 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
|
|
11
|
+
*
|
|
12
|
+
* Left mouse button: drag globe
|
|
13
|
+
* Middle mouse button: tilt globe around cursor location
|
|
14
|
+
* Right mouse button: tilt globe around center of screen
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export class GeospatialCameraPointersInput extends BaseCameraPointersInput {
|
|
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
|
+
getClassName() {
|
|
31
|
+
return "GeospatialCameraPointersInput";
|
|
32
|
+
}
|
|
33
|
+
onButtonDown(evt) {
|
|
34
|
+
const scene = this.camera.getScene();
|
|
35
|
+
let pickResult;
|
|
36
|
+
switch (evt.button) {
|
|
37
|
+
case 0: // Left button - drag/pan globe under cursor
|
|
38
|
+
pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);
|
|
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
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case 1: // Middle button - tilt camera around cursor
|
|
50
|
+
pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);
|
|
51
|
+
pickResult.pickedPoint && (this.camera._alternateRotationPt = pickResult.pickedPoint);
|
|
52
|
+
break;
|
|
53
|
+
case 2: // Right button - tilt camera around center of screen, already the default
|
|
54
|
+
this.camera._alternateRotationPt = this.camera.center;
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
onTouch(point, offsetX, offsetY) {
|
|
61
|
+
switch (point?.button) {
|
|
62
|
+
case 0: // Left button - drag/pan globe under cursor
|
|
63
|
+
this._hitPointRadius !== undefined && this._handleDrag(this._hitPointRadius);
|
|
64
|
+
break;
|
|
65
|
+
case 1: // Middle button - tilt camera around cursor
|
|
66
|
+
case 2: // Right button - tilt camera
|
|
67
|
+
this._handleTilt(offsetX, offsetY);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
onButtonUp(_evt) {
|
|
72
|
+
this._hitPointRadius = undefined;
|
|
73
|
+
this.camera._alternateRotationPt = null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The DragPlaneOffsetVector represents the vector between the dragPlane hit point and the dragPlane origin point.
|
|
77
|
+
* 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
|
|
78
|
+
* @param hitPointRadius The distance between the world origin (center of globe) and the initial drag hit point
|
|
79
|
+
* @param ray The ray from the camera to the new cursor location
|
|
80
|
+
* @param ref The offset vector between the drag plane's hitPoint and originPoint
|
|
81
|
+
*/
|
|
82
|
+
_recalculateDragPlaneOffsetVectorToRef(hitPointRadius, ray, ref) {
|
|
83
|
+
// Use the camera's geocentric normal to find the dragPlaneOriginPoint which lives at hitPointRadius along the camera's geocentric normal
|
|
84
|
+
this.camera.position.normalizeToRef(this._dragPlaneNormal);
|
|
85
|
+
this._dragPlaneNormal.scaleToRef(hitPointRadius, this._dragPlaneOriginPoint);
|
|
86
|
+
// Now create a plane at that point, perpendicular to the camera's geocentric normal
|
|
87
|
+
Plane.FromPositionAndNormalToRef(this._dragPlaneOriginPoint, this._dragPlaneNormal, this._dragPlane);
|
|
88
|
+
// Lastly, find the _dragPlaneHitPoint where the ray intersects the _dragPlane
|
|
89
|
+
IntersectRayWithPlaneToRef(ray, this._dragPlane, this._dragPlaneHitPoint);
|
|
90
|
+
// Store the new offset between the drag plane's hitPoint and originPoint
|
|
91
|
+
this._dragPlaneHitPoint.subtractToRef(this._dragPlaneOriginPoint, ref);
|
|
92
|
+
}
|
|
93
|
+
_handleDrag(hitPointRadius) {
|
|
94
|
+
const scene = this.camera.getScene();
|
|
95
|
+
const pickResult = scene.pick(scene.pointerX, scene.pointerY);
|
|
96
|
+
if (pickResult.ray) {
|
|
97
|
+
const newDragPlaneOffsetVector = TmpVectors.Vector3[5];
|
|
98
|
+
this._recalculateDragPlaneOffsetVectorToRef(hitPointRadius, pickResult.ray, newDragPlaneOffsetVector);
|
|
99
|
+
const delta = TmpVectors.Vector3[6];
|
|
100
|
+
newDragPlaneOffsetVector.subtractToRef(this._dragPlaneOffsetVector, delta);
|
|
101
|
+
this._dragPlaneOffsetVector.copyFrom(newDragPlaneOffsetVector);
|
|
102
|
+
this.camera._perFrameGeocentricTranslation.subtractInPlace(delta); // ???
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_handleTilt(deltaX, deltaY) {
|
|
106
|
+
this.camera._perFrameGeocentricRotation.y += -deltaX / this.angularSensibility; // yaw - looking side to side
|
|
107
|
+
this.camera._perFrameGeocentricRotation.x += -deltaY / this.angularSensibility; // pitch - look up towards sky / down towards ground
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function IntersectRayWithPlaneToRef(ray, plane, ref) {
|
|
111
|
+
// Distance along the ray to the plane; null if no hit
|
|
112
|
+
const dist = ray.intersectsPlane(plane);
|
|
113
|
+
if (dist !== null && dist >= 0) {
|
|
114
|
+
ray.origin.addToRef(ray.direction.scaleToRef(dist, TmpVectors.Vector3[0]), ref);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=geospatialCameraPointersInput.js.map
|
|
@@ -0,0 +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,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1C,qBAAgB,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC3C,0BAAqB,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAChD,uBAAkB,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC7C,2BAAsB,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;IA8F7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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"]}
|
|
@@ -17,3 +17,5 @@ export * from "./freeCameraMouseInput.js";
|
|
|
17
17
|
export * from "./freeCameraMouseWheelInput.js";
|
|
18
18
|
export * from "./freeCameraTouchInput.js";
|
|
19
19
|
export * from "./freeCameraVirtualJoystickInput.js";
|
|
20
|
+
export * from "./geospatialCameraPointersInput.js";
|
|
21
|
+
export * from "./geospatialCameraMouseWheelInput.js";
|
package/Cameras/Inputs/index.js
CHANGED
|
@@ -17,4 +17,6 @@ export * from "./freeCameraMouseInput.js";
|
|
|
17
17
|
export * from "./freeCameraMouseWheelInput.js";
|
|
18
18
|
export * from "./freeCameraTouchInput.js";
|
|
19
19
|
export * from "./freeCameraVirtualJoystickInput.js";
|
|
20
|
+
export * from "./geospatialCameraPointersInput.js";
|
|
21
|
+
export * from "./geospatialCameraMouseWheelInput.js";
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC","sourcesContent":["export * from \"./BaseCameraMouseWheelInput\";\r\nexport * from \"./BaseCameraPointersInput\";\r\nexport * from \"./arcRotateCameraGamepadInput\";\r\nexport * from \"./arcRotateCameraKeyboardMoveInput\";\r\nexport * from \"./arcRotateCameraMouseWheelInput\";\r\nexport * from \"./arcRotateCameraPointersInput\";\r\nexport * from \"./arcRotateCameraVRDeviceOrientationInput\";\r\nexport * from \"./flyCameraKeyboardInput\";\r\nexport * from \"./flyCameraMouseInput\";\r\nexport * from \"./followCameraKeyboardMoveInput\";\r\nexport * from \"./followCameraMouseWheelInput\";\r\nexport * from \"./followCameraPointersInput\";\r\nexport * from \"./freeCameraDeviceOrientationInput\";\r\nexport * from \"./freeCameraGamepadInput\";\r\nexport * from \"./freeCameraKeyboardMoveInput\";\r\nexport * from \"./freeCameraMouseInput\";\r\nexport * from \"./freeCameraMouseWheelInput\";\r\nexport * from \"./freeCameraTouchInput\";\r\nexport * from \"./freeCameraVirtualJoystickInput\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC","sourcesContent":["export * from \"./BaseCameraMouseWheelInput\";\r\nexport * from \"./BaseCameraPointersInput\";\r\nexport * from \"./arcRotateCameraGamepadInput\";\r\nexport * from \"./arcRotateCameraKeyboardMoveInput\";\r\nexport * from \"./arcRotateCameraMouseWheelInput\";\r\nexport * from \"./arcRotateCameraPointersInput\";\r\nexport * from \"./arcRotateCameraVRDeviceOrientationInput\";\r\nexport * from \"./flyCameraKeyboardInput\";\r\nexport * from \"./flyCameraMouseInput\";\r\nexport * from \"./followCameraKeyboardMoveInput\";\r\nexport * from \"./followCameraMouseWheelInput\";\r\nexport * from \"./followCameraPointersInput\";\r\nexport * from \"./freeCameraDeviceOrientationInput\";\r\nexport * from \"./freeCameraGamepadInput\";\r\nexport * from \"./freeCameraKeyboardMoveInput\";\r\nexport * from \"./freeCameraMouseInput\";\r\nexport * from \"./freeCameraMouseWheelInput\";\r\nexport * from \"./freeCameraTouchInput\";\r\nexport * from \"./freeCameraVirtualJoystickInput\";\r\nexport * from \"./geospatialCameraPointersInput\";\r\nexport * from \"./geospatialCameraMouseWheelInput\";\r\n"]}
|
|
@@ -800,6 +800,8 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
800
800
|
}
|
|
801
801
|
this.inputs.checkInputs();
|
|
802
802
|
let hasUserInteractions = false;
|
|
803
|
+
const inertialPanningLimit = this.speed * this._panningEpsilon;
|
|
804
|
+
const inertialRotationLimit = this.speed * this._rotationEpsilon;
|
|
803
805
|
// Inertia
|
|
804
806
|
if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
|
|
805
807
|
hasUserInteractions = true;
|
|
@@ -815,13 +817,13 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
815
817
|
this.inertialAlphaOffset *= this.inertia;
|
|
816
818
|
this.inertialBetaOffset *= this.inertia;
|
|
817
819
|
this.inertialRadiusOffset *= this.inertia;
|
|
818
|
-
if (Math.abs(this.inertialAlphaOffset) <
|
|
820
|
+
if (Math.abs(this.inertialAlphaOffset) < inertialRotationLimit) {
|
|
819
821
|
this.inertialAlphaOffset = 0;
|
|
820
822
|
}
|
|
821
|
-
if (Math.abs(this.inertialBetaOffset) <
|
|
823
|
+
if (Math.abs(this.inertialBetaOffset) < inertialRotationLimit) {
|
|
822
824
|
this.inertialBetaOffset = 0;
|
|
823
825
|
}
|
|
824
|
-
if (Math.abs(this.inertialRadiusOffset) <
|
|
826
|
+
if (Math.abs(this.inertialRadiusOffset) < inertialRotationLimit) {
|
|
825
827
|
this.inertialRadiusOffset = 0;
|
|
826
828
|
}
|
|
827
829
|
}
|
|
@@ -862,10 +864,10 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
862
864
|
}
|
|
863
865
|
this.inertialPanningX *= this.panningInertia;
|
|
864
866
|
this.inertialPanningY *= this.panningInertia;
|
|
865
|
-
if (Math.abs(this.inertialPanningX) <
|
|
867
|
+
if (Math.abs(this.inertialPanningX) < inertialPanningLimit) {
|
|
866
868
|
this.inertialPanningX = 0;
|
|
867
869
|
}
|
|
868
|
-
if (Math.abs(this.inertialPanningY) <
|
|
870
|
+
if (Math.abs(this.inertialPanningY) < inertialPanningLimit) {
|
|
869
871
|
this.inertialPanningY = 0;
|
|
870
872
|
}
|
|
871
873
|
}
|