@onerjs/core 8.31.0 → 8.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +8 -2
- package/Behaviors/Cameras/interpolatingBehavior.js +58 -6
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +11 -9
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +8 -20
- package/Cameras/Inputs/geospatialCameraPointersInput.js +35 -75
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Limits/geospatialLimits.d.ts +60 -0
- package/Cameras/Limits/geospatialLimits.js +89 -0
- package/Cameras/Limits/geospatialLimits.js.map +1 -0
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js +2 -2
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/cameraMovement.js +1 -1
- package/Cameras/cameraMovement.js.map +1 -1
- package/Cameras/deviceOrientationCamera.js +5 -3
- package/Cameras/deviceOrientationCamera.js.map +1 -1
- package/Cameras/flyCamera.d.ts +2 -1
- package/Cameras/flyCamera.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +78 -49
- package/Cameras/geospatialCamera.js +210 -191
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
- package/Cameras/geospatialCameraInputsManager.js +9 -0
- package/Cameras/geospatialCameraInputsManager.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +66 -0
- package/Cameras/geospatialCameraMovement.js +199 -0
- package/Cameras/geospatialCameraMovement.js.map +1 -0
- package/Cameras/targetCamera.d.ts +1 -1
- package/Cameras/targetCamera.js +2 -2
- package/Cameras/targetCamera.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +2 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
- package/FlowGraph/flowGraphMath.d.ts +25 -0
- package/FlowGraph/flowGraphMath.js +40 -0
- package/FlowGraph/flowGraphMath.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/shaderMaterial.js +4 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +5 -24
- package/Maths/math.vector.functions.js +32 -35
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +15 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/tools.d.ts +3 -0
- package/Misc/tools.js +43 -4
- package/Misc/tools.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +8 -8
- package/Particles/Node/Blocks/systemBlock.js +12 -12
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +9 -7
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +288 -149
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/particle.d.ts +4 -0
- package/Particles/particle.js +2 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +0 -4
- package/Particles/thinParticleSystem.function.d.ts +1 -1
- package/Particles/thinParticleSystem.function.js +9 -6
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -3
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/XR/webXRCamera.d.ts +5 -1
- package/XR/webXRCamera.js +2 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRExperienceHelper.js +1 -1
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freeCameraDeviceOrientationInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,uBAAuB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oGAAoG;QACpG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QACD,UAAU,CAAC,yBAAyB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC/J,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACzE,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,oBAAoB,EAAE,CAAC;YAC/C,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAEK,gBAAiB,CAAC,kCAAkC,CAAC,GAAG,gCAAgC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { FreeCamera } from \"../../Cameras/freeCamera\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { FreeCameraInputsManager } from \"../../Cameras/freeCameraInputsManager\";\r\nimport { Observable } from \"../../Misc/observable\";\r\n\r\n// Module augmentation to abstract orientation inputs from camera.\r\ndeclare module \"../../Cameras/freeCameraInputsManager\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface FreeCameraInputsManager {\r\n /**\r\n * @internal\r\n */\r\n _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;\r\n /**\r\n * Add orientation input support to the input manager.\r\n * @param smoothFactor deviceOrientation smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing\r\n * @returns the current input manager\r\n */\r\n addDeviceOrientation(smoothFactor?: number): FreeCameraInputsManager;\r\n }\r\n}\r\n\r\n/**\r\n * Add orientation input support to the input manager.\r\n * @param smoothFactor deviceOrientation smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing\r\n * @returns the current input manager\r\n */\r\nFreeCameraInputsManager.prototype.addDeviceOrientation = function (smoothFactor?: number): FreeCameraInputsManager {\r\n if (!this._deviceOrientationInput) {\r\n this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();\r\n if (smoothFactor) {\r\n this._deviceOrientationInput.smoothFactor = smoothFactor;\r\n }\r\n this.add(this._deviceOrientationInput);\r\n }\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.\r\n * Screen rotation is taken into account.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {\r\n private _camera: FreeCamera;\r\n\r\n private _screenOrientationAngle: number = 0;\r\n\r\n private _constantTransform: Quaternion;\r\n private _screenQuaternion: Quaternion = new Quaternion();\r\n\r\n private _alpha: number = 0;\r\n private _beta: number = 0;\r\n private _gamma: number = 0;\r\n\r\n /** alpha+beta+gamma smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing */\r\n public smoothFactor: number = 0;\r\n\r\n /**\r\n * Can be used to detect if a device orientation sensor is available on a device\r\n * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)\r\n * @returns a promise that will resolve on orientation change\r\n */\r\n public static async WaitForOrientationChangeAsync(timeout?: number): Promise<void> {\r\n return await new Promise((res, rej) => {\r\n let gotValue = false;\r\n const eventHandler = () => {\r\n window.removeEventListener(\"deviceorientation\", eventHandler);\r\n gotValue = true;\r\n res();\r\n };\r\n\r\n // If timeout is populated reject the promise\r\n if (timeout) {\r\n setTimeout(() => {\r\n if (!gotValue) {\r\n window.removeEventListener(\"deviceorientation\", eventHandler);\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n rej(\"WaitForOrientationChangeAsync timed out\");\r\n }\r\n }, timeout);\r\n }\r\n\r\n if (typeof DeviceOrientationEvent !== \"undefined\" && typeof (<any>DeviceOrientationEvent).requestPermission === \"function\") {\r\n (<any>DeviceOrientationEvent)\r\n .requestPermission()\r\n // eslint-disable-next-line github/no-then\r\n .then((response: string) => {\r\n if (response == \"granted\") {\r\n window.addEventListener(\"deviceorientation\", eventHandler);\r\n } else {\r\n Tools.Warn(\"Permission not granted.\");\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((error: any) => {\r\n Tools.Error(error);\r\n });\r\n } else {\r\n window.addEventListener(\"deviceorientation\", eventHandler);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onDeviceOrientationChangedObservable = new Observable<void>();\r\n /**\r\n * Instantiates a new input\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\n constructor() {\r\n this._constantTransform = new Quaternion(-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));\r\n this._orientationChanged();\r\n }\r\n\r\n /**\r\n * Define the camera controlled by the input.\r\n */\r\n public get camera(): FreeCamera {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: FreeCamera) {\r\n this._camera = camera;\r\n if (this._camera != null && !this._camera.rotationQuaternion) {\r\n this._camera.rotationQuaternion = new Quaternion();\r\n }\r\n if (this._camera) {\r\n this._camera.onDisposeObservable.add(() => {\r\n this._onDeviceOrientationChangedObservable.clear();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n */\r\n public attachControl(): void {\r\n const hostWindow = this.camera.getScene().getEngine().getHostWindow();\r\n\r\n if (hostWindow) {\r\n const eventHandler = () => {\r\n hostWindow.addEventListener(\"orientationchange\", this._orientationChanged);\r\n hostWindow.addEventListener(\"deviceorientation\", this._deviceOrientation);\r\n //In certain cases, the attach control is called AFTER orientation was changed,\r\n //So this is needed.\r\n this._orientationChanged();\r\n };\r\n if (typeof DeviceOrientationEvent !== \"undefined\" && typeof (<any>DeviceOrientationEvent).requestPermission === \"function\") {\r\n (<any>DeviceOrientationEvent)\r\n .requestPermission()\r\n // eslint-disable-next-line github/no-then\r\n .then((response: string) => {\r\n if (response === \"granted\") {\r\n eventHandler();\r\n } else {\r\n Tools.Warn(\"Permission not granted.\");\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((error: any) => {\r\n Tools.Error(error);\r\n });\r\n } else {\r\n eventHandler();\r\n }\r\n }\r\n }\r\n\r\n private _orientationChanged = () => {\r\n this._screenOrientationAngle =\r\n <any>window.orientation !== undefined\r\n ? +(<any>window.orientation)\r\n : (<any>window.screen).orientation && (<any>window.screen).orientation[\"angle\"]\r\n ? (<any>window.screen).orientation.angle\r\n : 0;\r\n this._screenOrientationAngle = -Tools.ToRadians(this._screenOrientationAngle / 2);\r\n this._screenQuaternion.copyFromFloats(0, Math.sin(this._screenOrientationAngle), 0, Math.cos(this._screenOrientationAngle));\r\n };\r\n\r\n private _deviceOrientation = (evt: DeviceOrientationEvent) => {\r\n if (this.smoothFactor) {\r\n this._alpha = evt.alpha !== null ? Tools.SmoothAngleChange(this._alpha, evt.alpha, this.smoothFactor) : 0;\r\n this._beta = evt.beta !== null ? Tools.SmoothAngleChange(this._beta, evt.beta, this.smoothFactor) : 0;\r\n this._gamma = evt.gamma !== null ? Tools.SmoothAngleChange(this._gamma, evt.gamma, this.smoothFactor) : 0;\r\n } else {\r\n this._alpha = evt.alpha !== null ? evt.alpha : 0;\r\n this._beta = evt.beta !== null ? evt.beta : 0;\r\n this._gamma = evt.gamma !== null ? evt.gamma : 0;\r\n }\r\n\r\n if (evt.alpha !== null) {\r\n this._onDeviceOrientationChangedObservable.notifyObservers();\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 window.removeEventListener(\"orientationchange\", this._orientationChanged);\r\n window.removeEventListener(\"deviceorientation\", this._deviceOrientation);\r\n this._alpha = 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 no device orientation provided, don't update the rotation.\r\n // Only testing against alpha under the assumption that orientation will never be so exact when set.\r\n if (!this._alpha) {\r\n return;\r\n }\r\n Quaternion.RotationYawPitchRollToRef(Tools.ToRadians(this._alpha), Tools.ToRadians(this._beta), -Tools.ToRadians(this._gamma), this.camera.rotationQuaternion);\r\n this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);\r\n this._camera.rotationQuaternion.multiplyInPlace(this._constantTransform);\r\n if (this._camera.getScene().useRightHandedSystem) {\r\n this._camera.rotationQuaternion.y *= -1;\r\n } else {\r\n this._camera.rotationQuaternion.z *= -1;\r\n }\r\n this._camera.rotationQuaternion.w *= -1;\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 \"FreeCameraDeviceOrientationInput\";\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 \"deviceOrientation\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"FreeCameraDeviceOrientationInput\"] = FreeCameraDeviceOrientationInput;\r\n"]}
|
|
1
|
+
{"version":3,"file":"freeCameraDeviceOrientationInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAmBnD;;;;GAIG;AACH,uBAAuB,CAAC,SAAS,CAAC,oBAAoB,GAAG,UAAU,YAAqB;IACpF,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAChC,IAAI,CAAC,uBAAuB,GAAG,IAAI,gCAAgC,EAAE,CAAC;QACtE,IAAI,YAAY,EAAE,CAAC;YACf,IAAI,CAAC,uBAAuB,CAAC,YAAY,GAAG,YAAY,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,gCAAgC;IAezC;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,OAAgB;QAC9D,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAClC,IAAI,QAAQ,GAAG,KAAK,CAAC;YACrB,MAAM,YAAY,GAAG,GAAG,EAAE;gBACtB,MAAM,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;gBAC9D,QAAQ,GAAG,IAA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C;YACD,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAEK,gBAAiB,CAAC,kCAAkC,CAAC,GAAG,gCAAgC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { FreeCamera } from \"../../Cameras/freeCamera\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { FreeCameraInputsManager } from \"../../Cameras/freeCameraInputsManager\";\r\nimport { Observable } from \"../../Misc/observable\";\r\n\r\n// Module augmentation to abstract orientation inputs from camera.\r\ndeclare module \"../../Cameras/freeCameraInputsManager\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface FreeCameraInputsManager {\r\n /**\r\n * @internal\r\n */\r\n _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;\r\n /**\r\n * Add orientation input support to the input manager.\r\n * @param smoothFactor deviceOrientation smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing\r\n * @returns the current input manager\r\n */\r\n addDeviceOrientation(smoothFactor?: number): FreeCameraInputsManager;\r\n }\r\n}\r\n\r\n/**\r\n * Add orientation input support to the input manager.\r\n * @param smoothFactor deviceOrientation smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing\r\n * @returns the current input manager\r\n */\r\nFreeCameraInputsManager.prototype.addDeviceOrientation = function (smoothFactor?: number): FreeCameraInputsManager {\r\n if (!this._deviceOrientationInput) {\r\n this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();\r\n if (smoothFactor) {\r\n this._deviceOrientationInput.smoothFactor = smoothFactor;\r\n }\r\n this.add(this._deviceOrientationInput);\r\n }\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.\r\n * Screen rotation is taken into account.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {\r\n private _camera: FreeCamera;\r\n\r\n private _screenOrientationAngle: number = 0;\r\n\r\n private _constantTransform: Quaternion;\r\n private _screenQuaternion: Quaternion = new Quaternion();\r\n\r\n private _alpha: number = 0;\r\n private _beta: number = 0;\r\n private _gamma: number = 0;\r\n\r\n /** alpha+beta+gamma smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing */\r\n public smoothFactor: number = 0;\r\n\r\n /**\r\n * Can be used to detect if a device orientation sensor is available on a device\r\n * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)\r\n * @returns a promise that will resolve on orientation change\r\n */\r\n public static async WaitForOrientationChangeAsync(timeout?: number): Promise<void> {\r\n return await new Promise((res, rej) => {\r\n let gotValue = false;\r\n const eventHandler = () => {\r\n window.removeEventListener(\"deviceorientation\", eventHandler);\r\n gotValue = true;\r\n res();\r\n };\r\n\r\n // If timeout is populated reject the promise\r\n if (timeout) {\r\n setTimeout(() => {\r\n if (!gotValue) {\r\n window.removeEventListener(\"deviceorientation\", eventHandler);\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n rej(\"WaitForOrientationChangeAsync timed out\");\r\n }\r\n }, timeout);\r\n }\r\n\r\n if (typeof DeviceOrientationEvent !== \"undefined\" && typeof (<any>DeviceOrientationEvent).requestPermission === \"function\") {\r\n (<any>DeviceOrientationEvent)\r\n .requestPermission()\r\n // eslint-disable-next-line github/no-then\r\n .then((response: string) => {\r\n if (response == \"granted\") {\r\n window.addEventListener(\"deviceorientation\", eventHandler);\r\n } else {\r\n Tools.Warn(\"Permission not granted.\");\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((error: any) => {\r\n Tools.Error(error);\r\n });\r\n } else {\r\n window.addEventListener(\"deviceorientation\", eventHandler);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onDeviceOrientationChangedObservable = new Observable<void>();\r\n /**\r\n * Instantiates a new input\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\n constructor() {\r\n this._constantTransform = new Quaternion(-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));\r\n this._orientationChanged();\r\n }\r\n\r\n /**\r\n * Define the camera controlled by the input.\r\n */\r\n public get camera(): FreeCamera {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: FreeCamera) {\r\n this._camera = camera;\r\n if (this._camera != null && !this._camera.rotationQuaternion) {\r\n this._camera.rotationQuaternion = new Quaternion();\r\n }\r\n if (this._camera) {\r\n this._camera.onDisposeObservable.add(() => {\r\n this._onDeviceOrientationChangedObservable.clear();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n */\r\n public attachControl(): void {\r\n const hostWindow = this.camera.getScene().getEngine().getHostWindow();\r\n\r\n if (hostWindow) {\r\n const eventHandler = () => {\r\n hostWindow.addEventListener(\"orientationchange\", this._orientationChanged);\r\n hostWindow.addEventListener(\"deviceorientation\", this._deviceOrientation);\r\n //In certain cases, the attach control is called AFTER orientation was changed,\r\n //So this is needed.\r\n this._orientationChanged();\r\n };\r\n if (typeof DeviceOrientationEvent !== \"undefined\" && typeof (<any>DeviceOrientationEvent).requestPermission === \"function\") {\r\n (<any>DeviceOrientationEvent)\r\n .requestPermission()\r\n // eslint-disable-next-line github/no-then\r\n .then((response: string) => {\r\n if (response === \"granted\") {\r\n eventHandler();\r\n } else {\r\n Tools.Warn(\"Permission not granted.\");\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((error: any) => {\r\n Tools.Error(error);\r\n });\r\n } else {\r\n eventHandler();\r\n }\r\n }\r\n }\r\n\r\n private _orientationChanged = () => {\r\n this._screenOrientationAngle =\r\n <any>window.orientation !== undefined\r\n ? +(<any>window.orientation)\r\n : (<any>window.screen).orientation && (<any>window.screen).orientation[\"angle\"]\r\n ? (<any>window.screen).orientation.angle\r\n : 0;\r\n this._screenOrientationAngle = -Tools.ToRadians(this._screenOrientationAngle / 2);\r\n this._screenQuaternion.copyFromFloats(0, Math.sin(this._screenOrientationAngle), 0, Math.cos(this._screenOrientationAngle));\r\n };\r\n\r\n private _deviceOrientation = (evt: DeviceOrientationEvent) => {\r\n if (this.smoothFactor) {\r\n this._alpha = evt.alpha !== null ? Tools.SmoothAngleChange(this._alpha, evt.alpha, this.smoothFactor) : 0;\r\n this._beta = evt.beta !== null ? Tools.SmoothAngleChange(this._beta, evt.beta, this.smoothFactor) : 0;\r\n this._gamma = evt.gamma !== null ? Tools.SmoothAngleChange(this._gamma, evt.gamma, this.smoothFactor) : 0;\r\n } else {\r\n this._alpha = evt.alpha !== null ? evt.alpha : 0;\r\n this._beta = evt.beta !== null ? evt.beta : 0;\r\n this._gamma = evt.gamma !== null ? evt.gamma : 0;\r\n }\r\n\r\n if (evt.alpha !== null) {\r\n this._onDeviceOrientationChangedObservable.notifyObservers();\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 window.removeEventListener(\"orientationchange\", this._orientationChanged);\r\n window.removeEventListener(\"deviceorientation\", this._deviceOrientation);\r\n this._alpha = 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 no device orientation provided, don't update the rotation.\r\n // Only testing against alpha under the assumption that orientation will never be so exact when set.\r\n if (!this._alpha) {\r\n return;\r\n }\r\n if (this._camera.rotationQuaternion) {\r\n Quaternion.RotationYawPitchRollToRef(Tools.ToRadians(this._alpha), Tools.ToRadians(this._beta), -Tools.ToRadians(this._gamma), this._camera.rotationQuaternion);\r\n\r\n this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);\r\n this._camera.rotationQuaternion.multiplyInPlace(this._constantTransform);\r\n if (this._camera.getScene().useRightHandedSystem) {\r\n this._camera.rotationQuaternion.y *= -1;\r\n } else {\r\n this._camera.rotationQuaternion.z *= -1;\r\n }\r\n this._camera.rotationQuaternion.w *= -1;\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 \"FreeCameraDeviceOrientationInput\";\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 \"deviceOrientation\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"FreeCameraDeviceOrientationInput\"] = FreeCameraDeviceOrientationInput;\r\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { GeospatialCamera } from "../geospatialCamera.js";
|
|
2
|
+
import type { ICameraInput } from "../cameraInputsManager.js";
|
|
3
|
+
/**
|
|
4
|
+
* Manage the keyboard inputs to control the movement of a geospatial camera.
|
|
5
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
|
|
6
|
+
*/
|
|
7
|
+
export declare class GeospatialCameraKeyboardInput implements ICameraInput<GeospatialCamera> {
|
|
8
|
+
/**
|
|
9
|
+
* Defines the camera the input is attached to.
|
|
10
|
+
*/
|
|
11
|
+
camera: GeospatialCamera;
|
|
12
|
+
/**
|
|
13
|
+
* Defines the list of key codes associated with the up action (pan up)
|
|
14
|
+
*/
|
|
15
|
+
keysUp: number[];
|
|
16
|
+
/**
|
|
17
|
+
* Defines the list of key codes associated with the down action (pan down)
|
|
18
|
+
*/
|
|
19
|
+
keysDown: number[];
|
|
20
|
+
/**
|
|
21
|
+
* Defines the list of key codes associated with the left action (pan left)
|
|
22
|
+
*/
|
|
23
|
+
keysLeft: number[];
|
|
24
|
+
/**
|
|
25
|
+
* Defines the list of key codes associated with the right action (pan right)
|
|
26
|
+
*/
|
|
27
|
+
keysRight: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Defines the list of key codes associated with zoom in (+ or =)
|
|
30
|
+
*/
|
|
31
|
+
keysZoomIn: number[];
|
|
32
|
+
/**
|
|
33
|
+
* Defines the list of key codes associated with zoom out (-)
|
|
34
|
+
*/
|
|
35
|
+
keysZoomOut: number[];
|
|
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
|
+
rotationSensitivity: number;
|
|
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
|
+
panSensitivity: number;
|
|
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
|
+
zoomSensitivity: number;
|
|
51
|
+
private _keys;
|
|
52
|
+
private _ctrlPressed;
|
|
53
|
+
private _onCanvasBlurObserver;
|
|
54
|
+
private _onKeyboardObserver;
|
|
55
|
+
private _engine;
|
|
56
|
+
private _scene;
|
|
57
|
+
/**
|
|
58
|
+
* Attach the input controls to a specific dom element to get the input from.
|
|
59
|
+
* @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
|
|
60
|
+
*/
|
|
61
|
+
attachControl(noPreventDefault?: boolean): void;
|
|
62
|
+
/**
|
|
63
|
+
* Detach the current controls from the specified dom element.
|
|
64
|
+
*/
|
|
65
|
+
detachControl(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Update the current camera state depending on the inputs that have been used this frame.
|
|
68
|
+
* This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
|
|
69
|
+
*/
|
|
70
|
+
checkInputs(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the class name of the current input.
|
|
73
|
+
* @returns the class name
|
|
74
|
+
*/
|
|
75
|
+
getClassName(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get the friendly name associated with the input class.
|
|
78
|
+
* @returns the input friendly name
|
|
79
|
+
*/
|
|
80
|
+
getSimpleName(): string;
|
|
81
|
+
}
|
|
@@ -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,EA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CAAC,CAAC;wBACvE,CAAC;6BAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;4BAC/C,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;wBACvE,CAAC;wBACD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;oBAC/B,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAjNU;IADN,SAAS,EAAE;6DACS;AAMd;IADN,SAAS,EAAE;+DACW;AAMhB;IADN,SAAS,EAAE;+DACW;AAMhB;IADN,SAAS,EAAE;gEACY;AAMjB;IADN,SAAS,EAAE;iEACmB;AAMxB;IADN,SAAS,EAAE;kEACoB;AAOzB;IADN,SAAS,EAAE;0EACqB;AAO1B;IADN,SAAS,EAAE;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"]}
|
|
@@ -6,7 +6,7 @@ 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
|
|
@@ -18,19 +18,15 @@ import { OrbitCameraPointersInput } from "./orbitCameraPointersInput.js";
|
|
|
18
18
|
*/
|
|
19
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;
|
|
24
|
+
/**
|
|
25
|
+
* Move camera from multitouch (pinch) zoom distances.
|
|
26
|
+
* @param previousPinchSquaredDistance
|
|
27
|
+
* @param pinchSquaredDistance
|
|
28
|
+
*/
|
|
29
|
+
protected _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void;
|
|
34
30
|
/**
|
|
35
31
|
* Move camera from multi touch panning positions.
|
|
36
32
|
* In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)
|
|
@@ -38,16 +34,8 @@ export declare class GeospatialCameraPointersInput extends OrbitCameraPointersIn
|
|
|
38
34
|
* @param multiTouchPanPosition
|
|
39
35
|
*/
|
|
40
36
|
protected _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
37
|
+
onDoubleTap(type: string): void;
|
|
41
38
|
onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
42
39
|
onButtonUp(_evt: IPointerEvent): void;
|
|
43
|
-
/**
|
|
44
|
-
* The DragPlaneOffsetVector represents the vector between the dragPlane hit point and the dragPlane origin point.
|
|
45
|
-
* 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
|
|
46
|
-
* @param hitPointRadius The distance between the world origin (center of globe) and the initial drag hit point
|
|
47
|
-
* @param ray The ray from the camera to the new cursor location
|
|
48
|
-
* @param ref The offset vector between the drag plane's hitPoint and originPoint
|
|
49
|
-
*/
|
|
50
|
-
private _recalculateDragPlaneOffsetVectorToRef;
|
|
51
|
-
private _handleDrag;
|
|
52
40
|
private _handleTilt;
|
|
53
41
|
}
|