@motionscript/core 0.1.0-alpha.5 → 0.1.0-alpha.7
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/CHANGELOG.md +55 -0
- package/README.md +2 -4
- package/dist/assets/errors.js +4 -5
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/scope.d.ts +1 -1
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +3 -18
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/index.d.ts +3 -5
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +2 -2
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/insets.d.ts +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/size.d.ts +1 -1
- package/dist/attributes/layout/size.js +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +44 -11
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +37 -9
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.d.ts +1 -1
- package/dist/attributes/properties/inputs.js +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +19 -140
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +12 -108
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -1
- package/dist/attributes/shape/corners/corner-radius.js +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts +1 -1
- package/dist/attributes/shape/fill/color/parser.js +1 -1
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.d.ts +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +1 -1
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +1 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -1
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +4 -3
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/path/ops.d.ts +1 -2
- package/dist/attributes/shape/path/ops.d.ts.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shared/operators.d.ts +2 -2
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/types.d.ts +2 -3
- package/dist/attributes/text/types.d.ts.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-D4FSTPML.js +14 -0
- package/dist/browser/chunks/chunk-D4FSTPML.js.map +7 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js +2 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js.map +7 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js +5 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js.map +7 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js +3 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +4 -4
- package/dist/browser/experimental.js +2 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +3 -4
- package/dist/browser/sdk.js +1 -1
- package/dist/component/api.d.ts +508 -0
- package/dist/component/api.d.ts.map +1 -0
- package/dist/component/api.js +4 -0
- package/dist/component/api.js.map +1 -0
- package/dist/component/builtins/audio.d.ts +26 -0
- package/dist/component/builtins/audio.d.ts.map +1 -0
- package/dist/component/builtins/audio.js +41 -0
- package/dist/component/builtins/audio.js.map +1 -0
- package/dist/component/builtins/canvas3d.d.ts +98 -0
- package/dist/component/builtins/canvas3d.d.ts.map +1 -0
- package/dist/component/builtins/canvas3d.js +21 -0
- package/dist/component/builtins/canvas3d.js.map +1 -0
- package/dist/component/builtins/composite.d.ts +56 -0
- package/dist/component/builtins/composite.d.ts.map +1 -0
- package/dist/component/builtins/composite.js +25 -0
- package/dist/component/builtins/composite.js.map +1 -0
- package/dist/component/builtins/geometry.d.ts +505 -0
- package/dist/component/builtins/geometry.d.ts.map +1 -0
- package/dist/component/builtins/geometry.js +107 -0
- package/dist/component/builtins/geometry.js.map +1 -0
- package/dist/component/builtins/layout.d.ts +88 -0
- package/dist/component/builtins/layout.d.ts.map +1 -0
- package/dist/component/builtins/layout.js +84 -0
- package/dist/component/builtins/layout.js.map +1 -0
- package/dist/component/builtins/media.d.ts +95 -0
- package/dist/component/builtins/media.d.ts.map +1 -0
- package/dist/component/builtins/media.js +149 -0
- package/dist/component/builtins/media.js.map +1 -0
- package/dist/component/builtins/providers.d.ts +23 -0
- package/dist/component/builtins/providers.d.ts.map +1 -0
- package/dist/component/builtins/providers.js +30 -0
- package/dist/component/builtins/providers.js.map +1 -0
- package/dist/component/builtins/text.d.ts +193 -0
- package/dist/component/builtins/text.d.ts.map +1 -0
- package/dist/component/builtins/text.js +113 -0
- package/dist/component/builtins/text.js.map +1 -0
- package/dist/component/builtins/three.d.ts +1085 -0
- package/dist/component/builtins/three.d.ts.map +1 -0
- package/dist/component/builtins/three.js +265 -0
- package/dist/component/builtins/three.js.map +1 -0
- package/dist/component/clip-of.d.ts +5 -0
- package/dist/component/clip-of.d.ts.map +1 -0
- package/dist/component/clip-of.js +33 -0
- package/dist/component/clip-of.js.map +1 -0
- package/dist/component/commands-for.d.ts +19 -0
- package/dist/component/commands-for.d.ts.map +1 -0
- package/dist/component/commands-for.js +5 -0
- package/dist/component/commands-for.js.map +1 -0
- package/dist/component/component-audio.d.ts +9 -0
- package/dist/component/component-audio.d.ts.map +1 -0
- package/dist/component/component-audio.js +18 -0
- package/dist/component/component-audio.js.map +1 -0
- package/dist/component/component2d.d.ts +9 -0
- package/dist/component/component2d.d.ts.map +1 -0
- package/dist/component/component2d.js +239 -0
- package/dist/component/component2d.js.map +1 -0
- package/dist/component/component3d.d.ts +9 -0
- package/dist/component/component3d.d.ts.map +1 -0
- package/dist/component/component3d.js +99 -0
- package/dist/component/component3d.js.map +1 -0
- package/dist/component/factory.d.ts +63 -0
- package/dist/component/factory.d.ts.map +1 -0
- package/dist/component/factory.js +313 -0
- package/dist/component/factory.js.map +1 -0
- package/dist/component/modules/aim.d.ts +30 -0
- package/dist/component/modules/aim.d.ts.map +1 -0
- package/dist/component/modules/aim.js +39 -0
- package/dist/component/modules/aim.js.map +1 -0
- package/dist/component/modules/corners.d.ts +13 -0
- package/dist/component/modules/corners.d.ts.map +1 -0
- package/dist/component/modules/corners.js +12 -0
- package/dist/component/modules/corners.js.map +1 -0
- package/dist/component/modules/flow.d.ts +26 -0
- package/dist/component/modules/flow.d.ts.map +1 -0
- package/dist/component/modules/flow.js +55 -0
- package/dist/component/modules/flow.js.map +1 -0
- package/dist/component/modules/material.d.ts +40 -0
- package/dist/component/modules/material.d.ts.map +1 -0
- package/dist/component/modules/material.js +75 -0
- package/dist/component/modules/material.js.map +1 -0
- package/dist/component/modules/paint.d.ts +71 -0
- package/dist/component/modules/paint.d.ts.map +1 -0
- package/dist/component/modules/paint.js +106 -0
- package/dist/component/modules/paint.js.map +1 -0
- package/dist/component/modules/shapes.d.ts +31 -0
- package/dist/component/modules/shapes.d.ts.map +1 -0
- package/dist/component/modules/shapes.js +43 -0
- package/dist/component/modules/shapes.js.map +1 -0
- package/dist/component/modules/text-layout.d.ts +26 -0
- package/dist/component/modules/text-layout.d.ts.map +1 -0
- package/dist/component/modules/text-layout.js +57 -0
- package/dist/component/modules/text-layout.js.map +1 -0
- package/dist/component/modules/text-style.d.ts +48 -0
- package/dist/component/modules/text-style.d.ts.map +1 -0
- package/dist/component/modules/text-style.js +63 -0
- package/dist/component/modules/text-style.js.map +1 -0
- package/dist/component/modules/three-entries.d.ts +23 -0
- package/dist/component/modules/three-entries.d.ts.map +1 -0
- package/dist/component/modules/three-entries.js +41 -0
- package/dist/component/modules/three-entries.js.map +1 -0
- package/dist/component/modules/view3d.d.ts +55 -0
- package/dist/component/modules/view3d.d.ts.map +1 -0
- package/dist/component/modules/view3d.js +160 -0
- package/dist/component/modules/view3d.js.map +1 -0
- package/dist/component/timeline.d.ts +22 -0
- package/dist/component/timeline.d.ts.map +1 -0
- package/dist/component/timeline.js +128 -0
- package/dist/component/timeline.js.map +1 -0
- package/dist/component/type-def.d.ts +26 -0
- package/dist/component/type-def.d.ts.map +1 -0
- package/dist/component/type-def.js +16 -0
- package/dist/component/type-def.js.map +1 -0
- package/dist/component/types.d.ts +91 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component/types.js +88 -0
- package/dist/component/types.js.map +1 -0
- package/dist/component/views.d.ts +121 -0
- package/dist/component/views.d.ts.map +1 -0
- package/dist/component/views.js +413 -0
- package/dist/component/views.js.map +1 -0
- package/dist/component.d.ts +10 -19
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +10 -19
- package/dist/component.js.map +1 -1
- package/dist/components/builtins/audio/audio.d.ts +53 -0
- package/dist/components/builtins/audio/audio.d.ts.map +1 -0
- package/dist/components/builtins/audio/audio.js +41 -0
- package/dist/components/builtins/audio/audio.js.map +1 -0
- package/dist/components/builtins/geometry/composite.d.ts +93 -0
- package/dist/components/builtins/geometry/composite.d.ts.map +1 -0
- package/dist/components/builtins/geometry/composite.js +25 -0
- package/dist/components/builtins/geometry/composite.js.map +1 -0
- package/dist/components/builtins/geometry/geometry.d.ts +921 -0
- package/dist/components/builtins/geometry/geometry.d.ts.map +1 -0
- package/dist/components/builtins/geometry/geometry.js +107 -0
- package/dist/components/builtins/geometry/geometry.js.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts +93 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.js +470 -0
- package/dist/components/builtins/geometry/shape-outline.js.map +1 -0
- package/dist/components/builtins/layout/layout.d.ts +186 -0
- package/dist/components/builtins/layout/layout.d.ts.map +1 -0
- package/dist/components/builtins/layout/layout.js +84 -0
- package/dist/components/builtins/layout/layout.js.map +1 -0
- package/dist/components/builtins/media/media.d.ts +240 -0
- package/dist/components/builtins/media/media.d.ts.map +1 -0
- package/dist/components/builtins/media/media.js +149 -0
- package/dist/components/builtins/media/media.js.map +1 -0
- package/dist/components/builtins/providers/providers.d.ts +47 -0
- package/dist/components/builtins/providers/providers.d.ts.map +1 -0
- package/dist/components/builtins/providers/providers.js +30 -0
- package/dist/components/builtins/providers/providers.js.map +1 -0
- package/dist/components/builtins/text/number-format.d.ts +66 -0
- package/dist/components/builtins/text/number-format.d.ts.map +1 -0
- package/dist/components/builtins/text/number-format.js +227 -0
- package/dist/components/builtins/text/number-format.js.map +1 -0
- package/dist/components/builtins/text/number-pattern.d.ts +51 -0
- package/dist/components/builtins/text/number-pattern.d.ts.map +1 -0
- package/dist/components/builtins/text/number-pattern.js +77 -0
- package/dist/components/builtins/text/number-pattern.js.map +1 -0
- package/dist/components/builtins/text/text-defaults.d.ts +32 -0
- package/dist/components/builtins/text/text-defaults.d.ts.map +1 -0
- package/dist/components/builtins/text/text-defaults.js +37 -0
- package/dist/components/builtins/text/text-defaults.js.map +1 -0
- package/dist/components/builtins/text/text-layout.d.ts +82 -0
- package/dist/components/builtins/text/text-layout.d.ts.map +1 -0
- package/dist/components/builtins/text/text-layout.js +331 -0
- package/dist/components/builtins/text/text-layout.js.map +1 -0
- package/dist/components/builtins/text/text.d.ts +409 -0
- package/dist/components/builtins/text/text.d.ts.map +1 -0
- package/dist/components/builtins/text/text.js +113 -0
- package/dist/components/builtins/text/text.js.map +1 -0
- package/dist/components/builtins/three/canvas3d.d.ts +245 -0
- package/dist/components/builtins/three/canvas3d.d.ts.map +1 -0
- package/dist/components/builtins/three/canvas3d.js +21 -0
- package/dist/components/builtins/three/canvas3d.js.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts +62 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.js +114 -0
- package/dist/components/builtins/three/grid-geometry3d.js.map +1 -0
- package/dist/components/builtins/three/three.d.ts +1889 -0
- package/dist/components/builtins/three/three.d.ts.map +1 -0
- package/dist/components/builtins/three/three.js +305 -0
- package/dist/components/builtins/three/three.js.map +1 -0
- package/dist/components/factory/api.d.ts +516 -0
- package/dist/components/factory/api.d.ts.map +1 -0
- package/dist/components/factory/api.js +4 -0
- package/dist/components/factory/api.js.map +1 -0
- package/dist/components/factory/clip-of.d.ts +5 -0
- package/dist/components/factory/clip-of.d.ts.map +1 -0
- package/dist/components/factory/clip-of.js +33 -0
- package/dist/components/factory/clip-of.js.map +1 -0
- package/dist/components/factory/commands-for.d.ts +19 -0
- package/dist/components/factory/commands-for.d.ts.map +1 -0
- package/dist/components/factory/commands-for.js +5 -0
- package/dist/components/factory/commands-for.js.map +1 -0
- package/dist/components/factory/component-audio.d.ts +9 -0
- package/dist/components/factory/component-audio.d.ts.map +1 -0
- package/dist/components/factory/component-audio.js +18 -0
- package/dist/components/factory/component-audio.js.map +1 -0
- package/dist/components/factory/component2d.d.ts +8 -0
- package/dist/components/factory/component2d.d.ts.map +1 -0
- package/dist/components/factory/component2d.js +240 -0
- package/dist/components/factory/component2d.js.map +1 -0
- package/dist/components/factory/component3d.d.ts +9 -0
- package/dist/components/factory/component3d.d.ts.map +1 -0
- package/dist/components/factory/component3d.js +99 -0
- package/dist/components/factory/component3d.js.map +1 -0
- package/dist/components/factory/factory.d.ts +63 -0
- package/dist/components/factory/factory.d.ts.map +1 -0
- package/dist/components/factory/factory.js +313 -0
- package/dist/components/factory/factory.js.map +1 -0
- package/dist/components/factory/timeline.d.ts +22 -0
- package/dist/components/factory/timeline.d.ts.map +1 -0
- package/dist/components/factory/timeline.js +128 -0
- package/dist/components/factory/timeline.js.map +1 -0
- package/dist/components/factory/type-def.d.ts +26 -0
- package/dist/components/factory/type-def.d.ts.map +1 -0
- package/dist/components/factory/type-def.js +16 -0
- package/dist/components/factory/type-def.js.map +1 -0
- package/dist/components/factory/types.d.ts +91 -0
- package/dist/components/factory/types.d.ts.map +1 -0
- package/dist/components/factory/types.js +88 -0
- package/dist/components/factory/types.js.map +1 -0
- package/dist/components/factory/views.d.ts +121 -0
- package/dist/components/factory/views.d.ts.map +1 -0
- package/dist/components/factory/views.js +413 -0
- package/dist/components/factory/views.js.map +1 -0
- package/dist/components/modules/aim.d.ts +30 -0
- package/dist/components/modules/aim.d.ts.map +1 -0
- package/dist/components/modules/aim.js +39 -0
- package/dist/components/modules/aim.js.map +1 -0
- package/dist/components/modules/corners.d.ts +13 -0
- package/dist/components/modules/corners.d.ts.map +1 -0
- package/dist/components/modules/corners.js +12 -0
- package/dist/components/modules/corners.js.map +1 -0
- package/dist/components/modules/flow.d.ts +26 -0
- package/dist/components/modules/flow.d.ts.map +1 -0
- package/dist/components/modules/flow.js +57 -0
- package/dist/components/modules/flow.js.map +1 -0
- package/dist/components/modules/material.d.ts +40 -0
- package/dist/components/modules/material.d.ts.map +1 -0
- package/dist/components/modules/material.js +75 -0
- package/dist/components/modules/material.js.map +1 -0
- package/dist/components/modules/paint.d.ts +71 -0
- package/dist/components/modules/paint.d.ts.map +1 -0
- package/dist/components/modules/paint.js +106 -0
- package/dist/components/modules/paint.js.map +1 -0
- package/dist/components/modules/shapes.d.ts +31 -0
- package/dist/components/modules/shapes.d.ts.map +1 -0
- package/dist/components/modules/shapes.js +43 -0
- package/dist/components/modules/shapes.js.map +1 -0
- package/dist/components/modules/text-layout.d.ts +26 -0
- package/dist/components/modules/text-layout.d.ts.map +1 -0
- package/dist/components/modules/text-layout.js +57 -0
- package/dist/components/modules/text-layout.js.map +1 -0
- package/dist/components/modules/text-style.d.ts +48 -0
- package/dist/components/modules/text-style.d.ts.map +1 -0
- package/dist/components/modules/text-style.js +63 -0
- package/dist/components/modules/text-style.js.map +1 -0
- package/dist/components/modules/three-entries.d.ts +23 -0
- package/dist/components/modules/three-entries.d.ts.map +1 -0
- package/dist/components/modules/three-entries.js +41 -0
- package/dist/components/modules/three-entries.js.map +1 -0
- package/dist/components/modules/view3d.d.ts +59 -0
- package/dist/components/modules/view3d.d.ts.map +1 -0
- package/dist/components/modules/view3d.js +171 -0
- package/dist/components/modules/view3d.js.map +1 -0
- package/dist/components/trees/2d/group-bounds.d.ts +56 -0
- package/dist/components/trees/2d/group-bounds.d.ts.map +1 -0
- package/dist/components/trees/2d/group-bounds.js +87 -0
- package/dist/components/trees/2d/group-bounds.js.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts +46 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.js +264 -0
- package/dist/components/trees/2d/node-lifecycle.js.map +1 -0
- package/dist/components/trees/2d/node-motion.d.ts +56 -0
- package/dist/components/trees/2d/node-motion.d.ts.map +1 -0
- package/dist/components/trees/2d/node-motion.js +86 -0
- package/dist/components/trees/2d/node-motion.js.map +1 -0
- package/dist/components/trees/2d/node-render.d.ts +36 -0
- package/dist/components/trees/2d/node-render.d.ts.map +1 -0
- package/dist/components/trees/2d/node-render.js +67 -0
- package/dist/components/trees/2d/node-render.js.map +1 -0
- package/dist/components/trees/2d/node-space.d.ts +63 -0
- package/dist/components/trees/2d/node-space.d.ts.map +1 -0
- package/dist/components/trees/2d/node-space.js +131 -0
- package/dist/components/trees/2d/node-space.js.map +1 -0
- package/dist/components/trees/2d/node-transform.d.ts +55 -0
- package/dist/components/trees/2d/node-transform.d.ts.map +1 -0
- package/dist/components/trees/2d/node-transform.js +73 -0
- package/dist/components/trees/2d/node-transform.js.map +1 -0
- package/dist/components/trees/2d/node2d.d.ts +1020 -0
- package/dist/components/trees/2d/node2d.d.ts.map +1 -0
- package/dist/components/trees/2d/node2d.js +1481 -0
- package/dist/components/trees/2d/node2d.js.map +1 -0
- package/dist/components/trees/audio/index.d.ts +2 -0
- package/dist/components/trees/audio/index.d.ts.map +1 -0
- package/dist/components/trees/audio/index.js +2 -0
- package/dist/components/trees/audio/index.js.map +1 -0
- package/dist/components/trees/audio/node-audio.d.ts +109 -0
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -0
- package/dist/components/trees/audio/node-audio.js +167 -0
- package/dist/components/trees/audio/node-audio.js.map +1 -0
- package/dist/components/trees/index.d.ts +10 -0
- package/dist/components/trees/index.d.ts.map +1 -0
- package/dist/components/trees/index.js +14 -0
- package/dist/components/trees/index.js.map +1 -0
- package/dist/components/trees/node/node-editor-state.d.ts +53 -0
- package/dist/components/trees/node/node-editor-state.d.ts.map +1 -0
- package/dist/components/trees/node/node-editor-state.js +23 -0
- package/dist/components/trees/node/node-editor-state.js.map +1 -0
- package/dist/components/trees/node/node-reactive.d.ts +89 -0
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -0
- package/dist/components/trees/node/node-reactive.js +135 -0
- package/dist/components/trees/node/node-reactive.js.map +1 -0
- package/dist/components/trees/node/node-time.d.ts +39 -0
- package/dist/components/trees/node/node-time.d.ts.map +1 -0
- package/dist/components/trees/node/node-time.js +14 -0
- package/dist/components/trees/node/node-time.js.map +1 -0
- package/dist/components/trees/node/node-walk.d.ts +46 -0
- package/dist/components/trees/node/node-walk.d.ts.map +1 -0
- package/dist/components/trees/node/node-walk.js +74 -0
- package/dist/components/trees/node/node-walk.js.map +1 -0
- package/dist/components/trees/node/node.d.ts +401 -0
- package/dist/components/trees/node/node.d.ts.map +1 -0
- package/dist/components/trees/node/node.js +680 -0
- package/dist/components/trees/node/node.js.map +1 -0
- package/dist/components/trees/root/canvas2d-node.d.ts +163 -0
- package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -0
- package/dist/components/trees/root/canvas2d-node.js +216 -0
- package/dist/components/trees/root/canvas2d-node.js.map +1 -0
- package/dist/components/trees/three/node3d.d.ts +222 -0
- package/dist/components/trees/three/node3d.d.ts.map +1 -0
- package/dist/components/trees/three/node3d.js +289 -0
- package/dist/components/trees/three/node3d.js.map +1 -0
- package/dist/document/audio.d.ts +9 -1
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +41 -0
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +13 -31
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +2 -2
- package/dist/document/command-traits.js +4 -1
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.d.ts +2 -2
- package/dist/document/deny-globals.js +2 -2
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +3 -3
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js +3 -3
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/index.d.ts +1 -1
- package/dist/document/expression/index.js +1 -1
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.js +1 -1
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/index.d.ts +1 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +1 -2
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.d.ts +14 -10
- package/dist/document/node-decorator.d.ts.map +1 -1
- package/dist/document/node-decorator.js +14 -10
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +9 -3
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.js +2 -2
- package/dist/document/placement.js.map +1 -1
- package/dist/document/registry.d.ts +29 -36
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +29 -35
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +49 -0
- package/dist/document/settled-index.d.ts.map +1 -0
- package/dist/document/settled-index.js +247 -0
- package/dist/document/settled-index.js.map +1 -0
- package/dist/document/timeline.d.ts +29 -3
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +99 -3
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +4 -4
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +1 -1
- package/dist/document/validate.js.map +1 -1
- package/dist/experimental.d.ts +22 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +20 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/types.d.ts +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/nodes/audio/index.d.ts +2 -2
- package/dist/nodes/audio/index.d.ts.map +1 -1
- package/dist/nodes/audio/index.js +0 -2
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -1
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +3 -0
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/index.d.ts +39 -27
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +16 -30
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/node/node.d.ts +7 -1
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +23 -8
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/root/canvas2d-node.d.ts +2 -1
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -1
- package/dist/nodes/root/canvas2d-node.js +3 -0
- package/dist/nodes/root/canvas2d-node.js.map +1 -1
- package/dist/nodes/text/richtext-node.d.ts +0 -5
- package/dist/nodes/text/richtext-node.d.ts.map +1 -1
- package/dist/nodes/text/richtext-node.js +5 -71
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts +5 -22
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +12 -363
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-layout.d.ts +87 -0
- package/dist/nodes/text/text-layout.d.ts.map +1 -0
- package/dist/nodes/text/text-layout.js +368 -0
- package/dist/nodes/text/text-layout.js.map +1 -0
- package/dist/nodes/three/canvas3d-node.d.ts +3 -1
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +6 -0
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/props/host.d.ts +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/slot.d.ts +1 -1
- package/dist/props/slot.js +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/render/clip.d.ts +1 -1
- package/dist/render/clip.js +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +11 -5
- package/dist/render/descriptors/text.d.ts.map +1 -1
- package/dist/render/descriptors/text.js +7 -1
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/render-context2d.d.ts +2 -2
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render3d/builders.d.ts +1 -1
- package/dist/render3d/builders.js +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +13 -19
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +13 -19
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +1 -1
- package/dist/render3d/scene3d.js +1 -1
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/texture.d.ts +2 -2
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/vector3.d.ts +2 -2
- package/dist/render3d/vector3.js +2 -2
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/runtime/asset-refine.d.ts +1 -1
- package/dist/runtime/asset-refine.d.ts.map +1 -1
- package/dist/runtime/asset-refine.js +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-update.js +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +0 -11
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +0 -25
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +7 -4
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +21 -7
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +11 -3
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +83 -23
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +3 -3
- package/dist/runtime/engine.js +2 -2
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +2 -2
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +9 -10
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +12 -5
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +6 -1
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +2 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +1 -1
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +2 -2
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +1 -1
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +6 -3
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +46 -21
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +47 -43
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +7 -9
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +2 -2
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +13 -1
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +14 -0
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/index.d.ts +2 -1
- package/dist/tween/index.d.ts.map +1 -1
- package/dist/tween/index.js +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/loop.d.ts +1 -1
- package/dist/tween/loop.js +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/util/reference.d.ts +6 -6
- package/dist/util/reference.js.map +1 -1
- package/package.json +7 -10
- package/dist/browser/chunks/chunk-FUZVFT3W.js +0 -18
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +0 -7
- package/dist/browser/chunks/chunk-QG6C23IJ.js +0 -3
- package/dist/browser/chunks/chunk-QG6C23IJ.js.map +0 -7
- package/dist/browser/chunks/chunk-SFNJRPBV.js +0 -2
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +0 -7
- package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js.map +0 -7
- /package/dist/browser/{jsx-jsx-dev-runtime.js.map → experimental.js.map} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { multiply, translation } from "../../../attributes/layout/matrix2d.js";
|
|
2
|
+
import { worldAnchors } from "../../../components/trees/2d/node-transform.js";
|
|
3
|
+
/**
|
|
4
|
+
* The four corners of `child`'s ink, in its **parent's** local space (y-up,
|
|
5
|
+
* relative to the parent's centre).
|
|
6
|
+
*
|
|
7
|
+
* The same two-step `nodeBox` makes: shift the child's matrix onto the ink's own
|
|
8
|
+
* centre (the matrix is canvas y-down and the bounds are y-up, hence the sign),
|
|
9
|
+
* then read the corners off it. That is what makes this correct for a child that
|
|
10
|
+
* is rotated, scaled, or whose ink is off-centre.
|
|
11
|
+
*/
|
|
12
|
+
function inkCorners(child) {
|
|
13
|
+
const b = child._localBounds();
|
|
14
|
+
const local = child._localMatrix();
|
|
15
|
+
const m = b.x === 0 && b.y === 0 ? local : multiply(local, translation(b.x, -b.y));
|
|
16
|
+
const a = worldAnchors(m, b.width / 2, b.height / 2);
|
|
17
|
+
return [a.topLeft, a.topRight, a.bottomRight, a.bottomLeft];
|
|
18
|
+
}
|
|
19
|
+
/** The axis-aligned span of a point set, or `null` for an empty one. */
|
|
20
|
+
function spanOf(points) {
|
|
21
|
+
if (points.length === 0)
|
|
22
|
+
return null;
|
|
23
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
24
|
+
for (const p of points) {
|
|
25
|
+
if (p.x < minX)
|
|
26
|
+
minX = p.x;
|
|
27
|
+
if (p.x > maxX)
|
|
28
|
+
maxX = p.x;
|
|
29
|
+
if (p.y < minY)
|
|
30
|
+
minY = p.y;
|
|
31
|
+
if (p.y > maxY)
|
|
32
|
+
maxY = p.y;
|
|
33
|
+
}
|
|
34
|
+
return { minX, minY, maxX, maxY };
|
|
35
|
+
}
|
|
36
|
+
function toBounds(span) {
|
|
37
|
+
return {
|
|
38
|
+
x: (span.minX + span.maxX) / 2,
|
|
39
|
+
y: (span.minY + span.maxY) / 2,
|
|
40
|
+
width: span.maxX - span.minX,
|
|
41
|
+
height: span.maxY - span.minY,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The extent of `node`'s children's ink in `node`'s own local space, or `null`
|
|
46
|
+
* when there is nothing to measure — no children, or an `intersect` whose parts
|
|
47
|
+
* don't overlap at all.
|
|
48
|
+
*
|
|
49
|
+
* `null` is the caller's cue to keep the layout cell: a node with no children
|
|
50
|
+
* has nothing else to offer, and an empty intersection draws nothing anywhere,
|
|
51
|
+
* so a box round the parts would be a box round a shape that isn't there. The
|
|
52
|
+
* cell at least stays in one place and stays grabbable, which is what a node you
|
|
53
|
+
* need to put another child into has to be.
|
|
54
|
+
*/
|
|
55
|
+
export function childInkBounds(node, mode) {
|
|
56
|
+
const children = node.children;
|
|
57
|
+
if (children.length === 0)
|
|
58
|
+
return null;
|
|
59
|
+
if (mode === "first") {
|
|
60
|
+
const span = spanOf(inkCorners(children[0]));
|
|
61
|
+
return span ? toBounds(span) : null;
|
|
62
|
+
}
|
|
63
|
+
if (mode === "union") {
|
|
64
|
+
const span = spanOf(children.flatMap(inkCorners));
|
|
65
|
+
return span ? toBounds(span) : null;
|
|
66
|
+
}
|
|
67
|
+
let span = null;
|
|
68
|
+
for (const child of children) {
|
|
69
|
+
const next = spanOf(inkCorners(child));
|
|
70
|
+
if (!next)
|
|
71
|
+
return null;
|
|
72
|
+
span = span
|
|
73
|
+
? {
|
|
74
|
+
minX: Math.max(span.minX, next.minX),
|
|
75
|
+
minY: Math.max(span.minY, next.minY),
|
|
76
|
+
maxX: Math.min(span.maxX, next.maxX),
|
|
77
|
+
maxY: Math.min(span.maxY, next.maxY),
|
|
78
|
+
}
|
|
79
|
+
: next;
|
|
80
|
+
// The parts have stopped overlapping — nothing is drawn, so there is no
|
|
81
|
+
// box to draw. See the header.
|
|
82
|
+
if (span.minX > span.maxX || span.minY > span.maxY)
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return span ? toBounds(span) : null;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=group-bounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-bounds.js","sourceRoot":"","sources":["../../../../src/components/trees/2d/group-bounds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAoDpE;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,KAAa;IAC7B,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;IACnC,MAAM,CAAC,GACH,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;AAChE,CAAC;AAED,wEAAwE;AACxE,SAAS,MAAM,CAAC,MAAiB;IAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC;IACzE,KAAK,MAA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/layout/bounds\";\r\nimport { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport { multiply, translation } from \"@/attributes/layout/matrix2d\";\r\nimport { worldAnchors } from \"@/components/trees/2d/node-transform\";\r\n\r\n/**\r\n * The ink extent of a node whose drawing is made **out of its children** rather\r\n * than out of a box of its own — a {@link BooleanGroup}, a {@link MaskGroup}.\r\n *\r\n * Both of those classes report their layout cell as their bounds by default,\r\n * and for both that cell is a fiction: nothing is drawn at its edges, nothing\r\n * is grabbable there, and it does not move when the parts inside it do. An\r\n * editor drawing a selection box around one is drawing a rectangle that has no\r\n * relationship to the pixels — which is exactly what {@link Node2D._localBounds}\r\n * exists to fix, and the reason it is a separate seam from `measure()`: the box\r\n * moves, the layout does not.\r\n *\r\n * ## Why an op decides the answer\r\n *\r\n * A bounding box is the one thing about a boolean result you *can* work out\r\n * without running the boolean. For a union it is even exact —\r\n * `bounds(A ∪ B) = bounds(A) ∪ bounds(B)` — and the same union is the honest\r\n * answer for `exclude`, whose result is a subset of it and whose parts are all\r\n * still there to be seen. The other two shrink instead: subtracting can only\r\n * ever cut into the first child, and an intersection lives inside every child\r\n * at once. So each mode below states which of those it is, and the result is a\r\n * *superset* of the true silhouette for `subtract`/`intersect` and exact for\r\n * the other two — never a box the drawing spills out of, which is the failure\r\n * that would matter.\r\n *\r\n * ## Why this composes with a resize that scales the children\r\n *\r\n * An editor can resize one of these nodes by scaling every child about the\r\n * corner the drag holds still, and that gesture is only\r\n * coherent if the box it is dragging follows the parts by the same factor. It\r\n * does, for all three modes: an axis-aligned scale about a point commutes with\r\n * union and intersection alike, so scaling every child by `k` scales the answer\r\n * here by exactly `k`. Neither half has to know about the other.\r\n */\r\nexport type ChildBoundsMode =\r\n /** Every child's ink, together — `union` and `exclude`. */\r\n | \"union\"\r\n /** The first child's ink alone — `subtract`'s base, and a mask's stencil. */\r\n | \"first\"\r\n /** Where every child's ink overlaps — `intersect`. */\r\n | \"intersect\";\r\n\r\n/** Min/max in the node's own local space, y-up, relative to its centre. */\r\ninterface Span {\r\n minX: number;\r\n minY: number;\r\n maxX: number;\r\n maxY: number;\r\n}\r\n\r\n/**\r\n * The four corners of `child`'s ink, in its **parent's** local space (y-up,\r\n * relative to the parent's centre).\r\n *\r\n * The same two-step `nodeBox` makes: shift the child's matrix onto the ink's own\r\n * centre (the matrix is canvas y-down and the bounds are y-up, hence the sign),\r\n * then read the corners off it. That is what makes this correct for a child that\r\n * is rotated, scaled, or whose ink is off-centre.\r\n */\r\nfunction inkCorners(child: Node2D): Vector2[] {\r\n const b = child._localBounds();\r\n const local = child._localMatrix();\r\n const m =\r\n b.x === 0 && b.y === 0 ? local : multiply(local, translation(b.x, -b.y));\r\n const a = worldAnchors(m, b.width / 2, b.height / 2);\r\n return [a.topLeft, a.topRight, a.bottomRight, a.bottomLeft];\r\n}\r\n\r\n/** The axis-aligned span of a point set, or `null` for an empty one. */\r\nfunction spanOf(points: Vector2[]): Span | null {\r\n if (points.length === 0) return null;\r\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\r\n for (const p of points) {\r\n if (p.x < minX) minX = p.x;\r\n if (p.x > maxX) maxX = p.x;\r\n if (p.y < minY) minY = p.y;\r\n if (p.y > maxY) maxY = p.y;\r\n }\r\n return { minX, minY, maxX, maxY };\r\n}\r\n\r\nfunction toBounds(span: Span): BoxBounds {\r\n return {\r\n x: (span.minX + span.maxX) / 2,\r\n y: (span.minY + span.maxY) / 2,\r\n width: span.maxX - span.minX,\r\n height: span.maxY - span.minY,\r\n };\r\n}\r\n\r\n/**\r\n * The extent of `node`'s children's ink in `node`'s own local space, or `null`\r\n * when there is nothing to measure — no children, or an `intersect` whose parts\r\n * don't overlap at all.\r\n *\r\n * `null` is the caller's cue to keep the layout cell: a node with no children\r\n * has nothing else to offer, and an empty intersection draws nothing anywhere,\r\n * so a box round the parts would be a box round a shape that isn't there. The\r\n * cell at least stays in one place and stays grabbable, which is what a node you\r\n * need to put another child into has to be.\r\n */\r\nexport function childInkBounds(\r\n node: Node2D,\r\n mode: ChildBoundsMode\r\n): BoxBounds | null {\r\n const children = node.children;\r\n if (children.length === 0) return null;\r\n\r\n if (mode === \"first\") {\r\n const span = spanOf(inkCorners(children[0]));\r\n return span ? toBounds(span) : null;\r\n }\r\n\r\n if (mode === \"union\") {\r\n const span = spanOf(children.flatMap(inkCorners));\r\n return span ? toBounds(span) : null;\r\n }\r\n\r\n let span: Span | null = null;\r\n for (const child of children) {\r\n const next = spanOf(inkCorners(child));\r\n if (!next) return null;\r\n span = span\r\n ? {\r\n minX: Math.max(span.minX, next.minX),\r\n minY: Math.max(span.minY, next.minY),\r\n maxX: Math.min(span.maxX, next.maxX),\r\n maxY: Math.min(span.maxY, next.maxY),\r\n }\r\n : next;\r\n // The parts have stopped overlapping — nothing is drawn, so there is no\r\n // box to draw. See the header.\r\n if (span.minX > span.maxX || span.minY > span.maxY) return null;\r\n }\r\n return span ? toBounds(span) : null;\r\n}\r\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EasingFunction } from "../../../tween/ease/type.js";
|
|
2
|
+
import { type Command } from "../../../tween/command.js";
|
|
3
|
+
import type { Node2D } from "./node2d.js";
|
|
4
|
+
/**
|
|
5
|
+
* Animated `addChildAt`: insert the child at `index` **already collapsed to 0**,
|
|
6
|
+
* then grow it in — fading opacity up and expanding its box from 0 → its natural
|
|
7
|
+
* size so the surrounding siblings **slide over to make room** rather than
|
|
8
|
+
* jumping. The mirror of {@link removeChildAtAnimated} (which pins to the
|
|
9
|
+
* measured size and shrinks to 0).
|
|
10
|
+
*
|
|
11
|
+
* A numeric-sized axis has its target size in hand up front. A `"hug"`/`"fill"`
|
|
12
|
+
* axis does not — its size is only known once laid out — so we measure the child
|
|
13
|
+
* **detached** (via {@link measureDetached}, using the parent's retained
|
|
14
|
+
* constraints + scope) *before* attaching it. That keeps the child out of the
|
|
15
|
+
* parent's layout flow while we size it, so the siblings never see it at full
|
|
16
|
+
* width for a frame — no reflow flash. The child is then added at 0 and the tween
|
|
17
|
+
* grows it to that measured size. Because the tween needs *numeric* endpoints
|
|
18
|
+
* (a string size only snaps, it can't interpolate), the original size token is
|
|
19
|
+
* restored once the command reaches its end so the child resumes normal reflow.
|
|
20
|
+
*
|
|
21
|
+
* If the parent hasn't been measured yet (no retained scope — nothing is on
|
|
22
|
+
* screen to reflow against), a non-numeric axis simply can't be pre-measured;
|
|
23
|
+
* it falls back to its authored token and fades in without a width tween.
|
|
24
|
+
*/
|
|
25
|
+
export declare function addChildAtAnimated(parent: Node2D, child: Node2D, index: number, duration: number, easing?: EasingFunction): Command<Record<string, never>>;
|
|
26
|
+
/**
|
|
27
|
+
* Animated `removeChildAt`: fade+size the child out, then detach it.
|
|
28
|
+
*
|
|
29
|
+
* The child stays in the tree — animating out — until the command reaches its
|
|
30
|
+
* end (`t === 1`), matching the "insert"/"remove" seekability
|
|
31
|
+
* `packages/components/code` established: a host asking for a time before the
|
|
32
|
+
* end sees the child still present, mid-fade; only reaching the end detaches it.
|
|
33
|
+
* Seeking back below the end after having reached it re-attaches the child at
|
|
34
|
+
* its original index, so the animation stays a function of `t` in both
|
|
35
|
+
* directions rather than a one-way commit.
|
|
36
|
+
*/
|
|
37
|
+
export declare function removeChildAtAnimated(parent: Node2D, index: number, duration: number, easing?: EasingFunction): Command<Record<string, never>>;
|
|
38
|
+
/**
|
|
39
|
+
* Animated `reparent`: fade+size the node out of its current parent, then
|
|
40
|
+
* reparent it and fade+size it in. The handoff happens at the animation's
|
|
41
|
+
* midpoint (`t === 0.5`) — seeking across it in either direction moves the node
|
|
42
|
+
* between parents to match, the same bidirectional membership rule
|
|
43
|
+
* {@link removeChildAtAnimated} uses.
|
|
44
|
+
*/
|
|
45
|
+
export declare function reparentAnimated(node: Node2D, newParent: Node2D, duration: number, easing?: EasingFunction): Command<Record<string, never>>;
|
|
46
|
+
//# sourceMappingURL=node-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/components/trees/2d/node-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAkD,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAmEpD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CA2EhC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAuDhC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CA0DhC"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { commandParallel, commandSequence, driveCommand } from "../../../tween/command.js";
|
|
2
|
+
/**
|
|
3
|
+
* Measure `child`'s natural size **without attaching it to `parent`** — so the
|
|
4
|
+
* measurement never perturbs the parent's layout (siblings don't shift for a
|
|
5
|
+
* frame). Uses the constraints + scope the parent retained from its last measure
|
|
6
|
+
* pass; returns `null` if the parent hasn't been measured yet (nothing on screen
|
|
7
|
+
* to reflow against), so the caller can fall back. Reads `parent.lastMeasure` —
|
|
8
|
+
* internal layout state the lifecycle helpers are the
|
|
9
|
+
* intended in-directory consumer of.
|
|
10
|
+
*/
|
|
11
|
+
function measureDetached(parent, child) {
|
|
12
|
+
const pass = parent.lastMeasure;
|
|
13
|
+
const scope = pass?.measurer;
|
|
14
|
+
// The scope (text measurement) is the essential input and is only present once
|
|
15
|
+
// the parent has been laid out; without it we can't size a hug child off-tree.
|
|
16
|
+
if (!scope)
|
|
17
|
+
return null;
|
|
18
|
+
// The parent's own constraints bound the child; fall back to its laid-out box,
|
|
19
|
+
// then to an unbounded space — a hug child shrink-wraps regardless, so a
|
|
20
|
+
// generous ceiling is fine.
|
|
21
|
+
const constraints = pass?.constraints ?? {
|
|
22
|
+
maxWidth: parent.measuredWidth || Number.MAX_SAFE_INTEGER,
|
|
23
|
+
maxHeight: parent.measuredHeight || Number.MAX_SAFE_INTEGER,
|
|
24
|
+
};
|
|
25
|
+
const size = child.measure(constraints, scope);
|
|
26
|
+
return { width: size.width ?? 0, height: size.height ?? 0 };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Companion for {@link Node2D}'s animated child-management methods. The sync
|
|
30
|
+
* variants (add/remove/clear/addChildAt/
|
|
31
|
+
* removeChildAt) stay inline on Node2D — each is a 3–5 line method that mutates
|
|
32
|
+
* `_children`/`_parent` and calls `bindAssets`/`bindChildContext`, so there is
|
|
33
|
+
* no body worth moving. These are the animated overloads, returned as
|
|
34
|
+
* {@link Command}s built from `child.to(...)` composed with
|
|
35
|
+
* {@link commandSequence}/{@link commandParallel} — the same choreography
|
|
36
|
+
* primitives a node's own multi-step commands use.
|
|
37
|
+
*
|
|
38
|
+
* Each command's setup (measuring the child, collapsing it, attaching/
|
|
39
|
+
* detaching/reparenting) runs **lazily, once, on the command's first
|
|
40
|
+
* evaluation** rather than when the function below is called — mirroring the
|
|
41
|
+
* generator these replaced, whose body didn't run a single line until the
|
|
42
|
+
* caller's first `.next()`. That laziness is load-bearing: a caller often does
|
|
43
|
+
* `const cmd = parent.addChildAt(child, i, dur); /* lay the parent out here *\/
|
|
44
|
+
* driveCmd(cmd)`, relying on the parent having a fresh `lastMeasure` by the time
|
|
45
|
+
* the hug/fill measurement in {@link addChildAtAnimated} actually runs. Doing
|
|
46
|
+
* that measurement eagerly — when this function is called, not when the
|
|
47
|
+
* command is first driven — reads whatever scope the parent happened to have
|
|
48
|
+
* at call time, which is often none at all.
|
|
49
|
+
*
|
|
50
|
+
* The container's `gap` is handled by the per-child `gapScale` prop these helpers
|
|
51
|
+
* tween in parallel with the child's box (see {@link addChildAtAnimated}); the
|
|
52
|
+
* flex layout (`flex.ts`) folds each child's `gapScale` into its gap budget, so
|
|
53
|
+
* the gap opens/closes in lockstep with the size instead of popping. No helper
|
|
54
|
+
* here needs to know the parent's axis or gap value.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Fraction of an insert/remove's `duration` spent on the size + gap motion; the
|
|
58
|
+
* remainder is the opacity fade. Splitting the two sequentially (grow → fade in,
|
|
59
|
+
* fade out → shrink) keeps the fading child from overlapping siblings that are
|
|
60
|
+
* still sliding: room is opened while it's invisible, then it fades in already in
|
|
61
|
+
* place (and mirror-image on remove). The size phase gets the larger share since
|
|
62
|
+
* it's the dominant motion and the fade only needs to read as a quick finish.
|
|
63
|
+
*/
|
|
64
|
+
const SIZE_PHASE = 0.7;
|
|
65
|
+
/**
|
|
66
|
+
* Animated `addChildAt`: insert the child at `index` **already collapsed to 0**,
|
|
67
|
+
* then grow it in — fading opacity up and expanding its box from 0 → its natural
|
|
68
|
+
* size so the surrounding siblings **slide over to make room** rather than
|
|
69
|
+
* jumping. The mirror of {@link removeChildAtAnimated} (which pins to the
|
|
70
|
+
* measured size and shrinks to 0).
|
|
71
|
+
*
|
|
72
|
+
* A numeric-sized axis has its target size in hand up front. A `"hug"`/`"fill"`
|
|
73
|
+
* axis does not — its size is only known once laid out — so we measure the child
|
|
74
|
+
* **detached** (via {@link measureDetached}, using the parent's retained
|
|
75
|
+
* constraints + scope) *before* attaching it. That keeps the child out of the
|
|
76
|
+
* parent's layout flow while we size it, so the siblings never see it at full
|
|
77
|
+
* width for a frame — no reflow flash. The child is then added at 0 and the tween
|
|
78
|
+
* grows it to that measured size. Because the tween needs *numeric* endpoints
|
|
79
|
+
* (a string size only snaps, it can't interpolate), the original size token is
|
|
80
|
+
* restored once the command reaches its end so the child resumes normal reflow.
|
|
81
|
+
*
|
|
82
|
+
* If the parent hasn't been measured yet (no retained scope — nothing is on
|
|
83
|
+
* screen to reflow against), a non-numeric axis simply can't be pre-measured;
|
|
84
|
+
* it falls back to its authored token and fades in without a width tween.
|
|
85
|
+
*/
|
|
86
|
+
export function addChildAtAnimated(parent, child, index, duration, easing) {
|
|
87
|
+
let animation = null;
|
|
88
|
+
let isNumericW = false;
|
|
89
|
+
let isNumericH = false;
|
|
90
|
+
let origW;
|
|
91
|
+
let origH;
|
|
92
|
+
const setup = () => {
|
|
93
|
+
const targetOpacity = child.opacity;
|
|
94
|
+
// Remember the authored size tokens so a hug/fill axis can be restored
|
|
95
|
+
// after the numeric grow-in tween finishes.
|
|
96
|
+
origW = child.width;
|
|
97
|
+
origH = child.height;
|
|
98
|
+
isNumericW = typeof origW === "number";
|
|
99
|
+
isNumericH = typeof origH === "number";
|
|
100
|
+
// Pre-measure any non-numeric axis while the child is still detached, so
|
|
101
|
+
// sizing it can't shift the parent's existing children for a frame.
|
|
102
|
+
const detached = isNumericW && isNumericH ? null : measureDetached(parent, child);
|
|
103
|
+
// Resolve each axis' grow-to target: a numeric axis uses its authored
|
|
104
|
+
// size; a hug/fill axis uses the detached measurement (or gives up the
|
|
105
|
+
// width tween if the parent isn't measured yet).
|
|
106
|
+
const tweenW = isNumericW || detached !== null;
|
|
107
|
+
const tweenH = isNumericH || detached !== null;
|
|
108
|
+
const targetW = isNumericW ? origW : (detached?.width ?? 0);
|
|
109
|
+
const targetH = isNumericH ? origH : (detached?.height ?? 0);
|
|
110
|
+
// Collapse the axes we can tween to 0 before inserting, so the child
|
|
111
|
+
// enters taking no room and the siblings hold their positions.
|
|
112
|
+
// `gapScale: 0` also suppresses the gap this child would add, so the
|
|
113
|
+
// flanking gap opens from 0 rather than snapping in the instant it
|
|
114
|
+
// attaches.
|
|
115
|
+
child.set({
|
|
116
|
+
opacity: 0,
|
|
117
|
+
gapScale: 0,
|
|
118
|
+
...(tweenW ? { width: 0 } : {}),
|
|
119
|
+
...(tweenH ? { height: 0 } : {}),
|
|
120
|
+
});
|
|
121
|
+
parent.addChildAt({ data: { child, index } });
|
|
122
|
+
const sizeProps = {};
|
|
123
|
+
if (tweenW)
|
|
124
|
+
sizeProps.width = targetW;
|
|
125
|
+
if (tweenH)
|
|
126
|
+
sizeProps.height = targetH;
|
|
127
|
+
// Two sequential phases so the fading-in child never overlaps siblings
|
|
128
|
+
// that are still sliding: first open the box and the flanking gap
|
|
129
|
+
// (opacity held at 0, so nothing is visible while the space is being
|
|
130
|
+
// made), then fade the now-placed child in. `gapScale` 0 → 1 tracks the
|
|
131
|
+
// size so siblings slide over continuously instead of jumping by `gap`.
|
|
132
|
+
const grow = duration * SIZE_PHASE;
|
|
133
|
+
const fade = duration - grow;
|
|
134
|
+
return commandSequence(child, commandParallel(child, child.to({ data: sizeProps, duration: grow, easing }), child.to({ data: { gapScale: 1 }, duration: grow, easing })), child.to({ data: { opacity: targetOpacity }, duration: fade, easing }));
|
|
135
|
+
};
|
|
136
|
+
return driveCommand(duration, (t) => {
|
|
137
|
+
if (!animation)
|
|
138
|
+
animation = setup();
|
|
139
|
+
animation.at(t);
|
|
140
|
+
if (t >= 1) {
|
|
141
|
+
// Restore any hug/fill token so the child reflows naturally from
|
|
142
|
+
// here on; the tween already landed the axis on its measured pixel
|
|
143
|
+
// size, so this is seamless.
|
|
144
|
+
const restore = {};
|
|
145
|
+
if (!isNumericW)
|
|
146
|
+
restore.width = origW;
|
|
147
|
+
if (!isNumericH)
|
|
148
|
+
restore.height = origH;
|
|
149
|
+
if (!isNumericW || !isNumericH)
|
|
150
|
+
child.set(restore);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Animated `removeChildAt`: fade+size the child out, then detach it.
|
|
156
|
+
*
|
|
157
|
+
* The child stays in the tree — animating out — until the command reaches its
|
|
158
|
+
* end (`t === 1`), matching the "insert"/"remove" seekability
|
|
159
|
+
* `packages/components/code` established: a host asking for a time before the
|
|
160
|
+
* end sees the child still present, mid-fade; only reaching the end detaches it.
|
|
161
|
+
* Seeking back below the end after having reached it re-attaches the child at
|
|
162
|
+
* its original index, so the animation stays a function of `t` in both
|
|
163
|
+
* directions rather than a one-way commit.
|
|
164
|
+
*/
|
|
165
|
+
export function removeChildAtAnimated(parent, index, duration, easing) {
|
|
166
|
+
let child = null;
|
|
167
|
+
let animation = null;
|
|
168
|
+
let setupDone = false;
|
|
169
|
+
const setup = () => {
|
|
170
|
+
setupDone = true;
|
|
171
|
+
// Out of range: nothing to animate — `child`/`animation` stay null, and
|
|
172
|
+
// every apply() below becomes a no-op.
|
|
173
|
+
if (index < 0 || index >= parent.children.length)
|
|
174
|
+
return;
|
|
175
|
+
child = parent.children[index];
|
|
176
|
+
// Pin to current rendered size so the shrink reflows siblings in the
|
|
177
|
+
// parent layout.
|
|
178
|
+
const lw = child.measuredWidth;
|
|
179
|
+
const lh = child.measuredHeight;
|
|
180
|
+
child.set({ width: lw, height: lh });
|
|
181
|
+
// Mirror of the insert: fade the child out first (box held at full
|
|
182
|
+
// size, so it doesn't overlap siblings mid-fade), then collapse the
|
|
183
|
+
// box and close the gap. `gapScale` 1 → 0 tracks the shrink so the gap
|
|
184
|
+
// closes continuously.
|
|
185
|
+
const fade = duration * (1 - SIZE_PHASE);
|
|
186
|
+
const shrink = duration - fade;
|
|
187
|
+
animation = commandSequence(child, child.to({ data: { opacity: 0 }, duration: fade, easing }), commandParallel(child, child.to({ data: { width: 0, height: 0 }, duration: shrink, easing }), child.to({ data: { gapScale: 0 }, duration: shrink, easing })));
|
|
188
|
+
};
|
|
189
|
+
return driveCommand(duration, (t) => {
|
|
190
|
+
if (!setupDone)
|
|
191
|
+
setup();
|
|
192
|
+
if (!animation || !child)
|
|
193
|
+
return;
|
|
194
|
+
const done = t >= 1;
|
|
195
|
+
if (!done && child.parent !== parent) {
|
|
196
|
+
// Seeking back into the animation after it had reached the end —
|
|
197
|
+
// the child is what's animating out, so put it back.
|
|
198
|
+
parent.addChildAt({ data: { child, index: Math.min(index, parent.children.length) } });
|
|
199
|
+
}
|
|
200
|
+
animation.at(t);
|
|
201
|
+
if (done) {
|
|
202
|
+
parent.remove(child);
|
|
203
|
+
// The child is detached now, so its 0 gapScale no longer affects any
|
|
204
|
+
// layout — but the same node can be re-added later (scenes reuse
|
|
205
|
+
// refs), and a plain (non-animated) addChild wouldn't reset it.
|
|
206
|
+
// Restore the default so a stale 0 can't silently swallow a gap on
|
|
207
|
+
// re-insert.
|
|
208
|
+
child.set({ gapScale: 1 });
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Animated `reparent`: fade+size the node out of its current parent, then
|
|
214
|
+
* reparent it and fade+size it in. The handoff happens at the animation's
|
|
215
|
+
* midpoint (`t === 0.5`) — seeking across it in either direction moves the node
|
|
216
|
+
* between parents to match, the same bidirectional membership rule
|
|
217
|
+
* {@link removeChildAtAnimated} uses.
|
|
218
|
+
*/
|
|
219
|
+
export function reparentAnimated(node, newParent, duration, easing) {
|
|
220
|
+
const half = duration / 2;
|
|
221
|
+
let animation = null;
|
|
222
|
+
let oldParent = null;
|
|
223
|
+
const setup = () => {
|
|
224
|
+
const targetOpacity = node.opacity;
|
|
225
|
+
oldParent = node.parent;
|
|
226
|
+
// Pin to current rendered size so exit shrink reflows the old parent.
|
|
227
|
+
const lw = node.measuredWidth;
|
|
228
|
+
const lh = node.measuredHeight;
|
|
229
|
+
node.set({ width: lw, height: lh });
|
|
230
|
+
// Exit the old parent (fade out, then collapse the box + gap) over the
|
|
231
|
+
// first half, then enter the new one (open the box + gap, then fade
|
|
232
|
+
// in) over the second — one flat sequence, so evaluating any `t` walks
|
|
233
|
+
// and settles every phase before it first. That is what makes the
|
|
234
|
+
// *enter* tweens' `from` correct even when a driven host asks for a
|
|
235
|
+
// time straight into the enter half without ever having evaluated the
|
|
236
|
+
// exit half first: `commandSequence` re-settles every prior phase on
|
|
237
|
+
// each call, so by the time an enter tween's `from` is lazily
|
|
238
|
+
// snapshotted (its own first evaluation), the exit phase has already
|
|
239
|
+
// collapsed the node to the state enter grows from.
|
|
240
|
+
const exitFade = half * (1 - SIZE_PHASE);
|
|
241
|
+
const exitShrink = half - exitFade;
|
|
242
|
+
const enterGrow = half * SIZE_PHASE;
|
|
243
|
+
const enterFade = half - enterGrow;
|
|
244
|
+
return commandSequence(node, node.to({ data: { opacity: 0 }, duration: exitFade, easing }), commandParallel(node, node.to({ data: { width: 0, height: 0 }, duration: exitShrink, easing }), node.to({ data: { gapScale: 0 }, duration: exitShrink, easing })), commandParallel(node, node.to({ data: { width: lw, height: lh }, duration: enterGrow, easing }), node.to({ data: { gapScale: 1 }, duration: enterGrow, easing })), node.to({ data: { opacity: targetOpacity }, duration: enterFade, easing }));
|
|
245
|
+
};
|
|
246
|
+
return driveCommand(duration, (t) => {
|
|
247
|
+
if (!animation)
|
|
248
|
+
animation = setup();
|
|
249
|
+
const elapsed = t * duration;
|
|
250
|
+
const inNewParent = elapsed >= half;
|
|
251
|
+
if (inNewParent && node.parent !== newParent) {
|
|
252
|
+
if (oldParent)
|
|
253
|
+
oldParent.remove(node);
|
|
254
|
+
newParent.add(node);
|
|
255
|
+
}
|
|
256
|
+
else if (!inNewParent && node.parent !== oldParent) {
|
|
257
|
+
newParent.remove(node);
|
|
258
|
+
if (oldParent)
|
|
259
|
+
oldParent.add(node);
|
|
260
|
+
}
|
|
261
|
+
animation.at(t);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=node-lifecycle.js.map
|
|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EAAE,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { EasingFunction } from \"@/tween/ease/type\";\r\nimport { commandParallel, commandSequence, driveCommand, type Command } from \"@/tween/command\";\r\nimport { SizeConstraints } from \"@/layout/constraints\";\r\nimport type { Node2D, Node2DProps } from \"./node2d\";\r\n\r\n/**\r\n * Measure `child`'s natural size **without attaching it to `parent`** — so the\r\n * measurement never perturbs the parent's layout (siblings don't shift for a\r\n * frame). Uses the constraints + scope the parent retained from its last measure\r\n * pass; returns `null` if the parent hasn't been measured yet (nothing on screen\r\n * to reflow against), so the caller can fall back. Reads `parent.lastMeasure` —\r\n * internal layout state the lifecycle helpers are the\r\n * intended in-directory consumer of.\r\n */\r\nfunction measureDetached(parent: Node2D, child: Node2D): { width: number; height: number } | null {\r\n const pass = parent.lastMeasure;\r\n const scope = pass?.measurer;\r\n // The scope (text measurement) is the essential input and is only present once\r\n // the parent has been laid out; without it we can't size a hug child off-tree.\r\n if (!scope) return null;\r\n // The parent's own constraints bound the child; fall back to its laid-out box,\r\n // then to an unbounded space — a hug child shrink-wraps regardless, so a\r\n // generous ceiling is fine.\r\n const constraints: SizeConstraints = pass?.constraints ?? {\r\n maxWidth: parent.measuredWidth || Number.MAX_SAFE_INTEGER,\r\n maxHeight: parent.measuredHeight || Number.MAX_SAFE_INTEGER,\r\n };\r\n const size = child.measure(constraints, scope);\r\n return { width: size.width ?? 0, height: size.height ?? 0 };\r\n}\r\n\r\n/**\r\n * Companion for {@link Node2D}'s animated child-management methods. The sync\r\n * variants (add/remove/clear/addChildAt/\r\n * removeChildAt) stay inline on Node2D — each is a 3–5 line method that mutates\r\n * `_children`/`_parent` and calls `bindAssets`/`bindChildContext`, so there is\r\n * no body worth moving. These are the animated overloads, returned as\r\n * {@link Command}s built from `child.to(...)` composed with\r\n * {@link commandSequence}/{@link commandParallel} — the same choreography\r\n * primitives a node's own multi-step commands use.\r\n *\r\n * Each command's setup (measuring the child, collapsing it, attaching/\r\n * detaching/reparenting) runs **lazily, once, on the command's first\r\n * evaluation** rather than when the function below is called — mirroring the\r\n * generator these replaced, whose body didn't run a single line until the\r\n * caller's first `.next()`. That laziness is load-bearing: a caller often does\r\n * `const cmd = parent.addChildAt(child, i, dur); /* lay the parent out here *\\/\r\n * driveCmd(cmd)`, relying on the parent having a fresh `lastMeasure` by the time\r\n * the hug/fill measurement in {@link addChildAtAnimated} actually runs. Doing\r\n * that measurement eagerly — when this function is called, not when the\r\n * command is first driven — reads whatever scope the parent happened to have\r\n * at call time, which is often none at all.\r\n *\r\n * The container's `gap` is handled by the per-child `gapScale` prop these helpers\r\n * tween in parallel with the child's box (see {@link addChildAtAnimated}); the\r\n * flex layout (`flex.ts`) folds each child's `gapScale` into its gap budget, so\r\n * the gap opens/closes in lockstep with the size instead of popping. No helper\r\n * here needs to know the parent's axis or gap value.\r\n */\r\n\r\n/**\r\n * Fraction of an insert/remove's `duration` spent on the size + gap motion; the\r\n * remainder is the opacity fade. Splitting the two sequentially (grow → fade in,\r\n * fade out → shrink) keeps the fading child from overlapping siblings that are\r\n * still sliding: room is opened while it's invisible, then it fades in already in\r\n * place (and mirror-image on remove). The size phase gets the larger share since\r\n * it's the dominant motion and the fade only needs to read as a quick finish.\r\n */\r\nconst SIZE_PHASE = 0.7;\r\n\r\n/**\r\n * Animated `addChildAt`: insert the child at `index` **already collapsed to 0**,\r\n * then grow it in — fading opacity up and expanding its box from 0 → its natural\r\n * size so the surrounding siblings **slide over to make room** rather than\r\n * jumping. The mirror of {@link removeChildAtAnimated} (which pins to the\r\n * measured size and shrinks to 0).\r\n *\r\n * A numeric-sized axis has its target size in hand up front. A `\"hug\"`/`\"fill\"`\r\n * axis does not — its size is only known once laid out — so we measure the child\r\n * **detached** (via {@link measureDetached}, using the parent's retained\r\n * constraints + scope) *before* attaching it. That keeps the child out of the\r\n * parent's layout flow while we size it, so the siblings never see it at full\r\n * width for a frame — no reflow flash. The child is then added at 0 and the tween\r\n * grows it to that measured size. Because the tween needs *numeric* endpoints\r\n * (a string size only snaps, it can't interpolate), the original size token is\r\n * restored once the command reaches its end so the child resumes normal reflow.\r\n *\r\n * If the parent hasn't been measured yet (no retained scope — nothing is on\r\n * screen to reflow against), a non-numeric axis simply can't be pre-measured;\r\n * it falls back to its authored token and fades in without a width tween.\r\n */\r\nexport function addChildAtAnimated(\r\n parent: Node2D,\r\n child: Node2D,\r\n index: number,\r\n duration: number,\r\n easing?: EasingFunction,\r\n): Command<Record<string, never>> {\r\n let animation: Command<Node2DProps> | null = null;\r\n let isNumericW = false;\r\n let isNumericH = false;\r\n let origW: Node2DProps[\"width\"];\r\n let origH: Node2DProps[\"height\"];\r\n\r\n const setup = (): Command<Node2DProps> => {\r\n const targetOpacity = child.opacity;\r\n // Remember the authored size tokens so a hug/fill axis can be restored\r\n // after the numeric grow-in tween finishes.\r\n origW = child.width;\r\n origH = child.height;\r\n isNumericW = typeof origW === \"number\";\r\n isNumericH = typeof origH === \"number\";\r\n\r\n // Pre-measure any non-numeric axis while the child is still detached, so\r\n // sizing it can't shift the parent's existing children for a frame.\r\n const detached = isNumericW && isNumericH ? null : measureDetached(parent, child);\r\n\r\n // Resolve each axis' grow-to target: a numeric axis uses its authored\r\n // size; a hug/fill axis uses the detached measurement (or gives up the\r\n // width tween if the parent isn't measured yet).\r\n const tweenW = isNumericW || detached !== null;\r\n const tweenH = isNumericH || detached !== null;\r\n const targetW = isNumericW ? (origW as number) : (detached?.width ?? 0);\r\n const targetH = isNumericH ? (origH as number) : (detached?.height ?? 0);\r\n\r\n // Collapse the axes we can tween to 0 before inserting, so the child\r\n // enters taking no room and the siblings hold their positions.\r\n // `gapScale: 0` also suppresses the gap this child would add, so the\r\n // flanking gap opens from 0 rather than snapping in the instant it\r\n // attaches.\r\n child.set({\r\n opacity: 0,\r\n gapScale: 0,\r\n ...(tweenW ? { width: 0 } : {}),\r\n ...(tweenH ? { height: 0 } : {}),\r\n } as Partial<Node2DProps>);\r\n parent.addChildAt({ data: { child, index } });\r\n\r\n const sizeProps: Partial<Node2DProps> = {};\r\n if (tweenW) sizeProps.width = targetW;\r\n if (tweenH) sizeProps.height = targetH;\r\n // Two sequential phases so the fading-in child never overlaps siblings\r\n // that are still sliding: first open the box and the flanking gap\r\n // (opacity held at 0, so nothing is visible while the space is being\r\n // made), then fade the now-placed child in. `gapScale` 0 → 1 tracks the\r\n // size so siblings slide over continuously instead of jumping by `gap`.\r\n const grow = duration * SIZE_PHASE;\r\n const fade = duration - grow;\r\n return commandSequence<Node2DProps>(\r\n child,\r\n commandParallel<Node2DProps>(\r\n child,\r\n child.to({ data: sizeProps, duration: grow, easing }),\r\n child.to({ data: { gapScale: 1 } as Partial<Node2DProps>, duration: grow, easing }),\r\n ),\r\n child.to({ data: { opacity: targetOpacity } as Partial<Node2DProps>, duration: fade, easing }),\r\n );\r\n };\r\n\r\n return driveCommand(duration, (t) => {\r\n if (!animation) animation = setup();\r\n animation.at(t);\r\n if (t >= 1) {\r\n // Restore any hug/fill token so the child reflows naturally from\r\n // here on; the tween already landed the axis on its measured pixel\r\n // size, so this is seamless.\r\n const restore: Partial<Node2DProps> = {};\r\n if (!isNumericW) restore.width = origW;\r\n if (!isNumericH) restore.height = origH;\r\n if (!isNumericW || !isNumericH) child.set(restore as Partial<Node2DProps>);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Animated `removeChildAt`: fade+size the child out, then detach it.\r\n *\r\n * The child stays in the tree — animating out — until the command reaches its\r\n * end (`t === 1`), matching the \"insert\"/\"remove\" seekability\r\n * `packages/components/code` established: a host asking for a time before the\r\n * end sees the child still present, mid-fade; only reaching the end detaches it.\r\n * Seeking back below the end after having reached it re-attaches the child at\r\n * its original index, so the animation stays a function of `t` in both\r\n * directions rather than a one-way commit.\r\n */\r\nexport function removeChildAtAnimated(\r\n parent: Node2D,\r\n index: number,\r\n duration: number,\r\n easing?: EasingFunction,\r\n): Command<Record<string, never>> {\r\n let child: Node2D | null = null;\r\n let animation: Command<Node2DProps> | null = null;\r\n let setupDone = false;\r\n\r\n const setup = (): void => {\r\n setupDone = true;\r\n // Out of range: nothing to animate — `child`/`animation` stay null, and\r\n // every apply() below becomes a no-op.\r\n if (index < 0 || index >= parent.children.length) return;\r\n child = parent.children[index];\r\n\r\n // Pin to current rendered size so the shrink reflows siblings in the\r\n // parent layout.\r\n const lw = child.measuredWidth;\r\n const lh = child.measuredHeight;\r\n child.set({ width: lw, height: lh } as Partial<Node2DProps>);\r\n\r\n // Mirror of the insert: fade the child out first (box held at full\r\n // size, so it doesn't overlap siblings mid-fade), then collapse the\r\n // box and close the gap. `gapScale` 1 → 0 tracks the shrink so the gap\r\n // closes continuously.\r\n const fade = duration * (1 - SIZE_PHASE);\r\n const shrink = duration - fade;\r\n animation = commandSequence<Node2DProps>(\r\n child,\r\n child.to({ data: { opacity: 0 } as Partial<Node2DProps>, duration: fade, easing }),\r\n commandParallel<Node2DProps>(\r\n child,\r\n child.to({ data: { width: 0, height: 0 } as Partial<Node2DProps>, duration: shrink, easing }),\r\n child.to({ data: { gapScale: 0 } as Partial<Node2DProps>, duration: shrink, easing }),\r\n ),\r\n );\r\n };\r\n\r\n return driveCommand(duration, (t) => {\r\n if (!setupDone) setup();\r\n if (!animation || !child) return;\r\n const done = t >= 1;\r\n if (!done && child.parent !== parent) {\r\n // Seeking back into the animation after it had reached the end —\r\n // the child is what's animating out, so put it back.\r\n parent.addChildAt({ data: { child, index: Math.min(index, parent.children.length) } });\r\n }\r\n animation.at(t);\r\n if (done) {\r\n parent.remove(child);\r\n // The child is detached now, so its 0 gapScale no longer affects any\r\n // layout — but the same node can be re-added later (scenes reuse\r\n // refs), and a plain (non-animated) addChild wouldn't reset it.\r\n // Restore the default so a stale 0 can't silently swallow a gap on\r\n // re-insert.\r\n child.set({ gapScale: 1 } as Partial<Node2DProps>);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Animated `reparent`: fade+size the node out of its current parent, then\r\n * reparent it and fade+size it in. The handoff happens at the animation's\r\n * midpoint (`t === 0.5`) — seeking across it in either direction moves the node\r\n * between parents to match, the same bidirectional membership rule\r\n * {@link removeChildAtAnimated} uses.\r\n */\r\nexport function reparentAnimated(\r\n node: Node2D,\r\n newParent: Node2D,\r\n duration: number,\r\n easing?: EasingFunction,\r\n): Command<Record<string, never>> {\r\n const half = duration / 2;\r\n let animation: Command<Node2DProps> | null = null;\r\n let oldParent: Node2D | null = null;\r\n\r\n const setup = (): Command<Node2DProps> => {\r\n const targetOpacity = node.opacity;\r\n oldParent = node.parent;\r\n\r\n // Pin to current rendered size so exit shrink reflows the old parent.\r\n const lw = node.measuredWidth;\r\n const lh = node.measuredHeight;\r\n node.set({ width: lw, height: lh } as Partial<Node2DProps>);\r\n\r\n // Exit the old parent (fade out, then collapse the box + gap) over the\r\n // first half, then enter the new one (open the box + gap, then fade\r\n // in) over the second — one flat sequence, so evaluating any `t` walks\r\n // and settles every phase before it first. That is what makes the\r\n // *enter* tweens' `from` correct even when a driven host asks for a\r\n // time straight into the enter half without ever having evaluated the\r\n // exit half first: `commandSequence` re-settles every prior phase on\r\n // each call, so by the time an enter tween's `from` is lazily\r\n // snapshotted (its own first evaluation), the exit phase has already\r\n // collapsed the node to the state enter grows from.\r\n const exitFade = half * (1 - SIZE_PHASE);\r\n const exitShrink = half - exitFade;\r\n const enterGrow = half * SIZE_PHASE;\r\n const enterFade = half - enterGrow;\r\n return commandSequence<Node2DProps>(\r\n node,\r\n node.to({ data: { opacity: 0 } as Partial<Node2DProps>, duration: exitFade, easing }),\r\n commandParallel<Node2DProps>(\r\n node,\r\n node.to({ data: { width: 0, height: 0 } as Partial<Node2DProps>, duration: exitShrink, easing }),\r\n node.to({ data: { gapScale: 0 } as Partial<Node2DProps>, duration: exitShrink, easing }),\r\n ),\r\n commandParallel<Node2DProps>(\r\n node,\r\n node.to({ data: { width: lw, height: lh } as Partial<Node2DProps>, duration: enterGrow, easing }),\r\n node.to({ data: { gapScale: 1 } as Partial<Node2DProps>, duration: enterGrow, easing }),\r\n ),\r\n node.to({ data: { opacity: targetOpacity } as Partial<Node2DProps>, duration: enterFade, easing }),\r\n );\r\n };\r\n\r\n return driveCommand(duration, (t) => {\r\n if (!animation) animation = setup();\r\n const elapsed = t * duration;\r\n const inNewParent = elapsed >= half;\r\n if (inNewParent && node.parent !== newParent) {\r\n if (oldParent) oldParent.remove(node);\r\n newParent.add(node);\r\n } else if (!inNewParent && node.parent !== oldParent) {\r\n newParent.remove(node);\r\n if (oldParent) oldParent.add(node);\r\n }\r\n animation.at(t);\r\n });\r\n}\r\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NodeRenderState } from "../../../render/render-context2d.js";
|
|
2
|
+
import { Vector2 } from "../../../attributes/layout/vector2.js";
|
|
3
|
+
/**
|
|
4
|
+
* Companion for {@link Node2D}'s clock advance and per-frame motion sampling. The
|
|
5
|
+
* reactive prop reads (x/y/rotation/scale) stay in Node2D's thin `_sampleMotion`
|
|
6
|
+
* wrapper; the backward-difference math lives here as a pure function over the
|
|
7
|
+
* reused scratch state — no per-frame allocation (the {@link MotionHistory}
|
|
8
|
+
* holder is created once per node at construction).
|
|
9
|
+
*/
|
|
10
|
+
/** Largest frame delta we trust for a velocity estimate (seconds). Larger gaps (scrub/seek) read as "unknown". */
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare const MAX_MOTION_DT = 0.2;
|
|
13
|
+
/**
|
|
14
|
+
* Per-node rolling history for the backward-difference velocity estimate.
|
|
15
|
+
* Allocated once with the node (mirrors the reused `_renderState` scratch), then
|
|
16
|
+
* mutated in place by {@link sampleMotion} each frame.
|
|
17
|
+
*/
|
|
18
|
+
/** @internal */
|
|
19
|
+
export interface MotionHistory {
|
|
20
|
+
prevPos: Vector2 | null;
|
|
21
|
+
prevTime: number;
|
|
22
|
+
prevRotation: number;
|
|
23
|
+
prevScale: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Record the current position as the history's previous frame, **without**
|
|
27
|
+
* deriving a velocity from it.
|
|
28
|
+
*
|
|
29
|
+
* The seam a driven scene primes through. A generator scene walks time forward
|
|
30
|
+
* one `dt` at a time, so its history is always the frame before and
|
|
31
|
+
* {@link sampleMotion}'s backward difference is a property of the timeline. A
|
|
32
|
+
* driven scene doesn't walk at all — it jumps straight to whatever frame is
|
|
33
|
+
* asked for — so differencing against "wherever the playhead last was" makes
|
|
34
|
+
* velocity a property of *how the viewer got here*: scrub quickly and a static
|
|
35
|
+
* node smears, hold still on the same frame and it doesn't, step backward and it
|
|
36
|
+
* reads zero. Priming with the position one frame earlier is what makes the
|
|
37
|
+
* answer depend on the frame alone.
|
|
38
|
+
*/
|
|
39
|
+
/** @internal */
|
|
40
|
+
export declare function primeMotion(history: MotionHistory, x: number, y: number, rotation: number, scale: number, at: number): void;
|
|
41
|
+
/** Create the zeroed history holder a node keeps for its lifetime. */
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare function createMotionHistory(): MotionHistory;
|
|
44
|
+
/**
|
|
45
|
+
* Compute this frame's motion (velocity/direction/speed/angular/scale) into the
|
|
46
|
+
* reused `state` as a backward difference against `history`, then roll the
|
|
47
|
+
* history forward. Velocity is `0`/`{0,0}` when no trustworthy delta exists —
|
|
48
|
+
* the first frame, or after a non-monotonic time jump (only `0 < dt <= MAX` is
|
|
49
|
+
* trusted, so a scrub that resets the clock reads as "unknown" rather than a
|
|
50
|
+
* spurious huge velocity). `x`/`y` are the world position (y-down) the caller
|
|
51
|
+
* resolved from `layoutBounds + x` / `layoutBounds - y`. Layout-dependent fields
|
|
52
|
+
* (`rects`/`elapsed`) are filled in later, at draw time.
|
|
53
|
+
*/
|
|
54
|
+
/** @internal */
|
|
55
|
+
export declare function sampleMotion(state: NodeRenderState, history: MotionHistory, x: number, y: number, rotation: number, scale: number, now: number): void;
|
|
56
|
+
//# sourceMappingURL=node-motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-motion.d.ts","sourceRoot":"","sources":["../../../../src/components/trees/2d/node-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD;;;;;;GAMG;AAEH,kHAAkH;AAClH,gBAAgB;AAChB,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC;;;;GAIG;AACH,gBAAgB;AAChB,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,gBAAgB;AAChB,wBAAgB,WAAW,CACvB,OAAO,EAAE,aAAa,EACtB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,GACX,IAAI,CAMN;AAED,sEAAsE;AACtE,gBAAgB;AAChB,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD;AAED;;;;;;;;;GASG;AACH,gBAAgB;AAChB,wBAAgB,YAAY,CACxB,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,aAAa,EACtB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACZ,IAAI,CA4BN"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Companion for {@link Node2D}'s clock advance and per-frame motion sampling. The
|
|
3
|
+
* reactive prop reads (x/y/rotation/scale) stay in Node2D's thin `_sampleMotion`
|
|
4
|
+
* wrapper; the backward-difference math lives here as a pure function over the
|
|
5
|
+
* reused scratch state — no per-frame allocation (the {@link MotionHistory}
|
|
6
|
+
* holder is created once per node at construction).
|
|
7
|
+
*/
|
|
8
|
+
/** Largest frame delta we trust for a velocity estimate (seconds). Larger gaps (scrub/seek) read as "unknown". */
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const MAX_MOTION_DT = 0.2;
|
|
11
|
+
/**
|
|
12
|
+
* Record the current position as the history's previous frame, **without**
|
|
13
|
+
* deriving a velocity from it.
|
|
14
|
+
*
|
|
15
|
+
* The seam a driven scene primes through. A generator scene walks time forward
|
|
16
|
+
* one `dt` at a time, so its history is always the frame before and
|
|
17
|
+
* {@link sampleMotion}'s backward difference is a property of the timeline. A
|
|
18
|
+
* driven scene doesn't walk at all — it jumps straight to whatever frame is
|
|
19
|
+
* asked for — so differencing against "wherever the playhead last was" makes
|
|
20
|
+
* velocity a property of *how the viewer got here*: scrub quickly and a static
|
|
21
|
+
* node smears, hold still on the same frame and it doesn't, step backward and it
|
|
22
|
+
* reads zero. Priming with the position one frame earlier is what makes the
|
|
23
|
+
* answer depend on the frame alone.
|
|
24
|
+
*/
|
|
25
|
+
/** @internal */
|
|
26
|
+
export function primeMotion(history, x, y, rotation, scale, at) {
|
|
27
|
+
if (!history.prevPos)
|
|
28
|
+
history.prevPos = { x, y };
|
|
29
|
+
else {
|
|
30
|
+
history.prevPos.x = x;
|
|
31
|
+
history.prevPos.y = y;
|
|
32
|
+
}
|
|
33
|
+
history.prevTime = at;
|
|
34
|
+
history.prevRotation = rotation;
|
|
35
|
+
history.prevScale = scale;
|
|
36
|
+
}
|
|
37
|
+
/** Create the zeroed history holder a node keeps for its lifetime. */
|
|
38
|
+
/** @internal */
|
|
39
|
+
export function createMotionHistory() {
|
|
40
|
+
return { prevPos: null, prevTime: 0, prevRotation: 0, prevScale: 1 };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Compute this frame's motion (velocity/direction/speed/angular/scale) into the
|
|
44
|
+
* reused `state` as a backward difference against `history`, then roll the
|
|
45
|
+
* history forward. Velocity is `0`/`{0,0}` when no trustworthy delta exists —
|
|
46
|
+
* the first frame, or after a non-monotonic time jump (only `0 < dt <= MAX` is
|
|
47
|
+
* trusted, so a scrub that resets the clock reads as "unknown" rather than a
|
|
48
|
+
* spurious huge velocity). `x`/`y` are the world position (y-down) the caller
|
|
49
|
+
* resolved from `layoutBounds + x` / `layoutBounds - y`. Layout-dependent fields
|
|
50
|
+
* (`rects`/`elapsed`) are filled in later, at draw time.
|
|
51
|
+
*/
|
|
52
|
+
/** @internal */
|
|
53
|
+
export function sampleMotion(state, history, x, y, rotation, scale, now) {
|
|
54
|
+
const dt = now - history.prevTime;
|
|
55
|
+
const prev = history.prevPos;
|
|
56
|
+
if (prev && dt > 0 && dt <= MAX_MOTION_DT) {
|
|
57
|
+
const vx = (x - prev.x) / dt;
|
|
58
|
+
const vy = (y - prev.y) / dt;
|
|
59
|
+
state.dt = dt;
|
|
60
|
+
state.velocity.x = vx;
|
|
61
|
+
state.velocity.y = vy;
|
|
62
|
+
state.speed = Math.hypot(vx, vy);
|
|
63
|
+
state.direction = (Math.atan2(vy, vx) * 180) / Math.PI;
|
|
64
|
+
state.angularVelocity = (rotation - history.prevRotation) / dt;
|
|
65
|
+
state.scaleVelocity = (scale - history.prevScale) / dt;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
state.dt = 0;
|
|
69
|
+
state.velocity.x = 0;
|
|
70
|
+
state.velocity.y = 0;
|
|
71
|
+
state.speed = 0;
|
|
72
|
+
state.direction = 0;
|
|
73
|
+
state.angularVelocity = 0;
|
|
74
|
+
state.scaleVelocity = 0;
|
|
75
|
+
}
|
|
76
|
+
if (!prev)
|
|
77
|
+
history.prevPos = { x, y };
|
|
78
|
+
else {
|
|
79
|
+
prev.x = x;
|
|
80
|
+
prev.y = y;
|
|
81
|
+
}
|
|
82
|
+
history.prevTime = now;
|
|
83
|
+
history.prevRotation = rotation;
|
|
84
|
+
history.prevScale = scale;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=node-motion.js.map
|