@motionscript/core 0.1.0-alpha.6 → 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 +28 -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-DHB4COFY.js.map → chunk-LKUYVFU3.js.map} +4 -4
- 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 +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +2 -4
- package/dist/browser/sdk.js +1 -1
- package/dist/component.d.ts +10 -18
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +10 -17
- 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/builtins.js +13 -13
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +2 -2
- package/dist/document/command-traits.js +1 -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/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 +3 -3
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/registry.d.ts +23 -25
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +12 -18
- package/dist/document/registry.js.map +1 -1
- package/dist/document/timeline.d.ts +3 -3
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +2 -2
- 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 +19 -19
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +17 -17
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -11
- 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/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 +3 -3
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +4 -4
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +2 -3
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +17 -35
- 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 +3 -3
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +2 -2
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +1 -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 +4 -5
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +43 -39
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +24 -25
- 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 +1 -1
- 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 +2 -10
- package/dist/browser/chunks/chunk-2RIYH36X.js +0 -3
- package/dist/browser/chunks/chunk-2RIYH36X.js.map +0 -7
- package/dist/browser/chunks/chunk-DDJN3QII.js +0 -15
- package/dist/browser/chunks/chunk-DDJN3QII.js.map +0 -7
- package/dist/browser/chunks/chunk-DHB4COFY.js +0 -2
- package/dist/browser/chunks/chunk-EJDPYDQI.js +0 -5
- package/dist/browser/chunks/chunk-EJDPYDQI.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/chunks/chunk-XAWE4EAK.js +0 -2
- package/dist/browser/chunks/chunk-XAWE4EAK.js.map +0 -7
- package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
- package/dist/browser/jsx-jsx-dev-runtime.js.map +0 -7
- package/dist/browser/jsx-jsx-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js.map +0 -7
|
@@ -89,7 +89,7 @@ export const Tex = {
|
|
|
89
89
|
* const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);
|
|
90
90
|
* g3.plane({ fill: scope }); // sized for you
|
|
91
91
|
*
|
|
92
|
-
* const stats =
|
|
92
|
+
* const stats = new Rect({ flow: "vertical", padding: 48, children: [Text({ text: "CPU" })] });
|
|
93
93
|
* g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });
|
|
94
94
|
*
|
|
95
95
|
* `width`/`height` are the buffer's resolution and default to 512. A source
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/render3d/builders.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,GAAG,EAAE,CAAC,CAA2B,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;IAC5E,MAAM,EAAE,CAAC,CAA8B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,KAAK,EAAE,CAAC,CAA6B,EAAmB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IACpF,QAAQ,EAAE,CAAC,CAAgC,EAAsB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC;IAChG,IAAI,EAAE,CAAC,CAA4B,EAAkB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM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AE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,gFAAgF;IAChF,MAAM,EAAE,CAAC,CAA6B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;CACjF,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,KAAK,EAAE,CAAC,GAAW,EAAE,CAAoB,EAAkB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7E,uEAAuE;IACvE,IAAI,EAAE,CACF,IAAuB,EACvB,KAAa,EACb,MAAc,EACd,CAA4C,EAC/B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IACnD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,EAAE,CACL,MAAuB,EACvB,CAAkF,EAClE,EAAE,CAAC,CAAC;QACpB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,GAAG,CAAC;QACJ,MAAM;KACT,CAAC;CACI,CAAC","sourcesContent":["import type {\r\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D,\r\n ConeGeometry3D, CylinderGeometry3D, EdgesGeometry3D, ExtrudeGeometry3D,\r\n Geometry3D, LatheGeometry3D, ModelGeometry3D, ParametricGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D, WireframeGeometry3D,\r\n} from \"./geometry\";\r\nimport type {\r\n BasicMaterial3D, DepthMaterial3D, LambertMaterial3D, LineBasicMaterial3D,\r\n LineDashedMaterial3D, MatcapMaterial3D, NormalMaterial3D, PhongMaterial3D,\r\n PhysicalMaterial3D, PointsMaterial3D, ShaderMaterial3D, ShadowMaterial3D,\r\n SpriteMaterial3D, StandardMaterial3D, ToonMaterial3D,\r\n} from \"./material\";\r\nimport type { DataTexture3D, ImageTexture3D, SurfaceSource3D, SurfaceTexture3D, TextureOptions3D } from \"./texture\";\r\n\r\n/** A descriptor's own params, with the `type` discriminant removed. */\r\ntype ParamsOf<T> = Omit<T, \"type\">;\r\n\r\n/**\r\n * Geometry descriptors.\r\n *\r\n * These are plain values, so hoist one out of the builder and share it across\r\n * meshes — the renderer dedupes by identity, so a shared geometry is uploaded to\r\n * the GPU once no matter how many meshes reference it.\r\n *\r\n * const brick = Geo.box({ width: 1, height: 0.5, depth: 0.5 });\r\n * g.mesh(brick, red, { position: [0, 0, 0] })\r\n * .mesh(brick, red, { position: [1, 0, 0] }); // same GPU buffer\r\n */\r\nexport const Geo = {\r\n box: (o?: ParamsOf<BoxGeometry3D>): BoxGeometry3D => ({ type: \"box\", ...o }),\r\n sphere: (o?: ParamsOf<SphereGeometry3D>): SphereGeometry3D => ({ type: \"sphere\", ...o }),\r\n plane: (o?: ParamsOf<PlaneGeometry3D>): PlaneGeometry3D => ({ type: \"plane\", ...o }),\r\n cylinder: (o?: ParamsOf<CylinderGeometry3D>): CylinderGeometry3D => ({ type: \"cylinder\", ...o }),\r\n cone: (o?: ParamsOf<ConeGeometry3D>): ConeGeometry3D => ({ type: \"cone\", ...o }),\r\n torus: (o?: ParamsOf<TorusGeometry3D>): TorusGeometry3D => ({ type: \"torus\", ...o }),\r\n torusKnot: (o?: ParamsOf<TorusKnotGeometry3D>): TorusKnotGeometry3D => ({ type: \"torusKnot\", ...o }),\r\n circle: (o?: ParamsOf<CircleGeometry3D>): CircleGeometry3D => ({ type: \"circle\", ...o }),\r\n ring: (o?: ParamsOf<RingGeometry3D>): RingGeometry3D => ({ type: \"ring\", ...o }),\r\n capsule: (o?: ParamsOf<CapsuleGeometry3D>): CapsuleGeometry3D => ({ type: \"capsule\", ...o }),\r\n\r\n tetrahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"tetrahedron\", ...o }),\r\n octahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"octahedron\", ...o }),\r\n icosahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"icosahedron\", ...o }),\r\n dodecahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"dodecahedron\", ...o }),\r\n\r\n extrude: (o: ParamsOf<ExtrudeGeometry3D>): ExtrudeGeometry3D => ({ type: \"extrude\", ...o }),\r\n lathe: (o: ParamsOf<LatheGeometry3D>): LatheGeometry3D => ({ type: \"lathe\", ...o }),\r\n tube: (o: ParamsOf<TubeGeometry3D>): TubeGeometry3D => ({ type: \"tube\", ...o }),\r\n\r\n /** Raw vertex buffers — any mesh you can compute. */\r\n buffer: (o: ParamsOf<BufferGeometry3D>): BufferGeometry3D => ({ type: \"buffer\", ...o }),\r\n /** A surface sampled over a `[0,1]²` grid. Sugar over {@link Geo.buffer}. */\r\n parametric: (o: ParamsOf<ParametricGeometry3D>): ParametricGeometry3D => ({ type: \"parametric\", ...o }),\r\n\r\n /** The hard edges of another geometry — a clean outline, no triangulation diagonals. */\r\n edges: (source: Geometry3D, o?: Omit<ParamsOf<EdgesGeometry3D>, \"source\">): EdgesGeometry3D =>\r\n ({ type: \"edges\", source, ...o }),\r\n /** Every triangle edge of another geometry. */\r\n wireframe: (source: Geometry3D): WireframeGeometry3D => ({ type: \"wireframe\", source }),\r\n\r\n model: (src: string, o?: Omit<ParamsOf<ModelGeometry3D>, \"src\">): ModelGeometry3D =>\r\n ({ type: \"modelGeometry\", src, ...o }),\r\n} as const;\r\n\r\n/**\r\n * Material descriptors.\r\n *\r\n * Like geometries these are shareable values — one hoisted material across many\r\n * meshes compiles one shader program instead of N.\r\n *\r\n * Reach for {@link Mat.standard} by default; {@link Mat.physical} only when a\r\n * surface actually needs clearcoat, transmission, sheen or iridescence, since\r\n * those cost more per pixel. {@link Mat.shader} is the full-control escape hatch.\r\n */\r\nexport const Mat = {\r\n basic: (o?: ParamsOf<BasicMaterial3D>): BasicMaterial3D => ({ type: \"basic\", ...o }),\r\n standard: (o?: ParamsOf<StandardMaterial3D>): StandardMaterial3D => ({ type: \"standard\", ...o }),\r\n physical: (o?: ParamsOf<PhysicalMaterial3D>): PhysicalMaterial3D => ({ type: \"physical\", ...o }),\r\n phong: (o?: ParamsOf<PhongMaterial3D>): PhongMaterial3D => ({ type: \"phong\", ...o }),\r\n lambert: (o?: ParamsOf<LambertMaterial3D>): LambertMaterial3D => ({ type: \"lambert\", ...o }),\r\n toon: (o?: ParamsOf<ToonMaterial3D>): ToonMaterial3D => ({ type: \"toon\", ...o }),\r\n normal: (o?: ParamsOf<NormalMaterial3D>): NormalMaterial3D => ({ type: \"normal\", ...o }),\r\n depth: (o?: ParamsOf<DepthMaterial3D>): DepthMaterial3D => ({ type: \"depth\", ...o }),\r\n matcap: (o?: ParamsOf<MatcapMaterial3D>): MatcapMaterial3D => ({ type: \"matcap\", ...o }),\r\n points: (o?: ParamsOf<PointsMaterial3D>): PointsMaterial3D => ({ type: \"points\", ...o }),\r\n lineBasic: (o?: ParamsOf<LineBasicMaterial3D>): LineBasicMaterial3D => ({ type: \"lineBasic\", ...o }),\r\n lineDashed: (o?: ParamsOf<LineDashedMaterial3D>): LineDashedMaterial3D => ({ type: \"lineDashed\", ...o }),\r\n sprite: (o?: ParamsOf<SpriteMaterial3D>): SpriteMaterial3D => ({ type: \"sprite\", ...o }),\r\n shadow: (o?: ParamsOf<ShadowMaterial3D>): ShadowMaterial3D => ({ type: \"shadow\", ...o }),\r\n /** Raw GLSL. Uniform *values* are free to animate; source changes recompile. */\r\n shader: (o: ParamsOf<ShaderMaterial3D>): ShaderMaterial3D => ({ type: \"shader\", ...o }),\r\n} as const;\r\n\r\n/**\r\n * Texture descriptors.\r\n *\r\n * {@link Tex.image} takes a manifest path and is loaded through core's ordinary\r\n * image pipeline, so the pixels are resident before the frame that needs them\r\n * draws. A bare string works anywhere a texture is expected, so `Tex.image` is\r\n * only needed when passing sampler options.\r\n */\r\nexport const Tex = {\r\n image: (src: string, o?: TextureOptions3D): ImageTexture3D => ({ src, ...o }),\r\n /** A texture from raw RGBA8888 bytes — gradient ramps, noise, LUTs. */\r\n data: (\r\n data: ArrayLike<number>,\r\n width: number,\r\n height: number,\r\n o?: TextureOptions3D & { revision?: number },\r\n ): DataTexture3D => ({ data, width, height, ...o }),\r\n /**\r\n * A texture painted from Motion Script's own 2D output — the bridge from 2D\r\n * onto 3D geometry.\r\n *\r\n * `source` is a **value**: a built `Graphics2D` command list, or a `Node2D`\r\n * subtree for anything needing real layout, shaped `Text` or a loaded\r\n * `Image`. Both are passed directly; there is no name to match and nothing\r\n * has to be mounted anywhere in particular.\r\n *\r\n * const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);\r\n * g3.plane({ fill: scope }); // sized for you\r\n *\r\n * const stats = <Rect flow=\"vertical\" padding={48}><Text text=\"CPU\" /></Rect>;\r\n * g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });\r\n *\r\n * `width`/`height` are the buffer's resolution and default to 512. A source\r\n * handed straight to `fill` gets exactly this treatment with those defaults,\r\n * so the builder is only needed to pin a resolution or a sampler option.\r\n * **Hoist the source** rather than rebuilding it each frame — see\r\n * {@link SurfaceTexture3D}.\r\n */\r\n surface: (\r\n source: SurfaceSource3D,\r\n o?: TextureOptions3D & { width?: number; height?: number; maxPixelRatio?: number },\r\n ): SurfaceTexture3D => ({\r\n width: 512,\r\n height: 512,\r\n ...o,\r\n source,\r\n }),\r\n} as const;\r\n"]}
|
|
1
|
+
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/render3d/builders.ts"],"names":[],"mappings":"AAkBA;;;;;;;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,EAAE,GAAG;QACX,GAAG,CAAC;QACJ,MAAM;KACT,CAAC;CACI,CAAC","sourcesContent":["import type {\r\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D,\r\n ConeGeometry3D, CylinderGeometry3D, EdgesGeometry3D, ExtrudeGeometry3D,\r\n Geometry3D, LatheGeometry3D, ModelGeometry3D, ParametricGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D, WireframeGeometry3D,\r\n} from \"./geometry\";\r\nimport type {\r\n BasicMaterial3D, DepthMaterial3D, LambertMaterial3D, LineBasicMaterial3D,\r\n LineDashedMaterial3D, MatcapMaterial3D, NormalMaterial3D, PhongMaterial3D,\r\n PhysicalMaterial3D, PointsMaterial3D, ShaderMaterial3D, ShadowMaterial3D,\r\n SpriteMaterial3D, StandardMaterial3D, ToonMaterial3D,\r\n} from \"./material\";\r\nimport type { DataTexture3D, ImageTexture3D, SurfaceSource3D, SurfaceTexture3D, TextureOptions3D } from \"./texture\";\r\n\r\n/** A descriptor's own params, with the `type` discriminant removed. */\r\ntype ParamsOf<T> = Omit<T, \"type\">;\r\n\r\n/**\r\n * Geometry descriptors.\r\n *\r\n * These are plain values, so hoist one out of the builder and share it across\r\n * meshes — the renderer dedupes by identity, so a shared geometry is uploaded to\r\n * the GPU once no matter how many meshes reference it.\r\n *\r\n * const brick = Geo.box({ width: 1, height: 0.5, depth: 0.5 });\r\n * g.mesh(brick, red, { position: [0, 0, 0] })\r\n * .mesh(brick, red, { position: [1, 0, 0] }); // same GPU buffer\r\n */\r\nexport const Geo = {\r\n box: (o?: ParamsOf<BoxGeometry3D>): BoxGeometry3D => ({ type: \"box\", ...o }),\r\n sphere: (o?: ParamsOf<SphereGeometry3D>): SphereGeometry3D => ({ type: \"sphere\", ...o }),\r\n plane: (o?: ParamsOf<PlaneGeometry3D>): PlaneGeometry3D => ({ type: \"plane\", ...o }),\r\n cylinder: (o?: ParamsOf<CylinderGeometry3D>): CylinderGeometry3D => ({ type: \"cylinder\", ...o }),\r\n cone: (o?: ParamsOf<ConeGeometry3D>): ConeGeometry3D => ({ type: \"cone\", ...o }),\r\n torus: (o?: ParamsOf<TorusGeometry3D>): TorusGeometry3D => ({ type: \"torus\", ...o }),\r\n torusKnot: (o?: ParamsOf<TorusKnotGeometry3D>): TorusKnotGeometry3D => ({ type: \"torusKnot\", ...o }),\r\n circle: (o?: ParamsOf<CircleGeometry3D>): CircleGeometry3D => ({ type: \"circle\", ...o }),\r\n ring: (o?: ParamsOf<RingGeometry3D>): RingGeometry3D => ({ type: \"ring\", ...o }),\r\n capsule: (o?: ParamsOf<CapsuleGeometry3D>): CapsuleGeometry3D => ({ type: \"capsule\", ...o }),\r\n\r\n tetrahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"tetrahedron\", ...o }),\r\n octahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"octahedron\", ...o }),\r\n icosahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"icosahedron\", ...o }),\r\n dodecahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"dodecahedron\", ...o }),\r\n\r\n extrude: (o: ParamsOf<ExtrudeGeometry3D>): ExtrudeGeometry3D => ({ type: \"extrude\", ...o }),\r\n lathe: (o: ParamsOf<LatheGeometry3D>): LatheGeometry3D => ({ type: \"lathe\", ...o }),\r\n tube: (o: ParamsOf<TubeGeometry3D>): TubeGeometry3D => ({ type: \"tube\", ...o }),\r\n\r\n /** Raw vertex buffers — any mesh you can compute. */\r\n buffer: (o: ParamsOf<BufferGeometry3D>): BufferGeometry3D => ({ type: \"buffer\", ...o }),\r\n /** A surface sampled over a `[0,1]²` grid. Sugar over {@link Geo.buffer}. */\r\n parametric: (o: ParamsOf<ParametricGeometry3D>): ParametricGeometry3D => ({ type: \"parametric\", ...o }),\r\n\r\n /** The hard edges of another geometry — a clean outline, no triangulation diagonals. */\r\n edges: (source: Geometry3D, o?: Omit<ParamsOf<EdgesGeometry3D>, \"source\">): EdgesGeometry3D =>\r\n ({ type: \"edges\", source, ...o }),\r\n /** Every triangle edge of another geometry. */\r\n wireframe: (source: Geometry3D): WireframeGeometry3D => ({ type: \"wireframe\", source }),\r\n\r\n model: (src: string, o?: Omit<ParamsOf<ModelGeometry3D>, \"src\">): ModelGeometry3D =>\r\n ({ type: \"modelGeometry\", src, ...o }),\r\n} as const;\r\n\r\n/**\r\n * Material descriptors.\r\n *\r\n * Like geometries these are shareable values — one hoisted material across many\r\n * meshes compiles one shader program instead of N.\r\n *\r\n * Reach for {@link Mat.standard} by default; {@link Mat.physical} only when a\r\n * surface actually needs clearcoat, transmission, sheen or iridescence, since\r\n * those cost more per pixel. {@link Mat.shader} is the full-control escape hatch.\r\n */\r\nexport const Mat = {\r\n basic: (o?: ParamsOf<BasicMaterial3D>): BasicMaterial3D => ({ type: \"basic\", ...o }),\r\n standard: (o?: ParamsOf<StandardMaterial3D>): StandardMaterial3D => ({ type: \"standard\", ...o }),\r\n physical: (o?: ParamsOf<PhysicalMaterial3D>): PhysicalMaterial3D => ({ type: \"physical\", ...o }),\r\n phong: (o?: ParamsOf<PhongMaterial3D>): PhongMaterial3D => ({ type: \"phong\", ...o }),\r\n lambert: (o?: ParamsOf<LambertMaterial3D>): LambertMaterial3D => ({ type: \"lambert\", ...o }),\r\n toon: (o?: ParamsOf<ToonMaterial3D>): ToonMaterial3D => ({ type: \"toon\", ...o }),\r\n normal: (o?: ParamsOf<NormalMaterial3D>): NormalMaterial3D => ({ type: \"normal\", ...o }),\r\n depth: (o?: ParamsOf<DepthMaterial3D>): DepthMaterial3D => ({ type: \"depth\", ...o }),\r\n matcap: (o?: ParamsOf<MatcapMaterial3D>): MatcapMaterial3D => ({ type: \"matcap\", ...o }),\r\n points: (o?: ParamsOf<PointsMaterial3D>): PointsMaterial3D => ({ type: \"points\", ...o }),\r\n lineBasic: (o?: ParamsOf<LineBasicMaterial3D>): LineBasicMaterial3D => ({ type: \"lineBasic\", ...o }),\r\n lineDashed: (o?: ParamsOf<LineDashedMaterial3D>): LineDashedMaterial3D => ({ type: \"lineDashed\", ...o }),\r\n sprite: (o?: ParamsOf<SpriteMaterial3D>): SpriteMaterial3D => ({ type: \"sprite\", ...o }),\r\n shadow: (o?: ParamsOf<ShadowMaterial3D>): ShadowMaterial3D => ({ type: \"shadow\", ...o }),\r\n /** Raw GLSL. Uniform *values* are free to animate; source changes recompile. */\r\n shader: (o: ParamsOf<ShaderMaterial3D>): ShaderMaterial3D => ({ type: \"shader\", ...o }),\r\n} as const;\r\n\r\n/**\r\n * Texture descriptors.\r\n *\r\n * {@link Tex.image} takes a manifest path and is loaded through core's ordinary\r\n * image pipeline, so the pixels are resident before the frame that needs them\r\n * draws. A bare string works anywhere a texture is expected, so `Tex.image` is\r\n * only needed when passing sampler options.\r\n */\r\nexport const Tex = {\r\n image: (src: string, o?: TextureOptions3D): ImageTexture3D => ({ src, ...o }),\r\n /** A texture from raw RGBA8888 bytes — gradient ramps, noise, LUTs. */\r\n data: (\r\n data: ArrayLike<number>,\r\n width: number,\r\n height: number,\r\n o?: TextureOptions3D & { revision?: number },\r\n ): DataTexture3D => ({ data, width, height, ...o }),\r\n /**\r\n * A texture painted from Motion Script's own 2D output — the bridge from 2D\r\n * onto 3D geometry.\r\n *\r\n * `source` is a **value**: a built `Graphics2D` command list, or a `Node2D`\r\n * subtree for anything needing real layout, shaped `Text` or a loaded\r\n * `Image`. Both are passed directly; there is no name to match and nothing\r\n * has to be mounted anywhere in particular.\r\n *\r\n * const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);\r\n * g3.plane({ fill: scope }); // sized for you\r\n *\r\n * const stats = new Rect({ flow: \"vertical\", padding: 48, children: [Text({ text: \"CPU\" })] });\r\n * g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });\r\n *\r\n * `width`/`height` are the buffer's resolution and default to 512. A source\r\n * handed straight to `fill` gets exactly this treatment with those defaults,\r\n * so the builder is only needed to pin a resolution or a sampler option.\r\n * **Hoist the source** rather than rebuilding it each frame — see\r\n * {@link SurfaceTexture3D}.\r\n */\r\n surface: (\r\n source: SurfaceSource3D,\r\n o?: TextureOptions3D & { width?: number; height?: number; maxPixelRatio?: number },\r\n ): SurfaceTexture3D => ({\r\n width: 512,\r\n height: 512,\r\n ...o,\r\n source,\r\n }),\r\n} as const;\r\n"]}
|
|
@@ -147,10 +147,8 @@ type ParamsOf<G> = Omit<G, "type">;
|
|
|
147
147
|
* the `Node3D` tree owns them. The exact division `Graphics2D` and
|
|
148
148
|
* `RenderContext2D` already make in 2D.
|
|
149
149
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* .box({ width: 2, cornerRadius: 0.15, fill: "#e0533d", roughness: 0.3 }));
|
|
153
|
-
* }
|
|
150
|
+
* render: (ctx) => ctx.draw(new Graphics3D()
|
|
151
|
+
* .box({ width: 2, cornerRadius: 0.15, fill: "#e0533d", roughness: 0.3 })),
|
|
154
152
|
*
|
|
155
153
|
* Nothing here touches a renderer: a built `Graphics3D` is handed to a
|
|
156
154
|
* {@link RenderContext3D}, which splices its ops into the scene being recorded.
|
|
@@ -169,23 +167,19 @@ type ParamsOf<G> = Omit<G, "type">;
|
|
|
169
167
|
*
|
|
170
168
|
* ── Animation ─────────────────────────────────────────────────────────────────
|
|
171
169
|
* A `Graphics3D` is rebuilt from scratch every frame, so animation is just
|
|
172
|
-
* reading the node's own
|
|
170
|
+
* reading the node's own state while building:
|
|
173
171
|
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
172
|
+
* const Rig = component3d({
|
|
173
|
+
* key: "rig",
|
|
174
|
+
* state: { spin: 0, lift: Types.custom<Vector3>([0, 0, 0], { lerp: lerpVector3 }) },
|
|
175
|
+
* render: (ctx, s) => ctx.draw(new Graphics3D()
|
|
176
|
+
* .box({ rotation: [0, s.spin, 0], position: s.lift })),
|
|
177
|
+
* });
|
|
178
|
+
* // a `to` of { spin: 360 } over two seconds turns it
|
|
177
179
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* }
|
|
182
|
-
* }
|
|
183
|
-
* // rig().to({ data: { spin: 360 }, duration: 2, easing: easeInOut() })
|
|
184
|
-
*
|
|
185
|
-
* Note `@vector3Property` rather than a bare `@property`. A prop holding a
|
|
186
|
-
* non-number needs an explicit tween (`lerpVector3`, `lerpEuler3`,
|
|
187
|
-
* `slerpQuaternion`) or `to()` has nothing to interpolate it with and leaves it
|
|
188
|
-
* alone; the attribute-typed decorators carry the right one already.
|
|
180
|
+
* Note the `lerp` on `lift`. An entry holding a non-number needs an explicit
|
|
181
|
+
* tween (`lerpVector3`, `lerpEuler3`, `slerpQuaternion`) or `to()` has nothing
|
|
182
|
+
* to interpolate it with and leaves it alone.
|
|
189
183
|
*
|
|
190
184
|
* ── Reconciliation identity ───────────────────────────────────────────────────
|
|
191
185
|
* The renderer caches one live 3D object per op and mutates it between frames
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphics3d.d.ts","sourceRoot":"","sources":["../../src/render3d/graphics3d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,EACR,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAClE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAClE,eAAe,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EACvE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EACvD,M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EAAmE;QACnE,MAAM,CAAC,EAAE,YAAY,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,WAAW,CAAC;KAC3B,GAAG,WAAW,GAAG,IAAI;IA2BtB,4CAA4C;IAC5C,MAAM,CAAC,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,WAAW,GAAG,IAAI;IAiB/F;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,gBAAgB,EAAE,CAAC;QAC3D,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;KACnD,GAAG,WAAW,GAAG,IAAI;IAgBtB,4DAA4D;IAC5D,GAAG,IAAI,SAAS,YAAY,EAAE;IAI9B,yCAAyC;IACzC,OAAO,IAAI,OAAO;CAGrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IACzB,gEAAgE;IAChE,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrC"}
|
|
@@ -94,10 +94,8 @@ function pickGeometry(source, type) {
|
|
|
94
94
|
* the `Node3D` tree owns them. The exact division `Graphics2D` and
|
|
95
95
|
* `RenderContext2D` already make in 2D.
|
|
96
96
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* .box({ width: 2, cornerRadius: 0.15, fill: "#e0533d", roughness: 0.3 }));
|
|
100
|
-
* }
|
|
97
|
+
* render: (ctx) => ctx.draw(new Graphics3D()
|
|
98
|
+
* .box({ width: 2, cornerRadius: 0.15, fill: "#e0533d", roughness: 0.3 })),
|
|
101
99
|
*
|
|
102
100
|
* Nothing here touches a renderer: a built `Graphics3D` is handed to a
|
|
103
101
|
* {@link RenderContext3D}, which splices its ops into the scene being recorded.
|
|
@@ -116,23 +114,19 @@ function pickGeometry(source, type) {
|
|
|
116
114
|
*
|
|
117
115
|
* ── Animation ─────────────────────────────────────────────────────────────────
|
|
118
116
|
* A `Graphics3D` is rebuilt from scratch every frame, so animation is just
|
|
119
|
-
* reading the node's own
|
|
117
|
+
* reading the node's own state while building:
|
|
120
118
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
119
|
+
* const Rig = component3d({
|
|
120
|
+
* key: "rig",
|
|
121
|
+
* state: { spin: 0, lift: Types.custom<Vector3>([0, 0, 0], { lerp: lerpVector3 }) },
|
|
122
|
+
* render: (ctx, s) => ctx.draw(new Graphics3D()
|
|
123
|
+
* .box({ rotation: [0, s.spin, 0], position: s.lift })),
|
|
124
|
+
* });
|
|
125
|
+
* // a `to` of { spin: 360 } over two seconds turns it
|
|
124
126
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* }
|
|
129
|
-
* }
|
|
130
|
-
* // rig().to({ data: { spin: 360 }, duration: 2, easing: easeInOut() })
|
|
131
|
-
*
|
|
132
|
-
* Note `@vector3Property` rather than a bare `@property`. A prop holding a
|
|
133
|
-
* non-number needs an explicit tween (`lerpVector3`, `lerpEuler3`,
|
|
134
|
-
* `slerpQuaternion`) or `to()` has nothing to interpolate it with and leaves it
|
|
135
|
-
* alone; the attribute-typed decorators carry the right one already.
|
|
127
|
+
* Note the `lerp` on `lift`. An entry holding a non-number needs an explicit
|
|
128
|
+
* tween (`lerpVector3`, `lerpEuler3`, `slerpQuaternion`) or `to()` has nothing
|
|
129
|
+
* to interpolate it with and leaves it alone.
|
|
136
130
|
*
|
|
137
131
|
* ── Reconciliation identity ───────────────────────────────────────────────────
|
|
138
132
|
* The renderer caches one live 3D object per op and mutates it between frames
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphics3d.js","sourceRoot":"","sources":["../../src/render3d/graphics3d.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoE5C;;;;;GAKG;AACH,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;CACpE,CAAC,CAAC;AAkDH,MAAM,cAAc,GAAG;IACnB,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ;IACvD,SAAS,EAAE,QAAQ,EAAE,aAAa;CAC5B,CAAC;AAEX;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC5B,SAAS,EAAE,WAAW,EAAE,WAAW;IACnC,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc;IAC3D,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW;IACnE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO;CACrC,CAAC;AAEX,kEAAkE;AAClE,MAAM,cAAc,GAAsB,CAAC,GAAG,uBAAuB,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEpG;;;;;GAKG;AACH,SAAS,aAAa,CAAC,MAAc;IACjC,MAAM,GAAG,GAAG,MAAiC,CAAC;IAC9C,IAAI,GAAwC,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QAC/B,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7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E,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,KAA4C,CAAC;YACvD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type {\r\n BoxGeometry3D, CapsuleGeometry3D, CircleGeometry3D, ConeGeometry3D,\r\n CylinderGeometry3D, ExtrudeGeometry3D, Geometry3D, LatheGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D,\r\n} from \"./geometry\";\r\nimport type { Material3D, Shading3D } from \"./material\";\r\nimport type { Texture3D } from \"./texture\";\r\nimport { resolveFill3D, type Fill3D } from \"./fill3d\";\r\nimport { inspectDrawable3D } from \"./inert\";\r\nimport { type Transform3D, type Blend3D, type Faces3D } from \"./transform\";\r\nimport type { Vector3Input } from \"./vector3\";\r\n\r\n// ─── Ops ─────────────────────────────────────────────────────────────────────\r\n\r\n/** One clip of a model's baked animation, sampled at an explicit time. */\r\nexport interface ModelAnimation3D {\r\n /** Clip name, or its index in the file. Defaults to the first clip. */\r\n clip?: string | number;\r\n /**\r\n * Seconds into the clip. **Explicit by design** — the renderer seeks to this\r\n * time rather than advancing by a delta, which is what keeps a model's\r\n * animation identical whether the frame was reached by playing forward or by\r\n * scrubbing backwards.\r\n */\r\n time: number;\r\n /** Blend weight, for cross-fading clips. Default 1. */\r\n weight?: number;\r\n}\r\n\r\n/**\r\n * How a `line` op connects its points: in order, or as disjoint start/end pairs,\r\n * or in order and closed back to the start.\r\n */\r\nexport type LineMode3D = \"strip\" | \"segments\" | \"loop\";\r\n\r\n/**\r\n * One recorded operation in a {@link Graphics3D} command list.\r\n *\r\n * Every op draws something. Hierarchy, lights and the camera are *scene*\r\n * concerns, recorded by the `Node3D` tree into a `Scene3D` — this is only ever\r\n * \"what one node paints\", which is exactly what a `Graphics2D` is in 2D.\r\n *\r\n * A drawable's geometry and material are *inline sub-descriptors*, not ops,\r\n * because in a 3D scene graph they are properties of an object rather than\r\n * children of it.\r\n */\r\nexport type Graphics3DOp =\r\n | { kind: \"mesh\"; geometry: Geometry3D; material: Material3D | readonly Material3D[]; transform?: Transform3D }\r\n | {\r\n kind: \"instances\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n /** Per-instance placement. Length drives the instance count. */\r\n instances: readonly Transform3D[];\r\n /** Per-instance tint. Needs a material that reads instance colour. */\r\n colors?: readonly Color[];\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"points\"; geometry: Geometry3D; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"line\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n mode: LineMode3D;\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"sprite\"; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"model\";\r\n src: string;\r\n animation?: readonly ModelAnimation3D[];\r\n /** Replace materials on the loaded graph, keyed by mesh or material name. */\r\n override?: Readonly<Record<string, Material3D>>;\r\n transform?: Transform3D;\r\n };\r\n\r\n/**\r\n * Op kinds that put something in the scene (as opposed to shaping the tree).\r\n *\r\n * Shared with `Scene3D`, whose op list is this one plus `push`/`pop`/`light`/\r\n * `camera` — so \"is anything actually drawn here\" has a single definition.\r\n */\r\n/** @internal */\r\nexport const DRAWABLE_KINDS: ReadonlySet<string> = new Set([\r\n \"mesh\", \"light\", \"instances\", \"points\", \"line\", \"sprite\", \"model\",\r\n]);\r\n\r\n// ─── Shorthand ───────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Material fields promoted onto the geometry sugar methods, so the common case is\r\n * one flat call: `.box({ width: 2, fill: \"red\", roughness: 0.3 })`.\r\n *\r\n * `fill` is the whole 2D fill vocabulary — see {@link Fill3D} — and is what a\r\n * flat `color` plus a `map` slot used to be. The rest is surface *response*\r\n * (how light behaves on it) rather than colour, which is the line Spline's\r\n * material panel draws too and the reason those stay separate fields.\r\n *\r\n * These desugar at record time into a full {@link Material3D} — `standard` by\r\n * default, `basic` when {@link unlit} is set — so the recorded op list stays\r\n * canonical. Pass {@link material} to bypass the shorthand entirely; every\r\n * renderer-level knob that is not a design decision (`depthWrite`, `alphaTest`,\r\n * `toneMapped`, `polygonOffset`, …) lives there and only there.\r\n */\r\nexport interface MaterialShorthand3D {\r\n /** A full descriptor (or an array, for multi-material). Wins over the rest. */\r\n material?: Material3D | readonly Material3D[];\r\n /** What the surface is made of: a colour, a texture, a gradient, 2D content. */\r\n fill?: Fill3D;\r\n opacity?: number;\r\n roughness?: number;\r\n metalness?: number;\r\n /** Self-illumination. Bloom in the post chain is what makes it glow. */\r\n emission?: Color;\r\n emissionStrength?: number;\r\n normalMap?: Texture3D;\r\n roughnessMap?: Texture3D;\r\n metalnessMap?: Texture3D;\r\n aoMap?: Texture3D;\r\n alphaMap?: Texture3D;\r\n envMapIntensity?: number;\r\n wireframe?: boolean;\r\n /** Facet or smooth shading. Default `\"smooth\"`. */\r\n shading?: Shading3D;\r\n /** Which faces to rasterize. Default `\"front\"`. */\r\n faces?: Faces3D;\r\n vertexColors?: boolean;\r\n blend?: Blend3D;\r\n /** Shade with an unlit `basic` material instead of `standard`. */\r\n unlit?: boolean;\r\n}\r\n\r\n/** Transform + material shorthand, accepted by every geometry sugar method. */\r\nexport type MeshShorthand3D = Transform3D & MaterialShorthand3D;\r\n\r\nconst TRANSFORM_KEYS = [\r\n \"position\", \"rotation\", \"quaternion\", \"scale\", \"lookAt\",\r\n \"visible\", \"shadow\", \"renderOrder\",\r\n] as const;\r\n\r\n/**\r\n * Shorthand keys copied straight onto the built descriptor.\r\n *\r\n * `fill` is deliberately absent: it resolves into `color` *and* `map` rather than\r\n * being one field, so it is handled on its own in {@link resolveMaterialShorthand3D}.\r\n */\r\nconst MATERIAL_SHORTHAND_KEYS = [\r\n \"opacity\", \"roughness\", \"metalness\",\r\n \"emission\", \"emissionStrength\", \"normalMap\", \"roughnessMap\",\r\n \"metalnessMap\", \"aoMap\", \"alphaMap\", \"envMapIntensity\", \"wireframe\",\r\n \"shading\", \"faces\", \"vertexColors\", \"blend\",\r\n] as const;\r\n\r\n/** Every key the shorthand owns, for stripping a geometry bag. */\r\nconst SHORTHAND_KEYS: readonly string[] = [...MATERIAL_SHORTHAND_KEYS, \"fill\", \"material\", \"unlit\"];\r\n\r\n/**\r\n * Pull the {@link Transform3D} fields out of a shorthand bag. Takes `object` so\r\n * the concrete option types at each call site pass without a cast, and returns\r\n * `undefined` rather than `{}` when there is nothing to apply — an absent\r\n * transform lets the renderer skip the matrix write entirely.\r\n */\r\nfunction pickTransform(source: object): Transform3D | undefined {\r\n const bag = source as Record<string, unknown>;\r\n let out: Record<string, unknown> | undefined;\r\n for (const key of TRANSFORM_KEYS) {\r\n if (bag[key] !== undefined) (out ??= {})[key] = bag[key];\r\n }\r\n return out as Transform3D | undefined;\r\n}\r\n\r\n/**\r\n * Build the material a shorthand bag describes. Always returns one, so a recorded\r\n * drawable op never has to be interpreted with \"…or the default\" in mind.\r\n *\r\n * Exported because `Mesh3D` desugars the identical bag from its own props: this\r\n * is where `fill` becomes `color`-or-`map`, and two copies of that decision is\r\n * two chances for a node and a builder call to paint differently.\r\n *\r\n * @internal\r\n */\r\nexport function resolveMaterialShorthand3D(source: MaterialShorthand3D): Material3D | readonly Material3D[] {\r\n if (source.material !== undefined) return source.material;\r\n\r\n const material: Record<string, unknown> = { type: source.unlit ? \"basic\" : \"standard\" };\r\n\r\n const fill = resolveFill3D(source.fill);\r\n if (fill.color !== undefined) material.color = fill.color;\r\n if (fill.map !== undefined) material.map = fill.map;\r\n\r\n for (const key of MATERIAL_SHORTHAND_KEYS) {\r\n const value = (source as Record<string, unknown>)[key];\r\n if (value !== undefined) material[key] = value;\r\n }\r\n return material as unknown as Material3D;\r\n}\r\n\r\n/** Drop the shorthand/transform keys, leaving only a geometry's own params. */\r\nfunction pickGeometry<T>(source: object, type: string): T {\r\n const bag = source as Record<string, unknown>;\r\n const out: Record<string, unknown> = { type };\r\n for (const key in bag) {\r\n if (SHORTHAND_KEYS.includes(key)) continue;\r\n if ((TRANSFORM_KEYS as readonly string[]).includes(key)) continue;\r\n if (bag[key] !== undefined) out[key] = bag[key];\r\n }\r\n return out as T;\r\n}\r\n\r\n/** Geometry params only, with `type` and the inherited passthrough removed. */\r\ntype ParamsOf<G> = Omit<G, \"type\">;\r\n\r\n// ─── Recorder ────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * What one 3D node draws — the `Graphics2D` of 3D.\r\n *\r\n * Records an ordered list of drawables (meshes, instanced meshes, points, lines,\r\n * sprites, models), each with its own geometry, material and local transform.\r\n * That is the whole surface: it holds no camera, no lights and no hierarchy,\r\n * because those are properties of a *scene* rather than of a thing in one, and\r\n * the `Node3D` tree owns them. The exact division `Graphics2D` and\r\n * `RenderContext2D` already make in 2D.\r\n *\r\n * protected renderSelf(ctx: RenderContext3D): void {\r\n * ctx.draw(new Graphics3D()\r\n * .box({ width: 2, cornerRadius: 0.15, fill: \"#e0533d\", roughness: 0.3 }));\r\n * }\r\n *\r\n * Nothing here touches a renderer: a built `Graphics3D` is handed to a\r\n * {@link RenderContext3D}, which splices its ops into the scene being recorded.\r\n *\r\n * ── One flat bag, deliberately ────────────────────────────────────────────────\r\n * `Graphics2D` paints with a *chained* `.rect(…).fill(…)`, and this does not,\r\n * which is the one place the two recorders diverge on purpose. In 2D a `fill` is\r\n * a **group-scoped op** covering the shapes recorded before it; in 3D a material\r\n * belongs to exactly one object, because a mesh *is* geometry plus material.\r\n * A chained `.box().fill()` would imply a group material that has nothing to\r\n * scope over, so the shape and what it is made of are stated together instead.\r\n *\r\n * ── Angles are DEGREES ────────────────────────────────────────────────────────\r\n * Every angle here — Euler rotations, sweep arcs, UV rotation — is in degrees,\r\n * matching the engine's 2D `rotation`. The renderer converts.\r\n *\r\n * ── Animation ─────────────────────────────────────────────────────────────────\r\n * A `Graphics3D` is rebuilt from scratch every frame, so animation is just\r\n * reading the node's own props while building:\r\n *\r\n * class Rig extends Canvas3D {\r\n * @property({ default: 0 }) declare spin: number;\r\n * @vector3Property() declare lift: Vector3;\r\n *\r\n * protected buildScene3D(scene: Scene3D): void {\r\n * scene.draw(new Graphics3D()\r\n * .box({ rotation: [0, this.spin, 0], position: this.lift }));\r\n * }\r\n * }\r\n * // rig().to({ data: { spin: 360 }, duration: 2, easing: easeInOut() })\r\n *\r\n * Note `@vector3Property` rather than a bare `@property`. A prop holding a\r\n * non-number needs an explicit tween (`lerpVector3`, `lerpEuler3`,\r\n * `slerpQuaternion`) or `to()` has nothing to interpolate it with and leaves it\r\n * alone; the attribute-typed decorators carry the right one already.\r\n *\r\n * ── Reconciliation identity ───────────────────────────────────────────────────\r\n * The renderer caches one live 3D object per op and mutates it between frames\r\n * rather than rebuilding. Identity is **derived**: it comes from the owning\r\n * `Node3D` plus a signature of what the op actually draws, so a builder that\r\n * emits ops conditionally reuses the right cache entry with nothing written by\r\n * hand. There is no `key` to set.\r\n *\r\n * ── What is cheap to animate ──────────────────────────────────────────────────\r\n * Transforms and most material values are in-place writes, so they cost nothing\r\n * per frame. **Geometry parameters are not** — three geometries are immutable, so\r\n * tweening `.box({ width: this.size })` reallocates the mesh every frame. Scale\r\n * the object instead: `.box({ width: 1, scale: [this.size, 1, 1] })`. The fields marked\r\n * \"structural\" on `MaterialCommon3D` recompile the shader program and should be\r\n * set once, not tweened.\r\n */\r\nexport class Graphics3D {\r\n private _ops: Graphics3DOp[] = [];\r\n\r\n /** Append one op, flagging (in development) inputs no renderer acts on. */\r\n private record(op: Graphics3DOp): void {\r\n inspectDrawable3D(op);\r\n this._ops.push(op);\r\n }\r\n\r\n // ─── Meshes ──────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record a mesh from an explicit geometry and material. The geometry sugar\r\n * methods below all funnel here.\r\n */\r\n mesh(\r\n geometry: Geometry3D,\r\n material?: Material3D | readonly Material3D[],\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"mesh\",\r\n geometry,\r\n material: material ?? { type: \"standard\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a mesh from a geometry `type` plus a flat shorthand bag. */\r\n private sugar(type: Geometry3D[\"type\"], options?: MeshShorthand3D): this {\r\n const source: MeshShorthand3D = options ?? {};\r\n return this.mesh(\r\n pickGeometry<Geometry3D>(source, type),\r\n resolveMaterialShorthand3D(source),\r\n pickTransform(source),\r\n );\r\n }\r\n\r\n box(options?: ParamsOf<BoxGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"box\", options);\r\n }\r\n sphere(options?: ParamsOf<SphereGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"sphere\", options);\r\n }\r\n plane(options?: ParamsOf<PlaneGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"plane\", options);\r\n }\r\n cylinder(options?: ParamsOf<CylinderGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cylinder\", options);\r\n }\r\n cone(options?: ParamsOf<ConeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cone\", options);\r\n }\r\n torus(options?: ParamsOf<TorusGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torus\", options);\r\n }\r\n torusKnot(options?: ParamsOf<TorusKnotGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torusKnot\", options);\r\n }\r\n circle(options?: ParamsOf<CircleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"circle\", options);\r\n }\r\n ring(options?: ParamsOf<RingGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"ring\", options);\r\n }\r\n capsule(options?: ParamsOf<CapsuleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"capsule\", options);\r\n }\r\n polyhedron(options: ParamsOf<PolyhedronGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"polyhedron\", options);\r\n }\r\n extrude(options: ParamsOf<ExtrudeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"extrude\", options);\r\n }\r\n lathe(options: ParamsOf<LatheGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"lathe\", options);\r\n }\r\n tube(options: ParamsOf<TubeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"tube\", options);\r\n }\r\n\r\n // ─── Other drawables ─────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record many copies of one geometry in a single draw call. The way to put\r\n * thousands of objects on screen — a plain `mesh` per copy would not keep up.\r\n *\r\n * g3.instances(Geo.box({ width: 0.2 }), Mat.standard({ color: \"cyan\" }),\r\n * positions.map(p => ({ position: p })))\r\n */\r\n instances(\r\n geometry: Geometry3D,\r\n material: Material3D,\r\n instances: readonly Transform3D[],\r\n options?: { colors?: readonly Color[]; transform?: Transform3D },\r\n ): this {\r\n this.record({\r\n kind: \"instances\",\r\n geometry,\r\n material,\r\n instances,\r\n colors: options?.colors,\r\n transform: options?.transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a point cloud — one sprite-like dot per vertex of `geometry`. */\r\n points(\r\n geometry: Geometry3D,\r\n material?: Material3D,\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"points\",\r\n geometry,\r\n material: material ?? { type: \"points\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a line. Give it either explicit `points` or a `geometry` (typically\r\n * `Geo.edges(...)` for a wireframe outline).\r\n *\r\n * `closed` joins the last point back to the first, as the 2D `line` op's\r\n * own field does. `segments` treats the points as disjoint start/end pairs\r\n * instead — the form `Geo.edges(...)` produces. (There is no subdivision to\r\n * confuse it with: a line is drawn from the points it is given.)\r\n */\r\n line(options: {\r\n points?: readonly Vector3Input[];\r\n geometry?: Geometry3D;\r\n material?: Material3D;\r\n /** Join the last point back to the first. */\r\n closed?: boolean;\r\n /** Treat the points as disjoint start/end pairs. */\r\n segments?: boolean;\r\n /** The line's paint. Cap and join have no meaning on a GL line. */\r\n stroke?: LineStroke3D;\r\n opacity?: number;\r\n transform?: Transform3D;\r\n } & Transform3D): this {\r\n const { points, geometry, material, closed, segments, stroke, opacity } = options;\r\n\r\n if (!points && !geometry) {\r\n throw new Error(\"Graphics3D.line() needs either `points` or `geometry`.\");\r\n }\r\n\r\n const resolved: Material3D = material ?? {\r\n type: stroke?.dash !== undefined ? \"lineDashed\" : \"lineBasic\",\r\n ...(stroke?.fill !== undefined ? { color: stroke.fill } : {}),\r\n ...(stroke?.weight !== undefined ? { width: stroke.weight } : {}),\r\n ...(stroke?.dash !== undefined\r\n ? { dashSize: stroke.dash[0], gapSize: stroke.dash[1] ?? stroke.dash[0] }\r\n : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n\r\n this.record({\r\n kind: \"line\",\r\n geometry: geometry ?? { type: \"buffer\", position: flattenPoints(points!) },\r\n material: resolved,\r\n mode: segments ? \"segments\" : closed ? \"loop\" : \"strip\",\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a camera-facing textured quad. */\r\n sprite(options: { fill?: Fill3D; material?: Material3D; opacity?: number } & Transform3D): this {\r\n const { fill, material, opacity } = options;\r\n const paint = resolveFill3D(fill);\r\n const resolved: Material3D = material ?? {\r\n type: \"sprite\",\r\n ...(paint.map !== undefined ? { map: paint.map } : {}),\r\n ...(paint.color !== undefined ? { color: paint.color } : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n this.record({\r\n kind: \"sprite\",\r\n material: resolved,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a loaded model. **glTF/GLB only**: any other format (an `.obj`, say)\r\n * resolves to an empty slot and draws nothing, and in development the first\r\n * one recorded warns.\r\n *\r\n * Baked animation is sampled by explicit `time`, never advanced by a delta, so\r\n * a model stays frame-identical under scrubbing.\r\n */\r\n model(options: {\r\n src: string;\r\n animation?: ModelAnimation3D | readonly ModelAnimation3D[];\r\n override?: Readonly<Record<string, Material3D>>;\r\n } & Transform3D): this {\r\n const { src, animation, override } = options;\r\n this.record({\r\n kind: \"model\",\r\n src,\r\n animation: animation === undefined\r\n ? undefined\r\n : Array.isArray(animation) ? animation : [animation as ModelAnimation3D],\r\n override,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n // ─── Consumption ─────────────────────────────────────────────────────────\r\n\r\n /** The recorded ops, in order. Replayed by the renderer. */\r\n ops(): readonly Graphics3DOp[] {\r\n return this._ops;\r\n }\r\n\r\n /** True when this node draws nothing. */\r\n isEmpty(): boolean {\r\n return this._ops.length === 0;\r\n }\r\n}\r\n\r\n/**\r\n * A 3D line's paint, named after the 2D `Stroke` it mirrors.\r\n *\r\n * `cap`, `join` and the rest of the 2D stroke vocabulary are deliberately absent:\r\n * they describe a stroked *path*, and a GL line has no outline to cap. Note that\r\n * `weight` above 1 is ignored by most WebGL implementations — for a genuinely\r\n * thick line, draw a `tube`.\r\n */\r\nexport interface LineStroke3D {\r\n /** The line's colour. Named `fill` to match the 2D `Stroke`. */\r\n fill?: Color;\r\n weight?: number;\r\n /** Dash and gap lengths, in world units. */\r\n dash?: readonly [number, number?];\r\n}\r\n\r\n/** Flatten `Vector3Input`s into the packed `[x, y, z, …]` a buffer wants. */\r\nfunction flattenPoints(points: readonly Vector3Input[]): number[] {\r\n const out: number[] = [];\r\n for (const point of points) {\r\n if (typeof point === \"number\") {\r\n out.push(point, point, point);\r\n } else if (Array.isArray(point)) {\r\n out.push(point[0] ?? 0, point[1] ?? 0, point[2] ?? 0);\r\n } else {\r\n const v = point as { x: number; y: number; z: number };\r\n out.push(v.x ?? 0, v.y ?? 0, v.z ?? 0);\r\n }\r\n }\r\n return out;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"graphics3d.js","sourceRoot":"","sources":["../../src/render3d/graphics3d.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoE5C;;;;;GAKG;AACH,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;CACpE,CAAC,CAAC;AAkDH,MAAM,cAAc,GAAG;IACnB,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ;IACvD,SAAS,EAAE,QAAQ,EAAE,aAAa;CAC5B,CAAC;AAEX;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC5B,SAAS,EAAE,WAAW,EAAE,WAAW;IACnC,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc;IAC3D,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW;IACnE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO;CACrC,CAAC;AAEX,kEAAkE;AAClE,MAAM,cAAc,GAAsB,CAAC,GAAG,uBAAuB,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEpG;;;;;GAKG;AACH,SAAS,aAAa,CAAC,MAAc;IACjC,MAAM,GAAG,GAAG,MAAiC,CAAC;IAC9C,IAAI,GAAwC,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QAC/B,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,CAAC,GAAG,KAAK,E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AClC,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,KAA4C,CAAC;YACvD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type {\r\n BoxGeometry3D, CapsuleGeometry3D, CircleGeometry3D, ConeGeometry3D,\r\n CylinderGeometry3D, ExtrudeGeometry3D, Geometry3D, LatheGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D,\r\n} from \"./geometry\";\r\nimport type { Material3D, Shading3D } from \"./material\";\r\nimport type { Texture3D } from \"./texture\";\r\nimport { resolveFill3D, type Fill3D } from \"./fill3d\";\r\nimport { inspectDrawable3D } from \"./inert\";\r\nimport { type Transform3D, type Blend3D, type Faces3D } from \"./transform\";\r\nimport type { Vector3Input } from \"./vector3\";\r\n\r\n// ─── Ops ─────────────────────────────────────────────────────────────────────\r\n\r\n/** One clip of a model's baked animation, sampled at an explicit time. */\r\nexport interface ModelAnimation3D {\r\n /** Clip name, or its index in the file. Defaults to the first clip. */\r\n clip?: string | number;\r\n /**\r\n * Seconds into the clip. **Explicit by design** — the renderer seeks to this\r\n * time rather than advancing by a delta, which is what keeps a model's\r\n * animation identical whether the frame was reached by playing forward or by\r\n * scrubbing backwards.\r\n */\r\n time: number;\r\n /** Blend weight, for cross-fading clips. Default 1. */\r\n weight?: number;\r\n}\r\n\r\n/**\r\n * How a `line` op connects its points: in order, or as disjoint start/end pairs,\r\n * or in order and closed back to the start.\r\n */\r\nexport type LineMode3D = \"strip\" | \"segments\" | \"loop\";\r\n\r\n/**\r\n * One recorded operation in a {@link Graphics3D} command list.\r\n *\r\n * Every op draws something. Hierarchy, lights and the camera are *scene*\r\n * concerns, recorded by the `Node3D` tree into a `Scene3D` — this is only ever\r\n * \"what one node paints\", which is exactly what a `Graphics2D` is in 2D.\r\n *\r\n * A drawable's geometry and material are *inline sub-descriptors*, not ops,\r\n * because in a 3D scene graph they are properties of an object rather than\r\n * children of it.\r\n */\r\nexport type Graphics3DOp =\r\n | { kind: \"mesh\"; geometry: Geometry3D; material: Material3D | readonly Material3D[]; transform?: Transform3D }\r\n | {\r\n kind: \"instances\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n /** Per-instance placement. Length drives the instance count. */\r\n instances: readonly Transform3D[];\r\n /** Per-instance tint. Needs a material that reads instance colour. */\r\n colors?: readonly Color[];\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"points\"; geometry: Geometry3D; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"line\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n mode: LineMode3D;\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"sprite\"; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"model\";\r\n src: string;\r\n animation?: readonly ModelAnimation3D[];\r\n /** Replace materials on the loaded graph, keyed by mesh or material name. */\r\n override?: Readonly<Record<string, Material3D>>;\r\n transform?: Transform3D;\r\n };\r\n\r\n/**\r\n * Op kinds that put something in the scene (as opposed to shaping the tree).\r\n *\r\n * Shared with `Scene3D`, whose op list is this one plus `push`/`pop`/`light`/\r\n * `camera` — so \"is anything actually drawn here\" has a single definition.\r\n */\r\n/** @internal */\r\nexport const DRAWABLE_KINDS: ReadonlySet<string> = new Set([\r\n \"mesh\", \"light\", \"instances\", \"points\", \"line\", \"sprite\", \"model\",\r\n]);\r\n\r\n// ─── Shorthand ───────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Material fields promoted onto the geometry sugar methods, so the common case is\r\n * one flat call: `.box({ width: 2, fill: \"red\", roughness: 0.3 })`.\r\n *\r\n * `fill` is the whole 2D fill vocabulary — see {@link Fill3D} — and is what a\r\n * flat `color` plus a `map` slot used to be. The rest is surface *response*\r\n * (how light behaves on it) rather than colour, which is the line Spline's\r\n * material panel draws too and the reason those stay separate fields.\r\n *\r\n * These desugar at record time into a full {@link Material3D} — `standard` by\r\n * default, `basic` when {@link unlit} is set — so the recorded op list stays\r\n * canonical. Pass {@link material} to bypass the shorthand entirely; every\r\n * renderer-level knob that is not a design decision (`depthWrite`, `alphaTest`,\r\n * `toneMapped`, `polygonOffset`, …) lives there and only there.\r\n */\r\nexport interface MaterialShorthand3D {\r\n /** A full descriptor (or an array, for multi-material). Wins over the rest. */\r\n material?: Material3D | readonly Material3D[];\r\n /** What the surface is made of: a colour, a texture, a gradient, 2D content. */\r\n fill?: Fill3D;\r\n opacity?: number;\r\n roughness?: number;\r\n metalness?: number;\r\n /** Self-illumination. Bloom in the post chain is what makes it glow. */\r\n emission?: Color;\r\n emissionStrength?: number;\r\n normalMap?: Texture3D;\r\n roughnessMap?: Texture3D;\r\n metalnessMap?: Texture3D;\r\n aoMap?: Texture3D;\r\n alphaMap?: Texture3D;\r\n envMapIntensity?: number;\r\n wireframe?: boolean;\r\n /** Facet or smooth shading. Default `\"smooth\"`. */\r\n shading?: Shading3D;\r\n /** Which faces to rasterize. Default `\"front\"`. */\r\n faces?: Faces3D;\r\n vertexColors?: boolean;\r\n blend?: Blend3D;\r\n /** Shade with an unlit `basic` material instead of `standard`. */\r\n unlit?: boolean;\r\n}\r\n\r\n/** Transform + material shorthand, accepted by every geometry sugar method. */\r\nexport type MeshShorthand3D = Transform3D & MaterialShorthand3D;\r\n\r\nconst TRANSFORM_KEYS = [\r\n \"position\", \"rotation\", \"quaternion\", \"scale\", \"lookAt\",\r\n \"visible\", \"shadow\", \"renderOrder\",\r\n] as const;\r\n\r\n/**\r\n * Shorthand keys copied straight onto the built descriptor.\r\n *\r\n * `fill` is deliberately absent: it resolves into `color` *and* `map` rather than\r\n * being one field, so it is handled on its own in {@link resolveMaterialShorthand3D}.\r\n */\r\nconst MATERIAL_SHORTHAND_KEYS = [\r\n \"opacity\", \"roughness\", \"metalness\",\r\n \"emission\", \"emissionStrength\", \"normalMap\", \"roughnessMap\",\r\n \"metalnessMap\", \"aoMap\", \"alphaMap\", \"envMapIntensity\", \"wireframe\",\r\n \"shading\", \"faces\", \"vertexColors\", \"blend\",\r\n] as const;\r\n\r\n/** Every key the shorthand owns, for stripping a geometry bag. */\r\nconst SHORTHAND_KEYS: readonly string[] = [...MATERIAL_SHORTHAND_KEYS, \"fill\", \"material\", \"unlit\"];\r\n\r\n/**\r\n * Pull the {@link Transform3D} fields out of a shorthand bag. Takes `object` so\r\n * the concrete option types at each call site pass without a cast, and returns\r\n * `undefined` rather than `{}` when there is nothing to apply — an absent\r\n * transform lets the renderer skip the matrix write entirely.\r\n */\r\nfunction pickTransform(source: object): Transform3D | undefined {\r\n const bag = source as Record<string, unknown>;\r\n let out: Record<string, unknown> | undefined;\r\n for (const key of TRANSFORM_KEYS) {\r\n if (bag[key] !== undefined) (out ??= {})[key] = bag[key];\r\n }\r\n return out as Transform3D | undefined;\r\n}\r\n\r\n/**\r\n * Build the material a shorthand bag describes. Always returns one, so a recorded\r\n * drawable op never has to be interpreted with \"…or the default\" in mind.\r\n *\r\n * Exported because `Mesh3D` desugars the identical bag from its own props: this\r\n * is where `fill` becomes `color`-or-`map`, and two copies of that decision is\r\n * two chances for a node and a builder call to paint differently.\r\n *\r\n * @internal\r\n */\r\nexport function resolveMaterialShorthand3D(source: MaterialShorthand3D): Material3D | readonly Material3D[] {\r\n if (source.material !== undefined) return source.material;\r\n\r\n const material: Record<string, unknown> = { type: source.unlit ? \"basic\" : \"standard\" };\r\n\r\n const fill = resolveFill3D(source.fill);\r\n if (fill.color !== undefined) material.color = fill.color;\r\n if (fill.map !== undefined) material.map = fill.map;\r\n\r\n for (const key of MATERIAL_SHORTHAND_KEYS) {\r\n const value = (source as Record<string, unknown>)[key];\r\n if (value !== undefined) material[key] = value;\r\n }\r\n return material as unknown as Material3D;\r\n}\r\n\r\n/** Drop the shorthand/transform keys, leaving only a geometry's own params. */\r\nfunction pickGeometry<T>(source: object, type: string): T {\r\n const bag = source as Record<string, unknown>;\r\n const out: Record<string, unknown> = { type };\r\n for (const key in bag) {\r\n if (SHORTHAND_KEYS.includes(key)) continue;\r\n if ((TRANSFORM_KEYS as readonly string[]).includes(key)) continue;\r\n if (bag[key] !== undefined) out[key] = bag[key];\r\n }\r\n return out as T;\r\n}\r\n\r\n/** Geometry params only, with `type` and the inherited passthrough removed. */\r\ntype ParamsOf<G> = Omit<G, \"type\">;\r\n\r\n// ─── Recorder ────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * What one 3D node draws — the `Graphics2D` of 3D.\r\n *\r\n * Records an ordered list of drawables (meshes, instanced meshes, points, lines,\r\n * sprites, models), each with its own geometry, material and local transform.\r\n * That is the whole surface: it holds no camera, no lights and no hierarchy,\r\n * because those are properties of a *scene* rather than of a thing in one, and\r\n * the `Node3D` tree owns them. The exact division `Graphics2D` and\r\n * `RenderContext2D` already make in 2D.\r\n *\r\n * render: (ctx) => ctx.draw(new Graphics3D()\r\n * .box({ width: 2, cornerRadius: 0.15, fill: \"#e0533d\", roughness: 0.3 })),\r\n *\r\n * Nothing here touches a renderer: a built `Graphics3D` is handed to a\r\n * {@link RenderContext3D}, which splices its ops into the scene being recorded.\r\n *\r\n * ── One flat bag, deliberately ────────────────────────────────────────────────\r\n * `Graphics2D` paints with a *chained* `.rect(…).fill(…)`, and this does not,\r\n * which is the one place the two recorders diverge on purpose. In 2D a `fill` is\r\n * a **group-scoped op** covering the shapes recorded before it; in 3D a material\r\n * belongs to exactly one object, because a mesh *is* geometry plus material.\r\n * A chained `.box().fill()` would imply a group material that has nothing to\r\n * scope over, so the shape and what it is made of are stated together instead.\r\n *\r\n * ── Angles are DEGREES ────────────────────────────────────────────────────────\r\n * Every angle here — Euler rotations, sweep arcs, UV rotation — is in degrees,\r\n * matching the engine's 2D `rotation`. The renderer converts.\r\n *\r\n * ── Animation ─────────────────────────────────────────────────────────────────\r\n * A `Graphics3D` is rebuilt from scratch every frame, so animation is just\r\n * reading the node's own state while building:\r\n *\r\n * const Rig = component3d({\r\n * key: \"rig\",\r\n * state: { spin: 0, lift: Types.custom<Vector3>([0, 0, 0], { lerp: lerpVector3 }) },\r\n * render: (ctx, s) => ctx.draw(new Graphics3D()\r\n * .box({ rotation: [0, s.spin, 0], position: s.lift })),\r\n * });\r\n * // a `to` of { spin: 360 } over two seconds turns it\r\n *\r\n * Note the `lerp` on `lift`. An entry holding a non-number needs an explicit\r\n * tween (`lerpVector3`, `lerpEuler3`, `slerpQuaternion`) or `to()` has nothing\r\n * to interpolate it with and leaves it alone.\r\n *\r\n * ── Reconciliation identity ───────────────────────────────────────────────────\r\n * The renderer caches one live 3D object per op and mutates it between frames\r\n * rather than rebuilding. Identity is **derived**: it comes from the owning\r\n * `Node3D` plus a signature of what the op actually draws, so a builder that\r\n * emits ops conditionally reuses the right cache entry with nothing written by\r\n * hand. There is no `key` to set.\r\n *\r\n * ── What is cheap to animate ──────────────────────────────────────────────────\r\n * Transforms and most material values are in-place writes, so they cost nothing\r\n * per frame. **Geometry parameters are not** — three geometries are immutable, so\r\n * tweening `.box({ width: this.size })` reallocates the mesh every frame. Scale\r\n * the object instead: `.box({ width: 1, scale: [this.size, 1, 1] })`. The fields marked\r\n * \"structural\" on `MaterialCommon3D` recompile the shader program and should be\r\n * set once, not tweened.\r\n */\r\nexport class Graphics3D {\r\n private _ops: Graphics3DOp[] = [];\r\n\r\n /** Append one op, flagging (in development) inputs no renderer acts on. */\r\n private record(op: Graphics3DOp): void {\r\n inspectDrawable3D(op);\r\n this._ops.push(op);\r\n }\r\n\r\n // ─── Meshes ──────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record a mesh from an explicit geometry and material. The geometry sugar\r\n * methods below all funnel here.\r\n */\r\n mesh(\r\n geometry: Geometry3D,\r\n material?: Material3D | readonly Material3D[],\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"mesh\",\r\n geometry,\r\n material: material ?? { type: \"standard\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a mesh from a geometry `type` plus a flat shorthand bag. */\r\n private sugar(type: Geometry3D[\"type\"], options?: MeshShorthand3D): this {\r\n const source: MeshShorthand3D = options ?? {};\r\n return this.mesh(\r\n pickGeometry<Geometry3D>(source, type),\r\n resolveMaterialShorthand3D(source),\r\n pickTransform(source),\r\n );\r\n }\r\n\r\n box(options?: ParamsOf<BoxGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"box\", options);\r\n }\r\n sphere(options?: ParamsOf<SphereGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"sphere\", options);\r\n }\r\n plane(options?: ParamsOf<PlaneGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"plane\", options);\r\n }\r\n cylinder(options?: ParamsOf<CylinderGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cylinder\", options);\r\n }\r\n cone(options?: ParamsOf<ConeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cone\", options);\r\n }\r\n torus(options?: ParamsOf<TorusGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torus\", options);\r\n }\r\n torusKnot(options?: ParamsOf<TorusKnotGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torusKnot\", options);\r\n }\r\n circle(options?: ParamsOf<CircleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"circle\", options);\r\n }\r\n ring(options?: ParamsOf<RingGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"ring\", options);\r\n }\r\n capsule(options?: ParamsOf<CapsuleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"capsule\", options);\r\n }\r\n polyhedron(options: ParamsOf<PolyhedronGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"polyhedron\", options);\r\n }\r\n extrude(options: ParamsOf<ExtrudeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"extrude\", options);\r\n }\r\n lathe(options: ParamsOf<LatheGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"lathe\", options);\r\n }\r\n tube(options: ParamsOf<TubeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"tube\", options);\r\n }\r\n\r\n // ─── Other drawables ─────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record many copies of one geometry in a single draw call. The way to put\r\n * thousands of objects on screen — a plain `mesh` per copy would not keep up.\r\n *\r\n * g3.instances(Geo.box({ width: 0.2 }), Mat.standard({ color: \"cyan\" }),\r\n * positions.map(p => ({ position: p })))\r\n */\r\n instances(\r\n geometry: Geometry3D,\r\n material: Material3D,\r\n instances: readonly Transform3D[],\r\n options?: { colors?: readonly Color[]; transform?: Transform3D },\r\n ): this {\r\n this.record({\r\n kind: \"instances\",\r\n geometry,\r\n material,\r\n instances,\r\n colors: options?.colors,\r\n transform: options?.transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a point cloud — one sprite-like dot per vertex of `geometry`. */\r\n points(\r\n geometry: Geometry3D,\r\n material?: Material3D,\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"points\",\r\n geometry,\r\n material: material ?? { type: \"points\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a line. Give it either explicit `points` or a `geometry` (typically\r\n * `Geo.edges(...)` for a wireframe outline).\r\n *\r\n * `closed` joins the last point back to the first, as the 2D `line` op's\r\n * own field does. `segments` treats the points as disjoint start/end pairs\r\n * instead — the form `Geo.edges(...)` produces. (There is no subdivision to\r\n * confuse it with: a line is drawn from the points it is given.)\r\n */\r\n line(options: {\r\n points?: readonly Vector3Input[];\r\n geometry?: Geometry3D;\r\n material?: Material3D;\r\n /** Join the last point back to the first. */\r\n closed?: boolean;\r\n /** Treat the points as disjoint start/end pairs. */\r\n segments?: boolean;\r\n /** The line's paint. Cap and join have no meaning on a GL line. */\r\n stroke?: LineStroke3D;\r\n opacity?: number;\r\n transform?: Transform3D;\r\n } & Transform3D): this {\r\n const { points, geometry, material, closed, segments, stroke, opacity } = options;\r\n\r\n if (!points && !geometry) {\r\n throw new Error(\"Graphics3D.line() needs either `points` or `geometry`.\");\r\n }\r\n\r\n const resolved: Material3D = material ?? {\r\n type: stroke?.dash !== undefined ? \"lineDashed\" : \"lineBasic\",\r\n ...(stroke?.fill !== undefined ? { color: stroke.fill } : {}),\r\n ...(stroke?.weight !== undefined ? { width: stroke.weight } : {}),\r\n ...(stroke?.dash !== undefined\r\n ? { dashSize: stroke.dash[0], gapSize: stroke.dash[1] ?? stroke.dash[0] }\r\n : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n\r\n this.record({\r\n kind: \"line\",\r\n geometry: geometry ?? { type: \"buffer\", position: flattenPoints(points!) },\r\n material: resolved,\r\n mode: segments ? \"segments\" : closed ? \"loop\" : \"strip\",\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a camera-facing textured quad. */\r\n sprite(options: { fill?: Fill3D; material?: Material3D; opacity?: number } & Transform3D): this {\r\n const { fill, material, opacity } = options;\r\n const paint = resolveFill3D(fill);\r\n const resolved: Material3D = material ?? {\r\n type: \"sprite\",\r\n ...(paint.map !== undefined ? { map: paint.map } : {}),\r\n ...(paint.color !== undefined ? { color: paint.color } : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n this.record({\r\n kind: \"sprite\",\r\n material: resolved,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a loaded model. **glTF/GLB only**: any other format (an `.obj`, say)\r\n * resolves to an empty slot and draws nothing, and in development the first\r\n * one recorded warns.\r\n *\r\n * Baked animation is sampled by explicit `time`, never advanced by a delta, so\r\n * a model stays frame-identical under scrubbing.\r\n */\r\n model(options: {\r\n src: string;\r\n animation?: ModelAnimation3D | readonly ModelAnimation3D[];\r\n override?: Readonly<Record<string, Material3D>>;\r\n } & Transform3D): this {\r\n const { src, animation, override } = options;\r\n this.record({\r\n kind: \"model\",\r\n src,\r\n animation: animation === undefined\r\n ? undefined\r\n : Array.isArray(animation) ? animation : [animation as ModelAnimation3D],\r\n override,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n // ─── Consumption ─────────────────────────────────────────────────────────\r\n\r\n /** The recorded ops, in order. Replayed by the renderer. */\r\n ops(): readonly Graphics3DOp[] {\r\n return this._ops;\r\n }\r\n\r\n /** True when this node draws nothing. */\r\n isEmpty(): boolean {\r\n return this._ops.length === 0;\r\n }\r\n}\r\n\r\n/**\r\n * A 3D line's paint, named after the 2D `Stroke` it mirrors.\r\n *\r\n * `cap`, `join` and the rest of the 2D stroke vocabulary are deliberately absent:\r\n * they describe a stroked *path*, and a GL line has no outline to cap. Note that\r\n * `weight` above 1 is ignored by most WebGL implementations — for a genuinely\r\n * thick line, draw a `tube`.\r\n */\r\nexport interface LineStroke3D {\r\n /** The line's colour. Named `fill` to match the 2D `Stroke`. */\r\n fill?: Color;\r\n weight?: number;\r\n /** Dash and gap lengths, in world units. */\r\n dash?: readonly [number, number?];\r\n}\r\n\r\n/** Flatten `Vector3Input`s into the packed `[x, y, z, …]` a buffer wants. */\r\nfunction flattenPoints(points: readonly Vector3Input[]): number[] {\r\n const out: number[] = [];\r\n for (const point of points) {\r\n if (typeof point === \"number\") {\r\n out.push(point, point, point);\r\n } else if (Array.isArray(point)) {\r\n out.push(point[0] ?? 0, point[1] ?? 0, point[2] ?? 0);\r\n } else {\r\n const v = point as { x: number; y: number; z: number };\r\n out.push(v.x ?? 0, v.y ?? 0, v.z ?? 0);\r\n }\r\n }\r\n return out;\r\n}\r\n"]}
|
|
@@ -46,7 +46,7 @@ export type Scene3DOp = {
|
|
|
46
46
|
* .light({ type: "ambient", intensity: 0.4 })
|
|
47
47
|
* .draw(new Graphics3D().box({ width: 2, fill: "tomato" }));
|
|
48
48
|
*
|
|
49
|
-
*
|
|
49
|
+
* Text({ text: "DEPTH", fontSize: 320, fill: scene })
|
|
50
50
|
*
|
|
51
51
|
* A bare `Scene3D` coerces to a `canvas3D` fill the way a bare CSS string coerces
|
|
52
52
|
* to a solid one, so `fill={scene}` and `fill={["#0b0d12", scene]}` both work.
|
package/dist/render3d/scene3d.js
CHANGED
|
@@ -19,7 +19,7 @@ import { warnInert3D } from "./inert.js";
|
|
|
19
19
|
* .light({ type: "ambient", intensity: 0.4 })
|
|
20
20
|
* .draw(new Graphics3D().box({ width: 2, fill: "tomato" }));
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Text({ text: "DEPTH", fontSize: 320, fill: scene })
|
|
23
23
|
*
|
|
24
24
|
* A bare `Scene3D` coerces to a `canvas3D` fill the way a bare CSS string coerces
|
|
25
25
|
* to a solid one, so `fill={scene}` and `fill={["#0b0d12", scene]}` both work.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene3d.js","sourceRoot":"","sources":["../../src/render3d/scene3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACH,gBAAgB,GAGnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqBtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,OAAQ,SAAQ,eAAe;IAChC,IAAI,GAAgB,EAAE,CAAC;IACvB,OAAO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AAa,CAAC;YAClE,MAAM,IAAI,KAAK,CACX,eAAe,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAClD,CAAC;QACN,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { DRAWABLE_KINDS, Graphics3D, type Graphics3DOp } from \"./graphics3d\";\r\nimport { RenderContext3D, type Node3DRenderState } from \"./render-context3d\";\r\nimport type { CameraData3D, OrthographicCameraData3D, PerspectiveCameraData3D } from \"./camera\";\r\nimport type { LightData3D } from \"./light\";\r\nimport {\r\n resolveShadows3D,\r\n type EnvironmentData3D, type FogData3D, type PostEffect3D,\r\n type ShadowSettings3D, type Shadows3D, type ToneSettings3D,\r\n} from \"./scene-settings\";\r\nimport { warnInert3D } from \"./inert\";\r\nimport type { Shadow3D, Transform3D } from \"./transform\";\r\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\r\n\r\n/** Options accepted by every `Camera3D` node and by {@link Scene3D.perspective}. */\r\ntype ParamsOf<T extends { type: string }> = Omit<T, \"type\">;\r\n\r\n/**\r\n * One recorded operation in a {@link Scene3D}.\r\n *\r\n * A superset of {@link Graphics3DOp}: everything a node draws, plus the four\r\n * things that describe the scene around it — the `push`/`pop` nesting the node\r\n * tree produces, the lights in it, and where it is viewed from.\r\n */\r\nexport type Scene3DOp =\r\n | { kind: \"push\"; transform?: Transform3D }\r\n | { kind: \"pop\" }\r\n | { kind: \"light\"; light: LightData3D; transform?: Transform3D }\r\n | { kind: \"camera\"; camera: CameraData3D }\r\n | Graphics3DOp;\r\n\r\n/**\r\n * A recorded 3D scene — and the {@link RenderContext3D} that records it.\r\n *\r\n * One value plays both parts, exactly as `Graphics2D` is both the builder and the\r\n * thing handed to a backend. A `Node3D` tree draws into it, and the result is a\r\n * flat op list plus a handful of scene-wide settings that a renderer replays.\r\n *\r\n * Almost always produced for you: a `Canvas3D` opens one per frame, walks its\r\n * `Node3D` children through it and paints the result through its own path. The\r\n * builder surface below is the escape hatch — it is what lets a scene be shaded\r\n * through *any* 2D shape rather than only a rect:\r\n *\r\n * const scene = new Scene3D()\r\n * .perspective({ orbit: 30, elevation: 20, distance: 6 })\r\n * .light({ type: \"ambient\", intensity: 0.4 })\r\n * .draw(new Graphics3D().box({ width: 2, fill: \"tomato\" }));\r\n *\r\n * <Text text=\"DEPTH\" fontSize={320} fill={scene} />\r\n *\r\n * A bare `Scene3D` coerces to a `canvas3D` fill the way a bare CSS string coerces\r\n * to a solid one, so `fill={scene}` and `fill={[\"#0b0d12\", scene]}` both work.\r\n */\r\nexport class Scene3D extends RenderContext3D {\r\n private _ops: Scene3DOp[] = [];\r\n private _camera: CameraData3D | null = null;\r\n private _fog: FogData3D | null = null;\r\n private _environment: EnvironmentData3D | null = null;\r\n private _shadows: ShadowSettings3D | null = null;\r\n private _tone: ToneSettings3D | null = null;\r\n private _post: PostEffect3D[] = [];\r\n /** Open `push` count, so {@link assertBalanced} can report a leak. */\r\n private _depth = 0;\r\n /**\r\n * The `shadow` of each open node scope, innermost last (`undefined` for a\r\n * scope that states none). What a drawable that states none of its own takes.\r\n */\r\n private _shadowScopes: (Shadow3D | undefined)[] = [];\r\n\r\n // ─── Node scopes ─────────────────────────────────────────────────────────\r\n\r\n override begin(state: Node3DRenderState): void {\r\n // The node's id rides on the transform's `key`, which is the renderer's\r\n // identity slot — so a group is cached against the node that opened it\r\n // rather than against its index among its siblings.\r\n this._ops.push({ kind: \"push\", transform: { ...state.transform, key: state.id } });\r\n this._shadowScopes.push(state.transform?.shadow);\r\n this._depth++;\r\n }\r\n\r\n override end(): void {\r\n this._ops.push({ kind: \"pop\" });\r\n this._shadowScopes.pop();\r\n this._depth--;\r\n }\r\n\r\n // ─── Drawables ───────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Splice what a node draws into the scene at the current scope.\r\n *\r\n * The ops are copied rather than referenced: a `Graphics3D` is rebuilt every\r\n * frame, so there is nothing to share, and a flat list is what the renderer\r\n * walks.\r\n *\r\n * A drawable that states no `shadow` of its own takes the one of the node\r\n * scope it is drawn in. That is what carries a node's `shadow` to its mesh: the\r\n * node's scope becomes a group, and a renderer reads casting and receiving off\r\n * the mesh, never off a group, so the scope's value would otherwise never be\r\n * seen. A `shadow` on the op itself wins.\r\n */\r\n override draw(graphics: Graphics3D): this {\r\n const ops = graphics.ops();\r\n const scope = this._shadowScopes[this._shadowScopes.length - 1];\r\n for (let i = 0; i < ops.length; i++) {\r\n const op = ops[i];\r\n if (scope === undefined || op.transform?.shadow !== undefined) {\r\n this._ops.push(op);\r\n } else {\r\n this._ops.push({ ...op, transform: { ...op.transform, shadow: scope } });\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n // ─── Lights ──────────────────────────────────────────────────────────────\r\n\r\n override light(light: LightData3D, transform?: Transform3D): this {\r\n this._ops.push({ kind: \"light\", light, transform });\r\n return this;\r\n }\r\n\r\n // ─── Camera ──────────────────────────────────────────────────────────────\r\n\r\n override camera(camera: CameraData3D): this {\r\n this._camera = camera;\r\n this._ops.push({ kind: \"camera\", camera });\r\n return this;\r\n }\r\n\r\n /** Set a perspective camera. The usual choice. */\r\n perspective(options?: ParamsOf<PerspectiveCameraData3D>): this {\r\n return this.camera({ type: \"perspective\", ...options } as PerspectiveCameraData3D);\r\n }\r\n\r\n /** Set an orthographic camera — parallel projection, for isometric looks. */\r\n orthographic(options?: ParamsOf<OrthographicCameraData3D>): this {\r\n return this.camera({ type: \"orthographic\", ...options } as OrthographicCameraData3D);\r\n }\r\n\r\n // ─── Scene settings ──────────────────────────────────────────────────────\r\n //\r\n // Fields rather than ops: a scene has exactly one fog and one environment.\r\n // Recording them positionally would imply an ordering that doesn't exist.\r\n // Last writer wins.\r\n\r\n override fog(fog: FogData3D | Color | null): this {\r\n if (fog === null) {\r\n this._fog = null;\r\n } else if (typeof fog === \"object\" && !Array.isArray(fog)) {\r\n this._fog = fog as FogData3D;\r\n } else {\r\n this._fog = { color: fog as Color };\r\n }\r\n return this;\r\n }\r\n\r\n override environment(environment: EnvironmentData3D | null): this {\r\n if (environment) {\r\n if (environment.src !== undefined || (environment.faces?.length ?? 0) > 0) {\r\n warnInert3D(\r\n \"environment-src\",\r\n \"An environment's `src` and `faces` (HDR, EXR, cubemap) are recorded, and no backend loads them. Only `preset: \\\"studio\\\"` is rendered: \"\r\n + \"without a preset the scene gets no image-based light and its `background` is not drawn.\",\r\n );\r\n }\r\n if (environment.params && Object.keys(environment.params).length > 0) {\r\n warnInert3D(\r\n \"environment-params\",\r\n \"`params` on an environment is not applied: nothing assigns it onto the generated environment.\",\r\n );\r\n }\r\n }\r\n this._environment = environment;\r\n return this;\r\n }\r\n\r\n override shadows(settings?: Shadows3D): this {\r\n this._shadows = resolveShadows3D(settings ?? true);\r\n return this;\r\n }\r\n\r\n override tone(settings: ToneSettings3D): this {\r\n this._tone = settings;\r\n return this;\r\n }\r\n\r\n override post(effects: PostEffect3D | readonly PostEffect3D[]): this {\r\n const added = Array.isArray(effects) ? (effects as PostEffect3D[]) : [effects as PostEffect3D];\r\n if (added.length > 0) {\r\n warnInert3D(\r\n \"post\",\r\n `Post-processing (${added.map((effect) => `\"${effect.type}\"`).join(\", \")}) is recorded, and no backend applies a pass: the scene renders exactly as it would without \\`post\\`. `\r\n + \"Use the Canvas3D's 2D `effects` over the composited result instead.\",\r\n );\r\n }\r\n this._post.push(...added);\r\n return this;\r\n }\r\n\r\n // ─── Consumption ─────────────────────────────────────────────────────────\r\n\r\n /** The recorded ops, in order. Replayed by the renderer. */\r\n ops(): readonly Scene3DOp[] {\r\n return this._ops;\r\n }\r\n\r\n /** The camera, or `null` to let the renderer supply a default framing. */\r\n cameraDescriptor(): CameraData3D | null {\r\n return this._camera;\r\n }\r\n fogDescriptor(): FogData3D | null {\r\n return this._fog;\r\n }\r\n environmentDescriptor(): EnvironmentData3D | null {\r\n return this._environment;\r\n }\r\n shadowSettings(): ShadowSettings3D | null {\r\n return this._shadows;\r\n }\r\n toneSettings(): ToneSettings3D | null {\r\n return this._tone;\r\n }\r\n postEffects(): readonly PostEffect3D[] {\r\n return this._post;\r\n }\r\n\r\n /**\r\n * True when nothing would be drawn — no mesh, light or other drawable. The\r\n * node skips the whole 3D pass (and the WebGL context entirely) in that case.\r\n */\r\n isEmpty(): boolean {\r\n return !this._ops.some((op) => DRAWABLE_KINDS.has(op.kind));\r\n }\r\n\r\n /**\r\n * Throw if `push` and `pop` are unbalanced. Called once by the consumer before\r\n * replay, so a mismatched scope fails loudly rather than silently reparenting\r\n * everything after it.\r\n *\r\n * A `Node3D` tree cannot get this wrong — `begin`/`end` are bracketed by the\r\n * walk — so in practice this catches a hand-built scene.\r\n */\r\n assertBalanced(): void {\r\n if (this._depth !== 0) {\r\n const verb = this._depth > 0 ? \"unclosed begin()\" : \"extra end()\";\r\n throw new Error(\r\n `Scene3D has ${Math.abs(this._depth)} ${verb}.`,\r\n );\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"scene3d.js","sourceRoot":"","sources":["../../src/render3d/scene3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACH,gBAAgB,GAGnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqBtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,OAAQ,SAAQ,eAAe;IAChC,IAAI,GAAgB,EAAE,CAAC;IACvB,OAAO,GAAwB,IAAI,CAAC;IACpC,IAAI,GAAqB,IAAI,CAAC;IAC9B,YAAY,GAA6B,IAAI,CAAC;IAC9C,QAAQ,GAA4B,IAAI,CAAC;IACzC,KAAK,GAA0B,IAAI,CAAC;IACpC,KAAK,GAAmB,EAAE,CAAC;IACnC,sEAAsE;IAC9D,MAAM,GAAG,CAAC,CAAC;IACnB;;;OAGG;IACK,aAAa,GAA6B,EAAE,CAAC;IAErD,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EAAqE,CAC1E,CAAC;QACN,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,4EAA4E;IAE5E,4DAA4D;IAC5D,GAAG;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,0EAA0E;IAC1E,gBAAgB;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,aAAa;QACT,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,qBAAqB;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,cAAc;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,YAAY;QACR,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,WAAW;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,OAAO;QACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;OAOG;IACH,cAAc;QACV,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,CAAC;YAClE,MAAM,IAAI,KAAK,CACX,eAAe,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAClD,CAAC;QACN,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { DRAWABLE_KINDS, Graphics3D, type Graphics3DOp } from \"./graphics3d\";\r\nimport { RenderContext3D, type Node3DRenderState } from \"./render-context3d\";\r\nimport type { CameraData3D, OrthographicCameraData3D, PerspectiveCameraData3D } from \"./camera\";\r\nimport type { LightData3D } from \"./light\";\r\nimport {\r\n resolveShadows3D,\r\n type EnvironmentData3D, type FogData3D, type PostEffect3D,\r\n type ShadowSettings3D, type Shadows3D, type ToneSettings3D,\r\n} from \"./scene-settings\";\r\nimport { warnInert3D } from \"./inert\";\r\nimport type { Shadow3D, Transform3D } from \"./transform\";\r\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\r\n\r\n/** Options accepted by every `Camera3D` node and by {@link Scene3D.perspective}. */\r\ntype ParamsOf<T extends { type: string }> = Omit<T, \"type\">;\r\n\r\n/**\r\n * One recorded operation in a {@link Scene3D}.\r\n *\r\n * A superset of {@link Graphics3DOp}: everything a node draws, plus the four\r\n * things that describe the scene around it — the `push`/`pop` nesting the node\r\n * tree produces, the lights in it, and where it is viewed from.\r\n */\r\nexport type Scene3DOp =\r\n | { kind: \"push\"; transform?: Transform3D }\r\n | { kind: \"pop\" }\r\n | { kind: \"light\"; light: LightData3D; transform?: Transform3D }\r\n | { kind: \"camera\"; camera: CameraData3D }\r\n | Graphics3DOp;\r\n\r\n/**\r\n * A recorded 3D scene — and the {@link RenderContext3D} that records it.\r\n *\r\n * One value plays both parts, exactly as `Graphics2D` is both the builder and the\r\n * thing handed to a backend. A `Node3D` tree draws into it, and the result is a\r\n * flat op list plus a handful of scene-wide settings that a renderer replays.\r\n *\r\n * Almost always produced for you: a `Canvas3D` opens one per frame, walks its\r\n * `Node3D` children through it and paints the result through its own path. The\r\n * builder surface below is the escape hatch — it is what lets a scene be shaded\r\n * through *any* 2D shape rather than only a rect:\r\n *\r\n * const scene = new Scene3D()\r\n * .perspective({ orbit: 30, elevation: 20, distance: 6 })\r\n * .light({ type: \"ambient\", intensity: 0.4 })\r\n * .draw(new Graphics3D().box({ width: 2, fill: \"tomato\" }));\r\n *\r\n * Text({ text: \"DEPTH\", fontSize: 320, fill: scene })\r\n *\r\n * A bare `Scene3D` coerces to a `canvas3D` fill the way a bare CSS string coerces\r\n * to a solid one, so `fill={scene}` and `fill={[\"#0b0d12\", scene]}` both work.\r\n */\r\nexport class Scene3D extends RenderContext3D {\r\n private _ops: Scene3DOp[] = [];\r\n private _camera: CameraData3D | null = null;\r\n private _fog: FogData3D | null = null;\r\n private _environment: EnvironmentData3D | null = null;\r\n private _shadows: ShadowSettings3D | null = null;\r\n private _tone: ToneSettings3D | null = null;\r\n private _post: PostEffect3D[] = [];\r\n /** Open `push` count, so {@link assertBalanced} can report a leak. */\r\n private _depth = 0;\r\n /**\r\n * The `shadow` of each open node scope, innermost last (`undefined` for a\r\n * scope that states none). What a drawable that states none of its own takes.\r\n */\r\n private _shadowScopes: (Shadow3D | undefined)[] = [];\r\n\r\n // ─── Node scopes ─────────────────────────────────────────────────────────\r\n\r\n override begin(state: Node3DRenderState): void {\r\n // The node's id rides on the transform's `key`, which is the renderer's\r\n // identity slot — so a group is cached against the node that opened it\r\n // rather than against its index among its siblings.\r\n this._ops.push({ kind: \"push\", transform: { ...state.transform, key: state.id } });\r\n this._shadowScopes.push(state.transform?.shadow);\r\n this._depth++;\r\n }\r\n\r\n override end(): void {\r\n this._ops.push({ kind: \"pop\" });\r\n this._shadowScopes.pop();\r\n this._depth--;\r\n }\r\n\r\n // ─── Drawables ───────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Splice what a node draws into the scene at the current scope.\r\n *\r\n * The ops are copied rather than referenced: a `Graphics3D` is rebuilt every\r\n * frame, so there is nothing to share, and a flat list is what the renderer\r\n * walks.\r\n *\r\n * A drawable that states no `shadow` of its own takes the one of the node\r\n * scope it is drawn in. That is what carries a node's `shadow` to its mesh: the\r\n * node's scope becomes a group, and a renderer reads casting and receiving off\r\n * the mesh, never off a group, so the scope's value would otherwise never be\r\n * seen. A `shadow` on the op itself wins.\r\n */\r\n override draw(graphics: Graphics3D): this {\r\n const ops = graphics.ops();\r\n const scope = this._shadowScopes[this._shadowScopes.length - 1];\r\n for (let i = 0; i < ops.length; i++) {\r\n const op = ops[i];\r\n if (scope === undefined || op.transform?.shadow !== undefined) {\r\n this._ops.push(op);\r\n } else {\r\n this._ops.push({ ...op, transform: { ...op.transform, shadow: scope } });\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n // ─── Lights ──────────────────────────────────────────────────────────────\r\n\r\n override light(light: LightData3D, transform?: Transform3D): this {\r\n this._ops.push({ kind: \"light\", light, transform });\r\n return this;\r\n }\r\n\r\n // ─── Camera ──────────────────────────────────────────────────────────────\r\n\r\n override camera(camera: CameraData3D): this {\r\n this._camera = camera;\r\n this._ops.push({ kind: \"camera\", camera });\r\n return this;\r\n }\r\n\r\n /** Set a perspective camera. The usual choice. */\r\n perspective(options?: ParamsOf<PerspectiveCameraData3D>): this {\r\n return this.camera({ type: \"perspective\", ...options } as PerspectiveCameraData3D);\r\n }\r\n\r\n /** Set an orthographic camera — parallel projection, for isometric looks. */\r\n orthographic(options?: ParamsOf<OrthographicCameraData3D>): this {\r\n return this.camera({ type: \"orthographic\", ...options } as OrthographicCameraData3D);\r\n }\r\n\r\n // ─── Scene settings ──────────────────────────────────────────────────────\r\n //\r\n // Fields rather than ops: a scene has exactly one fog and one environment.\r\n // Recording them positionally would imply an ordering that doesn't exist.\r\n // Last writer wins.\r\n\r\n override fog(fog: FogData3D | Color | null): this {\r\n if (fog === null) {\r\n this._fog = null;\r\n } else if (typeof fog === \"object\" && !Array.isArray(fog)) {\r\n this._fog = fog as FogData3D;\r\n } else {\r\n this._fog = { color: fog as Color };\r\n }\r\n return this;\r\n }\r\n\r\n override environment(environment: EnvironmentData3D | null): this {\r\n if (environment) {\r\n if (environment.src !== undefined || (environment.faces?.length ?? 0) > 0) {\r\n warnInert3D(\r\n \"environment-src\",\r\n \"An environment's `src` and `faces` (HDR, EXR, cubemap) are recorded, and no backend loads them. Only `preset: \\\"studio\\\"` is rendered: \"\r\n + \"without a preset the scene gets no image-based light and its `background` is not drawn.\",\r\n );\r\n }\r\n if (environment.params && Object.keys(environment.params).length > 0) {\r\n warnInert3D(\r\n \"environment-params\",\r\n \"`params` on an environment is not applied: nothing assigns it onto the generated environment.\",\r\n );\r\n }\r\n }\r\n this._environment = environment;\r\n return this;\r\n }\r\n\r\n override shadows(settings?: Shadows3D): this {\r\n this._shadows = resolveShadows3D(settings ?? true);\r\n return this;\r\n }\r\n\r\n override tone(settings: ToneSettings3D): this {\r\n this._tone = settings;\r\n return this;\r\n }\r\n\r\n override post(effects: PostEffect3D | readonly PostEffect3D[]): this {\r\n const added = Array.isArray(effects) ? (effects as PostEffect3D[]) : [effects as PostEffect3D];\r\n if (added.length > 0) {\r\n warnInert3D(\r\n \"post\",\r\n `Post-processing (${added.map((effect) => `\"${effect.type}\"`).join(\", \")}) is recorded, and no backend applies a pass: the scene renders exactly as it would without \\`post\\`. `\r\n + \"Use the Canvas3D's 2D `effects` over the composited result instead.\",\r\n );\r\n }\r\n this._post.push(...added);\r\n return this;\r\n }\r\n\r\n // ─── Consumption ─────────────────────────────────────────────────────────\r\n\r\n /** The recorded ops, in order. Replayed by the renderer. */\r\n ops(): readonly Scene3DOp[] {\r\n return this._ops;\r\n }\r\n\r\n /** The camera, or `null` to let the renderer supply a default framing. */\r\n cameraDescriptor(): CameraData3D | null {\r\n return this._camera;\r\n }\r\n fogDescriptor(): FogData3D | null {\r\n return this._fog;\r\n }\r\n environmentDescriptor(): EnvironmentData3D | null {\r\n return this._environment;\r\n }\r\n shadowSettings(): ShadowSettings3D | null {\r\n return this._shadows;\r\n }\r\n toneSettings(): ToneSettings3D | null {\r\n return this._tone;\r\n }\r\n postEffects(): readonly PostEffect3D[] {\r\n return this._post;\r\n }\r\n\r\n /**\r\n * True when nothing would be drawn — no mesh, light or other drawable. The\r\n * node skips the whole 3D pass (and the WebGL context entirely) in that case.\r\n */\r\n isEmpty(): boolean {\r\n return !this._ops.some((op) => DRAWABLE_KINDS.has(op.kind));\r\n }\r\n\r\n /**\r\n * Throw if `push` and `pop` are unbalanced. Called once by the consumer before\r\n * replay, so a mismatched scope fails loudly rather than silently reparenting\r\n * everything after it.\r\n *\r\n * A `Node3D` tree cannot get this wrong — `begin`/`end` are bracketed by the\r\n * walk — so in practice this catches a hand-built scene.\r\n */\r\n assertBalanced(): void {\r\n if (this._depth !== 0) {\r\n const verb = this._depth > 0 ? \"unclosed begin()\" : \"extra end()\";\r\n throw new Error(\r\n `Scene3D has ${Math.abs(this._depth)} ${verb}.`,\r\n );\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Vector2 } from "../attributes/layout/vector2.js";
|
|
2
2
|
import type { Graphics2D } from "../render/graphics2d.js";
|
|
3
|
-
import type { Node } from "../
|
|
4
|
-
import type { Node2D } from "../
|
|
3
|
+
import type { Node } from "../components/trees/node/node.js";
|
|
4
|
+
import type { Node2D } from "../components/trees/2d/node2d.js";
|
|
5
5
|
/** How sampling behaves outside the 0–1 UV range. */
|
|
6
6
|
export type TextureWrap3D = "clamp" | "repeat" | "mirror";
|
|
7
7
|
/** How texels are blended when the texture is scaled. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../../src/render3d/texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../../src/render3d/texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE3D,qDAAqD;AACrD,MAAM,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IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import type { Vector2 } from \"@/attributes/layout/vector2\";\r\n// Type-only, like `Color` above: `render3d` is pure data and never reaches into\r\n// the render or node layers at runtime. See SurfaceSource3D.\r\nimport type { Graphics2D } from \"@/render/graphics2d\";\r\nimport type { Node } from \"@/nodes/node/node\";\r\nimport type { Node2D } from \"@/nodes/2d/node2d\";\r\n\r\n/** How sampling behaves outside the 0–1 UV range. */\r\nexport type TextureWrap3D = \"clamp\" | \"repeat\" | \"mirror\";\r\n\r\n/** How texels are blended when the texture is scaled. */\r\nexport type TextureFilter3D = \"nearest\" | \"linear\";\r\n\r\n/**\r\n * Which colour space the texture's data is in.\r\n *\r\n * `\"srgb\"` for anything representing a *colour* an eye would see (albedo/`map`,\r\n * `emissiveMap`), so the renderer linearizes it before lighting maths.\r\n * `\"linear\"` for *data* maps whose channels are numbers rather than colours\r\n * (`normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `displacementMap`) —\r\n * linearizing those would corrupt them. Each map slot defaults correctly, so\r\n * this only needs setting for unusual pipelines.\r\n */\r\nexport type TextureColorSpace3D = \"srgb\" | \"linear\";\r\n\r\n/** Sampler state shared by every texture source. */\r\nexport interface TextureOptions3D {\r\n wrapS?: TextureWrap3D;\r\n wrapT?: TextureWrap3D;\r\n /** UV scale. `[2, 2]` tiles twice on each axis (needs a `repeat` wrap). */\r\n repeat?: Vector2 | readonly [number, number];\r\n offset?: Vector2 | readonly [number, number];\r\n /** UV rotation in **degrees**, about {@link center}. */\r\n rotation?: number;\r\n center?: Vector2 | readonly [number, number];\r\n magFilter?: TextureFilter3D;\r\n minFilter?: TextureFilter3D;\r\n /** Sharpness at grazing angles. Clamped to the GPU's maximum. */\r\n anisotropy?: number;\r\n flipY?: boolean;\r\n colorSpace?: TextureColorSpace3D;\r\n}\r\n\r\n/**\r\n * A texture loaded from the project's asset manifest.\r\n *\r\n * `src` is discovered by the asset-tracking render pass and requested through\r\n * core's ordinary image pipeline — the very same path a 2D image fill uses — so\r\n * the pixels are decoded and resident *before* the frame that needs them draws.\r\n */\r\nexport interface ImageTexture3D extends TextureOptions3D {\r\n src: string;\r\n}\r\n\r\n/**\r\n * A texture built from raw RGBA8888 bytes — the escape hatch for procedurally\r\n * generated pixels (gradient ramps, noise, LUTs, data encoded as colour).\r\n */\r\nexport interface DataTexture3D extends TextureOptions3D {\r\n data: ArrayLike<number>;\r\n width: number;\r\n height: number;\r\n /**\r\n * Bump to force a re-upload after mutating `data` in place. Mutation is\r\n * invisible to identity comparison, so without this the renderer cannot\r\n * tell the bytes changed. See {@link BufferGeometry3D.revision}.\r\n */\r\n revision?: number;\r\n}\r\n\r\n/**\r\n * A texture whose pixels are Motion Script's own 2D output, rasterized offscreen\r\n * — the way to put a chart, a readout or a whole laid-out UI onto 3D geometry.\r\n *\r\n * `source` is a value, not a name and not a mounted node: either a built\r\n * {@link Graphics2D} command list, or a `Node2D` subtree. Both are supplied directly,\r\n * so there is no matching indirection and nothing has to live in a particular\r\n * place in the scene tree.\r\n *\r\n * g3.plane({ map: Tex.surface(scopeGraphics, 1024, 640) })\r\n * g3.plane({ map: Tex.surface(statsSubtree, 1024, 640) })\r\n *\r\n * A `Node2D` source is *adopted for binding* by whatever paints the scene — it gets\r\n * that node's asset catalog, inherited context and clock, which is what makes a\r\n * webfont shape and an `<Image>` load. It is never laid out or painted by the\r\n * scene tree; it is measured against `width`×`height` and drawn into the buffer.\r\n *\r\n * **Hoist the source.** Building it fresh inside the scene builder allocates a new\r\n * subtree every frame — re-binding, re-laying-out, defeating the texture cache and\r\n * leaking. Declare it once and pass the same instance.\r\n *\r\n * That hoisting rule is also what removed this descriptor's old `key`: a hoisted\r\n * source *is* a stable identity, so the renderer keys the GPU texture off the\r\n * source object itself (in a `WeakMap`) rather than off its ordinal in the scene\r\n * walk. A conditionally-emitted surface therefore needs nothing written by hand,\r\n * and a source that goes out of scope becomes collectable instead of orphaning\r\n * its texture — which the ordinal scheme could not do.\r\n */\r\nexport interface SurfaceTexture3D extends TextureOptions3D {\r\n /** A built `Graphics2D`, or a `Node2D` subtree. Typed structurally — see below. */\r\n source: SurfaceSource3D;\r\n /** Buffer width in pixels. This *is* the texture's resolution. */\r\n width: number;\r\n /** Buffer height in pixels. */\r\n height: number;\r\n /**\r\n * Declare the source's pixels unchanging, so the buffer is rasterized once\r\n * and reused rather than redrawn every frame.\r\n *\r\n * Set by `resolveFill3D` for a fill chain, whose layers describe the same\r\n * image on every frame; an author's own source is live by default, which is\r\n * what makes an animated `Graphics2D` or a prop-driven subtree work with no\r\n * bookkeeping. Needs {@link identity} to be cacheable.\r\n *\r\n * @internal\r\n */\r\n static?: boolean;\r\n /**\r\n * Cache identity for a synthesized source.\r\n *\r\n * An author's source is identified by the source object itself (see the note\r\n * above), which is exactly right for something hoisted. A source built *for*\r\n * a fill is a fresh object every frame and has no such identity, so the value\r\n * it was derived from supplies one.\r\n *\r\n * @internal\r\n */\r\n identity?: string;\r\n /**\r\n * Ceiling on the buffer's device-pixel ratio. Default 1, i.e. the buffer is\r\n * exactly `width` × `height`.\r\n *\r\n * Unlike a 2D node — which wants to match the display — a surface is sampled by\r\n * a 3D material at whatever size the geometry occupies on screen, so the honest\r\n * control is `width`/`height`. Raise this only when a surface is viewed close\r\n * up and reads soft.\r\n */\r\n maxPixelRatio?: number;\r\n}\r\n\r\n/**\r\n * What a {@link SurfaceTexture3D} can be painted from: a built {@link Graphics2D}\r\n * command list, or a {@link Node2D} subtree.\r\n *\r\n * Both imports are **type-only**, exactly as `Color` is — `render3d` describes\r\n * scenes as data and never reaches into the render or node layers at runtime, and\r\n * a value import of `Node2D` here would close a real module cycle. Consumers narrow\r\n * with {@link resolveSurfaceSource}.\r\n */\r\nexport type SurfaceSource3D = Graphics2D | Node;\r\n\r\n// Declared against the dimension-agnostic base because that is what JSX produces\r\n// (`JSX.Element` is `Node`), so `Tex.surface(<Rect/>, …)` type-checks without a\r\n// cast. It has to be a 2D subtree in fact — the renderer lays it out and draws it\r\n// into a 2D buffer — and `resolveSurfaceSource` narrows to that; handing it a\r\n// `Node3D` fails at render time rather than here.\r\n\r\n/** A {@link SurfaceSource3D} narrowed to the arm its renderer should take. */\r\nexport type ResolvedSurfaceSource =\r\n | { kind: \"graphics\"; graphics: Graphics2D }\r\n | { kind: \"node\"; node: Node2D };\r\n\r\n/**\r\n * Narrow a surface source to the arm that knows how to draw it: a `Graphics2D` is\r\n * replayed into a render context, a `Node2D` is laid out against the buffer and\r\n * rendered.\r\n *\r\n * Structural rather than `instanceof`, because that would need value imports of\r\n * both classes and close the cycle the type-only imports above avoid. `Graphics2D`\r\n * is a command recorder and exposes `ops()`; a `Node2D` has no such method. The\r\n * union makes any *other* value a type error, so this only has to separate two\r\n * known shapes rather than validate an unknown one.\r\n */\r\nexport function resolveSurfaceSource(source: SurfaceSource3D): ResolvedSurfaceSource {\r\n return typeof (source as Graphics2D).ops === \"function\"\r\n ? { kind: \"graphics\", graphics: source as Graphics2D }\r\n : { kind: \"node\", node: source as Node2D };\r\n}\r\n\r\n/**\r\n * A texture reference. A bare string is sugar for `{ src }`, so the common case\r\n * is `map: \"/wood.png\"`.\r\n */\r\nexport type Texture3D = string | ImageTexture3D | DataTexture3D | SurfaceTexture3D;\r\n\r\n/** True for the raw-bytes form (vs. an asset-backed {@link ImageTexture3D}). */\r\nexport function isDataTexture3D(texture: Texture3D): texture is DataTexture3D {\r\n return typeof texture !== \"string\" && \"data\" in texture;\r\n}\r\n\r\n/** True for the {@link SurfaceTexture3D} form — pixels are rasterized from 2D. */\r\nexport function isSurfaceTexture3D(texture: Texture3D): texture is SurfaceTexture3D {\r\n return typeof texture !== \"string\" && \"source\" in texture;\r\n}\r\n\r\n/** Normalize the string shorthand to an {@link ImageTexture3D}. */\r\nexport function resolveTexture3D(texture: Texture3D): ImageTexture3D | DataTexture3D | SurfaceTexture3D {\r\n return typeof texture === \"string\" ? { src: texture } : texture;\r\n}\r\n\r\n/**\r\n * The asset `src` a texture reads from, or `null` when it has none (a data or\r\n * surface texture). Used by the asset-tracking pass to enumerate what a 3D scene\r\n * needs loaded — a `null` here means \"nothing to request\", not \"not a texture\".\r\n */\r\nexport function texture3DSource(texture: Texture3D): string | null {\r\n if (typeof texture === \"string\") return texture;\r\n if (isDataTexture3D(texture) || isSurfaceTexture3D(texture)) return null;\r\n return texture.src;\r\n}\r\n\r\n/**\r\n * True for a string that names an asset rather than a colour.\r\n *\r\n * Leading `/` or `.` is a path by construction; otherwise the extension decides.\r\n * A colour never matches either, and a bare name like `\"wood\"` is a colour —\r\n * which is right, since an asset reference without a path or extension is not\r\n * something the manifest could resolve either.\r\n */\r\nexport function looksLikeAssetPath(value: string): boolean {\r\n return value.startsWith(\"/\")\r\n || value.startsWith(\".\")\r\n || /\\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"texture.js","sourceRoot":"","sources":["../../src/render3d/texture.ts"],"names":[],"mappings":"AAkKA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IACxD,OAAO,OAAQ,MAAqB,CAAC,GAAG,KAAK,UAAU;QACnD,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAoB,EAAE;QACtD,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAgB,EAAE,CAAC;AACnD,CAAC;AAQD,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,OAAkB;IAC9C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,IAAI,OAAO,CAAC;AAC5D,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACjD,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,IAAI,OAAO,CAAC;AAC9D,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,OAAkB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAAkB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,OAAO,OAAO,CAAC,GAAG,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;WACrB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;WACrB,0DAA0D,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import type { Vector2 } from \"@/attributes/layout/vector2\";\r\n// Type-only, like `Color` above: `render3d` is pure data and never reaches into\r\n// the render or node layers at runtime. See SurfaceSource3D.\r\nimport type { Graphics2D } from \"@/render/graphics2d\";\r\nimport type { Node } from \"@/components/trees/node/node\";\r\nimport type { Node2D } from \"@/components/trees/2d/node2d\";\r\n\r\n/** How sampling behaves outside the 0–1 UV range. */\r\nexport type TextureWrap3D = \"clamp\" | \"repeat\" | \"mirror\";\r\n\r\n/** How texels are blended when the texture is scaled. */\r\nexport type TextureFilter3D = \"nearest\" | \"linear\";\r\n\r\n/**\r\n * Which colour space the texture's data is in.\r\n *\r\n * `\"srgb\"` for anything representing a *colour* an eye would see (albedo/`map`,\r\n * `emissiveMap`), so the renderer linearizes it before lighting maths.\r\n * `\"linear\"` for *data* maps whose channels are numbers rather than colours\r\n * (`normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `displacementMap`) —\r\n * linearizing those would corrupt them. Each map slot defaults correctly, so\r\n * this only needs setting for unusual pipelines.\r\n */\r\nexport type TextureColorSpace3D = \"srgb\" | \"linear\";\r\n\r\n/** Sampler state shared by every texture source. */\r\nexport interface TextureOptions3D {\r\n wrapS?: TextureWrap3D;\r\n wrapT?: TextureWrap3D;\r\n /** UV scale. `[2, 2]` tiles twice on each axis (needs a `repeat` wrap). */\r\n repeat?: Vector2 | readonly [number, number];\r\n offset?: Vector2 | readonly [number, number];\r\n /** UV rotation in **degrees**, about {@link center}. */\r\n rotation?: number;\r\n center?: Vector2 | readonly [number, number];\r\n magFilter?: TextureFilter3D;\r\n minFilter?: TextureFilter3D;\r\n /** Sharpness at grazing angles. Clamped to the GPU's maximum. */\r\n anisotropy?: number;\r\n flipY?: boolean;\r\n colorSpace?: TextureColorSpace3D;\r\n}\r\n\r\n/**\r\n * A texture loaded from the project's asset manifest.\r\n *\r\n * `src` is discovered by the asset-tracking render pass and requested through\r\n * core's ordinary image pipeline — the very same path a 2D image fill uses — so\r\n * the pixels are decoded and resident *before* the frame that needs them draws.\r\n */\r\nexport interface ImageTexture3D extends TextureOptions3D {\r\n src: string;\r\n}\r\n\r\n/**\r\n * A texture built from raw RGBA8888 bytes — the escape hatch for procedurally\r\n * generated pixels (gradient ramps, noise, LUTs, data encoded as colour).\r\n */\r\nexport interface DataTexture3D extends TextureOptions3D {\r\n data: ArrayLike<number>;\r\n width: number;\r\n height: number;\r\n /**\r\n * Bump to force a re-upload after mutating `data` in place. Mutation is\r\n * invisible to identity comparison, so without this the renderer cannot\r\n * tell the bytes changed. See {@link BufferGeometry3D.revision}.\r\n */\r\n revision?: number;\r\n}\r\n\r\n/**\r\n * A texture whose pixels are Motion Script's own 2D output, rasterized offscreen\r\n * — the way to put a chart, a readout or a whole laid-out UI onto 3D geometry.\r\n *\r\n * `source` is a value, not a name and not a mounted node: either a built\r\n * {@link Graphics2D} command list, or a `Node2D` subtree. Both are supplied directly,\r\n * so there is no matching indirection and nothing has to live in a particular\r\n * place in the scene tree.\r\n *\r\n * g3.plane({ map: Tex.surface(scopeGraphics, 1024, 640) })\r\n * g3.plane({ map: Tex.surface(statsSubtree, 1024, 640) })\r\n *\r\n * A `Node2D` source is *adopted for binding* by whatever paints the scene — it gets\r\n * that node's asset catalog, inherited context and clock, which is what makes a\r\n * webfont shape and an `<Image>` load. It is never laid out or painted by the\r\n * scene tree; it is measured against `width`×`height` and drawn into the buffer.\r\n *\r\n * **Hoist the source.** Building it fresh inside the scene builder allocates a new\r\n * subtree every frame — re-binding, re-laying-out, defeating the texture cache and\r\n * leaking. Declare it once and pass the same instance.\r\n *\r\n * That hoisting rule is also what removed this descriptor's old `key`: a hoisted\r\n * source *is* a stable identity, so the renderer keys the GPU texture off the\r\n * source object itself (in a `WeakMap`) rather than off its ordinal in the scene\r\n * walk. A conditionally-emitted surface therefore needs nothing written by hand,\r\n * and a source that goes out of scope becomes collectable instead of orphaning\r\n * its texture — which the ordinal scheme could not do.\r\n */\r\nexport interface SurfaceTexture3D extends TextureOptions3D {\r\n /** A built `Graphics2D`, or a `Node2D` subtree. Typed structurally — see below. */\r\n source: SurfaceSource3D;\r\n /** Buffer width in pixels. This *is* the texture's resolution. */\r\n width: number;\r\n /** Buffer height in pixels. */\r\n height: number;\r\n /**\r\n * Declare the source's pixels unchanging, so the buffer is rasterized once\r\n * and reused rather than redrawn every frame.\r\n *\r\n * Set by `resolveFill3D` for a fill chain, whose layers describe the same\r\n * image on every frame; an author's own source is live by default, which is\r\n * what makes an animated `Graphics2D` or a prop-driven subtree work with no\r\n * bookkeeping. Needs {@link identity} to be cacheable.\r\n *\r\n * @internal\r\n */\r\n static?: boolean;\r\n /**\r\n * Cache identity for a synthesized source.\r\n *\r\n * An author's source is identified by the source object itself (see the note\r\n * above), which is exactly right for something hoisted. A source built *for*\r\n * a fill is a fresh object every frame and has no such identity, so the value\r\n * it was derived from supplies one.\r\n *\r\n * @internal\r\n */\r\n identity?: string;\r\n /**\r\n * Ceiling on the buffer's device-pixel ratio. Default 1, i.e. the buffer is\r\n * exactly `width` × `height`.\r\n *\r\n * Unlike a 2D node — which wants to match the display — a surface is sampled by\r\n * a 3D material at whatever size the geometry occupies on screen, so the honest\r\n * control is `width`/`height`. Raise this only when a surface is viewed close\r\n * up and reads soft.\r\n */\r\n maxPixelRatio?: number;\r\n}\r\n\r\n/**\r\n * What a {@link SurfaceTexture3D} can be painted from: a built {@link Graphics2D}\r\n * command list, or a {@link Node2D} subtree.\r\n *\r\n * Both imports are **type-only**, exactly as `Color` is — `render3d` describes\r\n * scenes as data and never reaches into the render or node layers at runtime, and\r\n * a value import of `Node2D` here would close a real module cycle. Consumers narrow\r\n * with {@link resolveSurfaceSource}.\r\n */\r\nexport type SurfaceSource3D = Graphics2D | Node;\r\n\r\n// Declared against the dimension-agnostic base because that is what a built\r\n// node is typed as, so `Tex.surface(new Rect({ … }), …)` type-checks without a\r\n// cast. It has to be a 2D subtree in fact — the renderer lays it out and draws it\r\n// into a 2D buffer — and `resolveSurfaceSource` narrows to that; handing it a\r\n// `Node3D` fails at render time rather than here.\r\n\r\n/** A {@link SurfaceSource3D} narrowed to the arm its renderer should take. */\r\nexport type ResolvedSurfaceSource =\r\n | { kind: \"graphics\"; graphics: Graphics2D }\r\n | { kind: \"node\"; node: Node2D };\r\n\r\n/**\r\n * Narrow a surface source to the arm that knows how to draw it: a `Graphics2D` is\r\n * replayed into a render context, a `Node2D` is laid out against the buffer and\r\n * rendered.\r\n *\r\n * Structural rather than `instanceof`, because that would need value imports of\r\n * both classes and close the cycle the type-only imports above avoid. `Graphics2D`\r\n * is a command recorder and exposes `ops()`; a `Node2D` has no such method. The\r\n * union makes any *other* value a type error, so this only has to separate two\r\n * known shapes rather than validate an unknown one.\r\n */\r\nexport function resolveSurfaceSource(source: SurfaceSource3D): ResolvedSurfaceSource {\r\n return typeof (source as Graphics2D).ops === \"function\"\r\n ? { kind: \"graphics\", graphics: source as Graphics2D }\r\n : { kind: \"node\", node: source as Node2D };\r\n}\r\n\r\n/**\r\n * A texture reference. A bare string is sugar for `{ src }`, so the common case\r\n * is `map: \"/wood.png\"`.\r\n */\r\nexport type Texture3D = string | ImageTexture3D | DataTexture3D | SurfaceTexture3D;\r\n\r\n/** True for the raw-bytes form (vs. an asset-backed {@link ImageTexture3D}). */\r\nexport function isDataTexture3D(texture: Texture3D): texture is DataTexture3D {\r\n return typeof texture !== \"string\" && \"data\" in texture;\r\n}\r\n\r\n/** True for the {@link SurfaceTexture3D} form — pixels are rasterized from 2D. */\r\nexport function isSurfaceTexture3D(texture: Texture3D): texture is SurfaceTexture3D {\r\n return typeof texture !== \"string\" && \"source\" in texture;\r\n}\r\n\r\n/** Normalize the string shorthand to an {@link ImageTexture3D}. */\r\nexport function resolveTexture3D(texture: Texture3D): ImageTexture3D | DataTexture3D | SurfaceTexture3D {\r\n return typeof texture === \"string\" ? { src: texture } : texture;\r\n}\r\n\r\n/**\r\n * The asset `src` a texture reads from, or `null` when it has none (a data or\r\n * surface texture). Used by the asset-tracking pass to enumerate what a 3D scene\r\n * needs loaded — a `null` here means \"nothing to request\", not \"not a texture\".\r\n */\r\nexport function texture3DSource(texture: Texture3D): string | null {\r\n if (typeof texture === \"string\") return texture;\r\n if (isDataTexture3D(texture) || isSurfaceTexture3D(texture)) return null;\r\n return texture.src;\r\n}\r\n\r\n/**\r\n * True for a string that names an asset rather than a colour.\r\n *\r\n * Leading `/` or `.` is a path by construction; otherwise the extension decides.\r\n * A colour never matches either, and a bare name like `\"wood\"` is a colour —\r\n * which is right, since an asset reference without a path or extension is not\r\n * something the manifest could resolve either.\r\n */\r\nexport function looksLikeAssetPath(value: string): boolean {\r\n return value.startsWith(\"/\")\r\n || value.startsWith(\".\")\r\n || /\\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);\r\n}\r\n"]}
|
|
@@ -25,8 +25,8 @@ export declare function resolveVector3(input: Vector3Input | undefined): Vector3
|
|
|
25
25
|
* returns `to`.
|
|
26
26
|
*
|
|
27
27
|
* Pass this as a prop's `tween` so 3D vectors actually animate:
|
|
28
|
-
*
|
|
29
|
-
* carries it already. Without one `to()` **leaves the prop alone**, having
|
|
28
|
+
* `property({ default: …, tween: lerpVector3 })` — or a `Types.vector3` entry,
|
|
29
|
+
* which carries it already. Without one `to()` **leaves the prop alone**, having
|
|
30
30
|
* nothing to interpolate two vectors with.
|
|
31
31
|
*/
|
|
32
32
|
export declare function lerpVector3(from: Vector3, to: Vector3, t: number): Vector3;
|
package/dist/render3d/vector3.js
CHANGED
|
@@ -16,8 +16,8 @@ export function resolveVector3(input) {
|
|
|
16
16
|
* returns `to`.
|
|
17
17
|
*
|
|
18
18
|
* Pass this as a prop's `tween` so 3D vectors actually animate:
|
|
19
|
-
*
|
|
20
|
-
* carries it already. Without one `to()` **leaves the prop alone**, having
|
|
19
|
+
* `property({ default: …, tween: lerpVector3 })` — or a `Types.vector3` entry,
|
|
20
|
+
* which carries it already. Without one `to()` **leaves the prop alone**, having
|
|
21
21
|
* nothing to interpolate two vectors with.
|
|
22
22
|
*/
|
|
23
23
|
export function lerpVector3(from, to, t) {
|