@luma.gl/engine 10.0.0-alpha.8 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -4
- package/THIRD-PARTY-NOTICES.md +185 -0
- package/dist/animation/node-animation-binding.cjs +10 -0
- package/dist/animation/node-animation-binding.d.ts +1 -1
- package/dist/animation/node-animation-binding.d.ts.map +1 -1
- package/dist/animation/node-animation-binding.js +10 -0
- package/dist/animation/node-animation-binding.js.map +1 -1
- package/dist/arrow/index.cjs +5 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -0
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -0
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +161 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts +34 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts.map +1 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js +164 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js.map +1 -0
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.d.ts +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.d.ts.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.js.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.cjs +10 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.d.ts.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js +10 -3
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js.map +1 -1
- package/dist/compute/computation.cjs +1 -1
- package/dist/compute/computation.js +1 -1
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts +2 -2
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +1149 -657
- package/dist/dist.min.js +76 -69
- package/dist/dynamic-texture/video-texture.cjs +1 -1
- package/dist/dynamic-texture/video-texture.d.ts +3 -3
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/video-texture.js +1 -1
- package/dist/dynamic-texture/video-texture.js.map +1 -1
- package/dist/effects/index.cjs.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js +2 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.cjs +14 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +7 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.js +17 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -1
- package/dist/geometry/gpu-vector-geometry.cjs +3 -0
- package/dist/geometry/gpu-vector-geometry.d.ts +2 -0
- package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry.js +2 -0
- package/dist/geometry/gpu-vector-geometry.js.map +1 -1
- package/dist/gltf/gltf/animations/animations.d.ts +1 -1
- package/dist/gltf/gltf/animations/animations.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.cjs +3 -0
- package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.js +4 -0
- package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +80 -12
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +8 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +82 -14
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.cjs +6 -1
- package/dist/gltf/gltf/gltf-billboard.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.js +6 -1
- package/dist/gltf/gltf/gltf-billboard.js.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.cjs +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
- package/dist/gltf/index.cjs +2 -0
- 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 +1 -1
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-animations.cjs +8 -5
- package/dist/gltf/parsers/parse-gltf-animations.js +20 -5
- package/dist/gltf/parsers/parse-gltf-animations.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.cjs +36 -72
- package/dist/gltf/parsers/parse-gltf-lights.d.ts +6 -2
- package/dist/gltf/parsers/parse-gltf-lights.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.js +34 -91
- package/dist/gltf/parsers/parse-gltf-lights.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-metadata.cjs +60 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts +5 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts.map +1 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js +39 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js.map +1 -0
- package/dist/gltf/parsers/parse-gltf.cjs +23 -14
- package/dist/gltf/parsers/parse-gltf.d.ts +12 -2
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +21 -13
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/parsers/parse-pbr-material.cjs +13 -3
- package/dist/gltf/parsers/parse-pbr-material.d.ts +7 -2
- package/dist/gltf/parsers/parse-pbr-material.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-pbr-material.js +17 -5
- package/dist/gltf/parsers/parse-pbr-material.js.map +1 -1
- package/dist/gltf/parsers/post-process-gltf.cjs +1 -0
- package/dist/gltf/parsers/post-process-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/post-process-gltf.js +1 -0
- package/dist/gltf/parsers/post-process-gltf.js.map +1 -1
- package/dist/gltf/pbr/pbr-environment.cjs +21 -3
- package/dist/gltf/pbr/pbr-environment.d.ts +3 -0
- package/dist/gltf/pbr/pbr-environment.d.ts.map +1 -1
- package/dist/gltf/pbr/pbr-environment.js +19 -1
- package/dist/gltf/pbr/pbr-environment.js.map +1 -1
- package/dist/gltf/pbr/pbr-material.d.ts +3 -3
- package/dist/gltf/pbr/pbr-material.d.ts.map +1 -1
- package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-json-schema.js +1 -0
- package/dist/gltf/types/gltf-json-schema.js.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts +2 -0
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.js +1 -0
- package/dist/gltf/types/gltf-postprocessed-schema.js.map +1 -1
- package/dist/gltf/types/gltf-types.d.ts +19 -0
- package/dist/gltf/types/gltf-types.d.ts.map +1 -1
- package/dist/graph/models/index.cjs.map +1 -1
- package/dist/graph/models/path/path-attribute-model.cjs +4 -1
- package/dist/graph/models/path/path-attribute-model.d.ts +3 -1
- package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-attribute-model.js +6 -1
- package/dist/graph/models/path/path-attribute-model.js.map +1 -1
- package/dist/graph/models/path/path-storage-model.cjs +4 -1
- package/dist/graph/models/path/path-storage-model.d.ts +3 -1
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-storage-model.js +6 -1
- package/dist/graph/models/path/path-storage-model.js.map +1 -1
- package/dist/graph/physics/index.cjs.map +2 -2
- package/dist/graph/physics/physics-controller.cjs +42 -0
- package/dist/graph/physics/physics-controller.d.ts +12 -1
- package/dist/graph/physics/physics-controller.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller.js +41 -0
- package/dist/graph/physics/physics-controller.js.map +1 -1
- package/dist/graph/physics/scenegraph-instance.cjs +7 -0
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +8 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/tables/gpu-table-model.cjs +2 -2
- package/dist/graph/tables/gpu-table-model.d.ts +2 -1
- package/dist/graph/tables/gpu-table-model.d.ts.map +1 -1
- package/dist/graph/tables/gpu-table-model.js +2 -2
- package/dist/graph/tables/gpu-table-model.js.map +1 -1
- package/dist/graph/tables/index.cjs.map +1 -1
- 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 +126 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts +31 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -0
- package/dist/lighting/ambient-occlusion-pass.js +108 -0
- package/dist/lighting/ambient-occlusion-pass.js.map +1 -0
- package/dist/lighting/clustered-light-grid.cjs +378 -0
- package/dist/lighting/clustered-light-grid.d.ts +94 -0
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -0
- package/dist/lighting/clustered-light-grid.js +370 -0
- package/dist/lighting/clustered-light-grid.js.map +1 -0
- package/dist/lighting/contact-shadow-composite.cjs +80 -0
- package/dist/lighting/contact-shadow-composite.d.ts +6 -0
- package/dist/lighting/contact-shadow-composite.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-composite.js +59 -0
- package/dist/lighting/contact-shadow-composite.js.map +1 -0
- package/dist/lighting/contact-shadow-pass.cjs +102 -0
- package/dist/lighting/contact-shadow-pass.d.ts +23 -0
- package/dist/lighting/contact-shadow-pass.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-pass.js +85 -0
- package/dist/lighting/contact-shadow-pass.js.map +1 -0
- package/dist/lighting/index.cjs +128 -0
- package/dist/lighting/index.cjs.map +6 -0
- package/dist/lighting/index.d.ts +35 -0
- package/dist/lighting/index.d.ts.map +1 -0
- package/dist/lighting/index.js +22 -0
- package/dist/lighting/index.js.map +1 -0
- package/dist/lighting/lightmap-atlas.cjs +246 -0
- package/dist/lighting/lightmap-atlas.d.ts +53 -0
- package/dist/lighting/lightmap-atlas.d.ts.map +1 -0
- package/dist/lighting/lightmap-atlas.js +279 -0
- package/dist/lighting/lightmap-atlas.js.map +1 -0
- package/dist/lighting/lightmap-baker.cjs +238 -0
- package/dist/lighting/lightmap-baker.d.ts +62 -0
- package/dist/lighting/lightmap-baker.d.ts.map +1 -0
- package/dist/lighting/lightmap-baker.js +236 -0
- package/dist/lighting/lightmap-baker.js.map +1 -0
- package/dist/lighting/lightmap-data.cjs +117 -0
- package/dist/lighting/lightmap-data.d.ts +20 -0
- package/dist/lighting/lightmap-data.d.ts.map +1 -0
- package/dist/lighting/lightmap-data.js +110 -0
- package/dist/lighting/lightmap-data.js.map +1 -0
- package/dist/lighting/lightmap-environment.cjs +61 -0
- package/dist/lighting/lightmap-environment.d.ts +18 -0
- package/dist/lighting/lightmap-environment.d.ts.map +1 -0
- package/dist/lighting/lightmap-environment.js +46 -0
- package/dist/lighting/lightmap-environment.js.map +1 -0
- package/dist/lighting/pbr-environment.cjs +45 -0
- package/dist/lighting/pbr-environment.d.ts +25 -0
- package/dist/lighting/pbr-environment.d.ts.map +1 -0
- package/dist/lighting/pbr-environment.js +30 -0
- package/dist/lighting/pbr-environment.js.map +1 -0
- package/dist/lighting/pbr-material.cjs +75 -0
- package/dist/lighting/pbr-material.d.ts +33 -0
- package/dist/lighting/pbr-material.d.ts.map +1 -0
- package/dist/lighting/pbr-material.js +52 -0
- package/dist/lighting/pbr-material.js.map +1 -0
- package/dist/lighting/pbr-model.cjs +579 -0
- package/dist/lighting/pbr-model.d.ts +45 -0
- package/dist/lighting/pbr-model.d.ts.map +1 -0
- package/dist/lighting/pbr-model.js +545 -0
- package/dist/lighting/pbr-model.js.map +1 -0
- package/dist/lighting/pbr-surface-pass.cjs +116 -0
- package/dist/lighting/pbr-surface-pass.d.ts +35 -0
- package/dist/lighting/pbr-surface-pass.d.ts.map +1 -0
- package/dist/lighting/pbr-surface-pass.js +98 -0
- package/dist/lighting/pbr-surface-pass.js.map +1 -0
- package/dist/lighting/prefiltered-environment.cjs +275 -0
- package/dist/lighting/prefiltered-environment.d.ts +56 -0
- package/dist/lighting/prefiltered-environment.d.ts.map +1 -0
- package/dist/lighting/prefiltered-environment.js +264 -0
- package/dist/lighting/prefiltered-environment.js.map +1 -0
- package/dist/lighting/reflection-probe.cjs +321 -0
- package/dist/lighting/reflection-probe.d.ts +77 -0
- package/dist/lighting/reflection-probe.d.ts.map +1 -0
- package/dist/lighting/reflection-probe.js +298 -0
- package/dist/lighting/reflection-probe.js.map +1 -0
- package/dist/lighting/shadow-map-renderer.cjs +631 -0
- package/dist/lighting/shadow-map-renderer.d.ts +92 -0
- package/dist/lighting/shadow-map-renderer.d.ts.map +1 -0
- package/dist/lighting/shadow-map-renderer.js +622 -0
- package/dist/lighting/shadow-map-renderer.js.map +1 -0
- package/dist/lighting/shadow-quality.cjs +58 -0
- package/dist/lighting/shadow-quality.d.ts +13 -0
- package/dist/lighting/shadow-quality.d.ts.map +1 -0
- package/dist/lighting/shadow-quality.js +37 -0
- package/dist/lighting/shadow-quality.js.map +1 -0
- package/dist/material/material.cjs +3 -0
- package/dist/material/material.d.ts +2 -0
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +3 -0
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-bindings.cjs +10 -3
- package/dist/model/gpu-vector-bindings.d.ts +1 -1
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -1
- package/dist/model/gpu-vector-bindings.js +12 -3
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +4 -3
- package/dist/model/gpu-vector-draw-batches.d.ts +1 -1
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-draw-batches.js +4 -3
- package/dist/model/gpu-vector-draw-batches.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +42 -17
- package/dist/model/gpu-vector-model.d.ts +28 -4
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +49 -17
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/models/light-model-utils.cjs +2 -2
- package/dist/models/light-model-utils.d.ts +2 -1
- package/dist/models/light-model-utils.d.ts.map +1 -1
- package/dist/models/light-model-utils.js +2 -2
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/scenegraph/controllers/punctual-light-controller.cjs +121 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js +117 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js.map +1 -0
- package/dist/scenegraph/scene-metadata.cjs +43 -0
- package/dist/scenegraph/scene-metadata.d.ts +9 -0
- package/dist/scenegraph/scene-metadata.d.ts.map +1 -0
- package/dist/scenegraph/scene-metadata.js +21 -0
- package/dist/scenegraph/scene-metadata.js.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.cjs +99 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts +47 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.js +79 -0
- package/dist/scenegraph/scenegraph-interaction.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.cjs +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +10 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/splats/index.cjs.map +1 -1
- package/dist/splats/splat-data.cjs +34 -23
- package/dist/splats/splat-data.d.ts.map +1 -1
- package/dist/splats/splat-data.js +34 -22
- package/dist/splats/splat-data.js.map +1 -1
- package/dist/text/experimental.cjs.map +1 -1
- package/dist/text/fonts/atlas/text-utils.cjs +1 -1
- package/dist/text/fonts/atlas/text-utils.js +1 -1
- package/dist/text/fonts/atlas/text-utils.js.map +1 -1
- package/dist/text/fonts/index.cjs.map +1 -1
- package/dist/text/index.cjs +2 -0
- package/dist/text/index.cjs.map +2 -2
- package/dist/text/index.d.ts +1 -1
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +1 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/text-2d/index.cjs +3 -0
- package/dist/text/text-2d/index.d.ts +1 -0
- package/dist/text/text-2d/index.d.ts.map +1 -1
- package/dist/text/text-2d/index.js +1 -0
- package/dist/text/text-2d/index.js.map +1 -1
- package/dist/text/text-2d/model-utils/text-code-point-source.cjs +41 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.d.ts +8 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.d.ts.map +1 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.js +23 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.js.map +1 -0
- package/dist/text/text-2d/models/text-attribute-model.cjs +4 -1
- package/dist/text/text-2d/models/text-attribute-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-attribute-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-attribute-model.js +6 -1
- package/dist/text/text-2d/models/text-attribute-model.js.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.cjs +4 -1
- package/dist/text/text-2d/models/text-dictionary-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-dictionary-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.js +6 -1
- package/dist/text/text-2d/models/text-dictionary-model.js.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.cjs +4 -1
- package/dist/text/text-2d/models/text-storage-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-storage-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.js +6 -1
- package/dist/text/text-2d/models/text-storage-model.js.map +1 -1
- package/licenses/cesium.txt +207 -0
- package/licenses/deck-community.txt +19 -0
- package/licenses/deck.txt +19 -0
- package/licenses/glfx.txt +19 -0
- package/licenses/gltf-loader-ts.txt +21 -0
- package/licenses/magenta-font.txt +13 -0
- package/licenses/nvidia-fxaa.txt +25 -0
- package/licenses/philogl.txt +19 -0
- package/licenses/spark.txt +21 -0
- package/licenses/three.txt +21 -0
- package/package.json +17 -9
- package/src/animation/node-animation-binding.ts +18 -1
- package/src/arrow/index.ts +6 -0
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +224 -0
- package/src/arrow/renderers/text/renderers/arrow-text-renderer.ts +1 -0
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +12 -5
- package/src/compute/computation.ts +1 -1
- package/src/compute/swap.ts +2 -2
- package/src/dynamic-texture/video-texture.ts +9 -3
- package/src/effects/passes/postprocessing/fxaa/fxaa.ts +2 -1
- package/src/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/denoise.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/noise.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/sepia.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/vibrance.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/vignette.ts +2 -0
- package/src/geometry/gpu-vector-geometry-adapter.ts +19 -1
- package/src/geometry/gpu-vector-geometry.ts +3 -0
- package/src/gltf/gltf/animations/animations.ts +8 -1
- package/src/gltf/gltf/create-gltf-model.ts +4 -0
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
- package/src/gltf/gltf/gltf-billboard.ts +6 -1
- package/src/gltf/gltf/gltf-extension-support.ts +2 -2
- package/src/gltf/index.ts +2 -0
- package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
- package/src/gltf/parsers/parse-gltf-lights.ts +42 -130
- package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
- package/src/gltf/parsers/parse-gltf.ts +32 -16
- package/src/gltf/parsers/parse-pbr-material.ts +35 -7
- package/src/gltf/parsers/post-process-gltf.ts +1 -0
- package/src/gltf/pbr/pbr-environment.ts +27 -1
- package/src/gltf/pbr/pbr-material.ts +8 -3
- package/src/gltf/types/gltf-json-schema.ts +1 -0
- package/src/gltf/types/gltf-postprocessed-schema.ts +3 -0
- package/src/gltf/types/gltf-types.ts +20 -0
- package/src/graph/models/path/path-attribute-model.ts +10 -1
- package/src/graph/models/path/path-storage-model.ts +10 -1
- package/src/graph/physics/physics-controller.ts +55 -1
- package/src/graph/physics/scenegraph-instance.ts +10 -0
- package/src/graph/tables/gpu-table-model.ts +3 -2
- package/src/index.ts +19 -0
- package/src/lighting/ambient-occlusion-pass.ts +130 -0
- package/src/lighting/clustered-light-grid.ts +481 -0
- package/src/lighting/contact-shadow-composite.ts +67 -0
- package/src/lighting/contact-shadow-pass.ts +107 -0
- package/src/lighting/index.ts +125 -0
- package/src/lighting/lightmap-atlas.ts +348 -0
- package/src/lighting/lightmap-baker.ts +306 -0
- package/src/lighting/lightmap-data.ts +138 -0
- package/src/lighting/lightmap-environment.ts +70 -0
- package/src/lighting/pbr-environment.ts +55 -0
- package/src/lighting/pbr-material.ts +85 -0
- package/src/lighting/pbr-model.ts +608 -0
- package/src/lighting/pbr-surface-pass.ts +122 -0
- package/src/lighting/prefiltered-environment.ts +354 -0
- package/src/lighting/reflection-probe.ts +360 -0
- package/src/lighting/shadow-map-renderer.ts +918 -0
- package/src/lighting/shadow-quality.ts +50 -0
- package/src/material/material.ts +3 -0
- package/src/model/gpu-vector-bindings.ts +11 -3
- package/src/model/gpu-vector-draw-batches.ts +12 -10
- package/src/model/gpu-vector-model.ts +96 -20
- package/src/model/model.ts +1 -1
- package/src/models/light-model-utils.ts +3 -2
- package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
- package/src/scenegraph/scene-metadata.ts +23 -0
- package/src/scenegraph/scenegraph-interaction.ts +131 -0
- package/src/scenegraph/scenegraph-node.ts +12 -0
- package/src/splats/README.md +46 -0
- package/src/splats/splat-data.ts +53 -45
- package/src/text/fonts/atlas/text-utils.ts +1 -1
- package/src/text/index.ts +1 -0
- package/src/text/text-2d/index.ts +1 -0
- package/src/text/text-2d/model-utils/text-code-point-source.ts +34 -0
- package/src/text/text-2d/models/text-attribute-model.ts +10 -1
- package/src/text/text-2d/models/text-dictionary-model.ts +10 -1
- package/src/text/text-2d/models/text-storage-model.ts +10 -1
package/dist/dist.dev.js
CHANGED
|
@@ -104,8 +104,11 @@ var __exports__ = (() => {
|
|
|
104
104
|
PickingManager: () => PickingManager,
|
|
105
105
|
PlaneGeometry: () => PlaneGeometry2,
|
|
106
106
|
PointLightModel: () => PointLightModel,
|
|
107
|
+
PunctualLightController: () => PunctualLightController,
|
|
107
108
|
RingGeometry: () => RingGeometry,
|
|
109
|
+
SceneMetadata: () => SceneMetadata,
|
|
108
110
|
ScenegraphAnimator: () => ScenegraphAnimator,
|
|
111
|
+
ScenegraphInteractionManager: () => ScenegraphInteractionManager,
|
|
109
112
|
ScenegraphNode: () => ScenegraphNode,
|
|
110
113
|
ShaderInputs: () => ShaderInputs,
|
|
111
114
|
ShaderPassRenderer: () => ShaderPassRenderer,
|
|
@@ -131,6 +134,7 @@ var __exports__ = (() => {
|
|
|
131
134
|
decomposePhysicsTransform: () => decomposePhysicsTransform,
|
|
132
135
|
deformPositions: () => deformPositions,
|
|
133
136
|
evaluateAnimationSampler: () => evaluateAnimationSampler,
|
|
137
|
+
getFirstScenegraphInteractionHit: () => getFirstScenegraphInteractionHit,
|
|
134
138
|
getGPUVectorModelBatches: () => getGPUVectorModelBatches,
|
|
135
139
|
getIndexPickingModule: () => getIndexPickingModule,
|
|
136
140
|
getPlatformInfo: () => getPlatformInfo,
|
|
@@ -138,6 +142,7 @@ var __exports__ = (() => {
|
|
|
138
142
|
getTextureTransformMatrix: () => getTextureTransformMatrix,
|
|
139
143
|
indexColorPicking: () => picking2,
|
|
140
144
|
indexPicking: () => picking3,
|
|
145
|
+
isScenegraphInteractionEnabled: () => isScenegraphInteractionEnabled,
|
|
141
146
|
legacyColorPicking: () => legacyColorPicking,
|
|
142
147
|
loadImage: () => loadImage,
|
|
143
148
|
loadImageBitmap: () => loadImageBitmap,
|
|
@@ -145,6 +150,7 @@ var __exports__ = (() => {
|
|
|
145
150
|
makeAnimationLoop: () => makeAnimationLoop,
|
|
146
151
|
makeEdgeGeometry: () => makeEdgeGeometry,
|
|
147
152
|
makeEdgeGeometryFromGeometries: () => makeEdgeGeometryFromGeometries,
|
|
153
|
+
makeGPUVectorGeometry: () => makeGPUVectorGeometry,
|
|
148
154
|
makeInterleavedGeometry: () => makeInterleavedGeometry,
|
|
149
155
|
makeMaterialAnimationBinding: () => makeMaterialAnimationBinding,
|
|
150
156
|
makeNodeAnimationBinding: () => makeNodeAnimationBinding,
|
|
@@ -1697,18 +1703,6 @@ var __exports__ = (() => {
|
|
|
1697
1703
|
}
|
|
1698
1704
|
|
|
1699
1705
|
// ../../node_modules/@math.gl/core/dist/classes/matrix3.js
|
|
1700
|
-
var INDICES;
|
|
1701
|
-
(function(INDICES3) {
|
|
1702
|
-
INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
|
|
1703
|
-
INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
|
|
1704
|
-
INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
|
|
1705
|
-
INDICES3[INDICES3["COL1ROW0"] = 3] = "COL1ROW0";
|
|
1706
|
-
INDICES3[INDICES3["COL1ROW1"] = 4] = "COL1ROW1";
|
|
1707
|
-
INDICES3[INDICES3["COL1ROW2"] = 5] = "COL1ROW2";
|
|
1708
|
-
INDICES3[INDICES3["COL2ROW0"] = 6] = "COL2ROW0";
|
|
1709
|
-
INDICES3[INDICES3["COL2ROW1"] = 7] = "COL2ROW1";
|
|
1710
|
-
INDICES3[INDICES3["COL2ROW2"] = 8] = "COL2ROW2";
|
|
1711
|
-
})(INDICES || (INDICES = {}));
|
|
1712
1706
|
var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
1713
1707
|
var Matrix3 = class extends Matrix {
|
|
1714
1708
|
static get IDENTITY() {
|
|
@@ -1723,9 +1717,6 @@ var __exports__ = (() => {
|
|
|
1723
1717
|
get RANK() {
|
|
1724
1718
|
return 3;
|
|
1725
1719
|
}
|
|
1726
|
-
get INDICES() {
|
|
1727
|
-
return INDICES;
|
|
1728
|
-
}
|
|
1729
1720
|
constructor(array) {
|
|
1730
1721
|
super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
|
|
1731
1722
|
if (arguments.length === 1 && Array.isArray(array)) {
|
|
@@ -2501,6 +2492,35 @@ var __exports__ = (() => {
|
|
|
2501
2492
|
out[15] = 1;
|
|
2502
2493
|
return out;
|
|
2503
2494
|
}
|
|
2495
|
+
function affineComponents(matrix) {
|
|
2496
|
+
if (matrix.length !== 16 || Array.from(matrix).some((x) => !Number.isFinite(x)) || matrix[3] !== 0 || matrix[7] !== 0 || matrix[11] !== 0 || matrix[15] !== 1) {
|
|
2497
|
+
throw new RangeError("Expected a finite affine matrix");
|
|
2498
|
+
}
|
|
2499
|
+
const scale5 = [
|
|
2500
|
+
Math.hypot(matrix[0], matrix[1], matrix[2]),
|
|
2501
|
+
Math.hypot(matrix[4], matrix[5], matrix[6]),
|
|
2502
|
+
Math.hypot(matrix[8], matrix[9], matrix[10])
|
|
2503
|
+
];
|
|
2504
|
+
if (scale5.some((x) => x === 0 || !Number.isFinite(x)))
|
|
2505
|
+
throw new RangeError("Singular transform");
|
|
2506
|
+
const rotation = Array.from({ length: 9 }, (_, i) => matrix[Math.floor(i / 3) * 4 + i % 3] / scale5[Math.floor(i / 3)]);
|
|
2507
|
+
for (const [a, b] of [
|
|
2508
|
+
[0, 3],
|
|
2509
|
+
[0, 6],
|
|
2510
|
+
[3, 6]
|
|
2511
|
+
]) {
|
|
2512
|
+
if (Math.abs(rotation[a] * rotation[b] + rotation[a + 1] * rotation[b + 1] + rotation[a + 2] * rotation[b + 2]) > 1e-7) {
|
|
2513
|
+
throw new RangeError("Sheared transforms do not have a TRS decomposition");
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
const determinant3 = rotation[0] * (rotation[4] * rotation[8] - rotation[5] * rotation[7]) - rotation[3] * (rotation[1] * rotation[8] - rotation[2] * rotation[7]) + rotation[6] * (rotation[1] * rotation[5] - rotation[2] * rotation[4]);
|
|
2517
|
+
if (determinant3 < 0) {
|
|
2518
|
+
scale5[0] = -scale5[0];
|
|
2519
|
+
for (let i = 0; i < 3; i++)
|
|
2520
|
+
rotation[i] = -rotation[i];
|
|
2521
|
+
}
|
|
2522
|
+
return { rotation, scale: scale5, translation: [matrix[12], matrix[13], matrix[14]] };
|
|
2523
|
+
}
|
|
2504
2524
|
|
|
2505
2525
|
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
|
|
2506
2526
|
function add(out, a, b) {
|
|
@@ -2573,25 +2593,6 @@ var __exports__ = (() => {
|
|
|
2573
2593
|
}
|
|
2574
2594
|
|
|
2575
2595
|
// ../../node_modules/@math.gl/core/dist/classes/matrix4.js
|
|
2576
|
-
var INDICES2;
|
|
2577
|
-
(function(INDICES3) {
|
|
2578
|
-
INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
|
|
2579
|
-
INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
|
|
2580
|
-
INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
|
|
2581
|
-
INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3";
|
|
2582
|
-
INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0";
|
|
2583
|
-
INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1";
|
|
2584
|
-
INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2";
|
|
2585
|
-
INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3";
|
|
2586
|
-
INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0";
|
|
2587
|
-
INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1";
|
|
2588
|
-
INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2";
|
|
2589
|
-
INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3";
|
|
2590
|
-
INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0";
|
|
2591
|
-
INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1";
|
|
2592
|
-
INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2";
|
|
2593
|
-
INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3";
|
|
2594
|
-
})(INDICES2 || (INDICES2 = {}));
|
|
2595
2596
|
var DEFAULT_FOVY = 45 * Math.PI / 180;
|
|
2596
2597
|
var DEFAULT_ASPECT = 1;
|
|
2597
2598
|
var DEFAULT_NEAR = 0.1;
|
|
@@ -2610,9 +2611,6 @@ var __exports__ = (() => {
|
|
|
2610
2611
|
get RANK() {
|
|
2611
2612
|
return 4;
|
|
2612
2613
|
}
|
|
2613
|
-
get INDICES() {
|
|
2614
|
-
return INDICES2;
|
|
2615
|
-
}
|
|
2616
2614
|
constructor(array) {
|
|
2617
2615
|
super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
|
|
2618
2616
|
if (arguments.length === 1 && Array.isArray(array)) {
|
|
@@ -2852,27 +2850,15 @@ var __exports__ = (() => {
|
|
|
2852
2850
|
* @returns self
|
|
2853
2851
|
*/
|
|
2854
2852
|
getRotation(result, scaleResult) {
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
result[3] = 0;
|
|
2865
|
-
result[4] = this[4] * inverseScale0;
|
|
2866
|
-
result[5] = this[5] * inverseScale1;
|
|
2867
|
-
result[6] = this[6] * inverseScale2;
|
|
2868
|
-
result[7] = 0;
|
|
2869
|
-
result[8] = this[8] * inverseScale0;
|
|
2870
|
-
result[9] = this[9] * inverseScale1;
|
|
2871
|
-
result[10] = this[10] * inverseScale2;
|
|
2872
|
-
result[11] = 0;
|
|
2873
|
-
result[12] = 0;
|
|
2874
|
-
result[13] = 0;
|
|
2875
|
-
result[14] = 0;
|
|
2853
|
+
const { rotation, scale: scale5 } = affineComponents(this);
|
|
2854
|
+
result = result || new Array(16);
|
|
2855
|
+
if (scaleResult)
|
|
2856
|
+
for (let i = 0; i < 3; i++)
|
|
2857
|
+
scaleResult[i] = scale5[i];
|
|
2858
|
+
for (let i = 0; i < 16; i++)
|
|
2859
|
+
result[i] = 0;
|
|
2860
|
+
for (let i = 0; i < 9; i++)
|
|
2861
|
+
result[Math.floor(i / 3) * 4 + i % 3] = rotation[i];
|
|
2876
2862
|
result[15] = 1;
|
|
2877
2863
|
return result;
|
|
2878
2864
|
}
|
|
@@ -2883,21 +2869,13 @@ var __exports__ = (() => {
|
|
|
2883
2869
|
* @returns self
|
|
2884
2870
|
*/
|
|
2885
2871
|
getRotationMatrix3(result, scaleResult) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
result[1] = this[1] * inverseScale1;
|
|
2894
|
-
result[2] = this[2] * inverseScale2;
|
|
2895
|
-
result[3] = this[4] * inverseScale0;
|
|
2896
|
-
result[4] = this[5] * inverseScale1;
|
|
2897
|
-
result[5] = this[6] * inverseScale2;
|
|
2898
|
-
result[6] = this[8] * inverseScale0;
|
|
2899
|
-
result[7] = this[9] * inverseScale1;
|
|
2900
|
-
result[8] = this[10] * inverseScale2;
|
|
2872
|
+
const { rotation, scale: scale5 } = affineComponents(this);
|
|
2873
|
+
result = result || new Array(9);
|
|
2874
|
+
if (scaleResult)
|
|
2875
|
+
for (let i = 0; i < 3; i++)
|
|
2876
|
+
scaleResult[i] = scale5[i];
|
|
2877
|
+
for (let i = 0; i < 9; i++)
|
|
2878
|
+
result[i] = rotation[i];
|
|
2901
2879
|
return result;
|
|
2902
2880
|
}
|
|
2903
2881
|
// Modifiers
|
|
@@ -3290,6 +3268,28 @@ var __exports__ = (() => {
|
|
|
3290
3268
|
return normalize3(out, out);
|
|
3291
3269
|
};
|
|
3292
3270
|
})();
|
|
3271
|
+
function rotateTowards(out, a, b, step) {
|
|
3272
|
+
if (a.length !== 4 || b.length !== 4 || [...Array.from(a), ...Array.from(b), step].some((x) => !Number.isFinite(x))) {
|
|
3273
|
+
throw new RangeError("Expected finite quaternions and step");
|
|
3274
|
+
}
|
|
3275
|
+
if (a.length !== 4 || step < 0)
|
|
3276
|
+
throw new RangeError("Expected quaternions and a nonnegative step");
|
|
3277
|
+
const aScale = Math.max(...Array.from(a, Math.abs)), bScale = Math.max(...Array.from(b, Math.abs));
|
|
3278
|
+
if (!aScale || !bScale)
|
|
3279
|
+
throw new RangeError("Zero quaternion");
|
|
3280
|
+
const an = Array.from(a, (x) => x / aScale), bn = Array.from(b, (x) => x / bScale);
|
|
3281
|
+
const al = Math.hypot(...an), bl = Math.hypot(...bn);
|
|
3282
|
+
for (let i = 0; i < 4; i++) {
|
|
3283
|
+
an[i] /= al;
|
|
3284
|
+
bn[i] /= bl;
|
|
3285
|
+
}
|
|
3286
|
+
const dot4 = an.reduce((sum, x, i) => sum + x * bn[i], 0);
|
|
3287
|
+
const angle2 = 2 * Math.acos(Math.min(1, Math.abs(dot4)));
|
|
3288
|
+
if (out.length < 4)
|
|
3289
|
+
throw new RangeError("Result buffer is too short");
|
|
3290
|
+
slerp(out, an, bn, angle2 === 0 ? 0 : Math.min(1, step / angle2));
|
|
3291
|
+
return out;
|
|
3292
|
+
}
|
|
3293
3293
|
|
|
3294
3294
|
// ../../node_modules/@math.gl/core/dist/classes/quaternion.js
|
|
3295
3295
|
var Quaternion = class extends MathArray {
|
|
@@ -3362,6 +3362,9 @@ var __exports__ = (() => {
|
|
|
3362
3362
|
return this.check();
|
|
3363
3363
|
}
|
|
3364
3364
|
/** Set a quat to the identity quaternion */
|
|
3365
|
+
rotateTowards(target, step) {
|
|
3366
|
+
return rotateTowards(this, this, target, step);
|
|
3367
|
+
}
|
|
3365
3368
|
identity() {
|
|
3366
3369
|
identity2(this);
|
|
3367
3370
|
return this.check();
|
|
@@ -5731,184 +5734,6 @@ var __exports__ = (() => {
|
|
|
5731
5734
|
return typeof value;
|
|
5732
5735
|
}
|
|
5733
5736
|
|
|
5734
|
-
// ../shaders/src/module-injectors.ts
|
|
5735
|
-
var MODULE_INJECTORS_VS = (
|
|
5736
|
-
/* glsl */
|
|
5737
|
-
`#ifdef MODULE_LOGDEPTH
|
|
5738
|
-
logdepth_adjustPosition(gl_Position);
|
|
5739
|
-
#endif
|
|
5740
|
-
`
|
|
5741
|
-
);
|
|
5742
|
-
var MODULE_INJECTORS_FS = (
|
|
5743
|
-
/* glsl */
|
|
5744
|
-
`#ifdef MODULE_MATERIAL
|
|
5745
|
-
fragColor = material_filterColor(fragColor);
|
|
5746
|
-
#endif
|
|
5747
|
-
|
|
5748
|
-
#ifdef MODULE_LIGHTING
|
|
5749
|
-
fragColor = lighting_filterColor(fragColor);
|
|
5750
|
-
#endif
|
|
5751
|
-
|
|
5752
|
-
#ifdef MODULE_FOG
|
|
5753
|
-
fragColor = fog_filterColor(fragColor);
|
|
5754
|
-
#endif
|
|
5755
|
-
|
|
5756
|
-
#ifdef MODULE_PICKING
|
|
5757
|
-
fragColor = picking_filterHighlightColor(fragColor);
|
|
5758
|
-
fragColor = picking_filterPickingColor(fragColor);
|
|
5759
|
-
#endif
|
|
5760
|
-
|
|
5761
|
-
#ifdef MODULE_LOGDEPTH
|
|
5762
|
-
logdepth_setFragDepth();
|
|
5763
|
-
#endif
|
|
5764
|
-
`
|
|
5765
|
-
);
|
|
5766
|
-
|
|
5767
|
-
// ../shaders/src/lib/shader-assembly/shader-injections.ts
|
|
5768
|
-
var MODULE_INJECTORS = {
|
|
5769
|
-
vertex: MODULE_INJECTORS_VS,
|
|
5770
|
-
fragment: MODULE_INJECTORS_FS
|
|
5771
|
-
};
|
|
5772
|
-
var REGEX_START_OF_MAIN = /void\s+main\s*\([^)]*\)\s*\{\n?/;
|
|
5773
|
-
var REGEX_END_OF_MAIN = /}\n?[^{}]*$/;
|
|
5774
|
-
var fragments = [];
|
|
5775
|
-
var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
|
|
5776
|
-
function normalizeInjections(injections) {
|
|
5777
|
-
const result = { vertex: {}, fragment: {} };
|
|
5778
|
-
for (const hook in injections) {
|
|
5779
|
-
let injection = injections[hook];
|
|
5780
|
-
const stage = getHookStage(hook);
|
|
5781
|
-
if (typeof injection === "string") {
|
|
5782
|
-
injection = {
|
|
5783
|
-
order: 0,
|
|
5784
|
-
injection
|
|
5785
|
-
};
|
|
5786
|
-
}
|
|
5787
|
-
result[stage][hook] = injection;
|
|
5788
|
-
}
|
|
5789
|
-
return result;
|
|
5790
|
-
}
|
|
5791
|
-
function getHookStage(hook) {
|
|
5792
|
-
const type = hook.slice(0, 2);
|
|
5793
|
-
switch (type) {
|
|
5794
|
-
case "vs":
|
|
5795
|
-
return "vertex";
|
|
5796
|
-
case "fs":
|
|
5797
|
-
return "fragment";
|
|
5798
|
-
default:
|
|
5799
|
-
throw new Error(type);
|
|
5800
|
-
}
|
|
5801
|
-
}
|
|
5802
|
-
function injectShader(source4, stage, inject, injectStandardStubs = false, language = "glsl", entryPoints = {}) {
|
|
5803
|
-
const isVertex = stage === "vertex";
|
|
5804
|
-
for (const key in inject) {
|
|
5805
|
-
const fragmentData = inject[key];
|
|
5806
|
-
fragmentData.sort((a, b) => a.order - b.order);
|
|
5807
|
-
fragments.length = fragmentData.length;
|
|
5808
|
-
for (let i = 0, len2 = fragmentData.length; i < len2; ++i) {
|
|
5809
|
-
fragments[i] = fragmentData[i].injection;
|
|
5810
|
-
}
|
|
5811
|
-
const fragmentString = `${fragments.join("\n")}
|
|
5812
|
-
`;
|
|
5813
|
-
switch (key) {
|
|
5814
|
-
// declarations are injected before the main function
|
|
5815
|
-
case "vs:#decl":
|
|
5816
|
-
if (language === "wgsl" || isVertex) {
|
|
5817
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
5818
|
-
}
|
|
5819
|
-
break;
|
|
5820
|
-
// inject code at the beginning of the main function
|
|
5821
|
-
case "vs:#main-start":
|
|
5822
|
-
if (language === "wgsl" || isVertex) {
|
|
5823
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "start", entryPoints.vertex) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
5824
|
-
}
|
|
5825
|
-
break;
|
|
5826
|
-
// inject code at the end of main function
|
|
5827
|
-
case "vs:#main-end":
|
|
5828
|
-
if (language === "wgsl" || isVertex) {
|
|
5829
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "end", entryPoints.vertex) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
5830
|
-
}
|
|
5831
|
-
break;
|
|
5832
|
-
// declarations are injected before the main function
|
|
5833
|
-
case "fs:#decl":
|
|
5834
|
-
if (language === "wgsl" || !isVertex) {
|
|
5835
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
5836
|
-
}
|
|
5837
|
-
break;
|
|
5838
|
-
// inject code at the beginning of the main function
|
|
5839
|
-
case "fs:#main-start":
|
|
5840
|
-
if (language === "wgsl" || !isVertex) {
|
|
5841
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(
|
|
5842
|
-
source4,
|
|
5843
|
-
"fragment",
|
|
5844
|
-
fragmentString,
|
|
5845
|
-
"start",
|
|
5846
|
-
entryPoints.fragment
|
|
5847
|
-
) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
5848
|
-
}
|
|
5849
|
-
break;
|
|
5850
|
-
// inject code at the end of main function
|
|
5851
|
-
case "fs:#main-end":
|
|
5852
|
-
if (language === "wgsl" || !isVertex) {
|
|
5853
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "fragment", fragmentString, "end", entryPoints.fragment) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
5854
|
-
}
|
|
5855
|
-
break;
|
|
5856
|
-
default:
|
|
5857
|
-
source4 = source4.replace(key, (match) => match + fragmentString);
|
|
5858
|
-
}
|
|
5859
|
-
}
|
|
5860
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, "");
|
|
5861
|
-
if (injectStandardStubs) {
|
|
5862
|
-
source4 = source4.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
|
|
5863
|
-
}
|
|
5864
|
-
return source4;
|
|
5865
|
-
}
|
|
5866
|
-
function injectWGSLStageMain(source4, stage, fragmentString, position, entryPoint) {
|
|
5867
|
-
const bodyRange = getWGSLStageFunctionBodyRange(source4, stage, entryPoint);
|
|
5868
|
-
if (!bodyRange) {
|
|
5869
|
-
return source4;
|
|
5870
|
-
}
|
|
5871
|
-
if (position === "start") {
|
|
5872
|
-
const insertionIndex = bodyRange.openBraceIndex + 1;
|
|
5873
|
-
return `${source4.slice(0, insertionIndex)}
|
|
5874
|
-
${fragmentString}${source4.slice(insertionIndex)}`;
|
|
5875
|
-
}
|
|
5876
|
-
return `${source4.slice(0, bodyRange.closeBraceIndex)}${fragmentString}${source4.slice(
|
|
5877
|
-
bodyRange.closeBraceIndex
|
|
5878
|
-
)}`;
|
|
5879
|
-
}
|
|
5880
|
-
function getWGSLStageFunctionBodyRange(source4, stage, entryPoint) {
|
|
5881
|
-
const stageAttribute = stage === "vertex" ? "@vertex" : "@fragment";
|
|
5882
|
-
const stageIndex = source4.indexOf(stageAttribute);
|
|
5883
|
-
if (stageIndex < 0) {
|
|
5884
|
-
return null;
|
|
5885
|
-
}
|
|
5886
|
-
const functionIndex = entryPoint ? source4.search(new RegExp(`\\bfn\\s+${escapeRegExp(entryPoint)}\\s*\\(`)) : source4.indexOf("fn", stageIndex);
|
|
5887
|
-
if (functionIndex < 0) {
|
|
5888
|
-
return null;
|
|
5889
|
-
}
|
|
5890
|
-
const openBraceIndex = source4.indexOf("{", functionIndex);
|
|
5891
|
-
if (openBraceIndex < 0) {
|
|
5892
|
-
return null;
|
|
5893
|
-
}
|
|
5894
|
-
let braceDepth = 0;
|
|
5895
|
-
for (let index = openBraceIndex; index < source4.length; index++) {
|
|
5896
|
-
const character = source4[index];
|
|
5897
|
-
if (character === "{") {
|
|
5898
|
-
braceDepth++;
|
|
5899
|
-
} else if (character === "}") {
|
|
5900
|
-
braceDepth--;
|
|
5901
|
-
if (braceDepth === 0) {
|
|
5902
|
-
return { openBraceIndex, closeBraceIndex: index };
|
|
5903
|
-
}
|
|
5904
|
-
}
|
|
5905
|
-
}
|
|
5906
|
-
return null;
|
|
5907
|
-
}
|
|
5908
|
-
function escapeRegExp(value) {
|
|
5909
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5910
|
-
}
|
|
5911
|
-
|
|
5912
5737
|
// ../shaders/src/lib/shader-module/shader-module.ts
|
|
5913
5738
|
function initializeShaderModules(modules) {
|
|
5914
5739
|
modules.map((module) => initializeShaderModule(module));
|
|
@@ -5918,15 +5743,10 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
5918
5743
|
return;
|
|
5919
5744
|
}
|
|
5920
5745
|
initializeShaderModules(module.dependencies || []);
|
|
5921
|
-
const {
|
|
5922
|
-
propTypes = {},
|
|
5923
|
-
deprecations = [],
|
|
5924
|
-
// defines = {},
|
|
5925
|
-
inject = {}
|
|
5926
|
-
} = module;
|
|
5746
|
+
const { propTypes = {}, deprecations = [] } = module;
|
|
5927
5747
|
const instance = {
|
|
5928
|
-
|
|
5929
|
-
|
|
5748
|
+
parsedDeprecations: parseDeprecationDefinitions(deprecations),
|
|
5749
|
+
normalizedInjections: { vertex: {}, fragment: {} }
|
|
5930
5750
|
};
|
|
5931
5751
|
if (propTypes) {
|
|
5932
5752
|
instance.propValidators = makePropValidators(propTypes);
|
|
@@ -6028,7 +5848,7 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6028
5848
|
/** Compilers registered by the application, isolated to this assembler. */
|
|
6029
5849
|
_shaderTranspilers = /* @__PURE__ */ new Map();
|
|
6030
5850
|
/** Hook functions */
|
|
6031
|
-
|
|
5851
|
+
_injectionTargets = [];
|
|
6032
5852
|
/** Shader modules */
|
|
6033
5853
|
_defaultModules = [];
|
|
6034
5854
|
/** Register or replace the compiler for one input language. */
|
|
@@ -6098,19 +5918,18 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6098
5918
|
this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
|
|
6099
5919
|
}
|
|
6100
5920
|
/**
|
|
6101
|
-
* Register a shader
|
|
6102
|
-
* @param
|
|
6103
|
-
* @param options Optional hook metadata such as always-on header and footer source.
|
|
5921
|
+
* Register a shader injection target
|
|
5922
|
+
* @param injectionTarget Shared stage and name with language-specific parameters, return type, and source.
|
|
6104
5923
|
*/
|
|
6105
|
-
|
|
6106
|
-
this.
|
|
5924
|
+
addShaderInjectionTarget(injectionTarget) {
|
|
5925
|
+
this._injectionTargets.push(injectionTarget);
|
|
6107
5926
|
}
|
|
6108
5927
|
/**
|
|
6109
|
-
* Remove all registered shader
|
|
5928
|
+
* Remove all registered shader injection targets, for example before re-registering targets for a new
|
|
6110
5929
|
* application configuration. Default modules are not affected.
|
|
6111
5930
|
*/
|
|
6112
|
-
|
|
6113
|
-
this.
|
|
5931
|
+
resetShaderInjectionTargets() {
|
|
5932
|
+
this._injectionTargets.length = 0;
|
|
6114
5933
|
}
|
|
6115
5934
|
/**
|
|
6116
5935
|
* Dedupe and combine with default modules
|
|
@@ -6139,6 +5958,183 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6139
5958
|
}
|
|
6140
5959
|
};
|
|
6141
5960
|
|
|
5961
|
+
// ../shaders/src/module-injectors.ts
|
|
5962
|
+
var MODULE_INJECTORS_VS = (
|
|
5963
|
+
/* glsl */
|
|
5964
|
+
`#ifdef MODULE_LOGDEPTH
|
|
5965
|
+
logdepth_adjustPosition(gl_Position);
|
|
5966
|
+
#endif
|
|
5967
|
+
`
|
|
5968
|
+
);
|
|
5969
|
+
var MODULE_INJECTORS_FS = (
|
|
5970
|
+
/* glsl */
|
|
5971
|
+
`#ifdef MODULE_MATERIAL
|
|
5972
|
+
fragColor = material_filterColor(fragColor);
|
|
5973
|
+
#endif
|
|
5974
|
+
|
|
5975
|
+
#ifdef MODULE_LIGHTING
|
|
5976
|
+
fragColor = lighting_filterColor(fragColor);
|
|
5977
|
+
#endif
|
|
5978
|
+
|
|
5979
|
+
#ifdef MODULE_FOG
|
|
5980
|
+
fragColor = fog_filterColor(fragColor);
|
|
5981
|
+
#endif
|
|
5982
|
+
|
|
5983
|
+
#ifdef MODULE_PICKING
|
|
5984
|
+
fragColor = picking_filterHighlightColor(fragColor);
|
|
5985
|
+
fragColor = picking_filterPickingColor(fragColor);
|
|
5986
|
+
#endif
|
|
5987
|
+
|
|
5988
|
+
#ifdef MODULE_LOGDEPTH
|
|
5989
|
+
logdepth_setFragDepth();
|
|
5990
|
+
#endif
|
|
5991
|
+
`
|
|
5992
|
+
);
|
|
5993
|
+
|
|
5994
|
+
// ../shaders/src/lib/shader-assembly/shader-injections.ts
|
|
5995
|
+
var MODULE_INJECTORS = {
|
|
5996
|
+
vertex: MODULE_INJECTORS_VS,
|
|
5997
|
+
fragment: MODULE_INJECTORS_FS
|
|
5998
|
+
};
|
|
5999
|
+
var REGEX_START_OF_MAIN = /void\s+main\s*\([^)]*\)\s*\{\n?/;
|
|
6000
|
+
var REGEX_END_OF_MAIN = /}\n?[^{}]*$/;
|
|
6001
|
+
var fragments = [];
|
|
6002
|
+
var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
|
|
6003
|
+
function resolveShaderInjections(declarations, language, pluginName) {
|
|
6004
|
+
const resolved = {};
|
|
6005
|
+
for (const declaration of declarations) {
|
|
6006
|
+
const source4 = declaration[language];
|
|
6007
|
+
if (source4 === void 0) continue;
|
|
6008
|
+
if (declaration.stage !== "vertex" && declaration.stage !== "fragment" || declaration.target.includes(":")) {
|
|
6009
|
+
throw new Error("Shader injection targets require an explicit stage and unqualified target");
|
|
6010
|
+
}
|
|
6011
|
+
const target = `${declaration.stage === "vertex" ? "vs" : "fs"}:${declaration.target}`;
|
|
6012
|
+
if (!/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][A-Za-z0-9_]*)$/.test(target)) {
|
|
6013
|
+
throw new Error(
|
|
6014
|
+
`Shader injection target "${target}" must be a named shader injection target`
|
|
6015
|
+
);
|
|
6016
|
+
}
|
|
6017
|
+
resolved[target] ||= [];
|
|
6018
|
+
resolved[target].push({
|
|
6019
|
+
injection: source4,
|
|
6020
|
+
order: declaration.order ?? 0,
|
|
6021
|
+
...pluginName ? { pluginName } : {}
|
|
6022
|
+
});
|
|
6023
|
+
}
|
|
6024
|
+
return resolved;
|
|
6025
|
+
}
|
|
6026
|
+
function injectShader(source4, stage, inject, injectStandardStubs = false, language = "glsl", entryPoints = {}) {
|
|
6027
|
+
const isVertex = stage === "vertex";
|
|
6028
|
+
for (const key in inject) {
|
|
6029
|
+
const fragmentData = inject[key];
|
|
6030
|
+
fragmentData.sort(
|
|
6031
|
+
(a, b) => a.order - b.order
|
|
6032
|
+
);
|
|
6033
|
+
fragments.length = fragmentData.length;
|
|
6034
|
+
for (let i = 0, len2 = fragmentData.length; i < len2; ++i) {
|
|
6035
|
+
fragments[i] = fragmentData[i].injection;
|
|
6036
|
+
}
|
|
6037
|
+
const fragmentString = `${fragments.join("\n")}
|
|
6038
|
+
`;
|
|
6039
|
+
switch (key) {
|
|
6040
|
+
// declarations are injected before the main function
|
|
6041
|
+
case "vs:#decl":
|
|
6042
|
+
if (language === "wgsl" || isVertex) {
|
|
6043
|
+
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
6044
|
+
}
|
|
6045
|
+
break;
|
|
6046
|
+
// inject code at the beginning of the main function
|
|
6047
|
+
case "vs:#main-start":
|
|
6048
|
+
if (language === "wgsl" || isVertex) {
|
|
6049
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "start", entryPoints.vertex) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
6050
|
+
}
|
|
6051
|
+
break;
|
|
6052
|
+
// inject code at the end of main function
|
|
6053
|
+
case "vs:#main-end":
|
|
6054
|
+
if (language === "wgsl" || isVertex) {
|
|
6055
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "end", entryPoints.vertex) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
6056
|
+
}
|
|
6057
|
+
break;
|
|
6058
|
+
// declarations are injected before the main function
|
|
6059
|
+
case "fs:#decl":
|
|
6060
|
+
if (language === "wgsl" || !isVertex) {
|
|
6061
|
+
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
6062
|
+
}
|
|
6063
|
+
break;
|
|
6064
|
+
// inject code at the beginning of the main function
|
|
6065
|
+
case "fs:#main-start":
|
|
6066
|
+
if (language === "wgsl" || !isVertex) {
|
|
6067
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(
|
|
6068
|
+
source4,
|
|
6069
|
+
"fragment",
|
|
6070
|
+
fragmentString,
|
|
6071
|
+
"start",
|
|
6072
|
+
entryPoints.fragment
|
|
6073
|
+
) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
6074
|
+
}
|
|
6075
|
+
break;
|
|
6076
|
+
// inject code at the end of main function
|
|
6077
|
+
case "fs:#main-end":
|
|
6078
|
+
if (language === "wgsl" || !isVertex) {
|
|
6079
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "fragment", fragmentString, "end", entryPoints.fragment) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
6080
|
+
}
|
|
6081
|
+
break;
|
|
6082
|
+
default:
|
|
6083
|
+
source4 = source4.replace(key, (match) => match + fragmentString);
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
source4 = source4.replace(DECLARATION_INJECT_MARKER, "");
|
|
6087
|
+
if (injectStandardStubs) {
|
|
6088
|
+
source4 = source4.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
|
|
6089
|
+
}
|
|
6090
|
+
return source4;
|
|
6091
|
+
}
|
|
6092
|
+
function injectWGSLStageMain(source4, stage, fragmentString, position, entryPoint) {
|
|
6093
|
+
const bodyRange = getWGSLStageFunctionBodyRange(source4, stage, entryPoint);
|
|
6094
|
+
if (!bodyRange) {
|
|
6095
|
+
return source4;
|
|
6096
|
+
}
|
|
6097
|
+
if (position === "start") {
|
|
6098
|
+
const insertionIndex = bodyRange.openBraceIndex + 1;
|
|
6099
|
+
return `${source4.slice(0, insertionIndex)}
|
|
6100
|
+
${fragmentString}${source4.slice(insertionIndex)}`;
|
|
6101
|
+
}
|
|
6102
|
+
return `${source4.slice(0, bodyRange.closeBraceIndex)}${fragmentString}${source4.slice(
|
|
6103
|
+
bodyRange.closeBraceIndex
|
|
6104
|
+
)}`;
|
|
6105
|
+
}
|
|
6106
|
+
function getWGSLStageFunctionBodyRange(source4, stage, entryPoint) {
|
|
6107
|
+
const stageAttribute = stage === "vertex" ? "@vertex" : "@fragment";
|
|
6108
|
+
const stageIndex = source4.indexOf(stageAttribute);
|
|
6109
|
+
if (stageIndex < 0) {
|
|
6110
|
+
return null;
|
|
6111
|
+
}
|
|
6112
|
+
const functionIndex = entryPoint ? source4.search(new RegExp(`\\bfn\\s+${escapeRegExp(entryPoint)}\\s*\\(`)) : source4.indexOf("fn", stageIndex);
|
|
6113
|
+
if (functionIndex < 0) {
|
|
6114
|
+
return null;
|
|
6115
|
+
}
|
|
6116
|
+
const openBraceIndex = source4.indexOf("{", functionIndex);
|
|
6117
|
+
if (openBraceIndex < 0) {
|
|
6118
|
+
return null;
|
|
6119
|
+
}
|
|
6120
|
+
let braceDepth = 0;
|
|
6121
|
+
for (let index = openBraceIndex; index < source4.length; index++) {
|
|
6122
|
+
const character = source4[index];
|
|
6123
|
+
if (character === "{") {
|
|
6124
|
+
braceDepth++;
|
|
6125
|
+
} else if (character === "}") {
|
|
6126
|
+
braceDepth--;
|
|
6127
|
+
if (braceDepth === 0) {
|
|
6128
|
+
return { openBraceIndex, closeBraceIndex: index };
|
|
6129
|
+
}
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
return null;
|
|
6133
|
+
}
|
|
6134
|
+
function escapeRegExp(value) {
|
|
6135
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6136
|
+
}
|
|
6137
|
+
|
|
6142
6138
|
// ../shaders/src/lib/shader-module/shader-module-uniform-layout.ts
|
|
6143
6139
|
var GLSL_UNIFORM_BLOCK_FIELD_REGEXP = /^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/;
|
|
6144
6140
|
var GLSL_UNIFORM_BLOCK_REGEXP = /((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;
|
|
@@ -6363,13 +6359,13 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6363
6359
|
return uniforms;
|
|
6364
6360
|
};
|
|
6365
6361
|
}
|
|
6366
|
-
function appendInjections(injections,
|
|
6362
|
+
function appendInjections(injections, targetInjections, declInjections, mainInjections) {
|
|
6367
6363
|
for (const key in injections) {
|
|
6368
6364
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
6369
6365
|
if (match) {
|
|
6370
6366
|
const hash = match[2];
|
|
6371
6367
|
const name = match[3];
|
|
6372
|
-
const injectionType = hash ? name === "decl" ? declInjections : mainInjections :
|
|
6368
|
+
const injectionType = hash ? name === "decl" ? declInjections : mainInjections : targetInjections;
|
|
6373
6369
|
injectionType[key] = injectionType[key] || [];
|
|
6374
6370
|
injectionType[key].push(...injections[key]);
|
|
6375
6371
|
} else {
|
|
@@ -6410,50 +6406,53 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6410
6406
|
return source4;
|
|
6411
6407
|
}
|
|
6412
6408
|
|
|
6413
|
-
// ../shaders/src/lib/shader-assembly/shader-
|
|
6414
|
-
function
|
|
6409
|
+
// ../shaders/src/lib/shader-assembly/shader-injection-targets.ts
|
|
6410
|
+
function getShaderInjectionTargets(injectionTargets, targetInjections, shaderLanguage = "glsl") {
|
|
6415
6411
|
let result = "";
|
|
6416
|
-
for (const
|
|
6417
|
-
const
|
|
6418
|
-
const
|
|
6419
|
-
|
|
6412
|
+
for (const targetName in injectionTargets) {
|
|
6413
|
+
const targetFunction = injectionTargets[targetName];
|
|
6414
|
+
const returnType = targetFunction.returnType || "void";
|
|
6415
|
+
const functionPrefix = shaderLanguage === "wgsl" ? "fn" : returnType;
|
|
6416
|
+
const returnSuffix = shaderLanguage === "wgsl" && returnType !== "void" ? ` -> ${returnType}` : "";
|
|
6417
|
+
result += `${functionPrefix} ${targetFunction.signature}${returnSuffix} {
|
|
6420
6418
|
`;
|
|
6421
|
-
if (
|
|
6422
|
-
result += ` ${
|
|
6419
|
+
if (targetFunction.header) {
|
|
6420
|
+
result += ` ${targetFunction.header}`;
|
|
6423
6421
|
}
|
|
6424
|
-
if (
|
|
6425
|
-
const injections =
|
|
6422
|
+
if (targetInjections[targetName]) {
|
|
6423
|
+
const injections = targetInjections[targetName];
|
|
6426
6424
|
injections.sort((a, b) => a.order - b.order);
|
|
6427
6425
|
for (const injection of injections) {
|
|
6428
6426
|
result += ` ${injection.injection}
|
|
6429
6427
|
`;
|
|
6430
6428
|
}
|
|
6431
6429
|
}
|
|
6432
|
-
if (
|
|
6433
|
-
result += ` ${
|
|
6430
|
+
if (targetFunction.footer) {
|
|
6431
|
+
result += ` ${targetFunction.footer}`;
|
|
6434
6432
|
}
|
|
6435
6433
|
result += "}\n";
|
|
6436
6434
|
}
|
|
6437
6435
|
return result;
|
|
6438
6436
|
}
|
|
6439
|
-
function
|
|
6437
|
+
function normalizeShaderInjectionTargets(injectionTargets, pluginInjectionTargets = [], language = "glsl") {
|
|
6440
6438
|
const result = { vertex: {}, fragment: {} };
|
|
6441
|
-
for (const
|
|
6442
|
-
const
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6439
|
+
for (const injectionTarget of injectionTargets) {
|
|
6440
|
+
const implementation = injectionTarget[language];
|
|
6441
|
+
if (implementation) {
|
|
6442
|
+
const prefix = injectionTarget.stage === "vertex" ? "vs" : "fs";
|
|
6443
|
+
result[injectionTarget.stage][`${prefix}:${injectionTarget.name}`] = {
|
|
6444
|
+
...implementation,
|
|
6445
|
+
signature: `${injectionTarget.name}(${implementation.parameters})`
|
|
6446
|
+
};
|
|
6447
|
+
}
|
|
6449
6448
|
}
|
|
6450
|
-
for (const
|
|
6451
|
-
const
|
|
6449
|
+
for (const injectionTarget of pluginInjectionTargets) {
|
|
6450
|
+
const selected = normalizeShaderInjectionTargets([injectionTarget], [], language);
|
|
6452
6451
|
for (const stage of ["vertex", "fragment"]) {
|
|
6453
|
-
for (const [name, declaration] of Object.entries(
|
|
6452
|
+
for (const [name, declaration] of Object.entries(selected[stage])) {
|
|
6454
6453
|
const existing = result[stage][name];
|
|
6455
|
-
if (existing && existing.signature !== declaration.signature) {
|
|
6456
|
-
throw new Error(`Conflicting ShaderPlugin
|
|
6454
|
+
if (existing && (existing.signature !== declaration.signature || (existing.returnType || "void") !== (declaration.returnType || "void"))) {
|
|
6455
|
+
throw new Error(`Conflicting ShaderPlugin injection target ${name}`);
|
|
6457
6456
|
}
|
|
6458
6457
|
result[stage][name] = existing || declaration;
|
|
6459
6458
|
}
|
|
@@ -6461,50 +6460,28 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6461
6460
|
}
|
|
6462
6461
|
return result;
|
|
6463
6462
|
}
|
|
6464
|
-
function
|
|
6465
|
-
const stageRegistry =
|
|
6466
|
-
return Boolean(stageRegistry[
|
|
6463
|
+
function isShaderInjectionTargetRegistered(registry, targetName) {
|
|
6464
|
+
const stageRegistry = targetName.startsWith("vs:") ? registry.vertex : registry.fragment;
|
|
6465
|
+
return Boolean(stageRegistry[targetName]);
|
|
6467
6466
|
}
|
|
6468
|
-
function
|
|
6467
|
+
function validateShaderInjectionTargetInjections(registry, targetInjections, stage) {
|
|
6469
6468
|
const stagePrefix = stage === "vertex" ? "vs:" : stage === "fragment" ? "fs:" : null;
|
|
6470
|
-
for (const
|
|
6471
|
-
if (stagePrefix && !
|
|
6469
|
+
for (const targetName in targetInjections) {
|
|
6470
|
+
if (stagePrefix && !targetName.startsWith(stagePrefix)) {
|
|
6472
6471
|
continue;
|
|
6473
6472
|
}
|
|
6474
|
-
if (!
|
|
6473
|
+
if (!isShaderInjectionTargetRegistered(registry, targetName)) {
|
|
6475
6474
|
const pluginNames = [
|
|
6476
|
-
...new Set(
|
|
6475
|
+
...new Set(
|
|
6476
|
+
targetInjections[targetName].map((injection) => injection.pluginName).filter(Boolean)
|
|
6477
|
+
)
|
|
6477
6478
|
];
|
|
6478
6479
|
throw new Error(
|
|
6479
|
-
`Unknown shader
|
|
6480
|
+
`Unknown shader injection target ${targetName}${pluginNames.length ? ` (plugins: ${pluginNames.join(", ")})` : ""}`
|
|
6480
6481
|
);
|
|
6481
6482
|
}
|
|
6482
6483
|
}
|
|
6483
6484
|
}
|
|
6484
|
-
function addShaderHookToRegistry(registry, hookFunction) {
|
|
6485
|
-
const options = typeof hookFunction === "string" ? {} : hookFunction;
|
|
6486
|
-
const hook = (typeof hookFunction === "string" ? hookFunction : hookFunction.hook).trim();
|
|
6487
|
-
const stageSeparatorIndex = hook.indexOf(":");
|
|
6488
|
-
const shaderStage = hook.slice(0, stageSeparatorIndex);
|
|
6489
|
-
const signature = hook.slice(stageSeparatorIndex + 1);
|
|
6490
|
-
const name = hook.split("(")[0].trim();
|
|
6491
|
-
const normalizedHook = {
|
|
6492
|
-
hook: name,
|
|
6493
|
-
signature,
|
|
6494
|
-
header: options.header || "",
|
|
6495
|
-
footer: options.footer || ""
|
|
6496
|
-
};
|
|
6497
|
-
switch (shaderStage) {
|
|
6498
|
-
case "vs":
|
|
6499
|
-
registry.vertex[name] = normalizedHook;
|
|
6500
|
-
break;
|
|
6501
|
-
case "fs":
|
|
6502
|
-
registry.fragment[name] = normalizedHook;
|
|
6503
|
-
break;
|
|
6504
|
-
default:
|
|
6505
|
-
throw new Error(shaderStage);
|
|
6506
|
-
}
|
|
6507
|
-
}
|
|
6508
6485
|
|
|
6509
6486
|
// ../shaders/src/lib/glsl-utils/get-shader-info.ts
|
|
6510
6487
|
function getShaderInfo(source4, defaultName) {
|
|
@@ -6598,8 +6575,13 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6598
6575
|
}
|
|
6599
6576
|
return decoded;
|
|
6600
6577
|
}
|
|
6578
|
+
var attributeShaderTypeInfoCache = /* @__PURE__ */ new Map();
|
|
6601
6579
|
function getAttributeShaderTypeInfo(attributeType) {
|
|
6602
6580
|
const resolvedAttributeType = resolveAttributeShaderTypeAlias(attributeType);
|
|
6581
|
+
const cached = attributeShaderTypeInfoCache.get(resolvedAttributeType);
|
|
6582
|
+
if (cached) {
|
|
6583
|
+
return cached;
|
|
6584
|
+
}
|
|
6603
6585
|
const decoded = TYPE_INFO[resolvedAttributeType];
|
|
6604
6586
|
if (!decoded) {
|
|
6605
6587
|
throw new Error(`Unsupported attribute shader type: ${attributeType}`);
|
|
@@ -6608,13 +6590,15 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6608
6590
|
const integer = primitiveType === "i32" || primitiveType === "u32";
|
|
6609
6591
|
const signed = primitiveType !== "u32";
|
|
6610
6592
|
const byteLength = PRIMITIVE_TYPE_SIZES[primitiveType] * components2;
|
|
6611
|
-
|
|
6593
|
+
const result = Object.freeze({
|
|
6612
6594
|
primitiveType,
|
|
6613
6595
|
components: components2,
|
|
6614
6596
|
byteLength,
|
|
6615
6597
|
integer,
|
|
6616
6598
|
signed
|
|
6617
|
-
};
|
|
6599
|
+
});
|
|
6600
|
+
attributeShaderTypeInfoCache.set(resolvedAttributeType, result);
|
|
6601
|
+
return result;
|
|
6618
6602
|
}
|
|
6619
6603
|
var ShaderTypeDecoder = class {
|
|
6620
6604
|
getVariableShaderTypeInfo(format) {
|
|
@@ -6723,6 +6707,9 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6723
6707
|
"mat4x3<u32>": { type: "u32", components: 12 },
|
|
6724
6708
|
"mat4x4<u32>": { type: "u32", components: 16 }
|
|
6725
6709
|
};
|
|
6710
|
+
for (const info of Object.values(UNIFORM_FORMATS)) {
|
|
6711
|
+
Object.freeze(info);
|
|
6712
|
+
}
|
|
6726
6713
|
var WGSL_ATTRIBUTE_TYPE_ALIAS_MAP = {
|
|
6727
6714
|
vec2i: "vec2<i32>",
|
|
6728
6715
|
vec3i: "vec3<i32>",
|
|
@@ -7716,7 +7703,7 @@ return ${outputName};
|
|
|
7716
7703
|
language = "glsl",
|
|
7717
7704
|
modules,
|
|
7718
7705
|
defines = {},
|
|
7719
|
-
|
|
7706
|
+
injectionTargets = [],
|
|
7720
7707
|
inject = {},
|
|
7721
7708
|
pluginInjections = {},
|
|
7722
7709
|
pluginVertexInputs = {},
|
|
@@ -7756,13 +7743,20 @@ ${getApplicationDefines(allDefines)}
|
|
|
7756
7743
|
`;
|
|
7757
7744
|
break;
|
|
7758
7745
|
}
|
|
7759
|
-
const
|
|
7760
|
-
|
|
7746
|
+
const injectionTargetMap = normalizeShaderInjectionTargets(
|
|
7747
|
+
injectionTargets,
|
|
7748
|
+
options.pluginInjectionTargets,
|
|
7749
|
+
"glsl"
|
|
7750
|
+
);
|
|
7751
|
+
const targetInjections = {};
|
|
7761
7752
|
const declInjections = {};
|
|
7762
7753
|
const mainInjections = {};
|
|
7763
|
-
appendInjections(pluginInjections,
|
|
7764
|
-
|
|
7765
|
-
|
|
7754
|
+
appendInjections(pluginInjections, targetInjections, declInjections, mainInjections);
|
|
7755
|
+
const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "glsl") : {};
|
|
7756
|
+
appendInjections(applicationInjections, targetInjections, declInjections, mainInjections);
|
|
7757
|
+
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
7758
|
+
for (const key in injectionMap) {
|
|
7759
|
+
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
7766
7760
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
7767
7761
|
if (match) {
|
|
7768
7762
|
const hash = match[2];
|
|
@@ -7774,7 +7768,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7774
7768
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
7775
7769
|
}
|
|
7776
7770
|
} else {
|
|
7777
|
-
|
|
7771
|
+
targetInjections[key] = [...targetInjections[key] || [], injection];
|
|
7778
7772
|
}
|
|
7779
7773
|
} else {
|
|
7780
7774
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
@@ -7807,25 +7801,12 @@ ${getApplicationDefines(allDefines)}
|
|
|
7807
7801
|
}
|
|
7808
7802
|
const moduleSource = getShaderModuleSource(module, stage, log8);
|
|
7809
7803
|
assembledSource += moduleSource;
|
|
7810
|
-
const injections = module.instance?.normalizedInjections[stage] || {};
|
|
7811
|
-
for (const key in injections) {
|
|
7812
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
7813
|
-
if (match) {
|
|
7814
|
-
const name = match[2];
|
|
7815
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
7816
|
-
injectionType[key] = injectionType[key] || [];
|
|
7817
|
-
injectionType[key].push(injections[key]);
|
|
7818
|
-
} else {
|
|
7819
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
7820
|
-
hookInjections[key].push(injections[key]);
|
|
7821
|
-
}
|
|
7822
|
-
}
|
|
7823
7804
|
}
|
|
7824
|
-
|
|
7805
|
+
validateShaderInjectionTargetInjections(injectionTargetMap, targetInjections, stage);
|
|
7825
7806
|
assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
|
|
7826
7807
|
assembledSource += INJECT_SHADER_DECLARATIONS;
|
|
7827
7808
|
assembledSource = injectShader(assembledSource, stage, declInjections);
|
|
7828
|
-
assembledSource +=
|
|
7809
|
+
assembledSource += getShaderInjectionTargets(injectionTargetMap[stage], targetInjections);
|
|
7829
7810
|
assembledSource += coreSource;
|
|
7830
7811
|
assembledSource = injectShader(assembledSource, stage, mainInjections);
|
|
7831
7812
|
if (language === "glsl" && sourceVersion !== targetVersion) {
|
|
@@ -7858,7 +7839,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7858
7839
|
*/
|
|
7859
7840
|
assembleGLSLShaderPair(props) {
|
|
7860
7841
|
const modules = this._getModuleList(props.modules);
|
|
7861
|
-
const
|
|
7842
|
+
const injectionTargets = [...this._injectionTargets, ...props.injectionTargets || []];
|
|
7862
7843
|
const vertex = this._transpileShader(props, modules, props.vs, "vertex");
|
|
7863
7844
|
const fragment = this._transpileShader(props, modules, props.fs, "fragment");
|
|
7864
7845
|
const assembled = assembleGLSLShaderPair({
|
|
@@ -7866,7 +7847,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7866
7847
|
vs: vertex.code,
|
|
7867
7848
|
fs: props.fs == null ? void 0 : fragment.code,
|
|
7868
7849
|
modules: vertex.modules,
|
|
7869
|
-
|
|
7850
|
+
injectionTargets
|
|
7870
7851
|
});
|
|
7871
7852
|
return { ...assembled, modules };
|
|
7872
7853
|
}
|
|
@@ -8530,6 +8511,141 @@ ${getApplicationDefines(allDefines)}
|
|
|
8530
8511
|
return match?.[1];
|
|
8531
8512
|
}
|
|
8532
8513
|
|
|
8514
|
+
// ../shaders/src/lib/shader-assembly/wgsl-injection-target-names.ts
|
|
8515
|
+
function getWGSLInjectionTargetNames(targets, source4 = "") {
|
|
8516
|
+
const names = /* @__PURE__ */ new Map();
|
|
8517
|
+
const declarations = Object.values(targets).flatMap(
|
|
8518
|
+
(stage) => Object.entries(stage).map(
|
|
8519
|
+
([key, target]) => `${key.slice(3)}
|
|
8520
|
+
${target.signature}
|
|
8521
|
+
${target.header || ""}
|
|
8522
|
+
${target.footer || ""}`
|
|
8523
|
+
)
|
|
8524
|
+
);
|
|
8525
|
+
const usedNames = new Set(
|
|
8526
|
+
maskWGSLComments(`${source4}
|
|
8527
|
+
${declarations.join("\n")}`).match(
|
|
8528
|
+
/[_\p{XID_Start}][\p{XID_Continue}]*/gu
|
|
8529
|
+
)
|
|
8530
|
+
);
|
|
8531
|
+
for (const key of Object.keys(targets.vertex)) {
|
|
8532
|
+
const name = key.slice(3);
|
|
8533
|
+
if (targets.fragment[`fs:${name}`]) {
|
|
8534
|
+
names.set(name, {
|
|
8535
|
+
vertex: allocateName(`_luma_vertex_target_${name}`, usedNames),
|
|
8536
|
+
fragment: allocateName(`_luma_fragment_target_${name}`, usedNames)
|
|
8537
|
+
});
|
|
8538
|
+
}
|
|
8539
|
+
}
|
|
8540
|
+
return names;
|
|
8541
|
+
}
|
|
8542
|
+
function resolveWGSLInjectionTargetNames(source4, targets, targetNames = getWGSLInjectionTargetNames(targets)) {
|
|
8543
|
+
if (!targetNames.size) return source4;
|
|
8544
|
+
const masked = maskWGSLComments(source4);
|
|
8545
|
+
const functions = /* @__PURE__ */ new Map();
|
|
8546
|
+
const pattern = /((?:@\w+(?:\([^)]*\))?\s*)*)\bfn\s+([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu;
|
|
8547
|
+
for (let match = pattern.exec(masked); match; match = pattern.exec(masked)) {
|
|
8548
|
+
const bodyStart = masked.indexOf("{", pattern.lastIndex);
|
|
8549
|
+
let end = bodyStart + 1;
|
|
8550
|
+
let depth = 1;
|
|
8551
|
+
for (; end < masked.length && depth; end++) {
|
|
8552
|
+
if (masked[end] === "{") depth++;
|
|
8553
|
+
if (masked[end] === "}") depth--;
|
|
8554
|
+
}
|
|
8555
|
+
assert2(bodyStart >= 0 && depth === 0);
|
|
8556
|
+
const name = match[2];
|
|
8557
|
+
const nameStart = match.index + match[0].lastIndexOf(name);
|
|
8558
|
+
const calls = Array.from(
|
|
8559
|
+
masked.slice(bodyStart + 1, end - 1).matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu),
|
|
8560
|
+
(call) => call[1]
|
|
8561
|
+
);
|
|
8562
|
+
functions.set(name, {
|
|
8563
|
+
name,
|
|
8564
|
+
start: match.index,
|
|
8565
|
+
end,
|
|
8566
|
+
nameStart,
|
|
8567
|
+
bodyStart,
|
|
8568
|
+
calls,
|
|
8569
|
+
stages: /* @__PURE__ */ new Set(),
|
|
8570
|
+
entryStage: /@vertex\b/.test(match[1]) ? "vertex" : /@fragment\b/.test(match[1]) ? "fragment" : void 0
|
|
8571
|
+
});
|
|
8572
|
+
pattern.lastIndex = end;
|
|
8573
|
+
}
|
|
8574
|
+
function visit(name, stage) {
|
|
8575
|
+
const shaderFunction = functions.get(name);
|
|
8576
|
+
if (!shaderFunction || shaderFunction.stages.has(stage)) return;
|
|
8577
|
+
shaderFunction.stages.add(stage);
|
|
8578
|
+
for (const call of shaderFunction.calls) {
|
|
8579
|
+
visit(targetNames.get(call)?.[stage] || call, stage);
|
|
8580
|
+
}
|
|
8581
|
+
}
|
|
8582
|
+
for (const shaderFunction of functions.values()) {
|
|
8583
|
+
if (shaderFunction.entryStage) visit(shaderFunction.name, shaderFunction.entryStage);
|
|
8584
|
+
}
|
|
8585
|
+
for (const stage of ["vertex", "fragment"]) {
|
|
8586
|
+
for (const key of Object.keys(targets[stage])) {
|
|
8587
|
+
const name = key.slice(3);
|
|
8588
|
+
visit(targetNames.get(name)?.[stage] || name, stage);
|
|
8589
|
+
}
|
|
8590
|
+
}
|
|
8591
|
+
const affected = /* @__PURE__ */ new Set();
|
|
8592
|
+
let changed = true;
|
|
8593
|
+
while (changed) {
|
|
8594
|
+
changed = false;
|
|
8595
|
+
for (const shaderFunction of functions.values()) {
|
|
8596
|
+
if (!affected.has(shaderFunction.name) && shaderFunction.calls.some((call) => targetNames.has(call) || affected.has(call))) {
|
|
8597
|
+
affected.add(shaderFunction.name);
|
|
8598
|
+
changed = true;
|
|
8599
|
+
}
|
|
8600
|
+
}
|
|
8601
|
+
}
|
|
8602
|
+
const helperNames = /* @__PURE__ */ new Map();
|
|
8603
|
+
const usedNames = new Set(masked.match(/[_\p{XID_Start}][\p{XID_Continue}]*/gu));
|
|
8604
|
+
for (const name of affected) {
|
|
8605
|
+
if (functions.get(name)?.stages.size === 2) {
|
|
8606
|
+
helperNames.set(name, {
|
|
8607
|
+
vertex: allocateName(`_luma_vertex_helper_${name}`, usedNames),
|
|
8608
|
+
fragment: allocateName(`_luma_fragment_helper_${name}`, usedNames)
|
|
8609
|
+
});
|
|
8610
|
+
}
|
|
8611
|
+
}
|
|
8612
|
+
function getCallName(name, stage) {
|
|
8613
|
+
const targetName = targetNames.get(name)?.[stage];
|
|
8614
|
+
if (targetName) return targetName;
|
|
8615
|
+
return helperNames.get(name)?.[stage] || name;
|
|
8616
|
+
}
|
|
8617
|
+
for (const shaderFunction of [...functions.values()].reverse()) {
|
|
8618
|
+
if (!affected.has(shaderFunction.name)) continue;
|
|
8619
|
+
if (!shaderFunction.stages.size) {
|
|
8620
|
+
throw new Error(`Cannot infer WGSL target stage in ${shaderFunction.name}`);
|
|
8621
|
+
}
|
|
8622
|
+
const variants = [];
|
|
8623
|
+
const start = shaderFunction.start;
|
|
8624
|
+
for (const stage of shaderFunction.stages) {
|
|
8625
|
+
let text = source4.slice(start, shaderFunction.end);
|
|
8626
|
+
const body = masked.slice(shaderFunction.bodyStart + 1, shaderFunction.end - 1);
|
|
8627
|
+
const calls = [...body.matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu)];
|
|
8628
|
+
for (const call of calls.reverse()) {
|
|
8629
|
+
const offset2 = shaderFunction.bodyStart + 1 + call.index - start;
|
|
8630
|
+
const replacement = getCallName(call[1], stage);
|
|
8631
|
+
text = text.slice(0, offset2) + replacement + text.slice(offset2 + call[1].length);
|
|
8632
|
+
}
|
|
8633
|
+
const offset = shaderFunction.nameStart - start;
|
|
8634
|
+
text = text.slice(0, offset) + getCallName(shaderFunction.name, stage) + text.slice(offset + shaderFunction.name.length);
|
|
8635
|
+
variants.push(text);
|
|
8636
|
+
}
|
|
8637
|
+
source4 = source4.slice(0, start) + variants.join("\n") + source4.slice(shaderFunction.end);
|
|
8638
|
+
}
|
|
8639
|
+
return source4;
|
|
8640
|
+
}
|
|
8641
|
+
function allocateName(baseName, usedNames) {
|
|
8642
|
+
let name = baseName;
|
|
8643
|
+
let suffix = 0;
|
|
8644
|
+
while (usedNames.has(name)) name = `${baseName}_${++suffix}`;
|
|
8645
|
+
usedNames.add(name);
|
|
8646
|
+
return name;
|
|
8647
|
+
}
|
|
8648
|
+
|
|
8533
8649
|
// ../shaders/src/lib/preprocessor/preprocessor.ts
|
|
8534
8650
|
var DEFINE_NAME_PATTERN = "([a-zA-Z_][a-zA-Z0-9_]*)";
|
|
8535
8651
|
var IF_REGEXP = /^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/;
|
|
@@ -8668,7 +8784,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8668
8784
|
modules,
|
|
8669
8785
|
// defines = {},
|
|
8670
8786
|
defines = {},
|
|
8671
|
-
|
|
8787
|
+
injectionTargets = [],
|
|
8672
8788
|
inject = {},
|
|
8673
8789
|
pluginInjections = {},
|
|
8674
8790
|
pluginVertexInputs = {},
|
|
@@ -8692,13 +8808,20 @@ ${getApplicationDefines(allDefines)}
|
|
|
8692
8808
|
);
|
|
8693
8809
|
const coreSource = pluginVaryingAssembly.source;
|
|
8694
8810
|
let assembledSource = "";
|
|
8695
|
-
const
|
|
8696
|
-
|
|
8811
|
+
const injectionTargetMap = normalizeShaderInjectionTargets(
|
|
8812
|
+
injectionTargets,
|
|
8813
|
+
options.pluginInjectionTargets,
|
|
8814
|
+
"wgsl"
|
|
8815
|
+
);
|
|
8816
|
+
const targetInjections = {};
|
|
8697
8817
|
const declInjections = {};
|
|
8698
8818
|
const mainInjections = {};
|
|
8699
|
-
appendInjections(pluginInjections,
|
|
8700
|
-
|
|
8701
|
-
|
|
8819
|
+
appendInjections(pluginInjections, targetInjections, declInjections, mainInjections);
|
|
8820
|
+
const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "wgsl") : {};
|
|
8821
|
+
appendInjections(applicationInjections, targetInjections, declInjections, mainInjections);
|
|
8822
|
+
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
8823
|
+
for (const key in injectionMap) {
|
|
8824
|
+
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
8702
8825
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
8703
8826
|
if (match) {
|
|
8704
8827
|
const hash = match[2];
|
|
@@ -8710,7 +8833,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8710
8833
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
8711
8834
|
}
|
|
8712
8835
|
} else {
|
|
8713
|
-
|
|
8836
|
+
targetInjections[key] = [...targetInjections[key] || [], injection];
|
|
8714
8837
|
}
|
|
8715
8838
|
} else {
|
|
8716
8839
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
@@ -8723,7 +8846,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8723
8846
|
mainInjections
|
|
8724
8847
|
);
|
|
8725
8848
|
appendGeneratedVaryingInjections(pluginVaryingAssembly, declInjections, mainInjections);
|
|
8726
|
-
|
|
8849
|
+
validateShaderInjectionTargetInjections(injectionTargetMap, targetInjections);
|
|
8727
8850
|
const modulesToInject = modules.map((module) => ({
|
|
8728
8851
|
module,
|
|
8729
8852
|
source: preprocess(getShaderModuleSource(module, "wgsl", log8), { defines })
|
|
@@ -8752,19 +8875,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
8752
8875
|
checkShaderModuleDeprecations(module, coreSource, log8);
|
|
8753
8876
|
}
|
|
8754
8877
|
assembledSource += moduleSource;
|
|
8755
|
-
const injections = getWGSLModuleInjections(module);
|
|
8756
|
-
for (const key in injections) {
|
|
8757
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
8758
|
-
if (match) {
|
|
8759
|
-
const name = match[2];
|
|
8760
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
8761
|
-
injectionType[key] = injectionType[key] || [];
|
|
8762
|
-
injectionType[key].push(injections[key]);
|
|
8763
|
-
} else if (isShaderHookRegistered(hookFunctionMap, key)) {
|
|
8764
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
8765
|
-
hookInjections[key].push(injections[key]);
|
|
8766
|
-
}
|
|
8767
|
-
}
|
|
8768
8878
|
}
|
|
8769
8879
|
assembledSource += INJECT_SHADER_DECLARATIONS;
|
|
8770
8880
|
assembledSource = injectShader(
|
|
@@ -8775,13 +8885,31 @@ ${getApplicationDefines(allDefines)}
|
|
|
8775
8885
|
"wgsl",
|
|
8776
8886
|
{ vertex: vertexEntryPoint, fragment: fragmentEntryPoint }
|
|
8777
8887
|
);
|
|
8778
|
-
|
|
8888
|
+
const targetNames = getWGSLInjectionTargetNames(
|
|
8889
|
+
injectionTargetMap,
|
|
8890
|
+
[
|
|
8891
|
+
assembledSource,
|
|
8892
|
+
applicationRelocation.source,
|
|
8893
|
+
...Object.values(targetInjections).flat().map((injection) => injection.injection),
|
|
8894
|
+
...Object.values(mainInjections).flat().map((injection) => injection.injection)
|
|
8895
|
+
].join("\n")
|
|
8896
|
+
);
|
|
8897
|
+
assembledSource += getWGSLShaderInjectionTargets(
|
|
8898
|
+
injectionTargetMap,
|
|
8899
|
+
targetInjections,
|
|
8900
|
+
targetNames
|
|
8901
|
+
);
|
|
8779
8902
|
assembledSource += formatWGSLBindingAssignmentComments(bindingAssignments);
|
|
8780
8903
|
assembledSource += applicationRelocation.source;
|
|
8781
8904
|
assembledSource = injectShader(assembledSource, stage, mainInjections, false, "wgsl", {
|
|
8782
8905
|
vertex: vertexEntryPoint,
|
|
8783
8906
|
fragment: fragmentEntryPoint
|
|
8784
8907
|
});
|
|
8908
|
+
assembledSource = resolveWGSLInjectionTargetNames(
|
|
8909
|
+
assembledSource,
|
|
8910
|
+
injectionTargetMap,
|
|
8911
|
+
targetNames
|
|
8912
|
+
);
|
|
8785
8913
|
assertNoUnresolvedAutoBindings(assembledSource);
|
|
8786
8914
|
return { source: assembledSource, bindingAssignments };
|
|
8787
8915
|
}
|
|
@@ -8824,12 +8952,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
8824
8952
|
});
|
|
8825
8953
|
}
|
|
8826
8954
|
}
|
|
8827
|
-
function getWGSLModuleInjections(module) {
|
|
8828
|
-
return {
|
|
8829
|
-
...module.instance?.normalizedInjections.vertex || {},
|
|
8830
|
-
...module.instance?.normalizedInjections.fragment || {}
|
|
8831
|
-
};
|
|
8832
|
-
}
|
|
8833
8955
|
function getWGSLDeclarationInjections(declarationInjections) {
|
|
8834
8956
|
const unifiedDeclarations = [
|
|
8835
8957
|
...declarationInjections["vs:#decl"] || [],
|
|
@@ -8837,8 +8959,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
8837
8959
|
];
|
|
8838
8960
|
return unifiedDeclarations.length ? { "vs:#decl": unifiedDeclarations } : {};
|
|
8839
8961
|
}
|
|
8840
|
-
function
|
|
8841
|
-
return
|
|
8962
|
+
function getWGSLShaderInjectionTargets(injectionTargetMap, targetInjections, names = getWGSLInjectionTargetNames(injectionTargetMap)) {
|
|
8963
|
+
return ["vertex", "fragment"].map((stage) => {
|
|
8964
|
+
const targets = Object.fromEntries(
|
|
8965
|
+
Object.entries(injectionTargetMap[stage]).map(([key, target]) => {
|
|
8966
|
+
const name = key.slice(3);
|
|
8967
|
+
const emittedName = names.get(name)?.[stage] || name;
|
|
8968
|
+
return [key, { ...target, signature: emittedName + target.signature.slice(name.length) }];
|
|
8969
|
+
})
|
|
8970
|
+
);
|
|
8971
|
+
return getShaderInjectionTargets(targets, targetInjections, "wgsl");
|
|
8972
|
+
}).join("");
|
|
8842
8973
|
}
|
|
8843
8974
|
function getUsedBindingsByGroupFromApplicationWGSL(source4) {
|
|
8844
8975
|
const usedBindingsByGroup = /* @__PURE__ */ new Map();
|
|
@@ -9160,7 +9291,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9160
9291
|
*/
|
|
9161
9292
|
assembleWGSLShader(props) {
|
|
9162
9293
|
const modules = this._getModuleList(props.modules);
|
|
9163
|
-
const
|
|
9294
|
+
const injectionTargets = [...this._injectionTargets, ...props.injectionTargets || []];
|
|
9164
9295
|
const translated = this._transpileShader(
|
|
9165
9296
|
props,
|
|
9166
9297
|
modules,
|
|
@@ -9186,7 +9317,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9186
9317
|
defines,
|
|
9187
9318
|
_bindingRegistry: this._wgslBindingRegistry,
|
|
9188
9319
|
modules: translated.modules,
|
|
9189
|
-
|
|
9320
|
+
injectionTargets
|
|
9190
9321
|
});
|
|
9191
9322
|
const preprocessedSource = props.platformInfo.shaderLanguage === "wgsl" ? preprocess(assembledSource, { defines }) : assembledSource;
|
|
9192
9323
|
return {
|
|
@@ -9720,7 +9851,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9720
9851
|
}
|
|
9721
9852
|
|
|
9722
9853
|
// src/model/gpu-vector-draw-batches.ts
|
|
9723
|
-
function drawGPUVectorGroups(model, geometry, attributes, syncBindings, draw) {
|
|
9854
|
+
function drawGPUVectorGroups(model, geometry, attributes, syncBindings, draw, inferDrawCount) {
|
|
9724
9855
|
const geometryInputs = geometry.inputs;
|
|
9725
9856
|
const attributeInputs = attributes.inputs;
|
|
9726
9857
|
const geometryLayouts = geometry.sourceLayouts;
|
|
@@ -9758,16 +9889,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
9758
9889
|
);
|
|
9759
9890
|
syncBindings();
|
|
9760
9891
|
const vertexOffset = geometry.rowCount !== void 0 ? geometryOffsets[geometryBatchIndex] : attributes.vertexCount !== void 0 ? attributeOffsets[attributeBatchIndex] : 0;
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9892
|
+
if (inferDrawCount === "vertex")
|
|
9893
|
+
model.setVertexCount(
|
|
9894
|
+
Math.max(
|
|
9895
|
+
0,
|
|
9896
|
+
Math.min(
|
|
9897
|
+
geometry.rowCount ?? attributes.vertexCount ?? vertexCount,
|
|
9898
|
+
vertexCount - vertexOffset
|
|
9899
|
+
)
|
|
9767
9900
|
)
|
|
9768
|
-
)
|
|
9769
|
-
)
|
|
9770
|
-
if (attributes.instanceCount !== void 0)
|
|
9901
|
+
);
|
|
9902
|
+
if (inferDrawCount === "instance" && attributes.instanceCount !== void 0)
|
|
9771
9903
|
model.setInstanceCount(
|
|
9772
9904
|
Math.max(
|
|
9773
9905
|
0,
|
|
@@ -9825,8 +9957,14 @@ ${getApplicationDefines(allDefines)}
|
|
|
9825
9957
|
vertexCount;
|
|
9826
9958
|
instanceCount;
|
|
9827
9959
|
constantBuffers = {};
|
|
9828
|
-
setInputs(columns, explicitLayouts, stepMode) {
|
|
9829
|
-
|
|
9960
|
+
setInputs(columns, explicitLayouts, stepMode, enforceMatchingVectorLengths = true) {
|
|
9961
|
+
if (enforceMatchingVectorLengths) {
|
|
9962
|
+
validateGPUVectorBatchStructure(columns);
|
|
9963
|
+
} else {
|
|
9964
|
+
for (const column of Object.values(columns)) {
|
|
9965
|
+
if (column && !isConstant(column)) (0, import_core12.assert)(column.data.length === 1);
|
|
9966
|
+
}
|
|
9967
|
+
}
|
|
9830
9968
|
this.claimedNames.clear();
|
|
9831
9969
|
this.inputs = columns;
|
|
9832
9970
|
this.sourceLayouts = explicitLayouts;
|
|
@@ -9852,7 +9990,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9852
9990
|
if (!column) continue;
|
|
9853
9991
|
if (!isConstant(column) && !Array.isArray(column.data))
|
|
9854
9992
|
throw new TypeError(`Expected a GPU vector or constant for ${name}`);
|
|
9855
|
-
if (!isConstant(column)) {
|
|
9993
|
+
if (!isConstant(column) && enforceMatchingVectorLengths) {
|
|
9856
9994
|
const layout = layouts.find(
|
|
9857
9995
|
(layout2) => layout2.name === name || layout2.attributes?.some((attribute) => attribute.attribute === name)
|
|
9858
9996
|
);
|
|
@@ -10849,7 +10987,148 @@ ${getApplicationDefines(allDefines)}
|
|
|
10849
10987
|
return `${id}-${count}`;
|
|
10850
10988
|
}
|
|
10851
10989
|
|
|
10990
|
+
// ../core/src/api/utils/assert.ts
|
|
10991
|
+
function assert8(condition, message) {
|
|
10992
|
+
if (!condition) {
|
|
10993
|
+
const error = new Error(message ?? "luma.gl assertion failed.");
|
|
10994
|
+
Error.captureStackTrace?.(error, assert8);
|
|
10995
|
+
throw error;
|
|
10996
|
+
}
|
|
10997
|
+
}
|
|
10998
|
+
|
|
10852
10999
|
// ../core/src/api/adapter/resources/resource.ts
|
|
11000
|
+
var Resource = class {
|
|
11001
|
+
_owner = null;
|
|
11002
|
+
_ownedResources = /* @__PURE__ */ new Set();
|
|
11003
|
+
_state = "live";
|
|
11004
|
+
_destroyingOwnedResources = false;
|
|
11005
|
+
_destroyRequested = false;
|
|
11006
|
+
/** The resource responsible for destroying this resource, or null for caller-managed lifetime. */
|
|
11007
|
+
get owner() {
|
|
11008
|
+
return this._owner;
|
|
11009
|
+
}
|
|
11010
|
+
/** A snapshot of this resource's children. Mutating the snapshot cannot change ownership. */
|
|
11011
|
+
get ownedResources() {
|
|
11012
|
+
return Array.from(this._ownedResources);
|
|
11013
|
+
}
|
|
11014
|
+
/** Whether destruction has completed, including when cleanup reported an error. */
|
|
11015
|
+
get destroyed() {
|
|
11016
|
+
return this._state === "destroyed";
|
|
11017
|
+
}
|
|
11018
|
+
/** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
|
|
11019
|
+
transferOwnershipTo(owner) {
|
|
11020
|
+
assert8(this._state === "live" && !this._destroyingOwnedResources);
|
|
11021
|
+
assert8(!this._owner || this._owner.canChangeOwnership());
|
|
11022
|
+
assert8(!owner || owner.canChangeOwnership());
|
|
11023
|
+
for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
|
|
11024
|
+
assert8(ancestor !== this);
|
|
11025
|
+
}
|
|
11026
|
+
if (owner !== this._owner) {
|
|
11027
|
+
this._owner?._ownedResources.delete(this);
|
|
11028
|
+
this._owner = owner;
|
|
11029
|
+
owner?._ownedResources.add(this);
|
|
11030
|
+
}
|
|
11031
|
+
return this;
|
|
11032
|
+
}
|
|
11033
|
+
/** Destroy children before this resource. Subclasses implement hooks instead of overriding. */
|
|
11034
|
+
destroy() {
|
|
11035
|
+
if (this._state !== "live") {
|
|
11036
|
+
return;
|
|
11037
|
+
}
|
|
11038
|
+
if (this._destroyingOwnedResources) {
|
|
11039
|
+
this._destroyRequested = true;
|
|
11040
|
+
return;
|
|
11041
|
+
}
|
|
11042
|
+
this._destroyRequested = false;
|
|
11043
|
+
this._state = "destroying";
|
|
11044
|
+
this._owner?._ownedResources.delete(this);
|
|
11045
|
+
this._owner = null;
|
|
11046
|
+
const errors = [];
|
|
11047
|
+
try {
|
|
11048
|
+
try {
|
|
11049
|
+
this.onBeforeDestroy();
|
|
11050
|
+
} catch (error) {
|
|
11051
|
+
errors.push(error);
|
|
11052
|
+
}
|
|
11053
|
+
this.destroyChildren(errors);
|
|
11054
|
+
try {
|
|
11055
|
+
this.onDestroy();
|
|
11056
|
+
} catch (error) {
|
|
11057
|
+
errors.push(error);
|
|
11058
|
+
}
|
|
11059
|
+
} finally {
|
|
11060
|
+
this._state = "destroyed";
|
|
11061
|
+
}
|
|
11062
|
+
if (errors.length) {
|
|
11063
|
+
throw new AggregateError(errors, "Resource cleanup failed");
|
|
11064
|
+
}
|
|
11065
|
+
}
|
|
11066
|
+
/** @deprecated Use destroy(). */
|
|
11067
|
+
delete() {
|
|
11068
|
+
this.destroy();
|
|
11069
|
+
return this;
|
|
11070
|
+
}
|
|
11071
|
+
/** @deprecated Use resource.transferOwnershipTo(this). */
|
|
11072
|
+
attachResource(resource) {
|
|
11073
|
+
resource.transferOwnershipTo(this);
|
|
11074
|
+
}
|
|
11075
|
+
/** @deprecated Use resource.transferOwnershipTo(null). Only detaches a child owned by this. */
|
|
11076
|
+
detachResource(resource) {
|
|
11077
|
+
if (resource._owner === this) {
|
|
11078
|
+
resource.transferOwnershipTo(null);
|
|
11079
|
+
}
|
|
11080
|
+
}
|
|
11081
|
+
/** @deprecated Check resource.owner and call resource.destroy(). */
|
|
11082
|
+
destroyAttachedResource(resource) {
|
|
11083
|
+
if (resource._owner === this) {
|
|
11084
|
+
resource.destroy();
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11087
|
+
/** @deprecated Destroy individually owned resources, or destroy the owner. */
|
|
11088
|
+
destroyAttachedResources() {
|
|
11089
|
+
if (this._state !== "live" || this._destroyingOwnedResources) {
|
|
11090
|
+
return;
|
|
11091
|
+
}
|
|
11092
|
+
const errors = [];
|
|
11093
|
+
this.destroyChildren(errors);
|
|
11094
|
+
if (this._destroyRequested) {
|
|
11095
|
+
try {
|
|
11096
|
+
this.destroy();
|
|
11097
|
+
} catch (error) {
|
|
11098
|
+
errors.push(error);
|
|
11099
|
+
}
|
|
11100
|
+
}
|
|
11101
|
+
if (errors.length) {
|
|
11102
|
+
throw new AggregateError(errors, "Resource cleanup failed");
|
|
11103
|
+
}
|
|
11104
|
+
}
|
|
11105
|
+
/** Stop activity before children are destroyed. Errors are collected; this hook cannot veto cleanup. */
|
|
11106
|
+
onBeforeDestroy() {
|
|
11107
|
+
}
|
|
11108
|
+
/** Release this resource's own state after its children have been destroyed. */
|
|
11109
|
+
onDestroy() {
|
|
11110
|
+
}
|
|
11111
|
+
canChangeOwnership() {
|
|
11112
|
+
return this._state === "live" && !this._destroyingOwnedResources;
|
|
11113
|
+
}
|
|
11114
|
+
destroyChildren(errors) {
|
|
11115
|
+
this._destroyingOwnedResources = true;
|
|
11116
|
+
try {
|
|
11117
|
+
for (const resource of this._ownedResources) {
|
|
11118
|
+
try {
|
|
11119
|
+
resource.destroy();
|
|
11120
|
+
} catch (error) {
|
|
11121
|
+
errors.push(error);
|
|
11122
|
+
}
|
|
11123
|
+
}
|
|
11124
|
+
} finally {
|
|
11125
|
+
this._ownedResources.clear();
|
|
11126
|
+
this._destroyingOwnedResources = false;
|
|
11127
|
+
}
|
|
11128
|
+
}
|
|
11129
|
+
};
|
|
11130
|
+
|
|
11131
|
+
// ../core/src/api/adapter/resources/device-resource.ts
|
|
10853
11132
|
var CPU_HOTSPOT_PROFILER_MODULE = "cpu-hotspot-profiler";
|
|
10854
11133
|
var RESOURCE_COUNTS_STATS = "GPU Resource Counts";
|
|
10855
11134
|
var LEGACY_RESOURCE_COUNTS_STATS = "Resource Counts";
|
|
@@ -10905,7 +11184,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10905
11184
|
]);
|
|
10906
11185
|
var ORDERED_STATS_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10907
11186
|
var ORDERED_STAT_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10908
|
-
var
|
|
11187
|
+
var DeviceResource = class extends Resource {
|
|
10909
11188
|
/** Default properties for resource */
|
|
10910
11189
|
static defaultProps = {
|
|
10911
11190
|
id: "undefined",
|
|
@@ -10928,14 +11207,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
10928
11207
|
userData = {};
|
|
10929
11208
|
/** The device that this resource is associated with - TODO can we remove this dup? */
|
|
10930
11209
|
_device;
|
|
10931
|
-
/** Whether this resource has been destroyed */
|
|
10932
|
-
destroyed = false;
|
|
10933
11210
|
/** For resources that allocate GPU memory */
|
|
10934
11211
|
allocatedBytes = 0;
|
|
10935
11212
|
/** Stats bucket currently holding the tracked allocation */
|
|
10936
11213
|
allocatedBytesName = null;
|
|
10937
|
-
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
10938
|
-
_attachedResources = /* @__PURE__ */ new Set();
|
|
10939
11214
|
/** Whether luma.gl created and owns the underlying resource handle. */
|
|
10940
11215
|
get ownsHandle() {
|
|
10941
11216
|
return (this.props.handle === void 0 || this.props.handle === null) && !this.isHandleBorrowed;
|
|
@@ -10945,9 +11220,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
10945
11220
|
return Boolean(this.props._isHandleBorrowed);
|
|
10946
11221
|
}
|
|
10947
11222
|
/**
|
|
10948
|
-
* Create a new
|
|
11223
|
+
* Create a new DeviceResource. Called from Subclass
|
|
10949
11224
|
*/
|
|
10950
11225
|
constructor(device, props, defaultProps) {
|
|
11226
|
+
super();
|
|
10951
11227
|
if (!device) {
|
|
10952
11228
|
throw new Error("no device");
|
|
10953
11229
|
}
|
|
@@ -10959,20 +11235,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
10959
11235
|
this.userData = this.props.userData || {};
|
|
10960
11236
|
this.addStats();
|
|
10961
11237
|
}
|
|
10962
|
-
/**
|
|
10963
|
-
* destroy can be called on any resource to release it before it is garbage collected.
|
|
10964
|
-
*/
|
|
10965
|
-
destroy() {
|
|
10966
|
-
if (this.destroyed) {
|
|
10967
|
-
return;
|
|
10968
|
-
}
|
|
10969
|
-
this.destroyResource();
|
|
10970
|
-
}
|
|
10971
|
-
/** @deprecated Use destroy() */
|
|
10972
|
-
delete() {
|
|
10973
|
-
this.destroy();
|
|
10974
|
-
return this;
|
|
10975
|
-
}
|
|
10976
11238
|
/**
|
|
10977
11239
|
* Combines a map of user props and default props, only including props from defaultProps
|
|
10978
11240
|
* @returns returns a map of overridden default props
|
|
@@ -10980,46 +11242,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
10980
11242
|
getProps() {
|
|
10981
11243
|
return this.props;
|
|
10982
11244
|
}
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
10986
|
-
* Called automatically when sub resources are auto created but can be called by application
|
|
10987
|
-
*/
|
|
10988
|
-
attachResource(resource) {
|
|
10989
|
-
this._attachedResources.add(resource);
|
|
10990
|
-
}
|
|
10991
|
-
/**
|
|
10992
|
-
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
10993
|
-
*/
|
|
10994
|
-
detachResource(resource) {
|
|
10995
|
-
this._attachedResources.delete(resource);
|
|
10996
|
-
}
|
|
10997
|
-
/**
|
|
10998
|
-
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
10999
|
-
*/
|
|
11000
|
-
destroyAttachedResource(resource) {
|
|
11001
|
-
if (this._attachedResources.delete(resource)) {
|
|
11002
|
-
resource.destroy();
|
|
11003
|
-
}
|
|
11004
|
-
}
|
|
11005
|
-
/** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
|
|
11006
|
-
destroyAttachedResources() {
|
|
11007
|
-
for (const resource of this._attachedResources) {
|
|
11008
|
-
resource.destroy();
|
|
11009
|
-
}
|
|
11010
|
-
this._attachedResources = /* @__PURE__ */ new Set();
|
|
11245
|
+
/** Backend cleanup. Override this instead of destroy(); children are already destroyed. */
|
|
11246
|
+
destroyHandle() {
|
|
11011
11247
|
}
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11248
|
+
/** Complete device bookkeeping even when backend cleanup fails. */
|
|
11249
|
+
onDestroy() {
|
|
11250
|
+
try {
|
|
11251
|
+
this.destroyHandle();
|
|
11252
|
+
} finally {
|
|
11253
|
+
this.trackDeallocatedMemory();
|
|
11254
|
+
this.removeStats();
|
|
11017
11255
|
}
|
|
11018
|
-
this.destroyAttachedResources();
|
|
11019
|
-
this.removeStats();
|
|
11020
|
-
this.destroyed = true;
|
|
11021
11256
|
}
|
|
11022
|
-
/**
|
|
11257
|
+
/** Track object destruction after backend cleanup. */
|
|
11023
11258
|
removeStats() {
|
|
11024
11259
|
const profiler = getCpuHotspotProfiler(this._device);
|
|
11025
11260
|
const startTime = profiler ? getTimestamp() : 0;
|
|
@@ -11197,7 +11432,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11197
11432
|
let prototype = Object.getPrototypeOf(resource);
|
|
11198
11433
|
while (prototype) {
|
|
11199
11434
|
const parentPrototype = Object.getPrototypeOf(prototype);
|
|
11200
|
-
if (!parentPrototype || parentPrototype ===
|
|
11435
|
+
if (!parentPrototype || parentPrototype === DeviceResource.prototype) {
|
|
11201
11436
|
return getPrototypeToStringTag(prototype) || resource[Symbol.toStringTag] || resource.constructor.name;
|
|
11202
11437
|
}
|
|
11203
11438
|
prototype = parentPrototype;
|
|
@@ -11216,7 +11451,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11216
11451
|
}
|
|
11217
11452
|
|
|
11218
11453
|
// ../core/src/api/adapter/resources/buffer.ts
|
|
11219
|
-
var Buffer4 = class _Buffer extends
|
|
11454
|
+
var Buffer4 = class _Buffer extends DeviceResource {
|
|
11220
11455
|
/** Index buffer */
|
|
11221
11456
|
static INDEX = 16;
|
|
11222
11457
|
/** Vertex buffer */
|
|
@@ -11297,7 +11532,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11297
11532
|
}
|
|
11298
11533
|
}
|
|
11299
11534
|
static defaultProps = {
|
|
11300
|
-
...
|
|
11535
|
+
...DeviceResource.defaultProps,
|
|
11301
11536
|
handle: void 0,
|
|
11302
11537
|
usage: 0,
|
|
11303
11538
|
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
@@ -11319,7 +11554,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
11319
11554
|
}
|
|
11320
11555
|
|
|
11321
11556
|
// ../core/src/shadertypes/data-types/decode-data-types.ts
|
|
11557
|
+
var dataTypeInfoCache = /* @__PURE__ */ new Map();
|
|
11322
11558
|
function getDataTypeInfo(type) {
|
|
11559
|
+
const cached = dataTypeInfoCache.get(type);
|
|
11560
|
+
if (cached) {
|
|
11561
|
+
return cached;
|
|
11562
|
+
}
|
|
11563
|
+
const decoded = Object.freeze(decodeDataTypeInfo(type));
|
|
11564
|
+
if (Object.hasOwn(NORMALIZED_TYPE_MAP, type)) {
|
|
11565
|
+
dataTypeInfoCache.set(type, decoded);
|
|
11566
|
+
}
|
|
11567
|
+
return decoded;
|
|
11568
|
+
}
|
|
11569
|
+
function decodeDataTypeInfo(type) {
|
|
11323
11570
|
const normalized2 = type.includes("norm");
|
|
11324
11571
|
const integer = !normalized2 && !type.startsWith("float");
|
|
11325
11572
|
const signed = type.startsWith("s");
|
|
@@ -11660,40 +11907,33 @@ ${getApplicationDefines(allDefines)}
|
|
|
11660
11907
|
return this.isCompressed(format) && !format.endsWith("-webgl") ? WEBGPU_CREATE_FILTER2 : 0;
|
|
11661
11908
|
}
|
|
11662
11909
|
/** Computes the memory layout for a texture, in particular including row byte alignment */
|
|
11663
|
-
computeMemoryLayout(opts) {
|
|
11664
|
-
return computeTextureMemoryLayout(opts);
|
|
11910
|
+
computeMemoryLayout(opts, result) {
|
|
11911
|
+
return computeTextureMemoryLayout(opts, result);
|
|
11665
11912
|
}
|
|
11666
11913
|
};
|
|
11667
11914
|
var textureFormatDecoder = new TextureFormatDecoder();
|
|
11668
|
-
function computeTextureMemoryLayout({
|
|
11669
|
-
format,
|
|
11670
|
-
width,
|
|
11671
|
-
height,
|
|
11672
|
-
depth,
|
|
11673
|
-
byteAlignment
|
|
11674
|
-
}) {
|
|
11915
|
+
function computeTextureMemoryLayout({ format, width, height, depth, byteAlignment }, result = {}) {
|
|
11675
11916
|
const formatInfo = textureFormatDecoder.getInfo(format);
|
|
11917
|
+
const { bytesPerPixel, blockHeight = 1, compressed = false } = formatInfo;
|
|
11918
|
+
const bytesPerRow = getTextureBytesPerRow(formatInfo, width, byteAlignment);
|
|
11919
|
+
const rowsPerImage = compressed ? Math.ceil(height / blockHeight) : height;
|
|
11920
|
+
result.bytesPerPixel = bytesPerPixel;
|
|
11921
|
+
result.bytesPerRow = bytesPerRow;
|
|
11922
|
+
result.rowsPerImage = rowsPerImage;
|
|
11923
|
+
result.depthOrArrayLayers = depth;
|
|
11924
|
+
result.bytesPerImage = bytesPerRow * rowsPerImage;
|
|
11925
|
+
result.byteLength = result.bytesPerImage * depth;
|
|
11926
|
+
return result;
|
|
11927
|
+
}
|
|
11928
|
+
function getTextureBytesPerRow(formatInfo, width, byteAlignment) {
|
|
11676
11929
|
const {
|
|
11677
11930
|
bytesPerPixel,
|
|
11678
11931
|
bytesPerBlock = bytesPerPixel,
|
|
11679
11932
|
blockWidth = 1,
|
|
11680
|
-
blockHeight = 1,
|
|
11681
11933
|
compressed = false
|
|
11682
11934
|
} = formatInfo;
|
|
11683
11935
|
const blockColumns = compressed ? Math.ceil(width / blockWidth) : width;
|
|
11684
|
-
|
|
11685
|
-
const unpaddedBytesPerRow = blockColumns * bytesPerBlock;
|
|
11686
|
-
const bytesPerRow = Math.ceil(unpaddedBytesPerRow / byteAlignment) * byteAlignment;
|
|
11687
|
-
const rowsPerImage = blockRows;
|
|
11688
|
-
const byteLength = bytesPerRow * rowsPerImage * depth;
|
|
11689
|
-
return {
|
|
11690
|
-
bytesPerPixel,
|
|
11691
|
-
bytesPerRow,
|
|
11692
|
-
rowsPerImage,
|
|
11693
|
-
depthOrArrayLayers: depth,
|
|
11694
|
-
bytesPerImage: bytesPerRow * rowsPerImage,
|
|
11695
|
-
byteLength
|
|
11696
|
-
};
|
|
11936
|
+
return Math.ceil(blockColumns * bytesPerBlock / byteAlignment) * byteAlignment;
|
|
11697
11937
|
}
|
|
11698
11938
|
function getTextureFormatCapabilities(format) {
|
|
11699
11939
|
const info = getTextureFormatDefinition(format);
|
|
@@ -11715,7 +11955,18 @@ ${getApplicationDefines(allDefines)}
|
|
|
11715
11955
|
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
11716
11956
|
return formatCapabilities;
|
|
11717
11957
|
}
|
|
11958
|
+
var textureFormatInfoCache = /* @__PURE__ */ new Map();
|
|
11718
11959
|
function getTextureFormatInfo(format) {
|
|
11960
|
+
let formatInfo = textureFormatInfoCache.get(format);
|
|
11961
|
+
if (!formatInfo) {
|
|
11962
|
+
const decoded = decodeTextureFormatInfo(format);
|
|
11963
|
+
decoded.bitsPerChannel = Object.freeze([...decoded.bitsPerChannel]);
|
|
11964
|
+
formatInfo = Object.freeze(decoded);
|
|
11965
|
+
textureFormatInfoCache.set(format, formatInfo);
|
|
11966
|
+
}
|
|
11967
|
+
return formatInfo;
|
|
11968
|
+
}
|
|
11969
|
+
function decodeTextureFormatInfo(format) {
|
|
11719
11970
|
let formatInfo = getTextureFormatInfoUsingTable(format);
|
|
11720
11971
|
if (textureFormatDecoder.isCompressed(format)) {
|
|
11721
11972
|
formatInfo.channels = "rgb";
|
|
@@ -11855,9 +12106,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
11855
12106
|
}
|
|
11856
12107
|
|
|
11857
12108
|
// ../core/src/api/adapter/resources/sampler.ts
|
|
11858
|
-
var Sampler = class _Sampler extends
|
|
12109
|
+
var Sampler = class _Sampler extends DeviceResource {
|
|
11859
12110
|
static defaultProps = {
|
|
11860
|
-
...
|
|
12111
|
+
...DeviceResource.defaultProps,
|
|
11861
12112
|
type: "color-sampler",
|
|
11862
12113
|
addressModeU: "clamp-to-edge",
|
|
11863
12114
|
addressModeV: "clamp-to-edge",
|
|
@@ -11882,8 +12133,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
11882
12133
|
return props;
|
|
11883
12134
|
}
|
|
11884
12135
|
};
|
|
12136
|
+
function setTextureSampler(texture, sampler) {
|
|
12137
|
+
const nextSampler = sampler instanceof Sampler ? sampler : texture.device.createSampler(sampler);
|
|
12138
|
+
if (nextSampler === texture.sampler) {
|
|
12139
|
+
return;
|
|
12140
|
+
}
|
|
12141
|
+
if (!(sampler instanceof Sampler)) {
|
|
12142
|
+
nextSampler.transferOwnershipTo(texture);
|
|
12143
|
+
}
|
|
12144
|
+
const previousSampler = texture.sampler;
|
|
12145
|
+
texture.sampler = nextSampler;
|
|
12146
|
+
if (previousSampler?.owner === texture) {
|
|
12147
|
+
previousSampler.destroy();
|
|
12148
|
+
}
|
|
12149
|
+
}
|
|
11885
12150
|
|
|
11886
12151
|
// ../core/src/api/adapter/resources/texture.ts
|
|
12152
|
+
var textureLayoutScratchPool = [];
|
|
12153
|
+
var emptyTextureReadOptions = Object.freeze({});
|
|
11887
12154
|
var BASE_DIMENSIONS = {
|
|
11888
12155
|
"1d": "1d",
|
|
11889
12156
|
"2d": "2d",
|
|
@@ -11892,7 +12159,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11892
12159
|
"cube-array": "2d",
|
|
11893
12160
|
"3d": "3d"
|
|
11894
12161
|
};
|
|
11895
|
-
var Texture = class _Texture extends
|
|
12162
|
+
var Texture = class _Texture extends DeviceResource {
|
|
11896
12163
|
/** The texture can be bound for use as a sampled texture in a shader */
|
|
11897
12164
|
static SAMPLE = 4;
|
|
11898
12165
|
/** The texture can be bound for use as a storage texture in a shader */
|
|
@@ -11980,7 +12247,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11980
12247
|
}
|
|
11981
12248
|
/** Set sampler props associated with this texture */
|
|
11982
12249
|
setSampler(sampler) {
|
|
11983
|
-
this
|
|
12250
|
+
setTextureSampler(this, sampler);
|
|
11984
12251
|
}
|
|
11985
12252
|
/**
|
|
11986
12253
|
* Copy raw image data (bytes) into the texture.
|
|
@@ -12002,17 +12269,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
12002
12269
|
* Calculates the memory layout of the texture, required when reading and writing data.
|
|
12003
12270
|
* @return the backend-aligned linear layout, in particular bytesPerRow which includes any required padding for buffer copy/read paths
|
|
12004
12271
|
*/
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
const
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12272
|
+
/** The optional result is caller-owned; internal scratch never escapes this call. */
|
|
12273
|
+
computeMemoryLayout(options_ = emptyTextureReadOptions, result) {
|
|
12274
|
+
const scratch = textureLayoutScratchPool.pop() || {
|
|
12275
|
+
readOptions: {},
|
|
12276
|
+
layoutOptions: {}
|
|
12277
|
+
};
|
|
12278
|
+
try {
|
|
12279
|
+
const options = this._normalizeTextureReadOptions(options_, scratch.readOptions);
|
|
12280
|
+
const layoutOptions = scratch.layoutOptions;
|
|
12281
|
+
layoutOptions.format = this.format;
|
|
12282
|
+
layoutOptions.width = options.width;
|
|
12283
|
+
layoutOptions.height = options.height;
|
|
12284
|
+
layoutOptions.depth = options.depthOrArrayLayers;
|
|
12285
|
+
layoutOptions.byteAlignment = this.byteAlignment;
|
|
12286
|
+
return textureFormatDecoder.computeMemoryLayout(layoutOptions, result);
|
|
12287
|
+
} finally {
|
|
12288
|
+
textureLayoutScratchPool.push(scratch);
|
|
12289
|
+
}
|
|
12016
12290
|
}
|
|
12017
12291
|
/**
|
|
12018
12292
|
* Read the contents of a texture into a GPU Buffer.
|
|
@@ -12121,59 +12395,57 @@ ${getApplicationDefines(allDefines)}
|
|
|
12121
12395
|
});
|
|
12122
12396
|
}
|
|
12123
12397
|
}
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
const
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12398
|
+
/** The optional result is caller-owned scratch storage; every result field is overwritten. */
|
|
12399
|
+
_normalizeCopyImageDataOptions(options_, result = {}) {
|
|
12400
|
+
const { data, depth, depthOrArrayLayers } = options_;
|
|
12401
|
+
this._normalizeTextureWriteOptions(options_, result);
|
|
12402
|
+
if (depthOrArrayLayers === void 0 && depth !== void 0) {
|
|
12403
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> result.mipLevel) : this.depth;
|
|
12404
|
+
result.depthOrArrayLayers = Math.min(depth, mipDepth - result.z);
|
|
12405
|
+
}
|
|
12406
|
+
result.data = data;
|
|
12407
|
+
result.depth = result.depthOrArrayLayers;
|
|
12408
|
+
return result;
|
|
12131
12409
|
}
|
|
12132
|
-
_normalizeCopyExternalImageOptions(options_) {
|
|
12133
|
-
const
|
|
12134
|
-
const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
|
|
12135
|
-
const mipLevelSize = this._getMipLevelSize(mipLevel);
|
|
12410
|
+
_normalizeCopyExternalImageOptions(options_, result = {}) {
|
|
12411
|
+
const { width, height } = options_;
|
|
12136
12412
|
const size = this.device.getExternalImageSize(options_.image);
|
|
12137
|
-
const options =
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
options.
|
|
12413
|
+
const options = _Texture._normalizeOptions(
|
|
12414
|
+
options_,
|
|
12415
|
+
_Texture.defaultCopyExternalImageOptions,
|
|
12416
|
+
result
|
|
12417
|
+
);
|
|
12418
|
+
const mipWidth = Math.max(1, this.width >> options.mipLevel);
|
|
12419
|
+
const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
|
|
12420
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
|
|
12421
|
+
options.width = Math.min(width ?? size.width, mipWidth - options.x);
|
|
12422
|
+
options.height = Math.min(height ?? size.height, mipHeight - options.y);
|
|
12423
|
+
options.depth = Math.min(options.depth, mipDepth - options.z);
|
|
12146
12424
|
return options;
|
|
12147
12425
|
}
|
|
12148
|
-
_normalizeCopyElementImageOptions(options_) {
|
|
12149
|
-
const
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
options.width = Math.min(options.width,
|
|
12158
|
-
options.height = Math.min(options.height,
|
|
12159
|
-
options.depth = Math.min(options.depth,
|
|
12426
|
+
_normalizeCopyElementImageOptions(options_, result = {}) {
|
|
12427
|
+
const options = _Texture._normalizeOptions(
|
|
12428
|
+
options_,
|
|
12429
|
+
_Texture.defaultCopyElementImageOptions,
|
|
12430
|
+
result
|
|
12431
|
+
);
|
|
12432
|
+
const mipWidth = Math.max(1, this.width >> options.mipLevel);
|
|
12433
|
+
const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
|
|
12434
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
|
|
12435
|
+
options.width = Math.min(options.width ?? mipWidth, mipWidth - options.x);
|
|
12436
|
+
options.height = Math.min(options.height ?? mipHeight, mipHeight - options.y);
|
|
12437
|
+
options.depth = Math.min(options.depth, mipDepth - options.z);
|
|
12160
12438
|
return options;
|
|
12161
12439
|
}
|
|
12162
|
-
_normalizeTextureReadOptions(options_) {
|
|
12163
|
-
const
|
|
12164
|
-
const
|
|
12165
|
-
const
|
|
12166
|
-
const
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
options.width = Math.min(options.width, mipLevelSize.width - options.x);
|
|
12172
|
-
options.height = Math.min(options.height, mipLevelSize.height - options.y);
|
|
12173
|
-
options.depthOrArrayLayers = Math.min(
|
|
12174
|
-
options.depthOrArrayLayers,
|
|
12175
|
-
mipLevelSize.depthOrArrayLayers - options.z
|
|
12176
|
-
);
|
|
12440
|
+
_normalizeTextureReadOptions(options_, result = {}) {
|
|
12441
|
+
const { depthOrArrayLayers } = options_;
|
|
12442
|
+
const options = _Texture._normalizeOptions(options_, _Texture.defaultTextureReadOptions, result);
|
|
12443
|
+
const mipWidth = Math.max(1, this.width >> options.mipLevel);
|
|
12444
|
+
const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
|
|
12445
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
|
|
12446
|
+
options.width = Math.min(options.width ?? mipWidth, mipWidth - options.x);
|
|
12447
|
+
options.height = Math.min(options.height ?? mipHeight, mipHeight - options.y);
|
|
12448
|
+
options.depthOrArrayLayers = Math.min(depthOrArrayLayers ?? mipDepth, mipDepth - options.z);
|
|
12177
12449
|
return options;
|
|
12178
12450
|
}
|
|
12179
12451
|
/**
|
|
@@ -12228,31 +12500,15 @@ ${getApplicationDefines(allDefines)}
|
|
|
12228
12500
|
throw new Error(`${this} color readback does not support format ${this.format}`);
|
|
12229
12501
|
}
|
|
12230
12502
|
}
|
|
12231
|
-
_normalizeTextureWriteOptions(options_) {
|
|
12232
|
-
const
|
|
12233
|
-
|
|
12234
|
-
const
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
options.width = Math.min(options.width, mipLevelSize.width - options.x);
|
|
12241
|
-
options.height = Math.min(options.height, mipLevelSize.height - options.y);
|
|
12242
|
-
options.depthOrArrayLayers = Math.min(
|
|
12243
|
-
options.depthOrArrayLayers,
|
|
12244
|
-
mipLevelSize.depthOrArrayLayers - options.z
|
|
12245
|
-
);
|
|
12246
|
-
const layout = textureFormatDecoder.computeMemoryLayout({
|
|
12247
|
-
format: this.format,
|
|
12248
|
-
width: options.width,
|
|
12249
|
-
height: options.height,
|
|
12250
|
-
depth: options.depthOrArrayLayers,
|
|
12251
|
-
byteAlignment: this.byteAlignment
|
|
12252
|
-
});
|
|
12253
|
-
const minimumBytesPerRow = layout.bytesPerPixel * options.width;
|
|
12254
|
-
options.bytesPerRow = optionsWithoutUndefined.bytesPerRow ?? layout.bytesPerRow;
|
|
12255
|
-
options.rowsPerImage = optionsWithoutUndefined.rowsPerImage ?? options.height;
|
|
12503
|
+
_normalizeTextureWriteOptions(options_, result = {}) {
|
|
12504
|
+
const { byteOffset = 0, bytesPerRow, rowsPerImage } = options_;
|
|
12505
|
+
this._normalizeTextureReadOptions(options_, result);
|
|
12506
|
+
const options = result;
|
|
12507
|
+
options.byteOffset = byteOffset;
|
|
12508
|
+
const formatInfo = this.device.getTextureFormatInfo(this.format);
|
|
12509
|
+
const minimumBytesPerRow = formatInfo.bytesPerPixel * options.width;
|
|
12510
|
+
options.bytesPerRow = bytesPerRow ?? getTextureBytesPerRow(formatInfo, options.width, this.byteAlignment);
|
|
12511
|
+
options.rowsPerImage = rowsPerImage ?? options.height;
|
|
12256
12512
|
if (options.bytesPerRow < minimumBytesPerRow) {
|
|
12257
12513
|
throw new Error(
|
|
12258
12514
|
`bytesPerRow (${options.bytesPerRow}) must be at least ${minimumBytesPerRow} for ${this.format}`
|
|
@@ -12263,7 +12519,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12263
12519
|
`rowsPerImage (${options.rowsPerImage}) must be at least ${options.height} for ${this.format}`
|
|
12264
12520
|
);
|
|
12265
12521
|
}
|
|
12266
|
-
const bytesPerPixel =
|
|
12522
|
+
const { bytesPerPixel } = formatInfo;
|
|
12267
12523
|
if (bytesPerPixel && options.bytesPerRow % bytesPerPixel !== 0) {
|
|
12268
12524
|
throw new Error(
|
|
12269
12525
|
`bytesPerRow (${options.bytesPerRow}) must be a multiple of bytesPerPixel (${bytesPerPixel}) for ${this.format}`
|
|
@@ -12291,13 +12547,15 @@ ${getApplicationDefines(allDefines)}
|
|
|
12291
12547
|
}
|
|
12292
12548
|
return allocatedByteLength * this.samples;
|
|
12293
12549
|
}
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12550
|
+
/** Fill every declared field, resetting stale scratch values without allocating entries or spreads. */
|
|
12551
|
+
static _normalizeOptions(options, defaults, result) {
|
|
12552
|
+
for (const key in defaults) {
|
|
12553
|
+
result[key] = options[key] === void 0 ? defaults[key] : options[key];
|
|
12554
|
+
}
|
|
12555
|
+
return result;
|
|
12298
12556
|
}
|
|
12299
12557
|
static defaultProps = {
|
|
12300
|
-
...
|
|
12558
|
+
...DeviceResource.defaultProps,
|
|
12301
12559
|
data: null,
|
|
12302
12560
|
dimension: "2d",
|
|
12303
12561
|
format: "rgba8unorm",
|
|
@@ -12371,19 +12629,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
12371
12629
|
mipLevel: 0,
|
|
12372
12630
|
aspect: "all"
|
|
12373
12631
|
};
|
|
12374
|
-
static defaultTextureWriteOptions = {
|
|
12375
|
-
byteOffset: 0,
|
|
12376
|
-
bytesPerRow: void 0,
|
|
12377
|
-
rowsPerImage: void 0,
|
|
12378
|
-
x: 0,
|
|
12379
|
-
y: 0,
|
|
12380
|
-
z: 0,
|
|
12381
|
-
width: void 0,
|
|
12382
|
-
height: void 0,
|
|
12383
|
-
depthOrArrayLayers: 1,
|
|
12384
|
-
mipLevel: 0,
|
|
12385
|
-
aspect: "all"
|
|
12386
|
-
};
|
|
12387
12632
|
};
|
|
12388
12633
|
|
|
12389
12634
|
// ../core/src/api/adapter-utils/bind-groups.ts
|
|
@@ -13421,7 +13666,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
13421
13666
|
}
|
|
13422
13667
|
static defaultProps = {
|
|
13423
13668
|
...import_core14.RenderPipeline.defaultProps,
|
|
13424
|
-
|
|
13669
|
+
inferDrawCount: "no",
|
|
13670
|
+
enforceMatchingVectorLengths: true,
|
|
13425
13671
|
geometry: null,
|
|
13426
13672
|
attributeVectors: void 0,
|
|
13427
13673
|
source: void 0,
|
|
@@ -13615,7 +13861,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13615
13861
|
...this.props,
|
|
13616
13862
|
modules,
|
|
13617
13863
|
defines,
|
|
13618
|
-
|
|
13864
|
+
pluginInjectionTargets: resolvedPlugins.injectionTargets,
|
|
13619
13865
|
pluginInjections: resolvedPlugins.injections,
|
|
13620
13866
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13621
13867
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13646,7 +13892,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13646
13892
|
...this.props,
|
|
13647
13893
|
modules,
|
|
13648
13894
|
defines,
|
|
13649
|
-
|
|
13895
|
+
pluginInjectionTargets: resolvedPlugins.injectionTargets,
|
|
13650
13896
|
pluginInjections: resolvedPlugins.injections,
|
|
13651
13897
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13652
13898
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13764,9 +14010,26 @@ ${getApplicationDefines(allDefines)}
|
|
|
13764
14010
|
/**
|
|
13765
14011
|
* Issue one draw call.
|
|
13766
14012
|
* @param renderPass - render pass to draw into
|
|
14013
|
+
* @param options - Optional dynamic parameters restored after drawing, including on errors.
|
|
13767
14014
|
* @returns `true` if the draw call was executed, `false` if resources were not ready.
|
|
13768
14015
|
*/
|
|
13769
|
-
draw(renderPass) {
|
|
14016
|
+
draw(renderPass, options) {
|
|
14017
|
+
if (options?.parameters) {
|
|
14018
|
+
return this._withDrawParameters(renderPass, options.parameters, () => this._draw(renderPass));
|
|
14019
|
+
}
|
|
14020
|
+
return this._draw(renderPass);
|
|
14021
|
+
}
|
|
14022
|
+
/** Applies draw overrides around the complete model batch, including failure paths. */
|
|
14023
|
+
_withDrawParameters(renderPass, parameters, draw) {
|
|
14024
|
+
const state = renderPass.getParameters();
|
|
14025
|
+
try {
|
|
14026
|
+
renderPass.setParameters(parameters);
|
|
14027
|
+
return draw();
|
|
14028
|
+
} finally {
|
|
14029
|
+
renderPass.setParameters(state);
|
|
14030
|
+
}
|
|
14031
|
+
}
|
|
14032
|
+
_draw(renderPass) {
|
|
13770
14033
|
if (this.indexVector?.length === 0) {
|
|
13771
14034
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
13772
14035
|
this._needsRedraw = false;
|
|
@@ -13872,20 +14135,27 @@ ${getApplicationDefines(allDefines)}
|
|
|
13872
14135
|
/** Replaces per-vertex mesh vectors while preserving supplemental attributes. */
|
|
13873
14136
|
setGeometryVectors(vectors, bufferLayouts) {
|
|
13874
14137
|
bufferLayouts ??= this.getExplicitVectorLayouts(vectors) ?? this.getExplicitVectorLayouts(vectors, this.geometryVectorBindings.sourceLayouts);
|
|
13875
|
-
|
|
13876
|
-
if (
|
|
14138
|
+
this.validateVectorLengthPolicy();
|
|
14139
|
+
if (this.props.enforceMatchingVectorLengths) validateGPUVectorBatchStructure(vectors);
|
|
14140
|
+
if (this.props.enforceMatchingVectorLengths && (!this.isInstanced || this.attributeVectorBindings.vertexCount !== void 0))
|
|
13877
14141
|
validateGPUVectorBatchStructure([
|
|
13878
14142
|
...Object.values(vectors),
|
|
13879
14143
|
...Object.values(this.attributeVectorBindings.inputs)
|
|
13880
14144
|
]);
|
|
13881
|
-
this.geometryVectorBindings.setInputs(
|
|
14145
|
+
this.geometryVectorBindings.setInputs(
|
|
14146
|
+
vectors,
|
|
14147
|
+
bufferLayouts,
|
|
14148
|
+
"vertex",
|
|
14149
|
+
this.props.enforceMatchingVectorLengths
|
|
14150
|
+
);
|
|
13882
14151
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
13883
14152
|
this.syncVectorBindings();
|
|
13884
14153
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
13885
14154
|
(0, import_core14.assert)(
|
|
13886
14155
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
13887
14156
|
);
|
|
13888
|
-
|
|
14157
|
+
if (this.props.inferDrawCount === "vertex")
|
|
14158
|
+
this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
|
|
13889
14159
|
}
|
|
13890
14160
|
/** Replaces supplemental vectors; instanced models default these inputs to instance step mode. */
|
|
13891
14161
|
setAttributeVectors(vectors, bufferLayouts) {
|
|
@@ -13899,7 +14169,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
13899
14169
|
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
13900
14170
|
)?.stepMode ?? vector.bufferLayout?.stepMode) === "vertex"
|
|
13901
14171
|
);
|
|
13902
|
-
|
|
14172
|
+
this.validateVectorLengthPolicy();
|
|
14173
|
+
if (usesVertexRows && this.props.enforceMatchingVectorLengths)
|
|
13903
14174
|
validateGPUVectorBatchStructure([
|
|
13904
14175
|
...Object.values(this.geometryVectorBindings.inputs),
|
|
13905
14176
|
...Object.values(vectors)
|
|
@@ -13907,14 +14178,15 @@ ${getApplicationDefines(allDefines)}
|
|
|
13907
14178
|
this.attributeVectorBindings.setInputs(
|
|
13908
14179
|
vectors,
|
|
13909
14180
|
bufferLayouts,
|
|
13910
|
-
this.isInstanced ? "instance" : "vertex"
|
|
14181
|
+
this.isInstanced ? "instance" : "vertex",
|
|
14182
|
+
this.props.enforceMatchingVectorLengths
|
|
13911
14183
|
);
|
|
13912
14184
|
this.claimVectorLayouts(this.attributeVectorBindings);
|
|
13913
14185
|
this.syncVectorBindings();
|
|
13914
|
-
if (this.attributeVectorBindings.instanceCount !== void 0)
|
|
14186
|
+
if (this.props.inferDrawCount === "instance" && this.attributeVectorBindings.instanceCount !== void 0)
|
|
13915
14187
|
this.setInstanceCount(this.attributeVectorBindings.instanceCount);
|
|
13916
14188
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
13917
|
-
if (vertexCount !== void 0) {
|
|
14189
|
+
if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
|
|
13918
14190
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
13919
14191
|
(0, import_core14.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
13920
14192
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
@@ -14030,7 +14302,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
14030
14302
|
this.geometryVectorBindings,
|
|
14031
14303
|
this.attributeVectorBindings,
|
|
14032
14304
|
() => this.syncVectorBindings(),
|
|
14033
|
-
() => _GPUVectorModel.prototype.draw.call(this, renderPass)
|
|
14305
|
+
() => _GPUVectorModel.prototype.draw.call(this, renderPass),
|
|
14306
|
+
this.props.inferDrawCount
|
|
14034
14307
|
);
|
|
14035
14308
|
if (success) {
|
|
14036
14309
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
@@ -14131,7 +14404,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
14131
14404
|
}
|
|
14132
14405
|
);
|
|
14133
14406
|
}
|
|
14134
|
-
|
|
14407
|
+
validateVectorLengthPolicy() {
|
|
14408
|
+
(0, import_core14.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
|
|
14409
|
+
}
|
|
14410
|
+
setBatchDrawCount(rowCount, count = this.props.inferDrawCount === "no" ? "none" : this.props.inferDrawCount) {
|
|
14135
14411
|
if (count === "instance") {
|
|
14136
14412
|
this.setInstanceCount(rowCount);
|
|
14137
14413
|
} else if (count === "vertex") {
|
|
@@ -14159,13 +14435,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
14159
14435
|
const attributes = this.attributeVectorBindings;
|
|
14160
14436
|
const geometryLayouts = this.getExplicitVectorLayouts(geometry.inputs) ?? geometry.sourceLayouts;
|
|
14161
14437
|
const attributeLayouts = this.getExplicitVectorLayouts(attributes.inputs) ?? attributes.sourceLayouts;
|
|
14162
|
-
geometry.setInputs(
|
|
14438
|
+
geometry.setInputs(
|
|
14439
|
+
geometry.inputs,
|
|
14440
|
+
geometryLayouts,
|
|
14441
|
+
"vertex",
|
|
14442
|
+
this.props.enforceMatchingVectorLengths
|
|
14443
|
+
);
|
|
14163
14444
|
attributes.setInputs(
|
|
14164
14445
|
attributes.inputs,
|
|
14165
14446
|
attributeLayouts,
|
|
14166
|
-
this.isInstanced ? "instance" : "vertex"
|
|
14447
|
+
this.isInstanced ? "instance" : "vertex",
|
|
14448
|
+
this.props.enforceMatchingVectorLengths
|
|
14167
14449
|
);
|
|
14168
|
-
if (!this.isInstanced || attributes.vertexCount !== void 0)
|
|
14450
|
+
if (this.props.enforceMatchingVectorLengths && (!this.isInstanced || attributes.vertexCount !== void 0))
|
|
14169
14451
|
validateGPUVectorBatchStructure([
|
|
14170
14452
|
...Object.values(geometry.inputs),
|
|
14171
14453
|
...Object.values(attributes.inputs)
|
|
@@ -14807,6 +15089,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
14807
15089
|
topology;
|
|
14808
15090
|
vertexCount;
|
|
14809
15091
|
bufferLayout;
|
|
15092
|
+
/** Releases resources owned by uploaded geometry; borrowed vectors remain caller-owned. */
|
|
15093
|
+
destroy() {
|
|
15094
|
+
}
|
|
14810
15095
|
constructor(props) {
|
|
14811
15096
|
this.attributes = props.attributes;
|
|
14812
15097
|
this.indices = props.indices ?? null;
|
|
@@ -14818,6 +15103,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
14818
15103
|
|
|
14819
15104
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
14820
15105
|
var import_core16 = __toESM(require_core(), 1);
|
|
15106
|
+
function makeGPUVectorGeometry(device, geometry) {
|
|
15107
|
+
const gpuGeometry = makeGPUGeometry(device, geometry);
|
|
15108
|
+
try {
|
|
15109
|
+
const vectorGeometry = makeGPUVectorGeometryFromGPUGeometry(gpuGeometry);
|
|
15110
|
+
vectorGeometry.destroy = () => gpuGeometry.destroy();
|
|
15111
|
+
return vectorGeometry;
|
|
15112
|
+
} catch (error) {
|
|
15113
|
+
gpuGeometry.destroy();
|
|
15114
|
+
throw error;
|
|
15115
|
+
}
|
|
15116
|
+
}
|
|
14821
15117
|
function makeGPUVectorGeometryFromGPUGeometry(geometry) {
|
|
14822
15118
|
const attributes = {};
|
|
14823
15119
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|
|
@@ -15064,6 +15360,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
15064
15360
|
var Material = class {
|
|
15065
15361
|
/** Application-provided identifier. */
|
|
15066
15362
|
id;
|
|
15363
|
+
/** Structured metadata associated with this material. */
|
|
15364
|
+
metadata = {};
|
|
15067
15365
|
/** Device that owns the material resources. */
|
|
15068
15366
|
device;
|
|
15069
15367
|
/** Factory that defines the material schema. */
|
|
@@ -15120,6 +15418,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15120
15418
|
if (props.moduleProps) {
|
|
15121
15419
|
material.setProps(props.moduleProps);
|
|
15122
15420
|
}
|
|
15421
|
+
material.metadata = { ...this.metadata };
|
|
15123
15422
|
material.updateShaderInputs();
|
|
15124
15423
|
return material;
|
|
15125
15424
|
}
|
|
@@ -15939,11 +16238,11 @@ void main(void) {
|
|
|
15939
16238
|
destroyManagedInstanceBuffers(this._managedBuffers);
|
|
15940
16239
|
this._managedBuffers = {};
|
|
15941
16240
|
}
|
|
15942
|
-
draw(renderPass) {
|
|
16241
|
+
draw(renderPass, options) {
|
|
15943
16242
|
if (this.instanceCount === 0) {
|
|
15944
16243
|
return true;
|
|
15945
16244
|
}
|
|
15946
|
-
return super.draw(renderPass);
|
|
16245
|
+
return super.draw(renderPass, options);
|
|
15947
16246
|
}
|
|
15948
16247
|
setProps(props) {
|
|
15949
16248
|
this.lightModelProps = { ...this.lightModelProps, ...props };
|
|
@@ -16326,7 +16625,7 @@ void main(void) {
|
|
|
16326
16625
|
};
|
|
16327
16626
|
|
|
16328
16627
|
// src/scenegraph/scenegraph-node.ts
|
|
16329
|
-
function
|
|
16628
|
+
function assert11(condition, message) {
|
|
16330
16629
|
if (!condition) {
|
|
16331
16630
|
throw new Error(message);
|
|
16332
16631
|
}
|
|
@@ -16335,9 +16634,15 @@ void main(void) {
|
|
|
16335
16634
|
id;
|
|
16336
16635
|
matrix = new Matrix4();
|
|
16337
16636
|
display = true;
|
|
16637
|
+
/** Local selection eligibility, independent of visibility. */
|
|
16638
|
+
selectable = true;
|
|
16639
|
+
/** Local hover eligibility, independent of visibility. */
|
|
16640
|
+
hoverable = true;
|
|
16338
16641
|
position = new Vector3();
|
|
16339
16642
|
rotation = new Vector3();
|
|
16340
16643
|
scale = new Vector3(1, 1, 1);
|
|
16644
|
+
/** Structured metadata associated with this scene node. */
|
|
16645
|
+
metadata = {};
|
|
16341
16646
|
userData = {};
|
|
16342
16647
|
props = {};
|
|
16343
16648
|
constructor(props = {}) {
|
|
@@ -16362,17 +16667,17 @@ void main(void) {
|
|
|
16362
16667
|
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
16363
16668
|
}
|
|
16364
16669
|
setPosition(position) {
|
|
16365
|
-
|
|
16670
|
+
assert11(position.length === 3, "setPosition requires vector argument");
|
|
16366
16671
|
this.position = position;
|
|
16367
16672
|
return this;
|
|
16368
16673
|
}
|
|
16369
16674
|
setRotation(rotation) {
|
|
16370
|
-
|
|
16675
|
+
assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
16371
16676
|
this.rotation = rotation;
|
|
16372
16677
|
return this;
|
|
16373
16678
|
}
|
|
16374
16679
|
setScale(scale5) {
|
|
16375
|
-
|
|
16680
|
+
assert11(scale5.length === 3, "setScale requires vector argument");
|
|
16376
16681
|
this.scale = scale5;
|
|
16377
16682
|
return this;
|
|
16378
16683
|
}
|
|
@@ -16461,6 +16766,8 @@ void main(void) {
|
|
|
16461
16766
|
}
|
|
16462
16767
|
*/
|
|
16463
16768
|
_setScenegraphNodeProps(props) {
|
|
16769
|
+
if (props.selectable !== void 0) this.selectable = props.selectable;
|
|
16770
|
+
if (props.hoverable !== void 0) this.hoverable = props.hoverable;
|
|
16464
16771
|
if (props.display !== void 0) {
|
|
16465
16772
|
this.display = props.display;
|
|
16466
16773
|
}
|
|
@@ -16481,6 +16788,90 @@ void main(void) {
|
|
|
16481
16788
|
}
|
|
16482
16789
|
};
|
|
16483
16790
|
|
|
16791
|
+
// src/scenegraph/scenegraph-interaction.ts
|
|
16792
|
+
function isScenegraphInteractionEnabled(path, kind) {
|
|
16793
|
+
return path.length > 0 && path.every((node) => kind === "select" ? node.selectable : node.hoverable);
|
|
16794
|
+
}
|
|
16795
|
+
function getFirstScenegraphInteractionHit(hits, kind) {
|
|
16796
|
+
return hits.find((hit) => isScenegraphInteractionEnabled(hit.path, kind));
|
|
16797
|
+
}
|
|
16798
|
+
var ScenegraphInteractionManager = class {
|
|
16799
|
+
hoveredHits = /* @__PURE__ */ new Map();
|
|
16800
|
+
pendingHover = /* @__PURE__ */ new Map();
|
|
16801
|
+
onEvent;
|
|
16802
|
+
/** Creates a controller that reports bubbled selection and hover events. */
|
|
16803
|
+
constructor(onEvent) {
|
|
16804
|
+
this.onEvent = onEvent;
|
|
16805
|
+
}
|
|
16806
|
+
/** Selects the first eligible nearest-first hit and bubbles from target to root. */
|
|
16807
|
+
select(hits, controllerIndex = 0) {
|
|
16808
|
+
const hit = getFirstScenegraphInteractionHit(hits, "select");
|
|
16809
|
+
if (!hit) return void 0;
|
|
16810
|
+
this.emitPath("select", hit, 0, controllerIndex);
|
|
16811
|
+
return hit;
|
|
16812
|
+
}
|
|
16813
|
+
/** Updates hover from current hits; call after pointer, camera, object, or flag changes. */
|
|
16814
|
+
updateHover(hits, controllerIndex = 0) {
|
|
16815
|
+
const hit = getFirstScenegraphInteractionHit(hits, "hover");
|
|
16816
|
+
const queuedHit = hit ? { ...hit, path: [...hit.path] } : void 0;
|
|
16817
|
+
const activeQueue = this.pendingHover.get(controllerIndex);
|
|
16818
|
+
if (activeQueue) {
|
|
16819
|
+
activeQueue.push(queuedHit);
|
|
16820
|
+
return hit;
|
|
16821
|
+
}
|
|
16822
|
+
const queue = [queuedHit];
|
|
16823
|
+
this.pendingHover.set(controllerIndex, queue);
|
|
16824
|
+
try {
|
|
16825
|
+
while (queue.length) {
|
|
16826
|
+
const next = queue.shift();
|
|
16827
|
+
const previous = this.hoveredHits.get(controllerIndex);
|
|
16828
|
+
const previousPath = previous?.path || [];
|
|
16829
|
+
const nextPath = next?.path || [];
|
|
16830
|
+
let shared = 0;
|
|
16831
|
+
while (shared < previousPath.length && shared < nextPath.length && previousPath[shared] === nextPath[shared])
|
|
16832
|
+
shared++;
|
|
16833
|
+
if (next) this.hoveredHits.set(controllerIndex, next);
|
|
16834
|
+
else this.hoveredHits.delete(controllerIndex);
|
|
16835
|
+
if (previous) this.emitPath("hover-out", previous, shared, controllerIndex);
|
|
16836
|
+
if (next) this.emitPath("hover-in", next, shared, controllerIndex);
|
|
16837
|
+
}
|
|
16838
|
+
} finally {
|
|
16839
|
+
this.pendingHover.delete(controllerIndex);
|
|
16840
|
+
}
|
|
16841
|
+
return hit;
|
|
16842
|
+
}
|
|
16843
|
+
/** Emits exits for one controller and drops its tracked hover path. */
|
|
16844
|
+
clearHover(controllerIndex = 0) {
|
|
16845
|
+
this.updateHover([], controllerIndex);
|
|
16846
|
+
}
|
|
16847
|
+
/** Emits events from the target towards the first ancestor outside the shared subtree. */
|
|
16848
|
+
emitPath(type, hit, first, controllerIndex) {
|
|
16849
|
+
const { path } = hit;
|
|
16850
|
+
const target = path[path.length - 1];
|
|
16851
|
+
for (let index = path.length - 1; index >= first; index--) {
|
|
16852
|
+
this.onEvent({ type, target, currentTarget: path[index], controllerIndex, hit });
|
|
16853
|
+
}
|
|
16854
|
+
}
|
|
16855
|
+
};
|
|
16856
|
+
|
|
16857
|
+
// src/scenegraph/scene-metadata.ts
|
|
16858
|
+
var SceneMetadata = class {
|
|
16859
|
+
entries = /* @__PURE__ */ new Map();
|
|
16860
|
+
/** Associates metadata with a resource category and its source index. */
|
|
16861
|
+
set(category, index, metadata) {
|
|
16862
|
+
let categoryEntries = this.entries.get(category);
|
|
16863
|
+
if (!categoryEntries) {
|
|
16864
|
+
categoryEntries = /* @__PURE__ */ new Map();
|
|
16865
|
+
this.entries.set(category, categoryEntries);
|
|
16866
|
+
}
|
|
16867
|
+
categoryEntries.set(index, metadata);
|
|
16868
|
+
}
|
|
16869
|
+
/** Returns metadata for a resource, or undefined when none was supplied. */
|
|
16870
|
+
get(category, index = 0) {
|
|
16871
|
+
return this.entries.get(category)?.get(index);
|
|
16872
|
+
}
|
|
16873
|
+
};
|
|
16874
|
+
|
|
16484
16875
|
// src/scenegraph/group-node.ts
|
|
16485
16876
|
var import_core23 = __toESM(require_core(), 1);
|
|
16486
16877
|
|
|
@@ -17517,7 +17908,7 @@ void main(void) {
|
|
|
17517
17908
|
this._observeSource();
|
|
17518
17909
|
return this._updateTimestamp;
|
|
17519
17910
|
}
|
|
17520
|
-
/**
|
|
17911
|
+
/** DeviceResource label used by debug output. */
|
|
17521
17912
|
get [Symbol.toStringTag]() {
|
|
17522
17913
|
return "VideoTexture";
|
|
17523
17914
|
}
|
|
@@ -17921,7 +18312,7 @@ void main(void) {
|
|
|
17921
18312
|
Object.assign(this.userData, props.userData);
|
|
17922
18313
|
const platformInfo = getPlatformInfo(device);
|
|
17923
18314
|
const resolvedPlugins = (0, import_shaders6.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
|
|
17924
|
-
if (resolvedPlugins.
|
|
18315
|
+
if (resolvedPlugins.injectionTargets.length > 0) {
|
|
17925
18316
|
throw new Error("Computation does not support ShaderPlugin render hooks");
|
|
17926
18317
|
}
|
|
17927
18318
|
if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.interStageVariables).length > 0) {
|
|
@@ -20310,8 +20701,99 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20310
20701
|
]);
|
|
20311
20702
|
}
|
|
20312
20703
|
|
|
20704
|
+
// src/scenegraph/controllers/punctual-light-controller.ts
|
|
20705
|
+
var import_shaders8 = __toESM(require_shaders(), 1);
|
|
20706
|
+
var PunctualLightController = class {
|
|
20707
|
+
constructor(bindings, useByteColors = true) {
|
|
20708
|
+
this.bindings = bindings;
|
|
20709
|
+
this.useByteColors = useByteColors;
|
|
20710
|
+
this.update();
|
|
20711
|
+
}
|
|
20712
|
+
bindings;
|
|
20713
|
+
useByteColors;
|
|
20714
|
+
lights = [];
|
|
20715
|
+
/** Refreshes the stable light array after node or light properties change. */
|
|
20716
|
+
update() {
|
|
20717
|
+
this.lights.length = 0;
|
|
20718
|
+
for (const { path, definition } of this.bindings) {
|
|
20719
|
+
if (!path.length || path.some((node) => !node.display)) continue;
|
|
20720
|
+
const worldMatrix = new Matrix4();
|
|
20721
|
+
for (const node of path) worldMatrix.multiplyRight(node.matrix);
|
|
20722
|
+
const light = makePunctualLight(definition, worldMatrix, this.useByteColors);
|
|
20723
|
+
if (light) this.lights.push(light);
|
|
20724
|
+
}
|
|
20725
|
+
}
|
|
20726
|
+
};
|
|
20727
|
+
function makePunctualLight(definition, worldMatrix, useByteColors) {
|
|
20728
|
+
const color = normalizePunctualLightColor(definition.color || [1, 1, 1], useByteColors);
|
|
20729
|
+
const intensity = definition.intensity ?? 1;
|
|
20730
|
+
switch (definition.type) {
|
|
20731
|
+
case "directional":
|
|
20732
|
+
return makeDirectionalLight(worldMatrix, color, intensity);
|
|
20733
|
+
case "point":
|
|
20734
|
+
return makePointLight(worldMatrix, color, intensity, definition.range);
|
|
20735
|
+
case "spot":
|
|
20736
|
+
return makeSpotLight(worldMatrix, color, intensity, definition.range, definition.spot);
|
|
20737
|
+
default:
|
|
20738
|
+
return void 0;
|
|
20739
|
+
}
|
|
20740
|
+
}
|
|
20741
|
+
function normalizePunctualLightColor(color, useByteColors) {
|
|
20742
|
+
if (useByteColors) {
|
|
20743
|
+
return color.map((component) => component * 255);
|
|
20744
|
+
}
|
|
20745
|
+
return (0, import_shaders8.normalizeByteColor3)(color, false);
|
|
20746
|
+
}
|
|
20747
|
+
function makePointLight(worldMatrix, color, intensity, range) {
|
|
20748
|
+
const position = getLightPosition(worldMatrix);
|
|
20749
|
+
let attenuation = [1, 0, 0];
|
|
20750
|
+
if (range !== void 0 && range > 0) {
|
|
20751
|
+
attenuation = [1, 0, 1 / (range * range)];
|
|
20752
|
+
}
|
|
20753
|
+
return {
|
|
20754
|
+
type: "point",
|
|
20755
|
+
position,
|
|
20756
|
+
color,
|
|
20757
|
+
intensity,
|
|
20758
|
+
attenuation
|
|
20759
|
+
};
|
|
20760
|
+
}
|
|
20761
|
+
function makeDirectionalLight(worldMatrix, color, intensity) {
|
|
20762
|
+
const direction = getLightDirection(worldMatrix);
|
|
20763
|
+
return {
|
|
20764
|
+
type: "directional",
|
|
20765
|
+
direction,
|
|
20766
|
+
color,
|
|
20767
|
+
intensity
|
|
20768
|
+
};
|
|
20769
|
+
}
|
|
20770
|
+
function makeSpotLight(worldMatrix, color, intensity, range, spot = {}) {
|
|
20771
|
+
const position = getLightPosition(worldMatrix);
|
|
20772
|
+
const direction = getLightDirection(worldMatrix);
|
|
20773
|
+
let attenuation = [1, 0, 0];
|
|
20774
|
+
if (range !== void 0 && range > 0) {
|
|
20775
|
+
attenuation = [1, 0, 1 / (range * range)];
|
|
20776
|
+
}
|
|
20777
|
+
return {
|
|
20778
|
+
type: "spot",
|
|
20779
|
+
position,
|
|
20780
|
+
direction,
|
|
20781
|
+
color,
|
|
20782
|
+
intensity,
|
|
20783
|
+
attenuation,
|
|
20784
|
+
innerConeAngle: spot.innerConeAngle ?? 0,
|
|
20785
|
+
outerConeAngle: spot.outerConeAngle ?? Math.PI / 4
|
|
20786
|
+
};
|
|
20787
|
+
}
|
|
20788
|
+
function getLightPosition(worldMatrix) {
|
|
20789
|
+
return worldMatrix.transformAsPoint([0, 0, 0]);
|
|
20790
|
+
}
|
|
20791
|
+
function getLightDirection(worldMatrix) {
|
|
20792
|
+
return worldMatrix.transformAsVector([0, 0, -1]);
|
|
20793
|
+
}
|
|
20794
|
+
|
|
20313
20795
|
// src/scenegraph/controllers/area-light-controller.ts
|
|
20314
|
-
var
|
|
20796
|
+
var import_core37 = __toESM(require_core(), 1);
|
|
20315
20797
|
var AreaLightController = class {
|
|
20316
20798
|
scenes;
|
|
20317
20799
|
matrixAuthoredNodes = /* @__PURE__ */ new Set();
|
|
@@ -20321,11 +20803,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20321
20803
|
for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
|
|
20322
20804
|
for (const { node, definition, matrixAuthored } of bindings) {
|
|
20323
20805
|
if (matrixAuthored) this.matrixAuthoredNodes.add(node);
|
|
20324
|
-
(0,
|
|
20325
|
-
(0,
|
|
20326
|
-
(0,
|
|
20327
|
-
(0,
|
|
20328
|
-
(0,
|
|
20806
|
+
(0, import_core37.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
|
|
20807
|
+
(0, import_core37.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
|
|
20808
|
+
(0, import_core37.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
|
|
20809
|
+
(0, import_core37.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
|
|
20810
|
+
(0, import_core37.assert)(
|
|
20329
20811
|
(definition.color || [1, 1, 1]).every(
|
|
20330
20812
|
(component) => Number.isFinite(component) && component >= 0
|
|
20331
20813
|
)
|
|
@@ -20391,17 +20873,17 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20391
20873
|
function getMatrixRotation(matrix) {
|
|
20392
20874
|
const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
|
|
20393
20875
|
const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
|
|
20394
|
-
(0,
|
|
20876
|
+
(0, import_core37.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
|
|
20395
20877
|
horizontal.normalize();
|
|
20396
20878
|
vertical.normalize();
|
|
20397
20879
|
vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
|
|
20398
|
-
(0,
|
|
20880
|
+
(0, import_core37.assert)(vertical.magnitude() > 1e-8);
|
|
20399
20881
|
vertical.normalize();
|
|
20400
20882
|
const forward = new Vector3(horizontal).cross(vertical).normalize();
|
|
20401
20883
|
const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
|
|
20402
|
-
(0,
|
|
20884
|
+
(0, import_core37.assert)(authoredForward.magnitude() > 0);
|
|
20403
20885
|
authoredForward.normalize();
|
|
20404
|
-
(0,
|
|
20886
|
+
(0, import_core37.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
|
|
20405
20887
|
if (forward.dot(authoredForward) < 0) forward.negate();
|
|
20406
20888
|
return new Matrix4([
|
|
20407
20889
|
horizontal[0],
|
|
@@ -20959,15 +21441,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20959
21441
|
};
|
|
20960
21442
|
|
|
20961
21443
|
// src/audio/audio-graph.ts
|
|
20962
|
-
var
|
|
21444
|
+
var import_core39 = __toESM(require_core(), 1);
|
|
20963
21445
|
var AudioGraph = class {
|
|
20964
21446
|
constructor(definition, context, destination, getEmitterInputs) {
|
|
20965
21447
|
this.definition = definition;
|
|
20966
21448
|
for (const node of definition.nodes)
|
|
20967
|
-
(0,
|
|
21449
|
+
(0, import_core39.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
|
|
20968
21450
|
const validateEndpoint = (index, port = 0) => {
|
|
20969
|
-
(0,
|
|
20970
|
-
(0,
|
|
21451
|
+
(0, import_core39.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
|
|
21452
|
+
(0, import_core39.assert)(Number.isInteger(port) && port >= 0);
|
|
20971
21453
|
};
|
|
20972
21454
|
for (const edge of definition.connections) {
|
|
20973
21455
|
validateEndpoint(edge.from.node, edge.from.output);
|
|
@@ -20975,16 +21457,16 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20975
21457
|
}
|
|
20976
21458
|
for (const input of definition.inputs || []) {
|
|
20977
21459
|
validateEndpoint(input.node, input.input);
|
|
20978
|
-
(0,
|
|
21460
|
+
(0, import_core39.assert)(Number.isInteger(input.source) && input.source >= 0);
|
|
20979
21461
|
}
|
|
20980
21462
|
for (const output of definition.outputs || []) {
|
|
20981
21463
|
validateEndpoint(output.node, output.output);
|
|
20982
|
-
(0,
|
|
21464
|
+
(0, import_core39.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
|
|
20983
21465
|
}
|
|
20984
21466
|
const visiting = /* @__PURE__ */ new Set();
|
|
20985
21467
|
const visited = /* @__PURE__ */ new Set();
|
|
20986
21468
|
const visit = (index) => {
|
|
20987
|
-
(0,
|
|
21469
|
+
(0, import_core39.assert)(definition.nodes[index] && !visiting.has(index));
|
|
20988
21470
|
if (visited.has(index)) return;
|
|
20989
21471
|
visiting.add(index);
|
|
20990
21472
|
for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
|
|
@@ -21045,7 +21527,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21045
21527
|
/** Apply a scene-driven gain change using the authored transition shape. */
|
|
21046
21528
|
setGain(index, gain, time = this.nodes[index].context.currentTime) {
|
|
21047
21529
|
const definition = this.definition.nodes[index];
|
|
21048
|
-
(0,
|
|
21530
|
+
(0, import_core39.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
|
|
21049
21531
|
const parameter = this.nodes[index].gain;
|
|
21050
21532
|
const duration = definition.params.duration ?? 0;
|
|
21051
21533
|
const initialGain = parameter.value;
|
|
@@ -21055,7 +21537,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21055
21537
|
parameter.setValueAtTime(gain, time);
|
|
21056
21538
|
} else if (definition.params.interpolation === "custom") {
|
|
21057
21539
|
const curve = definition.params.curve;
|
|
21058
|
-
(0,
|
|
21540
|
+
(0, import_core39.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
|
|
21059
21541
|
parameter.setValueCurveAtTime(
|
|
21060
21542
|
Float32Array.from(curve, (value) => value * gain),
|
|
21061
21543
|
time,
|
|
@@ -21140,7 +21622,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21140
21622
|
}
|
|
21141
21623
|
|
|
21142
21624
|
// src/audio/audio-environment.ts
|
|
21143
|
-
var
|
|
21625
|
+
var import_core41 = __toESM(require_core(), 1);
|
|
21144
21626
|
function selectAudioEnvironmentZone(zones, position) {
|
|
21145
21627
|
let selected;
|
|
21146
21628
|
for (const zone of zones) {
|
|
@@ -21233,7 +21715,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21233
21715
|
}
|
|
21234
21716
|
};
|
|
21235
21717
|
function createParametricAudioResponse(context, parameters) {
|
|
21236
|
-
(0,
|
|
21718
|
+
(0, import_core41.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
|
|
21237
21719
|
const presets = {
|
|
21238
21720
|
generic: [1.49, 0.83, 7e-3, 0.011],
|
|
21239
21721
|
smallRoom: [0.4, 0.83, 2e-3, 3e-3],
|
|
@@ -21250,12 +21732,12 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21250
21732
|
underwater: [1.49, 0.1, 7e-3, 0.011]
|
|
21251
21733
|
};
|
|
21252
21734
|
const preset = parameters.preset ? presets[parameters.preset] : void 0;
|
|
21253
|
-
(0,
|
|
21735
|
+
(0, import_core41.assert)(!parameters.preset || preset);
|
|
21254
21736
|
const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
|
|
21255
21737
|
const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
|
|
21256
21738
|
const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
|
|
21257
21739
|
const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
|
|
21258
|
-
(0,
|
|
21740
|
+
(0, import_core41.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
|
|
21259
21741
|
const response = context.createBuffer(
|
|
21260
21742
|
2,
|
|
21261
21743
|
Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
|
|
@@ -21279,7 +21761,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21279
21761
|
}
|
|
21280
21762
|
|
|
21281
21763
|
// src/audio/audio-controller.ts
|
|
21282
|
-
var
|
|
21764
|
+
var import_core42 = __toESM(require_core(), 1);
|
|
21283
21765
|
var AudioController = class {
|
|
21284
21766
|
gain;
|
|
21285
21767
|
definition;
|
|
@@ -21389,25 +21871,25 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21389
21871
|
/** Change a graph gain using its authored interpolation and duration. */
|
|
21390
21872
|
setGraphGain(graphIndex, nodeIndex, gain) {
|
|
21391
21873
|
const graph = this.graphs.get(graphIndex);
|
|
21392
|
-
(0,
|
|
21874
|
+
(0, import_core42.assert)(!this.destroyed && graph);
|
|
21393
21875
|
graph.setGain(nodeIndex, gain);
|
|
21394
21876
|
}
|
|
21395
21877
|
startSource(sourceIndex, startTime, autoplayOnly, connect) {
|
|
21396
21878
|
const definition = this.definition.sources[sourceIndex];
|
|
21397
|
-
(0,
|
|
21879
|
+
(0, import_core42.assert)(definition);
|
|
21398
21880
|
if (autoplayOnly && !definition.autoPlay) return;
|
|
21399
21881
|
const context = this.options.audioContext;
|
|
21400
21882
|
const extended = definition.graph;
|
|
21401
21883
|
const oscillator = extended?.oscillator;
|
|
21402
|
-
(0,
|
|
21884
|
+
(0, import_core42.assert)(!(definition.audio !== void 0 && oscillator));
|
|
21403
21885
|
let source4;
|
|
21404
21886
|
if (oscillator) {
|
|
21405
21887
|
const node = context.createOscillator();
|
|
21406
21888
|
node.frequency.value = oscillator.frequency ?? 440;
|
|
21407
21889
|
node.detune.value = oscillator.detune ?? 0;
|
|
21408
|
-
(0,
|
|
21890
|
+
(0, import_core42.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
|
|
21409
21891
|
if (oscillator.type === "custom") {
|
|
21410
|
-
(0,
|
|
21892
|
+
(0, import_core42.assert)(oscillator.periodicWave);
|
|
21411
21893
|
node.setPeriodicWave(
|
|
21412
21894
|
context.createPeriodicWave(
|
|
21413
21895
|
new Float32Array(oscillator.periodicWave.real),
|
|
@@ -21418,7 +21900,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21418
21900
|
source4 = node;
|
|
21419
21901
|
} else {
|
|
21420
21902
|
const node = context.createBufferSource();
|
|
21421
|
-
(0,
|
|
21903
|
+
(0, import_core42.assert)(definition.audio !== void 0);
|
|
21422
21904
|
node.buffer = this.buffers.get(definition.audio);
|
|
21423
21905
|
node.loop = definition.loop ?? false;
|
|
21424
21906
|
node.loopStart = extended?.loopStart ?? 0;
|
|
@@ -21563,15 +22045,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21563
22045
|
}
|
|
21564
22046
|
addEmitter(index, node) {
|
|
21565
22047
|
const definition = this.definition.emitters[index];
|
|
21566
|
-
(0,
|
|
22048
|
+
(0, import_core42.assert)(
|
|
21567
22049
|
definition && (definition.type === "global" || definition.type === "positional" && node)
|
|
21568
22050
|
);
|
|
21569
|
-
(0,
|
|
22051
|
+
(0, import_core42.assert)(
|
|
21570
22052
|
!definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
|
|
21571
22053
|
);
|
|
21572
22054
|
for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
|
|
21573
22055
|
const source4 = this.definition.sources[sourceIndex];
|
|
21574
|
-
(0,
|
|
22056
|
+
(0, import_core42.assert)(
|
|
21575
22057
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21576
22058
|
);
|
|
21577
22059
|
}
|
|
@@ -21616,7 +22098,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21616
22098
|
const audioIndices = new Set(
|
|
21617
22099
|
[...sourceIndices].map((index) => {
|
|
21618
22100
|
const source4 = this.definition.sources[index];
|
|
21619
|
-
(0,
|
|
22101
|
+
(0, import_core42.assert)(
|
|
21620
22102
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21621
22103
|
);
|
|
21622
22104
|
return source4.audio;
|
|
@@ -21653,7 +22135,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21653
22135
|
const reverb = environment.reverb;
|
|
21654
22136
|
if (!reverb) return;
|
|
21655
22137
|
const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
|
|
21656
|
-
(0,
|
|
22138
|
+
(0, import_core42.assert)(response);
|
|
21657
22139
|
const bus = new AudioReverbBus(audioContext, response, this.gain, {
|
|
21658
22140
|
...reverb,
|
|
21659
22141
|
normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
|
|
@@ -21758,11 +22240,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21758
22240
|
};
|
|
21759
22241
|
|
|
21760
22242
|
// src/modules/picking/legacy-color-picking.ts
|
|
21761
|
-
var
|
|
21762
|
-
var legacyColorPicking =
|
|
22243
|
+
var import_shaders9 = __toESM(require_shaders(), 1);
|
|
22244
|
+
var legacyColorPicking = import_shaders9.picking;
|
|
21763
22245
|
|
|
21764
22246
|
// src/geometry/ring-geometry.ts
|
|
21765
|
-
var
|
|
22247
|
+
var import_core44 = __toESM(require_core(), 1);
|
|
21766
22248
|
var RingGeometry = class extends Geometry2 {
|
|
21767
22249
|
constructor(props = {}) {
|
|
21768
22250
|
const {
|
|
@@ -21773,7 +22255,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21773
22255
|
startAngle = 0,
|
|
21774
22256
|
angle: angle2 = Math.PI * 2
|
|
21775
22257
|
} = props;
|
|
21776
|
-
(0,
|
|
22258
|
+
(0, import_core44.assert)(
|
|
21777
22259
|
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
|
|
21778
22260
|
);
|
|
21779
22261
|
const halfHeight = height / 2;
|
|
@@ -21957,7 +22439,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21957
22439
|
};
|
|
21958
22440
|
|
|
21959
22441
|
// src/scenegraph/controllers/morph-controller.ts
|
|
21960
|
-
var
|
|
22442
|
+
var import_core47 = __toESM(require_core(), 1);
|
|
21961
22443
|
function setMorphWeights(node, weights) {
|
|
21962
22444
|
node.userData["morphWeights"] = [...weights];
|
|
21963
22445
|
const meshes = node.userData["morphMeshes"] || [];
|
|
@@ -21984,7 +22466,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21984
22466
|
function updateMorphWeights(state, weights) {
|
|
21985
22467
|
state.values.fill(0);
|
|
21986
22468
|
state.values.set(weights.slice(0, state.values.length));
|
|
21987
|
-
if (state.data instanceof
|
|
22469
|
+
if (state.data instanceof import_core47.Buffer) {
|
|
21988
22470
|
state.data.write(state.values);
|
|
21989
22471
|
} else {
|
|
21990
22472
|
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|
|
@@ -22007,6 +22489,10 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22007
22489
|
return Array.from(node.userData["morphWeights"] ?? []);
|
|
22008
22490
|
case "visibility":
|
|
22009
22491
|
return [node.display ? 1 : 0];
|
|
22492
|
+
case "selectable":
|
|
22493
|
+
return [node.selectable ? 1 : 0];
|
|
22494
|
+
case "hoverable":
|
|
22495
|
+
return [node.hoverable ? 1 : 0];
|
|
22010
22496
|
}
|
|
22011
22497
|
},
|
|
22012
22498
|
setValue: (value) => {
|
|
@@ -22023,6 +22509,12 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22023
22509
|
case "weights":
|
|
22024
22510
|
setMorphWeights(node, value);
|
|
22025
22511
|
break;
|
|
22512
|
+
case "selectable":
|
|
22513
|
+
node.setProps({ selectable: value[0] !== 0 });
|
|
22514
|
+
break;
|
|
22515
|
+
case "hoverable":
|
|
22516
|
+
node.setProps({ hoverable: value[0] !== 0 });
|
|
22517
|
+
break;
|
|
22026
22518
|
case "visibility":
|
|
22027
22519
|
node.setProps({ display: value[0] !== 0 });
|
|
22028
22520
|
options.onVisibilityChange?.();
|
|
@@ -22340,7 +22832,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22340
22832
|
}
|
|
22341
22833
|
|
|
22342
22834
|
// src/lighting/ltc-textures.ts
|
|
22343
|
-
var
|
|
22835
|
+
var import_shaders10 = __toESM(require_shaders(), 1);
|
|
22344
22836
|
|
|
22345
22837
|
// src/lighting/ltc-data.ts
|
|
22346
22838
|
var LTC_MATRIX_DATA = [
|
|
@@ -55123,7 +55615,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
55123
55615
|
width: 64,
|
|
55124
55616
|
height: 64,
|
|
55125
55617
|
format: "rgba16float",
|
|
55126
|
-
data: Uint16Array.from(data,
|
|
55618
|
+
data: Uint16Array.from(data, import_shaders10.toHalfFloat),
|
|
55127
55619
|
mipLevels: 1,
|
|
55128
55620
|
sampler: { minFilter: "nearest", magFilter: "nearest" }
|
|
55129
55621
|
});
|