@babylonjs/core 8.3.0 → 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.
Files changed (331) hide show
  1. package/Animations/animation.d.ts +4 -0
  2. package/Animations/animation.js +22 -13
  3. package/Animations/animation.js.map +1 -1
  4. package/Animations/animation.optimizations.d.ts +31 -0
  5. package/Animations/animation.optimizations.js +41 -0
  6. package/Animations/animation.optimizations.js.map +1 -0
  7. package/Animations/index.d.ts +1 -0
  8. package/Animations/index.js +1 -0
  9. package/Animations/index.js.map +1 -1
  10. package/Animations/pathCursor.js +3 -1
  11. package/Animations/pathCursor.js.map +1 -1
  12. package/Animations/runtimeAnimation.d.ts +3 -1
  13. package/Animations/runtimeAnimation.js +127 -116
  14. package/Animations/runtimeAnimation.js.map +1 -1
  15. package/Audio/audioSceneComponent.js +4 -4
  16. package/Audio/audioSceneComponent.js.map +1 -1
  17. package/Behaviors/Meshes/attachToBoxBehavior.js +6 -6
  18. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  19. package/Behaviors/Meshes/fadeInOutBehavior.js +3 -2
  20. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  21. package/Behaviors/Meshes/multiPointerScaleBehavior.js +6 -4
  22. package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
  23. package/Behaviors/Meshes/sixDofDragBehavior.js +3 -2
  24. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  25. package/Bones/skeleton.js +6 -6
  26. package/Bones/skeleton.js.map +1 -1
  27. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +2 -2
  28. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  29. package/Cameras/VR/vrExperienceHelper.js +2 -2
  30. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  31. package/Cameras/arcRotateCamera.js +6 -2
  32. package/Cameras/arcRotateCamera.js.map +1 -1
  33. package/Cameras/camera.js +2 -2
  34. package/Cameras/camera.js.map +1 -1
  35. package/Cameras/deviceOrientationCamera.js +3 -2
  36. package/Cameras/deviceOrientationCamera.js.map +1 -1
  37. package/Collisions/gpuPicker.d.ts +1 -0
  38. package/Collisions/gpuPicker.js +9 -0
  39. package/Collisions/gpuPicker.js.map +1 -1
  40. package/Debug/axesViewer.js +3 -2
  41. package/Debug/axesViewer.js.map +1 -1
  42. package/Debug/directionalLightFrustumViewer.js +4 -4
  43. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  44. package/Debug/physicsViewer.js +7 -6
  45. package/Debug/physicsViewer.js.map +1 -1
  46. package/Debug/skeletonViewer.js +4 -4
  47. package/Debug/skeletonViewer.js.map +1 -1
  48. package/Engines/Native/nativeInterfaces.d.ts +6 -7
  49. package/Engines/Native/nativeInterfaces.js.map +1 -1
  50. package/Engines/Processors/shaderCodeNode.js +2 -2
  51. package/Engines/Processors/shaderCodeNode.js.map +1 -1
  52. package/Engines/abstractEngine.d.ts +1 -0
  53. package/Engines/abstractEngine.js +14 -8
  54. package/Engines/abstractEngine.js.map +1 -1
  55. package/Engines/constants.d.ts +27 -5
  56. package/Engines/constants.js +27 -5
  57. package/Engines/constants.js.map +1 -1
  58. package/Engines/engine.js +8 -8
  59. package/Engines/engine.js.map +1 -1
  60. package/Engines/nativeEngine.js +13 -27
  61. package/Engines/nativeEngine.js.map +1 -1
  62. package/Engines/webgpuEngine.js +6 -2
  63. package/Engines/webgpuEngine.js.map +1 -1
  64. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +2 -2
  65. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
  66. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +3 -2
  67. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -1
  68. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +3 -2
  69. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +2 -2
  71. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -1
  72. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +3 -2
  73. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  74. package/FlowGraph/flowGraphAsyncExecutionBlock.js +5 -3
  75. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
  76. package/FlowGraph/flowGraphBlock.js +3 -2
  77. package/FlowGraph/flowGraphBlock.js.map +1 -1
  78. package/FlowGraph/flowGraphCoordinator.js +10 -6
  79. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  80. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
  81. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  82. package/FrameGraph/Node/nodeRenderGraphBlock.js +5 -4
  83. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  84. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +4 -3
  85. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  86. package/Gamepads/gamepadManager.js +2 -2
  87. package/Gamepads/gamepadManager.js.map +1 -1
  88. package/Gizmos/axisDragGizmo.js +3 -2
  89. package/Gizmos/axisDragGizmo.js.map +1 -1
  90. package/Gizmos/axisScaleGizmo.js +6 -4
  91. package/Gizmos/axisScaleGizmo.js.map +1 -1
  92. package/Gizmos/boundingBoxGizmo.js +28 -26
  93. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  94. package/Gizmos/cameraGizmo.js +6 -3
  95. package/Gizmos/cameraGizmo.js.map +1 -1
  96. package/Gizmos/gizmo.js +11 -10
  97. package/Gizmos/gizmo.js.map +1 -1
  98. package/Gizmos/gizmoManager.js +16 -12
  99. package/Gizmos/gizmoManager.js.map +1 -1
  100. package/Gizmos/lightGizmo.js +3 -2
  101. package/Gizmos/lightGizmo.js.map +1 -1
  102. package/Gizmos/planeDragGizmo.js +3 -2
  103. package/Gizmos/planeDragGizmo.js.map +1 -1
  104. package/Gizmos/planeRotationGizmo.js +3 -2
  105. package/Gizmos/planeRotationGizmo.js.map +1 -1
  106. package/Gizmos/positionGizmo.js +41 -28
  107. package/Gizmos/positionGizmo.js.map +1 -1
  108. package/Gizmos/rotationGizmo.js +26 -18
  109. package/Gizmos/rotationGizmo.js.map +1 -1
  110. package/Gizmos/scaleGizmo.js +47 -32
  111. package/Gizmos/scaleGizmo.js.map +1 -1
  112. package/Layers/effectLayerSceneComponent.js +4 -4
  113. package/Layers/effectLayerSceneComponent.js.map +1 -1
  114. package/Layers/layerSceneComponent.js +4 -4
  115. package/Layers/layerSceneComponent.js.map +1 -1
  116. package/LensFlares/lensFlareSystemSceneComponent.js +4 -4
  117. package/LensFlares/lensFlareSystemSceneComponent.js.map +1 -1
  118. package/Lights/Shadows/shadowGenerator.js +3 -3
  119. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  120. package/Lights/light.js +4 -4
  121. package/Lights/light.js.map +1 -1
  122. package/Loading/Plugins/babylonFileLoader.js +54 -46
  123. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  124. package/Loading/loadingScreen.js +4 -3
  125. package/Loading/loadingScreen.js.map +1 -1
  126. package/Loading/sceneLoader.js +15 -12
  127. package/Loading/sceneLoader.js.map +1 -1
  128. package/Materials/Node/Blocks/Dual/currentScreenBlock.js +9 -3
  129. package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
  130. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +11 -0
  131. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  132. package/Materials/Node/Blocks/Input/inputBlock.js +18 -31
  133. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  134. package/Materials/Node/Blocks/baseMathBlock.js +3 -1
  135. package/Materials/Node/Blocks/baseMathBlock.js.map +1 -1
  136. package/Materials/Node/Blocks/customBlock.js +53 -43
  137. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  138. package/Materials/Node/Enums/nodeMaterialModes.d.ts +3 -1
  139. package/Materials/Node/Enums/nodeMaterialModes.js +2 -0
  140. package/Materials/Node/Enums/nodeMaterialModes.js.map +1 -1
  141. package/Materials/Node/nodeMaterial.d.ts +5 -0
  142. package/Materials/Node/nodeMaterial.js +33 -20
  143. package/Materials/Node/nodeMaterial.js.map +1 -1
  144. package/Materials/Node/nodeMaterialBlock.js +7 -4
  145. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  146. package/Materials/Node/nodeMaterialBuildState.d.ts +13 -2
  147. package/Materials/Node/nodeMaterialBuildState.js +72 -7
  148. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  149. package/Materials/Node/nodeMaterialDefault.d.ts +5 -0
  150. package/Materials/Node/nodeMaterialDefault.js +28 -0
  151. package/Materials/Node/nodeMaterialDefault.js.map +1 -1
  152. package/Materials/Textures/cubeTexture.js +3 -1
  153. package/Materials/Textures/cubeTexture.js.map +1 -1
  154. package/Materials/Textures/videoTexture.js +5 -4
  155. package/Materials/Textures/videoTexture.js.map +1 -1
  156. package/Materials/materialDefines.js +3 -1
  157. package/Materials/materialDefines.js.map +1 -1
  158. package/Materials/multiMaterial.js +3 -1
  159. package/Materials/multiMaterial.js.map +1 -1
  160. package/Materials/shaderMaterial.js +3 -2
  161. package/Materials/shaderMaterial.js.map +1 -1
  162. package/Meshes/Compression/dracoEncoder.js +2 -2
  163. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  164. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +8 -8
  165. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  166. package/Meshes/GreasedLine/greasedLineMesh.js +6 -6
  167. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  168. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +4 -3
  169. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  170. package/Meshes/Node/Blocks/mathBlock.js +3 -1
  171. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  172. package/Meshes/Node/nodeGeometryBlock.js +8 -5
  173. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  174. package/Meshes/abstractMesh.js +2 -2
  175. package/Meshes/abstractMesh.js.map +1 -1
  176. package/Meshes/geodesicMesh.js +2 -2
  177. package/Meshes/geodesicMesh.js.map +1 -1
  178. package/Meshes/mesh.js +6 -6
  179. package/Meshes/mesh.js.map +1 -1
  180. package/Meshes/mesh.vertexData.functions.js +11 -10
  181. package/Meshes/mesh.vertexData.functions.js.map +1 -1
  182. package/Meshes/mesh.vertexData.subdivide.js +10 -10
  183. package/Meshes/mesh.vertexData.subdivide.js.map +1 -1
  184. package/Meshes/meshSimplification.js +10 -10
  185. package/Meshes/meshSimplification.js.map +1 -1
  186. package/Meshes/meshUtils.js +6 -3
  187. package/Meshes/meshUtils.js.map +1 -1
  188. package/Meshes/polygonMesh.js +10 -10
  189. package/Meshes/polygonMesh.js.map +1 -1
  190. package/Misc/PerformanceViewer/performanceViewerCollector.js +4 -4
  191. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  192. package/Misc/arrayTools.js +2 -2
  193. package/Misc/arrayTools.js.map +1 -1
  194. package/Misc/asyncLock.js +9 -9
  195. package/Misc/asyncLock.js.map +1 -1
  196. package/Misc/basis.js +4 -2
  197. package/Misc/basis.js.map +1 -1
  198. package/Misc/deepCopier.js +3 -2
  199. package/Misc/deepCopier.js.map +1 -1
  200. package/Misc/deepMerger.js +3 -2
  201. package/Misc/deepMerger.js.map +1 -1
  202. package/Misc/fileTools.js +4 -4
  203. package/Misc/fileTools.js.map +1 -1
  204. package/Misc/greasedLineTools.js +14 -13
  205. package/Misc/greasedLineTools.js.map +1 -1
  206. package/Misc/logger.js +3 -2
  207. package/Misc/logger.js.map +1 -1
  208. package/Misc/observable.extensions.js +4 -4
  209. package/Misc/observable.extensions.js.map +1 -1
  210. package/Misc/sceneSerializer.js +5 -4
  211. package/Misc/sceneSerializer.js.map +1 -1
  212. package/Misc/snapshotRenderingHelper.js +3 -1
  213. package/Misc/snapshotRenderingHelper.js.map +1 -1
  214. package/Misc/tags.js +2 -2
  215. package/Misc/tags.js.map +1 -1
  216. package/Misc/trajectoryClassifier.js +8 -8
  217. package/Misc/trajectoryClassifier.js.map +1 -1
  218. package/Particles/IParticleSystem.d.ts +1 -1
  219. package/Particles/IParticleSystem.js.map +1 -1
  220. package/Particles/baseParticleSystem.d.ts +11 -3
  221. package/Particles/baseParticleSystem.js +37 -3
  222. package/Particles/baseParticleSystem.js.map +1 -1
  223. package/Particles/gpuParticleSystem.js +1 -14
  224. package/Particles/gpuParticleSystem.js.map +1 -1
  225. package/Particles/particle.js +2 -2
  226. package/Particles/particle.js.map +1 -1
  227. package/Particles/particleSystem.js +15 -13
  228. package/Particles/particleSystem.js.map +1 -1
  229. package/Particles/thinParticleSystem.js +3 -16
  230. package/Particles/thinParticleSystem.js.map +1 -1
  231. package/Physics/physicsHelper.js +18 -14
  232. package/Physics/physicsHelper.js.map +1 -1
  233. package/Physics/v1/Plugins/ammoJSPlugin.js +10 -8
  234. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
  235. package/Physics/v1/Plugins/cannonJSPlugin.js +13 -8
  236. package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -1
  237. package/Physics/v1/Plugins/oimoJSPlugin.js +9 -8
  238. package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -1
  239. package/Physics/v1/physicsEngine.js +4 -4
  240. package/Physics/v1/physicsEngine.js.map +1 -1
  241. package/Physics/v1/physicsImpostor.js +10 -21
  242. package/Physics/v1/physicsImpostor.js.map +1 -1
  243. package/Physics/v2/Plugins/havokPlugin.js +12 -10
  244. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  245. package/Physics/v2/ragdoll.js +4 -4
  246. package/Physics/v2/ragdoll.js.map +1 -1
  247. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +3 -2
  248. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  249. package/PostProcesses/RenderPipeline/postProcessRenderEffect.js +8 -6
  250. package/PostProcesses/RenderPipeline/postProcessRenderEffect.js.map +1 -1
  251. package/PostProcesses/depthOfFieldMergePostProcess.js +4 -3
  252. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  253. package/Rendering/GlobalIllumination/giRSMManager.js +6 -6
  254. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  255. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +14 -14
  256. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  257. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +14 -12
  258. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  259. package/Rendering/iblCdfGenerator.js +4 -4
  260. package/Rendering/iblCdfGenerator.js.map +1 -1
  261. package/Rendering/objectRenderer.js +2 -2
  262. package/Rendering/objectRenderer.js.map +1 -1
  263. package/Rendering/reflectiveShadowMap.js +7 -5
  264. package/Rendering/reflectiveShadowMap.js.map +1 -1
  265. package/Sprites/spriteMap.js +2 -2
  266. package/Sprites/spriteMap.js.map +1 -1
  267. package/XR/features/WebXRAbstractFeature.js +2 -2
  268. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  269. package/XR/features/WebXRAnchorSystem.js +4 -4
  270. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  271. package/XR/features/WebXRBackgroundRemover.js +3 -1
  272. package/XR/features/WebXRBackgroundRemover.js.map +1 -1
  273. package/XR/features/WebXRControllerMovement.js +6 -3
  274. package/XR/features/WebXRControllerMovement.js.map +1 -1
  275. package/XR/features/WebXRControllerPhysics.js +12 -7
  276. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  277. package/XR/features/WebXRControllerPointerSelection.js +12 -7
  278. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  279. package/XR/features/WebXRControllerTeleportation.js +11 -7
  280. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  281. package/XR/features/WebXRDepthSensing.js +6 -6
  282. package/XR/features/WebXRDepthSensing.js.map +1 -1
  283. package/XR/features/WebXRHandTracking.js +60 -24
  284. package/XR/features/WebXRHandTracking.js.map +1 -1
  285. package/XR/features/WebXRHitTest.js +4 -4
  286. package/XR/features/WebXRHitTest.js.map +1 -1
  287. package/XR/features/WebXRImageTracking.js +2 -2
  288. package/XR/features/WebXRImageTracking.js.map +1 -1
  289. package/XR/features/WebXRLayers.js +2 -2
  290. package/XR/features/WebXRLayers.js.map +1 -1
  291. package/XR/features/WebXRNearInteraction.js +12 -7
  292. package/XR/features/WebXRNearInteraction.js.map +1 -1
  293. package/XR/features/WebXRRawCameraAccess.js +9 -4
  294. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  295. package/XR/features/WebXRSpaceWarp.js +2 -2
  296. package/XR/features/WebXRSpaceWarp.js.map +1 -1
  297. package/XR/motionController/webXRAbstractMotionController.js +19 -8
  298. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  299. package/XR/motionController/webXRGenericMotionController.js +2 -2
  300. package/XR/motionController/webXRGenericMotionController.js.map +1 -1
  301. package/XR/motionController/webXRHTCViveMotionController.js +5 -4
  302. package/XR/motionController/webXRHTCViveMotionController.js.map +1 -1
  303. package/XR/motionController/webXRMicrosoftMixedRealityController.js +9 -6
  304. package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
  305. package/XR/motionController/webXRMotionControllerManager.js +4 -4
  306. package/XR/motionController/webXRMotionControllerManager.js.map +1 -1
  307. package/XR/motionController/webXROculusTouchMotionController.js +5 -4
  308. package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
  309. package/XR/motionController/webXRProfiledMotionController.js +15 -10
  310. package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
  311. package/XR/webXRCamera.js +3 -2
  312. package/XR/webXRCamera.js.map +1 -1
  313. package/XR/webXREnterExitUI.js +5 -4
  314. package/XR/webXREnterExitUI.js.map +1 -1
  315. package/XR/webXRExperienceHelper.js +2 -2
  316. package/XR/webXRExperienceHelper.js.map +1 -1
  317. package/XR/webXRFeaturesManager.js +10 -7
  318. package/XR/webXRFeaturesManager.js.map +1 -1
  319. package/XR/webXRInput.js +8 -8
  320. package/XR/webXRInput.js.map +1 -1
  321. package/XR/webXRInputSource.js +4 -1
  322. package/XR/webXRInputSource.js.map +1 -1
  323. package/XR/webXRRenderTargetTextureProvider.js +3 -1
  324. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  325. package/assetContainer.js +156 -135
  326. package/assetContainer.js.map +1 -1
  327. package/node.js +2 -2
  328. package/node.js.map +1 -1
  329. package/package.json +1 -1
  330. package/scene.js +18 -11
  331. 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,CAAC,EAAE,CAAC;QAC3B,OAAO;IACX,CAAC;IAED,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAElC,iDAAiD;QACjD,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,sBAAsB,IAAI,cAAc,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzE,2DAA2D;QAC3D,MAAM,oBAAoB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChE,MAAM,gBAAgB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;YAC9D,gBAAgB,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;QAClE,CAAC;IACL,CAAC;IAED,IAAI,cAAc,IAAI,cAAc,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjE,yEAAyE;QACzE,MAAM,aAAa,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChE,MAAM,gBAAgB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;YAC9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC;YAC9C,SAAS,CAAC,cAAc,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"]}
