@babylonjs/core 6.36.1 → 6.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/Behaviors/Cameras/bouncingBehavior.js +8 -6
- package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
- package/Behaviors/Cameras/framingBehavior.js +3 -3
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraGamepadInput.js +4 -0
- package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
- package/Cameras/arcRotateCamera.d.ts +9 -8
- package/Cameras/arcRotateCamera.js +5 -5
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Engines/Extensions/engine.dynamicTexture.d.ts +2 -2
- package/Engines/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +28 -3
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -0
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +6 -2
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.d.ts +1 -0
- package/Engines/WebGPU/webgpuCacheBindGroups.js +12 -0
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.d.ts +2 -2
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js +5 -2
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +3 -0
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.js +2 -1
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +23 -5
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.js +4 -5
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js +10 -4
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +8 -53
- package/Engines/WebGPU/webgpuTextureHelper.js +4 -996
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +56 -0
- package/Engines/WebGPU/webgpuTextureManager.js +1012 -0
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -0
- package/Engines/engine.d.ts +1 -0
- package/Engines/engine.js +9 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +1 -0
- package/Engines/renderTargetWrapper.js +5 -1
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -0
- package/Engines/thinEngine.js +11 -7
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +9 -2
- package/Engines/webgpuEngine.js +75 -3
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +23 -6
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +14 -3
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +14 -3
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +12 -11
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +21 -6
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +15 -9
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +13 -5
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +9 -5
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +24 -6
- package/FlowGraph/flowGraph.js +12 -12
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.d.ts +31 -2
- package/FlowGraph/flowGraphBlock.js +8 -3
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +5 -1
- package/FlowGraph/flowGraphContext.js +4 -2
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +22 -2
- package/FlowGraph/flowGraphCoordinator.js +7 -11
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/{flowGraphWithOnDoneExecutionBlock.js → flowGraphExecutionBlockWithOutSignal.js} +1 -1
- package/FlowGraph/flowGraphExecutionBlockWithOutSignal.js.map +1 -0
- package/FlowGraph/flowGraphPathConverter.d.ts +13 -0
- package/FlowGraph/flowGraphPathConverter.js +31 -0
- package/FlowGraph/flowGraphPathConverter.js.map +1 -0
- package/FlowGraph/flowGraphPathConverterComponent.d.ts +19 -0
- package/FlowGraph/flowGraphPathConverterComponent.js +31 -0
- package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -0
- package/FlowGraph/index.d.ts +0 -1
- package/FlowGraph/index.js +0 -1
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/serialization.d.ts +8 -0
- package/FlowGraph/serialization.js +12 -4
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +86 -1
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/Materials/Textures/dynamicTexture.js +2 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/hardwareTextureWrapper.d.ts +1 -1
- package/Materials/Textures/hardwareTextureWrapper.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +6 -2
- package/Materials/Textures/internalTexture.js +6 -4
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +10 -10
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/material.d.ts +1 -1
- package/Materials/material.js +3 -1
- package/Materials/material.js.map +1 -1
- package/Materials/shaderMaterial.js +2 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +2 -0
- package/Materials/uniformBuffer.js +16 -0
- package/Materials/uniformBuffer.js.map +1 -1
- package/Meshes/Builders/groundBuilder.d.ts +57 -91
- package/Meshes/Builders/groundBuilder.js +57 -91
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/WebGPU/webgpuDataBuffer.d.ts +1 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js +2 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
- package/Meshes/geometry.js +3 -3
- package/Meshes/geometry.js.map +1 -1
- package/Misc/brdfTextureTools.js +9 -7
- package/Misc/brdfTextureTools.js.map +1 -1
- package/Misc/rgbdTextureTools.js +37 -37
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/ObjectModel/index.d.ts +1 -0
- package/ObjectModel/index.js +2 -0
- package/ObjectModel/index.js.map +1 -0
- package/ObjectModel/objectModelInterfaces.d.ts +21 -0
- package/ObjectModel/objectModelInterfaces.js +2 -0
- package/ObjectModel/objectModelInterfaces.js.map +1 -0
- package/Particles/computeShaderParticleSystem.js +2 -2
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js +2 -5
- package/Particles/particleSystem.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +1 -6
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/renderingManager.js +1 -1
- package/Rendering/renderingManager.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +9 -1
- package/XR/features/WebXRControllerTeleportation.js +10 -0
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/webXRCamera.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +5 -1
- package/types.js +0 -2
- package/types.js.map +1 -1
- package/FlowGraph/flowGraphPath.d.ts +0 -45
- package/FlowGraph/flowGraphPath.js +0 -156
- package/FlowGraph/flowGraphPath.js.map +0 -1
- package/FlowGraph/flowGraphPathComponent.d.ts +0 -42
- package/FlowGraph/flowGraphPathComponent.js +0 -51
- package/FlowGraph/flowGraphPathComponent.js.map +0 -1
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +0 -1
- /package/FlowGraph/{flowGraphWithOnDoneExecutionBlock.d.ts → flowGraphExecutionBlockWithOutSignal.d.ts} +0 -0
|
@@ -50,14 +50,16 @@ export class BouncingBehavior {
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
if (value) {
|
|
53
|
-
this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((
|
|
54
|
-
if (!
|
|
53
|
+
this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((transformNode) => {
|
|
54
|
+
if (!transformNode) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
transformNode.computeWorldMatrix(true);
|
|
58
|
+
if (transformNode.getBoundingInfo) {
|
|
59
|
+
const diagonal = transformNode.getBoundingInfo().diagonalLength;
|
|
60
|
+
this.lowerRadiusTransitionRange = diagonal * 0.05;
|
|
61
|
+
this.upperRadiusTransitionRange = diagonal * 0.05;
|
|
62
|
+
}
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
else if (this._onMeshTargetChangedObserver) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bouncingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/bouncingBehavior.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAKnE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QAkBI;;WAEG;QACI,uBAAkB,GAAG,GAAG,CAAC;QAEhC;;WAEG;QACI,+BAA0B,GAAG,CAAC,CAAC;QAEtC;;WAEG;QACI,+BAA0B,GAAG,CAAC,CAAC,CAAC;QAE/B,yBAAoB,GAAG,KAAK,CAAC;QA6FrC,aAAa;QACL,uBAAkB,GAAY,KAAK,CAAC;QACpC,4BAAuB,GAAwB,IAAI,CAAC;QACpD,iBAAY,GAAG,IAAI,KAAK,EAAc,CAAC;IAgFnD,CAAC;IAhNG;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,UAAU,CAAC;IACtB,CAAC;IA6BD;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,IAAW,mBAAmB,CAAC,KAAc;QACzC,IAAI,IAAI,CAAC,oBAAoB,KAAK,KAAK,EAAE;YACrC,OAAO;SACV;QAED,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAElC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QAED,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,4BAA4B,GAAG,MAAM,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAClF,IAAI,CAAC,IAAI,EAAE;oBACP,OAAO;iBACV;gBAED,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBAC9B,MAAM,QAAQ,GAAG,IAAI,CAA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EAC/B,EAAE,EACF,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CAAC,kBAAkB,EACvB,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,CACpC,CAAC;QAEF,IAAI,UAAU,EAAE;YACZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACtC;IACL,CAAC;IAED;;OAEG;IACO,oBAAoB;QAC1B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAEhC,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,eAAe,CAAC,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC;SACpE;IACL,CAAC;IAED;;OAEG;IACI,iBAAiB;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAC7B,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3C,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;SAC7B;IACL,CAAC;;AAxMD;;GAEG;AACW,+BAAc,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,AAApB,CAAqB;AAEjD;;GAEG;AACW,2BAAU,GAAG,cAAc,CAAC,kBAAkB,AAApC,CAAqC","sourcesContent":["import type { Behavior } from \"../../Behaviors/behavior\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport { BackEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Animatable } from \"../../Animations/animatable\";\r\nimport { Animation } from \"../../Animations/animation\";\r\n\r\n/**\r\n * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors#bouncing-behavior\r\n */\r\nexport class BouncingBehavior implements Behavior<ArcRotateCamera> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Bouncing\";\r\n }\r\n\r\n /**\r\n * The easing function used by animations\r\n */\r\n public static EasingFunction = new BackEase(0.3);\r\n\r\n /**\r\n * The easing mode used by animations\r\n */\r\n public static EasingMode = EasingFunction.EASINGMODE_EASEOUT;\r\n\r\n /**\r\n * The duration of the animation, in milliseconds\r\n */\r\n public transitionDuration = 450;\r\n\r\n /**\r\n * Length of the distance animated by the transition when lower radius is reached\r\n */\r\n public lowerRadiusTransitionRange = 2;\r\n\r\n /**\r\n * Length of the distance animated by the transition when upper radius is reached\r\n */\r\n public upperRadiusTransitionRange = -2;\r\n\r\n private _autoTransitionRange = false;\r\n\r\n /**\r\n * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically\r\n */\r\n public get autoTransitionRange(): boolean {\r\n return this._autoTransitionRange;\r\n }\r\n\r\n /**\r\n * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically\r\n * Transition ranges will be set to 5% of the bounding box diagonal in world space\r\n */\r\n public set autoTransitionRange(value: boolean) {\r\n if (this._autoTransitionRange === value) {\r\n return;\r\n }\r\n\r\n this._autoTransitionRange = value;\r\n\r\n const camera = this._attachedCamera;\r\n if (!camera) {\r\n return;\r\n }\r\n\r\n if (value) {\r\n this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((mesh) => {\r\n if (!mesh) {\r\n return;\r\n }\r\n\r\n mesh.computeWorldMatrix(true);\r\n const diagonal = mesh.getBoundingInfo().diagonalLength;\r\n\r\n this.lowerRadiusTransitionRange = diagonal * 0.05;\r\n this.upperRadiusTransitionRange = diagonal * 0.05;\r\n });\r\n } else if (this._onMeshTargetChangedObserver) {\r\n camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);\r\n }\r\n }\r\n\r\n // Connection\r\n private _attachedCamera: Nullable<ArcRotateCamera>;\r\n private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;\r\n private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;\r\n\r\n /**\r\n * Initializes the behavior.\r\n */\r\n public init(): void {\r\n // Do nothing\r\n }\r\n\r\n /**\r\n * Attaches the behavior to its arc rotate camera.\r\n * @param camera Defines the camera to attach the behavior to\r\n */\r\n public attach(camera: ArcRotateCamera): void {\r\n this._attachedCamera = camera;\r\n this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n // Add the bounce animation to the lower radius limit\r\n if (this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)) {\r\n this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange);\r\n }\r\n\r\n // Add the bounce animation to the upper radius limit\r\n if (this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)) {\r\n this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Detaches the behavior from its current arc rotate camera.\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n if (this._onAfterCheckInputsObserver) {\r\n this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);\r\n }\r\n if (this._onMeshTargetChangedObserver) {\r\n this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);\r\n }\r\n this._attachedCamera = null;\r\n }\r\n\r\n // Animations\r\n private _radiusIsAnimating: boolean = false;\r\n private _radiusBounceTransition: Nullable<Animation> = null;\r\n private _animatables = new Array<Animatable>();\r\n private _cachedWheelPrecision: number;\r\n\r\n /**\r\n * Checks if the camera radius is at the specified limit. Takes into account animation locks.\r\n * @param radiusLimit The limit to check against.\r\n * @returns Bool to indicate if at limit.\r\n */\r\n private _isRadiusAtLimit(radiusLimit: Nullable<number>): boolean {\r\n if (!this._attachedCamera) {\r\n return false;\r\n }\r\n\r\n if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Applies an animation to the radius of the camera, extending by the radiusDelta.\r\n * @param radiusDelta The delta by which to animate to. Can be negative.\r\n */\r\n private _applyBoundRadiusAnimation(radiusDelta: number): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n if (!this._radiusBounceTransition) {\r\n BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);\r\n this._radiusBounceTransition = Animation.CreateAnimation(\"radius\", Animation.ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);\r\n }\r\n // Prevent zoom until bounce has completed\r\n this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;\r\n this._attachedCamera.wheelPrecision = Infinity;\r\n this._attachedCamera.inertialRadiusOffset = 0;\r\n\r\n // Animate to the radius limit\r\n this.stopAllAnimations();\r\n this._radiusIsAnimating = true;\r\n const animatable = Animation.TransitionTo(\r\n \"radius\",\r\n this._attachedCamera.radius + radiusDelta,\r\n this._attachedCamera,\r\n this._attachedCamera.getScene(),\r\n 60,\r\n this._radiusBounceTransition,\r\n this.transitionDuration,\r\n () => this._clearAnimationLocks()\r\n );\r\n\r\n if (animatable) {\r\n this._animatables.push(animatable);\r\n }\r\n }\r\n\r\n /**\r\n * Removes all animation locks. Allows new animations to be added to any of the camera properties.\r\n */\r\n protected _clearAnimationLocks(): void {\r\n this._radiusIsAnimating = false;\r\n\r\n if (this._attachedCamera) {\r\n this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;\r\n }\r\n }\r\n\r\n /**\r\n * Stops and removes all animations that have been applied to the camera\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._attachedCamera.animations = [];\r\n }\r\n while (this._animatables.length) {\r\n this._animatables[0].onAnimationEnd = null;\r\n this._animatables[0].stop();\r\n this._animatables.shift();\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"bouncingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/bouncingBehavior.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAMnE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QAkBI;;WAEG;QACI,uBAAkB,GAAG,GAAG,CAAC;QAEhC;;WAEG;QACI,+BAA0B,GAAG,CAAC,CAAC;QAEtC;;WAEG;QACI,+BAA0B,GAAG,CAAC,CAAC,CAAC;QAE/B,yBAAoB,GAAG,KAAK,CAAC;QA+FrC,aAAa;QACL,uBAAkB,GAAY,KAAK,CAAC;QACpC,4BAAuB,GAAwB,IAAI,CAAC;QACpD,iBAAY,GAAG,IAAI,KAAK,EAAc,CAAC;IAgFnD,CAAC;IAlNG;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,UAAU,CAAC;IACtB,CAAC;IA6BD;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,IAAW,mBAAmB,CAAC,KAAc;QACzC,IAAI,IAAI,CAAC,oBAAoB,KAAK,KAAK,EAAE;YACrC,OAAO;SACV;QAED,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAElC,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QAED,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,4BAA4B,GAAG,MAAM,CAAC,6BAA6B,CAAC,GAAG,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import type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport { BackEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Animatable } from \"../../Animations/animatable\";\r\nimport { Animation } from \"../../Animations/animation\";\r\n\r\n/**\r\n * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors#bouncing-behavior\r\n */\r\nexport class BouncingBehavior implements Behavior<ArcRotateCamera> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Bouncing\";\r\n }\r\n\r\n /**\r\n * The easing function used by animations\r\n */\r\n public static EasingFunction = new BackEase(0.3);\r\n\r\n /**\r\n * The easing mode used by animations\r\n */\r\n public static EasingMode = EasingFunction.EASINGMODE_EASEOUT;\r\n\r\n /**\r\n * The duration of the animation, in milliseconds\r\n */\r\n public transitionDuration = 450;\r\n\r\n /**\r\n * Length of the distance animated by the transition when lower radius is reached\r\n */\r\n public lowerRadiusTransitionRange = 2;\r\n\r\n /**\r\n * Length of the distance animated by the transition when upper radius is reached\r\n */\r\n public upperRadiusTransitionRange = -2;\r\n\r\n private _autoTransitionRange = false;\r\n\r\n /**\r\n * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically\r\n */\r\n public get autoTransitionRange(): boolean {\r\n return this._autoTransitionRange;\r\n }\r\n\r\n /**\r\n * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically\r\n * Transition ranges will be set to 5% of the bounding box diagonal in world space\r\n */\r\n public set autoTransitionRange(value: boolean) {\r\n if (this._autoTransitionRange === value) {\r\n return;\r\n }\r\n\r\n this._autoTransitionRange = value;\r\n\r\n const camera = this._attachedCamera;\r\n if (!camera) {\r\n return;\r\n }\r\n\r\n if (value) {\r\n this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((transformNode) => {\r\n if (!transformNode) {\r\n return;\r\n }\r\n\r\n transformNode.computeWorldMatrix(true);\r\n if ((transformNode as AbstractMesh).getBoundingInfo) {\r\n const diagonal = (transformNode as AbstractMesh).getBoundingInfo().diagonalLength;\r\n\r\n this.lowerRadiusTransitionRange = diagonal * 0.05;\r\n this.upperRadiusTransitionRange = diagonal * 0.05;\r\n }\r\n });\r\n } else if (this._onMeshTargetChangedObserver) {\r\n camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);\r\n }\r\n }\r\n\r\n // Connection\r\n private _attachedCamera: Nullable<ArcRotateCamera>;\r\n private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;\r\n private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<TransformNode>>>;\r\n\r\n /**\r\n * Initializes the behavior.\r\n */\r\n public init(): void {\r\n // Do nothing\r\n }\r\n\r\n /**\r\n * Attaches the behavior to its arc rotate camera.\r\n * @param camera Defines the camera to attach the behavior to\r\n */\r\n public attach(camera: ArcRotateCamera): void {\r\n this._attachedCamera = camera;\r\n this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n // Add the bounce animation to the lower radius limit\r\n if (this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)) {\r\n this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange);\r\n }\r\n\r\n // Add the bounce animation to the upper radius limit\r\n if (this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)) {\r\n this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Detaches the behavior from its current arc rotate camera.\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n if (this._onAfterCheckInputsObserver) {\r\n this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);\r\n }\r\n if (this._onMeshTargetChangedObserver) {\r\n this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);\r\n }\r\n this._attachedCamera = null;\r\n }\r\n\r\n // Animations\r\n private _radiusIsAnimating: boolean = false;\r\n private _radiusBounceTransition: Nullable<Animation> = null;\r\n private _animatables = new Array<Animatable>();\r\n private _cachedWheelPrecision: number;\r\n\r\n /**\r\n * Checks if the camera radius is at the specified limit. Takes into account animation locks.\r\n * @param radiusLimit The limit to check against.\r\n * @returns Bool to indicate if at limit.\r\n */\r\n private _isRadiusAtLimit(radiusLimit: Nullable<number>): boolean {\r\n if (!this._attachedCamera) {\r\n return false;\r\n }\r\n\r\n if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Applies an animation to the radius of the camera, extending by the radiusDelta.\r\n * @param radiusDelta The delta by which to animate to. Can be negative.\r\n */\r\n private _applyBoundRadiusAnimation(radiusDelta: number): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n if (!this._radiusBounceTransition) {\r\n BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);\r\n this._radiusBounceTransition = Animation.CreateAnimation(\"radius\", Animation.ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);\r\n }\r\n // Prevent zoom until bounce has completed\r\n this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;\r\n this._attachedCamera.wheelPrecision = Infinity;\r\n this._attachedCamera.inertialRadiusOffset = 0;\r\n\r\n // Animate to the radius limit\r\n this.stopAllAnimations();\r\n this._radiusIsAnimating = true;\r\n const animatable = Animation.TransitionTo(\r\n \"radius\",\r\n this._attachedCamera.radius + radiusDelta,\r\n this._attachedCamera,\r\n this._attachedCamera.getScene(),\r\n 60,\r\n this._radiusBounceTransition,\r\n this.transitionDuration,\r\n () => this._clearAnimationLocks()\r\n );\r\n\r\n if (animatable) {\r\n this._animatables.push(animatable);\r\n }\r\n }\r\n\r\n /**\r\n * Removes all animation locks. Allows new animations to be added to any of the camera properties.\r\n */\r\n protected _clearAnimationLocks(): void {\r\n this._radiusIsAnimating = false;\r\n\r\n if (this._attachedCamera) {\r\n this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;\r\n }\r\n }\r\n\r\n /**\r\n * Stops and removes all animations that have been applied to the camera\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._attachedCamera.animations = [];\r\n }\r\n while (this._animatables.length) {\r\n this._animatables[0].onAnimationEnd = null;\r\n this._animatables[0].stop();\r\n this._animatables.shift();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -162,9 +162,9 @@ export class FramingBehavior {
|
|
|
162
162
|
this._isPointerDown = false;
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
|
-
this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((
|
|
166
|
-
if (
|
|
167
|
-
this.zoomOnMesh(
|
|
165
|
+
this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((transformNode) => {
|
|
166
|
+
if (transformNode && transformNode.getBoundingInfo) {
|
|
167
|
+
this.zoomOnMesh(transformNode, undefined, () => {
|
|
168
168
|
this.onTargetFramingAnimationEndObservable.notifyObservers();
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/framingBehavior.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,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aAC/B;YACD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;SAC7B;IACL,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACvB,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,CACH,IAAI,CAAC,eAAe,CAAC,mBAAmB,KAAK,CAAC;YAC9C,IAAI,CAAC,eAAe,CAAC,kBAAkB,KAAK,CAAC;YAC7C,IAAI,CAAC,eAAe,CAAC,oBAAoB,KAAK,CAAC;YAC/C,IAAI,CAAC,eAAe,CAAC,gBAAgB,KAAK,CAAC;YAC3C,IAAI,CAAC,eAAe,CAAC,gBAAgB,KAAK,CAAC;YAC3C,IAAI,CAAC,cAAc,CACtB,CAAC;IACN,CAAC;;AAtdD;;GAEG;AACW,8BAAc,GAAG,IAAI,eAAe,EAAE,AAAxB,CAAyB;AAErD;;GAEG;AACW,0BAAU,GAAG,cAAc,CAAC,oBAAoB,AAAtC,CAAuC;AAgd/D,UAAU;AAEV;;GAEG;AACW,oCAAoB,GAAG,CAAC,AAAJ,CAAK;AAEvC;;GAEG;AACW,mCAAmB,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Behavior } from \"../../Behaviors/behavior\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport { ExponentialEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { PointerInfoPre } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { PrecisionDate } from \"../../Misc/precisionDate\";\r\n\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Animatable } from \"../../Animations/animatable\";\r\nimport { Animation } from \"../../Animations/animation\";\r\n\r\n/**\r\n * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors#framing-behavior\r\n */\r\nexport class FramingBehavior implements Behavior<ArcRotateCamera> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Framing\";\r\n }\r\n\r\n /**\r\n * An event triggered when the animation to zoom on target mesh has ended\r\n */\r\n public onTargetFramingAnimationEndObservable = new Observable<void>();\r\n\r\n private _mode = FramingBehavior.FitFrustumSidesMode;\r\n private _radiusScale = 1.0;\r\n private _positionScale = 0.5;\r\n private _defaultElevation = 0.3;\r\n private _elevationReturnTime = 1500;\r\n private _elevationReturnWaitTime = 1000;\r\n private _zoomStopsAnimation = false;\r\n private _framingTime = 1500;\r\n\r\n /**\r\n * The easing function used by animations\r\n */\r\n public static EasingFunction = new ExponentialEase();\r\n\r\n /**\r\n * The easing mode used by animations\r\n */\r\n public static EasingMode = EasingFunction.EASINGMODE_EASEINOUT;\r\n\r\n /**\r\n * Sets the current mode used by the behavior\r\n */\r\n public set mode(mode: number) {\r\n this._mode = mode;\r\n }\r\n\r\n /**\r\n * Gets current mode used by the behavior.\r\n */\r\n public get mode(): number {\r\n return this._mode;\r\n }\r\n\r\n /**\r\n * Sets the scale applied to the radius (1 by default)\r\n */\r\n public set radiusScale(radius: number) {\r\n this._radiusScale = radius;\r\n }\r\n\r\n /**\r\n * Gets the scale applied to the radius\r\n */\r\n public get radiusScale(): number {\r\n return this._radiusScale;\r\n }\r\n\r\n /**\r\n * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.\r\n */\r\n public set positionScale(scale: number) {\r\n this._positionScale = scale;\r\n }\r\n\r\n /**\r\n * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.\r\n */\r\n public get positionScale(): number {\r\n return this._positionScale;\r\n }\r\n\r\n /**\r\n * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle\r\n * behaviour is triggered, in radians.\r\n */\r\n public set defaultElevation(elevation: number) {\r\n this._defaultElevation = elevation;\r\n }\r\n\r\n /**\r\n * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle\r\n * behaviour is triggered, in radians.\r\n */\r\n public get defaultElevation() {\r\n return this._defaultElevation;\r\n }\r\n\r\n /**\r\n * Sets the time (in milliseconds) taken to return to the default beta position.\r\n * Negative value indicates camera should not return to default.\r\n */\r\n public set elevationReturnTime(speed: number) {\r\n this._elevationReturnTime = speed;\r\n }\r\n\r\n /**\r\n * Gets the time (in milliseconds) taken to return to the default beta position.\r\n * Negative value indicates camera should not return to default.\r\n */\r\n public get elevationReturnTime(): number {\r\n return this._elevationReturnTime;\r\n }\r\n\r\n /**\r\n * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.\r\n */\r\n public set elevationReturnWaitTime(time: number) {\r\n this._elevationReturnWaitTime = time;\r\n }\r\n\r\n /**\r\n * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.\r\n */\r\n public get elevationReturnWaitTime(): number {\r\n return this._elevationReturnWaitTime;\r\n }\r\n\r\n /**\r\n * Sets the flag that indicates if user zooming should stop animation.\r\n */\r\n public set zoomStopsAnimation(flag: boolean) {\r\n this._zoomStopsAnimation = flag;\r\n }\r\n\r\n /**\r\n * Gets the flag that indicates if user zooming should stop animation.\r\n */\r\n public get zoomStopsAnimation(): boolean {\r\n return this._zoomStopsAnimation;\r\n }\r\n\r\n /**\r\n * Sets the transition time when framing the mesh, in milliseconds\r\n */\r\n public set framingTime(time: number) {\r\n this._framingTime = time;\r\n }\r\n\r\n /**\r\n * Gets the transition time when framing the mesh, in milliseconds\r\n */\r\n public get framingTime() {\r\n return this._framingTime;\r\n }\r\n\r\n /**\r\n * Define if the behavior should automatically change the configured\r\n * camera limits and sensibilities.\r\n */\r\n public autoCorrectCameraLimitsAndSensibility = true;\r\n\r\n // Default behavior functions\r\n private _onPrePointerObservableObserver: Nullable<Observer<PointerInfoPre>>;\r\n private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;\r\n private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;\r\n private _attachedCamera: Nullable<ArcRotateCamera>;\r\n private _isPointerDown = false;\r\n private _lastInteractionTime = -Infinity;\r\n\r\n /**\r\n * Initializes the behavior.\r\n */\r\n public init(): void {\r\n // Do nothing\r\n }\r\n\r\n /**\r\n * Attaches the behavior to its arc rotate camera.\r\n * @param camera Defines the camera to attach the behavior to\r\n */\r\n public attach(camera: ArcRotateCamera): void {\r\n this._attachedCamera = camera;\r\n const scene = this._attachedCamera.getScene();\r\n\r\n FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);\r\n\r\n this._onPrePointerObservableObserver = scene.onPrePointerObservable.add((pointerInfoPre) => {\r\n if (pointerInfoPre.type === PointerEventTypes.POINTERDOWN) {\r\n this._isPointerDown = true;\r\n return;\r\n }\r\n\r\n if (pointerInfoPre.type === PointerEventTypes.POINTERUP) {\r\n this._isPointerDown = false;\r\n }\r\n });\r\n\r\n this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((mesh) => {\r\n if (mesh) {\r\n this.zoomOnMesh(mesh, undefined, () => {\r\n this.onTargetFramingAnimationEndObservable.notifyObservers();\r\n });\r\n }\r\n });\r\n\r\n this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {\r\n // Stop the animation if there is user interaction and the animation should stop for this interaction\r\n this._applyUserInteraction();\r\n\r\n // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it\r\n // back to the default position after a given timeout\r\n this._maintainCameraAboveGround();\r\n });\r\n }\r\n\r\n /**\r\n * Detaches the behavior from its current arc rotate camera.\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n const scene = this._attachedCamera.getScene();\r\n\r\n if (this._onPrePointerObservableObserver) {\r\n scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);\r\n }\r\n\r\n if (this._onAfterCheckInputsObserver) {\r\n this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);\r\n }\r\n\r\n if (this._onMeshTargetChangedObserver) {\r\n this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);\r\n }\r\n\r\n this._attachedCamera = null;\r\n }\r\n\r\n // Framing control\r\n private _animatables = new Array<Animatable>();\r\n private _betaIsAnimating = false;\r\n private _betaTransition: Animation;\r\n private _radiusTransition: Animation;\r\n private _vectorTransition: Animation;\r\n\r\n /**\r\n * Targets the given mesh and updates zoom level accordingly.\r\n * @param mesh The mesh to target.\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n */\r\n public zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {\r\n mesh.computeWorldMatrix(true);\r\n\r\n const boundingBox = mesh.getBoundingInfo().boundingBox;\r\n this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);\r\n }\r\n\r\n /**\r\n * Targets the given mesh with its children and updates zoom level accordingly.\r\n * @param mesh The mesh to target.\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n */\r\n public zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {\r\n mesh.computeWorldMatrix(true);\r\n\r\n const boundingBox = mesh.getHierarchyBoundingVectors(true);\r\n this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);\r\n }\r\n\r\n /**\r\n * Targets the given meshes with their children and updates zoom level accordingly.\r\n * @param meshes The mesh to target.\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n */\r\n public zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {\r\n const min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const boundingInfo = meshes[i].getHierarchyBoundingVectors(true);\r\n Vector3.CheckExtends(boundingInfo.min, min, max);\r\n Vector3.CheckExtends(boundingInfo.max, min, max);\r\n }\r\n\r\n this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);\r\n }\r\n\r\n /**\r\n * Targets the bounding box info defined by its extends and updates zoom level accordingly.\r\n * @param minimumWorld Determines the smaller position of the bounding box extend\r\n * @param maximumWorld Determines the bigger position of the bounding box extend\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n * @returns true if the zoom was done\r\n */\r\n public zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): boolean {\r\n let zoomTarget: Vector3;\r\n\r\n if (!this._attachedCamera) {\r\n return false;\r\n }\r\n\r\n // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY\r\n const bottom = minimumWorld.y;\r\n const top = maximumWorld.y;\r\n const zoomTargetY = bottom + (top - bottom) * this._positionScale;\r\n const radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);\r\n\r\n if (focusOnOriginXZ) {\r\n zoomTarget = new Vector3(0, zoomTargetY, 0);\r\n } else {\r\n const centerWorld = minimumWorld.add(radiusWorld);\r\n zoomTarget = new Vector3(centerWorld.x, zoomTargetY, centerWorld.z);\r\n }\r\n\r\n if (!this._vectorTransition) {\r\n this._vectorTransition = Animation.CreateAnimation(\"target\", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);\r\n }\r\n\r\n this._betaIsAnimating = true;\r\n let animatable = Animation.TransitionTo(\"target\", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);\r\n if (animatable) {\r\n this._animatables.push(animatable);\r\n }\r\n\r\n // sets the radius and lower radius bounds\r\n // Small delta ensures camera is not always at lower zoom limit.\r\n let radius = 0;\r\n if (this._mode === FramingBehavior.FitFrustumSidesMode) {\r\n const position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);\r\n if (this.autoCorrectCameraLimitsAndSensibility) {\r\n this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;\r\n }\r\n radius = position;\r\n } else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {\r\n radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);\r\n if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {\r\n this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;\r\n }\r\n }\r\n\r\n // Set sensibilities\r\n if (this.autoCorrectCameraLimitsAndSensibility) {\r\n const extend = maximumWorld.subtract(minimumWorld).length();\r\n this._attachedCamera.panningSensibility = 5000 / extend;\r\n this._attachedCamera.wheelPrecision = 100 / radius;\r\n }\r\n\r\n // transition to new radius\r\n if (!this._radiusTransition) {\r\n this._radiusTransition = Animation.CreateAnimation(\"radius\", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);\r\n }\r\n\r\n animatable = Animation.TransitionTo(\"radius\", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, () => {\r\n this.stopAllAnimations();\r\n if (onAnimationEnd) {\r\n onAnimationEnd();\r\n }\r\n\r\n if (this._attachedCamera && this._attachedCamera.useInputToRestoreState) {\r\n this._attachedCamera.storeState();\r\n }\r\n });\r\n\r\n if (animatable) {\r\n this._animatables.push(animatable);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Calculates the lowest radius for the camera based on the bounding box of the mesh.\r\n * @param minimumWorld\r\n * @param maximumWorld\r\n * @returns The minimum distance from the primary mesh's center point at which the camera must be kept in order\r\n *\t\t to fully enclose the mesh in the viewing frustum.\r\n */\r\n protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number {\r\n const camera = this._attachedCamera;\r\n\r\n if (!camera) {\r\n return 0;\r\n }\r\n\r\n let distance = camera._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld, this._radiusScale);\r\n if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {\r\n // Don't exceed the requested limit\r\n distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;\r\n }\r\n\r\n // Don't exceed the upper radius limit\r\n if (camera.upperRadiusLimit) {\r\n distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;\r\n }\r\n\r\n return distance;\r\n }\r\n\r\n /**\r\n * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera\r\n * is automatically returned to its default position (expected to be above ground plane).\r\n */\r\n private _maintainCameraAboveGround(): void {\r\n if (this._elevationReturnTime < 0) {\r\n return;\r\n }\r\n\r\n const timeSinceInteraction = PrecisionDate.Now - this._lastInteractionTime;\r\n const defaultBeta = Math.PI * 0.5 - this._defaultElevation;\r\n const limitBeta = Math.PI * 0.5;\r\n\r\n // Bring the camera back up if below the ground plane\r\n if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {\r\n this._betaIsAnimating = true;\r\n\r\n //Transition to new position\r\n this.stopAllAnimations();\r\n\r\n if (!this._betaTransition) {\r\n this._betaTransition = Animation.CreateAnimation(\"beta\", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);\r\n }\r\n\r\n const animatabe = Animation.TransitionTo(\r\n \"beta\",\r\n defaultBeta,\r\n this._attachedCamera,\r\n this._attachedCamera.getScene(),\r\n 60,\r\n this._betaTransition,\r\n this._elevationReturnTime,\r\n () => {\r\n this._clearAnimationLocks();\r\n this.stopAllAnimations();\r\n }\r\n );\r\n\r\n if (animatabe) {\r\n this._animatables.push(animatabe);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.\r\n */\r\n private _clearAnimationLocks(): void {\r\n this._betaIsAnimating = false;\r\n }\r\n\r\n /**\r\n * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.\r\n */\r\n private _applyUserInteraction(): void {\r\n if (this.isUserIsMoving) {\r\n this._lastInteractionTime = PrecisionDate.Now;\r\n this.stopAllAnimations();\r\n this._clearAnimationLocks();\r\n }\r\n }\r\n\r\n /**\r\n * Stops and removes all animations that have been applied to the camera\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._attachedCamera.animations = [];\r\n }\r\n\r\n while (this._animatables.length) {\r\n if (this._animatables[0]) {\r\n this._animatables[0].onAnimationEnd = null;\r\n this._animatables[0].stop();\r\n }\r\n this._animatables.shift();\r\n }\r\n }\r\n\r\n /**\r\n * Gets a value indicating if the user is moving the camera\r\n */\r\n public get isUserIsMoving(): boolean {\r\n if (!this._attachedCamera) {\r\n return false;\r\n }\r\n\r\n return (\r\n this._attachedCamera.inertialAlphaOffset !== 0 ||\r\n this._attachedCamera.inertialBetaOffset !== 0 ||\r\n this._attachedCamera.inertialRadiusOffset !== 0 ||\r\n this._attachedCamera.inertialPanningX !== 0 ||\r\n this._attachedCamera.inertialPanningY !== 0 ||\r\n this._isPointerDown\r\n );\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * The camera can move all the way towards the mesh.\r\n */\r\n public static IgnoreBoundsSizeMode = 0;\r\n\r\n /**\r\n * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides\r\n */\r\n public static FitFrustumSidesMode = 1;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"framingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/framingBehavior.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,eAAe;IAA5B;QAQI;;WAEG;QACI,0CAAqC,GAAG,IAAI,UAAU,EAAQ,CAAC;QAE9D,UAAK,GAAG,eAAe,CAAC,mBAAmB,CAAC;QAC5C,iBAAY,GAAG,GAAG,CAAC;QACnB,mBAAc,GAAG,GAAG,CAAC;QACrB,sBAAiB,GAAG,GAAG,CAAC;QACxB,yBAAoB,GAAG,IAAI,CAAC;QAC5B,6BAAwB,GAAG,IAAI,CAAC;QAChC,wBAAmB,GAAG,KAAK,CAAC;QAC5B,iBAAY,GAAG,IAAI,CAAC;QAgI5B;;;WAGG;QACI,0CAAqC,GAAG,IAAI,CAAC;QAO5C,mBAAc,GAAG,KAAK,CAAC;QACvB,yBAAoB,GAAG,CAAC,QAAQ,CAAC;QAyEzC,kBAAkB;QACV,iBAAY,GAAG,IAAI,KAAK,EAAc,CAAC;QACvC,qBAAgB,GAAG,KAAK,CAAC;IA8QrC,CAAC;IAxfG;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IA0BD;;OAE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sourcesContent":["import type { Behavior } from \"../../Behaviors/behavior\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport { ExponentialEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { PointerInfoPre } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { PrecisionDate } from \"../../Misc/precisionDate\";\r\n\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Animatable } from \"../../Animations/animatable\";\r\nimport { Animation } from \"../../Animations/animation\";\r\n\r\n/**\r\n * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors#framing-behavior\r\n */\r\nexport class FramingBehavior implements Behavior<ArcRotateCamera> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Framing\";\r\n }\r\n\r\n /**\r\n * An event triggered when the animation to zoom on target mesh has ended\r\n */\r\n public onTargetFramingAnimationEndObservable = new Observable<void>();\r\n\r\n private _mode = FramingBehavior.FitFrustumSidesMode;\r\n private _radiusScale = 1.0;\r\n private _positionScale = 0.5;\r\n private _defaultElevation = 0.3;\r\n private _elevationReturnTime = 1500;\r\n private _elevationReturnWaitTime = 1000;\r\n private _zoomStopsAnimation = false;\r\n private _framingTime = 1500;\r\n\r\n /**\r\n * The easing function used by animations\r\n */\r\n public static EasingFunction = new ExponentialEase();\r\n\r\n /**\r\n * The easing mode used by animations\r\n */\r\n public static EasingMode = EasingFunction.EASINGMODE_EASEINOUT;\r\n\r\n /**\r\n * Sets the current mode used by the behavior\r\n */\r\n public set mode(mode: number) {\r\n this._mode = mode;\r\n }\r\n\r\n /**\r\n * Gets current mode used by the behavior.\r\n */\r\n public get mode(): number {\r\n return this._mode;\r\n }\r\n\r\n /**\r\n * Sets the scale applied to the radius (1 by default)\r\n */\r\n public set radiusScale(radius: number) {\r\n this._radiusScale = radius;\r\n }\r\n\r\n /**\r\n * Gets the scale applied to the radius\r\n */\r\n public get radiusScale(): number {\r\n return this._radiusScale;\r\n }\r\n\r\n /**\r\n * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.\r\n */\r\n public set positionScale(scale: number) {\r\n this._positionScale = scale;\r\n }\r\n\r\n /**\r\n * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.\r\n */\r\n public get positionScale(): number {\r\n return this._positionScale;\r\n }\r\n\r\n /**\r\n * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle\r\n * behaviour is triggered, in radians.\r\n */\r\n public set defaultElevation(elevation: number) {\r\n this._defaultElevation = elevation;\r\n }\r\n\r\n /**\r\n * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle\r\n * behaviour is triggered, in radians.\r\n */\r\n public get defaultElevation() {\r\n return this._defaultElevation;\r\n }\r\n\r\n /**\r\n * Sets the time (in milliseconds) taken to return to the default beta position.\r\n * Negative value indicates camera should not return to default.\r\n */\r\n public set elevationReturnTime(speed: number) {\r\n this._elevationReturnTime = speed;\r\n }\r\n\r\n /**\r\n * Gets the time (in milliseconds) taken to return to the default beta position.\r\n * Negative value indicates camera should not return to default.\r\n */\r\n public get elevationReturnTime(): number {\r\n return this._elevationReturnTime;\r\n }\r\n\r\n /**\r\n * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.\r\n */\r\n public set elevationReturnWaitTime(time: number) {\r\n this._elevationReturnWaitTime = time;\r\n }\r\n\r\n /**\r\n * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.\r\n */\r\n public get elevationReturnWaitTime(): number {\r\n return this._elevationReturnWaitTime;\r\n }\r\n\r\n /**\r\n * Sets the flag that indicates if user zooming should stop animation.\r\n */\r\n public set zoomStopsAnimation(flag: boolean) {\r\n this._zoomStopsAnimation = flag;\r\n }\r\n\r\n /**\r\n * Gets the flag that indicates if user zooming should stop animation.\r\n */\r\n public get zoomStopsAnimation(): boolean {\r\n return this._zoomStopsAnimation;\r\n }\r\n\r\n /**\r\n * Sets the transition time when framing the mesh, in milliseconds\r\n */\r\n public set framingTime(time: number) {\r\n this._framingTime = time;\r\n }\r\n\r\n /**\r\n * Gets the transition time when framing the mesh, in milliseconds\r\n */\r\n public get framingTime() {\r\n return this._framingTime;\r\n }\r\n\r\n /**\r\n * Define if the behavior should automatically change the configured\r\n * camera limits and sensibilities.\r\n */\r\n public autoCorrectCameraLimitsAndSensibility = true;\r\n\r\n // Default behavior functions\r\n private _onPrePointerObservableObserver: Nullable<Observer<PointerInfoPre>>;\r\n private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;\r\n private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<TransformNode>>>;\r\n private _attachedCamera: Nullable<ArcRotateCamera>;\r\n private _isPointerDown = false;\r\n private _lastInteractionTime = -Infinity;\r\n\r\n /**\r\n * Initializes the behavior.\r\n */\r\n public init(): void {\r\n // Do nothing\r\n }\r\n\r\n /**\r\n * Attaches the behavior to its arc rotate camera.\r\n * @param camera Defines the camera to attach the behavior to\r\n */\r\n public attach(camera: ArcRotateCamera): void {\r\n this._attachedCamera = camera;\r\n const scene = this._attachedCamera.getScene();\r\n\r\n FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);\r\n\r\n this._onPrePointerObservableObserver = scene.onPrePointerObservable.add((pointerInfoPre) => {\r\n if (pointerInfoPre.type === PointerEventTypes.POINTERDOWN) {\r\n this._isPointerDown = true;\r\n return;\r\n }\r\n\r\n if (pointerInfoPre.type === PointerEventTypes.POINTERUP) {\r\n this._isPointerDown = false;\r\n }\r\n });\r\n\r\n this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((transformNode) => {\r\n if (transformNode && (transformNode as AbstractMesh).getBoundingInfo) {\r\n this.zoomOnMesh(transformNode as AbstractMesh, undefined, () => {\r\n this.onTargetFramingAnimationEndObservable.notifyObservers();\r\n });\r\n }\r\n });\r\n\r\n this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {\r\n // Stop the animation if there is user interaction and the animation should stop for this interaction\r\n this._applyUserInteraction();\r\n\r\n // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it\r\n // back to the default position after a given timeout\r\n this._maintainCameraAboveGround();\r\n });\r\n }\r\n\r\n /**\r\n * Detaches the behavior from its current arc rotate camera.\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n const scene = this._attachedCamera.getScene();\r\n\r\n if (this._onPrePointerObservableObserver) {\r\n scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);\r\n }\r\n\r\n if (this._onAfterCheckInputsObserver) {\r\n this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);\r\n }\r\n\r\n if (this._onMeshTargetChangedObserver) {\r\n this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);\r\n }\r\n\r\n this._attachedCamera = null;\r\n }\r\n\r\n // Framing control\r\n private _animatables = new Array<Animatable>();\r\n private _betaIsAnimating = false;\r\n private _betaTransition: Animation;\r\n private _radiusTransition: Animation;\r\n private _vectorTransition: Animation;\r\n\r\n /**\r\n * Targets the given mesh and updates zoom level accordingly.\r\n * @param mesh The mesh to target.\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n */\r\n public zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {\r\n mesh.computeWorldMatrix(true);\r\n\r\n const boundingBox = mesh.getBoundingInfo().boundingBox;\r\n this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);\r\n }\r\n\r\n /**\r\n * Targets the given mesh with its children and updates zoom level accordingly.\r\n * @param mesh The mesh to target.\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n */\r\n public zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {\r\n mesh.computeWorldMatrix(true);\r\n\r\n const boundingBox = mesh.getHierarchyBoundingVectors(true);\r\n this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);\r\n }\r\n\r\n /**\r\n * Targets the given meshes with their children and updates zoom level accordingly.\r\n * @param meshes The mesh to target.\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n */\r\n public zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {\r\n const min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const boundingInfo = meshes[i].getHierarchyBoundingVectors(true);\r\n Vector3.CheckExtends(boundingInfo.min, min, max);\r\n Vector3.CheckExtends(boundingInfo.max, min, max);\r\n }\r\n\r\n this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);\r\n }\r\n\r\n /**\r\n * Targets the bounding box info defined by its extends and updates zoom level accordingly.\r\n * @param minimumWorld Determines the smaller position of the bounding box extend\r\n * @param maximumWorld Determines the bigger position of the bounding box extend\r\n * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh\r\n * @param onAnimationEnd Callback triggered at the end of the framing animation\r\n * @returns true if the zoom was done\r\n */\r\n public zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): boolean {\r\n let zoomTarget: Vector3;\r\n\r\n if (!this._attachedCamera) {\r\n return false;\r\n }\r\n\r\n // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY\r\n const bottom = minimumWorld.y;\r\n const top = maximumWorld.y;\r\n const zoomTargetY = bottom + (top - bottom) * this._positionScale;\r\n const radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);\r\n\r\n if (focusOnOriginXZ) {\r\n zoomTarget = new Vector3(0, zoomTargetY, 0);\r\n } else {\r\n const centerWorld = minimumWorld.add(radiusWorld);\r\n zoomTarget = new Vector3(centerWorld.x, zoomTargetY, centerWorld.z);\r\n }\r\n\r\n if (!this._vectorTransition) {\r\n this._vectorTransition = Animation.CreateAnimation(\"target\", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);\r\n }\r\n\r\n this._betaIsAnimating = true;\r\n let animatable = Animation.TransitionTo(\"target\", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);\r\n if (animatable) {\r\n this._animatables.push(animatable);\r\n }\r\n\r\n // sets the radius and lower radius bounds\r\n // Small delta ensures camera is not always at lower zoom limit.\r\n let radius = 0;\r\n if (this._mode === FramingBehavior.FitFrustumSidesMode) {\r\n const position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);\r\n if (this.autoCorrectCameraLimitsAndSensibility) {\r\n this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;\r\n }\r\n radius = position;\r\n } else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {\r\n radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);\r\n if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {\r\n this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;\r\n }\r\n }\r\n\r\n // Set sensibilities\r\n if (this.autoCorrectCameraLimitsAndSensibility) {\r\n const extend = maximumWorld.subtract(minimumWorld).length();\r\n this._attachedCamera.panningSensibility = 5000 / extend;\r\n this._attachedCamera.wheelPrecision = 100 / radius;\r\n }\r\n\r\n // transition to new radius\r\n if (!this._radiusTransition) {\r\n this._radiusTransition = Animation.CreateAnimation(\"radius\", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);\r\n }\r\n\r\n animatable = Animation.TransitionTo(\"radius\", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, () => {\r\n this.stopAllAnimations();\r\n if (onAnimationEnd) {\r\n onAnimationEnd();\r\n }\r\n\r\n if (this._attachedCamera && this._attachedCamera.useInputToRestoreState) {\r\n this._attachedCamera.storeState();\r\n }\r\n });\r\n\r\n if (animatable) {\r\n this._animatables.push(animatable);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Calculates the lowest radius for the camera based on the bounding box of the mesh.\r\n * @param minimumWorld\r\n * @param maximumWorld\r\n * @returns The minimum distance from the primary mesh's center point at which the camera must be kept in order\r\n *\t\t to fully enclose the mesh in the viewing frustum.\r\n */\r\n protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number {\r\n const camera = this._attachedCamera;\r\n\r\n if (!camera) {\r\n return 0;\r\n }\r\n\r\n let distance = camera._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld, this._radiusScale);\r\n if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {\r\n // Don't exceed the requested limit\r\n distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;\r\n }\r\n\r\n // Don't exceed the upper radius limit\r\n if (camera.upperRadiusLimit) {\r\n distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;\r\n }\r\n\r\n return distance;\r\n }\r\n\r\n /**\r\n * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera\r\n * is automatically returned to its default position (expected to be above ground plane).\r\n */\r\n private _maintainCameraAboveGround(): void {\r\n if (this._elevationReturnTime < 0) {\r\n return;\r\n }\r\n\r\n const timeSinceInteraction = PrecisionDate.Now - this._lastInteractionTime;\r\n const defaultBeta = Math.PI * 0.5 - this._defaultElevation;\r\n const limitBeta = Math.PI * 0.5;\r\n\r\n // Bring the camera back up if below the ground plane\r\n if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {\r\n this._betaIsAnimating = true;\r\n\r\n //Transition to new position\r\n this.stopAllAnimations();\r\n\r\n if (!this._betaTransition) {\r\n this._betaTransition = Animation.CreateAnimation(\"beta\", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);\r\n }\r\n\r\n const animatabe = Animation.TransitionTo(\r\n \"beta\",\r\n defaultBeta,\r\n this._attachedCamera,\r\n this._attachedCamera.getScene(),\r\n 60,\r\n this._betaTransition,\r\n this._elevationReturnTime,\r\n () => {\r\n this._clearAnimationLocks();\r\n this.stopAllAnimations();\r\n }\r\n );\r\n\r\n if (animatabe) {\r\n this._animatables.push(animatabe);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.\r\n */\r\n private _clearAnimationLocks(): void {\r\n this._betaIsAnimating = false;\r\n }\r\n\r\n /**\r\n * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.\r\n */\r\n private _applyUserInteraction(): void {\r\n if (this.isUserIsMoving) {\r\n this._lastInteractionTime = PrecisionDate.Now;\r\n this.stopAllAnimations();\r\n this._clearAnimationLocks();\r\n }\r\n }\r\n\r\n /**\r\n * Stops and removes all animations that have been applied to the camera\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._attachedCamera.animations = [];\r\n }\r\n\r\n while (this._animatables.length) {\r\n if (this._animatables[0]) {\r\n this._animatables[0].onAnimationEnd = null;\r\n this._animatables[0].stop();\r\n }\r\n this._animatables.shift();\r\n }\r\n }\r\n\r\n /**\r\n * Gets a value indicating if the user is moving the camera\r\n */\r\n public get isUserIsMoving(): boolean {\r\n if (!this._attachedCamera) {\r\n return false;\r\n }\r\n\r\n return (\r\n this._attachedCamera.inertialAlphaOffset !== 0 ||\r\n this._attachedCamera.inertialBetaOffset !== 0 ||\r\n this._attachedCamera.inertialRadiusOffset !== 0 ||\r\n this._attachedCamera.inertialPanningX !== 0 ||\r\n this._attachedCamera.inertialPanningY !== 0 ||\r\n this._isPointerDown\r\n );\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * The camera can move all the way towards the mesh.\r\n */\r\n public static IgnoreBoundsSizeMode = 0;\r\n\r\n /**\r\n * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides\r\n */\r\n public static FitFrustumSidesMode = 1;\r\n}\r\n"]}
|
|
@@ -48,6 +48,10 @@ export class ArcRotateCameraGamepadInput {
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
this.gamepad = manager.getGamepadByType(Gamepad.XBOX);
|
|
51
|
+
// if no xbox controller was found, but there are gamepad controllers, take the first one
|
|
52
|
+
if (!this.gamepad && manager.gamepads.length) {
|
|
53
|
+
this.gamepad = manager.gamepads[0];
|
|
54
|
+
}
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* Detach the current controls from the specified dom element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arcRotateCameraGamepadInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/arcRotateCameraGamepadInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAAxC;QAWI;;;WAGG;QAEI,+BAA0B,GAAG,EAAE,CAAC;QAEvC;;;WAGG;QAEI,2BAAsB,GAAG,EAAE,CAAC;QAE3B,gBAAW,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"arcRotateCameraGamepadInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/arcRotateCameraGamepadInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAAxC;QAWI;;;WAGG;QAEI,+BAA0B,GAAG,EAAE,CAAC;QAEvC;;;WAGG;QAEI,2BAAsB,GAAG,EAAE,CAAC;QAE3B,gBAAW,GAAG,GAAG,CAAC;IAsG9B,CAAC;IApGG;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,WAAW,KAAK,GAAG,CAAC;IACpC,CAAC;IAED,IAAW,WAAW,CAAC,KAAc;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1C,CAAC;IAKD;;OAEG;IACI,aAAa;QAChB,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC;QACtD,IAAI,CAAC,2BAA2B,GAAG,OAAO,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACpF,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,YAAY,EAAE;gBACvC,4BAA4B;gBAC5B,IA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{ Observer } from \"../../Misc/observable\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport { Gamepad } from \"../../Gamepads/gamepad\";\r\n/**\r\n * Manage the gamepad inputs to control an arc rotate camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: ArcRotateCamera;\r\n\r\n /**\r\n * Defines the gamepad the input is gathering event from.\r\n */\r\n public gamepad: Nullable<Gamepad>;\r\n\r\n /**\r\n * Defines the gamepad rotation sensibility.\r\n * This is the threshold from when rotation starts to be accounted for to prevent jittering.\r\n */\r\n @serialize()\r\n public gamepadRotationSensibility = 80;\r\n\r\n /**\r\n * Defines the gamepad move sensibility.\r\n * This is the threshold from when moving starts to be accounted for for to prevent jittering.\r\n */\r\n @serialize()\r\n public gamepadMoveSensibility = 40;\r\n\r\n private _yAxisScale = 1.0;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted\r\n */\r\n public get invertYAxis() {\r\n return this._yAxisScale !== 1.0;\r\n }\r\n\r\n public set invertYAxis(value: boolean) {\r\n this._yAxisScale = value ? -1.0 : 1.0;\r\n }\r\n\r\n private _onGamepadConnectedObserver: Nullable<Observer<Gamepad>>;\r\n private _onGamepadDisconnectedObserver: Nullable<Observer<Gamepad>>;\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 manager = this.camera.getScene().gamepadManager;\r\n this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add((gamepad) => {\r\n if (gamepad.type !== Gamepad.POSE_ENABLED) {\r\n // prioritize XBOX gamepads.\r\n if (!this.gamepad || gamepad.type === Gamepad.XBOX) {\r\n this.gamepad = gamepad;\r\n }\r\n }\r\n });\r\n\r\n this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add((gamepad) => {\r\n if (this.gamepad === gamepad) {\r\n this.gamepad = null;\r\n }\r\n });\r\n\r\n this.gamepad = manager.getGamepadByType(Gamepad.XBOX);\r\n // if no xbox controller was found, but there are gamepad controllers, take the first one\r\n if (!this.gamepad && manager.gamepads.length) {\r\n this.gamepad = manager.gamepads[0];\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 this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);\r\n this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);\r\n this.gamepad = null;\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.gamepad) {\r\n const camera = this.camera;\r\n const rsValues = this.gamepad.rightStick;\r\n\r\n if (rsValues) {\r\n if (rsValues.x != 0) {\r\n const normalizedRX = rsValues.x / this.gamepadRotationSensibility;\r\n if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {\r\n camera.inertialAlphaOffset += normalizedRX;\r\n }\r\n }\r\n\r\n if (rsValues.y != 0) {\r\n const normalizedRY = (rsValues.y / this.gamepadRotationSensibility) * this._yAxisScale;\r\n if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {\r\n camera.inertialBetaOffset += normalizedRY;\r\n }\r\n }\r\n }\r\n\r\n const lsValues = this.gamepad.leftStick;\r\n if (lsValues && lsValues.y != 0) {\r\n const normalizedLY = lsValues.y / this.gamepadMoveSensibility;\r\n if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {\r\n this.camera.inertialRadiusOffset -= normalizedLY;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the class name of the current intput.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"ArcRotateCameraGamepadInput\";\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 \"gamepad\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"ArcRotateCameraGamepadInput\"] = ArcRotateCameraGamepadInput;\r\n"]}
|
|
@@ -10,6 +10,7 @@ import { Camera } from "./camera";
|
|
|
10
10
|
import { TargetCamera } from "./targetCamera";
|
|
11
11
|
import { ArcRotateCameraInputsManager } from "../Cameras/arcRotateCameraInputsManager";
|
|
12
12
|
import type { Collider } from "../Collisions/collider";
|
|
13
|
+
import type { TransformNode } from "../Meshes/transformNode.js";
|
|
13
14
|
/**
|
|
14
15
|
* This represents an orbital type of camera.
|
|
15
16
|
*
|
|
@@ -36,7 +37,7 @@ export declare class ArcRotateCamera extends TargetCamera {
|
|
|
36
37
|
*/
|
|
37
38
|
overrideCloneAlphaBetaRadius: Nullable<boolean>;
|
|
38
39
|
protected _target: Vector3;
|
|
39
|
-
protected _targetHost: Nullable<
|
|
40
|
+
protected _targetHost: Nullable<TransformNode>;
|
|
40
41
|
/**
|
|
41
42
|
* Defines the target point of the camera.
|
|
42
43
|
* The camera looks towards it from the radius distance.
|
|
@@ -44,12 +45,12 @@ export declare class ArcRotateCamera extends TargetCamera {
|
|
|
44
45
|
get target(): Vector3;
|
|
45
46
|
set target(value: Vector3);
|
|
46
47
|
/**
|
|
47
|
-
* Defines the target
|
|
48
|
+
* Defines the target transform node of the camera.
|
|
48
49
|
* The camera looks towards it from the radius distance.
|
|
49
50
|
* Please note that setting a target host will disable panning.
|
|
50
51
|
*/
|
|
51
|
-
get targetHost(): Nullable<
|
|
52
|
-
set targetHost(value: Nullable<
|
|
52
|
+
get targetHost(): Nullable<TransformNode>;
|
|
53
|
+
set targetHost(value: Nullable<TransformNode>);
|
|
53
54
|
/**
|
|
54
55
|
* Return the current target position of the camera. This value is expressed in local space.
|
|
55
56
|
* @returns the target position
|
|
@@ -295,9 +296,9 @@ export declare class ArcRotateCamera extends TargetCamera {
|
|
|
295
296
|
get useAutoRotationBehavior(): boolean;
|
|
296
297
|
set useAutoRotationBehavior(value: boolean);
|
|
297
298
|
/**
|
|
298
|
-
* Observable triggered when the
|
|
299
|
+
* Observable triggered when the transform node target has been changed on the camera.
|
|
299
300
|
*/
|
|
300
|
-
onMeshTargetChangedObservable: Observable<Nullable<
|
|
301
|
+
onMeshTargetChangedObservable: Observable<Nullable<TransformNode>>;
|
|
301
302
|
/**
|
|
302
303
|
* Event raised when the camera is colliding with a mesh.
|
|
303
304
|
*/
|
|
@@ -409,12 +410,12 @@ export declare class ArcRotateCamera extends TargetCamera {
|
|
|
409
410
|
* Defines the target the camera should look at.
|
|
410
411
|
* This will automatically adapt alpha beta and radius to fit within the new target.
|
|
411
412
|
* Please note that setting a target as a mesh will disable panning.
|
|
412
|
-
* @param target Defines the new target as a Vector or a
|
|
413
|
+
* @param target Defines the new target as a Vector or a transform node
|
|
413
414
|
* @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
|
|
414
415
|
* @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
|
|
415
416
|
* @param cloneAlphaBetaRadius If true, replicate the current setup (alpha, beta, radius) on the new target
|
|
416
417
|
*/
|
|
417
|
-
setTarget(target:
|
|
418
|
+
setTarget(target: TransformNode | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean, cloneAlphaBetaRadius?: boolean): void;
|
|
418
419
|
/** @internal */
|
|
419
420
|
_getViewMatrix(): Matrix;
|
|
420
421
|
protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
|
|
@@ -34,7 +34,7 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
34
34
|
this.setTarget(value);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Defines the target
|
|
37
|
+
* Defines the target transform node of the camera.
|
|
38
38
|
* The camera looks towards it from the radius distance.
|
|
39
39
|
* Please note that setting a target host will disable panning.
|
|
40
40
|
*/
|
|
@@ -503,7 +503,7 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
503
503
|
*/
|
|
504
504
|
this.mapPanning = false;
|
|
505
505
|
/**
|
|
506
|
-
* Observable triggered when the
|
|
506
|
+
* Observable triggered when the transform node target has been changed on the camera.
|
|
507
507
|
*/
|
|
508
508
|
this.onMeshTargetChangedObservable = new Observable();
|
|
509
509
|
/**
|
|
@@ -842,7 +842,7 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
842
842
|
* Defines the target the camera should look at.
|
|
843
843
|
* This will automatically adapt alpha beta and radius to fit within the new target.
|
|
844
844
|
* Please note that setting a target as a mesh will disable panning.
|
|
845
|
-
* @param target Defines the new target as a Vector or a
|
|
845
|
+
* @param target Defines the new target as a Vector or a transform node
|
|
846
846
|
* @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
|
|
847
847
|
* @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
|
|
848
848
|
* @param cloneAlphaBetaRadius If true, replicate the current setup (alpha, beta, radius) on the new target
|
|
@@ -850,8 +850,8 @@ export class ArcRotateCamera extends TargetCamera {
|
|
|
850
850
|
setTarget(target, toBoundingCenter = false, allowSamePosition = false, cloneAlphaBetaRadius = false) {
|
|
851
851
|
var _a;
|
|
852
852
|
cloneAlphaBetaRadius = (_a = this.overrideCloneAlphaBetaRadius) !== null && _a !== void 0 ? _a : cloneAlphaBetaRadius;
|
|
853
|
-
if (target.
|
|
854
|
-
if (toBoundingCenter) {
|
|
853
|
+
if (target.computeWorldMatrix) {
|
|
854
|
+
if (toBoundingCenter && target.getBoundingInfo) {
|
|
855
855
|
this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
|
|
856
856
|
}
|
|
857
857
|
else {
|