@babylonjs/core 8.36.1 → 8.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +5 -1
- package/AudioV2/audioParameter.js +4 -0
- package/AudioV2/audioParameter.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
- package/AudioV2/webAudio/components/webAudioParameterComponent.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/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/camera.js +1 -0
- package/Cameras/camera.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/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.js +0 -4
- package/Cameras/targetCamera.js.map +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Debug/debugLayer.d.ts +1 -1
- package/Debug/debugLayer.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/webgpuCacheSampler.js +4 -0
- package/Engines/WebGPU/webgpuCacheSampler.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.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +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/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.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/Rendering/shadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.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.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +14 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +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/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/csmShadowGeneratorTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.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/Rendering/shadowGeneratorTask.d.ts +2 -3
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.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/Tasks/Texture/copyToTextureTask.d.ts +4 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.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/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +22 -3
- package/FrameGraph/frameGraphRenderContext.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/PBR/openpbrMaterial.js +2 -1
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +19 -0
- package/Materials/floatingOriginMatrixOverrides.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/Node/Blocks/randomBlock.js +11 -11
- package/Meshes/Node/Blocks/randomBlock.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/copyTextureToTexture.d.ts +8 -1
- package/Misc/copyTextureToTexture.js +16 -2
- package/Misc/copyTextureToTexture.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 +6 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
- package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +0 -4
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +1 -8
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +16 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +67 -14
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.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 +3 -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 +40 -22
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +21 -9
- package/Particles/Node/Blocks/systemBlock.js +37 -22
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +7 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +6 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +14 -5
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +586 -148
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -1
- package/Particles/Node/nodeParticleSystemSet.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 +3 -3
- package/Particles/thinParticleSystem.function.js +11 -8
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +5 -7
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -1
- package/Rendering/prePassRenderer.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/copyTextureToTexture.fragment.js +2 -2
- package/Shaders/copyTextureToTexture.fragment.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/copyTextureToTexture.fragment.js +3 -3
- package/ShadersWGSL/copyTextureToTexture.fragment.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/webXRSessionManager.js +4 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -3
- package/scene.js +8 -7
- package/scene.js.map +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -3,9 +3,6 @@ import type { IAudioParameterRampOptions } from "../../audioParameter.js";
|
|
|
3
3
|
import type { _WebAudioEngine } from "../webAudioEngine.js";
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare class _WebAudioParameterComponent {
|
|
6
|
-
private _deferredRampOptions;
|
|
7
|
-
private _deferredTargetValue;
|
|
8
|
-
private _isObservingUpdates;
|
|
9
6
|
private _rampEndTime;
|
|
10
7
|
private _engine;
|
|
11
8
|
private _param;
|
|
@@ -24,22 +21,7 @@ export declare class _WebAudioParameterComponent {
|
|
|
24
21
|
/**
|
|
25
22
|
* Sets the target value of the audio parameter with an optional ramping duration and shape.
|
|
26
23
|
*
|
|
27
|
-
* If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it
|
|
28
|
-
* will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with
|
|
29
|
-
* `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have
|
|
30
|
-
* this issue, but we throw an error in all browsers to ensure consistent behavior.
|
|
31
|
-
*
|
|
32
|
-
* There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and
|
|
33
|
-
* `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.
|
|
34
|
-
*
|
|
35
|
-
* It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using
|
|
36
|
-
* `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will
|
|
37
|
-
* probably be a performance hit to maintain quality at audio rates.
|
|
38
|
-
*
|
|
39
24
|
* @internal
|
|
40
25
|
*/
|
|
41
26
|
setTargetValue(value: number, options?: Nullable<Partial<IAudioParameterRampOptions>>): void;
|
|
42
|
-
private _deferRamp;
|
|
43
|
-
private _applyDeferredRamp;
|
|
44
|
-
private _clearDeferredRamp;
|
|
45
27
|
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import { _GetAudioParamCurveValues } from "../../audioUtils.js";
|
|
2
|
-
/**
|
|
3
|
-
* Maximum time in seconds to wait for an active ramp to finish before starting a new ramp.
|
|
4
|
-
*
|
|
5
|
-
* New ramps will throw an error if the active ramp has more than this amount of time remaining.
|
|
6
|
-
*
|
|
7
|
-
* This is needed because short ramps are used to avoid pops and clicks when setting audio parameters, and we
|
|
8
|
-
* don't want to throw an error if a short ramp is active.
|
|
9
|
-
*
|
|
10
|
-
* This constant is set to 11 milliseconds, which is short enough to avoid perceptual differences in most cases, but
|
|
11
|
-
* long enough to allow for short ramps to be completed in a reasonable time frame.
|
|
12
|
-
*/
|
|
13
|
-
const MaxWaitTime = 0.011;
|
|
14
2
|
/**
|
|
15
3
|
* Minimum duration in seconds for a ramp to be considered valid.
|
|
16
4
|
*
|
|
@@ -22,18 +10,7 @@ const MinRampDuration = 0.000001;
|
|
|
22
10
|
export class _WebAudioParameterComponent {
|
|
23
11
|
/** @internal */
|
|
24
12
|
constructor(engine, param) {
|
|
25
|
-
this._deferredRampOptions = {
|
|
26
|
-
duration: 0,
|
|
27
|
-
shape: "linear" /* AudioParameterRampShape.Linear */,
|
|
28
|
-
};
|
|
29
|
-
this._deferredTargetValue = -1;
|
|
30
|
-
this._isObservingUpdates = false;
|
|
31
13
|
this._rampEndTime = 0;
|
|
32
|
-
this._applyDeferredRamp = () => {
|
|
33
|
-
if (0 < this._deferredRampOptions.duration && this._rampEndTime < this._engine.currentTime) {
|
|
34
|
-
this.setTargetValue(this._deferredTargetValue, this._deferredRampOptions);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
14
|
this._engine = engine;
|
|
38
15
|
this._param = param;
|
|
39
16
|
this._targetValue = param.value;
|
|
@@ -55,68 +32,31 @@ export class _WebAudioParameterComponent {
|
|
|
55
32
|
}
|
|
56
33
|
/** @internal */
|
|
57
34
|
dispose() {
|
|
58
|
-
this._clearDeferredRamp();
|
|
59
35
|
this._param = null;
|
|
60
36
|
this._engine = null;
|
|
61
37
|
}
|
|
62
38
|
/**
|
|
63
39
|
* Sets the target value of the audio parameter with an optional ramping duration and shape.
|
|
64
40
|
*
|
|
65
|
-
* If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it
|
|
66
|
-
* will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with
|
|
67
|
-
* `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have
|
|
68
|
-
* this issue, but we throw an error in all browsers to ensure consistent behavior.
|
|
69
|
-
*
|
|
70
|
-
* There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and
|
|
71
|
-
* `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.
|
|
72
|
-
*
|
|
73
|
-
* It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using
|
|
74
|
-
* `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will
|
|
75
|
-
* probably be a performance hit to maintain quality at audio rates.
|
|
76
|
-
*
|
|
77
41
|
* @internal
|
|
78
42
|
*/
|
|
79
43
|
setTargetValue(value, options = null) {
|
|
80
|
-
if (this._targetValue === value) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
44
|
const shape = typeof options?.shape === "string" ? options.shape : "linear" /* AudioParameterRampShape.Linear */;
|
|
84
|
-
let duration = typeof options?.duration === "number" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;
|
|
85
45
|
const startTime = this._engine.currentTime;
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
else {
|
|
92
|
-
this._deferRamp(value, duration, shape);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
46
|
+
if (shape === "none" /* AudioParameterRampShape.None */) {
|
|
47
|
+
this._param.cancelScheduledValues(startTime);
|
|
48
|
+
this._param.value = this._targetValue = value;
|
|
49
|
+
this._rampEndTime = startTime;
|
|
50
|
+
return;
|
|
95
51
|
}
|
|
52
|
+
let duration = typeof options?.duration === "number" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;
|
|
96
53
|
if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {
|
|
97
54
|
this._param.setValueAtTime((this._targetValue = value), startTime);
|
|
98
55
|
return;
|
|
99
56
|
}
|
|
100
57
|
this._param.cancelScheduledValues(startTime);
|
|
101
|
-
this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this.
|
|
102
|
-
this._clearDeferredRamp();
|
|
58
|
+
this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._param.value, (this._targetValue = value)), startTime, duration);
|
|
103
59
|
this._rampEndTime = startTime + duration;
|
|
104
60
|
}
|
|
105
|
-
_deferRamp(value, duration, shape) {
|
|
106
|
-
this._deferredRampOptions.duration = duration;
|
|
107
|
-
this._deferredRampOptions.shape = shape;
|
|
108
|
-
this._deferredTargetValue = value;
|
|
109
|
-
if (!this._isObservingUpdates) {
|
|
110
|
-
this._engine._addUpdateObserver(this._applyDeferredRamp);
|
|
111
|
-
this._isObservingUpdates = true;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
_clearDeferredRamp() {
|
|
115
|
-
this._deferredRampOptions.duration = 0;
|
|
116
|
-
if (this._isObservingUpdates) {
|
|
117
|
-
this._engine._removeUpdateObserver(this._applyDeferredRamp);
|
|
118
|
-
this._isObservingUpdates = false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
61
|
}
|
|
122
62
|
//# sourceMappingURL=webAudioParameterComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAudioParameterComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/components/webAudioParameterComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D
|
|
1
|
+
{"version":3,"file":"webAudioParameterComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/components/webAudioParameterComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D;;;;;GAKG;AACH,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAMpC,gBAAgB;IAChB,YAAY,MAAuB,EAAE,KAAiB;QAN9C,iBAAY,GAAW,CAAC,CAAC;QAO7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,gBAAgB;IAChB,IAAW,SAAS;QAChB,OAAO,IAAI,CAA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AO,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC;YACxF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,OAAO;QACX,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEvI,IAAI,CAAC,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC7C,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport { AudioParameterRampShape } from \"../../audioParameter\";\nimport { _GetAudioParamCurveValues } from \"../../audioUtils\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\n\n/**\n * Minimum duration in seconds for a ramp to be considered valid.\n *\n * If the duration is less than this value, the value will be set immediately instead of being ramped smoothly since\n * there is no perceptual difference for such short durations, so a ramp is not needed.\n */\nconst MinRampDuration = 0.000001;\n\n/** @internal */\nexport class _WebAudioParameterComponent {\n private _rampEndTime: number = 0;\n private _engine: _WebAudioEngine;\n private _param: AudioParam;\n private _targetValue: number;\n\n /** @internal */\n constructor(engine: _WebAudioEngine, param: AudioParam) {\n this._engine = engine;\n this._param = param;\n this._targetValue = param.value;\n }\n\n /** @internal */\n public get isRamping(): boolean {\n return this._engine.currentTime < this._rampEndTime;\n }\n\n /** @internal */\n public get targetValue(): number {\n return this._targetValue;\n }\n\n public set targetValue(value: number) {\n this.setTargetValue(value);\n }\n\n /** @internal */\n public get value(): number {\n return this._param.value;\n }\n\n /** @internal */\n public dispose(): void {\n this._param = null!;\n this._engine = null!;\n }\n\n /**\n * Sets the target value of the audio parameter with an optional ramping duration and shape.\n *\n * @internal\n */\n public setTargetValue(value: number, options: Nullable<Partial<IAudioParameterRampOptions>> = null): void {\n const shape = typeof options?.shape === \"string\" ? options.shape : AudioParameterRampShape.Linear;\n\n const startTime = this._engine.currentTime;\n\n if (shape === AudioParameterRampShape.None) {\n this._param.cancelScheduledValues(startTime);\n this._param.value = this._targetValue = value;\n this._rampEndTime = startTime;\n return;\n }\n\n let duration = typeof options?.duration === \"number\" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;\n\n if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {\n this._param.setValueAtTime((this._targetValue = value), startTime);\n return;\n }\n\n this._param.cancelScheduledValues(startTime);\n this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._param.value, (this._targetValue = value)), startTime, duration);\n\n this._rampEndTime = startTime + duration;\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Behavior } from "../behavior.js";
|
|
2
|
+
import { EasingFunction } from "../../Animations/easing.js";
|
|
3
|
+
import type { Camera } from "../../Cameras/camera.js";
|
|
4
|
+
import type { IColor3Like, IColor4Like, IMatrixLike, IQuaternionLike, IVector2Like, IVector3Like } from "../../Maths/math.like.js";
|
|
5
|
+
export type AllowedAnimValue = number | IVector2Like | IVector3Like | IQuaternionLike | IMatrixLike | IColor3Like | IColor4Like | SizeLike | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Animate camera property changes with an interpolation effect
|
|
8
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors
|
|
9
|
+
*/
|
|
10
|
+
export declare class InterpolatingBehavior<C extends Camera = Camera> implements Behavior<C> {
|
|
11
|
+
/**
|
|
12
|
+
* Gets the name of the behavior.
|
|
13
|
+
*/
|
|
14
|
+
get name(): string;
|
|
15
|
+
/**
|
|
16
|
+
* The easing function to use for interpolation
|
|
17
|
+
*/
|
|
18
|
+
easingFunction: EasingFunction;
|
|
19
|
+
/**
|
|
20
|
+
* The easing mode (default is EASINGMODE_EASEINOUT)
|
|
21
|
+
*/
|
|
22
|
+
easingMode: number;
|
|
23
|
+
/**
|
|
24
|
+
* Duration of the animation in milliseconds
|
|
25
|
+
*/
|
|
26
|
+
transitionDuration: number;
|
|
27
|
+
private _attachedCamera;
|
|
28
|
+
private _animatables;
|
|
29
|
+
private _promiseResolve?;
|
|
30
|
+
/**
|
|
31
|
+
* Initializes the behavior
|
|
32
|
+
*/
|
|
33
|
+
constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the behavior
|
|
36
|
+
*/
|
|
37
|
+
init(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Attaches the behavior to a camera
|
|
40
|
+
* @param camera The camera to attach to
|
|
41
|
+
*/
|
|
42
|
+
attach(camera: C): void;
|
|
43
|
+
/**
|
|
44
|
+
* Detaches the behavior from the camera
|
|
45
|
+
*/
|
|
46
|
+
detach(): void;
|
|
47
|
+
get isInterpolating(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Stops and removes all animations
|
|
50
|
+
*/
|
|
51
|
+
stopAllAnimations(): void;
|
|
52
|
+
updateProperties<K extends keyof C>(properties: Map<K, AllowedAnimValue>): void;
|
|
53
|
+
animatePropertiesAsync<K extends keyof C>(properties: Map<K, AllowedAnimValue>, transitionDuration?: number, easingFn?: EasingFunction): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export type SizeLike = {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { CubicEase, EasingFunction } from "../../Animations/easing.js";
|
|
2
|
+
import { Animation } from "../../Animations/animation.js";
|
|
3
|
+
/**
|
|
4
|
+
* Animate camera property changes with an interpolation effect
|
|
5
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors
|
|
6
|
+
*/
|
|
7
|
+
export class InterpolatingBehavior {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the name of the behavior.
|
|
10
|
+
*/
|
|
11
|
+
get name() {
|
|
12
|
+
return "Interpolating";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Initializes the behavior
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
/**
|
|
19
|
+
* The easing function to use for interpolation
|
|
20
|
+
*/
|
|
21
|
+
this.easingFunction = new CubicEase();
|
|
22
|
+
/**
|
|
23
|
+
* The easing mode (default is EASINGMODE_EASEINOUT)
|
|
24
|
+
*/
|
|
25
|
+
this.easingMode = EasingFunction.EASINGMODE_EASEINOUT;
|
|
26
|
+
/**
|
|
27
|
+
* Duration of the animation in milliseconds
|
|
28
|
+
*/
|
|
29
|
+
this.transitionDuration = 450;
|
|
30
|
+
this._attachedCamera = null;
|
|
31
|
+
this._animatables = new Map();
|
|
32
|
+
this.easingFunction.setEasingMode(this.easingMode);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the behavior
|
|
36
|
+
*/
|
|
37
|
+
init() {
|
|
38
|
+
// Nothing to do on init
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Attaches the behavior to a camera
|
|
42
|
+
* @param camera The camera to attach to
|
|
43
|
+
*/
|
|
44
|
+
attach(camera) {
|
|
45
|
+
this._attachedCamera = camera;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Detaches the behavior from the camera
|
|
49
|
+
*/
|
|
50
|
+
detach() {
|
|
51
|
+
if (!this._attachedCamera) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.stopAllAnimations();
|
|
55
|
+
this._attachedCamera = null;
|
|
56
|
+
}
|
|
57
|
+
get isInterpolating() {
|
|
58
|
+
return this._animatables.size > 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Stops and removes all animations
|
|
62
|
+
*/
|
|
63
|
+
stopAllAnimations() {
|
|
64
|
+
if (this._attachedCamera) {
|
|
65
|
+
this._animatables.forEach((animatable) => animatable.stop());
|
|
66
|
+
}
|
|
67
|
+
this._animatables.clear();
|
|
68
|
+
this._promiseResolve?.();
|
|
69
|
+
this._promiseResolve = undefined;
|
|
70
|
+
}
|
|
71
|
+
updateProperties(properties) {
|
|
72
|
+
properties.forEach((value, key) => {
|
|
73
|
+
if (value !== undefined) {
|
|
74
|
+
const animatable = this._animatables.get(String(key));
|
|
75
|
+
animatable && (animatable.target = value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async animatePropertiesAsync(properties, transitionDuration = this.transitionDuration, easingFn = this.easingFunction) {
|
|
80
|
+
const promise = new Promise((resolve) => {
|
|
81
|
+
this._promiseResolve = resolve;
|
|
82
|
+
this.stopAllAnimations();
|
|
83
|
+
if (!this._attachedCamera) {
|
|
84
|
+
this._promiseResolve = undefined;
|
|
85
|
+
return resolve();
|
|
86
|
+
}
|
|
87
|
+
const camera = this._attachedCamera;
|
|
88
|
+
const scene = camera.getScene();
|
|
89
|
+
const checkClear = (animation) => {
|
|
90
|
+
this._animatables.delete(animation);
|
|
91
|
+
if (this._animatables.size === 0) {
|
|
92
|
+
this._promiseResolve = undefined;
|
|
93
|
+
resolve();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
properties.forEach((value, key) => {
|
|
97
|
+
if (value !== undefined) {
|
|
98
|
+
const propertyName = String(key);
|
|
99
|
+
const animation = Animation.CreateAnimation(propertyName, GetAnimationType(value), 60, easingFn);
|
|
100
|
+
const animatable = Animation.TransitionTo(propertyName, value, camera, scene, 60, animation, transitionDuration, () => checkClear(propertyName));
|
|
101
|
+
if (animatable) {
|
|
102
|
+
this._animatables.set(propertyName, animatable);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return await promise;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Structural type-guards (no instanceof)
|
|
111
|
+
function IsQuaternionLike(v) {
|
|
112
|
+
return v != null && typeof v.x === "number" && typeof v.y === "number" && typeof v.z === "number" && typeof v.w === "number";
|
|
113
|
+
}
|
|
114
|
+
function IsMatrixLike(v) {
|
|
115
|
+
return v != null && (Array.isArray(v.m) || typeof v.m === "object");
|
|
116
|
+
}
|
|
117
|
+
function IsVector3Like(v) {
|
|
118
|
+
return v != null && typeof v.x === "number" && typeof v.y === "number" && typeof v.z === "number";
|
|
119
|
+
}
|
|
120
|
+
function IsVector2Like(v) {
|
|
121
|
+
return v != null && typeof v.x === "number" && typeof v.y === "number";
|
|
122
|
+
}
|
|
123
|
+
function IsColor3Like(v) {
|
|
124
|
+
return v != null && typeof v.r === "number" && typeof v.g === "number" && typeof v.b === "number";
|
|
125
|
+
}
|
|
126
|
+
function IsColor4Like(v) {
|
|
127
|
+
return v != null && typeof v.r === "number" && typeof v.g === "number" && typeof v.b === "number" && typeof v.a === "number";
|
|
128
|
+
}
|
|
129
|
+
function IsSizeLike(v) {
|
|
130
|
+
return v != null && typeof v.width === "number" && typeof v.height === "number";
|
|
131
|
+
}
|
|
132
|
+
const GetAnimationType = (value) => {
|
|
133
|
+
if (IsQuaternionLike(value)) {
|
|
134
|
+
return Animation.ANIMATIONTYPE_QUATERNION;
|
|
135
|
+
}
|
|
136
|
+
if (IsMatrixLike(value)) {
|
|
137
|
+
return Animation.ANIMATIONTYPE_MATRIX;
|
|
138
|
+
}
|
|
139
|
+
if (IsVector3Like(value)) {
|
|
140
|
+
return Animation.ANIMATIONTYPE_VECTOR3;
|
|
141
|
+
}
|
|
142
|
+
if (IsVector2Like(value)) {
|
|
143
|
+
return Animation.ANIMATIONTYPE_VECTOR2;
|
|
144
|
+
}
|
|
145
|
+
if (IsColor3Like(value)) {
|
|
146
|
+
return Animation.ANIMATIONTYPE_COLOR3;
|
|
147
|
+
}
|
|
148
|
+
if (IsColor4Like(value)) {
|
|
149
|
+
return Animation.ANIMATIONTYPE_COLOR4;
|
|
150
|
+
}
|
|
151
|
+
if (IsSizeLike(value)) {
|
|
152
|
+
return Animation.ANIMATIONTYPE_SIZE;
|
|
153
|
+
}
|
|
154
|
+
// Fallback to float for numbers and unknown shapes
|
|
155
|
+
return Animation.ANIMATIONTYPE_FLOAT;
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=interpolatingBehavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolatingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/interpolatingBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAMvD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAC9B;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAqBD;;OAEG;IACH;QAtBA;;WAEG;QACI,mBAAc,GAAmB,IAAI,SAAS,EAAE,CAAC;QAExD;;WAEG;QACI,eAAU,GAAG,cAAc,CAAC,oBAAoB,CAAC;QAExD;;WAEG;QACI,uBAAkB,GAAG,GAAG,CAAC;QAExB,oBAAe,GAAgB,IAAI,CAAC;QACpC,iBAAY,GAA4B,IAAI,GAAG,EAAsB,CAAC;QAO1E,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,IAAI;QACP,wBAAwB;IAC5B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAS;QACnB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,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,KAAK,QAAQ,CAAC;AACpF,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,KAAuB,EAAU,EAAE;IACzD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC,wBAAwB,CAAC;IAC9C,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,qBAAqB,CAAC;IAC3C,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,qBAAqB,CAAC;IAC3C,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC,kBAAkB,CAAC;IACxC,CAAC;IAED,mDAAmD;IACnD,OAAO,SAAS,CAAC,mBAAmB,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import type { Behavior } from \"../behavior\";\r\nimport { CubicEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Animatable } from \"../../Animations/animatable.core\";\r\nimport { Animation } from \"../../Animations/animation\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { IColor3Like, IColor4Like, IMatrixLike, IQuaternionLike, IVector2Like, IVector3Like } from \"../../Maths/math.like\";\r\n\r\nexport type AllowedAnimValue = number | IVector2Like | IVector3Like | IQuaternionLike | IMatrixLike | IColor3Like | IColor4Like | SizeLike | undefined;\r\n\r\n/**\r\n * Animate camera property changes with an interpolation effect\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors\r\n */\r\nexport class InterpolatingBehavior<C extends Camera = Camera> implements Behavior<C> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Interpolating\";\r\n }\r\n\r\n /**\r\n * The easing function to use for interpolation\r\n */\r\n public easingFunction: EasingFunction = new CubicEase();\r\n\r\n /**\r\n * The easing mode (default is EASINGMODE_EASEINOUT)\r\n */\r\n public easingMode = EasingFunction.EASINGMODE_EASEINOUT;\r\n\r\n /**\r\n * Duration of the animation in milliseconds\r\n */\r\n public transitionDuration = 450;\r\n\r\n private _attachedCamera: Nullable<C> = null;\r\n private _animatables: Map<string, Animatable> = new Map<string, Animatable>();\r\n private _promiseResolve?: () => void;\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n constructor() {\r\n this.easingFunction.setEasingMode(this.easingMode);\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init(): void {\r\n // Nothing to do on init\r\n }\r\n\r\n /**\r\n * Attaches the behavior to a camera\r\n * @param camera The camera to attach to\r\n */\r\n public attach(camera: C): void {\r\n this._attachedCamera = camera;\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the camera\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n this.stopAllAnimations();\r\n this._attachedCamera = null;\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return this._animatables.size > 0;\r\n }\r\n\r\n /**\r\n * Stops and removes all animations\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._animatables.forEach((animatable) => animatable.stop());\r\n }\r\n this._animatables.clear();\r\n this._promiseResolve?.();\r\n this._promiseResolve = undefined;\r\n }\r\n\r\n public updateProperties<K extends keyof C>(properties: Map<K, AllowedAnimValue>): void {\r\n properties.forEach((value, key) => {\r\n if (value !== undefined) {\r\n const animatable = this._animatables.get(String(key));\r\n animatable && (animatable.target = value as unknown as any);\r\n }\r\n });\r\n }\r\n\r\n public async animatePropertiesAsync<K extends keyof C>(\r\n properties: Map<K, AllowedAnimValue>,\r\n transitionDuration: number = this.transitionDuration,\r\n easingFn: EasingFunction = this.easingFunction\r\n ): Promise<void> {\r\n const promise = new Promise<void>((resolve) => {\r\n this._promiseResolve = resolve;\r\n this.stopAllAnimations();\r\n if (!this._attachedCamera) {\r\n this._promiseResolve = undefined;\r\n return resolve();\r\n }\r\n const camera = this._attachedCamera;\r\n const scene = camera.getScene();\r\n\r\n const checkClear = (animation: string) => {\r\n this._animatables.delete(animation);\r\n if (this._animatables.size === 0) {\r\n this._promiseResolve = undefined;\r\n resolve();\r\n }\r\n };\r\n\r\n properties.forEach((value, key) => {\r\n if (value !== undefined) {\r\n const propertyName = String(key);\r\n const animation = Animation.CreateAnimation(propertyName, GetAnimationType(value), 60, easingFn);\r\n const animatable = Animation.TransitionTo(propertyName, value, camera, scene, 60, animation, transitionDuration, () => checkClear(propertyName));\r\n if (animatable) {\r\n this._animatables.set(propertyName, animatable);\r\n }\r\n }\r\n });\r\n });\r\n return await promise;\r\n }\r\n}\r\n\r\n// Structural type-guards (no instanceof)\r\nfunction IsQuaternionLike(v: any): v is IQuaternionLike {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\" && typeof v.z === \"number\" && typeof v.w === \"number\";\r\n}\r\n\r\nfunction IsMatrixLike(v: any): v is IMatrixLike {\r\n return v != null && (Array.isArray((v as any).m) || typeof (v as any).m === \"object\");\r\n}\r\n\r\nfunction IsVector3Like(v: any): v is IVector3Like {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\" && typeof v.z === \"number\";\r\n}\r\n\r\nfunction IsVector2Like(v: any): v is IVector2Like {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\";\r\n}\r\n\r\nfunction IsColor3Like(v: any): v is IColor3Like {\r\n return v != null && typeof v.r === \"number\" && typeof v.g === \"number\" && typeof v.b === \"number\";\r\n}\r\n\r\nfunction IsColor4Like(v: any): v is IColor4Like {\r\n return v != null && typeof v.r === \"number\" && typeof v.g === \"number\" && typeof v.b === \"number\" && typeof v.a === \"number\";\r\n}\r\n\r\nexport type SizeLike = { width: number; height: number };\r\n\r\nfunction IsSizeLike(v: any): v is SizeLike {\r\n return v != null && typeof v.width === \"number\" && typeof v.height === \"number\";\r\n}\r\n\r\nconst GetAnimationType = (value: AllowedAnimValue): number => {\r\n if (IsQuaternionLike(value)) {\r\n return Animation.ANIMATIONTYPE_QUATERNION;\r\n }\r\n if (IsMatrixLike(value)) {\r\n return Animation.ANIMATIONTYPE_MATRIX;\r\n }\r\n if (IsVector3Like(value)) {\r\n return Animation.ANIMATIONTYPE_VECTOR3;\r\n }\r\n if (IsVector2Like(value)) {\r\n return Animation.ANIMATIONTYPE_VECTOR2;\r\n }\r\n if (IsColor3Like(value)) {\r\n return Animation.ANIMATIONTYPE_COLOR3;\r\n }\r\n if (IsColor4Like(value)) {\r\n return Animation.ANIMATIONTYPE_COLOR4;\r\n }\r\n if (IsSizeLike(value)) {\r\n return Animation.ANIMATIONTYPE_SIZE;\r\n }\r\n\r\n // Fallback to float for numbers and unknown shapes\r\n return Animation.ANIMATIONTYPE_FLOAT;\r\n};\r\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Nullable } from "../../types.js";
|
|
2
2
|
import type { ArcRotateCamera } from "../../Cameras/arcRotateCamera.js";
|
|
3
|
-
import {
|
|
3
|
+
import { OrbitCameraPointersInput } from "../../Cameras/Inputs/orbitCameraPointersInput.js";
|
|
4
4
|
import type { PointerTouch } from "../../Events/pointerEvents.js";
|
|
5
5
|
import type { IPointerEvent } from "../../Events/deviceInputEvents.js";
|
|
6
6
|
/**
|
|
7
7
|
* Manage the pointers inputs to control an arc rotate camera.
|
|
8
8
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
|
|
9
9
|
*/
|
|
10
|
-
export declare class ArcRotateCameraPointersInput extends
|
|
10
|
+
export declare class ArcRotateCameraPointersInput extends OrbitCameraPointersInput {
|
|
11
11
|
/**
|
|
12
12
|
* Defines the camera the input is attached to.
|
|
13
13
|
*/
|
|
@@ -53,42 +53,27 @@ export declare class ArcRotateCameraPointersInput extends BaseCameraPointersInpu
|
|
|
53
53
|
* Overrides pinchDeltaPercentage and pinchPrecision.
|
|
54
54
|
*/
|
|
55
55
|
useNaturalPinchZoom: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Defines whether zoom (2 fingers pinch) is enabled through multitouch
|
|
58
|
-
*/
|
|
59
|
-
pinchZoom: boolean;
|
|
60
56
|
/**
|
|
61
57
|
* Defines the pointer panning sensibility or how fast is the camera moving.
|
|
62
58
|
*/
|
|
63
59
|
panningSensibility: number;
|
|
64
|
-
/**
|
|
65
|
-
* Defines whether panning (2 fingers swipe) is enabled through multitouch.
|
|
66
|
-
*/
|
|
67
|
-
multiTouchPanning: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Defines whether panning is enabled for both pan (2 fingers swipe) and
|
|
70
|
-
* zoom (pinch) through multitouch.
|
|
71
|
-
*/
|
|
72
|
-
multiTouchPanAndZoom: boolean;
|
|
73
60
|
/**
|
|
74
61
|
* Revers pinch action direction.
|
|
75
62
|
*/
|
|
76
63
|
pinchInwards: boolean;
|
|
77
64
|
private _isPanClick;
|
|
78
|
-
private _twoFingerActivityCount;
|
|
79
|
-
private _isPinching;
|
|
80
65
|
/**
|
|
81
66
|
* Move camera from multi touch panning positions.
|
|
82
67
|
* @param previousMultiTouchPanPosition
|
|
83
68
|
* @param multiTouchPanPosition
|
|
84
69
|
*/
|
|
85
|
-
|
|
70
|
+
protected _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
|
|
86
71
|
/**
|
|
87
|
-
* Move camera from pinch zoom distances.
|
|
72
|
+
* Move camera from multitouch (pinch) zoom distances.
|
|
88
73
|
* @param previousPinchSquaredDistance
|
|
89
74
|
* @param pinchSquaredDistance
|
|
90
75
|
*/
|
|
91
|
-
|
|
76
|
+
protected _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void;
|
|
92
77
|
/**
|
|
93
78
|
* Called on pointer POINTERMOVE event if only a single touch is active.
|
|
94
79
|
* @param point current touch point
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "../../tslib.es6.js";
|
|
2
2
|
import { serialize } from "../../Misc/decorators.js";
|
|
3
3
|
import { CameraInputTypes } from "../../Cameras/cameraInputsManager.js";
|
|
4
|
-
import {
|
|
4
|
+
import { OrbitCameraPointersInput } from "../../Cameras/Inputs/orbitCameraPointersInput.js";
|
|
5
5
|
/**
|
|
6
6
|
* Manage the pointers inputs to control an arc rotate camera.
|
|
7
7
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
|
|
8
8
|
*/
|
|
9
|
-
export class ArcRotateCameraPointersInput extends
|
|
9
|
+
export class ArcRotateCameraPointersInput extends OrbitCameraPointersInput {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
12
|
/**
|
|
@@ -41,30 +41,15 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
|
|
|
41
41
|
* Overrides pinchDeltaPercentage and pinchPrecision.
|
|
42
42
|
*/
|
|
43
43
|
this.useNaturalPinchZoom = false;
|
|
44
|
-
/**
|
|
45
|
-
* Defines whether zoom (2 fingers pinch) is enabled through multitouch
|
|
46
|
-
*/
|
|
47
|
-
this.pinchZoom = true;
|
|
48
44
|
/**
|
|
49
45
|
* Defines the pointer panning sensibility or how fast is the camera moving.
|
|
50
46
|
*/
|
|
51
47
|
this.panningSensibility = 1000.0;
|
|
52
|
-
/**
|
|
53
|
-
* Defines whether panning (2 fingers swipe) is enabled through multitouch.
|
|
54
|
-
*/
|
|
55
|
-
this.multiTouchPanning = true;
|
|
56
|
-
/**
|
|
57
|
-
* Defines whether panning is enabled for both pan (2 fingers swipe) and
|
|
58
|
-
* zoom (pinch) through multitouch.
|
|
59
|
-
*/
|
|
60
|
-
this.multiTouchPanAndZoom = true;
|
|
61
48
|
/**
|
|
62
49
|
* Revers pinch action direction.
|
|
63
50
|
*/
|
|
64
51
|
this.pinchInwards = true;
|
|
65
52
|
this._isPanClick = false;
|
|
66
|
-
this._twoFingerActivityCount = 0;
|
|
67
|
-
this._isPinching = false;
|
|
68
53
|
}
|
|
69
54
|
/**
|
|
70
55
|
* Gets the class name of the current input.
|
|
@@ -87,7 +72,7 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
|
|
|
87
72
|
}
|
|
88
73
|
}
|
|
89
74
|
/**
|
|
90
|
-
* Move camera from pinch zoom distances.
|
|
75
|
+
* Move camera from multitouch (pinch) zoom distances.
|
|
91
76
|
* @param previousPinchSquaredDistance
|
|
92
77
|
* @param pinchSquaredDistance
|
|
93
78
|
*/
|
|
@@ -139,44 +124,9 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
|
|
|
139
124
|
* @param multiTouchPanPosition multi-touch position in current step
|
|
140
125
|
*/
|
|
141
126
|
onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// previousPinchSquaredDistance and pinchSquaredDistance to compare.
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
|
|
149
|
-
// Last time this method is called at the end of a pinch.
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
// Zoom and panning enabled together
|
|
153
|
-
if (this.multiTouchPanAndZoom) {
|
|
154
|
-
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
155
|
-
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
156
|
-
// Zoom and panning enabled but only one at a time
|
|
157
|
-
}
|
|
158
|
-
else if (this.multiTouchPanning && this.pinchZoom) {
|
|
159
|
-
this._twoFingerActivityCount++;
|
|
160
|
-
if (this._isPinching ||
|
|
161
|
-
(this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.pinchToPanMaxDistance)) {
|
|
162
|
-
// Since pinch has not been active long, assume we intend to zoom.
|
|
163
|
-
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
164
|
-
// Since we are pinching, remain pinching on next iteration.
|
|
165
|
-
this._isPinching = true;
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
// Pause between pinch starting and moving implies not a zoom event. Pan instead.
|
|
169
|
-
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
170
|
-
}
|
|
171
|
-
// Panning enabled, zoom disabled
|
|
172
|
-
}
|
|
173
|
-
else if (this.multiTouchPanning) {
|
|
174
|
-
this._computeMultiTouchPanning(previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
175
|
-
// Zoom enabled, panning disabled
|
|
176
|
-
}
|
|
177
|
-
else if (this.pinchZoom) {
|
|
178
|
-
this._computePinchZoom(previousPinchSquaredDistance, pinchSquaredDistance);
|
|
179
|
-
}
|
|
127
|
+
this._shouldStartPinchZoom =
|
|
128
|
+
this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.pinchToPanMaxDistance;
|
|
129
|
+
super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
|
|
180
130
|
}
|
|
181
131
|
/**
|
|
182
132
|
* Called each time a new POINTERDOWN event occurs. Ie, for each button
|
|
@@ -185,6 +135,7 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
|
|
|
185
135
|
*/
|
|
186
136
|
onButtonDown(evt) {
|
|
187
137
|
this._isPanClick = evt.button === this.camera._panningMouseButton;
|
|
138
|
+
super.onButtonDown(evt);
|
|
188
139
|
}
|
|
189
140
|
/**
|
|
190
141
|
* Called each time a new POINTERUP event occurs. Ie, for each button
|
|
@@ -192,16 +143,14 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
|
|
|
192
143
|
* @param _evt Defines the event to track
|
|
193
144
|
*/
|
|
194
145
|
onButtonUp(_evt) {
|
|
195
|
-
|
|
196
|
-
this._isPinching = false;
|
|
146
|
+
super.onButtonUp(_evt);
|
|
197
147
|
}
|
|
198
148
|
/**
|
|
199
149
|
* Called when window becomes inactive.
|
|
200
150
|
*/
|
|
201
151
|
onLostFocus() {
|
|
202
152
|
this._isPanClick = false;
|
|
203
|
-
|
|
204
|
-
this._isPinching = false;
|
|
153
|
+
super.onLostFocus();
|
|
205
154
|
}
|
|
206
155
|
}
|
|
207
156
|
/**
|
|
@@ -226,17 +175,8 @@ __decorate([
|
|
|
226
175
|
__decorate([
|
|
227
176
|
serialize()
|
|
228
177
|
], ArcRotateCameraPointersInput.prototype, "useNaturalPinchZoom", void 0);
|
|
229
|
-
__decorate([
|
|
230
|
-
serialize()
|
|
231
|
-
], ArcRotateCameraPointersInput.prototype, "pinchZoom", void 0);
|
|
232
178
|
__decorate([
|
|
233
179
|
serialize()
|
|
234
180
|
], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
|
|
235
|
-
__decorate([
|
|
236
|
-
serialize()
|
|
237
|
-
], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
|
|
238
|
-
__decorate([
|
|
239
|
-
serialize()
|
|
240
|
-
], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
|
|
241
181
|
CameraInputTypes["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
|
|
242
182
|
//# sourceMappingURL=arcRotateCameraPointersInput.js.map
|