@luma.gl/engine 9.4.0-alpha.4 → 9.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -1
- package/dist/animation/animation-clip.d.ts +18 -0
- package/dist/animation/animation-clip.d.ts.map +1 -0
- package/dist/animation/animation-clip.js +15 -0
- package/dist/animation/animation-clip.js.map +1 -0
- package/dist/animation/animation-interpolation.d.ts +18 -0
- package/dist/animation/animation-interpolation.d.ts.map +1 -0
- package/dist/animation/animation-interpolation.js +101 -0
- package/dist/animation/animation-interpolation.js.map +1 -0
- package/dist/animation/animation-mixer.d.ts +88 -0
- package/dist/animation/animation-mixer.d.ts.map +1 -0
- package/dist/animation/animation-mixer.js +287 -0
- package/dist/animation/animation-mixer.js.map +1 -0
- package/dist/animation/animation-track.d.ts +42 -0
- package/dist/animation/animation-track.d.ts.map +1 -0
- package/dist/animation/animation-track.js +34 -0
- package/dist/animation/animation-track.js.map +1 -0
- package/dist/animation/animator.js +1 -1
- package/dist/animation/animator.js.map +1 -1
- package/dist/animation/key-frames.js +1 -1
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/morph-targets.d.ts +15 -0
- package/dist/animation/morph-targets.d.ts.map +1 -0
- package/dist/animation/morph-targets.js +151 -0
- package/dist/animation/morph-targets.js.map +1 -0
- package/dist/animation/skin.d.ts +18 -0
- package/dist/animation/skin.d.ts.map +1 -0
- package/dist/animation/skin.js +30 -0
- package/dist/animation/skin.js.map +1 -0
- package/dist/animation/timeline.js +1 -1
- package/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop-template.js +1 -1
- package/dist/animation-loop/animation-loop-template.js.map +1 -1
- package/dist/animation-loop/animation-loop.d.ts +5 -4
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +3 -3
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.d.ts +1 -1
- package/dist/animation-loop/animation-props.js +1 -1
- package/dist/animation-loop/animation-props.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +6 -3
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/animation-loop/request-animation-frame.js +1 -1
- package/dist/animation-loop/request-animation-frame.js.map +1 -1
- package/dist/application-utils/load-file.js +1 -1
- package/dist/application-utils/load-file.js.map +1 -1
- package/dist/application-utils/random.js +1 -1
- package/dist/application-utils/random.js.map +1 -1
- package/dist/compute/buffer-transform.d.ts +1 -1
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +1 -1
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.d.ts +1 -1
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +11 -6
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.js +1 -1
- package/dist/compute/swap.js.map +1 -1
- package/dist/compute/texture-transform.js +1 -1
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/controls/orbit-controls.d.ts +61 -0
- package/dist/controls/orbit-controls.d.ts.map +1 -0
- package/dist/controls/orbit-controls.js +179 -0
- package/dist/controls/orbit-controls.js.map +1 -0
- package/dist/debug/copy-texture-to-image.js +1 -1
- package/dist/debug/copy-texture-to-image.js.map +1 -1
- package/dist/debug/debug-framebuffer.js +1 -1
- package/dist/debug/debug-framebuffer.js.map +1 -1
- package/dist/debug/debug-shader-layout.js +1 -1
- package/dist/debug/debug-shader-layout.js.map +1 -1
- package/dist/debug/pixel-data-utils.js +1 -1
- package/dist/debug/pixel-data-utils.js.map +1 -1
- package/dist/dist.dev.js +7588 -6260
- package/dist/dist.min.js +31 -31
- package/dist/dynamic-buffer/dynamic-buffer.js +1 -1
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +3 -2
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.js +1 -1
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
- package/dist/dynamic-texture/texture-data.js +1 -1
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.js +1 -1
- package/dist/dynamic-texture/video-texture.js.map +1 -1
- package/dist/geometries/cone-geometry.js +1 -1
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.js +1 -1
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.js +1 -1
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +1 -1
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.js +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.js +1 -1
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.js +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.js +1 -1
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/geometry/mesh-simplification.d.ts +29 -0
- package/dist/geometry/mesh-simplification.d.ts.map +1 -0
- package/dist/geometry/mesh-simplification.js +402 -0
- package/dist/geometry/mesh-simplification.js.map +1 -0
- package/dist/index.cjs +9858 -1420
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/material/material-factory.js +1 -1
- package/dist/material/material-factory.js.map +1 -1
- package/dist/material/material.js +1 -1
- package/dist/material/material.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +35 -10
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +1 -1
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.js +1 -1
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/billboard-texture-module.js +1 -1
- package/dist/models/billboard-texture-module.js.map +1 -1
- package/dist/models/clip-space.js +1 -1
- package/dist/models/clip-space.js.map +1 -1
- package/dist/models/directional-light-model.js +1 -1
- package/dist/models/directional-light-model.js.map +1 -1
- package/dist/models/light-model-utils.js +1 -1
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/models/point-light-model.js +1 -1
- package/dist/models/point-light-model.js.map +1 -1
- package/dist/models/spot-light-model.js +1 -1
- package/dist/models/spot-light-model.js.map +1 -1
- package/dist/modules/picking/color-picking.js +1 -1
- package/dist/modules/picking/color-picking.js.map +1 -1
- package/dist/modules/picking/index-color-picking.js +1 -1
- package/dist/modules/picking/index-color-picking.js.map +1 -1
- package/dist/modules/picking/index-picking.js +1 -1
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/modules/picking/legacy-color-picking.js +1 -1
- package/dist/modules/picking/legacy-color-picking.js.map +1 -1
- package/dist/modules/picking/legacy-picking-manager.js +1 -1
- package/dist/modules/picking/legacy-picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-manager.js +1 -1
- package/dist/modules/picking/picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-uniforms.js +1 -1
- package/dist/modules/picking/picking-uniforms.js.map +1 -1
- package/dist/modules/picking/picking.js +1 -1
- package/dist/modules/picking/picking.js.map +1 -1
- package/dist/passes/get-fragment-shader.js +1 -1
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +19 -1
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +180 -11
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.js +1 -1
- package/dist/passes/texture-transform-module.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +7 -1
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.js +1 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-bounds.js +1 -1
- package/dist/scenegraph/scenegraph-bounds.js.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +4 -4
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/shader-inputs.js +1 -1
- package/dist/shader-inputs.js.map +1 -1
- package/dist/utils/buffer-layout-helper.js +1 -1
- package/dist/utils/buffer-layout-helper.js.map +1 -1
- package/dist/utils/buffer-layout-order.js +1 -1
- package/dist/utils/buffer-layout-order.js.map +1 -1
- package/dist/utils/deep-equal.js +1 -1
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/shader-module-utils.js +1 -1
- package/dist/utils/shader-module-utils.js.map +1 -1
- package/dist/utils/uid.js +1 -1
- package/dist/utils/uid.js.map +1 -1
- package/package.json +2 -2
- package/src/animation/animation-clip.ts +28 -0
- package/src/animation/animation-interpolation.ts +175 -0
- package/src/animation/animation-mixer.ts +370 -0
- package/src/animation/animation-track.ts +70 -0
- package/src/animation/animator.ts +1 -1
- package/src/animation/key-frames.ts +1 -1
- package/src/animation/morph-targets.ts +191 -0
- package/src/animation/skin.ts +50 -0
- package/src/animation/timeline.ts +1 -1
- package/src/animation-loop/animation-loop-template.ts +1 -1
- package/src/animation-loop/animation-loop.ts +8 -7
- package/src/animation-loop/animation-props.ts +2 -2
- package/src/animation-loop/make-animation-loop.ts +8 -5
- package/src/animation-loop/request-animation-frame.ts +1 -1
- package/src/application-utils/load-file.ts +1 -1
- package/src/application-utils/random.ts +1 -1
- package/src/compute/buffer-transform.ts +2 -2
- package/src/compute/computation.ts +22 -8
- package/src/compute/swap.ts +1 -1
- package/src/compute/texture-transform.ts +1 -1
- package/src/controls/orbit-controls.ts +248 -0
- package/src/debug/copy-texture-to-image.ts +1 -1
- package/src/debug/debug-framebuffer.ts +1 -1
- package/src/debug/debug-shader-layout.ts +1 -1
- package/src/debug/pixel-data-utils.ts +1 -1
- package/src/dynamic-buffer/dynamic-buffer.ts +1 -1
- package/src/dynamic-texture/dynamic-texture.ts +3 -2
- package/src/dynamic-texture/texture-binding-source.ts +1 -1
- package/src/dynamic-texture/texture-data.ts +1 -1
- package/src/dynamic-texture/video-texture.ts +1 -1
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +1 -1
- package/src/geometries/cylinder-geometry.ts +1 -1
- package/src/geometries/ico-sphere-geometry.ts +1 -1
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +1 -1
- package/src/geometry/geometry.ts +1 -1
- package/src/geometry/gpu-geometry.ts +1 -1
- package/src/geometry/mesh-simplification.ts +554 -0
- package/src/index.ts +31 -1
- package/src/material/material-factory.ts +1 -1
- package/src/material/material.ts +1 -1
- package/src/model/model.ts +67 -12
- package/src/model/split-uniforms-and-bindings.ts +1 -1
- package/src/models/billboard-texture-model.ts +1 -1
- package/src/models/billboard-texture-module.ts +1 -1
- package/src/models/clip-space.ts +1 -1
- package/src/models/directional-light-model.ts +1 -1
- package/src/models/light-model-utils.ts +1 -1
- package/src/models/point-light-model.ts +1 -1
- package/src/models/spot-light-model.ts +1 -1
- package/src/modules/picking/color-picking.ts +1 -1
- package/src/modules/picking/index-color-picking.ts +1 -1
- package/src/modules/picking/index-picking.ts +1 -1
- package/src/modules/picking/legacy-color-picking.ts +1 -1
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/modules/picking/picking.ts +1 -1
- package/src/passes/get-fragment-shader.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +246 -14
- package/src/passes/texture-transform-module.ts +1 -1
- package/src/scenegraph/group-node.ts +8 -1
- package/src/scenegraph/model-node.ts +1 -1
- package/src/scenegraph/scenegraph-bounds.ts +1 -1
- package/src/scenegraph/scenegraph-node.ts +4 -4
- package/src/shader-inputs.ts +1 -1
- package/src/utils/buffer-layout-helper.ts +1 -1
- package/src/utils/buffer-layout-order.ts +1 -1
- package/src/utils/deep-equal.ts +1 -1
- package/src/utils/shader-module-utils.ts +1 -1
- package/src/utils/uid.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-layout-order.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"buffer-layout-order.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAG9B,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,yCAAyC,CACvD,YAA0B,EAC1B,YAA4B;IAE5B,MAAM,eAAe,GAAG,6BAA6B,CAAC,YAAY,CAAC,CAAC;IAEpE,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1C,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,MAAM,YAAY,GAAG,2BAA2B,CAC9C,6BAA6B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CACtF,CAAC;QACF,MAAM,YAAY,GAAG,2BAA2B,CAC9C,6BAA6B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CACtF,CAAC;QAEF,OAAO,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/utils/deep-equal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-equal.js","sourceRoot":"","sources":["../../src/utils/deep-equal.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"deep-equal.js","sourceRoot":"","sources":["../../src/utils/deep-equal.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D;;;;;;GAMG;AACH,+BAA+B;AAC/B,MAAM,UAAU,SAAS,CAAC,CAAM,EAAE,CAAM,EAAE,KAAa;IACrD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/C,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;gBACtC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1C,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
export function mergeShaderModuleBindingsIntoLayout(shaderLayout, modules) {
|
|
5
5
|
if (!shaderLayout || !modules.some(module => module.bindingLayout?.length)) {
|
|
6
6
|
return shaderLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module-utils.js","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"shader-module-utils.js","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAO5D,MAAM,UAAU,mCAAmC,CACjD,YAA8C,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BAAuB,iBAAiB,CAAC,QAAQ,EAAE,CACjI,CAAC;QACJ,CAAC;QAED,gBAAgB,CAAC,IAAI,CAAC,EAAC,GAAG,iBAAiB,EAAC,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
package/dist/utils/uid.js
CHANGED
package/dist/utils/uid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uid.js","sourceRoot":"","sources":["../../src/utils/uid.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"uid.js","sourceRoot":"","sources":["../../src/utils/uid.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,MAAM,WAAW,GAA2B,EAAE,CAAC;AAE/C;;;;IAII;AACJ,MAAM,UAAU,GAAG,CAAC,KAAa,IAAI;IACnC,WAAW,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;IAChC,OAAO,GAAG,EAAE,IAAI,KAAK,EAAE,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.4.0-
|
|
3
|
+
"version": "9.4.0-beta.2",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@probe.gl/log": "^4.1.1",
|
|
50
50
|
"@probe.gl/stats": "^4.1.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "e337f045355c2416fd2066bf7c4144ac7f891c1f"
|
|
53
53
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {AnimationTrack} from './animation-track';
|
|
6
|
+
|
|
7
|
+
/** Construction properties for a named, reusable animation clip. */
|
|
8
|
+
export type AnimationClipProps = {
|
|
9
|
+
/** Application-visible clip name. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Tracks evaluated together whenever this clip plays. */
|
|
12
|
+
tracks: AnimationTrack[];
|
|
13
|
+
/** Optional explicit clip duration, in seconds. */
|
|
14
|
+
duration?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** A named set of target-bound animation tracks. */
|
|
18
|
+
export class AnimationClip {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly tracks: AnimationTrack[];
|
|
21
|
+
readonly duration: number;
|
|
22
|
+
|
|
23
|
+
constructor(props: AnimationClipProps) {
|
|
24
|
+
this.name = props.name || 'unnamed';
|
|
25
|
+
this.tracks = props.tracks;
|
|
26
|
+
this.duration = props.duration ?? Math.max(0, ...props.tracks.map(track => track.duration));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** Interpolation modes shared by animation formats and engine tracks. */
|
|
6
|
+
export type AnimationInterpolation = 'STEP' | 'LINEAR' | 'CUBICSPLINE';
|
|
7
|
+
|
|
8
|
+
/** Value interpretation used for interpolation and weighted blending. */
|
|
9
|
+
export type AnimationValueType = 'vector' | 'quaternion';
|
|
10
|
+
|
|
11
|
+
/** Keyframe times and values in the glTF-compatible animation sampler layout. */
|
|
12
|
+
export type AnimationSampler = {
|
|
13
|
+
/** Keyframe times, in seconds. */
|
|
14
|
+
input: readonly number[];
|
|
15
|
+
/** One value per keyframe, or in-tangent/value/out-tangent triples for cubic splines. */
|
|
16
|
+
output: readonly (readonly number[])[];
|
|
17
|
+
/** Keyframe interpolation mode. */
|
|
18
|
+
interpolation?: AnimationInterpolation | string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Samples keyframes without applying playback loops or modifying the supplied values. */
|
|
22
|
+
export function evaluateAnimationSampler(
|
|
23
|
+
time: number,
|
|
24
|
+
sampler: AnimationSampler,
|
|
25
|
+
valueType: AnimationValueType = 'vector'
|
|
26
|
+
): number[] | null {
|
|
27
|
+
const {input, output, interpolation = 'LINEAR'} = sampler;
|
|
28
|
+
if (!input.length || !output.length || !Number.isFinite(time)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const lastIndex = input.length - 1;
|
|
33
|
+
if (time <= input[0] || lastIndex === 0) {
|
|
34
|
+
return getKeyframeValue(output, interpolation, 0, valueType);
|
|
35
|
+
}
|
|
36
|
+
if (time >= input[lastIndex]) {
|
|
37
|
+
return getKeyframeValue(output, interpolation, lastIndex, valueType);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let previousIndex = 0;
|
|
41
|
+
let nextIndex = lastIndex;
|
|
42
|
+
while (nextIndex - previousIndex > 1) {
|
|
43
|
+
const middleIndex = Math.floor((previousIndex + nextIndex) / 2);
|
|
44
|
+
if (input[middleIndex] <= time) {
|
|
45
|
+
previousIndex = middleIndex;
|
|
46
|
+
} else {
|
|
47
|
+
nextIndex = middleIndex;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const previousTime = input[previousIndex];
|
|
52
|
+
const nextTime = input[nextIndex];
|
|
53
|
+
const interval = nextTime - previousTime;
|
|
54
|
+
if (interval <= 0 || interpolation === 'STEP') {
|
|
55
|
+
return getKeyframeValue(output, interpolation, previousIndex, valueType);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ratio = (time - previousTime) / interval;
|
|
59
|
+
switch (interpolation) {
|
|
60
|
+
case 'LINEAR': {
|
|
61
|
+
const previousValue = output[previousIndex];
|
|
62
|
+
const nextValue = output[nextIndex];
|
|
63
|
+
if (!previousValue || !nextValue) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return valueType === 'quaternion'
|
|
67
|
+
? interpolateQuaternion(previousValue, nextValue, ratio)
|
|
68
|
+
: interpolateVector(previousValue, nextValue, ratio);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
case 'CUBICSPLINE': {
|
|
72
|
+
const previousValue = output[previousIndex * 3 + 1];
|
|
73
|
+
const previousOutTangent = output[previousIndex * 3 + 2];
|
|
74
|
+
const nextInTangent = output[nextIndex * 3];
|
|
75
|
+
const nextValue = output[nextIndex * 3 + 1];
|
|
76
|
+
if (!previousValue || !previousOutTangent || !nextInTangent || !nextValue) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const interpolatedValue = interpolateCubicSpline(
|
|
81
|
+
previousValue,
|
|
82
|
+
previousOutTangent,
|
|
83
|
+
nextInTangent,
|
|
84
|
+
nextValue,
|
|
85
|
+
interval,
|
|
86
|
+
ratio
|
|
87
|
+
);
|
|
88
|
+
return valueType === 'quaternion'
|
|
89
|
+
? normalizeQuaternion(interpolatedValue)
|
|
90
|
+
: interpolatedValue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
default:
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Interpolates quaternions on their shortest spherical arc. */
|
|
99
|
+
export function interpolateQuaternion(
|
|
100
|
+
start: readonly number[],
|
|
101
|
+
end: readonly number[],
|
|
102
|
+
ratio: number
|
|
103
|
+
): number[] {
|
|
104
|
+
const normalizedStart = normalizeQuaternion(start);
|
|
105
|
+
const normalizedEnd = normalizeQuaternion(end);
|
|
106
|
+
let dotProduct = normalizedStart.reduce(
|
|
107
|
+
(sum, component, index) => sum + component * normalizedEnd[index],
|
|
108
|
+
0
|
|
109
|
+
);
|
|
110
|
+
const endDirection = dotProduct < 0 ? -1 : 1;
|
|
111
|
+
dotProduct = Math.min(Math.abs(dotProduct), 1);
|
|
112
|
+
|
|
113
|
+
if (dotProduct > 0.9995) {
|
|
114
|
+
return normalizeQuaternion(
|
|
115
|
+
normalizedStart.map(
|
|
116
|
+
(component, index) => component + ratio * (normalizedEnd[index] * endDirection - component)
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const angle = Math.acos(dotProduct);
|
|
122
|
+
const sineAngle = Math.sin(angle);
|
|
123
|
+
const startWeight = Math.sin((1 - ratio) * angle) / sineAngle;
|
|
124
|
+
const endWeight = (Math.sin(ratio * angle) / sineAngle) * endDirection;
|
|
125
|
+
return normalizeQuaternion(
|
|
126
|
+
normalizedStart.map(
|
|
127
|
+
(component, index) => component * startWeight + normalizedEnd[index] * endWeight
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function getKeyframeValue(
|
|
133
|
+
output: readonly (readonly number[])[],
|
|
134
|
+
interpolation: string,
|
|
135
|
+
index: number,
|
|
136
|
+
valueType: AnimationValueType
|
|
137
|
+
): number[] | null {
|
|
138
|
+
const value = output[interpolation === 'CUBICSPLINE' ? index * 3 + 1 : index];
|
|
139
|
+
if (!value) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return valueType === 'quaternion' ? normalizeQuaternion(value) : [...value];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function interpolateVector(
|
|
146
|
+
start: readonly number[],
|
|
147
|
+
end: readonly number[],
|
|
148
|
+
ratio: number
|
|
149
|
+
): number[] {
|
|
150
|
+
return start.map((component, index) => (1 - ratio) * component + ratio * end[index]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function interpolateCubicSpline(
|
|
154
|
+
previousValue: readonly number[],
|
|
155
|
+
previousOutTangent: readonly number[],
|
|
156
|
+
nextInTangent: readonly number[],
|
|
157
|
+
nextValue: readonly number[],
|
|
158
|
+
interval: number,
|
|
159
|
+
ratio: number
|
|
160
|
+
): number[] {
|
|
161
|
+
const squaredRatio = ratio * ratio;
|
|
162
|
+
const cubedRatio = squaredRatio * ratio;
|
|
163
|
+
return previousValue.map(
|
|
164
|
+
(component, index) =>
|
|
165
|
+
(2 * cubedRatio - 3 * squaredRatio + 1) * component +
|
|
166
|
+
(cubedRatio - 2 * squaredRatio + ratio) * previousOutTangent[index] * interval +
|
|
167
|
+
(-2 * cubedRatio + 3 * squaredRatio) * nextValue[index] +
|
|
168
|
+
(cubedRatio - squaredRatio) * nextInTangent[index] * interval
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function normalizeQuaternion(value: readonly number[]): number[] {
|
|
173
|
+
const length = Math.hypot(...value);
|
|
174
|
+
return length > 0 ? value.map(component => component / length) : [0, 0, 0, 1];
|
|
175
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {AnimationClip} from './animation-clip';
|
|
6
|
+
import {type AnimationValueType, interpolateQuaternion} from './animation-interpolation';
|
|
7
|
+
import type {AnimationBinding} from './animation-track';
|
|
8
|
+
|
|
9
|
+
/** Supported clip playback loop modes. */
|
|
10
|
+
export type AnimationLoopMode = 'once' | 'repeat' | 'ping-pong';
|
|
11
|
+
|
|
12
|
+
/** Optional initial playback properties for a clip action. */
|
|
13
|
+
export type AnimationActionProps = {
|
|
14
|
+
/** Playback loop behavior. */
|
|
15
|
+
loop?: AnimationLoopMode;
|
|
16
|
+
/** Number of playback traversals before a repeating action finishes. */
|
|
17
|
+
repetitions?: number;
|
|
18
|
+
/** Playback speed and direction. */
|
|
19
|
+
timeScale?: number;
|
|
20
|
+
/** Blend contribution relative to other actions. */
|
|
21
|
+
weight?: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type AnimationFade = {
|
|
25
|
+
duration: number;
|
|
26
|
+
elapsedTime: number;
|
|
27
|
+
startWeight: number;
|
|
28
|
+
endWeight: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type AccumulatedAnimationValue = {
|
|
32
|
+
binding: AnimationBinding;
|
|
33
|
+
value: number[];
|
|
34
|
+
valueType: AnimationValueType;
|
|
35
|
+
weight: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Playback state and blend influence for a single animation clip. */
|
|
39
|
+
export class AnimationAction {
|
|
40
|
+
readonly clip: AnimationClip;
|
|
41
|
+
readonly mixer: AnimationMixer;
|
|
42
|
+
time: number = 0;
|
|
43
|
+
timeScale: number;
|
|
44
|
+
weight: number;
|
|
45
|
+
loop: AnimationLoopMode;
|
|
46
|
+
repetitions: number;
|
|
47
|
+
paused: boolean = false;
|
|
48
|
+
playing: boolean = false;
|
|
49
|
+
|
|
50
|
+
private elapsedTime: number = 0;
|
|
51
|
+
private fade: AnimationFade | null = null;
|
|
52
|
+
|
|
53
|
+
constructor(mixer: AnimationMixer, clip: AnimationClip, props: AnimationActionProps = {}) {
|
|
54
|
+
this.mixer = mixer;
|
|
55
|
+
this.clip = clip;
|
|
56
|
+
this.loop = props.loop || 'repeat';
|
|
57
|
+
this.repetitions = props.repetitions ?? Number.POSITIVE_INFINITY;
|
|
58
|
+
this.timeScale = props.timeScale ?? 1;
|
|
59
|
+
this.weight = props.weight ?? 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Starts or resumes playback. */
|
|
63
|
+
play(): this {
|
|
64
|
+
this.playing = true;
|
|
65
|
+
this.paused = false;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Temporarily suspends playback while preserving local time. */
|
|
70
|
+
pause(): this {
|
|
71
|
+
this.paused = true;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Continues playback after pausing. */
|
|
76
|
+
resume(): this {
|
|
77
|
+
this.playing = true;
|
|
78
|
+
this.paused = false;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Stops playback and restores the initial clip time. */
|
|
83
|
+
stop(): this {
|
|
84
|
+
this.playing = false;
|
|
85
|
+
this.paused = false;
|
|
86
|
+
this.fade = null;
|
|
87
|
+
return this.reset();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Restores the initial clip time without changing playback state. */
|
|
91
|
+
reset(): this {
|
|
92
|
+
this.elapsedTime = 0;
|
|
93
|
+
this.time = 0;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Seeks to the supplied elapsed clip time, in seconds. */
|
|
98
|
+
setTime(time: number): this {
|
|
99
|
+
this.elapsedTime = time;
|
|
100
|
+
this.time = this.resolveLocalTime(time);
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Selects playback loop behavior and an optional traversal count. */
|
|
105
|
+
setLoop(loop: AnimationLoopMode, repetitions: number = Number.POSITIVE_INFINITY): this {
|
|
106
|
+
this.loop = loop;
|
|
107
|
+
this.repetitions = repetitions;
|
|
108
|
+
this.time = this.resolveLocalTime(this.elapsedTime);
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Sets the action's blend contribution. */
|
|
113
|
+
setEffectiveWeight(weight: number): this {
|
|
114
|
+
this.weight = Math.max(0, weight);
|
|
115
|
+
this.fade = null;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Sets the action's playback speed and direction. */
|
|
120
|
+
setEffectiveTimeScale(timeScale: number): this {
|
|
121
|
+
this.timeScale = timeScale;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Fades this action's current weight to full influence. */
|
|
126
|
+
fadeIn(duration: number): this {
|
|
127
|
+
return this.scheduleFade(1, duration);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Fades this action's current weight to zero influence. */
|
|
131
|
+
fadeOut(duration: number): this {
|
|
132
|
+
return this.scheduleFade(0, duration);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Fades this action out while another action fades in. */
|
|
136
|
+
crossFadeTo(action: AnimationAction, duration: number): this {
|
|
137
|
+
action.weight = 0;
|
|
138
|
+
action.play().fadeIn(duration);
|
|
139
|
+
return this.fadeOut(duration);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Fades another action out while this action fades in. */
|
|
143
|
+
crossFadeFrom(action: AnimationAction, duration: number): this {
|
|
144
|
+
action.crossFadeTo(this, duration);
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** @internal Advances playback and pending fades by mixer-relative seconds. */
|
|
149
|
+
advance(deltaTime: number): void {
|
|
150
|
+
if (!this.playing || this.paused) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.advanceFade(Math.abs(deltaTime));
|
|
155
|
+
this.elapsedTime += deltaTime * this.timeScale;
|
|
156
|
+
this.time = this.resolveLocalTime(this.elapsedTime);
|
|
157
|
+
if (this.hasFinished()) {
|
|
158
|
+
this.playing = false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** @internal Whether this action should contribute its current sampled value. */
|
|
163
|
+
get shouldApply(): boolean {
|
|
164
|
+
return (this.playing || this.hasFinished()) && this.weight > 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private scheduleFade(endWeight: number, duration: number): this {
|
|
168
|
+
if (duration <= 0) {
|
|
169
|
+
this.weight = endWeight;
|
|
170
|
+
this.fade = null;
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
this.fade = {duration, elapsedTime: 0, startWeight: this.weight, endWeight};
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private advanceFade(deltaTime: number): void {
|
|
178
|
+
if (!this.fade) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.fade.elapsedTime += deltaTime;
|
|
182
|
+
const ratio = Math.min(this.fade.elapsedTime / this.fade.duration, 1);
|
|
183
|
+
this.weight = this.fade.startWeight + (this.fade.endWeight - this.fade.startWeight) * ratio;
|
|
184
|
+
if (ratio === 1) {
|
|
185
|
+
this.fade = null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private hasFinished(): boolean {
|
|
190
|
+
const duration = this.clip.duration;
|
|
191
|
+
if (duration <= 0) {
|
|
192
|
+
return this.loop === 'once';
|
|
193
|
+
}
|
|
194
|
+
if (this.loop === 'once') {
|
|
195
|
+
return this.elapsedTime >= duration || this.elapsedTime < 0;
|
|
196
|
+
}
|
|
197
|
+
return (
|
|
198
|
+
Number.isFinite(this.repetitions) && Math.abs(this.elapsedTime) >= duration * this.repetitions
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private resolveLocalTime(elapsedTime: number): number {
|
|
203
|
+
const duration = this.clip.duration;
|
|
204
|
+
if (duration <= 0) {
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (this.loop === 'once') {
|
|
209
|
+
return Math.min(Math.max(elapsedTime, 0), duration);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (Number.isFinite(this.repetitions) && Math.abs(elapsedTime) >= duration * this.repetitions) {
|
|
213
|
+
if (this.loop === 'ping-pong' && this.repetitions % 2 === 0) {
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
return elapsedTime < 0 ? 0 : duration;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const wrappedTime =
|
|
220
|
+
elapsedTime >= 0 && elapsedTime < duration
|
|
221
|
+
? elapsedTime
|
|
222
|
+
: ((elapsedTime % duration) + duration) % duration;
|
|
223
|
+
if (this.loop === 'repeat') {
|
|
224
|
+
return wrappedTime;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const traversal = Math.floor(elapsedTime / duration);
|
|
228
|
+
return Math.abs(traversal % 2) === 0 ? wrappedTime : duration - wrappedTime;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Coordinates reusable clip playback and blends tracks that share a target binding. */
|
|
233
|
+
export class AnimationMixer {
|
|
234
|
+
time: number = 0;
|
|
235
|
+
timeScale: number = 1;
|
|
236
|
+
|
|
237
|
+
private readonly clips = new Map<string, AnimationClip>();
|
|
238
|
+
private readonly actions = new Map<AnimationClip, AnimationAction>();
|
|
239
|
+
private readonly initialValues = new Map<string | AnimationBinding, number[]>();
|
|
240
|
+
|
|
241
|
+
constructor(clips: AnimationClip[] = []) {
|
|
242
|
+
clips.forEach(clip => this.addClip(clip));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Makes a named clip available for playback. */
|
|
246
|
+
addClip(clip: AnimationClip): this {
|
|
247
|
+
this.clips.set(clip.name, clip);
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Returns the cached playback action for a clip or registered clip name. */
|
|
252
|
+
clipAction(clip: AnimationClip | string, props?: AnimationActionProps): AnimationAction {
|
|
253
|
+
const resolvedClip = typeof clip === 'string' ? this.clips.get(clip) : clip;
|
|
254
|
+
if (!resolvedClip) {
|
|
255
|
+
throw new Error(`Unknown animation clip: ${clip}`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
this.addClip(resolvedClip);
|
|
259
|
+
let action = this.actions.get(resolvedClip);
|
|
260
|
+
if (!action) {
|
|
261
|
+
action = new AnimationAction(this, resolvedClip, props);
|
|
262
|
+
this.actions.set(resolvedClip, action);
|
|
263
|
+
}
|
|
264
|
+
return action;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** Returns a previously created named action, if present. */
|
|
268
|
+
getAction(name: string): AnimationAction | undefined {
|
|
269
|
+
const clip = this.clips.get(name);
|
|
270
|
+
return clip ? this.actions.get(clip) : undefined;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Advances playback by seconds, then applies blended animation values. */
|
|
274
|
+
update(deltaTime: number): this {
|
|
275
|
+
this.advance(deltaTime);
|
|
276
|
+
this.applyValues();
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Advances action clocks and crossfades without evaluating CPU-side animation tracks. */
|
|
281
|
+
advance(deltaTime: number): this {
|
|
282
|
+
const scaledDeltaTime = deltaTime * this.timeScale;
|
|
283
|
+
this.time += scaledDeltaTime;
|
|
284
|
+
this.actions.forEach(action => action.advance(scaledDeltaTime));
|
|
285
|
+
return this;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Seeks every action to an absolute mixer time, in seconds. */
|
|
289
|
+
setTime(time: number): this {
|
|
290
|
+
this.time = time;
|
|
291
|
+
this.actions.forEach(action => {
|
|
292
|
+
if (!action.paused) {
|
|
293
|
+
action.setTime(time * action.timeScale);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
this.applyValues();
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Stops and resets all registered playback actions. */
|
|
301
|
+
stopAllAction(): this {
|
|
302
|
+
this.actions.forEach(action => action.stop());
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private applyValues(): void {
|
|
307
|
+
const accumulatedValues = new Map<string | AnimationBinding, AccumulatedAnimationValue>();
|
|
308
|
+
|
|
309
|
+
this.actions.forEach(action => {
|
|
310
|
+
if (!action.shouldApply && !(action.playing && action.weight === 0)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
action.clip.tracks.forEach(track => {
|
|
315
|
+
const value = track.evaluate(action.time);
|
|
316
|
+
if (!value) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const bindingKey = track.binding.id || track.binding;
|
|
321
|
+
if (!this.initialValues.has(bindingKey)) {
|
|
322
|
+
const initialValue = track.binding.getValue?.();
|
|
323
|
+
if (initialValue) {
|
|
324
|
+
this.initialValues.set(bindingKey, [...initialValue]);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (action.weight === 0 && !this.initialValues.has(bindingKey)) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const accumulatedValue = accumulatedValues.get(bindingKey);
|
|
332
|
+
if (!accumulatedValue) {
|
|
333
|
+
accumulatedValues.set(bindingKey, {
|
|
334
|
+
binding: track.binding,
|
|
335
|
+
value: [...value],
|
|
336
|
+
valueType: track.valueType,
|
|
337
|
+
weight: action.weight
|
|
338
|
+
});
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (action.weight === 0) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const totalWeight = accumulatedValue.weight + action.weight;
|
|
346
|
+
const ratio = action.weight / totalWeight;
|
|
347
|
+
accumulatedValue.value =
|
|
348
|
+
track.valueType === 'quaternion'
|
|
349
|
+
? interpolateQuaternion(accumulatedValue.value, value, ratio)
|
|
350
|
+
: accumulatedValue.value.map(
|
|
351
|
+
(component, index) => component + (value[index] - component) * ratio
|
|
352
|
+
);
|
|
353
|
+
accumulatedValue.weight = totalWeight;
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
accumulatedValues.forEach(({binding, value, valueType, weight}, bindingKey) => {
|
|
358
|
+
const baseline = weight < 1 ? this.initialValues.get(bindingKey) : undefined;
|
|
359
|
+
if (baseline && baseline.length === value.length) {
|
|
360
|
+
value =
|
|
361
|
+
valueType === 'quaternion'
|
|
362
|
+
? interpolateQuaternion(baseline, value, weight)
|
|
363
|
+
: value.map(
|
|
364
|
+
(component, index) => baseline[index] + (component - baseline[index]) * weight
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
binding.setValue(value);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|