@luma.gl/engine 10.0.0-beta.4 → 10.0.0-rc.2
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 +82 -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/audio/audio-controller.cjs +6 -2
- package/dist/audio/audio-controller.d.ts.map +1 -1
- package/dist/audio/audio-controller.js +6 -2
- package/dist/audio/audio-controller.js.map +1 -1
- package/dist/audio/audio-graph.cjs +26 -2
- package/dist/audio/audio-graph.d.ts +9 -0
- package/dist/audio/audio-graph.d.ts.map +1 -1
- package/dist/audio/audio-graph.js +35 -10
- package/dist/audio/audio-graph.js.map +1 -1
- package/dist/dist.dev.js +1689 -1094
- 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 +402 -0
- package/dist/effects/graph/gpu-effect-operation.d.ts +101 -0
- package/dist/effects/graph/gpu-effect-operation.d.ts.map +1 -0
- package/dist/effects/graph/gpu-effect-operation.js +410 -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 +117 -30
- package/dist/effects/index.cjs.map +3 -3
- package/dist/effects/index.d.ts +34 -18
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/index.js +31 -18
- package/dist/effects/index.js.map +1 -1
- 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/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-blur-filters/bloom-composite-shader-pass.cjs +200 -13
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts +992 -6
- 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 +3 -3
- 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/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 +83 -66
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +470 -2
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js +80 -62
- 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 +14 -5
- package/dist/effects/passes/screen-space/depth-aware-blur.d.ts +125 -17
- package/dist/effects/passes/screen-space/depth-aware-blur.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/depth-aware-blur.js +11 -3
- package/dist/effects/passes/screen-space/depth-aware-blur.js.map +1 -1
- package/dist/effects/passes/screen-space/dof.cjs +19 -3
- package/dist/effects/passes/screen-space/dof.d.ts +181 -0
- package/dist/effects/passes/screen-space/dof.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/dof.js +17 -3
- package/dist/effects/passes/screen-space/dof.js.map +1 -1
- package/dist/effects/passes/screen-space/gtao.cjs +82 -62
- package/dist/effects/passes/screen-space/gtao.d.ts +608 -3
- package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.js +83 -60
- 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 +225 -3
- 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 +162 -3
- 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 +70 -61
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +309 -2
- 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 +69 -59
- package/dist/effects/passes/screen-space/screen-space-global-illumination.js.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.cjs +151 -83
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +778 -7
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.js +148 -79
- 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 +69 -44
- 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 +67 -42
- package/dist/effects/passes/screen-space/ssao.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 +161 -2
- 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/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/experimental-controls.cjs +13 -3
- package/dist/experimental-controls.d.ts +2 -1
- package/dist/experimental-controls.d.ts.map +1 -1
- package/dist/experimental-controls.js +1 -1
- package/dist/experimental-controls.js.map +1 -1
- package/dist/experimental-materials.cjs +37 -3
- package/dist/experimental-materials.d.ts +2 -1
- package/dist/experimental-materials.d.ts.map +1 -1
- package/dist/experimental-materials.js +1 -1
- package/dist/experimental-materials.js.map +1 -1
- package/dist/experimental-textures.cjs +13 -3
- package/dist/experimental-textures.d.ts +2 -1
- package/dist/experimental-textures.d.ts.map +1 -1
- package/dist/experimental-textures.js +1 -1
- package/dist/experimental-textures.js.map +1 -1
- package/dist/experimental-webxr.cjs +17 -3
- package/dist/experimental-webxr.d.ts +2 -1
- package/dist/experimental-webxr.d.ts.map +1 -1
- package/dist/experimental-webxr.js +1 -1
- package/dist/experimental-webxr.js.map +1 -1
- 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 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- 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 +71 -20
- package/dist/lighting/clustered-light-grid.d.ts +37 -0
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -1
- package/dist/lighting/clustered-light-grid.js +68 -18
- 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 +274 -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 +11 -6
- 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 +155 -0
- package/dist/passes/effect-renderer.d.ts +158 -0
- package/dist/passes/effect-renderer.d.ts.map +1 -0
- package/dist/passes/effect-renderer.js +143 -0
- package/dist/passes/effect-renderer.js.map +1 -0
- 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/passes/shader-pass-renderer.cjs +94 -68
- package/dist/passes/shader-pass-renderer.d.ts +32 -15
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +104 -76
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- 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/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 +3 -1
- package/dist/text/fonts/atlas/browser-font-atlas.d.ts.map +1 -1
- package/dist/text/fonts/atlas/browser-font-atlas.js +10 -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/index.cjs +2 -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/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/audio/audio-controller.ts +4 -1
- package/src/audio/audio-graph.ts +46 -25
- package/src/effects/README.md +38 -14
- package/src/effects/glfx-effects.ts +227 -0
- package/src/effects/graph/gpu-effect-operation.ts +601 -0
- package/src/effects/graph/temporal-graph-history.ts +46 -0
- package/src/effects/index.ts +81 -19
- package/src/effects/passes/postprocessing/fxaa/fxaa.ts +8 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/tone-mapping.ts +8 -0
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.ts +219 -19
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.ts +6 -6
- package/src/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +45 -45
- package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +88 -68
- package/src/effects/passes/screen-space/copy-pass.ts +4 -0
- package/src/effects/passes/screen-space/depth-aware-blur.ts +13 -3
- package/src/effects/passes/screen-space/dof.ts +20 -3
- package/src/effects/passes/screen-space/gtao.ts +91 -65
- package/src/effects/passes/screen-space/hdr-auto-exposure.ts +109 -84
- package/src/effects/passes/screen-space/height-fog.ts +18 -3
- package/src/effects/passes/screen-space/motion-blur.ts +8 -7
- package/src/effects/passes/screen-space/outlines.ts +143 -17
- package/src/effects/passes/screen-space/screen-space-global-illumination.ts +75 -64
- package/src/effects/passes/screen-space/screen-space-reflections.ts +158 -95
- package/src/effects/passes/screen-space/selection-outline.ts +11 -0
- package/src/effects/passes/screen-space/ssao.ts +79 -46
- package/src/effects/passes/screen-space/temporal-antialiasing.ts +43 -33
- package/src/effects/passes/screen-space/temporal-frame.ts +33 -0
- package/src/effects/passes/screen-space/volumetric-fog.ts +30 -24
- 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/experimental-controls.ts +13 -1
- package/src/experimental-materials.ts +37 -1
- package/src/experimental-textures.ts +9 -1
- package/src/experimental-webxr.ts +18 -1
- 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 +25 -0
- package/src/lighting/ambient-occlusion-pass.ts +62 -28
- package/src/lighting/clustered-light-grid.ts +87 -30
- 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 +12 -3
- package/src/lighting/shadow-map-renderer.ts +57 -43
- package/src/model/gpu-vector-model.ts +47 -18
- package/src/passes/effect-renderer.ts +332 -0
- package/src/passes/scene-capture-pass.ts +51 -0
- package/src/passes/shader-pass-renderer.ts +164 -115
- package/src/scenegraph/model-node.ts +5 -0
- package/src/splats/README.md +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 +12 -2
- package/src/text/fonts/atlas/lru-cache.ts +6 -1
- package/src/text/fonts/index.ts +1 -0
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,6 +109,7 @@ 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,
|
|
@@ -125,6 +127,7 @@ var __exports__ = (() => {
|
|
|
125
127
|
VideoTexture: () => VideoTexture,
|
|
126
128
|
_resolveLoadFileUrl: () => _resolveLoadFileUrl,
|
|
127
129
|
applyMorphTargets: () => applyMorphTargets,
|
|
130
|
+
bakeScenegraphGPUAnimation: () => bakeScenegraphGPUAnimation,
|
|
128
131
|
cancelAnimationFramePolyfill: () => cancelAnimationFramePolyfill,
|
|
129
132
|
colorPicking: () => picking,
|
|
130
133
|
createAreaLightLTCTextures: () => createAreaLightLTCTextures,
|
|
@@ -133,11 +136,13 @@ var __exports__ = (() => {
|
|
|
133
136
|
decodeMorphTargetAttribute: () => decodeMorphTargetAttribute,
|
|
134
137
|
decomposePhysicsTransform: () => decomposePhysicsTransform,
|
|
135
138
|
deformPositions: () => deformPositions,
|
|
139
|
+
encodeSceneCapturePass: () => encodeSceneCapturePass,
|
|
136
140
|
evaluateAnimationSampler: () => evaluateAnimationSampler,
|
|
137
141
|
getFirstScenegraphInteractionHit: () => getFirstScenegraphInteractionHit,
|
|
138
142
|
getGPUVectorModelBatches: () => getGPUVectorModelBatches,
|
|
139
143
|
getIndexPickingModule: () => getIndexPickingModule,
|
|
140
144
|
getPlatformInfo: () => getPlatformInfo,
|
|
145
|
+
getScenegraphGPUPlaybackClip: () => getScenegraphGPUPlaybackClip,
|
|
141
146
|
getTextureTransformDeltaMatrix: () => getTextureTransformDeltaMatrix,
|
|
142
147
|
getTextureTransformMatrix: () => getTextureTransformMatrix,
|
|
143
148
|
indexColorPicking: () => picking2,
|
|
@@ -160,6 +165,7 @@ var __exports__ = (() => {
|
|
|
160
165
|
makeStrokeGeometry: () => makeStrokeGeometry,
|
|
161
166
|
makeTextureTransformAnimationBinding: () => makeTextureTransformAnimationBinding,
|
|
162
167
|
picking: () => picking4,
|
|
168
|
+
planScenegraphGPUAnimation: () => planScenegraphGPUAnimation,
|
|
163
169
|
publishedTransforms: () => publishedTransforms,
|
|
164
170
|
readPhysicsRotation: () => readPhysicsRotation,
|
|
165
171
|
readPhysicsVector: () => readPhysicsVector,
|
|
@@ -658,99 +664,79 @@ var __exports__ = (() => {
|
|
|
658
664
|
}
|
|
659
665
|
};
|
|
660
666
|
|
|
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;
|
|
667
|
+
// src/animation/scenegraph-gpu-animation-layout.ts
|
|
668
|
+
function planScenegraphGPUAnimation(timings, primitives, options = {}, device) {
|
|
669
|
+
const reject = (fallbackReason, estimatedByteLength2 = 0) => ({ layout: null, estimatedByteLength: estimatedByteLength2, fallbackReason });
|
|
670
|
+
if (options.enabled === false) {
|
|
671
|
+
return reject("disabled");
|
|
710
672
|
}
|
|
711
|
-
|
|
712
|
-
return
|
|
673
|
+
if (!timings.length) {
|
|
674
|
+
return reject("no-animations");
|
|
713
675
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
if (!
|
|
718
|
-
|
|
676
|
+
const sampleRate = options.sampleRate ?? 30;
|
|
677
|
+
const maxFrames = options.maxFrames ?? 8192;
|
|
678
|
+
const maxBytes = options.maxBytes ?? 64 * 1024 * 1024;
|
|
679
|
+
if (!Number.isFinite(sampleRate) || sampleRate <= 0 || !Number.isSafeInteger(maxFrames) || maxFrames <= 0 || !Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
|
|
680
|
+
return reject("invalid-options");
|
|
719
681
|
}
|
|
720
|
-
if (
|
|
721
|
-
|
|
682
|
+
if (new Set(timings.map((timing) => timing.name)).size !== timings.length) {
|
|
683
|
+
return reject("unsupported-scene");
|
|
722
684
|
}
|
|
723
|
-
|
|
724
|
-
|
|
685
|
+
let frameCount = 0;
|
|
686
|
+
const clips = [];
|
|
687
|
+
for (const { name, duration } of timings) {
|
|
688
|
+
if (!Number.isFinite(duration) || duration < 0) {
|
|
689
|
+
return reject("invalid-animation");
|
|
690
|
+
}
|
|
691
|
+
const clipFrameCount = Math.max(1, Math.ceil(duration * sampleRate) + 1);
|
|
692
|
+
if (!Number.isSafeInteger(clipFrameCount) || frameCount + clipFrameCount > maxFrames) {
|
|
693
|
+
return reject("frame-budget");
|
|
694
|
+
}
|
|
695
|
+
clips.push({
|
|
696
|
+
name,
|
|
697
|
+
duration,
|
|
698
|
+
frameOffset: frameCount,
|
|
699
|
+
frameCount: clipFrameCount
|
|
700
|
+
});
|
|
701
|
+
frameCount += clipFrameCount;
|
|
725
702
|
}
|
|
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
|
-
}
|
|
703
|
+
let estimatedByteLength = 0;
|
|
704
|
+
let maximumAtlasByteLength = 0;
|
|
705
|
+
let maximumFrameStride = 0;
|
|
706
|
+
for (const { jointCount, morphTargetCount, count = 1 } of primitives) {
|
|
707
|
+
if (!Number.isSafeInteger(jointCount) || jointCount < 0 || !Number.isSafeInteger(morphTargetCount) || morphTargetCount < 0 || !Number.isSafeInteger(count) || count < 1) {
|
|
708
|
+
return reject("invalid-options");
|
|
738
709
|
}
|
|
710
|
+
const frameStride = getScenegraphGPUAnimationFrameStride(jointCount, morphTargetCount);
|
|
711
|
+
const atlasByteLength = frameCount * frameStride * 16;
|
|
712
|
+
maximumFrameStride = Math.max(maximumFrameStride, frameStride);
|
|
713
|
+
maximumAtlasByteLength = Math.max(maximumAtlasByteLength, atlasByteLength);
|
|
714
|
+
estimatedByteLength += atlasByteLength * count;
|
|
739
715
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
if (!attribute.constant && attribute.size) {
|
|
747
|
-
count = Math.min(count, attribute.value.length / attribute.size);
|
|
716
|
+
if (!Number.isSafeInteger(estimatedByteLength) || estimatedByteLength > maxBytes) {
|
|
717
|
+
return reject("byte-budget", estimatedByteLength);
|
|
718
|
+
}
|
|
719
|
+
if (device?.type === "webgpu") {
|
|
720
|
+
if (maximumAtlasByteLength > Math.min(device.limits.maxBufferSize, device.limits.maxStorageBufferBindingSize)) {
|
|
721
|
+
return reject("buffer-limit", estimatedByteLength);
|
|
748
722
|
}
|
|
723
|
+
} else if (device && (maximumFrameStride > device.limits.maxTextureDimension2D || frameCount > device.limits.maxTextureDimension2D)) {
|
|
724
|
+
return reject("texture-limit", estimatedByteLength);
|
|
749
725
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
726
|
+
return { layout: { sampleRate, frameCount, clips }, estimatedByteLength };
|
|
727
|
+
}
|
|
728
|
+
function getScenegraphGPUAnimationFrameStride(jointCount, morphTargetCount) {
|
|
729
|
+
return 4 + jointCount * 4 + morphTargetCount;
|
|
753
730
|
}
|
|
731
|
+
function getScenegraphGPUAnimationFrames(clip, time, sampleRate) {
|
|
732
|
+
const frame = Math.min(Math.max(time, 0) * sampleRate, clip.frameCount - 1);
|
|
733
|
+
const firstFrame = Math.floor(frame);
|
|
734
|
+
const secondFrame = Math.min(firstFrame + 1, clip.frameCount - 1);
|
|
735
|
+
return [clip.frameOffset + firstFrame, clip.frameOffset + secondFrame, frame - firstFrame];
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/animation/scenegraph-gpu-animation.ts
|
|
739
|
+
var import_core6 = __toESM(require_core(), 1);
|
|
754
740
|
|
|
755
741
|
// ../../node_modules/@math.gl/core/dist/lib/common.js
|
|
756
742
|
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
|
|
@@ -2426,6 +2412,54 @@ var __exports__ = (() => {
|
|
|
2426
2412
|
return out;
|
|
2427
2413
|
}
|
|
2428
2414
|
var ortho = orthoNO;
|
|
2415
|
+
function lookAtXAxis(out, upx, upy, upz, r0, r1, r2, z0, z1, z2) {
|
|
2416
|
+
if (!r0 && !r1 && !r2 || !upx && !upy && !upz) {
|
|
2417
|
+
return normalizeAxis(out, 0, 0, 0);
|
|
2418
|
+
}
|
|
2419
|
+
if (upy * r2 - upz * r1 !== 0 || upz * r0 - upx * r2 !== 0 || upx * r1 - upy * r0 !== 0) {
|
|
2420
|
+
normalizeAxis(out, upy * z2 - upz * z1, upz * z0 - upx * z2, upx * z1 - upy * z0);
|
|
2421
|
+
if (out[0] || out[1] || out[2]) {
|
|
2422
|
+
return out;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
const a0 = Math.abs(z0);
|
|
2426
|
+
const a1 = Math.abs(z1);
|
|
2427
|
+
const a2 = Math.abs(z2);
|
|
2428
|
+
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);
|
|
2429
|
+
if (a2 <= a0 && a2 <= a1) {
|
|
2430
|
+
return normalizeAxis(out, sign * z1, -sign * z0, 0);
|
|
2431
|
+
}
|
|
2432
|
+
if (a0 <= a1) {
|
|
2433
|
+
return normalizeAxis(out, 0, sign * z2, -sign * z1);
|
|
2434
|
+
}
|
|
2435
|
+
return normalizeAxis(out, -sign * z2, 0, sign * z0);
|
|
2436
|
+
}
|
|
2437
|
+
function normalizeAxis(out, x0, x1, x2) {
|
|
2438
|
+
let len2 = x0 * x0 + x1 * x1 + x2 * x2;
|
|
2439
|
+
if (len2 === 0 || len2 === Infinity) {
|
|
2440
|
+
const max = Math.max(Math.abs(x0), Math.abs(x1), Math.abs(x2));
|
|
2441
|
+
if (!max || max === Infinity) {
|
|
2442
|
+
len2 = 0;
|
|
2443
|
+
} else {
|
|
2444
|
+
x0 /= max;
|
|
2445
|
+
x1 /= max;
|
|
2446
|
+
x2 /= max;
|
|
2447
|
+
len2 = x0 * x0 + x1 * x1 + x2 * x2;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
if (len2 > 0) {
|
|
2451
|
+
len2 = 1 / Math.sqrt(len2);
|
|
2452
|
+
out[0] = x0 * len2;
|
|
2453
|
+
out[1] = x1 * len2;
|
|
2454
|
+
out[2] = x2 * len2;
|
|
2455
|
+
} else {
|
|
2456
|
+
out[0] = 0;
|
|
2457
|
+
out[1] = 0;
|
|
2458
|
+
out[2] = 0;
|
|
2459
|
+
}
|
|
2460
|
+
return out;
|
|
2461
|
+
}
|
|
2462
|
+
var lookAtAxis = [0, 0, 0];
|
|
2429
2463
|
function lookAt(out, eye, center, up) {
|
|
2430
2464
|
let len2;
|
|
2431
2465
|
let x0;
|
|
@@ -2452,24 +2486,14 @@ var __exports__ = (() => {
|
|
|
2452
2486
|
z0 = eyex - centerx;
|
|
2453
2487
|
z1 = eyey - centery;
|
|
2454
2488
|
z2 = eyez - centerz;
|
|
2489
|
+
const r0 = z0;
|
|
2490
|
+
const r1 = z1;
|
|
2491
|
+
const r2 = z2;
|
|
2455
2492
|
len2 = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
|
|
2456
2493
|
z0 *= len2;
|
|
2457
2494
|
z1 *= len2;
|
|
2458
2495
|
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
|
-
}
|
|
2496
|
+
[x0, x1, x2] = lookAtXAxis(lookAtAxis, upx, upy, upz, r0, r1, r2, z0, z1, z2);
|
|
2473
2497
|
y0 = z1 * x2 - z2 * x1;
|
|
2474
2498
|
y1 = z2 * x0 - z0 * x2;
|
|
2475
2499
|
y2 = z0 * x1 - z1 * x0;
|
|
@@ -3565,118 +3589,614 @@ var __exports__ = (() => {
|
|
|
3565
3589
|
}
|
|
3566
3590
|
};
|
|
3567
3591
|
|
|
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);
|
|
3592
|
+
// src/scenegraph/group-node.ts
|
|
3593
|
+
var import_core2 = __toESM(require_core(), 1);
|
|
3594
|
+
|
|
3595
|
+
// src/utils/uid.ts
|
|
3596
|
+
var uidCounters = {};
|
|
3597
|
+
function uid(id = "id") {
|
|
3598
|
+
uidCounters[id] = uidCounters[id] || 1;
|
|
3599
|
+
const count = uidCounters[id]++;
|
|
3600
|
+
return `${id}-${count}`;
|
|
3583
3601
|
}
|
|
3584
3602
|
|
|
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
|
-
});
|
|
3603
|
+
// src/scenegraph/scenegraph-node.ts
|
|
3604
|
+
function assert2(condition, message) {
|
|
3605
|
+
if (!condition) {
|
|
3606
|
+
throw new Error(message);
|
|
3630
3607
|
}
|
|
3631
|
-
}
|
|
3632
|
-
var
|
|
3608
|
+
}
|
|
3609
|
+
var ScenegraphNode = class {
|
|
3610
|
+
id;
|
|
3611
|
+
matrix = new Matrix4();
|
|
3612
|
+
display = true;
|
|
3613
|
+
/** Local selection eligibility, independent of visibility. */
|
|
3614
|
+
selectable = true;
|
|
3615
|
+
/** Local hover eligibility, independent of visibility. */
|
|
3616
|
+
hoverable = true;
|
|
3617
|
+
position = new Vector3();
|
|
3618
|
+
rotation = new Vector3();
|
|
3619
|
+
scale = new Vector3(1, 1, 1);
|
|
3620
|
+
/** Structured metadata associated with this scene node. */
|
|
3621
|
+
metadata = {};
|
|
3622
|
+
userData = {};
|
|
3623
|
+
props = {};
|
|
3633
3624
|
constructor(props = {}) {
|
|
3634
|
-
const
|
|
3635
|
-
|
|
3625
|
+
const { id } = props;
|
|
3626
|
+
this.id = id || uid(this.constructor.name);
|
|
3627
|
+
this._setScenegraphNodeProps(props);
|
|
3636
3628
|
}
|
|
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
|
-
}
|
|
3629
|
+
getBounds() {
|
|
3630
|
+
return null;
|
|
3657
3631
|
}
|
|
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
|
-
}
|
|
3632
|
+
destroy() {
|
|
3666
3633
|
}
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
}
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3634
|
+
/** @deprecated use .destroy() */
|
|
3635
|
+
delete() {
|
|
3636
|
+
this.destroy();
|
|
3637
|
+
}
|
|
3638
|
+
setProps(props) {
|
|
3639
|
+
this._setScenegraphNodeProps(props);
|
|
3640
|
+
return this;
|
|
3641
|
+
}
|
|
3642
|
+
toString() {
|
|
3643
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
3644
|
+
}
|
|
3645
|
+
setPosition(position) {
|
|
3646
|
+
assert2(position.length === 3, "setPosition requires vector argument");
|
|
3647
|
+
this.position = position;
|
|
3648
|
+
return this;
|
|
3649
|
+
}
|
|
3650
|
+
setRotation(rotation) {
|
|
3651
|
+
assert2(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
3652
|
+
this.rotation = rotation;
|
|
3653
|
+
return this;
|
|
3654
|
+
}
|
|
3655
|
+
setScale(scale5) {
|
|
3656
|
+
assert2(scale5.length === 3, "setScale requires vector argument");
|
|
3657
|
+
this.scale = scale5;
|
|
3658
|
+
return this;
|
|
3659
|
+
}
|
|
3660
|
+
setMatrix(matrix, copyMatrix = true) {
|
|
3661
|
+
if (copyMatrix) {
|
|
3662
|
+
this.matrix.copy(matrix);
|
|
3663
|
+
} else {
|
|
3664
|
+
this.matrix = matrix;
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
setMatrixComponents(components2) {
|
|
3668
|
+
const { position, rotation, scale: scale5, update = true } = components2;
|
|
3669
|
+
if (position) {
|
|
3670
|
+
this.setPosition(position);
|
|
3671
|
+
}
|
|
3672
|
+
if (rotation) {
|
|
3673
|
+
this.setRotation(rotation);
|
|
3674
|
+
}
|
|
3675
|
+
if (scale5) {
|
|
3676
|
+
this.setScale(scale5);
|
|
3677
|
+
}
|
|
3678
|
+
if (update) {
|
|
3679
|
+
this.updateMatrix();
|
|
3680
|
+
}
|
|
3681
|
+
return this;
|
|
3682
|
+
}
|
|
3683
|
+
updateMatrix() {
|
|
3684
|
+
this.matrix.identity();
|
|
3685
|
+
this.matrix.translate(this.position);
|
|
3686
|
+
if (this.rotation.length === 4) {
|
|
3687
|
+
const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
|
|
3688
|
+
this.matrix.multiplyRight(rotationMatrix);
|
|
3689
|
+
} else {
|
|
3690
|
+
this.matrix.rotateXYZ(this.rotation);
|
|
3691
|
+
}
|
|
3692
|
+
this.matrix.scale(this.scale);
|
|
3693
|
+
return this;
|
|
3694
|
+
}
|
|
3695
|
+
update({ position, rotation, scale: scale5 } = {}) {
|
|
3696
|
+
if (position) {
|
|
3697
|
+
this.setPosition(position);
|
|
3698
|
+
}
|
|
3699
|
+
if (rotation) {
|
|
3700
|
+
this.setRotation(rotation);
|
|
3701
|
+
}
|
|
3702
|
+
if (scale5) {
|
|
3703
|
+
this.setScale(scale5);
|
|
3704
|
+
}
|
|
3705
|
+
this.updateMatrix();
|
|
3706
|
+
return this;
|
|
3707
|
+
}
|
|
3708
|
+
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
3709
|
+
modelMatrix = modelMatrix || this.matrix;
|
|
3710
|
+
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
3711
|
+
const worldInverse = worldMatrix.invert();
|
|
3712
|
+
const worldInverseTranspose = worldInverse.transpose();
|
|
3713
|
+
return {
|
|
3714
|
+
viewMatrix,
|
|
3715
|
+
modelMatrix,
|
|
3716
|
+
objectMatrix: modelMatrix,
|
|
3717
|
+
worldMatrix,
|
|
3718
|
+
worldInverseMatrix: worldInverse,
|
|
3719
|
+
worldInverseTransposeMatrix: worldInverseTranspose
|
|
3720
|
+
};
|
|
3721
|
+
}
|
|
3722
|
+
// TODO - copied code, not yet vetted
|
|
3723
|
+
/*
|
|
3724
|
+
transform() {
|
|
3725
|
+
if (!this.parent) {
|
|
3726
|
+
this.endPosition.set(this.position);
|
|
3727
|
+
this.endRotation.set(this.rotation);
|
|
3728
|
+
this.endScale.set(this.scale);
|
|
3729
|
+
} else {
|
|
3730
|
+
const parent = this.parent;
|
|
3731
|
+
this.endPosition.set(this.position.add(parent.endPosition));
|
|
3732
|
+
this.endRotation.set(this.rotation.add(parent.endRotation));
|
|
3733
|
+
this.endScale.set(this.scale.add(parent.endScale));
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
const ch = this.children;
|
|
3737
|
+
for (let i = 0; i < ch.length; ++i) {
|
|
3738
|
+
ch[i].transform();
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
return this;
|
|
3742
|
+
}
|
|
3743
|
+
*/
|
|
3744
|
+
_setScenegraphNodeProps(props) {
|
|
3745
|
+
if (props.selectable !== void 0) this.selectable = props.selectable;
|
|
3746
|
+
if (props.hoverable !== void 0) this.hoverable = props.hoverable;
|
|
3747
|
+
if (props.display !== void 0) {
|
|
3748
|
+
this.display = props.display;
|
|
3749
|
+
}
|
|
3750
|
+
if (props?.position) {
|
|
3751
|
+
this.setPosition(props.position);
|
|
3752
|
+
}
|
|
3753
|
+
if (props?.rotation) {
|
|
3754
|
+
this.setRotation(props.rotation);
|
|
3755
|
+
}
|
|
3756
|
+
if (props?.scale) {
|
|
3757
|
+
this.setScale(props.scale);
|
|
3758
|
+
}
|
|
3759
|
+
this.updateMatrix();
|
|
3760
|
+
if (props?.matrix) {
|
|
3761
|
+
this.setMatrix(props.matrix);
|
|
3762
|
+
}
|
|
3763
|
+
Object.assign(this.props, props);
|
|
3764
|
+
}
|
|
3765
|
+
};
|
|
3766
|
+
|
|
3767
|
+
// src/scenegraph/scenegraph-bounds.ts
|
|
3768
|
+
function makeEmptyScenegraphBounds() {
|
|
3769
|
+
return [
|
|
3770
|
+
[Infinity, Infinity, Infinity],
|
|
3771
|
+
[-Infinity, -Infinity, -Infinity]
|
|
3772
|
+
];
|
|
3773
|
+
}
|
|
3774
|
+
function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
|
|
3775
|
+
const transformMatrix = new Matrix4(transform);
|
|
3776
|
+
for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
|
|
3777
|
+
const corner = new Vector3(
|
|
3778
|
+
sourceBounds[cornerIndex & 1 ? 1 : 0][0],
|
|
3779
|
+
sourceBounds[cornerIndex & 2 ? 1 : 0][1],
|
|
3780
|
+
sourceBounds[cornerIndex & 4 ? 1 : 0][2]
|
|
3781
|
+
);
|
|
3782
|
+
transformMatrix.transformAsPoint(corner, corner);
|
|
3783
|
+
for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
|
|
3784
|
+
targetBounds[0][componentIndex] = Math.min(
|
|
3785
|
+
targetBounds[0][componentIndex],
|
|
3786
|
+
corner[componentIndex]
|
|
3787
|
+
);
|
|
3788
|
+
targetBounds[1][componentIndex] = Math.max(
|
|
3789
|
+
targetBounds[1][componentIndex],
|
|
3790
|
+
corner[componentIndex]
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
function areScenegraphBoundsDefined(bounds) {
|
|
3796
|
+
return Number.isFinite(bounds[0][0]);
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
// src/scenegraph/group-node.ts
|
|
3800
|
+
var GroupNode = class _GroupNode extends ScenegraphNode {
|
|
3801
|
+
children;
|
|
3802
|
+
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
3803
|
+
transformSource;
|
|
3804
|
+
constructor(props = {}) {
|
|
3805
|
+
props = Array.isArray(props) ? { children: props } : props;
|
|
3806
|
+
const { children = [] } = props;
|
|
3807
|
+
import_core2.log.assert(
|
|
3808
|
+
children.every((child) => child instanceof ScenegraphNode),
|
|
3809
|
+
"every child must an instance of ScenegraphNode"
|
|
3810
|
+
);
|
|
3811
|
+
super(props);
|
|
3812
|
+
this.children = children;
|
|
3813
|
+
this.transformSource = props.transformSource ?? null;
|
|
3814
|
+
}
|
|
3815
|
+
getBounds() {
|
|
3816
|
+
const result = makeEmptyScenegraphBounds();
|
|
3817
|
+
this.traverse((node, { worldMatrix }) => {
|
|
3818
|
+
const bounds = node.getBounds();
|
|
3819
|
+
if (!bounds) {
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
|
|
3823
|
+
expandScenegraphBounds(result, bounds, nodeWorldMatrix);
|
|
3824
|
+
});
|
|
3825
|
+
return areScenegraphBoundsDefined(result) ? result : null;
|
|
3826
|
+
}
|
|
3827
|
+
destroy() {
|
|
3828
|
+
this.children.forEach((child) => child.destroy());
|
|
3829
|
+
this.removeAll();
|
|
3830
|
+
super.destroy();
|
|
3831
|
+
}
|
|
3832
|
+
// Unpacks arrays and nested arrays of children
|
|
3833
|
+
add(...children) {
|
|
3834
|
+
for (const child of children) {
|
|
3835
|
+
if (Array.isArray(child)) {
|
|
3836
|
+
this.add(...child);
|
|
3837
|
+
} else {
|
|
3838
|
+
this.children.push(child);
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
return this;
|
|
3842
|
+
}
|
|
3843
|
+
remove(child) {
|
|
3844
|
+
const children = this.children;
|
|
3845
|
+
const indexOf = children.indexOf(child);
|
|
3846
|
+
if (indexOf > -1) {
|
|
3847
|
+
children.splice(indexOf, 1);
|
|
3848
|
+
}
|
|
3849
|
+
return this;
|
|
3850
|
+
}
|
|
3851
|
+
removeAll() {
|
|
3852
|
+
this.children = [];
|
|
3853
|
+
return this;
|
|
3854
|
+
}
|
|
3855
|
+
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
3856
|
+
findNode(path) {
|
|
3857
|
+
const matches = this.findNodes(path);
|
|
3858
|
+
if (matches.length > 1) {
|
|
3859
|
+
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
3860
|
+
}
|
|
3861
|
+
return matches[0];
|
|
3862
|
+
}
|
|
3863
|
+
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
3864
|
+
findNodes(path) {
|
|
3865
|
+
const anchored = path.startsWith("/");
|
|
3866
|
+
const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
|
|
3867
|
+
if (!segment || /~(?![01])/.test(segment)) {
|
|
3868
|
+
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
3869
|
+
}
|
|
3870
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
3871
|
+
});
|
|
3872
|
+
const matches = [];
|
|
3873
|
+
const ancestors = [];
|
|
3874
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3875
|
+
const pending = [{ node: this, depth: 0 }];
|
|
3876
|
+
while (pending.length) {
|
|
3877
|
+
const { node, depth } = pending.pop();
|
|
3878
|
+
(0, import_core2.assert)(!visited.has(node));
|
|
3879
|
+
visited.add(node);
|
|
3880
|
+
ancestors.length = depth;
|
|
3881
|
+
ancestors.push(node.id);
|
|
3882
|
+
const offset = ancestors.length - segments.length;
|
|
3883
|
+
if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
|
|
3884
|
+
matches.push(node);
|
|
3885
|
+
}
|
|
3886
|
+
if (node instanceof _GroupNode) {
|
|
3887
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
3888
|
+
pending.push({ node: node.children[index], depth: depth + 1 });
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
return matches;
|
|
3893
|
+
}
|
|
3894
|
+
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
3895
|
+
if (!this.display) {
|
|
3896
|
+
return;
|
|
3897
|
+
}
|
|
3898
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
3899
|
+
for (const child of this.children) {
|
|
3900
|
+
if (!child.display) {
|
|
3901
|
+
continue;
|
|
3902
|
+
}
|
|
3903
|
+
if (child instanceof _GroupNode) {
|
|
3904
|
+
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
3905
|
+
} else {
|
|
3906
|
+
visitor(child, { worldMatrix: modelMatrix });
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
/** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
|
|
3911
|
+
traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
|
|
3912
|
+
const cameraMatrix = new Matrix4(viewMatrix);
|
|
3913
|
+
const nodes = [];
|
|
3914
|
+
this.traverse(
|
|
3915
|
+
(node, context) => {
|
|
3916
|
+
const bounds = node.getBounds();
|
|
3917
|
+
const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
|
|
3918
|
+
const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
|
|
3919
|
+
nodeWorldMatrix.transformAsPoint(center, center);
|
|
3920
|
+
cameraMatrix.transformAsPoint(center, center);
|
|
3921
|
+
nodes.push({
|
|
3922
|
+
node,
|
|
3923
|
+
context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
|
|
3924
|
+
index: nodes.length
|
|
3925
|
+
});
|
|
3926
|
+
},
|
|
3927
|
+
{ worldMatrix: new Matrix4(worldMatrix) }
|
|
3928
|
+
);
|
|
3929
|
+
const direction = order === "back-to-front" ? -1 : 1;
|
|
3930
|
+
nodes.sort(
|
|
3931
|
+
(first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
|
|
3932
|
+
);
|
|
3933
|
+
for (const { node, context } of nodes) {
|
|
3934
|
+
visitor(node, context);
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
preorderTraversal(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
3938
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
3939
|
+
visitor(this, { worldMatrix: modelMatrix });
|
|
3940
|
+
for (const child of this.children) {
|
|
3941
|
+
if (child instanceof _GroupNode) {
|
|
3942
|
+
child.preorderTraversal(visitor, { worldMatrix: modelMatrix });
|
|
3943
|
+
} else {
|
|
3944
|
+
visitor(child, { worldMatrix: modelMatrix });
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
};
|
|
3949
|
+
|
|
3950
|
+
// src/scenegraph/model-node.ts
|
|
3951
|
+
var ModelNode = class extends ScenegraphNode {
|
|
3952
|
+
model;
|
|
3953
|
+
gpuAnimation;
|
|
3954
|
+
instanceMatrices;
|
|
3955
|
+
bounds = null;
|
|
3956
|
+
managedResources;
|
|
3957
|
+
// TODO - is this used? override callbacks to make sure we call them with this
|
|
3958
|
+
// onBeforeRender = null;
|
|
3959
|
+
// onAfterRender = null;
|
|
3960
|
+
// AfterRender = null;
|
|
3961
|
+
constructor(props) {
|
|
3962
|
+
super(props);
|
|
3963
|
+
this.model = props.model;
|
|
3964
|
+
this.gpuAnimation = props.gpuAnimation;
|
|
3965
|
+
this.managedResources = props.managedResources || [];
|
|
3966
|
+
this.instanceMatrices = props.instanceMatrices || null;
|
|
3967
|
+
this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
|
|
3968
|
+
this.setProps(props);
|
|
3969
|
+
}
|
|
3970
|
+
destroy() {
|
|
3971
|
+
if (this.model) {
|
|
3972
|
+
this.model.destroy();
|
|
3973
|
+
this.model = null;
|
|
3974
|
+
}
|
|
3975
|
+
this.managedResources.forEach((resource) => resource.destroy());
|
|
3976
|
+
this.managedResources = [];
|
|
3977
|
+
}
|
|
3978
|
+
getBounds() {
|
|
3979
|
+
return this.bounds;
|
|
3980
|
+
}
|
|
3981
|
+
// Expose model methods
|
|
3982
|
+
draw(renderPass) {
|
|
3983
|
+
return this.model.draw(renderPass);
|
|
3984
|
+
}
|
|
3985
|
+
};
|
|
3986
|
+
function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
3987
|
+
const instancedBounds = makeEmptyScenegraphBounds();
|
|
3988
|
+
for (const instanceMatrix of instanceMatrices) {
|
|
3989
|
+
expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
|
|
3990
|
+
}
|
|
3991
|
+
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
// ../../node_modules/@math.gl/core/dist/types/typed-array-brand.js
|
|
3995
|
+
var typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
3996
|
+
function getTypedArrayName(value) {
|
|
3997
|
+
return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : void 0;
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
// ../../node_modules/@math.gl/core/dist/types/is-array.js
|
|
4001
|
+
function isTypedArray(value) {
|
|
4002
|
+
const name = getTypedArrayName(value);
|
|
4003
|
+
return name !== void 0 && name !== "BigInt64Array" && name !== "BigUint64Array";
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
// ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
|
|
4007
|
+
var geometryId = 0;
|
|
4008
|
+
var Geometry = class {
|
|
4009
|
+
constructor(props) {
|
|
4010
|
+
this.userData = {};
|
|
4011
|
+
this.id = props.id || `geometry-${++geometryId}`;
|
|
4012
|
+
this.topology = props.topology;
|
|
4013
|
+
this.attributes = {};
|
|
4014
|
+
let indices = props.indices ? normalizeAttribute(props.indices) : void 0;
|
|
4015
|
+
for (const [name, input] of Object.entries(props.attributes || {})) {
|
|
4016
|
+
const attribute = normalizeAttribute(input);
|
|
4017
|
+
if (name === "POSITION" || name === "positions") {
|
|
4018
|
+
attribute.size || (attribute.size = 3);
|
|
4019
|
+
}
|
|
4020
|
+
if (name === "indices") {
|
|
4021
|
+
if (indices)
|
|
4022
|
+
throw new Error("Geometry has multiple index attributes");
|
|
4023
|
+
indices = attribute;
|
|
4024
|
+
} else {
|
|
4025
|
+
this.attributes[name] = attribute;
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
if (indices) {
|
|
4029
|
+
if (!(indices.value instanceof Uint16Array || indices.value instanceof Uint32Array)) {
|
|
4030
|
+
throw new Error("Geometry indices must be a Uint16Array or Uint32Array");
|
|
4031
|
+
}
|
|
4032
|
+
indices.size = 1;
|
|
4033
|
+
this.indices = indices;
|
|
4034
|
+
validateIndices(indices, this.attributes);
|
|
4035
|
+
}
|
|
4036
|
+
this.vertexCount = props.vertexCount ?? calculateVertexCount(this.attributes, this.indices);
|
|
4037
|
+
if (!Number.isInteger(this.vertexCount) || this.vertexCount < 0) {
|
|
4038
|
+
throw new Error("Geometry vertexCount must be a non-negative integer");
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
getVertexCount() {
|
|
4042
|
+
return this.vertexCount;
|
|
4043
|
+
}
|
|
4044
|
+
getAttributes() {
|
|
4045
|
+
return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
|
|
4046
|
+
}
|
|
4047
|
+
};
|
|
4048
|
+
function normalizeAttribute(input) {
|
|
4049
|
+
const attribute = isTypedArray(input) ? { value: input } : { ...input };
|
|
4050
|
+
if (!isTypedArray(attribute.value)) {
|
|
4051
|
+
throw new Error("Geometry attributes must contain a typed-array value");
|
|
4052
|
+
}
|
|
4053
|
+
if (attribute.size !== void 0 && (!Number.isInteger(attribute.size) || attribute.size < 1)) {
|
|
4054
|
+
throw new Error("Geometry attribute size must be a positive integer");
|
|
4055
|
+
}
|
|
4056
|
+
if (attribute.size && attribute.value.length % attribute.size !== 0) {
|
|
4057
|
+
throw new Error("Geometry attribute length must be divisible by its size");
|
|
4058
|
+
}
|
|
4059
|
+
return attribute;
|
|
4060
|
+
}
|
|
4061
|
+
function validateIndices(indices, attributes) {
|
|
4062
|
+
let maximumIndex = -1;
|
|
4063
|
+
for (const index of indices.value)
|
|
4064
|
+
maximumIndex = Math.max(maximumIndex, Number(index));
|
|
4065
|
+
for (const [name, attribute] of Object.entries(attributes)) {
|
|
4066
|
+
if (!attribute.constant && attribute.size) {
|
|
4067
|
+
const attributeVertexCount = attribute.value.length / attribute.size;
|
|
4068
|
+
if (maximumIndex >= attributeVertexCount) {
|
|
4069
|
+
throw new Error(`Geometry index ${maximumIndex} exceeds ${name} vertex count ${attributeVertexCount}`);
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
function calculateVertexCount(attributes, indices) {
|
|
4075
|
+
if (indices)
|
|
4076
|
+
return indices.value.length;
|
|
4077
|
+
let count = Infinity;
|
|
4078
|
+
for (const attribute of Object.values(attributes)) {
|
|
4079
|
+
if (!attribute.constant && attribute.size) {
|
|
4080
|
+
count = Math.min(count, attribute.value.length / attribute.size);
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
if (!Number.isFinite(count))
|
|
4084
|
+
throw new Error("Geometry has no countable attributes");
|
|
4085
|
+
return count;
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4088
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/geometry-helpers.js
|
|
4089
|
+
function assertPositive(value, name) {
|
|
4090
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
4091
|
+
throw new Error(`${name} must be greater than zero`);
|
|
4092
|
+
}
|
|
4093
|
+
function assertNonNegative(value, name) {
|
|
4094
|
+
if (!Number.isFinite(value) || value < 0)
|
|
4095
|
+
throw new Error(`${name} must be non-negative`);
|
|
4096
|
+
}
|
|
4097
|
+
function assertSegments(value, name, minimum = 1) {
|
|
4098
|
+
if (!Number.isInteger(value) || value < minimum)
|
|
4099
|
+
throw new Error(`${name} must be an integer >= ${minimum}`);
|
|
4100
|
+
}
|
|
4101
|
+
function makeIndices(vertexCount, values) {
|
|
4102
|
+
return vertexCount > 65535 ? new Uint32Array(values) : new Uint16Array(values);
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/box-geometry.js
|
|
4106
|
+
var BoxGeometry = class extends Geometry {
|
|
4107
|
+
constructor(props = {}) {
|
|
4108
|
+
const size = props.size || [1, 1, 1];
|
|
4109
|
+
assertPositive(size[0], "size[0]");
|
|
4110
|
+
assertPositive(size[1], "size[1]");
|
|
4111
|
+
assertPositive(size[2], "size[2]");
|
|
4112
|
+
const half = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
4113
|
+
const positions = [];
|
|
4114
|
+
const normals = [];
|
|
4115
|
+
const texCoords = [];
|
|
4116
|
+
const indices = [];
|
|
4117
|
+
const faces = [
|
|
4118
|
+
{ n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
4119
|
+
{ n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
4120
|
+
{ n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
|
|
4121
|
+
{ n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
|
|
4122
|
+
{ n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
|
|
4123
|
+
{ n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
|
|
4124
|
+
];
|
|
4125
|
+
for (const face of faces) {
|
|
4126
|
+
const base = positions.length / 3;
|
|
4127
|
+
for (const [s, t, u, v] of [
|
|
4128
|
+
[-1, -1, 0, 0],
|
|
4129
|
+
[1, -1, 1, 0],
|
|
4130
|
+
[1, 1, 1, 1],
|
|
4131
|
+
[-1, 1, 0, 1]
|
|
4132
|
+
]) {
|
|
4133
|
+
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);
|
|
4134
|
+
normals.push(...face.n);
|
|
4135
|
+
texCoords.push(u, v);
|
|
4136
|
+
}
|
|
4137
|
+
indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
|
|
4138
|
+
}
|
|
4139
|
+
super({
|
|
4140
|
+
id: props.id,
|
|
4141
|
+
topology: "triangle-list",
|
|
4142
|
+
indices: makeIndices(24, indices),
|
|
4143
|
+
attributes: {
|
|
4144
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
4145
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
4146
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
4147
|
+
...props.attributes
|
|
4148
|
+
}
|
|
4149
|
+
});
|
|
4150
|
+
}
|
|
4151
|
+
};
|
|
4152
|
+
var CubeGeometry = class extends BoxGeometry {
|
|
4153
|
+
constructor(props = {}) {
|
|
4154
|
+
const size = props.size ?? 1;
|
|
4155
|
+
super({ ...props, size: [size, size, size] });
|
|
4156
|
+
}
|
|
4157
|
+
};
|
|
4158
|
+
|
|
4159
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/surface-of-revolution.js
|
|
4160
|
+
function makeSurfaceOfRevolution(rings, nradial) {
|
|
4161
|
+
const positions = [];
|
|
4162
|
+
const normals = [];
|
|
4163
|
+
const texCoords = [];
|
|
4164
|
+
const indices = [];
|
|
4165
|
+
const stride = nradial + 1;
|
|
4166
|
+
for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
|
|
4167
|
+
const ring = rings[ringIndex];
|
|
4168
|
+
for (let radial = 0; radial <= nradial; radial++) {
|
|
4169
|
+
const u = radial / nradial;
|
|
4170
|
+
const angle2 = u * Math.PI * 2;
|
|
4171
|
+
const sin = Math.sin(angle2);
|
|
4172
|
+
const cos = Math.cos(angle2);
|
|
4173
|
+
positions.push(sin * ring.radius, ring.y, cos * ring.radius);
|
|
4174
|
+
normals.push(sin * ring.normalRadius, ring.normalY, cos * ring.normalRadius);
|
|
4175
|
+
texCoords.push(u, ringIndex / (rings.length - 1));
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
for (let ring = 0; ring < rings.length - 1; ring++) {
|
|
4179
|
+
for (let radial = 0; radial < nradial; radial++) {
|
|
4180
|
+
const a = ring * stride + radial;
|
|
4181
|
+
const b = a + 1;
|
|
4182
|
+
const c = a + stride;
|
|
4183
|
+
const d = c + 1;
|
|
4184
|
+
indices.push(a, b, d, a, d, c);
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
return {
|
|
4188
|
+
...{ positions, normals, texCoords, indices },
|
|
4189
|
+
indexArray: makeIndices(positions.length / 3, indices)
|
|
4190
|
+
};
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/truncated-cone-geometry.js
|
|
4194
|
+
var TruncatedConeGeometry = class extends Geometry {
|
|
4195
|
+
constructor(props = {}) {
|
|
4196
|
+
const { topRadius = 0, bottomRadius = 0, topCap = false, bottomCap = false, height = 1, nradial = 10, nvertical = 1, verticalAxis = "y" } = props;
|
|
4197
|
+
assertNonNegative(topRadius, "topRadius");
|
|
4198
|
+
assertNonNegative(bottomRadius, "bottomRadius");
|
|
4199
|
+
if (topRadius === 0 && bottomRadius === 0)
|
|
3680
4200
|
throw new Error("At least one radius must be greater than zero");
|
|
3681
4201
|
assertPositive(height, "height");
|
|
3682
4202
|
assertSegments(nradial, "nradial", 3);
|
|
@@ -4118,7 +4638,7 @@ var __exports__ = (() => {
|
|
|
4118
4638
|
};
|
|
4119
4639
|
|
|
4120
4640
|
// src/geometry/geometry.ts
|
|
4121
|
-
var
|
|
4641
|
+
var import_core3 = __toESM(require_core(), 1);
|
|
4122
4642
|
var Geometry2 = class extends Geometry {
|
|
4123
4643
|
bufferLayout;
|
|
4124
4644
|
constructor(props) {
|
|
@@ -4171,14 +4691,14 @@ var __exports__ = (() => {
|
|
|
4171
4691
|
}
|
|
4172
4692
|
bufferLayout.push({
|
|
4173
4693
|
name: getGeometryShaderAttributeName(attributeName),
|
|
4174
|
-
format:
|
|
4694
|
+
format: import_core3.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2)
|
|
4175
4695
|
});
|
|
4176
4696
|
}
|
|
4177
4697
|
return bufferLayout;
|
|
4178
4698
|
}
|
|
4179
4699
|
|
|
4180
4700
|
// src/geometry/geometry-utils.ts
|
|
4181
|
-
var
|
|
4701
|
+
var import_core4 = __toESM(require_core(), 1);
|
|
4182
4702
|
|
|
4183
4703
|
// ../../node_modules/@math.gl/geometry/dist/lib/geometry-utils.js
|
|
4184
4704
|
function unpackIndexedGeometry(geometry) {
|
|
@@ -4230,8 +4750,8 @@ var __exports__ = (() => {
|
|
|
4230
4750
|
if (size === void 0) {
|
|
4231
4751
|
throw new Error(`Attribute ${sourceName} is missing a size`);
|
|
4232
4752
|
}
|
|
4233
|
-
const format =
|
|
4234
|
-
const vertexFormatInfo =
|
|
4753
|
+
const format = import_core4.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2);
|
|
4754
|
+
const vertexFormatInfo = import_core4.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
4235
4755
|
byteOffset = alignTo(byteOffset, minAttributeAlignment);
|
|
4236
4756
|
interleavedAttributes.push({
|
|
4237
4757
|
sourceName,
|
|
@@ -4445,29 +4965,374 @@ var __exports__ = (() => {
|
|
|
4445
4965
|
}
|
|
4446
4966
|
}
|
|
4447
4967
|
}
|
|
4448
|
-
|
|
4449
|
-
// src/
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
const
|
|
4454
|
-
const
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4968
|
+
|
|
4969
|
+
// src/scenegraph/controllers/morph-controller.ts
|
|
4970
|
+
var import_core5 = __toESM(require_core(), 1);
|
|
4971
|
+
function setMorphWeights(node, weights) {
|
|
4972
|
+
node.userData["morphWeights"] = [...weights];
|
|
4973
|
+
const meshes = node.userData["morphMeshes"] || [];
|
|
4974
|
+
for (const mesh of meshes) {
|
|
4975
|
+
mesh.preorderTraversal((child) => {
|
|
4976
|
+
if (!(child instanceof ModelNode)) {
|
|
4977
|
+
return;
|
|
4978
|
+
}
|
|
4979
|
+
const state = child.userData["morphTargets"];
|
|
4980
|
+
if (!state) {
|
|
4981
|
+
return;
|
|
4982
|
+
}
|
|
4983
|
+
const gpuWeights = child.userData["morphWeightTransport"];
|
|
4984
|
+
if (gpuWeights) {
|
|
4985
|
+
updateMorphWeights(gpuWeights, weights);
|
|
4986
|
+
child.userData["morphWeights"] = [...weights];
|
|
4987
|
+
return;
|
|
4988
|
+
}
|
|
4989
|
+
updateMorphTargetBuffers(child.model, state.geometry, state.targets, weights);
|
|
4990
|
+
child.userData["morphWeights"] = [...weights];
|
|
4991
|
+
});
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
function updateMorphWeights(state, weights) {
|
|
4995
|
+
state.values.fill(0);
|
|
4996
|
+
state.values.set(weights.slice(0, state.values.length));
|
|
4997
|
+
if (state.data instanceof import_core5.Buffer) {
|
|
4998
|
+
state.data.write(state.values);
|
|
4999
|
+
} else {
|
|
5000
|
+
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
|
|
5004
|
+
// src/animation/node-animation-binding.ts
|
|
5005
|
+
function makeNodeAnimationBinding(node, property, options = {}) {
|
|
5006
|
+
return {
|
|
5007
|
+
id: options.id,
|
|
5008
|
+
...property === "translation" || property === "rotation" || property === "scale" || property === "weights" ? { poseTarget: { node, property } } : {},
|
|
5009
|
+
getValue: () => {
|
|
5010
|
+
switch (property) {
|
|
5011
|
+
case "translation":
|
|
5012
|
+
return Array.from(node.position);
|
|
5013
|
+
case "rotation":
|
|
5014
|
+
return Array.from(node.rotation);
|
|
5015
|
+
case "scale":
|
|
5016
|
+
return Array.from(node.scale);
|
|
5017
|
+
case "weights":
|
|
5018
|
+
return Array.from(node.userData["morphWeights"] ?? []);
|
|
5019
|
+
case "visibility":
|
|
5020
|
+
return [node.display ? 1 : 0];
|
|
5021
|
+
case "selectable":
|
|
5022
|
+
return [node.selectable ? 1 : 0];
|
|
5023
|
+
case "hoverable":
|
|
5024
|
+
return [node.hoverable ? 1 : 0];
|
|
5025
|
+
}
|
|
5026
|
+
},
|
|
5027
|
+
setValue: (value) => {
|
|
5028
|
+
switch (property) {
|
|
5029
|
+
case "translation":
|
|
5030
|
+
node.setPosition(value).updateMatrix();
|
|
5031
|
+
break;
|
|
5032
|
+
case "rotation":
|
|
5033
|
+
node.setRotation(value).updateMatrix();
|
|
5034
|
+
break;
|
|
5035
|
+
case "scale":
|
|
5036
|
+
node.setScale(value).updateMatrix();
|
|
5037
|
+
break;
|
|
5038
|
+
case "weights":
|
|
5039
|
+
setMorphWeights(node, value);
|
|
5040
|
+
break;
|
|
5041
|
+
case "selectable":
|
|
5042
|
+
node.setProps({ selectable: value[0] !== 0 });
|
|
5043
|
+
break;
|
|
5044
|
+
case "hoverable":
|
|
5045
|
+
node.setProps({ hoverable: value[0] !== 0 });
|
|
5046
|
+
break;
|
|
5047
|
+
case "visibility":
|
|
5048
|
+
node.setProps({ display: value[0] !== 0 });
|
|
5049
|
+
options.onVisibilityChange?.();
|
|
5050
|
+
break;
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
};
|
|
5054
|
+
}
|
|
5055
|
+
|
|
5056
|
+
// src/animation/skin.ts
|
|
5057
|
+
function updateSkinJointMatrices(props) {
|
|
5058
|
+
const { joints, meshNode, worldMatrices, inverseBindMatrices, target } = props;
|
|
5059
|
+
const matrixCount = joints.length;
|
|
5060
|
+
const jointMatrices = target && target.length === matrixCount * 16 ? target : new Float32Array(matrixCount * 16);
|
|
5061
|
+
const meshWorldMatrix = meshNode ? worldMatrices.get(meshNode) || meshNode.matrix : void 0;
|
|
5062
|
+
const inverseMeshMatrix = meshWorldMatrix ? new Matrix4(meshWorldMatrix).invert() : null;
|
|
5063
|
+
for (let jointIndex = 0; jointIndex < matrixCount; jointIndex++) {
|
|
5064
|
+
const jointNode = joints[jointIndex];
|
|
5065
|
+
const jointWorldMatrix = worldMatrices.get(jointNode) || jointNode.matrix;
|
|
5066
|
+
const jointMatrix = inverseMeshMatrix ? new Matrix4(inverseMeshMatrix).multiplyRight(jointWorldMatrix) : new Matrix4(jointWorldMatrix);
|
|
5067
|
+
const offset = jointIndex * 16;
|
|
5068
|
+
if (inverseBindMatrices && inverseBindMatrices.length >= offset + 16) {
|
|
5069
|
+
const inverseBindMatrix = new Matrix4();
|
|
5070
|
+
for (let componentIndex = 0; componentIndex < 16; componentIndex++) {
|
|
5071
|
+
inverseBindMatrix[componentIndex] = inverseBindMatrices[offset + componentIndex];
|
|
5072
|
+
}
|
|
5073
|
+
jointMatrix.multiplyRight(inverseBindMatrix);
|
|
5074
|
+
}
|
|
5075
|
+
jointMatrices.set(jointMatrix, offset);
|
|
5076
|
+
}
|
|
5077
|
+
return jointMatrices;
|
|
5078
|
+
}
|
|
5079
|
+
|
|
5080
|
+
// src/animation/scenegraph-gpu-animation.ts
|
|
5081
|
+
var ScenegraphGPUAnimationResources = class {
|
|
5082
|
+
constructor(device, layout, animationJointCount, morphTargetCount, capacity = 1, id = "scenegraph-animation") {
|
|
5083
|
+
this.layout = layout;
|
|
5084
|
+
this.animationJointCount = animationJointCount;
|
|
5085
|
+
this.morphTargetCount = morphTargetCount;
|
|
5086
|
+
this.animationFrameStride = getScenegraphGPUAnimationFrameStride(
|
|
5087
|
+
animationJointCount,
|
|
5088
|
+
morphTargetCount
|
|
5089
|
+
);
|
|
5090
|
+
this.animationFrameValues = new Float32Array(layout.frameCount * this.animationFrameStride * 4);
|
|
5091
|
+
this.animationParameters = new Float32Array(capacity * 4);
|
|
5092
|
+
this.animationBlend = new Float32Array(capacity * 4);
|
|
5093
|
+
this.animationFrames = createScenegraphGPUAnimationStorage(
|
|
5094
|
+
device,
|
|
5095
|
+
`${id}-frames`,
|
|
5096
|
+
this.animationFrameValues,
|
|
5097
|
+
this.animationFrameStride,
|
|
5098
|
+
layout.frameCount
|
|
5099
|
+
);
|
|
5100
|
+
try {
|
|
5101
|
+
this.animationParameterBuffer = device.createBuffer({
|
|
5102
|
+
id: `${id}-instanceAnimationFrames`,
|
|
5103
|
+
data: this.animationParameters,
|
|
5104
|
+
usage: import_core6.Buffer.VERTEX | import_core6.Buffer.COPY_DST
|
|
5105
|
+
});
|
|
5106
|
+
try {
|
|
5107
|
+
this.animationBlendBuffer = device.createBuffer({
|
|
5108
|
+
id: `${id}-instanceAnimationBlend`,
|
|
5109
|
+
data: this.animationBlend,
|
|
5110
|
+
usage: import_core6.Buffer.VERTEX | import_core6.Buffer.COPY_DST
|
|
5111
|
+
});
|
|
5112
|
+
} catch (error) {
|
|
5113
|
+
this.animationParameterBuffer.destroy();
|
|
5114
|
+
throw error;
|
|
5115
|
+
}
|
|
5116
|
+
} catch (error) {
|
|
5117
|
+
this.animationFrames.destroy();
|
|
5118
|
+
throw error;
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
layout;
|
|
5122
|
+
animationJointCount;
|
|
5123
|
+
morphTargetCount;
|
|
5124
|
+
animationFrames;
|
|
5125
|
+
animationFrameValues;
|
|
5126
|
+
animationFrameStride;
|
|
5127
|
+
animationParameters;
|
|
5128
|
+
animationParameterBuffer;
|
|
5129
|
+
animationBlend;
|
|
5130
|
+
animationBlendBuffer;
|
|
5131
|
+
/** Shader options for the shared GPU animation module. */
|
|
5132
|
+
get defines() {
|
|
5133
|
+
return {
|
|
5134
|
+
HAS_GPU_CROWD_ANIMATION: true,
|
|
5135
|
+
CROWD_ANIMATION_FRAME_STRIDE: this.animationFrameStride
|
|
5136
|
+
};
|
|
5137
|
+
}
|
|
5138
|
+
get bindings() {
|
|
5139
|
+
return { gpuAnimationFrames: this.animationFrames };
|
|
5140
|
+
}
|
|
5141
|
+
/** Vertex attributes consumed by the GPU animation shader module. */
|
|
5142
|
+
get attributes() {
|
|
5143
|
+
return {
|
|
5144
|
+
instanceAnimationFrames: this.animationParameterBuffer,
|
|
5145
|
+
instanceAnimationBlend: this.animationBlendBuffer
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
5148
|
+
get bufferLayout() {
|
|
5149
|
+
return [
|
|
5150
|
+
{ name: "instanceAnimationFrames", format: "float32x4", stepMode: "instance" },
|
|
5151
|
+
{ name: "instanceAnimationBlend", format: "float32x4", stepMode: "instance" }
|
|
5152
|
+
];
|
|
5153
|
+
}
|
|
5154
|
+
/** Uploads the baked atlas after sampling has finished. */
|
|
5155
|
+
upload() {
|
|
5156
|
+
if (this.animationFrames instanceof import_core6.Buffer) {
|
|
5157
|
+
this.animationFrames.write(this.animationFrameValues);
|
|
5158
|
+
} else {
|
|
5159
|
+
this.animationFrames.writeData(this.animationFrameValues, {
|
|
5160
|
+
width: this.animationFrameStride,
|
|
5161
|
+
height: this.layout.frameCount
|
|
5162
|
+
});
|
|
5163
|
+
}
|
|
5164
|
+
}
|
|
5165
|
+
destroy() {
|
|
5166
|
+
this.animationParameterBuffer.destroy();
|
|
5167
|
+
this.animationBlendBuffer.destroy();
|
|
5168
|
+
this.animationFrames.destroy();
|
|
5169
|
+
}
|
|
5170
|
+
};
|
|
5171
|
+
function createScenegraphGPUAnimationStorage(device, id, values, width, height) {
|
|
5172
|
+
if (device.type === "webgpu") {
|
|
5173
|
+
return device.createBuffer({ id, data: values, usage: import_core6.Buffer.STORAGE | import_core6.Buffer.COPY_DST });
|
|
5174
|
+
}
|
|
5175
|
+
const texture = device.createTexture({
|
|
5176
|
+
id,
|
|
5177
|
+
format: "rgba32float",
|
|
5178
|
+
width,
|
|
5179
|
+
height,
|
|
5180
|
+
usage: import_core6.Texture.SAMPLE | import_core6.Texture.COPY_DST,
|
|
5181
|
+
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
5182
|
+
});
|
|
5183
|
+
try {
|
|
5184
|
+
texture.writeData(values, { width, height });
|
|
5185
|
+
return texture;
|
|
5186
|
+
} catch (error) {
|
|
5187
|
+
texture.destroy();
|
|
5188
|
+
throw error;
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5191
|
+
function getScenegraphGPUPlaybackClip(clip) {
|
|
5192
|
+
return new AnimationClip({
|
|
5193
|
+
name: clip.name,
|
|
5194
|
+
duration: clip.duration,
|
|
5195
|
+
tracks: clip.tracks.filter((track) => !track.binding.poseTarget)
|
|
5196
|
+
});
|
|
5197
|
+
}
|
|
5198
|
+
function bakeScenegraphGPUAnimation({
|
|
5199
|
+
scenes,
|
|
5200
|
+
clips,
|
|
5201
|
+
layout,
|
|
5202
|
+
targets,
|
|
5203
|
+
skins = []
|
|
5204
|
+
}) {
|
|
5205
|
+
const poseNodes = /* @__PURE__ */ new Map();
|
|
5206
|
+
const clone2 = (source4) => {
|
|
5207
|
+
const existing = poseNodes.get(source4);
|
|
5208
|
+
if (existing) return existing;
|
|
5209
|
+
const pose = new GroupNode({ id: source4.id });
|
|
5210
|
+
poseNodes.set(source4, pose);
|
|
5211
|
+
resetPose(source4, pose);
|
|
5212
|
+
for (const child of source4.children) {
|
|
5213
|
+
if (child instanceof GroupNode) pose.add(clone2(child));
|
|
5214
|
+
}
|
|
5215
|
+
return pose;
|
|
5216
|
+
};
|
|
5217
|
+
const poseScenes = scenes.map(clone2);
|
|
5218
|
+
const bindMatrices = collectWorldMatrices(poseScenes);
|
|
5219
|
+
const poseTargets = targets.map(({ node, resources: resources2, relativeToBindPose }) => {
|
|
5220
|
+
const pose = poseNodes.get(node);
|
|
5221
|
+
(0, import_core6.assert)(pose && resources2.layout === layout);
|
|
5222
|
+
const skin = skins.find((candidate) => candidate.node === node);
|
|
5223
|
+
(0, import_core6.assert)(
|
|
5224
|
+
!skin || !resources2.animationJointCount || skin.joints.length <= resources2.animationJointCount
|
|
5225
|
+
);
|
|
5226
|
+
const joints = skin?.joints.map(clone2);
|
|
5227
|
+
return {
|
|
5228
|
+
pose,
|
|
5229
|
+
resources: resources2,
|
|
5230
|
+
inverseBind: relativeToBindPose ? new Matrix4(bindMatrices.get(pose)).invert() : null,
|
|
5231
|
+
joints,
|
|
5232
|
+
inverseBindMatrices: skin?.inverseBindMatrices
|
|
5233
|
+
};
|
|
5234
|
+
});
|
|
5235
|
+
try {
|
|
5236
|
+
const mixer = new AnimationMixer();
|
|
5237
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
5238
|
+
for (const clip of layout.clips) {
|
|
5239
|
+
mixer.stopAllAction();
|
|
5240
|
+
for (const [source4, pose] of poseNodes) resetPose(source4, pose);
|
|
5241
|
+
const sourceClip = clips.find((candidate) => candidate.name === clip.name);
|
|
5242
|
+
(0, import_core6.assert)(sourceClip);
|
|
5243
|
+
const tracks = sourceClip.tracks.flatMap((track) => {
|
|
5244
|
+
const target = track.binding.poseTarget;
|
|
5245
|
+
const pose = target && poseNodes.get(target.node);
|
|
5246
|
+
if (!pose || !target) return [];
|
|
5247
|
+
let binding = bindings.get(track.binding);
|
|
5248
|
+
if (!binding) {
|
|
5249
|
+
binding = makeNodeAnimationBinding(pose, target.property, { id: track.binding.id });
|
|
5250
|
+
bindings.set(track.binding, binding);
|
|
5251
|
+
}
|
|
5252
|
+
return [new AnimationTrack({ ...track, binding })];
|
|
5253
|
+
});
|
|
5254
|
+
const action = mixer.clipAction(
|
|
5255
|
+
new AnimationClip({
|
|
5256
|
+
name: clip.name,
|
|
5257
|
+
duration: clip.duration,
|
|
5258
|
+
tracks
|
|
5259
|
+
})
|
|
5260
|
+
).setLoop("once", 1).play();
|
|
5261
|
+
for (let frame = 0; frame < clip.frameCount; frame++) {
|
|
5262
|
+
action.setTime(Math.min(frame / layout.sampleRate, clip.duration));
|
|
5263
|
+
mixer.update(0);
|
|
5264
|
+
const matrices = collectWorldMatrices(poseScenes);
|
|
5265
|
+
for (const { pose, resources: resources2, inverseBind, joints, inverseBindMatrices } of poseTargets) {
|
|
5266
|
+
const offset = (clip.frameOffset + frame) * resources2.animationFrameStride * 4;
|
|
5267
|
+
const values = resources2.animationFrameValues;
|
|
5268
|
+
const world = matrices.get(pose);
|
|
5269
|
+
values.set(inverseBind ? new Matrix4(inverseBind).multiplyRight(world) : world, offset);
|
|
5270
|
+
if (joints && resources2.animationJointCount) {
|
|
5271
|
+
updateSkinJointMatrices({
|
|
5272
|
+
joints,
|
|
5273
|
+
meshNode: pose,
|
|
5274
|
+
worldMatrices: matrices,
|
|
5275
|
+
inverseBindMatrices,
|
|
5276
|
+
target: values.subarray(offset + 16, offset + 16 + joints.length * 16)
|
|
5277
|
+
});
|
|
5278
|
+
}
|
|
5279
|
+
const weights = pose.userData["morphWeights"];
|
|
5280
|
+
const weightOffset = offset + 16 + resources2.animationJointCount * 16;
|
|
5281
|
+
for (let index = 0; index < resources2.morphTargetCount; index++) {
|
|
5282
|
+
values[weightOffset + index * 4] = weights?.[index] ?? 0;
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
4465
5285
|
}
|
|
4466
|
-
jointMatrix.multiplyRight(inverseBindMatrix);
|
|
4467
5286
|
}
|
|
4468
|
-
|
|
5287
|
+
for (const { resources: resources2 } of targets) resources2.upload();
|
|
5288
|
+
} finally {
|
|
5289
|
+
for (const pose of poseNodes.values()) pose.destroy();
|
|
5290
|
+
}
|
|
5291
|
+
const resources = targets.map((target) => target.resources);
|
|
5292
|
+
const clipsByName = new Map(layout.clips.map((clip) => [clip.name, clip]));
|
|
5293
|
+
return (animator) => updateScenegraphGPUAnimation(animator, layout, clipsByName, resources);
|
|
5294
|
+
}
|
|
5295
|
+
function updateScenegraphGPUAnimation(animator, layout, clipsByName, resources) {
|
|
5296
|
+
const actions = animator.getAnimations().filter((animation) => animation.action.shouldApply && animation.action.weight > 0);
|
|
5297
|
+
(0, import_core6.assert)(actions.length <= 2);
|
|
5298
|
+
const primary = actions.find((animation) => animation.name === animator.activeClip) || actions[0];
|
|
5299
|
+
const primaryLayout = primary && clipsByName.get(primary.name) || layout.clips[0];
|
|
5300
|
+
const secondary = actions.find((animation) => animation !== primary);
|
|
5301
|
+
const secondaryLayout = secondary && clipsByName.get(secondary.name);
|
|
5302
|
+
const frames = getScenegraphGPUAnimationFrames(
|
|
5303
|
+
primaryLayout,
|
|
5304
|
+
primary?.action.time || 0,
|
|
5305
|
+
layout.sampleRate
|
|
5306
|
+
);
|
|
5307
|
+
const secondaryFrames = secondaryLayout && secondary ? getScenegraphGPUAnimationFrames(secondaryLayout, secondary.action.time, layout.sampleRate) : [0, 0, 0];
|
|
5308
|
+
const totalWeight = (primary?.action.weight || 0) + (secondary?.action.weight || 0);
|
|
5309
|
+
for (const resource of resources) {
|
|
5310
|
+
resource.animationParameters.set([...frames, primary?.action.weight || 1]);
|
|
5311
|
+
resource.animationBlend.set([
|
|
5312
|
+
...secondaryFrames,
|
|
5313
|
+
secondaryLayout && secondary && totalWeight > 0 ? secondary.action.weight / totalWeight : 0
|
|
5314
|
+
]);
|
|
5315
|
+
resource.animationParameterBuffer.write(resource.animationParameters);
|
|
5316
|
+
resource.animationBlendBuffer.write(resource.animationBlend);
|
|
4469
5317
|
}
|
|
4470
|
-
|
|
5318
|
+
}
|
|
5319
|
+
function resetPose(source4, target) {
|
|
5320
|
+
target.setProps({
|
|
5321
|
+
position: Array.from(source4.position),
|
|
5322
|
+
rotation: Array.from(source4.rotation),
|
|
5323
|
+
scale: Array.from(source4.scale),
|
|
5324
|
+
matrix: Array.from(source4.matrix)
|
|
5325
|
+
});
|
|
5326
|
+
target.userData["morphWeights"] = source4.userData["morphWeights"];
|
|
5327
|
+
}
|
|
5328
|
+
function collectWorldMatrices(scenes) {
|
|
5329
|
+
const matrices = /* @__PURE__ */ new Map();
|
|
5330
|
+
for (const scene of scenes) {
|
|
5331
|
+
scene.preorderTraversal((node, { worldMatrix }) => {
|
|
5332
|
+
if (node instanceof GroupNode) matrices.set(node, worldMatrix);
|
|
5333
|
+
});
|
|
5334
|
+
}
|
|
5335
|
+
return matrices;
|
|
4471
5336
|
}
|
|
4472
5337
|
|
|
4473
5338
|
// src/animation/timeline.ts
|
|
@@ -4642,7 +5507,7 @@ var __exports__ = (() => {
|
|
|
4642
5507
|
};
|
|
4643
5508
|
|
|
4644
5509
|
// src/animation-loop/animation-loop.ts
|
|
4645
|
-
var
|
|
5510
|
+
var import_core7 = __toESM(require_core(), 1);
|
|
4646
5511
|
|
|
4647
5512
|
// src/animation-loop/request-animation-frame.ts
|
|
4648
5513
|
function requestAnimationFramePolyfill(callback) {
|
|
@@ -4912,7 +5777,7 @@ var __exports__ = (() => {
|
|
|
4912
5777
|
throw new Error("No device provided");
|
|
4913
5778
|
}
|
|
4914
5779
|
this.stats = props.stats || new Stats({ id: `animation-loop-${statIdCounter++}` });
|
|
4915
|
-
this.sharedStats =
|
|
5780
|
+
this.sharedStats = import_core7.luma.stats.get(ANIMATION_LOOP_STATS);
|
|
4916
5781
|
this.frameRate = this.stats.get("Frame Rate");
|
|
4917
5782
|
this.frameRate.setSampleSize(1);
|
|
4918
5783
|
this.cpuTime = this.stats.get("CPU Time");
|
|
@@ -5324,10 +6189,10 @@ var __exports__ = (() => {
|
|
|
5324
6189
|
};
|
|
5325
6190
|
|
|
5326
6191
|
// src/animation-loop/make-animation-loop.ts
|
|
5327
|
-
var
|
|
6192
|
+
var import_core8 = __toESM(require_core(), 1);
|
|
5328
6193
|
function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
5329
6194
|
let renderLoop = null;
|
|
5330
|
-
const device = props?.device ||
|
|
6195
|
+
const device = props?.device || import_core8.luma.createDevice({
|
|
5331
6196
|
id: "animation-loop",
|
|
5332
6197
|
adapters: props?.adapters,
|
|
5333
6198
|
createCanvasContext: true
|
|
@@ -5685,14 +6550,14 @@ var __exports__ = (() => {
|
|
|
5685
6550
|
}
|
|
5686
6551
|
|
|
5687
6552
|
// src/model/gpu-vector-model.ts
|
|
5688
|
-
var
|
|
6553
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
5689
6554
|
var import_shaders3 = __toESM(require_shaders(), 1);
|
|
5690
6555
|
|
|
5691
6556
|
// ../shaders/src/lib/utils/assert.ts
|
|
5692
|
-
function
|
|
6557
|
+
function assert5(condition, message) {
|
|
5693
6558
|
if (!condition) {
|
|
5694
6559
|
const error = new Error(message || "shaders: assertion failed.");
|
|
5695
|
-
Error.captureStackTrace?.(error,
|
|
6560
|
+
Error.captureStackTrace?.(error, assert5);
|
|
5696
6561
|
throw error;
|
|
5697
6562
|
}
|
|
5698
6563
|
}
|
|
@@ -5847,7 +6712,7 @@ var __exports__ = (() => {
|
|
|
5847
6712
|
const interfaceProviders = /* @__PURE__ */ new Set();
|
|
5848
6713
|
for (const module of result) {
|
|
5849
6714
|
if (module.implements !== void 0) {
|
|
5850
|
-
|
|
6715
|
+
assert5(!interfaceProviders.has(module.implements));
|
|
5851
6716
|
interfaceProviders.add(module.implements);
|
|
5852
6717
|
}
|
|
5853
6718
|
}
|
|
@@ -5875,7 +6740,7 @@ var __exports__ = (() => {
|
|
|
5875
6740
|
_transpileShader(props, modules, source4, stage) {
|
|
5876
6741
|
const sourceLanguage = props.sourceLanguage || this.shaderLanguage;
|
|
5877
6742
|
if (sourceLanguage === this.shaderLanguage) {
|
|
5878
|
-
|
|
6743
|
+
assert5(
|
|
5879
6744
|
!getShaderModuleDependencies(modules).some(
|
|
5880
6745
|
(module) => module.sourceLanguage && module.sourceLanguage !== this.shaderLanguage
|
|
5881
6746
|
)
|
|
@@ -5883,9 +6748,9 @@ var __exports__ = (() => {
|
|
|
5883
6748
|
return { code: source4 || "", modules };
|
|
5884
6749
|
}
|
|
5885
6750
|
const transpiler = this._shaderTranspilers.get(sourceLanguage);
|
|
5886
|
-
|
|
6751
|
+
assert5(transpiler);
|
|
5887
6752
|
const dependencies = getShaderModuleDependencies(modules);
|
|
5888
|
-
|
|
6753
|
+
assert5(
|
|
5889
6754
|
!dependencies.some(
|
|
5890
6755
|
(module) => module.sourceLanguage && module.sourceLanguage !== sourceLanguage && module.sourceLanguage !== this.shaderLanguage
|
|
5891
6756
|
)
|
|
@@ -6191,7 +7056,7 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6191
7056
|
const message = formatShaderModuleUniformLayoutError(validationResult);
|
|
6192
7057
|
options.log?.error?.(message, validationResult)();
|
|
6193
7058
|
if (options.throwOnError !== false) {
|
|
6194
|
-
|
|
7059
|
+
assert5(false, message);
|
|
6195
7060
|
}
|
|
6196
7061
|
return validationResult;
|
|
6197
7062
|
}
|
|
@@ -6229,17 +7094,16 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6229
7094
|
return nonStd140Blocks;
|
|
6230
7095
|
}
|
|
6231
7096
|
function extractShaderUniformBlockFieldNames(shaderSource, language, uniformBlockName) {
|
|
6232
|
-
const
|
|
7097
|
+
const uncommentedSource = stripShaderComments(shaderSource);
|
|
7098
|
+
const sourceBody = language === "wgsl" ? extractWGSLStructBody(uncommentedSource, uniformBlockName) : extractGLSLUniformBlockBody(uncommentedSource, uniformBlockName);
|
|
6233
7099
|
if (!sourceBody) {
|
|
6234
7100
|
return null;
|
|
6235
7101
|
}
|
|
6236
7102
|
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);
|
|
7103
|
+
const declarations = language === "wgsl" ? sourceBody.split(/;|,(?=\s*[A-Za-z0-9_]+\s*:)/) : sourceBody.replace(/^\s*#.*$/gm, "").split(";");
|
|
7104
|
+
for (const declaration of declarations) {
|
|
7105
|
+
const line = declaration.replace(/\s+/g, " ").trim();
|
|
7106
|
+
const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : `${line};`.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
|
|
6243
7107
|
if (fieldMatch) {
|
|
6244
7108
|
fieldNames.push(fieldMatch[1]);
|
|
6245
7109
|
}
|
|
@@ -6399,7 +7263,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6399
7263
|
moduleSource = module.source || "";
|
|
6400
7264
|
break;
|
|
6401
7265
|
default:
|
|
6402
|
-
|
|
7266
|
+
assert5(false);
|
|
6403
7267
|
}
|
|
6404
7268
|
if (!module.name) {
|
|
6405
7269
|
throw new Error("Shader module must have a name");
|
|
@@ -7723,7 +8587,7 @@ return ${outputName};
|
|
|
7723
8587
|
prologue = true,
|
|
7724
8588
|
log: log8
|
|
7725
8589
|
} = options;
|
|
7726
|
-
|
|
8590
|
+
assert5(typeof source4 === "string", "shader source must be a string");
|
|
7727
8591
|
const sourceVersion = language === "glsl" ? getShaderInfo(source4).version : -1;
|
|
7728
8592
|
const targetVersion = platformInfo.shaderLanguageVersion;
|
|
7729
8593
|
const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
|
|
@@ -8564,7 +9428,7 @@ ${declarations.join("\n")}`).match(
|
|
|
8564
9428
|
if (masked[end] === "{") depth++;
|
|
8565
9429
|
if (masked[end] === "}") depth--;
|
|
8566
9430
|
}
|
|
8567
|
-
|
|
9431
|
+
assert5(bodyStart >= 0 && depth === 0);
|
|
8568
9432
|
const name = match[2];
|
|
8569
9433
|
const nameStart = match.index + match[0].lastIndexOf(name);
|
|
8570
9434
|
const calls = Array.from(
|
|
@@ -8805,7 +9669,7 @@ ${declarations.join("\n")}`).match(
|
|
|
8805
9669
|
fragmentEntryPoint = "fragmentMain",
|
|
8806
9670
|
log: log8
|
|
8807
9671
|
} = options;
|
|
8808
|
-
|
|
9672
|
+
assert5(typeof source4 === "string", "shader source must be a string");
|
|
8809
9673
|
const preprocessedSource = preprocess(source4, { defines });
|
|
8810
9674
|
const pluginVertexInputAssembly = assembleShaderPluginVertexInputsWGSL(
|
|
8811
9675
|
preprocessedSource,
|
|
@@ -9370,7 +10234,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9370
10234
|
};
|
|
9371
10235
|
|
|
9372
10236
|
// src/model/batch-uniform-buffer.ts
|
|
9373
|
-
var
|
|
10237
|
+
var import_core9 = __toESM(require_core(), 1);
|
|
9374
10238
|
var BatchUniformBuffer = class {
|
|
9375
10239
|
constructor(device) {
|
|
9376
10240
|
this.device = device;
|
|
@@ -9385,7 +10249,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9385
10249
|
const buffer = this.device.createBuffer({
|
|
9386
10250
|
id: "batch-uniforms",
|
|
9387
10251
|
byteLength: capacity,
|
|
9388
|
-
usage:
|
|
10252
|
+
usage: import_core9.Buffer.UNIFORM | import_core9.Buffer.COPY_DST
|
|
9389
10253
|
});
|
|
9390
10254
|
this.buffer?.destroy();
|
|
9391
10255
|
this.buffer = buffer;
|
|
@@ -9399,7 +10263,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9399
10263
|
}
|
|
9400
10264
|
/** Writes one slot without overwriting earlier batches in this call. */
|
|
9401
10265
|
write(data) {
|
|
9402
|
-
(0,
|
|
10266
|
+
(0, import_core9.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
|
|
9403
10267
|
const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
|
|
9404
10268
|
this.buffer.write(data, binding.offset);
|
|
9405
10269
|
this.byteOffset += this.getAlignedByteLength(data.byteLength);
|
|
@@ -9577,7 +10441,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9577
10441
|
}
|
|
9578
10442
|
|
|
9579
10443
|
// src/utils/buffer-layout-helper.ts
|
|
9580
|
-
var
|
|
10444
|
+
var import_core10 = __toESM(require_core(), 1);
|
|
9581
10445
|
var BufferLayoutHelper = class {
|
|
9582
10446
|
bufferLayouts;
|
|
9583
10447
|
constructor(bufferLayouts) {
|
|
@@ -9588,7 +10452,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9588
10452
|
}
|
|
9589
10453
|
/** Get attribute names from a BufferLayout */
|
|
9590
10454
|
getAttributeNamesForBuffer(bufferLayout) {
|
|
9591
|
-
return (0,
|
|
10455
|
+
return (0, import_core10.getBufferLayoutAttributeNames)(bufferLayout);
|
|
9592
10456
|
}
|
|
9593
10457
|
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
9594
10458
|
const mergedLayouts = [...bufferLayouts1];
|
|
@@ -9605,16 +10469,16 @@ ${declarations.join("\n")}`).match(
|
|
|
9605
10469
|
};
|
|
9606
10470
|
|
|
9607
10471
|
// src/utils/buffer-layout-order.ts
|
|
9608
|
-
var
|
|
10472
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
9609
10473
|
function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
9610
|
-
const shaderLayoutMap = (0,
|
|
10474
|
+
const shaderLayoutMap = (0, import_core11.getShaderAttributeLocationMap)(shaderLayout);
|
|
9611
10475
|
const sortedLayout = bufferLayout.slice();
|
|
9612
10476
|
sortedLayout.sort((a, b) => {
|
|
9613
|
-
const minLocationA = (0,
|
|
9614
|
-
(0,
|
|
10477
|
+
const minLocationA = (0, import_core11.getMinimumAttributeLocation)(
|
|
10478
|
+
(0, import_core11.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9615
10479
|
);
|
|
9616
|
-
const minLocationB = (0,
|
|
9617
|
-
(0,
|
|
10480
|
+
const minLocationB = (0, import_core11.getMinimumAttributeLocation)(
|
|
10481
|
+
(0, import_core11.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9618
10482
|
);
|
|
9619
10483
|
return minLocationA - minLocationB;
|
|
9620
10484
|
});
|
|
@@ -9768,16 +10632,8 @@ ${declarations.join("\n")}`).match(
|
|
|
9768
10632
|
};
|
|
9769
10633
|
}
|
|
9770
10634
|
|
|
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
10635
|
// src/model/gpu-vector-model-batches.ts
|
|
9780
|
-
var
|
|
10636
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
9781
10637
|
function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
|
|
9782
10638
|
for (const [name, vector] of Object.entries(vectors)) {
|
|
9783
10639
|
if (!vector) continue;
|
|
@@ -9841,22 +10697,22 @@ ${declarations.join("\n")}`).match(
|
|
|
9841
10697
|
if (format.includes("<")) {
|
|
9842
10698
|
throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
|
|
9843
10699
|
}
|
|
9844
|
-
return
|
|
10700
|
+
return import_core12.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
9845
10701
|
}
|
|
9846
10702
|
|
|
9847
10703
|
// src/utils/gpu-vector-batch-structure.ts
|
|
9848
|
-
var
|
|
10704
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
9849
10705
|
function validateGPUVectorBatchStructure(vectors) {
|
|
9850
10706
|
let reference;
|
|
9851
10707
|
for (const vector of Object.values(vectors)) {
|
|
9852
10708
|
if (!vector || "isConstant" in vector) continue;
|
|
9853
10709
|
let rowCount = 0;
|
|
9854
10710
|
for (const chunk of vector.data) rowCount += chunk.length;
|
|
9855
|
-
(0,
|
|
10711
|
+
(0, import_core13.assert)(rowCount === vector.length);
|
|
9856
10712
|
if (reference) {
|
|
9857
|
-
(0,
|
|
10713
|
+
(0, import_core13.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
|
|
9858
10714
|
for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
|
|
9859
|
-
(0,
|
|
10715
|
+
(0, import_core13.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
|
|
9860
10716
|
}
|
|
9861
10717
|
} else reference = vector;
|
|
9862
10718
|
}
|
|
@@ -9949,7 +10805,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9949
10805
|
}
|
|
9950
10806
|
|
|
9951
10807
|
// src/model/gpu-vector-bindings.ts
|
|
9952
|
-
var
|
|
10808
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
9953
10809
|
var GPUVectorBindings = class {
|
|
9954
10810
|
constructor(device, id) {
|
|
9955
10811
|
this.device = device;
|
|
@@ -9974,7 +10830,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9974
10830
|
validateGPUVectorBatchStructure(columns);
|
|
9975
10831
|
} else {
|
|
9976
10832
|
for (const column of Object.values(columns)) {
|
|
9977
|
-
if (column && !isConstant(column)) (0,
|
|
10833
|
+
if (column && !isConstant(column)) (0, import_core14.assert)(column.data.length === 1);
|
|
9978
10834
|
}
|
|
9979
10835
|
}
|
|
9980
10836
|
this.claimedNames.clear();
|
|
@@ -9992,7 +10848,7 @@ ${declarations.join("\n")}`).match(
|
|
|
9992
10848
|
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
9993
10849
|
))
|
|
9994
10850
|
return [];
|
|
9995
|
-
(0,
|
|
10851
|
+
(0, import_core14.assert)(column.format);
|
|
9996
10852
|
const format = column.format;
|
|
9997
10853
|
const byteStride = isConstant(column) ? 0 : column.byteStride;
|
|
9998
10854
|
return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
|
|
@@ -10008,10 +10864,10 @@ ${declarations.join("\n")}`).match(
|
|
|
10008
10864
|
);
|
|
10009
10865
|
const mode = layout?.stepMode ?? stepMode;
|
|
10010
10866
|
if (mode === "instance") {
|
|
10011
|
-
(0,
|
|
10867
|
+
(0, import_core14.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
|
|
10012
10868
|
this.instanceCount = column.length;
|
|
10013
10869
|
} else {
|
|
10014
|
-
(0,
|
|
10870
|
+
(0, import_core14.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
|
|
10015
10871
|
this.vertexCount = column.length;
|
|
10016
10872
|
}
|
|
10017
10873
|
this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
|
|
@@ -10056,7 +10912,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10056
10912
|
for (const definition of definitions) {
|
|
10057
10913
|
const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
|
|
10058
10914
|
if (!column) continue;
|
|
10059
|
-
(0,
|
|
10915
|
+
(0, import_core14.assert)(column.format === void 0 || column.format === definition.format);
|
|
10060
10916
|
if (isConstant(column)) {
|
|
10061
10917
|
this.constants[definition.attribute] = getShaderConstant(column);
|
|
10062
10918
|
constantByteLength = Math.max(
|
|
@@ -10083,7 +10939,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10083
10939
|
buffer = this.device.createBuffer({
|
|
10084
10940
|
id: `${this.id}-${layout.name}-constant`,
|
|
10085
10941
|
byteLength: bytes.byteLength,
|
|
10086
|
-
usage:
|
|
10942
|
+
usage: import_core14.Buffer.VERTEX | import_core14.Buffer.COPY_DST | import_core14.Buffer.COPY_SRC
|
|
10087
10943
|
});
|
|
10088
10944
|
this.constantBuffers[layout.name] = buffer;
|
|
10089
10945
|
}
|
|
@@ -10120,7 +10976,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10120
10976
|
const chunk = vector.data[0];
|
|
10121
10977
|
if (!chunk) return;
|
|
10122
10978
|
const byteOffset = chunk.byteOffset - layoutOffset;
|
|
10123
|
-
(0,
|
|
10979
|
+
(0, import_core14.assert)(byteOffset >= 0);
|
|
10124
10980
|
this.buffers[name] = chunk.buffer;
|
|
10125
10981
|
this.byteOffsets[name] = byteOffset;
|
|
10126
10982
|
}
|
|
@@ -10129,7 +10985,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10129
10985
|
return Boolean(column && "isConstant" in column && column.isConstant);
|
|
10130
10986
|
}
|
|
10131
10987
|
function getShaderConstant(column) {
|
|
10132
|
-
const information =
|
|
10988
|
+
const information = import_core14.vertexFormatDecoder.getVertexFormatInfo(column.format);
|
|
10133
10989
|
if (column.format === "unorm10-10-10-2") {
|
|
10134
10990
|
const word = column.value[0];
|
|
10135
10991
|
return new Float32Array([
|
|
@@ -10199,7 +11055,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10199
11055
|
}
|
|
10200
11056
|
|
|
10201
11057
|
// src/shader-inputs.ts
|
|
10202
|
-
var
|
|
11058
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
10203
11059
|
var import_shaders2 = __toESM(require_shaders(), 1);
|
|
10204
11060
|
|
|
10205
11061
|
// src/model/split-uniforms-and-bindings.ts
|
|
@@ -10249,7 +11105,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10249
11105
|
for (const resolvedModule of resolvedModules) {
|
|
10250
11106
|
modules[resolvedModule.name] = resolvedModule;
|
|
10251
11107
|
}
|
|
10252
|
-
|
|
11108
|
+
import_core15.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
|
|
10253
11109
|
this.modules = modules;
|
|
10254
11110
|
this.moduleUniforms = {};
|
|
10255
11111
|
this.moduleBindings = {};
|
|
@@ -10257,7 +11113,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10257
11113
|
if (module) {
|
|
10258
11114
|
this._addModule(module);
|
|
10259
11115
|
if (module.name && name !== module.name && !this.options.disableWarnings) {
|
|
10260
|
-
|
|
11116
|
+
import_core15.log.warn(`Module name: ${name} vs ${module.name}`)();
|
|
10261
11117
|
}
|
|
10262
11118
|
}
|
|
10263
11119
|
}
|
|
@@ -10281,7 +11137,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10281
11137
|
const module = this.modules[moduleName];
|
|
10282
11138
|
if (!module) {
|
|
10283
11139
|
if (!this.options.disableWarnings) {
|
|
10284
|
-
|
|
11140
|
+
import_core15.log.warn(`Module ${name} not found`)();
|
|
10285
11141
|
}
|
|
10286
11142
|
} else {
|
|
10287
11143
|
const oldUniforms = this.moduleUniforms[moduleName];
|
|
@@ -10476,7 +11332,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10476
11332
|
var VERSION = true ? "5.0.0" : "untranspiled source";
|
|
10477
11333
|
|
|
10478
11334
|
// ../../node_modules/probe.gl/dist/log/utils/assert.js
|
|
10479
|
-
function
|
|
11335
|
+
function assert10(condition, message) {
|
|
10480
11336
|
if (!condition) {
|
|
10481
11337
|
throw new Error(message || "Assertion failed");
|
|
10482
11338
|
}
|
|
@@ -10498,7 +11354,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10498
11354
|
default:
|
|
10499
11355
|
return 0;
|
|
10500
11356
|
}
|
|
10501
|
-
|
|
11357
|
+
assert10(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
10502
11358
|
return resolvedLevel;
|
|
10503
11359
|
}
|
|
10504
11360
|
function normalizeArguments(opts) {
|
|
@@ -10524,7 +11380,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10524
11380
|
opts.message = opts.message();
|
|
10525
11381
|
}
|
|
10526
11382
|
const messageType = typeof opts.message;
|
|
10527
|
-
|
|
11383
|
+
assert10(messageType === "string" || messageType === "object");
|
|
10528
11384
|
return Object.assign(opts, { args }, opts.opts);
|
|
10529
11385
|
}
|
|
10530
11386
|
|
|
@@ -10940,7 +11796,7 @@ ${declarations.join("\n")}`).match(
|
|
|
10940
11796
|
}
|
|
10941
11797
|
_emit(_type, normalized2) {
|
|
10942
11798
|
const method = normalized2.method;
|
|
10943
|
-
|
|
11799
|
+
assert10(method);
|
|
10944
11800
|
normalized2.total = this.getTotal();
|
|
10945
11801
|
normalized2.delta = this.getDelta();
|
|
10946
11802
|
this._deltaTs = probe.getHighResolutionTimer();
|
|
@@ -10986,10 +11842,10 @@ ${declarations.join("\n")}`).match(
|
|
|
10986
11842
|
}
|
|
10987
11843
|
|
|
10988
11844
|
// ../../node_modules/probe.gl/dist/log/index.js
|
|
10989
|
-
var
|
|
11845
|
+
var log4 = new ProbeLog({ id: "@probe.gl/log" });
|
|
10990
11846
|
|
|
10991
11847
|
// ../core/src/api/utils/log.ts
|
|
10992
|
-
var
|
|
11848
|
+
var log5 = new ProbeLog({ id: "luma.gl" });
|
|
10993
11849
|
|
|
10994
11850
|
// ../core/src/api/utils/uid.ts
|
|
10995
11851
|
var uidCounters2 = {};
|
|
@@ -11000,10 +11856,10 @@ ${declarations.join("\n")}`).match(
|
|
|
11000
11856
|
}
|
|
11001
11857
|
|
|
11002
11858
|
// ../core/src/api/utils/assert.ts
|
|
11003
|
-
function
|
|
11859
|
+
function assert11(condition, message) {
|
|
11004
11860
|
if (!condition) {
|
|
11005
11861
|
const error = new Error(message ?? "luma.gl assertion failed.");
|
|
11006
|
-
Error.captureStackTrace?.(error,
|
|
11862
|
+
Error.captureStackTrace?.(error, assert11);
|
|
11007
11863
|
throw error;
|
|
11008
11864
|
}
|
|
11009
11865
|
}
|
|
@@ -11029,11 +11885,11 @@ ${declarations.join("\n")}`).match(
|
|
|
11029
11885
|
}
|
|
11030
11886
|
/** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
|
|
11031
11887
|
transferOwnershipTo(owner) {
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11888
|
+
assert11(this._state === "live" && !this._destroyingOwnedResources);
|
|
11889
|
+
assert11(!this._owner || this._owner.canChangeOwnership());
|
|
11890
|
+
assert11(!owner || owner.canChangeOwnership());
|
|
11035
11891
|
for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
|
|
11036
|
-
|
|
11892
|
+
assert11(ancestor !== this);
|
|
11037
11893
|
}
|
|
11038
11894
|
if (owner !== this._owner) {
|
|
11039
11895
|
this._owner?._ownedResources.delete(this);
|
|
@@ -11463,7 +12319,7 @@ ${declarations.join("\n")}`).match(
|
|
|
11463
12319
|
}
|
|
11464
12320
|
|
|
11465
12321
|
// ../core/src/api/adapter/resources/buffer.ts
|
|
11466
|
-
var
|
|
12322
|
+
var Buffer6 = class _Buffer extends DeviceResource {
|
|
11467
12323
|
/** Index buffer */
|
|
11468
12324
|
static INDEX = 16;
|
|
11469
12325
|
/** Vertex buffer */
|
|
@@ -12171,7 +13027,7 @@ ${declarations.join("\n")}`).match(
|
|
|
12171
13027
|
"cube-array": "2d",
|
|
12172
13028
|
"3d": "3d"
|
|
12173
13029
|
};
|
|
12174
|
-
var
|
|
13030
|
+
var Texture3 = class _Texture extends DeviceResource {
|
|
12175
13031
|
/** The texture can be bound for use as a sampled texture in a shader */
|
|
12176
13032
|
static SAMPLE = 4;
|
|
12177
13033
|
/** The texture can be bound for use as a storage texture in a shader */
|
|
@@ -12240,7 +13096,7 @@ ${declarations.join("\n")}`).match(
|
|
|
12240
13096
|
this.width = 1;
|
|
12241
13097
|
this.height = 1;
|
|
12242
13098
|
if (this.props.width === void 0 || this.props.height === void 0) {
|
|
12243
|
-
|
|
13099
|
+
log5.warn(
|
|
12244
13100
|
`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`
|
|
12245
13101
|
)();
|
|
12246
13102
|
}
|
|
@@ -12644,18 +13500,21 @@ ${declarations.join("\n")}`).match(
|
|
|
12644
13500
|
};
|
|
12645
13501
|
|
|
12646
13502
|
// ../core/src/api/adapter-utils/bind-groups.ts
|
|
13503
|
+
var UNIFORMS_SUFFIX = "uniforms";
|
|
12647
13504
|
function getShaderLayoutBinding(shaderLayout, bindingName, options) {
|
|
13505
|
+
const lowerCaseName = bindingName.toLowerCase();
|
|
13506
|
+
const aliasName = lowerCaseName.endsWith(UNIFORMS_SUFFIX) ? lowerCaseName.slice(0, -UNIFORMS_SUFFIX.length) : void 0;
|
|
12648
13507
|
const bindingLayout = shaderLayout.bindings.find(
|
|
12649
|
-
(binding) => binding.name === bindingName ||
|
|
13508
|
+
(binding) => binding.name === bindingName || aliasName !== void 0 && binding.name.toLowerCase() === aliasName
|
|
12650
13509
|
);
|
|
12651
13510
|
if (!bindingLayout && !options?.ignoreWarnings) {
|
|
12652
|
-
|
|
13511
|
+
log5.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
|
|
12653
13512
|
}
|
|
12654
13513
|
return bindingLayout || null;
|
|
12655
13514
|
}
|
|
12656
13515
|
|
|
12657
13516
|
// ../core/src/dynamic/dynamic-buffer/dynamic-buffer.ts
|
|
12658
|
-
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH =
|
|
13517
|
+
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer6.DEBUG_DATA_MAX_LENGTH;
|
|
12659
13518
|
var DynamicBuffer = class {
|
|
12660
13519
|
/** Device that owns the backing buffer. */
|
|
12661
13520
|
device;
|
|
@@ -12722,7 +13581,7 @@ ${declarations.join("\n")}`).match(
|
|
|
12722
13581
|
usage: bufferProps.usage ?? adoptedBuffer?.usage,
|
|
12723
13582
|
indexType: bufferProps.indexType ?? adoptedBuffer?.indexType
|
|
12724
13583
|
};
|
|
12725
|
-
if ((normalizedBufferProps.usage || 0) &
|
|
13584
|
+
if ((normalizedBufferProps.usage || 0) & Buffer6.INDEX && !normalizedBufferProps.indexType) {
|
|
12726
13585
|
if (bufferProps.data instanceof Uint32Array) {
|
|
12727
13586
|
normalizedBufferProps.indexType = "uint32";
|
|
12728
13587
|
} else if (bufferProps.data instanceof Uint16Array) {
|
|
@@ -13218,11 +14077,11 @@ ${declarations.join("\n")}`).match(
|
|
|
13218
14077
|
data: void 0
|
|
13219
14078
|
};
|
|
13220
14079
|
if (this.device.isTextureFormatCompressed(resolvedFormat) && !userProvidedUsage) {
|
|
13221
|
-
baseTextureProps.usage =
|
|
14080
|
+
baseTextureProps.usage = Texture3.SAMPLE | Texture3.COPY_DST;
|
|
13222
14081
|
}
|
|
13223
14082
|
const shouldGenerateMipmaps = this.props.mipmaps && !textureData.hasExplicitMipChain && !this.device.isTextureFormatCompressed(resolvedFormat);
|
|
13224
14083
|
if (this.device.type === "webgpu" && shouldGenerateMipmaps) {
|
|
13225
|
-
const requiredUsage = this.props.dimension === "3d" ?
|
|
14084
|
+
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;
|
|
13226
14085
|
baseTextureProps.usage |= requiredUsage;
|
|
13227
14086
|
}
|
|
13228
14087
|
const maxMips = this.device.getMipLevelCount(baseTextureProps.width, baseTextureProps.height);
|
|
@@ -13236,14 +14095,14 @@ ${declarations.join("\n")}`).match(
|
|
|
13236
14095
|
this._setTextureSubresources(textureData.subresources);
|
|
13237
14096
|
}
|
|
13238
14097
|
if (this.props.mipmaps && !textureData.hasExplicitMipChain && !shouldGenerateMipmaps) {
|
|
13239
|
-
|
|
14098
|
+
log5.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)();
|
|
13240
14099
|
}
|
|
13241
14100
|
if (shouldGenerateMipmaps) {
|
|
13242
14101
|
this.generateMipmaps();
|
|
13243
14102
|
}
|
|
13244
14103
|
this.isReady = true;
|
|
13245
14104
|
this.resolveReady(this.texture);
|
|
13246
|
-
|
|
14105
|
+
log5.info(1, `${this} created`)();
|
|
13247
14106
|
} catch (e) {
|
|
13248
14107
|
const err = e instanceof Error ? e : new Error(String(e));
|
|
13249
14108
|
this.rejectReady(err);
|
|
@@ -13267,7 +14126,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13267
14126
|
this.device.generateMipmapsWebGPU(this.texture);
|
|
13268
14127
|
this._touch();
|
|
13269
14128
|
} else {
|
|
13270
|
-
|
|
14129
|
+
log5.warn(`${this} mipmaps not supported on ${this.device.type}`);
|
|
13271
14130
|
}
|
|
13272
14131
|
}
|
|
13273
14132
|
/** Set sampler or create one from props */
|
|
@@ -13292,7 +14151,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13292
14151
|
const layout = this.texture.computeMemoryLayout({ width, height, depthOrArrayLayers });
|
|
13293
14152
|
const buffer = this.device.createBuffer({
|
|
13294
14153
|
byteLength: layout.byteLength,
|
|
13295
|
-
usage:
|
|
14154
|
+
usage: Buffer6.COPY_DST | Buffer6.MAP_READ
|
|
13296
14155
|
});
|
|
13297
14156
|
this.texture.readBuffer(
|
|
13298
14157
|
{
|
|
@@ -13337,7 +14196,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13337
14196
|
this._view = this.texture.view;
|
|
13338
14197
|
prev.destroy();
|
|
13339
14198
|
this._touchGeneration();
|
|
13340
|
-
|
|
14199
|
+
log5.info(`${this} resized`);
|
|
13341
14200
|
return true;
|
|
13342
14201
|
}
|
|
13343
14202
|
/** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
|
|
@@ -13443,12 +14302,12 @@ ${declarations.join("\n")}`).match(
|
|
|
13443
14302
|
}
|
|
13444
14303
|
_checkNotDestroyed() {
|
|
13445
14304
|
if (this.destroyed) {
|
|
13446
|
-
|
|
14305
|
+
log5.warn(`${this} already destroyed`);
|
|
13447
14306
|
}
|
|
13448
14307
|
}
|
|
13449
14308
|
_checkReady() {
|
|
13450
14309
|
if (!this.isReady) {
|
|
13451
|
-
|
|
14310
|
+
log5.warn(`${this} Cannot perform this operation before ready`);
|
|
13452
14311
|
}
|
|
13453
14312
|
}
|
|
13454
14313
|
_touch() {
|
|
@@ -13459,7 +14318,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13459
14318
|
this._touch();
|
|
13460
14319
|
}
|
|
13461
14320
|
static defaultProps = {
|
|
13462
|
-
...
|
|
14321
|
+
...Texture3.defaultProps,
|
|
13463
14322
|
dimension: "2d",
|
|
13464
14323
|
data: null,
|
|
13465
14324
|
mipmaps: false
|
|
@@ -13656,13 +14515,13 @@ ${declarations.join("\n")}`).match(
|
|
|
13656
14515
|
var GPUVectorModel = class _GPUVectorModel {
|
|
13657
14516
|
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
13658
14517
|
static async createAsync(device, props) {
|
|
13659
|
-
const ownsCompilation = !
|
|
13660
|
-
const asyncCompilation = ownsCompilation ?
|
|
14518
|
+
const ownsCompilation = !import_core16.PipelineFactory.getAsyncCompilation(device);
|
|
14519
|
+
const asyncCompilation = ownsCompilation ? import_core16.PipelineFactory.beginAsyncCompilation(device) : import_core16.PipelineFactory.getAsyncCompilation(device);
|
|
13661
14520
|
let model;
|
|
13662
14521
|
try {
|
|
13663
14522
|
model = new this(device, props);
|
|
13664
14523
|
} finally {
|
|
13665
|
-
if (ownsCompilation)
|
|
14524
|
+
if (ownsCompilation) import_core16.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
13666
14525
|
}
|
|
13667
14526
|
try {
|
|
13668
14527
|
if (ownsCompilation) {
|
|
@@ -13677,7 +14536,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13677
14536
|
}
|
|
13678
14537
|
}
|
|
13679
14538
|
static defaultProps = {
|
|
13680
|
-
...
|
|
14539
|
+
...import_core16.RenderPipeline.defaultProps,
|
|
13681
14540
|
inferDrawCount: "no",
|
|
13682
14541
|
enforceMatchingVectorLengths: true,
|
|
13683
14542
|
geometry: null,
|
|
@@ -13861,7 +14720,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13861
14720
|
const isWebGPU = this.device.type === "webgpu";
|
|
13862
14721
|
if (isWebGPU && this.props.source) {
|
|
13863
14722
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13864
|
-
(0,
|
|
14723
|
+
(0, import_core16.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
13865
14724
|
const {
|
|
13866
14725
|
source: source4,
|
|
13867
14726
|
getUniforms: getUniforms2,
|
|
@@ -13898,7 +14757,7 @@ ${declarations.join("\n")}`).match(
|
|
|
13898
14757
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
13899
14758
|
} else {
|
|
13900
14759
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13901
|
-
(0,
|
|
14760
|
+
(0, import_core16.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
|
|
13902
14761
|
const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
|
|
13903
14762
|
platformInfo,
|
|
13904
14763
|
...this.props,
|
|
@@ -13914,9 +14773,9 @@ ${declarations.join("\n")}`).match(
|
|
|
13914
14773
|
this._getModuleUniforms = getUniforms2;
|
|
13915
14774
|
this._bindingTable = [];
|
|
13916
14775
|
}
|
|
13917
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
13918
|
-
this.shaderFactory = props.shaderFactory ||
|
|
13919
|
-
const asyncCompilation =
|
|
14776
|
+
this.pipelineFactory = props.pipelineFactory || import_core16.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
14777
|
+
this.shaderFactory = props.shaderFactory || import_core16.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
14778
|
+
const asyncCompilation = import_core16.PipelineFactory.getAsyncCompilation(this.device);
|
|
13920
14779
|
if (asyncCompilation) {
|
|
13921
14780
|
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
13922
14781
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -14041,22 +14900,38 @@ ${declarations.join("\n")}`).match(
|
|
|
14041
14900
|
renderPass.setParameters(state);
|
|
14042
14901
|
}
|
|
14043
14902
|
}
|
|
14044
|
-
|
|
14903
|
+
/**
|
|
14904
|
+
* Draws one caller-owned WebGPU indirect record in the open pass. The active index buffer
|
|
14905
|
+
* selects the indexed (20-byte) or non-indexed (16-byte) layout. The record supplies all
|
|
14906
|
+
* counts and offsets for this call. Subsequent direct draws use the model's own counts.
|
|
14907
|
+
* @param byteOffset Four-byte-aligned start of the record in a buffer with INDIRECT usage.
|
|
14908
|
+
* @returns Whether the draw completed using the same readiness rules as draw().
|
|
14909
|
+
*/
|
|
14910
|
+
drawIndirect(renderPass, buffer, byteOffset = 0) {
|
|
14911
|
+
(0, import_core16.assert)(this.device.type === "webgpu" && (buffer.usage & import_core16.Buffer.INDIRECT) !== 0);
|
|
14912
|
+
return this._draw(renderPass, buffer, byteOffset);
|
|
14913
|
+
}
|
|
14914
|
+
_draw(renderPass, indirectBuffer, byteOffset = 0) {
|
|
14045
14915
|
if (this.indexVector?.length === 0) {
|
|
14046
14916
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
14047
14917
|
this._needsRedraw = false;
|
|
14048
14918
|
return true;
|
|
14049
14919
|
}
|
|
14050
14920
|
if (!this.drawingVectorBatches && (this.geometryVectorBindings.batchCount !== 1 || this.attributeVectorBindings.batchCount !== 1)) {
|
|
14921
|
+
if (indirectBuffer) {
|
|
14922
|
+
(0, import_core16.assert)(
|
|
14923
|
+
this.geometryVectorBindings.batchCount <= 1 && this.attributeVectorBindings.batchCount <= 1
|
|
14924
|
+
);
|
|
14925
|
+
}
|
|
14051
14926
|
return this.drawVectorGroups(renderPass);
|
|
14052
14927
|
}
|
|
14053
14928
|
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
14054
|
-
|
|
14929
|
+
import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
14055
14930
|
return false;
|
|
14056
14931
|
}
|
|
14057
14932
|
const loadingBinding = this._areBindingsLoading();
|
|
14058
14933
|
if (loadingBinding) {
|
|
14059
|
-
|
|
14934
|
+
import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
14060
14935
|
return false;
|
|
14061
14936
|
}
|
|
14062
14937
|
this._syncAttachmentFormats(renderPass);
|
|
@@ -14080,7 +14955,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14080
14955
|
this.pipeline = this._updatePipeline();
|
|
14081
14956
|
pipelineErrored = this.pipeline.isErrored;
|
|
14082
14957
|
if (pipelineErrored) {
|
|
14083
|
-
|
|
14958
|
+
import_core16.log.info(
|
|
14084
14959
|
LOG_DRAW_PRIORITY,
|
|
14085
14960
|
`>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
|
|
14086
14961
|
)();
|
|
@@ -14088,7 +14963,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14088
14963
|
} else {
|
|
14089
14964
|
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
14090
14965
|
if (drawValidationError) {
|
|
14091
|
-
|
|
14966
|
+
import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
14092
14967
|
this._drawBlockedReason = drawValidationError;
|
|
14093
14968
|
drawSuccess = false;
|
|
14094
14969
|
} else {
|
|
@@ -14102,21 +14977,30 @@ ${declarations.join("\n")}`).match(
|
|
|
14102
14977
|
_bindGroupCacheKeys: this._getBindGroupCacheKeys()
|
|
14103
14978
|
});
|
|
14104
14979
|
renderPass.setVertexArray(this.vertexArray);
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14980
|
+
if (indirectBuffer) {
|
|
14981
|
+
if (indexBuffer) {
|
|
14982
|
+
renderPass.drawIndexedIndirect(indirectBuffer, byteOffset);
|
|
14983
|
+
} else {
|
|
14984
|
+
renderPass.drawIndirect(indirectBuffer, byteOffset);
|
|
14985
|
+
}
|
|
14986
|
+
drawSuccess = true;
|
|
14987
|
+
} else {
|
|
14988
|
+
const hasNoInstances = this.isInstanced === true && this.instanceCount === 0;
|
|
14989
|
+
drawSuccess = hasNoInstances ? true : renderPass.draw({
|
|
14990
|
+
isInstanced: this.isInstanced,
|
|
14991
|
+
vertexCount: this.vertexCount,
|
|
14992
|
+
instanceCount: this.isInstanced ? this.instanceCount : void 0,
|
|
14993
|
+
indexCount,
|
|
14994
|
+
firstVertex: this.firstVertex,
|
|
14995
|
+
firstIndex: this.firstIndex,
|
|
14996
|
+
transformFeedback: this.transformFeedback || void 0,
|
|
14997
|
+
uniforms: this.props.uniforms,
|
|
14998
|
+
// WebGL shares underlying cached programs even for models that have different
|
|
14999
|
+
// parameters and topology, so those compatibility overrides remain per draw.
|
|
15000
|
+
parameters: this.parameters,
|
|
15001
|
+
topology: this.topology
|
|
15002
|
+
});
|
|
15003
|
+
}
|
|
14120
15004
|
}
|
|
14121
15005
|
}
|
|
14122
15006
|
} finally {
|
|
@@ -14163,7 +15047,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14163
15047
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
14164
15048
|
this.syncVectorBindings();
|
|
14165
15049
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
14166
|
-
(0,
|
|
15050
|
+
(0, import_core16.assert)(
|
|
14167
15051
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
14168
15052
|
);
|
|
14169
15053
|
if (this.props.inferDrawCount === "vertex")
|
|
@@ -14200,7 +15084,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14200
15084
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
14201
15085
|
if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
|
|
14202
15086
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
14203
|
-
(0,
|
|
15087
|
+
(0, import_core16.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
14204
15088
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
14205
15089
|
}
|
|
14206
15090
|
}
|
|
@@ -14211,9 +15095,9 @@ ${declarations.join("\n")}`).match(
|
|
|
14211
15095
|
/** Replaces the borrowed contiguous uint16/uint32 index vector. */
|
|
14212
15096
|
setIndexVector(vector) {
|
|
14213
15097
|
if (vector) {
|
|
14214
|
-
(0,
|
|
14215
|
-
(0,
|
|
14216
|
-
(0,
|
|
15098
|
+
(0, import_core16.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
|
|
15099
|
+
(0, import_core16.assert)(vector.data.length <= 1);
|
|
15100
|
+
(0, import_core16.assert)(
|
|
14217
15101
|
vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
|
|
14218
15102
|
);
|
|
14219
15103
|
}
|
|
@@ -14225,7 +15109,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14225
15109
|
const chunk = vector?.data[0];
|
|
14226
15110
|
if (chunk && this.indexVector) {
|
|
14227
15111
|
const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
|
|
14228
|
-
(0,
|
|
15112
|
+
(0, import_core16.assert)(
|
|
14229
15113
|
buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
|
|
14230
15114
|
);
|
|
14231
15115
|
}
|
|
@@ -14299,7 +15183,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14299
15183
|
/** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
|
|
14300
15184
|
setGPUVectors(vectors, options) {
|
|
14301
15185
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
14302
|
-
(0,
|
|
15186
|
+
(0, import_core16.assert)(batches.length <= 1);
|
|
14303
15187
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
14304
15188
|
if (batches[0]) this.setGPUData(batches[0].data);
|
|
14305
15189
|
this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
|
|
@@ -14338,7 +15222,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14338
15222
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
14339
15223
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
14340
15224
|
for (const name of Object.keys(vectors)) {
|
|
14341
|
-
(0,
|
|
15225
|
+
(0, import_core16.assert)(!vectors[name] || this.currentAttributes[name]);
|
|
14342
15226
|
}
|
|
14343
15227
|
const previousAttributes = { ...this.currentAttributes };
|
|
14344
15228
|
const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
|
|
@@ -14348,7 +15232,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14348
15232
|
const previousIsInstanced = this.isInstanced;
|
|
14349
15233
|
const previousVertexCountSet = this._vertexCountSet;
|
|
14350
15234
|
const drawingVectorBatches = this.drawingVectorBatches;
|
|
14351
|
-
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new
|
|
15235
|
+
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core16.UniformStore(this.device, this.shaderInputs.modules) : void 0;
|
|
14352
15236
|
if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
|
|
14353
15237
|
this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
|
|
14354
15238
|
let batchByteLength = 0;
|
|
@@ -14409,7 +15293,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14409
15293
|
Object.entries(data).map(([name, chunk]) => {
|
|
14410
15294
|
const layout = this.bufferLayout.find((layout2) => layout2.name === name);
|
|
14411
15295
|
const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
|
|
14412
|
-
(0,
|
|
15296
|
+
(0, import_core16.assert)(byteOffset >= 0);
|
|
14413
15297
|
return [name, byteOffset];
|
|
14414
15298
|
})
|
|
14415
15299
|
)
|
|
@@ -14417,7 +15301,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14417
15301
|
);
|
|
14418
15302
|
}
|
|
14419
15303
|
validateVectorLengthPolicy() {
|
|
14420
|
-
(0,
|
|
15304
|
+
(0, import_core16.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
|
|
14421
15305
|
}
|
|
14422
15306
|
setBatchDrawCount(rowCount, count = this.props.inferDrawCount === "no" ? "none" : this.props.inferDrawCount) {
|
|
14423
15307
|
if (count === "instance") {
|
|
@@ -14540,7 +15424,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14540
15424
|
/** Set the shader inputs */
|
|
14541
15425
|
setShaderInputs(shaderInputs) {
|
|
14542
15426
|
this.shaderInputs = shaderInputs;
|
|
14543
|
-
this._uniformStore = new
|
|
15427
|
+
this._uniformStore = new import_core16.UniformStore(this.device, this.shaderInputs.modules);
|
|
14544
15428
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14545
15429
|
if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
|
|
14546
15430
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -14611,7 +15495,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14611
15495
|
this._drawBlockedReason = false;
|
|
14612
15496
|
const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
|
|
14613
15497
|
if (buffers["indices"]) {
|
|
14614
|
-
|
|
15498
|
+
import_core16.log.warn(
|
|
14615
15499
|
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
14616
15500
|
)();
|
|
14617
15501
|
}
|
|
@@ -14625,7 +15509,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14625
15509
|
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
14626
15510
|
if (!bufferLayout) {
|
|
14627
15511
|
if (!disableWarnings) {
|
|
14628
|
-
|
|
15512
|
+
import_core16.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
14629
15513
|
}
|
|
14630
15514
|
continue;
|
|
14631
15515
|
}
|
|
@@ -14637,7 +15521,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14637
15521
|
const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
|
|
14638
15522
|
if (bufferSlot === null) {
|
|
14639
15523
|
if (!disableWarnings) {
|
|
14640
|
-
|
|
15524
|
+
import_core16.log.warn(
|
|
14641
15525
|
`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
|
|
14642
15526
|
)();
|
|
14643
15527
|
}
|
|
@@ -14658,7 +15542,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14658
15542
|
}
|
|
14659
15543
|
}
|
|
14660
15544
|
if (!set2 && !disableWarnings) {
|
|
14661
|
-
|
|
15545
|
+
import_core16.log.warn(
|
|
14662
15546
|
`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
|
|
14663
15547
|
)();
|
|
14664
15548
|
}
|
|
@@ -14679,7 +15563,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14679
15563
|
if (attributeInfo) {
|
|
14680
15564
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
14681
15565
|
} else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
|
|
14682
|
-
|
|
15566
|
+
import_core16.log.warn(
|
|
14683
15567
|
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
14684
15568
|
)();
|
|
14685
15569
|
}
|
|
@@ -14716,7 +15600,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14716
15600
|
* @param bindings GPUVectorModel bindings already resolved for this draw preparation.
|
|
14717
15601
|
*/
|
|
14718
15602
|
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
14719
|
-
return shaderLayout.bindings.length ? (0,
|
|
15603
|
+
return shaderLayout.bindings.length ? (0, import_core16.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
|
|
14720
15604
|
}
|
|
14721
15605
|
_getBindGroupCacheKeys() {
|
|
14722
15606
|
return {};
|
|
@@ -14731,9 +15615,9 @@ ${declarations.join("\n")}`).match(
|
|
|
14731
15615
|
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
14732
15616
|
}
|
|
14733
15617
|
for (const binding of Object.values(this.bindings)) {
|
|
14734
|
-
if (binding instanceof
|
|
15618
|
+
if (binding instanceof import_core16.TextureView) {
|
|
14735
15619
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
14736
|
-
} else if (binding instanceof
|
|
15620
|
+
} else if (binding instanceof import_core16.Buffer || binding instanceof import_core16.Texture || binding instanceof import_core16.ExternalTexture) {
|
|
14737
15621
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
14738
15622
|
} else if (binding instanceof DynamicBuffer) {
|
|
14739
15623
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -14792,7 +15676,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14792
15676
|
const previousVertexShader = this.pipeline?.vs ?? null;
|
|
14793
15677
|
const previousFragmentShader = this.pipeline?.fs ?? null;
|
|
14794
15678
|
if (this.pipeline) {
|
|
14795
|
-
|
|
15679
|
+
import_core16.log.log(
|
|
14796
15680
|
1,
|
|
14797
15681
|
`GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
|
|
14798
15682
|
)();
|
|
@@ -14842,7 +15726,7 @@ ${declarations.join("\n")}`).match(
|
|
|
14842
15726
|
};
|
|
14843
15727
|
}
|
|
14844
15728
|
_finishPipelineUpdate(update) {
|
|
14845
|
-
this._attributeInfos = (0,
|
|
15729
|
+
this._attributeInfos = (0, import_core16.getAttributeInfosFromLayouts)(
|
|
14846
15730
|
this.pipeline.shaderLayout,
|
|
14847
15731
|
this.bufferLayout
|
|
14848
15732
|
);
|
|
@@ -14858,24 +15742,24 @@ ${declarations.join("\n")}`).match(
|
|
|
14858
15742
|
_lastLogTime = 0;
|
|
14859
15743
|
_logOpen = false;
|
|
14860
15744
|
_logDrawCallStart() {
|
|
14861
|
-
const logDrawTimeout =
|
|
14862
|
-
if (
|
|
15745
|
+
const logDrawTimeout = import_core16.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
15746
|
+
if (import_core16.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
14863
15747
|
return;
|
|
14864
15748
|
}
|
|
14865
15749
|
this._lastLogTime = Date.now();
|
|
14866
15750
|
this._logOpen = true;
|
|
14867
|
-
|
|
15751
|
+
import_core16.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core16.log.level <= 2 })();
|
|
14868
15752
|
}
|
|
14869
15753
|
_logDrawCallEnd() {
|
|
14870
15754
|
if (this._logOpen) {
|
|
14871
15755
|
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
14872
|
-
|
|
15756
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
14873
15757
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
14874
|
-
|
|
15758
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
14875
15759
|
const attributeTable = this._getAttributeDebugTable();
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
15760
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
15761
|
+
import_core16.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
15762
|
+
import_core16.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
14879
15763
|
this._logOpen = false;
|
|
14880
15764
|
}
|
|
14881
15765
|
}
|
|
@@ -14915,8 +15799,8 @@ ${declarations.join("\n")}`).match(
|
|
|
14915
15799
|
}
|
|
14916
15800
|
// TODO - fix typing of luma data types
|
|
14917
15801
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
14918
|
-
const TypedArrayConstructor =
|
|
14919
|
-
const typedArray = attribute instanceof
|
|
15802
|
+
const TypedArrayConstructor = import_core16.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
15803
|
+
const typedArray = attribute instanceof import_core16.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
14920
15804
|
return typedArray.toString();
|
|
14921
15805
|
}
|
|
14922
15806
|
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
@@ -15002,7 +15886,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15002
15886
|
}
|
|
15003
15887
|
|
|
15004
15888
|
// src/geometry/gpu-geometry.ts
|
|
15005
|
-
var
|
|
15889
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
15006
15890
|
var GPUGeometry = class {
|
|
15007
15891
|
/** Application-provided or generated identifier. */
|
|
15008
15892
|
id;
|
|
@@ -15027,7 +15911,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15027
15911
|
this.vertexCount = props.vertexCount;
|
|
15028
15912
|
this.bufferLayout = props.bufferLayout || [];
|
|
15029
15913
|
if (this.indices) {
|
|
15030
|
-
if (!(this.indices.usage &
|
|
15914
|
+
if (!(this.indices.usage & import_core17.Buffer.INDEX)) {
|
|
15031
15915
|
throw new Error("Index buffer must have INDEX usage");
|
|
15032
15916
|
}
|
|
15033
15917
|
}
|
|
@@ -15076,7 +15960,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15076
15960
|
return void 0;
|
|
15077
15961
|
}
|
|
15078
15962
|
const data = geometry.indices.value;
|
|
15079
|
-
return device.createBuffer({ usage:
|
|
15963
|
+
return device.createBuffer({ usage: import_core17.Buffer.INDEX, data });
|
|
15080
15964
|
}
|
|
15081
15965
|
function getAttributeBuffersFromGeometry(device, geometry) {
|
|
15082
15966
|
const attributes = {};
|
|
@@ -15116,7 +16000,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15116
16000
|
};
|
|
15117
16001
|
|
|
15118
16002
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
15119
|
-
var
|
|
16003
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
15120
16004
|
function makeGPUVectorGeometry(device, geometry) {
|
|
15121
16005
|
const gpuGeometry = makeGPUGeometry(device, geometry);
|
|
15122
16006
|
try {
|
|
@@ -15133,7 +16017,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15133
16017
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|
|
15134
16018
|
const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
|
|
15135
16019
|
const format = bufferLayout?.format;
|
|
15136
|
-
const byteStride2 = bufferLayout?.byteStride ?? (format ?
|
|
16020
|
+
const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core18.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
|
|
15137
16021
|
const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
|
|
15138
16022
|
attributes[name] = {
|
|
15139
16023
|
name,
|
|
@@ -15296,7 +16180,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15296
16180
|
};
|
|
15297
16181
|
|
|
15298
16182
|
// src/material/material.ts
|
|
15299
|
-
var
|
|
16183
|
+
var import_core19 = __toESM(require_core(), 1);
|
|
15300
16184
|
|
|
15301
16185
|
// src/material/material-factory.ts
|
|
15302
16186
|
var MATERIAL_BIND_GROUP = 3;
|
|
@@ -15400,7 +16284,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15400
16284
|
])
|
|
15401
16285
|
);
|
|
15402
16286
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
15403
|
-
this._uniformStore = new
|
|
16287
|
+
this._uniformStore = new import_core19.UniformStore(this.device, this.shaderInputs.modules);
|
|
15404
16288
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
15405
16289
|
if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
|
|
15406
16290
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -15515,9 +16399,9 @@ ${declarations.join("\n")}`).match(
|
|
|
15515
16399
|
getBindingsUpdateTimestamp() {
|
|
15516
16400
|
let timestamp = 0;
|
|
15517
16401
|
for (const binding of Object.values(this.bindings)) {
|
|
15518
|
-
if (binding instanceof
|
|
16402
|
+
if (binding instanceof import_core19.TextureView) {
|
|
15519
16403
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
15520
|
-
} else if (binding instanceof
|
|
16404
|
+
} else if (binding instanceof import_core19.Buffer || binding instanceof import_core19.Texture || binding instanceof import_core19.ExternalTexture) {
|
|
15521
16405
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
15522
16406
|
} else if (binding instanceof DynamicBuffer) {
|
|
15523
16407
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -15585,7 +16469,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15585
16469
|
}
|
|
15586
16470
|
|
|
15587
16471
|
// src/compute/buffer-transform.ts
|
|
15588
|
-
var
|
|
16472
|
+
var import_core20 = __toESM(require_core(), 1);
|
|
15589
16473
|
var import_shaders4 = __toESM(require_shaders(), 1);
|
|
15590
16474
|
var GL_INTERLEAVED_ATTRIBS = 35980;
|
|
15591
16475
|
var GL_SEPARATE_ATTRIBS = 35981;
|
|
@@ -15659,14 +16543,14 @@ ${declarations.join("\n")}`).match(
|
|
|
15659
16543
|
/** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
|
|
15660
16544
|
setOutputVectors(vectors) {
|
|
15661
16545
|
const batches = getGPUVectorModelBatches(this.model.id, vectors);
|
|
15662
|
-
(0,
|
|
15663
|
-
(0,
|
|
16546
|
+
(0, import_core20.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
|
|
16547
|
+
(0, import_core20.assert)(batches.length <= 1);
|
|
15664
16548
|
this.outputVectorBindings = vectors;
|
|
15665
16549
|
this.transformFeedback.setBuffers({
|
|
15666
16550
|
...this.outputBuffers,
|
|
15667
16551
|
...Object.fromEntries(
|
|
15668
16552
|
Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
|
|
15669
|
-
(0,
|
|
16553
|
+
(0, import_core20.assert)(data.byteStride === data.rowByteLength);
|
|
15670
16554
|
return [
|
|
15671
16555
|
name,
|
|
15672
16556
|
{
|
|
@@ -15690,7 +16574,7 @@ ${declarations.join("\n")}`).match(
|
|
|
15690
16574
|
if (!result) {
|
|
15691
16575
|
throw new Error("BufferTransform#getBuffer");
|
|
15692
16576
|
}
|
|
15693
|
-
if (result instanceof
|
|
16577
|
+
if (result instanceof import_core20.Buffer) {
|
|
15694
16578
|
return result.readAsync();
|
|
15695
16579
|
}
|
|
15696
16580
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
@@ -16601,204 +17485,40 @@ void main(void) {
|
|
|
16601
17485
|
};
|
|
16602
17486
|
|
|
16603
17487
|
// src/models/spot-light-model.ts
|
|
16604
|
-
var SPOT_LIGHT_GEOMETRY = new ConeGeometry({
|
|
16605
|
-
cap: true,
|
|
16606
|
-
nradial: 16,
|
|
16607
|
-
nvertical: 1,
|
|
16608
|
-
radius: 1
|
|
16609
|
-
});
|
|
16610
|
-
var SpotLightModel = class extends BaseLightModel {
|
|
16611
|
-
constructor(device, props) {
|
|
16612
|
-
super(device, props, {
|
|
16613
|
-
anchorMode: "apex",
|
|
16614
|
-
buildInstanceData: buildSpotLightInstanceData,
|
|
16615
|
-
geometry: SPOT_LIGHT_GEOMETRY,
|
|
16616
|
-
idPrefix: "spot-light-model",
|
|
16617
|
-
sizePropNames: ["spotLightLength"]
|
|
16618
|
-
});
|
|
16619
|
-
}
|
|
16620
|
-
};
|
|
16621
|
-
|
|
16622
|
-
// src/models/directional-light-model.ts
|
|
16623
|
-
var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry({
|
|
16624
|
-
cap: true,
|
|
16625
|
-
nradial: 12,
|
|
16626
|
-
nvertical: 1,
|
|
16627
|
-
radius: 1
|
|
16628
|
-
});
|
|
16629
|
-
var DirectionalLightModel = class extends BaseLightModel {
|
|
16630
|
-
constructor(device, props) {
|
|
16631
|
-
super(device, props, {
|
|
16632
|
-
anchorMode: "apex",
|
|
16633
|
-
buildInstanceData: buildDirectionalLightInstanceData,
|
|
16634
|
-
geometry: DIRECTIONAL_LIGHT_GEOMETRY,
|
|
16635
|
-
idPrefix: "directional-light-model",
|
|
16636
|
-
sizePropNames: ["directionalLightLength"]
|
|
16637
|
-
});
|
|
16638
|
-
}
|
|
16639
|
-
};
|
|
16640
|
-
|
|
16641
|
-
// src/scenegraph/scenegraph-node.ts
|
|
16642
|
-
function assert11(condition, message) {
|
|
16643
|
-
if (!condition) {
|
|
16644
|
-
throw new Error(message);
|
|
16645
|
-
}
|
|
16646
|
-
}
|
|
16647
|
-
var ScenegraphNode = class {
|
|
16648
|
-
id;
|
|
16649
|
-
matrix = new Matrix4();
|
|
16650
|
-
display = true;
|
|
16651
|
-
/** Local selection eligibility, independent of visibility. */
|
|
16652
|
-
selectable = true;
|
|
16653
|
-
/** Local hover eligibility, independent of visibility. */
|
|
16654
|
-
hoverable = true;
|
|
16655
|
-
position = new Vector3();
|
|
16656
|
-
rotation = new Vector3();
|
|
16657
|
-
scale = new Vector3(1, 1, 1);
|
|
16658
|
-
/** Structured metadata associated with this scene node. */
|
|
16659
|
-
metadata = {};
|
|
16660
|
-
userData = {};
|
|
16661
|
-
props = {};
|
|
16662
|
-
constructor(props = {}) {
|
|
16663
|
-
const { id } = props;
|
|
16664
|
-
this.id = id || uid(this.constructor.name);
|
|
16665
|
-
this._setScenegraphNodeProps(props);
|
|
16666
|
-
}
|
|
16667
|
-
getBounds() {
|
|
16668
|
-
return null;
|
|
16669
|
-
}
|
|
16670
|
-
destroy() {
|
|
16671
|
-
}
|
|
16672
|
-
/** @deprecated use .destroy() */
|
|
16673
|
-
delete() {
|
|
16674
|
-
this.destroy();
|
|
16675
|
-
}
|
|
16676
|
-
setProps(props) {
|
|
16677
|
-
this._setScenegraphNodeProps(props);
|
|
16678
|
-
return this;
|
|
16679
|
-
}
|
|
16680
|
-
toString() {
|
|
16681
|
-
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
16682
|
-
}
|
|
16683
|
-
setPosition(position) {
|
|
16684
|
-
assert11(position.length === 3, "setPosition requires vector argument");
|
|
16685
|
-
this.position = position;
|
|
16686
|
-
return this;
|
|
16687
|
-
}
|
|
16688
|
-
setRotation(rotation) {
|
|
16689
|
-
assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
16690
|
-
this.rotation = rotation;
|
|
16691
|
-
return this;
|
|
16692
|
-
}
|
|
16693
|
-
setScale(scale5) {
|
|
16694
|
-
assert11(scale5.length === 3, "setScale requires vector argument");
|
|
16695
|
-
this.scale = scale5;
|
|
16696
|
-
return this;
|
|
16697
|
-
}
|
|
16698
|
-
setMatrix(matrix, copyMatrix = true) {
|
|
16699
|
-
if (copyMatrix) {
|
|
16700
|
-
this.matrix.copy(matrix);
|
|
16701
|
-
} else {
|
|
16702
|
-
this.matrix = matrix;
|
|
16703
|
-
}
|
|
16704
|
-
}
|
|
16705
|
-
setMatrixComponents(components2) {
|
|
16706
|
-
const { position, rotation, scale: scale5, update = true } = components2;
|
|
16707
|
-
if (position) {
|
|
16708
|
-
this.setPosition(position);
|
|
16709
|
-
}
|
|
16710
|
-
if (rotation) {
|
|
16711
|
-
this.setRotation(rotation);
|
|
16712
|
-
}
|
|
16713
|
-
if (scale5) {
|
|
16714
|
-
this.setScale(scale5);
|
|
16715
|
-
}
|
|
16716
|
-
if (update) {
|
|
16717
|
-
this.updateMatrix();
|
|
16718
|
-
}
|
|
16719
|
-
return this;
|
|
16720
|
-
}
|
|
16721
|
-
updateMatrix() {
|
|
16722
|
-
this.matrix.identity();
|
|
16723
|
-
this.matrix.translate(this.position);
|
|
16724
|
-
if (this.rotation.length === 4) {
|
|
16725
|
-
const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
|
|
16726
|
-
this.matrix.multiplyRight(rotationMatrix);
|
|
16727
|
-
} else {
|
|
16728
|
-
this.matrix.rotateXYZ(this.rotation);
|
|
16729
|
-
}
|
|
16730
|
-
this.matrix.scale(this.scale);
|
|
16731
|
-
return this;
|
|
16732
|
-
}
|
|
16733
|
-
update({ position, rotation, scale: scale5 } = {}) {
|
|
16734
|
-
if (position) {
|
|
16735
|
-
this.setPosition(position);
|
|
16736
|
-
}
|
|
16737
|
-
if (rotation) {
|
|
16738
|
-
this.setRotation(rotation);
|
|
16739
|
-
}
|
|
16740
|
-
if (scale5) {
|
|
16741
|
-
this.setScale(scale5);
|
|
16742
|
-
}
|
|
16743
|
-
this.updateMatrix();
|
|
16744
|
-
return this;
|
|
16745
|
-
}
|
|
16746
|
-
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
16747
|
-
modelMatrix = modelMatrix || this.matrix;
|
|
16748
|
-
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
16749
|
-
const worldInverse = worldMatrix.invert();
|
|
16750
|
-
const worldInverseTranspose = worldInverse.transpose();
|
|
16751
|
-
return {
|
|
16752
|
-
viewMatrix,
|
|
16753
|
-
modelMatrix,
|
|
16754
|
-
objectMatrix: modelMatrix,
|
|
16755
|
-
worldMatrix,
|
|
16756
|
-
worldInverseMatrix: worldInverse,
|
|
16757
|
-
worldInverseTransposeMatrix: worldInverseTranspose
|
|
16758
|
-
};
|
|
17488
|
+
var SPOT_LIGHT_GEOMETRY = new ConeGeometry({
|
|
17489
|
+
cap: true,
|
|
17490
|
+
nradial: 16,
|
|
17491
|
+
nvertical: 1,
|
|
17492
|
+
radius: 1
|
|
17493
|
+
});
|
|
17494
|
+
var SpotLightModel = class extends BaseLightModel {
|
|
17495
|
+
constructor(device, props) {
|
|
17496
|
+
super(device, props, {
|
|
17497
|
+
anchorMode: "apex",
|
|
17498
|
+
buildInstanceData: buildSpotLightInstanceData,
|
|
17499
|
+
geometry: SPOT_LIGHT_GEOMETRY,
|
|
17500
|
+
idPrefix: "spot-light-model",
|
|
17501
|
+
sizePropNames: ["spotLightLength"]
|
|
17502
|
+
});
|
|
16759
17503
|
}
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
|
|
16766
|
-
|
|
16767
|
-
|
|
16768
|
-
|
|
16769
|
-
|
|
16770
|
-
|
|
16771
|
-
|
|
16772
|
-
|
|
16773
|
-
|
|
16774
|
-
|
|
16775
|
-
|
|
16776
|
-
|
|
16777
|
-
|
|
16778
|
-
|
|
16779
|
-
return this;
|
|
16780
|
-
}
|
|
16781
|
-
*/
|
|
16782
|
-
_setScenegraphNodeProps(props) {
|
|
16783
|
-
if (props.selectable !== void 0) this.selectable = props.selectable;
|
|
16784
|
-
if (props.hoverable !== void 0) this.hoverable = props.hoverable;
|
|
16785
|
-
if (props.display !== void 0) {
|
|
16786
|
-
this.display = props.display;
|
|
16787
|
-
}
|
|
16788
|
-
if (props?.position) {
|
|
16789
|
-
this.setPosition(props.position);
|
|
16790
|
-
}
|
|
16791
|
-
if (props?.rotation) {
|
|
16792
|
-
this.setRotation(props.rotation);
|
|
16793
|
-
}
|
|
16794
|
-
if (props?.scale) {
|
|
16795
|
-
this.setScale(props.scale);
|
|
16796
|
-
}
|
|
16797
|
-
this.updateMatrix();
|
|
16798
|
-
if (props?.matrix) {
|
|
16799
|
-
this.setMatrix(props.matrix);
|
|
16800
|
-
}
|
|
16801
|
-
Object.assign(this.props, props);
|
|
17504
|
+
};
|
|
17505
|
+
|
|
17506
|
+
// src/models/directional-light-model.ts
|
|
17507
|
+
var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry({
|
|
17508
|
+
cap: true,
|
|
17509
|
+
nradial: 12,
|
|
17510
|
+
nvertical: 1,
|
|
17511
|
+
radius: 1
|
|
17512
|
+
});
|
|
17513
|
+
var DirectionalLightModel = class extends BaseLightModel {
|
|
17514
|
+
constructor(device, props) {
|
|
17515
|
+
super(device, props, {
|
|
17516
|
+
anchorMode: "apex",
|
|
17517
|
+
buildInstanceData: buildDirectionalLightInstanceData,
|
|
17518
|
+
geometry: DIRECTIONAL_LIGHT_GEOMETRY,
|
|
17519
|
+
idPrefix: "directional-light-model",
|
|
17520
|
+
sizePropNames: ["directionalLightLength"]
|
|
17521
|
+
});
|
|
16802
17522
|
}
|
|
16803
17523
|
};
|
|
16804
17524
|
|
|
@@ -16874,201 +17594,15 @@ void main(void) {
|
|
|
16874
17594
|
/** Associates metadata with a resource category and its source index. */
|
|
16875
17595
|
set(category, index, metadata) {
|
|
16876
17596
|
let categoryEntries = this.entries.get(category);
|
|
16877
|
-
if (!categoryEntries) {
|
|
16878
|
-
categoryEntries = /* @__PURE__ */ new Map();
|
|
16879
|
-
this.entries.set(category, categoryEntries);
|
|
16880
|
-
}
|
|
16881
|
-
categoryEntries.set(index, metadata);
|
|
16882
|
-
}
|
|
16883
|
-
/** Returns metadata for a resource, or undefined when none was supplied. */
|
|
16884
|
-
get(category, index = 0) {
|
|
16885
|
-
return this.entries.get(category)?.get(index);
|
|
16886
|
-
}
|
|
16887
|
-
};
|
|
16888
|
-
|
|
16889
|
-
// src/scenegraph/group-node.ts
|
|
16890
|
-
var import_core18 = __toESM(require_core(), 1);
|
|
16891
|
-
|
|
16892
|
-
// src/scenegraph/scenegraph-bounds.ts
|
|
16893
|
-
function makeEmptyScenegraphBounds() {
|
|
16894
|
-
return [
|
|
16895
|
-
[Infinity, Infinity, Infinity],
|
|
16896
|
-
[-Infinity, -Infinity, -Infinity]
|
|
16897
|
-
];
|
|
16898
|
-
}
|
|
16899
|
-
function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
|
|
16900
|
-
const transformMatrix = new Matrix4(transform);
|
|
16901
|
-
for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
|
|
16902
|
-
const corner = new Vector3(
|
|
16903
|
-
sourceBounds[cornerIndex & 1 ? 1 : 0][0],
|
|
16904
|
-
sourceBounds[cornerIndex & 2 ? 1 : 0][1],
|
|
16905
|
-
sourceBounds[cornerIndex & 4 ? 1 : 0][2]
|
|
16906
|
-
);
|
|
16907
|
-
transformMatrix.transformAsPoint(corner, corner);
|
|
16908
|
-
for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
|
|
16909
|
-
targetBounds[0][componentIndex] = Math.min(
|
|
16910
|
-
targetBounds[0][componentIndex],
|
|
16911
|
-
corner[componentIndex]
|
|
16912
|
-
);
|
|
16913
|
-
targetBounds[1][componentIndex] = Math.max(
|
|
16914
|
-
targetBounds[1][componentIndex],
|
|
16915
|
-
corner[componentIndex]
|
|
16916
|
-
);
|
|
16917
|
-
}
|
|
16918
|
-
}
|
|
16919
|
-
}
|
|
16920
|
-
function areScenegraphBoundsDefined(bounds) {
|
|
16921
|
-
return Number.isFinite(bounds[0][0]);
|
|
16922
|
-
}
|
|
16923
|
-
|
|
16924
|
-
// src/scenegraph/group-node.ts
|
|
16925
|
-
var GroupNode = class _GroupNode extends ScenegraphNode {
|
|
16926
|
-
children;
|
|
16927
|
-
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
16928
|
-
transformSource;
|
|
16929
|
-
constructor(props = {}) {
|
|
16930
|
-
props = Array.isArray(props) ? { children: props } : props;
|
|
16931
|
-
const { children = [] } = props;
|
|
16932
|
-
import_core18.log.assert(
|
|
16933
|
-
children.every((child) => child instanceof ScenegraphNode),
|
|
16934
|
-
"every child must an instance of ScenegraphNode"
|
|
16935
|
-
);
|
|
16936
|
-
super(props);
|
|
16937
|
-
this.children = children;
|
|
16938
|
-
this.transformSource = props.transformSource ?? null;
|
|
16939
|
-
}
|
|
16940
|
-
getBounds() {
|
|
16941
|
-
const result = makeEmptyScenegraphBounds();
|
|
16942
|
-
this.traverse((node, { worldMatrix }) => {
|
|
16943
|
-
const bounds = node.getBounds();
|
|
16944
|
-
if (!bounds) {
|
|
16945
|
-
return;
|
|
16946
|
-
}
|
|
16947
|
-
const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
|
|
16948
|
-
expandScenegraphBounds(result, bounds, nodeWorldMatrix);
|
|
16949
|
-
});
|
|
16950
|
-
return areScenegraphBoundsDefined(result) ? result : null;
|
|
16951
|
-
}
|
|
16952
|
-
destroy() {
|
|
16953
|
-
this.children.forEach((child) => child.destroy());
|
|
16954
|
-
this.removeAll();
|
|
16955
|
-
super.destroy();
|
|
16956
|
-
}
|
|
16957
|
-
// Unpacks arrays and nested arrays of children
|
|
16958
|
-
add(...children) {
|
|
16959
|
-
for (const child of children) {
|
|
16960
|
-
if (Array.isArray(child)) {
|
|
16961
|
-
this.add(...child);
|
|
16962
|
-
} else {
|
|
16963
|
-
this.children.push(child);
|
|
16964
|
-
}
|
|
16965
|
-
}
|
|
16966
|
-
return this;
|
|
16967
|
-
}
|
|
16968
|
-
remove(child) {
|
|
16969
|
-
const children = this.children;
|
|
16970
|
-
const indexOf = children.indexOf(child);
|
|
16971
|
-
if (indexOf > -1) {
|
|
16972
|
-
children.splice(indexOf, 1);
|
|
16973
|
-
}
|
|
16974
|
-
return this;
|
|
16975
|
-
}
|
|
16976
|
-
removeAll() {
|
|
16977
|
-
this.children = [];
|
|
16978
|
-
return this;
|
|
16979
|
-
}
|
|
16980
|
-
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
16981
|
-
findNode(path) {
|
|
16982
|
-
const matches = this.findNodes(path);
|
|
16983
|
-
if (matches.length > 1) {
|
|
16984
|
-
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
16985
|
-
}
|
|
16986
|
-
return matches[0];
|
|
16987
|
-
}
|
|
16988
|
-
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
16989
|
-
findNodes(path) {
|
|
16990
|
-
const anchored = path.startsWith("/");
|
|
16991
|
-
const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
|
|
16992
|
-
if (!segment || /~(?![01])/.test(segment)) {
|
|
16993
|
-
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
16994
|
-
}
|
|
16995
|
-
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
16996
|
-
});
|
|
16997
|
-
const matches = [];
|
|
16998
|
-
const ancestors = [];
|
|
16999
|
-
const visited = /* @__PURE__ */ new Set();
|
|
17000
|
-
const pending = [{ node: this, depth: 0 }];
|
|
17001
|
-
while (pending.length) {
|
|
17002
|
-
const { node, depth } = pending.pop();
|
|
17003
|
-
(0, import_core18.assert)(!visited.has(node));
|
|
17004
|
-
visited.add(node);
|
|
17005
|
-
ancestors.length = depth;
|
|
17006
|
-
ancestors.push(node.id);
|
|
17007
|
-
const offset = ancestors.length - segments.length;
|
|
17008
|
-
if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
|
|
17009
|
-
matches.push(node);
|
|
17010
|
-
}
|
|
17011
|
-
if (node instanceof _GroupNode) {
|
|
17012
|
-
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
17013
|
-
pending.push({ node: node.children[index], depth: depth + 1 });
|
|
17014
|
-
}
|
|
17015
|
-
}
|
|
17016
|
-
}
|
|
17017
|
-
return matches;
|
|
17018
|
-
}
|
|
17019
|
-
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
17020
|
-
if (!this.display) {
|
|
17021
|
-
return;
|
|
17022
|
-
}
|
|
17023
|
-
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
17024
|
-
for (const child of this.children) {
|
|
17025
|
-
if (!child.display) {
|
|
17026
|
-
continue;
|
|
17027
|
-
}
|
|
17028
|
-
if (child instanceof _GroupNode) {
|
|
17029
|
-
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
17030
|
-
} else {
|
|
17031
|
-
visitor(child, { worldMatrix: modelMatrix });
|
|
17032
|
-
}
|
|
17033
|
-
}
|
|
17034
|
-
}
|
|
17035
|
-
/** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
|
|
17036
|
-
traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
|
|
17037
|
-
const cameraMatrix = new Matrix4(viewMatrix);
|
|
17038
|
-
const nodes = [];
|
|
17039
|
-
this.traverse(
|
|
17040
|
-
(node, context) => {
|
|
17041
|
-
const bounds = node.getBounds();
|
|
17042
|
-
const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
|
|
17043
|
-
const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
|
|
17044
|
-
nodeWorldMatrix.transformAsPoint(center, center);
|
|
17045
|
-
cameraMatrix.transformAsPoint(center, center);
|
|
17046
|
-
nodes.push({
|
|
17047
|
-
node,
|
|
17048
|
-
context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
|
|
17049
|
-
index: nodes.length
|
|
17050
|
-
});
|
|
17051
|
-
},
|
|
17052
|
-
{ worldMatrix: new Matrix4(worldMatrix) }
|
|
17053
|
-
);
|
|
17054
|
-
const direction = order === "back-to-front" ? -1 : 1;
|
|
17055
|
-
nodes.sort(
|
|
17056
|
-
(first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
|
|
17057
|
-
);
|
|
17058
|
-
for (const { node, context } of nodes) {
|
|
17059
|
-
visitor(node, context);
|
|
17597
|
+
if (!categoryEntries) {
|
|
17598
|
+
categoryEntries = /* @__PURE__ */ new Map();
|
|
17599
|
+
this.entries.set(category, categoryEntries);
|
|
17060
17600
|
}
|
|
17601
|
+
categoryEntries.set(index, metadata);
|
|
17061
17602
|
}
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
for (const child of this.children) {
|
|
17066
|
-
if (child instanceof _GroupNode) {
|
|
17067
|
-
child.preorderTraversal(visitor, { worldMatrix: modelMatrix });
|
|
17068
|
-
} else {
|
|
17069
|
-
visitor(child, { worldMatrix: modelMatrix });
|
|
17070
|
-
}
|
|
17071
|
-
}
|
|
17603
|
+
/** Returns metadata for a resource, or undefined when none was supplied. */
|
|
17604
|
+
get(category, index = 0) {
|
|
17605
|
+
return this.entries.get(category)?.get(index);
|
|
17072
17606
|
}
|
|
17073
17607
|
};
|
|
17074
17608
|
|
|
@@ -17093,55 +17627,13 @@ void main(void) {
|
|
|
17093
17627
|
}
|
|
17094
17628
|
};
|
|
17095
17629
|
|
|
17096
|
-
// src/scenegraph/model-node.ts
|
|
17097
|
-
var ModelNode = class extends ScenegraphNode {
|
|
17098
|
-
model;
|
|
17099
|
-
instanceMatrices;
|
|
17100
|
-
bounds = null;
|
|
17101
|
-
managedResources;
|
|
17102
|
-
// TODO - is this used? override callbacks to make sure we call them with this
|
|
17103
|
-
// onBeforeRender = null;
|
|
17104
|
-
// onAfterRender = null;
|
|
17105
|
-
// AfterRender = null;
|
|
17106
|
-
constructor(props) {
|
|
17107
|
-
super(props);
|
|
17108
|
-
this.model = props.model;
|
|
17109
|
-
this.managedResources = props.managedResources || [];
|
|
17110
|
-
this.instanceMatrices = props.instanceMatrices || null;
|
|
17111
|
-
this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
|
|
17112
|
-
this.setProps(props);
|
|
17113
|
-
}
|
|
17114
|
-
destroy() {
|
|
17115
|
-
if (this.model) {
|
|
17116
|
-
this.model.destroy();
|
|
17117
|
-
this.model = null;
|
|
17118
|
-
}
|
|
17119
|
-
this.managedResources.forEach((resource) => resource.destroy());
|
|
17120
|
-
this.managedResources = [];
|
|
17121
|
-
}
|
|
17122
|
-
getBounds() {
|
|
17123
|
-
return this.bounds;
|
|
17124
|
-
}
|
|
17125
|
-
// Expose model methods
|
|
17126
|
-
draw(renderPass) {
|
|
17127
|
-
return this.model.draw(renderPass);
|
|
17128
|
-
}
|
|
17129
|
-
};
|
|
17130
|
-
function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
17131
|
-
const instancedBounds = makeEmptyScenegraphBounds();
|
|
17132
|
-
for (const instanceMatrix of instanceMatrices) {
|
|
17133
|
-
expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
|
|
17134
|
-
}
|
|
17135
|
-
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
17136
|
-
}
|
|
17137
|
-
|
|
17138
17630
|
// src/geometry/edge-geometry.ts
|
|
17139
|
-
var
|
|
17631
|
+
var import_core21 = __toESM(require_core(), 1);
|
|
17140
17632
|
function makeEdgeGeometry(geometry, options = {}) {
|
|
17141
17633
|
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
17142
17634
|
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
17143
|
-
(0,
|
|
17144
|
-
(0,
|
|
17635
|
+
(0, import_core21.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
17636
|
+
(0, import_core21.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
17145
17637
|
const sourceIndices = geometry.indices?.value;
|
|
17146
17638
|
const sourceCount = positions.value.length / 3;
|
|
17147
17639
|
const representatives = /* @__PURE__ */ new Map();
|
|
@@ -17160,9 +17652,9 @@ void main(void) {
|
|
|
17160
17652
|
function weldPosition(index) {
|
|
17161
17653
|
const cached = representatives.get(index);
|
|
17162
17654
|
if (cached !== void 0) return cached;
|
|
17163
|
-
(0,
|
|
17655
|
+
(0, import_core21.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
17164
17656
|
const position = readPosition(index);
|
|
17165
|
-
(0,
|
|
17657
|
+
(0, import_core21.assert)(position.every(Number.isFinite));
|
|
17166
17658
|
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
17167
17659
|
const radius = weldTolerance > 0 ? 1 : 0;
|
|
17168
17660
|
for (let east = -radius; east <= radius; east++) {
|
|
@@ -17236,11 +17728,11 @@ void main(void) {
|
|
|
17236
17728
|
});
|
|
17237
17729
|
}
|
|
17238
17730
|
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
17239
|
-
(0,
|
|
17731
|
+
(0, import_core21.assert)(geometries.length > 0);
|
|
17240
17732
|
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
17241
17733
|
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
17242
17734
|
const firstAttribute = attributes[0];
|
|
17243
|
-
(0,
|
|
17735
|
+
(0, import_core21.assert)(
|
|
17244
17736
|
attributes.every(
|
|
17245
17737
|
(attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
|
|
17246
17738
|
)
|
|
@@ -17259,7 +17751,7 @@ void main(void) {
|
|
|
17259
17751
|
positions.set(attribute.value, positionOffset);
|
|
17260
17752
|
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
17261
17753
|
const index = geometry.indices?.value[offset] ?? offset;
|
|
17262
|
-
(0,
|
|
17754
|
+
(0, import_core21.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
17263
17755
|
indices[indexOffset++] = index + positionOffset / 3;
|
|
17264
17756
|
}
|
|
17265
17757
|
positionOffset += attribute.value.length;
|
|
@@ -17276,26 +17768,26 @@ void main(void) {
|
|
|
17276
17768
|
}
|
|
17277
17769
|
function getTrianglePositions(geometry, positionAttribute) {
|
|
17278
17770
|
const positions = geometry.attributes[positionAttribute];
|
|
17279
|
-
(0,
|
|
17280
|
-
(0,
|
|
17281
|
-
(0,
|
|
17771
|
+
(0, import_core21.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
|
|
17772
|
+
(0, import_core21.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
17773
|
+
(0, import_core21.assert)(
|
|
17282
17774
|
!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
|
|
17283
17775
|
);
|
|
17284
|
-
(0,
|
|
17776
|
+
(0, import_core21.assert)(
|
|
17285
17777
|
geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
|
|
17286
17778
|
);
|
|
17287
17779
|
return positions;
|
|
17288
17780
|
}
|
|
17289
17781
|
|
|
17290
17782
|
// src/geometry/stroke-geometry.ts
|
|
17291
|
-
var
|
|
17783
|
+
var import_core22 = __toESM(require_core(), 1);
|
|
17292
17784
|
function makeStrokeGeometry(path, options = {}) {
|
|
17293
17785
|
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
17294
|
-
(0,
|
|
17295
|
-
(0,
|
|
17786
|
+
(0, import_core22.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
17787
|
+
(0, import_core22.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
17296
17788
|
const points = [];
|
|
17297
17789
|
for (const position of path) {
|
|
17298
|
-
(0,
|
|
17790
|
+
(0, import_core22.assert)(
|
|
17299
17791
|
Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
|
|
17300
17792
|
);
|
|
17301
17793
|
const previous = points.at(-1);
|
|
@@ -17455,12 +17947,12 @@ void main(void) {
|
|
|
17455
17947
|
}
|
|
17456
17948
|
|
|
17457
17949
|
// src/geometry/mesh-simplification.ts
|
|
17458
|
-
var
|
|
17950
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
17459
17951
|
var QUADRIC_COMPONENTS = 10;
|
|
17460
17952
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
17461
17953
|
function simplifyMesh(options) {
|
|
17462
17954
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
17463
|
-
(0,
|
|
17955
|
+
(0, import_core23.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
17464
17956
|
const targetIndexCount = Math.max(
|
|
17465
17957
|
0,
|
|
17466
17958
|
Math.min(
|
|
@@ -17553,7 +18045,7 @@ void main(void) {
|
|
|
17553
18045
|
const firstVertex = indices[indexOffset2];
|
|
17554
18046
|
const secondVertex = indices[indexOffset2 + 1];
|
|
17555
18047
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
17556
|
-
(0,
|
|
18048
|
+
(0, import_core23.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
17557
18049
|
const triangle = {
|
|
17558
18050
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
17559
18051
|
active: false
|
|
@@ -17888,7 +18380,7 @@ void main(void) {
|
|
|
17888
18380
|
}
|
|
17889
18381
|
|
|
17890
18382
|
// src/dynamic-texture/video-texture.ts
|
|
17891
|
-
var
|
|
18383
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
17892
18384
|
var VideoTexture = class {
|
|
17893
18385
|
/** Device used to create copied and native external texture bindings. */
|
|
17894
18386
|
device;
|
|
@@ -17937,7 +18429,7 @@ void main(void) {
|
|
|
17937
18429
|
* @param props Live video source and copied texture options.
|
|
17938
18430
|
*/
|
|
17939
18431
|
constructor(device, props) {
|
|
17940
|
-
(0,
|
|
18432
|
+
(0, import_core24.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
17941
18433
|
this.device = device;
|
|
17942
18434
|
this.id = props.id || uid("video-texture");
|
|
17943
18435
|
this._source = props.source;
|
|
@@ -17951,7 +18443,7 @@ void main(void) {
|
|
|
17951
18443
|
* @param source Next caller-owned video source to follow.
|
|
17952
18444
|
*/
|
|
17953
18445
|
setSource(source4) {
|
|
17954
|
-
(0,
|
|
18446
|
+
(0, import_core24.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
17955
18447
|
this._destroyExternalTexture();
|
|
17956
18448
|
this._source = source4;
|
|
17957
18449
|
this._sourceVersion++;
|
|
@@ -18029,7 +18521,7 @@ void main(void) {
|
|
|
18029
18521
|
width: size.width,
|
|
18030
18522
|
height: size.height,
|
|
18031
18523
|
format: "rgba8unorm",
|
|
18032
|
-
usage:
|
|
18524
|
+
usage: import_core24.Texture.SAMPLE | import_core24.Texture.COPY_DST,
|
|
18033
18525
|
mipLevels: 1,
|
|
18034
18526
|
sampler: this._sampler
|
|
18035
18527
|
});
|
|
@@ -18064,7 +18556,7 @@ void main(void) {
|
|
|
18064
18556
|
*/
|
|
18065
18557
|
_getResolvedSize() {
|
|
18066
18558
|
const size = getVideoTextureSourceSize(this._source);
|
|
18067
|
-
(0,
|
|
18559
|
+
(0, import_core24.assert)(size.width > 0 && size.height > 0);
|
|
18068
18560
|
return size;
|
|
18069
18561
|
}
|
|
18070
18562
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -18129,11 +18621,11 @@ void main(void) {
|
|
|
18129
18621
|
}
|
|
18130
18622
|
|
|
18131
18623
|
// src/passes/shader-pass-renderer.ts
|
|
18132
|
-
var
|
|
18624
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
18133
18625
|
var import_shaders7 = __toESM(require_shaders(), 1);
|
|
18134
18626
|
|
|
18135
18627
|
// src/compute/swap.ts
|
|
18136
|
-
var
|
|
18628
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
18137
18629
|
var Swap = class {
|
|
18138
18630
|
id;
|
|
18139
18631
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -18165,7 +18657,7 @@ void main(void) {
|
|
|
18165
18657
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
18166
18658
|
id: `${props.id}-texture-0`,
|
|
18167
18659
|
format: colorAttachment,
|
|
18168
|
-
usage:
|
|
18660
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
|
|
18169
18661
|
width,
|
|
18170
18662
|
height
|
|
18171
18663
|
})
|
|
@@ -18175,7 +18667,7 @@ void main(void) {
|
|
|
18175
18667
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
18176
18668
|
id: `${props.id}-texture-1`,
|
|
18177
18669
|
format: colorAttachment,
|
|
18178
|
-
usage:
|
|
18670
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
|
|
18179
18671
|
width,
|
|
18180
18672
|
height
|
|
18181
18673
|
})
|
|
@@ -18239,7 +18731,7 @@ void main(void) {
|
|
|
18239
18731
|
};
|
|
18240
18732
|
|
|
18241
18733
|
// src/compute/computation.ts
|
|
18242
|
-
var
|
|
18734
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
18243
18735
|
var import_shaders6 = __toESM(require_shaders(), 1);
|
|
18244
18736
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
18245
18737
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -18251,13 +18743,13 @@ void main(void) {
|
|
|
18251
18743
|
* constructor remains the synchronous compatibility path.
|
|
18252
18744
|
*/
|
|
18253
18745
|
static async createAsync(device, props) {
|
|
18254
|
-
const ownsCompilation = !
|
|
18255
|
-
const asyncCompilation = ownsCompilation ?
|
|
18746
|
+
const ownsCompilation = !import_core26.PipelineFactory.getAsyncCompilation(device);
|
|
18747
|
+
const asyncCompilation = ownsCompilation ? import_core26.PipelineFactory.beginAsyncCompilation(device) : import_core26.PipelineFactory.getAsyncCompilation(device);
|
|
18256
18748
|
let computation;
|
|
18257
18749
|
try {
|
|
18258
18750
|
computation = new _Computation(device, props);
|
|
18259
18751
|
} finally {
|
|
18260
|
-
if (ownsCompilation)
|
|
18752
|
+
if (ownsCompilation) import_core26.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
18261
18753
|
}
|
|
18262
18754
|
try {
|
|
18263
18755
|
if (ownsCompilation) {
|
|
@@ -18272,7 +18764,7 @@ void main(void) {
|
|
|
18272
18764
|
}
|
|
18273
18765
|
}
|
|
18274
18766
|
static defaultProps = {
|
|
18275
|
-
...
|
|
18767
|
+
...import_core26.ComputePipeline.defaultProps,
|
|
18276
18768
|
id: "unnamed",
|
|
18277
18769
|
handle: void 0,
|
|
18278
18770
|
userData: {},
|
|
@@ -18347,10 +18839,10 @@ void main(void) {
|
|
|
18347
18839
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
18348
18840
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
18349
18841
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
18350
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
18351
|
-
this.shaderFactory = props.shaderFactory ||
|
|
18842
|
+
this.pipelineFactory = props.pipelineFactory || import_core26.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
18843
|
+
this.shaderFactory = props.shaderFactory || import_core26.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
18352
18844
|
const shaderAssembler = this.props.shaderAssembler;
|
|
18353
|
-
(0,
|
|
18845
|
+
(0, import_core26.assert)(shaderAssembler instanceof WGSLShaderAssembler);
|
|
18354
18846
|
const {
|
|
18355
18847
|
source: source4,
|
|
18356
18848
|
getUniforms: getUniforms2,
|
|
@@ -18374,7 +18866,7 @@ void main(void) {
|
|
|
18374
18866
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
18375
18867
|
modules
|
|
18376
18868
|
) || null;
|
|
18377
|
-
const asyncCompilation =
|
|
18869
|
+
const asyncCompilation = import_core26.PipelineFactory.getAsyncCompilation(this.device);
|
|
18378
18870
|
if (asyncCompilation) {
|
|
18379
18871
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
18380
18872
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -18441,7 +18933,7 @@ void main(void) {
|
|
|
18441
18933
|
}
|
|
18442
18934
|
setShaderInputs(shaderInputs) {
|
|
18443
18935
|
this.shaderInputs = shaderInputs;
|
|
18444
|
-
this._uniformStore = new
|
|
18936
|
+
this._uniformStore = new import_core26.UniformStore(this.device, this.shaderInputs.modules);
|
|
18445
18937
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
18446
18938
|
if (shaderModuleHasUniforms(module)) {
|
|
18447
18939
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -18510,7 +19002,7 @@ void main(void) {
|
|
|
18510
19002
|
if (!this._pipelineNeedsUpdate) return null;
|
|
18511
19003
|
const previousShader = this.pipeline ? this.shader : null;
|
|
18512
19004
|
if (this.pipeline) {
|
|
18513
|
-
|
|
19005
|
+
import_core26.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
18514
19006
|
}
|
|
18515
19007
|
this._pipelineNeedsUpdate = false;
|
|
18516
19008
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -18528,27 +19020,27 @@ void main(void) {
|
|
|
18528
19020
|
_lastLogTime = 0;
|
|
18529
19021
|
_logOpen = false;
|
|
18530
19022
|
_logDrawCallStart() {
|
|
18531
|
-
const logDrawTimeout =
|
|
18532
|
-
if (
|
|
19023
|
+
const logDrawTimeout = import_core26.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
19024
|
+
if (import_core26.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
18533
19025
|
return;
|
|
18534
19026
|
}
|
|
18535
19027
|
this._lastLogTime = Date.now();
|
|
18536
19028
|
this._logOpen = true;
|
|
18537
|
-
|
|
19029
|
+
import_core26.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core26.log.level <= 2 })();
|
|
18538
19030
|
}
|
|
18539
19031
|
_logDrawCallEnd() {
|
|
18540
19032
|
if (this._logOpen) {
|
|
18541
19033
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
18542
|
-
|
|
18543
|
-
|
|
19034
|
+
import_core26.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
19035
|
+
import_core26.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
18544
19036
|
this._logOpen = false;
|
|
18545
19037
|
}
|
|
18546
19038
|
}
|
|
18547
19039
|
_drawCount = 0;
|
|
18548
19040
|
// TODO - fix typing of luma data types
|
|
18549
19041
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
18550
|
-
const TypedArrayConstructor =
|
|
18551
|
-
const typedArray = attribute instanceof
|
|
19042
|
+
const TypedArrayConstructor = import_core26.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
19043
|
+
const typedArray = attribute instanceof import_core26.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
18552
19044
|
return typedArray.toString();
|
|
18553
19045
|
}
|
|
18554
19046
|
};
|
|
@@ -18768,7 +19260,12 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18768
19260
|
if (!outputTexture) {
|
|
18769
19261
|
return false;
|
|
18770
19262
|
}
|
|
18771
|
-
|
|
19263
|
+
this.drawOutput(commandEncoder, outputTexture, null);
|
|
19264
|
+
return true;
|
|
19265
|
+
}
|
|
19266
|
+
/** @internal Records presentation of a completed effect output. */
|
|
19267
|
+
drawOutput(commandEncoder, outputTexture, target) {
|
|
19268
|
+
const framebuffer = target ?? this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
|
|
18772
19269
|
this.textureModel.setProps({ backgroundTexture: outputTexture });
|
|
18773
19270
|
this.textureModel.predraw(commandEncoder);
|
|
18774
19271
|
const renderPass = commandEncoder.beginRenderPass({
|
|
@@ -18776,9 +19273,11 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18776
19273
|
framebuffer,
|
|
18777
19274
|
clearDepth: false
|
|
18778
19275
|
});
|
|
18779
|
-
|
|
18780
|
-
|
|
18781
|
-
|
|
19276
|
+
try {
|
|
19277
|
+
this.textureModel.draw(renderPass);
|
|
19278
|
+
} finally {
|
|
19279
|
+
renderPass.end();
|
|
19280
|
+
}
|
|
18782
19281
|
}
|
|
18783
19282
|
/** Runs the shaderPasses in sequence on the sourceTexture and returns a texture with the results.
|
|
18784
19283
|
* @returns null if the the sourceTexture has not yet been loaded
|
|
@@ -18893,28 +19392,28 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18893
19392
|
if (isCompositeShaderPass(passDefinition)) {
|
|
18894
19393
|
validateRenderTargetNames(passDefinition.name, passDefinition.renderTargets || {});
|
|
18895
19394
|
this.renderTargets = createManagedRenderTargets(device, passDefinition.renderTargets || {});
|
|
18896
|
-
|
|
18897
|
-
|
|
19395
|
+
const { compute, passes } = planFullscreenPasses(device, passDefinition);
|
|
19396
|
+
if (compute) {
|
|
19397
|
+
this.computeRenderer = new FullscreenComputePass(
|
|
18898
19398
|
device,
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
19399
|
+
compute,
|
|
19400
|
+
Object.fromEntries(
|
|
19401
|
+
Object.entries(this.renderTargets).map(([name, target]) => [
|
|
19402
|
+
name,
|
|
19403
|
+
target.texture.format
|
|
19404
|
+
])
|
|
19405
|
+
)
|
|
18902
19406
|
);
|
|
18903
19407
|
}
|
|
18904
|
-
|
|
18905
|
-
(step) => !passDefinition.compute.replacedPasses.includes(step.shaderPass.name)
|
|
18906
|
-
) : passDefinition.steps;
|
|
18907
|
-
this.subPassExecutions = executableSteps.flatMap(
|
|
18908
|
-
(step) => this.createStepExecutions(passDefinition, step, flipY)
|
|
18909
|
-
);
|
|
19408
|
+
this.subPassExecutions = this.createPassExecutions(passes, flipY);
|
|
18910
19409
|
return;
|
|
18911
19410
|
}
|
|
18912
19411
|
validateShaderPassDoesNotOwnRenderTargets(passDefinition, passDefinition.name);
|
|
18913
19412
|
this.renderTargets = {};
|
|
18914
|
-
this.subPassExecutions = this.createPassExecutions(
|
|
18915
|
-
|
|
19413
|
+
this.subPassExecutions = this.createPassExecutions(
|
|
19414
|
+
planShaderSubpasses(passDefinition, passDefinition.name),
|
|
18916
19415
|
flipY
|
|
18917
|
-
|
|
19416
|
+
);
|
|
18918
19417
|
}
|
|
18919
19418
|
destroy() {
|
|
18920
19419
|
this.computeRenderer?.destroy();
|
|
@@ -18935,8 +19434,23 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18935
19434
|
options.originalTexture,
|
|
18936
19435
|
options.previousTexture
|
|
18937
19436
|
);
|
|
18938
|
-
this.computeRenderer
|
|
18939
|
-
|
|
19437
|
+
const { optimization } = this.computeRenderer;
|
|
19438
|
+
const outputs = Object.fromEntries(
|
|
19439
|
+
Object.entries(optimization.outputs).map(([binding, targetName]) => [
|
|
19440
|
+
binding,
|
|
19441
|
+
this.renderTargets[targetName].texture.view
|
|
19442
|
+
])
|
|
19443
|
+
);
|
|
19444
|
+
this.computeRenderer.prepare(options.commandEncoder, sourceTexture.view, outputs, {
|
|
19445
|
+
...this.shaderInputs.getUniformValues()[optimization.uniformModule],
|
|
19446
|
+
...optimization.uniforms,
|
|
19447
|
+
...options.runtimeUniforms[optimization.uniformModule]
|
|
19448
|
+
});
|
|
19449
|
+
const target = this.renderTargets[Object.values(optimization.outputs)[0]].texture;
|
|
19450
|
+
const pass = options.commandEncoder.beginComputePass({ id: optimization.name });
|
|
19451
|
+
this.computeRenderer.dispatch(pass, target.width, target.height);
|
|
19452
|
+
pass.end();
|
|
19453
|
+
for (const targetName of Object.values(optimization.outputs)) {
|
|
18940
19454
|
this.markTargetWritten(targetName);
|
|
18941
19455
|
}
|
|
18942
19456
|
}
|
|
@@ -19042,34 +19556,12 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19042
19556
|
}
|
|
19043
19557
|
return resolvedBindings;
|
|
19044
19558
|
}
|
|
19045
|
-
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
`${compositeShaderPass.name}/${step.shaderPass.name}`
|
|
19049
|
-
);
|
|
19050
|
-
return this.createPassExecutions(step.shaderPass, {
|
|
19051
|
-
ownerName: `${compositeShaderPass.name}/${step.shaderPass.name}`,
|
|
19052
|
-
firstInputs: step.inputs,
|
|
19053
|
-
lastOutput: step.output,
|
|
19054
|
-
uniformOverrides: step.uniforms,
|
|
19055
|
-
flipY
|
|
19056
|
-
});
|
|
19057
|
-
}
|
|
19058
|
-
createPassExecutions(shaderPass, options) {
|
|
19059
|
-
const subPasses = shaderPass.passes || [];
|
|
19060
|
-
return subPasses.map((subPass, index) => {
|
|
19061
|
-
const isFirstSubPass = index === 0;
|
|
19062
|
-
const isLastSubPass = index === subPasses.length - 1;
|
|
19063
|
-
const inputs = isFirstSubPass && options.firstInputs !== void 0 ? options.firstInputs : subPass.inputs;
|
|
19064
|
-
const output = isLastSubPass && options.lastOutput !== void 0 ? options.lastOutput : subPass.output;
|
|
19065
|
-
validateSubPassRouting(options.ownerName, inputs, output, this.renderTargets);
|
|
19559
|
+
createPassExecutions(passes, flipY) {
|
|
19560
|
+
return passes.map(({ subPass, ...pass }) => {
|
|
19561
|
+
validateSubPassRouting(pass.ownerName, pass.inputs, pass.output, this.renderTargets);
|
|
19066
19562
|
return {
|
|
19067
|
-
|
|
19068
|
-
shaderPass,
|
|
19069
|
-
subPassRenderer: new SubPassRenderer(this.device, shaderPass, subPass, options.flipY),
|
|
19070
|
-
inputs,
|
|
19071
|
-
output,
|
|
19072
|
-
uniforms: mergeUniforms(options.uniformOverrides, subPass.uniforms)
|
|
19563
|
+
...pass,
|
|
19564
|
+
subPassRenderer: new SubPassRenderer(this.device, pass.shaderPass, subPass, flipY)
|
|
19073
19565
|
};
|
|
19074
19566
|
});
|
|
19075
19567
|
}
|
|
@@ -19092,20 +19584,16 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19092
19584
|
return this.passDefinition.name;
|
|
19093
19585
|
}
|
|
19094
19586
|
};
|
|
19095
|
-
var
|
|
19587
|
+
var FullscreenComputePass = class {
|
|
19096
19588
|
optimization;
|
|
19097
|
-
renderTargets;
|
|
19098
|
-
shaderInputs;
|
|
19099
19589
|
computation;
|
|
19100
19590
|
parameterBuffer;
|
|
19101
|
-
constructor(device, optimization,
|
|
19591
|
+
constructor(device, optimization, outputFormats) {
|
|
19102
19592
|
this.optimization = optimization;
|
|
19103
|
-
this.renderTargets = renderTargets;
|
|
19104
|
-
this.shaderInputs = shaderInputs;
|
|
19105
19593
|
this.parameterBuffer = device.createBuffer({
|
|
19106
19594
|
id: `${optimization.name}-parameters`,
|
|
19107
19595
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
19108
|
-
usage:
|
|
19596
|
+
usage: import_core27.Buffer.UNIFORM | import_core27.Buffer.COPY_DST
|
|
19109
19597
|
});
|
|
19110
19598
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
19111
19599
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -19114,7 +19602,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19114
19602
|
group: 0,
|
|
19115
19603
|
location: outputIndex + 2,
|
|
19116
19604
|
access: "write-only",
|
|
19117
|
-
format:
|
|
19605
|
+
format: outputFormats[targetName]
|
|
19118
19606
|
})
|
|
19119
19607
|
);
|
|
19120
19608
|
try {
|
|
@@ -19140,12 +19628,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19140
19628
|
throw error;
|
|
19141
19629
|
}
|
|
19142
19630
|
}
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
...this.shaderInputs.getUniformValues()[this.optimization.uniformModule] || {},
|
|
19146
|
-
...this.optimization.uniforms,
|
|
19147
|
-
...runtimeUniforms[this.optimization.uniformModule] || {}
|
|
19148
|
-
};
|
|
19631
|
+
/** Binds the current graph or renderer resources and records its uniform upload. */
|
|
19632
|
+
prepare(commandEncoder, source4, outputs, effectiveUniforms) {
|
|
19149
19633
|
const uniformValues = new Float32Array(
|
|
19150
19634
|
Math.max(Math.ceil(this.optimization.uniformNames.length / 4) * 4, 4)
|
|
19151
19635
|
);
|
|
@@ -19153,26 +19637,26 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19153
19637
|
const value = effectiveUniforms[uniformName];
|
|
19154
19638
|
uniformValues[uniformIndex] = typeof value === "number" ? value : 0;
|
|
19155
19639
|
}
|
|
19156
|
-
this.parameterBuffer.
|
|
19157
|
-
|
|
19158
|
-
|
|
19640
|
+
this.parameterBuffer.device.writeBufferViaCommandEncoder(
|
|
19641
|
+
commandEncoder,
|
|
19642
|
+
this.parameterBuffer,
|
|
19643
|
+
uniformValues
|
|
19644
|
+
);
|
|
19645
|
+
this.computation.setBindings({
|
|
19159
19646
|
[this.optimization.uniformBinding]: this.parameterBuffer,
|
|
19160
|
-
sourceTexture:
|
|
19161
|
-
|
|
19162
|
-
|
|
19163
|
-
bindings[bindingName] = this.renderTargets[targetName].texture.view;
|
|
19164
|
-
}
|
|
19165
|
-
this.computation.setBindings(bindings);
|
|
19647
|
+
sourceTexture: source4,
|
|
19648
|
+
...outputs
|
|
19649
|
+
});
|
|
19166
19650
|
this.computation.predraw(commandEncoder);
|
|
19167
|
-
|
|
19168
|
-
|
|
19651
|
+
}
|
|
19652
|
+
/** Dispatches against the dimensions of the first declared storage output. */
|
|
19653
|
+
dispatch(pass, width, height) {
|
|
19169
19654
|
this.computation.dispatch(
|
|
19170
|
-
|
|
19171
|
-
Math.ceil(
|
|
19172
|
-
Math.ceil(
|
|
19655
|
+
pass,
|
|
19656
|
+
Math.ceil(width / this.optimization.workgroupSize[0]),
|
|
19657
|
+
Math.ceil(height / this.optimization.workgroupSize[1]),
|
|
19173
19658
|
1
|
|
19174
19659
|
);
|
|
19175
|
-
computePass.end();
|
|
19176
19660
|
}
|
|
19177
19661
|
destroy() {
|
|
19178
19662
|
this.computation.destroy();
|
|
@@ -19185,6 +19669,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19185
19669
|
subPass;
|
|
19186
19670
|
flipY;
|
|
19187
19671
|
constructor(device, shaderPass, subPass, flipY) {
|
|
19672
|
+
(0, import_shaders7.initializeShaderModule)(shaderPass);
|
|
19188
19673
|
this.shaderPass = shaderPass;
|
|
19189
19674
|
this.subPass = subPass;
|
|
19190
19675
|
this.flipY = flipY;
|
|
@@ -19225,16 +19710,42 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19225
19710
|
this.model.draw(renderPass);
|
|
19226
19711
|
}
|
|
19227
19712
|
};
|
|
19713
|
+
function planFullscreenPasses(device, effect, options = {}) {
|
|
19714
|
+
const fallback = effect.initialPasses?.fragment ?? [];
|
|
19715
|
+
const compute = options.allowCompute !== false && supportsComputeOptimization(device, effect, options.colorFormat) ? effect.initialPasses ? effect.initialPasses.compute : effect.compute : void 0;
|
|
19716
|
+
const steps = effect.initialPasses ? [...compute ? [] : fallback, ...effect.steps] : compute ? effect.steps.filter((step) => !effect.compute.replacedPasses.includes(step.shaderPass.name)) : effect.steps;
|
|
19717
|
+
return {
|
|
19718
|
+
compute,
|
|
19719
|
+
passes: steps.flatMap((step) => {
|
|
19720
|
+
const ownerName = effect.name + "/" + step.shaderPass.name;
|
|
19721
|
+
validateShaderPassDoesNotOwnRenderTargets(step.shaderPass, ownerName);
|
|
19722
|
+
return planShaderSubpasses(step.shaderPass, ownerName, step);
|
|
19723
|
+
})
|
|
19724
|
+
};
|
|
19725
|
+
}
|
|
19726
|
+
function planShaderSubpasses(shaderPass, ownerName, step) {
|
|
19727
|
+
const subPasses = shaderPass.passes ?? [];
|
|
19728
|
+
return subPasses.map((subPass, index) => ({
|
|
19729
|
+
ownerName,
|
|
19730
|
+
shaderPass,
|
|
19731
|
+
subPass,
|
|
19732
|
+
inputs: (index === 0 ? step?.inputs : void 0) ?? subPass.inputs,
|
|
19733
|
+
output: (index === subPasses.length - 1 ? step?.output : void 0) ?? subPass.output,
|
|
19734
|
+
uniforms: mergeUniforms(step?.uniforms, subPass.uniforms)
|
|
19735
|
+
}));
|
|
19736
|
+
}
|
|
19228
19737
|
function getExecutableShaderPasses(shaderPasses) {
|
|
19229
19738
|
return shaderPasses.flatMap(
|
|
19230
|
-
(shaderPass) => isCompositeShaderPass(shaderPass) ? shaderPass.
|
|
19739
|
+
(shaderPass) => isCompositeShaderPass(shaderPass) ? [...shaderPass.initialPasses?.fragment ?? [], ...shaderPass.steps].map(
|
|
19740
|
+
(step) => step.shaderPass
|
|
19741
|
+
) : [shaderPass]
|
|
19231
19742
|
);
|
|
19232
19743
|
}
|
|
19233
19744
|
function isCompositeShaderPass(shaderPass) {
|
|
19234
19745
|
return "steps" in shaderPass;
|
|
19235
19746
|
}
|
|
19236
|
-
function supportsComputeOptimization(device, compositeShaderPass) {
|
|
19237
|
-
const optimization = compositeShaderPass.compute;
|
|
19747
|
+
function supportsComputeOptimization(device, compositeShaderPass, colorFormat = device.preferredColorFormat) {
|
|
19748
|
+
const optimization = compositeShaderPass.initialPasses ? compositeShaderPass.initialPasses.compute : compositeShaderPass.compute;
|
|
19238
19749
|
if (!optimization || device.type !== "webgpu") {
|
|
19239
19750
|
return false;
|
|
19240
19751
|
}
|
|
@@ -19247,7 +19758,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19247
19758
|
if (!target?.storage) {
|
|
19248
19759
|
return false;
|
|
19249
19760
|
}
|
|
19250
|
-
const format = target.format ||
|
|
19761
|
+
const format = target.format || colorFormat;
|
|
19251
19762
|
return device.getTextureFormatCapabilities(format).store;
|
|
19252
19763
|
});
|
|
19253
19764
|
}
|
|
@@ -19390,7 +19901,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19390
19901
|
width: targetSize[0],
|
|
19391
19902
|
height: targetSize[1],
|
|
19392
19903
|
format: spec.format || device.preferredColorFormat,
|
|
19393
|
-
usage:
|
|
19904
|
+
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),
|
|
19394
19905
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
19395
19906
|
});
|
|
19396
19907
|
const framebuffer = device.createFramebuffer({
|
|
@@ -19444,8 +19955,152 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19444
19955
|
return [sourceAspect / outputAspect, 1];
|
|
19445
19956
|
}
|
|
19446
19957
|
|
|
19958
|
+
// src/passes/effect-renderer.ts
|
|
19959
|
+
function resolveEffectOptions(effect, options) {
|
|
19960
|
+
if ("configure" in effect) return effect.configure(options);
|
|
19961
|
+
const {
|
|
19962
|
+
scaleResources,
|
|
19963
|
+
variants,
|
|
19964
|
+
optionDefaults,
|
|
19965
|
+
optionUniforms,
|
|
19966
|
+
optionInputs,
|
|
19967
|
+
historyClearOptions
|
|
19968
|
+
} = effect;
|
|
19969
|
+
const overrides = options;
|
|
19970
|
+
const defaults = optionDefaults;
|
|
19971
|
+
const readOption = (key) => overrides?.[key] ?? defaults[key];
|
|
19972
|
+
const readValue = (mapping) => {
|
|
19973
|
+
const option = readOption(mapping.option);
|
|
19974
|
+
if (!mapping.values) return option;
|
|
19975
|
+
const key = String(option);
|
|
19976
|
+
return Object.hasOwn(mapping.values, key) ? mapping.values[key] : void 0;
|
|
19977
|
+
};
|
|
19978
|
+
const value = variants && String(readOption(variants.option));
|
|
19979
|
+
const variant = variants && value !== void 0 && Object.hasOwn(variants.values, value) ? variants.values[value] : void 0;
|
|
19980
|
+
const resolved = { ...effect, ...variant };
|
|
19981
|
+
const resources = { ...resolved.resources };
|
|
19982
|
+
if (scaleResources) {
|
|
19983
|
+
const scale5 = readValue(scaleResources) ?? (scaleResources.fallback && readValue(scaleResources.fallback)) ?? scaleResources.defaultScale;
|
|
19984
|
+
if (typeof scale5 !== "number" || !Number.isFinite(scale5) || scale5 <= 0 && !scaleResources.minimum) {
|
|
19985
|
+
throw new Error(effect.name + ": resource scale must be a finite positive number");
|
|
19986
|
+
}
|
|
19987
|
+
for (const name of scaleResources.targets) {
|
|
19988
|
+
const resource = resources[name];
|
|
19989
|
+
if (!resource?.scale) continue;
|
|
19990
|
+
const factor = scaleResources.factors?.[name] ?? 1;
|
|
19991
|
+
const size = Math.max(scale5, scaleResources.minimum ?? 0) * factor;
|
|
19992
|
+
resources[name] = { ...resource, scale: [size, size] };
|
|
19993
|
+
}
|
|
19994
|
+
}
|
|
19995
|
+
for (const name of Object.keys(historyClearOptions ?? {})) {
|
|
19996
|
+
const mapping = historyClearOptions?.[name];
|
|
19997
|
+
const resource = resources[name];
|
|
19998
|
+
const initial = resource?.initialize;
|
|
19999
|
+
if (!mapping || !initial || initial === "original") continue;
|
|
20000
|
+
const value2 = readOption(mapping.option);
|
|
20001
|
+
if (typeof value2 === "number" && Number.isFinite(value2)) {
|
|
20002
|
+
const [, green, blue, alpha] = initial.clearColor;
|
|
20003
|
+
resources[name] = {
|
|
20004
|
+
...resource,
|
|
20005
|
+
initialize: {
|
|
20006
|
+
clearColor: [Math.max(value2, mapping.minimum ?? -Infinity), green, blue, alpha]
|
|
20007
|
+
}
|
|
20008
|
+
};
|
|
20009
|
+
}
|
|
20010
|
+
}
|
|
20011
|
+
const passes = resolved.passes.map((pass) => {
|
|
20012
|
+
const moduleName = pass.kind === "fullscreen" ? pass.shaderPass.name : pass.module.name;
|
|
20013
|
+
const uniformOptions = optionUniforms?.[moduleName];
|
|
20014
|
+
const inputOptions = optionInputs?.[moduleName];
|
|
20015
|
+
if (!uniformOptions && !inputOptions) return pass;
|
|
20016
|
+
const uniforms = { ...pass.uniforms };
|
|
20017
|
+
const inputs = { ...pass.inputs };
|
|
20018
|
+
for (const [name, mapping] of Object.entries(uniformOptions ?? {})) {
|
|
20019
|
+
const value2 = readValue(mapping);
|
|
20020
|
+
if (value2 !== void 0) uniforms[name] = value2;
|
|
20021
|
+
}
|
|
20022
|
+
for (const [name, mapping] of Object.entries(inputOptions ?? {})) {
|
|
20023
|
+
const value2 = readValue(mapping);
|
|
20024
|
+
if (typeof value2 === "string") inputs[name] = value2;
|
|
20025
|
+
}
|
|
20026
|
+
return { ...pass, uniforms, ...inputOptions ? { inputs } : {} };
|
|
20027
|
+
});
|
|
20028
|
+
return { ...resolved, resources, passes };
|
|
20029
|
+
}
|
|
20030
|
+
function resolveEffect(effect) {
|
|
20031
|
+
return {
|
|
20032
|
+
name: effect.name,
|
|
20033
|
+
renderTargets: effect.resources,
|
|
20034
|
+
initialPasses: effect.initialPasses && {
|
|
20035
|
+
...effect.initialPasses,
|
|
20036
|
+
fragment: effect.initialPasses.fragment.map(lowerEffectPass)
|
|
20037
|
+
},
|
|
20038
|
+
steps: effect.passes.map(lowerEffectPass)
|
|
20039
|
+
};
|
|
20040
|
+
}
|
|
20041
|
+
function lowerEffectPass(pass) {
|
|
20042
|
+
if (pass.kind === "fullscreen") return pass;
|
|
20043
|
+
const { kind, module, ...routing } = pass;
|
|
20044
|
+
return { ...routing, shaderPass: { ...module, passes: [{ action: kind }] } };
|
|
20045
|
+
}
|
|
20046
|
+
function resolveEffectEntries(effects) {
|
|
20047
|
+
return effects.map((entry) => {
|
|
20048
|
+
if (!("effect" in entry)) return resolveEffect(entry);
|
|
20049
|
+
const { effect } = entry;
|
|
20050
|
+
if ("configure" in effect && effect.configure || "optionDefaults" in effect) {
|
|
20051
|
+
return resolveEffect(
|
|
20052
|
+
resolveEffectOptions(effect, entry.options)
|
|
20053
|
+
);
|
|
20054
|
+
}
|
|
20055
|
+
return resolveEffect(effect);
|
|
20056
|
+
});
|
|
20057
|
+
}
|
|
20058
|
+
var EffectRenderer = class extends ShaderPassRenderer {
|
|
20059
|
+
constructor(device, { effects, ...props }) {
|
|
20060
|
+
super(device, {
|
|
20061
|
+
...props,
|
|
20062
|
+
shaderPasses: resolveEffectEntries(effects)
|
|
20063
|
+
});
|
|
20064
|
+
}
|
|
20065
|
+
render({
|
|
20066
|
+
target,
|
|
20067
|
+
commandEncoder = this.device.commandEncoder,
|
|
20068
|
+
...frame
|
|
20069
|
+
}) {
|
|
20070
|
+
if (target && target.device !== this.device) {
|
|
20071
|
+
throw new Error("EffectRenderer target must belong to the renderer device");
|
|
20072
|
+
}
|
|
20073
|
+
const output = this.encodeToTexture(commandEncoder, frame);
|
|
20074
|
+
if (target === void 0) {
|
|
20075
|
+
return output;
|
|
20076
|
+
}
|
|
20077
|
+
if (!output) {
|
|
20078
|
+
return false;
|
|
20079
|
+
}
|
|
20080
|
+
this.drawOutput(commandEncoder, output, target);
|
|
20081
|
+
return true;
|
|
20082
|
+
}
|
|
20083
|
+
};
|
|
20084
|
+
|
|
20085
|
+
// src/passes/scene-capture-pass.ts
|
|
20086
|
+
function encodeSceneCapturePass(definition, options) {
|
|
20087
|
+
const { commandEncoder, frame } = options;
|
|
20088
|
+
definition.prepare?.(commandEncoder, frame);
|
|
20089
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
20090
|
+
...definition.pass,
|
|
20091
|
+
...definition.getPassProps?.(frame),
|
|
20092
|
+
id: options.id ?? definition.name,
|
|
20093
|
+
framebuffer: options.framebuffers[definition.target]
|
|
20094
|
+
});
|
|
20095
|
+
try {
|
|
20096
|
+
return definition.draw(renderPass, frame);
|
|
20097
|
+
} finally {
|
|
20098
|
+
renderPass.end();
|
|
20099
|
+
}
|
|
20100
|
+
}
|
|
20101
|
+
|
|
19447
20102
|
// src/modules/picking/picking-manager.ts
|
|
19448
|
-
var
|
|
20103
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
19449
20104
|
|
|
19450
20105
|
// src/modules/picking/picking-uniforms.ts
|
|
19451
20106
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -19709,13 +20364,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
19709
20364
|
format: "rgba8unorm",
|
|
19710
20365
|
width: 1,
|
|
19711
20366
|
height: 1,
|
|
19712
|
-
usage:
|
|
20367
|
+
usage: import_core28.Texture.RENDER_ATTACHMENT
|
|
19713
20368
|
});
|
|
19714
20369
|
const pickingTexture = this.device.createTexture({
|
|
19715
20370
|
format: "rg32sint",
|
|
19716
20371
|
width: 1,
|
|
19717
20372
|
height: 1,
|
|
19718
|
-
usage:
|
|
20373
|
+
usage: import_core28.Texture.RENDER_ATTACHMENT | import_core28.Texture.COPY_SRC
|
|
19719
20374
|
});
|
|
19720
20375
|
return this.device.createFramebuffer({
|
|
19721
20376
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -19727,7 +20382,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19727
20382
|
format: "rgba8unorm",
|
|
19728
20383
|
width: 1,
|
|
19729
20384
|
height: 1,
|
|
19730
|
-
usage:
|
|
20385
|
+
usage: import_core28.Texture.RENDER_ATTACHMENT | import_core28.Texture.COPY_SRC
|
|
19731
20386
|
});
|
|
19732
20387
|
return this.device.createFramebuffer({
|
|
19733
20388
|
colorAttachments: [pickingTexture],
|
|
@@ -19749,7 +20404,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19749
20404
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19750
20405
|
const readBuffer = this.device.createBuffer({
|
|
19751
20406
|
byteLength: layout.byteLength,
|
|
19752
|
-
usage:
|
|
20407
|
+
usage: import_core28.Buffer.COPY_DST | import_core28.Buffer.MAP_READ
|
|
19753
20408
|
});
|
|
19754
20409
|
try {
|
|
19755
20410
|
pickTexture.readBuffer(
|
|
@@ -19785,7 +20440,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19785
20440
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19786
20441
|
const readBuffer = this.device.createBuffer({
|
|
19787
20442
|
byteLength: layout.byteLength,
|
|
19788
|
-
usage:
|
|
20443
|
+
usage: import_core28.Buffer.COPY_DST | import_core28.Buffer.MAP_READ
|
|
19789
20444
|
});
|
|
19790
20445
|
try {
|
|
19791
20446
|
pickTexture.readBuffer(
|
|
@@ -20467,7 +21122,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20467
21122
|
}
|
|
20468
21123
|
|
|
20469
21124
|
// src/scenegraph/controllers/skin-controller.ts
|
|
20470
|
-
var
|
|
21125
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
20471
21126
|
var SkinController = class {
|
|
20472
21127
|
bindings;
|
|
20473
21128
|
/** Palettes owned by a GPU producer for the duration of their binding. */
|
|
@@ -20501,7 +21156,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20501
21156
|
target: binding.jointMatrices
|
|
20502
21157
|
});
|
|
20503
21158
|
if (binding.skinJointMatrices) {
|
|
20504
|
-
if (binding.skinJointMatrices instanceof
|
|
21159
|
+
if (binding.skinJointMatrices instanceof import_core29.Buffer) {
|
|
20505
21160
|
binding.skinJointMatrices.write(binding.jointMatrices);
|
|
20506
21161
|
} else {
|
|
20507
21162
|
binding.skinJointMatrices.writeData(binding.jointMatrices, {
|
|
@@ -20519,7 +21174,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20519
21174
|
}
|
|
20520
21175
|
/** Borrow a WebGPU storage palette and suspend CPU writes until the lease is released. */
|
|
20521
21176
|
claimGPUPalette(binding) {
|
|
20522
|
-
if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof
|
|
21177
|
+
if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof import_core29.Buffer))
|
|
20523
21178
|
throw new Error("GPU skinning requires an owned storage palette");
|
|
20524
21179
|
if (this.gpuDriven.has(binding)) throw new Error("Skin palette already has a GPU producer");
|
|
20525
21180
|
this.gpuDriven.add(binding);
|
|
@@ -20546,7 +21201,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20546
21201
|
return device.createBuffer({
|
|
20547
21202
|
id: `${id}-skin-joint-matrices`,
|
|
20548
21203
|
byteLength: jointMatrices.byteLength,
|
|
20549
|
-
usage:
|
|
21204
|
+
usage: import_core29.Buffer.STORAGE | import_core29.Buffer.COPY_DST
|
|
20550
21205
|
});
|
|
20551
21206
|
}
|
|
20552
21207
|
const width = jointMatrices.length / 4;
|
|
@@ -20558,7 +21213,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20558
21213
|
format: "rgba32float",
|
|
20559
21214
|
width,
|
|
20560
21215
|
height: 1,
|
|
20561
|
-
usage:
|
|
21216
|
+
usage: import_core29.Texture.SAMPLE | import_core29.Texture.COPY_DST,
|
|
20562
21217
|
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
20563
21218
|
});
|
|
20564
21219
|
}
|
|
@@ -20601,7 +21256,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20601
21256
|
};
|
|
20602
21257
|
|
|
20603
21258
|
// src/scenegraph/controllers/billboard-controller.ts
|
|
20604
|
-
var
|
|
21259
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
20605
21260
|
var BillboardController = class {
|
|
20606
21261
|
scenes;
|
|
20607
21262
|
bindings = /* @__PURE__ */ new Map();
|
|
@@ -20612,8 +21267,8 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20612
21267
|
const { definition } = binding;
|
|
20613
21268
|
const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
|
|
20614
21269
|
const up = new Vector3(definition.up || [0, 1, 0]);
|
|
20615
|
-
(0,
|
|
20616
|
-
(0,
|
|
21270
|
+
(0, import_core30.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
|
|
21271
|
+
(0, import_core30.assert)(
|
|
20617
21272
|
new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
|
|
20618
21273
|
);
|
|
20619
21274
|
this.bindings.set(binding.node, binding);
|
|
@@ -20623,7 +21278,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20623
21278
|
getDrawEntries(options) {
|
|
20624
21279
|
const { sceneIndex = 0, cameraId = "default" } = options;
|
|
20625
21280
|
const scene = this.scenes[sceneIndex];
|
|
20626
|
-
(0,
|
|
21281
|
+
(0, import_core30.assert)(scene);
|
|
20627
21282
|
const viewMatrix = new Matrix4(options.viewMatrix);
|
|
20628
21283
|
const cameraMatrix = new Matrix4(viewMatrix).invert();
|
|
20629
21284
|
const cameraPosition = new Vector3(cameraMatrix.getTranslation());
|
|
@@ -20823,7 +21478,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20823
21478
|
}
|
|
20824
21479
|
|
|
20825
21480
|
// src/scenegraph/controllers/area-light-controller.ts
|
|
20826
|
-
var
|
|
21481
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
20827
21482
|
var AreaLightController = class {
|
|
20828
21483
|
scenes;
|
|
20829
21484
|
matrixAuthoredNodes = /* @__PURE__ */ new Set();
|
|
@@ -20833,11 +21488,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20833
21488
|
for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
|
|
20834
21489
|
for (const { node, definition, matrixAuthored } of bindings) {
|
|
20835
21490
|
if (matrixAuthored) this.matrixAuthoredNodes.add(node);
|
|
20836
|
-
(0,
|
|
20837
|
-
(0,
|
|
20838
|
-
(0,
|
|
20839
|
-
(0,
|
|
20840
|
-
(0,
|
|
21491
|
+
(0, import_core31.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
|
|
21492
|
+
(0, import_core31.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
|
|
21493
|
+
(0, import_core31.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
|
|
21494
|
+
(0, import_core31.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
|
|
21495
|
+
(0, import_core31.assert)(
|
|
20841
21496
|
(definition.color || [1, 1, 1]).every(
|
|
20842
21497
|
(component) => Number.isFinite(component) && component >= 0
|
|
20843
21498
|
)
|
|
@@ -20903,17 +21558,17 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20903
21558
|
function getMatrixRotation(matrix) {
|
|
20904
21559
|
const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
|
|
20905
21560
|
const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
|
|
20906
|
-
(0,
|
|
21561
|
+
(0, import_core31.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
|
|
20907
21562
|
horizontal.normalize();
|
|
20908
21563
|
vertical.normalize();
|
|
20909
21564
|
vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
|
|
20910
|
-
(0,
|
|
21565
|
+
(0, import_core31.assert)(vertical.magnitude() > 1e-8);
|
|
20911
21566
|
vertical.normalize();
|
|
20912
21567
|
const forward = new Vector3(horizontal).cross(vertical).normalize();
|
|
20913
21568
|
const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
|
|
20914
|
-
(0,
|
|
21569
|
+
(0, import_core31.assert)(authoredForward.magnitude() > 0);
|
|
20915
21570
|
authoredForward.normalize();
|
|
20916
|
-
(0,
|
|
21571
|
+
(0, import_core31.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
|
|
20917
21572
|
if (forward.dot(authoredForward) < 0) forward.negate();
|
|
20918
21573
|
return new Matrix4([
|
|
20919
21574
|
horizontal[0],
|
|
@@ -21471,15 +22126,18 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21471
22126
|
};
|
|
21472
22127
|
|
|
21473
22128
|
// src/audio/audio-graph.ts
|
|
21474
|
-
var
|
|
22129
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
21475
22130
|
var AudioGraph = class {
|
|
21476
22131
|
constructor(definition, context, destination, getEmitterInputs) {
|
|
21477
22132
|
this.definition = definition;
|
|
22133
|
+
this.context = context;
|
|
22134
|
+
this.destination = destination;
|
|
22135
|
+
this.getEmitterInputs = getEmitterInputs;
|
|
21478
22136
|
for (const node of definition.nodes)
|
|
21479
|
-
(0,
|
|
22137
|
+
(0, import_core32.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
|
|
21480
22138
|
const validateEndpoint = (index, port = 0) => {
|
|
21481
|
-
(0,
|
|
21482
|
-
(0,
|
|
22139
|
+
(0, import_core32.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
|
|
22140
|
+
(0, import_core32.assert)(Number.isInteger(port) && port >= 0);
|
|
21483
22141
|
};
|
|
21484
22142
|
for (const edge of definition.connections) {
|
|
21485
22143
|
validateEndpoint(edge.from.node, edge.from.output);
|
|
@@ -21487,16 +22145,16 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21487
22145
|
}
|
|
21488
22146
|
for (const input of definition.inputs || []) {
|
|
21489
22147
|
validateEndpoint(input.node, input.input);
|
|
21490
|
-
(0,
|
|
22148
|
+
(0, import_core32.assert)(Number.isInteger(input.source) && input.source >= 0);
|
|
21491
22149
|
}
|
|
21492
22150
|
for (const output of definition.outputs || []) {
|
|
21493
22151
|
validateEndpoint(output.node, output.output);
|
|
21494
|
-
(0,
|
|
22152
|
+
(0, import_core32.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
|
|
21495
22153
|
}
|
|
21496
22154
|
const visiting = /* @__PURE__ */ new Set();
|
|
21497
22155
|
const visited = /* @__PURE__ */ new Set();
|
|
21498
22156
|
const visit = (index) => {
|
|
21499
|
-
(0,
|
|
22157
|
+
(0, import_core32.assert)(definition.nodes[index] && !visiting.has(index));
|
|
21500
22158
|
if (visited.has(index)) return;
|
|
21501
22159
|
visiting.add(index);
|
|
21502
22160
|
for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
|
|
@@ -21504,10 +22162,29 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21504
22162
|
visited.add(index);
|
|
21505
22163
|
};
|
|
21506
22164
|
definition.nodes.forEach((_, index) => visit(index));
|
|
22165
|
+
this.connectProcessors();
|
|
22166
|
+
}
|
|
22167
|
+
definition;
|
|
22168
|
+
context;
|
|
22169
|
+
destination;
|
|
22170
|
+
getEmitterInputs;
|
|
22171
|
+
nodes = [];
|
|
22172
|
+
/** Tracks whether a source has fed these processors since they were connected. */
|
|
22173
|
+
hasConnectedSource = false;
|
|
22174
|
+
/** Flush buffered samples while retaining gain automation. */
|
|
22175
|
+
reset() {
|
|
22176
|
+
if (!this.hasConnectedSource) return;
|
|
22177
|
+
const previousNodes = this.nodes.slice();
|
|
22178
|
+
this.destroy();
|
|
22179
|
+
this.connectProcessors(previousNodes);
|
|
22180
|
+
}
|
|
22181
|
+
/** Wire graph processors, reusing gain nodes to preserve their AudioParam automation. */
|
|
22182
|
+
connectProcessors(previousNodes = []) {
|
|
22183
|
+
const { definition, context, destination, getEmitterInputs } = this;
|
|
21507
22184
|
try {
|
|
21508
22185
|
definition.nodes.forEach(
|
|
21509
22186
|
(node, index) => this.nodes.push(
|
|
21510
|
-
createProcessor(
|
|
22187
|
+
(node.kind === "gain" ? previousNodes[index] : void 0) ?? createProcessor(
|
|
21511
22188
|
context,
|
|
21512
22189
|
node,
|
|
21513
22190
|
Math.max(
|
|
@@ -21546,18 +22223,18 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21546
22223
|
throw error;
|
|
21547
22224
|
}
|
|
21548
22225
|
}
|
|
21549
|
-
definition;
|
|
21550
|
-
nodes = [];
|
|
21551
22226
|
connectSource(index, source4) {
|
|
21552
22227
|
for (const input of this.definition.inputs || []) {
|
|
21553
|
-
if (input.source === index)
|
|
22228
|
+
if (input.source === index) {
|
|
21554
22229
|
source4.connect(this.nodes[input.node], 0, this.getInputPort(input.node, input.input ?? 0));
|
|
22230
|
+
this.hasConnectedSource = true;
|
|
22231
|
+
}
|
|
21555
22232
|
}
|
|
21556
22233
|
}
|
|
21557
22234
|
/** Apply a scene-driven gain change using the authored transition shape. */
|
|
21558
22235
|
setGain(index, gain, time = this.nodes[index].context.currentTime) {
|
|
21559
22236
|
const definition = this.definition.nodes[index];
|
|
21560
|
-
(0,
|
|
22237
|
+
(0, import_core32.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
|
|
21561
22238
|
const parameter = this.nodes[index].gain;
|
|
21562
22239
|
const duration = definition.params.duration ?? 0;
|
|
21563
22240
|
const initialGain = parameter.value;
|
|
@@ -21567,7 +22244,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21567
22244
|
parameter.setValueAtTime(gain, time);
|
|
21568
22245
|
} else if (definition.params.interpolation === "custom") {
|
|
21569
22246
|
const curve = definition.params.curve;
|
|
21570
|
-
(0,
|
|
22247
|
+
(0, import_core32.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
|
|
21571
22248
|
parameter.setValueCurveAtTime(
|
|
21572
22249
|
Float32Array.from(curve, (value) => value * gain),
|
|
21573
22250
|
time,
|
|
@@ -21580,6 +22257,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21580
22257
|
destroy() {
|
|
21581
22258
|
for (const node of this.nodes) node.disconnect();
|
|
21582
22259
|
this.nodes.length = 0;
|
|
22260
|
+
this.hasConnectedSource = false;
|
|
21583
22261
|
}
|
|
21584
22262
|
getInputPort(index, port) {
|
|
21585
22263
|
return this.definition.nodes[index].kind === "audiomixer" ? 0 : port;
|
|
@@ -21652,7 +22330,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21652
22330
|
}
|
|
21653
22331
|
|
|
21654
22332
|
// src/audio/audio-environment.ts
|
|
21655
|
-
var
|
|
22333
|
+
var import_core33 = __toESM(require_core(), 1);
|
|
21656
22334
|
function selectAudioEnvironmentZone(zones, position) {
|
|
21657
22335
|
let selected;
|
|
21658
22336
|
for (const zone of zones) {
|
|
@@ -21745,7 +22423,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21745
22423
|
}
|
|
21746
22424
|
};
|
|
21747
22425
|
function createParametricAudioResponse(context, parameters) {
|
|
21748
|
-
(0,
|
|
22426
|
+
(0, import_core33.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
|
|
21749
22427
|
const presets = {
|
|
21750
22428
|
generic: [1.49, 0.83, 7e-3, 0.011],
|
|
21751
22429
|
smallRoom: [0.4, 0.83, 2e-3, 3e-3],
|
|
@@ -21762,12 +22440,12 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21762
22440
|
underwater: [1.49, 0.1, 7e-3, 0.011]
|
|
21763
22441
|
};
|
|
21764
22442
|
const preset = parameters.preset ? presets[parameters.preset] : void 0;
|
|
21765
|
-
(0,
|
|
22443
|
+
(0, import_core33.assert)(!parameters.preset || preset);
|
|
21766
22444
|
const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
|
|
21767
22445
|
const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
|
|
21768
22446
|
const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
|
|
21769
22447
|
const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
|
|
21770
|
-
(0,
|
|
22448
|
+
(0, import_core33.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
|
|
21771
22449
|
const response = context.createBuffer(
|
|
21772
22450
|
2,
|
|
21773
22451
|
Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
|
|
@@ -21791,7 +22469,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21791
22469
|
}
|
|
21792
22470
|
|
|
21793
22471
|
// src/audio/audio-controller.ts
|
|
21794
|
-
var
|
|
22472
|
+
var import_core34 = __toESM(require_core(), 1);
|
|
21795
22473
|
var AudioController = class {
|
|
21796
22474
|
gain;
|
|
21797
22475
|
definition;
|
|
@@ -21901,25 +22579,25 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21901
22579
|
/** Change a graph gain using its authored interpolation and duration. */
|
|
21902
22580
|
setGraphGain(graphIndex, nodeIndex, gain) {
|
|
21903
22581
|
const graph = this.graphs.get(graphIndex);
|
|
21904
|
-
(0,
|
|
22582
|
+
(0, import_core34.assert)(!this.destroyed && graph);
|
|
21905
22583
|
graph.setGain(nodeIndex, gain);
|
|
21906
22584
|
}
|
|
21907
22585
|
startSource(sourceIndex, startTime, autoplayOnly, connect) {
|
|
21908
22586
|
const definition = this.definition.sources[sourceIndex];
|
|
21909
|
-
(0,
|
|
22587
|
+
(0, import_core34.assert)(definition);
|
|
21910
22588
|
if (autoplayOnly && !definition.autoPlay) return;
|
|
21911
22589
|
const context = this.options.audioContext;
|
|
21912
22590
|
const extended = definition.graph;
|
|
21913
22591
|
const oscillator = extended?.oscillator;
|
|
21914
|
-
(0,
|
|
22592
|
+
(0, import_core34.assert)(!(definition.audio !== void 0 && oscillator));
|
|
21915
22593
|
let source4;
|
|
21916
22594
|
if (oscillator) {
|
|
21917
22595
|
const node = context.createOscillator();
|
|
21918
22596
|
node.frequency.value = oscillator.frequency ?? 440;
|
|
21919
22597
|
node.detune.value = oscillator.detune ?? 0;
|
|
21920
|
-
(0,
|
|
22598
|
+
(0, import_core34.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
|
|
21921
22599
|
if (oscillator.type === "custom") {
|
|
21922
|
-
(0,
|
|
22600
|
+
(0, import_core34.assert)(oscillator.periodicWave);
|
|
21923
22601
|
node.setPeriodicWave(
|
|
21924
22602
|
context.createPeriodicWave(
|
|
21925
22603
|
new Float32Array(oscillator.periodicWave.real),
|
|
@@ -21930,7 +22608,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21930
22608
|
source4 = node;
|
|
21931
22609
|
} else {
|
|
21932
22610
|
const node = context.createBufferSource();
|
|
21933
|
-
(0,
|
|
22611
|
+
(0, import_core34.assert)(definition.audio !== void 0);
|
|
21934
22612
|
node.buffer = this.buffers.get(definition.audio);
|
|
21935
22613
|
node.loop = definition.loop ?? false;
|
|
21936
22614
|
node.loopStart = extended?.loopStart ?? 0;
|
|
@@ -21968,6 +22646,10 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21968
22646
|
gain.disconnect();
|
|
21969
22647
|
}
|
|
21970
22648
|
this.playing.clear();
|
|
22649
|
+
for (const graph of this.graphs.values()) {
|
|
22650
|
+
if (this.destroyed) graph.destroy();
|
|
22651
|
+
else graph.reset();
|
|
22652
|
+
}
|
|
21971
22653
|
for (const bus of this.reverbBuses.values()) bus.reset();
|
|
21972
22654
|
}
|
|
21973
22655
|
/** Call after animation updates, with the camera's inverse view matrix. Distances are in meters. */
|
|
@@ -22065,7 +22747,6 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22065
22747
|
emitter.airFilter?.disconnect();
|
|
22066
22748
|
emitter.gain.disconnect();
|
|
22067
22749
|
}
|
|
22068
|
-
for (const graph of this.graphs.values()) graph.destroy();
|
|
22069
22750
|
for (const bus of this.reverbBuses.values()) bus.destroy();
|
|
22070
22751
|
this.reverbBuses.clear();
|
|
22071
22752
|
for (const direct of this.directGains) direct.disconnect();
|
|
@@ -22075,15 +22756,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22075
22756
|
}
|
|
22076
22757
|
addEmitter(index, node) {
|
|
22077
22758
|
const definition = this.definition.emitters[index];
|
|
22078
|
-
(0,
|
|
22759
|
+
(0, import_core34.assert)(
|
|
22079
22760
|
definition && (definition.type === "global" || definition.type === "positional" && node)
|
|
22080
22761
|
);
|
|
22081
|
-
(0,
|
|
22762
|
+
(0, import_core34.assert)(
|
|
22082
22763
|
!definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
|
|
22083
22764
|
);
|
|
22084
22765
|
for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
|
|
22085
22766
|
const source4 = this.definition.sources[sourceIndex];
|
|
22086
|
-
(0,
|
|
22767
|
+
(0, import_core34.assert)(
|
|
22087
22768
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
22088
22769
|
);
|
|
22089
22770
|
}
|
|
@@ -22128,7 +22809,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22128
22809
|
const audioIndices = new Set(
|
|
22129
22810
|
[...sourceIndices].map((index) => {
|
|
22130
22811
|
const source4 = this.definition.sources[index];
|
|
22131
|
-
(0,
|
|
22812
|
+
(0, import_core34.assert)(
|
|
22132
22813
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
22133
22814
|
);
|
|
22134
22815
|
return source4.audio;
|
|
@@ -22165,7 +22846,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22165
22846
|
const reverb = environment.reverb;
|
|
22166
22847
|
if (!reverb) return;
|
|
22167
22848
|
const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
|
|
22168
|
-
(0,
|
|
22849
|
+
(0, import_core34.assert)(response);
|
|
22169
22850
|
const bus = new AudioReverbBus(audioContext, response, this.gain, {
|
|
22170
22851
|
...reverb,
|
|
22171
22852
|
normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
|
|
@@ -22274,7 +22955,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22274
22955
|
var legacyColorPicking = import_shaders9.picking;
|
|
22275
22956
|
|
|
22276
22957
|
// src/geometry/ring-geometry.ts
|
|
22277
|
-
var
|
|
22958
|
+
var import_core35 = __toESM(require_core(), 1);
|
|
22278
22959
|
var RingGeometry = class extends Geometry2 {
|
|
22279
22960
|
constructor(props = {}) {
|
|
22280
22961
|
const {
|
|
@@ -22285,7 +22966,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
22285
22966
|
startAngle = 0,
|
|
22286
22967
|
angle: angle2 = Math.PI * 2
|
|
22287
22968
|
} = props;
|
|
22288
|
-
(0,
|
|
22969
|
+
(0, import_core35.assert)(
|
|
22289
22970
|
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
|
|
22290
22971
|
);
|
|
22291
22972
|
const halfHeight = height / 2;
|
|
@@ -22468,92 +23149,6 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22468
23149
|
bindingLayout: [{ name: "publishedBodyMatrices", group: 0 }]
|
|
22469
23150
|
};
|
|
22470
23151
|
|
|
22471
|
-
// src/scenegraph/controllers/morph-controller.ts
|
|
22472
|
-
var import_core34 = __toESM(require_core(), 1);
|
|
22473
|
-
function setMorphWeights(node, weights) {
|
|
22474
|
-
node.userData["morphWeights"] = [...weights];
|
|
22475
|
-
const meshes = node.userData["morphMeshes"] || [];
|
|
22476
|
-
for (const mesh of meshes) {
|
|
22477
|
-
mesh.preorderTraversal((child) => {
|
|
22478
|
-
if (!(child instanceof ModelNode)) {
|
|
22479
|
-
return;
|
|
22480
|
-
}
|
|
22481
|
-
const state = child.userData["morphTargets"];
|
|
22482
|
-
if (!state) {
|
|
22483
|
-
return;
|
|
22484
|
-
}
|
|
22485
|
-
const gpuWeights = child.userData["morphWeightTransport"];
|
|
22486
|
-
if (gpuWeights) {
|
|
22487
|
-
updateMorphWeights(gpuWeights, weights);
|
|
22488
|
-
child.userData["morphWeights"] = [...weights];
|
|
22489
|
-
return;
|
|
22490
|
-
}
|
|
22491
|
-
updateMorphTargetBuffers(child.model, state.geometry, state.targets, weights);
|
|
22492
|
-
child.userData["morphWeights"] = [...weights];
|
|
22493
|
-
});
|
|
22494
|
-
}
|
|
22495
|
-
}
|
|
22496
|
-
function updateMorphWeights(state, weights) {
|
|
22497
|
-
state.values.fill(0);
|
|
22498
|
-
state.values.set(weights.slice(0, state.values.length));
|
|
22499
|
-
if (state.data instanceof import_core34.Buffer) {
|
|
22500
|
-
state.data.write(state.values);
|
|
22501
|
-
} else {
|
|
22502
|
-
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|
|
22503
|
-
}
|
|
22504
|
-
}
|
|
22505
|
-
|
|
22506
|
-
// src/animation/node-animation-binding.ts
|
|
22507
|
-
function makeNodeAnimationBinding(node, property, options = {}) {
|
|
22508
|
-
return {
|
|
22509
|
-
id: options.id,
|
|
22510
|
-
getValue: () => {
|
|
22511
|
-
switch (property) {
|
|
22512
|
-
case "translation":
|
|
22513
|
-
return Array.from(node.position);
|
|
22514
|
-
case "rotation":
|
|
22515
|
-
return Array.from(node.rotation);
|
|
22516
|
-
case "scale":
|
|
22517
|
-
return Array.from(node.scale);
|
|
22518
|
-
case "weights":
|
|
22519
|
-
return Array.from(node.userData["morphWeights"] ?? []);
|
|
22520
|
-
case "visibility":
|
|
22521
|
-
return [node.display ? 1 : 0];
|
|
22522
|
-
case "selectable":
|
|
22523
|
-
return [node.selectable ? 1 : 0];
|
|
22524
|
-
case "hoverable":
|
|
22525
|
-
return [node.hoverable ? 1 : 0];
|
|
22526
|
-
}
|
|
22527
|
-
},
|
|
22528
|
-
setValue: (value) => {
|
|
22529
|
-
switch (property) {
|
|
22530
|
-
case "translation":
|
|
22531
|
-
node.setPosition(value).updateMatrix();
|
|
22532
|
-
break;
|
|
22533
|
-
case "rotation":
|
|
22534
|
-
node.setRotation(value).updateMatrix();
|
|
22535
|
-
break;
|
|
22536
|
-
case "scale":
|
|
22537
|
-
node.setScale(value).updateMatrix();
|
|
22538
|
-
break;
|
|
22539
|
-
case "weights":
|
|
22540
|
-
setMorphWeights(node, value);
|
|
22541
|
-
break;
|
|
22542
|
-
case "selectable":
|
|
22543
|
-
node.setProps({ selectable: value[0] !== 0 });
|
|
22544
|
-
break;
|
|
22545
|
-
case "hoverable":
|
|
22546
|
-
node.setProps({ hoverable: value[0] !== 0 });
|
|
22547
|
-
break;
|
|
22548
|
-
case "visibility":
|
|
22549
|
-
node.setProps({ display: value[0] !== 0 });
|
|
22550
|
-
options.onVisibilityChange?.();
|
|
22551
|
-
break;
|
|
22552
|
-
}
|
|
22553
|
-
}
|
|
22554
|
-
};
|
|
22555
|
-
}
|
|
22556
|
-
|
|
22557
23152
|
// src/animation/scenegraph-animator.ts
|
|
22558
23153
|
var ScenegraphAnimator = class extends Animator {
|
|
22559
23154
|
mixer;
|