@@ -10,3 +10,4 @@ export * from "./animationRange.js";
10
10
  export * from "./animatable.interface.js";
11
11
  export * from "./pathCursor.js";
12
12
  export * from "./animationGroupMask.js";
13
+ export * from "./animation.optimizations.js";
@@ -10,4 +10,5 @@ export * from "./animationRange.js";
10
10
  export * from "./animatable.interface.js";
11
11
  export * from "./pathCursor.js";
12
12
  export * from "./animationGroupMask.js";
13
+ export * from "./animation.optimizations.js";
13
14
  //# sourceMappingURL=index.js.map
@@ -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"]}
@@ -82,7 +82,9 @@ export class PathCursor {
82
82
  * @returns This path cursor
83
83
  */
84
84
  _raiseOnChange() {
85
- this._onchange.forEach((f) => f(this));
85
+ for (const f of this._onchange) {
86
+ f(this);
87
+ }
86
88
  return this;
87
89
  }
88
90
  /**
@@ -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,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,OAAe,KAAK;QACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEhB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,OAAe,KAAK;QAChC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAEjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,IAAI,CAAC,IAAY;QACpB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,4CAA4C;YAC5C,MAAM,kCAAkC,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QACnB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACK,aAAa;QACjB,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACK,cAAc;QAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvC,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 this._onchange.forEach((f) => f(this));\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"]}
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,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,OAAe,KAAK;QACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEhB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,OAAe,KAAK;QAChC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAEjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,IAAI,CAAC,IAAY;QACpB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,4CAA4C;YAC5C,MAAM,kCAAkC,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QACnB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACK,aAAa;QACjB,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;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
- private _animation;
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
- events.forEach((e) => {
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
- // Check limits
427
- if (from < this._minFrame || from > this._maxFrame) {
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
- let offsetValue;
435
- // Compute the frame according to the elapsed time and the fps of the animation ("from" and "to" are not factored in!)
436
- let absoluteFrame = (elapsedTimeSinceAnimationStart * (animation.framePerSecond * speedRatio)) / 1000.0 + this._absoluteFrameOffset;
437
- let highLimitValue = 0;
438
- // Apply the yoyo function if required
439
- let yoyoLoop = false;
440
- const yoyoMode = loop && this._animationState.loopMode === Animation.ANIMATIONLOOPMODE_YOYO;
441
- if (yoyoMode) {
442
- const position = (absoluteFrame - from) / frameRange;
443
- // Apply the yoyo curve
444
- const sin = Math.sin(position * Math.PI);
445
- const yoyoPosition = Math.abs(sin);
446
- // Map the yoyo position back to the range
447
- absoluteFrame = yoyoPosition * frameRange + from;
448
- const direction = sin >= 0 ? 1 : -1;
449
- if (this._yoyoDirection !== direction) {
450
- yoyoLoop = true;
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
- this._yoyoDirection = direction;
453
- }
454
- this._previousElapsedTime = elapsedTimeSinceAnimationStart;
455
- this._previousAbsoluteFrame = absoluteFrame;
456
- if (!loop && to >= from && ((absoluteFrame >= frameRange && speedRatio > 0) || (absoluteFrame <= 0 && speedRatio < 0))) {
457
- // If we are out of range and not looping get back to caller
458
- returnValue = false;
459
- highLimitValue = animation._getKeyValue(this._maxValue);
460
- }
461
- else if (!loop && from >= to && ((absoluteFrame <= frameRange && speedRatio < 0) || (absoluteFrame >= 0 && speedRatio > 0))) {
462
- returnValue = false;
463
- highLimitValue = animation._getKeyValue(this._minValue);
464
- }
465
- else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
466
- const keyOffset = to.toString() + from.toString();
467
- if (!this._offsetsCache[keyOffset]) {
468
- this._animationState.repeatCount = 0;
469
- this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE; // force a specific codepath in animation._interpolate()!
470
- const fromValue = animation._interpolate(from, this._animationState);
471
- const toValue = animation._interpolate(to, this._animationState);
472
- this._animationState.loopMode = this._getCorrectLoopMode();
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
- this._offsetsCache[keyOffset] = toValue - fromValue;
515
+ offsetValue = 0;
477
516
  break;
478
517
  // Quaternion
479
518
  case Animation.ANIMATIONTYPE_QUATERNION:
480
- this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
519
+ offsetValue = _staticOffsetValueQuaternion;
481
520
  break;
482
521
  // Vector3
483
522
  case Animation.ANIMATIONTYPE_VECTOR3:
484
- this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
523
+ offsetValue = _staticOffsetValueVector3;
485
524
  break;
486
525
  // Vector2
487
526
  case Animation.ANIMATIONTYPE_VECTOR2:
488
- this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
527
+ offsetValue = _staticOffsetValueVector2;
489
528
  break;
490
529
  // Size
491
530
  case Animation.ANIMATIONTYPE_SIZE:
492
- this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
531
+ offsetValue = _staticOffsetValueSize;
493
532
  break;
494
533
  // Color3
495
534
  case Animation.ANIMATIONTYPE_COLOR3:
496
- this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
535
+ offsetValue = _staticOffsetValueColor3;
497
536
  break;
498
- default:
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
- // Compute value
538
- let currentFrame;
539
- if (this._host && this._host.syncRoot) {
540
- // If we must sync with an animatable, calculate the current frame based on the frame of the root animatable
541
- const syncRoot = this._host.syncRoot;
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
- currentFrame = returnValue && frameRange !== 0 ? from + (absoluteFrame % frameRange) : to;
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
- const events = this._events;
554
- // Reset event/state if looping
555
- if ((!yoyoMode && ((speedRatio > 0 && this.currentFrame > currentFrame) || (speedRatio < 0 && this.currentFrame < currentFrame))) || (yoyoMode && yoyoLoop)) {
556
- this._onLoop();
557
- // Need to reset animation events
558
- for (let index = 0; index < events.length; index++) {
559
- if (!events[index].onlyOnce) {
560
- // reset event, the animation is looping
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._animationState.key = speedRatio > 0 ? 0 : animation.getKeys().length - 1;
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);