@luma.gl/engine 10.0.0-rc.1 → 10.0.0
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/THIRD-PARTY-NOTICES.md +89 -0
- package/dist/animation/animation-track.d.ts +7 -0
- package/dist/animation/animation-track.d.ts.map +1 -1
- package/dist/animation/animation-track.js.map +1 -1
- package/dist/animation/node-animation-binding.cjs +1 -0
- package/dist/animation/node-animation-binding.d.ts +2 -1
- package/dist/animation/node-animation-binding.d.ts.map +1 -1
- package/dist/animation/node-animation-binding.js +6 -0
- package/dist/animation/node-animation-binding.js.map +1 -1
- package/dist/animation/scenegraph-gpu-animation-layout.cjs +99 -0
- package/dist/animation/scenegraph-gpu-animation-layout.d.ts +69 -0
- package/dist/animation/scenegraph-gpu-animation-layout.d.ts.map +1 -0
- package/dist/animation/scenegraph-gpu-animation-layout.js +90 -0
- package/dist/animation/scenegraph-gpu-animation-layout.js.map +1 -0
- package/dist/animation/scenegraph-gpu-animation.cjs +281 -0
- package/dist/animation/scenegraph-gpu-animation.d.ts +54 -0
- package/dist/animation/scenegraph-gpu-animation.d.ts.map +1 -0
- package/dist/animation/scenegraph-gpu-animation.js +274 -0
- package/dist/animation/scenegraph-gpu-animation.js.map +1 -0
- package/dist/arrow/arrow-picking.cjs +4 -3
- package/dist/arrow/arrow-picking.d.ts +15 -5
- package/dist/arrow/arrow-picking.d.ts.map +1 -1
- package/dist/arrow/arrow-picking.js +16 -5
- package/dist/arrow/arrow-picking.js.map +1 -1
- package/dist/arrow/index.cjs.map +1 -1
- package/dist/dist.dev.js +1735 -1100
- package/dist/dist.min.js +69 -70
- package/dist/effects/glfx-effects.cjs +261 -0
- package/dist/effects/glfx-effects.d.ts +959 -0
- package/dist/effects/glfx-effects.d.ts.map +1 -0
- package/dist/effects/glfx-effects.js +200 -0
- package/dist/effects/glfx-effects.js.map +1 -0
- package/dist/effects/graph/gpu-effect-operation.cjs +461 -0
- package/dist/effects/graph/gpu-effect-operation.d.ts +127 -0
- package/dist/effects/graph/gpu-effect-operation.d.ts.map +1 -0
- package/dist/effects/graph/gpu-effect-operation.js +474 -0
- package/dist/effects/graph/gpu-effect-operation.js.map +1 -0
- package/dist/effects/graph/temporal-graph-history.cjs +48 -0
- package/dist/effects/graph/temporal-graph-history.d.ts +17 -0
- package/dist/effects/graph/temporal-graph-history.d.ts.map +1 -0
- package/dist/effects/graph/temporal-graph-history.js +30 -0
- package/dist/effects/graph/temporal-graph-history.js.map +1 -0
- package/dist/effects/index.cjs +179 -34
- package/dist/effects/index.cjs.map +3 -3
- package/dist/effects/index.d.ts +64 -27
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/index.js +51 -18
- package/dist/effects/index.js.map +1 -1
- package/dist/effects/passes/postprocessing/detail/detail-blur.cjs +95 -0
- package/dist/effects/passes/postprocessing/detail/detail-blur.d.ts +126 -0
- package/dist/effects/passes/postprocessing/detail/detail-blur.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/detail/detail-blur.js +63 -0
- package/dist/effects/passes/postprocessing/detail/detail-blur.js.map +1 -0
- package/dist/effects/passes/postprocessing/detail/high-pass.cjs +80 -0
- package/dist/effects/passes/postprocessing/detail/high-pass.d.ts +183 -0
- package/dist/effects/passes/postprocessing/detail/high-pass.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/detail/high-pass.js +59 -0
- package/dist/effects/passes/postprocessing/detail/high-pass.js.map +1 -0
- package/dist/effects/passes/postprocessing/detail/local-contrast.cjs +81 -0
- package/dist/effects/passes/postprocessing/detail/local-contrast.d.ts +163 -0
- package/dist/effects/passes/postprocessing/detail/local-contrast.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/detail/local-contrast.js +57 -0
- package/dist/effects/passes/postprocessing/detail/local-contrast.js.map +1 -0
- package/dist/effects/passes/postprocessing/detail/unsharp-mask.cjs +73 -0
- package/dist/effects/passes/postprocessing/detail/unsharp-mask.d.ts +43 -0
- package/dist/effects/passes/postprocessing/detail/unsharp-mask.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/detail/unsharp-mask.js +46 -0
- package/dist/effects/passes/postprocessing/detail/unsharp-mask.js.map +1 -0
- package/dist/effects/passes/postprocessing/fxaa/fxaa.cjs +9 -2
- package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts +19 -0
- package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js +6 -0
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/effects/passes/postprocessing/grading/curves.cjs +91 -0
- package/dist/effects/passes/postprocessing/grading/curves.d.ts +54 -0
- package/dist/effects/passes/postprocessing/grading/curves.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/grading/curves.js +73 -0
- package/dist/effects/passes/postprocessing/grading/curves.js.map +1 -0
- package/dist/effects/passes/postprocessing/grading/lift-gamma-gain.cjs +71 -0
- package/dist/effects/passes/postprocessing/grading/lift-gamma-gain.d.ts +76 -0
- package/dist/effects/passes/postprocessing/grading/lift-gamma-gain.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/grading/lift-gamma-gain.js +50 -0
- package/dist/effects/passes/postprocessing/grading/lift-gamma-gain.js.map +1 -0
- package/dist/effects/passes/postprocessing/grading/shadows-highlights.cjs +160 -0
- package/dist/effects/passes/postprocessing/grading/shadows-highlights.d.ts +232 -0
- package/dist/effects/passes/postprocessing/grading/shadows-highlights.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/grading/shadows-highlights.js +138 -0
- package/dist/effects/passes/postprocessing/grading/shadows-highlights.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/chromatic-aberration.cjs +84 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/chromatic-aberration.d.ts +36 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/chromatic-aberration.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/chromatic-aberration.js +58 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/chromatic-aberration.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/levels.cjs +106 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/levels.d.ts +105 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/levels.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/levels.js +89 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/levels.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/lut-color-grading.cjs +327 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/lut-color-grading.d.ts +201 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/lut-color-grading.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/lut-color-grading.js +296 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/lut-color-grading.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/output-dithering.cjs +85 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/output-dithering.d.ts +36 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/output-dithering.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/output-dithering.js +59 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/output-dithering.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/pack-color-lut.cjs +58 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/pack-color-lut.d.ts +27 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/pack-color-lut.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/pack-color-lut.js +45 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/pack-color-lut.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/persistence.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/persistence.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/posterize.cjs +64 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/posterize.d.ts +48 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/posterize.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/posterize.js +42 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/posterize.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/sharpen.cjs +110 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sharpen.d.ts +214 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sharpen.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sharpen.js +89 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sharpen.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/threshold.cjs +62 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/threshold.d.ts +47 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/threshold.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/threshold.js +40 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/threshold.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.cjs +9 -2
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts +41 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js +6 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.cjs +200 -13
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts +993 -7
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js +199 -10
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts +4 -4
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-lens-effects.cjs +8 -6
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-lens-effects.d.ts +7 -7
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-lens-effects.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-lens-effects.js +8 -6
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-lens-effects.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/gaussianblur.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/gaussianblur.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-warp-filters/displacement-map.cjs +79 -0
- package/dist/effects/passes/postprocessing/image-warp-filters/displacement-map.d.ts +59 -0
- package/dist/effects/passes/postprocessing/image-warp-filters/displacement-map.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/image-warp-filters/displacement-map.js +63 -0
- package/dist/effects/passes/postprocessing/image-warp-filters/displacement-map.js.map +1 -0
- package/dist/effects/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-warp-filters/swirl.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-warp-filters/warp.js.map +1 -1
- package/dist/effects/passes/postprocessing/layer-styles/bevel.cjs +100 -0
- package/dist/effects/passes/postprocessing/layer-styles/bevel.d.ts +73 -0
- package/dist/effects/passes/postprocessing/layer-styles/bevel.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/layer-styles/bevel.js +78 -0
- package/dist/effects/passes/postprocessing/layer-styles/bevel.js.map +1 -0
- package/dist/effects/passes/postprocessing/layer-styles/drop-shadow.cjs +180 -0
- package/dist/effects/passes/postprocessing/layer-styles/drop-shadow.d.ts +152 -0
- package/dist/effects/passes/postprocessing/layer-styles/drop-shadow.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/layer-styles/drop-shadow.js +157 -0
- package/dist/effects/passes/postprocessing/layer-styles/drop-shadow.js.map +1 -0
- package/dist/effects/passes/postprocessing/optical/lens-flare.cjs +67 -0
- package/dist/effects/passes/postprocessing/optical/lens-flare.d.ts +181 -0
- package/dist/effects/passes/postprocessing/optical/lens-flare.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/optical/lens-flare.js +52 -0
- package/dist/effects/passes/postprocessing/optical/lens-flare.js.map +1 -0
- package/dist/effects/passes/postprocessing/optical/light-shafts.cjs +138 -0
- package/dist/effects/passes/postprocessing/optical/light-shafts.d.ts +138 -0
- package/dist/effects/passes/postprocessing/optical/light-shafts.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/optical/light-shafts.js +119 -0
- package/dist/effects/passes/postprocessing/optical/light-shafts.js.map +1 -0
- package/dist/effects/passes/postprocessing/optical/optical-textures.cjs +104 -0
- package/dist/effects/passes/postprocessing/optical/optical-textures.d.ts +43 -0
- package/dist/effects/passes/postprocessing/optical/optical-textures.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/optical/optical-textures.js +69 -0
- package/dist/effects/passes/postprocessing/optical/optical-textures.js.map +1 -0
- package/dist/effects/passes/postprocessing/optical/selective-glow.cjs +64 -0
- package/dist/effects/passes/postprocessing/optical/selective-glow.d.ts +190 -0
- package/dist/effects/passes/postprocessing/optical/selective-glow.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/optical/selective-glow.js +49 -0
- package/dist/effects/passes/postprocessing/optical/selective-glow.js.map +1 -0
- package/dist/effects/passes/postprocessing/smaa.cjs +279 -0
- package/dist/effects/passes/postprocessing/smaa.d.ts +95 -0
- package/dist/effects/passes/postprocessing/smaa.d.ts.map +1 -0
- package/dist/effects/passes/postprocessing/smaa.js +253 -0
- package/dist/effects/passes/postprocessing/smaa.js.map +1 -0
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.cjs +41 -40
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts +116 -8
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js +38 -37
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.cjs +101 -70
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +496 -5
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js +97 -65
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js.map +1 -1
- package/dist/effects/passes/screen-space/copy-pass.cjs +7 -0
- package/dist/effects/passes/screen-space/copy-pass.d.ts +1 -0
- package/dist/effects/passes/screen-space/copy-pass.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/copy-pass.js +4 -0
- package/dist/effects/passes/screen-space/copy-pass.js.map +1 -1
- package/dist/effects/passes/screen-space/depth-aware-blur.cjs +7 -5
- package/dist/effects/passes/screen-space/depth-aware-blur.d.ts +21 -19
- package/dist/effects/passes/screen-space/depth-aware-blur.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/depth-aware-blur.js +5 -3
- package/dist/effects/passes/screen-space/depth-aware-blur.js.map +1 -1
- package/dist/effects/passes/screen-space/dof.cjs +16 -7
- package/dist/effects/passes/screen-space/dof.d.ts +63 -4
- package/dist/effects/passes/screen-space/dof.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/dof.js +12 -4
- package/dist/effects/passes/screen-space/dof.js.map +1 -1
- package/dist/effects/passes/screen-space/gtao.cjs +93 -64
- package/dist/effects/passes/screen-space/gtao.d.ts +642 -6
- package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.js +94 -62
- package/dist/effects/passes/screen-space/gtao.js.map +1 -1
- package/dist/effects/passes/screen-space/hdr-auto-exposure.cjs +103 -79
- package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts +226 -4
- package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/hdr-auto-exposure.js +102 -77
- package/dist/effects/passes/screen-space/hdr-auto-exposure.js.map +1 -1
- package/dist/effects/passes/screen-space/height-fog.cjs +14 -0
- package/dist/effects/passes/screen-space/height-fog.d.ts +71 -0
- package/dist/effects/passes/screen-space/height-fog.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/height-fog.js +16 -3
- package/dist/effects/passes/screen-space/height-fog.js.map +1 -1
- package/dist/effects/passes/screen-space/motion-blur.cjs +7 -8
- package/dist/effects/passes/screen-space/motion-blur.d.ts +41 -2
- package/dist/effects/passes/screen-space/motion-blur.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/motion-blur.js +6 -6
- package/dist/effects/passes/screen-space/motion-blur.js.map +1 -1
- package/dist/effects/passes/screen-space/outlines.cjs +143 -18
- package/dist/effects/passes/screen-space/outlines.d.ts +163 -4
- package/dist/effects/passes/screen-space/outlines.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/outlines.js +137 -15
- package/dist/effects/passes/screen-space/outlines.js.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.cjs +82 -63
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +333 -5
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.js +81 -61
- package/dist/effects/passes/screen-space/screen-space-global-illumination.js.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.cjs +165 -85
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +802 -10
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.js +162 -81
- package/dist/effects/passes/screen-space/screen-space-reflections.js.map +1 -1
- package/dist/effects/passes/screen-space/selection-outline.cjs +12 -2
- package/dist/effects/passes/screen-space/selection-outline.d.ts +44 -0
- package/dist/effects/passes/screen-space/selection-outline.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/selection-outline.js +9 -0
- package/dist/effects/passes/screen-space/selection-outline.js.map +1 -1
- package/dist/effects/passes/screen-space/ssao.cjs +66 -43
- package/dist/effects/passes/screen-space/ssao.d.ts +648 -3
- package/dist/effects/passes/screen-space/ssao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/ssao.js +64 -41
- package/dist/effects/passes/screen-space/ssao.js.map +1 -1
- package/dist/effects/passes/screen-space/ssr-camera-temporal.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/ssr-camera-temporal.js.map +1 -1
- package/dist/effects/passes/screen-space/temporal-antialiasing.cjs +42 -30
- package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts +107 -6
- package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/temporal-antialiasing.js +40 -27
- package/dist/effects/passes/screen-space/temporal-antialiasing.js.map +1 -1
- package/dist/effects/passes/screen-space/temporal-frame.cjs +34 -0
- package/dist/effects/passes/screen-space/temporal-frame.d.ts +23 -0
- package/dist/effects/passes/screen-space/temporal-frame.d.ts.map +1 -0
- package/dist/effects/passes/screen-space/temporal-frame.js +16 -0
- package/dist/effects/passes/screen-space/temporal-frame.js.map +1 -0
- package/dist/effects/passes/screen-space/volumetric-fog.cjs +25 -22
- package/dist/effects/passes/screen-space/volumetric-fog.d.ts +162 -3
- package/dist/effects/passes/screen-space/volumetric-fog.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/volumetric-fog.js +27 -21
- package/dist/effects/passes/screen-space/volumetric-fog.js.map +1 -1
- package/dist/effects/scene-effect-attachments.cjs +15 -0
- package/dist/effects/scene-effect-attachments.d.ts +23 -0
- package/dist/effects/scene-effect-attachments.d.ts.map +1 -0
- package/dist/effects/scene-effect-attachments.js +5 -0
- package/dist/effects/scene-effect-attachments.js.map +1 -0
- package/dist/effects/temporal-upscale/index.cjs +40 -0
- package/dist/effects/temporal-upscale/index.d.ts +5 -0
- package/dist/effects/temporal-upscale/index.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/index.js +6 -0
- package/dist/effects/temporal-upscale/index.js.map +1 -0
- package/dist/effects/temporal-upscale/temporal-math.cjs +202 -0
- package/dist/effects/temporal-upscale/temporal-math.d.ts +101 -0
- package/dist/effects/temporal-upscale/temporal-math.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/temporal-math.js +202 -0
- package/dist/effects/temporal-upscale/temporal-math.js.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.cjs +353 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts +7 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.js +321 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.js.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.cjs +392 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.d.ts +143 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.js +385 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.js.map +1 -0
- package/dist/gltf/gltf/create-gltf-model.cjs +34 -71
- package/dist/gltf/gltf/create-gltf-model.d.ts +3 -0
- package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.js +40 -74
- package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +46 -4
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +9 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +54 -4
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-animated-crowd.cjs +25 -136
- package/dist/gltf/gltf/gltf-animated-crowd.d.ts +4 -8
- package/dist/gltf/gltf/gltf-animated-crowd.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-animated-crowd.js +27 -139
- package/dist/gltf/gltf/gltf-animated-crowd.js.map +1 -1
- package/dist/gltf/gltf/gltf-animation-nodes.cjs +84 -0
- package/dist/gltf/gltf/gltf-animation-nodes.d.ts +11 -0
- package/dist/gltf/gltf/gltf-animation-nodes.d.ts.map +1 -0
- package/dist/gltf/gltf/gltf-animation-nodes.js +62 -0
- package/dist/gltf/gltf/gltf-animation-nodes.js.map +1 -0
- package/dist/gltf/gltf/gltf-animator.cjs +8 -2
- package/dist/gltf/gltf/gltf-animator.d.ts +6 -1
- package/dist/gltf/gltf/gltf-animator.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-animator.js +10 -2
- package/dist/gltf/gltf/gltf-animator.js.map +1 -1
- package/dist/gltf/gltf/gltf-gpu-animation-controller.cjs +81 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts +9 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts.map +1 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.js +67 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.js.map +1 -0
- package/dist/gltf/gltf/gltf-gpu-animation.cjs +33 -28
- package/dist/gltf/gltf/gltf-gpu-animation.d.ts +7 -26
- package/dist/gltf/gltf/gltf-gpu-animation.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-gpu-animation.js +29 -28
- package/dist/gltf/gltf/gltf-gpu-animation.js.map +1 -1
- package/dist/gltf/index.cjs.map +3 -3
- package/dist/gltf/index.d.ts +2 -2
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf.cjs +4 -2
- package/dist/gltf/parsers/parse-gltf.d.ts +3 -0
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +7 -2
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/graph/models/index.cjs.map +2 -2
- package/dist/graph/physics/index.cjs +5 -0
- package/dist/graph/physics/index.cjs.map +3 -3
- package/dist/graph/physics/index.d.ts +1 -0
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/index.js +1 -0
- package/dist/graph/physics/index.js.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.cjs +21 -0
- package/dist/graph/physics/physics-controller-geometry.d.ts +8 -1
- package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.js +22 -0
- package/dist/graph/physics/physics-controller-geometry.js.map +1 -1
- package/dist/graph/physics/scenegraph-session.d.ts +1 -1
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
- package/dist/graph/tables/index.cjs.map +2 -2
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lighting/ambient-occlusion-pass.cjs +47 -28
- package/dist/lighting/ambient-occlusion-pass.d.ts +12 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -1
- package/dist/lighting/ambient-occlusion-pass.js +45 -26
- package/dist/lighting/ambient-occlusion-pass.js.map +1 -1
- package/dist/lighting/clustered-light-grid.cjs +73 -26
- package/dist/lighting/clustered-light-grid.d.ts +38 -5
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -1
- package/dist/lighting/clustered-light-grid.js +70 -24
- package/dist/lighting/clustered-light-grid.js.map +1 -1
- package/dist/lighting/contact-shadow-composite.cjs +72 -51
- package/dist/lighting/contact-shadow-composite.d.ts +262 -3
- package/dist/lighting/contact-shadow-composite.d.ts.map +1 -1
- package/dist/lighting/contact-shadow-composite.js +72 -50
- package/dist/lighting/contact-shadow-composite.js.map +1 -1
- package/dist/lighting/contact-shadow-pass.cjs +50 -39
- package/dist/lighting/contact-shadow-pass.d.ts +8 -0
- package/dist/lighting/contact-shadow-pass.d.ts.map +1 -1
- package/dist/lighting/contact-shadow-pass.js +47 -37
- package/dist/lighting/contact-shadow-pass.js.map +1 -1
- package/dist/lighting/cortao/cortao-occluder-lookup-table.cjs +96 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts +41 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.js +94 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.js.map +1 -0
- package/dist/lighting/cortao/cortao-parameters.cjs +127 -0
- package/dist/lighting/cortao/cortao-parameters.d.ts +95 -0
- package/dist/lighting/cortao/cortao-parameters.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-parameters.js +122 -0
- package/dist/lighting/cortao/cortao-parameters.js.map +1 -0
- package/dist/lighting/cortao/cortao-pass.cjs +100 -0
- package/dist/lighting/cortao/cortao-pass.d.ts +33 -0
- package/dist/lighting/cortao/cortao-pass.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-pass.js +84 -0
- package/dist/lighting/cortao/cortao-pass.js.map +1 -0
- package/dist/lighting/cortao/cortao-passes.cjs +42 -0
- package/dist/lighting/cortao/cortao-passes.d.ts +38 -0
- package/dist/lighting/cortao/cortao-passes.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-passes.js +19 -0
- package/dist/lighting/cortao/cortao-passes.js.map +1 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.cjs +606 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts +49 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.js +610 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.js.map +1 -0
- package/dist/lighting/cortao/cortao-shaders.cjs +667 -0
- package/dist/lighting/cortao/cortao-shaders.d.ts +118 -0
- package/dist/lighting/cortao/cortao-shaders.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-shaders.js +657 -0
- package/dist/lighting/cortao/cortao-shaders.js.map +1 -0
- package/dist/lighting/cortao/cortao-upsample.cjs +191 -0
- package/dist/lighting/cortao/cortao-upsample.d.ts +16 -0
- package/dist/lighting/cortao/cortao-upsample.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-upsample.js +159 -0
- package/dist/lighting/cortao/cortao-upsample.js.map +1 -0
- package/dist/lighting/cortao/cortao-webgl-passes.cjs +229 -0
- package/dist/lighting/cortao/cortao-webgl-passes.d.ts +28 -0
- package/dist/lighting/cortao/cortao-webgl-passes.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-webgl-passes.js +212 -0
- package/dist/lighting/cortao/cortao-webgl-passes.js.map +1 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.cjs +348 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.d.ts +31 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.js +335 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.js.map +1 -0
- package/dist/lighting/index.cjs +13 -2
- package/dist/lighting/index.cjs.map +3 -3
- package/dist/lighting/index.d.ts +12 -7
- package/dist/lighting/index.d.ts.map +1 -1
- package/dist/lighting/index.js +6 -5
- package/dist/lighting/index.js.map +1 -1
- package/dist/lighting/shadow-map-renderer.cjs +40 -37
- package/dist/lighting/shadow-map-renderer.d.ts +15 -0
- package/dist/lighting/shadow-map-renderer.d.ts.map +1 -1
- package/dist/lighting/shadow-map-renderer.js +37 -35
- package/dist/lighting/shadow-map-renderer.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +39 -16
- package/dist/model/gpu-vector-model.d.ts +8 -0
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +46 -18
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/passes/effect-renderer.cjs +190 -0
- package/dist/passes/effect-renderer.d.ts +182 -0
- package/dist/passes/effect-renderer.d.ts.map +1 -0
- package/dist/passes/effect-renderer.js +182 -0
- package/dist/passes/effect-renderer.js.map +1 -0
- package/dist/passes/{shader-pass-renderer.cjs → fullscreen-effect-executor.cjs} +131 -94
- package/dist/passes/fullscreen-effect-executor.d.ts +188 -0
- package/dist/passes/fullscreen-effect-executor.d.ts.map +1 -0
- package/dist/passes/{shader-pass-renderer.js → fullscreen-effect-executor.js} +132 -100
- package/dist/passes/fullscreen-effect-executor.js.map +1 -0
- package/dist/passes/fullscreen-effect-module.cjs +15 -0
- package/dist/passes/fullscreen-effect-module.d.ts +47 -0
- package/dist/passes/fullscreen-effect-module.d.ts.map +1 -0
- package/dist/passes/fullscreen-effect-module.js +5 -0
- package/dist/passes/fullscreen-effect-module.js.map +1 -0
- package/dist/passes/fullscreen-effect-plan.cjs +15 -0
- package/dist/passes/fullscreen-effect-plan.d.ts +49 -0
- package/dist/passes/fullscreen-effect-plan.d.ts.map +1 -0
- package/dist/passes/fullscreen-effect-plan.js +5 -0
- package/dist/passes/fullscreen-effect-plan.js.map +1 -0
- package/dist/passes/get-fragment-shader.cjs +3 -0
- package/dist/passes/get-fragment-shader.d.ts +2 -2
- package/dist/passes/get-fragment-shader.d.ts.map +1 -1
- package/dist/passes/get-fragment-shader.js +3 -0
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/scene-capture-pass.cjs +42 -0
- package/dist/passes/scene-capture-pass.d.ts +29 -0
- package/dist/passes/scene-capture-pass.d.ts.map +1 -0
- package/dist/passes/scene-capture-pass.js +21 -0
- package/dist/passes/scene-capture-pass.js.map +1 -0
- package/dist/scenegraph/model-node.cjs +2 -0
- package/dist/scenegraph/model-node.d.ts +4 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +2 -0
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/shader-inputs.cjs +1 -1
- package/dist/shader-inputs.d.ts +1 -1
- package/dist/shader-inputs.js +1 -1
- package/dist/splats/gpu-paged-splat-renderer.cjs +52 -8
- package/dist/splats/gpu-paged-splat-renderer.d.ts +16 -3
- package/dist/splats/gpu-paged-splat-renderer.d.ts.map +1 -1
- package/dist/splats/gpu-paged-splat-renderer.js +55 -9
- package/dist/splats/gpu-paged-splat-renderer.js.map +1 -1
- package/dist/splats/gpu-paged-splat-shaders.cjs +3 -1
- package/dist/splats/gpu-paged-splat-shaders.d.ts.map +1 -1
- package/dist/splats/gpu-paged-splat-shaders.js +3 -1
- package/dist/splats/gpu-paged-splat-shaders.js.map +1 -1
- package/dist/splats/index.cjs.map +2 -2
- package/dist/text/fonts/atlas/browser-font-atlas.cjs +10 -1
- package/dist/text/fonts/atlas/browser-font-atlas.d.ts +4 -1
- package/dist/text/fonts/atlas/browser-font-atlas.d.ts.map +1 -1
- package/dist/text/fonts/atlas/browser-font-atlas.js +11 -2
- package/dist/text/fonts/atlas/browser-font-atlas.js.map +1 -1
- package/dist/text/fonts/atlas/lru-cache.cjs +4 -0
- package/dist/text/fonts/atlas/lru-cache.d.ts +3 -1
- package/dist/text/fonts/atlas/lru-cache.d.ts.map +1 -1
- package/dist/text/fonts/atlas/lru-cache.js +4 -0
- package/dist/text/fonts/atlas/lru-cache.js.map +1 -1
- package/dist/text/fonts/build-sdf-font-atlas.cjs +1 -1
- package/dist/text/fonts/build-sdf-font-atlas.d.ts.map +1 -1
- package/dist/text/fonts/build-sdf-font-atlas.js +4 -2
- package/dist/text/fonts/build-sdf-font-atlas.js.map +1 -1
- package/dist/text/fonts/index.cjs +4 -0
- package/dist/text/fonts/index.cjs.map +1 -1
- package/dist/text/fonts/index.d.ts +1 -1
- package/dist/text/fonts/index.d.ts.map +1 -1
- package/dist/text/fonts/index.js +1 -1
- package/dist/text/fonts/index.js.map +1 -1
- package/dist/text/index.cjs.map +1 -1
- package/dist/utils/shader-module-utils.cjs +3 -0
- package/dist/utils/shader-module-utils.d.ts.map +1 -1
- package/dist/utils/shader-module-utils.js +3 -0
- package/dist/utils/shader-module-utils.js.map +1 -1
- package/licenses/smaa.txt +24 -0
- package/package.json +8 -8
- package/src/animation/animation-track.ts +5 -0
- package/src/animation/node-animation-binding.ts +9 -8
- package/src/animation/scenegraph-gpu-animation-layout.ts +195 -0
- package/src/animation/scenegraph-gpu-animation.ts +340 -0
- package/src/arrow/arrow-picking.ts +23 -11
- package/src/effects/README.md +40 -16
- package/src/effects/glfx-effects.ts +227 -0
- package/src/effects/graph/gpu-effect-operation.ts +720 -0
- package/src/effects/graph/temporal-graph-history.ts +46 -0
- package/src/effects/index.ts +161 -28
- package/src/effects/passes/postprocessing/detail/detail-blur.ts +77 -0
- package/src/effects/passes/postprocessing/detail/high-pass.ts +86 -0
- package/src/effects/passes/postprocessing/detail/local-contrast.ts +79 -0
- package/src/effects/passes/postprocessing/detail/unsharp-mask.ts +56 -0
- package/src/effects/passes/postprocessing/fxaa/fxaa.ts +10 -2
- package/src/effects/passes/postprocessing/grading/curves.ts +83 -0
- package/src/effects/passes/postprocessing/grading/lift-gamma-gain.ts +68 -0
- package/src/effects/passes/postprocessing/grading/shadows-highlights.ts +169 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/chromatic-aberration.ts +68 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/denoise.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/levels.ts +111 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/lut-color-grading.ts +347 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/noise.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/output-dithering.ts +69 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/pack-color-lut.ts +67 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/persistence.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/posterize.ts +52 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/sepia.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/sharpen.ts +112 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/threshold.ts +50 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/tone-mapping.ts +10 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/vibrance.ts +2 -2
- package/src/effects/passes/postprocessing/image-adjust-filters/vignette.ts +2 -2
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.ts +233 -29
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.ts +7 -7
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-lens-effects.ts +13 -11
- package/src/effects/passes/postprocessing/image-blur-filters/bloom.ts +2 -2
- package/src/effects/passes/postprocessing/image-blur-filters/gaussianblur.ts +2 -2
- package/src/effects/passes/postprocessing/image-blur-filters/tiltshift.ts +2 -2
- package/src/effects/passes/postprocessing/image-blur-filters/triangleblur.ts +2 -2
- package/src/effects/passes/postprocessing/image-blur-filters/zoomblur.ts +2 -2
- package/src/effects/passes/postprocessing/image-fun-filters/colorhalftone.ts +2 -2
- package/src/effects/passes/postprocessing/image-fun-filters/dotscreen.ts +2 -2
- package/src/effects/passes/postprocessing/image-fun-filters/edgework.ts +2 -2
- package/src/effects/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +2 -2
- package/src/effects/passes/postprocessing/image-fun-filters/ink.ts +2 -2
- package/src/effects/passes/postprocessing/image-fun-filters/magnify.ts +2 -2
- package/src/effects/passes/postprocessing/image-warp-filters/bulgepinch.ts +2 -2
- package/src/effects/passes/postprocessing/image-warp-filters/displacement-map.ts +74 -0
- package/src/effects/passes/postprocessing/image-warp-filters/swirl.ts +2 -2
- package/src/effects/passes/postprocessing/image-warp-filters/warp.ts +2 -2
- package/src/effects/passes/postprocessing/layer-styles/bevel.ts +92 -0
- package/src/effects/passes/postprocessing/layer-styles/drop-shadow.ts +176 -0
- package/src/effects/passes/postprocessing/optical/lens-flare.ts +64 -0
- package/src/effects/passes/postprocessing/optical/light-shafts.ts +139 -0
- package/src/effects/passes/postprocessing/optical/optical-textures.ts +74 -0
- package/src/effects/passes/postprocessing/optical/selective-glow.ts +62 -0
- package/src/effects/passes/postprocessing/smaa.ts +265 -0
- package/src/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +47 -47
- package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +113 -77
- package/src/effects/passes/screen-space/copy-pass.ts +6 -2
- package/src/effects/passes/screen-space/depth-aware-blur.ts +9 -6
- package/src/effects/passes/screen-space/dof.ts +26 -8
- package/src/effects/passes/screen-space/gtao.ts +110 -74
- package/src/effects/passes/screen-space/hdr-auto-exposure.ts +114 -89
- package/src/effects/passes/screen-space/height-fog.ts +21 -6
- package/src/effects/passes/screen-space/motion-blur.ts +9 -8
- package/src/effects/passes/screen-space/outlines.ts +145 -19
- package/src/effects/passes/screen-space/screen-space-global-illumination.ts +95 -73
- package/src/effects/passes/screen-space/screen-space-reflections.ts +179 -104
- package/src/effects/passes/screen-space/selection-outline.ts +13 -2
- package/src/effects/passes/screen-space/ssao.ts +79 -48
- package/src/effects/passes/screen-space/ssr-camera-temporal.ts +4 -4
- package/src/effects/passes/screen-space/temporal-antialiasing.ts +45 -35
- package/src/effects/passes/screen-space/temporal-frame.ts +33 -0
- package/src/effects/passes/screen-space/volumetric-fog.ts +32 -26
- package/src/effects/scene-effect-attachments.ts +26 -0
- package/src/effects/temporal-upscale/index.ts +20 -0
- package/src/effects/temporal-upscale/temporal-math.ts +308 -0
- package/src/effects/temporal-upscale/temporal-upscale-shaders.ts +326 -0
- package/src/effects/temporal-upscale/temporal-upscaler.ts +538 -0
- package/src/gltf/gltf/create-gltf-model.ts +59 -90
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +71 -5
- package/src/gltf/gltf/gltf-animated-crowd.ts +30 -177
- package/src/gltf/gltf/gltf-animation-nodes.ts +82 -0
- package/src/gltf/gltf/gltf-animator.ts +15 -4
- package/src/gltf/gltf/gltf-gpu-animation-controller.ts +88 -0
- package/src/gltf/gltf/gltf-gpu-animation.ts +53 -60
- package/src/gltf/index.ts +5 -0
- package/src/gltf/parsers/parse-gltf.ts +12 -2
- package/src/graph/physics/index.ts +4 -0
- package/src/graph/physics/physics-controller-geometry.ts +33 -1
- package/src/index.ts +28 -6
- package/src/lighting/ambient-occlusion-pass.ts +62 -28
- package/src/lighting/clustered-light-grid.ts +89 -40
- package/src/lighting/contact-shadow-composite.ts +80 -52
- package/src/lighting/contact-shadow-pass.ts +59 -39
- package/src/lighting/cortao/cortao-occluder-lookup-table.ts +138 -0
- package/src/lighting/cortao/cortao-parameters.ts +218 -0
- package/src/lighting/cortao/cortao-pass.ts +136 -0
- package/src/lighting/cortao/cortao-passes.ts +50 -0
- package/src/lighting/cortao/cortao-shaders-wgsl.ts +633 -0
- package/src/lighting/cortao/cortao-shaders.ts +674 -0
- package/src/lighting/cortao/cortao-upsample.ts +177 -0
- package/src/lighting/cortao/cortao-webgl-passes.ts +284 -0
- package/src/lighting/cortao/cortao-webgpu-passes.ts +430 -0
- package/src/lighting/index.ts +13 -5
- package/src/lighting/shadow-map-renderer.ts +57 -43
- package/src/model/gpu-vector-model.ts +47 -18
- package/src/passes/effect-renderer.ts +404 -0
- package/src/passes/{shader-pass-renderer.ts → fullscreen-effect-executor.ts} +270 -181
- package/src/passes/fullscreen-effect-module.ts +71 -0
- package/src/passes/fullscreen-effect-plan.ts +59 -0
- package/src/passes/get-fragment-shader.ts +7 -2
- package/src/passes/scene-capture-pass.ts +51 -0
- package/src/scenegraph/model-node.ts +5 -0
- package/src/shader-inputs.ts +1 -1
- package/src/splats/gpu-paged-splat-renderer.ts +77 -9
- package/src/splats/gpu-paged-splat-shaders.ts +7 -1
- package/src/text/fonts/atlas/browser-font-atlas.ts +13 -2
- package/src/text/fonts/atlas/lru-cache.ts +6 -1
- package/src/text/fonts/build-sdf-font-atlas.ts +4 -2
- package/src/text/fonts/index.ts +2 -0
- package/src/utils/shader-module-utils.ts +3 -0
- package/dist/passes/shader-pass-renderer.d.ts +0 -160
- package/dist/passes/shader-pass-renderer.d.ts.map +0 -1
- package/dist/passes/shader-pass-renderer.js.map +0 -1
package/dist/dist.dev.js
CHANGED
|
@@ -83,6 +83,7 @@ var __exports__ = (() => {
|
|
|
83
83
|
DirectionalLightModel: () => DirectionalLightModel,
|
|
84
84
|
DynamicBuffer: () => DynamicBuffer,
|
|
85
85
|
DynamicTexture: () => DynamicTexture,
|
|
86
|
+
EffectRenderer: () => EffectRenderer,
|
|
86
87
|
GPUGeometry: () => GPUGeometry,
|
|
87
88
|
GPUVectorGeometry: () => GPUVectorGeometry,
|
|
88
89
|
GPUVectorModel: () => GPUVectorModel,
|
|
@@ -108,10 +109,10 @@ var __exports__ = (() => {
|
|
|
108
109
|
RingGeometry: () => RingGeometry,
|
|
109
110
|
SceneMetadata: () => SceneMetadata,
|
|
110
111
|
ScenegraphAnimator: () => ScenegraphAnimator,
|
|
112
|
+
ScenegraphGPUAnimationResources: () => ScenegraphGPUAnimationResources,
|
|
111
113
|
ScenegraphInteractionManager: () => ScenegraphInteractionManager,
|
|
112
114
|
ScenegraphNode: () => ScenegraphNode,
|
|
113
115
|
ShaderInputs: () => ShaderInputs,
|
|
114
|
-
ShaderPassRenderer: () => ShaderPassRenderer,
|
|
115
116
|
SkinController: () => SkinController,
|
|
116
117
|
SphereGeometry: () => SphereGeometry2,
|
|
117
118
|
SpotLightModel: () => SpotLightModel,
|
|
@@ -125,6 +126,7 @@ var __exports__ = (() => {
|
|
|
125
126
|
VideoTexture: () => VideoTexture,
|
|
126
127
|
_resolveLoadFileUrl: () => _resolveLoadFileUrl,
|
|
127
128
|
applyMorphTargets: () => applyMorphTargets,
|
|
129
|
+
bakeScenegraphGPUAnimation: () => bakeScenegraphGPUAnimation,
|
|
128
130
|
cancelAnimationFramePolyfill: () => cancelAnimationFramePolyfill,
|
|
129
131
|
colorPicking: () => picking,
|
|
130
132
|
createAreaLightLTCTextures: () => createAreaLightLTCTextures,
|
|
@@ -133,11 +135,13 @@ var __exports__ = (() => {
|
|
|
133
135
|
decodeMorphTargetAttribute: () => decodeMorphTargetAttribute,
|
|
134
136
|
decomposePhysicsTransform: () => decomposePhysicsTransform,
|
|
135
137
|
deformPositions: () => deformPositions,
|
|
138
|
+
encodeSceneCapturePass: () => encodeSceneCapturePass,
|
|
136
139
|
evaluateAnimationSampler: () => evaluateAnimationSampler,
|
|
137
140
|
getFirstScenegraphInteractionHit: () => getFirstScenegraphInteractionHit,
|
|
138
141
|
getGPUVectorModelBatches: () => getGPUVectorModelBatches,
|
|
139
142
|
getIndexPickingModule: () => getIndexPickingModule,
|
|
140
143
|
getPlatformInfo: () => getPlatformInfo,
|
|
144
|
+
getScenegraphGPUPlaybackClip: () => getScenegraphGPUPlaybackClip,
|
|
141
145
|
getTextureTransformDeltaMatrix: () => getTextureTransformDeltaMatrix,
|
|
142
146
|
getTextureTransformMatrix: () => getTextureTransformMatrix,
|
|
143
147
|
indexColorPicking: () => picking2,
|
|
@@ -160,6 +164,7 @@ var __exports__ = (() => {
|
|
|
160
164
|
makeStrokeGeometry: () => makeStrokeGeometry,
|
|
161
165
|
makeTextureTransformAnimationBinding: () => makeTextureTransformAnimationBinding,
|
|
162
166
|
picking: () => picking4,
|
|
167
|
+
planScenegraphGPUAnimation: () => planScenegraphGPUAnimation,
|
|
163
168
|
publishedTransforms: () => publishedTransforms,
|
|
164
169
|
readPhysicsRotation: () => readPhysicsRotation,
|
|
165
170
|
readPhysicsVector: () => readPhysicsVector,
|
|
@@ -658,99 +663,79 @@ var __exports__ = (() => {
|
|
|
658
663
|
}
|
|
659
664
|
};
|
|
660
665
|
|
|
661
|
-
//
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
// ../../node_modules/@math.gl/core/dist/types/is-array.js
|
|
668
|
-
function isTypedArray(value) {
|
|
669
|
-
const name = getTypedArrayName(value);
|
|
670
|
-
return name !== void 0 && name !== "BigInt64Array" && name !== "BigUint64Array";
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
|
|
674
|
-
var geometryId = 0;
|
|
675
|
-
var Geometry = class {
|
|
676
|
-
constructor(props) {
|
|
677
|
-
this.userData = {};
|
|
678
|
-
this.id = props.id || `geometry-${++geometryId}`;
|
|
679
|
-
this.topology = props.topology;
|
|
680
|
-
this.attributes = {};
|
|
681
|
-
let indices = props.indices ? normalizeAttribute(props.indices) : void 0;
|
|
682
|
-
for (const [name, input] of Object.entries(props.attributes || {})) {
|
|
683
|
-
const attribute = normalizeAttribute(input);
|
|
684
|
-
if (name === "POSITION" || name === "positions") {
|
|
685
|
-
attribute.size || (attribute.size = 3);
|
|
686
|
-
}
|
|
687
|
-
if (name === "indices") {
|
|
688
|
-
if (indices)
|
|
689
|
-
throw new Error("Geometry has multiple index attributes");
|
|
690
|
-
indices = attribute;
|
|
691
|
-
} else {
|
|
692
|
-
this.attributes[name] = attribute;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
if (indices) {
|
|
696
|
-
if (!(indices.value instanceof Uint16Array || indices.value instanceof Uint32Array)) {
|
|
697
|
-
throw new Error("Geometry indices must be a Uint16Array or Uint32Array");
|
|
698
|
-
}
|
|
699
|
-
indices.size = 1;
|
|
700
|
-
this.indices = indices;
|
|
701
|
-
validateIndices(indices, this.attributes);
|
|
702
|
-
}
|
|
703
|
-
this.vertexCount = props.vertexCount ?? calculateVertexCount(this.attributes, this.indices);
|
|
704
|
-
if (!Number.isInteger(this.vertexCount) || this.vertexCount < 0) {
|
|
705
|
-
throw new Error("Geometry vertexCount must be a non-negative integer");
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
getVertexCount() {
|
|
709
|
-
return this.vertexCount;
|
|
666
|
+
// src/animation/scenegraph-gpu-animation-layout.ts
|
|
667
|
+
function planScenegraphGPUAnimation(timings, primitives, options = {}, device) {
|
|
668
|
+
const reject = (fallbackReason, estimatedByteLength2 = 0) => ({ layout: null, estimatedByteLength: estimatedByteLength2, fallbackReason });
|
|
669
|
+
if (options.enabled === false) {
|
|
670
|
+
return reject("disabled");
|
|
710
671
|
}
|
|
711
|
-
|
|
712
|
-
return
|
|
672
|
+
if (!timings.length) {
|
|
673
|
+
return reject("no-animations");
|
|
713
674
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
if (!
|
|
718
|
-
|
|
675
|
+
const sampleRate = options.sampleRate ?? 30;
|
|
676
|
+
const maxFrames = options.maxFrames ?? 8192;
|
|
677
|
+
const maxBytes = options.maxBytes ?? 64 * 1024 * 1024;
|
|
678
|
+
if (!Number.isFinite(sampleRate) || sampleRate <= 0 || !Number.isSafeInteger(maxFrames) || maxFrames <= 0 || !Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
|
|
679
|
+
return reject("invalid-options");
|
|
719
680
|
}
|
|
720
|
-
if (
|
|
721
|
-
|
|
681
|
+
if (new Set(timings.map((timing) => timing.name)).size !== timings.length) {
|
|
682
|
+
return reject("unsupported-scene");
|
|
722
683
|
}
|
|
723
|
-
|
|
724
|
-
|
|
684
|
+
let frameCount = 0;
|
|
685
|
+
const clips = [];
|
|
686
|
+
for (const { name, duration } of timings) {
|
|
687
|
+
if (!Number.isFinite(duration) || duration < 0) {
|
|
688
|
+
return reject("invalid-animation");
|
|
689
|
+
}
|
|
690
|
+
const clipFrameCount = Math.max(1, Math.ceil(duration * sampleRate) + 1);
|
|
691
|
+
if (!Number.isSafeInteger(clipFrameCount) || frameCount + clipFrameCount > maxFrames) {
|
|
692
|
+
return reject("frame-budget");
|
|
693
|
+
}
|
|
694
|
+
clips.push({
|
|
695
|
+
name,
|
|
696
|
+
duration,
|
|
697
|
+
frameOffset: frameCount,
|
|
698
|
+
frameCount: clipFrameCount
|
|
699
|
+
});
|
|
700
|
+
frameCount += clipFrameCount;
|
|
725
701
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
for (const [name, attribute] of Object.entries(attributes)) {
|
|
733
|
-
if (!attribute.constant && attribute.size) {
|
|
734
|
-
const attributeVertexCount = attribute.value.length / attribute.size;
|
|
735
|
-
if (maximumIndex >= attributeVertexCount) {
|
|
736
|
-
throw new Error(`Geometry index ${maximumIndex} exceeds ${name} vertex count ${attributeVertexCount}`);
|
|
737
|
-
}
|
|
702
|
+
let estimatedByteLength = 0;
|
|
703
|
+
let maximumAtlasByteLength = 0;
|
|
704
|
+
let maximumFrameStride = 0;
|
|
705
|
+
for (const { jointCount, morphTargetCount, count = 1 } of primitives) {
|
|
706
|
+
if (!Number.isSafeInteger(jointCount) || jointCount < 0 || !Number.isSafeInteger(morphTargetCount) || morphTargetCount < 0 || !Number.isSafeInteger(count) || count < 1) {
|
|
707
|
+
return reject("invalid-options");
|
|
738
708
|
}
|
|
709
|
+
const frameStride = getScenegraphGPUAnimationFrameStride(jointCount, morphTargetCount);
|
|
710
|
+
const atlasByteLength = frameCount * frameStride * 16;
|
|
711
|
+
maximumFrameStride = Math.max(maximumFrameStride, frameStride);
|
|
712
|
+
maximumAtlasByteLength = Math.max(maximumAtlasByteLength, atlasByteLength);
|
|
713
|
+
estimatedByteLength += atlasByteLength * count;
|
|
739
714
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
if (!attribute.constant && attribute.size) {
|
|
747
|
-
count = Math.min(count, attribute.value.length / attribute.size);
|
|
715
|
+
if (!Number.isSafeInteger(estimatedByteLength) || estimatedByteLength > maxBytes) {
|
|
716
|
+
return reject("byte-budget", estimatedByteLength);
|
|
717
|
+
}
|
|
718
|
+
if (device?.type === "webgpu") {
|
|
719
|
+
if (maximumAtlasByteLength > Math.min(device.limits.maxBufferSize, device.limits.maxStorageBufferBindingSize)) {
|
|
720
|
+
return reject("buffer-limit", estimatedByteLength);
|
|
748
721
|
}
|
|
722
|
+
} else if (device && (maximumFrameStride > device.limits.maxTextureDimension2D || frameCount > device.limits.maxTextureDimension2D)) {
|
|
723
|
+
return reject("texture-limit", estimatedByteLength);
|
|
749
724
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
725
|
+
return { layout: { sampleRate, frameCount, clips }, estimatedByteLength };
|
|
726
|
+
}
|
|
727
|
+
function getScenegraphGPUAnimationFrameStride(jointCount, morphTargetCount) {
|
|
728
|
+
return 4 + jointCount * 4 + morphTargetCount;
|
|
753
729
|
}
|
|
730
|
+
function getScenegraphGPUAnimationFrames(clip, time, sampleRate) {
|
|
731
|
+
const frame = Math.min(Math.max(time, 0) * sampleRate, clip.frameCount - 1);
|
|
732
|
+
const firstFrame = Math.floor(frame);
|
|
733
|
+
const secondFrame = Math.min(firstFrame + 1, clip.frameCount - 1);
|
|
734
|
+
return [clip.frameOffset + firstFrame, clip.frameOffset + secondFrame, frame - firstFrame];
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/animation/scenegraph-gpu-animation.ts
|
|
738
|
+
var import_core6 = __toESM(require_core(), 1);
|
|
754
739
|
|
|
755
740
|
// ../../node_modules/@math.gl/core/dist/lib/common.js
|
|
756
741
|
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
@@ -2426,6 +2411,54 @@ var __exports__ = (() => {
|
|
|
2426
2411
|
return out;
|
|
2427
2412
|
}
|
|
2428
2413
|
var ortho = orthoNO;
|
|
2414
|
+
function lookAtXAxis(out, upx, upy, upz, r0, r1, r2, z0, z1, z2) {
|
|
2415
|
+
if (!r0 && !r1 && !r2 || !upx && !upy && !upz) {
|
|
2416
|
+
return normalizeAxis(out, 0, 0, 0);
|
|
2417
|
+
}
|
|
2418
|
+
if (upy * r2 - upz * r1 !== 0 || upz * r0 - upx * r2 !== 0 || upx * r1 - upy * r0 !== 0) {
|
|
2419
|
+
normalizeAxis(out, upy * z2 - upz * z1, upz * z0 - upx * z2, upx * z1 - upy * z0);
|
|
2420
|
+
if (out[0] || out[1] || out[2]) {
|
|
2421
|
+
return out;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
const a0 = Math.abs(z0);
|
|
2425
|
+
const a1 = Math.abs(z1);
|
|
2426
|
+
const a2 = Math.abs(z2);
|
|
2427
|
+
const sign = a0 >= a1 && a0 >= a2 ? Math.sign(upx) * Math.sign(z0) : a1 >= a2 ? Math.sign(upy) * Math.sign(z1) : Math.sign(upz) * Math.sign(z2);
|
|
2428
|
+
if (a2 <= a0 && a2 <= a1) {
|
|
2429
|
+
return normalizeAxis(out, sign * z1, -sign * z0, 0);
|
|
2430
|
+
}
|
|
2431
|
+
if (a0 <= a1) {
|
|
2432
|
+
return normalizeAxis(out, 0, sign * z2, -sign * z1);
|
|
2433
|
+
}
|
|
2434
|
+
return normalizeAxis(out, -sign * z2, 0, sign * z0);
|
|
2435
|
+
}
|
|
2436
|
+
function normalizeAxis(out, x0, x1, x2) {
|
|
2437
|
+
let len2 = x0 * x0 + x1 * x1 + x2 * x2;
|
|
2438
|
+
if (len2 === 0 || len2 === Infinity) {
|
|
2439
|
+
const max = Math.max(Math.abs(x0), Math.abs(x1), Math.abs(x2));
|
|
2440
|
+
if (!max || max === Infinity) {
|
|
2441
|
+
len2 = 0;
|
|
2442
|
+
} else {
|
|
2443
|
+
x0 /= max;
|
|
2444
|
+
x1 /= max;
|
|
2445
|
+
x2 /= max;
|
|
2446
|
+
len2 = x0 * x0 + x1 * x1 + x2 * x2;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
if (len2 > 0) {
|
|
2450
|
+
len2 = 1 / Math.sqrt(len2);
|
|
2451
|
+
out[0] = x0 * len2;
|
|
2452
|
+
out[1] = x1 * len2;
|
|
2453
|
+
out[2] = x2 * len2;
|
|
2454
|
+
} else {
|
|
2455
|
+
out[0] = 0;
|
|
2456
|
+
out[1] = 0;
|
|
2457
|
+
out[2] = 0;
|
|
2458
|
+
}
|
|
2459
|
+
return out;
|
|
2460
|
+
}
|
|
2461
|
+
var lookAtAxis = [0, 0, 0];
|
|
2429
2462
|
function lookAt(out, eye, center, up) {
|
|
2430
2463
|
let len2;
|
|
2431
2464
|
let x0;
|
|
@@ -2452,24 +2485,14 @@ var __exports__ = (() => {
|
|
|
2452
2485
|
z0 = eyex - centerx;
|
|
2453
2486
|
z1 = eyey - centery;
|
|
2454
2487
|
z2 = eyez - centerz;
|
|
2488
|
+
const r0 = z0;
|
|
2489
|
+
const r1 = z1;
|
|
2490
|
+
const r2 = z2;
|
|
2455
2491
|
len2 = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
|
|
2456
2492
|
z0 *= len2;
|
|
2457
2493
|
z1 *= len2;
|
|
2458
2494
|
z2 *= len2;
|
|
2459
|
-
x0 = upy
|
|
2460
|
-
x1 = upz * z0 - upx * z2;
|
|
2461
|
-
x2 = upx * z1 - upy * z0;
|
|
2462
|
-
len2 = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
|
2463
|
-
if (!len2) {
|
|
2464
|
-
x0 = 0;
|
|
2465
|
-
x1 = 0;
|
|
2466
|
-
x2 = 0;
|
|
2467
|
-
} else {
|
|
2468
|
-
len2 = 1 / len2;
|
|
2469
|
-
x0 *= len2;
|
|
2470
|
-
x1 *= len2;
|
|
2471
|
-
x2 *= len2;
|
|
2472
|
-
}
|
|
2495
|
+
[x0, x1, x2] = lookAtXAxis(lookAtAxis, upx, upy, upz, r0, r1, r2, z0, z1, z2);
|
|
2473
2496
|
y0 = z1 * x2 - z2 * x1;
|
|
2474
2497
|
y1 = z2 * x0 - z0 * x2;
|
|
2475
2498
|
y2 = z0 * x1 - z1 * x0;
|
|
@@ -3565,118 +3588,614 @@ var __exports__ = (() => {
|
|
|
3565
3588
|
}
|
|
3566
3589
|
};
|
|
3567
3590
|
|
|
3568
|
-
//
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
}
|
|
3573
|
-
function
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
function assertSegments(value, name, minimum = 1) {
|
|
3578
|
-
if (!Number.isInteger(value) || value < minimum)
|
|
3579
|
-
throw new Error(`${name} must be an integer >= ${minimum}`);
|
|
3580
|
-
}
|
|
3581
|
-
function makeIndices(vertexCount, values) {
|
|
3582
|
-
return vertexCount > 65535 ? new Uint32Array(values) : new Uint16Array(values);
|
|
3591
|
+
// src/scenegraph/group-node.ts
|
|
3592
|
+
var import_core2 = __toESM(require_core(), 1);
|
|
3593
|
+
|
|
3594
|
+
// src/utils/uid.ts
|
|
3595
|
+
var uidCounters = {};
|
|
3596
|
+
function uid(id = "id") {
|
|
3597
|
+
uidCounters[id] = uidCounters[id] || 1;
|
|
3598
|
+
const count = uidCounters[id]++;
|
|
3599
|
+
return `${id}-${count}`;
|
|
3583
3600
|
}
|
|
3584
3601
|
|
|
3585
|
-
//
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
assertPositive(size[0], "size[0]");
|
|
3590
|
-
assertPositive(size[1], "size[1]");
|
|
3591
|
-
assertPositive(size[2], "size[2]");
|
|
3592
|
-
const half = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
3593
|
-
const positions = [];
|
|
3594
|
-
const normals = [];
|
|
3595
|
-
const texCoords = [];
|
|
3596
|
-
const indices = [];
|
|
3597
|
-
const faces = [
|
|
3598
|
-
{ n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
3599
|
-
{ n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
3600
|
-
{ n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
|
|
3601
|
-
{ n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
|
|
3602
|
-
{ n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
|
|
3603
|
-
{ n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
|
|
3604
|
-
];
|
|
3605
|
-
for (const face of faces) {
|
|
3606
|
-
const base = positions.length / 3;
|
|
3607
|
-
for (const [s, t, u, v] of [
|
|
3608
|
-
[-1, -1, 0, 0],
|
|
3609
|
-
[1, -1, 1, 0],
|
|
3610
|
-
[1, 1, 1, 1],
|
|
3611
|
-
[-1, 1, 0, 1]
|
|
3612
|
-
]) {
|
|
3613
|
-
positions.push(face.n[0] * half[0] + face.u[0] * face.h1 * s + face.v[0] * face.h2 * t, face.n[1] * half[1] + face.u[1] * face.h1 * s + face.v[1] * face.h2 * t, face.n[2] * half[2] + face.u[2] * face.h1 * s + face.v[2] * face.h2 * t);
|
|
3614
|
-
normals.push(...face.n);
|
|
3615
|
-
texCoords.push(u, v);
|
|
3616
|
-
}
|
|
3617
|
-
indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
|
|
3618
|
-
}
|
|
3619
|
-
super({
|
|
3620
|
-
id: props.id,
|
|
3621
|
-
topology: "triangle-list",
|
|
3622
|
-
indices: makeIndices(24, indices),
|
|
3623
|
-
attributes: {
|
|
3624
|
-
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
3625
|
-
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
3626
|
-
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
3627
|
-
...props.attributes
|
|
3628
|
-
}
|
|
3629
|
-
});
|
|
3602
|
+
// src/scenegraph/scenegraph-node.ts
|
|
3603
|
+
function assert2(condition, message) {
|
|
3604
|
+
if (!condition) {
|
|
3605
|
+
throw new Error(message);
|
|
3630
3606
|
}
|
|
3631
|
-
}
|
|
3632
|
-
var
|
|
3607
|
+
}
|
|
3608
|
+
var ScenegraphNode = class {
|
|
3609
|
+
id;
|
|
3610
|
+
matrix = new Matrix4();
|
|
3611
|
+
display = true;
|
|
3612
|
+
/** Local selection eligibility, independent of visibility. */
|
|
3613
|
+
selectable = true;
|
|
3614
|
+
/** Local hover eligibility, independent of visibility. */
|
|
3615
|
+
hoverable = true;
|
|
3616
|
+
position = new Vector3();
|
|
3617
|
+
rotation = new Vector3();
|
|
3618
|
+
scale = new Vector3(1, 1, 1);
|
|
3619
|
+
/** Structured metadata associated with this scene node. */
|
|
3620
|
+
metadata = {};
|
|
3621
|
+
userData = {};
|
|
3622
|
+
props = {};
|
|
3633
3623
|
constructor(props = {}) {
|
|
3634
|
-
const
|
|
3635
|
-
|
|
3624
|
+
const { id } = props;
|
|
3625
|
+
this.id = id || uid(this.constructor.name);
|
|
3626
|
+
this._setScenegraphNodeProps(props);
|
|
3636
3627
|
}
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
// ../../node_modules/@math.gl/geometry/dist/geometries/surface-of-revolution.js
|
|
3640
|
-
function makeSurfaceOfRevolution(rings, nradial) {
|
|
3641
|
-
const positions = [];
|
|
3642
|
-
const normals = [];
|
|
3643
|
-
const texCoords = [];
|
|
3644
|
-
const indices = [];
|
|
3645
|
-
const stride = nradial + 1;
|
|
3646
|
-
for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
|
|
3647
|
-
const ring = rings[ringIndex];
|
|
3648
|
-
for (let radial = 0; radial <= nradial; radial++) {
|
|
3649
|
-
const u = radial / nradial;
|
|
3650
|
-
const angle2 = u * Math.PI * 2;
|
|
3651
|
-
const sin = Math.sin(angle2);
|
|
3652
|
-
const cos = Math.cos(angle2);
|
|
3653
|
-
positions.push(sin * ring.radius, ring.y, cos * ring.radius);
|
|
3654
|
-
normals.push(sin * ring.normalRadius, ring.normalY, cos * ring.normalRadius);
|
|
3655
|
-
texCoords.push(u, ringIndex / (rings.length - 1));
|
|
3656
|
-
}
|
|
3628
|
+
getBounds() {
|
|
3629
|
+
return null;
|
|
3657
3630
|
}
|
|
3658
|
-
|
|
3659
|
-
for (let radial = 0; radial < nradial; radial++) {
|
|
3660
|
-
const a = ring * stride + radial;
|
|
3661
|
-
const b = a + 1;
|
|
3662
|
-
const c = a + stride;
|
|
3663
|
-
const d = c + 1;
|
|
3664
|
-
indices.push(a, b, d, a, d, c);
|
|
3665
|
-
}
|
|
3631
|
+
destroy() {
|
|
3666
3632
|
}
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
}
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3633
|
+
/** @deprecated use .destroy() */
|
|
3634
|
+
delete() {
|
|
3635
|
+
this.destroy();
|
|
3636
|
+
}
|
|
3637
|
+
setProps(props) {
|
|
3638
|
+
this._setScenegraphNodeProps(props);
|
|
3639
|
+
return this;
|
|
3640
|
+
}
|
|
3641
|
+
toString() {
|
|
3642
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
3643
|
+
}
|
|
3644
|
+
setPosition(position) {
|
|
3645
|
+
assert2(position.length === 3, "setPosition requires vector argument");
|
|
3646
|
+
this.position = position;
|
|
3647
|
+
return this;
|
|
3648
|
+
}
|
|
3649
|
+
setRotation(rotation) {
|
|
3650
|
+
assert2(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
3651
|
+
this.rotation = rotation;
|
|
3652
|
+
return this;
|
|
3653
|
+
}
|
|
3654
|
+
setScale(scale5) {
|
|
3655
|
+
assert2(scale5.length === 3, "setScale requires vector argument");
|
|
3656
|
+
this.scale = scale5;
|
|
3657
|
+
return this;
|
|
3658
|
+
}
|
|
3659
|
+
setMatrix(matrix, copyMatrix = true) {
|
|
3660
|
+
if (copyMatrix) {
|
|
3661
|
+
this.matrix.copy(matrix);
|
|
3662
|
+
} else {
|
|
3663
|
+
this.matrix = matrix;
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
setMatrixComponents(components2) {
|
|
3667
|
+
const { position, rotation, scale: scale5, update = true } = components2;
|
|
3668
|
+
if (position) {
|
|
3669
|
+
this.setPosition(position);
|
|
3670
|
+
}
|
|
3671
|
+
if (rotation) {
|
|
3672
|
+
this.setRotation(rotation);
|
|
3673
|
+
}
|
|
3674
|
+
if (scale5) {
|
|
3675
|
+
this.setScale(scale5);
|
|
3676
|
+
}
|
|
3677
|
+
if (update) {
|
|
3678
|
+
this.updateMatrix();
|
|
3679
|
+
}
|
|
3680
|
+
return this;
|
|
3681
|
+
}
|
|
3682
|
+
updateMatrix() {
|
|
3683
|
+
this.matrix.identity();
|
|
3684
|
+
this.matrix.translate(this.position);
|
|
3685
|
+
if (this.rotation.length === 4) {
|
|
3686
|
+
const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
|
|
3687
|
+
this.matrix.multiplyRight(rotationMatrix);
|
|
3688
|
+
} else {
|
|
3689
|
+
this.matrix.rotateXYZ(this.rotation);
|
|
3690
|
+
}
|
|
3691
|
+
this.matrix.scale(this.scale);
|
|
3692
|
+
return this;
|
|
3693
|
+
}
|
|
3694
|
+
update({ position, rotation, scale: scale5 } = {}) {
|
|
3695
|
+
if (position) {
|
|
3696
|
+
this.setPosition(position);
|
|
3697
|
+
}
|
|
3698
|
+
if (rotation) {
|
|
3699
|
+
this.setRotation(rotation);
|
|
3700
|
+
}
|
|
3701
|
+
if (scale5) {
|
|
3702
|
+
this.setScale(scale5);
|
|
3703
|
+
}
|
|
3704
|
+
this.updateMatrix();
|
|
3705
|
+
return this;
|
|
3706
|
+
}
|
|
3707
|
+
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
3708
|
+
modelMatrix = modelMatrix || this.matrix;
|
|
3709
|
+
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
3710
|
+
const worldInverse = worldMatrix.invert();
|
|
3711
|
+
const worldInverseTranspose = worldInverse.transpose();
|
|
3712
|
+
return {
|
|
3713
|
+
viewMatrix,
|
|
3714
|
+
modelMatrix,
|
|
3715
|
+
objectMatrix: modelMatrix,
|
|
3716
|
+
worldMatrix,
|
|
3717
|
+
worldInverseMatrix: worldInverse,
|
|
3718
|
+
worldInverseTransposeMatrix: worldInverseTranspose
|
|
3719
|
+
};
|
|
3720
|
+
}
|
|
3721
|
+
// TODO - copied code, not yet vetted
|
|
3722
|
+
/*
|
|
3723
|
+
transform() {
|
|
3724
|
+
if (!this.parent) {
|
|
3725
|
+
this.endPosition.set(this.position);
|
|
3726
|
+
this.endRotation.set(this.rotation);
|
|
3727
|
+
this.endScale.set(this.scale);
|
|
3728
|
+
} else {
|
|
3729
|
+
const parent = this.parent;
|
|
3730
|
+
this.endPosition.set(this.position.add(parent.endPosition));
|
|
3731
|
+
this.endRotation.set(this.rotation.add(parent.endRotation));
|
|
3732
|
+
this.endScale.set(this.scale.add(parent.endScale));
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
const ch = this.children;
|
|
3736
|
+
for (let i = 0; i < ch.length; ++i) {
|
|
3737
|
+
ch[i].transform();
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
return this;
|
|
3741
|
+
}
|
|
3742
|
+
*/
|
|
3743
|
+
_setScenegraphNodeProps(props) {
|
|
3744
|
+
if (props.selectable !== void 0) this.selectable = props.selectable;
|
|
3745
|
+
if (props.hoverable !== void 0) this.hoverable = props.hoverable;
|
|
3746
|
+
if (props.display !== void 0) {
|
|
3747
|
+
this.display = props.display;
|
|
3748
|
+
}
|
|
3749
|
+
if (props?.position) {
|
|
3750
|
+
this.setPosition(props.position);
|
|
3751
|
+
}
|
|
3752
|
+
if (props?.rotation) {
|
|
3753
|
+
this.setRotation(props.rotation);
|
|
3754
|
+
}
|
|
3755
|
+
if (props?.scale) {
|
|
3756
|
+
this.setScale(props.scale);
|
|
3757
|
+
}
|
|
3758
|
+
this.updateMatrix();
|
|
3759
|
+
if (props?.matrix) {
|
|
3760
|
+
this.setMatrix(props.matrix);
|
|
3761
|
+
}
|
|
3762
|
+
Object.assign(this.props, props);
|
|
3763
|
+
}
|
|
3764
|
+
};
|
|
3765
|
+
|
|
3766
|
+
// src/scenegraph/scenegraph-bounds.ts
|
|
3767
|
+
function makeEmptyScenegraphBounds() {
|
|
3768
|
+
return [
|
|
3769
|
+
[Infinity, Infinity, Infinity],
|
|
3770
|
+
[-Infinity, -Infinity, -Infinity]
|
|
3771
|
+
];
|
|
3772
|
+
}
|
|
3773
|
+
function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
|
|
3774
|
+
const transformMatrix = new Matrix4(transform);
|
|
3775
|
+
for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
|
|
3776
|
+
const corner = new Vector3(
|
|
3777
|
+
sourceBounds[cornerIndex & 1 ? 1 : 0][0],
|
|
3778
|
+
sourceBounds[cornerIndex & 2 ? 1 : 0][1],
|
|
3779
|
+
sourceBounds[cornerIndex & 4 ? 1 : 0][2]
|
|
3780
|
+
);
|
|
3781
|
+
transformMatrix.transformAsPoint(corner, corner);
|
|
3782
|
+
for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
|
|
3783
|
+
targetBounds[0][componentIndex] = Math.min(
|
|
3784
|
+
targetBounds[0][componentIndex],
|
|
3785
|
+
corner[componentIndex]
|
|
3786
|
+
);
|
|
3787
|
+
targetBounds[1][componentIndex] = Math.max(
|
|
3788
|
+
targetBounds[1][componentIndex],
|
|
3789
|
+
corner[componentIndex]
|
|
3790
|
+
);
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
function areScenegraphBoundsDefined(bounds) {
|
|
3795
|
+
return Number.isFinite(bounds[0][0]);
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
// src/scenegraph/group-node.ts
|
|
3799
|
+
var GroupNode = class _GroupNode extends ScenegraphNode {
|
|
3800
|
+
children;
|
|
3801
|
+
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
3802
|
+
transformSource;
|
|
3803
|
+
constructor(props = {}) {
|
|
3804
|
+
props = Array.isArray(props) ? { children: props } : props;
|
|
3805
|
+
const { children = [] } = props;
|
|
3806
|
+
import_core2.log.assert(
|
|
3807
|
+
children.every((child) => child instanceof ScenegraphNode),
|
|
3808
|
+
"every child must an instance of ScenegraphNode"
|
|
3809
|
+
);
|
|
3810
|
+
super(props);
|
|
3811
|
+
this.children = children;
|
|
3812
|
+
this.transformSource = props.transformSource ?? null;
|
|
3813
|
+
}
|
|
3814
|
+
getBounds() {
|
|
3815
|
+
const result = makeEmptyScenegraphBounds();
|
|
3816
|
+
this.traverse((node, { worldMatrix }) => {
|
|
3817
|
+
const bounds = node.getBounds();
|
|
3818
|
+
if (!bounds) {
|
|
3819
|
+
return;
|
|
3820
|
+
}
|
|
3821
|
+
const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
|
|
3822
|
+
expandScenegraphBounds(result, bounds, nodeWorldMatrix);
|
|
3823
|
+
});
|
|
3824
|
+
return areScenegraphBoundsDefined(result) ? result : null;
|
|
3825
|
+
}
|
|
3826
|
+
destroy() {
|
|
3827
|
+
this.children.forEach((child) => child.destroy());
|
|
3828
|
+
this.removeAll();
|
|
3829
|
+
super.destroy();
|
|
3830
|
+
}
|
|
3831
|
+
// Unpacks arrays and nested arrays of children
|
|
3832
|
+
add(...children) {
|
|
3833
|
+
for (const child of children) {
|
|
3834
|
+
if (Array.isArray(child)) {
|
|
3835
|
+
this.add(...child);
|
|
3836
|
+
} else {
|
|
3837
|
+
this.children.push(child);
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
return this;
|
|
3841
|
+
}
|
|
3842
|
+
remove(child) {
|
|
3843
|
+
const children = this.children;
|
|
3844
|
+
const indexOf = children.indexOf(child);
|
|
3845
|
+
if (indexOf > -1) {
|
|
3846
|
+
children.splice(indexOf, 1);
|
|
3847
|
+
}
|
|
3848
|
+
return this;
|
|
3849
|
+
}
|
|
3850
|
+
removeAll() {
|
|
3851
|
+
this.children = [];
|
|
3852
|
+
return this;
|
|
3853
|
+
}
|
|
3854
|
+
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
3855
|
+
findNode(path) {
|
|
3856
|
+
const matches = this.findNodes(path);
|
|
3857
|
+
if (matches.length > 1) {
|
|
3858
|
+
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
3859
|
+
}
|
|
3860
|
+
return matches[0];
|
|
3861
|
+
}
|
|
3862
|
+
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
3863
|
+
findNodes(path) {
|
|
3864
|
+
const anchored = path.startsWith("/");
|
|
3865
|
+
const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
|
|
3866
|
+
if (!segment || /~(?![01])/.test(segment)) {
|
|
3867
|
+
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
3868
|
+
}
|
|
3869
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
3870
|
+
});
|
|
3871
|
+
const matches = [];
|
|
3872
|
+
const ancestors = [];
|
|
3873
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3874
|
+
const pending = [{ node: this, depth: 0 }];
|
|
3875
|
+
while (pending.length) {
|
|
3876
|
+
const { node, depth } = pending.pop();
|
|
3877
|
+
(0, import_core2.assert)(!visited.has(node));
|
|
3878
|
+
visited.add(node);
|
|
3879
|
+
ancestors.length = depth;
|
|
3880
|
+
ancestors.push(node.id);
|
|
3881
|
+
const offset = ancestors.length - segments.length;
|
|
3882
|
+
if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
|
|
3883
|
+
matches.push(node);
|
|
3884
|
+
}
|
|
3885
|
+
if (node instanceof _GroupNode) {
|
|
3886
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
3887
|
+
pending.push({ node: node.children[index], depth: depth + 1 });
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
return matches;
|
|
3892
|
+
}
|
|
3893
|
+
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
3894
|
+
if (!this.display) {
|
|
3895
|
+
return;
|
|
3896
|
+
}
|
|
3897
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
3898
|
+
for (const child of this.children) {
|
|
3899
|
+
if (!child.display) {
|
|
3900
|
+
continue;
|
|
3901
|
+
}
|
|
3902
|
+
if (child instanceof _GroupNode) {
|
|
3903
|
+
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
3904
|
+
} else {
|
|
3905
|
+
visitor(child, { worldMatrix: modelMatrix });
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
/** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
|
|
3910
|
+
traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
|
|
3911
|
+
const cameraMatrix = new Matrix4(viewMatrix);
|
|
3912
|
+
const nodes = [];
|
|
3913
|
+
this.traverse(
|
|
3914
|
+
(node, context) => {
|
|
3915
|
+
const bounds = node.getBounds();
|
|
3916
|
+
const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
|
|
3917
|
+
const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
|
|
3918
|
+
nodeWorldMatrix.transformAsPoint(center, center);
|
|
3919
|
+
cameraMatrix.transformAsPoint(center, center);
|
|
3920
|
+
nodes.push({
|
|
3921
|
+
node,
|
|
3922
|
+
context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
|
|
3923
|
+
index: nodes.length
|
|
3924
|
+
});
|
|
3925
|
+
},
|
|
3926
|
+
{ worldMatrix: new Matrix4(worldMatrix) }
|
|
3927
|
+
);
|
|
3928
|
+
const direction = order === "back-to-front" ? -1 : 1;
|
|
3929
|
+
nodes.sort(
|
|
3930
|
+
(first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
|
|
3931
|
+
);
|
|
3932
|
+
for (const { node, context } of nodes) {
|
|
3933
|
+
visitor(node, context);
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
preorderTraversal(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
3937
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
3938
|
+
visitor(this, { worldMatrix: modelMatrix });
|
|
3939
|
+
for (const child of this.children) {
|
|
3940
|
+
if (child instanceof _GroupNode) {
|
|
3941
|
+
child.preorderTraversal(visitor, { worldMatrix: modelMatrix });
|
|
3942
|
+
} else {
|
|
3943
|
+
visitor(child, { worldMatrix: modelMatrix });
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
};
|
|
3948
|
+
|
|
3949
|
+
// src/scenegraph/model-node.ts
|
|
3950
|
+
var ModelNode = class extends ScenegraphNode {
|
|
3951
|
+
model;
|
|
3952
|
+
gpuAnimation;
|
|
3953
|
+
instanceMatrices;
|
|
3954
|
+
bounds = null;
|
|
3955
|
+
managedResources;
|
|
3956
|
+
// TODO - is this used? override callbacks to make sure we call them with this
|
|
3957
|
+
// onBeforeRender = null;
|
|
3958
|
+
// onAfterRender = null;
|
|
3959
|
+
// AfterRender = null;
|
|
3960
|
+
constructor(props) {
|
|
3961
|
+
super(props);
|
|
3962
|
+
this.model = props.model;
|
|
3963
|
+
this.gpuAnimation = props.gpuAnimation;
|
|
3964
|
+
this.managedResources = props.managedResources || [];
|
|
3965
|
+
this.instanceMatrices = props.instanceMatrices || null;
|
|
3966
|
+
this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
|
|
3967
|
+
this.setProps(props);
|
|
3968
|
+
}
|
|
3969
|
+
destroy() {
|
|
3970
|
+
if (this.model) {
|
|
3971
|
+
this.model.destroy();
|
|
3972
|
+
this.model = null;
|
|
3973
|
+
}
|
|
3974
|
+
this.managedResources.forEach((resource) => resource.destroy());
|
|
3975
|
+
this.managedResources = [];
|
|
3976
|
+
}
|
|
3977
|
+
getBounds() {
|
|
3978
|
+
return this.bounds;
|
|
3979
|
+
}
|
|
3980
|
+
// Expose model methods
|
|
3981
|
+
draw(renderPass) {
|
|
3982
|
+
return this.model.draw(renderPass);
|
|
3983
|
+
}
|
|
3984
|
+
};
|
|
3985
|
+
function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
3986
|
+
const instancedBounds = makeEmptyScenegraphBounds();
|
|
3987
|
+
for (const instanceMatrix of instanceMatrices) {
|
|
3988
|
+
expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
|
|
3989
|
+
}
|
|
3990
|
+
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
// ../../node_modules/@math.gl/core/dist/types/typed-array-brand.js
|
|
3994
|
+
var typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
3995
|
+
function getTypedArrayName(value) {
|
|
3996
|
+
return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : void 0;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
// ../../node_modules/@math.gl/core/dist/types/is-array.js
|
|
4000
|
+
function isTypedArray(value) {
|
|
4001
|
+
const name = getTypedArrayName(value);
|
|
4002
|
+
return name !== void 0 && name !== "BigInt64Array" && name !== "BigUint64Array";
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
// ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
|
|
4006
|
+
var geometryId = 0;
|
|
4007
|
+
var Geometry = class {
|
|
4008
|
+
constructor(props) {
|
|
4009
|
+
this.userData = {};
|
|
4010
|
+
this.id = props.id || `geometry-${++geometryId}`;
|
|
4011
|
+
this.topology = props.topology;
|
|
4012
|
+
this.attributes = {};
|
|
4013
|
+
let indices = props.indices ? normalizeAttribute(props.indices) : void 0;
|
|
4014
|
+
for (const [name, input] of Object.entries(props.attributes || {})) {
|
|
4015
|
+
const attribute = normalizeAttribute(input);
|
|
4016
|
+
if (name === "POSITION" || name === "positions") {
|
|
4017
|
+
attribute.size || (attribute.size = 3);
|
|
4018
|
+
}
|
|
4019
|
+
if (name === "indices") {
|
|
4020
|
+
if (indices)
|
|
4021
|
+
throw new Error("Geometry has multiple index attributes");
|
|
4022
|
+
indices = attribute;
|
|
4023
|
+
} else {
|
|
4024
|
+
this.attributes[name] = attribute;
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
if (indices) {
|
|
4028
|
+
if (!(indices.value instanceof Uint16Array || indices.value instanceof Uint32Array)) {
|
|
4029
|
+
throw new Error("Geometry indices must be a Uint16Array or Uint32Array");
|
|
4030
|
+
}
|
|
4031
|
+
indices.size = 1;
|
|
4032
|
+
this.indices = indices;
|
|
4033
|
+
validateIndices(indices, this.attributes);
|
|
4034
|
+
}
|
|
4035
|
+
this.vertexCount = props.vertexCount ?? calculateVertexCount(this.attributes, this.indices);
|
|
4036
|
+
if (!Number.isInteger(this.vertexCount) || this.vertexCount < 0) {
|
|
4037
|
+
throw new Error("Geometry vertexCount must be a non-negative integer");
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
getVertexCount() {
|
|
4041
|
+
return this.vertexCount;
|
|
4042
|
+
}
|
|
4043
|
+
getAttributes() {
|
|
4044
|
+
return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
|
|
4045
|
+
}
|
|
4046
|
+
};
|
|
4047
|
+
function normalizeAttribute(input) {
|
|
4048
|
+
const attribute = isTypedArray(input) ? { value: input } : { ...input };
|
|
4049
|
+
if (!isTypedArray(attribute.value)) {
|
|
4050
|
+
throw new Error("Geometry attributes must contain a typed-array value");
|
|
4051
|
+
}
|
|
4052
|
+
if (attribute.size !== void 0 && (!Number.isInteger(attribute.size) || attribute.size < 1)) {
|
|
4053
|
+
throw new Error("Geometry attribute size must be a positive integer");
|
|
4054
|
+
}
|
|
4055
|
+
if (attribute.size && attribute.value.length % attribute.size !== 0) {
|
|
4056
|
+
throw new Error("Geometry attribute length must be divisible by its size");
|
|
4057
|
+
}
|
|
4058
|
+
return attribute;
|
|
4059
|
+
}
|
|
4060
|
+
function validateIndices(indices, attributes) {
|
|
4061
|
+
let maximumIndex = -1;
|
|
4062
|
+
for (const index of indices.value)
|
|
4063
|
+
maximumIndex = Math.max(maximumIndex, Number(index));
|
|
4064
|
+
for (const [name, attribute] of Object.entries(attributes)) {
|
|
4065
|
+
if (!attribute.constant && attribute.size) {
|
|
4066
|
+
const attributeVertexCount = attribute.value.length / attribute.size;
|
|
4067
|
+
if (maximumIndex >= attributeVertexCount) {
|
|
4068
|
+
throw new Error(`Geometry index ${maximumIndex} exceeds ${name} vertex count ${attributeVertexCount}`);
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
function calculateVertexCount(attributes, indices) {
|
|
4074
|
+
if (indices)
|
|
4075
|
+
return indices.value.length;
|
|
4076
|
+
let count = Infinity;
|
|
4077
|
+
for (const attribute of Object.values(attributes)) {
|
|
4078
|
+
if (!attribute.constant && attribute.size) {
|
|
4079
|
+
count = Math.min(count, attribute.value.length / attribute.size);
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
if (!Number.isFinite(count))
|
|
4083
|
+
throw new Error("Geometry has no countable attributes");
|
|
4084
|
+
return count;
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/geometry-helpers.js
|
|
4088
|
+
function assertPositive(value, name) {
|
|
4089
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
4090
|
+
throw new Error(`${name} must be greater than zero`);
|
|
4091
|
+
}
|
|
4092
|
+
function assertNonNegative(value, name) {
|
|
4093
|
+
if (!Number.isFinite(value) || value < 0)
|
|
4094
|
+
throw new Error(`${name} must be non-negative`);
|
|
4095
|
+
}
|
|
4096
|
+
function assertSegments(value, name, minimum = 1) {
|
|
4097
|
+
if (!Number.isInteger(value) || value < minimum)
|
|
4098
|
+
throw new Error(`${name} must be an integer >= ${minimum}`);
|
|
4099
|
+
}
|
|
4100
|
+
function makeIndices(vertexCount, values) {
|
|
4101
|
+
return vertexCount > 65535 ? new Uint32Array(values) : new Uint16Array(values);
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/box-geometry.js
|
|
4105
|
+
var BoxGeometry = class extends Geometry {
|
|
4106
|
+
constructor(props = {}) {
|
|
4107
|
+
const size = props.size || [1, 1, 1];
|
|
4108
|
+
assertPositive(size[0], "size[0]");
|
|
4109
|
+
assertPositive(size[1], "size[1]");
|
|
4110
|
+
assertPositive(size[2], "size[2]");
|
|
4111
|
+
const half = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
4112
|
+
const positions = [];
|
|
4113
|
+
const normals = [];
|
|
4114
|
+
const texCoords = [];
|
|
4115
|
+
const indices = [];
|
|
4116
|
+
const faces = [
|
|
4117
|
+
{ n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
4118
|
+
{ n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
4119
|
+
{ n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
|
|
4120
|
+
{ n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
|
|
4121
|
+
{ n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
|
|
4122
|
+
{ n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
|
|
4123
|
+
];
|
|
4124
|
+
for (const face of faces) {
|
|
4125
|
+
const base = positions.length / 3;
|
|
4126
|
+
for (const [s, t, u, v] of [
|
|
4127
|
+
[-1, -1, 0, 0],
|
|
4128
|
+
[1, -1, 1, 0],
|
|
4129
|
+
[1, 1, 1, 1],
|
|
4130
|
+
[-1, 1, 0, 1]
|
|
4131
|
+
]) {
|
|
4132
|
+
positions.push(face.n[0] * half[0] + face.u[0] * face.h1 * s + face.v[0] * face.h2 * t, face.n[1] * half[1] + face.u[1] * face.h1 * s + face.v[1] * face.h2 * t, face.n[2] * half[2] + face.u[2] * face.h1 * s + face.v[2] * face.h2 * t);
|
|
4133
|
+
normals.push(...face.n);
|
|
4134
|
+
texCoords.push(u, v);
|
|
4135
|
+
}
|
|
4136
|
+
indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
|
|
4137
|
+
}
|
|
4138
|
+
super({
|
|
4139
|
+
id: props.id,
|
|
4140
|
+
topology: "triangle-list",
|
|
4141
|
+
indices: makeIndices(24, indices),
|
|
4142
|
+
attributes: {
|
|
4143
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
4144
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
4145
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
4146
|
+
...props.attributes
|
|
4147
|
+
}
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
4150
|
+
};
|
|
4151
|
+
var CubeGeometry = class extends BoxGeometry {
|
|
4152
|
+
constructor(props = {}) {
|
|
4153
|
+
const size = props.size ?? 1;
|
|
4154
|
+
super({ ...props, size: [size, size, size] });
|
|
4155
|
+
}
|
|
4156
|
+
};
|
|
4157
|
+
|
|
4158
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/surface-of-revolution.js
|
|
4159
|
+
function makeSurfaceOfRevolution(rings, nradial) {
|
|
4160
|
+
const positions = [];
|
|
4161
|
+
const normals = [];
|
|
4162
|
+
const texCoords = [];
|
|
4163
|
+
const indices = [];
|
|
4164
|
+
const stride = nradial + 1;
|
|
4165
|
+
for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
|
|
4166
|
+
const ring = rings[ringIndex];
|
|
4167
|
+
for (let radial = 0; radial <= nradial; radial++) {
|
|
4168
|
+
const u = radial / nradial;
|
|
4169
|
+
const angle2 = u * Math.PI * 2;
|
|
4170
|
+
const sin = Math.sin(angle2);
|
|
4171
|
+
const cos = Math.cos(angle2);
|
|
4172
|
+
positions.push(sin * ring.radius, ring.y, cos * ring.radius);
|
|
4173
|
+
normals.push(sin * ring.normalRadius, ring.normalY, cos * ring.normalRadius);
|
|
4174
|
+
texCoords.push(u, ringIndex / (rings.length - 1));
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
for (let ring = 0; ring < rings.length - 1; ring++) {
|
|
4178
|
+
for (let radial = 0; radial < nradial; radial++) {
|
|
4179
|
+
const a = ring * stride + radial;
|
|
4180
|
+
const b = a + 1;
|
|
4181
|
+
const c = a + stride;
|
|
4182
|
+
const d = c + 1;
|
|
4183
|
+
indices.push(a, b, d, a, d, c);
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
return {
|
|
4187
|
+
...{ positions, normals, texCoords, indices },
|
|
4188
|
+
indexArray: makeIndices(positions.length / 3, indices)
|
|
4189
|
+
};
|
|
4190
|
+
}
|
|
4191
|
+
|
|
4192
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/truncated-cone-geometry.js
|
|
4193
|
+
var TruncatedConeGeometry = class extends Geometry {
|
|
4194
|
+
constructor(props = {}) {
|
|
4195
|
+
const { topRadius = 0, bottomRadius = 0, topCap = false, bottomCap = false, height = 1, nradial = 10, nvertical = 1, verticalAxis = "y" } = props;
|
|
4196
|
+
assertNonNegative(topRadius, "topRadius");
|
|
4197
|
+
assertNonNegative(bottomRadius, "bottomRadius");
|
|
4198
|
+
if (topRadius === 0 && bottomRadius === 0)
|
|
3680
4199
|
throw new Error("At least one radius must be greater than zero");
|
|
3681
4200
|
assertPositive(height, "height");
|
|
3682
4201
|
assertSegments(nradial, "nradial", 3);
|
|
@@ -4118,7 +4637,7 @@ var __exports__ = (() => {
|
|
|
4118
4637
|
};
|
|
4119
4638
|
|
|
4120
4639
|
// src/geometry/geometry.ts
|
|
4121
|
-
var
|
|
4640
|
+
var import_core3 = __toESM(require_core(), 1);
|
|
4122
4641
|
var Geometry2 = class extends Geometry {
|
|
4123
4642
|
bufferLayout;
|
|
4124
4643
|
constructor(props) {
|
|
@@ -4171,14 +4690,14 @@ var __exports__ = (() => {
|
|
|
4171
4690
|
}
|
|
4172
4691
|
bufferLayout.push({
|
|
4173
4692
|
name: getGeometryShaderAttributeName(attributeName),
|
|
4174
|
-
format:
|
|
4693
|
+
format: import_core3.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2)
|
|
4175
4694
|
});
|
|
4176
4695
|
}
|
|
4177
4696
|
return bufferLayout;
|
|
4178
4697
|
}
|
|
4179
4698
|
|
|
4180
4699
|
// src/geometry/geometry-utils.ts
|
|
4181
|
-
var
|
|
4700
|
+
var import_core4 = __toESM(require_core(), 1);
|
|
4182
4701
|
|
|
4183
4702
|
// ../../node_modules/@math.gl/geometry/dist/lib/geometry-utils.js
|
|
4184
4703
|
function unpackIndexedGeometry(geometry) {
|
|
@@ -4230,8 +4749,8 @@ var __exports__ = (() => {
|
|
|
4230
4749
|
if (size === void 0) {
|
|
4231
4750
|
throw new Error(`Attribute ${sourceName} is missing a size`);
|
|
4232
4751
|
}
|
|
4233
|
-
const format =
|
|
4234
|
-
const vertexFormatInfo =
|
|
4752
|
+
const format = import_core4.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2);
|
|
4753
|
+
const vertexFormatInfo = import_core4.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
4235
4754
|
byteOffset = alignTo(byteOffset, minAttributeAlignment);
|
|
4236
4755
|
interleavedAttributes.push({
|
|
4237
4756
|
sourceName,
|
|
@@ -4446,6 +4965,93 @@ var __exports__ = (() => {
|
|
|
4446
4965
|
}
|
|
4447
4966
|
}
|
|
4448
4967
|
|
|
4968
|
+
// src/scenegraph/controllers/morph-controller.ts
|
|
4969
|
+
var import_core5 = __toESM(require_core(), 1);
|
|
4970
|
+
function setMorphWeights(node, weights) {
|
|
4971
|
+
node.userData["morphWeights"] = [...weights];
|
|
4972
|
+
const meshes = node.userData["morphMeshes"] || [];
|
|
4973
|
+
for (const mesh of meshes) {
|
|
4974
|
+
mesh.preorderTraversal((child) => {
|
|
4975
|
+
if (!(child instanceof ModelNode)) {
|
|
4976
|
+
return;
|
|
4977
|
+
}
|
|
4978
|
+
const state = child.userData["morphTargets"];
|
|
4979
|
+
if (!state) {
|
|
4980
|
+
return;
|
|
4981
|
+
}
|
|
4982
|
+
const gpuWeights = child.userData["morphWeightTransport"];
|
|
4983
|
+
if (gpuWeights) {
|
|
4984
|
+
updateMorphWeights(gpuWeights, weights);
|
|
4985
|
+
child.userData["morphWeights"] = [...weights];
|
|
4986
|
+
return;
|
|
4987
|
+
}
|
|
4988
|
+
updateMorphTargetBuffers(child.model, state.geometry, state.targets, weights);
|
|
4989
|
+
child.userData["morphWeights"] = [...weights];
|
|
4990
|
+
});
|
|
4991
|
+
}
|
|
4992
|
+
}
|
|
4993
|
+
function updateMorphWeights(state, weights) {
|
|
4994
|
+
state.values.fill(0);
|
|
4995
|
+
state.values.set(weights.slice(0, state.values.length));
|
|
4996
|
+
if (state.data instanceof import_core5.Buffer) {
|
|
4997
|
+
state.data.write(state.values);
|
|
4998
|
+
} else {
|
|
4999
|
+
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
|
|
5003
|
+
// src/animation/node-animation-binding.ts
|
|
5004
|
+
function makeNodeAnimationBinding(node, property, options = {}) {
|
|
5005
|
+
return {
|
|
5006
|
+
id: options.id,
|
|
5007
|
+
...property === "translation" || property === "rotation" || property === "scale" || property === "weights" ? { poseTarget: { node, property } } : {},
|
|
5008
|
+
getValue: () => {
|
|
5009
|
+
switch (property) {
|
|
5010
|
+
case "translation":
|
|
5011
|
+
return Array.from(node.position);
|
|
5012
|
+
case "rotation":
|
|
5013
|
+
return Array.from(node.rotation);
|
|
5014
|
+
case "scale":
|
|
5015
|
+
return Array.from(node.scale);
|
|
5016
|
+
case "weights":
|
|
5017
|
+
return Array.from(node.userData["morphWeights"] ?? []);
|
|
5018
|
+
case "visibility":
|
|
5019
|
+
return [node.display ? 1 : 0];
|
|
5020
|
+
case "selectable":
|
|
5021
|
+
return [node.selectable ? 1 : 0];
|
|
5022
|
+
case "hoverable":
|
|
5023
|
+
return [node.hoverable ? 1 : 0];
|
|
5024
|
+
}
|
|
5025
|
+
},
|
|
5026
|
+
setValue: (value) => {
|
|
5027
|
+
switch (property) {
|
|
5028
|
+
case "translation":
|
|
5029
|
+
node.setPosition(value).updateMatrix();
|
|
5030
|
+
break;
|
|
5031
|
+
case "rotation":
|
|
5032
|
+
node.setRotation(value).updateMatrix();
|
|
5033
|
+
break;
|
|
5034
|
+
case "scale":
|
|
5035
|
+
node.setScale(value).updateMatrix();
|
|
5036
|
+
break;
|
|
5037
|
+
case "weights":
|
|
5038
|
+
setMorphWeights(node, value);
|
|
5039
|
+
break;
|
|
5040
|
+
case "selectable":
|
|
5041
|
+
node.setProps({ selectable: value[0] !== 0 });
|
|
5042
|
+
break;
|
|
5043
|
+
case "hoverable":
|
|
5044
|
+
node.setProps({ hoverable: value[0] !== 0 });
|
|
5045
|
+
break;
|
|
5046
|
+
case "visibility":
|
|
5047
|
+
node.setProps({ display: value[0] !== 0 });
|
|
5048
|
+
options.onVisibilityChange?.();
|
|
5049
|
+
break;
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
};
|
|
5053
|
+
}
|
|
5054
|
+
|
|
4449
5055
|
// src/animation/skin.ts
|
|
4450
5056
|
function updateSkinJointMatrices(props) {
|
|
4451
5057
|
const { joints, meshNode, worldMatrices, inverseBindMatrices, target } = props;
|
|
@@ -4467,7 +5073,265 @@ var __exports__ = (() => {
|
|
|
4467
5073
|
}
|
|
4468
5074
|
jointMatrices.set(jointMatrix, offset);
|
|
4469
5075
|
}
|
|
4470
|
-
return jointMatrices;
|
|
5076
|
+
return jointMatrices;
|
|
5077
|
+
}
|
|
5078
|
+
|
|
5079
|
+
// src/animation/scenegraph-gpu-animation.ts
|
|
5080
|
+
var ScenegraphGPUAnimationResources = class {
|
|
5081
|
+
constructor(device, layout, animationJointCount, morphTargetCount, capacity = 1, id = "scenegraph-animation") {
|
|
5082
|
+
this.layout = layout;
|
|
5083
|
+
this.animationJointCount = animationJointCount;
|
|
5084
|
+
this.morphTargetCount = morphTargetCount;
|
|
5085
|
+
this.animationFrameStride = getScenegraphGPUAnimationFrameStride(
|
|
5086
|
+
animationJointCount,
|
|
5087
|
+
morphTargetCount
|
|
5088
|
+
);
|
|
5089
|
+
this.animationFrameValues = new Float32Array(layout.frameCount * this.animationFrameStride * 4);
|
|
5090
|
+
this.animationParameters = new Float32Array(capacity * 4);
|
|
5091
|
+
this.animationBlend = new Float32Array(capacity * 4);
|
|
5092
|
+
this.animationFrames = createScenegraphGPUAnimationStorage(
|
|
5093
|
+
device,
|
|
5094
|
+
`${id}-frames`,
|
|
5095
|
+
this.animationFrameValues,
|
|
5096
|
+
this.animationFrameStride,
|
|
5097
|
+
layout.frameCount
|
|
5098
|
+
);
|
|
5099
|
+
try {
|
|
5100
|
+
this.animationParameterBuffer = device.createBuffer({
|
|
5101
|
+
id: `${id}-instanceAnimationFrames`,
|
|
5102
|
+
data: this.animationParameters,
|
|
5103
|
+
usage: import_core6.Buffer.VERTEX | import_core6.Buffer.COPY_DST
|
|
5104
|
+
});
|
|
5105
|
+
try {
|
|
5106
|
+
this.animationBlendBuffer = device.createBuffer({
|
|
5107
|
+
id: `${id}-instanceAnimationBlend`,
|
|
5108
|
+
data: this.animationBlend,
|
|
5109
|
+
usage: import_core6.Buffer.VERTEX | import_core6.Buffer.COPY_DST
|
|
5110
|
+
});
|
|
5111
|
+
} catch (error) {
|
|
5112
|
+
this.animationParameterBuffer.destroy();
|
|
5113
|
+
throw error;
|
|
5114
|
+
}
|
|
5115
|
+
} catch (error) {
|
|
5116
|
+
this.animationFrames.destroy();
|
|
5117
|
+
throw error;
|
|
5118
|
+
}
|
|
5119
|
+
}
|
|
5120
|
+
layout;
|
|
5121
|
+
animationJointCount;
|
|
5122
|
+
morphTargetCount;
|
|
5123
|
+
animationFrames;
|
|
5124
|
+
animationFrameValues;
|
|
5125
|
+
animationFrameStride;
|
|
5126
|
+
animationParameters;
|
|
5127
|
+
animationParameterBuffer;
|
|
5128
|
+
animationBlend;
|
|
5129
|
+
animationBlendBuffer;
|
|
5130
|
+
/** Shader options for the shared GPU animation module. */
|
|
5131
|
+
get defines() {
|
|
5132
|
+
return {
|
|
5133
|
+
HAS_GPU_CROWD_ANIMATION: true,
|
|
5134
|
+
CROWD_ANIMATION_FRAME_STRIDE: this.animationFrameStride
|
|
5135
|
+
};
|
|
5136
|
+
}
|
|
5137
|
+
get bindings() {
|
|
5138
|
+
return { gpuAnimationFrames: this.animationFrames };
|
|
5139
|
+
}
|
|
5140
|
+
/** Vertex attributes consumed by the GPU animation shader module. */
|
|
5141
|
+
get attributes() {
|
|
5142
|
+
return {
|
|
5143
|
+
instanceAnimationFrames: this.animationParameterBuffer,
|
|
5144
|
+
instanceAnimationBlend: this.animationBlendBuffer
|
|
5145
|
+
};
|
|
5146
|
+
}
|
|
5147
|
+
get bufferLayout() {
|
|
5148
|
+
return [
|
|
5149
|
+
{ name: "instanceAnimationFrames", format: "float32x4", stepMode: "instance" },
|
|
5150
|
+
{ name: "instanceAnimationBlend", format: "float32x4", stepMode: "instance" }
|
|
5151
|
+
];
|
|
5152
|
+
}
|
|
5153
|
+
/** Uploads the baked atlas after sampling has finished. */
|
|
5154
|
+
upload() {
|
|
5155
|
+
if (this.animationFrames instanceof import_core6.Buffer) {
|
|
5156
|
+
this.animationFrames.write(this.animationFrameValues);
|
|
5157
|
+
} else {
|
|
5158
|
+
this.animationFrames.writeData(this.animationFrameValues, {
|
|
5159
|
+
width: this.animationFrameStride,
|
|
5160
|
+
height: this.layout.frameCount
|
|
5161
|
+
});
|
|
5162
|
+
}
|
|
5163
|
+
}
|
|
5164
|
+
destroy() {
|
|
5165
|
+
this.animationParameterBuffer.destroy();
|
|
5166
|
+
this.animationBlendBuffer.destroy();
|
|
5167
|
+
this.animationFrames.destroy();
|
|
5168
|
+
}
|
|
5169
|
+
};
|
|
5170
|
+
function createScenegraphGPUAnimationStorage(device, id, values, width, height) {
|
|
5171
|
+
if (device.type === "webgpu") {
|
|
5172
|
+
return device.createBuffer({ id, data: values, usage: import_core6.Buffer.STORAGE | import_core6.Buffer.COPY_DST });
|
|
5173
|
+
}
|
|
5174
|
+
const texture = device.createTexture({
|
|
5175
|
+
id,
|
|
5176
|
+
format: "rgba32float",
|
|
5177
|
+
width,
|
|
5178
|
+
height,
|
|
5179
|
+
usage: import_core6.Texture.SAMPLE | import_core6.Texture.COPY_DST,
|
|
5180
|
+
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
5181
|
+
});
|
|
5182
|
+
try {
|
|
5183
|
+
texture.writeData(values, { width, height });
|
|
5184
|
+
return texture;
|
|
5185
|
+
} catch (error) {
|
|
5186
|
+
texture.destroy();
|
|
5187
|
+
throw error;
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
function getScenegraphGPUPlaybackClip(clip) {
|
|
5191
|
+
return new AnimationClip({
|
|
5192
|
+
name: clip.name,
|
|
5193
|
+
duration: clip.duration,
|
|
5194
|
+
tracks: clip.tracks.filter((track) => !track.binding.poseTarget)
|
|
5195
|
+
});
|
|
5196
|
+
}
|
|
5197
|
+
function bakeScenegraphGPUAnimation({
|
|
5198
|
+
scenes,
|
|
5199
|
+
clips,
|
|
5200
|
+
layout,
|
|
5201
|
+
targets,
|
|
5202
|
+
skins = []
|
|
5203
|
+
}) {
|
|
5204
|
+
const poseNodes = /* @__PURE__ */ new Map();
|
|
5205
|
+
const clone2 = (source4) => {
|
|
5206
|
+
const existing = poseNodes.get(source4);
|
|
5207
|
+
if (existing) return existing;
|
|
5208
|
+
const pose = new GroupNode({ id: source4.id });
|
|
5209
|
+
poseNodes.set(source4, pose);
|
|
5210
|
+
resetPose(source4, pose);
|
|
5211
|
+
for (const child of source4.children) {
|
|
5212
|
+
if (child instanceof GroupNode) pose.add(clone2(child));
|
|
5213
|
+
}
|
|
5214
|
+
return pose;
|
|
5215
|
+
};
|
|
5216
|
+
const poseScenes = scenes.map(clone2);
|
|
5217
|
+
const bindMatrices = collectWorldMatrices(poseScenes);
|
|
5218
|
+
const poseTargets = targets.map(({ node, resources: resources2, relativeToBindPose }) => {
|
|
5219
|
+
const pose = poseNodes.get(node);
|
|
5220
|
+
(0, import_core6.assert)(pose && resources2.layout === layout);
|
|
5221
|
+
const skin = skins.find((candidate) => candidate.node === node);
|
|
5222
|
+
(0, import_core6.assert)(
|
|
5223
|
+
!skin || !resources2.animationJointCount || skin.joints.length <= resources2.animationJointCount
|
|
5224
|
+
);
|
|
5225
|
+
const joints = skin?.joints.map(clone2);
|
|
5226
|
+
return {
|
|
5227
|
+
pose,
|
|
5228
|
+
resources: resources2,
|
|
5229
|
+
inverseBind: relativeToBindPose ? new Matrix4(bindMatrices.get(pose)).invert() : null,
|
|
5230
|
+
joints,
|
|
5231
|
+
inverseBindMatrices: skin?.inverseBindMatrices
|
|
5232
|
+
};
|
|
5233
|
+
});
|
|
5234
|
+
try {
|
|
5235
|
+
const mixer = new AnimationMixer();
|
|
5236
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
5237
|
+
for (const clip of layout.clips) {
|
|
5238
|
+
mixer.stopAllAction();
|
|
5239
|
+
for (const [source4, pose] of poseNodes) resetPose(source4, pose);
|
|
5240
|
+
const sourceClip = clips.find((candidate) => candidate.name === clip.name);
|
|
5241
|
+
(0, import_core6.assert)(sourceClip);
|
|
5242
|
+
const tracks = sourceClip.tracks.flatMap((track) => {
|
|
5243
|
+
const target = track.binding.poseTarget;
|
|
5244
|
+
const pose = target && poseNodes.get(target.node);
|
|
5245
|
+
if (!pose || !target) return [];
|
|
5246
|
+
let binding = bindings.get(track.binding);
|
|
5247
|
+
if (!binding) {
|
|
5248
|
+
binding = makeNodeAnimationBinding(pose, target.property, { id: track.binding.id });
|
|
5249
|
+
bindings.set(track.binding, binding);
|
|
5250
|
+
}
|
|
5251
|
+
return [new AnimationTrack({ ...track, binding })];
|
|
5252
|
+
});
|
|
5253
|
+
const action = mixer.clipAction(
|
|
5254
|
+
new AnimationClip({
|
|
5255
|
+
name: clip.name,
|
|
5256
|
+
duration: clip.duration,
|
|
5257
|
+
tracks
|
|
5258
|
+
})
|
|
5259
|
+
).setLoop("once", 1).play();
|
|
5260
|
+
for (let frame = 0; frame < clip.frameCount; frame++) {
|
|
5261
|
+
action.setTime(Math.min(frame / layout.sampleRate, clip.duration));
|
|
5262
|
+
mixer.update(0);
|
|
5263
|
+
const matrices = collectWorldMatrices(poseScenes);
|
|
5264
|
+
for (const { pose, resources: resources2, inverseBind, joints, inverseBindMatrices } of poseTargets) {
|
|
5265
|
+
const offset = (clip.frameOffset + frame) * resources2.animationFrameStride * 4;
|
|
5266
|
+
const values = resources2.animationFrameValues;
|
|
5267
|
+
const world = matrices.get(pose);
|
|
5268
|
+
values.set(inverseBind ? new Matrix4(inverseBind).multiplyRight(world) : world, offset);
|
|
5269
|
+
if (joints && resources2.animationJointCount) {
|
|
5270
|
+
updateSkinJointMatrices({
|
|
5271
|
+
joints,
|
|
5272
|
+
meshNode: pose,
|
|
5273
|
+
worldMatrices: matrices,
|
|
5274
|
+
inverseBindMatrices,
|
|
5275
|
+
target: values.subarray(offset + 16, offset + 16 + joints.length * 16)
|
|
5276
|
+
});
|
|
5277
|
+
}
|
|
5278
|
+
const weights = pose.userData["morphWeights"];
|
|
5279
|
+
const weightOffset = offset + 16 + resources2.animationJointCount * 16;
|
|
5280
|
+
for (let index = 0; index < resources2.morphTargetCount; index++) {
|
|
5281
|
+
values[weightOffset + index * 4] = weights?.[index] ?? 0;
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
for (const { resources: resources2 } of targets) resources2.upload();
|
|
5287
|
+
} finally {
|
|
5288
|
+
for (const pose of poseNodes.values()) pose.destroy();
|
|
5289
|
+
}
|
|
5290
|
+
const resources = targets.map((target) => target.resources);
|
|
5291
|
+
const clipsByName = new Map(layout.clips.map((clip) => [clip.name, clip]));
|
|
5292
|
+
return (animator) => updateScenegraphGPUAnimation(animator, layout, clipsByName, resources);
|
|
5293
|
+
}
|
|
5294
|
+
function updateScenegraphGPUAnimation(animator, layout, clipsByName, resources) {
|
|
5295
|
+
const actions = animator.getAnimations().filter((animation) => animation.action.shouldApply && animation.action.weight > 0);
|
|
5296
|
+
(0, import_core6.assert)(actions.length <= 2);
|
|
5297
|
+
const primary = actions.find((animation) => animation.name === animator.activeClip) || actions[0];
|
|
5298
|
+
const primaryLayout = primary && clipsByName.get(primary.name) || layout.clips[0];
|
|
5299
|
+
const secondary = actions.find((animation) => animation !== primary);
|
|
5300
|
+
const secondaryLayout = secondary && clipsByName.get(secondary.name);
|
|
5301
|
+
const frames = getScenegraphGPUAnimationFrames(
|
|
5302
|
+
primaryLayout,
|
|
5303
|
+
primary?.action.time || 0,
|
|
5304
|
+
layout.sampleRate
|
|
5305
|
+
);
|
|
5306
|
+
const secondaryFrames = secondaryLayout && secondary ? getScenegraphGPUAnimationFrames(secondaryLayout, secondary.action.time, layout.sampleRate) : [0, 0, 0];
|
|
5307
|
+
const totalWeight = (primary?.action.weight || 0) + (secondary?.action.weight || 0);
|
|
5308
|
+
for (const resource of resources) {
|
|
5309
|
+
resource.animationParameters.set([...frames, primary?.action.weight || 1]);
|
|
5310
|
+
resource.animationBlend.set([
|
|
5311
|
+
...secondaryFrames,
|
|
5312
|
+
secondaryLayout && secondary && totalWeight > 0 ? secondary.action.weight / totalWeight : 0
|
|
5313
|
+
]);
|
|
5314
|
+
resource.animationParameterBuffer.write(resource.animationParameters);
|
|
5315
|
+
resource.animationBlendBuffer.write(resource.animationBlend);
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
function resetPose(source4, target) {
|
|
5319
|
+
target.setProps({
|
|
5320
|
+
position: Array.from(source4.position),
|
|
5321
|
+
rotation: Array.from(source4.rotation),
|
|
5322
|
+
scale: Array.from(source4.scale),
|
|
5323
|
+
matrix: Array.from(source4.matrix)
|
|
5324
|
+
});
|
|
5325
|
+
target.userData["morphWeights"] = source4.userData["morphWeights"];
|
|
5326
|
+
}
|
|
5327
|
+
function collectWorldMatrices(scenes) {
|
|
5328
|
+
const matrices = /* @__PURE__ */ new Map();
|
|
5329
|
+
for (const scene of scenes) {
|
|
5330
|
+
scene.preorderTraversal((node, { worldMatrix }) => {
|
|
5331
|
+
if (node instanceof GroupNode) matrices.set(node, worldMatrix);
|
|
5332
|
+
});
|
|
5333
|
+
}
|
|
5334
|
+
return matrices;
|
|
4471
5335
|
}
|
|
4472
5336
|
|
|
4473
5337
|
// src/animation/timeline.ts
|
|
@@ -4642,7 +5506,7 @@ var __exports__ = (() => {
|
|
|
4642
5506
|
};
|
|
4643
5507
|
|
|
4644
5508
|
// src/animation-loop/animation-loop.ts
|
|
4645
|
-
var
|
|
5509
|
+
var import_core7 = __toESM(require_core(), 1);
|
|
4646
5510
|
|
|
4647
5511
|
// src/animation-loop/request-animation-frame.ts
|
|
4648
5512
|
function requestAnimationFramePolyfill(callback) {
|
|
@@ -4912,7 +5776,7 @@ var __exports__ = (() => {
|
|
|
4912
5776
|
throw new Error("No device provided");
|
|
4913
5777
|
}
|
|
4914
5778
|
this.stats = props.stats || new Stats({ id: `animation-loop-${statIdCounter++}` });
|
|
4915
|
-
this.sharedStats =
|
|
5779
|
+
this.sharedStats = import_core7.luma.stats.get(ANIMATION_LOOP_STATS);
|
|
4916
5780
|
this.frameRate = this.stats.get("Frame Rate");
|
|
4917
5781
|
this.frameRate.setSampleSize(1);
|
|
4918
5782
|
this.cpuTime = this.stats.get("CPU Time");
|
|
@@ -5324,10 +6188,10 @@ var __exports__ = (() => {
|
|
|
5324
6188
|
};
|
|
5325
6189
|
|
|
5326
6190
|
// src/animation-loop/make-animation-loop.ts
|
|
5327
|
-
var
|
|
6191
|
+
var import_core8 = __toESM(require_core(), 1);
|
|
5328
6192
|
function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
5329
6193
|
let renderLoop = null;
|
|
5330
|
-
const device = props?.device ||
|
|
6194
|
+
const device = props?.device || import_core8.luma.createDevice({
|
|
5331
6195
|
id: "animation-loop",
|
|
5332
6196
|
adapters: props?.adapters,
|
|
5333
6197
|
createCanvasContext: true
|
|
@@ -5685,14 +6549,14 @@ var __exports__ = (() => {
|
|
|
5685
6549
|
}
|
|
5686
6550
|
|
|
5687
6551
|
// src/model/gpu-vector-model.ts
|
|
5688
|
-
var
|
|
6552
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
5689
6553
|
var import_shaders3 = __toESM(require_shaders(), 1);
|
|
5690
6554
|
|
|
5691
6555
|
// ../shaders/src/lib/utils/assert.ts
|
|
5692
|
-
function
|
|
6556
|
+
function assert5(condition, message) {
|
|
5693
6557
|
if (!condition) {
|
|
5694
6558
|
const error = new Error(message || "shaders: assertion failed.");
|
|
5695
|
-
Error.captureStackTrace?.(error,
|
|
6559
|
+
Error.captureStackTrace?.(error, assert5);
|
|
5696
6560
|
throw error;
|
|
5697
6561
|
}
|
|
5698
6562
|
}
|
|
@@ -5847,7 +6711,7 @@ var __exports__ = (() => {
|
|
|
5847
6711
|
const interfaceProviders = /* @__PURE__ */ new Set();
|
|
5848
6712
|
for (const module of result) {
|
|
5849
6713
|
if (module.implements !== void 0) {
|
|
5850
|
-
|
|
6714
|
+
assert5(!interfaceProviders.has(module.implements));
|
|
5851
6715
|
interfaceProviders.add(module.implements);
|
|
5852
6716
|
}
|
|
5853
6717
|
}
|
|
@@ -5875,7 +6739,7 @@ var __exports__ = (() => {
|
|
|
5875
6739
|
_transpileShader(props, modules, source4, stage) {
|
|
5876
6740
|
const sourceLanguage = props.sourceLanguage || this.shaderLanguage;
|
|
5877
6741
|
if (sourceLanguage === this.shaderLanguage) {
|
|
5878
|
-
|
|
6742
|
+
assert5(
|
|
5879
6743
|
!getShaderModuleDependencies(modules).some(
|
|
5880
6744
|
(module) => module.sourceLanguage && module.sourceLanguage !== this.shaderLanguage
|
|
5881
6745
|
)
|
|
@@ -5883,9 +6747,9 @@ var __exports__ = (() => {
|
|
|
5883
6747
|
return { code: source4 || "", modules };
|
|
5884
6748
|
}
|
|
5885
6749
|
const transpiler = this._shaderTranspilers.get(sourceLanguage);
|
|
5886
|
-
|
|
6750
|
+
assert5(transpiler);
|
|
5887
6751
|
const dependencies = getShaderModuleDependencies(modules);
|
|
5888
|
-
|
|
6752
|
+
assert5(
|
|
5889
6753
|
!dependencies.some(
|
|
5890
6754
|
(module) => module.sourceLanguage && module.sourceLanguage !== sourceLanguage && module.sourceLanguage !== this.shaderLanguage
|
|
5891
6755
|
)
|
|
@@ -6191,7 +7055,7 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6191
7055
|
const message = formatShaderModuleUniformLayoutError(validationResult);
|
|
6192
7056
|
options.log?.error?.(message, validationResult)();
|
|
6193
7057
|
if (options.throwOnError !== false) {
|
|
6194
|
-
|
|
7058
|
+
assert5(false, message);
|
|
6195
7059
|
}
|
|
6196
7060
|
return validationResult;
|
|
6197
7061
|
}
|
|
@@ -6229,17 +7093,16 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6229
7093
|
return nonStd140Blocks;
|
|
6230
7094
|
}
|
|
6231
7095
|
function extractShaderUniformBlockFieldNames(shaderSource, language, uniformBlockName) {
|
|
6232
|
-
const
|
|
7096
|
+
const uncommentedSource = stripShaderComments(shaderSource);
|
|
7097
|
+
const sourceBody = language === "wgsl" ? extractWGSLStructBody(uncommentedSource, uniformBlockName) : extractGLSLUniformBlockBody(uncommentedSource, uniformBlockName);
|
|
6233
7098
|
if (!sourceBody) {
|
|
6234
7099
|
return null;
|
|
6235
7100
|
}
|
|
6236
7101
|
const fieldNames = [];
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
}
|
|
6242
|
-
const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : line.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
|
|
7102
|
+
const declarations = language === "wgsl" ? sourceBody.split(/;|,(?=\s*[A-Za-z0-9_]+\s*:)/) : sourceBody.replace(/^\s*#.*$/gm, "").split(";");
|
|
7103
|
+
for (const declaration of declarations) {
|
|
7104
|
+
const line = declaration.replace(/\s+/g, " ").trim();
|
|
7105
|
+
const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : `${line};`.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
|
|
6243
7106
|
if (fieldMatch) {
|
|
6244
7107
|
fieldNames.push(fieldMatch[1]);
|
|
6245
7108
|
}
|
|
@@ -6399,7 +7262,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6399
7262
|
moduleSource = module.source || "";
|
|
6400
7263
|
break;
|
|
6401
7264
|
default:
|
|
6402
|
-
|
|
7265
|
+
assert5(false);
|
|
6403
7266
|
}
|
|
6404
7267
|
if (!module.name) {
|
|
6405
7268
|
throw new Error("Shader module must have a name");
|
|
@@ -7723,7 +8586,7 @@ return ${outputName};
|
|
|
7723
8586
|
prologue = true,
|
|
7724
8587
|
log: log8
|
|
7725
8588
|
} = options;
|
|
7726
|
-
|
|
8589
|
+
assert5(typeof source4 === "string", "shader source must be a string");
|
|
7727
8590
|
const sourceVersion = language === "glsl" ? getShaderInfo(source4).version : -1;
|
|
7728
8591
|
const targetVersion = platformInfo.shaderLanguageVersion;
|
|
7729
8592
|
const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
|
|
@@ -8564,7 +9427,7 @@ ${declarations.join("\n")}`).match(
|
|
|
8564
9427
|
if (masked[end] === "{") depth++;
|
|
8565
9428
|
if (masked[end] === "}") depth--;
|
|
8566
9429
|
}
|
|
8567
|
-
|
|
9430
|
+
assert5(bodyStart >= 0 && depth === 0);
|
|
8568
9431
|
const name = match[2];
|
|
8569
9432
|
const nameStart = match.index + match[0].lastIndexOf(name);
|
|
8570
9433
|
const calls = Array.from(
|
|
@@ -8805,7 +9668,7 @@ ${declarations.join("\n")}`).match(
|
|
|
8805
9668
|
fragmentEntryPoint = "fragmentMain",
|
|
8806
9669
|
log: log8
|
|
8807
9670
|
} = options;
|
|
8808
|
-
|
|
9671
|
+
assert5(typeof source4 === "string", "shader source must be a string");
|
|
8809
9672
|
const preprocessedSource = preprocess(source4, { defines });
|
|
8810
9673
|
const pluginVertexInputAssembly = assembleShaderPluginVertexInputsWGSL(
|
|
8811
9674
|
preprocessedSource,
|
|
@@ -9370,7 +10233,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9370
10233
|
};
|
|
9371
10234
|
|
|
9372
10235
|
// src/model/batch-uniform-buffer.ts
|
|
9373
|
-
var
|
|
10236
|
+
var import_core9 = __toESM(require_core(), 1);
|
|
9374
10237
|
var BatchUniformBuffer = class {
|
|
9375
10238
|
constructor(device) {
|
|
9376
10239
|
this.device = device;
|
|
@@ -9385,7 +10248,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9385
10248
|
const buffer = this.device.createBuffer({
|
|
9386
10249
|
id: "batch-uniforms",
|
|
9387
10250
|
byteLength: capacity,
|
|
9388
|
-
usage:
|
|
10251
|
+
usage: import_core9.Buffer.UNIFORM | import_core9.Buffer.COPY_DST
|
|
9389
10252
|
});
|
|
9390
10253
|
this.buffer?.destroy();
|
|
9391
10254
|
this.buffer = buffer;
|
|
@@ -9399,7 +10262,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9399
10262
|
}
|
|
9400
10263
|
/** Writes one slot without overwriting earlier batches in this call. */
|
|
9401
10264
|
write(data) {
|
|
9402
|
-
(0,
|
|
10265
|
+
(0, import_core9.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
|
|
9403
10266
|
const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
|
|
9404
10267
|
this.buffer.write(data, binding.offset);
|
|
9405
10268
|
this.byteOffset += this.getAlignedByteLength(data.byteLength);
|
|
@@ -9577,7 +10440,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9577
10440
|
}
|
|
9578
10441
|
|
|
9579
10442
|
// src/utils/buffer-layout-helper.ts
|
|
9580
|
-
var
|
|
10443
|
+
var import_core10 = __toESM(require_core(), 1);
|
|
9581
10444
|
var BufferLayoutHelper = class {
|
|
9582
10445
|
bufferLayouts;
|
|
9583
10446
|
constructor(bufferLayouts) {
|
|
@@ -9588,7 +10451,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9588
10451
|
}
|
|
9589
10452
|
/** Get attribute names from a BufferLayout */
|
|
9590
10453
|
getAttributeNamesForBuffer(bufferLayout) {
|
|
9591
|
-
return (0,
|
|
10454
|
+
return (0, import_core10.getBufferLayoutAttributeNames)(bufferLayout);
|
|
9592
10455
|
}
|
|
9593
10456
|
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
9594
10457
|
const mergedLayouts = [...bufferLayouts1];
|
|
@@ -9605,16 +10468,16 @@ ${declarations.join("\n")}`).match(
|
|
|
9605
10468
|
};
|
|
9606
10469
|
|
|
9607
10470
|
// src/utils/buffer-layout-order.ts
|
|
9608
|
-
var
|
|
10471
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
9609
10472
|
function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
9610
|
-
const shaderLayoutMap = (0,
|
|
10473
|
+
const shaderLayoutMap = (0, import_core11.getShaderAttributeLocationMap)(shaderLayout);
|
|
9611
10474
|
const sortedLayout = bufferLayout.slice();
|
|
9612
10475
|
sortedLayout.sort((a, b) => {
|
|
9613
|
-
const minLocationA = (0,
|
|
9614
|
-
(0,
|
|
10476
|
+
const minLocationA = (0, import_core11.getMinimumAttributeLocation)(
|
|
10477
|
+
(0, import_core11.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9615
10478
|
);
|
|
9616
|
-
const minLocationB = (0,
|
|
9617
|
-
(0,
|
|
10479
|
+
const minLocationB = (0, import_core11.getMinimumAttributeLocation)(
|
|
10480
|
+
(0, import_core11.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9618
10481
|
);
|
|
9619
10482
|
return minLocationA - minLocationB;
|
|
9620
10483
|
});
|
|
@@ -9646,6 +10509,9 @@ ${declarations.join("\n")}`).match(
|
|
|
9646
10509
|
if (binding && bindingLayout.visibility !== void 0) {
|
|
9647
10510
|
binding.visibility = bindingLayout.visibility;
|
|
9648
10511
|
}
|
|
10512
|
+
if (binding?.type === "texture" && bindingLayout.sampleType !== void 0) {
|
|
10513
|
+
binding.sampleType = bindingLayout.sampleType;
|
|
10514
|
+
}
|
|
9649
10515
|
}
|
|
9650
10516
|
}
|
|
9651
10517
|
}
|
|
@@ -9768,16 +10634,8 @@ ${declarations.join("\n")}`).match(
|
|
|
9768
10634
|
};
|
|
9769
10635
|
}
|
|
9770
10636
|
|
|
9771
|
-
// src/utils/uid.ts
|
|
9772
|
-
var uidCounters = {};
|
|
9773
|
-
function uid(id = "id") {
|
|
9774
|
-
uidCounters[id] = uidCounters[id] || 1;
|
|
9775
|
-
const count = uidCounters[id]++;
|
|
9776
|
-
return `${id}-${count}`;
|
|
9777
|
-
}
|
|
9778
|
-
|
|
9779
10637
|
// src/model/gpu-vector-model-batches.ts
|
|
9780
|
-
var
|
|
10638
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
9781
10639
|
function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
|
|
9782
10640
|
for (const [name, vector] of Object.entries(vectors)) {
|
|
9783
10641
|
if (!vector) continue;
|
|
@@ -9841,22 +10699,22 @@ ${declarations.join("\n")}`).match(
|
|
|
9841
10699
|
if (format.includes("<")) {
|
|
9842
10700
|
throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
|
|
9843
10701
|
}
|
|
9844
|
-
return
|
|
10702
|
+
return import_core12.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
9845
10703
|
}
|
|
9846
10704
|
|
|
9847
10705
|
// src/utils/gpu-vector-batch-structure.ts
|
|
9848
|
-
var
|
|
10706
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
9849
10707
|
function validateGPUVectorBatchStructure(vectors) {
|
|
9850
10708
|
let reference;
|
|
9851
10709
|
for (const vector of Object.values(vectors)) {
|
|
9852
10710
|
if (!vector || "isConstant" in vector) continue;
|
|
9853
10711
|
let rowCount = 0;
|
|
9854
10712
|
for (const chunk of vector.data) rowCount += chunk.length;
|
|
9855
|
-
(0,
|
|
10713
|
+
(0, import_core13.assert)(rowCount === vector.length);
|
|
9856
10714
|
if (reference) {
|
|
9857
|
-
(0,
|
|
10715
|
+
(0, import_core13.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
|
|
9858
10716
|
for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
|
|
9859
|
-
(0,
|
|
10717
|
+
(0, import_core13.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
|
|
9860
10718
|
}
|
|
9861
10719
|
} else reference = vector;
|
|
9862
10720
|
}
|
|
@@ -9949,7 +10807,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9949
10807
|
}
|
|
9950
10808
|
|
|
9951
10809
|
// src/model/gpu-vector-bindings.ts
|
|
9952
|
-
var
|
|
10810
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
9953
10811
|
var GPUVectorBindings = class {
|
|
9954
10812
|
constructor(device, id) {
|
|
9955
10813
|
this.device = device;
|
|
@@ -9974,7 +10832,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9974
10832
|
validateGPUVectorBatchStructure(columns);
|
|
9975
10833
|
} else {
|
|
9976
10834
|
for (const column of Object.values(columns)) {
|
|
9977
|
-
if (column && !isConstant(column)) (0,
|
|
10835
|
+
if (column && !isConstant(column)) (0, import_core14.assert)(column.data.length === 1);
|
|
9978
10836
|
}
|
|
9979
10837
|
}
|
|
9980
10838
|
this.claimedNames.clear();
|
|
@@ -9992,7 +10850,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9992
10850
|
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
9993
10851
|
))
|
|
9994
10852
|
return [];
|
|
9995
|
-
(0,
|
|
10853
|
+
(0, import_core14.assert)(column.format);
|
|
9996
10854
|
const format = column.format;
|
|
9997
10855
|
const byteStride = isConstant(column) ? 0 : column.byteStride;
|
|
9998
10856
|
return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
|
|
@@ -10008,10 +10866,10 @@ ${declarations.join("\n")}`).match(
|
|
|
10008
10866
|
);
|
|
10009
10867
|
const mode = layout?.stepMode ?? stepMode;
|
|
10010
10868
|
if (mode === "instance") {
|
|
10011
|
-
(0,
|
|
10869
|
+
(0, import_core14.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
|
|
10012
10870
|
this.instanceCount = column.length;
|
|
10013
10871
|
} else {
|
|
10014
|
-
(0,
|
|
10872
|
+
(0, import_core14.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
|
|
10015
10873
|
this.vertexCount = column.length;
|
|
10016
10874
|
}
|
|
10017
10875
|
this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
|
|
@@ -10056,7 +10914,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10056
10914
|
for (const definition of definitions) {
|
|
10057
10915
|
const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
|
|
10058
10916
|
if (!column) continue;
|
|
10059
|
-
(0,
|
|
10917
|
+
(0, import_core14.assert)(column.format === void 0 || column.format === definition.format);
|
|
10060
10918
|
if (isConstant(column)) {
|
|
10061
10919
|
this.constants[definition.attribute] = getShaderConstant(column);
|
|
10062
10920
|
constantByteLength = Math.max(
|
|
@@ -10083,7 +10941,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10083
10941
|
buffer = this.device.createBuffer({
|
|
10084
10942
|
id: `${this.id}-${layout.name}-constant`,
|
|
10085
10943
|
byteLength: bytes.byteLength,
|
|
10086
|
-
usage:
|
|
10944
|
+
usage: import_core14.Buffer.VERTEX | import_core14.Buffer.COPY_DST | import_core14.Buffer.COPY_SRC
|
|
10087
10945
|
});
|
|
10088
10946
|
this.constantBuffers[layout.name] = buffer;
|
|
10089
10947
|
}
|
|
@@ -10120,7 +10978,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10120
10978
|
const chunk = vector.data[0];
|
|
10121
10979
|
if (!chunk) return;
|
|
10122
10980
|
const byteOffset = chunk.byteOffset - layoutOffset;
|
|
10123
|
-
(0,
|
|
10981
|
+
(0, import_core14.assert)(byteOffset >= 0);
|
|
10124
10982
|
this.buffers[name] = chunk.buffer;
|
|
10125
10983
|
this.byteOffsets[name] = byteOffset;
|
|
10126
10984
|
}
|
|
@@ -10129,7 +10987,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10129
10987
|
return Boolean(column && "isConstant" in column && column.isConstant);
|
|
10130
10988
|
}
|
|
10131
10989
|
function getShaderConstant(column) {
|
|
10132
|
-
const information =
|
|
10990
|
+
const information = import_core14.vertexFormatDecoder.getVertexFormatInfo(column.format);
|
|
10133
10991
|
if (column.format === "unorm10-10-10-2") {
|
|
10134
10992
|
const word = column.value[0];
|
|
10135
10993
|
return new Float32Array([
|
|
@@ -10199,7 +11057,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10199
11057
|
}
|
|
10200
11058
|
|
|
10201
11059
|
// src/shader-inputs.ts
|
|
10202
|
-
var
|
|
11060
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
10203
11061
|
var import_shaders2 = __toESM(require_shaders(), 1);
|
|
10204
11062
|
|
|
10205
11063
|
// src/model/split-uniforms-and-bindings.ts
|
|
@@ -10249,7 +11107,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10249
11107
|
for (const resolvedModule of resolvedModules) {
|
|
10250
11108
|
modules[resolvedModule.name] = resolvedModule;
|
|
10251
11109
|
}
|
|
10252
|
-
|
|
11110
|
+
import_core15.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
|
|
10253
11111
|
this.modules = modules;
|
|
10254
11112
|
this.moduleUniforms = {};
|
|
10255
11113
|
this.moduleBindings = {};
|
|
@@ -10257,7 +11115,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10257
11115
|
if (module) {
|
|
10258
11116
|
this._addModule(module);
|
|
10259
11117
|
if (module.name && name !== module.name && !this.options.disableWarnings) {
|
|
10260
|
-
|
|
11118
|
+
import_core15.log.warn(`Module name: ${name} vs ${module.name}`)();
|
|
10261
11119
|
}
|
|
10262
11120
|
}
|
|
10263
11121
|
}
|
|
@@ -10281,7 +11139,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10281
11139
|
const module = this.modules[moduleName];
|
|
10282
11140
|
if (!module) {
|
|
10283
11141
|
if (!this.options.disableWarnings) {
|
|
10284
|
-
|
|
11142
|
+
import_core15.log.warn(`Module ${name} not found`)();
|
|
10285
11143
|
}
|
|
10286
11144
|
} else {
|
|
10287
11145
|
const oldUniforms = this.moduleUniforms[moduleName];
|
|
@@ -10335,7 +11193,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10335
11193
|
/**
|
|
10336
11194
|
* Gets binding values for a single shader module without flattening them into the full shader map.
|
|
10337
11195
|
*
|
|
10338
|
-
* This is used by systems such as {@link
|
|
11196
|
+
* This is used by systems such as {@link FullscreenEffectExecutor} that execute one shader module at a
|
|
10339
11197
|
* time and need the defaults for just that module.
|
|
10340
11198
|
*/
|
|
10341
11199
|
getModuleBindingValues(moduleName) {
|
|
@@ -10476,7 +11334,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10476
11334
|
var VERSION = true ? "5.0.0" : "untranspiled source";
|
|
10477
11335
|
|
|
10478
11336
|
// ../../node_modules/probe.gl/dist/log/utils/assert.js
|
|
10479
|
-
function
|
|
11337
|
+
function assert10(condition, message) {
|
|
10480
11338
|
if (!condition) {
|
|
10481
11339
|
throw new Error(message || "Assertion failed");
|
|
10482
11340
|
}
|
|
@@ -10498,7 +11356,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10498
11356
|
default:
|
|
10499
11357
|
return 0;
|
|
10500
11358
|
}
|
|
10501
|
-
|
|
11359
|
+
assert10(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
10502
11360
|
return resolvedLevel;
|
|
10503
11361
|
}
|
|
10504
11362
|
function normalizeArguments(opts) {
|
|
@@ -10524,7 +11382,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10524
11382
|
opts.message = opts.message();
|
|
10525
11383
|
}
|
|
10526
11384
|
const messageType = typeof opts.message;
|
|
10527
|
-
|
|
11385
|
+
assert10(messageType === "string" || messageType === "object");
|
|
10528
11386
|
return Object.assign(opts, { args }, opts.opts);
|
|
10529
11387
|
}
|
|
10530
11388
|
|
|
@@ -10940,7 +11798,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10940
11798
|
}
|
|
10941
11799
|
_emit(_type, normalized2) {
|
|
10942
11800
|
const method = normalized2.method;
|
|
10943
|
-
|
|
11801
|
+
assert10(method);
|
|
10944
11802
|
normalized2.total = this.getTotal();
|
|
10945
11803
|
normalized2.delta = this.getDelta();
|
|
10946
11804
|
this._deltaTs = probe.getHighResolutionTimer();
|
|
@@ -10986,10 +11844,10 @@ ${declarations.join("\n")}`).match(
|
|
|
10986
11844
|
}
|
|
10987
11845
|
|
|
10988
11846
|
// ../../node_modules/probe.gl/dist/log/index.js
|
|
10989
|
-
var
|
|
11847
|
+
var log4 = new ProbeLog({ id: "@probe.gl/log" });
|
|
10990
11848
|
|
|
10991
11849
|
// ../core/src/api/utils/log.ts
|
|
10992
|
-
var
|
|
11850
|
+
var log5 = new ProbeLog({ id: "luma.gl" });
|
|
10993
11851
|
|
|
10994
11852
|
// ../core/src/api/utils/uid.ts
|
|
10995
11853
|
var uidCounters2 = {};
|
|
@@ -11000,10 +11858,10 @@ ${declarations.join("\n")}`).match(
|
|
|
11000
11858
|
}
|
|
11001
11859
|
|
|
11002
11860
|
// ../core/src/api/utils/assert.ts
|
|
11003
|
-
function
|
|
11861
|
+
function assert11(condition, message) {
|
|
11004
11862
|
if (!condition) {
|
|
11005
11863
|
const error = new Error(message ?? "luma.gl assertion failed.");
|
|
11006
|
-
Error.captureStackTrace?.(error,
|
|
11864
|
+
Error.captureStackTrace?.(error, assert11);
|
|
11007
11865
|
throw error;
|
|
11008
11866
|
}
|
|
11009
11867
|
}
|
|
@@ -11029,11 +11887,11 @@ ${declarations.join("\n")}`).match(
|
|
|
11029
11887
|
}
|
|
11030
11888
|
/** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
|
|
11031
11889
|
transferOwnershipTo(owner) {
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11890
|
+
assert11(this._state === "live" && !this._destroyingOwnedResources);
|
|
11891
|
+
assert11(!this._owner || this._owner.canChangeOwnership());
|
|
11892
|
+
assert11(!owner || owner.canChangeOwnership());
|
|
11035
11893
|
for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
|
|
11036
|
-
|
|
11894
|
+
assert11(ancestor !== this);
|
|
11037
11895
|
}
|
|
11038
11896
|
if (owner !== this._owner) {
|
|
11039
11897
|
this._owner?._ownedResources.delete(this);
|
|
@@ -11463,7 +12321,7 @@ ${declarations.join("\n")}`).match(
|
|
|
11463
12321
|
}
|
|
11464
12322
|
|
|
11465
12323
|
// ../core/src/api/adapter/resources/buffer.ts
|
|
11466
|
-
var
|
|
12324
|
+
var Buffer6 = class _Buffer extends DeviceResource {
|
|
11467
12325
|
/** Index buffer */
|
|
11468
12326
|
static INDEX = 16;
|
|
11469
12327
|
/** Vertex buffer */
|
|
@@ -12171,7 +13029,7 @@ ${declarations.join("\n")}`).match(
|
|
|
12171
13029
|
"cube-array": "2d",
|
|
12172
13030
|
"3d": "3d"
|
|
12173
13031
|
};
|
|
12174
|
-
var
|
|
13032
|
+
var Texture3 = class _Texture extends DeviceResource {
|
|
12175
13033
|
/** The texture can be bound for use as a sampled texture in a shader */
|
|
12176
13034
|
static SAMPLE = 4;
|
|
12177
13035
|
/** The texture can be bound for use as a storage texture in a shader */
|
|
@@ -12240,7 +13098,7 @@ ${declarations.join("\n")}`).match(
|
|
|
12240
13098
|
this.width = 1;
|
|
12241
13099
|
this.height = 1;
|
|
12242
13100
|
if (this.props.width === void 0 || this.props.height === void 0) {
|
|
12243
|
-
|
|
13101
|
+
log5.warn(
|
|
12244
13102
|
`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`
|
|
12245
13103
|
)();
|
|
12246
13104
|
}
|
|
@@ -12652,13 +13510,13 @@ ${declarations.join("\n")}`).match(
|
|
|
12652
13510
|
(binding) => binding.name === bindingName || aliasName !== void 0 && binding.name.toLowerCase() === aliasName
|
|
12653
13511
|
);
|
|
12654
13512
|
if (!bindingLayout && !options?.ignoreWarnings) {
|
|
12655
|
-
|
|
13513
|
+
log5.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
|
|
12656
13514
|
}
|
|
12657
13515
|
return bindingLayout || null;
|
|
12658
13516
|
}
|
|
12659
13517
|
|
|
12660
13518
|
// ../core/src/dynamic/dynamic-buffer/dynamic-buffer.ts
|
|
12661
|
-
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH =
|
|
13519
|
+
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer6.DEBUG_DATA_MAX_LENGTH;
|
|
12662
13520
|
var DynamicBuffer = class {
|
|
12663
13521
|
/** Device that owns the backing buffer. */
|
|
12664
13522
|
device;
|
|
@@ -12725,7 +13583,7 @@ ${declarations.join("\n")}`).match(
|
|
|
12725
13583
|
usage: bufferProps.usage ?? adoptedBuffer?.usage,
|
|
12726
13584
|
indexType: bufferProps.indexType ?? adoptedBuffer?.indexType
|
|
12727
13585
|
};
|
|
12728
|
-
if ((normalizedBufferProps.usage || 0) &
|
|
13586
|
+
if ((normalizedBufferProps.usage || 0) & Buffer6.INDEX && !normalizedBufferProps.indexType) {
|
|
12729
13587
|
if (bufferProps.data instanceof Uint32Array) {
|
|
12730
13588
|
normalizedBufferProps.indexType = "uint32";
|
|
12731
13589
|
} else if (bufferProps.data instanceof Uint16Array) {
|
|
@@ -13221,11 +14079,11 @@ ${declarations.join("\n")}`).match(
|
|
|
13221
14079
|
data: void 0
|
|
13222
14080
|
};
|
|
13223
14081
|
if (this.device.isTextureFormatCompressed(resolvedFormat) && !userProvidedUsage) {
|
|
13224
|
-
baseTextureProps.usage =
|
|
14082
|
+
baseTextureProps.usage = Texture3.SAMPLE | Texture3.COPY_DST;
|
|
13225
14083
|
}
|
|
13226
14084
|
const shouldGenerateMipmaps = this.props.mipmaps && !textureData.hasExplicitMipChain && !this.device.isTextureFormatCompressed(resolvedFormat);
|
|
13227
14085
|
if (this.device.type === "webgpu" && shouldGenerateMipmaps) {
|
|
13228
|
-
const requiredUsage = this.props.dimension === "3d" ?
|
|
14086
|
+
const requiredUsage = this.props.dimension === "3d" ? Texture3.SAMPLE | Texture3.STORAGE | Texture3.COPY_DST | Texture3.COPY_SRC : Texture3.SAMPLE | Texture3.RENDER | Texture3.COPY_DST | Texture3.COPY_SRC;
|
|
13229
14087
|
baseTextureProps.usage |= requiredUsage;
|
|
13230
14088
|
}
|
|
13231
14089
|
const maxMips = this.device.getMipLevelCount(baseTextureProps.width, baseTextureProps.height);
|
|
@@ -13239,14 +14097,14 @@ ${declarations.join("\n")}`).match(
|
|
|
13239
14097
|
this._setTextureSubresources(textureData.subresources);
|
|
13240
14098
|
}
|
|
13241
14099
|
if (this.props.mipmaps && !textureData.hasExplicitMipChain && !shouldGenerateMipmaps) {
|
|
13242
|
-
|
|
14100
|
+
log5.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)();
|
|
13243
14101
|
}
|
|
13244
14102
|
if (shouldGenerateMipmaps) {
|
|
13245
14103
|
this.generateMipmaps();
|
|
13246
14104
|
}
|
|
13247
14105
|
this.isReady = true;
|
|
13248
14106
|
this.resolveReady(this.texture);
|
|
13249
|
-
|
|
14107
|
+
log5.info(1, `${this} created`)();
|
|
13250
14108
|
} catch (e) {
|
|
13251
14109
|
const err = e instanceof Error ? e : new Error(String(e));
|
|
13252
14110
|
this.rejectReady(err);
|
|
@@ -13270,7 +14128,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13270
14128
|
this.device.generateMipmapsWebGPU(this.texture);
|
|
13271
14129
|
this._touch();
|
|
13272
14130
|
} else {
|
|
13273
|
-
|
|
14131
|
+
log5.warn(`${this} mipmaps not supported on ${this.device.type}`);
|
|
13274
14132
|
}
|
|
13275
14133
|
}
|
|
13276
14134
|
/** Set sampler or create one from props */
|
|
@@ -13295,7 +14153,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13295
14153
|
const layout = this.texture.computeMemoryLayout({ width, height, depthOrArrayLayers });
|
|
13296
14154
|
const buffer = this.device.createBuffer({
|
|
13297
14155
|
byteLength: layout.byteLength,
|
|
13298
|
-
usage:
|
|
14156
|
+
usage: Buffer6.COPY_DST | Buffer6.MAP_READ
|
|
13299
14157
|
});
|
|
13300
14158
|
this.texture.readBuffer(
|
|
13301
14159
|
{
|
|
@@ -13340,7 +14198,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13340
14198
|
this._view = this.texture.view;
|
|
13341
14199
|
prev.destroy();
|
|
13342
14200
|
this._touchGeneration();
|
|
13343
|
-
|
|
14201
|
+
log5.info(`${this} resized`);
|
|
13344
14202
|
return true;
|
|
13345
14203
|
}
|
|
13346
14204
|
/** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
|
|
@@ -13446,12 +14304,12 @@ ${declarations.join("\n")}`).match(
|
|
|
13446
14304
|
}
|
|
13447
14305
|
_checkNotDestroyed() {
|
|
13448
14306
|
if (this.destroyed) {
|
|
13449
|
-
|
|
14307
|
+
log5.warn(`${this} already destroyed`);
|
|
13450
14308
|
}
|
|
13451
14309
|
}
|
|
13452
14310
|
_checkReady() {
|
|
13453
14311
|
if (!this.isReady) {
|
|
13454
|
-
|
|
14312
|
+
log5.warn(`${this} Cannot perform this operation before ready`);
|
|
13455
14313
|
}
|
|
13456
14314
|
}
|
|
13457
14315
|
_touch() {
|
|
@@ -13462,7 +14320,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13462
14320
|
this._touch();
|
|
13463
14321
|
}
|
|
13464
14322
|
static defaultProps = {
|
|
13465
|
-
...
|
|
14323
|
+
...Texture3.defaultProps,
|
|
13466
14324
|
dimension: "2d",
|
|
13467
14325
|
data: null,
|
|
13468
14326
|
mipmaps: false
|
|
@@ -13659,13 +14517,13 @@ ${declarations.join("\n")}`).match(
|
|
|
13659
14517
|
var GPUVectorModel = class _GPUVectorModel {
|
|
13660
14518
|
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
13661
14519
|
static async createAsync(device, props) {
|
|
13662
|
-
const ownsCompilation = !
|
|
13663
|
-
const asyncCompilation = ownsCompilation ?
|
|
14520
|
+
const ownsCompilation = !import_core16.PipelineFactory.getAsyncCompilation(device);
|
|
14521
|
+
const asyncCompilation = ownsCompilation ? import_core16.PipelineFactory.beginAsyncCompilation(device) : import_core16.PipelineFactory.getAsyncCompilation(device);
|
|
13664
14522
|
let model;
|
|
13665
14523
|
try {
|
|
13666
14524
|
model = new this(device, props);
|
|
13667
14525
|
} finally {
|
|
13668
|
-
if (ownsCompilation)
|
|
14526
|
+
if (ownsCompilation) import_core16.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
13669
14527
|
}
|
|
13670
14528
|
try {
|
|
13671
14529
|
if (ownsCompilation) {
|
|
@@ -13680,7 +14538,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13680
14538
|
}
|
|
13681
14539
|
}
|
|
13682
14540
|
static defaultProps = {
|
|
13683
|
-
...
|
|
14541
|
+
...import_core16.RenderPipeline.defaultProps,
|
|
13684
14542
|
inferDrawCount: "no",
|
|
13685
14543
|
enforceMatchingVectorLengths: true,
|
|
13686
14544
|
geometry: null,
|
|
@@ -13864,7 +14722,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13864
14722
|
const isWebGPU = this.device.type === "webgpu";
|
|
13865
14723
|
if (isWebGPU && this.props.source) {
|
|
13866
14724
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13867
|
-
(0,
|
|
14725
|
+
(0, import_core16.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
13868
14726
|
const {
|
|
13869
14727
|
source: source4,
|
|
13870
14728
|
getUniforms: getUniforms2,
|
|
@@ -13901,7 +14759,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13901
14759
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
13902
14760
|
} else {
|
|
13903
14761
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13904
|
-
(0,
|
|
14762
|
+
(0, import_core16.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
|
|
13905
14763
|
const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
|
|
13906
14764
|
platformInfo,
|
|
13907
14765
|
...this.props,
|
|
@@ -13917,9 +14775,9 @@ ${declarations.join("\n")}`).match(
|
|
|
13917
14775
|
this._getModuleUniforms = getUniforms2;
|
|
13918
14776
|
this._bindingTable = [];
|
|
13919
14777
|
}
|
|
13920
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
13921
|
-
this.shaderFactory = props.shaderFactory ||
|
|
13922
|
-
const asyncCompilation =
|
|
14778
|
+
this.pipelineFactory = props.pipelineFactory || import_core16.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
14779
|
+
this.shaderFactory = props.shaderFactory || import_core16.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
14780
|
+
const asyncCompilation = import_core16.PipelineFactory.getAsyncCompilation(this.device);
|
|
13923
14781
|
if (asyncCompilation) {
|
|
13924
14782
|
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
13925
14783
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -14044,22 +14902,38 @@ ${declarations.join("\n")}`).match(
|
|
|
14044
14902
|
renderPass.setParameters(state);
|
|
14045
14903
|
}
|
|
14046
14904
|
}
|
|
14047
|
-
|
|
14905
|
+
/**
|
|
14906
|
+
* Draws one caller-owned WebGPU indirect record in the open pass. The active index buffer
|
|
14907
|
+
* selects the indexed (20-byte) or non-indexed (16-byte) layout. The record supplies all
|
|
14908
|
+
* counts and offsets for this call. Subsequent direct draws use the model's own counts.
|
|
14909
|
+
* @param byteOffset Four-byte-aligned start of the record in a buffer with INDIRECT usage.
|
|
14910
|
+
* @returns Whether the draw completed using the same readiness rules as draw().
|
|
14911
|
+
*/
|
|
14912
|
+
drawIndirect(renderPass, buffer, byteOffset = 0) {
|
|
14913
|
+
(0, import_core16.assert)(this.device.type === "webgpu" && (buffer.usage & import_core16.Buffer.INDIRECT) !== 0);
|
|
14914
|
+
return this._draw(renderPass, buffer, byteOffset);
|
|
14915
|
+
}
|
|
14916
|
+
_draw(renderPass, indirectBuffer, byteOffset = 0) {
|
|
14048
14917
|
if (this.indexVector?.length === 0) {
|
|
14049
14918
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
14050
14919
|
this._needsRedraw = false;
|
|
14051
14920
|
return true;
|
|
14052
14921
|
}
|
|
14053
14922
|
if (!this.drawingVectorBatches && (this.geometryVectorBindings.batchCount !== 1 || this.attributeVectorBindings.batchCount !== 1)) {
|
|
14923
|
+
if (indirectBuffer) {
|
|
14924
|
+
(0, import_core16.assert)(
|
|
14925
|
+
this.geometryVectorBindings.batchCount <= 1 && this.attributeVectorBindings.batchCount <= 1
|
|
14926
|
+
);
|
|
14927
|
+
}
|
|
14054
14928
|
return this.drawVectorGroups(renderPass);
|
|
14055
14929
|
}
|
|
14056
14930
|
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
14057
|
-
|
|
14931
|
+
import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
14058
14932
|
return false;
|
|
14059
14933
|
}
|
|
14060
14934
|
const loadingBinding = this._areBindingsLoading();
|
|
14061
14935
|
if (loadingBinding) {
|
|
14062
|
-
|
|
14936
|
+
import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
14063
14937
|
return false;
|
|
14064
14938
|
}
|
|
14065
14939
|
this._syncAttachmentFormats(renderPass);
|
|
@@ -14083,7 +14957,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14083
14957
|
this.pipeline = this._updatePipeline();
|
|
14084
14958
|
pipelineErrored = this.pipeline.isErrored;
|
|
14085
14959
|
if (pipelineErrored) {
|
|
14086
|
-
|
|
14960
|
+
import_core16.log.info(
|
|
14087
14961
|
LOG_DRAW_PRIORITY,
|
|
14088
14962
|
`>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
|
|
14089
14963
|
)();
|
|
@@ -14091,7 +14965,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14091
14965
|
} else {
|
|
14092
14966
|
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
14093
14967
|
if (drawValidationError) {
|
|
14094
|
-
|
|
14968
|
+
import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
14095
14969
|
this._drawBlockedReason = drawValidationError;
|
|
14096
14970
|
drawSuccess = false;
|
|
14097
14971
|
} else {
|
|
@@ -14105,21 +14979,30 @@ ${declarations.join("\n")}`).match(
|
|
|
14105
14979
|
_bindGroupCacheKeys: this._getBindGroupCacheKeys()
|
|
14106
14980
|
});
|
|
14107
14981
|
renderPass.setVertexArray(this.vertexArray);
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14982
|
+
if (indirectBuffer) {
|
|
14983
|
+
if (indexBuffer) {
|
|
14984
|
+
renderPass.drawIndexedIndirect(indirectBuffer, byteOffset);
|
|
14985
|
+
} else {
|
|
14986
|
+
renderPass.drawIndirect(indirectBuffer, byteOffset);
|
|
14987
|
+
}
|
|
14988
|
+
drawSuccess = true;
|
|
14989
|
+
} else {
|
|
14990
|
+
const hasNoInstances = this.isInstanced === true && this.instanceCount === 0;
|
|
14991
|
+
drawSuccess = hasNoInstances ? true : renderPass.draw({
|
|
14992
|
+
isInstanced: this.isInstanced,
|
|
14993
|
+
vertexCount: this.vertexCount,
|
|
14994
|
+
instanceCount: this.isInstanced ? this.instanceCount : void 0,
|
|
14995
|
+
indexCount,
|
|
14996
|
+
firstVertex: this.firstVertex,
|
|
14997
|
+
firstIndex: this.firstIndex,
|
|
14998
|
+
transformFeedback: this.transformFeedback || void 0,
|
|
14999
|
+
uniforms: this.props.uniforms,
|
|
15000
|
+
// WebGL shares underlying cached programs even for models that have different
|
|
15001
|
+
// parameters and topology, so those compatibility overrides remain per draw.
|
|
15002
|
+
parameters: this.parameters,
|
|
15003
|
+
topology: this.topology
|
|
15004
|
+
});
|
|
15005
|
+
}
|
|
14123
15006
|
}
|
|
14124
15007
|
}
|
|
14125
15008
|
} finally {
|
|
@@ -14166,7 +15049,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14166
15049
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
14167
15050
|
this.syncVectorBindings();
|
|
14168
15051
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
14169
|
-
(0,
|
|
15052
|
+
(0, import_core16.assert)(
|
|
14170
15053
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
14171
15054
|
);
|
|
14172
15055
|
if (this.props.inferDrawCount === "vertex")
|
|
@@ -14203,7 +15086,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14203
15086
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
14204
15087
|
if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
|
|
14205
15088
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
14206
|
-
(0,
|
|
15089
|
+
(0, import_core16.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
14207
15090
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
14208
15091
|
}
|
|
14209
15092
|
}
|
|
@@ -14214,9 +15097,9 @@ ${declarations.join("\n")}`).match(
|
|
|
14214
15097
|
/** Replaces the borrowed contiguous uint16/uint32 index vector. */
|
|
14215
15098
|
setIndexVector(vector) {
|
|
14216
15099
|
if (vector) {
|
|
14217
|
-
(0,
|
|
14218
|
-
(0,
|
|
14219
|
-
(0,
|
|
15100
|
+
(0, import_core16.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
|
|
15101
|
+
(0, import_core16.assert)(vector.data.length <= 1);
|
|
15102
|
+
(0, import_core16.assert)(
|
|
14220
15103
|
vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
|
|
14221
15104
|
);
|
|
14222
15105
|
}
|
|
@@ -14228,7 +15111,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14228
15111
|
const chunk = vector?.data[0];
|
|
14229
15112
|
if (chunk && this.indexVector) {
|
|
14230
15113
|
const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
|
|
14231
|
-
(0,
|
|
15114
|
+
(0, import_core16.assert)(
|
|
14232
15115
|
buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
|
|
14233
15116
|
);
|
|
14234
15117
|
}
|
|
@@ -14302,7 +15185,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14302
15185
|
/** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
|
|
14303
15186
|
setGPUVectors(vectors, options) {
|
|
14304
15187
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
14305
|
-
(0,
|
|
15188
|
+
(0, import_core16.assert)(batches.length <= 1);
|
|
14306
15189
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
14307
15190
|
if (batches[0]) this.setGPUData(batches[0].data);
|
|
14308
15191
|
this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
|
|
@@ -14341,7 +15224,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14341
15224
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
14342
15225
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
14343
15226
|
for (const name of Object.keys(vectors)) {
|
|
14344
|
-
(0,
|
|
15227
|
+
(0, import_core16.assert)(!vectors[name] || this.currentAttributes[name]);
|
|
14345
15228
|
}
|
|
14346
15229
|
const previousAttributes = { ...this.currentAttributes };
|
|
14347
15230
|
const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
|
|
@@ -14351,7 +15234,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14351
15234
|
const previousIsInstanced = this.isInstanced;
|
|
14352
15235
|
const previousVertexCountSet = this._vertexCountSet;
|
|
14353
15236
|
const drawingVectorBatches = this.drawingVectorBatches;
|
|
14354
|
-
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new
|
|
15237
|
+
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core16.UniformStore(this.device, this.shaderInputs.modules) : void 0;
|
|
14355
15238
|
if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
|
|
14356
15239
|
this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
|
|
14357
15240
|
let batchByteLength = 0;
|
|
@@ -14412,7 +15295,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14412
15295
|
Object.entries(data).map(([name, chunk]) => {
|
|
14413
15296
|
const layout = this.bufferLayout.find((layout2) => layout2.name === name);
|
|
14414
15297
|
const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
|
|
14415
|
-
(0,
|
|
15298
|
+
(0, import_core16.assert)(byteOffset >= 0);
|
|
14416
15299
|
return [name, byteOffset];
|
|
14417
15300
|
})
|
|
14418
15301
|
)
|
|
@@ -14420,7 +15303,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14420
15303
|
);
|
|
14421
15304
|
}
|
|
14422
15305
|
validateVectorLengthPolicy() {
|
|
14423
|
-
(0,
|
|
15306
|
+
(0, import_core16.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
|
|
14424
15307
|
}
|
|
14425
15308
|
setBatchDrawCount(rowCount, count = this.props.inferDrawCount === "no" ? "none" : this.props.inferDrawCount) {
|
|
14426
15309
|
if (count === "instance") {
|
|
@@ -14543,7 +15426,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14543
15426
|
/** Set the shader inputs */
|
|
14544
15427
|
setShaderInputs(shaderInputs) {
|
|
14545
15428
|
this.shaderInputs = shaderInputs;
|
|
14546
|
-
this._uniformStore = new
|
|
15429
|
+
this._uniformStore = new import_core16.UniformStore(this.device, this.shaderInputs.modules);
|
|
14547
15430
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14548
15431
|
if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
|
|
14549
15432
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -14614,7 +15497,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14614
15497
|
this._drawBlockedReason = false;
|
|
14615
15498
|
const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
|
|
14616
15499
|
if (buffers["indices"]) {
|
|
14617
|
-
|
|
15500
|
+
import_core16.log.warn(
|
|
14618
15501
|
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
14619
15502
|
)();
|
|
14620
15503
|
}
|
|
@@ -14628,7 +15511,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14628
15511
|
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
14629
15512
|
if (!bufferLayout) {
|
|
14630
15513
|
if (!disableWarnings) {
|
|
14631
|
-
|
|
15514
|
+
import_core16.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
14632
15515
|
}
|
|
14633
15516
|
continue;
|
|
14634
15517
|
}
|
|
@@ -14640,7 +15523,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14640
15523
|
const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
|
|
14641
15524
|
if (bufferSlot === null) {
|
|
14642
15525
|
if (!disableWarnings) {
|
|
14643
|
-
|
|
15526
|
+
import_core16.log.warn(
|
|
14644
15527
|
`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
|
|
14645
15528
|
)();
|
|
14646
15529
|
}
|
|
@@ -14661,7 +15544,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14661
15544
|
}
|
|
14662
15545
|
}
|
|
14663
15546
|
if (!set2 && !disableWarnings) {
|
|
14664
|
-
|
|
15547
|
+
import_core16.log.warn(
|
|
14665
15548
|
`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
|
|
14666
15549
|
)();
|
|
14667
15550
|
}
|
|
@@ -14682,7 +15565,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14682
15565
|
if (attributeInfo) {
|
|
14683
15566
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
14684
15567
|
} else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
|
|
14685
|
-
|
|
15568
|
+
import_core16.log.warn(
|
|
14686
15569
|
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
14687
15570
|
)();
|
|
14688
15571
|
}
|
|
@@ -14719,7 +15602,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14719
15602
|
* @param bindings GPUVectorModel bindings already resolved for this draw preparation.
|
|
14720
15603
|
*/
|
|
14721
15604
|
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
14722
|
-
return shaderLayout.bindings.length ? (0,
|
|
15605
|
+
return shaderLayout.bindings.length ? (0, import_core16.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
|
|
14723
15606
|
}
|
|
14724
15607
|
_getBindGroupCacheKeys() {
|
|
14725
15608
|
return {};
|
|
@@ -14734,9 +15617,9 @@ ${declarations.join("\n")}`).match(
|
|
|
14734
15617
|
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
14735
15618
|
}
|
|
14736
15619
|
for (const binding of Object.values(this.bindings)) {
|
|
14737
|
-
if (binding instanceof
|
|
15620
|
+
if (binding instanceof import_core16.TextureView) {
|
|
14738
15621
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
14739
|
-
} else if (binding instanceof
|
|
15622
|
+
} else if (binding instanceof import_core16.Buffer || binding instanceof import_core16.Texture || binding instanceof import_core16.ExternalTexture) {
|
|
14740
15623
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
14741
15624
|
} else if (binding instanceof DynamicBuffer) {
|
|
14742
15625
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -14795,7 +15678,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14795
15678
|
const previousVertexShader = this.pipeline?.vs ?? null;
|
|
14796
15679
|
const previousFragmentShader = this.pipeline?.fs ?? null;
|
|
14797
15680
|
if (this.pipeline) {
|
|
14798
|
-
|
|
15681
|
+
import_core16.log.log(
|
|
14799
15682
|
1,
|
|
14800
15683
|
`GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
|
|
14801
15684
|
)();
|
|
@@ -14845,7 +15728,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14845
15728
|
};
|
|
14846
15729
|
}
|
|
14847
15730
|
_finishPipelineUpdate(update) {
|
|
14848
|
-
this._attributeInfos = (0,
|
|
15731
|
+
this._attributeInfos = (0, import_core16.getAttributeInfosFromLayouts)(
|
|
14849
15732
|
this.pipeline.shaderLayout,
|
|
14850
15733
|
this.bufferLayout
|
|
14851
15734
|
);
|
|
@@ -14861,24 +15744,24 @@ ${declarations.join("\n")}`).match(
|
|
|
14861
15744
|
_lastLogTime = 0;
|
|
14862
15745
|
_logOpen = false;
|
|
14863
15746
|
_logDrawCallStart() {
|
|
14864
|
-
const logDrawTimeout =
|
|
14865
|
-
if (
|
|
15747
|
+
const logDrawTimeout = import_core16.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
15748
|
+
if (import_core16.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
14866
15749
|
return;
|
|
14867
15750
|
}
|
|
14868
15751
|
this._lastLogTime = Date.now();
|
|
14869
15752
|
this._logOpen = true;
|
|
14870
|
-
|
|
15753
|
+
import_core16.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core16.log.level <= 2 })();
|
|
14871
15754
|
}
|
|
14872
15755
|
_logDrawCallEnd() {
|
|
14873
15756
|
if (this._logOpen) {
|
|
14874
15757
|
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
14875
|
-
|
|
15758
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
14876
15759
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
14877
|
-
|
|
15760
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
14878
15761
|
const attributeTable = this._getAttributeDebugTable();
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
15762
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
15763
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
15764
|
+
import_core16.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
14882
15765
|
this._logOpen = false;
|
|
14883
15766
|
}
|
|
14884
15767
|
}
|
|
@@ -14918,8 +15801,8 @@ ${declarations.join("\n")}`).match(
|
|
|
14918
15801
|
}
|
|
14919
15802
|
// TODO - fix typing of luma data types
|
|
14920
15803
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
14921
|
-
const TypedArrayConstructor =
|
|
14922
|
-
const typedArray = attribute instanceof
|
|
15804
|
+
const TypedArrayConstructor = import_core16.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
15805
|
+
const typedArray = attribute instanceof import_core16.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
14923
15806
|
return typedArray.toString();
|
|
14924
15807
|
}
|
|
14925
15808
|
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
@@ -15005,7 +15888,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15005
15888
|
}
|
|
15006
15889
|
|
|
15007
15890
|
// src/geometry/gpu-geometry.ts
|
|
15008
|
-
var
|
|
15891
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
15009
15892
|
var GPUGeometry = class {
|
|
15010
15893
|
/** Application-provided or generated identifier. */
|
|
15011
15894
|
id;
|
|
@@ -15030,7 +15913,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15030
15913
|
this.vertexCount = props.vertexCount;
|
|
15031
15914
|
this.bufferLayout = props.bufferLayout || [];
|
|
15032
15915
|
if (this.indices) {
|
|
15033
|
-
if (!(this.indices.usage &
|
|
15916
|
+
if (!(this.indices.usage & import_core17.Buffer.INDEX)) {
|
|
15034
15917
|
throw new Error("Index buffer must have INDEX usage");
|
|
15035
15918
|
}
|
|
15036
15919
|
}
|
|
@@ -15079,7 +15962,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15079
15962
|
return void 0;
|
|
15080
15963
|
}
|
|
15081
15964
|
const data = geometry.indices.value;
|
|
15082
|
-
return device.createBuffer({ usage:
|
|
15965
|
+
return device.createBuffer({ usage: import_core17.Buffer.INDEX, data });
|
|
15083
15966
|
}
|
|
15084
15967
|
function getAttributeBuffersFromGeometry(device, geometry) {
|
|
15085
15968
|
const attributes = {};
|
|
@@ -15119,7 +16002,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15119
16002
|
};
|
|
15120
16003
|
|
|
15121
16004
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
15122
|
-
var
|
|
16005
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
15123
16006
|
function makeGPUVectorGeometry(device, geometry) {
|
|
15124
16007
|
const gpuGeometry = makeGPUGeometry(device, geometry);
|
|
15125
16008
|
try {
|
|
@@ -15136,7 +16019,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15136
16019
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|
|
15137
16020
|
const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
|
|
15138
16021
|
const format = bufferLayout?.format;
|
|
15139
|
-
const byteStride2 = bufferLayout?.byteStride ?? (format ?
|
|
16022
|
+
const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core18.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
|
|
15140
16023
|
const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
|
|
15141
16024
|
attributes[name] = {
|
|
15142
16025
|
name,
|
|
@@ -15299,7 +16182,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15299
16182
|
};
|
|
15300
16183
|
|
|
15301
16184
|
// src/material/material.ts
|
|
15302
|
-
var
|
|
16185
|
+
var import_core19 = __toESM(require_core(), 1);
|
|
15303
16186
|
|
|
15304
16187
|
// src/material/material-factory.ts
|
|
15305
16188
|
var MATERIAL_BIND_GROUP = 3;
|
|
@@ -15403,7 +16286,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15403
16286
|
])
|
|
15404
16287
|
);
|
|
15405
16288
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
15406
|
-
this._uniformStore = new
|
|
16289
|
+
this._uniformStore = new import_core19.UniformStore(this.device, this.shaderInputs.modules);
|
|
15407
16290
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
15408
16291
|
if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
|
|
15409
16292
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -15518,9 +16401,9 @@ ${declarations.join("\n")}`).match(
|
|
|
15518
16401
|
getBindingsUpdateTimestamp() {
|
|
15519
16402
|
let timestamp = 0;
|
|
15520
16403
|
for (const binding of Object.values(this.bindings)) {
|
|
15521
|
-
if (binding instanceof
|
|
16404
|
+
if (binding instanceof import_core19.TextureView) {
|
|
15522
16405
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
15523
|
-
} else if (binding instanceof
|
|
16406
|
+
} else if (binding instanceof import_core19.Buffer || binding instanceof import_core19.Texture || binding instanceof import_core19.ExternalTexture) {
|
|
15524
16407
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
15525
16408
|
} else if (binding instanceof DynamicBuffer) {
|
|
15526
16409
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -15588,7 +16471,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15588
16471
|
}
|
|
15589
16472
|
|
|
15590
16473
|
// src/compute/buffer-transform.ts
|
|
15591
|
-
var
|
|
16474
|
+
var import_core20 = __toESM(require_core(), 1);
|
|
15592
16475
|
var import_shaders4 = __toESM(require_shaders(), 1);
|
|
15593
16476
|
var GL_INTERLEAVED_ATTRIBS = 35980;
|
|
15594
16477
|
var GL_SEPARATE_ATTRIBS = 35981;
|
|
@@ -15662,14 +16545,14 @@ ${declarations.join("\n")}`).match(
|
|
|
15662
16545
|
/** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
|
|
15663
16546
|
setOutputVectors(vectors) {
|
|
15664
16547
|
const batches = getGPUVectorModelBatches(this.model.id, vectors);
|
|
15665
|
-
(0,
|
|
15666
|
-
(0,
|
|
16548
|
+
(0, import_core20.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
|
|
16549
|
+
(0, import_core20.assert)(batches.length <= 1);
|
|
15667
16550
|
this.outputVectorBindings = vectors;
|
|
15668
16551
|
this.transformFeedback.setBuffers({
|
|
15669
16552
|
...this.outputBuffers,
|
|
15670
16553
|
...Object.fromEntries(
|
|
15671
16554
|
Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
|
|
15672
|
-
(0,
|
|
16555
|
+
(0, import_core20.assert)(data.byteStride === data.rowByteLength);
|
|
15673
16556
|
return [
|
|
15674
16557
|
name,
|
|
15675
16558
|
{
|
|
@@ -15693,7 +16576,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15693
16576
|
if (!result) {
|
|
15694
16577
|
throw new Error("BufferTransform#getBuffer");
|
|
15695
16578
|
}
|
|
15696
|
-
if (result instanceof
|
|
16579
|
+
if (result instanceof import_core20.Buffer) {
|
|
15697
16580
|
return result.readAsync();
|
|
15698
16581
|
}
|
|
15699
16582
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
@@ -16609,199 +17492,35 @@ void main(void) {
|
|
|
16609
17492
|
nradial: 16,
|
|
16610
17493
|
nvertical: 1,
|
|
16611
17494
|
radius: 1
|
|
16612
|
-
});
|
|
16613
|
-
var SpotLightModel = class extends BaseLightModel {
|
|
16614
|
-
constructor(device, props) {
|
|
16615
|
-
super(device, props, {
|
|
16616
|
-
anchorMode: "apex",
|
|
16617
|
-
buildInstanceData: buildSpotLightInstanceData,
|
|
16618
|
-
geometry: SPOT_LIGHT_GEOMETRY,
|
|
16619
|
-
idPrefix: "spot-light-model",
|
|
16620
|
-
sizePropNames: ["spotLightLength"]
|
|
16621
|
-
});
|
|
16622
|
-
}
|
|
16623
|
-
};
|
|
16624
|
-
|
|
16625
|
-
// src/models/directional-light-model.ts
|
|
16626
|
-
var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry({
|
|
16627
|
-
cap: true,
|
|
16628
|
-
nradial: 12,
|
|
16629
|
-
nvertical: 1,
|
|
16630
|
-
radius: 1
|
|
16631
|
-
});
|
|
16632
|
-
var DirectionalLightModel = class extends BaseLightModel {
|
|
16633
|
-
constructor(device, props) {
|
|
16634
|
-
super(device, props, {
|
|
16635
|
-
anchorMode: "apex",
|
|
16636
|
-
buildInstanceData: buildDirectionalLightInstanceData,
|
|
16637
|
-
geometry: DIRECTIONAL_LIGHT_GEOMETRY,
|
|
16638
|
-
idPrefix: "directional-light-model",
|
|
16639
|
-
sizePropNames: ["directionalLightLength"]
|
|
16640
|
-
});
|
|
16641
|
-
}
|
|
16642
|
-
};
|
|
16643
|
-
|
|
16644
|
-
// src/scenegraph/scenegraph-node.ts
|
|
16645
|
-
function assert11(condition, message) {
|
|
16646
|
-
if (!condition) {
|
|
16647
|
-
throw new Error(message);
|
|
16648
|
-
}
|
|
16649
|
-
}
|
|
16650
|
-
var ScenegraphNode = class {
|
|
16651
|
-
id;
|
|
16652
|
-
matrix = new Matrix4();
|
|
16653
|
-
display = true;
|
|
16654
|
-
/** Local selection eligibility, independent of visibility. */
|
|
16655
|
-
selectable = true;
|
|
16656
|
-
/** Local hover eligibility, independent of visibility. */
|
|
16657
|
-
hoverable = true;
|
|
16658
|
-
position = new Vector3();
|
|
16659
|
-
rotation = new Vector3();
|
|
16660
|
-
scale = new Vector3(1, 1, 1);
|
|
16661
|
-
/** Structured metadata associated with this scene node. */
|
|
16662
|
-
metadata = {};
|
|
16663
|
-
userData = {};
|
|
16664
|
-
props = {};
|
|
16665
|
-
constructor(props = {}) {
|
|
16666
|
-
const { id } = props;
|
|
16667
|
-
this.id = id || uid(this.constructor.name);
|
|
16668
|
-
this._setScenegraphNodeProps(props);
|
|
16669
|
-
}
|
|
16670
|
-
getBounds() {
|
|
16671
|
-
return null;
|
|
16672
|
-
}
|
|
16673
|
-
destroy() {
|
|
16674
|
-
}
|
|
16675
|
-
/** @deprecated use .destroy() */
|
|
16676
|
-
delete() {
|
|
16677
|
-
this.destroy();
|
|
16678
|
-
}
|
|
16679
|
-
setProps(props) {
|
|
16680
|
-
this._setScenegraphNodeProps(props);
|
|
16681
|
-
return this;
|
|
16682
|
-
}
|
|
16683
|
-
toString() {
|
|
16684
|
-
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
16685
|
-
}
|
|
16686
|
-
setPosition(position) {
|
|
16687
|
-
assert11(position.length === 3, "setPosition requires vector argument");
|
|
16688
|
-
this.position = position;
|
|
16689
|
-
return this;
|
|
16690
|
-
}
|
|
16691
|
-
setRotation(rotation) {
|
|
16692
|
-
assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
16693
|
-
this.rotation = rotation;
|
|
16694
|
-
return this;
|
|
16695
|
-
}
|
|
16696
|
-
setScale(scale5) {
|
|
16697
|
-
assert11(scale5.length === 3, "setScale requires vector argument");
|
|
16698
|
-
this.scale = scale5;
|
|
16699
|
-
return this;
|
|
16700
|
-
}
|
|
16701
|
-
setMatrix(matrix, copyMatrix = true) {
|
|
16702
|
-
if (copyMatrix) {
|
|
16703
|
-
this.matrix.copy(matrix);
|
|
16704
|
-
} else {
|
|
16705
|
-
this.matrix = matrix;
|
|
16706
|
-
}
|
|
16707
|
-
}
|
|
16708
|
-
setMatrixComponents(components2) {
|
|
16709
|
-
const { position, rotation, scale: scale5, update = true } = components2;
|
|
16710
|
-
if (position) {
|
|
16711
|
-
this.setPosition(position);
|
|
16712
|
-
}
|
|
16713
|
-
if (rotation) {
|
|
16714
|
-
this.setRotation(rotation);
|
|
16715
|
-
}
|
|
16716
|
-
if (scale5) {
|
|
16717
|
-
this.setScale(scale5);
|
|
16718
|
-
}
|
|
16719
|
-
if (update) {
|
|
16720
|
-
this.updateMatrix();
|
|
16721
|
-
}
|
|
16722
|
-
return this;
|
|
16723
|
-
}
|
|
16724
|
-
updateMatrix() {
|
|
16725
|
-
this.matrix.identity();
|
|
16726
|
-
this.matrix.translate(this.position);
|
|
16727
|
-
if (this.rotation.length === 4) {
|
|
16728
|
-
const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
|
|
16729
|
-
this.matrix.multiplyRight(rotationMatrix);
|
|
16730
|
-
} else {
|
|
16731
|
-
this.matrix.rotateXYZ(this.rotation);
|
|
16732
|
-
}
|
|
16733
|
-
this.matrix.scale(this.scale);
|
|
16734
|
-
return this;
|
|
16735
|
-
}
|
|
16736
|
-
update({ position, rotation, scale: scale5 } = {}) {
|
|
16737
|
-
if (position) {
|
|
16738
|
-
this.setPosition(position);
|
|
16739
|
-
}
|
|
16740
|
-
if (rotation) {
|
|
16741
|
-
this.setRotation(rotation);
|
|
16742
|
-
}
|
|
16743
|
-
if (scale5) {
|
|
16744
|
-
this.setScale(scale5);
|
|
16745
|
-
}
|
|
16746
|
-
this.updateMatrix();
|
|
16747
|
-
return this;
|
|
16748
|
-
}
|
|
16749
|
-
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
16750
|
-
modelMatrix = modelMatrix || this.matrix;
|
|
16751
|
-
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
16752
|
-
const worldInverse = worldMatrix.invert();
|
|
16753
|
-
const worldInverseTranspose = worldInverse.transpose();
|
|
16754
|
-
return {
|
|
16755
|
-
viewMatrix,
|
|
16756
|
-
modelMatrix,
|
|
16757
|
-
objectMatrix: modelMatrix,
|
|
16758
|
-
worldMatrix,
|
|
16759
|
-
worldInverseMatrix: worldInverse,
|
|
16760
|
-
worldInverseTransposeMatrix: worldInverseTranspose
|
|
16761
|
-
};
|
|
16762
|
-
}
|
|
16763
|
-
// TODO - copied code, not yet vetted
|
|
16764
|
-
/*
|
|
16765
|
-
transform() {
|
|
16766
|
-
if (!this.parent) {
|
|
16767
|
-
this.endPosition.set(this.position);
|
|
16768
|
-
this.endRotation.set(this.rotation);
|
|
16769
|
-
this.endScale.set(this.scale);
|
|
16770
|
-
} else {
|
|
16771
|
-
const parent = this.parent;
|
|
16772
|
-
this.endPosition.set(this.position.add(parent.endPosition));
|
|
16773
|
-
this.endRotation.set(this.rotation.add(parent.endRotation));
|
|
16774
|
-
this.endScale.set(this.scale.add(parent.endScale));
|
|
16775
|
-
}
|
|
16776
|
-
|
|
16777
|
-
const ch = this.children;
|
|
16778
|
-
for (let i = 0; i < ch.length; ++i) {
|
|
16779
|
-
ch[i].transform();
|
|
16780
|
-
}
|
|
16781
|
-
|
|
16782
|
-
return this;
|
|
16783
|
-
}
|
|
16784
|
-
*/
|
|
16785
|
-
_setScenegraphNodeProps(props) {
|
|
16786
|
-
if (props.selectable !== void 0) this.selectable = props.selectable;
|
|
16787
|
-
if (props.hoverable !== void 0) this.hoverable = props.hoverable;
|
|
16788
|
-
if (props.display !== void 0) {
|
|
16789
|
-
this.display = props.display;
|
|
16790
|
-
}
|
|
16791
|
-
if (props?.position) {
|
|
16792
|
-
this.setPosition(props.position);
|
|
16793
|
-
}
|
|
16794
|
-
if (props?.rotation) {
|
|
16795
|
-
this.setRotation(props.rotation);
|
|
16796
|
-
}
|
|
16797
|
-
if (props?.scale) {
|
|
16798
|
-
this.setScale(props.scale);
|
|
16799
|
-
}
|
|
16800
|
-
this.updateMatrix();
|
|
16801
|
-
if (props?.matrix) {
|
|
16802
|
-
this.setMatrix(props.matrix);
|
|
16803
|
-
}
|
|
16804
|
-
Object.assign(this.props, props);
|
|
17495
|
+
});
|
|
17496
|
+
var SpotLightModel = class extends BaseLightModel {
|
|
17497
|
+
constructor(device, props) {
|
|
17498
|
+
super(device, props, {
|
|
17499
|
+
anchorMode: "apex",
|
|
17500
|
+
buildInstanceData: buildSpotLightInstanceData,
|
|
17501
|
+
geometry: SPOT_LIGHT_GEOMETRY,
|
|
17502
|
+
idPrefix: "spot-light-model",
|
|
17503
|
+
sizePropNames: ["spotLightLength"]
|
|
17504
|
+
});
|
|
17505
|
+
}
|
|
17506
|
+
};
|
|
17507
|
+
|
|
17508
|
+
// src/models/directional-light-model.ts
|
|
17509
|
+
var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry({
|
|
17510
|
+
cap: true,
|
|
17511
|
+
nradial: 12,
|
|
17512
|
+
nvertical: 1,
|
|
17513
|
+
radius: 1
|
|
17514
|
+
});
|
|
17515
|
+
var DirectionalLightModel = class extends BaseLightModel {
|
|
17516
|
+
constructor(device, props) {
|
|
17517
|
+
super(device, props, {
|
|
17518
|
+
anchorMode: "apex",
|
|
17519
|
+
buildInstanceData: buildDirectionalLightInstanceData,
|
|
17520
|
+
geometry: DIRECTIONAL_LIGHT_GEOMETRY,
|
|
17521
|
+
idPrefix: "directional-light-model",
|
|
17522
|
+
sizePropNames: ["directionalLightLength"]
|
|
17523
|
+
});
|
|
16805
17524
|
}
|
|
16806
17525
|
};
|
|
16807
17526
|
|
|
@@ -16889,262 +17608,34 @@ void main(void) {
|
|
|
16889
17608
|
}
|
|
16890
17609
|
};
|
|
16891
17610
|
|
|
16892
|
-
// src/scenegraph/group-node.ts
|
|
16893
|
-
var import_core18 = __toESM(require_core(), 1);
|
|
16894
|
-
|
|
16895
|
-
// src/scenegraph/scenegraph-bounds.ts
|
|
16896
|
-
function makeEmptyScenegraphBounds() {
|
|
16897
|
-
return [
|
|
16898
|
-
[Infinity, Infinity, Infinity],
|
|
16899
|
-
[-Infinity, -Infinity, -Infinity]
|
|
16900
|
-
];
|
|
16901
|
-
}
|
|
16902
|
-
function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
|
|
16903
|
-
const transformMatrix = new Matrix4(transform);
|
|
16904
|
-
for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
|
|
16905
|
-
const corner = new Vector3(
|
|
16906
|
-
sourceBounds[cornerIndex & 1 ? 1 : 0][0],
|
|
16907
|
-
sourceBounds[cornerIndex & 2 ? 1 : 0][1],
|
|
16908
|
-
sourceBounds[cornerIndex & 4 ? 1 : 0][2]
|
|
16909
|
-
);
|
|
16910
|
-
transformMatrix.transformAsPoint(corner, corner);
|
|
16911
|
-
for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
|
|
16912
|
-
targetBounds[0][componentIndex] = Math.min(
|
|
16913
|
-
targetBounds[0][componentIndex],
|
|
16914
|
-
corner[componentIndex]
|
|
16915
|
-
);
|
|
16916
|
-
targetBounds[1][componentIndex] = Math.max(
|
|
16917
|
-
targetBounds[1][componentIndex],
|
|
16918
|
-
corner[componentIndex]
|
|
16919
|
-
);
|
|
16920
|
-
}
|
|
16921
|
-
}
|
|
16922
|
-
}
|
|
16923
|
-
function areScenegraphBoundsDefined(bounds) {
|
|
16924
|
-
return Number.isFinite(bounds[0][0]);
|
|
16925
|
-
}
|
|
16926
|
-
|
|
16927
|
-
// src/scenegraph/group-node.ts
|
|
16928
|
-
var GroupNode = class _GroupNode extends ScenegraphNode {
|
|
16929
|
-
children;
|
|
16930
|
-
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
16931
|
-
transformSource;
|
|
16932
|
-
constructor(props = {}) {
|
|
16933
|
-
props = Array.isArray(props) ? { children: props } : props;
|
|
16934
|
-
const { children = [] } = props;
|
|
16935
|
-
import_core18.log.assert(
|
|
16936
|
-
children.every((child) => child instanceof ScenegraphNode),
|
|
16937
|
-
"every child must an instance of ScenegraphNode"
|
|
16938
|
-
);
|
|
16939
|
-
super(props);
|
|
16940
|
-
this.children = children;
|
|
16941
|
-
this.transformSource = props.transformSource ?? null;
|
|
16942
|
-
}
|
|
16943
|
-
getBounds() {
|
|
16944
|
-
const result = makeEmptyScenegraphBounds();
|
|
16945
|
-
this.traverse((node, { worldMatrix }) => {
|
|
16946
|
-
const bounds = node.getBounds();
|
|
16947
|
-
if (!bounds) {
|
|
16948
|
-
return;
|
|
16949
|
-
}
|
|
16950
|
-
const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
|
|
16951
|
-
expandScenegraphBounds(result, bounds, nodeWorldMatrix);
|
|
16952
|
-
});
|
|
16953
|
-
return areScenegraphBoundsDefined(result) ? result : null;
|
|
16954
|
-
}
|
|
16955
|
-
destroy() {
|
|
16956
|
-
this.children.forEach((child) => child.destroy());
|
|
16957
|
-
this.removeAll();
|
|
16958
|
-
super.destroy();
|
|
16959
|
-
}
|
|
16960
|
-
// Unpacks arrays and nested arrays of children
|
|
16961
|
-
add(...children) {
|
|
16962
|
-
for (const child of children) {
|
|
16963
|
-
if (Array.isArray(child)) {
|
|
16964
|
-
this.add(...child);
|
|
16965
|
-
} else {
|
|
16966
|
-
this.children.push(child);
|
|
16967
|
-
}
|
|
16968
|
-
}
|
|
16969
|
-
return this;
|
|
16970
|
-
}
|
|
16971
|
-
remove(child) {
|
|
16972
|
-
const children = this.children;
|
|
16973
|
-
const indexOf = children.indexOf(child);
|
|
16974
|
-
if (indexOf > -1) {
|
|
16975
|
-
children.splice(indexOf, 1);
|
|
16976
|
-
}
|
|
16977
|
-
return this;
|
|
16978
|
-
}
|
|
16979
|
-
removeAll() {
|
|
16980
|
-
this.children = [];
|
|
16981
|
-
return this;
|
|
16982
|
-
}
|
|
16983
|
-
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
16984
|
-
findNode(path) {
|
|
16985
|
-
const matches = this.findNodes(path);
|
|
16986
|
-
if (matches.length > 1) {
|
|
16987
|
-
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
16988
|
-
}
|
|
16989
|
-
return matches[0];
|
|
16990
|
-
}
|
|
16991
|
-
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
16992
|
-
findNodes(path) {
|
|
16993
|
-
const anchored = path.startsWith("/");
|
|
16994
|
-
const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
|
|
16995
|
-
if (!segment || /~(?![01])/.test(segment)) {
|
|
16996
|
-
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
16997
|
-
}
|
|
16998
|
-
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
16999
|
-
});
|
|
17000
|
-
const matches = [];
|
|
17001
|
-
const ancestors = [];
|
|
17002
|
-
const visited = /* @__PURE__ */ new Set();
|
|
17003
|
-
const pending = [{ node: this, depth: 0 }];
|
|
17004
|
-
while (pending.length) {
|
|
17005
|
-
const { node, depth } = pending.pop();
|
|
17006
|
-
(0, import_core18.assert)(!visited.has(node));
|
|
17007
|
-
visited.add(node);
|
|
17008
|
-
ancestors.length = depth;
|
|
17009
|
-
ancestors.push(node.id);
|
|
17010
|
-
const offset = ancestors.length - segments.length;
|
|
17011
|
-
if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
|
|
17012
|
-
matches.push(node);
|
|
17013
|
-
}
|
|
17014
|
-
if (node instanceof _GroupNode) {
|
|
17015
|
-
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
17016
|
-
pending.push({ node: node.children[index], depth: depth + 1 });
|
|
17017
|
-
}
|
|
17018
|
-
}
|
|
17019
|
-
}
|
|
17020
|
-
return matches;
|
|
17021
|
-
}
|
|
17022
|
-
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
17023
|
-
if (!this.display) {
|
|
17024
|
-
return;
|
|
17025
|
-
}
|
|
17026
|
-
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
17027
|
-
for (const child of this.children) {
|
|
17028
|
-
if (!child.display) {
|
|
17029
|
-
continue;
|
|
17030
|
-
}
|
|
17031
|
-
if (child instanceof _GroupNode) {
|
|
17032
|
-
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
17033
|
-
} else {
|
|
17034
|
-
visitor(child, { worldMatrix: modelMatrix });
|
|
17035
|
-
}
|
|
17036
|
-
}
|
|
17037
|
-
}
|
|
17038
|
-
/** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
|
|
17039
|
-
traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
|
|
17040
|
-
const cameraMatrix = new Matrix4(viewMatrix);
|
|
17041
|
-
const nodes = [];
|
|
17042
|
-
this.traverse(
|
|
17043
|
-
(node, context) => {
|
|
17044
|
-
const bounds = node.getBounds();
|
|
17045
|
-
const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
|
|
17046
|
-
const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
|
|
17047
|
-
nodeWorldMatrix.transformAsPoint(center, center);
|
|
17048
|
-
cameraMatrix.transformAsPoint(center, center);
|
|
17049
|
-
nodes.push({
|
|
17050
|
-
node,
|
|
17051
|
-
context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
|
|
17052
|
-
index: nodes.length
|
|
17053
|
-
});
|
|
17054
|
-
},
|
|
17055
|
-
{ worldMatrix: new Matrix4(worldMatrix) }
|
|
17056
|
-
);
|
|
17057
|
-
const direction = order === "back-to-front" ? -1 : 1;
|
|
17058
|
-
nodes.sort(
|
|
17059
|
-
(first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
|
|
17060
|
-
);
|
|
17061
|
-
for (const { node, context } of nodes) {
|
|
17062
|
-
visitor(node, context);
|
|
17063
|
-
}
|
|
17064
|
-
}
|
|
17065
|
-
preorderTraversal(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
17066
|
-
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
17067
|
-
visitor(this, { worldMatrix: modelMatrix });
|
|
17068
|
-
for (const child of this.children) {
|
|
17069
|
-
if (child instanceof _GroupNode) {
|
|
17070
|
-
child.preorderTraversal(visitor, { worldMatrix: modelMatrix });
|
|
17071
|
-
} else {
|
|
17072
|
-
visitor(child, { worldMatrix: modelMatrix });
|
|
17073
|
-
}
|
|
17074
|
-
}
|
|
17075
|
-
}
|
|
17076
|
-
};
|
|
17077
|
-
|
|
17078
17611
|
// src/scenegraph/geometry-node.ts
|
|
17079
17612
|
var GeometryNode = class extends ScenegraphNode {
|
|
17080
17613
|
geometry;
|
|
17081
|
-
constructor(props) {
|
|
17082
|
-
super(props);
|
|
17083
|
-
this.geometry = props.geometry;
|
|
17084
|
-
}
|
|
17085
|
-
getBounds() {
|
|
17086
|
-
const positions = this.geometry.attributes["POSITION"];
|
|
17087
|
-
if (!positions || positions.size !== 3 || !positions.value.length) return null;
|
|
17088
|
-
const minimum = [Infinity, Infinity, Infinity];
|
|
17089
|
-
const maximum = [-Infinity, -Infinity, -Infinity];
|
|
17090
|
-
for (let index = 0; index < positions.value.length; index++) {
|
|
17091
|
-
const axis = index % 3;
|
|
17092
|
-
minimum[axis] = Math.min(minimum[axis], positions.value[index]);
|
|
17093
|
-
maximum[axis] = Math.max(maximum[axis], positions.value[index]);
|
|
17094
|
-
}
|
|
17095
|
-
return [minimum, maximum];
|
|
17096
|
-
}
|
|
17097
|
-
};
|
|
17098
|
-
|
|
17099
|
-
// src/scenegraph/model-node.ts
|
|
17100
|
-
var ModelNode = class extends ScenegraphNode {
|
|
17101
|
-
model;
|
|
17102
|
-
instanceMatrices;
|
|
17103
|
-
bounds = null;
|
|
17104
|
-
managedResources;
|
|
17105
|
-
// TODO - is this used? override callbacks to make sure we call them with this
|
|
17106
|
-
// onBeforeRender = null;
|
|
17107
|
-
// onAfterRender = null;
|
|
17108
|
-
// AfterRender = null;
|
|
17109
|
-
constructor(props) {
|
|
17110
|
-
super(props);
|
|
17111
|
-
this.model = props.model;
|
|
17112
|
-
this.managedResources = props.managedResources || [];
|
|
17113
|
-
this.instanceMatrices = props.instanceMatrices || null;
|
|
17114
|
-
this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
|
|
17115
|
-
this.setProps(props);
|
|
17116
|
-
}
|
|
17117
|
-
destroy() {
|
|
17118
|
-
if (this.model) {
|
|
17119
|
-
this.model.destroy();
|
|
17120
|
-
this.model = null;
|
|
17121
|
-
}
|
|
17122
|
-
this.managedResources.forEach((resource) => resource.destroy());
|
|
17123
|
-
this.managedResources = [];
|
|
17614
|
+
constructor(props) {
|
|
17615
|
+
super(props);
|
|
17616
|
+
this.geometry = props.geometry;
|
|
17124
17617
|
}
|
|
17125
17618
|
getBounds() {
|
|
17126
|
-
|
|
17127
|
-
|
|
17128
|
-
|
|
17129
|
-
|
|
17130
|
-
|
|
17619
|
+
const positions = this.geometry.attributes["POSITION"];
|
|
17620
|
+
if (!positions || positions.size !== 3 || !positions.value.length) return null;
|
|
17621
|
+
const minimum = [Infinity, Infinity, Infinity];
|
|
17622
|
+
const maximum = [-Infinity, -Infinity, -Infinity];
|
|
17623
|
+
for (let index = 0; index < positions.value.length; index++) {
|
|
17624
|
+
const axis = index % 3;
|
|
17625
|
+
minimum[axis] = Math.min(minimum[axis], positions.value[index]);
|
|
17626
|
+
maximum[axis] = Math.max(maximum[axis], positions.value[index]);
|
|
17627
|
+
}
|
|
17628
|
+
return [minimum, maximum];
|
|
17131
17629
|
}
|
|
17132
17630
|
};
|
|
17133
|
-
function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
17134
|
-
const instancedBounds = makeEmptyScenegraphBounds();
|
|
17135
|
-
for (const instanceMatrix of instanceMatrices) {
|
|
17136
|
-
expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
|
|
17137
|
-
}
|
|
17138
|
-
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
17139
|
-
}
|
|
17140
17631
|
|
|
17141
17632
|
// src/geometry/edge-geometry.ts
|
|
17142
|
-
var
|
|
17633
|
+
var import_core21 = __toESM(require_core(), 1);
|
|
17143
17634
|
function makeEdgeGeometry(geometry, options = {}) {
|
|
17144
17635
|
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
17145
17636
|
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
17146
|
-
(0,
|
|
17147
|
-
(0,
|
|
17637
|
+
(0, import_core21.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
17638
|
+
(0, import_core21.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
17148
17639
|
const sourceIndices = geometry.indices?.value;
|
|
17149
17640
|
const sourceCount = positions.value.length / 3;
|
|
17150
17641
|
const representatives = /* @__PURE__ */ new Map();
|
|
@@ -17163,9 +17654,9 @@ void main(void) {
|
|
|
17163
17654
|
function weldPosition(index) {
|
|
17164
17655
|
const cached = representatives.get(index);
|
|
17165
17656
|
if (cached !== void 0) return cached;
|
|
17166
|
-
(0,
|
|
17657
|
+
(0, import_core21.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
17167
17658
|
const position = readPosition(index);
|
|
17168
|
-
(0,
|
|
17659
|
+
(0, import_core21.assert)(position.every(Number.isFinite));
|
|
17169
17660
|
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
17170
17661
|
const radius = weldTolerance > 0 ? 1 : 0;
|
|
17171
17662
|
for (let east = -radius; east <= radius; east++) {
|
|
@@ -17239,11 +17730,11 @@ void main(void) {
|
|
|
17239
17730
|
});
|
|
17240
17731
|
}
|
|
17241
17732
|
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
17242
|
-
(0,
|
|
17733
|
+
(0, import_core21.assert)(geometries.length > 0);
|
|
17243
17734
|
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
17244
17735
|
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
17245
17736
|
const firstAttribute = attributes[0];
|
|
17246
|
-
(0,
|
|
17737
|
+
(0, import_core21.assert)(
|
|
17247
17738
|
attributes.every(
|
|
17248
17739
|
(attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
|
|
17249
17740
|
)
|
|
@@ -17262,7 +17753,7 @@ void main(void) {
|
|
|
17262
17753
|
positions.set(attribute.value, positionOffset);
|
|
17263
17754
|
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
17264
17755
|
const index = geometry.indices?.value[offset] ?? offset;
|
|
17265
|
-
(0,
|
|
17756
|
+
(0, import_core21.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
17266
17757
|
indices[indexOffset++] = index + positionOffset / 3;
|
|
17267
17758
|
}
|
|
17268
17759
|
positionOffset += attribute.value.length;
|
|
@@ -17279,26 +17770,26 @@ void main(void) {
|
|
|
17279
17770
|
}
|
|
17280
17771
|
function getTrianglePositions(geometry, positionAttribute) {
|
|
17281
17772
|
const positions = geometry.attributes[positionAttribute];
|
|
17282
|
-
(0,
|
|
17283
|
-
(0,
|
|
17284
|
-
(0,
|
|
17773
|
+
(0, import_core21.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
|
|
17774
|
+
(0, import_core21.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
17775
|
+
(0, import_core21.assert)(
|
|
17285
17776
|
!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
|
|
17286
17777
|
);
|
|
17287
|
-
(0,
|
|
17778
|
+
(0, import_core21.assert)(
|
|
17288
17779
|
geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
|
|
17289
17780
|
);
|
|
17290
17781
|
return positions;
|
|
17291
17782
|
}
|
|
17292
17783
|
|
|
17293
17784
|
// src/geometry/stroke-geometry.ts
|
|
17294
|
-
var
|
|
17785
|
+
var import_core22 = __toESM(require_core(), 1);
|
|
17295
17786
|
function makeStrokeGeometry(path, options = {}) {
|
|
17296
17787
|
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
17297
|
-
(0,
|
|
17298
|
-
(0,
|
|
17788
|
+
(0, import_core22.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
17789
|
+
(0, import_core22.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
17299
17790
|
const points = [];
|
|
17300
17791
|
for (const position of path) {
|
|
17301
|
-
(0,
|
|
17792
|
+
(0, import_core22.assert)(
|
|
17302
17793
|
Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
|
|
17303
17794
|
);
|
|
17304
17795
|
const previous = points.at(-1);
|
|
@@ -17458,12 +17949,12 @@ void main(void) {
|
|
|
17458
17949
|
}
|
|
17459
17950
|
|
|
17460
17951
|
// src/geometry/mesh-simplification.ts
|
|
17461
|
-
var
|
|
17952
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
17462
17953
|
var QUADRIC_COMPONENTS = 10;
|
|
17463
17954
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
17464
17955
|
function simplifyMesh(options) {
|
|
17465
17956
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
17466
|
-
(0,
|
|
17957
|
+
(0, import_core23.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
17467
17958
|
const targetIndexCount = Math.max(
|
|
17468
17959
|
0,
|
|
17469
17960
|
Math.min(
|
|
@@ -17556,7 +18047,7 @@ void main(void) {
|
|
|
17556
18047
|
const firstVertex = indices[indexOffset2];
|
|
17557
18048
|
const secondVertex = indices[indexOffset2 + 1];
|
|
17558
18049
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
17559
|
-
(0,
|
|
18050
|
+
(0, import_core23.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
17560
18051
|
const triangle = {
|
|
17561
18052
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
17562
18053
|
active: false
|
|
@@ -17891,7 +18382,7 @@ void main(void) {
|
|
|
17891
18382
|
}
|
|
17892
18383
|
|
|
17893
18384
|
// src/dynamic-texture/video-texture.ts
|
|
17894
|
-
var
|
|
18385
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
17895
18386
|
var VideoTexture = class {
|
|
17896
18387
|
/** Device used to create copied and native external texture bindings. */
|
|
17897
18388
|
device;
|
|
@@ -17940,7 +18431,7 @@ void main(void) {
|
|
|
17940
18431
|
* @param props Live video source and copied texture options.
|
|
17941
18432
|
*/
|
|
17942
18433
|
constructor(device, props) {
|
|
17943
|
-
(0,
|
|
18434
|
+
(0, import_core24.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
17944
18435
|
this.device = device;
|
|
17945
18436
|
this.id = props.id || uid("video-texture");
|
|
17946
18437
|
this._source = props.source;
|
|
@@ -17954,7 +18445,7 @@ void main(void) {
|
|
|
17954
18445
|
* @param source Next caller-owned video source to follow.
|
|
17955
18446
|
*/
|
|
17956
18447
|
setSource(source4) {
|
|
17957
|
-
(0,
|
|
18448
|
+
(0, import_core24.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
17958
18449
|
this._destroyExternalTexture();
|
|
17959
18450
|
this._source = source4;
|
|
17960
18451
|
this._sourceVersion++;
|
|
@@ -18032,7 +18523,7 @@ void main(void) {
|
|
|
18032
18523
|
width: size.width,
|
|
18033
18524
|
height: size.height,
|
|
18034
18525
|
format: "rgba8unorm",
|
|
18035
|
-
usage:
|
|
18526
|
+
usage: import_core24.Texture.SAMPLE | import_core24.Texture.COPY_DST,
|
|
18036
18527
|
mipLevels: 1,
|
|
18037
18528
|
sampler: this._sampler
|
|
18038
18529
|
});
|
|
@@ -18067,7 +18558,7 @@ void main(void) {
|
|
|
18067
18558
|
*/
|
|
18068
18559
|
_getResolvedSize() {
|
|
18069
18560
|
const size = getVideoTextureSourceSize(this._source);
|
|
18070
|
-
(0,
|
|
18561
|
+
(0, import_core24.assert)(size.width > 0 && size.height > 0);
|
|
18071
18562
|
return size;
|
|
18072
18563
|
}
|
|
18073
18564
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -18131,12 +18622,12 @@ void main(void) {
|
|
|
18131
18622
|
return `${sourceVersion}:${source4.timestamp}:${source4.displayWidth}x${source4.displayHeight}`;
|
|
18132
18623
|
}
|
|
18133
18624
|
|
|
18134
|
-
// src/passes/
|
|
18135
|
-
var
|
|
18625
|
+
// src/passes/fullscreen-effect-executor.ts
|
|
18626
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
18136
18627
|
var import_shaders7 = __toESM(require_shaders(), 1);
|
|
18137
18628
|
|
|
18138
18629
|
// src/compute/swap.ts
|
|
18139
|
-
var
|
|
18630
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
18140
18631
|
var Swap = class {
|
|
18141
18632
|
id;
|
|
18142
18633
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -18168,7 +18659,7 @@ void main(void) {
|
|
|
18168
18659
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
18169
18660
|
id: `${props.id}-texture-0`,
|
|
18170
18661
|
format: colorAttachment,
|
|
18171
|
-
usage:
|
|
18662
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
|
|
18172
18663
|
width,
|
|
18173
18664
|
height
|
|
18174
18665
|
})
|
|
@@ -18178,7 +18669,7 @@ void main(void) {
|
|
|
18178
18669
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
18179
18670
|
id: `${props.id}-texture-1`,
|
|
18180
18671
|
format: colorAttachment,
|
|
18181
|
-
usage:
|
|
18672
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
|
|
18182
18673
|
width,
|
|
18183
18674
|
height
|
|
18184
18675
|
})
|
|
@@ -18242,7 +18733,7 @@ void main(void) {
|
|
|
18242
18733
|
};
|
|
18243
18734
|
|
|
18244
18735
|
// src/compute/computation.ts
|
|
18245
|
-
var
|
|
18736
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
18246
18737
|
var import_shaders6 = __toESM(require_shaders(), 1);
|
|
18247
18738
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
18248
18739
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -18254,13 +18745,13 @@ void main(void) {
|
|
|
18254
18745
|
* constructor remains the synchronous compatibility path.
|
|
18255
18746
|
*/
|
|
18256
18747
|
static async createAsync(device, props) {
|
|
18257
|
-
const ownsCompilation = !
|
|
18258
|
-
const asyncCompilation = ownsCompilation ?
|
|
18748
|
+
const ownsCompilation = !import_core26.PipelineFactory.getAsyncCompilation(device);
|
|
18749
|
+
const asyncCompilation = ownsCompilation ? import_core26.PipelineFactory.beginAsyncCompilation(device) : import_core26.PipelineFactory.getAsyncCompilation(device);
|
|
18259
18750
|
let computation;
|
|
18260
18751
|
try {
|
|
18261
18752
|
computation = new _Computation(device, props);
|
|
18262
18753
|
} finally {
|
|
18263
|
-
if (ownsCompilation)
|
|
18754
|
+
if (ownsCompilation) import_core26.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
18264
18755
|
}
|
|
18265
18756
|
try {
|
|
18266
18757
|
if (ownsCompilation) {
|
|
@@ -18275,7 +18766,7 @@ void main(void) {
|
|
|
18275
18766
|
}
|
|
18276
18767
|
}
|
|
18277
18768
|
static defaultProps = {
|
|
18278
|
-
...
|
|
18769
|
+
...import_core26.ComputePipeline.defaultProps,
|
|
18279
18770
|
id: "unnamed",
|
|
18280
18771
|
handle: void 0,
|
|
18281
18772
|
userData: {},
|
|
@@ -18350,10 +18841,10 @@ void main(void) {
|
|
|
18350
18841
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
18351
18842
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
18352
18843
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
18353
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
18354
|
-
this.shaderFactory = props.shaderFactory ||
|
|
18844
|
+
this.pipelineFactory = props.pipelineFactory || import_core26.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
18845
|
+
this.shaderFactory = props.shaderFactory || import_core26.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
18355
18846
|
const shaderAssembler = this.props.shaderAssembler;
|
|
18356
|
-
(0,
|
|
18847
|
+
(0, import_core26.assert)(shaderAssembler instanceof WGSLShaderAssembler);
|
|
18357
18848
|
const {
|
|
18358
18849
|
source: source4,
|
|
18359
18850
|
getUniforms: getUniforms2,
|
|
@@ -18377,7 +18868,7 @@ void main(void) {
|
|
|
18377
18868
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
18378
18869
|
modules
|
|
18379
18870
|
) || null;
|
|
18380
|
-
const asyncCompilation =
|
|
18871
|
+
const asyncCompilation = import_core26.PipelineFactory.getAsyncCompilation(this.device);
|
|
18381
18872
|
if (asyncCompilation) {
|
|
18382
18873
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
18383
18874
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -18444,7 +18935,7 @@ void main(void) {
|
|
|
18444
18935
|
}
|
|
18445
18936
|
setShaderInputs(shaderInputs) {
|
|
18446
18937
|
this.shaderInputs = shaderInputs;
|
|
18447
|
-
this._uniformStore = new
|
|
18938
|
+
this._uniformStore = new import_core26.UniformStore(this.device, this.shaderInputs.modules);
|
|
18448
18939
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
18449
18940
|
if (shaderModuleHasUniforms(module)) {
|
|
18450
18941
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -18513,7 +19004,7 @@ void main(void) {
|
|
|
18513
19004
|
if (!this._pipelineNeedsUpdate) return null;
|
|
18514
19005
|
const previousShader = this.pipeline ? this.shader : null;
|
|
18515
19006
|
if (this.pipeline) {
|
|
18516
|
-
|
|
19007
|
+
import_core26.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
18517
19008
|
}
|
|
18518
19009
|
this._pipelineNeedsUpdate = false;
|
|
18519
19010
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -18531,27 +19022,27 @@ void main(void) {
|
|
|
18531
19022
|
_lastLogTime = 0;
|
|
18532
19023
|
_logOpen = false;
|
|
18533
19024
|
_logDrawCallStart() {
|
|
18534
|
-
const logDrawTimeout =
|
|
18535
|
-
if (
|
|
19025
|
+
const logDrawTimeout = import_core26.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
19026
|
+
if (import_core26.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
18536
19027
|
return;
|
|
18537
19028
|
}
|
|
18538
19029
|
this._lastLogTime = Date.now();
|
|
18539
19030
|
this._logOpen = true;
|
|
18540
|
-
|
|
19031
|
+
import_core26.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core26.log.level <= 2 })();
|
|
18541
19032
|
}
|
|
18542
19033
|
_logDrawCallEnd() {
|
|
18543
19034
|
if (this._logOpen) {
|
|
18544
19035
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
18545
|
-
|
|
18546
|
-
|
|
19036
|
+
import_core26.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
19037
|
+
import_core26.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
18547
19038
|
this._logOpen = false;
|
|
18548
19039
|
}
|
|
18549
19040
|
}
|
|
18550
19041
|
_drawCount = 0;
|
|
18551
19042
|
// TODO - fix typing of luma data types
|
|
18552
19043
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
18553
|
-
const TypedArrayConstructor =
|
|
18554
|
-
const typedArray = attribute instanceof
|
|
19044
|
+
const TypedArrayConstructor = import_core26.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
19045
|
+
const typedArray = attribute instanceof import_core26.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
18555
19046
|
return typedArray.toString();
|
|
18556
19047
|
}
|
|
18557
19048
|
};
|
|
@@ -18559,6 +19050,11 @@ void main(void) {
|
|
|
18559
19050
|
// src/passes/get-fragment-shader.ts
|
|
18560
19051
|
function getFragmentShaderForRenderPass(options) {
|
|
18561
19052
|
const { shaderPass, action, shadingLanguage } = options;
|
|
19053
|
+
if (shadingLanguage === "glsl" ? !shaderPass.fs : !shaderPass.source) {
|
|
19054
|
+
throw new Error(
|
|
19055
|
+
`${shaderPass.name}: fullscreen effect requires a ${shadingLanguage} fragment implementation`
|
|
19056
|
+
);
|
|
19057
|
+
}
|
|
18562
19058
|
switch (action) {
|
|
18563
19059
|
case "filter":
|
|
18564
19060
|
const filterFunc = `${shaderPass.name}_filterColor_ext`;
|
|
@@ -18705,9 +19201,9 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18705
19201
|
}
|
|
18706
19202
|
};
|
|
18707
19203
|
|
|
18708
|
-
// src/passes/
|
|
19204
|
+
// src/passes/fullscreen-effect-executor.ts
|
|
18709
19205
|
var RESERVED_RENDER_TARGET_NAMES = /* @__PURE__ */ new Set(["original", "previous"]);
|
|
18710
|
-
var
|
|
19206
|
+
var FullscreenEffectExecutor = class {
|
|
18711
19207
|
device;
|
|
18712
19208
|
shaderInputs;
|
|
18713
19209
|
passRenderers;
|
|
@@ -18723,8 +19219,9 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18723
19219
|
);
|
|
18724
19220
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(modules);
|
|
18725
19221
|
const size = device.getCanvasContext().getDrawingBufferSize();
|
|
19222
|
+
const colorFormat = props.colorFormat ?? device.preferredColorFormat;
|
|
18726
19223
|
this.swapFramebuffers = new SwapFramebuffers(device, {
|
|
18727
|
-
colorAttachments: [
|
|
19224
|
+
colorAttachments: [colorFormat],
|
|
18728
19225
|
width: size[0],
|
|
18729
19226
|
height: size[1]
|
|
18730
19227
|
});
|
|
@@ -18734,10 +19231,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18734
19231
|
});
|
|
18735
19232
|
const flipY = props.flipY ?? device.type === "webgpu";
|
|
18736
19233
|
this.passRenderers = props.shaderPasses.map(
|
|
18737
|
-
(shaderPass) => new PassRenderer(
|
|
19234
|
+
(shaderPass, index) => new PassRenderer(
|
|
19235
|
+
device,
|
|
19236
|
+
shaderPass,
|
|
19237
|
+
this.shaderInputs,
|
|
19238
|
+
flipY,
|
|
19239
|
+
colorFormat,
|
|
19240
|
+
props.occurrences?.[index]
|
|
19241
|
+
)
|
|
18738
19242
|
);
|
|
18739
19243
|
}
|
|
18740
|
-
/** Destroys resources created by this
|
|
19244
|
+
/** Destroys resources created by this FullscreenEffectExecutor */
|
|
18741
19245
|
destroy() {
|
|
18742
19246
|
for (const passRenderer of this.passRenderers) {
|
|
18743
19247
|
passRenderer.destroy();
|
|
@@ -18771,17 +19275,24 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18771
19275
|
if (!outputTexture) {
|
|
18772
19276
|
return false;
|
|
18773
19277
|
}
|
|
18774
|
-
|
|
19278
|
+
this.drawOutput(commandEncoder, outputTexture, null);
|
|
19279
|
+
return true;
|
|
19280
|
+
}
|
|
19281
|
+
/** @internal Records presentation of a completed effect output. */
|
|
19282
|
+
drawOutput(commandEncoder, outputTexture, target) {
|
|
19283
|
+
const framebuffer = target ?? this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
|
|
18775
19284
|
this.textureModel.setProps({ backgroundTexture: outputTexture });
|
|
18776
19285
|
this.textureModel.predraw(commandEncoder);
|
|
18777
19286
|
const renderPass = commandEncoder.beginRenderPass({
|
|
18778
|
-
id: "
|
|
19287
|
+
id: "fullscreen-effect-executor-to-screen",
|
|
18779
19288
|
framebuffer,
|
|
18780
19289
|
clearDepth: false
|
|
18781
19290
|
});
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
|
|
19291
|
+
try {
|
|
19292
|
+
this.textureModel.draw(renderPass);
|
|
19293
|
+
} finally {
|
|
19294
|
+
renderPass.end();
|
|
19295
|
+
}
|
|
18785
19296
|
}
|
|
18786
19297
|
/** Runs the shaderPasses in sequence on the sourceTexture and returns a texture with the results.
|
|
18787
19298
|
* @returns null if the the sourceTexture has not yet been loaded
|
|
@@ -18796,7 +19307,9 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18796
19307
|
*/
|
|
18797
19308
|
encodeToTexture(commandEncoder, options) {
|
|
18798
19309
|
if (commandEncoder.device !== this.device) {
|
|
18799
|
-
throw new Error(
|
|
19310
|
+
throw new Error(
|
|
19311
|
+
"FullscreenEffectExecutor command encoder must belong to the renderer device"
|
|
19312
|
+
);
|
|
18800
19313
|
}
|
|
18801
19314
|
const { sourceTexture } = options;
|
|
18802
19315
|
if (sourceTexture instanceof DynamicTexture && !sourceTexture.isReady) {
|
|
@@ -18813,7 +19326,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18813
19326
|
this.textureModel.predraw(commandEncoder);
|
|
18814
19327
|
const sourceFramebuffer = getSeedFramebuffer(this.swapFramebuffers, originalTexture);
|
|
18815
19328
|
const seedRenderPass = commandEncoder.beginRenderPass({
|
|
18816
|
-
id: "
|
|
19329
|
+
id: "fullscreen-effect-executor-seed-source",
|
|
18817
19330
|
framebuffer: sourceFramebuffer,
|
|
18818
19331
|
clearColor: [0, 0, 0, 1],
|
|
18819
19332
|
clearDepth: false
|
|
@@ -18846,7 +19359,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18846
19359
|
const resolvedUniforms = resolveExecutionUniforms(
|
|
18847
19360
|
this.shaderInputs,
|
|
18848
19361
|
execution,
|
|
18849
|
-
options.uniforms || {}
|
|
19362
|
+
options.uniforms || {},
|
|
19363
|
+
passRenderer.occurrence?.uniforms
|
|
18850
19364
|
);
|
|
18851
19365
|
execution.subPassRenderer.prepare({
|
|
18852
19366
|
commandEncoder,
|
|
@@ -18858,7 +19372,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18858
19372
|
uniforms: resolvedUniforms
|
|
18859
19373
|
});
|
|
18860
19374
|
const renderPass = commandEncoder.beginRenderPass({
|
|
18861
|
-
id: "
|
|
19375
|
+
id: "fullscreen-effect-executor-run-pass",
|
|
18862
19376
|
framebuffer: outputFramebuffer,
|
|
18863
19377
|
clearColor: [0, 0, 0, 1],
|
|
18864
19378
|
clearDepth: 1
|
|
@@ -18883,42 +19397,48 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18883
19397
|
}
|
|
18884
19398
|
};
|
|
18885
19399
|
var PassRenderer = class {
|
|
18886
|
-
device
|
|
18887
|
-
|
|
18888
|
-
passDefinition;
|
|
18889
|
-
renderTargets;
|
|
18890
|
-
subPassExecutions;
|
|
18891
|
-
computeRenderer;
|
|
18892
|
-
constructor(device, passDefinition, shaderInputs, flipY) {
|
|
19400
|
+
constructor(device, passDefinition, shaderInputs, flipY, colorFormat, occurrence) {
|
|
19401
|
+
this.occurrence = occurrence;
|
|
18893
19402
|
this.device = device;
|
|
18894
19403
|
this.shaderInputs = shaderInputs;
|
|
18895
19404
|
this.passDefinition = passDefinition;
|
|
18896
19405
|
if (isCompositeShaderPass(passDefinition)) {
|
|
18897
19406
|
validateRenderTargetNames(passDefinition.name, passDefinition.renderTargets || {});
|
|
18898
|
-
this.renderTargets = createManagedRenderTargets(
|
|
18899
|
-
|
|
18900
|
-
|
|
19407
|
+
this.renderTargets = createManagedRenderTargets(
|
|
19408
|
+
device,
|
|
19409
|
+
passDefinition.renderTargets || {},
|
|
19410
|
+
colorFormat
|
|
19411
|
+
);
|
|
19412
|
+
const { compute, passes } = planFullscreenPasses(device, passDefinition, { colorFormat });
|
|
19413
|
+
if (compute) {
|
|
19414
|
+
this.computeRenderer = new FullscreenComputePass(
|
|
18901
19415
|
device,
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
19416
|
+
compute,
|
|
19417
|
+
Object.fromEntries(
|
|
19418
|
+
Object.entries(this.renderTargets).map(([name, target]) => [
|
|
19419
|
+
name,
|
|
19420
|
+
target.texture.format
|
|
19421
|
+
])
|
|
19422
|
+
)
|
|
18905
19423
|
);
|
|
18906
19424
|
}
|
|
18907
|
-
|
|
18908
|
-
(step) => !passDefinition.compute.replacedPasses.includes(step.shaderPass.name)
|
|
18909
|
-
) : passDefinition.steps;
|
|
18910
|
-
this.subPassExecutions = executableSteps.flatMap(
|
|
18911
|
-
(step) => this.createStepExecutions(passDefinition, step, flipY)
|
|
18912
|
-
);
|
|
19425
|
+
this.subPassExecutions = this.createPassExecutions(passes, flipY);
|
|
18913
19426
|
return;
|
|
18914
19427
|
}
|
|
18915
19428
|
validateShaderPassDoesNotOwnRenderTargets(passDefinition, passDefinition.name);
|
|
18916
19429
|
this.renderTargets = {};
|
|
18917
|
-
this.subPassExecutions = this.createPassExecutions(
|
|
18918
|
-
|
|
19430
|
+
this.subPassExecutions = this.createPassExecutions(
|
|
19431
|
+
planShaderSubpasses(passDefinition, passDefinition.name),
|
|
18919
19432
|
flipY
|
|
18920
|
-
|
|
19433
|
+
);
|
|
18921
19434
|
}
|
|
19435
|
+
occurrence;
|
|
19436
|
+
device;
|
|
19437
|
+
shaderInputs;
|
|
19438
|
+
passDefinition;
|
|
19439
|
+
renderTargets;
|
|
19440
|
+
subPassExecutions;
|
|
19441
|
+
computeRenderer;
|
|
18922
19442
|
destroy() {
|
|
18923
19443
|
this.computeRenderer?.destroy();
|
|
18924
19444
|
for (const execution of this.subPassExecutions) {
|
|
@@ -18938,8 +19458,24 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18938
19458
|
options.originalTexture,
|
|
18939
19459
|
options.previousTexture
|
|
18940
19460
|
);
|
|
18941
|
-
this.computeRenderer
|
|
18942
|
-
|
|
19461
|
+
const { optimization } = this.computeRenderer;
|
|
19462
|
+
const outputs = Object.fromEntries(
|
|
19463
|
+
Object.entries(optimization.outputs).map(([binding, targetName]) => [
|
|
19464
|
+
binding,
|
|
19465
|
+
this.renderTargets[targetName].texture.view
|
|
19466
|
+
])
|
|
19467
|
+
);
|
|
19468
|
+
this.computeRenderer.prepare(options.commandEncoder, sourceTexture.view, outputs, {
|
|
19469
|
+
...this.shaderInputs.getUniformValues()[optimization.uniformModule],
|
|
19470
|
+
...optimization.uniforms,
|
|
19471
|
+
...options.runtimeUniforms[optimization.uniformModule],
|
|
19472
|
+
...this.occurrence?.uniforms?.[optimization.uniformModule]
|
|
19473
|
+
});
|
|
19474
|
+
const target = this.renderTargets[Object.values(optimization.outputs)[0]].texture;
|
|
19475
|
+
const pass = options.commandEncoder.beginComputePass({ id: optimization.name });
|
|
19476
|
+
this.computeRenderer.dispatch(pass, target.width, target.height);
|
|
19477
|
+
pass.end();
|
|
19478
|
+
for (const targetName of Object.values(optimization.outputs)) {
|
|
18943
19479
|
this.markTargetWritten(targetName);
|
|
18944
19480
|
}
|
|
18945
19481
|
}
|
|
@@ -19013,7 +19549,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19013
19549
|
const inputMap = execution.inputs || { sourceTexture: "previous" };
|
|
19014
19550
|
const shaderInputBindings = this.shaderInputs.getModuleBindingValues(execution.shaderPass.name);
|
|
19015
19551
|
const externalBindingsForPass = Object.fromEntries(
|
|
19016
|
-
Object.entries(externalBindings).filter(
|
|
19552
|
+
Object.entries({ ...externalBindings, ...this.occurrence?.bindings }).filter(
|
|
19017
19553
|
([name]) => execution.shaderPass.bindingLayout?.some((binding) => binding.name === name)
|
|
19018
19554
|
)
|
|
19019
19555
|
);
|
|
@@ -19045,34 +19581,12 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19045
19581
|
}
|
|
19046
19582
|
return resolvedBindings;
|
|
19047
19583
|
}
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
`${compositeShaderPass.name}/${step.shaderPass.name}`
|
|
19052
|
-
);
|
|
19053
|
-
return this.createPassExecutions(step.shaderPass, {
|
|
19054
|
-
ownerName: `${compositeShaderPass.name}/${step.shaderPass.name}`,
|
|
19055
|
-
firstInputs: step.inputs,
|
|
19056
|
-
lastOutput: step.output,
|
|
19057
|
-
uniformOverrides: step.uniforms,
|
|
19058
|
-
flipY
|
|
19059
|
-
});
|
|
19060
|
-
}
|
|
19061
|
-
createPassExecutions(shaderPass, options) {
|
|
19062
|
-
const subPasses = shaderPass.passes || [];
|
|
19063
|
-
return subPasses.map((subPass, index) => {
|
|
19064
|
-
const isFirstSubPass = index === 0;
|
|
19065
|
-
const isLastSubPass = index === subPasses.length - 1;
|
|
19066
|
-
const inputs = isFirstSubPass && options.firstInputs !== void 0 ? options.firstInputs : subPass.inputs;
|
|
19067
|
-
const output = isLastSubPass && options.lastOutput !== void 0 ? options.lastOutput : subPass.output;
|
|
19068
|
-
validateSubPassRouting(options.ownerName, inputs, output, this.renderTargets);
|
|
19584
|
+
createPassExecutions(passes, flipY) {
|
|
19585
|
+
return passes.map(({ subPass, ...pass }) => {
|
|
19586
|
+
validateSubPassRouting(pass.ownerName, pass.inputs, pass.output, this.renderTargets);
|
|
19069
19587
|
return {
|
|
19070
|
-
|
|
19071
|
-
shaderPass,
|
|
19072
|
-
subPassRenderer: new SubPassRenderer(this.device, shaderPass, subPass, options.flipY),
|
|
19073
|
-
inputs,
|
|
19074
|
-
output,
|
|
19075
|
-
uniforms: mergeUniforms(options.uniformOverrides, subPass.uniforms)
|
|
19588
|
+
...pass,
|
|
19589
|
+
subPassRenderer: new SubPassRenderer(this.device, pass.shaderPass, subPass, flipY)
|
|
19076
19590
|
};
|
|
19077
19591
|
});
|
|
19078
19592
|
}
|
|
@@ -19095,20 +19609,16 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19095
19609
|
return this.passDefinition.name;
|
|
19096
19610
|
}
|
|
19097
19611
|
};
|
|
19098
|
-
var
|
|
19612
|
+
var FullscreenComputePass = class {
|
|
19099
19613
|
optimization;
|
|
19100
|
-
renderTargets;
|
|
19101
|
-
shaderInputs;
|
|
19102
19614
|
computation;
|
|
19103
19615
|
parameterBuffer;
|
|
19104
|
-
constructor(device, optimization,
|
|
19616
|
+
constructor(device, optimization, outputFormats) {
|
|
19105
19617
|
this.optimization = optimization;
|
|
19106
|
-
this.renderTargets = renderTargets;
|
|
19107
|
-
this.shaderInputs = shaderInputs;
|
|
19108
19618
|
this.parameterBuffer = device.createBuffer({
|
|
19109
19619
|
id: `${optimization.name}-parameters`,
|
|
19110
19620
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
19111
|
-
usage:
|
|
19621
|
+
usage: import_core27.Buffer.UNIFORM | import_core27.Buffer.COPY_DST
|
|
19112
19622
|
});
|
|
19113
19623
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
19114
19624
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -19117,7 +19627,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19117
19627
|
group: 0,
|
|
19118
19628
|
location: outputIndex + 2,
|
|
19119
19629
|
access: "write-only",
|
|
19120
|
-
format:
|
|
19630
|
+
format: outputFormats[targetName]
|
|
19121
19631
|
})
|
|
19122
19632
|
);
|
|
19123
19633
|
try {
|
|
@@ -19143,12 +19653,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19143
19653
|
throw error;
|
|
19144
19654
|
}
|
|
19145
19655
|
}
|
|
19146
|
-
|
|
19147
|
-
|
|
19148
|
-
...this.shaderInputs.getUniformValues()[this.optimization.uniformModule] || {},
|
|
19149
|
-
...this.optimization.uniforms,
|
|
19150
|
-
...runtimeUniforms[this.optimization.uniformModule] || {}
|
|
19151
|
-
};
|
|
19656
|
+
/** Binds the current graph or renderer resources and records its uniform upload. */
|
|
19657
|
+
prepare(commandEncoder, source4, outputs, effectiveUniforms) {
|
|
19152
19658
|
const uniformValues = new Float32Array(
|
|
19153
19659
|
Math.max(Math.ceil(this.optimization.uniformNames.length / 4) * 4, 4)
|
|
19154
19660
|
);
|
|
@@ -19156,26 +19662,26 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19156
19662
|
const value = effectiveUniforms[uniformName];
|
|
19157
19663
|
uniformValues[uniformIndex] = typeof value === "number" ? value : 0;
|
|
19158
19664
|
}
|
|
19159
|
-
this.parameterBuffer.
|
|
19160
|
-
|
|
19161
|
-
|
|
19665
|
+
this.parameterBuffer.device.writeBufferViaCommandEncoder(
|
|
19666
|
+
commandEncoder,
|
|
19667
|
+
this.parameterBuffer,
|
|
19668
|
+
uniformValues
|
|
19669
|
+
);
|
|
19670
|
+
this.computation.setBindings({
|
|
19162
19671
|
[this.optimization.uniformBinding]: this.parameterBuffer,
|
|
19163
|
-
sourceTexture:
|
|
19164
|
-
|
|
19165
|
-
|
|
19166
|
-
bindings[bindingName] = this.renderTargets[targetName].texture.view;
|
|
19167
|
-
}
|
|
19168
|
-
this.computation.setBindings(bindings);
|
|
19672
|
+
sourceTexture: source4,
|
|
19673
|
+
...outputs
|
|
19674
|
+
});
|
|
19169
19675
|
this.computation.predraw(commandEncoder);
|
|
19170
|
-
|
|
19171
|
-
|
|
19676
|
+
}
|
|
19677
|
+
/** Dispatches against the dimensions of the first declared storage output. */
|
|
19678
|
+
dispatch(pass, width, height) {
|
|
19172
19679
|
this.computation.dispatch(
|
|
19173
|
-
|
|
19174
|
-
Math.ceil(
|
|
19175
|
-
Math.ceil(
|
|
19680
|
+
pass,
|
|
19681
|
+
Math.ceil(width / this.optimization.workgroupSize[0]),
|
|
19682
|
+
Math.ceil(height / this.optimization.workgroupSize[1]),
|
|
19176
19683
|
1
|
|
19177
19684
|
);
|
|
19178
|
-
computePass.end();
|
|
19179
19685
|
}
|
|
19180
19686
|
destroy() {
|
|
19181
19687
|
this.computation.destroy();
|
|
@@ -19188,6 +19694,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19188
19694
|
subPass;
|
|
19189
19695
|
flipY;
|
|
19190
19696
|
constructor(device, shaderPass, subPass, flipY) {
|
|
19697
|
+
(0, import_shaders7.initializeShaderModule)(shaderPass);
|
|
19191
19698
|
this.shaderPass = shaderPass;
|
|
19192
19699
|
this.subPass = subPass;
|
|
19193
19700
|
this.flipY = flipY;
|
|
@@ -19228,16 +19735,42 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19228
19735
|
this.model.draw(renderPass);
|
|
19229
19736
|
}
|
|
19230
19737
|
};
|
|
19738
|
+
function planFullscreenPasses(device, effect, options = {}) {
|
|
19739
|
+
const fallback = effect.initialPasses?.fragment ?? [];
|
|
19740
|
+
const compute = options.allowCompute !== false && supportsComputeOptimization(device, effect, options.colorFormat) ? effect.initialPasses ? effect.initialPasses.compute : effect.compute : void 0;
|
|
19741
|
+
const steps = effect.initialPasses ? [...compute ? [] : fallback, ...effect.steps] : compute ? effect.steps.filter((step) => !effect.compute.replacedPasses.includes(step.shaderPass.name)) : effect.steps;
|
|
19742
|
+
return {
|
|
19743
|
+
compute,
|
|
19744
|
+
passes: steps.flatMap((step) => {
|
|
19745
|
+
const ownerName = effect.name + "/" + step.shaderPass.name;
|
|
19746
|
+
validateShaderPassDoesNotOwnRenderTargets(step.shaderPass, ownerName);
|
|
19747
|
+
return planShaderSubpasses(step.shaderPass, ownerName, step);
|
|
19748
|
+
})
|
|
19749
|
+
};
|
|
19750
|
+
}
|
|
19751
|
+
function planShaderSubpasses(shaderPass, ownerName, step) {
|
|
19752
|
+
const subPasses = shaderPass.passes ?? [];
|
|
19753
|
+
return subPasses.map((subPass, index) => ({
|
|
19754
|
+
ownerName,
|
|
19755
|
+
shaderPass,
|
|
19756
|
+
subPass,
|
|
19757
|
+
inputs: (index === 0 ? step?.inputs : void 0) ?? subPass.inputs,
|
|
19758
|
+
output: (index === subPasses.length - 1 ? step?.output : void 0) ?? subPass.output,
|
|
19759
|
+
uniforms: mergeUniforms(step?.uniforms, subPass.uniforms)
|
|
19760
|
+
}));
|
|
19761
|
+
}
|
|
19231
19762
|
function getExecutableShaderPasses(shaderPasses) {
|
|
19232
19763
|
return shaderPasses.flatMap(
|
|
19233
|
-
(shaderPass) => isCompositeShaderPass(shaderPass) ? shaderPass.
|
|
19764
|
+
(shaderPass) => isCompositeShaderPass(shaderPass) ? [...shaderPass.initialPasses?.fragment ?? [], ...shaderPass.steps].map(
|
|
19765
|
+
(step) => step.shaderPass
|
|
19766
|
+
) : [shaderPass]
|
|
19234
19767
|
);
|
|
19235
19768
|
}
|
|
19236
19769
|
function isCompositeShaderPass(shaderPass) {
|
|
19237
19770
|
return "steps" in shaderPass;
|
|
19238
19771
|
}
|
|
19239
|
-
function supportsComputeOptimization(device, compositeShaderPass) {
|
|
19240
|
-
const optimization = compositeShaderPass.compute;
|
|
19772
|
+
function supportsComputeOptimization(device, compositeShaderPass, colorFormat = device.preferredColorFormat) {
|
|
19773
|
+
const optimization = compositeShaderPass.initialPasses ? compositeShaderPass.initialPasses.compute : compositeShaderPass.compute;
|
|
19241
19774
|
if (!optimization || device.type !== "webgpu") {
|
|
19242
19775
|
return false;
|
|
19243
19776
|
}
|
|
@@ -19250,7 +19783,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19250
19783
|
if (!target?.storage) {
|
|
19251
19784
|
return false;
|
|
19252
19785
|
}
|
|
19253
|
-
const format = target.format ||
|
|
19786
|
+
const format = target.format || colorFormat;
|
|
19254
19787
|
return device.getTextureFormatCapabilities(format).store;
|
|
19255
19788
|
});
|
|
19256
19789
|
}
|
|
@@ -19258,7 +19791,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19258
19791
|
const renderTargets = shaderPass.renderTargets;
|
|
19259
19792
|
if (renderTargets && Object.keys(renderTargets).length > 0) {
|
|
19260
19793
|
throw new Error(
|
|
19261
|
-
`${ownerName}:
|
|
19794
|
+
`${ownerName}: FullscreenEffectModule.renderTargets is not supported; use FullscreenEffectPlan.renderTargets instead`
|
|
19262
19795
|
);
|
|
19263
19796
|
}
|
|
19264
19797
|
}
|
|
@@ -19289,26 +19822,30 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19289
19822
|
...subPassUniforms || {}
|
|
19290
19823
|
};
|
|
19291
19824
|
}
|
|
19292
|
-
function resolveExecutionUniforms(shaderInputs, execution, runtimeUniforms) {
|
|
19825
|
+
function resolveExecutionUniforms(shaderInputs, execution, runtimeUniforms, occurrenceUniforms) {
|
|
19293
19826
|
return mergeUniforms(
|
|
19294
19827
|
mergeUniforms(
|
|
19295
19828
|
shaderInputs.getUniformValues()[execution.shaderPass.name],
|
|
19296
19829
|
execution.uniforms
|
|
19297
19830
|
),
|
|
19298
|
-
|
|
19831
|
+
mergeUniforms(
|
|
19832
|
+
runtimeUniforms[execution.shaderPass.name],
|
|
19833
|
+
occurrenceUniforms?.[execution.shaderPass.name]
|
|
19834
|
+
)
|
|
19299
19835
|
);
|
|
19300
19836
|
}
|
|
19301
|
-
function createManagedRenderTargets(device, renderTargets) {
|
|
19837
|
+
function createManagedRenderTargets(device, renderTargets, colorFormat) {
|
|
19302
19838
|
const size = device.getCanvasContext().getDrawingBufferSize();
|
|
19303
19839
|
const managedRenderTargets = {};
|
|
19304
|
-
for (const [name,
|
|
19840
|
+
for (const [name, resource] of Object.entries(renderTargets)) {
|
|
19841
|
+
const spec = resource.format ? resource : { ...resource, format: colorFormat };
|
|
19305
19842
|
if (spec.aliasFor) {
|
|
19306
19843
|
const aliasedTarget = managedRenderTargets[spec.aliasFor];
|
|
19307
19844
|
if (!aliasedTarget) {
|
|
19308
19845
|
throw new Error(`${name}: target alias references an unknown earlier target`);
|
|
19309
19846
|
}
|
|
19310
19847
|
const targetSize = getRenderTargetSize(size, spec.scale);
|
|
19311
|
-
const targetFormat = spec.format
|
|
19848
|
+
const targetFormat = spec.format ?? colorFormat;
|
|
19312
19849
|
if (spec.lifetime === "history" || aliasedTarget.spec.lifetime === "history" || !hasMatchingRenderTargetScale(spec, aliasedTarget.spec) || aliasedTarget.texture.width !== targetSize[0] || aliasedTarget.texture.height !== targetSize[1] || aliasedTarget.texture.format !== targetFormat || spec.storage && !aliasedTarget.spec.storage || !hasMatchingRenderTargetSampler(spec, aliasedTarget.spec)) {
|
|
19313
19850
|
throw new Error(
|
|
19314
19851
|
`${name}: target alias must match a transient target's size, format, and sampler`
|
|
@@ -19393,7 +19930,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19393
19930
|
width: targetSize[0],
|
|
19394
19931
|
height: targetSize[1],
|
|
19395
19932
|
format: spec.format || device.preferredColorFormat,
|
|
19396
|
-
usage:
|
|
19933
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.RENDER | import_core27.Texture.COPY_SRC | import_core27.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core27.Texture.STORAGE : 0),
|
|
19397
19934
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
19398
19935
|
});
|
|
19399
19936
|
const framebuffer = device.createFramebuffer({
|
|
@@ -19422,7 +19959,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19422
19959
|
function getFramebufferTexture(framebuffer) {
|
|
19423
19960
|
const texture = framebuffer.colorAttachments[0]?.texture;
|
|
19424
19961
|
if (!texture) {
|
|
19425
|
-
throw new Error("
|
|
19962
|
+
throw new Error("FullscreenEffectExecutor: framebuffer is missing a color attachment texture");
|
|
19426
19963
|
}
|
|
19427
19964
|
return texture;
|
|
19428
19965
|
}
|
|
@@ -19447,8 +19984,192 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19447
19984
|
return [sourceAspect / outputAspect, 1];
|
|
19448
19985
|
}
|
|
19449
19986
|
|
|
19987
|
+
// src/passes/effect-renderer.ts
|
|
19988
|
+
function resolveEffectOptions(effect, options) {
|
|
19989
|
+
if ("configure" in effect) return effect.configure(options);
|
|
19990
|
+
const {
|
|
19991
|
+
scaleResources,
|
|
19992
|
+
variants,
|
|
19993
|
+
optionDefaults,
|
|
19994
|
+
optionUniforms,
|
|
19995
|
+
optionInputs,
|
|
19996
|
+
historyClearOptions
|
|
19997
|
+
} = effect;
|
|
19998
|
+
const overrides = options;
|
|
19999
|
+
const defaults = optionDefaults;
|
|
20000
|
+
const readOption = (key) => overrides?.[key] ?? defaults[key];
|
|
20001
|
+
const readValue = (mapping) => {
|
|
20002
|
+
const option = readOption(mapping.option);
|
|
20003
|
+
if (!mapping.values) return option;
|
|
20004
|
+
const key = String(option);
|
|
20005
|
+
return Object.hasOwn(mapping.values, key) ? mapping.values[key] : void 0;
|
|
20006
|
+
};
|
|
20007
|
+
const value = variants && String(readOption(variants.option));
|
|
20008
|
+
const variant = variants && value !== void 0 && Object.hasOwn(variants.values, value) ? variants.values[value] : void 0;
|
|
20009
|
+
const resolved = { ...effect, ...variant };
|
|
20010
|
+
const resources = { ...resolved.resources };
|
|
20011
|
+
if (scaleResources) {
|
|
20012
|
+
const scale5 = readValue(scaleResources) ?? (scaleResources.fallback && readValue(scaleResources.fallback)) ?? scaleResources.defaultScale;
|
|
20013
|
+
if (typeof scale5 !== "number" || !Number.isFinite(scale5) || scale5 <= 0 && !scaleResources.minimum) {
|
|
20014
|
+
throw new Error(effect.name + ": resource scale must be a finite positive number");
|
|
20015
|
+
}
|
|
20016
|
+
for (const name of scaleResources.targets) {
|
|
20017
|
+
const resource = resources[name];
|
|
20018
|
+
if (!resource?.scale) continue;
|
|
20019
|
+
const factor = scaleResources.factors?.[name] ?? 1;
|
|
20020
|
+
const size = Math.max(scale5, scaleResources.minimum ?? 0) * factor;
|
|
20021
|
+
resources[name] = { ...resource, scale: [size, size] };
|
|
20022
|
+
}
|
|
20023
|
+
}
|
|
20024
|
+
for (const name of Object.keys(historyClearOptions ?? {})) {
|
|
20025
|
+
const mapping = historyClearOptions?.[name];
|
|
20026
|
+
const resource = resources[name];
|
|
20027
|
+
const initial = resource?.initialize;
|
|
20028
|
+
if (!mapping || !initial || initial === "original") continue;
|
|
20029
|
+
const value2 = readOption(mapping.option);
|
|
20030
|
+
if (typeof value2 === "number" && Number.isFinite(value2)) {
|
|
20031
|
+
const [, green, blue, alpha] = initial.clearColor;
|
|
20032
|
+
resources[name] = {
|
|
20033
|
+
...resource,
|
|
20034
|
+
initialize: {
|
|
20035
|
+
clearColor: [Math.max(value2, mapping.minimum ?? -Infinity), green, blue, alpha]
|
|
20036
|
+
}
|
|
20037
|
+
};
|
|
20038
|
+
}
|
|
20039
|
+
}
|
|
20040
|
+
const passes = resolved.passes.map((pass) => {
|
|
20041
|
+
const moduleName = pass.kind === "fullscreen" ? pass.shaderPass.name : pass.module.name;
|
|
20042
|
+
const uniformOptions = optionUniforms?.[moduleName];
|
|
20043
|
+
const inputOptions = optionInputs?.[moduleName];
|
|
20044
|
+
if (!uniformOptions && !inputOptions) return pass;
|
|
20045
|
+
const uniforms = { ...pass.uniforms };
|
|
20046
|
+
const inputs = { ...pass.inputs };
|
|
20047
|
+
for (const [name, mapping] of Object.entries(uniformOptions ?? {})) {
|
|
20048
|
+
const value2 = readValue(mapping);
|
|
20049
|
+
if (value2 !== void 0) uniforms[name] = value2;
|
|
20050
|
+
}
|
|
20051
|
+
for (const [name, mapping] of Object.entries(inputOptions ?? {})) {
|
|
20052
|
+
const value2 = readValue(mapping);
|
|
20053
|
+
if (typeof value2 === "string") inputs[name] = value2;
|
|
20054
|
+
}
|
|
20055
|
+
return { ...pass, uniforms, ...inputOptions ? { inputs } : {} };
|
|
20056
|
+
});
|
|
20057
|
+
return { ...resolved, resources, passes };
|
|
20058
|
+
}
|
|
20059
|
+
function resolveEffect(effect) {
|
|
20060
|
+
return {
|
|
20061
|
+
name: effect.name,
|
|
20062
|
+
renderTargets: effect.resources,
|
|
20063
|
+
initialPasses: effect.initialPasses && {
|
|
20064
|
+
...effect.initialPasses,
|
|
20065
|
+
fragment: effect.initialPasses.fragment.map(lowerEffectPass)
|
|
20066
|
+
},
|
|
20067
|
+
steps: effect.passes.map(lowerEffectPass)
|
|
20068
|
+
};
|
|
20069
|
+
}
|
|
20070
|
+
function lowerEffectPass(pass) {
|
|
20071
|
+
if (pass.kind === "fullscreen") return pass;
|
|
20072
|
+
const { kind, module, ...routing } = pass;
|
|
20073
|
+
return { ...routing, shaderPass: { ...module, passes: [{ action: kind }] } };
|
|
20074
|
+
}
|
|
20075
|
+
function resolveEffectEntries(effects) {
|
|
20076
|
+
return effects.map((entry) => {
|
|
20077
|
+
if (!("effect" in entry)) {
|
|
20078
|
+
return resolveEffect(
|
|
20079
|
+
"optionDefaults" in entry ? resolveEffectOptions(entry) : entry
|
|
20080
|
+
);
|
|
20081
|
+
}
|
|
20082
|
+
const { effect } = entry;
|
|
20083
|
+
if ("configure" in effect && effect.configure || "optionDefaults" in effect) {
|
|
20084
|
+
return resolveEffect(
|
|
20085
|
+
resolveEffectOptions(effect, entry.options)
|
|
20086
|
+
);
|
|
20087
|
+
}
|
|
20088
|
+
return resolveEffect(effect);
|
|
20089
|
+
});
|
|
20090
|
+
}
|
|
20091
|
+
var EffectRenderer = class {
|
|
20092
|
+
device;
|
|
20093
|
+
#executor;
|
|
20094
|
+
constructor(device, { effects, ...props }) {
|
|
20095
|
+
this.device = device;
|
|
20096
|
+
this.#executor = new FullscreenEffectExecutor(device, {
|
|
20097
|
+
...props,
|
|
20098
|
+
shaderPasses: resolveEffectEntries(effects),
|
|
20099
|
+
occurrences: effects.map(
|
|
20100
|
+
(entry) => "effect" in entry ? { bindings: { ...entry.bindings }, uniforms: { ...entry.uniforms } } : void 0
|
|
20101
|
+
)
|
|
20102
|
+
});
|
|
20103
|
+
}
|
|
20104
|
+
destroy() {
|
|
20105
|
+
this.#executor.destroy();
|
|
20106
|
+
}
|
|
20107
|
+
resize(size) {
|
|
20108
|
+
this.#executor.resize(size);
|
|
20109
|
+
}
|
|
20110
|
+
resetHistory() {
|
|
20111
|
+
this.#executor.resetHistory();
|
|
20112
|
+
}
|
|
20113
|
+
/** Uses a borrowed sampler for both color-chain textures. Set again after resizing. */
|
|
20114
|
+
setColorSampler(sampler) {
|
|
20115
|
+
const { current, next } = this.#executor.swapFramebuffers;
|
|
20116
|
+
current.colorAttachments[0].texture.setSampler(sampler);
|
|
20117
|
+
next.colorAttachments[0].texture.setSampler(sampler);
|
|
20118
|
+
}
|
|
20119
|
+
get shaderInputs() {
|
|
20120
|
+
return this.#executor.shaderInputs;
|
|
20121
|
+
}
|
|
20122
|
+
renderToTexture(options) {
|
|
20123
|
+
return this.render(options);
|
|
20124
|
+
}
|
|
20125
|
+
renderToScreen(options) {
|
|
20126
|
+
return this.render({ ...options, target: null });
|
|
20127
|
+
}
|
|
20128
|
+
encodeToTexture(commandEncoder, options) {
|
|
20129
|
+
return this.render({ ...options, commandEncoder });
|
|
20130
|
+
}
|
|
20131
|
+
encodeToScreen(commandEncoder, options) {
|
|
20132
|
+
return this.render({ ...options, commandEncoder, target: null });
|
|
20133
|
+
}
|
|
20134
|
+
render({
|
|
20135
|
+
target,
|
|
20136
|
+
commandEncoder = this.device.commandEncoder,
|
|
20137
|
+
...frame
|
|
20138
|
+
}) {
|
|
20139
|
+
if (target && target.device !== this.device) {
|
|
20140
|
+
throw new Error("EffectRenderer target must belong to the renderer device");
|
|
20141
|
+
}
|
|
20142
|
+
const output = this.#executor.encodeToTexture(commandEncoder, frame);
|
|
20143
|
+
if (target === void 0) {
|
|
20144
|
+
return output;
|
|
20145
|
+
}
|
|
20146
|
+
if (!output) {
|
|
20147
|
+
return false;
|
|
20148
|
+
}
|
|
20149
|
+
this.#executor.drawOutput(commandEncoder, output, target);
|
|
20150
|
+
return true;
|
|
20151
|
+
}
|
|
20152
|
+
};
|
|
20153
|
+
|
|
20154
|
+
// src/passes/scene-capture-pass.ts
|
|
20155
|
+
function encodeSceneCapturePass(definition, options) {
|
|
20156
|
+
const { commandEncoder, frame } = options;
|
|
20157
|
+
definition.prepare?.(commandEncoder, frame);
|
|
20158
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
20159
|
+
...definition.pass,
|
|
20160
|
+
...definition.getPassProps?.(frame),
|
|
20161
|
+
id: options.id ?? definition.name,
|
|
20162
|
+
framebuffer: options.framebuffers[definition.target]
|
|
20163
|
+
});
|
|
20164
|
+
try {
|
|
20165
|
+
return definition.draw(renderPass, frame);
|
|
20166
|
+
} finally {
|
|
20167
|
+
renderPass.end();
|
|
20168
|
+
}
|
|
20169
|
+
}
|
|
20170
|
+
|
|
19450
20171
|
// src/modules/picking/picking-manager.ts
|
|
19451
|
-
var
|
|
20172
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
19452
20173
|
|
|
19453
20174
|
// src/modules/picking/picking-uniforms.ts
|
|
19454
20175
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -19712,13 +20433,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
19712
20433
|
format: "rgba8unorm",
|
|
19713
20434
|
width: 1,
|
|
19714
20435
|
height: 1,
|
|
19715
|
-
usage:
|
|
20436
|
+
usage: import_core28.Texture.RENDER_ATTACHMENT
|
|
19716
20437
|
});
|
|
19717
20438
|
const pickingTexture = this.device.createTexture({
|
|
19718
20439
|
format: "rg32sint",
|
|
19719
20440
|
width: 1,
|
|
19720
20441
|
height: 1,
|
|
19721
|
-
usage:
|
|
20442
|
+
usage: import_core28.Texture.RENDER_ATTACHMENT | import_core28.Texture.COPY_SRC
|
|
19722
20443
|
});
|
|
19723
20444
|
return this.device.createFramebuffer({
|
|
19724
20445
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -19730,7 +20451,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19730
20451
|
format: "rgba8unorm",
|
|
19731
20452
|
width: 1,
|
|
19732
20453
|
height: 1,
|
|
19733
|
-
usage:
|
|
20454
|
+
usage: import_core28.Texture.RENDER_ATTACHMENT | import_core28.Texture.COPY_SRC
|
|
19734
20455
|
});
|
|
19735
20456
|
return this.device.createFramebuffer({
|
|
19736
20457
|
colorAttachments: [pickingTexture],
|
|
@@ -19752,7 +20473,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19752
20473
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19753
20474
|
const readBuffer = this.device.createBuffer({
|
|
19754
20475
|
byteLength: layout.byteLength,
|
|
19755
|
-
usage:
|
|
20476
|
+
usage: import_core28.Buffer.COPY_DST | import_core28.Buffer.MAP_READ
|
|
19756
20477
|
});
|
|
19757
20478
|
try {
|
|
19758
20479
|
pickTexture.readBuffer(
|
|
@@ -19788,7 +20509,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19788
20509
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19789
20510
|
const readBuffer = this.device.createBuffer({
|
|
19790
20511
|
byteLength: layout.byteLength,
|
|
19791
|
-
usage:
|
|
20512
|
+
usage: import_core28.Buffer.COPY_DST | import_core28.Buffer.MAP_READ
|
|
19792
20513
|
});
|
|
19793
20514
|
try {
|
|
19794
20515
|
pickTexture.readBuffer(
|
|
@@ -20470,7 +21191,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20470
21191
|
}
|
|
20471
21192
|
|
|
20472
21193
|
// src/scenegraph/controllers/skin-controller.ts
|
|
20473
|
-
var
|
|
21194
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
20474
21195
|
var SkinController = class {
|
|
20475
21196
|
bindings;
|
|
20476
21197
|
/** Palettes owned by a GPU producer for the duration of their binding. */
|
|
@@ -20504,7 +21225,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20504
21225
|
target: binding.jointMatrices
|
|
20505
21226
|
});
|
|
20506
21227
|
if (binding.skinJointMatrices) {
|
|
20507
|
-
if (binding.skinJointMatrices instanceof
|
|
21228
|
+
if (binding.skinJointMatrices instanceof import_core29.Buffer) {
|
|
20508
21229
|
binding.skinJointMatrices.write(binding.jointMatrices);
|
|
20509
21230
|
} else {
|
|
20510
21231
|
binding.skinJointMatrices.writeData(binding.jointMatrices, {
|
|
@@ -20522,7 +21243,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20522
21243
|
}
|
|
20523
21244
|
/** Borrow a WebGPU storage palette and suspend CPU writes until the lease is released. */
|
|
20524
21245
|
claimGPUPalette(binding) {
|
|
20525
|
-
if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof
|
|
21246
|
+
if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof import_core29.Buffer))
|
|
20526
21247
|
throw new Error("GPU skinning requires an owned storage palette");
|
|
20527
21248
|
if (this.gpuDriven.has(binding)) throw new Error("Skin palette already has a GPU producer");
|
|
20528
21249
|
this.gpuDriven.add(binding);
|
|
@@ -20549,7 +21270,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20549
21270
|
return device.createBuffer({
|
|
20550
21271
|
id: `${id}-skin-joint-matrices`,
|
|
20551
21272
|
byteLength: jointMatrices.byteLength,
|
|
20552
|
-
usage:
|
|
21273
|
+
usage: import_core29.Buffer.STORAGE | import_core29.Buffer.COPY_DST
|
|
20553
21274
|
});
|
|
20554
21275
|
}
|
|
20555
21276
|
const width = jointMatrices.length / 4;
|
|
@@ -20561,7 +21282,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20561
21282
|
format: "rgba32float",
|
|
20562
21283
|
width,
|
|
20563
21284
|
height: 1,
|
|
20564
|
-
usage:
|
|
21285
|
+
usage: import_core29.Texture.SAMPLE | import_core29.Texture.COPY_DST,
|
|
20565
21286
|
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
20566
21287
|
});
|
|
20567
21288
|
}
|
|
@@ -20604,7 +21325,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20604
21325
|
};
|
|
20605
21326
|
|
|
20606
21327
|
// src/scenegraph/controllers/billboard-controller.ts
|
|
20607
|
-
var
|
|
21328
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
20608
21329
|
var BillboardController = class {
|
|
20609
21330
|
scenes;
|
|
20610
21331
|
bindings = /* @__PURE__ */ new Map();
|
|
@@ -20615,8 +21336,8 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20615
21336
|
const { definition } = binding;
|
|
20616
21337
|
const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
|
|
20617
21338
|
const up = new Vector3(definition.up || [0, 1, 0]);
|
|
20618
|
-
(0,
|
|
20619
|
-
(0,
|
|
21339
|
+
(0, import_core30.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
|
|
21340
|
+
(0, import_core30.assert)(
|
|
20620
21341
|
new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
|
|
20621
21342
|
);
|
|
20622
21343
|
this.bindings.set(binding.node, binding);
|
|
@@ -20626,7 +21347,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20626
21347
|
getDrawEntries(options) {
|
|
20627
21348
|
const { sceneIndex = 0, cameraId = "default" } = options;
|
|
20628
21349
|
const scene = this.scenes[sceneIndex];
|
|
20629
|
-
(0,
|
|
21350
|
+
(0, import_core30.assert)(scene);
|
|
20630
21351
|
const viewMatrix = new Matrix4(options.viewMatrix);
|
|
20631
21352
|
const cameraMatrix = new Matrix4(viewMatrix).invert();
|
|
20632
21353
|
const cameraPosition = new Vector3(cameraMatrix.getTranslation());
|
|
@@ -20826,7 +21547,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20826
21547
|
}
|
|
20827
21548
|
|
|
20828
21549
|
// src/scenegraph/controllers/area-light-controller.ts
|
|
20829
|
-
var
|
|
21550
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
20830
21551
|
var AreaLightController = class {
|
|
20831
21552
|
scenes;
|
|
20832
21553
|
matrixAuthoredNodes = /* @__PURE__ */ new Set();
|
|
@@ -20836,11 +21557,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20836
21557
|
for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
|
|
20837
21558
|
for (const { node, definition, matrixAuthored } of bindings) {
|
|
20838
21559
|
if (matrixAuthored) this.matrixAuthoredNodes.add(node);
|
|
20839
|
-
(0,
|
|
20840
|
-
(0,
|
|
20841
|
-
(0,
|
|
20842
|
-
(0,
|
|
20843
|
-
(0,
|
|
21560
|
+
(0, import_core31.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
|
|
21561
|
+
(0, import_core31.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
|
|
21562
|
+
(0, import_core31.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
|
|
21563
|
+
(0, import_core31.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
|
|
21564
|
+
(0, import_core31.assert)(
|
|
20844
21565
|
(definition.color || [1, 1, 1]).every(
|
|
20845
21566
|
(component) => Number.isFinite(component) && component >= 0
|
|
20846
21567
|
)
|
|
@@ -20906,17 +21627,17 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20906
21627
|
function getMatrixRotation(matrix) {
|
|
20907
21628
|
const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
|
|
20908
21629
|
const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
|
|
20909
|
-
(0,
|
|
21630
|
+
(0, import_core31.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
|
|
20910
21631
|
horizontal.normalize();
|
|
20911
21632
|
vertical.normalize();
|
|
20912
21633
|
vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
|
|
20913
|
-
(0,
|
|
21634
|
+
(0, import_core31.assert)(vertical.magnitude() > 1e-8);
|
|
20914
21635
|
vertical.normalize();
|
|
20915
21636
|
const forward = new Vector3(horizontal).cross(vertical).normalize();
|
|
20916
21637
|
const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
|
|
20917
|
-
(0,
|
|
21638
|
+
(0, import_core31.assert)(authoredForward.magnitude() > 0);
|
|
20918
21639
|
authoredForward.normalize();
|
|
20919
|
-
(0,
|
|
21640
|
+
(0, import_core31.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
|
|
20920
21641
|
if (forward.dot(authoredForward) < 0) forward.negate();
|
|
20921
21642
|
return new Matrix4([
|
|
20922
21643
|
horizontal[0],
|
|
@@ -21474,7 +22195,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21474
22195
|
};
|
|
21475
22196
|
|
|
21476
22197
|
// src/audio/audio-graph.ts
|
|
21477
|
-
var
|
|
22198
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
21478
22199
|
var AudioGraph = class {
|
|
21479
22200
|
constructor(definition, context, destination, getEmitterInputs) {
|
|
21480
22201
|
this.definition = definition;
|
|
@@ -21482,10 +22203,10 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21482
22203
|
this.destination = destination;
|
|
21483
22204
|
this.getEmitterInputs = getEmitterInputs;
|
|
21484
22205
|
for (const node of definition.nodes)
|
|
21485
|
-
(0,
|
|
22206
|
+
(0, import_core32.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
|
|
21486
22207
|
const validateEndpoint = (index, port = 0) => {
|
|
21487
|
-
(0,
|
|
21488
|
-
(0,
|
|
22208
|
+
(0, import_core32.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
|
|
22209
|
+
(0, import_core32.assert)(Number.isInteger(port) && port >= 0);
|
|
21489
22210
|
};
|
|
21490
22211
|
for (const edge of definition.connections) {
|
|
21491
22212
|
validateEndpoint(edge.from.node, edge.from.output);
|
|
@@ -21493,16 +22214,16 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21493
22214
|
}
|
|
21494
22215
|
for (const input of definition.inputs || []) {
|
|
21495
22216
|
validateEndpoint(input.node, input.input);
|
|
21496
|
-
(0,
|
|
22217
|
+
(0, import_core32.assert)(Number.isInteger(input.source) && input.source >= 0);
|
|
21497
22218
|
}
|
|
21498
22219
|
for (const output of definition.outputs || []) {
|
|
21499
22220
|
validateEndpoint(output.node, output.output);
|
|
21500
|
-
(0,
|
|
22221
|
+
(0, import_core32.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
|
|
21501
22222
|
}
|
|
21502
22223
|
const visiting = /* @__PURE__ */ new Set();
|
|
21503
22224
|
const visited = /* @__PURE__ */ new Set();
|
|
21504
22225
|
const visit = (index) => {
|
|
21505
|
-
(0,
|
|
22226
|
+
(0, import_core32.assert)(definition.nodes[index] && !visiting.has(index));
|
|
21506
22227
|
if (visited.has(index)) return;
|
|
21507
22228
|
visiting.add(index);
|
|
21508
22229
|
for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
|
|
@@ -21582,7 +22303,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21582
22303
|
/** Apply a scene-driven gain change using the authored transition shape. */
|
|
21583
22304
|
setGain(index, gain, time = this.nodes[index].context.currentTime) {
|
|
21584
22305
|
const definition = this.definition.nodes[index];
|
|
21585
|
-
(0,
|
|
22306
|
+
(0, import_core32.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
|
|
21586
22307
|
const parameter = this.nodes[index].gain;
|
|
21587
22308
|
const duration = definition.params.duration ?? 0;
|
|
21588
22309
|
const initialGain = parameter.value;
|
|
@@ -21592,7 +22313,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21592
22313
|
parameter.setValueAtTime(gain, time);
|
|
21593
22314
|
} else if (definition.params.interpolation === "custom") {
|
|
21594
22315
|
const curve = definition.params.curve;
|
|
21595
|
-
(0,
|
|
22316
|
+
(0, import_core32.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
|
|
21596
22317
|
parameter.setValueCurveAtTime(
|
|
21597
22318
|
Float32Array.from(curve, (value) => value * gain),
|
|
21598
22319
|
time,
|
|
@@ -21678,7 +22399,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21678
22399
|
}
|
|
21679
22400
|
|
|
21680
22401
|
// src/audio/audio-environment.ts
|
|
21681
|
-
var
|
|
22402
|
+
var import_core33 = __toESM(require_core(), 1);
|
|
21682
22403
|
function selectAudioEnvironmentZone(zones, position) {
|
|
21683
22404
|
let selected;
|
|
21684
22405
|
for (const zone of zones) {
|
|
@@ -21771,7 +22492,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21771
22492
|
}
|
|
21772
22493
|
};
|
|
21773
22494
|
function createParametricAudioResponse(context, parameters) {
|
|
21774
|
-
(0,
|
|
22495
|
+
(0, import_core33.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
|
|
21775
22496
|
const presets = {
|
|
21776
22497
|
generic: [1.49, 0.83, 7e-3, 0.011],
|
|
21777
22498
|
smallRoom: [0.4, 0.83, 2e-3, 3e-3],
|
|
@@ -21788,12 +22509,12 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21788
22509
|
underwater: [1.49, 0.1, 7e-3, 0.011]
|
|
21789
22510
|
};
|
|
21790
22511
|
const preset = parameters.preset ? presets[parameters.preset] : void 0;
|
|
21791
|
-
(0,
|
|
22512
|
+
(0, import_core33.assert)(!parameters.preset || preset);
|
|
21792
22513
|
const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
|
|
21793
22514
|
const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
|
|
21794
22515
|
const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
|
|
21795
22516
|
const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
|
|
21796
|
-
(0,
|
|
22517
|
+
(0, import_core33.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
|
|
21797
22518
|
const response = context.createBuffer(
|
|
21798
22519
|
2,
|
|
21799
22520
|
Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
|
|
@@ -21817,7 +22538,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21817
22538
|
}
|
|
21818
22539
|
|
|
21819
22540
|
// src/audio/audio-controller.ts
|
|
21820
|
-
var
|
|
22541
|
+
var import_core34 = __toESM(require_core(), 1);
|
|
21821
22542
|
var AudioController = class {
|
|
21822
22543
|
gain;
|
|
21823
22544
|
definition;
|
|
@@ -21927,25 +22648,25 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21927
22648
|
/** Change a graph gain using its authored interpolation and duration. */
|
|
21928
22649
|
setGraphGain(graphIndex, nodeIndex, gain) {
|
|
21929
22650
|
const graph = this.graphs.get(graphIndex);
|
|
21930
|
-
(0,
|
|
22651
|
+
(0, import_core34.assert)(!this.destroyed && graph);
|
|
21931
22652
|
graph.setGain(nodeIndex, gain);
|
|
21932
22653
|
}
|
|
21933
22654
|
startSource(sourceIndex, startTime, autoplayOnly, connect) {
|
|
21934
22655
|
const definition = this.definition.sources[sourceIndex];
|
|
21935
|
-
(0,
|
|
22656
|
+
(0, import_core34.assert)(definition);
|
|
21936
22657
|
if (autoplayOnly && !definition.autoPlay) return;
|
|
21937
22658
|
const context = this.options.audioContext;
|
|
21938
22659
|
const extended = definition.graph;
|
|
21939
22660
|
const oscillator = extended?.oscillator;
|
|
21940
|
-
(0,
|
|
22661
|
+
(0, import_core34.assert)(!(definition.audio !== void 0 && oscillator));
|
|
21941
22662
|
let source4;
|
|
21942
22663
|
if (oscillator) {
|
|
21943
22664
|
const node = context.createOscillator();
|
|
21944
22665
|
node.frequency.value = oscillator.frequency ?? 440;
|
|
21945
22666
|
node.detune.value = oscillator.detune ?? 0;
|
|
21946
|
-
(0,
|
|
22667
|
+
(0, import_core34.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
|
|
21947
22668
|
if (oscillator.type === "custom") {
|
|
21948
|
-
(0,
|
|
22669
|
+
(0, import_core34.assert)(oscillator.periodicWave);
|
|
21949
22670
|
node.setPeriodicWave(
|
|
21950
22671
|
context.createPeriodicWave(
|
|
21951
22672
|
new Float32Array(oscillator.periodicWave.real),
|
|
@@ -21956,7 +22677,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21956
22677
|
source4 = node;
|
|
21957
22678
|
} else {
|
|
21958
22679
|
const node = context.createBufferSource();
|
|
21959
|
-
(0,
|
|
22680
|
+
(0, import_core34.assert)(definition.audio !== void 0);
|
|
21960
22681
|
node.buffer = this.buffers.get(definition.audio);
|
|
21961
22682
|
node.loop = definition.loop ?? false;
|
|
21962
22683
|
node.loopStart = extended?.loopStart ?? 0;
|
|
@@ -22104,15 +22825,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22104
22825
|
}
|
|
22105
22826
|
addEmitter(index, node) {
|
|
22106
22827
|
const definition = this.definition.emitters[index];
|
|
22107
|
-
(0,
|
|
22828
|
+
(0, import_core34.assert)(
|
|
22108
22829
|
definition && (definition.type === "global" || definition.type === "positional" && node)
|
|
22109
22830
|
);
|
|
22110
|
-
(0,
|
|
22831
|
+
(0, import_core34.assert)(
|
|
22111
22832
|
!definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
|
|
22112
22833
|
);
|
|
22113
22834
|
for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
|
|
22114
22835
|
const source4 = this.definition.sources[sourceIndex];
|
|
22115
|
-
(0,
|
|
22836
|
+
(0, import_core34.assert)(
|
|
22116
22837
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
22117
22838
|
);
|
|
22118
22839
|
}
|
|
@@ -22157,7 +22878,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22157
22878
|
const audioIndices = new Set(
|
|
22158
22879
|
[...sourceIndices].map((index) => {
|
|
22159
22880
|
const source4 = this.definition.sources[index];
|
|
22160
|
-
(0,
|
|
22881
|
+
(0, import_core34.assert)(
|
|
22161
22882
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
22162
22883
|
);
|
|
22163
22884
|
return source4.audio;
|
|
@@ -22194,7 +22915,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22194
22915
|
const reverb = environment.reverb;
|
|
22195
22916
|
if (!reverb) return;
|
|
22196
22917
|
const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
|
|
22197
|
-
(0,
|
|
22918
|
+
(0, import_core34.assert)(response);
|
|
22198
22919
|
const bus = new AudioReverbBus(audioContext, response, this.gain, {
|
|
22199
22920
|
...reverb,
|
|
22200
22921
|
normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
|
|
@@ -22303,7 +23024,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22303
23024
|
var legacyColorPicking = import_shaders9.picking;
|
|
22304
23025
|
|
|
22305
23026
|
// src/geometry/ring-geometry.ts
|
|
22306
|
-
var
|
|
23027
|
+
var import_core35 = __toESM(require_core(), 1);
|
|
22307
23028
|
var RingGeometry = class extends Geometry2 {
|
|
22308
23029
|
constructor(props = {}) {
|
|
22309
23030
|
const {
|
|
@@ -22314,7 +23035,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22314
23035
|
startAngle = 0,
|
|
22315
23036
|
angle: angle2 = Math.PI * 2
|
|
22316
23037
|
} = props;
|
|
22317
|
-
(0,
|
|
23038
|
+
(0, import_core35.assert)(
|
|
22318
23039
|
Number.isFinite(innerRadius) && innerRadius >= 0 && Number.isFinite(outerRadius) && outerRadius > innerRadius && Number.isFinite(height) && height > 0 && Number.isFinite(startAngle) && Number.isFinite(angle2) && angle2 > 0 && angle2 <= Math.PI * 2 && Number.isInteger(segments) && segments >= 3
|
|
22319
23040
|
);
|
|
22320
23041
|
const halfHeight = height / 2;
|
|
@@ -22497,92 +23218,6 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22497
23218
|
bindingLayout: [{ name: "publishedBodyMatrices", group: 0 }]
|
|
22498
23219
|
};
|
|
22499
23220
|
|
|
22500
|
-
// src/scenegraph/controllers/morph-controller.ts
|
|
22501
|
-
var import_core34 = __toESM(require_core(), 1);
|
|
22502
|
-
function setMorphWeights(node, weights) {
|
|
22503
|
-
node.userData["morphWeights"] = [...weights];
|
|
22504
|
-
const meshes = node.userData["morphMeshes"] || [];
|
|
22505
|
-
for (const mesh of meshes) {
|
|
22506
|
-
mesh.preorderTraversal((child) => {
|
|
22507
|
-
if (!(child instanceof ModelNode)) {
|
|
22508
|
-
return;
|
|
22509
|
-
}
|
|
22510
|
-
const state = child.userData["morphTargets"];
|
|
22511
|
-
if (!state) {
|
|
22512
|
-
return;
|
|
22513
|
-
}
|
|
22514
|
-
const gpuWeights = child.userData["morphWeightTransport"];
|
|
22515
|
-
if (gpuWeights) {
|
|
22516
|
-
updateMorphWeights(gpuWeights, weights);
|
|
22517
|
-
child.userData["morphWeights"] = [...weights];
|
|
22518
|
-
return;
|
|
22519
|
-
}
|
|
22520
|
-
updateMorphTargetBuffers(child.model, state.geometry, state.targets, weights);
|
|
22521
|
-
child.userData["morphWeights"] = [...weights];
|
|
22522
|
-
});
|
|
22523
|
-
}
|
|
22524
|
-
}
|
|
22525
|
-
function updateMorphWeights(state, weights) {
|
|
22526
|
-
state.values.fill(0);
|
|
22527
|
-
state.values.set(weights.slice(0, state.values.length));
|
|
22528
|
-
if (state.data instanceof import_core34.Buffer) {
|
|
22529
|
-
state.data.write(state.values);
|
|
22530
|
-
} else {
|
|
22531
|
-
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|
|
22532
|
-
}
|
|
22533
|
-
}
|
|
22534
|
-
|
|
22535
|
-
// src/animation/node-animation-binding.ts
|
|
22536
|
-
function makeNodeAnimationBinding(node, property, options = {}) {
|
|
22537
|
-
return {
|
|
22538
|
-
id: options.id,
|
|
22539
|
-
getValue: () => {
|
|
22540
|
-
switch (property) {
|
|
22541
|
-
case "translation":
|
|
22542
|
-
return Array.from(node.position);
|
|
22543
|
-
case "rotation":
|
|
22544
|
-
return Array.from(node.rotation);
|
|
22545
|
-
case "scale":
|
|
22546
|
-
return Array.from(node.scale);
|
|
22547
|
-
case "weights":
|
|
22548
|
-
return Array.from(node.userData["morphWeights"] ?? []);
|
|
22549
|
-
case "visibility":
|
|
22550
|
-
return [node.display ? 1 : 0];
|
|
22551
|
-
case "selectable":
|
|
22552
|
-
return [node.selectable ? 1 : 0];
|
|
22553
|
-
case "hoverable":
|
|
22554
|
-
return [node.hoverable ? 1 : 0];
|
|
22555
|
-
}
|
|
22556
|
-
},
|
|
22557
|
-
setValue: (value) => {
|
|
22558
|
-
switch (property) {
|
|
22559
|
-
case "translation":
|
|
22560
|
-
node.setPosition(value).updateMatrix();
|
|
22561
|
-
break;
|
|
22562
|
-
case "rotation":
|
|
22563
|
-
node.setRotation(value).updateMatrix();
|
|
22564
|
-
break;
|
|
22565
|
-
case "scale":
|
|
22566
|
-
node.setScale(value).updateMatrix();
|
|
22567
|
-
break;
|
|
22568
|
-
case "weights":
|
|
22569
|
-
setMorphWeights(node, value);
|
|
22570
|
-
break;
|
|
22571
|
-
case "selectable":
|
|
22572
|
-
node.setProps({ selectable: value[0] !== 0 });
|
|
22573
|
-
break;
|
|
22574
|
-
case "hoverable":
|
|
22575
|
-
node.setProps({ hoverable: value[0] !== 0 });
|
|
22576
|
-
break;
|
|
22577
|
-
case "visibility":
|
|
22578
|
-
node.setProps({ display: value[0] !== 0 });
|
|
22579
|
-
options.onVisibilityChange?.();
|
|
22580
|
-
break;
|
|
22581
|
-
}
|
|
22582
|
-
}
|
|
22583
|
-
};
|
|
22584
|
-
}
|
|
22585
|
-
|
|
22586
23221
|
// src/animation/scenegraph-animator.ts
|
|
22587
23222
|
var ScenegraphAnimator = class extends Animator {
|
|
22588
23223
|
mixer;
|