@pibbl/core 0.0.1 → 0.0.3-alpha.85.1
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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +81 -0
- package/dist/features/machines/animation.d.ts +64 -0
- package/dist/features/machines/animation.js +55 -0
- package/dist/features/machines/animation.js.map +7 -0
- package/dist/features/machines/animation.mjs +1 -0
- package/dist/features/machines/assign.d.ts +16 -0
- package/dist/features/machines/assign.js +15 -0
- package/dist/features/machines/assign.js.map +7 -0
- package/dist/features/machines/callback.d.ts +9 -0
- package/dist/features/machines/callback.js +7 -0
- package/dist/features/machines/callback.js.map +7 -0
- package/dist/features/machines/hook.d.ts +30 -0
- package/dist/features/machines/hook.js +37 -0
- package/dist/features/machines/hook.js.map +7 -0
- package/dist/features/machines/index.d.ts +6 -0
- package/dist/features/machines/index.js +12 -0
- package/dist/features/machines/index.js.map +7 -0
- package/dist/features/machines/index.mjs +1 -0
- package/dist/features/machines/runtime.d.ts +18 -0
- package/dist/features/machines/runtime.js +363 -0
- package/dist/features/machines/runtime.js.map +7 -0
- package/dist/features/machines/types.d.ts +164 -0
- package/dist/features/physics/2d-geometry.d.ts +3 -3
- package/dist/features/physics/2d-geometry.js.map +1 -1
- package/dist/features/physics/2d.d.ts +115 -62
- package/dist/features/physics/2d.js +59 -28
- package/dist/features/physics/2d.js.map +2 -2
- package/dist/features/physics/lib/2d/query-types.d.ts +6 -0
- package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
- package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
- package/dist/features/physics/lib/2d/types.d.ts +8 -30
- package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
- package/dist/features/physics/lib/2d/world/queries.js.map +2 -2
- package/dist/features/sprites/formats/aseprite.d.ts +5 -0
- package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
- package/dist/features/sprites/index.d.ts +6 -0
- package/dist/features/sprites/loader.d.ts +25 -0
- package/dist/features/sprites/model.d.ts +75 -0
- package/dist/features/sprites/sprite.d.ts +22 -0
- package/dist/features/textures/index.d.ts +12 -2
- package/dist/features/textures/index.js +33 -1
- package/dist/features/textures/index.js.map +2 -2
- package/dist/features/textures/lib/chemical-field.d.ts +56 -0
- package/dist/features/textures/lib/chemical-field.js +154 -0
- package/dist/features/textures/lib/chemical-field.js.map +7 -0
- package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
- package/dist/features/textures/lib/chemical-recipes.js +275 -0
- package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
- package/dist/features/textures/lib/definitions.d.ts +3 -18
- package/dist/features/textures/lib/definitions.js +15 -20
- package/dist/features/textures/lib/definitions.js.map +2 -2
- package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
- package/dist/features/textures/lib/geometric-patterns.js +305 -0
- package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
- package/dist/features/textures/lib/gray-scott.d.ts +55 -0
- package/dist/features/textures/lib/gray-scott.js +39 -0
- package/dist/features/textures/lib/gray-scott.js.map +7 -0
- package/dist/features/textures/lib/patterns.d.ts +123 -0
- package/dist/features/textures/lib/patterns.js +344 -0
- package/dist/features/textures/lib/patterns.js.map +7 -0
- package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
- package/dist/features/textures/lib/reaction-diffusion.js +9 -20
- package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
- package/dist/features/textures/lib/simulation.d.ts +10 -4
- package/dist/features/textures/lib/simulation.js +23 -13
- package/dist/features/textures/lib/simulation.js.map +2 -2
- package/dist/features/viz/index.d.ts +79 -5
- package/dist/features/viz/index.js +145 -4
- package/dist/features/viz/index.js.map +2 -2
- package/dist/features/viz/inspection/bar.d.ts +79 -0
- package/dist/features/viz/inspection/bar.js +49 -0
- package/dist/features/viz/inspection/bar.js.map +7 -0
- package/dist/features/viz/inspection/candle.d.ts +156 -0
- package/dist/features/viz/inspection/candle.js +120 -0
- package/dist/features/viz/inspection/candle.js.map +7 -0
- package/dist/features/viz/inspection/capture-types.d.ts +65 -0
- package/dist/features/viz/inspection/capture.d.ts +16 -0
- package/dist/features/viz/inspection/capture.js +49 -0
- package/dist/features/viz/inspection/capture.js.map +7 -0
- package/dist/features/viz/inspection/handler.d.ts +36 -0
- package/dist/features/viz/inspection/handler.js +91 -0
- package/dist/features/viz/inspection/handler.js.map +7 -0
- package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
- package/dist/features/viz/inspection/ohlc-bar.js +118 -0
- package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
- package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
- package/dist/features/viz/inspection/owned-ref.js +99 -0
- package/dist/features/viz/inspection/owned-ref.js.map +7 -0
- package/dist/features/viz/inspection/painted-point.d.ts +22 -0
- package/dist/features/viz/inspection/painted-point.js +29 -0
- package/dist/features/viz/inspection/painted-point.js.map +7 -0
- package/dist/features/viz/inspection/queries.d.ts +100 -0
- package/dist/features/viz/inspection/queries.js +192 -0
- package/dist/features/viz/inspection/queries.js.map +7 -0
- package/dist/features/viz/inspection/query-types.d.ts +177 -0
- package/dist/features/viz/inspection/volume.d.ts +104 -0
- package/dist/features/viz/inspection/volume.js +95 -0
- package/dist/features/viz/inspection/volume.js.map +7 -0
- package/dist/features/viz/inspection.d.ts +19 -0
- package/dist/features/viz/inspection.js +54 -0
- package/dist/features/viz/inspection.js.map +7 -0
- package/dist/features/viz/inspection.mjs +1 -0
- package/dist/features/viz/lib/area-series.d.ts +62 -0
- package/dist/features/viz/lib/area-series.js +120 -0
- package/dist/features/viz/lib/area-series.js.map +7 -0
- package/dist/features/viz/lib/axis-labels.d.ts +2 -0
- package/dist/features/viz/lib/axis-labels.js +41 -0
- package/dist/features/viz/lib/axis-labels.js.map +7 -0
- package/dist/features/viz/lib/axis-title.d.ts +23 -0
- package/dist/features/viz/lib/axis-title.js +23 -0
- package/dist/features/viz/lib/axis-title.js.map +7 -0
- package/dist/features/viz/lib/axis.d.ts +1 -1
- package/dist/features/viz/lib/axis.js +50 -50
- package/dist/features/viz/lib/axis.js.map +2 -2
- package/dist/features/viz/lib/bar-scale.d.ts +7 -0
- package/dist/features/viz/lib/bar-scale.js +34 -0
- package/dist/features/viz/lib/bar-scale.js.map +7 -0
- package/dist/features/viz/lib/bar-series.d.ts +3 -1
- package/dist/features/viz/lib/bar-series.js +21 -5
- package/dist/features/viz/lib/bar-series.js.map +2 -2
- package/dist/features/viz/lib/baseline-series.d.ts +55 -0
- package/dist/features/viz/lib/baseline-series.js +136 -0
- package/dist/features/viz/lib/baseline-series.js.map +7 -0
- package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
- package/dist/features/viz/lib/candlestick-series.js +150 -0
- package/dist/features/viz/lib/candlestick-series.js.map +7 -0
- package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
- package/dist/features/viz/lib/censored-point-series.js +129 -0
- package/dist/features/viz/lib/censored-point-series.js.map +7 -0
- package/dist/features/viz/lib/chart-lines.d.ts +41 -0
- package/dist/features/viz/lib/chart-lines.js +32 -0
- package/dist/features/viz/lib/chart-lines.js.map +7 -0
- package/dist/features/viz/lib/color-context.d.ts +4 -0
- package/dist/features/viz/lib/color-context.js +41 -0
- package/dist/features/viz/lib/color-context.js.map +7 -0
- package/dist/features/viz/lib/color-math.d.ts +4 -0
- package/dist/features/viz/lib/color-math.js +31 -0
- package/dist/features/viz/lib/color-math.js.map +7 -0
- package/dist/features/viz/lib/color-types.d.ts +53 -0
- package/dist/features/viz/lib/curve-definition.d.ts +49 -0
- package/dist/features/viz/lib/curve-definition.js +148 -0
- package/dist/features/viz/lib/curve-definition.js.map +7 -0
- package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/diverging-color-scale.js +51 -0
- package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
- package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
- package/dist/features/viz/lib/domain-navigation.js +77 -0
- package/dist/features/viz/lib/domain-navigation.js.map +7 -0
- package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
- package/dist/features/viz/lib/editable-chart-elements.js +733 -0
- package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
- package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
- package/dist/features/viz/lib/financial-aggregation.js +116 -0
- package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
- package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
- package/dist/features/viz/lib/financial-autoscale.js +61 -0
- package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
- package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
- package/dist/features/viz/lib/financial-comparison.js +98 -0
- package/dist/features/viz/lib/financial-comparison.js.map +7 -0
- package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
- package/dist/features/viz/lib/financial-geometry.js +67 -0
- package/dist/features/viz/lib/financial-geometry.js.map +7 -0
- package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
- package/dist/features/viz/lib/financial-indicators.js +135 -0
- package/dist/features/viz/lib/financial-indicators.js.map +7 -0
- package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
- package/dist/features/viz/lib/financial-oscillators.js +265 -0
- package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
- package/dist/features/viz/lib/hover-data.d.ts +1 -1
- package/dist/features/viz/lib/hover-data.js +6 -3
- package/dist/features/viz/lib/hover-data.js.map +2 -2
- package/dist/features/viz/lib/hover-types.d.ts +5 -5
- package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
- package/dist/features/viz/lib/interval-band-series.js +136 -0
- package/dist/features/viz/lib/interval-band-series.js.map +7 -0
- package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
- package/dist/features/viz/lib/interval-diamond-series.js +124 -0
- package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
- package/dist/features/viz/lib/interval-series.d.ts +79 -0
- package/dist/features/viz/lib/interval-series.js +158 -0
- package/dist/features/viz/lib/interval-series.js.map +7 -0
- package/dist/features/viz/lib/line-series.d.ts +1 -1
- package/dist/features/viz/lib/line-series.js +47 -28
- package/dist/features/viz/lib/line-series.js.map +2 -2
- package/dist/features/viz/lib/linear-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/linear-scale-component.js +18 -0
- package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
- package/dist/features/viz/lib/linear-scale.js +1 -1
- package/dist/features/viz/lib/linear-scale.js.map +2 -2
- package/dist/features/viz/lib/log-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/log-scale-component.js +19 -0
- package/dist/features/viz/lib/log-scale-component.js.map +7 -0
- package/dist/features/viz/lib/log-scale.d.ts +2 -0
- package/dist/features/viz/lib/log-scale.js +53 -0
- package/dist/features/viz/lib/log-scale.js.map +7 -0
- package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
- package/dist/features/viz/lib/monotone-curve.js +63 -0
- package/dist/features/viz/lib/monotone-curve.js.map +7 -0
- package/dist/features/viz/lib/nearest.d.ts +9 -9
- package/dist/features/viz/lib/nearest.js.map +1 -1
- package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
- package/dist/features/viz/lib/numeric-ticks.d.ts +38 -0
- package/dist/features/viz/lib/numeric-ticks.js +54 -0
- package/dist/features/viz/lib/numeric-ticks.js.map +7 -0
- package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
- package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
- package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
- package/dist/features/viz/lib/paired-series.d.ts +44 -0
- package/dist/features/viz/lib/paired-series.js +93 -0
- package/dist/features/viz/lib/paired-series.js.map +7 -0
- package/dist/features/viz/lib/plot-series.js +11 -6
- package/dist/features/viz/lib/plot-series.js.map +2 -2
- package/dist/features/viz/lib/plot-types.d.ts +4 -3
- package/dist/features/viz/lib/point-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/point-scale-component.js +19 -0
- package/dist/features/viz/lib/point-scale-component.js.map +7 -0
- package/dist/features/viz/lib/point-scale.d.ts +2 -0
- package/dist/features/viz/lib/point-scale.js +45 -0
- package/dist/features/viz/lib/point-scale.js.map +7 -0
- package/dist/features/viz/lib/point-series.d.ts +1 -1
- package/dist/features/viz/lib/point-series.js +36 -9
- package/dist/features/viz/lib/point-series.js.map +2 -2
- package/dist/features/viz/lib/point-types.d.ts +5 -2
- package/dist/features/viz/lib/reference-band.d.ts +16 -0
- package/dist/features/viz/lib/reference-band.js +27 -0
- package/dist/features/viz/lib/reference-band.js.map +7 -0
- package/dist/features/viz/lib/scale-adjust.js +9 -4
- package/dist/features/viz/lib/scale-adjust.js.map +2 -2
- package/dist/features/viz/lib/scale-context.d.ts +5 -4
- package/dist/features/viz/lib/scale-context.js +15 -11
- package/dist/features/viz/lib/scale-context.js.map +2 -2
- package/dist/features/viz/lib/scale-provider.d.ts +2 -0
- package/dist/features/viz/lib/scale-provider.js +13 -0
- package/dist/features/viz/lib/scale-provider.js.map +7 -0
- package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
- package/dist/features/viz/lib/scale-ticks.js +64 -0
- package/dist/features/viz/lib/scale-ticks.js.map +7 -0
- package/dist/features/viz/lib/scale-view.d.ts +4 -0
- package/dist/features/viz/lib/scale-view.js +21 -0
- package/dist/features/viz/lib/scale-view.js.map +7 -0
- package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/sequential-color-scale.js +49 -0
- package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
- package/dist/features/viz/lib/series-position.d.ts +12 -0
- package/dist/features/viz/lib/series-position.js +44 -0
- package/dist/features/viz/lib/series-position.js.map +7 -0
- package/dist/features/viz/lib/step-curves.d.ts +19 -0
- package/dist/features/viz/lib/step-curves.js +53 -0
- package/dist/features/viz/lib/step-curves.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/symlog-scale-component.js +19 -0
- package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
- package/dist/features/viz/lib/symlog-scale.js +38 -0
- package/dist/features/viz/lib/symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
- package/dist/features/viz/lib/threshold-color-scale.js +59 -0
- package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
- package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
- package/dist/features/viz/lib/trading-time-mapping.js +89 -0
- package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
- package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
- package/dist/features/viz/lib/trading-time-scale.js +96 -0
- package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
- package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
- package/dist/features/viz/lib/trajectory-series.js +111 -0
- package/dist/features/viz/lib/trajectory-series.js.map +7 -0
- package/dist/features/viz/lib/types.d.ts +114 -21
- package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-bar-scale.js +9 -0
- package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
- package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-continuous-scale.js +14 -0
- package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
- package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-linear-scale.js +9 -0
- package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
- package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-log-scale.js +9 -0
- package/dist/features/viz/lib/use-log-scale.js.map +7 -0
- package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-point-scale.js +9 -0
- package/dist/features/viz/lib/use-point-scale.js.map +7 -0
- package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-symlog-scale.js +9 -0
- package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-utc-scale.js +9 -0
- package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
- package/dist/features/viz/lib/utc-labels.d.ts +12 -0
- package/dist/features/viz/lib/utc-labels.js +27 -0
- package/dist/features/viz/lib/utc-labels.js.map +7 -0
- package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/utc-scale-component.js +18 -0
- package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
- package/dist/features/viz/lib/utc-scale.d.ts +21 -0
- package/dist/features/viz/lib/utc-scale.js +123 -0
- package/dist/features/viz/lib/utc-scale.js.map +7 -0
- package/dist/features/viz/lib/volume-series.d.ts +59 -0
- package/dist/features/viz/lib/volume-series.js +117 -0
- package/dist/features/viz/lib/volume-series.js.map +7 -0
- package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
- package/dist/features/viz/lib/weighted-point-series.js +169 -0
- package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
- package/dist/filters/emboss-gpu.d.ts +4 -0
- package/dist/filters/emboss-gpu.js +39 -0
- package/dist/filters/emboss-gpu.js.map +7 -0
- package/dist/filters/emboss.d.ts +32 -0
- package/dist/filters/emboss.js +106 -0
- package/dist/filters/emboss.js.map +7 -0
- package/dist/filters/reflection-gpu.d.ts +3 -1
- package/dist/filters/reflection-gpu.js +5 -2
- package/dist/filters/reflection-gpu.js.map +2 -2
- package/dist/filters/render-emboss-boundary.d.ts +13 -0
- package/dist/filters/render-emboss-boundary.js +131 -0
- package/dist/filters/render-emboss-boundary.js.map +7 -0
- package/dist/filters.d.ts +2 -0
- package/dist/filters.js +2 -0
- package/dist/filters.js.map +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +2 -2
- package/dist/lib/animation/definition.d.ts +5 -3
- package/dist/lib/animation/definition.js +29 -4
- package/dist/lib/animation/definition.js.map +2 -2
- package/dist/lib/animation/playback.d.ts +8 -0
- package/dist/lib/animation/playback.js +33 -11
- package/dist/lib/animation/playback.js.map +2 -2
- package/dist/lib/animation/spring.d.ts +3 -1
- package/dist/lib/animation/spring.js.map +2 -2
- package/dist/lib/animation/types.d.ts +29 -73
- package/dist/lib/events/event-facade.d.ts +13 -0
- package/dist/lib/events/event-facade.js +23 -0
- package/dist/lib/events/event-facade.js.map +2 -2
- package/dist/lib/events/propagation.js +19 -14
- package/dist/lib/events/propagation.js.map +2 -2
- package/dist/lib/execute-render.js +13 -0
- package/dist/lib/execute-render.js.map +2 -2
- package/dist/lib/hooks/use-animated-value.d.ts +11 -21
- package/dist/lib/hooks/use-animated-value.js +23 -70
- package/dist/lib/hooks/use-animated-value.js.map +3 -3
- package/dist/lib/hooks/use-playback.js +1 -0
- package/dist/lib/hooks/use-playback.js.map +2 -2
- package/dist/lib/recording/recording.d.ts +43 -0
- package/dist/lib/recording/recording.js +555 -0
- package/dist/lib/recording/recording.js.map +7 -0
- package/dist/lib/recording/types.d.ts +118 -0
- package/dist/lib/recording/wasm-bytes.d.ts +1 -0
- package/dist/lib/recording/wasm-bytes.js +5 -0
- package/dist/lib/recording/wasm-bytes.js.map +7 -0
- package/dist/lib/recording/worker-source.d.ts +1 -0
- package/dist/lib/recording/worker-source.js +5 -0
- package/dist/lib/recording/worker-source.js.map +7 -0
- package/dist/lib/render-transaction.d.ts +5 -2
- package/dist/lib/render-transaction.js +23 -1
- package/dist/lib/render-transaction.js.map +2 -2
- package/dist/lib/series-inspection-frame.d.ts +18 -0
- package/dist/lib/series-inspection-frame.js +70 -0
- package/dist/lib/series-inspection-frame.js.map +7 -0
- package/dist/lib/types.d.ts +6 -0
- package/package.json +27 -5
- package/dist/features/viz/lib/scale.d.ts +0 -11
- package/dist/features/viz/lib/scale.js +0 -80
- package/dist/features/viz/lib/scale.js.map +0 -7
- package/dist/features/viz/lib/use-scale.d.ts +0 -20
- package/dist/features/viz/lib/use-scale.js +0 -10
- package/dist/features/viz/lib/use-scale.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/features/physics/lib/2d/world/queries.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n boundsOfShape2D,\n type PibblPhysicsAabb2D,\n type PibblPhysicsPose2D,\n type PibblPhysicsRay2D,\n type PibblPhysicsShape2D,\n type PibblPhysicsVector2,\n} from \"../../../2d-geometry.js\";\nimport { copyFiniteVector2, requireNonnegativeNumber } from \"../../shared/validation.js\";\nimport { containsPointInShape2D, overlapPreparedShapes2D } from \"../collision/pairs.js\";\nimport { raycastShape2D, shapeCastAgainstShape2D } from \"../collision/casts.js\";\nimport { RADIANS_TO_DEGREES } from \"../numeric-policy.js\";\nimport { createShape2D, type ShapeRecord2D } from \"../shape-records.js\";\nimport type {\n PibblPhysicsBodyHandle2D,\n PibblPhysicsColliderHandle2D,\n PibblPhysicsCollisionFilter,\n PibblPhysicsQueryHit2D,\n PibblPhysicsQueryMatch2D,\n PibblPhysicsQueryMode,\n PibblPhysicsQueryOptions2D,\n PibblPhysicsQueryResult2D,\n} from \"../types.js\";\nimport type { DynamicAabbBroadPhase2D } from \"./broad-phase.js\";\nimport { collisionFiltersAllow2D } from \"./ccd.js\";\nimport { COLLIDER_SENSOR_2D } from \"./contact-cache.js\";\nimport type { BodyStore2D, ColliderStore2D } from \"./storage.js\";\n\ninterface HandleIdentity2D {\n readonly index: number;\n readonly generation: number;\n}\n\nexport interface CommittedWorldQueriesOptions2D {\n readonly generation: number;\n readonly bodies: BodyStore2D;\n readonly colliders: ColliderStore2D;\n readonly broadPhase: DynamicAabbBroadPhase2D;\n readonly materializeBody: (index: number, generation: number) => PibblPhysicsBodyHandle2D;\n readonly materializeCollider: (index: number, generation: number) => PibblPhysicsColliderHandle2D;\n readonly resolveBody: (handle: PibblPhysicsBodyHandle2D) => HandleIdentity2D | null;\n readonly resolveCollider: (handle: PibblPhysicsColliderHandle2D) => HandleIdentity2D | null;\n}\n\ninterface PreparedQueryOptions2D {\n readonly mode: PibblPhysicsQueryMode;\n readonly sensors: \"include\" | \"exclude\" | \"only\";\n readonly collisionFilter: PibblPhysicsCollisionFilter | null;\n readonly excludeBody: HandleIdentity2D | null;\n readonly excludeCollider: HandleIdentity2D | null;\n readonly valid: boolean;\n}\n\nexport class CommittedWorldQueries2D {\n private active = true;\n private candidateProxies: Int32Array;\n private hitColliderIndices: Int32Array;\n private hitColliderGenerations: Uint32Array;\n private hitBodyIndices: Int32Array;\n private hitBodyGenerations: Uint32Array;\n private hitPointX: Float64Array;\n private hitPointY: Float64Array;\n private hitNormalX: Float64Array;\n private hitNormalY: Float64Array;\n private hitDistances: Float64Array;\n private hitTimes: Float64Array;\n private hitCount = 0;\n private readonly shapeShells = new WeakMap<ShapeRecord2D, PibblPhysicsShape2D>();\n\n constructor(private readonly options: CommittedWorldQueriesOptions2D) {\n const capacity = normalizedCapacity(options.broadPhase.proxyCapacity);\n this.candidateProxies = new Int32Array(capacity);\n this.hitColliderIndices = new Int32Array(capacity);\n this.hitColliderGenerations = new Uint32Array(capacity);\n this.hitBodyIndices = new Int32Array(capacity);\n this.hitBodyGenerations = new Uint32Array(capacity);\n this.hitPointX = new Float64Array(capacity);\n this.hitPointY = new Float64Array(capacity);\n this.hitNormalX = new Float64Array(capacity);\n this.hitNormalY = new Float64Array(capacity);\n this.hitDistances = new Float64Array(capacity);\n this.hitTimes = new Float64Array(capacity);\n }\n\n invalidate(): void {\n this.active = false;\n this.hitCount = 0;\n }\n\n raycast<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n ray: PibblPhysicsRay2D,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const origin = copyFiniteVector2(ray.origin, \"ray.origin\");\n const direction = copyFiniteVector2(ray.direction, \"ray.direction\");\n const directionLength = Math.hypot(direction[0], direction[1]);\n if (directionLength === 0) throw new RangeError(\"ray.direction must be non-zero.\");\n const maxDistance = requireNonnegativeNumber(ray.maxDistance, \"ray.maxDistance\");\n const endX = origin[0] + (direction[0] / directionLength) * maxDistance;\n const endY = origin[1] + (direction[1] / directionLength) * maxDistance;\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(origin[0], endX),\n Math.min(origin[1], endY),\n Math.max(origin[0], endX),\n Math.max(origin[1], endY),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = raycastShape2D(collider.shape, collider.pose, ray);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n shapeCast<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n from: PibblPhysicsPose2D,\n translation: PibblPhysicsVector2,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const copiedTranslation = copyFiniteVector2(translation, \"translation\");\n const start = boundsOfShape2D(shape, from);\n const end = boundsOfShape2D(shape, {\n position: [from.position[0] + copiedTranslation[0], from.position[1] + copiedTranslation[1]],\n rotationDegrees: from.rotationDegrees,\n });\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(start.min[0], end.min[0]),\n Math.min(start.min[1], end.min[1]),\n Math.max(start.max[0], end.max[0]),\n Math.max(start.max[1], end.max[1]),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = shapeCastAgainstShape2D(shape, from, copiedTranslation, collider.shape, collider.pose);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n overlapShape<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n pose: PibblPhysicsPose2D,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n const bounds = this.isGenerationLive(worldGeneration) ? boundsOfShape2D(shape, pose) : null;\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n overlapPreparedShapes2D(shape, pose, collider.shape, collider.pose),\n );\n }\n\n queryAabb<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyAabb(bounds);\n return this.runMatchQuery(worldGeneration, copied, queryOptions, (collider) => {\n const colliderBounds = boundsOfShape2D(collider.shape, collider.pose);\n return aabbsOverlap(copied, colliderBounds);\n });\n }\n\n queryPoint<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n point: PibblPhysicsVector2,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyFiniteVector2(point, \"point\");\n const bounds = Object.freeze({ min: copied, max: copied });\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n containsPointInShape2D(collider.shape, collider.pose, copied),\n );\n }\n\n private runMatchQuery<Mode extends PibblPhysicsQueryMode>(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D | null,\n queryOptions: PibblPhysicsQueryOptions2D<Mode> | undefined,\n matches: (collider: SemanticCollider2D) => boolean,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (bounds === null || !this.isUsable(worldGeneration, prepared)) {\n return emptyResult(prepared.mode);\n }\n this.beginQuery();\n const candidateCount = this.queryCandidates(bounds.min[0], bounds.min[1], bounds.max[0], bounds.max[1]);\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null || !matches(collider)) continue;\n if (prepared.mode === \"any\") {\n return true as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;\n }\n this.appendMatch(collider);\n }\n return this.finishMatches<Mode>(prepared.mode);\n }\n\n private prepareOptions<Mode extends PibblPhysicsQueryMode>(\n queryOptions: PibblPhysicsQueryOptions2D<Mode> | undefined,\n ): PreparedQueryOptions2D {\n const mode = modeOf(queryOptions);\n const sensors = queryOptions?.sensors ?? \"include\";\n if (sensors !== \"include\" && sensors !== \"exclude\" && sensors !== \"only\") {\n throw new RangeError(\"query sensors must be include, exclude, or only.\");\n }\n const excludeBody =\n queryOptions?.excludeBody === undefined ? null : this.options.resolveBody(queryOptions.excludeBody);\n const excludeCollider =\n queryOptions?.excludeCollider === undefined ? null : this.options.resolveCollider(queryOptions.excludeCollider);\n const validBody =\n queryOptions?.excludeBody === undefined ||\n (excludeBody !== null && this.options.bodies.has(excludeBody.index, excludeBody.generation));\n const validCollider =\n queryOptions?.excludeCollider === undefined ||\n (excludeCollider !== null && this.options.colliders.has(excludeCollider.index, excludeCollider.generation));\n return {\n mode,\n sensors,\n collisionFilter: queryOptions?.collisionFilter ?? null,\n excludeBody,\n excludeCollider,\n valid: validBody && validCollider,\n };\n }\n\n private isUsable(worldGeneration: number, prepared: PreparedQueryOptions2D): boolean {\n return this.isGenerationLive(worldGeneration) && prepared.valid;\n }\n\n private isGenerationLive(worldGeneration: number): boolean {\n return this.active && worldGeneration === this.options.generation;\n }\n\n private beginQuery(): void {\n this.hitCount = 0;\n this.ensureCapacity(this.options.broadPhase.proxyCapacity);\n }\n\n private queryCandidates(minX: number, minY: number, maxX: number, maxY: number): number {\n return this.options.broadPhase.queryAabbInto(\n minX,\n minY,\n maxX,\n maxY,\n this.candidateProxies,\n 0,\n this.candidateProxies.length,\n );\n }\n\n private semanticColliderAt(candidate: number, prepared: PreparedQueryOptions2D): SemanticCollider2D | null {\n const proxy = this.candidateProxies[candidate]!;\n const colliderIndex = this.options.broadPhase.proxyColliderIndices[proxy]!;\n const colliderGeneration = this.options.broadPhase.proxyColliderGenerations[proxy]!;\n const { colliders, bodies } = this.options;\n if (!colliders.has(colliderIndex, colliderGeneration)) return null;\n const bodyIndex = colliders.bodyIndices[colliderIndex]!;\n const bodyGeneration = colliders.bodyGenerations[colliderIndex]!;\n if (!bodies.has(bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeBody, bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeCollider, colliderIndex, colliderGeneration)) return null;\n const sensor = (colliders.flags[colliderIndex]! & COLLIDER_SENSOR_2D) !== 0;\n if (prepared.sensors === \"exclude\" && sensor) return null;\n if (prepared.sensors === \"only\" && !sensor) return null;\n if (\n prepared.collisionFilter !== null &&\n !collisionFiltersAllow2D(prepared.collisionFilter, colliders.filters[colliderIndex])\n )\n return null;\n const record = colliders.shapes[colliderIndex];\n if (record === null) return null;\n return {\n colliderIndex,\n colliderGeneration,\n bodyIndex,\n bodyGeneration,\n shape: this.shapeShell(record),\n pose: publicBodyOriginPose(bodies, bodyIndex),\n };\n }\n\n private appendHit(\n collider: SemanticCollider2D,\n point: PibblPhysicsVector2,\n normal: PibblPhysicsVector2,\n distance: number,\n time: number,\n ): void {\n const target = this.hitCount;\n this.writeIdentity(target, collider);\n this.hitPointX[target] = point[0];\n this.hitPointY[target] = point[1];\n this.hitNormalX[target] = normal[0];\n this.hitNormalY[target] = normal[1];\n this.hitDistances[target] = distance;\n this.hitTimes[target] = time;\n this.hitCount += 1;\n }\n\n private appendMatch(collider: SemanticCollider2D): void {\n this.writeIdentity(this.hitCount, collider);\n this.hitCount += 1;\n }\n\n private writeIdentity(target: number, collider: SemanticCollider2D): void {\n this.hitColliderIndices[target] = collider.colliderIndex;\n this.hitColliderGenerations[target] = collider.colliderGeneration;\n this.hitBodyIndices[target] = collider.bodyIndex;\n this.hitBodyGenerations[target] = collider.bodyGeneration;\n }\n\n private finishHits<Mode extends PibblPhysicsQueryMode>(\n mode: PibblPhysicsQueryMode,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D> {\n this.sortHits(true);\n if (mode === \"any\") {\n return false as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeHit(0)) as PibblPhysicsQueryResult2D<\n Mode,\n PibblPhysicsQueryHit2D\n >;\n }\n const results: PibblPhysicsQueryHit2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeHit(index));\n }\n return Object.freeze(results) as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n }\n\n private finishMatches<Mode extends PibblPhysicsQueryMode>(\n mode: PibblPhysicsQueryMode,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n this.sortHits(false);\n if (mode === \"any\") {\n return false as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeMatch(0)) as PibblPhysicsQueryResult2D<\n Mode,\n PibblPhysicsQueryMatch2D\n >;\n }\n const results: PibblPhysicsQueryMatch2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeMatch(index));\n }\n return Object.freeze(results) as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;\n }\n\n private materializeHit(index: number): PibblPhysicsQueryHit2D {\n return Object.freeze({\n ...this.materializeMatch(index),\n point: freezeVector(this.hitPointX[index]!, this.hitPointY[index]!),\n normal: freezeVector(this.hitNormalX[index]!, this.hitNormalY[index]!),\n distance: this.hitDistances[index]!,\n timeOfImpact: this.hitTimes[index]!,\n });\n }\n\n private materializeMatch(index: number): PibblPhysicsQueryMatch2D {\n const bodyIndex = this.hitBodyIndices[index]!;\n const bodyGeneration = this.hitBodyGenerations[index]!;\n const colliderIndex = this.hitColliderIndices[index]!;\n const colliderGeneration = this.hitColliderGenerations[index]!;\n return Object.freeze({\n body: this.options.materializeBody(bodyIndex, bodyGeneration),\n collider: this.options.materializeCollider(colliderIndex, colliderGeneration),\n bodyGeneration,\n colliderGeneration,\n tag: this.options.colliders.tags[colliderIndex],\n });\n }\n\n private sortHits(withDistance: boolean): void {\n for (let index = 1; index < this.hitCount; index += 1) {\n let current = index;\n while (current > 0 && this.compareHits(current, current - 1, withDistance) < 0) {\n this.swapHits(current, current - 1, withDistance);\n current -= 1;\n }\n }\n }\n\n private compareHits(first: number, second: number, withDistance: boolean): number {\n if (withDistance) {\n const time = this.hitTimes[first]! - this.hitTimes[second]!;\n if (time !== 0) return time;\n const distance = this.hitDistances[first]! - this.hitDistances[second]!;\n if (distance !== 0) return distance;\n }\n return (\n this.hitColliderIndices[first]! - this.hitColliderIndices[second]! ||\n this.hitColliderGenerations[first]! - this.hitColliderGenerations[second]!\n );\n }\n\n private swapHits(first: number, second: number, withDistance: boolean): void {\n swapInt32(this.hitColliderIndices, first, second);\n swapUint32(this.hitColliderGenerations, first, second);\n swapInt32(this.hitBodyIndices, first, second);\n swapUint32(this.hitBodyGenerations, first, second);\n if (!withDistance) return;\n swapFloat64(this.hitPointX, first, second);\n swapFloat64(this.hitPointY, first, second);\n swapFloat64(this.hitNormalX, first, second);\n swapFloat64(this.hitNormalY, first, second);\n swapFloat64(this.hitDistances, first, second);\n swapFloat64(this.hitTimes, first, second);\n }\n\n private shapeShell(record: ShapeRecord2D): PibblPhysicsShape2D {\n let shell = this.shapeShells.get(record);\n if (shell === undefined) {\n shell = createShape2D(record);\n this.shapeShells.set(record, shell);\n }\n return shell;\n }\n\n private ensureCapacity(required: number): void {\n if (required <= this.candidateProxies.length) return;\n const capacity = normalizedCapacity(required);\n this.candidateProxies = growInt32(this.candidateProxies, capacity);\n this.hitColliderIndices = growInt32(this.hitColliderIndices, capacity);\n this.hitColliderGenerations = growUint32(this.hitColliderGenerations, capacity);\n this.hitBodyIndices = growInt32(this.hitBodyIndices, capacity);\n this.hitBodyGenerations = growUint32(this.hitBodyGenerations, capacity);\n this.hitPointX = growFloat64(this.hitPointX, capacity);\n this.hitPointY = growFloat64(this.hitPointY, capacity);\n this.hitNormalX = growFloat64(this.hitNormalX, capacity);\n this.hitNormalY = growFloat64(this.hitNormalY, capacity);\n this.hitDistances = growFloat64(this.hitDistances, capacity);\n this.hitTimes = growFloat64(this.hitTimes, capacity);\n }\n}\n\ninterface SemanticCollider2D {\n readonly colliderIndex: number;\n readonly colliderGeneration: number;\n readonly bodyIndex: number;\n readonly bodyGeneration: number;\n readonly shape: PibblPhysicsShape2D;\n readonly pose: PibblPhysicsPose2D;\n}\n\nfunction modeOf<Mode extends PibblPhysicsQueryMode>(\n options: PibblPhysicsQueryOptions2D<Mode> | undefined,\n): PibblPhysicsQueryMode {\n const mode = options?.mode ?? \"closest\";\n if (mode !== \"closest\" && mode !== \"any\" && mode !== \"all\") {\n throw new RangeError(\"query mode must be closest, any, or all.\");\n }\n return mode;\n}\n\nfunction emptyResult<Mode extends PibblPhysicsQueryMode, Result>(\n mode: PibblPhysicsQueryMode,\n): PibblPhysicsQueryResult2D<Mode, Result> {\n return (mode === \"any\" ? false : mode === \"all\" ? Object.freeze([]) : null) as PibblPhysicsQueryResult2D<Mode, Result>;\n}\n\nfunction sameIdentity(identity: HandleIdentity2D | null, index: number, generation: number): boolean {\n return identity !== null && identity.index === index && identity.generation === generation;\n}\n\nfunction publicPose(x: number, y: number, rotationRadians: number): PibblPhysicsPose2D {\n return {\n position: [x, y],\n rotationDegrees: rotationRadians * RADIANS_TO_DEGREES,\n };\n}\n\nfunction publicBodyOriginPose(\n bodies: BodyStore2D,\n index: number,\n): PibblPhysicsPose2D {\n const rotationRadians = bodies.rotationRadians[index]!;\n const cosine = Math.cos(rotationRadians);\n const sine = Math.sin(rotationRadians);\n const localCenterX = bodies.localCenterX[index]!;\n const localCenterY = bodies.localCenterY[index]!;\n return publicPose(\n bodies.positionX[index]! - cosine * localCenterX + sine * localCenterY,\n bodies.positionY[index]! - sine * localCenterX - cosine * localCenterY,\n rotationRadians,\n );\n}\n\nfunction copyAabb(bounds: PibblPhysicsAabb2D): PibblPhysicsAabb2D {\n const min = copyFiniteVector2(bounds.min, \"bounds.min\");\n const max = copyFiniteVector2(bounds.max, \"bounds.max\");\n if (min[0] > max[0] || min[1] > max[1]) {\n throw new RangeError(\"bounds.min must not exceed bounds.max.\");\n }\n return Object.freeze({ min, max });\n}\n\nfunction aabbsOverlap(first: PibblPhysicsAabb2D, second: PibblPhysicsAabb2D): boolean {\n return (\n first.min[0] <= second.max[0] &&\n first.max[0] >= second.min[0] &&\n first.min[1] <= second.max[1] &&\n first.max[1] >= second.min[1]\n );\n}\n\nfunction freezeVector(x: number, y: number): PibblPhysicsVector2 {\n return Object.freeze([x, y] as const);\n}\n\nfunction normalizedCapacity(required: number): number {\n let capacity = 1;\n while (capacity < required) capacity *= 2;\n return capacity;\n}\n\nfunction growInt32(source: Int32Array, capacity: number): Int32Array {\n const result = new Int32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growUint32(source: Uint32Array, capacity: number): Uint32Array {\n const result = new Uint32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growFloat64(source: Float64Array, capacity: number): Float64Array {\n const result = new Float64Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction swapInt32(values: Int32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapUint32(values: Uint32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapFloat64(values: Float64Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,OAMK;AACP,SAAS,mBAAmB,gCAAgC;AAC5D,SAAS,wBAAwB,+BAA+B;AAChE,SAAS,gBAAgB,+BAA+B;AACxD,SAAS,0BAA0B;AACnC,SAAS,qBAAyC;AAYlD,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AA4B5B,MAAM,wBAAwB;AAAA,EAgBnC,YAA6B,SAAyC;AAAzC;AAC3B,UAAM,WAAW,mBAAmB,QAAQ,WAAW,aAAa;AACpE,SAAK,mBAAmB,IAAI,WAAW,QAAQ;AAC/C,SAAK,qBAAqB,IAAI,WAAW,QAAQ;AACjD,SAAK,yBAAyB,IAAI,YAAY,QAAQ;AACtD,SAAK,iBAAiB,IAAI,WAAW,QAAQ;AAC7C,SAAK,qBAAqB,IAAI,YAAY,QAAQ;AAClD,SAAK,YAAY,IAAI,aAAa,QAAQ;AAC1C,SAAK,YAAY,IAAI,aAAa,QAAQ;AAC1C,SAAK,aAAa,IAAI,aAAa,QAAQ;AAC3C,SAAK,aAAa,IAAI,aAAa,QAAQ;AAC3C,SAAK,eAAe,IAAI,aAAa,QAAQ;AAC7C,SAAK,WAAW,IAAI,aAAa,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I,MAAM;AACjB,SAAO;AACT;AAEA,SAAS,UAAU,QAAoB,OAAe,QAAsB;AAC1E,QAAM,QAAQ,OAAO,KAAK;AAC1B,SAAO,KAAK,IAAI,OAAO,MAAM;AAC7B,SAAO,MAAM,IAAI;AACnB;AAEA,SAAS,WAAW,QAAqB,OAAe,QAAsB;AAC5E,QAAM,QAAQ,OAAO,KAAK;AAC1B,SAAO,KAAK,IAAI,OAAO,MAAM;AAC7B,SAAO,MAAM,IAAI;AACnB;AAEA,SAAS,YAAY,QAAsB,OAAe,QAAsB;AAC9E,QAAM,QAAQ,OAAO,KAAK;AAC1B,SAAO,KAAK,IAAI,OAAO,MAAM;AAC7B,SAAO,MAAM,IAAI;AACnB;",
|
|
4
|
+
"sourcesContent": ["import type { QueryMode, QueryOptions, QueryResult } from '../query-types.js';\nimport {\n boundsOfShape2D,\n type PibblPhysicsAabb2D,\n type PibblPhysicsPose2D,\n type PibblPhysicsRay2D,\n type PibblPhysicsShape2D,\n type PibblPhysicsVector2,\n} from \"../../../2d-geometry.js\";\nimport { copyFiniteVector2, requireNonnegativeNumber } from \"../../shared/validation.js\";\nimport { containsPointInShape2D, overlapPreparedShapes2D } from \"../collision/pairs.js\";\nimport { raycastShape2D, shapeCastAgainstShape2D } from \"../collision/casts.js\";\nimport { RADIANS_TO_DEGREES } from \"../numeric-policy.js\";\nimport { createShape2D, type ShapeRecord2D } from \"../shape-records.js\";\nimport type {\n PibblPhysicsBodyHandle2D,\n PibblPhysicsColliderHandle2D,\n PibblPhysicsCollisionFilter,\n PibblPhysicsQueryHit2D,\n PibblPhysicsQueryMatch2D,\n} from \"../types.js\";\nimport type { DynamicAabbBroadPhase2D } from \"./broad-phase.js\";\nimport { collisionFiltersAllow2D } from \"./ccd.js\";\nimport { COLLIDER_SENSOR_2D } from \"./contact-cache.js\";\nimport type { BodyStore2D, ColliderStore2D } from \"./storage.js\";\n\ninterface HandleIdentity2D {\n readonly index: number;\n readonly generation: number;\n}\n\nexport interface CommittedWorldQueriesOptions2D {\n readonly generation: number;\n readonly bodies: BodyStore2D;\n readonly colliders: ColliderStore2D;\n readonly broadPhase: DynamicAabbBroadPhase2D;\n readonly materializeBody: (index: number, generation: number) => PibblPhysicsBodyHandle2D;\n readonly materializeCollider: (index: number, generation: number) => PibblPhysicsColliderHandle2D;\n readonly resolveBody: (handle: PibblPhysicsBodyHandle2D) => HandleIdentity2D | null;\n readonly resolveCollider: (handle: PibblPhysicsColliderHandle2D) => HandleIdentity2D | null;\n}\n\ninterface PreparedQueryOptions2D {\n readonly mode: QueryMode;\n readonly sensors: \"include\" | \"exclude\" | \"only\";\n readonly collisionFilter: PibblPhysicsCollisionFilter | null;\n readonly excludeBody: HandleIdentity2D | null;\n readonly excludeCollider: HandleIdentity2D | null;\n readonly valid: boolean;\n}\n\nexport class CommittedWorldQueries2D {\n private active = true;\n private candidateProxies: Int32Array;\n private hitColliderIndices: Int32Array;\n private hitColliderGenerations: Uint32Array;\n private hitBodyIndices: Int32Array;\n private hitBodyGenerations: Uint32Array;\n private hitPointX: Float64Array;\n private hitPointY: Float64Array;\n private hitNormalX: Float64Array;\n private hitNormalY: Float64Array;\n private hitDistances: Float64Array;\n private hitTimes: Float64Array;\n private hitCount = 0;\n private readonly shapeShells = new WeakMap<ShapeRecord2D, PibblPhysicsShape2D>();\n\n constructor(private readonly options: CommittedWorldQueriesOptions2D) {\n const capacity = normalizedCapacity(options.broadPhase.proxyCapacity);\n this.candidateProxies = new Int32Array(capacity);\n this.hitColliderIndices = new Int32Array(capacity);\n this.hitColliderGenerations = new Uint32Array(capacity);\n this.hitBodyIndices = new Int32Array(capacity);\n this.hitBodyGenerations = new Uint32Array(capacity);\n this.hitPointX = new Float64Array(capacity);\n this.hitPointY = new Float64Array(capacity);\n this.hitNormalX = new Float64Array(capacity);\n this.hitNormalY = new Float64Array(capacity);\n this.hitDistances = new Float64Array(capacity);\n this.hitTimes = new Float64Array(capacity);\n }\n\n invalidate(): void {\n this.active = false;\n this.hitCount = 0;\n }\n\n raycast<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n ray: PibblPhysicsRay2D,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const origin = copyFiniteVector2(ray.origin, \"ray.origin\");\n const direction = copyFiniteVector2(ray.direction, \"ray.direction\");\n const directionLength = Math.hypot(direction[0], direction[1]);\n if (directionLength === 0) throw new RangeError(\"ray.direction must be non-zero.\");\n const maxDistance = requireNonnegativeNumber(ray.maxDistance, \"ray.maxDistance\");\n const endX = origin[0] + (direction[0] / directionLength) * maxDistance;\n const endY = origin[1] + (direction[1] / directionLength) * maxDistance;\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(origin[0], endX),\n Math.min(origin[1], endY),\n Math.max(origin[0], endX),\n Math.max(origin[1], endY),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = raycastShape2D(collider.shape, collider.pose, ray);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n shapeCast<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n from: PibblPhysicsPose2D,\n translation: PibblPhysicsVector2,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const copiedTranslation = copyFiniteVector2(translation, \"translation\");\n const start = boundsOfShape2D(shape, from);\n const end = boundsOfShape2D(shape, {\n position: [from.position[0] + copiedTranslation[0], from.position[1] + copiedTranslation[1]],\n rotationDegrees: from.rotationDegrees,\n });\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(start.min[0], end.min[0]),\n Math.min(start.min[1], end.min[1]),\n Math.max(start.max[0], end.max[0]),\n Math.max(start.max[1], end.max[1]),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = shapeCastAgainstShape2D(shape, from, copiedTranslation, collider.shape, collider.pose);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n overlapShape<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n pose: PibblPhysicsPose2D,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n const bounds = this.isGenerationLive(worldGeneration) ? boundsOfShape2D(shape, pose) : null;\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n overlapPreparedShapes2D(shape, pose, collider.shape, collider.pose),\n );\n }\n\n queryAabb<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyAabb(bounds);\n return this.runMatchQuery(worldGeneration, copied, queryOptions, (collider) => {\n const colliderBounds = boundsOfShape2D(collider.shape, collider.pose);\n return aabbsOverlap(copied, colliderBounds);\n });\n }\n\n queryPoint<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n point: PibblPhysicsVector2,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyFiniteVector2(point, \"point\");\n const bounds = Object.freeze({ min: copied, max: copied });\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n containsPointInShape2D(collider.shape, collider.pose, copied),\n );\n }\n\n private runMatchQuery<Mode extends QueryMode>(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D | null,\n queryOptions: QueryOptions<Mode> | undefined,\n matches: (collider: SemanticCollider2D) => boolean,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (bounds === null || !this.isUsable(worldGeneration, prepared)) {\n return emptyResult(prepared.mode);\n }\n this.beginQuery();\n const candidateCount = this.queryCandidates(bounds.min[0], bounds.min[1], bounds.max[0], bounds.max[1]);\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null || !matches(collider)) continue;\n if (prepared.mode === \"any\") {\n return true as QueryResult<Mode, PibblPhysicsQueryMatch2D>;\n }\n this.appendMatch(collider);\n }\n return this.finishMatches<Mode>(prepared.mode);\n }\n\n private prepareOptions<Mode extends QueryMode>(\n queryOptions: QueryOptions<Mode> | undefined,\n ): PreparedQueryOptions2D {\n const mode = modeOf(queryOptions);\n const sensors = queryOptions?.sensors ?? \"include\";\n if (sensors !== \"include\" && sensors !== \"exclude\" && sensors !== \"only\") {\n throw new RangeError(\"query sensors must be include, exclude, or only.\");\n }\n const excludeBody =\n queryOptions?.excludeBody === undefined ? null : this.options.resolveBody(queryOptions.excludeBody);\n const excludeCollider =\n queryOptions?.excludeCollider === undefined ? null : this.options.resolveCollider(queryOptions.excludeCollider);\n const validBody =\n queryOptions?.excludeBody === undefined ||\n (excludeBody !== null && this.options.bodies.has(excludeBody.index, excludeBody.generation));\n const validCollider =\n queryOptions?.excludeCollider === undefined ||\n (excludeCollider !== null && this.options.colliders.has(excludeCollider.index, excludeCollider.generation));\n return {\n mode,\n sensors,\n collisionFilter: queryOptions?.collisionFilter ?? null,\n excludeBody,\n excludeCollider,\n valid: validBody && validCollider,\n };\n }\n\n private isUsable(worldGeneration: number, prepared: PreparedQueryOptions2D): boolean {\n return this.isGenerationLive(worldGeneration) && prepared.valid;\n }\n\n private isGenerationLive(worldGeneration: number): boolean {\n return this.active && worldGeneration === this.options.generation;\n }\n\n private beginQuery(): void {\n this.hitCount = 0;\n this.ensureCapacity(this.options.broadPhase.proxyCapacity);\n }\n\n private queryCandidates(minX: number, minY: number, maxX: number, maxY: number): number {\n return this.options.broadPhase.queryAabbInto(\n minX,\n minY,\n maxX,\n maxY,\n this.candidateProxies,\n 0,\n this.candidateProxies.length,\n );\n }\n\n private semanticColliderAt(candidate: number, prepared: PreparedQueryOptions2D): SemanticCollider2D | null {\n const proxy = this.candidateProxies[candidate]!;\n const colliderIndex = this.options.broadPhase.proxyColliderIndices[proxy]!;\n const colliderGeneration = this.options.broadPhase.proxyColliderGenerations[proxy]!;\n const { colliders, bodies } = this.options;\n if (!colliders.has(colliderIndex, colliderGeneration)) return null;\n const bodyIndex = colliders.bodyIndices[colliderIndex]!;\n const bodyGeneration = colliders.bodyGenerations[colliderIndex]!;\n if (!bodies.has(bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeBody, bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeCollider, colliderIndex, colliderGeneration)) return null;\n const sensor = (colliders.flags[colliderIndex]! & COLLIDER_SENSOR_2D) !== 0;\n if (prepared.sensors === \"exclude\" && sensor) return null;\n if (prepared.sensors === \"only\" && !sensor) return null;\n if (\n prepared.collisionFilter !== null &&\n !collisionFiltersAllow2D(prepared.collisionFilter, colliders.filters[colliderIndex])\n )\n return null;\n const record = colliders.shapes[colliderIndex];\n if (record === null) return null;\n return {\n colliderIndex,\n colliderGeneration,\n bodyIndex,\n bodyGeneration,\n shape: this.shapeShell(record),\n pose: publicBodyOriginPose(bodies, bodyIndex),\n };\n }\n\n private appendHit(\n collider: SemanticCollider2D,\n point: PibblPhysicsVector2,\n normal: PibblPhysicsVector2,\n distance: number,\n time: number,\n ): void {\n const target = this.hitCount;\n this.writeIdentity(target, collider);\n this.hitPointX[target] = point[0];\n this.hitPointY[target] = point[1];\n this.hitNormalX[target] = normal[0];\n this.hitNormalY[target] = normal[1];\n this.hitDistances[target] = distance;\n this.hitTimes[target] = time;\n this.hitCount += 1;\n }\n\n private appendMatch(collider: SemanticCollider2D): void {\n this.writeIdentity(this.hitCount, collider);\n this.hitCount += 1;\n }\n\n private writeIdentity(target: number, collider: SemanticCollider2D): void {\n this.hitColliderIndices[target] = collider.colliderIndex;\n this.hitColliderGenerations[target] = collider.colliderGeneration;\n this.hitBodyIndices[target] = collider.bodyIndex;\n this.hitBodyGenerations[target] = collider.bodyGeneration;\n }\n\n private finishHits<Mode extends QueryMode>(\n mode: QueryMode,\n ): QueryResult<Mode, PibblPhysicsQueryHit2D> {\n this.sortHits(true);\n if (mode === \"any\") {\n return false as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeHit(0)) as QueryResult<\n Mode,\n PibblPhysicsQueryHit2D\n >;\n }\n const results: PibblPhysicsQueryHit2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeHit(index));\n }\n return Object.freeze(results) as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n }\n\n private finishMatches<Mode extends QueryMode>(\n mode: QueryMode,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n this.sortHits(false);\n if (mode === \"any\") {\n return false as QueryResult<Mode, PibblPhysicsQueryMatch2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeMatch(0)) as QueryResult<\n Mode,\n PibblPhysicsQueryMatch2D\n >;\n }\n const results: PibblPhysicsQueryMatch2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeMatch(index));\n }\n return Object.freeze(results) as QueryResult<Mode, PibblPhysicsQueryMatch2D>;\n }\n\n private materializeHit(index: number): PibblPhysicsQueryHit2D {\n return Object.freeze({\n ...this.materializeMatch(index),\n point: freezeVector(this.hitPointX[index]!, this.hitPointY[index]!),\n normal: freezeVector(this.hitNormalX[index]!, this.hitNormalY[index]!),\n distance: this.hitDistances[index]!,\n timeOfImpact: this.hitTimes[index]!,\n });\n }\n\n private materializeMatch(index: number): PibblPhysicsQueryMatch2D {\n const bodyIndex = this.hitBodyIndices[index]!;\n const bodyGeneration = this.hitBodyGenerations[index]!;\n const colliderIndex = this.hitColliderIndices[index]!;\n const colliderGeneration = this.hitColliderGenerations[index]!;\n return Object.freeze({\n body: this.options.materializeBody(bodyIndex, bodyGeneration),\n collider: this.options.materializeCollider(colliderIndex, colliderGeneration),\n bodyGeneration,\n colliderGeneration,\n tag: this.options.colliders.tags[colliderIndex],\n });\n }\n\n private sortHits(withDistance: boolean): void {\n for (let index = 1; index < this.hitCount; index += 1) {\n let current = index;\n while (current > 0 && this.compareHits(current, current - 1, withDistance) < 0) {\n this.swapHits(current, current - 1, withDistance);\n current -= 1;\n }\n }\n }\n\n private compareHits(first: number, second: number, withDistance: boolean): number {\n if (withDistance) {\n const time = this.hitTimes[first]! - this.hitTimes[second]!;\n if (time !== 0) return time;\n const distance = this.hitDistances[first]! - this.hitDistances[second]!;\n if (distance !== 0) return distance;\n }\n return (\n this.hitColliderIndices[first]! - this.hitColliderIndices[second]! ||\n this.hitColliderGenerations[first]! - this.hitColliderGenerations[second]!\n );\n }\n\n private swapHits(first: number, second: number, withDistance: boolean): void {\n swapInt32(this.hitColliderIndices, first, second);\n swapUint32(this.hitColliderGenerations, first, second);\n swapInt32(this.hitBodyIndices, first, second);\n swapUint32(this.hitBodyGenerations, first, second);\n if (!withDistance) return;\n swapFloat64(this.hitPointX, first, second);\n swapFloat64(this.hitPointY, first, second);\n swapFloat64(this.hitNormalX, first, second);\n swapFloat64(this.hitNormalY, first, second);\n swapFloat64(this.hitDistances, first, second);\n swapFloat64(this.hitTimes, first, second);\n }\n\n private shapeShell(record: ShapeRecord2D): PibblPhysicsShape2D {\n let shell = this.shapeShells.get(record);\n if (shell === undefined) {\n shell = createShape2D(record);\n this.shapeShells.set(record, shell);\n }\n return shell;\n }\n\n private ensureCapacity(required: number): void {\n if (required <= this.candidateProxies.length) return;\n const capacity = normalizedCapacity(required);\n this.candidateProxies = growInt32(this.candidateProxies, capacity);\n this.hitColliderIndices = growInt32(this.hitColliderIndices, capacity);\n this.hitColliderGenerations = growUint32(this.hitColliderGenerations, capacity);\n this.hitBodyIndices = growInt32(this.hitBodyIndices, capacity);\n this.hitBodyGenerations = growUint32(this.hitBodyGenerations, capacity);\n this.hitPointX = growFloat64(this.hitPointX, capacity);\n this.hitPointY = growFloat64(this.hitPointY, capacity);\n this.hitNormalX = growFloat64(this.hitNormalX, capacity);\n this.hitNormalY = growFloat64(this.hitNormalY, capacity);\n this.hitDistances = growFloat64(this.hitDistances, capacity);\n this.hitTimes = growFloat64(this.hitTimes, capacity);\n }\n}\n\ninterface SemanticCollider2D {\n readonly colliderIndex: number;\n readonly colliderGeneration: number;\n readonly bodyIndex: number;\n readonly bodyGeneration: number;\n readonly shape: PibblPhysicsShape2D;\n readonly pose: PibblPhysicsPose2D;\n}\n\nfunction modeOf<Mode extends QueryMode>(\n options: QueryOptions<Mode> | undefined,\n): QueryMode {\n const mode = options?.mode ?? \"closest\";\n if (mode !== \"closest\" && mode !== \"any\" && mode !== \"all\") {\n throw new RangeError(\"query mode must be closest, any, or all.\");\n }\n return mode;\n}\n\nfunction emptyResult<Mode extends QueryMode, Result>(\n mode: QueryMode,\n): QueryResult<Mode, Result> {\n return (mode === \"any\" ? false : mode === \"all\" ? Object.freeze([]) : null) as QueryResult<Mode, Result>;\n}\n\nfunction sameIdentity(identity: HandleIdentity2D | null, index: number, generation: number): boolean {\n return identity !== null && identity.index === index && identity.generation === generation;\n}\n\nfunction publicPose(x: number, y: number, rotationRadians: number): PibblPhysicsPose2D {\n return {\n position: [x, y],\n rotationDegrees: rotationRadians * RADIANS_TO_DEGREES,\n };\n}\n\nfunction publicBodyOriginPose(\n bodies: BodyStore2D,\n index: number,\n): PibblPhysicsPose2D {\n const rotationRadians = bodies.rotationRadians[index]!;\n const cosine = Math.cos(rotationRadians);\n const sine = Math.sin(rotationRadians);\n const localCenterX = bodies.localCenterX[index]!;\n const localCenterY = bodies.localCenterY[index]!;\n return publicPose(\n bodies.positionX[index]! - cosine * localCenterX + sine * localCenterY,\n bodies.positionY[index]! - sine * localCenterX - cosine * localCenterY,\n rotationRadians,\n );\n}\n\nfunction copyAabb(bounds: PibblPhysicsAabb2D): PibblPhysicsAabb2D {\n const min = copyFiniteVector2(bounds.min, \"bounds.min\");\n const max = copyFiniteVector2(bounds.max, \"bounds.max\");\n if (min[0] > max[0] || min[1] > max[1]) {\n throw new RangeError(\"bounds.min must not exceed bounds.max.\");\n }\n return Object.freeze({ min, max });\n}\n\nfunction aabbsOverlap(first: PibblPhysicsAabb2D, second: PibblPhysicsAabb2D): boolean {\n return (\n first.min[0] <= second.max[0] &&\n first.max[0] >= second.min[0] &&\n first.min[1] <= second.max[1] &&\n first.max[1] >= second.min[1]\n );\n}\n\nfunction freezeVector(x: number, y: number): PibblPhysicsVector2 {\n return Object.freeze([x, y] as const);\n}\n\nfunction normalizedCapacity(required: number): number {\n let capacity = 1;\n while (capacity < required) capacity *= 2;\n return capacity;\n}\n\nfunction growInt32(source: Int32Array, capacity: number): Int32Array {\n const result = new Int32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growUint32(source: Uint32Array, capacity: number): Uint32Array {\n const result = new Uint32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growFloat64(source: Float64Array, capacity: number): Float64Array {\n const result = new Float64Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction swapInt32(values: Int32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapUint32(values: Uint32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapFloat64(values: Float64Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,OAMK;AACP,SAAS,mBAAmB,gCAAgC;AAC5D,SAAS,wBAAwB,+BAA+B;AAChE,SAAS,gBAAgB,+BAA+B;AACxD,SAAS,0BAA0B;AACnC,SAAS,qBAAyC;AASlD,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AA4B5B,MAAM,wBAAwB;AAAA,EAgBnC,YAA6B,SAAyC;AAAzC;AAC3B,UAAM,WAAW,mBAAmB,QAAQ,WAAW,aAAa;AACpE,SAAK,mBAAmB,IAAI,WAAW,QAAQ;AAC/C,SAAK,qBAAqB,IAAI,WAAW,QAAQ;AACjD,SAAK,yBAAyB,IAAI,YAAY,QAAQ;AACtD,SAAK,iBAAiB,IAAI,WAAW,QAAQ;AAC7C,SAAK,qBAAqB,IAAI,YAAY,QAAQ;AAClD,SAAK,YAAY,IAAI,aAAa,QAAQ;AAC1C,SAAK,YAAY,IAAI,aAAa,QAAQ;AAC1C,SAAK,aAAa,IAAI,aAAa,QAAQ;AAC3C,SAAK,aAAa,IAAI,aAAa,QAAQ;AAC3C,SAAK,eAAe,IAAI,aAAa,QAAQ;AAC7C,SAAK,WAAW,IAAI,aAAa,QAAQ;AAAA,EAC3C;AAAA,EAb6B;AAAA,EAfrB,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACF,cAAc,oBAAI,QAA4C;AAAA,EAiB/E,aAAmB;AACjB,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,QACE,iBACA,KACA,cAC2C;AAC3C,UAAM,WAAW,KAAK,eAAe,Y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,QAAM,QAAQ,OAAO,KAAK;AAC1B,SAAO,KAAK,IAAI,OAAO,MAAM;AAC7B,SAAO,MAAM,IAAI;AACnB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SpriteSheetFormat } from '../model.js';
|
|
2
|
+
/** Import Aseprite JSON hash or array exports, including frame tags and millisecond timing. See {@link SpriteSheetFormat}.
|
|
3
|
+
* @returns An explicit atlas metadata adapter.
|
|
4
|
+
*/
|
|
5
|
+
export declare function aseprite(): SpriteSheetFormat;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SpriteSheetFormat } from '../model.js';
|
|
2
|
+
/** Import TexturePacker JSON hash/array rectangles with clockwise packed rotation and trim offsets. See {@link SpriteSheetFormat}.
|
|
3
|
+
* @returns An explicit atlas metadata adapter.
|
|
4
|
+
*/
|
|
5
|
+
export declare function texturePacker(): SpriteSheetFormat;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Sprite } from './sprite.js';
|
|
2
|
+
export type { SpriteProps, SpriteStyle } from './sprite.js';
|
|
3
|
+
export { loadSpriteSheet } from './loader.js';
|
|
4
|
+
export type { SpriteSheet, SpriteGrid } from './loader.js';
|
|
5
|
+
export { defineSpriteAnimation } from './model.js';
|
|
6
|
+
export type { SpriteFrame, SpriteRectangle, SpriteFrameData, SpriteAnimationFrameData, SpriteSheetData, SpriteSheetFormat } from './model.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type SpriteFrame, type SpriteSheetFormat } from './model.js';
|
|
2
|
+
import type { PibblAnimationDefinition } from '../../lib/animation/types.js';
|
|
3
|
+
/** Shared decoded atlas and immutable frames/clips. Dispose after all consumers unmount. See {@link SpriteFrame}. */
|
|
4
|
+
export interface SpriteSheet {
|
|
5
|
+
/** Frames indexed by atlas name or numeric grid index. */ readonly frames: Readonly<Record<string | number, SpriteFrame>>;
|
|
6
|
+
/** Named, seekable animation definitions from the atlas. */ readonly animations: Readonly<Record<string, PibblAnimationDefinition<SpriteFrame>>>;
|
|
7
|
+
/** Release decoded images; unmount every consumer before calling. */ readonly dispose: () => void;
|
|
8
|
+
}
|
|
9
|
+
/** Dimensions of a regular grid, in image pixels. See {@link SpriteFrame}. */
|
|
10
|
+
export interface SpriteGrid {
|
|
11
|
+
readonly frameWidth: number; /** Positive cell height in pixels. */
|
|
12
|
+
readonly frameHeight: number; /** Outer border width in pixels; defaults to zero. */
|
|
13
|
+
readonly margin?: number; /** Gap between cells in pixels; defaults to zero. */
|
|
14
|
+
readonly spacing?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Load a grid image or metadata through an explicitly supplied import adapter. See {@link SpriteFrame}.
|
|
17
|
+
* @param url - Grid image URL or atlas metadata URL.
|
|
18
|
+
* @param options - Grid dimensions or an explicit metadata format adapter.
|
|
19
|
+
* @returns A decoded sprite sheet with explicit disposal ownership.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadSpriteSheet(url: string, options: {
|
|
22
|
+
readonly grid: SpriteGrid;
|
|
23
|
+
} | {
|
|
24
|
+
readonly format: SpriteSheetFormat;
|
|
25
|
+
}): Promise<SpriteSheet>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { PibblAnimationDefinition } from '../../lib/animation/types.js';
|
|
2
|
+
/** Pixel rectangle within an atlas page or original frame. See {@link SpriteFrame}. */
|
|
3
|
+
export interface SpriteRectangle {
|
|
4
|
+
readonly x: number; /** Vertical pixel offset. */
|
|
5
|
+
readonly y: number; /** Width in pixels. */
|
|
6
|
+
readonly width: number; /** Height in pixels. */
|
|
7
|
+
readonly height: number;
|
|
8
|
+
}
|
|
9
|
+
/** Normalized frame information returned by a format adapter. See {@link SpriteFrame}. */
|
|
10
|
+
export interface SpriteFrameData {
|
|
11
|
+
/** Unique frame name in this sheet. */ readonly name: string;
|
|
12
|
+
/** Zero-based atlas page index; defaults to zero. */ readonly page?: number;
|
|
13
|
+
/** Packed rectangle within the atlas page. */ readonly rect: SpriteRectangle;
|
|
14
|
+
/** Original frame dimensions before trimming. */ readonly sourceSize?: Readonly<{
|
|
15
|
+
width: number; /** Height in pixels. */
|
|
16
|
+
height: number;
|
|
17
|
+
}>;
|
|
18
|
+
/** Trimmed content offset within the original frame. */ readonly trim?: Readonly<{
|
|
19
|
+
x: number; /** Vertical pixel offset. */
|
|
20
|
+
y: number;
|
|
21
|
+
}>;
|
|
22
|
+
/** Whether the packed rectangle is rotated clockwise. */ readonly rotated?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** One normalized timed frame reference. Durations are milliseconds. See {@link SpriteFrame}. */
|
|
25
|
+
export interface SpriteAnimationFrameData {
|
|
26
|
+
readonly frame: string; /** Positive duration of the animation step in milliseconds. */
|
|
27
|
+
readonly duration: number;
|
|
28
|
+
}
|
|
29
|
+
/** Adapter result. Image paths resolve relative to the metadata URL. See {@link SpriteFrame}. */
|
|
30
|
+
export interface SpriteSheetData {
|
|
31
|
+
/** Atlas image URLs, relative to the metadata URL. */ readonly images: readonly string[];
|
|
32
|
+
/** Normalized frame records for this sheet. */ readonly frames: readonly SpriteFrameData[];
|
|
33
|
+
/** Named sequences of timed frame references. */ readonly animations?: Readonly<Record<string, readonly SpriteAnimationFrameData[]>>;
|
|
34
|
+
}
|
|
35
|
+
/** Import adapter; loaders invoke this directly without a format registry. See {@link SpriteFrame}. */
|
|
36
|
+
export interface SpriteSheetFormat {
|
|
37
|
+
readonly parse: (data: unknown) => SpriteSheetData;
|
|
38
|
+
}
|
|
39
|
+
export interface FrameRecord extends SpriteFrameData {
|
|
40
|
+
readonly image: HTMLImageElement;
|
|
41
|
+
readonly owner: {
|
|
42
|
+
disposed: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Immutable atlas frame. Obtain frames from loadSpriteSheet; images belong to the sheet. See {@link SpriteFrame}. */
|
|
46
|
+
export declare class SpriteFrame {
|
|
47
|
+
private readonly identity;
|
|
48
|
+
/** Original logical frame width, before transparent borders were trimmed.
|
|
49
|
+
* @returns Width in logical pixels.
|
|
50
|
+
*/
|
|
51
|
+
get width(): number;
|
|
52
|
+
/** Original logical frame height, before transparent borders were trimmed.
|
|
53
|
+
* @returns Height in logical pixels.
|
|
54
|
+
*/
|
|
55
|
+
get height(): number;
|
|
56
|
+
/** Stable name supplied by the atlas or numeric grid index.
|
|
57
|
+
* @returns The frame name.
|
|
58
|
+
*/
|
|
59
|
+
get name(): string;
|
|
60
|
+
}
|
|
61
|
+
export declare function makeFrame(record: FrameRecord): SpriteFrame;
|
|
62
|
+
export declare function frameRecord(frame: SpriteFrame): FrameRecord;
|
|
63
|
+
/** Author a finite discrete animation using FPS or explicit positive millisecond durations. See {@link SpriteFrame}.
|
|
64
|
+
* @param options - Frames with a shared FPS or individual millisecond durations.
|
|
65
|
+
* @returns A seekable discrete animation definition.
|
|
66
|
+
*/
|
|
67
|
+
export declare function defineSpriteAnimation(options: {
|
|
68
|
+
readonly frames: readonly SpriteFrame[];
|
|
69
|
+
readonly fps: number;
|
|
70
|
+
} | {
|
|
71
|
+
readonly frames: readonly Readonly<{
|
|
72
|
+
frame: SpriteFrame;
|
|
73
|
+
duration: number;
|
|
74
|
+
}>[];
|
|
75
|
+
}): PibblAnimationDefinition<SpriteFrame>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ImageProps } from '../../lib/components/img.js';
|
|
2
|
+
import type { SystemStyle } from '../../lib/types.js';
|
|
3
|
+
import { type SpriteFrame } from './model.js';
|
|
4
|
+
/** Drawing inputs; frame also accepts a signal through Pibbl's declared primitive inputs. See {@link SpriteFrame}. */
|
|
5
|
+
export interface SpriteProps extends ImageProps {
|
|
6
|
+
/** Atlas frame to draw; its sheet must remain undisposed. */ readonly frame: SpriteFrame;
|
|
7
|
+
/** Image interpolation; defaults to linear. */ readonly sampling?: 'nearest' | 'linear';
|
|
8
|
+
/** Normalized origin within the original frame, defaulting to the top-left. */ readonly anchor?: Readonly<{
|
|
9
|
+
x: number; /** Vertical anchor fraction. */
|
|
10
|
+
y: number;
|
|
11
|
+
}>;
|
|
12
|
+
/** Mirror the frame horizontally. */ readonly flipX?: boolean;
|
|
13
|
+
/** Mirror the frame vertically. */ readonly flipY?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Logical size overrides; omitted dimensions use the original untrimmed frame size. See {@link SpriteFrame}. */
|
|
16
|
+
export interface SpriteStyle extends SystemStyle {
|
|
17
|
+
readonly width?: number; /** Logical height; defaults to the original frame height. */
|
|
18
|
+
readonly height?: number; /** Opacity multiplier applied to the frame. */
|
|
19
|
+
readonly opacity?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Draw a shared atlas frame, preserving its logical geometry across frame changes. See {@link SpriteFrame}. */
|
|
22
|
+
export declare const Sprite: import("@pibbl/core").PibblPrimitiveComponent<SpriteProps, import("@pibbl/core").PrimitiveInput<SpriteProps, SpriteStyle>>;
|
|
@@ -16,7 +16,17 @@ export { tendrils } from "./lib/tendrils.js";
|
|
|
16
16
|
export type { TendrilsOptions, TendrilsMessage } from "./lib/tendrils.js";
|
|
17
17
|
export { lightning } from "./lib/lightning.js";
|
|
18
18
|
export type { LightningOptions, LightningMessage } from "./lib/lightning.js";
|
|
19
|
-
export type { ElectricPoint, ElectricOptions, ElectricControl } from "./lib/electric-shared.js";
|
|
20
|
-
export type { ElectricSource, ElectricSourceMessage } from "./lib/electric-sources.js";
|
|
19
|
+
export type { ElectricPoint, ElectricOptions, ElectricControl, } from "./lib/electric-shared.js";
|
|
20
|
+
export type { ElectricSource, ElectricSourceMessage, } from "./lib/electric-sources.js";
|
|
21
21
|
export { rainDrops } from "./lib/rain-drops.js";
|
|
22
22
|
export type { RainDropsOptions, RainDropsMessage } from "./lib/rain-drops.js";
|
|
23
|
+
export { stripes, checkers, woodGrain, plainWeave, twill, herringbone, } from "./lib/patterns.js";
|
|
24
|
+
export type { FabricOptions, PatternMotionOptions, StripesOptions, CheckersOptions, WoodGrainOptions, } from "./lib/patterns.js";
|
|
25
|
+
export { grayScottPresets } from "./lib/gray-scott.js";
|
|
26
|
+
export type { ReactionDiffusionPreset } from "./lib/gray-scott.js";
|
|
27
|
+
export { softNoise, ridgedNoise } from "./lib/patterns.js";
|
|
28
|
+
export type { NoiseOptions } from "./lib/patterns.js";
|
|
29
|
+
export { schnakenberg, barkley, brusselator, schnakenbergPresets, barkleyPresets, brusselatorPresets } from './lib/chemical-recipes.js';
|
|
30
|
+
export type { SchnakenbergOptions, BarkleyOptions, BrusselatorOptions } from './lib/chemical-recipes.js';
|
|
31
|
+
export { polkaDots, halftone, plaid, truchet, plaidPresets } from './lib/geometric-patterns.js';
|
|
32
|
+
export type { PolkaDotsOptions, HalftoneOptions, PlaidBand, PlaidOptions, TruchetOptions } from './lib/geometric-patterns.js';
|
|
@@ -13,19 +13,51 @@ import { waterSurface } from "./lib/water-surface.js";
|
|
|
13
13
|
import { tendrils } from "./lib/tendrils.js";
|
|
14
14
|
import { lightning } from "./lib/lightning.js";
|
|
15
15
|
import { rainDrops } from "./lib/rain-drops.js";
|
|
16
|
+
import {
|
|
17
|
+
stripes,
|
|
18
|
+
checkers,
|
|
19
|
+
woodGrain,
|
|
20
|
+
plainWeave,
|
|
21
|
+
twill,
|
|
22
|
+
herringbone
|
|
23
|
+
} from "./lib/patterns.js";
|
|
24
|
+
import { grayScottPresets } from "./lib/gray-scott.js";
|
|
25
|
+
import { softNoise, ridgedNoise } from "./lib/patterns.js";
|
|
26
|
+
import { schnakenberg, barkley, brusselator, schnakenbergPresets, barkleyPresets, brusselatorPresets } from "./lib/chemical-recipes.js";
|
|
27
|
+
import { polkaDots, halftone, plaid, truchet, plaidPresets } from "./lib/geometric-patterns.js";
|
|
16
28
|
export {
|
|
17
29
|
ProceduralTexture,
|
|
18
30
|
ReactionDiffusion,
|
|
31
|
+
barkley,
|
|
32
|
+
barkleyPresets,
|
|
33
|
+
brusselator,
|
|
34
|
+
brusselatorPresets,
|
|
19
35
|
cellular,
|
|
36
|
+
checkers,
|
|
37
|
+
grayScottPresets,
|
|
38
|
+
halftone,
|
|
39
|
+
herringbone,
|
|
20
40
|
lightning,
|
|
21
41
|
marble,
|
|
22
42
|
paper,
|
|
43
|
+
plaid,
|
|
44
|
+
plaidPresets,
|
|
45
|
+
plainWeave,
|
|
46
|
+
polkaDots,
|
|
23
47
|
rainDrops,
|
|
24
48
|
reactionDiffusion,
|
|
49
|
+
ridgedNoise,
|
|
50
|
+
schnakenberg,
|
|
51
|
+
schnakenbergPresets,
|
|
52
|
+
softNoise,
|
|
53
|
+
stripes,
|
|
25
54
|
tendrils,
|
|
26
55
|
texturePalettes,
|
|
56
|
+
truchet,
|
|
57
|
+
twill,
|
|
27
58
|
useTexture,
|
|
28
59
|
waterSurface,
|
|
29
|
-
waterWaves
|
|
60
|
+
waterWaves,
|
|
61
|
+
woodGrain
|
|
30
62
|
};
|
|
31
63
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/features/textures/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { ReactionDiffusion } from \"./lib/reaction-diffusion.js\";\nexport type {\n ReactionDiffusionProps,\n TextureBrush,\n} from \"./lib/reaction-diffusion.js\";\nexport { texturePalettes } from \"./lib/palette.js\";\nexport type { TexturePalette, TextureResolution } from \"./lib/palette.js\";\nexport { ProceduralTexture } from \"./lib/procedural-texture.js\";\nexport type { ProceduralTextureProps } from \"./lib/procedural-texture.js\";\nexport type { TextureKind } from \"./lib/material-field.js\";\nexport type {\n TextureRenderer,\n TextureRenderFrame,\n} from \"./lib/presentation.js\";\nexport {\n useTexture,\n marble,\n paper,\n cellular,\n reactionDiffusion,\n} from \"./lib/definitions.js\";\nexport type {\n MaterialOptions,\n ReactionDiffusionOptions,\n InkMessage,\n} from \"./lib/definitions.js\";\nexport { waterWaves } from \"./lib/water-waves.js\";\nexport type {\n WaterWavesOptions,\n WaterWavesMessage,\n} from \"./lib/water-waves.js\";\nexport { waterSurface } from \"./lib/water-surface.js\";\nexport type {\n WaterSurfaceMessage,\n WaterSurfaceObstacle,\n WaterSurfaceOptions,\n} from \"./lib/water-surface.js\";\nexport { tendrils } from \"./lib/tendrils.js\";\nexport type { TendrilsOptions, TendrilsMessage } from \"./lib/tendrils.js\";\nexport { lightning } from \"./lib/lightning.js\";\nexport type { LightningOptions, LightningMessage } from \"./lib/lightning.js\";\nexport type {
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB;AAKlC,SAAS,uBAAuB;AAEhC,SAAS,yBAAyB;AAOlC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,kBAAkB;AAK3B,SAAS,oBAAoB;AAM7B,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["export { ReactionDiffusion } from \"./lib/reaction-diffusion.js\";\nexport type {\n ReactionDiffusionProps,\n TextureBrush,\n} from \"./lib/reaction-diffusion.js\";\nexport { texturePalettes } from \"./lib/palette.js\";\nexport type { TexturePalette, TextureResolution } from \"./lib/palette.js\";\nexport { ProceduralTexture } from \"./lib/procedural-texture.js\";\nexport type { ProceduralTextureProps } from \"./lib/procedural-texture.js\";\nexport type { TextureKind } from \"./lib/material-field.js\";\nexport type {\n TextureRenderer,\n TextureRenderFrame,\n} from \"./lib/presentation.js\";\nexport {\n useTexture,\n marble,\n paper,\n cellular,\n reactionDiffusion,\n} from \"./lib/definitions.js\";\nexport type {\n MaterialOptions,\n ReactionDiffusionOptions,\n InkMessage,\n} from \"./lib/definitions.js\";\nexport { waterWaves } from \"./lib/water-waves.js\";\nexport type {\n WaterWavesOptions,\n WaterWavesMessage,\n} from \"./lib/water-waves.js\";\nexport { waterSurface } from \"./lib/water-surface.js\";\nexport type {\n WaterSurfaceMessage,\n WaterSurfaceObstacle,\n WaterSurfaceOptions,\n} from \"./lib/water-surface.js\";\nexport { tendrils } from \"./lib/tendrils.js\";\nexport type { TendrilsOptions, TendrilsMessage } from \"./lib/tendrils.js\";\nexport { lightning } from \"./lib/lightning.js\";\nexport type { LightningOptions, LightningMessage } from \"./lib/lightning.js\";\nexport type {\n ElectricPoint,\n ElectricOptions,\n ElectricControl,\n} from \"./lib/electric-shared.js\";\nexport type {\n ElectricSource,\n ElectricSourceMessage,\n} from \"./lib/electric-sources.js\";\n\nexport { rainDrops } from \"./lib/rain-drops.js\";\nexport type { RainDropsOptions, RainDropsMessage } from \"./lib/rain-drops.js\";\n\nexport {\n stripes,\n checkers,\n woodGrain,\n plainWeave,\n twill,\n herringbone,\n} from \"./lib/patterns.js\";\nexport type {\n FabricOptions,\n PatternMotionOptions,\n StripesOptions,\n CheckersOptions,\n WoodGrainOptions,\n} from \"./lib/patterns.js\";\nexport { grayScottPresets } from \"./lib/gray-scott.js\";\nexport type { ReactionDiffusionPreset } from \"./lib/gray-scott.js\";\n\nexport { softNoise, ridgedNoise } from \"./lib/patterns.js\";\nexport type { NoiseOptions } from \"./lib/patterns.js\";\n\nexport { schnakenberg, barkley, brusselator, schnakenbergPresets, barkleyPresets, brusselatorPresets } from './lib/chemical-recipes.js';\nexport type { SchnakenbergOptions, BarkleyOptions, BrusselatorOptions } from './lib/chemical-recipes.js';\n\nexport { polkaDots, halftone, plaid, truchet, plaidPresets } from './lib/geometric-patterns.js';\nexport type { PolkaDotsOptions, HalftoneOptions, PlaidBand, PlaidOptions, TruchetOptions } from './lib/geometric-patterns.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,yBAAyB;AAKlC,SAAS,uBAAuB;AAEhC,SAAS,yBAAyB;AAOlC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,kBAAkB;AAK3B,SAAS,oBAAoB;AAM7B,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAY1B,SAAS,iBAAiB;AAG1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,wBAAwB;AAGjC,SAAS,WAAW,mBAAmB;AAGvC,SAAS,cAAc,SAAS,aAAa,qBAAqB,gBAAgB,0BAA0B;AAG5G,SAAS,WAAW,UAAU,OAAO,SAAS,oBAAoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Private periodic finite-difference state; presentation adds a duplicate seam row/column. */
|
|
2
|
+
export interface ChemicalConfig {
|
|
3
|
+
readonly a: number;
|
|
4
|
+
readonly b: number;
|
|
5
|
+
readonly epsilon: number;
|
|
6
|
+
readonly diffusionU: number;
|
|
7
|
+
readonly diffusionV: number;
|
|
8
|
+
readonly seed: number;
|
|
9
|
+
readonly initialNoise: number;
|
|
10
|
+
readonly warmupSteps: number;
|
|
11
|
+
readonly speed: number;
|
|
12
|
+
readonly paused: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface Model {
|
|
15
|
+
readonly equilibrium: (c: ChemicalConfig) => readonly [number, number];
|
|
16
|
+
readonly reaction: (u: number, v: number, c: ChemicalConfig) => readonly [number, number];
|
|
17
|
+
readonly excite: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const schnakenbergModel: Model;
|
|
20
|
+
export declare const brusselatorModel: Model;
|
|
21
|
+
export declare const barkleyModel: Model;
|
|
22
|
+
export declare class ChemicalField {
|
|
23
|
+
private readonly options;
|
|
24
|
+
u: Float32Array;
|
|
25
|
+
v: Float32Array;
|
|
26
|
+
private nextU;
|
|
27
|
+
private nextV;
|
|
28
|
+
private maxU;
|
|
29
|
+
private maxV;
|
|
30
|
+
readonly width: number;
|
|
31
|
+
readonly height: number;
|
|
32
|
+
readonly baseline: number;
|
|
33
|
+
constructor(options: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
config: ChemicalConfig;
|
|
37
|
+
model: Model;
|
|
38
|
+
});
|
|
39
|
+
advance(count: number): void;
|
|
40
|
+
paint(options: {
|
|
41
|
+
u: number;
|
|
42
|
+
v: number;
|
|
43
|
+
radius: number;
|
|
44
|
+
strength: number;
|
|
45
|
+
}): void;
|
|
46
|
+
stir(options: {
|
|
47
|
+
u: number;
|
|
48
|
+
v: number;
|
|
49
|
+
du: number;
|
|
50
|
+
dv: number;
|
|
51
|
+
radius: number;
|
|
52
|
+
}): void;
|
|
53
|
+
intensity(index: number): number;
|
|
54
|
+
dispose(): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const schnakenbergModel = {
|
|
2
|
+
equilibrium: (c) => [c.a + c.b, c.b / (c.a + c.b) ** 2],
|
|
3
|
+
reaction: (u, v, c) => {
|
|
4
|
+
const q = u * u * v;
|
|
5
|
+
return [c.a - u + q, c.b - q];
|
|
6
|
+
},
|
|
7
|
+
excite: false
|
|
8
|
+
};
|
|
9
|
+
const brusselatorModel = {
|
|
10
|
+
equilibrium: (c) => [c.a, c.b / c.a],
|
|
11
|
+
reaction: (u, v, c) => {
|
|
12
|
+
const q = u * u * v;
|
|
13
|
+
return [c.a - (c.b + 1) * u + q, c.b * u - q];
|
|
14
|
+
},
|
|
15
|
+
excite: false
|
|
16
|
+
};
|
|
17
|
+
const barkleyModel = {
|
|
18
|
+
equilibrium: () => [0, 0],
|
|
19
|
+
reaction: (u, v, c) => [
|
|
20
|
+
u * (1 - u) * (u - (v + c.b) / c.a) / c.epsilon,
|
|
21
|
+
u - v
|
|
22
|
+
],
|
|
23
|
+
excite: true
|
|
24
|
+
};
|
|
25
|
+
function hash(i, seed) {
|
|
26
|
+
let n = Math.imul(i ^ seed, 73244475);
|
|
27
|
+
n = Math.imul(n ^ n >>> 16, 73244475);
|
|
28
|
+
return ((n ^ n >>> 16) >>> 0) / 4294967295;
|
|
29
|
+
}
|
|
30
|
+
const wrap = (value, size) => (value % size + size) % size;
|
|
31
|
+
class ChemicalField {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
this.options = options;
|
|
34
|
+
this.width = options.width;
|
|
35
|
+
this.height = options.height;
|
|
36
|
+
const n = this.width * this.height;
|
|
37
|
+
this.u = new Float32Array(n);
|
|
38
|
+
this.v = new Float32Array(n);
|
|
39
|
+
this.nextU = new Float32Array(n);
|
|
40
|
+
this.nextV = new Float32Array(n);
|
|
41
|
+
const c = options.config, [u, v] = options.model.equilibrium(c);
|
|
42
|
+
this.baseline = options.model.excite ? 1 : u;
|
|
43
|
+
for (let y = 0; y < this.height; y++)
|
|
44
|
+
for (let x = 0; x < this.width; x++) {
|
|
45
|
+
const i = y * this.width + x, noise = hash(i, c.seed) - 0.5;
|
|
46
|
+
if (options.model.excite) {
|
|
47
|
+
const split = 0.5 + (hash(0, c.seed) - 0.5) * 0.08;
|
|
48
|
+
this.u[i] = (x > this.width * 0.22 && x < this.width * 0.5 && y < this.height * split ? 1 : 0) * (1 - c.initialNoise * 0.5) + c.initialNoise * Math.max(0, noise);
|
|
49
|
+
this.v[i] = y >= this.height * split ? 0.5 : 0;
|
|
50
|
+
} else {
|
|
51
|
+
this.u[i] = u * (1 + c.initialNoise * noise);
|
|
52
|
+
this.v[i] = v * (1 + c.initialNoise * (hash(i, c.seed ^ 1367130551) - 0.5));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.maxU = Math.max(1, u * 1.5);
|
|
56
|
+
this.maxV = Math.max(1, v * 1.5);
|
|
57
|
+
this.advance(c.warmupSteps);
|
|
58
|
+
}
|
|
59
|
+
options;
|
|
60
|
+
u;
|
|
61
|
+
v;
|
|
62
|
+
nextU;
|
|
63
|
+
nextV;
|
|
64
|
+
maxU = 1;
|
|
65
|
+
maxV = 1;
|
|
66
|
+
width;
|
|
67
|
+
height;
|
|
68
|
+
baseline;
|
|
69
|
+
advance(count) {
|
|
70
|
+
const { config: c, model } = this.options, w = this.width, h = this.height;
|
|
71
|
+
for (let step = 0; step < count; step++) {
|
|
72
|
+
const stiffness = model.excite ? 1 / c.epsilon : 1 + this.maxU * this.maxU + 2 * this.maxU * this.maxV + c.b;
|
|
73
|
+
const dt = Math.min(
|
|
74
|
+
0.05,
|
|
75
|
+
0.2 / Math.max(1e-3, c.diffusionU, c.diffusionV),
|
|
76
|
+
0.1 / stiffness
|
|
77
|
+
);
|
|
78
|
+
let maxU = 0, maxV = 0;
|
|
79
|
+
for (let y = 0; y < h; y++) {
|
|
80
|
+
const row = y * w, above = (y === 0 ? h - 1 : y - 1) * w, below = (y === h - 1 ? 0 : y + 1) * w;
|
|
81
|
+
for (let x = 0; x < w; x++) {
|
|
82
|
+
const i = row + x, left = row + (x === 0 ? w - 1 : x - 1), right = row + (x === w - 1 ? 0 : x + 1);
|
|
83
|
+
const u = this.u[i], v = this.v[i];
|
|
84
|
+
const lapU = this.u[left] + this.u[right] + this.u[above + x] + this.u[below + x] - 4 * u;
|
|
85
|
+
const lapV = this.v[left] + this.v[right] + this.v[above + x] + this.v[below + x] - 4 * v;
|
|
86
|
+
const [ru, rv] = model.reaction(u, v, c);
|
|
87
|
+
const nu = Math.max(0, u + dt * (c.diffusionU * lapU + ru));
|
|
88
|
+
const nv = Math.max(0, v + dt * (c.diffusionV * lapV + rv));
|
|
89
|
+
if (!Number.isFinite(nu) || !Number.isFinite(nv))
|
|
90
|
+
throw new RangeError(
|
|
91
|
+
"Reaction-diffusion parameters produced a nonfinite field."
|
|
92
|
+
);
|
|
93
|
+
this.nextU[i] = nu;
|
|
94
|
+
this.nextV[i] = nv;
|
|
95
|
+
maxU = Math.max(maxU, nu);
|
|
96
|
+
maxV = Math.max(maxV, nv);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
[this.u, this.nextU] = [this.nextU, this.u];
|
|
100
|
+
[this.v, this.nextV] = [this.nextV, this.v];
|
|
101
|
+
this.maxU = maxU;
|
|
102
|
+
this.maxV = maxV;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
paint(options) {
|
|
106
|
+
const { width: w, height: h } = this;
|
|
107
|
+
for (let y = 0; y < h; y++)
|
|
108
|
+
for (let x = 0; x < w; x++) {
|
|
109
|
+
const dx = wrap(x - options.u * w + w / 2, w) - w / 2, dy = wrap(y - options.v * h + h / 2, h) - h / 2;
|
|
110
|
+
const distance = Math.hypot(dx, dy) / options.radius;
|
|
111
|
+
if (distance >= 1) continue;
|
|
112
|
+
const dose = options.strength * (1 - distance * distance) ** 2;
|
|
113
|
+
const i = y * w + x;
|
|
114
|
+
this.u[i] = Math.max(
|
|
115
|
+
this.u[i],
|
|
116
|
+
this.options.model.excite ? dose : this.baseline * (1 + 2 * dose)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
this.maxU = Math.max(this.maxU, this.baseline * 3);
|
|
120
|
+
}
|
|
121
|
+
stir(options) {
|
|
122
|
+
const w = this.width, h = this.height;
|
|
123
|
+
const sample = (field, x, y) => {
|
|
124
|
+
x = wrap(x, w);
|
|
125
|
+
y = wrap(y, h);
|
|
126
|
+
const ix = Math.floor(x), iy = Math.floor(y), fx = x - ix, fy = y - iy;
|
|
127
|
+
const x1 = (ix + 1) % w, y1 = (iy + 1) % h;
|
|
128
|
+
return (field[iy * w + ix] * (1 - fx) + field[iy * w + x1] * fx) * (1 - fy) + (field[y1 * w + ix] * (1 - fx) + field[y1 * w + x1] * fx) * fy;
|
|
129
|
+
};
|
|
130
|
+
for (let y = 0; y < h; y++)
|
|
131
|
+
for (let x = 0; x < w; x++) {
|
|
132
|
+
const dx = wrap(x - options.u * w + w / 2, w) - w / 2, dy = wrap(y - options.v * h + h / 2, h) - h / 2;
|
|
133
|
+
const t = Math.max(0, 1 - Math.hypot(dx, dy) / options.radius), weight = t * t * (3 - 2 * t);
|
|
134
|
+
const px = x - options.du * w * weight, py = y - options.dv * h * weight, i = y * w + x;
|
|
135
|
+
this.nextU[i] = sample(this.u, px, py);
|
|
136
|
+
this.nextV[i] = sample(this.v, px, py);
|
|
137
|
+
}
|
|
138
|
+
[this.u, this.nextU] = [this.nextU, this.u];
|
|
139
|
+
[this.v, this.nextV] = [this.nextV, this.v];
|
|
140
|
+
}
|
|
141
|
+
intensity(index) {
|
|
142
|
+
return this.options.model.excite ? this.u[index] : this.u[index] / (2 * this.baseline);
|
|
143
|
+
}
|
|
144
|
+
dispose() {
|
|
145
|
+
this.u = this.v = this.nextU = this.nextV = new Float32Array(0);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
ChemicalField,
|
|
150
|
+
barkleyModel,
|
|
151
|
+
brusselatorModel,
|
|
152
|
+
schnakenbergModel
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=chemical-field.js.map
|