@babylonjs/core 8.3.1 → 8.4.0
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/animation.d.ts +4 -0
- package/Animations/animation.js +22 -13
- package/Animations/animation.js.map +1 -1
- package/Animations/animation.optimizations.d.ts +31 -0
- package/Animations/animation.optimizations.js +41 -0
- package/Animations/animation.optimizations.js.map +1 -0
- package/Animations/index.d.ts +1 -0
- package/Animations/index.js +1 -0
- package/Animations/index.js.map +1 -1
- package/Animations/pathCursor.js +3 -1
- package/Animations/pathCursor.js.map +1 -1
- package/Animations/runtimeAnimation.d.ts +3 -1
- package/Animations/runtimeAnimation.js +127 -116
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioSceneComponent.js +4 -4
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Behaviors/Meshes/attachToBoxBehavior.js +6 -6
- package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
- package/Behaviors/Meshes/fadeInOutBehavior.js +3 -2
- package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
- package/Behaviors/Meshes/multiPointerScaleBehavior.js +6 -4
- package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js +3 -2
- package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
- package/Bones/skeleton.js +6 -6
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js +2 -2
- package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js +2 -2
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/arcRotateCamera.js +6 -2
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.js +2 -2
- package/Cameras/camera.js.map +1 -1
- package/Cameras/deviceOrientationCamera.js +3 -2
- package/Cameras/deviceOrientationCamera.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +1 -0
- package/Collisions/gpuPicker.js +9 -0
- package/Collisions/gpuPicker.js.map +1 -1
- package/Debug/axesViewer.js +3 -2
- package/Debug/axesViewer.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.js +4 -4
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Debug/physicsViewer.js +7 -6
- package/Debug/physicsViewer.js.map +1 -1
- package/Debug/skeletonViewer.js +4 -4
- package/Debug/skeletonViewer.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js +2 -2
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/abstractEngine.d.ts +1 -0
- package/Engines/abstractEngine.js +14 -8
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +27 -5
- package/Engines/constants.js +27 -5
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.js +8 -8
- package/Engines/engine.js.map +1 -1
- package/Engines/webgpuEngine.js +6 -2
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +2 -2
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +3 -2
- package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +3 -2
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +2 -2
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +3 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
- package/FlowGraph/flowGraphAsyncExecutionBlock.js +5 -3
- package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphBlock.js +3 -2
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.js +10 -6
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +5 -4
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +4 -3
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/Gamepads/gamepadManager.js +2 -2
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/axisDragGizmo.js +3 -2
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +6 -4
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +28 -26
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.js +6 -3
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.js +11 -10
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.js +16 -12
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/lightGizmo.js +3 -2
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.js +3 -2
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +3 -2
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.js +41 -28
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js +26 -18
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.js +47 -32
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Layers/effectLayerSceneComponent.js +4 -4
- package/Layers/effectLayerSceneComponent.js.map +1 -1
- package/Layers/layerSceneComponent.js +4 -4
- package/Layers/layerSceneComponent.js.map +1 -1
- package/LensFlares/lensFlareSystemSceneComponent.js +4 -4
- package/LensFlares/lensFlareSystemSceneComponent.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +3 -3
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/light.js +4 -4
- package/Lights/light.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +54 -46
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/loadingScreen.js +4 -3
- package/Loading/loadingScreen.js.map +1 -1
- package/Loading/sceneLoader.js +15 -12
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +9 -3
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +11 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +18 -31
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/baseMathBlock.js +3 -1
- package/Materials/Node/Blocks/baseMathBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +53 -43
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Enums/nodeMaterialModes.d.ts +3 -1
- package/Materials/Node/Enums/nodeMaterialModes.js +2 -0
- package/Materials/Node/Enums/nodeMaterialModes.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +5 -0
- package/Materials/Node/nodeMaterial.js +33 -20
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.js +7 -4
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +13 -2
- package/Materials/Node/nodeMaterialBuildState.js +72 -7
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialDefault.d.ts +5 -0
- package/Materials/Node/nodeMaterialDefault.js +28 -0
- package/Materials/Node/nodeMaterialDefault.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +3 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +5 -4
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/materialDefines.js +3 -1
- package/Materials/materialDefines.js.map +1 -1
- package/Materials/multiMaterial.js +3 -1
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/shaderMaterial.js +3 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.js +2 -2
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +8 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +6 -6
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +4 -3
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +3 -1
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +8 -5
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/abstractMesh.js +2 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geodesicMesh.js +2 -2
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/mesh.js +6 -6
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.functions.js +11 -10
- package/Meshes/mesh.vertexData.functions.js.map +1 -1
- package/Meshes/mesh.vertexData.subdivide.js +10 -10
- package/Meshes/mesh.vertexData.subdivide.js.map +1 -1
- package/Meshes/meshSimplification.js +10 -10
- package/Meshes/meshSimplification.js.map +1 -1
- package/Meshes/meshUtils.js +6 -3
- package/Meshes/meshUtils.js.map +1 -1
- package/Meshes/polygonMesh.js +10 -10
- package/Meshes/polygonMesh.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +4 -4
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/arrayTools.js +2 -2
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/asyncLock.js +9 -9
- package/Misc/asyncLock.js.map +1 -1
- package/Misc/basis.js +4 -2
- package/Misc/basis.js.map +1 -1
- package/Misc/deepCopier.js +3 -2
- package/Misc/deepCopier.js.map +1 -1
- package/Misc/deepMerger.js +3 -2
- package/Misc/deepMerger.js.map +1 -1
- package/Misc/fileTools.js +4 -4
- package/Misc/fileTools.js.map +1 -1
- package/Misc/greasedLineTools.js +14 -13
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/logger.js +3 -2
- package/Misc/logger.js.map +1 -1
- package/Misc/observable.extensions.js +4 -4
- package/Misc/observable.extensions.js.map +1 -1
- package/Misc/sceneSerializer.js +5 -4
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +3 -1
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/tags.js +2 -2
- package/Misc/tags.js.map +1 -1
- package/Misc/trajectoryClassifier.js +8 -8
- package/Misc/trajectoryClassifier.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +1 -1
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +11 -3
- package/Particles/baseParticleSystem.js +37 -3
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -14
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particle.js +2 -2
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.js +15 -13
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.js +3 -16
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsHelper.js +18 -14
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/v1/Plugins/ammoJSPlugin.js +10 -8
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/v1/Plugins/cannonJSPlugin.js +13 -8
- package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/v1/Plugins/oimoJSPlugin.js +9 -8
- package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/v1/physicsEngine.js +4 -4
- package/Physics/v1/physicsEngine.js.map +1 -1
- package/Physics/v1/physicsImpostor.js +10 -21
- package/Physics/v1/physicsImpostor.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +12 -10
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/ragdoll.js +4 -4
- package/Physics/v2/ragdoll.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +3 -2
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js +8 -6
- package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js +4 -3
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js +6 -6
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +14 -14
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +14 -12
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/iblCdfGenerator.js +4 -4
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/objectRenderer.js +2 -2
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js +7 -5
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Sprites/spriteMap.js +2 -2
- package/Sprites/spriteMap.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.js +2 -2
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js +4 -4
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRBackgroundRemover.js +3 -1
- package/XR/features/WebXRBackgroundRemover.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js +6 -3
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js +12 -7
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +12 -7
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js +11 -7
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js +6 -6
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +60 -24
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js +4 -4
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRImageTracking.js +2 -2
- package/XR/features/WebXRImageTracking.js.map +1 -1
- package/XR/features/WebXRLayers.js +2 -2
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +12 -7
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js +9 -4
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js +2 -2
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +19 -8
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/motionController/webXRGenericMotionController.js +2 -2
- package/XR/motionController/webXRGenericMotionController.js.map +1 -1
- package/XR/motionController/webXRHTCViveMotionController.js +5 -4
- package/XR/motionController/webXRHTCViveMotionController.js.map +1 -1
- package/XR/motionController/webXRMicrosoftMixedRealityController.js +9 -6
- package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
- package/XR/motionController/webXRMotionControllerManager.js +4 -4
- package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
- package/XR/motionController/webXROculusTouchMotionController.js +5 -4
- package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
- package/XR/motionController/webXRProfiledMotionController.js +15 -10
- package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
- package/XR/webXRCamera.js +3 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXREnterExitUI.js +5 -4
- package/XR/webXREnterExitUI.js.map +1 -1
- package/XR/webXRExperienceHelper.js +2 -2
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRFeaturesManager.js +10 -7
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +8 -8
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRInputSource.js +4 -1
- package/XR/webXRInputSource.js.map +1 -1
- package/XR/webXRRenderTargetTextureProvider.js +3 -1
- package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
- package/assetContainer.js +156 -135
- package/assetContainer.js.map +1 -1
- package/node.js +2 -2
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +18 -11
- package/scene.js.map +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Scene } from "../scene.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interface used to define the optimization options for animations
|
|
4
|
+
*/
|
|
5
|
+
export type AnimationOptimization = {
|
|
6
|
+
/**
|
|
7
|
+
* Do not merge runtime animations
|
|
8
|
+
* @defaultValue true
|
|
9
|
+
*/
|
|
10
|
+
mergeRuntimeAnimations: false;
|
|
11
|
+
} | {
|
|
12
|
+
/**
|
|
13
|
+
* All runtime animations will be merged into the first animatable
|
|
14
|
+
* @defaultValue true
|
|
15
|
+
*/
|
|
16
|
+
mergeRuntimeAnimations: true;
|
|
17
|
+
/**
|
|
18
|
+
* If true, all keyframes evaluation will be merged from the first runtime animation
|
|
19
|
+
* You need to turn on `mergeRuntimeAnimations` for this to work
|
|
20
|
+
* @defaultValue false
|
|
21
|
+
*/
|
|
22
|
+
mergeKeyFrames: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* This is a destructive optimization that merges all animatables into the first one.
|
|
26
|
+
* That animatable will also host all the runtime animations.
|
|
27
|
+
* We expect that all the animatables are on the same timeframe (same start, end, loop, etc..)
|
|
28
|
+
* @param scene defines the scene to optimize
|
|
29
|
+
* @param options defines the optimization options
|
|
30
|
+
*/
|
|
31
|
+
export declare function OptimizeAnimations(scene: Scene, options?: Partial<AnimationOptimization>): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a destructive optimization that merges all animatables into the first one.
|
|
3
|
+
* That animatable will also host all the runtime animations.
|
|
4
|
+
* We expect that all the animatables are on the same timeframe (same start, end, loop, etc..)
|
|
5
|
+
* @param scene defines the scene to optimize
|
|
6
|
+
* @param options defines the optimization options
|
|
7
|
+
*/
|
|
8
|
+
export function OptimizeAnimations(scene, options = {}) {
|
|
9
|
+
const mergeRuntimeAnimations = options.mergeRuntimeAnimations ?? true;
|
|
10
|
+
const mergeKeyFrames = options.mergeRuntimeAnimations === true ? (options.mergeKeyFrames ?? false) : false;
|
|
11
|
+
// We will go through all the current animatables and merge them
|
|
12
|
+
const animatables = scene.animatables;
|
|
13
|
+
if (animatables.length === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const mainAnimatable = animatables[0];
|
|
17
|
+
for (let i = 1; i < animatables.length; i++) {
|
|
18
|
+
const animatable = animatables[i];
|
|
19
|
+
// Merge the current animatable with the main one
|
|
20
|
+
mainAnimatable._runtimeAnimations.push(...animatable._runtimeAnimations);
|
|
21
|
+
}
|
|
22
|
+
if (mergeRuntimeAnimations && mainAnimatable._runtimeAnimations.length > 1) {
|
|
23
|
+
// Make sure only one runtime animation is driving the beat
|
|
24
|
+
const mainRuntimeAnimation = mainAnimatable._runtimeAnimations[0];
|
|
25
|
+
for (let i = 1; i < mainAnimatable._runtimeAnimations.length; i++) {
|
|
26
|
+
const runtimeAnimation = mainAnimatable._runtimeAnimations[i];
|
|
27
|
+
runtimeAnimation._coreRuntimeAnimation = mainRuntimeAnimation;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (mergeKeyFrames && mainAnimatable._runtimeAnimations.length > 1) {
|
|
31
|
+
// Merge the keyframes from all the runtime animations into the first one
|
|
32
|
+
const mainAnimation = mainAnimatable._runtimeAnimations[0]._animation;
|
|
33
|
+
for (let i = 1; i < mainAnimatable._runtimeAnimations.length; i++) {
|
|
34
|
+
const runtimeAnimation = mainAnimatable._runtimeAnimations[i];
|
|
35
|
+
const animation = runtimeAnimation._animation;
|
|
36
|
+
animation._coreAnimation = mainAnimation;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
scene._activeAnimatables = [mainAnimatable];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=animation.optimizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.optimizations.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/animation.optimizations.ts"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,UAA0C,EAAE;IACzF,MAAM,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,IAAI,IAAI,CAAC;IACtE,MAAM,cAAc,GAAG,OAAO,CAAC,sBAAsB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAE3G,gEAAgE;IAChE,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IAEtC,IAAI,WAAW,CAAC,MAAM,KAAK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c,GAAG,aAAa,CAAC;QAC7C,CAAC;IACL,CAAC;IAED,KAAK,CAAC,kBAAkB,GAAG,CAAC,cAAc,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * Interface used to define the optimization options for animations\r\n */\r\nexport type AnimationOptimization =\r\n | {\r\n /**\r\n * Do not merge runtime animations\r\n * @defaultValue true\r\n */\r\n mergeRuntimeAnimations: false;\r\n }\r\n | {\r\n /**\r\n * All runtime animations will be merged into the first animatable\r\n * @defaultValue true\r\n */\r\n mergeRuntimeAnimations: true;\r\n /**\r\n * If true, all keyframes evaluation will be merged from the first runtime animation\r\n * You need to turn on `mergeRuntimeAnimations` for this to work\r\n * @defaultValue false\r\n */\r\n mergeKeyFrames: boolean;\r\n };\r\n\r\n/**\r\n * This is a destructive optimization that merges all animatables into the first one.\r\n * That animatable will also host all the runtime animations.\r\n * We expect that all the animatables are on the same timeframe (same start, end, loop, etc..)\r\n * @param scene defines the scene to optimize\r\n * @param options defines the optimization options\r\n */\r\nexport function OptimizeAnimations(scene: Scene, options: Partial<AnimationOptimization> = {}) {\r\n const mergeRuntimeAnimations = options.mergeRuntimeAnimations ?? true;\r\n const mergeKeyFrames = options.mergeRuntimeAnimations === true ? (options.mergeKeyFrames ?? false) : false;\r\n\r\n // We will go through all the current animatables and merge them\r\n const animatables = scene.animatables;\r\n\r\n if (animatables.length === 0) {\r\n return;\r\n }\r\n\r\n const mainAnimatable = animatables[0];\r\n\r\n for (let i = 1; i < animatables.length; i++) {\r\n const animatable = animatables[i];\r\n\r\n // Merge the current animatable with the main one\r\n mainAnimatable._runtimeAnimations.push(...animatable._runtimeAnimations);\r\n }\r\n\r\n if (mergeRuntimeAnimations && mainAnimatable._runtimeAnimations.length > 1) {\r\n // Make sure only one runtime animation is driving the beat\r\n const mainRuntimeAnimation = mainAnimatable._runtimeAnimations[0];\r\n for (let i = 1; i < mainAnimatable._runtimeAnimations.length; i++) {\r\n const runtimeAnimation = mainAnimatable._runtimeAnimations[i];\r\n runtimeAnimation._coreRuntimeAnimation = mainRuntimeAnimation;\r\n }\r\n }\r\n\r\n if (mergeKeyFrames && mainAnimatable._runtimeAnimations.length > 1) {\r\n // Merge the keyframes from all the runtime animations into the first one\r\n const mainAnimation = mainAnimatable._runtimeAnimations[0]._animation;\r\n for (let i = 1; i < mainAnimatable._runtimeAnimations.length; i++) {\r\n const runtimeAnimation = mainAnimatable._runtimeAnimations[i];\r\n const animation = runtimeAnimation._animation;\r\n animation._coreAnimation = mainAnimation;\r\n }\r\n }\r\n\r\n scene._activeAnimatables = [mainAnimatable];\r\n}\r\n"]}
|
package/Animations/index.d.ts
CHANGED
package/Animations/index.js
CHANGED
package/Animations/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./animatable\";\r\nexport * from \"./animation\";\r\nexport * from \"./animationPropertiesOverride\";\r\nexport * from \"./easing\";\r\nexport * from \"./runtimeAnimation\";\r\nexport * from \"./animationEvent\";\r\nexport * from \"./animationGroup\";\r\nexport * from \"./animationKey\";\r\nexport * from \"./animationRange\";\r\nexport * from \"./animatable.interface\";\r\nexport * from \"./pathCursor\";\r\nexport * from \"./animationGroupMask\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC","sourcesContent":["export * from \"./animatable\";\r\nexport * from \"./animation\";\r\nexport * from \"./animationPropertiesOverride\";\r\nexport * from \"./easing\";\r\nexport * from \"./runtimeAnimation\";\r\nexport * from \"./animationEvent\";\r\nexport * from \"./animationGroup\";\r\nexport * from \"./animationKey\";\r\nexport * from \"./animationRange\";\r\nexport * from \"./animatable.interface\";\r\nexport * from \"./pathCursor\";\r\nexport * from \"./animationGroupMask\";\r\nexport * from \"./animation.optimizations\";\r\n"]}
|
package/Animations/pathCursor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathCursor.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/pathCursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C;;GAEG;AACH,MAAM,OAAO,UAAU;IAgBnB;;;OAGG;IACH,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAnBhC;;WAEG;QACK,cAAS,GAAG,IAAI,KAAK,EAAgC,CAAC;QAE9D;;WAEG;QACH,UAAK,GAAW,CAAC,CAAC;QAElB;;WAEG;QACH,eAAU,GAAG,EAAiB,CAAC;IAMI,CAAC;IAEpC;;;OAGG;IACI,QAAQ;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9D,OAAO,IAAI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AC;IAED;;;OAGG;IACK,cAAc;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC7B,CAAC,CAAC,IAAI,CAAC,CAAC;QACZ,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,CAA+B;QAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEvB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Path2 } from \"../Maths/math.path\";\r\n\r\n/**\r\n * A cursor which tracks a point on a path\r\n */\r\nexport class PathCursor {\r\n /**\r\n * Stores path cursor callbacks for when an onchange event is triggered\r\n */\r\n private _onchange = new Array<(cursor: PathCursor) => void>();\r\n\r\n /**\r\n * The value of the path cursor\r\n */\r\n value: number = 0;\r\n\r\n /**\r\n * The animation array of the path cursor\r\n */\r\n animations = [] as Animation[];\r\n\r\n /**\r\n * Initializes the path cursor\r\n * @param _path The path to track\r\n */\r\n constructor(private _path: Path2) {}\r\n\r\n /**\r\n * Gets the cursor point on the path\r\n * @returns A point on the path cursor at the cursor location\r\n */\r\n public getPoint(): Vector3 {\r\n const point = this._path.getPointAtLengthPosition(this.value);\r\n return new Vector3(point.x, 0, point.y);\r\n }\r\n\r\n /**\r\n * Moves the cursor ahead by the step amount\r\n * @param step The amount to move the cursor forward\r\n * @returns This path cursor\r\n */\r\n public moveAhead(step: number = 0.002): PathCursor {\r\n this.move(step);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Moves the cursor behind by the step amount\r\n * @param step The amount to move the cursor back\r\n * @returns This path cursor\r\n */\r\n public moveBack(step: number = 0.002): PathCursor {\r\n this.move(-step);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Moves the cursor by the step amount\r\n * If the step amount is greater than one, an exception is thrown\r\n * @param step The amount to move the cursor\r\n * @returns This path cursor\r\n */\r\n public move(step: number): PathCursor {\r\n if (Math.abs(step) > 1) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"step size should be less than 1.\";\r\n }\r\n\r\n this.value += step;\r\n this._ensureLimits();\r\n this._raiseOnChange();\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Ensures that the value is limited between zero and one\r\n * @returns This path cursor\r\n */\r\n private _ensureLimits(): PathCursor {\r\n while (this.value > 1) {\r\n this.value -= 1;\r\n }\r\n while (this.value < 0) {\r\n this.value += 1;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs onchange callbacks on change (used by the animation engine)\r\n * @returns This path cursor\r\n */\r\n private _raiseOnChange(): PathCursor {\r\n for (const f of this._onchange) {\r\n f(this);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Executes a function on change\r\n * @param f A path cursor onchange callback\r\n * @returns This path cursor\r\n */\r\n public onchange(f: (cursor: PathCursor) => void): PathCursor {\r\n this._onchange.push(f);\r\n\r\n return this;\r\n }\r\n}\r\n"]}
|
|
@@ -14,7 +14,7 @@ export declare class RuntimeAnimation {
|
|
|
14
14
|
/**
|
|
15
15
|
* The animation used by the runtime animation
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
_animation: Animation;
|
|
18
18
|
/**
|
|
19
19
|
* The target of the runtime animation
|
|
20
20
|
*/
|
|
@@ -91,6 +91,8 @@ export declare class RuntimeAnimation {
|
|
|
91
91
|
private _minValue;
|
|
92
92
|
private _maxValue;
|
|
93
93
|
private _targetIsArray;
|
|
94
|
+
/** @internal */
|
|
95
|
+
_coreRuntimeAnimation: RuntimeAnimation | null;
|
|
94
96
|
/**
|
|
95
97
|
* Gets the current frame of the runtime animation
|
|
96
98
|
*/
|
|
@@ -105,6 +105,8 @@ export class RuntimeAnimation {
|
|
|
105
105
|
*/
|
|
106
106
|
this._previousAbsoluteFrame = 0;
|
|
107
107
|
this._targetIsArray = false;
|
|
108
|
+
/** @internal */
|
|
109
|
+
this._coreRuntimeAnimation = null;
|
|
108
110
|
this._animation = animation;
|
|
109
111
|
this._target = target;
|
|
110
112
|
this._scene = scene;
|
|
@@ -150,9 +152,9 @@ export class RuntimeAnimation {
|
|
|
150
152
|
// Cloning events locally
|
|
151
153
|
const events = animation.getEvents();
|
|
152
154
|
if (events && events.length > 0) {
|
|
153
|
-
|
|
155
|
+
for (const e of events) {
|
|
154
156
|
this._events.push(e._clone());
|
|
155
|
-
}
|
|
157
|
+
}
|
|
156
158
|
}
|
|
157
159
|
this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
|
|
158
160
|
}
|
|
@@ -423,150 +425,159 @@ export class RuntimeAnimation {
|
|
|
423
425
|
return false;
|
|
424
426
|
}
|
|
425
427
|
let returnValue = true;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
from = this._minFrame;
|
|
429
|
-
}
|
|
430
|
-
if (to < this._minFrame || to > this._maxFrame) {
|
|
431
|
-
to = this._maxFrame;
|
|
432
|
-
}
|
|
428
|
+
let currentFrame;
|
|
429
|
+
const events = this._events;
|
|
433
430
|
const frameRange = to - from;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
//
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
450
|
-
|
|
431
|
+
if (!this._coreRuntimeAnimation) {
|
|
432
|
+
// Check limits
|
|
433
|
+
if (from < this._minFrame || from > this._maxFrame) {
|
|
434
|
+
from = this._minFrame;
|
|
435
|
+
}
|
|
436
|
+
if (to < this._minFrame || to > this._maxFrame) {
|
|
437
|
+
to = this._maxFrame;
|
|
438
|
+
}
|
|
439
|
+
let offsetValue;
|
|
440
|
+
// Compute the frame according to the elapsed time and the fps of the animation ("from" and "to" are not factored in!)
|
|
441
|
+
let absoluteFrame = (elapsedTimeSinceAnimationStart * (animation.framePerSecond * speedRatio)) / 1000.0 + this._absoluteFrameOffset;
|
|
442
|
+
let highLimitValue = 0;
|
|
443
|
+
// Apply the yoyo function if required
|
|
444
|
+
let yoyoLoop = false;
|
|
445
|
+
const yoyoMode = loop && this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_YOYO;
|
|
446
|
+
if (yoyoMode) {
|
|
447
|
+
const position = (absoluteFrame - from) / frameRange;
|
|
448
|
+
// Apply the yoyo curve
|
|
449
|
+
const sin = Math.sin(position * Math.PI);
|
|
450
|
+
const yoyoPosition = Math.abs(sin);
|
|
451
|
+
// Map the yoyo position back to the range
|
|
452
|
+
absoluteFrame = yoyoPosition * frameRange + from;
|
|
453
|
+
const direction = sin >= 0 ? 1 : -1;
|
|
454
|
+
if (this._yoyoDirection !== direction) {
|
|
455
|
+
yoyoLoop = true;
|
|
456
|
+
}
|
|
457
|
+
this._yoyoDirection = direction;
|
|
458
|
+
}
|
|
459
|
+
this._previousElapsedTime = elapsedTimeSinceAnimationStart;
|
|
460
|
+
this._previousAbsoluteFrame = absoluteFrame;
|
|
461
|
+
if (!loop && to >= from && ((absoluteFrame >= frameRange && speedRatio > 0) || (absoluteFrame <= 0 && speedRatio < 0))) {
|
|
462
|
+
// If we are out of range and not looping get back to caller
|
|
463
|
+
returnValue = false;
|
|
464
|
+
highLimitValue = animation._getKeyValue(this._maxValue);
|
|
451
465
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
466
|
+
else if (!loop && from >= to && ((absoluteFrame <= frameRange && speedRatio < 0) || (absoluteFrame >= 0 && speedRatio > 0))) {
|
|
467
|
+
returnValue = false;
|
|
468
|
+
highLimitValue = animation._getKeyValue(this._minValue);
|
|
469
|
+
}
|
|
470
|
+
else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
|
|
471
|
+
const keyOffset = to.toString() + from.toString();
|
|
472
|
+
if (!this._offsetsCache[keyOffset]) {
|
|
473
|
+
this._animationState.repeatCount = 0;
|
|
474
|
+
this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE; // force a specific codepath in animation._interpolate()!
|
|
475
|
+
const fromValue = animation._interpolate(from, this._animationState);
|
|
476
|
+
const toValue = animation._interpolate(to, this._animationState);
|
|
477
|
+
this._animationState.loopMode = this._getCorrectLoopMode();
|
|
478
|
+
switch (animation.dataType) {
|
|
479
|
+
// Float
|
|
480
|
+
case Animation.ANIMATIONTYPE_FLOAT:
|
|
481
|
+
this._offsetsCache[keyOffset] = toValue - fromValue;
|
|
482
|
+
break;
|
|
483
|
+
// Quaternion
|
|
484
|
+
case Animation.ANIMATIONTYPE_QUATERNION:
|
|
485
|
+
this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
|
|
486
|
+
break;
|
|
487
|
+
// Vector3
|
|
488
|
+
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
489
|
+
this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
|
|
490
|
+
break;
|
|
491
|
+
// Vector2
|
|
492
|
+
case Animation.ANIMATIONTYPE_VECTOR2:
|
|
493
|
+
this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
|
|
494
|
+
break;
|
|
495
|
+
// Size
|
|
496
|
+
case Animation.ANIMATIONTYPE_SIZE:
|
|
497
|
+
this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
|
|
498
|
+
break;
|
|
499
|
+
// Color3
|
|
500
|
+
case Animation.ANIMATIONTYPE_COLOR3:
|
|
501
|
+
this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
|
|
502
|
+
break;
|
|
503
|
+
default:
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
this._highLimitsCache[keyOffset] = toValue;
|
|
507
|
+
}
|
|
508
|
+
highLimitValue = this._highLimitsCache[keyOffset];
|
|
509
|
+
offsetValue = this._offsetsCache[keyOffset];
|
|
510
|
+
}
|
|
511
|
+
if (offsetValue === undefined) {
|
|
473
512
|
switch (animation.dataType) {
|
|
474
513
|
// Float
|
|
475
514
|
case Animation.ANIMATIONTYPE_FLOAT:
|
|
476
|
-
|
|
515
|
+
offsetValue = 0;
|
|
477
516
|
break;
|
|
478
517
|
// Quaternion
|
|
479
518
|
case Animation.ANIMATIONTYPE_QUATERNION:
|
|
480
|
-
|
|
519
|
+
offsetValue = _staticOffsetValueQuaternion;
|
|
481
520
|
break;
|
|
482
521
|
// Vector3
|
|
483
522
|
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
484
|
-
|
|
523
|
+
offsetValue = _staticOffsetValueVector3;
|
|
485
524
|
break;
|
|
486
525
|
// Vector2
|
|
487
526
|
case Animation.ANIMATIONTYPE_VECTOR2:
|
|
488
|
-
|
|
527
|
+
offsetValue = _staticOffsetValueVector2;
|
|
489
528
|
break;
|
|
490
529
|
// Size
|
|
491
530
|
case Animation.ANIMATIONTYPE_SIZE:
|
|
492
|
-
|
|
531
|
+
offsetValue = _staticOffsetValueSize;
|
|
493
532
|
break;
|
|
494
533
|
// Color3
|
|
495
534
|
case Animation.ANIMATIONTYPE_COLOR3:
|
|
496
|
-
|
|
535
|
+
offsetValue = _staticOffsetValueColor3;
|
|
497
536
|
break;
|
|
498
|
-
|
|
537
|
+
case Animation.ANIMATIONTYPE_COLOR4:
|
|
538
|
+
offsetValue = _staticOffsetValueColor4;
|
|
499
539
|
break;
|
|
500
540
|
}
|
|
501
|
-
this._highLimitsCache[keyOffset] = toValue;
|
|
502
|
-
}
|
|
503
|
-
highLimitValue = this._highLimitsCache[keyOffset];
|
|
504
|
-
offsetValue = this._offsetsCache[keyOffset];
|
|
505
|
-
}
|
|
506
|
-
if (offsetValue === undefined) {
|
|
507
|
-
switch (animation.dataType) {
|
|
508
|
-
// Float
|
|
509
|
-
case Animation.ANIMATIONTYPE_FLOAT:
|
|
510
|
-
offsetValue = 0;
|
|
511
|
-
break;
|
|
512
|
-
// Quaternion
|
|
513
|
-
case Animation.ANIMATIONTYPE_QUATERNION:
|
|
514
|
-
offsetValue = _staticOffsetValueQuaternion;
|
|
515
|
-
break;
|
|
516
|
-
// Vector3
|
|
517
|
-
case Animation.ANIMATIONTYPE_VECTOR3:
|
|
518
|
-
offsetValue = _staticOffsetValueVector3;
|
|
519
|
-
break;
|
|
520
|
-
// Vector2
|
|
521
|
-
case Animation.ANIMATIONTYPE_VECTOR2:
|
|
522
|
-
offsetValue = _staticOffsetValueVector2;
|
|
523
|
-
break;
|
|
524
|
-
// Size
|
|
525
|
-
case Animation.ANIMATIONTYPE_SIZE:
|
|
526
|
-
offsetValue = _staticOffsetValueSize;
|
|
527
|
-
break;
|
|
528
|
-
// Color3
|
|
529
|
-
case Animation.ANIMATIONTYPE_COLOR3:
|
|
530
|
-
offsetValue = _staticOffsetValueColor3;
|
|
531
|
-
break;
|
|
532
|
-
case Animation.ANIMATIONTYPE_COLOR4:
|
|
533
|
-
offsetValue = _staticOffsetValueColor4;
|
|
534
|
-
break;
|
|
535
541
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
const hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
|
|
543
|
-
currentFrame = from + frameRange * hostNormalizedFrame;
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
if ((absoluteFrame > 0 && from > to) || (absoluteFrame < 0 && from < to)) {
|
|
547
|
-
currentFrame = returnValue && frameRange !== 0 ? to + (absoluteFrame % frameRange) : from;
|
|
542
|
+
// Compute value
|
|
543
|
+
if (this._host && this._host.syncRoot) {
|
|
544
|
+
// If we must sync with an animatable, calculate the current frame based on the frame of the root animatable
|
|
545
|
+
const syncRoot = this._host.syncRoot;
|
|
546
|
+
const hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
|
|
547
|
+
currentFrame = from + frameRange * hostNormalizedFrame;
|
|
548
548
|
}
|
|
549
549
|
else {
|
|
550
|
-
|
|
550
|
+
if ((absoluteFrame > 0 && from > to) || (absoluteFrame < 0 && from < to)) {
|
|
551
|
+
currentFrame = returnValue && frameRange !== 0 ? to + (absoluteFrame % frameRange) : from;
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
currentFrame = returnValue && frameRange !== 0 ? from + (absoluteFrame % frameRange) : to;
|
|
555
|
+
}
|
|
551
556
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
events[index].isDone = false;
|
|
557
|
+
// Reset event/state if looping
|
|
558
|
+
if ((!yoyoMode && ((speedRatio > 0 && this.currentFrame > currentFrame) || (speedRatio < 0 && this.currentFrame < currentFrame))) || (yoyoMode && yoyoLoop)) {
|
|
559
|
+
this._onLoop();
|
|
560
|
+
// Need to reset animation events
|
|
561
|
+
for (let index = 0; index < events.length; index++) {
|
|
562
|
+
if (!events[index].onlyOnce) {
|
|
563
|
+
// reset event, the animation is looping
|
|
564
|
+
events[index].isDone = false;
|
|
565
|
+
}
|
|
562
566
|
}
|
|
567
|
+
this._animationState.key = speedRatio > 0 ? 0 : animation.getKeys().length - 1;
|
|
563
568
|
}
|
|
564
|
-
this.
|
|
569
|
+
this._currentFrame = currentFrame;
|
|
570
|
+
this._animationState.repeatCount = frameRange === 0 ? 0 : (absoluteFrame / frameRange) >> 0;
|
|
571
|
+
this._animationState.highLimitValue = highLimitValue;
|
|
572
|
+
this._animationState.offsetValue = offsetValue;
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
currentFrame = this._coreRuntimeAnimation.currentFrame;
|
|
576
|
+
this._currentFrame = currentFrame;
|
|
577
|
+
this._animationState.repeatCount = this._coreRuntimeAnimation._animationState.repeatCount;
|
|
578
|
+
this._animationState.highLimitValue = this._coreRuntimeAnimation._animationState.highLimitValue;
|
|
579
|
+
this._animationState.offsetValue = this._coreRuntimeAnimation._animationState.offsetValue;
|
|
565
580
|
}
|
|
566
|
-
this._currentFrame = currentFrame;
|
|
567
|
-
this._animationState.repeatCount = frameRange === 0 ? 0 : (absoluteFrame / frameRange) >> 0;
|
|
568
|
-
this._animationState.highLimitValue = highLimitValue;
|
|
569
|
-
this._animationState.offsetValue = offsetValue;
|
|
570
581
|
const currentValue = animation._interpolate(currentFrame, this._animationState);
|
|
571
582
|
// Set value
|
|
572
583
|
this.setValue(currentValue, weight);
|