@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":"render-context2d.js","sourceRoot":"","sources":["../../src/render/render-context2d.ts"],"names":[],"mappings":"","sourcesContent":["import type { FontStyle, TextStyle } from \"@/attributes/text/types\";\nimport type { TransformState } from \"./descriptors/transform\";\nimport type { MeasureContext2D } from \"./measure-context\";\nimport type { TextState } from \"./descriptors/text\";\nimport type { TextBlockLayout } from \"./text-layout\";\nimport type { Graphics2D } from \"./graphics2d\";\nimport type { Clip } from \"./clip\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\nimport type { SceneEffect } from \"@/attributes/shape/effects/union\";\nimport type { Size2D } from \"@/attributes/layout/size\";\n\n/**\n * Where an effect scope draws: `'foreground'` warps/filters the node's *own*\n * content (its fill, stroke and children), `'backdrop'` warps/filters the canvas\n * content already painted *beneath* the node (clipped to its silhouette). See\n * {@link RenderContext2D.beginEffects}.\n */\nexport type EffectTarget = \"foreground\" | \"backdrop\";\n\n/**\n * Pixels produced by {@link RenderContext2D.rasterize}: RGBA8888,\n * unpremultiplied, top-down (canvas row order). `width`/`height` are **device**\n * px, so they reflect the pixel ratio the renderer actually used rather than the\n * logical size that was asked for.\n */\nexport interface RasterizedSurface {\n pixels: Uint8Array;\n width: number;\n height: number;\n}\n\n/**\n * A bounding box in the current node's local space (origin = the node's\n * layout-cell centre, the same space shapes are drawn in). `left/top` use the\n * canvas convention (y down).\n */\nexport interface SpaceRect {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\n/**\n * Reference rects a fill can resolve against, supplied per-node at `begin()`.\n * `local` is derived from the drawn shapes themselves and `global` (the\n * viewport) is computed by the renderer from the surface size, so only the\n * parent frame is passed here.\n */\nexport interface SpaceRects {\n /** The parent node's content rect, in this node's local space. */\n parent?: SpaceRect;\n}\n\n/**\n * Per-node state supplied to {@link RenderContext2D.begin} for the duration of a\n * node's draw scope. Carries the node identity and gradient-space `rects` plus\n * the node's per-frame motion, sampled at render time. Motion-driven effects\n * (e.g. motion blur) read the current node's `velocity` from this state instead\n * of being authored with a fixed direction.\n *\n * Velocity fields are `0`/`{0,0}` when the motion is unknown — the first frame a\n * node renders, or after a time discontinuity (scrub/seek) where no trustworthy\n * delta exists.\n */\nexport interface NodeRenderState {\n /** Stable node identifier. */\n id: string;\n /** Parent / viewport rects in this node's local space. */\n rects: SpaceRects;\n /** How long this node has existed, in seconds (`NodeTime.elapsed`). */\n elapsed: number;\n /** The frame delta, in seconds, used to derive displacement from velocity. */\n dt: number;\n /** Translational velocity in px/sec, world space (y-down). `{0,0}` when unknown. */\n velocity: Vector2;\n /** Heading of `velocity` in degrees (`atan2(vy, vx)`). `0` when unknown. */\n direction: number;\n /** Magnitude of `velocity` in px/sec. `0` when unknown. */\n speed: number;\n /** Rotational velocity in degrees/sec. `0` when unknown. Reserved for radial motion blur. */\n angularVelocity: number;\n /** Scale velocity in scale-units/sec. `0` when unknown. Reserved for zoom motion blur. */\n scaleVelocity: number;\n}\n\n/**\n * The drawing surface a `Node2D` paints into — **the whole of what a node may\n * ask of a renderer, and nothing else.**\n *\n * Shapes are never declared directly on the context: they are built with a\n * {@link Graphics2D} command list and submitted via {@link draw}. Multiple\n * shapes chained on one `Graphics2D` before a paint call are combined into a\n * single surface and painted together:\n *\n * ctx.draw(new Graphics2D().ellipse(...).rect(...).fill(...)); // shared surface\n *\n * On top of that it carries text measurement — it extends {@link MeasureContext2D}, so\n * a node measures and draws through one object — and the higher-level scoping\n * operations: transforms, masks, clips, camera, boolean ops, effect scopes.\n * `begin(state)` / `end()` bracket each node's draw call so the context can\n * track which node is active.\n *\n * **An interface, with `CanvasRenderContext2D` as its one base class.** What a\n * node calls and what a *host* calls are different lists: `execute`,\n * `screenshot`, `unmount` and `dispose` drive a render pass and have no business\n * being reachable from inside one. Splitting them is what keeps this surface\n * the size it is. Every real backend still extends the class, which preserves\n * the `draw` to `drawGraphics` invariant that gives them all one implementation\n * of text-default resolution.\n *\n * `RenderContext3D` is its sibling, not its subclass: the two share no members,\n * because a 3D scene is described with lights, a camera and meshes rather than\n * with paths and paint.\n */\nexport interface RenderContext2D extends MeasureContext2D {\n measureText(\n text: string,\n fontSize: number,\n fontFamily: string,\n fontWeight?: number,\n letterSpacing?: number,\n fontStyle?: FontStyle,\n ): Size2D;\n\n // ---- Inherited text-style defaults ------------------------------------\n // `<DefaultTextStyle>` reaches a `Text`/`RichText` node through the context\n // map, applied once when the node binds. A raw `Graphics2D` has no node to\n // bind, so it inherits the same defaults here instead — pushed around a\n // subtree's draw scope, and folded into each `text`/`richText` op by\n // `draw()`. Same vocabulary (`TextStyle`), same precedence, two channels.\n\n /**\n * Set text-style defaults for everything drawn until the matching\n * {@link popTextStyle} — the drawn-graphics half of `<DefaultTextStyle>`.\n *\n * `style` is **merged** onto the defaults already in effect, per key, so\n * nesting accumulates the way the node channel does: an outer scope's\n * `fontFamily` and an inner scope's `fontSize` both apply, and a key set by\n * both takes the inner value. Values are resolved (a tweened `fontSize`\n * arrives as this frame's number), not callbacks.\n *\n * Pass `null` to open a scope that inherits **nothing** — not the enclosing\n * defaults and not the project's `theme.typography.default`. That is for a\n * node whose text is its own vocabulary rather than the document's: `Code`\n * does it so a scene-wide serif face doesn't reflow a monospaced code block.\n *\n * Always pair with `popTextStyle()` in a `finally`; the stack is shared with\n * every sibling drawn afterwards.\n */\n pushTextStyle(style: TextStyle | null): void;\n\n /** Close the innermost scope opened by {@link pushTextStyle}. */\n popTextStyle(): void;\n\n /**\n * The text-style defaults in effect right now: the innermost\n * {@link pushTextStyle} scope, or the project's `theme.typography.default`\n * when no scope is open — the same preset a `Text` node falls back to, so a\n * drawn label and a node label agree on the project's base typography.\n */\n readonly defaultTextStyle: TextStyle;\n\n /**\n * Replay a built `Graphics2D` against this context.\n *\n * Resolves the ambient text defaults onto the op list before handing it to\n * the backend, which is what keeps the real renderer and the precomp asset\n * walk agreeing on which font an under-specified `text` op shapes with: a\n * family that one resolves and the other does not is a font that never loads\n * and glyphs that never paint.\n */\n draw(graphics: Graphics2D): void;\n\n /**\n * Lay `state` out the way it would be drawn and report where every character\n * landed — see {@link TextBlockLayout} for the space and the caret model.\n *\n * This is what makes on-canvas text editing possible: glyph positions live\n * in the backend's shaper, so a host drawing its own caret and selection has\n * no way to compute them, and anything it approximates in the DOM disagrees\n * with the render as soon as the font, the line height or the wrapping does.\n *\n * Takes the whole {@link TextState} rather than a handful of font fields\n * because the resolution a caret has to agree with lives in the backend:\n * `'autofit'` picks a size from the box, `wrap` turns the width into a wrap\n * limit, and `textAlign` places the lines within it. Handing over the same\n * descriptor that gets drawn is what keeps the two from drifting apart.\n *\n * Returns `null` when the backend cannot measure this — the default, so a\n * backend that never needed glyph positions keeps working, and for cases no\n * caret model fits: text-on-path (glyphs follow a curve, not a line box) and\n * a block with active selection segments.\n */\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\n\n /**\n * Push a transform (position, rotation, scale, opacity, …) and return the\n * context so subsequent draw calls are issued in the transformed space. The\n * transform is popped when `end()` is called for the node that pushed it.\n */\n transform(state: Partial<TransformState>): RenderContext2D;\n\n /**\n * Open a boolean-path collection scope. Shapes drawn until `endBoolean()`\n * are gathered (fills/strokes suppressed) and combined with `op`. After\n * `endBoolean()` the merged path is left as the active surface, so a\n * paint-only `Graphics2D` (`new Graphics2D().fill(...).stroke(...)`)\n * submitted via `draw()` styles the combined result.\n */\n beginBoolean(op: BooleanOperation): void;\n endBoolean(): void;\n\n // Mask scope (imperative) — used by MaskGroup and other node-level callers\n // that manage the scope with explicit begin/apply/end:\n //\n // beginMask({ mode, inverted })\n // <render mask child> // child draws its own Graphics2D\n // applyMask()\n // <render content children> // children draw their own Graphics2D\n // endMask()\n //\n // The chain-friendly form lives on `Graphics2D` (`.mask().applyMask().endMask()`)\n // for inline use within a single `draw()`.\n //\n // For `vector` mode the mask child's path is collected and used as a\n // clipPath; fills/strokes are suppressed. For `alpha` and `luminance`\n // the mask is rendered into an offscreen layer and combined with content\n // via blend modes.\n beginMask(options?: MaskOptions): void;\n applyMask(): void;\n endMask(): void;\n\n /**\n * Push a clip region built from a {@link Clip} command list. The clip's\n * shapes are unioned (with `cut()`s subtracted) into a single path and\n * intersected with the active clip, so children are confined to that\n * compound outline — any silhouette, not just a rect or ellipse. Used both\n * for a node's `clip` boundary and to confine backdrop effects (blur,\n * magnify) to the node's exact shape. Paired with `endClip()`.\n */\n beginClip(clip: Clip): void;\n /** Pop the most-recently pushed clip region. */\n endClip(): void;\n\n /**\n * Open an effect scope over the node, applying `effects` to either the node's\n * own content or the content beneath it. Paired with {@link endEffects}.\n *\n * `target`:\n * - `'foreground'` — warps/filters the node's *own* drawing (its fill, stroke\n * and children captured between begin/end), like blur. Used for bulge and\n * foreground posterize.\n * - `'backdrop'` — warps/filters the canvas content already painted *beneath*\n * the node, clipped to the active silhouette clip, so the node's own edges\n * stay sharp (Figma-style). Used for backdrop-flagged filters (blur,\n * grayscale, pixelate, …), magnify, backdrop posterize, and backdrop SkSL.\n *\n * The renderer decides per effect whether to compose it as an `ImageFilter`\n * or run it as a snapshot/redraw shader — callers never route by effect type.\n * `width`/`height` are the node's logical size, for size-relative effects\n * (e.g. pixelate) and shader lens boxes.\n */\n beginEffects(effects: SceneEffect[], target: EffectTarget, width: number, height: number): void;\n endEffects(): void;\n\n /**\n * Draw `draw` into an offscreen buffer instead of onto the canvas, and hand\n * back its pixels. The buffer is `width` × `height` **logical** px with its\n * origin at the centre, matching the space a node draws in — so `draw` can be\n * an ordinary `render()` call on a node subtree and needs no special casing.\n *\n * This is what backs `Tex.surface`: `Canvas3D` rasterizes each of its 2D\n * sources through here, then hands the pixels to the 3D backend as a texture.\n * It runs *inside* the frame that consumes it, so a scrubbed frame is\n * identical to a played one.\n *\n * Returns `null` when the backend cannot rasterize offscreen — the material\n * then renders without that map. `pixelRatio` is a ceiling on the buffer's\n * device-pixel scale, not a guarantee; the renderer may clamp it.\n */\n rasterize(\n width: number,\n height: number,\n draw: () => void,\n pixelRatio?: number,\n ): RasterizedSurface | null;\n\n /**\n * Push a camera viewport. Clips to `viewport` (canvas-space, centred\n * coords) and applies the inverse camera transform so children render as\n * seen through the lens. `heading` rotates the world counter to the camera\n * angle. Paired with `endCamera()`.\n *\n * @param viewport Bounding rect of the camera node in canvas space.\n * @param lookAt World-space point the camera looks at.\n * @param zoom Uniform scale applied around `lookAt`.\n * @param heading Camera rotation in degrees.\n */\n beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\n endCamera(): void;\n\n /**\n * Whether this context ever reads `NodeRenderState.rects`.\n *\n * True for anything that actually paints, since a fill with `space:'parent'`\n * resolves against them. A context that only inspects *what* would be drawn\n * never looks at them, and computing them costs an object allocation per node\n * per frame. Nodes check this before doing that work; see `Node2D.beforeRender`.\n */\n readonly readsSpaceRects: boolean;\n\n /**\n * Whether this context only cares about *visible* output.\n *\n * True for anything that paints: a subtree at zero opacity contributes no\n * pixels, so walking it produces draw calls the rasterizer will discard.\n *\n * A context that inspects rather than paints sets this `false`, and that is\n * the whole reason this is a capability rather than an unconditional check:\n * such a walk exists to discover which images, videos, fonts and effects a\n * frame *references* — regardless of whether they can be seen. An invisible\n * node's font still has to load, because it may fade in two frames later and\n * glyphs that were never registered never paint. Skipping it there is not an\n * optimisation, it is a missing asset.\n *\n * Same shape and same reasoning as {@link readsSpaceRects}: the context\n * declares what it needs, and nodes check before doing work that would be\n * thrown away. See `Node2D.render`.\n */\n readonly drawsVisibleOnly: boolean;\n\n}\n\n/**\n * A render *pass*: a {@link RenderContext2D} plus the per-node scope bracket the\n * walk opens around each node.\n *\n * Split off from the drawing surface because the two have different callers.\n * `begin`/`end` are `Node2D.render`'s, once per node, and they push onto a stack\n * every fill with `space:'parent'` and every motion-driven effect reads back\n * from. A custom node's `renderSelf` calling one would open a scope nothing\n * closes — and since `renderSelf` is handed a {@link RenderContext2D}, it now\n * cannot.\n *\n * Every backend implements this; a host driving a render pass holds one.\n *\n * @internal\n */\nexport interface RenderPass2D extends RenderContext2D {\n /**\n * Open a node draw scope. Must be paired with `end()`. Pushes the node's\n * id and {@link NodeRenderState} (gradient-space rects + per-frame motion)\n * for the duration of the scope.\n */\n begin(state: NodeRenderState): void;\n\n /** Close the innermost node draw scope opened by `begin()`. */\n end(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"render-context2d.js","sourceRoot":"","sources":["../../src/render/render-context2d.ts"],"names":[],"mappings":"","sourcesContent":["import type { FontStyle, TextStyle } from \"@/attributes/text/types\";\r\nimport type { TransformState } from \"./descriptors/transform\";\r\nimport type { MeasureContext2D } from \"./measure-context\";\r\nimport type { TextState } from \"./descriptors/text\";\r\nimport type { TextBlockLayout } from \"./text-layout\";\r\nimport type { Graphics2D } from \"./graphics2d\";\r\nimport type { Clip } from \"./clip\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\r\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\r\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\r\nimport type { Size2D } from \"@/attributes/layout/size\";\r\n\r\n/**\r\n * Where an effect scope draws: `'foreground'` warps/filters the node's *own*\r\n * content (its fill, stroke and children), `'backdrop'` warps/filters the canvas\r\n * content already painted *beneath* the node (clipped to its silhouette). See\r\n * {@link RenderContext2D.beginEffects}.\r\n */\r\nexport type EffectTarget = \"foreground\" | \"backdrop\";\r\n\r\n/**\r\n * Pixels produced by {@link RenderContext2D.rasterize}: RGBA8888,\r\n * unpremultiplied, top-down (canvas row order). `width`/`height` are **device**\r\n * px, so they reflect the pixel ratio the renderer actually used rather than the\r\n * logical size that was asked for.\r\n */\r\nexport interface RasterizedSurface {\r\n pixels: Uint8Array;\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * A bounding box in the current node's local space (origin = the node's\r\n * layout-cell centre, the same space shapes are drawn in). `left/top` use the\r\n * canvas convention (y down).\r\n */\r\nexport interface SpaceRect {\r\n left: number;\r\n top: number;\r\n right: number;\r\n bottom: number;\r\n}\r\n\r\n/**\r\n * Reference rects a fill can resolve against, supplied per-node at `begin()`.\r\n * `local` is derived from the drawn shapes themselves and `global` (the\r\n * viewport) is computed by the renderer from the surface size, so only the\r\n * parent frame is passed here.\r\n */\r\nexport interface SpaceRects {\r\n /** The parent node's content rect, in this node's local space. */\r\n parent?: SpaceRect;\r\n}\r\n\r\n/**\r\n * Per-node state supplied to {@link RenderContext2D.begin} for the duration of a\r\n * node's draw scope. Carries the node identity and gradient-space `rects` plus\r\n * the node's per-frame motion, sampled at render time. Motion-driven effects\r\n * (e.g. motion blur) read the current node's `velocity` from this state instead\r\n * of being authored with a fixed direction.\r\n *\r\n * Velocity fields are `0`/`{0,0}` when the motion is unknown — the first frame a\r\n * node renders, or after a time discontinuity (scrub/seek) where no trustworthy\r\n * delta exists.\r\n */\r\nexport interface NodeRenderState {\r\n /** Stable node identifier. */\r\n id: string;\r\n /** Parent / viewport rects in this node's local space. */\r\n rects: SpaceRects;\r\n /** How long this node has existed, in seconds (`NodeTime.elapsed`). */\r\n elapsed: number;\r\n /** The frame delta, in seconds, used to derive displacement from velocity. */\r\n dt: number;\r\n /** Translational velocity in px/sec, world space (y-down). `{0,0}` when unknown. */\r\n velocity: Vector2;\r\n /** Heading of `velocity` in degrees (`atan2(vy, vx)`). `0` when unknown. */\r\n direction: number;\r\n /** Magnitude of `velocity` in px/sec. `0` when unknown. */\r\n speed: number;\r\n /** Rotational velocity in degrees/sec. `0` when unknown. Reserved for radial motion blur. */\r\n angularVelocity: number;\r\n /** Scale velocity in scale-units/sec. `0` when unknown. Reserved for zoom motion blur. */\r\n scaleVelocity: number;\r\n}\r\n\r\n/**\r\n * The drawing surface a `Node2D` paints into — **the whole of what a node may\r\n * ask of a renderer, and nothing else.**\r\n *\r\n * Shapes are never declared directly on the context: they are built with a\r\n * {@link Graphics2D} command list and submitted via {@link draw}. Multiple\r\n * shapes chained on one `Graphics2D` before a paint call are combined into a\r\n * single surface and painted together:\r\n *\r\n * ctx.draw(new Graphics2D().ellipse(...).rect(...).fill(...)); // shared surface\r\n *\r\n * On top of that it carries text measurement — it extends {@link MeasureContext2D}, so\r\n * a node measures and draws through one object — and the higher-level scoping\r\n * operations: transforms, masks, clips, camera, boolean ops, effect scopes.\r\n * `begin(state)` / `end()` bracket each node's draw call so the context can\r\n * track which node is active.\r\n *\r\n * **An interface, with `CanvasRenderContext2D` as its one base class.** What a\r\n * node calls and what a *host* calls are different lists: `execute`,\r\n * `screenshot`, `unmount` and `dispose` drive a render pass and have no business\r\n * being reachable from inside one. Splitting them is what keeps this surface\r\n * the size it is. Every real backend still extends the class, which preserves\r\n * the `draw` to `drawGraphics` invariant that gives them all one implementation\r\n * of text-default resolution.\r\n *\r\n * `RenderContext3D` is its sibling, not its subclass: the two share no members,\r\n * because a 3D scene is described with lights, a camera and meshes rather than\r\n * with paths and paint.\r\n */\r\nexport interface RenderContext2D extends MeasureContext2D {\r\n measureText(\r\n text: string,\r\n fontSize: number,\r\n fontFamily: string,\r\n fontWeight?: number,\r\n letterSpacing?: number,\r\n fontStyle?: FontStyle,\r\n ): Size2D;\r\n\r\n // ---- Inherited text-style defaults ------------------------------------\r\n // `<DefaultTextStyle>` reaches a `Text`/`RichText` node through the context\r\n // map, applied once when the node binds. A raw `Graphics2D` has no node to\r\n // bind, so it inherits the same defaults here instead — pushed around a\r\n // subtree's draw scope, and folded into each `text`/`richText` op by\r\n // `draw()`. Same vocabulary (`TextStyle`), same precedence, two channels.\r\n\r\n /**\r\n * Set text-style defaults for everything drawn until the matching\r\n * {@link popTextStyle} — the drawn-graphics half of `<DefaultTextStyle>`.\r\n *\r\n * `style` is **merged** onto the defaults already in effect, per key, so\r\n * nesting accumulates the way the node channel does: an outer scope's\r\n * `fontFamily` and an inner scope's `fontSize` both apply, and a key set by\r\n * both takes the inner value. Values are resolved (a tweened `fontSize`\r\n * arrives as this frame's number), not callbacks.\r\n *\r\n * Pass `null` to open a scope that inherits **nothing** — not the enclosing\r\n * defaults and not the project's `theme.typography.default`. That is for a\r\n * node whose text is its own vocabulary rather than the document's: `Code`\r\n * does it so a scene-wide serif face doesn't reflow a monospaced code block.\r\n *\r\n * Always pair with `popTextStyle()` in a `finally`; the stack is shared with\r\n * every sibling drawn afterwards.\r\n */\r\n pushTextStyle(style: TextStyle | null): void;\r\n\r\n /** Close the innermost scope opened by {@link pushTextStyle}. */\r\n popTextStyle(): void;\r\n\r\n /**\r\n * The text-style defaults in effect right now: the innermost\r\n * {@link pushTextStyle} scope, or the project's `theme.typography.default`\r\n * when no scope is open — the same preset a `Text` node falls back to, so a\r\n * drawn label and a node label agree on the project's base typography.\r\n */\r\n readonly defaultTextStyle: TextStyle;\r\n\r\n /**\r\n * Replay a built `Graphics2D` against this context.\r\n *\r\n * Resolves the ambient text defaults onto the op list before handing it to\r\n * the backend, which is what keeps the real renderer and the precomp asset\r\n * walk agreeing on which font an under-specified `text` op shapes with: a\r\n * family that one resolves and the other does not is a font that never loads\r\n * and glyphs that never paint.\r\n */\r\n draw(graphics: Graphics2D): void;\r\n\r\n /**\r\n * Lay `state` out the way it would be drawn and report where every character\r\n * landed — see {@link TextBlockLayout} for the space and the caret model.\r\n *\r\n * This is what makes on-canvas text editing possible: glyph positions live\r\n * in the backend's shaper, so a host drawing its own caret and selection has\r\n * no way to compute them, and anything it approximates in the DOM disagrees\r\n * with the render as soon as the font, the line height or the wrapping does.\r\n *\r\n * Takes the whole {@link TextState} rather than a handful of font fields\r\n * because the resolution a caret has to agree with lives in the backend:\r\n * `'autofit'` picks a size from the box, `wrap` turns the width into a wrap\r\n * limit, and `textAlign` places the lines within it. Handing over the same\r\n * descriptor that gets drawn is what keeps the two from drifting apart.\r\n *\r\n * Returns `null` when the backend cannot measure this — the default, so a\r\n * backend that never needed glyph positions keeps working, and for cases no\r\n * caret model fits: text-on-path (glyphs follow a curve, not a line box) and\r\n * a block with active selection segments.\r\n */\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\r\n\r\n /**\r\n * Push a transform (position, rotation, scale, opacity, …) and return the\r\n * context so subsequent draw calls are issued in the transformed space. The\r\n * transform is popped when `end()` is called for the node that pushed it.\r\n */\r\n transform(state: Partial<TransformState>): RenderContext2D;\r\n\r\n /**\r\n * Open a boolean-path collection scope. Shapes drawn until `endBoolean()`\r\n * are gathered (fills/strokes suppressed) and combined with `op`. After\r\n * `endBoolean()` the merged path is left as the active surface, so a\r\n * paint-only `Graphics2D` (`new Graphics2D().fill(...).stroke(...)`)\r\n * submitted via `draw()` styles the combined result.\r\n */\r\n beginBoolean(op: BooleanOperation): void;\r\n endBoolean(): void;\r\n\r\n // Mask scope (imperative) — used by MaskGroup and other node-level callers\r\n // that manage the scope with explicit begin/apply/end:\r\n //\r\n // beginMask({ mode, inverted })\r\n // <render mask child> // child draws its own Graphics2D\r\n // applyMask()\r\n // <render content children> // children draw their own Graphics2D\r\n // endMask()\r\n //\r\n // The chain-friendly form lives on `Graphics2D` (`.mask().applyMask().endMask()`)\r\n // for inline use within a single `draw()`.\r\n //\r\n // For `vector` mode the mask child's path is collected and used as a\r\n // clipPath; fills/strokes are suppressed. For `alpha` and `luminance`\r\n // the mask is rendered into an offscreen layer and combined with content\r\n // via blend modes.\r\n beginMask(options?: MaskOptions): void;\r\n applyMask(): void;\r\n endMask(): void;\r\n\r\n /**\r\n * Push a clip region built from a {@link Clip} command list. The clip's\r\n * shapes are unioned (with `cut()`s subtracted) into a single path and\r\n * intersected with the active clip, so children are confined to that\r\n * compound outline — any silhouette, not just a rect or ellipse. Used both\r\n * for a node's `clip` boundary and to confine backdrop effects (blur,\r\n * magnify) to the node's exact shape. Paired with `endClip()`.\r\n */\r\n beginClip(clip: Clip): void;\r\n /** Pop the most-recently pushed clip region. */\r\n endClip(): void;\r\n\r\n /**\r\n * Open an effect scope over the node, applying `effects` to either the node's\r\n * own content or the content beneath it. Paired with {@link endEffects}.\r\n *\r\n * `target`:\r\n * - `'foreground'` — warps/filters the node's *own* drawing (its fill, stroke\r\n * and children captured between begin/end), like blur. Used for bulge and\r\n * foreground posterize.\r\n * - `'backdrop'` — warps/filters the canvas content already painted *beneath*\r\n * the node, clipped to the active silhouette clip, so the node's own edges\r\n * stay sharp (Figma-style). Used for backdrop-flagged filters (blur,\r\n * grayscale, pixelate, …), magnify, backdrop posterize, and backdrop SkSL.\r\n *\r\n * The renderer decides per effect whether to compose it as an `ImageFilter`\r\n * or run it as a snapshot/redraw shader — callers never route by effect type.\r\n * `width`/`height` are the node's logical size, for size-relative effects\r\n * (e.g. pixelate) and shader lens boxes.\r\n */\r\n beginEffects(effects: NodeEffect[], target: EffectTarget, width: number, height: number): void;\r\n endEffects(): void;\r\n\r\n /**\r\n * Draw `draw` into an offscreen buffer instead of onto the canvas, and hand\r\n * back its pixels. The buffer is `width` × `height` **logical** px with its\r\n * origin at the centre, matching the space a node draws in — so `draw` can be\r\n * an ordinary `render()` call on a node subtree and needs no special casing.\r\n *\r\n * This is what backs `Tex.surface`: `Canvas3D` rasterizes each of its 2D\r\n * sources through here, then hands the pixels to the 3D backend as a texture.\r\n * It runs *inside* the frame that consumes it, so a scrubbed frame is\r\n * identical to a played one.\r\n *\r\n * Returns `null` when the backend cannot rasterize offscreen — the material\r\n * then renders without that map. `pixelRatio` is a ceiling on the buffer's\r\n * device-pixel scale, not a guarantee; the renderer may clamp it.\r\n */\r\n rasterize(\r\n width: number,\r\n height: number,\r\n draw: () => void,\r\n pixelRatio?: number,\r\n ): RasterizedSurface | null;\r\n\r\n /**\r\n * Push a camera viewport. Clips to `viewport` (canvas-space, centred\r\n * coords) and applies the inverse camera transform so children render as\r\n * seen through the lens. `heading` rotates the world counter to the camera\r\n * angle. Paired with `endCamera()`.\r\n *\r\n * @param viewport Bounding rect of the camera node in canvas space.\r\n * @param lookAt World-space point the camera looks at.\r\n * @param zoom Uniform scale applied around `lookAt`.\r\n * @param heading Camera rotation in degrees.\r\n */\r\n beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\r\n endCamera(): void;\r\n\r\n /**\r\n * Whether this context ever reads `NodeRenderState.rects`.\r\n *\r\n * True for anything that actually paints, since a fill with `space:'parent'`\r\n * resolves against them. A context that only inspects *what* would be drawn\r\n * never looks at them, and computing them costs an object allocation per node\r\n * per frame. Nodes check this before doing that work; see `Node2D.beforeRender`.\r\n */\r\n readonly readsSpaceRects: boolean;\r\n\r\n /**\r\n * Whether this context only cares about *visible* output.\r\n *\r\n * True for anything that paints: a subtree at zero opacity contributes no\r\n * pixels, so walking it produces draw calls the rasterizer will discard.\r\n *\r\n * A context that inspects rather than paints sets this `false`, and that is\r\n * the whole reason this is a capability rather than an unconditional check:\r\n * such a walk exists to discover which images, videos, fonts and effects a\r\n * frame *references* — regardless of whether they can be seen. An invisible\r\n * node's font still has to load, because it may fade in two frames later and\r\n * glyphs that were never registered never paint. Skipping it there is not an\r\n * optimisation, it is a missing asset.\r\n *\r\n * Same shape and same reasoning as {@link readsSpaceRects}: the context\r\n * declares what it needs, and nodes check before doing work that would be\r\n * thrown away. See `Node2D.render`.\r\n */\r\n readonly drawsVisibleOnly: boolean;\r\n\r\n}\r\n\r\n/**\r\n * A render *pass*: a {@link RenderContext2D} plus the per-node scope bracket the\r\n * walk opens around each node.\r\n *\r\n * Split off from the drawing surface because the two have different callers.\r\n * `begin`/`end` are `Node2D.render`'s, once per node, and they push onto a stack\r\n * every fill with `space:'parent'` and every motion-driven effect reads back\r\n * from. A custom node's `renderSelf` calling one would open a scope nothing\r\n * closes — and since `renderSelf` is handed a {@link RenderContext2D}, it now\r\n * cannot.\r\n *\r\n * Every backend implements this; a host driving a render pass holds one.\r\n *\r\n * @internal\r\n */\r\nexport interface RenderPass2D extends RenderContext2D {\r\n /**\r\n * Open a node draw scope. Must be paired with `end()`, also when the scope\r\n * throws. Pushes the node's id and {@link NodeRenderState} (gradient-space\r\n * rects + per-frame motion) for the duration of the scope.\r\n */\r\n begin(state: NodeRenderState): void;\r\n\r\n /** Close the innermost node draw scope opened by `begin()`. */\r\n end(): void;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/render/surface.ts"],"names":[],"mappings":"","sourcesContent":["import { Size2D } from \"@/attributes/layout/size\";\n\n/**\n * The host-facing half of a render context: where pixels land, and how the\n * preview frames them.\n *\n * Split out from `CanvasRenderContext2D` because a *node* never touches any of\n * it — a node draws, and the host decides what it is drawing into. A `Session`\n * owns one of these; a node is handed a `RenderContext2D`.\n *\n * **`mount` takes `unknown`, not `HTMLCanvasElement`.** `packages/core` compiles\n * with `lib: [\"ES2022\"]` and no DOM, deliberately, so this layer cannot name a\n * canvas — and it does not need to: a browser backend takes a canvas, a headless\n * one takes a size. Each narrows the argument at its own `mount`, where the\n * relevant types exist. `SkiaRenderContext` satisfies this structurally, so\n * neither `skia-render` nor `web` imports it.\n */\nexport interface RenderSurface {\n mount(target: unknown): void;\n unmount(): void;\n /** Device pixels per viewport unit. Rasterization, not zoom — see {@link view}. */\n pixelRatio: number;\n /** Preview pan/zoom over the frame. Costs a repaint, never a surface rebuild. */\n view: { zoom: number; x: number; y: number };\n /** The frame's own size when the surface is a window onto it, else `null`. */\n frame: Size2D | null;\n clipToFrame: boolean;\n /**\n * What the frame's backdrop is painted with. `\"transparent\"` lets whatever\n * is behind the canvas show through where nothing was drawn.\n */\n frameBackground: \"black\" | \"transparent\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/render/surface.ts"],"names":[],"mappings":"","sourcesContent":["import { Size2D } from \"@/attributes/layout/size\";\r\n\r\n/**\r\n * The host-facing half of a render context: where pixels land, and how the\r\n * preview frames them.\r\n *\r\n * Split out from `CanvasRenderContext2D` because a *node* never touches any of\r\n * it — a node draws, and the host decides what it is drawing into. A `Session`\r\n * owns one of these; a node is handed a `RenderContext2D`.\r\n *\r\n * **`mount` takes `unknown`, not `HTMLCanvasElement`.** `packages/core` compiles\r\n * with `lib: [\"ES2022\"]` and no DOM, deliberately, so this layer cannot name a\r\n * canvas — and it does not need to: a browser backend takes a canvas, a headless\r\n * one takes a size. Each narrows the argument at its own `mount`, where the\r\n * relevant types exist. `SkiaRenderContext` satisfies this structurally, so\r\n * neither `skia-render` nor `web` imports it.\r\n */\r\nexport interface RenderSurface {\r\n mount(target: unknown): void;\r\n unmount(): void;\r\n /** Device pixels per viewport unit. Rasterization, not zoom — see {@link view}. */\r\n pixelRatio: number;\r\n /** Preview pan/zoom over the frame. Costs a repaint, never a surface rebuild. */\r\n view: { zoom: number; x: number; y: number };\r\n /** The frame's own size when the surface is a window onto it, else `null`. */\r\n frame: Size2D | null;\r\n clipToFrame: boolean;\r\n /**\r\n * What the frame's backdrop is painted with. `\"transparent\"` lets whatever\r\n * is behind the canvas show through where nothing was drawn.\r\n */\r\n frameBackground: \"black\" | \"transparent\";\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-defaults.js","sourceRoot":"","sources":["../../src/render/text-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AASrF;;;;;GAKG;AACH,MAAM,SAAS,GAAG;IACd,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe;CAC1B,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG;IACxB,YAAY,EAAE,WAAW;CACiB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAoB,EAAE,KAAgB;IAC5E,oEAAoE;IACpE,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAErE,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAwB,IAAI,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG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E,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1D,IAAI,OAAO;YAAE,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAsC,CAAC;IACtF,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,2HAA2H;AAC3H,SAAS,SAAS,CAAC,MAAc,EAAE,KAAgB,EAAE,IAA+B;IAChF,MAAM,OAAO,GAAG,MAAiC,CAAC;IAClD,IAAI,GAAG,GAAmC,IAAI,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,SAAS;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import { EMPTY_TEXT_STYLE, TEXT_SHAPING_KEYS, textOps } from \"@/attributes/text/ops\";\nimport type { ResolvedTextSpan, TextShapingKey, TextStyle } from \"@/attributes/text/types\";\nimport { Graphics2D, type GraphicsOp, type GraphicsShapeOp } from \"./graphics2d\";\n\n/** The recorded `text` op, state and all. */\ntype TextOp = Extract<GraphicsShapeOp, { kind: \"text\" }>;\n/** The recorded `richText` op, state and all. */\ntype RichTextOp = Extract<GraphicsShapeOp, { kind: \"richText\" }>;\n\n/**\n * The span-level half of {@link TEXT_SHAPING_KEYS}. A `richText` op carries its\n * typography per span rather than on the shape, so a default has to be filled in\n * span by span — except `lineHeight`/`textAlign`, which lay the block out as a\n * whole and so live on the op itself.\n */\nconst SPAN_KEYS = [\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'letterSpacing',\n] as const satisfies readonly TextShapingKey[];\n\n/** The `richText` op's own layout keys — the ones that aren't per-span. */\nconst RICHTEXT_BLOCK_KEYS = [\n 'lineHeight', 'textAlign',\n] as const satisfies readonly TextShapingKey[];\n\n/**\n * `graphics` with `style` filled into every `text`/`richText` op that left a\n * shaping field unset — the drawn-text half of `<DefaultTextStyle>`.\n *\n * A `Text` node inherits defaults through the context channel, once, at bind\n * time (`applyTextDefaults`); a raw `Graphics2D` has no node to bind, so it\n * inherits here instead, at draw time, from the scope it is drawn in. Called\n * from `RenderContext2D.draw`, so a custom node's `ctx.draw(...)`, an offscreen\n * rasterization and the precomp pass's asset walk all see the same resolved op\n * list — which is what makes an inherited font actually *load* rather than\n * merely be asked for.\n *\n * A key counts as unset only when it is `undefined`: an op that names a value\n * always wins, exactly as an author-set prop beats an inherited one on a node.\n * Returns `graphics` itself when nothing changes, which is the common case (the\n * scene sets no defaults, or every op already names its own).\n */\nexport function applyGraphicsTextDefaults(graphics: Graphics2D, style: TextStyle): Graphics2D {\n // Not gated on `style` alone any more: an op naming a `variant` has\n // something to inherit even in a scope that sets nothing, so the walk has to\n // happen either way. The lazy copy below is what keeps that cheap.\n const ambient = hasShapingDefaults(style) ? style : EMPTY_TEXT_STYLE;\n\n const ops = graphics.ops();\n let next: GraphicsOp[] | null = null;\n for (let i = 0; i < ops.length; i++) {\n const op = ops[i];\n if (op.kind !== \"text\" && op.kind !== \"richText\") continue;\n const effective = effectiveStyle(op.state.variant, ambient);\n if (!hasShapingDefaults(effective)) continue;\n const patched = op.kind === \"text\"\n ? patchText(op, effective)\n : patchRichText(op, effective);\n if (!patched) continue;\n // Copy lazily: an op list with nothing to fill in keeps its identity, so\n // a fully-specified Text node allocates nothing on the way through.\n if (!next) next = ops.slice();\n next[i] = patched;\n }\n return next ? graphics._withOps(next) : graphics;\n}\n\n/**\n * The defaults one op inherits: its `variant`'s preset laid over the enclosing\n * scope's.\n *\n * That order is the node ladder one level down — an explicit value beats a\n * variant beats an inherited `<DefaultTextStyle>` — and it is why the merge is\n * here rather than in the caller: the ambient scope is per *subtree* while a\n * variant is per *op*, so they cannot be flattened before the walk.\n */\nfunction effectiveStyle(variant: string | undefined, ambient: TextStyle): TextStyle {\n return textOps.mergeStyle(ambient, variant ? textOps.preset(variant) : undefined);\n}\n\n/** Does `style` set anything a drawn text op could inherit? */\nfunction hasShapingDefaults(style: TextStyle): boolean {\n for (const key of TEXT_SHAPING_KEYS) {\n if (style[key] !== undefined) return true;\n }\n return false;\n}\n\nfunction patchText(op: TextOp, style: TextStyle): TextOp | null {\n const state = fillUnset(op.state, style, TEXT_SHAPING_KEYS);\n return state ? { kind: \"text\", state: state as TextOp[\"state\"] } : null;\n}\n\nfunction patchRichText(op: RichTextOp, style: TextStyle): RichTextOp | null {\n let state = fillUnset(op.state, style, RICHTEXT_BLOCK_KEYS);\n const spans = patchSpans(op.state.spans, style);\n if (spans) state = { ...(state ?? op.state), spans };\n return state ? { kind: \"richText\", state: state as RichTextOp[\"state\"] } : null;\n}\n\n/** The spans with defaults filled in, or `null` when none needed any. */\nfunction patchSpans(\n spans: ResolvedTextSpan[] | undefined,\n style: TextStyle,\n): ResolvedTextSpan[] | null {\n if (!spans || spans.length === 0) return null;\n // A span has no autofit mode — it is a run inside a block, sized by the\n // block — so an inherited `'autofit'` is skipped rather than written through\n // as a bad number.\n const spanStyle = style.fontSize === \"autofit\" ? { ...style, fontSize: undefined } : style;\n let next: ResolvedTextSpan[] | null = null;\n for (let i = 0; i < spans.length; i++) {\n const patched = fillUnset(spans[i], spanStyle, SPAN_KEYS);\n if (patched) (next ??= spans.slice())[i] = patched as unknown as ResolvedTextSpan;\n }\n return next;\n}\n\n/** A copy of `target` with each of `keys` it leaves `undefined` taken from `style`, or `null` when none needed filling. */\nfunction fillUnset(target: object, style: TextStyle, keys: readonly TextShapingKey[]): Record<string, unknown> | null {\n const current = target as Record<string, unknown>;\n let out: Record<string, unknown> | null = null;\n for (const key of keys) {\n if (current[key] !== undefined) continue;\n const value = style[key];\n if (value === undefined) continue;\n (out ??= { ...current })[key] = value;\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"text-defaults.js","sourceRoot":"","sources":["../../src/render/text-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AASrF;;;;;GAKG;AACH,MAAM,SAAS,GAAG;IACd,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe;CAC1B,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG;IACxB,YAAY,EAAE,WAAW;CACiB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAoB,EAAE,KAAgB;IAC5E,oEAAoE;IACpE,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAErE,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAwB,IAAI,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU;YAAE,SAAS;QAC3D,MAAM,SAAS,GAAG,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC;YAAE,SAAS;QAC7C,MAAM,OAAO,GAAG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M,OAAO,GAAG,MAAiC,CAAC;IAClD,IAAI,GAAG,GAAmC,IAAI,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,SAAS;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import { EMPTY_TEXT_STYLE, TEXT_SHAPING_KEYS, textOps } from \"@/attributes/text/ops\";\r\nimport type { ResolvedTextSpan, TextShapingKey, TextStyle } from \"@/attributes/text/types\";\r\nimport { Graphics2D, type GraphicsOp, type GraphicsShapeOp } from \"./graphics2d\";\r\n\r\n/** The recorded `text` op, state and all. */\r\ntype TextOp = Extract<GraphicsShapeOp, { kind: \"text\" }>;\r\n/** The recorded `richText` op, state and all. */\r\ntype RichTextOp = Extract<GraphicsShapeOp, { kind: \"richText\" }>;\r\n\r\n/**\r\n * The span-level half of {@link TEXT_SHAPING_KEYS}. A `richText` op carries its\r\n * typography per span rather than on the shape, so a default has to be filled in\r\n * span by span — except `lineHeight`/`textAlign`, which lay the block out as a\r\n * whole and so live on the op itself.\r\n */\r\nconst SPAN_KEYS = [\r\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'letterSpacing',\r\n] as const satisfies readonly TextShapingKey[];\r\n\r\n/** The `richText` op's own layout keys — the ones that aren't per-span. */\r\nconst RICHTEXT_BLOCK_KEYS = [\r\n 'lineHeight', 'textAlign',\r\n] as const satisfies readonly TextShapingKey[];\r\n\r\n/**\r\n * `graphics` with `style` filled into every `text`/`richText` op that left a\r\n * shaping field unset — the drawn-text half of `<DefaultTextStyle>`.\r\n *\r\n * A `Text` node inherits defaults through the context channel, once, at bind\r\n * time (`applyTextDefaults`); a raw `Graphics2D` has no node to bind, so it\r\n * inherits here instead, at draw time, from the scope it is drawn in. Called\r\n * from `RenderContext2D.draw`, so a custom node's `ctx.draw(...)`, an offscreen\r\n * rasterization and the precomp pass's asset walk all see the same resolved op\r\n * list — which is what makes an inherited font actually *load* rather than\r\n * merely be asked for.\r\n *\r\n * A key counts as unset only when it is `undefined`: an op that names a value\r\n * always wins, exactly as an author-set prop beats an inherited one on a node.\r\n * Returns `graphics` itself when nothing changes, which is the common case (the\r\n * scene sets no defaults, or every op already names its own).\r\n */\r\nexport function applyGraphicsTextDefaults(graphics: Graphics2D, style: TextStyle): Graphics2D {\r\n // Not gated on `style` alone any more: an op naming a `variant` has\r\n // something to inherit even in a scope that sets nothing, so the walk has to\r\n // happen either way. The lazy copy below is what keeps that cheap.\r\n const ambient = hasShapingDefaults(style) ? style : EMPTY_TEXT_STYLE;\r\n\r\n const ops = graphics.ops();\r\n let next: GraphicsOp[] | null = null;\r\n for (let i = 0; i < ops.length; i++) {\r\n const op = ops[i];\r\n if (op.kind !== \"text\" && op.kind !== \"richText\") continue;\r\n const effective = effectiveStyle(op.state.variant, ambient);\r\n if (!hasShapingDefaults(effective)) continue;\r\n const patched = op.kind === \"text\"\r\n ? patchText(op, effective)\r\n : patchRichText(op, effective);\r\n if (!patched) continue;\r\n // Copy lazily: an op list with nothing to fill in keeps its identity, so\r\n // a fully-specified Text node allocates nothing on the way through.\r\n if (!next) next = ops.slice();\r\n next[i] = patched;\r\n }\r\n return next ? graphics._withOps(next) : graphics;\r\n}\r\n\r\n/**\r\n * The defaults one op inherits: its `variant`'s preset laid over the enclosing\r\n * scope's.\r\n *\r\n * That order is the node ladder one level down — an explicit value beats a\r\n * variant beats an inherited `<DefaultTextStyle>` — and it is why the merge is\r\n * here rather than in the caller: the ambient scope is per *subtree* while a\r\n * variant is per *op*, so they cannot be flattened before the walk.\r\n */\r\nfunction effectiveStyle(variant: string | undefined, ambient: TextStyle): TextStyle {\r\n return textOps.mergeStyle(ambient, variant ? textOps.preset(variant) : undefined);\r\n}\r\n\r\n/** Does `style` set anything a drawn text op could inherit? */\r\nfunction hasShapingDefaults(style: TextStyle): boolean {\r\n for (const key of TEXT_SHAPING_KEYS) {\r\n if (style[key] !== undefined) return true;\r\n }\r\n return false;\r\n}\r\n\r\nfunction patchText(op: TextOp, style: TextStyle): TextOp | null {\r\n const state = fillUnset(op.state, style, TEXT_SHAPING_KEYS);\r\n return state ? { kind: \"text\", state: state as TextOp[\"state\"] } : null;\r\n}\r\n\r\nfunction patchRichText(op: RichTextOp, style: TextStyle): RichTextOp | null {\r\n let state = fillUnset(op.state, style, RICHTEXT_BLOCK_KEYS);\r\n const spans = patchSpans(op.state.spans, style);\r\n if (spans) state = { ...(state ?? op.state), spans };\r\n return state ? { kind: \"richText\", state: state as RichTextOp[\"state\"] } : null;\r\n}\r\n\r\n/** The spans with defaults filled in, or `null` when none needed any. */\r\nfunction patchSpans(\r\n spans: ResolvedTextSpan[] | undefined,\r\n style: TextStyle,\r\n): ResolvedTextSpan[] | null {\r\n if (!spans || spans.length === 0) return null;\r\n // A span has no autofit mode — it is a run inside a block, sized by the\r\n // block — so an inherited `'autofit'` is skipped rather than written through\r\n // as a bad number.\r\n const spanStyle = style.fontSize === \"autofit\" ? { ...style, fontSize: undefined } : style;\r\n let next: ResolvedTextSpan[] | null = null;\r\n for (let i = 0; i < spans.length; i++) {\r\n const patched = fillUnset(spans[i], spanStyle, SPAN_KEYS);\r\n if (patched) (next ??= spans.slice())[i] = patched as unknown as ResolvedTextSpan;\r\n }\r\n return next;\r\n}\r\n\r\n/** A copy of `target` with each of `keys` it leaves `undefined` taken from `style`, or `null` when none needed filling. */\r\nfunction fillUnset(target: object, style: TextStyle, keys: readonly TextShapingKey[]): Record<string, unknown> | null {\r\n const current = target as Record<string, unknown>;\r\n let out: Record<string, unknown> | null = null;\r\n for (const key of keys) {\r\n if (current[key] !== undefined) continue;\r\n const value = style[key];\r\n if (value === undefined) continue;\r\n (out ??= { ...current })[key] = value;\r\n }\r\n return out;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-layout.js","sourceRoot":"","sources":["../../src/render/text-layout.ts"],"names":[],"mappings":"AAoDA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAuB;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAcD;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,OAAQ,KAAgC,EAAE,eAAe,KAAK,UAAU;QAC3E,CAAC,CAAC,KAAwB;QAC1B,CAAC,CAAC,IAAI,CAAC;AACf,CAAC","sourcesContent":["import type { TextState } from \"./descriptors/text\";\n\n/**\n * Where a laid-out run of text put its characters — the measurement an editor\n * needs in order to draw its own caret and selection over rendered glyphs.\n *\n * **Space.** Block-local canvas pixels: origin at the centre of the text block,\n * **y down**, before the node's own transform. That is exactly the space the\n * backend shapes into when handed origin `(0, 0)`, so a caret at x = 0 sits on\n * the block's centre line and nothing here has to know where the node is.\n * {@link nodeTextLayout} is what lifts it into viewport space.\n *\n * **Why carets rather than glyph boxes.** A text cursor lives *between*\n * characters, so a run of n characters has n + 1 positions — and the two extra\n * facts an editor needs (where the run starts, where it ends) are precisely the\n * ones a list of glyph boxes leaves implicit. Reporting the slots directly also\n * means the host never has to reason about advance widths, kerning or trailing\n * whitespace to place a cursor.\n */\n\n/** One laid-out line of a text block. */\nexport interface TextBlockLine {\n /**\n * Character range this line covers, `[start, end)`, as offsets into the\n * block's whole string. A hard line break is *not* part of either line.\n */\n start: number;\n end: number;\n /** Top and bottom of the line box, block-local. */\n top: number;\n bottom: number;\n /**\n * The x of every caret slot on this line, block-local, in offset order:\n * `carets[i]` is the slot at character `start + i`, so there are\n * `end - start + 1` of them — one before each character plus one after the\n * last. Ordered left-to-right; bidirectional text is not modelled in v1.\n */\n carets: number[];\n}\n\n/**\n * A shaped text block: its lines, and the size the shaping produced.\n *\n * `width`/`height` are the block's own extent, which is what a hugging node\n * measures to — not the box it may have been aligned within.\n */\nexport interface TextBlockLayout {\n lines: TextBlockLine[];\n width: number;\n height: number;\n}\n\n/**\n * The caret slot count implied by a layout — i.e. one past the last character.\n *\n * Lines exclude their line break, so summing their slots would count the breaks\n * twice and lose the final position; this reads it off the last line instead.\n */\nexport function caretCount(layout: TextBlockLayout): number {\n const last = layout.lines[layout.lines.length - 1];\n return last ? last.end + 1 : 1;\n}\n\n/**\n * Something that can report where a shaped text block put its characters.\n *\n * Narrower than {@link RenderContext2D}, which is the only real implementation:\n * `nodeTextLayout` needs exactly this one call, and typing it against the whole\n * render context would make a caret measurement look like it required a\n * renderer. It does not — it requires a shaper.\n */\nexport interface TextBlockSource {\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\n}\n\n/**\n * Narrow `value` to a {@link TextBlockSource}, or `null` when it cannot report\n * glyph positions.\n *\n * A capability check rather than a cast, because it really is one: a\n * {@link MeasureContext2D} answers how *wide* text comes out, which every backend can\n * do, while reporting where each character *landed* needs a shaper that keeps\n * its line boxes. A host handed a measurer that has no such shaper should get\n * \"no caret model here\", not a crash.\n */\nexport function asTextBlockSource(value: unknown): TextBlockSource | null {\n return typeof (value as TextBlockSource | null)?.layoutTextBlock === \"function\"\n ? value as TextBlockSource\n : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"text-layout.js","sourceRoot":"","sources":["../../src/render/text-layout.ts"],"names":[],"mappings":"AAoDA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAuB;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAcD;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,OAAQ,KAAgC,EAAE,eAAe,KAAK,UAAU;QAC3E,CAAC,CAAC,KAAwB;QAC1B,CAAC,CAAC,IAAI,CAAC;AACf,CAAC","sourcesContent":["import type { TextState } from \"./descriptors/text\";\r\n\r\n/**\r\n * Where a laid-out run of text put its characters — the measurement an editor\r\n * needs in order to draw its own caret and selection over rendered glyphs.\r\n *\r\n * **Space.** Block-local canvas pixels: origin at the centre of the text block,\r\n * **y down**, before the node's own transform. That is exactly the space the\r\n * backend shapes into when handed origin `(0, 0)`, so a caret at x = 0 sits on\r\n * the block's centre line and nothing here has to know where the node is.\r\n * {@link nodeTextLayout} is what lifts it into viewport space.\r\n *\r\n * **Why carets rather than glyph boxes.** A text cursor lives *between*\r\n * characters, so a run of n characters has n + 1 positions — and the two extra\r\n * facts an editor needs (where the run starts, where it ends) are precisely the\r\n * ones a list of glyph boxes leaves implicit. Reporting the slots directly also\r\n * means the host never has to reason about advance widths, kerning or trailing\r\n * whitespace to place a cursor.\r\n */\r\n\r\n/** One laid-out line of a text block. */\r\nexport interface TextBlockLine {\r\n /**\r\n * Character range this line covers, `[start, end)`, as offsets into the\r\n * block's whole string. A hard line break is *not* part of either line.\r\n */\r\n start: number;\r\n end: number;\r\n /** Top and bottom of the line box, block-local. */\r\n top: number;\r\n bottom: number;\r\n /**\r\n * The x of every caret slot on this line, block-local, in offset order:\r\n * `carets[i]` is the slot at character `start + i`, so there are\r\n * `end - start + 1` of them — one before each character plus one after the\r\n * last. Ordered left-to-right; bidirectional text is not modelled in v1.\r\n */\r\n carets: number[];\r\n}\r\n\r\n/**\r\n * A shaped text block: its lines, and the size the shaping produced.\r\n *\r\n * `width`/`height` are the block's own extent, which is what a hugging node\r\n * measures to — not the box it may have been aligned within.\r\n */\r\nexport interface TextBlockLayout {\r\n lines: TextBlockLine[];\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * The caret slot count implied by a layout — i.e. one past the last character.\r\n *\r\n * Lines exclude their line break, so summing their slots would count the breaks\r\n * twice and lose the final position; this reads it off the last line instead.\r\n */\r\nexport function caretCount(layout: TextBlockLayout): number {\r\n const last = layout.lines[layout.lines.length - 1];\r\n return last ? last.end + 1 : 1;\r\n}\r\n\r\n/**\r\n * Something that can report where a shaped text block put its characters.\r\n *\r\n * Narrower than {@link RenderContext2D}, which is the only real implementation:\r\n * `nodeTextLayout` needs exactly this one call, and typing it against the whole\r\n * render context would make a caret measurement look like it required a\r\n * renderer. It does not — it requires a shaper.\r\n */\r\nexport interface TextBlockSource {\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\r\n}\r\n\r\n/**\r\n * Narrow `value` to a {@link TextBlockSource}, or `null` when it cannot report\r\n * glyph positions.\r\n *\r\n * A capability check rather than a cast, because it really is one: a\r\n * {@link MeasureContext2D} answers how *wide* text comes out, which every backend can\r\n * do, while reporting where each character *landed* needs a shaper that keeps\r\n * its line boxes. A host handed a measurer that has no such shaper should get\r\n * \"no caret model here\", not a crash.\r\n */\r\nexport function asTextBlockSource(value: unknown): TextBlockSource | null {\r\n return typeof (value as TextBlockSource | null)?.layoutTextBlock === \"function\"\r\n ? value as TextBlockSource\r\n : null;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds3d.d.ts","sourceRoot":"","sources":["../../src/render3d/bounds3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzD;;;;;;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AAC9D,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAOrE;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,EAAE,CAY7C;AAED;;;;;;GAMG;AACH,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,CAazD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAsH9E"}
|
|
@@ -109,9 +109,11 @@ export function geometryBounds3D(geometry) {
|
|
|
109
109
|
return centeredBox3(outer, outer, 0);
|
|
110
110
|
}
|
|
111
111
|
// `height` is the straight mid-section only, so the caps add a radius at
|
|
112
|
-
// each end — the one place three's naming would mislead a reader here.
|
|
112
|
+
// each end — the one place three's naming would mislead a reader here. Its
|
|
113
|
+
// default radius is 0.5, not three's 1: the renderer builds core's default,
|
|
114
|
+
// so a box drawn round three's would be twice too wide.
|
|
113
115
|
case "capsule": {
|
|
114
|
-
const radius = geometry.radius ??
|
|
116
|
+
const radius = geometry.radius ?? 0.5;
|
|
115
117
|
return centeredBox3(radius, (geometry.height ?? 1) / 2 + radius, radius);
|
|
116
118
|
}
|
|
117
119
|
// Every platonic solid is inscribed in its radius, so the sphere bounds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds3d.js","sourceRoot":"","sources":["../../src/render3d/bounds3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AAkCzD,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAAC,EAAU,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IAAI,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,IAAI;YAAE,IAAI,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,IAAI;YAAE,IAAI,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;AACtF,CAAC;AAED,yCAAyC;AACzC,SAAS,UAAU,CAAC,GAAS,EAAE,EAAU;IACrC,OAAO;QACH,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAChE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;KACnE,CAAC;AACN,CAAC","sourcesContent":["import { cylinderRadii, type Geometry3D } from \"./geometry\";\nimport { applyMatrix4, type Matrix4 } from \"./matrix4\";\nimport { resolveVector3, type Vector3 } from \"./vector3\";\n\n/**\n * Axis-aligned bounds for the 3D descriptors — the \"how big is it, and where\" an\n * editor needs in order to put a box round a mesh it did not build.\n *\n * **Analytic, not sampled.** Every primitive's extent falls straight out of its\n * parameters, so this is a table of formulas rather than a walk over vertices,\n * and it costs nothing to ask per pointer move. The defaults each one falls back\n * to are *three's* defaults, not invented here, because a descriptor that omits\n * `radius` renders at three's 1 and a box drawn round a different number would\n * be a box in the wrong place — see the note on each.\n *\n * **Conservative where it is not exact.** A partial sweep (`thetaLength` on a\n * sphere, `arc` on a torus) is bounded by the full figure rather than by the\n * wedge actually drawn: the exact answer is an arc-endpoint problem per shape\n * per axis, and the cost of getting it wrong is a selection box that *cuts\n * through* the mesh, where the cost of over-reporting is one that sits a little\n * loose. Over-reporting is the safe direction, and it is the direction taken\n * everywhere here.\n *\n * **`null` means \"no answer\", not \"empty\".** Three descriptors genuinely cannot\n * be measured without something this package does not have: a loaded model file,\n * a rasterized path, or a user callback that may read the frame clock. A caller\n * that gets `null` draws no box, which is the honest outcome — a wrong box is\n * worse than none.\n */\n\n/** An axis-aligned box. `min` is corner-wise minimum, not a point on the mesh. */\nexport interface Box3 {\n min: Vector3;\n max: Vector3;\n}\n\n/** @internal A box centred on the origin with the given half-extents. */\nexport function centeredBox3(hx: number, hy: number, hz: number): Box3 {\n return { min: { x: -hx, y: -hy, z: -hz }, max: { x: hx, y: hy, z: hz } };\n}\n\n/** @internal The union of two boxes; either may be `null`. */\nexport function unionBox3(a: Box3 | null, b: Box3 | null): Box3 | null {\n if (!a) return b;\n if (!b) return a;\n return {\n min: { x: Math.min(a.min.x, b.min.x), y: Math.min(a.min.y, b.min.y), z: Math.min(a.min.z, b.min.z) },\n max: { x: Math.max(a.max.x, b.max.x), y: Math.max(a.max.y, b.max.y), z: Math.max(a.max.z, b.max.z) },\n };\n}\n\n/** @internal The box's eight corners, in no particular order. */\nexport function corners3(box: Box3): Vector3[] {\n const { min, max } = box;\n return [\n { x: min.x, y: min.y, z: min.z },\n { x: max.x, y: min.y, z: min.z },\n { x: min.x, y: max.y, z: min.z },\n { x: max.x, y: max.y, z: min.z },\n { x: min.x, y: min.y, z: max.z },\n { x: max.x, y: min.y, z: max.z },\n { x: min.x, y: max.y, z: max.z },\n { x: max.x, y: max.y, z: max.z },\n ];\n}\n\n/**\n * `box` mapped through `m` and re-bounded — the AABB of the transformed AABB.\n *\n * Not the AABB of the transformed *mesh*: a rotated box's corner-bounds are\n * larger than the shape inside them. That slack is the price of not carrying\n * vertex data around, and it errs in the safe direction (see the module note).\n */\n/** @internal */\nexport function transformBox3(box: Box3, m: Matrix4): Box3 {\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (const corner of corners3(box)) {\n const p = applyMatrix4(m, corner);\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.z < minZ) minZ = p.z;\n if (p.x > maxX) maxX = p.x;\n if (p.y > maxY) maxY = p.y;\n if (p.z > maxZ) maxZ = p.z;\n }\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\n}\n\n/**\n * The local-space bounds of a geometry descriptor, or `null` when it cannot be\n * measured from the descriptor alone. See the module note for both halves of\n * that sentence.\n */\nexport function geometryBounds3D(geometry: Geometry3D | undefined): Box3 | null {\n if (!geometry) return null;\n\n switch (geometry.type) {\n // three centres a box on its origin; the defaults are 1 on every axis.\n case \"box\":\n return centeredBox3(\n (geometry.width ?? 1) / 2,\n (geometry.height ?? 1) / 2,\n (geometry.depth ?? 1) / 2,\n );\n\n // Full sphere even for a wedge — see the module note on partial sweeps.\n case \"sphere\":\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, geometry.radius ?? 1);\n\n // Flat in XY, facing +Z. Zero depth is correct rather than degenerate:\n // the projected box of a plane seen edge-on genuinely is a line.\n case \"plane\":\n return centeredBox3((geometry.width ?? 1) / 2, (geometry.height ?? 1) / 2, 0);\n\n // A cone is a cylinder with one radius zeroed, and three models it as its\n // own type — so the two share nothing here but the shape of the answer.\n case \"cylinder\": {\n const [top, bottom] = cylinderRadii(geometry.radius);\n const radius = Math.max(top, bottom);\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\n }\n case \"cone\": {\n const radius = geometry.radius ?? 1;\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\n }\n\n // The ring lies in XY and the tube swells it in Z by its own radius.\n case \"torus\": {\n const radius = geometry.radius ?? 1;\n const tube = geometry.thickness ?? 0.4;\n return centeredBox3(radius + tube, radius + tube, tube);\n }\n\n // three's knot curve is `radius * (2 + cos(qu/p)) / 2` in XY and\n // `radius * sin(qu/p) / 2` in Z, so it reaches 1.5·radius across and\n // 0.5·radius deep before the tube is added.\n case \"torusKnot\": {\n const radius = geometry.radius ?? 1;\n const tube = geometry.thickness ?? 0.4;\n return centeredBox3(radius * 1.5 + tube, radius * 1.5 + tube, radius * 0.5 + tube);\n }\n\n case \"circle\":\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, 0);\n\n case \"ring\": {\n const outer = geometry.radius ?? 1;\n return centeredBox3(outer, outer, 0);\n }\n\n // `height` is the straight mid-section only, so the caps add a radius at\n // each end — the one place three's naming would mislead a reader here.\n case \"capsule\": {\n const radius = geometry.radius ?? 1;\n return centeredBox3(radius, (geometry.height ?? 1) / 2 + radius, radius);\n }\n\n // Every platonic solid is inscribed in its radius, so the sphere bounds\n // it — loosely for a tetrahedron, exactly for a subdivided icosahedron.\n case \"polyhedron\": {\n const radius = geometry.radius ?? 1;\n return centeredBox3(radius, radius, radius);\n }\n\n // A profile revolved about Y: the widest |x| becomes the radius in both\n // ground axes, and the profile's own y range carries straight over.\n case \"lathe\": {\n let radius = 0;\n let minY = Infinity;\n let maxY = -Infinity;\n for (const point of geometry.points) {\n const p = resolveVector3(point);\n radius = Math.max(radius, Math.abs(p.x));\n minY = Math.min(minY, p.y);\n maxY = Math.max(maxY, p.y);\n }\n if (!Number.isFinite(minY)) return null;\n return { min: { x: -radius, y: minY, z: -radius }, max: { x: radius, y: maxY, z: radius } };\n }\n\n // The path's own extent, swollen by the tube radius on every axis. The\n // curve bulges outside its control points, so this is a lower bound made\n // safe by the radius rather than an exact one.\n case \"tube\": {\n const points = geometry.points.map((point) => resolveVector3(point));\n const box = pointsBounds3(points);\n if (!box) return null;\n return expandBox3(box, geometry.radius ?? 1);\n }\n\n // Raw vertex data — the one case that is a walk, because there is nothing\n // else to read it off.\n case \"buffer\":\n return positionBounds3(geometry.position);\n\n // A derived geometry has its source's extent: an outline of a shape is\n // the same size as the shape.\n case \"edges\":\n case \"wireframe\":\n return geometryBounds3D(geometry.source);\n\n // Three that need what this package hasn't got: a rasterized 2D path, a\n // callback that may read the clock, and a file off the network.\n case \"extrude\":\n case \"parametric\":\n case \"modelGeometry\":\n default:\n return null;\n }\n}\n\n/** Bounds of a point list, or `null` when it is empty. */\nfunction pointsBounds3(points: readonly Vector3[]): Box3 | null {\n if (points.length === 0) return null;\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (const p of points) {\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.z < minZ) minZ = p.z;\n if (p.x > maxX) maxX = p.x;\n if (p.y > maxY) maxY = p.y;\n if (p.z > maxZ) maxZ = p.z;\n }\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\n}\n\n/** Bounds of a flat `[x, y, z, …]` position buffer. */\nfunction positionBounds3(position: ArrayLike<number>): Box3 | null {\n if (position.length < 3) return null;\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i + 2 < position.length; i += 3) {\n const x = position[i], y = position[i + 1], z = position[i + 2];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (z < minZ) minZ = z;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n if (z > maxZ) maxZ = z;\n }\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\n}\n\n/** `box` grown by `by` on every axis. */\nfunction expandBox3(box: Box3, by: number): Box3 {\n return {\n min: { x: box.min.x - by, y: box.min.y - by, z: box.min.z - by },\n max: { x: box.max.x + by, y: box.max.y + by, z: box.max.z + by },\n };\n}\n"]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D } from \"./geometry\";\r\nimport { applyMatrix4, type Matrix4 } from \"./matrix4\";\r\nimport { resolveVector3, type Vector3 } from \"./vector3\";\r\n\r\n/**\r\n * Axis-aligned bounds for the 3D descriptors — the \"how big is it, and where\" an\r\n * editor needs in order to put a box round a mesh it did not build.\r\n *\r\n * **Analytic, not sampled.** Every primitive's extent falls straight out of its\r\n * parameters, so this is a table of formulas rather than a walk over vertices,\r\n * and it costs nothing to ask per pointer move. The defaults each one falls back\r\n * to are *three's* defaults, not invented here, because a descriptor that omits\r\n * `radius` renders at three's 1 and a box drawn round a different number would\r\n * be a box in the wrong place — see the note on each.\r\n *\r\n * **Conservative where it is not exact.** A partial sweep (`thetaLength` on a\r\n * sphere, `arc` on a torus) is bounded by the full figure rather than by the\r\n * wedge actually drawn: the exact answer is an arc-endpoint problem per shape\r\n * per axis, and the cost of getting it wrong is a selection box that *cuts\r\n * through* the mesh, where the cost of over-reporting is one that sits a little\r\n * loose. Over-reporting is the safe direction, and it is the direction taken\r\n * everywhere here.\r\n *\r\n * **`null` means \"no answer\", not \"empty\".** Three descriptors genuinely cannot\r\n * be measured without something this package does not have: a loaded model file,\r\n * a rasterized path, or a user callback that may read the frame clock. A caller\r\n * that gets `null` draws no box, which is the honest outcome — a wrong box is\r\n * worse than none.\r\n */\r\n\r\n/** An axis-aligned box. `min` is corner-wise minimum, not a point on the mesh. */\r\nexport interface Box3 {\r\n min: Vector3;\r\n max: Vector3;\r\n}\r\n\r\n/** @internal A box centred on the origin with the given half-extents. */\r\nexport function centeredBox3(hx: number, hy: number, hz: number): Box3 {\r\n return { min: { x: -hx, y: -hy, z: -hz }, max: { x: hx, y: hy, z: hz } };\r\n}\r\n\r\n/** @internal The union of two boxes; either may be `null`. */\r\nexport function unionBox3(a: Box3 | null, b: Box3 | null): Box3 | null {\r\n if (!a) return b;\r\n if (!b) return a;\r\n return {\r\n min: { x: Math.min(a.min.x, b.min.x), y: Math.min(a.min.y, b.min.y), z: Math.min(a.min.z, b.min.z) },\r\n max: { x: Math.max(a.max.x, b.max.x), y: Math.max(a.max.y, b.max.y), z: Math.max(a.max.z, b.max.z) },\r\n };\r\n}\r\n\r\n/** @internal The box's eight corners, in no particular order. */\r\nexport function corners3(box: Box3): Vector3[] {\r\n const { min, max } = box;\r\n return [\r\n { x: min.x, y: min.y, z: min.z },\r\n { x: max.x, y: min.y, z: min.z },\r\n { x: min.x, y: max.y, z: min.z },\r\n { x: max.x, y: max.y, z: min.z },\r\n { x: min.x, y: min.y, z: max.z },\r\n { x: max.x, y: min.y, z: max.z },\r\n { x: min.x, y: max.y, z: max.z },\r\n { x: max.x, y: max.y, z: max.z },\r\n ];\r\n}\r\n\r\n/**\r\n * `box` mapped through `m` and re-bounded — the AABB of the transformed AABB.\r\n *\r\n * Not the AABB of the transformed *mesh*: a rotated box's corner-bounds are\r\n * larger than the shape inside them. That slack is the price of not carrying\r\n * vertex data around, and it errs in the safe direction (see the module note).\r\n */\r\n/** @internal */\r\nexport function transformBox3(box: Box3, m: Matrix4): Box3 {\r\n let minX = Infinity, minY = Infinity, minZ = Infinity;\r\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\r\n for (const corner of corners3(box)) {\r\n const p = applyMatrix4(m, corner);\r\n if (p.x < minX) minX = p.x;\r\n if (p.y < minY) minY = p.y;\r\n if (p.z < minZ) minZ = p.z;\r\n if (p.x > maxX) maxX = p.x;\r\n if (p.y > maxY) maxY = p.y;\r\n if (p.z > maxZ) maxZ = p.z;\r\n }\r\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\r\n}\r\n\r\n/**\r\n * The local-space bounds of a geometry descriptor, or `null` when it cannot be\r\n * measured from the descriptor alone. See the module note for both halves of\r\n * that sentence.\r\n */\r\nexport function geometryBounds3D(geometry: Geometry3D | undefined): Box3 | null {\r\n if (!geometry) return null;\r\n\r\n switch (geometry.type) {\r\n // three centres a box on its origin; the defaults are 1 on every axis.\r\n case \"box\":\r\n return centeredBox3(\r\n (geometry.width ?? 1) / 2,\r\n (geometry.height ?? 1) / 2,\r\n (geometry.depth ?? 1) / 2,\r\n );\r\n\r\n // Full sphere even for a wedge — see the module note on partial sweeps.\r\n case \"sphere\":\r\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, geometry.radius ?? 1);\r\n\r\n // Flat in XY, facing +Z. Zero depth is correct rather than degenerate:\r\n // the projected box of a plane seen edge-on genuinely is a line.\r\n case \"plane\":\r\n return centeredBox3((geometry.width ?? 1) / 2, (geometry.height ?? 1) / 2, 0);\r\n\r\n // A cone is a cylinder with one radius zeroed, and three models it as its\r\n // own type — so the two share nothing here but the shape of the answer.\r\n case \"cylinder\": {\r\n const [top, bottom] = cylinderRadii(geometry.radius);\r\n const radius = Math.max(top, bottom);\r\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\r\n }\r\n case \"cone\": {\r\n const radius = geometry.radius ?? 1;\r\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\r\n }\r\n\r\n // The ring lies in XY and the tube swells it in Z by its own radius.\r\n case \"torus\": {\r\n const radius = geometry.radius ?? 1;\r\n const tube = geometry.thickness ?? 0.4;\r\n return centeredBox3(radius + tube, radius + tube, tube);\r\n }\r\n\r\n // three's knot curve is `radius * (2 + cos(qu/p)) / 2` in XY and\r\n // `radius * sin(qu/p) / 2` in Z, so it reaches 1.5·radius across and\r\n // 0.5·radius deep before the tube is added.\r\n case \"torusKnot\": {\r\n const radius = geometry.radius ?? 1;\r\n const tube = geometry.thickness ?? 0.4;\r\n return centeredBox3(radius * 1.5 + tube, radius * 1.5 + tube, radius * 0.5 + tube);\r\n }\r\n\r\n case \"circle\":\r\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, 0);\r\n\r\n case \"ring\": {\r\n const outer = geometry.radius ?? 1;\r\n return centeredBox3(outer, outer, 0);\r\n }\r\n\r\n // `height` is the straight mid-section only, so the caps add a radius at\r\n // each end — the one place three's naming would mislead a reader here. Its\r\n // default radius is 0.5, not three's 1: the renderer builds core's default,\r\n // so a box drawn round three's would be twice too wide.\r\n case \"capsule\": {\r\n const radius = geometry.radius ?? 0.5;\r\n return centeredBox3(radius, (geometry.height ?? 1) / 2 + radius, radius);\r\n }\r\n\r\n // Every platonic solid is inscribed in its radius, so the sphere bounds\r\n // it — loosely for a tetrahedron, exactly for a subdivided icosahedron.\r\n case \"polyhedron\": {\r\n const radius = geometry.radius ?? 1;\r\n return centeredBox3(radius, radius, radius);\r\n }\r\n\r\n // A profile revolved about Y: the widest |x| becomes the radius in both\r\n // ground axes, and the profile's own y range carries straight over.\r\n case \"lathe\": {\r\n let radius = 0;\r\n let minY = Infinity;\r\n let maxY = -Infinity;\r\n for (const point of geometry.points) {\r\n const p = resolveVector3(point);\r\n radius = Math.max(radius, Math.abs(p.x));\r\n minY = Math.min(minY, p.y);\r\n maxY = Math.max(maxY, p.y);\r\n }\r\n if (!Number.isFinite(minY)) return null;\r\n return { min: { x: -radius, y: minY, z: -radius }, max: { x: radius, y: maxY, z: radius } };\r\n }\r\n\r\n // The path's own extent, swollen by the tube radius on every axis. The\r\n // curve bulges outside its control points, so this is a lower bound made\r\n // safe by the radius rather than an exact one.\r\n case \"tube\": {\r\n const points = geometry.points.map((point) => resolveVector3(point));\r\n const box = pointsBounds3(points);\r\n if (!box) return null;\r\n return expandBox3(box, geometry.radius ?? 1);\r\n }\r\n\r\n // Raw vertex data — the one case that is a walk, because there is nothing\r\n // else to read it off.\r\n case \"buffer\":\r\n return positionBounds3(geometry.position);\r\n\r\n // A derived geometry has its source's extent: an outline of a shape is\r\n // the same size as the shape.\r\n case \"edges\":\r\n case \"wireframe\":\r\n return geometryBounds3D(geometry.source);\r\n\r\n // Three that need what this package hasn't got: a rasterized 2D path, a\r\n // callback that may read the clock, and a file off the network.\r\n case \"extrude\":\r\n case \"parametric\":\r\n case \"modelGeometry\":\r\n default:\r\n return null;\r\n }\r\n}\r\n\r\n/** Bounds of a point list, or `null` when it is empty. */\r\nfunction pointsBounds3(points: readonly Vector3[]): Box3 | null {\r\n if (points.length === 0) return null;\r\n let minX = Infinity, minY = Infinity, minZ = Infinity;\r\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\r\n for (const p of points) {\r\n if (p.x < minX) minX = p.x;\r\n if (p.y < minY) minY = p.y;\r\n if (p.z < minZ) minZ = p.z;\r\n if (p.x > maxX) maxX = p.x;\r\n if (p.y > maxY) maxY = p.y;\r\n if (p.z > maxZ) maxZ = p.z;\r\n }\r\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\r\n}\r\n\r\n/** Bounds of a flat `[x, y, z, …]` position buffer. */\r\nfunction positionBounds3(position: ArrayLike<number>): Box3 | null {\r\n if (position.length < 3) return null;\r\n let minX = Infinity, minY = Infinity, minZ = Infinity;\r\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\r\n for (let i = 0; i + 2 < position.length; i += 3) {\r\n const x = position[i], y = position[i + 1], z = position[i + 2];\r\n if (x < minX) minX = x;\r\n if (y < minY) minY = y;\r\n if (z < minZ) minZ = z;\r\n if (x > maxX) maxX = x;\r\n if (y > maxY) maxY = y;\r\n if (z > maxZ) maxZ = z;\r\n }\r\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\r\n}\r\n\r\n/** `box` grown by `by` on every axis. */\r\nfunction expandBox3(box: Box3, by: number): Box3 {\r\n return {\r\n min: { x: box.min.x - by, y: box.min.y - by, z: box.min.z - by },\r\n max: { x: box.max.x + by, y: box.max.y + by, z: box.max.z + by },\r\n };\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/render3d/builders.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,GAAG,EAAE,CAAC,CAA2B,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK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eometry3D,\n ConeGeometry3D, CylinderGeometry3D, EdgesGeometry3D, ExtrudeGeometry3D,\n Geometry3D, LatheGeometry3D, ModelGeometry3D, ParametricGeometry3D,\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D, WireframeGeometry3D,\n} from \"./geometry\";\nimport type {\n BasicMaterial3D, DepthMaterial3D, LambertMaterial3D, LineBasicMaterial3D,\n LineDashedMaterial3D, MatcapMaterial3D, NormalMaterial3D, PhongMaterial3D,\n PhysicalMaterial3D, PointsMaterial3D, ShaderMaterial3D, ShadowMaterial3D,\n SpriteMaterial3D, StandardMaterial3D, ToonMaterial3D,\n} from \"./material\";\nimport type { DataTexture3D, ImageTexture3D, SurfaceSource3D, SurfaceTexture3D, TextureOptions3D } from \"./texture\";\n\n/** A descriptor's own params, with the `type` discriminant removed. */\ntype ParamsOf<T> = Omit<T, \"type\">;\n\n/**\n * Geometry descriptors.\n *\n * These are plain values, so hoist one out of the builder and share it across\n * meshes — the renderer dedupes by identity, so a shared geometry is uploaded to\n * the GPU once no matter how many meshes reference it.\n *\n * const brick = Geo.box({ width: 1, height: 0.5, depth: 0.5 });\n * g.mesh(brick, red, { position: [0, 0, 0] })\n * .mesh(brick, red, { position: [1, 0, 0] }); // same GPU buffer\n */\nexport const Geo = {\n box: (o?: ParamsOf<BoxGeometry3D>): BoxGeometry3D => ({ type: \"box\", ...o }),\n sphere: (o?: ParamsOf<SphereGeometry3D>): SphereGeometry3D => ({ type: \"sphere\", ...o }),\n plane: (o?: ParamsOf<PlaneGeometry3D>): PlaneGeometry3D => ({ type: \"plane\", ...o }),\n cylinder: (o?: ParamsOf<CylinderGeometry3D>): CylinderGeometry3D => ({ type: \"cylinder\", ...o }),\n cone: (o?: ParamsOf<ConeGeometry3D>): ConeGeometry3D => ({ type: \"cone\", ...o }),\n torus: (o?: ParamsOf<TorusGeometry3D>): TorusGeometry3D => ({ type: \"torus\", ...o }),\n torusKnot: (o?: ParamsOf<TorusKnotGeometry3D>): TorusKnotGeometry3D => ({ type: \"torusKnot\", ...o }),\n circle: (o?: ParamsOf<CircleGeometry3D>): CircleGeometry3D => ({ type: \"circle\", ...o }),\n ring: (o?: ParamsOf<RingGeometry3D>): RingGeometry3D => ({ type: \"ring\", ...o }),\n capsule: (o?: ParamsOf<CapsuleGeometry3D>): CapsuleGeometry3D => ({ type: \"capsule\", ...o }),\n\n tetrahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"tetrahedron\", ...o }),\n octahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"octahedron\", ...o }),\n icosahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"icosahedron\", ...o }),\n dodecahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"dodecahedron\", ...o }),\n\n extrude: (o: ParamsOf<ExtrudeGeometry3D>): ExtrudeGeometry3D => ({ type: \"extrude\", ...o }),\n lathe: (o: ParamsOf<LatheGeometry3D>): LatheGeometry3D => ({ type: \"lathe\", ...o }),\n tube: (o: ParamsOf<TubeGeometry3D>): TubeGeometry3D => ({ type: \"tube\", ...o }),\n\n /** Raw vertex buffers — any mesh you can compute. */\n buffer: (o: ParamsOf<BufferGeometry3D>): BufferGeometry3D => ({ type: \"buffer\", ...o }),\n /** A surface sampled over a `[0,1]²` grid. Sugar over {@link Geo.buffer}. */\n parametric: (o: ParamsOf<ParametricGeometry3D>): ParametricGeometry3D => ({ type: \"parametric\", ...o }),\n\n /** The hard edges of another geometry — a clean outline, no triangulation diagonals. */\n edges: (source: Geometry3D, o?: Omit<ParamsOf<EdgesGeometry3D>, \"source\">): EdgesGeometry3D =>\n ({ type: \"edges\", source, ...o }),\n /** Every triangle edge of another geometry. */\n wireframe: (source: Geometry3D): WireframeGeometry3D => ({ type: \"wireframe\", source }),\n\n model: (src: string, o?: Omit<ParamsOf<ModelGeometry3D>, \"src\">): ModelGeometry3D =>\n ({ type: \"modelGeometry\", src, ...o }),\n} as const;\n\n/**\n * Material descriptors.\n *\n * Like geometries these are shareable values — one hoisted material across many\n * meshes compiles one shader program instead of N.\n *\n * Reach for {@link Mat.standard} by default; {@link Mat.physical} only when a\n * surface actually needs clearcoat, transmission, sheen or iridescence, since\n * those cost more per pixel. {@link Mat.shader} is the full-control escape hatch.\n */\nexport const Mat = {\n basic: (o?: ParamsOf<BasicMaterial3D>): BasicMaterial3D => ({ type: \"basic\", ...o }),\n standard: (o?: ParamsOf<StandardMaterial3D>): StandardMaterial3D => ({ type: \"standard\", ...o }),\n physical: (o?: ParamsOf<PhysicalMaterial3D>): PhysicalMaterial3D => ({ type: \"physical\", ...o }),\n phong: (o?: ParamsOf<PhongMaterial3D>): PhongMaterial3D => ({ type: \"phong\", ...o }),\n lambert: (o?: ParamsOf<LambertMaterial3D>): LambertMaterial3D => ({ type: \"lambert\", ...o }),\n toon: (o?: ParamsOf<ToonMaterial3D>): ToonMaterial3D => ({ type: \"toon\", ...o }),\n normal: (o?: ParamsOf<NormalMaterial3D>): NormalMaterial3D => ({ type: \"normal\", ...o }),\n depth: (o?: ParamsOf<DepthMaterial3D>): DepthMaterial3D => ({ type: \"depth\", ...o }),\n matcap: (o?: ParamsOf<MatcapMaterial3D>): MatcapMaterial3D => ({ type: \"matcap\", ...o }),\n points: (o?: ParamsOf<PointsMaterial3D>): PointsMaterial3D => ({ type: \"points\", ...o }),\n lineBasic: (o?: ParamsOf<LineBasicMaterial3D>): LineBasicMaterial3D => ({ type: \"lineBasic\", ...o }),\n lineDashed: (o?: ParamsOf<LineDashedMaterial3D>): LineDashedMaterial3D => ({ type: \"lineDashed\", ...o }),\n sprite: (o?: ParamsOf<SpriteMaterial3D>): SpriteMaterial3D => ({ type: \"sprite\", ...o }),\n shadow: (o?: ParamsOf<ShadowMaterial3D>): ShadowMaterial3D => ({ type: \"shadow\", ...o }),\n /** Raw GLSL. Uniform *values* are free to animate; source changes recompile. */\n shader: (o: ParamsOf<ShaderMaterial3D>): ShaderMaterial3D => ({ type: \"shader\", ...o }),\n} as const;\n\n/**\n * Texture descriptors.\n *\n * {@link Tex.image} takes a manifest path and is loaded through core's ordinary\n * image pipeline, so the pixels are resident before the frame that needs them\n * draws. A bare string works anywhere a texture is expected, so `Tex.image` is\n * only needed when passing sampler options.\n */\nexport const Tex = {\n image: (src: string, o?: TextureOptions3D): ImageTexture3D => ({ src, ...o }),\n /** A texture from raw RGBA8888 bytes — gradient ramps, noise, LUTs. */\n data: (\n data: ArrayLike<number>,\n width: number,\n height: number,\n o?: TextureOptions3D & { revision?: number },\n ): DataTexture3D => ({ data, width, height, ...o }),\n /**\n * A texture painted from Motion Script's own 2D output — the bridge from 2D\n * onto 3D geometry.\n *\n * `source` is a **value**: a built `Graphics2D` command list, or a `Node2D`\n * subtree for anything needing real layout, shaped `Text` or a loaded\n * `Image`. Both are passed directly; there is no name to match and nothing\n * has to be mounted anywhere in particular.\n *\n * const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);\n * g3.plane({ fill: scope }); // sized for you\n *\n * const stats = <Rect flow=\"vertical\" padding={48}><Text text=\"CPU\" /></Rect>;\n * g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });\n *\n * `width`/`height` are the buffer's resolution and default to 512. A source\n * handed straight to `fill` gets exactly this treatment with those defaults,\n * so the builder is only needed to pin a resolution or a sampler option.\n * **Hoist the source** rather than rebuilding it each frame — see\n * {@link SurfaceTexture3D}.\n */\n surface: (\n source: SurfaceSource3D,\n o?: TextureOptions3D & { width?: number; height?: number; maxPixelRatio?: number },\n ): SurfaceTexture3D => ({\n width: 512,\n height: 512,\n ...o,\n source,\n }),\n} as const;\n"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OAAO,EAAE,CACL,MAAuB,EACvB,CAAkF,EAClE,EAAE,CAAC,CAAC;QACpB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,GAAG,CAAC;QACJ,MAAM;KACT,CAAC;CACI,CAAC","sourcesContent":["import type {\r\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D,\r\n ConeGeometry3D, CylinderGeometry3D, EdgesGeometry3D, ExtrudeGeometry3D,\r\n Geometry3D, LatheGeometry3D, ModelGeometry3D, ParametricGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D, WireframeGeometry3D,\r\n} from \"./geometry\";\r\nimport type {\r\n BasicMaterial3D, DepthMaterial3D, LambertMaterial3D, LineBasicMaterial3D,\r\n LineDashedMaterial3D, MatcapMaterial3D, NormalMaterial3D, PhongMaterial3D,\r\n PhysicalMaterial3D, PointsMaterial3D, ShaderMaterial3D, ShadowMaterial3D,\r\n SpriteMaterial3D, StandardMaterial3D, ToonMaterial3D,\r\n} from \"./material\";\r\nimport type { DataTexture3D, ImageTexture3D, SurfaceSource3D, SurfaceTexture3D, TextureOptions3D } from \"./texture\";\r\n\r\n/** A descriptor's own params, with the `type` discriminant removed. */\r\ntype ParamsOf<T> = Omit<T, \"type\">;\r\n\r\n/**\r\n * Geometry descriptors.\r\n *\r\n * These are plain values, so hoist one out of the builder and share it across\r\n * meshes — the renderer dedupes by identity, so a shared geometry is uploaded to\r\n * the GPU once no matter how many meshes reference it.\r\n *\r\n * const brick = Geo.box({ width: 1, height: 0.5, depth: 0.5 });\r\n * g.mesh(brick, red, { position: [0, 0, 0] })\r\n * .mesh(brick, red, { position: [1, 0, 0] }); // same GPU buffer\r\n */\r\nexport const Geo = {\r\n box: (o?: ParamsOf<BoxGeometry3D>): BoxGeometry3D => ({ type: \"box\", ...o }),\r\n sphere: (o?: ParamsOf<SphereGeometry3D>): SphereGeometry3D => ({ type: \"sphere\", ...o }),\r\n plane: (o?: ParamsOf<PlaneGeometry3D>): PlaneGeometry3D => ({ type: \"plane\", ...o }),\r\n cylinder: (o?: ParamsOf<CylinderGeometry3D>): CylinderGeometry3D => ({ type: \"cylinder\", ...o }),\r\n cone: (o?: ParamsOf<ConeGeometry3D>): ConeGeometry3D => ({ type: \"cone\", ...o }),\r\n torus: (o?: ParamsOf<TorusGeometry3D>): TorusGeometry3D => ({ type: \"torus\", ...o }),\r\n torusKnot: (o?: ParamsOf<TorusKnotGeometry3D>): TorusKnotGeometry3D => ({ type: \"torusKnot\", ...o }),\r\n circle: (o?: ParamsOf<CircleGeometry3D>): CircleGeometry3D => ({ type: \"circle\", ...o }),\r\n ring: (o?: ParamsOf<RingGeometry3D>): RingGeometry3D => ({ type: \"ring\", ...o }),\r\n capsule: (o?: ParamsOf<CapsuleGeometry3D>): CapsuleGeometry3D => ({ type: \"capsule\", ...o }),\r\n\r\n tetrahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"tetrahedron\", ...o }),\r\n octahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"octahedron\", ...o }),\r\n icosahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"icosahedron\", ...o }),\r\n dodecahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"dodecahedron\", ...o }),\r\n\r\n extrude: (o: ParamsOf<ExtrudeGeometry3D>): ExtrudeGeometry3D => ({ type: \"extrude\", ...o }),\r\n lathe: (o: ParamsOf<LatheGeometry3D>): LatheGeometry3D => ({ type: \"lathe\", ...o }),\r\n tube: (o: ParamsOf<TubeGeometry3D>): TubeGeometry3D => ({ type: \"tube\", ...o }),\r\n\r\n /** Raw vertex buffers — any mesh you can compute. */\r\n buffer: (o: ParamsOf<BufferGeometry3D>): BufferGeometry3D => ({ type: \"buffer\", ...o }),\r\n /** A surface sampled over a `[0,1]²` grid. Sugar over {@link Geo.buffer}. */\r\n parametric: (o: ParamsOf<ParametricGeometry3D>): ParametricGeometry3D => ({ type: \"parametric\", ...o }),\r\n\r\n /** The hard edges of another geometry — a clean outline, no triangulation diagonals. */\r\n edges: (source: Geometry3D, o?: Omit<ParamsOf<EdgesGeometry3D>, \"source\">): EdgesGeometry3D =>\r\n ({ type: \"edges\", source, ...o }),\r\n /** Every triangle edge of another geometry. */\r\n wireframe: (source: Geometry3D): WireframeGeometry3D => ({ type: \"wireframe\", source }),\r\n\r\n model: (src: string, o?: Omit<ParamsOf<ModelGeometry3D>, \"src\">): ModelGeometry3D =>\r\n ({ type: \"modelGeometry\", src, ...o }),\r\n} as const;\r\n\r\n/**\r\n * Material descriptors.\r\n *\r\n * Like geometries these are shareable values — one hoisted material across many\r\n * meshes compiles one shader program instead of N.\r\n *\r\n * Reach for {@link Mat.standard} by default; {@link Mat.physical} only when a\r\n * surface actually needs clearcoat, transmission, sheen or iridescence, since\r\n * those cost more per pixel. {@link Mat.shader} is the full-control escape hatch.\r\n */\r\nexport const Mat = {\r\n basic: (o?: ParamsOf<BasicMaterial3D>): BasicMaterial3D => ({ type: \"basic\", ...o }),\r\n standard: (o?: ParamsOf<StandardMaterial3D>): StandardMaterial3D => ({ type: \"standard\", ...o }),\r\n physical: (o?: ParamsOf<PhysicalMaterial3D>): PhysicalMaterial3D => ({ type: \"physical\", ...o }),\r\n phong: (o?: ParamsOf<PhongMaterial3D>): PhongMaterial3D => ({ type: \"phong\", ...o }),\r\n lambert: (o?: ParamsOf<LambertMaterial3D>): LambertMaterial3D => ({ type: \"lambert\", ...o }),\r\n toon: (o?: ParamsOf<ToonMaterial3D>): ToonMaterial3D => ({ type: \"toon\", ...o }),\r\n normal: (o?: ParamsOf<NormalMaterial3D>): NormalMaterial3D => ({ type: \"normal\", ...o }),\r\n depth: (o?: ParamsOf<DepthMaterial3D>): DepthMaterial3D => ({ type: \"depth\", ...o }),\r\n matcap: (o?: ParamsOf<MatcapMaterial3D>): MatcapMaterial3D => ({ type: \"matcap\", ...o }),\r\n points: (o?: ParamsOf<PointsMaterial3D>): PointsMaterial3D => ({ type: \"points\", ...o }),\r\n lineBasic: (o?: ParamsOf<LineBasicMaterial3D>): LineBasicMaterial3D => ({ type: \"lineBasic\", ...o }),\r\n lineDashed: (o?: ParamsOf<LineDashedMaterial3D>): LineDashedMaterial3D => ({ type: \"lineDashed\", ...o }),\r\n sprite: (o?: ParamsOf<SpriteMaterial3D>): SpriteMaterial3D => ({ type: \"sprite\", ...o }),\r\n shadow: (o?: ParamsOf<ShadowMaterial3D>): ShadowMaterial3D => ({ type: \"shadow\", ...o }),\r\n /** Raw GLSL. Uniform *values* are free to animate; source changes recompile. */\r\n shader: (o: ParamsOf<ShaderMaterial3D>): ShaderMaterial3D => ({ type: \"shader\", ...o }),\r\n} as const;\r\n\r\n/**\r\n * Texture descriptors.\r\n *\r\n * {@link Tex.image} takes a manifest path and is loaded through core's ordinary\r\n * image pipeline, so the pixels are resident before the frame that needs them\r\n * draws. A bare string works anywhere a texture is expected, so `Tex.image` is\r\n * only needed when passing sampler options.\r\n */\r\nexport const Tex = {\r\n image: (src: string, o?: TextureOptions3D): ImageTexture3D => ({ src, ...o }),\r\n /** A texture from raw RGBA8888 bytes — gradient ramps, noise, LUTs. */\r\n data: (\r\n data: ArrayLike<number>,\r\n width: number,\r\n height: number,\r\n o?: TextureOptions3D & { revision?: number },\r\n ): DataTexture3D => ({ data, width, height, ...o }),\r\n /**\r\n * A texture painted from Motion Script's own 2D output — the bridge from 2D\r\n * onto 3D geometry.\r\n *\r\n * `source` is a **value**: a built `Graphics2D` command list, or a `Node2D`\r\n * subtree for anything needing real layout, shaped `Text` or a loaded\r\n * `Image`. Both are passed directly; there is no name to match and nothing\r\n * has to be mounted anywhere in particular.\r\n *\r\n * const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);\r\n * g3.plane({ fill: scope }); // sized for you\r\n *\r\n * const stats = <Rect flow=\"vertical\" padding={48}><Text text=\"CPU\" /></Rect>;\r\n * g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });\r\n *\r\n * `width`/`height` are the buffer's resolution and default to 512. A source\r\n * handed straight to `fill` gets exactly this treatment with those defaults,\r\n * so the builder is only needed to pin a resolution or a sampler option.\r\n * **Hoist the source** rather than rebuilding it each frame — see\r\n * {@link SurfaceTexture3D}.\r\n */\r\n surface: (\r\n source: SurfaceSource3D,\r\n o?: TextureOptions3D & { width?: number; height?: number; maxPixelRatio?: number },\r\n ): SurfaceTexture3D => ({\r\n width: 512,\r\n height: 512,\r\n ...o,\r\n source,\r\n }),\r\n} as const;\r\n"]}
|
|
@@ -74,6 +74,12 @@ export type CameraData3D = PerspectiveCameraData3D | OrthographicCameraData3D;
|
|
|
74
74
|
* that orbit around it is set. Including it here would make every camera polar
|
|
75
75
|
* the moment it named a subject, silently discarding its `position`.
|
|
76
76
|
*/
|
|
77
|
+
/** What an unset polar field of an orbiting camera reads as. */
|
|
78
|
+
export declare const ORBIT_CAMERA_DEFAULTS: {
|
|
79
|
+
readonly orbit: 0;
|
|
80
|
+
readonly elevation: 0;
|
|
81
|
+
readonly distance: 10;
|
|
82
|
+
};
|
|
77
83
|
export declare function isOrbitCamera3D(camera: CameraData3D): boolean;
|
|
78
84
|
/**
|
|
79
85
|
* A camera's effective position and aim.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/render3d/camera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAkB,KAAK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camera.js
CHANGED
|
@@ -8,6 +8,8 @@ import { resolveVector3 } from "./vector3.js";
|
|
|
8
8
|
* that orbit around it is set. Including it here would make every camera polar
|
|
9
9
|
* the moment it named a subject, silently discarding its `position`.
|
|
10
10
|
*/
|
|
11
|
+
/** What an unset polar field of an orbiting camera reads as. */
|
|
12
|
+
export const ORBIT_CAMERA_DEFAULTS = { orbit: 0, elevation: 0, distance: 10 };
|
|
11
13
|
export function isOrbitCamera3D(camera) {
|
|
12
14
|
return camera.orbit !== undefined
|
|
13
15
|
|| camera.elevation !== undefined
|
|
@@ -36,12 +38,12 @@ export function resolveCameraPlacement(camera) {
|
|
|
36
38
|
lookAt: aim === undefined ? undefined : resolveVector3(aim),
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
|
-
const distance = camera.distance ??
|
|
40
|
-
const azimuth = ((camera.orbit ??
|
|
41
|
+
const distance = camera.distance ?? ORBIT_CAMERA_DEFAULTS.distance;
|
|
42
|
+
const azimuth = ((camera.orbit ?? ORBIT_CAMERA_DEFAULTS.orbit) * Math.PI) / 180;
|
|
41
43
|
// Just short of the pole: at exactly ±90° the view direction is parallel to
|
|
42
44
|
// the up vector and the look-at basis is undefined, which reads as the shot
|
|
43
45
|
// snapping to an arbitrary roll on the frame it crosses.
|
|
44
|
-
const elevation = (clamp(camera.elevation ??
|
|
46
|
+
const elevation = (clamp(camera.elevation ?? ORBIT_CAMERA_DEFAULTS.elevation, -89.9, 89.9) * Math.PI) / 180;
|
|
45
47
|
const horizontal = Math.cos(elevation) * distance;
|
|
46
48
|
return {
|
|
47
49
|
position: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/render3d/camera.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAmC,MAAM,WAAW,CAAC;AAuE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IAChD,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS;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D,MAAM,EAAE,MAAM;KACjB,CAAC;AACN,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,IAAY;IACnD,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3D,CAAC","sourcesContent":["import type { Passthrough3D } from \"./geometry\";\r\nimport type { Transform3D } from \"./transform\";\r\nimport { resolveVector3, type Vector3, type Vector3Input } from \"./vector3\";\r\n\r\n/**\r\n * What every camera has, whatever it projects with.\r\n *\r\n * A camera can be placed two ways and they are not redundant. The\r\n * {@link Transform3D} half — `position` plus `lookAt` — is right when the shot is\r\n * pinned to something, and it is what a camera inside a moving rig uses. The\r\n * polar half — {@link target}, {@link orbit}, {@link elevation},\r\n * {@link distance} — is right when the shot is *about* the subject, which is\r\n * most of the time, and it is the only one of the two that animates cleanly:\r\n *\r\n * cam().to({ data: { orbit: 160, elevation: 30 }, duration: 4 });\r\n *\r\n * Writing that same move through `position` means composing sines by hand every\r\n * frame, which is what every scene did before this existed.\r\n *\r\n * Setting any polar field derives `position` and `lookAt`, so the two halves are\r\n * never in force at once. See {@link resolveCameraPlacement}.\r\n */\r\nexport interface CameraCommon3D extends Transform3D, Passthrough3D {\r\n /** The point the camera looks at, and orbits around. Default origin. */\r\n target?: Vector3Input;\r\n /** Azimuth around {@link target}, in **degrees**. 0 looks down −Z. */\r\n orbit?: number;\r\n /** Angle above the horizon, in **degrees**. Clamped just short of vertical. */\r\n elevation?: number;\r\n /** Distance from {@link target}. */\r\n distance?: number;\r\n\r\n /**\r\n * Near and far clip planes.\r\n *\r\n * Both are derived from the scene's own bounds when omitted, which is right\r\n * far more often than any constant: too near a `far` clips the back of the\r\n * scene, too far a `near` destroys depth precision. Set them only to override.\r\n */\r\n near?: number;\r\n far?: number;\r\n /** Zoom factor applied on top of the projection. */\r\n zoom?: number;\r\n}\r\n\r\n/**\r\n * A perspective camera — converging rays, so distant things shrink. What you want\r\n * unless you specifically need the flat look of an orthographic projection.\r\n */\r\nexport interface PerspectiveCameraData3D extends CameraCommon3D {\r\n type: \"perspective\";\r\n /** Vertical field of view in **degrees**. Default 50. */\r\n fov?: number;\r\n}\r\n\r\n/**\r\n * An orthographic camera — parallel rays, so size is independent of distance.\r\n * For isometric views, technical diagrams and 2.5D layouts.\r\n *\r\n * {@link frustumHeight} sets the visible world height and derives the width from\r\n * the node's aspect ratio. An asymmetric frustum is a `params` override rather\r\n * than four more fields, because four explicit edges is a projection-matrix\r\n * feature rather than a framing one.\r\n */\r\nexport interface OrthographicCameraData3D extends CameraCommon3D {\r\n type: \"orthographic\";\r\n /** Visible world-space height; width follows the node's aspect. Default 10. */\r\n frustumHeight?: number;\r\n}\r\n\r\n/** Every camera a scene can be viewed through. Discriminated on `type`. */\r\nexport type CameraData3D = PerspectiveCameraData3D | OrthographicCameraData3D;\r\n\r\n/**\r\n * True when the camera is placed polar-ly.\r\n *\r\n * `target` is deliberately not part of this. It answers \"what am I looking at\",\r\n * which is meaningful on its own — it is `lookAt` under a name that reads right\r\n * beside `orbit` — and only becomes a *placement* once one of the three fields\r\n * that orbit around it is set. Including it here would make every camera polar\r\n * the moment it named a subject, silently discarding its `position`.\r\n */\r\n/** What an unset polar field of an orbiting camera reads as. */\r\nexport const ORBIT_CAMERA_DEFAULTS = { orbit: 0, elevation: 0, distance: 10 } as const;\r\n\r\nexport function isOrbitCamera3D(camera: CameraData3D): boolean {\r\n return camera.orbit !== undefined\r\n || camera.elevation !== undefined\r\n || camera.distance !== undefined;\r\n}\r\n\r\n/**\r\n * A camera's effective position and aim.\r\n *\r\n * One definition, shared by the renderer and by the editor's picking geometry —\r\n * two places computing \"where is the camera\" from the same descriptor is two\r\n * chances to disagree about what the author sees, and a gizmo drawn against a\r\n * camera nobody renders is worse than no gizmo.\r\n *\r\n * The polar fields win over `position`/`lookAt` when any of them is set, so the\r\n * two placements can never both be half-applied.\r\n */\r\nexport function resolveCameraPlacement(camera: CameraData3D): {\r\n position: Vector3;\r\n lookAt: Vector3 | undefined;\r\n} {\r\n const target = resolveVector3(camera.target ?? 0);\r\n\r\n if (!isOrbitCamera3D(camera)) {\r\n // `target` is the subject either way, so a camera placed by `position`\r\n // still aims at it — which is what makes `target` one idea rather than a\r\n // polar-only field with `lookAt` as its non-polar twin.\r\n const aim = camera.lookAt ?? camera.target;\r\n return {\r\n position: resolveVector3(camera.position ?? 0),\r\n lookAt: aim === undefined ? undefined : resolveVector3(aim),\r\n };\r\n }\r\n\r\n const distance = camera.distance ?? ORBIT_CAMERA_DEFAULTS.distance;\r\n const azimuth = ((camera.orbit ?? ORBIT_CAMERA_DEFAULTS.orbit) * Math.PI) / 180;\r\n // Just short of the pole: at exactly ±90° the view direction is parallel to\r\n // the up vector and the look-at basis is undefined, which reads as the shot\r\n // snapping to an arbitrary roll on the frame it crosses.\r\n const elevation = (clamp(camera.elevation ?? ORBIT_CAMERA_DEFAULTS.elevation, -89.9, 89.9) * Math.PI) / 180;\r\n\r\n const horizontal = Math.cos(elevation) * distance;\r\n\r\n return {\r\n position: {\r\n x: target.x + Math.sin(azimuth) * horizontal,\r\n y: target.y + Math.sin(elevation) * distance,\r\n z: target.z + Math.cos(azimuth) * horizontal,\r\n },\r\n lookAt: target,\r\n };\r\n}\r\n\r\nfunction clamp(value: number, low: number, high: number): number {\r\n return value < low ? low : value > high ? high : value;\r\n}\r\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Color } from "../attributes/shape/fill/color/parser.js";
|
|
2
2
|
import type { Fill } from "../attributes/shape/fill/chain.js";
|
|
3
|
+
import { looksLikeAssetPath } from "./texture.js";
|
|
3
4
|
import type { SurfaceSource3D, Texture3D } from "./texture.js";
|
|
5
|
+
export { looksLikeAssetPath };
|
|
4
6
|
/**
|
|
5
7
|
* What a surface is made of.
|
|
6
8
|
*
|
|
@@ -49,15 +51,6 @@ export interface Fill3DOptions {
|
|
|
49
51
|
* already able to do it.
|
|
50
52
|
*/
|
|
51
53
|
export declare function resolveFill3D(fill: Fill3D | undefined, options?: Fill3DOptions): ResolvedFill3D;
|
|
52
|
-
/**
|
|
53
|
-
* True for a string that names an asset rather than a colour.
|
|
54
|
-
*
|
|
55
|
-
* Leading `/` or `.` is a path by construction; otherwise the extension decides.
|
|
56
|
-
* A colour never matches either, and a bare name like `"wood"` is a colour —
|
|
57
|
-
* which is right, since an asset reference without a path or extension is not
|
|
58
|
-
* something the manifest could resolve either.
|
|
59
|
-
*/
|
|
60
|
-
export declare function looksLikeAssetPath(value: string): boolean;
|
|
61
54
|
/**
|
|
62
55
|
* Interpolate two fills.
|
|
63
56
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill3d.d.ts","sourceRoot":"","sources":["../../src/render3d/fill3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAoC,MAAM,sCAAsC,CAAC;AAEpG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAM1D,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,CAAC;AAEhE,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,GAAG,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC1B,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,GAAE,aAAkB,GAC5B,cAAc,CA2BhB;
|
|
1
|
+
{"version":3,"file":"fill3d.d.ts","sourceRoot":"","sources":["../../src/render3d/fill3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAoC,MAAM,sCAAsC,CAAC;AAEpG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAM1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,CAAC;AAEhE,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,GAAG,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC1B,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,GAAE,aAAkB,GAC5B,cAAc,CA2BhB;AAyED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOtE"}
|
package/dist/render3d/fill3d.js
CHANGED
|
@@ -5,6 +5,8 @@ import { lerpColor } from "../attributes/shape/fill/lerp.js";
|
|
|
5
5
|
// `render/graphics2d` reaches only the *effects* chain at runtime, never back
|
|
6
6
|
// into `render3d` — see the note on `SurfaceSource3D`.
|
|
7
7
|
import { Graphics2D } from "../render/graphics2d.js";
|
|
8
|
+
import { looksLikeAssetPath } from "./texture.js";
|
|
9
|
+
export { looksLikeAssetPath };
|
|
8
10
|
const DEFAULT_SIZE = 512;
|
|
9
11
|
/**
|
|
10
12
|
* Resolve a {@link Fill3D} into the material fields it describes.
|
|
@@ -93,19 +95,6 @@ function rasterized(fill, options) {
|
|
|
93
95
|
identity: `fill:${fillIdentity(fill)}:${width}x${height}`,
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
|
-
/**
|
|
97
|
-
* True for a string that names an asset rather than a colour.
|
|
98
|
-
*
|
|
99
|
-
* Leading `/` or `.` is a path by construction; otherwise the extension decides.
|
|
100
|
-
* A colour never matches either, and a bare name like `"wood"` is a colour —
|
|
101
|
-
* which is right, since an asset reference without a path or extension is not
|
|
102
|
-
* something the manifest could resolve either.
|
|
103
|
-
*/
|
|
104
|
-
export function looksLikeAssetPath(value) {
|
|
105
|
-
return value.startsWith("/")
|
|
106
|
-
|| value.startsWith(".")
|
|
107
|
-
|| /\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);
|
|
108
|
-
}
|
|
109
98
|
/** True for a `Texture3D` descriptor object (not a source value). */
|
|
110
99
|
function isTextureDescriptor(value) {
|
|
111
100
|
return "src" in value || "data" in value || ("source" in value && "width" in value);
|