@motionscript/core 0.1.0-alpha.0 → 0.1.0-alpha.5
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 +282 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +93 -72
- package/dist/assets/asset-index.js.map +1 -1
- package/dist/assets/catalog.d.ts +9 -0
- package/dist/assets/catalog.d.ts.map +1 -1
- package/dist/assets/catalog.js +11 -0
- package/dist/assets/catalog.js.map +1 -1
- package/dist/assets/errors.d.ts.map +1 -1
- package/dist/assets/errors.js +8 -3
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/manager.d.ts +26 -1
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +93 -11
- package/dist/assets/manager.js.map +1 -1
- package/dist/assets/manifest.js.map +1 -1
- package/dist/assets/record.js.map +1 -1
- package/dist/assets/scope.d.ts +3 -3
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/filters/chain.d.ts +1 -1
- package/dist/attributes/audio/filters/chain.js.map +1 -1
- package/dist/attributes/audio/filters/curve.d.ts +8 -8
- package/dist/attributes/audio/filters/curve.d.ts.map +1 -1
- package/dist/attributes/audio/filters/curve.js +20 -19
- package/dist/attributes/audio/filters/curve.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/gain.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/highpass.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/lowpass.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/speed.d.ts +2 -2
- package/dist/attributes/audio/filters/implementations/speed.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/tremolo.js.map +1 -1
- package/dist/attributes/audio/filters/index.d.ts +1 -1
- package/dist/attributes/audio/filters/index.d.ts.map +1 -1
- package/dist/attributes/audio/filters/index.js +1 -1
- package/dist/attributes/audio/filters/index.js.map +1 -1
- package/dist/attributes/audio/filters/registry.js.map +1 -1
- package/dist/attributes/audio/filters/union.js.map +1 -1
- package/dist/attributes/audio/request.d.ts +32 -4
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js +9 -1
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +11 -2
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +15 -8
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +4 -2
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +8 -4
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/index.d.ts +1 -0
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +1 -0
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/alignment.js +1 -1
- package/dist/attributes/layout/alignment.js.map +1 -1
- package/dist/attributes/layout/index.js.map +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/layout/transform3d.js.map +1 -1
- package/dist/attributes/layout/vector2.js.map +1 -1
- package/dist/attributes/layout/world-transform.js.map +1 -1
- package/dist/attributes/mask/boolean.js.map +1 -1
- package/dist/attributes/mask/mask.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +17 -6
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +26 -14
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +9 -2
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +15 -1
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/render3d/orbit.d.ts +8 -8
- package/dist/attributes/render3d/orbit.js +7 -7
- package/dist/attributes/render3d/orbit.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/corners/corner-style.js.map +1 -1
- package/dist/attributes/shape/corners/corners.js.map +1 -1
- package/dist/attributes/shape/corners/index.js.map +1 -1
- package/dist/attributes/shape/effects/backdrop.d.ts +4 -4
- package/dist/attributes/shape/effects/backdrop.d.ts.map +1 -1
- package/dist/attributes/shape/effects/backdrop.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +28 -120
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +16 -88
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +2 -2
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +15 -24
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +15 -8
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/index.d.ts +2 -6
- package/dist/attributes/shape/effects/index.d.ts.map +1 -1
- package/dist/attributes/shape/effects/index.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +23 -6
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +44 -10
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/union.d.ts +2 -6
- package/dist/attributes/shape/effects/union.d.ts.map +1 -1
- package/dist/attributes/shape/effects/union.js.map +1 -1
- package/dist/attributes/shape/fill/blend.js.map +1 -1
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/coerce.js.map +1 -1
- package/dist/attributes/shape/fill/color/constants.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
- package/dist/attributes/shape/fill/color/parser.js +81 -44
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.d.ts +16 -0
- package/dist/attributes/shape/fill/gradient-stops.d.ts.map +1 -0
- package/dist/attributes/shape/fill/gradient-stops.js +65 -0
- package/dist/attributes/shape/fill/gradient-stops.js.map +1 -0
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/color.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/conic-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/conic-gradient.js +2 -5
- package/dist/attributes/shape/fill/implementations/conic-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/dot-grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js +2 -10
- package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.js +5 -4
- package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/linear-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/linear-gradient.js +2 -6
- package/dist/attributes/shape/fill/implementations/linear-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/radial-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/radial-gradient.js +2 -5
- package/dist/attributes/shape/fill/implementations/radial-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/stripe.js.map +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/index.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +9 -1
- package/dist/attributes/shape/fill/lerp.d.ts.map +1 -1
- package/dist/attributes/shape/fill/lerp.js +12 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/fill/media-preset.js.map +1 -1
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/fill/union.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +4 -10
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -13
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/alpha.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/exposure.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/posterize-time.js.map +1 -1
- package/dist/attributes/shape/filters/index.d.ts +1 -1
- package/dist/attributes/shape/filters/index.js.map +1 -1
- package/dist/attributes/shape/filters/registry.d.ts +2 -2
- package/dist/attributes/shape/filters/registry.js +3 -3
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +6 -7
- 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/anchors.d.ts.map +1 -1
- package/dist/attributes/shape/path/anchors.js +12 -5
- package/dist/attributes/shape/path/anchors.js.map +1 -1
- package/dist/attributes/shape/path/bezier.js.map +1 -1
- package/dist/attributes/shape/path/index.js.map +1 -1
- package/dist/attributes/shape/path/measure.js.map +1 -1
- package/dist/attributes/shape/path/morph.d.ts.map +1 -1
- package/dist/attributes/shape/path/morph.js +16 -4
- package/dist/attributes/shape/path/morph.js.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shape/path/types.js.map +1 -1
- package/dist/attributes/shape/path/walk.js.map +1 -1
- package/dist/attributes/shape/shaders/index.js.map +1 -1
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shadow/index.js.map +1 -1
- package/dist/attributes/shape/shadow/shadow.js.map +1 -1
- package/dist/attributes/shape/stroke/index.d.ts +2 -2
- package/dist/attributes/shape/stroke/index.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/index.js +1 -1
- package/dist/attributes/shape/stroke/index.js.map +1 -1
- package/dist/attributes/shape/stroke/stroke.d.ts +27 -6
- package/dist/attributes/shape/stroke/stroke.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/stroke.js +22 -2
- package/dist/attributes/shape/stroke/stroke.js.map +1 -1
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/index.js.map +1 -1
- package/dist/attributes/text/ops.d.ts +6 -0
- package/dist/attributes/text/ops.d.ts.map +1 -1
- package/dist/attributes/text/ops.js +1 -0
- package/dist/attributes/text/ops.js.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-FUZVFT3W.js +18 -0
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +7 -0
- package/dist/browser/chunks/chunk-QG6C23IJ.js +3 -0
- package/dist/browser/chunks/chunk-QG6C23IJ.js.map +7 -0
- package/dist/browser/chunks/chunk-SFNJRPBV.js +2 -0
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +3 -3
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/jsx-jsx-dev-runtime.js +1 -1
- package/dist/browser/jsx-jsx-runtime.js +1 -1
- package/dist/browser/manifest.json +3 -2
- package/dist/browser/sdk.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/document/audio.d.ts +1 -1
- package/dist/document/audio.js +4 -4
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +8 -14
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +1 -1
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +17 -3
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts +2 -2
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/compile.d.ts.map +1 -1
- package/dist/document/expression/compile.js +8 -5
- package/dist/document/expression/compile.js.map +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/expression/parse.d.ts.map +1 -1
- package/dist/document/expression/parse.js +15 -6
- package/dist/document/expression/parse.js.map +1 -1
- package/dist/document/expression/refs.d.ts +1 -1
- package/dist/document/expression/refs.js +1 -1
- package/dist/document/expression/refs.js.map +1 -1
- package/dist/document/expression/types.js.map +1 -1
- package/dist/document/expression/walk.d.ts.map +1 -1
- package/dist/document/expression/walk.js +2 -1
- package/dist/document/expression/walk.js.map +1 -1
- package/dist/document/index.d.ts +2 -0
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +2 -0
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +19 -0
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.d.ts +70 -0
- package/dist/document/placement.d.ts.map +1 -0
- package/dist/document/placement.js +83 -0
- package/dist/document/placement.js.map +1 -0
- package/dist/document/project.d.ts +2 -2
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js.map +1 -1
- package/dist/document/registry.d.ts +34 -16
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +51 -12
- package/dist/document/registry.js.map +1 -1
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +73 -18
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +192 -40
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +12 -12
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js +2 -2
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +2 -2
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +37 -31
- package/dist/document/validate.js.map +1 -1
- package/dist/document/withdraw.d.ts +28 -0
- package/dist/document/withdraw.d.ts.map +1 -0
- package/dist/document/withdraw.js +61 -0
- package/dist/document/withdraw.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-runtime.d.ts +9 -1
- package/dist/jsx/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-runtime.js +13 -3
- package/dist/jsx/jsx-runtime.js.map +1 -1
- package/dist/layout/bounds.d.ts +0 -1
- package/dist/layout/bounds.d.ts.map +1 -1
- package/dist/layout/bounds.js.map +1 -1
- package/dist/layout/constraints.js.map +1 -1
- package/dist/layout/flex.d.ts +4 -2
- package/dist/layout/flex.d.ts.map +1 -1
- package/dist/layout/flex.js +27 -11
- package/dist/layout/flex.js.map +1 -1
- package/dist/layout/freeform.js.map +1 -1
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/item.js.map +1 -1
- package/dist/layout/ops.d.ts +6 -0
- package/dist/layout/ops.d.ts.map +1 -1
- package/dist/layout/ops.js +6 -0
- package/dist/layout/ops.js.map +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/nodes/2d/node-lifecycle.js.map +1 -1
- package/dist/nodes/2d/node-motion.js.map +1 -1
- package/dist/nodes/2d/node-render.d.ts +3 -3
- package/dist/nodes/2d/node-render.d.ts.map +1 -1
- package/dist/nodes/2d/node-render.js.map +1 -1
- package/dist/nodes/2d/node-transform.js.map +1 -1
- package/dist/nodes/2d/node2d.d.ts +115 -3
- package/dist/nodes/2d/node2d.d.ts.map +1 -1
- package/dist/nodes/2d/node2d.js +188 -32
- package/dist/nodes/2d/node2d.js.map +1 -1
- package/dist/nodes/2d/paint-node.d.ts +27 -0
- package/dist/nodes/2d/paint-node.d.ts.map +1 -1
- package/dist/nodes/2d/paint-node.js +42 -0
- package/dist/nodes/2d/paint-node.js.map +1 -1
- package/dist/nodes/audio/audio-bus.js.map +1 -1
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/node-audio.d.ts +3 -2
- package/dist/nodes/audio/node-audio.d.ts.map +1 -1
- package/dist/nodes/audio/node-audio.js +8 -5
- package/dist/nodes/audio/node-audio.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -2
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +2 -2
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/geometry/bounds-shape-node.d.ts +4 -4
- package/dist/nodes/geometry/bounds-shape-node.js +2 -2
- package/dist/nodes/geometry/bounds-shape-node.js.map +1 -1
- package/dist/nodes/geometry/box-path-node.d.ts +3 -3
- package/dist/nodes/geometry/box-path-node.js +2 -2
- package/dist/nodes/geometry/box-path-node.js.map +1 -1
- package/dist/nodes/geometry/ellipse-node.js.map +1 -1
- package/dist/nodes/geometry/group-bounds.d.ts +2 -2
- package/dist/nodes/geometry/group-bounds.d.ts.map +1 -1
- package/dist/nodes/geometry/group-bounds.js +1 -2
- package/dist/nodes/geometry/group-bounds.js.map +1 -1
- package/dist/nodes/geometry/path-node.d.ts.map +1 -1
- package/dist/nodes/geometry/path-node.js +6 -0
- package/dist/nodes/geometry/path-node.js.map +1 -1
- package/dist/nodes/geometry/polygon-node.js.map +1 -1
- package/dist/nodes/geometry/polygram-node.js.map +1 -1
- package/dist/nodes/geometry/rect-node.js.map +1 -1
- package/dist/nodes/geometry/shape-node.js.map +1 -1
- package/dist/nodes/geometry/shape-outline.d.ts +2 -2
- package/dist/nodes/geometry/shape-outline.d.ts.map +1 -1
- package/dist/nodes/geometry/shape-outline.js +2 -13
- package/dist/nodes/geometry/shape-outline.js.map +1 -1
- package/dist/nodes/index.d.ts +3 -8
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +3 -8
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/layout/camera-node.d.ts +9 -0
- package/dist/nodes/layout/camera-node.d.ts.map +1 -1
- package/dist/nodes/layout/camera-node.js +38 -3
- package/dist/nodes/layout/camera-node.js.map +1 -1
- package/dist/nodes/layout/orbit-camera-node.d.ts +1 -1
- package/dist/nodes/layout/orbit-camera-node.js +1 -1
- package/dist/nodes/layout/orbit-camera-node.js.map +1 -1
- package/dist/nodes/layout/rotated-box.js.map +1 -1
- package/dist/nodes/media/video-node.d.ts.map +1 -1
- package/dist/nodes/media/video-node.js +5 -3
- package/dist/nodes/media/video-node.js.map +1 -1
- package/dist/nodes/node/declare-paints.js.map +1 -1
- package/dist/nodes/node/node-editor-state.js.map +1 -1
- package/dist/nodes/node/node-reactive.js.map +1 -1
- package/dist/nodes/node/node-time.d.ts +3 -3
- package/dist/nodes/node/node-time.d.ts.map +1 -1
- package/dist/nodes/node/node-time.js +1 -1
- package/dist/nodes/node/node-time.js.map +1 -1
- package/dist/nodes/node/node-walk.js.map +1 -1
- package/dist/nodes/node/node.d.ts +5 -3
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +44 -19
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/node/text-defaults.d.ts +10 -12
- package/dist/nodes/node/text-defaults.d.ts.map +1 -1
- package/dist/nodes/node/text-defaults.js +10 -12
- package/dist/nodes/node/text-defaults.js.map +1 -1
- package/dist/nodes/{scene → root}/canvas2d-node.d.ts +2 -2
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -0
- package/dist/nodes/{scene → root}/canvas2d-node.js +2 -2
- package/dist/nodes/root/canvas2d-node.js.map +1 -0
- package/dist/nodes/root/provider-node.d.ts.map +1 -0
- package/dist/nodes/root/provider-node.js.map +1 -0
- package/dist/nodes/root/theme-provider-node.d.ts.map +1 -0
- package/dist/nodes/root/theme-provider-node.js.map +1 -0
- package/dist/nodes/text/default-text-style-node.d.ts +5 -2
- package/dist/nodes/text/default-text-style-node.d.ts.map +1 -1
- package/dist/nodes/text/default-text-style-node.js +10 -4
- package/dist/nodes/text/default-text-style-node.js.map +1 -1
- package/dist/nodes/text/number-format.d.ts +1 -1
- package/dist/nodes/text/number-format.js +1 -1
- package/dist/nodes/text/number-format.js.map +1 -1
- package/dist/nodes/text/number-node.js.map +1 -1
- package/dist/nodes/text/number-pattern.js.map +1 -1
- package/dist/nodes/text/richtext-node.js +1 -1
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +1 -1
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-node.js.map +1 -1
- package/dist/nodes/text/text-selection.js.map +1 -1
- package/dist/nodes/three/camera-nodes.d.ts +21 -3
- package/dist/nodes/three/camera-nodes.d.ts.map +1 -1
- package/dist/nodes/three/camera-nodes.js +42 -1
- package/dist/nodes/three/camera-nodes.js.map +1 -1
- package/dist/nodes/three/canvas3d-node.d.ts +29 -6
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +44 -2
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/nodes/three/drawable-nodes.d.ts +25 -11
- package/dist/nodes/three/drawable-nodes.d.ts.map +1 -1
- package/dist/nodes/three/drawable-nodes.js +43 -13
- package/dist/nodes/three/drawable-nodes.js.map +1 -1
- package/dist/nodes/three/environment-nodes.d.ts +9 -3
- package/dist/nodes/three/environment-nodes.d.ts.map +1 -1
- package/dist/nodes/three/environment-nodes.js.map +1 -1
- package/dist/nodes/three/geometry-nodes.d.ts +2 -2
- package/dist/nodes/three/geometry-nodes.js +2 -2
- package/dist/nodes/three/geometry-nodes.js.map +1 -1
- package/dist/nodes/three/grid-geometry3d.js.map +1 -1
- package/dist/nodes/three/group3d.js.map +1 -1
- package/dist/nodes/three/light-nodes.d.ts.map +1 -1
- package/dist/nodes/three/light-nodes.js +3 -3
- package/dist/nodes/three/light-nodes.js.map +1 -1
- package/dist/nodes/three/mesh3d.js.map +1 -1
- package/dist/nodes/three/node3d.d.ts +48 -0
- package/dist/nodes/three/node3d.d.ts.map +1 -1
- package/dist/nodes/three/node3d.js +53 -3
- package/dist/nodes/three/node3d.js.map +1 -1
- package/dist/platform/audio-sink.d.ts +2 -2
- package/dist/platform/audio-sink.d.ts.map +1 -1
- package/dist/platform/audio-sink.js.map +1 -1
- package/dist/platform/exporter.d.ts +13 -8
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/stepped-clock.js.map +1 -1
- package/dist/platform/storage-adapter.d.ts +12 -6
- package/dist/platform/storage-adapter.d.ts.map +1 -1
- package/dist/platform/storage-adapter.js +4 -0
- package/dist/platform/storage-adapter.js.map +1 -1
- package/dist/platform/ticker.d.ts +6 -0
- package/dist/platform/ticker.d.ts.map +1 -1
- package/dist/platform/ticker.js +6 -0
- package/dist/platform/ticker.js.map +1 -1
- package/dist/project/config.js.map +1 -1
- package/dist/project/index.js.map +1 -1
- package/dist/project/tree.d.ts +3 -3
- package/dist/project/tree.d.ts.map +1 -1
- package/dist/project/tree.js.map +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/index.js.map +1 -1
- package/dist/props/observer.js.map +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/renamed-scene-names.d.ts +17 -0
- package/dist/renamed-scene-names.d.ts.map +1 -0
- package/dist/renamed-scene-names.js +9 -0
- package/dist/renamed-scene-names.js.map +1 -0
- package/dist/render/canvas-render-context2d.d.ts +10 -3
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js +10 -0
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/ellipse.js.map +1 -1
- package/dist/render/descriptors/latex.js.map +1 -1
- package/dist/render/descriptors/line.js.map +1 -1
- package/dist/render/descriptors/path-builder.js.map +1 -1
- package/dist/render/descriptors/path.js.map +1 -1
- package/dist/render/descriptors/polygon.js.map +1 -1
- package/dist/render/descriptors/polygram.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/richtext.js.map +1 -1
- package/dist/render/descriptors/shape.d.ts +12 -0
- package/dist/render/descriptors/shape.d.ts.map +1 -1
- package/dist/render/descriptors/shape.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +2 -2
- package/dist/render/descriptors/text.js +2 -2
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/descriptors/transform.d.ts +2 -2
- package/dist/render/descriptors/transform.d.ts.map +1 -1
- package/dist/render/descriptors/transform.js.map +1 -1
- package/dist/render/graphics2d.d.ts +3 -3
- package/dist/render/graphics2d.d.ts.map +1 -1
- package/dist/render/graphics2d.js +1 -1
- package/dist/render/graphics2d.js.map +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/measure-context.js.map +1 -1
- package/dist/render/null-render-context.js.map +1 -1
- package/dist/render/render-context2d.d.ts +5 -5
- package/dist/render/render-context2d.d.ts.map +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/surface.js.map +1 -1
- package/dist/render/text-defaults.js.map +1 -1
- package/dist/render/text-layout.js.map +1 -1
- package/dist/render3d/bounds3d.d.ts.map +1 -1
- package/dist/render3d/bounds3d.js +4 -2
- package/dist/render3d/bounds3d.js.map +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/camera.d.ts +6 -0
- package/dist/render3d/camera.d.ts.map +1 -1
- package/dist/render3d/camera.js +5 -3
- package/dist/render3d/camera.js.map +1 -1
- package/dist/render3d/fill3d.d.ts +2 -9
- package/dist/render3d/fill3d.d.ts.map +1 -1
- package/dist/render3d/fill3d.js +2 -13
- package/dist/render3d/fill3d.js.map +1 -1
- package/dist/render3d/geometry.d.ts +8 -1
- package/dist/render3d/geometry.d.ts.map +1 -1
- package/dist/render3d/geometry.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +8 -4
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +18 -10
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/index.d.ts +1 -1
- package/dist/render3d/index.js +1 -1
- package/dist/render3d/index.js.map +1 -1
- package/dist/render3d/inert.d.ts +14 -0
- package/dist/render3d/inert.d.ts.map +1 -0
- package/dist/render3d/inert.js +62 -0
- package/dist/render3d/inert.js.map +1 -0
- package/dist/render3d/light.js.map +1 -1
- package/dist/render3d/material.d.ts +10 -5
- package/dist/render3d/material.d.ts.map +1 -1
- package/dist/render3d/material.js.map +1 -1
- package/dist/render3d/matrix4.js.map +1 -1
- package/dist/render3d/render-context3d.js.map +1 -1
- package/dist/render3d/resources.d.ts +2 -2
- package/dist/render3d/resources.js +2 -2
- package/dist/render3d/resources.js.map +1 -1
- package/dist/render3d/rounded-box.js.map +1 -1
- package/dist/render3d/scene-settings.d.ts +23 -4
- package/dist/render3d/scene-settings.d.ts.map +1 -1
- package/dist/render3d/scene-settings.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +11 -0
- package/dist/render3d/scene3d.d.ts.map +1 -1
- package/dist/render3d/scene3d.js +39 -6
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/segments.js.map +1 -1
- package/dist/render3d/texture.d.ts +9 -0
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js +13 -0
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/tracking.js.map +1 -1
- package/dist/render3d/transform.d.ts +1 -1
- package/dist/render3d/transform.js.map +1 -1
- package/dist/render3d/vector3.d.ts +18 -1
- package/dist/render3d/vector3.d.ts.map +1 -1
- package/dist/render3d/vector3.js +27 -0
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/render3d/walk.d.ts +1 -1
- package/dist/render3d/walk.d.ts.map +1 -1
- package/dist/render3d/walk.js +5 -1
- package/dist/render3d/walk.js.map +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +2 -2
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +8 -2
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/builtin-context.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +5 -3
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +10 -6
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +9 -0
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +33 -3
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +5 -0
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +2 -0
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/frame-time.d.ts +31 -0
- package/dist/runtime/frame-time.d.ts.map +1 -0
- package/dist/runtime/frame-time.js +29 -0
- package/dist/runtime/frame-time.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +44 -3
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +118 -3
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +2 -1
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +5 -2
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/placement.d.ts.map +1 -1
- package/dist/runtime/placement.js +4 -5
- package/dist/runtime/placement.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +31 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +63 -6
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/playback.js.map +1 -1
- package/dist/runtime/precompisition.js.map +1 -1
- package/dist/runtime/project-assets.js.map +1 -1
- package/dist/runtime/session.d.ts +9 -7
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +12 -4
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/settle.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +1 -1
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js +4 -3
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +27 -22
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +23 -9
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +12 -4
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +10 -22
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/ease/constants.d.ts.map +1 -1
- package/dist/tween/ease/constants.js +8 -5
- package/dist/tween/ease/constants.js.map +1 -1
- package/dist/tween/ease/curve.d.ts.map +1 -1
- package/dist/tween/ease/curve.js +4 -3
- package/dist/tween/ease/curve.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +15 -0
- package/dist/tween/ease/describe.d.ts.map +1 -0
- package/dist/tween/ease/describe.js +37 -0
- package/dist/tween/ease/describe.js.map +1 -0
- package/dist/tween/ease/type.js.map +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/inert.js.map +1 -1
- package/dist/tween/lerp.js.map +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/tween/prepare.d.ts +3 -3
- package/dist/tween/prepare.js +3 -3
- package/dist/tween/prepare.js.map +1 -1
- package/dist/tween/seekable.d.ts +12 -1
- package/dist/tween/seekable.d.ts.map +1 -1
- package/dist/tween/seekable.js +15 -0
- package/dist/tween/seekable.js.map +1 -1
- package/dist/tween/stepper.js.map +1 -1
- package/dist/tween/to-command.js.map +1 -1
- package/dist/util/clamp.js.map +1 -1
- package/dist/util/context.js.map +1 -1
- package/dist/util/csv.js.map +1 -1
- package/dist/util/generateList.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/metrics.d.ts +1 -1
- package/dist/util/metrics.js +1 -1
- package/dist/util/metrics.js.map +1 -1
- package/dist/util/random.js.map +1 -1
- package/dist/util/reference.js.map +1 -1
- package/dist/util/scheduler.js.map +1 -1
- package/package.json +2 -1
- package/dist/attributes/shape/effects/implementations/displace.d.ts +0 -48
- package/dist/attributes/shape/effects/implementations/displace.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/displace.js +0 -30
- package/dist/attributes/shape/effects/implementations/displace.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/god-rays.d.ts +0 -28
- package/dist/attributes/shape/effects/implementations/god-rays.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/god-rays.js +0 -26
- package/dist/attributes/shape/effects/implementations/god-rays.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/texture.d.ts +0 -28
- package/dist/attributes/shape/effects/implementations/texture.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/texture.js +0 -25
- package/dist/attributes/shape/effects/implementations/texture.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/trails.d.ts +0 -41
- package/dist/attributes/shape/effects/implementations/trails.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/trails.js +0 -22
- package/dist/attributes/shape/effects/implementations/trails.js.map +0 -1
- package/dist/browser/chunks/chunk-2T3HXSC2.js +0 -2
- package/dist/browser/chunks/chunk-2T3HXSC2.js.map +0 -7
- package/dist/browser/chunks/chunk-P3XQCHDW.js +0 -16
- package/dist/browser/chunks/chunk-P3XQCHDW.js.map +0 -7
- package/dist/browser/chunks/chunk-VJQMKHGQ.js +0 -3
- package/dist/browser/chunks/chunk-VJQMKHGQ.js.map +0 -7
- package/dist/nodes/geometry/dot-grid-node.d.ts +0 -105
- package/dist/nodes/geometry/dot-grid-node.d.ts.map +0 -1
- package/dist/nodes/geometry/dot-grid-node.js +0 -142
- package/dist/nodes/geometry/dot-grid-node.js.map +0 -1
- package/dist/nodes/geometry/grid-lines.d.ts +0 -101
- package/dist/nodes/geometry/grid-lines.d.ts.map +0 -1
- package/dist/nodes/geometry/grid-lines.js +0 -128
- package/dist/nodes/geometry/grid-lines.js.map +0 -1
- package/dist/nodes/geometry/grid-pattern-node.d.ts +0 -58
- package/dist/nodes/geometry/grid-pattern-node.d.ts.map +0 -1
- package/dist/nodes/geometry/grid-pattern-node.js +0 -172
- package/dist/nodes/geometry/grid-pattern-node.js.map +0 -1
- package/dist/nodes/geometry/line-grid-node.d.ts +0 -62
- package/dist/nodes/geometry/line-grid-node.d.ts.map +0 -1
- package/dist/nodes/geometry/line-grid-node.js +0 -127
- package/dist/nodes/geometry/line-grid-node.js.map +0 -1
- package/dist/nodes/geometry/line-node.d.ts +0 -58
- package/dist/nodes/geometry/line-node.d.ts.map +0 -1
- package/dist/nodes/geometry/line-node.js +0 -123
- package/dist/nodes/geometry/line-node.js.map +0 -1
- package/dist/nodes/geometry/viewport-pattern-node.d.ts +0 -39
- package/dist/nodes/geometry/viewport-pattern-node.d.ts.map +0 -1
- package/dist/nodes/geometry/viewport-pattern-node.js +0 -79
- package/dist/nodes/geometry/viewport-pattern-node.js.map +0 -1
- package/dist/nodes/scene/canvas2d-node.d.ts.map +0 -1
- package/dist/nodes/scene/canvas2d-node.js.map +0 -1
- package/dist/nodes/scene/provider-node.d.ts.map +0 -1
- package/dist/nodes/scene/provider-node.js.map +0 -1
- package/dist/nodes/scene/theme-provider-node.d.ts.map +0 -1
- package/dist/nodes/scene/theme-provider-node.js.map +0 -1
- /package/dist/nodes/{scene → root}/provider-node.d.ts +0 -0
- /package/dist/nodes/{scene → root}/provider-node.js +0 -0
- /package/dist/nodes/{scene → root}/theme-provider-node.d.ts +0 -0
- /package/dist/nodes/{scene → root}/theme-provider-node.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rounded-box.js","sourceRoot":"","sources":["../../src/render3d/rounded-box.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;GASG;AACH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,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;IAC7C,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { BufferGeometry3D } from \"./geometry\";\n\n/**\n * A box with rounded edges and corners, evaluated into vertex buffers.\n *\n * `Rect` has had `cornerRadius` since the beginning and it is most of what makes\n * 2D content read as designed rather than as debug output; the same is true in\n * 3D, and it is the one thing a Spline scene has that a bare three scene does\n * not. three has no rounded box in core — its `RoundedBoxGeometry` is an addon,\n * and importing addons would defeat the lazy `import(\"three\")` boundary — so the\n * surface is built here: in core, as plain data, backend-agnostic and testable\n * without a GPU, exactly like `evaluateParametric`.\n *\n * The surface is the Minkowski sum of an inner box (each half-extent reduced by\n * `radius`) and a sphere of that radius, which decomposes into 26 patches: 6 flat\n * faces, 12 quarter-cylinder edges and 8 spherical-octant corners. Each patch is\n * a grid of `core + radius * direction`, where `direction` is also the vertex\n * normal — so lighting is exact rather than interpolated off a deformed box.\n */\nexport interface RoundedBoxOptions {\n width: number;\n height: number;\n depth: number;\n radius: number;\n /** Face subdivision per axis, as `[x, y, z]`. */\n segments: readonly [number, number, number];\n}\n\ntype Vec3 = readonly [number, number, number];\n\n/** A patch grid, before it is tessellated into the output buffers. */\ninterface Grid {\n /** Position at grid coordinate `(u, v)`, both in `[0, 1]`. */\n position: (u: number, v: number) => Vec3;\n /** Unit normal at `(u, v)`. */\n normal: (u: number, v: number) => Vec3;\n uSteps: number;\n vSteps: number;\n}\n\n/**\n * Arc resolution for the rounded regions, derived from how round the box\n * actually is rather than exposed as a knob.\n *\n * `segments` means face subdivision on every other shape and has to keep meaning\n * that here; a second count just for the arcs would be a field whose right value\n * is always \"enough that it looks smooth\". That is a function of the radius\n * relative to the box, so it is computed — a barely-rounded edge gets the\n * minimum, a nearly-spherical one gets a full sweep.\n */\nfunction arcSegmentsFor(radius: number, maxHalf: number): number {\n if (maxHalf <= 0) return 3;\n return Math.max(3, Math.min(16, Math.round((radius / maxHalf) * 40)));\n}\n\n/**\n * Build the rounded box's vertex buffers.\n *\n * Returns a plain {@link BufferGeometry3D}, so the renderer's existing buffer\n * path uploads it with no new code, and `Geo.edges`/`Geo.wireframe` derive from\n * it like any other geometry.\n */\nexport function evaluateRoundedBox(options: RoundedBoxOptions): BufferGeometry3D {\n const half: Vec3 = [options.width / 2, options.height / 2, options.depth / 2];\n const maxHalf = Math.max(half[0], half[1], half[2]);\n const radius = Math.max(0, Math.min(options.radius, half[0], half[1], half[2]));\n\n // The inner box the sphere is swept around. Clamped at zero so a radius equal\n // to a half-extent (a fully rounded axis) degenerates to a line rather than\n // folding the surface inside out.\n const box: Vec3 = [\n Math.max(0, half[0] - radius),\n Math.max(0, half[1] - radius),\n Math.max(0, half[2] - radius),\n ];\n\n const arc = arcSegmentsFor(radius, maxHalf);\n\n const position: number[] = [];\n const normal: number[] = [];\n const uv: number[] = [];\n const index: number[] = [];\n\n for (const grid of patches(half, box, radius, options.segments, arc)) {\n emit(grid, half, position, normal, uv, index);\n }\n\n return {\n type: \"buffer\",\n position: new Float32Array(position),\n normal: new Float32Array(normal),\n uv: new Float32Array(uv),\n index: new Uint32Array(index),\n staticData: true,\n };\n}\n\n/** The 26 patches, in face then edge then corner order. */\nfunction* patches(\n half: Vec3,\n box: Vec3,\n radius: number,\n segments: readonly [number, number, number],\n arc: number,\n): Generator<Grid> {\n const AXES = [0, 1, 2] as const;\n const SIGNS = [-1, 1] as const;\n\n // 6 faces: flat, spanning the inner box on the two free axes and pinned at\n // the full half-extent on its own. Subdivided by `segments`, which is what a\n // displacement map reads.\n for (const axis of AXES) {\n const u = (axis + 1) % 3;\n const v = (axis + 2) % 3;\n for (const sign of SIGNS) {\n const face = axisVector(axis, sign);\n yield {\n uSteps: segments[u],\n vSteps: segments[v],\n normal: () => face,\n position: (a, b) => {\n const point: number[] = [0, 0, 0];\n point[axis] = sign * half[axis];\n point[u] = lerp(-box[u], box[u], a);\n point[v] = lerp(-box[v], box[v], b);\n return point as unknown as Vec3;\n },\n };\n }\n }\n\n if (radius <= 0) return;\n\n // 12 edges: a quarter cylinder. The direction sweeps 90 degrees in the plane\n // of the two pinned axes while the core slides along the third.\n for (const axis of AXES) {\n const a = (axis + 1) % 3;\n const b = (axis + 2) % 3;\n for (const signA of SIGNS) {\n for (const signB of SIGNS) {\n yield {\n uSteps: arc,\n vSteps: segments[axis],\n normal: (t) => {\n const angle = (t * Math.PI) / 2;\n const dir: number[] = [0, 0, 0];\n dir[a] = signA * Math.cos(angle);\n dir[b] = signB * Math.sin(angle);\n return dir as unknown as Vec3;\n },\n position: (t, s) => {\n const angle = (t * Math.PI) / 2;\n const point: number[] = [0, 0, 0];\n point[a] = signA * (box[a] + radius * Math.cos(angle));\n point[b] = signB * (box[b] + radius * Math.sin(angle));\n point[axis] = lerp(-box[axis], box[axis], s);\n return point as unknown as Vec3;\n },\n };\n }\n }\n }\n\n // 8 corners: a spherical octant around a fixed corner of the inner box.\n for (const signX of SIGNS) {\n for (const signY of SIGNS) {\n for (const signZ of SIGNS) {\n const corner: Vec3 = [signX * box[0], signY * box[1], signZ * box[2]];\n const direction = (u: number, v: number): Vec3 => {\n const polar = (u * Math.PI) / 2;\n const azimuth = (v * Math.PI) / 2;\n return [\n signX * Math.sin(polar) * Math.cos(azimuth),\n signY * Math.cos(polar),\n signZ * Math.sin(polar) * Math.sin(azimuth),\n ];\n };\n yield {\n uSteps: arc,\n vSteps: arc,\n normal: direction,\n position: (u, v) => {\n const dir = direction(u, v);\n return [\n corner[0] + radius * dir[0],\n corner[1] + radius * dir[1],\n corner[2] + radius * dir[2],\n ];\n },\n };\n }\n }\n }\n}\n\n/**\n * Tessellate one patch into the output buffers.\n *\n * Winding is decided per triangle by comparing its own normal against the\n * surface normal at that vertex, rather than by reasoning about the sign\n * combination that produced the patch: 26 patches is 26 chances to get a\n * handedness backwards, and one inverted face on a `faces: \"front\"` mesh is a\n * hole you can see through. Degenerate triangles — the pole of a corner octant,\n * and every quad of a patch whose extent collapsed to zero — are dropped rather\n * than emitted with an undefined normal.\n */\nfunction emit(\n grid: Grid,\n half: Vec3,\n position: number[],\n normal: number[],\n uv: number[],\n index: number[],\n): void {\n const base = position.length / 3;\n const uCount = grid.uSteps + 1;\n const vCount = grid.vSteps + 1;\n\n for (let vi = 0; vi < vCount; vi++) {\n for (let ui = 0; ui < uCount; ui++) {\n const u = grid.uSteps === 0 ? 0 : ui / grid.uSteps;\n const v = grid.vSteps === 0 ? 0 : vi / grid.vSteps;\n const point = grid.position(u, v);\n const dir = grid.normal(u, v);\n position.push(point[0], point[1], point[2]);\n normal.push(dir[0], dir[1], dir[2]);\n const [s, t] = planarUv(point, dir, half);\n uv.push(s, t);\n }\n }\n\n for (let vi = 0; vi < grid.vSteps; vi++) {\n for (let ui = 0; ui < grid.uSteps; ui++) {\n const a = base + vi * uCount + ui;\n const b = a + 1;\n const c = a + uCount;\n const d = c + 1;\n pushTriangle(position, normal, index, a, c, b);\n pushTriangle(position, normal, index, b, c, d);\n }\n }\n}\n\n/** Emit one triangle, flipped if its winding faces away from the surface normal. */\nfunction pushTriangle(\n position: number[],\n normal: number[],\n index: number[],\n a: number,\n b: number,\n c: number,\n): void {\n const ax = position[a * 3], ay = position[a * 3 + 1], az = position[a * 3 + 2];\n const bx = position[b * 3], by = position[b * 3 + 1], bz = position[b * 3 + 2];\n const cx = position[c * 3], cy = position[c * 3 + 1], cz = position[c * 3 + 2];\n\n const ux = bx - ax, uy = by - ay, uz = bz - az;\n const vx = cx - ax, vy = cy - ay, vz = cz - az;\n\n const nx = uy * vz - uz * vy;\n const ny = uz * vx - ux * vz;\n const nz = ux * vy - uy * vx;\n\n // A collapsed quad — a pole, or a patch with no extent. No orientation to\n // decide and no area to shade.\n if (nx * nx + ny * ny + nz * nz < 1e-20) return;\n\n const facing = nx * normal[a * 3] + ny * normal[a * 3 + 1] + nz * normal[a * 3 + 2];\n\n if (facing >= 0) index.push(a, b, c);\n else index.push(a, c, b);\n}\n\n/**\n * A planar UV, projected along whichever axis the normal points most strongly\n * down.\n *\n * Deliberately approximate, and documented as such: the faces get an exact\n * box-projected UV, which is what a texture on a rounded box is almost always\n * for, and the arcs get a continuous projection that meets those faces without a\n * seam. An exact arc-length unwrap would need a per-patch atlas, which is a\n * texturing feature rather than a shape one.\n */\nfunction planarUv(point: Vec3, dir: Vec3, half: Vec3): [number, number] {\n const ax = Math.abs(dir[0]);\n const ay = Math.abs(dir[1]);\n const az = Math.abs(dir[2]);\n\n const axis = ax >= ay && ax >= az ? 0 : ay >= az ? 1 : 2;\n const u = (axis + 1) % 3;\n const v = (axis + 2) % 3;\n\n return [\n half[u] === 0 ? 0.5 : 0.5 + point[u] / (2 * half[u]),\n half[v] === 0 ? 0.5 : 0.5 + point[v] / (2 * half[v]),\n ];\n}\n\nfunction axisVector(axis: number, sign: number): Vec3 {\n const out: number[] = [0, 0, 0];\n out[axis] = sign;\n return out as unknown as Vec3;\n}\n\nfunction lerp(from: number, to: number, t: number): number {\n return from + (to - from) * t;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rounded-box.js","sourceRoot":"","sources":["../../src/render3d/rounded-box.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;GASG;AACH,SAAS,cAAc,CAAC,MAAc,EAAE,OAAe;IACnD,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IACzD,MAAM,IAAI,GAAS,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,OAAO,CAAC,KAAK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E,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAEzB,OAAO;QACH,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KACvD,CAAC;AACN,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,IAAY;IAC1C,MAAM,GAAG,GAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjB,OAAO,GAAsB,CAAC;AAClC,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;IAC7C,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import type { BufferGeometry3D } from \"./geometry\";\r\n\r\n/**\r\n * A box with rounded edges and corners, evaluated into vertex buffers.\r\n *\r\n * `Rect` has had `cornerRadius` since the beginning and it is most of what makes\r\n * 2D content read as designed rather than as debug output; the same is true in\r\n * 3D, and it is the one thing a Spline scene has that a bare three scene does\r\n * not. three has no rounded box in core — its `RoundedBoxGeometry` is an addon,\r\n * and importing addons would defeat the lazy `import(\"three\")` boundary — so the\r\n * surface is built here: in core, as plain data, backend-agnostic and testable\r\n * without a GPU, exactly like `evaluateParametric`.\r\n *\r\n * The surface is the Minkowski sum of an inner box (each half-extent reduced by\r\n * `radius`) and a sphere of that radius, which decomposes into 26 patches: 6 flat\r\n * faces, 12 quarter-cylinder edges and 8 spherical-octant corners. Each patch is\r\n * a grid of `core + radius * direction`, where `direction` is also the vertex\r\n * normal — so lighting is exact rather than interpolated off a deformed box.\r\n */\r\nexport interface RoundedBoxOptions {\r\n width: number;\r\n height: number;\r\n depth: number;\r\n radius: number;\r\n /** Face subdivision per axis, as `[x, y, z]`. */\r\n segments: readonly [number, number, number];\r\n}\r\n\r\ntype Vec3 = readonly [number, number, number];\r\n\r\n/** A patch grid, before it is tessellated into the output buffers. */\r\ninterface Grid {\r\n /** Position at grid coordinate `(u, v)`, both in `[0, 1]`. */\r\n position: (u: number, v: number) => Vec3;\r\n /** Unit normal at `(u, v)`. */\r\n normal: (u: number, v: number) => Vec3;\r\n uSteps: number;\r\n vSteps: number;\r\n}\r\n\r\n/**\r\n * Arc resolution for the rounded regions, derived from how round the box\r\n * actually is rather than exposed as a knob.\r\n *\r\n * `segments` means face subdivision on every other shape and has to keep meaning\r\n * that here; a second count just for the arcs would be a field whose right value\r\n * is always \"enough that it looks smooth\". That is a function of the radius\r\n * relative to the box, so it is computed — a barely-rounded edge gets the\r\n * minimum, a nearly-spherical one gets a full sweep.\r\n */\r\nfunction arcSegmentsFor(radius: number, maxHalf: number): number {\r\n if (maxHalf <= 0) return 3;\r\n return Math.max(3, Math.min(16, Math.round((radius / maxHalf) * 40)));\r\n}\r\n\r\n/**\r\n * Build the rounded box's vertex buffers.\r\n *\r\n * Returns a plain {@link BufferGeometry3D}, so the renderer's existing buffer\r\n * path uploads it with no new code, and `Geo.edges`/`Geo.wireframe` derive from\r\n * it like any other geometry.\r\n */\r\nexport function evaluateRoundedBox(options: RoundedBoxOptions): BufferGeometry3D {\r\n const half: Vec3 = [options.width / 2, options.height / 2, options.depth / 2];\r\n const maxHalf = Math.max(half[0], half[1], half[2]);\r\n const radius = Math.max(0, Math.min(options.radius, half[0], half[1], half[2]));\r\n\r\n // The inner box the sphere is swept around. Clamped at zero so a radius equal\r\n // to a half-extent (a fully rounded axis) degenerates to a line rather than\r\n // folding the surface inside out.\r\n const box: Vec3 = [\r\n Math.max(0, half[0] - radius),\r\n Math.max(0, half[1] - radius),\r\n Math.max(0, half[2] - radius),\r\n ];\r\n\r\n const arc = arcSegmentsFor(radius, maxHalf);\r\n\r\n const position: number[] = [];\r\n const normal: number[] = [];\r\n const uv: number[] = [];\r\n const index: number[] = [];\r\n\r\n for (const grid of patches(half, box, radius, options.segments, arc)) {\r\n emit(grid, half, position, normal, uv, index);\r\n }\r\n\r\n return {\r\n type: \"buffer\",\r\n position: new Float32Array(position),\r\n normal: new Float32Array(normal),\r\n uv: new Float32Array(uv),\r\n index: new Uint32Array(index),\r\n staticData: true,\r\n };\r\n}\r\n\r\n/** The 26 patches, in face then edge then corner order. */\r\nfunction* patches(\r\n half: Vec3,\r\n box: Vec3,\r\n radius: number,\r\n segments: readonly [number, number, number],\r\n arc: number,\r\n): Generator<Grid> {\r\n const AXES = [0, 1, 2] as const;\r\n const SIGNS = [-1, 1] as const;\r\n\r\n // 6 faces: flat, spanning the inner box on the two free axes and pinned at\r\n // the full half-extent on its own. Subdivided by `segments`, which is what a\r\n // displacement map reads.\r\n for (const axis of AXES) {\r\n const u = (axis + 1) % 3;\r\n const v = (axis + 2) % 3;\r\n for (const sign of SIGNS) {\r\n const face = axisVector(axis, sign);\r\n yield {\r\n uSteps: segments[u],\r\n vSteps: segments[v],\r\n normal: () => face,\r\n position: (a, b) => {\r\n const point: number[] = [0, 0, 0];\r\n point[axis] = sign * half[axis];\r\n point[u] = lerp(-box[u], box[u], a);\r\n point[v] = lerp(-box[v], box[v], b);\r\n return point as unknown as Vec3;\r\n },\r\n };\r\n }\r\n }\r\n\r\n if (radius <= 0) return;\r\n\r\n // 12 edges: a quarter cylinder. The direction sweeps 90 degrees in the plane\r\n // of the two pinned axes while the core slides along the third.\r\n for (const axis of AXES) {\r\n const a = (axis + 1) % 3;\r\n const b = (axis + 2) % 3;\r\n for (const signA of SIGNS) {\r\n for (const signB of SIGNS) {\r\n yield {\r\n uSteps: arc,\r\n vSteps: segments[axis],\r\n normal: (t) => {\r\n const angle = (t * Math.PI) / 2;\r\n const dir: number[] = [0, 0, 0];\r\n dir[a] = signA * Math.cos(angle);\r\n dir[b] = signB * Math.sin(angle);\r\n return dir as unknown as Vec3;\r\n },\r\n position: (t, s) => {\r\n const angle = (t * Math.PI) / 2;\r\n const point: number[] = [0, 0, 0];\r\n point[a] = signA * (box[a] + radius * Math.cos(angle));\r\n point[b] = signB * (box[b] + radius * Math.sin(angle));\r\n point[axis] = lerp(-box[axis], box[axis], s);\r\n return point as unknown as Vec3;\r\n },\r\n };\r\n }\r\n }\r\n }\r\n\r\n // 8 corners: a spherical octant around a fixed corner of the inner box.\r\n for (const signX of SIGNS) {\r\n for (const signY of SIGNS) {\r\n for (const signZ of SIGNS) {\r\n const corner: Vec3 = [signX * box[0], signY * box[1], signZ * box[2]];\r\n const direction = (u: number, v: number): Vec3 => {\r\n const polar = (u * Math.PI) / 2;\r\n const azimuth = (v * Math.PI) / 2;\r\n return [\r\n signX * Math.sin(polar) * Math.cos(azimuth),\r\n signY * Math.cos(polar),\r\n signZ * Math.sin(polar) * Math.sin(azimuth),\r\n ];\r\n };\r\n yield {\r\n uSteps: arc,\r\n vSteps: arc,\r\n normal: direction,\r\n position: (u, v) => {\r\n const dir = direction(u, v);\r\n return [\r\n corner[0] + radius * dir[0],\r\n corner[1] + radius * dir[1],\r\n corner[2] + radius * dir[2],\r\n ];\r\n },\r\n };\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Tessellate one patch into the output buffers.\r\n *\r\n * Winding is decided per triangle by comparing its own normal against the\r\n * surface normal at that vertex, rather than by reasoning about the sign\r\n * combination that produced the patch: 26 patches is 26 chances to get a\r\n * handedness backwards, and one inverted face on a `faces: \"front\"` mesh is a\r\n * hole you can see through. Degenerate triangles — the pole of a corner octant,\r\n * and every quad of a patch whose extent collapsed to zero — are dropped rather\r\n * than emitted with an undefined normal.\r\n */\r\nfunction emit(\r\n grid: Grid,\r\n half: Vec3,\r\n position: number[],\r\n normal: number[],\r\n uv: number[],\r\n index: number[],\r\n): void {\r\n const base = position.length / 3;\r\n const uCount = grid.uSteps + 1;\r\n const vCount = grid.vSteps + 1;\r\n\r\n for (let vi = 0; vi < vCount; vi++) {\r\n for (let ui = 0; ui < uCount; ui++) {\r\n const u = grid.uSteps === 0 ? 0 : ui / grid.uSteps;\r\n const v = grid.vSteps === 0 ? 0 : vi / grid.vSteps;\r\n const point = grid.position(u, v);\r\n const dir = grid.normal(u, v);\r\n position.push(point[0], point[1], point[2]);\r\n normal.push(dir[0], dir[1], dir[2]);\r\n const [s, t] = planarUv(point, dir, half);\r\n uv.push(s, t);\r\n }\r\n }\r\n\r\n for (let vi = 0; vi < grid.vSteps; vi++) {\r\n for (let ui = 0; ui < grid.uSteps; ui++) {\r\n const a = base + vi * uCount + ui;\r\n const b = a + 1;\r\n const c = a + uCount;\r\n const d = c + 1;\r\n pushTriangle(position, normal, index, a, c, b);\r\n pushTriangle(position, normal, index, b, c, d);\r\n }\r\n }\r\n}\r\n\r\n/** Emit one triangle, flipped if its winding faces away from the surface normal. */\r\nfunction pushTriangle(\r\n position: number[],\r\n normal: number[],\r\n index: number[],\r\n a: number,\r\n b: number,\r\n c: number,\r\n): void {\r\n const ax = position[a * 3], ay = position[a * 3 + 1], az = position[a * 3 + 2];\r\n const bx = position[b * 3], by = position[b * 3 + 1], bz = position[b * 3 + 2];\r\n const cx = position[c * 3], cy = position[c * 3 + 1], cz = position[c * 3 + 2];\r\n\r\n const ux = bx - ax, uy = by - ay, uz = bz - az;\r\n const vx = cx - ax, vy = cy - ay, vz = cz - az;\r\n\r\n const nx = uy * vz - uz * vy;\r\n const ny = uz * vx - ux * vz;\r\n const nz = ux * vy - uy * vx;\r\n\r\n // A collapsed quad — a pole, or a patch with no extent. No orientation to\r\n // decide and no area to shade.\r\n if (nx * nx + ny * ny + nz * nz < 1e-20) return;\r\n\r\n const facing = nx * normal[a * 3] + ny * normal[a * 3 + 1] + nz * normal[a * 3 + 2];\r\n\r\n if (facing >= 0) index.push(a, b, c);\r\n else index.push(a, c, b);\r\n}\r\n\r\n/**\r\n * A planar UV, projected along whichever axis the normal points most strongly\r\n * down.\r\n *\r\n * Deliberately approximate, and documented as such: the faces get an exact\r\n * box-projected UV, which is what a texture on a rounded box is almost always\r\n * for, and the arcs get a continuous projection that meets those faces without a\r\n * seam. An exact arc-length unwrap would need a per-patch atlas, which is a\r\n * texturing feature rather than a shape one.\r\n */\r\nfunction planarUv(point: Vec3, dir: Vec3, half: Vec3): [number, number] {\r\n const ax = Math.abs(dir[0]);\r\n const ay = Math.abs(dir[1]);\r\n const az = Math.abs(dir[2]);\r\n\r\n const axis = ax >= ay && ax >= az ? 0 : ay >= az ? 1 : 2;\r\n const u = (axis + 1) % 3;\r\n const v = (axis + 2) % 3;\r\n\r\n return [\r\n half[u] === 0 ? 0.5 : 0.5 + point[u] / (2 * half[u]),\r\n half[v] === 0 ? 0.5 : 0.5 + point[v] / (2 * half[v]),\r\n ];\r\n}\r\n\r\nfunction axisVector(axis: number, sign: number): Vec3 {\r\n const out: number[] = [0, 0, 0];\r\n out[axis] = sign;\r\n return out as unknown as Vec3;\r\n}\r\n\r\nfunction lerp(from: number, to: number, t: number): number {\r\n return from + (to - from) * t;\r\n}\r\n"]}
|
|
@@ -38,19 +38,32 @@ export interface FogData3D {
|
|
|
38
38
|
* three background, so the 3D path was doing strictly less than the 2D one it sat
|
|
39
39
|
* in front of. What genuinely needs the 3D pass is a sky that *reprojects* as the
|
|
40
40
|
* camera turns, which is this.
|
|
41
|
+
*
|
|
42
|
+
* ── What renders today ────────────────────────────────────────────────────────
|
|
43
|
+
* Only {@link preset} `"studio"` (a neutral grey room generated per renderer).
|
|
44
|
+
* {@link src} and {@link faces} are declared, tracked by the asset window and
|
|
45
|
+
* recorded, but no backend loads an HDR, EXR or cubemap: an environment that
|
|
46
|
+
* names only those lights nothing and draws no {@link background}. {@link params}
|
|
47
|
+
* is not applied either. In development, the first of each warns.
|
|
41
48
|
*/
|
|
42
49
|
export interface EnvironmentData3D extends Passthrough3D {
|
|
43
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* A 360° panorama — `.hdr`/`.exr` for real IBL, or a plain image.
|
|
52
|
+
* **Not loaded yet**: see the note on the type.
|
|
53
|
+
*/
|
|
44
54
|
src?: string;
|
|
45
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Six faces, in three's order: +X, −X, +Y, −Y, +Z, −Z.
|
|
57
|
+
* **Not loaded yet**: see the note on the type.
|
|
58
|
+
*/
|
|
46
59
|
faces?: readonly string[];
|
|
47
|
-
/** A built-in studio interior. Needs no asset — the fastest way to good metal. */
|
|
60
|
+
/** A built-in studio interior. Needs no asset — the fastest way to good metal. The only environment that renders. */
|
|
48
61
|
preset?: "studio";
|
|
49
62
|
/** Multiplies the light received. Default 1. */
|
|
50
63
|
intensity?: number;
|
|
51
64
|
/** Rotate the panorama, in **degrees**. */
|
|
52
65
|
rotation?: Vector3Input;
|
|
53
|
-
/** Also draw it behind the scene, as an infinitely distant sky. */
|
|
66
|
+
/** Also draw it behind the scene, as an infinitely distant sky. Draws the `preset`; there is nothing to draw for `src`/`faces`. */
|
|
54
67
|
background?: boolean;
|
|
55
68
|
/** Blur applied to the background only, 0–1. Leaves the lighting sharp. */
|
|
56
69
|
blur?: number;
|
|
@@ -106,6 +119,12 @@ export interface ToneSettings3D {
|
|
|
106
119
|
*
|
|
107
120
|
* Post-processing forces the render through an offscreen target, so a scene with
|
|
108
121
|
* any of these costs more than one without, even for a cheap effect.
|
|
122
|
+
*
|
|
123
|
+
* **No pass is applied yet.** The chain is recorded on the scene and read only to
|
|
124
|
+
* track the textures a `shaderPass` names; a scene with `bloom` renders exactly
|
|
125
|
+
* like one without, and so does every `params` on an effect. The first `post` set
|
|
126
|
+
* in development warns. Until the passes land, use the 2D `effects` of the
|
|
127
|
+
* `Canvas3D`, which run over its composited result.
|
|
109
128
|
*/
|
|
110
129
|
export type PostEffect3D =
|
|
111
130
|
/** Bleeds light from bright pixels, in HDR. What makes `emission` actually glow. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene-settings.d.ts","sourceRoot":"","sources":["../../src/render3d/scene-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED
|
|
1
|
+
{"version":3,"file":"scene-settings.d.ts","sourceRoot":"","sources":["../../src/render3d/scene-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IACl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;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AAC7F,8DAA8D;GAC5D,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,GACvE,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AAC1E,mFAAmF;GACjF,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC;AACxF,yEAAyE;GACvE,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene-settings.js","sourceRoot":"","sources":["../../src/render3d/scene-settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scene-settings.js","sourceRoot":"","sources":["../../src/render3d/scene-settings.ts"],"names":[],"mappings":"AA6FA,6CAA6C;AAC7C,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACxD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC;AACvC,CAAC","sourcesContent":["import type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type { Passthrough3D } from \"./geometry\";\r\nimport type { Uniform3D } from \"./material\";\r\nimport type { Vector3Input } from \"./vector3\";\r\n\r\n/**\r\n * Depth haze that fades distant geometry toward a colour.\r\n *\r\n * One shape rather than a discriminated pair: setting {@link density} is\r\n * exponential fog and setting {@link near}/{@link far} is linear, which is what\r\n * the old `type` field said twice. Writing `type: \"exponential\"` beside a `far`\r\n * silently dropped the `far`; there is nothing to get wrong now.\r\n *\r\n * `color` is derived from the viewport's own fill when omitted. Fog that does not\r\n * match what is behind it reads as a grey wall rather than as distance, and the\r\n * two colours being separately typed by hand is exactly how they drift.\r\n */\r\nexport interface FogData3D {\r\n color?: Color;\r\n /** Linear fog: distance at which fog begins. */\r\n near?: number;\r\n /** Linear fog: distance at which fog is total. */\r\n far?: number;\r\n /** Exponential-squared falloff. Wins over {@link near}/{@link far}. */\r\n density?: number;\r\n}\r\n\r\n/**\r\n * Image-based lighting, and the sky it comes from.\r\n *\r\n * Light and background are one control because they are one physical thing: an\r\n * HDRI that lights a scene is the same panorama you see behind it, and having\r\n * them as two nodes meant setting one, wondering why metal was black or why the\r\n * sky was missing, and setting the other.\r\n *\r\n * This is also *all* that is left of the old `Background3D`. A solid colour, a\r\n * gradient or a flat image behind the scene is a **2D fill** — `Canvas3D` is a\r\n * `Rect` and already composites its 3D pass over its own fill layers, the\r\n * renderer already clears transparent, and neither lighting nor fog touches a\r\n * three background, so the 3D path was doing strictly less than the 2D one it sat\r\n * in front of. What genuinely needs the 3D pass is a sky that *reprojects* as the\r\n * camera turns, which is this.\r\n *\r\n * ── What renders today ────────────────────────────────────────────────────────\r\n * Only {@link preset} `\"studio\"` (a neutral grey room generated per renderer).\r\n * {@link src} and {@link faces} are declared, tracked by the asset window and\r\n * recorded, but no backend loads an HDR, EXR or cubemap: an environment that\r\n * names only those lights nothing and draws no {@link background}. {@link params}\r\n * is not applied either. In development, the first of each warns.\r\n */\r\nexport interface EnvironmentData3D extends Passthrough3D {\r\n /**\r\n * A 360° panorama — `.hdr`/`.exr` for real IBL, or a plain image.\r\n * **Not loaded yet**: see the note on the type.\r\n */\r\n src?: string;\r\n /**\r\n * Six faces, in three's order: +X, −X, +Y, −Y, +Z, −Z.\r\n * **Not loaded yet**: see the note on the type.\r\n */\r\n faces?: readonly string[];\r\n /** A built-in studio interior. Needs no asset — the fastest way to good metal. The only environment that renders. */\r\n preset?: \"studio\";\r\n /** Multiplies the light received. Default 1. */\r\n intensity?: number;\r\n /** Rotate the panorama, in **degrees**. */\r\n rotation?: Vector3Input;\r\n /** Also draw it behind the scene, as an infinitely distant sky. Draws the `preset`; there is nothing to draw for `src`/`faces`. */\r\n background?: boolean;\r\n /** Blur applied to the background only, 0–1. Leaves the lighting sharp. */\r\n blur?: number;\r\n}\r\n\r\n/**\r\n * Scene-wide shadow settings.\r\n *\r\n * `quality` stands in for the map resolution and the filter three exposes\r\n * separately (`pcf`, `pcfSoft`, `vsm`, `mapSize`): those two are chosen together\r\n * in practice, and neither is a design decision. Individual lights soften their\r\n * own shadow; objects opt out with `shadow={false}`.\r\n *\r\n * Enabling shadows recompiles every material that receives them, so treat this as\r\n * setup rather than something to animate.\r\n */\r\nexport interface ShadowSettings3D {\r\n enabled?: boolean;\r\n /** Default `\"medium\"`. */\r\n quality?: \"low\" | \"medium\" | \"high\";\r\n}\r\n\r\n/** Shadows as written on a viewport: a switch, or the settings. */\r\nexport type Shadows3D = boolean | ShadowSettings3D;\r\n\r\n/** Normalize a viewport's `shadows` prop. */\r\nexport function resolveShadows3D(value: Shadows3D | undefined): ShadowSettings3D | null {\r\n if (value === undefined || value === false) return null;\r\n if (value === true) return { enabled: true };\r\n return { enabled: true, ...value };\r\n}\r\n\r\n/**\r\n * How high-dynamic-range colour is mapped into displayable range.\r\n *\r\n * `\"aces\"` is the filmic default most renderers use and handles bright\r\n * highlights gracefully; `\"none\"` clips them. Materials opt out individually with\r\n * `toneMapped: false` — useful for UI-like overlays that must keep an exact colour.\r\n */\r\nexport type ToneMapping3D =\r\n | \"none\"\r\n | \"linear\"\r\n | \"reinhard\"\r\n | \"cineon\"\r\n | \"aces\"\r\n | \"agx\"\r\n | \"neutral\";\r\n\r\n/** Tone mapping and exposure, as a viewport carries them. */\r\nexport interface ToneSettings3D {\r\n mapping?: ToneMapping3D;\r\n /** Stops of exposure applied before mapping. Default 1. */\r\n exposure?: number;\r\n}\r\n\r\n/**\r\n * A full-frame post-processing pass, applied after the scene renders.\r\n *\r\n * Deliberately short, because most of what used to be here is a 2D effect. A\r\n * `Canvas3D` is a `Node2D`, so it already carries the whole `effects` chain —\r\n * vignette, grain, colour grading, blur, chromatic aberration and the rest run\r\n * over the composited result with no 3D pass involved, and post-process\r\n * antialiasing is what the viewport's own `antialias` already does with MSAA.\r\n *\r\n * What is left are the passes that genuinely need what only the 3D pass has:\r\n * `ssao` and `dof` read the depth buffer, `outline` reads object ids, and `bloom`\r\n * reads **HDR radiance before tone mapping** — which is why an emissive surface\r\n * blooms here and merely brightens under the 2D chain. `shaderPass` stays as the\r\n * escape hatch for a pass that needs to sit inside the 3D composite.\r\n *\r\n * Post-processing forces the render through an offscreen target, so a scene with\r\n * any of these costs more than one without, even for a cheap effect.\r\n *\r\n * **No pass is applied yet.** The chain is recorded on the scene and read only to\r\n * track the textures a `shaderPass` names; a scene with `bloom` renders exactly\r\n * like one without, and so does every `params` on an effect. The first `post` set\r\n * in development warns. Until the passes land, use the 2D `effects` of the\r\n * `Canvas3D`, which run over its composited result.\r\n */\r\nexport type PostEffect3D =\r\n /** Bleeds light from bright pixels, in HDR. What makes `emission` actually glow. */\r\n | ({ type: \"bloom\"; strength?: number; radius?: number; threshold?: number } & Passthrough3D)\r\n /** Contact shadows in creases, from screen-space geometry. */\r\n | ({ type: \"ssao\"; radius?: number; intensity?: number } & Passthrough3D)\r\n | ({ type: \"outline\"; color?: Color; thickness?: number } & Passthrough3D)\r\n /** Depth of field. `focus` is the sharp distance, `aperture` the blur strength. */\r\n | ({ type: \"dof\"; focus?: number; aperture?: number; maxBlur?: number } & Passthrough3D)\r\n /** Anything expressible as one fragment pass inside the 3D composite. */\r\n | ({ type: \"shaderPass\"; fragment: string; uniforms?: Readonly<Record<string, Uniform3D>> } & Passthrough3D);\r\n"]}
|
|
@@ -61,6 +61,11 @@ export declare class Scene3D extends RenderContext3D {
|
|
|
61
61
|
private _post;
|
|
62
62
|
/** Open `push` count, so {@link assertBalanced} can report a leak. */
|
|
63
63
|
private _depth;
|
|
64
|
+
/**
|
|
65
|
+
* The `shadow` of each open node scope, innermost last (`undefined` for a
|
|
66
|
+
* scope that states none). What a drawable that states none of its own takes.
|
|
67
|
+
*/
|
|
68
|
+
private _shadowScopes;
|
|
64
69
|
begin(state: Node3DRenderState): void;
|
|
65
70
|
end(): void;
|
|
66
71
|
/**
|
|
@@ -69,6 +74,12 @@ export declare class Scene3D extends RenderContext3D {
|
|
|
69
74
|
* The ops are copied rather than referenced: a `Graphics3D` is rebuilt every
|
|
70
75
|
* frame, so there is nothing to share, and a flat list is what the renderer
|
|
71
76
|
* walks.
|
|
77
|
+
*
|
|
78
|
+
* A drawable that states no `shadow` of its own takes the one of the node
|
|
79
|
+
* scope it is drawn in. That is what carries a node's `shadow` to its mesh: the
|
|
80
|
+
* node's scope becomes a group, and a renderer reads casting and receiving off
|
|
81
|
+
* the mesh, never off a group, so the scope's value would otherwise never be
|
|
82
|
+
* seen. A `shadow` on the op itself wins.
|
|
72
83
|
*/
|
|
73
84
|
draw(graphics: Graphics3D): this;
|
|
74
85
|
light(light: LightData3D, transform?: Transform3D): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene3d.d.ts","sourceRoot":"","sources":["../../src/render3d/scene3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,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AAW,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI;IAoBxD,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,IAAI;IAKnC,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAKpC,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,YAAY,EAAE,GAAG,IAAI;IAepE,4DAA4D;IAC5D,GAAG,IAAI,SAAS,SAAS,EAAE;IAI3B,0EAA0E;IAC1E,gBAAgB,IAAI,YAAY,GAAG,IAAI;IAGvC,aAAa,IAAI,SAAS,GAAG,IAAI;IAGjC,qBAAqB,IAAI,iBAAiB,GAAG,IAAI;IAGjD,cAAc,IAAI,gBAAgB,GAAG,IAAI;IAGzC,YAAY,IAAI,cAAc,GAAG,IAAI;IAGrC,WAAW,IAAI,SAAS,YAAY,EAAE;IAItC;;;OAGG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;;;;OAOG;IACH,cAAc,IAAI,IAAI;CAQzB"}
|
package/dist/render3d/scene3d.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DRAWABLE_KINDS } from "./graphics3d.js";
|
|
2
2
|
import { RenderContext3D } from "./render-context3d.js";
|
|
3
3
|
import { resolveShadows3D, } from "./scene-settings.js";
|
|
4
|
+
import { warnInert3D } from "./inert.js";
|
|
4
5
|
/**
|
|
5
6
|
* A recorded 3D scene — and the {@link RenderContext3D} that records it.
|
|
6
7
|
*
|
|
@@ -33,16 +34,23 @@ export class Scene3D extends RenderContext3D {
|
|
|
33
34
|
_post = [];
|
|
34
35
|
/** Open `push` count, so {@link assertBalanced} can report a leak. */
|
|
35
36
|
_depth = 0;
|
|
37
|
+
/**
|
|
38
|
+
* The `shadow` of each open node scope, innermost last (`undefined` for a
|
|
39
|
+
* scope that states none). What a drawable that states none of its own takes.
|
|
40
|
+
*/
|
|
41
|
+
_shadowScopes = [];
|
|
36
42
|
// ─── Node scopes ─────────────────────────────────────────────────────────
|
|
37
43
|
begin(state) {
|
|
38
44
|
// The node's id rides on the transform's `key`, which is the renderer's
|
|
39
45
|
// identity slot — so a group is cached against the node that opened it
|
|
40
46
|
// rather than against its index among its siblings.
|
|
41
47
|
this._ops.push({ kind: "push", transform: { ...state.transform, key: state.id } });
|
|
48
|
+
this._shadowScopes.push(state.transform?.shadow);
|
|
42
49
|
this._depth++;
|
|
43
50
|
}
|
|
44
51
|
end() {
|
|
45
52
|
this._ops.push({ kind: "pop" });
|
|
53
|
+
this._shadowScopes.pop();
|
|
46
54
|
this._depth--;
|
|
47
55
|
}
|
|
48
56
|
// ─── Drawables ───────────────────────────────────────────────────────────
|
|
@@ -52,11 +60,25 @@ export class Scene3D extends RenderContext3D {
|
|
|
52
60
|
* The ops are copied rather than referenced: a `Graphics3D` is rebuilt every
|
|
53
61
|
* frame, so there is nothing to share, and a flat list is what the renderer
|
|
54
62
|
* walks.
|
|
63
|
+
*
|
|
64
|
+
* A drawable that states no `shadow` of its own takes the one of the node
|
|
65
|
+
* scope it is drawn in. That is what carries a node's `shadow` to its mesh: the
|
|
66
|
+
* node's scope becomes a group, and a renderer reads casting and receiving off
|
|
67
|
+
* the mesh, never off a group, so the scope's value would otherwise never be
|
|
68
|
+
* seen. A `shadow` on the op itself wins.
|
|
55
69
|
*/
|
|
56
70
|
draw(graphics) {
|
|
57
71
|
const ops = graphics.ops();
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
const scope = this._shadowScopes[this._shadowScopes.length - 1];
|
|
73
|
+
for (let i = 0; i < ops.length; i++) {
|
|
74
|
+
const op = ops[i];
|
|
75
|
+
if (scope === undefined || op.transform?.shadow !== undefined) {
|
|
76
|
+
this._ops.push(op);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this._ops.push({ ...op, transform: { ...op.transform, shadow: scope } });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
60
82
|
return this;
|
|
61
83
|
}
|
|
62
84
|
// ─── Lights ──────────────────────────────────────────────────────────────
|
|
@@ -96,6 +118,15 @@ export class Scene3D extends RenderContext3D {
|
|
|
96
118
|
return this;
|
|
97
119
|
}
|
|
98
120
|
environment(environment) {
|
|
121
|
+
if (environment) {
|
|
122
|
+
if (environment.src !== undefined || (environment.faces?.length ?? 0) > 0) {
|
|
123
|
+
warnInert3D("environment-src", "An environment's `src` and `faces` (HDR, EXR, cubemap) are recorded, and no backend loads them. Only `preset: \"studio\"` is rendered: "
|
|
124
|
+
+ "without a preset the scene gets no image-based light and its `background` is not drawn.");
|
|
125
|
+
}
|
|
126
|
+
if (environment.params && Object.keys(environment.params).length > 0) {
|
|
127
|
+
warnInert3D("environment-params", "`params` on an environment is not applied: nothing assigns it onto the generated environment.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
99
130
|
this._environment = environment;
|
|
100
131
|
return this;
|
|
101
132
|
}
|
|
@@ -108,10 +139,12 @@ export class Scene3D extends RenderContext3D {
|
|
|
108
139
|
return this;
|
|
109
140
|
}
|
|
110
141
|
post(effects) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
142
|
+
const added = Array.isArray(effects) ? effects : [effects];
|
|
143
|
+
if (added.length > 0) {
|
|
144
|
+
warnInert3D("post", `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\`. `
|
|
145
|
+
+ "Use the Canvas3D's 2D `effects` over the composited result instead.");
|
|
146
|
+
}
|
|
147
|
+
this._post.push(...added);
|
|
115
148
|
return this;
|
|
116
149
|
}
|
|
117
150
|
// ─── Consumption ─────────────────────────────────────────────────────────
|
|
@@ -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,gBAAg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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\";\nimport { RenderContext3D, type Node3DRenderState } from \"./render-context3d\";\nimport type { CameraData3D, OrthographicCameraData3D, PerspectiveCameraData3D } from \"./camera\";\nimport type { LightData3D } from \"./light\";\nimport {\n resolveShadows3D,\n type EnvironmentData3D, type FogData3D, type PostEffect3D,\n type ShadowSettings3D, type Shadows3D, type ToneSettings3D,\n} from \"./scene-settings\";\nimport type { Transform3D } from \"./transform\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\n\n/** Options accepted by every `Camera3D` node and by {@link Scene3D.perspective}. */\ntype ParamsOf<T extends { type: string }> = Omit<T, \"type\">;\n\n/**\n * One recorded operation in a {@link Scene3D}.\n *\n * A superset of {@link Graphics3DOp}: everything a node draws, plus the four\n * things that describe the scene around it — the `push`/`pop` nesting the node\n * tree produces, the lights in it, and where it is viewed from.\n */\nexport type Scene3DOp =\n | { kind: \"push\"; transform?: Transform3D }\n | { kind: \"pop\" }\n | { kind: \"light\"; light: LightData3D; transform?: Transform3D }\n | { kind: \"camera\"; camera: CameraData3D }\n | Graphics3DOp;\n\n/**\n * A recorded 3D scene — and the {@link RenderContext3D} that records it.\n *\n * One value plays both parts, exactly as `Graphics2D` is both the builder and the\n * thing handed to a backend. A `Node3D` tree draws into it, and the result is a\n * flat op list plus a handful of scene-wide settings that a renderer replays.\n *\n * Almost always produced for you: a `Canvas3D` opens one per frame, walks its\n * `Node3D` children through it and paints the result through its own path. The\n * builder surface below is the escape hatch — it is what lets a scene be shaded\n * through *any* 2D shape rather than only a rect:\n *\n * const scene = new Scene3D()\n * .perspective({ orbit: 30, elevation: 20, distance: 6 })\n * .light({ type: \"ambient\", intensity: 0.4 })\n * .draw(new Graphics3D().box({ width: 2, fill: \"tomato\" }));\n *\n * <Text text=\"DEPTH\" fontSize={320} fill={scene} />\n *\n * A bare `Scene3D` coerces to a `canvas3D` fill the way a bare CSS string coerces\n * to a solid one, so `fill={scene}` and `fill={[\"#0b0d12\", scene]}` both work.\n */\nexport class Scene3D extends RenderContext3D {\n private _ops: Scene3DOp[] = [];\n private _camera: CameraData3D | null = null;\n private _fog: FogData3D | null = null;\n private _environment: EnvironmentData3D | null = null;\n private _shadows: ShadowSettings3D | null = null;\n private _tone: ToneSettings3D | null = null;\n private _post: PostEffect3D[] = [];\n /** Open `push` count, so {@link assertBalanced} can report a leak. */\n private _depth = 0;\n\n // ─── Node scopes ─────────────────────────────────────────────────────────\n\n override begin(state: Node3DRenderState): void {\n // The node's id rides on the transform's `key`, which is the renderer's\n // identity slot — so a group is cached against the node that opened it\n // rather than against its index among its siblings.\n this._ops.push({ kind: \"push\", transform: { ...state.transform, key: state.id } });\n this._depth++;\n }\n\n override end(): void {\n this._ops.push({ kind: \"pop\" });\n this._depth--;\n }\n\n // ─── Drawables ───────────────────────────────────────────────────────────\n\n /**\n * Splice what a node draws into the scene at the current scope.\n *\n * The ops are copied rather than referenced: a `Graphics3D` is rebuilt every\n * frame, so there is nothing to share, and a flat list is what the renderer\n * walks.\n */\n override draw(graphics: Graphics3D): this {\n const ops = graphics.ops();\n for (let i = 0; i < ops.length; i++) this._ops.push(ops[i]);\n return this;\n }\n\n // ─── Lights ──────────────────────────────────────────────────────────────\n\n override light(light: LightData3D, transform?: Transform3D): this {\n this._ops.push({ kind: \"light\", light, transform });\n return this;\n }\n\n // ─── Camera ──────────────────────────────────────────────────────────────\n\n override camera(camera: CameraData3D): this {\n this._camera = camera;\n this._ops.push({ kind: \"camera\", camera });\n return this;\n }\n\n /** Set a perspective camera. The usual choice. */\n perspective(options?: ParamsOf<PerspectiveCameraData3D>): this {\n return this.camera({ type: \"perspective\", ...options } as PerspectiveCameraData3D);\n }\n\n /** Set an orthographic camera — parallel projection, for isometric looks. */\n orthographic(options?: ParamsOf<OrthographicCameraData3D>): this {\n return this.camera({ type: \"orthographic\", ...options } as OrthographicCameraData3D);\n }\n\n // ─── Scene settings ──────────────────────────────────────────────────────\n //\n // Fields rather than ops: a scene has exactly one fog and one environment.\n // Recording them positionally would imply an ordering that doesn't exist.\n // Last writer wins.\n\n override fog(fog: FogData3D | Color | null): this {\n if (fog === null) {\n this._fog = null;\n } else if (typeof fog === \"object\" && !Array.isArray(fog)) {\n this._fog = fog as FogData3D;\n } else {\n this._fog = { color: fog as Color };\n }\n return this;\n }\n\n override environment(environment: EnvironmentData3D | null): this {\n this._environment = environment;\n return this;\n }\n\n override shadows(settings?: Shadows3D): this {\n this._shadows = resolveShadows3D(settings ?? true);\n return this;\n }\n\n override tone(settings: ToneSettings3D): this {\n this._tone = settings;\n return this;\n }\n\n override post(effects: PostEffect3D | readonly PostEffect3D[]): this {\n if (Array.isArray(effects)) this._post.push(...(effects as PostEffect3D[]));\n else this._post.push(effects as PostEffect3D);\n return this;\n }\n\n // ─── Consumption ─────────────────────────────────────────────────────────\n\n /** The recorded ops, in order. Replayed by the renderer. */\n ops(): readonly Scene3DOp[] {\n return this._ops;\n }\n\n /** The camera, or `null` to let the renderer supply a default framing. */\n cameraDescriptor(): CameraData3D | null {\n return this._camera;\n }\n fogDescriptor(): FogData3D | null {\n return this._fog;\n }\n environmentDescriptor(): EnvironmentData3D | null {\n return this._environment;\n }\n shadowSettings(): ShadowSettings3D | null {\n return this._shadows;\n }\n toneSettings(): ToneSettings3D | null {\n return this._tone;\n }\n postEffects(): readonly PostEffect3D[] {\n return this._post;\n }\n\n /**\n * True when nothing would be drawn — no mesh, light or other drawable. The\n * node skips the whole 3D pass (and the WebGL context entirely) in that case.\n */\n isEmpty(): boolean {\n return !this._ops.some((op) => DRAWABLE_KINDS.has(op.kind));\n }\n\n /**\n * Throw if `push` and `pop` are unbalanced. Called once by the consumer before\n * replay, so a mismatched scope fails loudly rather than silently reparenting\n * everything after it.\n *\n * A `Node3D` tree cannot get this wrong — `begin`/`end` are bracketed by the\n * walk — so in practice this catches a hand-built scene.\n */\n assertBalanced(): void {\n if (this._depth !== 0) {\n const verb = this._depth > 0 ? \"unclosed begin()\" : \"extra end()\";\n throw new Error(\n `Scene3D has ${Math.abs(this._depth)} ${verb}.`,\n );\n }\n }\n}\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,4EAA4E;IAEnE,KAAK,CAAC,KAAwB;QACnC,wEAAwE;QACxE,uEAAuE;QACvE,oDAAoD;QACpD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,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AAC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segments.js","sourceRoot":"","sources":["../../src/render3d/segments.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACtB,KAA6B,EAC7B,QAA2B;IAE3B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * Subdivision counts, as one name.\n *\n * three spells this ten different ways — `widthSegments`, `heightSegments`,\n * `depthSegments`, `radialSegments`, `tubularSegments`, `thetaSegments`,\n * `phiSegments`, `capSegments`, `curveSegments`, `detail` — and which one a given\n * shape wants is a thing an author has to look up every time. Every geometry here\n * takes one {@link Segments3D} instead, and the per-axis meaning is documented on\n * the shape rather than encoded in a name.\n *\n * A scalar applies to every axis, which is what you want when you are just\n * turning the resolution up. A tuple is per-axis, in the order the shape's own\n * docs give.\n */\nexport type Segments3D =\n | number\n | readonly [number]\n | readonly [number, number]\n | readonly [number, number, number];\n\n/**\n * Resolve a {@link Segments3D} against a shape's per-axis defaults.\n *\n * A scalar broadcasts, a tuple fills what it names and leaves the rest at the\n * default, and `undefined` is entirely defaults — so an unset `segments` never\n * pins a shape to a resolution invented at a call site.\n *\n * Values are floored and clamped to at least 1, because a fractional or zero\n * subdivision count reaches three as a degenerate geometry rather than as an\n * error.\n */\nexport function segmentsOf(\n value: Segments3D | undefined,\n defaults: readonly number[],\n): number[] {\n if (value === undefined) return defaults.map(clampSegment);\n if (typeof value === \"number\") return defaults.map(() => clampSegment(value));\n return defaults.map((fallback, index) => clampSegment(value[index] ?? fallback));\n}\n\nfunction clampSegment(value: number): number {\n return Math.max(1, Math.floor(value));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"segments.js","sourceRoot":"","sources":["../../src/render3d/segments.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACtB,KAA6B,EAC7B,QAA2B;IAE3B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/**\r\n * Subdivision counts, as one name.\r\n *\r\n * three spells this ten different ways — `widthSegments`, `heightSegments`,\r\n * `depthSegments`, `radialSegments`, `tubularSegments`, `thetaSegments`,\r\n * `phiSegments`, `capSegments`, `curveSegments`, `detail` — and which one a given\r\n * shape wants is a thing an author has to look up every time. Every geometry here\r\n * takes one {@link Segments3D} instead, and the per-axis meaning is documented on\r\n * the shape rather than encoded in a name.\r\n *\r\n * A scalar applies to every axis, which is what you want when you are just\r\n * turning the resolution up. A tuple is per-axis, in the order the shape's own\r\n * docs give.\r\n */\r\nexport type Segments3D =\r\n | number\r\n | readonly [number]\r\n | readonly [number, number]\r\n | readonly [number, number, number];\r\n\r\n/**\r\n * Resolve a {@link Segments3D} against a shape's per-axis defaults.\r\n *\r\n * A scalar broadcasts, a tuple fills what it names and leaves the rest at the\r\n * default, and `undefined` is entirely defaults — so an unset `segments` never\r\n * pins a shape to a resolution invented at a call site.\r\n *\r\n * Values are floored and clamped to at least 1, because a fractional or zero\r\n * subdivision count reaches three as a degenerate geometry rather than as an\r\n * error.\r\n */\r\nexport function segmentsOf(\r\n value: Segments3D | undefined,\r\n defaults: readonly number[],\r\n): number[] {\r\n if (value === undefined) return defaults.map(clampSegment);\r\n if (typeof value === \"number\") return defaults.map(() => clampSegment(value));\r\n return defaults.map((fallback, index) => clampSegment(value[index] ?? fallback));\r\n}\r\n\r\nfunction clampSegment(value: number): number {\r\n return Math.max(1, Math.floor(value));\r\n}\r\n"]}
|
|
@@ -175,4 +175,13 @@ export declare function resolveTexture3D(texture: Texture3D): ImageTexture3D | D
|
|
|
175
175
|
* needs loaded — a `null` here means "nothing to request", not "not a texture".
|
|
176
176
|
*/
|
|
177
177
|
export declare function texture3DSource(texture: Texture3D): string | null;
|
|
178
|
+
/**
|
|
179
|
+
* True for a string that names an asset rather than a colour.
|
|
180
|
+
*
|
|
181
|
+
* Leading `/` or `.` is a path by construction; otherwise the extension decides.
|
|
182
|
+
* A colour never matches either, and a bare name like `"wood"` is a colour —
|
|
183
|
+
* which is right, since an asset reference without a path or extension is not
|
|
184
|
+
* something the manifest could resolve either.
|
|
185
|
+
*/
|
|
186
|
+
export declare function looksLikeAssetPath(value: string): boolean;
|
|
178
187
|
//# sourceMappingURL=texture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../../src/render3d/texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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nF,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,IAAI,aAAa,CAE5E;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,IAAI,gBAAgB,CAElF;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,GAAG,cAAc,GAAG,aAAa,GAAG,gBAAgB,CAEtG;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAIjE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIzD"}
|
package/dist/render3d/texture.js
CHANGED
|
@@ -38,4 +38,17 @@ export function texture3DSource(texture) {
|
|
|
38
38
|
return null;
|
|
39
39
|
return texture.src;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* True for a string that names an asset rather than a colour.
|
|
43
|
+
*
|
|
44
|
+
* Leading `/` or `.` is a path by construction; otherwise the extension decides.
|
|
45
|
+
* A colour never matches either, and a bare name like `"wood"` is a colour —
|
|
46
|
+
* which is right, since an asset reference without a path or extension is not
|
|
47
|
+
* something the manifest could resolve either.
|
|
48
|
+
*/
|
|
49
|
+
export function looksLikeAssetPath(value) {
|
|
50
|
+
return value.startsWith("/")
|
|
51
|
+
|| value.startsWith(".")
|
|
52
|
+
|| /\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);
|
|
53
|
+
}
|
|
41
54
|
//# sourceMappingURL=texture.js.map
|
|
@@ -1 +1 @@
|
|
|
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","sourcesContent":["import type { Vector2 } from \"@/attributes/layout/vector2\";\n// Type-only, like `Color` above: `render3d` is pure data and never reaches into\n// the render or node layers at runtime. See SurfaceSource3D.\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { Node } from \"@/nodes/node/node\";\nimport type { Node2D } from \"@/nodes/2d/node2d\";\n\n/** How sampling behaves outside the 0–1 UV range. */\nexport type TextureWrap3D = \"clamp\" | \"repeat\" | \"mirror\";\n\n/** How texels are blended when the texture is scaled. */\nexport type TextureFilter3D = \"nearest\" | \"linear\";\n\n/**\n * Which colour space the texture's data is in.\n *\n * `\"srgb\"` for anything representing a *colour* an eye would see (albedo/`map`,\n * `emissiveMap`), so the renderer linearizes it before lighting maths.\n * `\"linear\"` for *data* maps whose channels are numbers rather than colours\n * (`normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `displacementMap`) —\n * linearizing those would corrupt them. Each map slot defaults correctly, so\n * this only needs setting for unusual pipelines.\n */\nexport type TextureColorSpace3D = \"srgb\" | \"linear\";\n\n/** Sampler state shared by every texture source. */\nexport interface TextureOptions3D {\n wrapS?: TextureWrap3D;\n wrapT?: TextureWrap3D;\n /** UV scale. `[2, 2]` tiles twice on each axis (needs a `repeat` wrap). */\n repeat?: Vector2 | readonly [number, number];\n offset?: Vector2 | readonly [number, number];\n /** UV rotation in **degrees**, about {@link center}. */\n rotation?: number;\n center?: Vector2 | readonly [number, number];\n magFilter?: TextureFilter3D;\n minFilter?: TextureFilter3D;\n /** Sharpness at grazing angles. Clamped to the GPU's maximum. */\n anisotropy?: number;\n flipY?: boolean;\n colorSpace?: TextureColorSpace3D;\n}\n\n/**\n * A texture loaded from the project's asset manifest.\n *\n * `src` is discovered by the asset-tracking render pass and requested through\n * core's ordinary image pipeline — the very same path a 2D image fill uses — so\n * the pixels are decoded and resident *before* the frame that needs them draws.\n */\nexport interface ImageTexture3D extends TextureOptions3D {\n src: string;\n}\n\n/**\n * A texture built from raw RGBA8888 bytes — the escape hatch for procedurally\n * generated pixels (gradient ramps, noise, LUTs, data encoded as colour).\n */\nexport interface DataTexture3D extends TextureOptions3D {\n data: ArrayLike<number>;\n width: number;\n height: number;\n /**\n * Bump to force a re-upload after mutating `data` in place. Mutation is\n * invisible to identity comparison, so without this the renderer cannot\n * tell the bytes changed. See {@link BufferGeometry3D.revision}.\n */\n revision?: number;\n}\n\n/**\n * A texture whose pixels are Motion Script's own 2D output, rasterized offscreen\n * — the way to put a chart, a readout or a whole laid-out UI onto 3D geometry.\n *\n * `source` is a value, not a name and not a mounted node: either a built\n * {@link Graphics2D} command list, or a `Node2D` subtree. Both are supplied directly,\n * so there is no matching indirection and nothing has to live in a particular\n * place in the scene tree.\n *\n * g3.plane({ map: Tex.surface(scopeGraphics, 1024, 640) })\n * g3.plane({ map: Tex.surface(statsSubtree, 1024, 640) })\n *\n * A `Node2D` source is *adopted for binding* by whatever paints the scene — it gets\n * that node's asset catalog, inherited context and clock, which is what makes a\n * webfont shape and an `<Image>` load. It is never laid out or painted by the\n * scene tree; it is measured against `width`×`height` and drawn into the buffer.\n *\n * **Hoist the source.** Building it fresh inside the scene builder allocates a new\n * subtree every frame — re-binding, re-laying-out, defeating the texture cache and\n * leaking. Declare it once and pass the same instance.\n *\n * That hoisting rule is also what removed this descriptor's old `key`: a hoisted\n * source *is* a stable identity, so the renderer keys the GPU texture off the\n * source object itself (in a `WeakMap`) rather than off its ordinal in the scene\n * walk. A conditionally-emitted surface therefore needs nothing written by hand,\n * and a source that goes out of scope becomes collectable instead of orphaning\n * its texture — which the ordinal scheme could not do.\n */\nexport interface SurfaceTexture3D extends TextureOptions3D {\n /** A built `Graphics2D`, or a `Node2D` subtree. Typed structurally — see below. */\n source: SurfaceSource3D;\n /** Buffer width in pixels. This *is* the texture's resolution. */\n width: number;\n /** Buffer height in pixels. */\n height: number;\n /**\n * Declare the source's pixels unchanging, so the buffer is rasterized once\n * and reused rather than redrawn every frame.\n *\n * Set by `resolveFill3D` for a fill chain, whose layers describe the same\n * image on every frame; an author's own source is live by default, which is\n * what makes an animated `Graphics2D` or a prop-driven subtree work with no\n * bookkeeping. Needs {@link identity} to be cacheable.\n *\n * @internal\n */\n static?: boolean;\n /**\n * Cache identity for a synthesized source.\n *\n * An author's source is identified by the source object itself (see the note\n * above), which is exactly right for something hoisted. A source built *for*\n * a fill is a fresh object every frame and has no such identity, so the value\n * it was derived from supplies one.\n *\n * @internal\n */\n identity?: string;\n /**\n * Ceiling on the buffer's device-pixel ratio. Default 1, i.e. the buffer is\n * exactly `width` × `height`.\n *\n * Unlike a 2D node — which wants to match the display — a surface is sampled by\n * a 3D material at whatever size the geometry occupies on screen, so the honest\n * control is `width`/`height`. Raise this only when a surface is viewed close\n * up and reads soft.\n */\n maxPixelRatio?: number;\n}\n\n/**\n * What a {@link SurfaceTexture3D} can be painted from: a built {@link Graphics2D}\n * command list, or a {@link Node2D} subtree.\n *\n * Both imports are **type-only**, exactly as `Color` is — `render3d` describes\n * scenes as data and never reaches into the render or node layers at runtime, and\n * a value import of `Node2D` here would close a real module cycle. Consumers narrow\n * with {@link resolveSurfaceSource}.\n */\nexport type SurfaceSource3D = Graphics2D | Node;\n\n// Declared against the dimension-agnostic base because that is what JSX produces\n// (`JSX.Element` is `Node`), so `Tex.surface(<Rect/>, …)` type-checks without a\n// cast. It has to be a 2D subtree in fact — the renderer lays it out and draws it\n// into a 2D buffer — and `resolveSurfaceSource` narrows to that; handing it a\n// `Node3D` fails at render time rather than here.\n\n/** A {@link SurfaceSource3D} narrowed to the arm its renderer should take. */\nexport type ResolvedSurfaceSource =\n | { kind: \"graphics\"; graphics: Graphics2D }\n | { kind: \"node\"; node: Node2D };\n\n/**\n * Narrow a surface source to the arm that knows how to draw it: a `Graphics2D` is\n * replayed into a render context, a `Node2D` is laid out against the buffer and\n * rendered.\n *\n * Structural rather than `instanceof`, because that would need value imports of\n * both classes and close the cycle the type-only imports above avoid. `Graphics2D`\n * is a command recorder and exposes `ops()`; a `Node2D` has no such method. The\n * union makes any *other* value a type error, so this only has to separate two\n * known shapes rather than validate an unknown one.\n */\nexport function resolveSurfaceSource(source: SurfaceSource3D): ResolvedSurfaceSource {\n return typeof (source as Graphics2D).ops === \"function\"\n ? { kind: \"graphics\", graphics: source as Graphics2D }\n : { kind: \"node\", node: source as Node2D };\n}\n\n/**\n * A texture reference. A bare string is sugar for `{ src }`, so the common case\n * is `map: \"/wood.png\"`.\n */\nexport type Texture3D = string | ImageTexture3D | DataTexture3D | SurfaceTexture3D;\n\n/** True for the raw-bytes form (vs. an asset-backed {@link ImageTexture3D}). */\nexport function isDataTexture3D(texture: Texture3D): texture is DataTexture3D {\n return typeof texture !== \"string\" && \"data\" in texture;\n}\n\n/** True for the {@link SurfaceTexture3D} form — pixels are rasterized from 2D. */\nexport function isSurfaceTexture3D(texture: Texture3D): texture is SurfaceTexture3D {\n return typeof texture !== \"string\" && \"source\" in texture;\n}\n\n/** Normalize the string shorthand to an {@link ImageTexture3D}. */\nexport function resolveTexture3D(texture: Texture3D): ImageTexture3D | DataTexture3D | SurfaceTexture3D {\n return typeof texture === \"string\" ? { src: texture } : texture;\n}\n\n/**\n * The asset `src` a texture reads from, or `null` when it has none (a data or\n * surface texture). Used by the asset-tracking pass to enumerate what a 3D scene\n * needs loaded — a `null` here means \"nothing to request\", not \"not a texture\".\n */\nexport function texture3DSource(texture: Texture3D): string | null {\n if (typeof texture === \"string\") return texture;\n if (isDataTexture3D(texture) || isSurfaceTexture3D(texture)) return null;\n return texture.src;\n}\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 \"@/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/render3d/tracking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAW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;QAAE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IACxB,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Asset discovery for 3D scenes.\n *\n * Walks a {@link Graphics3D}'s or {@link Scene3D}'s descriptors for the resources it references and\n * declares them into an {@link AssetScope}, so the ordinary asset timeline →\n * `AssetManager.loadAt` chain has them decoded and resident *before* the frame\n * that needs them renders. That is what lets the 3D draw stay synchronous.\n *\n * This runs off the very same descriptors the real render consumes — the node\n * builds its `Graphics3D` through one method that both paths call — so what gets\n * loaded cannot drift from what gets drawn.\n */\n\nimport type { AssetScope } from \"@/assets/scope\";\nimport type { LoaderFn } from \"@/assets/record\";\nimport type { Graphics3D } from \"./graphics3d\";\nimport { Scene3D } from \"./scene3d\";\nimport type { Geometry3D } from \"./geometry\";\nimport type { EnvironmentData3D } from \"./scene-settings\";\nimport { isSurfaceTexture3D, resolveSurfaceSource, texture3DSource } from \"./texture\";\nimport {\n canvas3DResourceKey, canvas3DResourceLoader,\n type Canvas3DResourceKind, type Canvas3DResourceLoader,\n} from \"./resources\";\nimport { forEachTexture3D } from \"./walk\";\n\n/**\n * Declare every asset a 3D scene or drawable list needs: textures as images, models\n * and environment panoramas through the backend's loader, and each `Tex.surface`\n * node source as a subtree of the declaring node.\n *\n * A `Graphics2D` surface source declares nothing.\n */\nexport function declare3DResources(g3: Graphics3D | Scene3D, assets: AssetScope): void {\n forEachTexture3D(g3, (value) => {\n if (isSurfaceTexture3D(value)) {\n const source = resolveSurfaceSource(value.source);\n if (source.kind === \"node\") assets.subtree(source.node);\n return;\n }\n const src = texture3DSource(value);\n if (src !== null) assets.image(src);\n });\n\n const geometry = (value: Geometry3D | undefined): void => {\n if (value === undefined) return;\n if (value.type === \"modelGeometry\") {\n declareLoader(\"gltf\", value.src, assets);\n } else if (value.type === \"edges\" || value.type === \"wireframe\") {\n geometry(value.source);\n }\n };\n\n for (const op of g3.ops()) {\n switch (op.kind) {\n case \"mesh\":\n case \"points\":\n case \"line\":\n case \"instances\":\n geometry(op.geometry);\n break;\n case \"model\":\n declareLoader(\"gltf\", op.src, assets);\n break;\n }\n }\n\n if (g3 instanceof Scene3D) declareEnvironment(g3.environmentDescriptor(), assets);\n}\n\n/** An environment's panoramas. A `preset` is generated and needs nothing. */\nexport function declareEnvironment(\n environment: Pick<EnvironmentData3D, \"src\" | \"faces\"> | null,\n assets: AssetScope,\n): void {\n if (environment === null) return;\n if (environment.src !== undefined) declareLoader(hdrKind(environment.src), environment.src, assets);\n for (const face of environment.faces ?? []) declareLoader(hdrKind(face), face, assets);\n}\n\n// Stable per backend loader and key, so declaring a resource again hands the scope\n// the same function rather than tripping its conflicting-loader check.\nconst resourceLoads = new WeakMap<Canvas3DResourceLoader, Map<string, LoaderFn>>();\n\nfunction declareLoader(kind: Canvas3DResourceKind, src: string, assets: AssetScope): void {\n const load = canvas3DResourceLoader();\n if (!load) return;\n const key = canvas3DResourceKey(kind, src);\n let byKey = resourceLoads.get(load);\n if (!byKey) resourceLoads.set(load, (byKey = new Map()));\n let fn = byKey.get(key);\n if (!fn) byKey.set(key, (fn = () => load(kind, src)));\n assets.loader(key, fn);\n}\n\nfunction hdrKind(src: string): Canvas3DResourceKind {\n const lower = src.toLowerCase();\n if (lower.endsWith(\".exr\")) return \"exr\";\n return \"hdr\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/render3d/tracking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EACH,mBAAmB,EAAE,sBAAsB,GAE9C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAwB,EAAE,MAAkB;IAC3E,gBAAgB,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3B,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAClD,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM;gBAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxD,OAAO;QACX,CAAC;QACD,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,GAAG,KAAK,IAAI;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,CAAC,KAA6B,EAAQ,EAAE;QACrD,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YACjC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,KAAK,CAAC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AC;IACtC,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3C,IAAI,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK;QAAE,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IACxB,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/**\r\n * Asset discovery for 3D scenes.\r\n *\r\n * Walks a {@link Graphics3D}'s or {@link Scene3D}'s descriptors for the resources it references and\r\n * declares them into an {@link AssetScope}, so the ordinary asset timeline →\r\n * `AssetManager.loadAt` chain has them decoded and resident *before* the frame\r\n * that needs them renders. That is what lets the 3D draw stay synchronous.\r\n *\r\n * This runs off the very same descriptors the real render consumes — the node\r\n * builds its `Graphics3D` through one method that both paths call — so what gets\r\n * loaded cannot drift from what gets drawn.\r\n */\r\n\r\nimport type { AssetScope } from \"@/assets/scope\";\r\nimport type { LoaderFn } from \"@/assets/record\";\r\nimport type { Graphics3D } from \"./graphics3d\";\r\nimport { Scene3D } from \"./scene3d\";\r\nimport type { Geometry3D } from \"./geometry\";\r\nimport type { EnvironmentData3D } from \"./scene-settings\";\r\nimport { isSurfaceTexture3D, resolveSurfaceSource, texture3DSource } from \"./texture\";\r\nimport {\r\n canvas3DResourceKey, canvas3DResourceLoader,\r\n type Canvas3DResourceKind, type Canvas3DResourceLoader,\r\n} from \"./resources\";\r\nimport { forEachTexture3D } from \"./walk\";\r\n\r\n/**\r\n * Declare every asset a 3D scene or drawable list needs: textures as images, models\r\n * and environment panoramas through the backend's loader, and each `Tex.surface`\r\n * node source as a subtree of the declaring node.\r\n *\r\n * A `Graphics2D` surface source declares nothing.\r\n */\r\nexport function declare3DResources(g3: Graphics3D | Scene3D, assets: AssetScope): void {\r\n forEachTexture3D(g3, (value) => {\r\n if (isSurfaceTexture3D(value)) {\r\n const source = resolveSurfaceSource(value.source);\r\n if (source.kind === \"node\") assets.subtree(source.node);\r\n return;\r\n }\r\n const src = texture3DSource(value);\r\n if (src !== null) assets.image(src);\r\n });\r\n\r\n const geometry = (value: Geometry3D | undefined): void => {\r\n if (value === undefined) return;\r\n if (value.type === \"modelGeometry\") {\r\n declareLoader(\"gltf\", value.src, assets);\r\n } else if (value.type === \"edges\" || value.type === \"wireframe\") {\r\n geometry(value.source);\r\n }\r\n };\r\n\r\n for (const op of g3.ops()) {\r\n switch (op.kind) {\r\n case \"mesh\":\r\n case \"points\":\r\n case \"line\":\r\n case \"instances\":\r\n geometry(op.geometry);\r\n break;\r\n case \"model\":\r\n declareLoader(\"gltf\", op.src, assets);\r\n break;\r\n }\r\n }\r\n\r\n if (g3 instanceof Scene3D) declareEnvironment(g3.environmentDescriptor(), assets);\r\n}\r\n\r\n/** An environment's panoramas. A `preset` is generated and needs nothing. */\r\nexport function declareEnvironment(\r\n environment: Pick<EnvironmentData3D, \"src\" | \"faces\"> | null,\r\n assets: AssetScope,\r\n): void {\r\n if (environment === null) return;\r\n if (environment.src !== undefined) declareLoader(hdrKind(environment.src), environment.src, assets);\r\n for (const face of environment.faces ?? []) declareLoader(hdrKind(face), face, assets);\r\n}\r\n\r\n// Stable per backend loader and key, so declaring a resource again hands the scope\r\n// the same function rather than tripping its conflicting-loader check.\r\nconst resourceLoads = new WeakMap<Canvas3DResourceLoader, Map<string, LoaderFn>>();\r\n\r\nfunction declareLoader(kind: Canvas3DResourceKind, src: string, assets: AssetScope): void {\r\n const load = canvas3DResourceLoader();\r\n if (!load) return;\r\n const key = canvas3DResourceKey(kind, src);\r\n let byKey = resourceLoads.get(load);\r\n if (!byKey) resourceLoads.set(load, (byKey = new Map()));\r\n let fn = byKey.get(key);\r\n if (!fn) byKey.set(key, (fn = () => load(kind, src)));\r\n assets.loader(key, fn);\r\n}\r\n\r\nfunction hdrKind(src: string): Canvas3DResourceKind {\r\n const lower = src.toLowerCase();\r\n if (lower.endsWith(\".exr\")) return \"exr\";\r\n return \"hdr\";\r\n}\r\n"]}
|
|
@@ -51,7 +51,7 @@ export declare function resolveShadowOptions3D(mode: Shadow3D | undefined): Shad
|
|
|
51
51
|
* Placement of a single 3D object. Every field is optional; an omitted field
|
|
52
52
|
* means identity, so `{}` is a valid no-op transform.
|
|
53
53
|
*
|
|
54
|
-
* Rotation is in **degrees** —
|
|
54
|
+
* Rotation is in **degrees** — the engine's 2D `rotation` is degrees, so 3D
|
|
55
55
|
* matches and authors never write `Math.PI`. The renderer converts.
|
|
56
56
|
*
|
|
57
57
|
* There is no `key` here. Reconciler identity is derived: a node stamps its own
|