@luma.gl/engine 10.0.0-alpha.9 → 10.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -4
- package/THIRD-PARTY-NOTICES.md +185 -0
- package/dist/animation/deform-positions.d.ts +1 -1
- package/dist/animation/deform-positions.d.ts.map +1 -1
- 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/animation/skin.cjs +4 -4
- package/dist/animation/skin.d.ts +1 -1
- package/dist/animation/skin.d.ts.map +1 -1
- package/dist/animation/skin.js +1 -1
- package/dist/animation/skin.js.map +1 -1
- package/dist/animation/texture-transform.cjs +7 -7
- package/dist/animation/texture-transform.js +1 -1
- package/dist/animation/texture-transform.js.map +1 -1
- package/dist/arrow/arrow-mesh-types.d.ts +1 -1
- package/dist/arrow/arrow-mesh-types.d.ts.map +1 -1
- package/dist/arrow/index.cjs.map +2 -2
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.cjs +2 -2
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.d.ts +1 -1
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.js +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +14 -15
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts.map +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js +23 -18
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.cjs +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js.map +1 -1
- package/dist/audio/audio-controller.cjs +6 -6
- package/dist/audio/audio-controller.d.ts +1 -1
- package/dist/audio/audio-controller.d.ts.map +1 -1
- package/dist/audio/audio-controller.js +1 -1
- package/dist/audio/audio-controller.js.map +1 -1
- package/dist/audio/audio-environment.cjs +6 -6
- package/dist/audio/audio-environment.d.ts +1 -1
- package/dist/audio/audio-environment.d.ts.map +1 -1
- package/dist/audio/audio-environment.js +1 -1
- package/dist/audio/audio-environment.js.map +1 -1
- package/dist/compute/computation.cjs +1 -1
- package/dist/compute/computation.d.ts +1 -1
- package/dist/compute/computation.d.ts.map +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/debug/pixel-data-utils.d.ts +1 -1
- package/dist/debug/pixel-data-utils.d.ts.map +1 -1
- package/dist/dist.dev.js +1087 -570
- package/dist/dist.min.js +74 -67
- 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/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts +1 -1
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.cjs +4 -4
- package/dist/effects/passes/screen-space/gtao.d.ts +1 -1
- package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.js +1 -1
- package/dist/effects/passes/screen-space/gtao.js.map +1 -1
- package/dist/effects/passes/screen-space/height-fog.d.ts +1 -1
- package/dist/effects/passes/screen-space/height-fog.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/ssr-camera-temporal.d.ts +1 -1
- package/dist/effects/passes/screen-space/ssr-camera-temporal.d.ts.map +1 -1
- package/dist/experimental/controls/index.cjs +0 -3
- package/dist/experimental/controls/index.cjs.map +2 -2
- package/dist/experimental/controls/index.d.ts +0 -2
- package/dist/experimental/controls/index.d.ts.map +1 -1
- package/dist/experimental/controls/index.js +0 -1
- package/dist/experimental/controls/index.js.map +1 -1
- package/dist/experimental/webxr/webxr-input.d.ts +1 -1
- package/dist/experimental/webxr/webxr-input.d.ts.map +1 -1
- package/dist/experimental-controls.cjs +21 -0
- package/dist/experimental-controls.d.ts +2 -0
- package/dist/experimental-controls.d.ts.map +1 -0
- package/dist/experimental-controls.js +5 -0
- package/dist/experimental-controls.js.map +1 -0
- package/dist/experimental-materials.cjs +21 -0
- package/dist/experimental-materials.d.ts +2 -0
- package/dist/experimental-materials.d.ts.map +1 -0
- package/dist/experimental-materials.js +5 -0
- package/dist/experimental-materials.js.map +1 -0
- package/dist/experimental-textures.cjs +21 -0
- package/dist/experimental-textures.d.ts +2 -0
- package/dist/experimental-textures.d.ts.map +1 -0
- package/dist/experimental-textures.js +5 -0
- package/dist/experimental-textures.js.map +1 -0
- package/dist/{experimental/controls/orbit-controls.cjs → experimental-webxr.cjs} +5 -11
- package/dist/experimental-webxr.d.ts +2 -0
- package/dist/experimental-webxr.d.ts.map +1 -0
- package/dist/experimental-webxr.js +5 -0
- package/dist/experimental-webxr.js.map +1 -0
- package/dist/geometry/edge-geometry.d.ts +1 -1
- package/dist/geometry/edge-geometry.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.cjs +18 -17
- package/dist/geometry/geometry-primitives.d.ts +2 -2
- package/dist/geometry/geometry-primitives.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.js +3 -2
- package/dist/geometry/geometry-primitives.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +1 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.cjs +6 -6
- package/dist/geometry/geometry-utils.d.ts +2 -2
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +1 -1
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.cjs +2 -2
- package/dist/geometry/geometry.d.ts +4 -3
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -1
- package/dist/geometry/ring-geometry.cjs +6 -6
- package/dist/geometry/ring-geometry.d.ts +1 -1
- package/dist/geometry/ring-geometry.d.ts.map +1 -1
- package/dist/geometry/ring-geometry.js +2 -2
- package/dist/geometry/ring-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 +1 -1
- 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-animated-crowd.d.ts +2 -1
- package/dist/gltf/gltf/gltf-animated-crowd.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-animated-crowd.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/gltf/gltf-instancing.cjs +2 -2
- package/dist/gltf/gltf/gltf-instancing.d.ts +1 -1
- package/dist/gltf/gltf/gltf-instancing.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-instancing.js +1 -1
- package/dist/gltf/gltf/gltf-instancing.js.map +1 -1
- package/dist/gltf/gltf/gltf-lightmap.cjs +2 -2
- package/dist/gltf/gltf/gltf-lightmap.d.ts +1 -1
- package/dist/gltf/gltf/gltf-lightmap.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-lightmap.js +1 -1
- package/dist/gltf/gltf/gltf-lightmap.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 +1 -1
- 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 +41 -77
- 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 +35 -92
- 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 +4 -1
- package/dist/gltf/parsers/parse-gltf.d.ts +10 -2
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +3 -0
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/parsers/parse-pbr-material.cjs +40 -30
- 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 +18 -6
- package/dist/gltf/parsers/parse-pbr-material.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/physics/export-state.cjs +8 -8
- package/dist/gltf/physics/export-state.js +1 -1
- package/dist/gltf/physics/export-state.js.map +1 -1
- package/dist/gltf/physics/index.cjs.map +2 -2
- package/dist/gltf/physics/mesh-snapshot.cjs +3 -3
- package/dist/gltf/physics/mesh-snapshot.js +1 -1
- package/dist/gltf/physics/mesh-snapshot.js.map +1 -1
- package/dist/gltf/physics/node-collision-geometry.cjs +3 -3
- package/dist/gltf/physics/node-collision-geometry.js +1 -1
- package/dist/gltf/physics/node-collision-geometry.js.map +1 -1
- package/dist/gltf/physics/parse-gltf-physics.cjs +10 -10
- package/dist/gltf/physics/parse-gltf-physics.js +1 -1
- package/dist/gltf/physics/parse-gltf-physics.js.map +1 -1
- package/dist/gltf/physics/parse-physics-joints.cjs +3 -3
- package/dist/gltf/physics/parse-physics-joints.d.ts +1 -1
- package/dist/gltf/physics/parse-physics-joints.d.ts.map +1 -1
- package/dist/gltf/physics/parse-physics-joints.js +1 -1
- package/dist/gltf/physics/parse-physics-joints.js.map +1 -1
- package/dist/gltf/physics/property-bindings.cjs +4 -4
- package/dist/gltf/physics/property-bindings.js +1 -1
- package/dist/gltf/physics/property-bindings.js.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.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/graph/models/index.cjs.map +2 -2
- 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 +12 -9
- package/dist/graph/models/path/path-storage-model.d.ts +4 -2
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-storage-model.js +8 -3
- package/dist/graph/models/path/path-storage-model.js.map +1 -1
- package/dist/graph/models/polygon/polygon-attribute-model.cjs +4 -4
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts +1 -1
- package/dist/graph/models/polygon/polygon-attribute-model.js +1 -1
- package/dist/graph/models/polygon/polygon-shaders.d.ts +1 -1
- package/dist/graph/models/polygon/polygon-storage-model.cjs +4 -4
- package/dist/graph/models/polygon/polygon-storage-model.d.ts +1 -1
- package/dist/graph/models/polygon/polygon-storage-model.js +1 -1
- package/dist/graph/physics/index.cjs.map +2 -2
- package/dist/graph/physics/index.d.ts +1 -1
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.cjs +8 -8
- package/dist/graph/physics/physics-controller-geometry.js +2 -2
- package/dist/graph/physics/physics-controller-geometry.js.map +1 -1
- package/dist/graph/physics/physics-controller.cjs +106 -0
- package/dist/graph/physics/physics-controller.d.ts +41 -3
- package/dist/graph/physics/physics-controller.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller.js +106 -0
- package/dist/graph/physics/physics-controller.js.map +1 -1
- package/dist/graph/physics/physics-scenegraph.cjs +4 -4
- package/dist/graph/physics/physics-scenegraph.d.ts +1 -1
- package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -1
- package/dist/graph/physics/physics-scenegraph.js +1 -1
- package/dist/graph/physics/physics-scenegraph.js.map +1 -1
- package/dist/graph/physics/scenegraph-instance.cjs +16 -2
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +17 -1
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/physics/scenegraph-motion.cjs +7 -7
- package/dist/graph/physics/scenegraph-motion.d.ts +1 -1
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-motion.js +1 -1
- package/dist/graph/physics/scenegraph-motion.js.map +1 -1
- package/dist/graph/physics/scenegraph-properties.cjs +3 -3
- package/dist/graph/physics/scenegraph-properties.js +1 -1
- package/dist/graph/physics/scenegraph-properties.js.map +1 -1
- package/dist/graph/physics/scenegraph-publication.cjs +5 -5
- package/dist/graph/physics/scenegraph-publication.d.ts +1 -1
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-publication.js +1 -1
- package/dist/graph/physics/scenegraph-publication.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 +2 -2
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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 +32 -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 +24 -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 +78 -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-model.cjs +20 -3
- package/dist/model/gpu-vector-model.d.ts +20 -2
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +21 -3
- 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 +4 -4
- package/dist/models/light-model-utils.d.ts +3 -2
- package/dist/models/light-model-utils.d.ts.map +1 -1
- package/dist/models/light-model-utils.js +3 -3
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/modules/picking/color-picking.d.ts +1 -1
- package/dist/modules/picking/index-color-picking.d.ts +1 -1
- package/dist/modules/picking/index-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking.d.ts +1 -1
- package/dist/scenegraph/controllers/area-light-controller.cjs +11 -11
- package/dist/scenegraph/controllers/area-light-controller.js +1 -1
- package/dist/scenegraph/controllers/area-light-controller.js.map +1 -1
- package/dist/scenegraph/controllers/billboard-controller.cjs +28 -28
- package/dist/scenegraph/controllers/billboard-controller.d.ts +2 -1
- package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -1
- package/dist/scenegraph/controllers/billboard-controller.js +1 -1
- package/dist/scenegraph/controllers/billboard-controller.js.map +1 -1
- package/dist/scenegraph/controllers/joint-controller.cjs +5 -5
- package/dist/scenegraph/controllers/joint-controller.js +1 -1
- package/dist/scenegraph/controllers/joint-controller.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/controllers/skin-controller.cjs +2 -2
- package/dist/scenegraph/controllers/skin-controller.js +1 -1
- package/dist/scenegraph/controllers/skin-controller.js.map +1 -1
- package/dist/scenegraph/group-node.cjs +14 -14
- package/dist/scenegraph/group-node.d.ts +2 -2
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +1 -1
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +1 -1
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/physics-transforms.cjs +2 -2
- package/dist/scenegraph/physics-transforms.d.ts +1 -1
- package/dist/scenegraph/physics-transforms.d.ts.map +1 -1
- package/dist/scenegraph/physics-transforms.js +1 -1
- package/dist/scenegraph/physics-transforms.js.map +1 -1
- 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-bounds.cjs +3 -3
- package/dist/scenegraph/scenegraph-bounds.d.ts +1 -1
- package/dist/scenegraph/scenegraph-bounds.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-bounds.js +1 -1
- package/dist/scenegraph/scenegraph-bounds.js.map +1 -1
- 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 +17 -7
- package/dist/scenegraph/scenegraph-node.d.ts +12 -1
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +11 -1
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/scenegraph/transform-source.d.ts +1 -1
- package/dist/scenegraph/transform-source.d.ts.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/dist/text/text-3d/extrude.cjs +15 -15
- package/dist/text/text-3d/extrude.js +1 -1
- package/dist/text/text-3d/extrude.js.map +1 -1
- package/dist/text/text-3d/index.cjs.map +2 -2
- package/dist/text/text-3d/paths/curves.cjs +5 -5
- package/dist/text/text-3d/paths/curves.d.ts +1 -1
- package/dist/text/text-3d/paths/curves.d.ts.map +1 -1
- package/dist/text/text-3d/paths/curves.js +1 -1
- package/dist/text/text-3d/paths/curves.js.map +1 -1
- package/dist/text/text-3d/paths/path.cjs +5 -5
- package/dist/text/text-3d/paths/path.d.ts +1 -1
- package/dist/text/text-3d/paths/path.d.ts.map +1 -1
- package/dist/text/text-3d/paths/path.js +1 -1
- package/dist/text/text-3d/paths/path.js.map +1 -1
- package/dist/text/text-3d/paths/shape-path.d.ts +1 -1
- package/dist/text/text-3d/paths/shape-path.d.ts.map +1 -1
- package/dist/text/text-3d/paths/shape-utils.cjs +2 -2
- package/dist/text/text-3d/paths/shape-utils.d.ts +1 -1
- package/dist/text/text-3d/paths/shape-utils.d.ts.map +1 -1
- package/dist/text/text-3d/paths/shape-utils.js +1 -1
- package/dist/text/text-3d/paths/shape-utils.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 +21 -13
- package/src/animation/deform-positions.ts +1 -1
- package/src/animation/node-animation-binding.ts +18 -1
- package/src/animation/skin.ts +2 -1
- package/src/animation/texture-transform.ts +1 -1
- package/src/arrow/arrow-geometry.ts +1 -1
- package/src/arrow/arrow-mesh-types.ts +1 -1
- package/src/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.ts +1 -1
- package/src/arrow/renderers/polygon/renderers/arrow-polygon-renderer.ts +1 -1
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +24 -20
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +1 -1
- package/src/audio/audio-controller.ts +1 -1
- package/src/audio/audio-environment.ts +1 -1
- package/src/compute/computation.ts +2 -2
- package/src/compute/swap.ts +2 -2
- package/src/debug/pixel-data-utils.ts +1 -1
- 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/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +1 -1
- package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +1 -1
- package/src/effects/passes/screen-space/gtao.ts +1 -1
- package/src/effects/passes/screen-space/height-fog.ts +1 -1
- package/src/effects/passes/screen-space/screen-space-global-illumination.ts +1 -1
- package/src/effects/passes/screen-space/screen-space-reflections.ts +1 -1
- package/src/effects/passes/screen-space/ssr-camera-temporal.ts +1 -1
- package/src/experimental/controls/index.ts +0 -2
- package/src/experimental/webxr/webxr-input.ts +1 -1
- package/{dist/experimental/controls/orbit-controls.js → src/experimental-controls.ts} +2 -2
- package/src/experimental-materials.ts +5 -0
- package/src/experimental-textures.ts +5 -0
- package/src/experimental-webxr.ts +5 -0
- package/src/geometry/edge-geometry.ts +2 -2
- package/src/geometry/geometry-primitives.ts +6 -3
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +7 -7
- package/src/geometry/gpu-geometry.ts +1 -1
- package/src/geometry/gpu-vector-geometry-adapter.ts +1 -1
- package/src/geometry/ring-geometry.ts +2 -2
- package/src/gltf/gltf/animations/animations.ts +8 -1
- package/src/gltf/gltf/create-gltf-model.ts +5 -1
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
- package/src/gltf/gltf/gltf-animated-crowd.ts +2 -1
- package/src/gltf/gltf/gltf-billboard.ts +6 -1
- package/src/gltf/gltf/gltf-extension-support.ts +2 -2
- package/src/gltf/gltf/gltf-instancing.ts +1 -1
- package/src/gltf/gltf/gltf-lightmap.ts +1 -1
- package/src/gltf/index.ts +1 -0
- package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
- package/src/gltf/parsers/parse-gltf-lights.ts +43 -131
- package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
- package/src/gltf/parsers/parse-gltf.ts +11 -2
- package/src/gltf/parsers/parse-pbr-material.ts +36 -8
- package/src/gltf/pbr/pbr-environment.ts +27 -1
- package/src/gltf/pbr/pbr-material.ts +8 -3
- package/src/gltf/physics/export-state.ts +1 -1
- package/src/gltf/physics/mesh-snapshot.ts +1 -1
- package/src/gltf/physics/node-collision-geometry.ts +1 -1
- package/src/gltf/physics/parse-gltf-physics.ts +1 -1
- package/src/gltf/physics/parse-physics-joints.ts +1 -1
- package/src/gltf/physics/property-bindings.ts +1 -1
- package/src/gltf/types/gltf-json-schema.ts +1 -0
- package/src/gltf/types/gltf-postprocessed-schema.ts +1 -0
- package/src/graph/models/path/path-attribute-model.ts +10 -1
- package/src/graph/models/path/path-storage-model.ts +13 -4
- package/src/graph/models/polygon/polygon-attribute-model.ts +1 -1
- package/src/graph/models/polygon/polygon-storage-model.ts +1 -1
- package/src/graph/physics/index.ts +1 -0
- package/src/graph/physics/physics-controller-geometry.ts +2 -2
- package/src/graph/physics/physics-controller.ts +155 -2
- package/src/graph/physics/physics-scenegraph.ts +1 -1
- package/src/graph/physics/scenegraph-instance.ts +27 -1
- package/src/graph/physics/scenegraph-motion.ts +1 -1
- package/src/graph/physics/scenegraph-properties.ts +1 -1
- package/src/graph/physics/scenegraph-publication.ts +1 -1
- package/src/graph/tables/gpu-table-model.ts +3 -2
- package/src/index.ts +17 -0
- package/src/lighting/ambient-occlusion-pass.ts +131 -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 +108 -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 +361 -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-model.ts +42 -4
- package/src/model/model.ts +1 -1
- package/src/models/light-model-utils.ts +5 -3
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/scenegraph/controllers/area-light-controller.ts +1 -1
- package/src/scenegraph/controllers/billboard-controller.ts +2 -1
- package/src/scenegraph/controllers/joint-controller.ts +1 -1
- package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
- package/src/scenegraph/controllers/skin-controller.ts +1 -1
- package/src/scenegraph/group-node.ts +2 -2
- package/src/scenegraph/model-node.ts +1 -1
- package/src/scenegraph/physics-transforms.ts +1 -1
- package/src/scenegraph/scene-metadata.ts +23 -0
- package/src/scenegraph/scenegraph-bounds.ts +2 -2
- package/src/scenegraph/scenegraph-interaction.ts +131 -0
- package/src/scenegraph/scenegraph-node.ts +14 -1
- package/src/scenegraph/transform-source.ts +1 -1
- package/src/splats/README.md +1 -1
- 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/src/text/text-3d/extrude.ts +1 -1
- package/src/text/text-3d/font.ts +1 -1
- package/src/text/text-3d/paths/curves.ts +1 -1
- package/src/text/text-3d/paths/path.ts +1 -1
- package/src/text/text-3d/paths/shape-path.ts +1 -1
- package/src/text/text-3d/paths/shape-utils.ts +2 -2
- package/dist/experimental/controls/orbit-controls.d.ts +0 -3
- package/dist/experimental/controls/orbit-controls.d.ts.map +0 -1
- package/dist/experimental/controls/orbit-controls.js.map +0 -1
- package/src/experimental/controls/orbit-controls.ts +0 -6
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,
|
|
@@ -652,6 +657,18 @@ var __exports__ = (() => {
|
|
|
652
657
|
}
|
|
653
658
|
};
|
|
654
659
|
|
|
660
|
+
// ../../node_modules/@math.gl/core/dist/types/typed-array-brand.js
|
|
661
|
+
var typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
662
|
+
function getTypedArrayName(value) {
|
|
663
|
+
return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : void 0;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// ../../node_modules/@math.gl/core/dist/types/is-array.js
|
|
667
|
+
function isTypedArray(value) {
|
|
668
|
+
const name = getTypedArrayName(value);
|
|
669
|
+
return name !== void 0 && name !== "BigInt64Array" && name !== "BigUint64Array";
|
|
670
|
+
}
|
|
671
|
+
|
|
655
672
|
// ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
|
|
656
673
|
var geometryId = 0;
|
|
657
674
|
var Geometry = class {
|
|
@@ -707,9 +724,6 @@ var __exports__ = (() => {
|
|
|
707
724
|
}
|
|
708
725
|
return attribute;
|
|
709
726
|
}
|
|
710
|
-
function isTypedArray(value) {
|
|
711
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
712
|
-
}
|
|
713
727
|
function validateIndices(indices, attributes) {
|
|
714
728
|
let maximumIndex = -1;
|
|
715
729
|
for (const index of indices.value)
|
|
@@ -1698,18 +1712,6 @@ var __exports__ = (() => {
|
|
|
1698
1712
|
}
|
|
1699
1713
|
|
|
1700
1714
|
// ../../node_modules/@math.gl/core/dist/classes/matrix3.js
|
|
1701
|
-
var INDICES;
|
|
1702
|
-
(function(INDICES3) {
|
|
1703
|
-
INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
|
|
1704
|
-
INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
|
|
1705
|
-
INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
|
|
1706
|
-
INDICES3[INDICES3["COL1ROW0"] = 3] = "COL1ROW0";
|
|
1707
|
-
INDICES3[INDICES3["COL1ROW1"] = 4] = "COL1ROW1";
|
|
1708
|
-
INDICES3[INDICES3["COL1ROW2"] = 5] = "COL1ROW2";
|
|
1709
|
-
INDICES3[INDICES3["COL2ROW0"] = 6] = "COL2ROW0";
|
|
1710
|
-
INDICES3[INDICES3["COL2ROW1"] = 7] = "COL2ROW1";
|
|
1711
|
-
INDICES3[INDICES3["COL2ROW2"] = 8] = "COL2ROW2";
|
|
1712
|
-
})(INDICES || (INDICES = {}));
|
|
1713
1715
|
var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
1714
1716
|
var Matrix3 = class extends Matrix {
|
|
1715
1717
|
static get IDENTITY() {
|
|
@@ -1724,9 +1726,6 @@ var __exports__ = (() => {
|
|
|
1724
1726
|
get RANK() {
|
|
1725
1727
|
return 3;
|
|
1726
1728
|
}
|
|
1727
|
-
get INDICES() {
|
|
1728
|
-
return INDICES;
|
|
1729
|
-
}
|
|
1730
1729
|
constructor(array) {
|
|
1731
1730
|
super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
|
|
1732
1731
|
if (arguments.length === 1 && Array.isArray(array)) {
|
|
@@ -2502,6 +2501,35 @@ var __exports__ = (() => {
|
|
|
2502
2501
|
out[15] = 1;
|
|
2503
2502
|
return out;
|
|
2504
2503
|
}
|
|
2504
|
+
function affineComponents(matrix) {
|
|
2505
|
+
if (matrix.length !== 16 || Array.from(matrix).some((x) => !Number.isFinite(x)) || matrix[3] !== 0 || matrix[7] !== 0 || matrix[11] !== 0 || matrix[15] !== 1) {
|
|
2506
|
+
throw new RangeError("Expected a finite affine matrix");
|
|
2507
|
+
}
|
|
2508
|
+
const scale5 = [
|
|
2509
|
+
Math.hypot(matrix[0], matrix[1], matrix[2]),
|
|
2510
|
+
Math.hypot(matrix[4], matrix[5], matrix[6]),
|
|
2511
|
+
Math.hypot(matrix[8], matrix[9], matrix[10])
|
|
2512
|
+
];
|
|
2513
|
+
if (scale5.some((x) => x === 0 || !Number.isFinite(x)))
|
|
2514
|
+
throw new RangeError("Singular transform");
|
|
2515
|
+
const rotation = Array.from({ length: 9 }, (_, i) => matrix[Math.floor(i / 3) * 4 + i % 3] / scale5[Math.floor(i / 3)]);
|
|
2516
|
+
for (const [a, b] of [
|
|
2517
|
+
[0, 3],
|
|
2518
|
+
[0, 6],
|
|
2519
|
+
[3, 6]
|
|
2520
|
+
]) {
|
|
2521
|
+
if (Math.abs(rotation[a] * rotation[b] + rotation[a + 1] * rotation[b + 1] + rotation[a + 2] * rotation[b + 2]) > 1e-7) {
|
|
2522
|
+
throw new RangeError("Sheared transforms do not have a TRS decomposition");
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
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]);
|
|
2526
|
+
if (determinant3 < 0) {
|
|
2527
|
+
scale5[0] = -scale5[0];
|
|
2528
|
+
for (let i = 0; i < 3; i++)
|
|
2529
|
+
rotation[i] = -rotation[i];
|
|
2530
|
+
}
|
|
2531
|
+
return { rotation, scale: scale5, translation: [matrix[12], matrix[13], matrix[14]] };
|
|
2532
|
+
}
|
|
2505
2533
|
|
|
2506
2534
|
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
|
|
2507
2535
|
function add(out, a, b) {
|
|
@@ -2574,25 +2602,6 @@ var __exports__ = (() => {
|
|
|
2574
2602
|
}
|
|
2575
2603
|
|
|
2576
2604
|
// ../../node_modules/@math.gl/core/dist/classes/matrix4.js
|
|
2577
|
-
var INDICES2;
|
|
2578
|
-
(function(INDICES3) {
|
|
2579
|
-
INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
|
|
2580
|
-
INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
|
|
2581
|
-
INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
|
|
2582
|
-
INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3";
|
|
2583
|
-
INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0";
|
|
2584
|
-
INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1";
|
|
2585
|
-
INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2";
|
|
2586
|
-
INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3";
|
|
2587
|
-
INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0";
|
|
2588
|
-
INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1";
|
|
2589
|
-
INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2";
|
|
2590
|
-
INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3";
|
|
2591
|
-
INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0";
|
|
2592
|
-
INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1";
|
|
2593
|
-
INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2";
|
|
2594
|
-
INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3";
|
|
2595
|
-
})(INDICES2 || (INDICES2 = {}));
|
|
2596
2605
|
var DEFAULT_FOVY = 45 * Math.PI / 180;
|
|
2597
2606
|
var DEFAULT_ASPECT = 1;
|
|
2598
2607
|
var DEFAULT_NEAR = 0.1;
|
|
@@ -2611,9 +2620,6 @@ var __exports__ = (() => {
|
|
|
2611
2620
|
get RANK() {
|
|
2612
2621
|
return 4;
|
|
2613
2622
|
}
|
|
2614
|
-
get INDICES() {
|
|
2615
|
-
return INDICES2;
|
|
2616
|
-
}
|
|
2617
2623
|
constructor(array) {
|
|
2618
2624
|
super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
|
|
2619
2625
|
if (arguments.length === 1 && Array.isArray(array)) {
|
|
@@ -2853,27 +2859,15 @@ var __exports__ = (() => {
|
|
|
2853
2859
|
* @returns self
|
|
2854
2860
|
*/
|
|
2855
2861
|
getRotation(result, scaleResult) {
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
result[3] = 0;
|
|
2866
|
-
result[4] = this[4] * inverseScale0;
|
|
2867
|
-
result[5] = this[5] * inverseScale1;
|
|
2868
|
-
result[6] = this[6] * inverseScale2;
|
|
2869
|
-
result[7] = 0;
|
|
2870
|
-
result[8] = this[8] * inverseScale0;
|
|
2871
|
-
result[9] = this[9] * inverseScale1;
|
|
2872
|
-
result[10] = this[10] * inverseScale2;
|
|
2873
|
-
result[11] = 0;
|
|
2874
|
-
result[12] = 0;
|
|
2875
|
-
result[13] = 0;
|
|
2876
|
-
result[14] = 0;
|
|
2862
|
+
const { rotation, scale: scale5 } = affineComponents(this);
|
|
2863
|
+
result = result || new Array(16);
|
|
2864
|
+
if (scaleResult)
|
|
2865
|
+
for (let i = 0; i < 3; i++)
|
|
2866
|
+
scaleResult[i] = scale5[i];
|
|
2867
|
+
for (let i = 0; i < 16; i++)
|
|
2868
|
+
result[i] = 0;
|
|
2869
|
+
for (let i = 0; i < 9; i++)
|
|
2870
|
+
result[Math.floor(i / 3) * 4 + i % 3] = rotation[i];
|
|
2877
2871
|
result[15] = 1;
|
|
2878
2872
|
return result;
|
|
2879
2873
|
}
|
|
@@ -2884,21 +2878,13 @@ var __exports__ = (() => {
|
|
|
2884
2878
|
* @returns self
|
|
2885
2879
|
*/
|
|
2886
2880
|
getRotationMatrix3(result, scaleResult) {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
result[1] = this[1] * inverseScale1;
|
|
2895
|
-
result[2] = this[2] * inverseScale2;
|
|
2896
|
-
result[3] = this[4] * inverseScale0;
|
|
2897
|
-
result[4] = this[5] * inverseScale1;
|
|
2898
|
-
result[5] = this[6] * inverseScale2;
|
|
2899
|
-
result[6] = this[8] * inverseScale0;
|
|
2900
|
-
result[7] = this[9] * inverseScale1;
|
|
2901
|
-
result[8] = this[10] * inverseScale2;
|
|
2881
|
+
const { rotation, scale: scale5 } = affineComponents(this);
|
|
2882
|
+
result = result || new Array(9);
|
|
2883
|
+
if (scaleResult)
|
|
2884
|
+
for (let i = 0; i < 3; i++)
|
|
2885
|
+
scaleResult[i] = scale5[i];
|
|
2886
|
+
for (let i = 0; i < 9; i++)
|
|
2887
|
+
result[i] = rotation[i];
|
|
2902
2888
|
return result;
|
|
2903
2889
|
}
|
|
2904
2890
|
// Modifiers
|
|
@@ -3291,6 +3277,28 @@ var __exports__ = (() => {
|
|
|
3291
3277
|
return normalize3(out, out);
|
|
3292
3278
|
};
|
|
3293
3279
|
})();
|
|
3280
|
+
function rotateTowards(out, a, b, step) {
|
|
3281
|
+
if (a.length !== 4 || b.length !== 4 || [...Array.from(a), ...Array.from(b), step].some((x) => !Number.isFinite(x))) {
|
|
3282
|
+
throw new RangeError("Expected finite quaternions and step");
|
|
3283
|
+
}
|
|
3284
|
+
if (a.length !== 4 || step < 0)
|
|
3285
|
+
throw new RangeError("Expected quaternions and a nonnegative step");
|
|
3286
|
+
const aScale = Math.max(...Array.from(a, Math.abs)), bScale = Math.max(...Array.from(b, Math.abs));
|
|
3287
|
+
if (!aScale || !bScale)
|
|
3288
|
+
throw new RangeError("Zero quaternion");
|
|
3289
|
+
const an = Array.from(a, (x) => x / aScale), bn = Array.from(b, (x) => x / bScale);
|
|
3290
|
+
const al = Math.hypot(...an), bl = Math.hypot(...bn);
|
|
3291
|
+
for (let i = 0; i < 4; i++) {
|
|
3292
|
+
an[i] /= al;
|
|
3293
|
+
bn[i] /= bl;
|
|
3294
|
+
}
|
|
3295
|
+
const dot4 = an.reduce((sum, x, i) => sum + x * bn[i], 0);
|
|
3296
|
+
const angle2 = 2 * Math.acos(Math.min(1, Math.abs(dot4)));
|
|
3297
|
+
if (out.length < 4)
|
|
3298
|
+
throw new RangeError("Result buffer is too short");
|
|
3299
|
+
slerp(out, an, bn, angle2 === 0 ? 0 : Math.min(1, step / angle2));
|
|
3300
|
+
return out;
|
|
3301
|
+
}
|
|
3294
3302
|
|
|
3295
3303
|
// ../../node_modules/@math.gl/core/dist/classes/quaternion.js
|
|
3296
3304
|
var Quaternion = class extends MathArray {
|
|
@@ -3363,6 +3371,9 @@ var __exports__ = (() => {
|
|
|
3363
3371
|
return this.check();
|
|
3364
3372
|
}
|
|
3365
3373
|
/** Set a quat to the identity quaternion */
|
|
3374
|
+
rotateTowards(target, step) {
|
|
3375
|
+
return rotateTowards(this, this, target, step);
|
|
3376
|
+
}
|
|
3366
3377
|
identity() {
|
|
3367
3378
|
identity2(this);
|
|
3368
3379
|
return this.check();
|
|
@@ -3553,31 +3564,6 @@ var __exports__ = (() => {
|
|
|
3553
3564
|
}
|
|
3554
3565
|
};
|
|
3555
3566
|
|
|
3556
|
-
// ../../node_modules/@math.gl/geometry/dist/lib/geometry-utils.js
|
|
3557
|
-
function unpackIndexedGeometry(geometry) {
|
|
3558
|
-
if (!geometry.indices)
|
|
3559
|
-
return geometry;
|
|
3560
|
-
const indices = geometry.indices.value;
|
|
3561
|
-
const attributes = {};
|
|
3562
|
-
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
3563
|
-
if (!attribute)
|
|
3564
|
-
continue;
|
|
3565
|
-
if (attribute.constant || !attribute.size) {
|
|
3566
|
-
attributes[name] = attribute;
|
|
3567
|
-
continue;
|
|
3568
|
-
}
|
|
3569
|
-
const ArrayType = attribute.value.constructor;
|
|
3570
|
-
const value = new ArrayType(indices.length * attribute.size);
|
|
3571
|
-
for (let i = 0; i < indices.length; i++) {
|
|
3572
|
-
for (let component = 0; component < attribute.size; component++) {
|
|
3573
|
-
value[i * attribute.size + component] = attribute.value[Number(indices[i]) * attribute.size + component];
|
|
3574
|
-
}
|
|
3575
|
-
}
|
|
3576
|
-
attributes[name] = { ...attribute, value };
|
|
3577
|
-
}
|
|
3578
|
-
return { attributes };
|
|
3579
|
-
}
|
|
3580
|
-
|
|
3581
3567
|
// ../../node_modules/@math.gl/geometry/dist/geometries/geometry-helpers.js
|
|
3582
3568
|
function assertPositive(value, name) {
|
|
3583
3569
|
if (!Number.isFinite(value) || value <= 0)
|
|
@@ -4192,6 +4178,33 @@ var __exports__ = (() => {
|
|
|
4192
4178
|
|
|
4193
4179
|
// src/geometry/geometry-utils.ts
|
|
4194
4180
|
var import_core3 = __toESM(require_core(), 1);
|
|
4181
|
+
|
|
4182
|
+
// ../../node_modules/@math.gl/geometry/dist/lib/geometry-utils.js
|
|
4183
|
+
function unpackIndexedGeometry(geometry) {
|
|
4184
|
+
if (!geometry.indices)
|
|
4185
|
+
return geometry;
|
|
4186
|
+
const indices = geometry.indices.value;
|
|
4187
|
+
const attributes = {};
|
|
4188
|
+
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
4189
|
+
if (!attribute)
|
|
4190
|
+
continue;
|
|
4191
|
+
if (attribute.constant || !attribute.size) {
|
|
4192
|
+
attributes[name] = attribute;
|
|
4193
|
+
continue;
|
|
4194
|
+
}
|
|
4195
|
+
const ArrayType = attribute.value.constructor;
|
|
4196
|
+
const value = new ArrayType(indices.length * attribute.size);
|
|
4197
|
+
for (let i = 0; i < indices.length; i++) {
|
|
4198
|
+
for (let component = 0; component < attribute.size; component++) {
|
|
4199
|
+
value[i * attribute.size + component] = attribute.value[Number(indices[i]) * attribute.size + component];
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
attributes[name] = { ...attribute, value };
|
|
4203
|
+
}
|
|
4204
|
+
return { attributes };
|
|
4205
|
+
}
|
|
4206
|
+
|
|
4207
|
+
// src/geometry/geometry-utils.ts
|
|
4195
4208
|
function makeInterleavedGeometry(geometry, options = {}) {
|
|
4196
4209
|
const bufferName = options.bufferName || "geometry";
|
|
4197
4210
|
if (isInterleavedGeometry(geometry, bufferName)) {
|
|
@@ -4628,7 +4641,7 @@ var __exports__ = (() => {
|
|
|
4628
4641
|
};
|
|
4629
4642
|
|
|
4630
4643
|
// src/animation-loop/animation-loop.ts
|
|
4631
|
-
var
|
|
4644
|
+
var import_core4 = __toESM(require_core(), 1);
|
|
4632
4645
|
|
|
4633
4646
|
// src/animation-loop/request-animation-frame.ts
|
|
4634
4647
|
function requestAnimationFramePolyfill(callback) {
|
|
@@ -4898,7 +4911,7 @@ var __exports__ = (() => {
|
|
|
4898
4911
|
throw new Error("No device provided");
|
|
4899
4912
|
}
|
|
4900
4913
|
this.stats = props.stats || new Stats({ id: `animation-loop-${statIdCounter++}` });
|
|
4901
|
-
this.sharedStats =
|
|
4914
|
+
this.sharedStats = import_core4.luma.stats.get(ANIMATION_LOOP_STATS);
|
|
4902
4915
|
this.frameRate = this.stats.get("Frame Rate");
|
|
4903
4916
|
this.frameRate.setSampleSize(1);
|
|
4904
4917
|
this.cpuTime = this.stats.get("CPU Time");
|
|
@@ -5310,10 +5323,10 @@ var __exports__ = (() => {
|
|
|
5310
5323
|
};
|
|
5311
5324
|
|
|
5312
5325
|
// src/animation-loop/make-animation-loop.ts
|
|
5313
|
-
var
|
|
5326
|
+
var import_core5 = __toESM(require_core(), 1);
|
|
5314
5327
|
function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
5315
5328
|
let renderLoop = null;
|
|
5316
|
-
const device = props?.device ||
|
|
5329
|
+
const device = props?.device || import_core5.luma.createDevice({
|
|
5317
5330
|
id: "animation-loop",
|
|
5318
5331
|
adapters: props?.adapters,
|
|
5319
5332
|
createCanvasContext: true
|
|
@@ -5671,7 +5684,7 @@ var __exports__ = (() => {
|
|
|
5671
5684
|
}
|
|
5672
5685
|
|
|
5673
5686
|
// src/model/gpu-vector-model.ts
|
|
5674
|
-
var
|
|
5687
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
5675
5688
|
var import_shaders3 = __toESM(require_shaders(), 1);
|
|
5676
5689
|
|
|
5677
5690
|
// ../shaders/src/lib/utils/assert.ts
|
|
@@ -5846,7 +5859,7 @@ var __exports__ = (() => {
|
|
|
5846
5859
|
/** Compilers registered by the application, isolated to this assembler. */
|
|
5847
5860
|
_shaderTranspilers = /* @__PURE__ */ new Map();
|
|
5848
5861
|
/** Hook functions */
|
|
5849
|
-
|
|
5862
|
+
_injectionTargets = [];
|
|
5850
5863
|
/** Shader modules */
|
|
5851
5864
|
_defaultModules = [];
|
|
5852
5865
|
/** Register or replace the compiler for one input language. */
|
|
@@ -5916,18 +5929,18 @@ var __exports__ = (() => {
|
|
|
5916
5929
|
this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
|
|
5917
5930
|
}
|
|
5918
5931
|
/**
|
|
5919
|
-
* Register a shader
|
|
5920
|
-
* @param
|
|
5932
|
+
* Register a shader injection target
|
|
5933
|
+
* @param injectionTarget Shared stage and name with language-specific parameters, return type, and source.
|
|
5921
5934
|
*/
|
|
5922
|
-
|
|
5923
|
-
this.
|
|
5935
|
+
addShaderInjectionTarget(injectionTarget) {
|
|
5936
|
+
this._injectionTargets.push(injectionTarget);
|
|
5924
5937
|
}
|
|
5925
5938
|
/**
|
|
5926
|
-
* Remove all registered shader
|
|
5939
|
+
* Remove all registered shader injection targets, for example before re-registering targets for a new
|
|
5927
5940
|
* application configuration. Default modules are not affected.
|
|
5928
5941
|
*/
|
|
5929
|
-
|
|
5930
|
-
this.
|
|
5942
|
+
resetShaderInjectionTargets() {
|
|
5943
|
+
this._injectionTargets.length = 0;
|
|
5931
5944
|
}
|
|
5932
5945
|
/**
|
|
5933
5946
|
* Dedupe and combine with default modules
|
|
@@ -6008,7 +6021,9 @@ var __exports__ = (() => {
|
|
|
6008
6021
|
}
|
|
6009
6022
|
const target = `${declaration.stage === "vertex" ? "vs" : "fs"}:${declaration.target}`;
|
|
6010
6023
|
if (!/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][A-Za-z0-9_]*)$/.test(target)) {
|
|
6011
|
-
throw new Error(
|
|
6024
|
+
throw new Error(
|
|
6025
|
+
`Shader injection target "${target}" must be a named shader injection target`
|
|
6026
|
+
);
|
|
6012
6027
|
}
|
|
6013
6028
|
resolved[target] ||= [];
|
|
6014
6029
|
resolved[target].push({
|
|
@@ -6355,13 +6370,13 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6355
6370
|
return uniforms;
|
|
6356
6371
|
};
|
|
6357
6372
|
}
|
|
6358
|
-
function appendInjections(injections,
|
|
6373
|
+
function appendInjections(injections, targetInjections, declInjections, mainInjections) {
|
|
6359
6374
|
for (const key in injections) {
|
|
6360
6375
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
6361
6376
|
if (match) {
|
|
6362
6377
|
const hash = match[2];
|
|
6363
6378
|
const name = match[3];
|
|
6364
|
-
const injectionType = hash ? name === "decl" ? declInjections : mainInjections :
|
|
6379
|
+
const injectionType = hash ? name === "decl" ? declInjections : mainInjections : targetInjections;
|
|
6365
6380
|
injectionType[key] = injectionType[key] || [];
|
|
6366
6381
|
injectionType[key].push(...injections[key]);
|
|
6367
6382
|
} else {
|
|
@@ -6402,53 +6417,53 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6402
6417
|
return source4;
|
|
6403
6418
|
}
|
|
6404
6419
|
|
|
6405
|
-
// ../shaders/src/lib/shader-assembly/shader-
|
|
6406
|
-
function
|
|
6420
|
+
// ../shaders/src/lib/shader-assembly/shader-injection-targets.ts
|
|
6421
|
+
function getShaderInjectionTargets(injectionTargets, targetInjections, shaderLanguage = "glsl") {
|
|
6407
6422
|
let result = "";
|
|
6408
|
-
for (const
|
|
6409
|
-
const
|
|
6410
|
-
const returnType =
|
|
6423
|
+
for (const targetName in injectionTargets) {
|
|
6424
|
+
const targetFunction = injectionTargets[targetName];
|
|
6425
|
+
const returnType = targetFunction.returnType || "void";
|
|
6411
6426
|
const functionPrefix = shaderLanguage === "wgsl" ? "fn" : returnType;
|
|
6412
6427
|
const returnSuffix = shaderLanguage === "wgsl" && returnType !== "void" ? ` -> ${returnType}` : "";
|
|
6413
|
-
result += `${functionPrefix} ${
|
|
6428
|
+
result += `${functionPrefix} ${targetFunction.signature}${returnSuffix} {
|
|
6414
6429
|
`;
|
|
6415
|
-
if (
|
|
6416
|
-
result += ` ${
|
|
6430
|
+
if (targetFunction.header) {
|
|
6431
|
+
result += ` ${targetFunction.header}`;
|
|
6417
6432
|
}
|
|
6418
|
-
if (
|
|
6419
|
-
const injections =
|
|
6433
|
+
if (targetInjections[targetName]) {
|
|
6434
|
+
const injections = targetInjections[targetName];
|
|
6420
6435
|
injections.sort((a, b) => a.order - b.order);
|
|
6421
6436
|
for (const injection of injections) {
|
|
6422
6437
|
result += ` ${injection.injection}
|
|
6423
6438
|
`;
|
|
6424
6439
|
}
|
|
6425
6440
|
}
|
|
6426
|
-
if (
|
|
6427
|
-
result += ` ${
|
|
6441
|
+
if (targetFunction.footer) {
|
|
6442
|
+
result += ` ${targetFunction.footer}`;
|
|
6428
6443
|
}
|
|
6429
6444
|
result += "}\n";
|
|
6430
6445
|
}
|
|
6431
6446
|
return result;
|
|
6432
6447
|
}
|
|
6433
|
-
function
|
|
6448
|
+
function normalizeShaderInjectionTargets(injectionTargets, pluginInjectionTargets = [], language = "glsl") {
|
|
6434
6449
|
const result = { vertex: {}, fragment: {} };
|
|
6435
|
-
for (const
|
|
6436
|
-
const implementation =
|
|
6450
|
+
for (const injectionTarget of injectionTargets) {
|
|
6451
|
+
const implementation = injectionTarget[language];
|
|
6437
6452
|
if (implementation) {
|
|
6438
|
-
const prefix =
|
|
6439
|
-
result[
|
|
6453
|
+
const prefix = injectionTarget.stage === "vertex" ? "vs" : "fs";
|
|
6454
|
+
result[injectionTarget.stage][`${prefix}:${injectionTarget.name}`] = {
|
|
6440
6455
|
...implementation,
|
|
6441
|
-
signature: `${
|
|
6456
|
+
signature: `${injectionTarget.name}(${implementation.parameters})`
|
|
6442
6457
|
};
|
|
6443
6458
|
}
|
|
6444
6459
|
}
|
|
6445
|
-
for (const
|
|
6446
|
-
const selected =
|
|
6460
|
+
for (const injectionTarget of pluginInjectionTargets) {
|
|
6461
|
+
const selected = normalizeShaderInjectionTargets([injectionTarget], [], language);
|
|
6447
6462
|
for (const stage of ["vertex", "fragment"]) {
|
|
6448
6463
|
for (const [name, declaration] of Object.entries(selected[stage])) {
|
|
6449
6464
|
const existing = result[stage][name];
|
|
6450
6465
|
if (existing && (existing.signature !== declaration.signature || (existing.returnType || "void") !== (declaration.returnType || "void"))) {
|
|
6451
|
-
throw new Error(`Conflicting ShaderPlugin
|
|
6466
|
+
throw new Error(`Conflicting ShaderPlugin injection target ${name}`);
|
|
6452
6467
|
}
|
|
6453
6468
|
result[stage][name] = existing || declaration;
|
|
6454
6469
|
}
|
|
@@ -6456,22 +6471,24 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6456
6471
|
}
|
|
6457
6472
|
return result;
|
|
6458
6473
|
}
|
|
6459
|
-
function
|
|
6460
|
-
const stageRegistry =
|
|
6461
|
-
return Boolean(stageRegistry[
|
|
6474
|
+
function isShaderInjectionTargetRegistered(registry, targetName) {
|
|
6475
|
+
const stageRegistry = targetName.startsWith("vs:") ? registry.vertex : registry.fragment;
|
|
6476
|
+
return Boolean(stageRegistry[targetName]);
|
|
6462
6477
|
}
|
|
6463
|
-
function
|
|
6478
|
+
function validateShaderInjectionTargetInjections(registry, targetInjections, stage) {
|
|
6464
6479
|
const stagePrefix = stage === "vertex" ? "vs:" : stage === "fragment" ? "fs:" : null;
|
|
6465
|
-
for (const
|
|
6466
|
-
if (stagePrefix && !
|
|
6480
|
+
for (const targetName in targetInjections) {
|
|
6481
|
+
if (stagePrefix && !targetName.startsWith(stagePrefix)) {
|
|
6467
6482
|
continue;
|
|
6468
6483
|
}
|
|
6469
|
-
if (!
|
|
6484
|
+
if (!isShaderInjectionTargetRegistered(registry, targetName)) {
|
|
6470
6485
|
const pluginNames = [
|
|
6471
|
-
...new Set(
|
|
6486
|
+
...new Set(
|
|
6487
|
+
targetInjections[targetName].map((injection) => injection.pluginName).filter(Boolean)
|
|
6488
|
+
)
|
|
6472
6489
|
];
|
|
6473
6490
|
throw new Error(
|
|
6474
|
-
`Unknown shader
|
|
6491
|
+
`Unknown shader injection target ${targetName}${pluginNames.length ? ` (plugins: ${pluginNames.join(", ")})` : ""}`
|
|
6475
6492
|
);
|
|
6476
6493
|
}
|
|
6477
6494
|
}
|
|
@@ -6569,8 +6586,13 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6569
6586
|
}
|
|
6570
6587
|
return decoded;
|
|
6571
6588
|
}
|
|
6589
|
+
var attributeShaderTypeInfoCache = /* @__PURE__ */ new Map();
|
|
6572
6590
|
function getAttributeShaderTypeInfo(attributeType) {
|
|
6573
6591
|
const resolvedAttributeType = resolveAttributeShaderTypeAlias(attributeType);
|
|
6592
|
+
const cached = attributeShaderTypeInfoCache.get(resolvedAttributeType);
|
|
6593
|
+
if (cached) {
|
|
6594
|
+
return cached;
|
|
6595
|
+
}
|
|
6574
6596
|
const decoded = TYPE_INFO[resolvedAttributeType];
|
|
6575
6597
|
if (!decoded) {
|
|
6576
6598
|
throw new Error(`Unsupported attribute shader type: ${attributeType}`);
|
|
@@ -6579,13 +6601,15 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6579
6601
|
const integer = primitiveType === "i32" || primitiveType === "u32";
|
|
6580
6602
|
const signed = primitiveType !== "u32";
|
|
6581
6603
|
const byteLength = PRIMITIVE_TYPE_SIZES[primitiveType] * components2;
|
|
6582
|
-
|
|
6604
|
+
const result = Object.freeze({
|
|
6583
6605
|
primitiveType,
|
|
6584
6606
|
components: components2,
|
|
6585
6607
|
byteLength,
|
|
6586
6608
|
integer,
|
|
6587
6609
|
signed
|
|
6588
|
-
};
|
|
6610
|
+
});
|
|
6611
|
+
attributeShaderTypeInfoCache.set(resolvedAttributeType, result);
|
|
6612
|
+
return result;
|
|
6589
6613
|
}
|
|
6590
6614
|
var ShaderTypeDecoder = class {
|
|
6591
6615
|
getVariableShaderTypeInfo(format) {
|
|
@@ -6694,6 +6718,9 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6694
6718
|
"mat4x3<u32>": { type: "u32", components: 12 },
|
|
6695
6719
|
"mat4x4<u32>": { type: "u32", components: 16 }
|
|
6696
6720
|
};
|
|
6721
|
+
for (const info of Object.values(UNIFORM_FORMATS)) {
|
|
6722
|
+
Object.freeze(info);
|
|
6723
|
+
}
|
|
6697
6724
|
var WGSL_ATTRIBUTE_TYPE_ALIAS_MAP = {
|
|
6698
6725
|
vec2i: "vec2<i32>",
|
|
6699
6726
|
vec3i: "vec3<i32>",
|
|
@@ -7687,7 +7714,7 @@ return ${outputName};
|
|
|
7687
7714
|
language = "glsl",
|
|
7688
7715
|
modules,
|
|
7689
7716
|
defines = {},
|
|
7690
|
-
|
|
7717
|
+
injectionTargets = [],
|
|
7691
7718
|
inject = {},
|
|
7692
7719
|
pluginInjections = {},
|
|
7693
7720
|
pluginVertexInputs = {},
|
|
@@ -7727,13 +7754,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
7727
7754
|
`;
|
|
7728
7755
|
break;
|
|
7729
7756
|
}
|
|
7730
|
-
const
|
|
7731
|
-
|
|
7757
|
+
const injectionTargetMap = normalizeShaderInjectionTargets(
|
|
7758
|
+
injectionTargets,
|
|
7759
|
+
options.pluginInjectionTargets,
|
|
7760
|
+
"glsl"
|
|
7761
|
+
);
|
|
7762
|
+
const targetInjections = {};
|
|
7732
7763
|
const declInjections = {};
|
|
7733
7764
|
const mainInjections = {};
|
|
7734
|
-
appendInjections(pluginInjections,
|
|
7765
|
+
appendInjections(pluginInjections, targetInjections, declInjections, mainInjections);
|
|
7735
7766
|
const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "glsl") : {};
|
|
7736
|
-
appendInjections(applicationInjections,
|
|
7767
|
+
appendInjections(applicationInjections, targetInjections, declInjections, mainInjections);
|
|
7737
7768
|
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
7738
7769
|
for (const key in injectionMap) {
|
|
7739
7770
|
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
@@ -7748,7 +7779,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7748
7779
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
7749
7780
|
}
|
|
7750
7781
|
} else {
|
|
7751
|
-
|
|
7782
|
+
targetInjections[key] = [...targetInjections[key] || [], injection];
|
|
7752
7783
|
}
|
|
7753
7784
|
} else {
|
|
7754
7785
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
@@ -7782,11 +7813,11 @@ ${getApplicationDefines(allDefines)}
|
|
|
7782
7813
|
const moduleSource = getShaderModuleSource(module, stage, log8);
|
|
7783
7814
|
assembledSource += moduleSource;
|
|
7784
7815
|
}
|
|
7785
|
-
|
|
7816
|
+
validateShaderInjectionTargetInjections(injectionTargetMap, targetInjections, stage);
|
|
7786
7817
|
assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
|
|
7787
7818
|
assembledSource += INJECT_SHADER_DECLARATIONS;
|
|
7788
7819
|
assembledSource = injectShader(assembledSource, stage, declInjections);
|
|
7789
|
-
assembledSource +=
|
|
7820
|
+
assembledSource += getShaderInjectionTargets(injectionTargetMap[stage], targetInjections);
|
|
7790
7821
|
assembledSource += coreSource;
|
|
7791
7822
|
assembledSource = injectShader(assembledSource, stage, mainInjections);
|
|
7792
7823
|
if (language === "glsl" && sourceVersion !== targetVersion) {
|
|
@@ -7819,7 +7850,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7819
7850
|
*/
|
|
7820
7851
|
assembleGLSLShaderPair(props) {
|
|
7821
7852
|
const modules = this._getModuleList(props.modules);
|
|
7822
|
-
const
|
|
7853
|
+
const injectionTargets = [...this._injectionTargets, ...props.injectionTargets || []];
|
|
7823
7854
|
const vertex = this._transpileShader(props, modules, props.vs, "vertex");
|
|
7824
7855
|
const fragment = this._transpileShader(props, modules, props.fs, "fragment");
|
|
7825
7856
|
const assembled = assembleGLSLShaderPair({
|
|
@@ -7827,7 +7858,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7827
7858
|
vs: vertex.code,
|
|
7828
7859
|
fs: props.fs == null ? void 0 : fragment.code,
|
|
7829
7860
|
modules: vertex.modules,
|
|
7830
|
-
|
|
7861
|
+
injectionTargets
|
|
7831
7862
|
});
|
|
7832
7863
|
return { ...assembled, modules };
|
|
7833
7864
|
}
|
|
@@ -8491,6 +8522,141 @@ ${getApplicationDefines(allDefines)}
|
|
|
8491
8522
|
return match?.[1];
|
|
8492
8523
|
}
|
|
8493
8524
|
|
|
8525
|
+
// ../shaders/src/lib/shader-assembly/wgsl-injection-target-names.ts
|
|
8526
|
+
function getWGSLInjectionTargetNames(targets, source4 = "") {
|
|
8527
|
+
const names = /* @__PURE__ */ new Map();
|
|
8528
|
+
const declarations = Object.values(targets).flatMap(
|
|
8529
|
+
(stage) => Object.entries(stage).map(
|
|
8530
|
+
([key, target]) => `${key.slice(3)}
|
|
8531
|
+
${target.signature}
|
|
8532
|
+
${target.header || ""}
|
|
8533
|
+
${target.footer || ""}`
|
|
8534
|
+
)
|
|
8535
|
+
);
|
|
8536
|
+
const usedNames = new Set(
|
|
8537
|
+
maskWGSLComments(`${source4}
|
|
8538
|
+
${declarations.join("\n")}`).match(
|
|
8539
|
+
/[_\p{XID_Start}][\p{XID_Continue}]*/gu
|
|
8540
|
+
)
|
|
8541
|
+
);
|
|
8542
|
+
for (const key of Object.keys(targets.vertex)) {
|
|
8543
|
+
const name = key.slice(3);
|
|
8544
|
+
if (targets.fragment[`fs:${name}`]) {
|
|
8545
|
+
names.set(name, {
|
|
8546
|
+
vertex: allocateName(`_luma_vertex_target_${name}`, usedNames),
|
|
8547
|
+
fragment: allocateName(`_luma_fragment_target_${name}`, usedNames)
|
|
8548
|
+
});
|
|
8549
|
+
}
|
|
8550
|
+
}
|
|
8551
|
+
return names;
|
|
8552
|
+
}
|
|
8553
|
+
function resolveWGSLInjectionTargetNames(source4, targets, targetNames = getWGSLInjectionTargetNames(targets)) {
|
|
8554
|
+
if (!targetNames.size) return source4;
|
|
8555
|
+
const masked = maskWGSLComments(source4);
|
|
8556
|
+
const functions = /* @__PURE__ */ new Map();
|
|
8557
|
+
const pattern = /((?:@\w+(?:\([^)]*\))?\s*)*)\bfn\s+([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu;
|
|
8558
|
+
for (let match = pattern.exec(masked); match; match = pattern.exec(masked)) {
|
|
8559
|
+
const bodyStart = masked.indexOf("{", pattern.lastIndex);
|
|
8560
|
+
let end = bodyStart + 1;
|
|
8561
|
+
let depth = 1;
|
|
8562
|
+
for (; end < masked.length && depth; end++) {
|
|
8563
|
+
if (masked[end] === "{") depth++;
|
|
8564
|
+
if (masked[end] === "}") depth--;
|
|
8565
|
+
}
|
|
8566
|
+
assert2(bodyStart >= 0 && depth === 0);
|
|
8567
|
+
const name = match[2];
|
|
8568
|
+
const nameStart = match.index + match[0].lastIndexOf(name);
|
|
8569
|
+
const calls = Array.from(
|
|
8570
|
+
masked.slice(bodyStart + 1, end - 1).matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu),
|
|
8571
|
+
(call) => call[1]
|
|
8572
|
+
);
|
|
8573
|
+
functions.set(name, {
|
|
8574
|
+
name,
|
|
8575
|
+
start: match.index,
|
|
8576
|
+
end,
|
|
8577
|
+
nameStart,
|
|
8578
|
+
bodyStart,
|
|
8579
|
+
calls,
|
|
8580
|
+
stages: /* @__PURE__ */ new Set(),
|
|
8581
|
+
entryStage: /@vertex\b/.test(match[1]) ? "vertex" : /@fragment\b/.test(match[1]) ? "fragment" : void 0
|
|
8582
|
+
});
|
|
8583
|
+
pattern.lastIndex = end;
|
|
8584
|
+
}
|
|
8585
|
+
function visit(name, stage) {
|
|
8586
|
+
const shaderFunction = functions.get(name);
|
|
8587
|
+
if (!shaderFunction || shaderFunction.stages.has(stage)) return;
|
|
8588
|
+
shaderFunction.stages.add(stage);
|
|
8589
|
+
for (const call of shaderFunction.calls) {
|
|
8590
|
+
visit(targetNames.get(call)?.[stage] || call, stage);
|
|
8591
|
+
}
|
|
8592
|
+
}
|
|
8593
|
+
for (const shaderFunction of functions.values()) {
|
|
8594
|
+
if (shaderFunction.entryStage) visit(shaderFunction.name, shaderFunction.entryStage);
|
|
8595
|
+
}
|
|
8596
|
+
for (const stage of ["vertex", "fragment"]) {
|
|
8597
|
+
for (const key of Object.keys(targets[stage])) {
|
|
8598
|
+
const name = key.slice(3);
|
|
8599
|
+
visit(targetNames.get(name)?.[stage] || name, stage);
|
|
8600
|
+
}
|
|
8601
|
+
}
|
|
8602
|
+
const affected = /* @__PURE__ */ new Set();
|
|
8603
|
+
let changed = true;
|
|
8604
|
+
while (changed) {
|
|
8605
|
+
changed = false;
|
|
8606
|
+
for (const shaderFunction of functions.values()) {
|
|
8607
|
+
if (!affected.has(shaderFunction.name) && shaderFunction.calls.some((call) => targetNames.has(call) || affected.has(call))) {
|
|
8608
|
+
affected.add(shaderFunction.name);
|
|
8609
|
+
changed = true;
|
|
8610
|
+
}
|
|
8611
|
+
}
|
|
8612
|
+
}
|
|
8613
|
+
const helperNames = /* @__PURE__ */ new Map();
|
|
8614
|
+
const usedNames = new Set(masked.match(/[_\p{XID_Start}][\p{XID_Continue}]*/gu));
|
|
8615
|
+
for (const name of affected) {
|
|
8616
|
+
if (functions.get(name)?.stages.size === 2) {
|
|
8617
|
+
helperNames.set(name, {
|
|
8618
|
+
vertex: allocateName(`_luma_vertex_helper_${name}`, usedNames),
|
|
8619
|
+
fragment: allocateName(`_luma_fragment_helper_${name}`, usedNames)
|
|
8620
|
+
});
|
|
8621
|
+
}
|
|
8622
|
+
}
|
|
8623
|
+
function getCallName(name, stage) {
|
|
8624
|
+
const targetName = targetNames.get(name)?.[stage];
|
|
8625
|
+
if (targetName) return targetName;
|
|
8626
|
+
return helperNames.get(name)?.[stage] || name;
|
|
8627
|
+
}
|
|
8628
|
+
for (const shaderFunction of [...functions.values()].reverse()) {
|
|
8629
|
+
if (!affected.has(shaderFunction.name)) continue;
|
|
8630
|
+
if (!shaderFunction.stages.size) {
|
|
8631
|
+
throw new Error(`Cannot infer WGSL target stage in ${shaderFunction.name}`);
|
|
8632
|
+
}
|
|
8633
|
+
const variants = [];
|
|
8634
|
+
const start = shaderFunction.start;
|
|
8635
|
+
for (const stage of shaderFunction.stages) {
|
|
8636
|
+
let text = source4.slice(start, shaderFunction.end);
|
|
8637
|
+
const body = masked.slice(shaderFunction.bodyStart + 1, shaderFunction.end - 1);
|
|
8638
|
+
const calls = [...body.matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu)];
|
|
8639
|
+
for (const call of calls.reverse()) {
|
|
8640
|
+
const offset2 = shaderFunction.bodyStart + 1 + call.index - start;
|
|
8641
|
+
const replacement = getCallName(call[1], stage);
|
|
8642
|
+
text = text.slice(0, offset2) + replacement + text.slice(offset2 + call[1].length);
|
|
8643
|
+
}
|
|
8644
|
+
const offset = shaderFunction.nameStart - start;
|
|
8645
|
+
text = text.slice(0, offset) + getCallName(shaderFunction.name, stage) + text.slice(offset + shaderFunction.name.length);
|
|
8646
|
+
variants.push(text);
|
|
8647
|
+
}
|
|
8648
|
+
source4 = source4.slice(0, start) + variants.join("\n") + source4.slice(shaderFunction.end);
|
|
8649
|
+
}
|
|
8650
|
+
return source4;
|
|
8651
|
+
}
|
|
8652
|
+
function allocateName(baseName, usedNames) {
|
|
8653
|
+
let name = baseName;
|
|
8654
|
+
let suffix = 0;
|
|
8655
|
+
while (usedNames.has(name)) name = `${baseName}_${++suffix}`;
|
|
8656
|
+
usedNames.add(name);
|
|
8657
|
+
return name;
|
|
8658
|
+
}
|
|
8659
|
+
|
|
8494
8660
|
// ../shaders/src/lib/preprocessor/preprocessor.ts
|
|
8495
8661
|
var DEFINE_NAME_PATTERN = "([a-zA-Z_][a-zA-Z0-9_]*)";
|
|
8496
8662
|
var IF_REGEXP = /^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/;
|
|
@@ -8629,7 +8795,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8629
8795
|
modules,
|
|
8630
8796
|
// defines = {},
|
|
8631
8797
|
defines = {},
|
|
8632
|
-
|
|
8798
|
+
injectionTargets = [],
|
|
8633
8799
|
inject = {},
|
|
8634
8800
|
pluginInjections = {},
|
|
8635
8801
|
pluginVertexInputs = {},
|
|
@@ -8653,13 +8819,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
8653
8819
|
);
|
|
8654
8820
|
const coreSource = pluginVaryingAssembly.source;
|
|
8655
8821
|
let assembledSource = "";
|
|
8656
|
-
const
|
|
8657
|
-
|
|
8822
|
+
const injectionTargetMap = normalizeShaderInjectionTargets(
|
|
8823
|
+
injectionTargets,
|
|
8824
|
+
options.pluginInjectionTargets,
|
|
8825
|
+
"wgsl"
|
|
8826
|
+
);
|
|
8827
|
+
const targetInjections = {};
|
|
8658
8828
|
const declInjections = {};
|
|
8659
8829
|
const mainInjections = {};
|
|
8660
|
-
appendInjections(pluginInjections,
|
|
8830
|
+
appendInjections(pluginInjections, targetInjections, declInjections, mainInjections);
|
|
8661
8831
|
const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "wgsl") : {};
|
|
8662
|
-
appendInjections(applicationInjections,
|
|
8832
|
+
appendInjections(applicationInjections, targetInjections, declInjections, mainInjections);
|
|
8663
8833
|
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
8664
8834
|
for (const key in injectionMap) {
|
|
8665
8835
|
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
@@ -8674,7 +8844,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8674
8844
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
8675
8845
|
}
|
|
8676
8846
|
} else {
|
|
8677
|
-
|
|
8847
|
+
targetInjections[key] = [...targetInjections[key] || [], injection];
|
|
8678
8848
|
}
|
|
8679
8849
|
} else {
|
|
8680
8850
|
mainInjections[key] = [...mainInjections[key] || [], injection];
|
|
@@ -8687,7 +8857,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8687
8857
|
mainInjections
|
|
8688
8858
|
);
|
|
8689
8859
|
appendGeneratedVaryingInjections(pluginVaryingAssembly, declInjections, mainInjections);
|
|
8690
|
-
|
|
8860
|
+
validateShaderInjectionTargetInjections(injectionTargetMap, targetInjections);
|
|
8691
8861
|
const modulesToInject = modules.map((module) => ({
|
|
8692
8862
|
module,
|
|
8693
8863
|
source: preprocess(getShaderModuleSource(module, "wgsl", log8), { defines })
|
|
@@ -8726,13 +8896,31 @@ ${getApplicationDefines(allDefines)}
|
|
|
8726
8896
|
"wgsl",
|
|
8727
8897
|
{ vertex: vertexEntryPoint, fragment: fragmentEntryPoint }
|
|
8728
8898
|
);
|
|
8729
|
-
|
|
8899
|
+
const targetNames = getWGSLInjectionTargetNames(
|
|
8900
|
+
injectionTargetMap,
|
|
8901
|
+
[
|
|
8902
|
+
assembledSource,
|
|
8903
|
+
applicationRelocation.source,
|
|
8904
|
+
...Object.values(targetInjections).flat().map((injection) => injection.injection),
|
|
8905
|
+
...Object.values(mainInjections).flat().map((injection) => injection.injection)
|
|
8906
|
+
].join("\n")
|
|
8907
|
+
);
|
|
8908
|
+
assembledSource += getWGSLShaderInjectionTargets(
|
|
8909
|
+
injectionTargetMap,
|
|
8910
|
+
targetInjections,
|
|
8911
|
+
targetNames
|
|
8912
|
+
);
|
|
8730
8913
|
assembledSource += formatWGSLBindingAssignmentComments(bindingAssignments);
|
|
8731
8914
|
assembledSource += applicationRelocation.source;
|
|
8732
8915
|
assembledSource = injectShader(assembledSource, stage, mainInjections, false, "wgsl", {
|
|
8733
8916
|
vertex: vertexEntryPoint,
|
|
8734
8917
|
fragment: fragmentEntryPoint
|
|
8735
8918
|
});
|
|
8919
|
+
assembledSource = resolveWGSLInjectionTargetNames(
|
|
8920
|
+
assembledSource,
|
|
8921
|
+
injectionTargetMap,
|
|
8922
|
+
targetNames
|
|
8923
|
+
);
|
|
8736
8924
|
assertNoUnresolvedAutoBindings(assembledSource);
|
|
8737
8925
|
return { source: assembledSource, bindingAssignments };
|
|
8738
8926
|
}
|
|
@@ -8782,8 +8970,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
8782
8970
|
];
|
|
8783
8971
|
return unifiedDeclarations.length ? { "vs:#decl": unifiedDeclarations } : {};
|
|
8784
8972
|
}
|
|
8785
|
-
function
|
|
8786
|
-
return
|
|
8973
|
+
function getWGSLShaderInjectionTargets(injectionTargetMap, targetInjections, names = getWGSLInjectionTargetNames(injectionTargetMap)) {
|
|
8974
|
+
return ["vertex", "fragment"].map((stage) => {
|
|
8975
|
+
const targets = Object.fromEntries(
|
|
8976
|
+
Object.entries(injectionTargetMap[stage]).map(([key, target]) => {
|
|
8977
|
+
const name = key.slice(3);
|
|
8978
|
+
const emittedName = names.get(name)?.[stage] || name;
|
|
8979
|
+
return [key, { ...target, signature: emittedName + target.signature.slice(name.length) }];
|
|
8980
|
+
})
|
|
8981
|
+
);
|
|
8982
|
+
return getShaderInjectionTargets(targets, targetInjections, "wgsl");
|
|
8983
|
+
}).join("");
|
|
8787
8984
|
}
|
|
8788
8985
|
function getUsedBindingsByGroupFromApplicationWGSL(source4) {
|
|
8789
8986
|
const usedBindingsByGroup = /* @__PURE__ */ new Map();
|
|
@@ -9105,7 +9302,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9105
9302
|
*/
|
|
9106
9303
|
assembleWGSLShader(props) {
|
|
9107
9304
|
const modules = this._getModuleList(props.modules);
|
|
9108
|
-
const
|
|
9305
|
+
const injectionTargets = [...this._injectionTargets, ...props.injectionTargets || []];
|
|
9109
9306
|
const translated = this._transpileShader(
|
|
9110
9307
|
props,
|
|
9111
9308
|
modules,
|
|
@@ -9131,7 +9328,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9131
9328
|
defines,
|
|
9132
9329
|
_bindingRegistry: this._wgslBindingRegistry,
|
|
9133
9330
|
modules: translated.modules,
|
|
9134
|
-
|
|
9331
|
+
injectionTargets
|
|
9135
9332
|
});
|
|
9136
9333
|
const preprocessedSource = props.platformInfo.shaderLanguage === "wgsl" ? preprocess(assembledSource, { defines }) : assembledSource;
|
|
9137
9334
|
return {
|
|
@@ -9172,7 +9369,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9172
9369
|
};
|
|
9173
9370
|
|
|
9174
9371
|
// src/model/batch-uniform-buffer.ts
|
|
9175
|
-
var
|
|
9372
|
+
var import_core6 = __toESM(require_core(), 1);
|
|
9176
9373
|
var BatchUniformBuffer = class {
|
|
9177
9374
|
constructor(device) {
|
|
9178
9375
|
this.device = device;
|
|
@@ -9187,7 +9384,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9187
9384
|
const buffer = this.device.createBuffer({
|
|
9188
9385
|
id: "batch-uniforms",
|
|
9189
9386
|
byteLength: capacity,
|
|
9190
|
-
usage:
|
|
9387
|
+
usage: import_core6.Buffer.UNIFORM | import_core6.Buffer.COPY_DST
|
|
9191
9388
|
});
|
|
9192
9389
|
this.buffer?.destroy();
|
|
9193
9390
|
this.buffer = buffer;
|
|
@@ -9201,7 +9398,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9201
9398
|
}
|
|
9202
9399
|
/** Writes one slot without overwriting earlier batches in this call. */
|
|
9203
9400
|
write(data) {
|
|
9204
|
-
(0,
|
|
9401
|
+
(0, import_core6.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
|
|
9205
9402
|
const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
|
|
9206
9403
|
this.buffer.write(data, binding.offset);
|
|
9207
9404
|
this.byteOffset += this.getAlignedByteLength(data.byteLength);
|
|
@@ -9379,7 +9576,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9379
9576
|
}
|
|
9380
9577
|
|
|
9381
9578
|
// src/utils/buffer-layout-helper.ts
|
|
9382
|
-
var
|
|
9579
|
+
var import_core7 = __toESM(require_core(), 1);
|
|
9383
9580
|
var BufferLayoutHelper = class {
|
|
9384
9581
|
bufferLayouts;
|
|
9385
9582
|
constructor(bufferLayouts) {
|
|
@@ -9390,7 +9587,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9390
9587
|
}
|
|
9391
9588
|
/** Get attribute names from a BufferLayout */
|
|
9392
9589
|
getAttributeNamesForBuffer(bufferLayout) {
|
|
9393
|
-
return (0,
|
|
9590
|
+
return (0, import_core7.getBufferLayoutAttributeNames)(bufferLayout);
|
|
9394
9591
|
}
|
|
9395
9592
|
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
9396
9593
|
const mergedLayouts = [...bufferLayouts1];
|
|
@@ -9407,16 +9604,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
9407
9604
|
};
|
|
9408
9605
|
|
|
9409
9606
|
// src/utils/buffer-layout-order.ts
|
|
9410
|
-
var
|
|
9607
|
+
var import_core8 = __toESM(require_core(), 1);
|
|
9411
9608
|
function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
9412
|
-
const shaderLayoutMap = (0,
|
|
9609
|
+
const shaderLayoutMap = (0, import_core8.getShaderAttributeLocationMap)(shaderLayout);
|
|
9413
9610
|
const sortedLayout = bufferLayout.slice();
|
|
9414
9611
|
sortedLayout.sort((a, b) => {
|
|
9415
|
-
const minLocationA = (0,
|
|
9416
|
-
(0,
|
|
9612
|
+
const minLocationA = (0, import_core8.getMinimumAttributeLocation)(
|
|
9613
|
+
(0, import_core8.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9417
9614
|
);
|
|
9418
|
-
const minLocationB = (0,
|
|
9419
|
-
(0,
|
|
9615
|
+
const minLocationB = (0, import_core8.getMinimumAttributeLocation)(
|
|
9616
|
+
(0, import_core8.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9420
9617
|
);
|
|
9421
9618
|
return minLocationA - minLocationB;
|
|
9422
9619
|
});
|
|
@@ -9579,7 +9776,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9579
9776
|
}
|
|
9580
9777
|
|
|
9581
9778
|
// src/model/gpu-vector-model-batches.ts
|
|
9582
|
-
var
|
|
9779
|
+
var import_core9 = __toESM(require_core(), 1);
|
|
9583
9780
|
function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
|
|
9584
9781
|
for (const [name, vector] of Object.entries(vectors)) {
|
|
9585
9782
|
if (!vector) continue;
|
|
@@ -9643,22 +9840,22 @@ ${getApplicationDefines(allDefines)}
|
|
|
9643
9840
|
if (format.includes("<")) {
|
|
9644
9841
|
throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
|
|
9645
9842
|
}
|
|
9646
|
-
return
|
|
9843
|
+
return import_core9.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
9647
9844
|
}
|
|
9648
9845
|
|
|
9649
9846
|
// src/utils/gpu-vector-batch-structure.ts
|
|
9650
|
-
var
|
|
9847
|
+
var import_core10 = __toESM(require_core(), 1);
|
|
9651
9848
|
function validateGPUVectorBatchStructure(vectors) {
|
|
9652
9849
|
let reference;
|
|
9653
9850
|
for (const vector of Object.values(vectors)) {
|
|
9654
9851
|
if (!vector || "isConstant" in vector) continue;
|
|
9655
9852
|
let rowCount = 0;
|
|
9656
9853
|
for (const chunk of vector.data) rowCount += chunk.length;
|
|
9657
|
-
(0,
|
|
9854
|
+
(0, import_core10.assert)(rowCount === vector.length);
|
|
9658
9855
|
if (reference) {
|
|
9659
|
-
(0,
|
|
9856
|
+
(0, import_core10.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
|
|
9660
9857
|
for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
|
|
9661
|
-
(0,
|
|
9858
|
+
(0, import_core10.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
|
|
9662
9859
|
}
|
|
9663
9860
|
} else reference = vector;
|
|
9664
9861
|
}
|
|
@@ -9751,7 +9948,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9751
9948
|
}
|
|
9752
9949
|
|
|
9753
9950
|
// src/model/gpu-vector-bindings.ts
|
|
9754
|
-
var
|
|
9951
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
9755
9952
|
var GPUVectorBindings = class {
|
|
9756
9953
|
constructor(device, id) {
|
|
9757
9954
|
this.device = device;
|
|
@@ -9776,7 +9973,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9776
9973
|
validateGPUVectorBatchStructure(columns);
|
|
9777
9974
|
} else {
|
|
9778
9975
|
for (const column of Object.values(columns)) {
|
|
9779
|
-
if (column && !isConstant(column)) (0,
|
|
9976
|
+
if (column && !isConstant(column)) (0, import_core11.assert)(column.data.length === 1);
|
|
9780
9977
|
}
|
|
9781
9978
|
}
|
|
9782
9979
|
this.claimedNames.clear();
|
|
@@ -9794,7 +9991,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9794
9991
|
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
9795
9992
|
))
|
|
9796
9993
|
return [];
|
|
9797
|
-
(0,
|
|
9994
|
+
(0, import_core11.assert)(column.format);
|
|
9798
9995
|
const format = column.format;
|
|
9799
9996
|
const byteStride = isConstant(column) ? 0 : column.byteStride;
|
|
9800
9997
|
return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
|
|
@@ -9810,10 +10007,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
9810
10007
|
);
|
|
9811
10008
|
const mode = layout?.stepMode ?? stepMode;
|
|
9812
10009
|
if (mode === "instance") {
|
|
9813
|
-
(0,
|
|
10010
|
+
(0, import_core11.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
|
|
9814
10011
|
this.instanceCount = column.length;
|
|
9815
10012
|
} else {
|
|
9816
|
-
(0,
|
|
10013
|
+
(0, import_core11.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
|
|
9817
10014
|
this.vertexCount = column.length;
|
|
9818
10015
|
}
|
|
9819
10016
|
this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
|
|
@@ -9858,7 +10055,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9858
10055
|
for (const definition of definitions) {
|
|
9859
10056
|
const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
|
|
9860
10057
|
if (!column) continue;
|
|
9861
|
-
(0,
|
|
10058
|
+
(0, import_core11.assert)(column.format === void 0 || column.format === definition.format);
|
|
9862
10059
|
if (isConstant(column)) {
|
|
9863
10060
|
this.constants[definition.attribute] = getShaderConstant(column);
|
|
9864
10061
|
constantByteLength = Math.max(
|
|
@@ -9885,7 +10082,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9885
10082
|
buffer = this.device.createBuffer({
|
|
9886
10083
|
id: `${this.id}-${layout.name}-constant`,
|
|
9887
10084
|
byteLength: bytes.byteLength,
|
|
9888
|
-
usage:
|
|
10085
|
+
usage: import_core11.Buffer.VERTEX | import_core11.Buffer.COPY_DST | import_core11.Buffer.COPY_SRC
|
|
9889
10086
|
});
|
|
9890
10087
|
this.constantBuffers[layout.name] = buffer;
|
|
9891
10088
|
}
|
|
@@ -9922,7 +10119,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9922
10119
|
const chunk = vector.data[0];
|
|
9923
10120
|
if (!chunk) return;
|
|
9924
10121
|
const byteOffset = chunk.byteOffset - layoutOffset;
|
|
9925
|
-
(0,
|
|
10122
|
+
(0, import_core11.assert)(byteOffset >= 0);
|
|
9926
10123
|
this.buffers[name] = chunk.buffer;
|
|
9927
10124
|
this.byteOffsets[name] = byteOffset;
|
|
9928
10125
|
}
|
|
@@ -9931,7 +10128,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9931
10128
|
return Boolean(column && "isConstant" in column && column.isConstant);
|
|
9932
10129
|
}
|
|
9933
10130
|
function getShaderConstant(column) {
|
|
9934
|
-
const information =
|
|
10131
|
+
const information = import_core11.vertexFormatDecoder.getVertexFormatInfo(column.format);
|
|
9935
10132
|
if (column.format === "unorm10-10-10-2") {
|
|
9936
10133
|
const word = column.value[0];
|
|
9937
10134
|
return new Float32Array([
|
|
@@ -10001,13 +10198,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
10001
10198
|
}
|
|
10002
10199
|
|
|
10003
10200
|
// src/shader-inputs.ts
|
|
10004
|
-
var
|
|
10201
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
10005
10202
|
var import_shaders2 = __toESM(require_shaders(), 1);
|
|
10006
10203
|
|
|
10007
10204
|
// src/model/split-uniforms-and-bindings.ts
|
|
10008
10205
|
function isUniformValue(value) {
|
|
10009
|
-
const
|
|
10010
|
-
return
|
|
10206
|
+
const isNumericArray2 = Array.isArray(value) ? value.length === 0 || typeof value[0] === "number" : ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
10207
|
+
return isNumericArray2 || typeof value === "number" || typeof value === "boolean";
|
|
10011
10208
|
}
|
|
10012
10209
|
function splitUniformsAndBindings(uniforms, uniformTypes2 = {}) {
|
|
10013
10210
|
const result = { bindings: {}, uniforms: {} };
|
|
@@ -10051,7 +10248,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10051
10248
|
for (const resolvedModule of resolvedModules) {
|
|
10052
10249
|
modules[resolvedModule.name] = resolvedModule;
|
|
10053
10250
|
}
|
|
10054
|
-
|
|
10251
|
+
import_core12.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
|
|
10055
10252
|
this.modules = modules;
|
|
10056
10253
|
this.moduleUniforms = {};
|
|
10057
10254
|
this.moduleBindings = {};
|
|
@@ -10059,7 +10256,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10059
10256
|
if (module) {
|
|
10060
10257
|
this._addModule(module);
|
|
10061
10258
|
if (module.name && name !== module.name && !this.options.disableWarnings) {
|
|
10062
|
-
|
|
10259
|
+
import_core12.log.warn(`Module name: ${name} vs ${module.name}`)();
|
|
10063
10260
|
}
|
|
10064
10261
|
}
|
|
10065
10262
|
}
|
|
@@ -10083,7 +10280,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10083
10280
|
const module = this.modules[moduleName];
|
|
10084
10281
|
if (!module) {
|
|
10085
10282
|
if (!this.options.disableWarnings) {
|
|
10086
|
-
|
|
10283
|
+
import_core12.log.warn(`Module ${name} not found`)();
|
|
10087
10284
|
}
|
|
10088
10285
|
} else {
|
|
10089
10286
|
const oldUniforms = this.moduleUniforms[moduleName];
|
|
@@ -10801,7 +10998,148 @@ ${getApplicationDefines(allDefines)}
|
|
|
10801
10998
|
return `${id}-${count}`;
|
|
10802
10999
|
}
|
|
10803
11000
|
|
|
11001
|
+
// ../core/src/api/utils/assert.ts
|
|
11002
|
+
function assert8(condition, message) {
|
|
11003
|
+
if (!condition) {
|
|
11004
|
+
const error = new Error(message ?? "luma.gl assertion failed.");
|
|
11005
|
+
Error.captureStackTrace?.(error, assert8);
|
|
11006
|
+
throw error;
|
|
11007
|
+
}
|
|
11008
|
+
}
|
|
11009
|
+
|
|
10804
11010
|
// ../core/src/api/adapter/resources/resource.ts
|
|
11011
|
+
var Resource = class {
|
|
11012
|
+
_owner = null;
|
|
11013
|
+
_ownedResources = /* @__PURE__ */ new Set();
|
|
11014
|
+
_state = "live";
|
|
11015
|
+
_destroyingOwnedResources = false;
|
|
11016
|
+
_destroyRequested = false;
|
|
11017
|
+
/** The resource responsible for destroying this resource, or null for caller-managed lifetime. */
|
|
11018
|
+
get owner() {
|
|
11019
|
+
return this._owner;
|
|
11020
|
+
}
|
|
11021
|
+
/** A snapshot of this resource's children. Mutating the snapshot cannot change ownership. */
|
|
11022
|
+
get ownedResources() {
|
|
11023
|
+
return Array.from(this._ownedResources);
|
|
11024
|
+
}
|
|
11025
|
+
/** Whether destruction has completed, including when cleanup reported an error. */
|
|
11026
|
+
get destroyed() {
|
|
11027
|
+
return this._state === "destroyed";
|
|
11028
|
+
}
|
|
11029
|
+
/** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
|
|
11030
|
+
transferOwnershipTo(owner) {
|
|
11031
|
+
assert8(this._state === "live" && !this._destroyingOwnedResources);
|
|
11032
|
+
assert8(!this._owner || this._owner.canChangeOwnership());
|
|
11033
|
+
assert8(!owner || owner.canChangeOwnership());
|
|
11034
|
+
for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
|
|
11035
|
+
assert8(ancestor !== this);
|
|
11036
|
+
}
|
|
11037
|
+
if (owner !== this._owner) {
|
|
11038
|
+
this._owner?._ownedResources.delete(this);
|
|
11039
|
+
this._owner = owner;
|
|
11040
|
+
owner?._ownedResources.add(this);
|
|
11041
|
+
}
|
|
11042
|
+
return this;
|
|
11043
|
+
}
|
|
11044
|
+
/** Destroy children before this resource. Subclasses implement hooks instead of overriding. */
|
|
11045
|
+
destroy() {
|
|
11046
|
+
if (this._state !== "live") {
|
|
11047
|
+
return;
|
|
11048
|
+
}
|
|
11049
|
+
if (this._destroyingOwnedResources) {
|
|
11050
|
+
this._destroyRequested = true;
|
|
11051
|
+
return;
|
|
11052
|
+
}
|
|
11053
|
+
this._destroyRequested = false;
|
|
11054
|
+
this._state = "destroying";
|
|
11055
|
+
this._owner?._ownedResources.delete(this);
|
|
11056
|
+
this._owner = null;
|
|
11057
|
+
const errors = [];
|
|
11058
|
+
try {
|
|
11059
|
+
try {
|
|
11060
|
+
this.onBeforeDestroy();
|
|
11061
|
+
} catch (error) {
|
|
11062
|
+
errors.push(error);
|
|
11063
|
+
}
|
|
11064
|
+
this.destroyChildren(errors);
|
|
11065
|
+
try {
|
|
11066
|
+
this.onDestroy();
|
|
11067
|
+
} catch (error) {
|
|
11068
|
+
errors.push(error);
|
|
11069
|
+
}
|
|
11070
|
+
} finally {
|
|
11071
|
+
this._state = "destroyed";
|
|
11072
|
+
}
|
|
11073
|
+
if (errors.length) {
|
|
11074
|
+
throw new AggregateError(errors, "Resource cleanup failed");
|
|
11075
|
+
}
|
|
11076
|
+
}
|
|
11077
|
+
/** @deprecated Use destroy(). */
|
|
11078
|
+
delete() {
|
|
11079
|
+
this.destroy();
|
|
11080
|
+
return this;
|
|
11081
|
+
}
|
|
11082
|
+
/** @deprecated Use resource.transferOwnershipTo(this). */
|
|
11083
|
+
attachResource(resource) {
|
|
11084
|
+
resource.transferOwnershipTo(this);
|
|
11085
|
+
}
|
|
11086
|
+
/** @deprecated Use resource.transferOwnershipTo(null). Only detaches a child owned by this. */
|
|
11087
|
+
detachResource(resource) {
|
|
11088
|
+
if (resource._owner === this) {
|
|
11089
|
+
resource.transferOwnershipTo(null);
|
|
11090
|
+
}
|
|
11091
|
+
}
|
|
11092
|
+
/** @deprecated Check resource.owner and call resource.destroy(). */
|
|
11093
|
+
destroyAttachedResource(resource) {
|
|
11094
|
+
if (resource._owner === this) {
|
|
11095
|
+
resource.destroy();
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11098
|
+
/** @deprecated Destroy individually owned resources, or destroy the owner. */
|
|
11099
|
+
destroyAttachedResources() {
|
|
11100
|
+
if (this._state !== "live" || this._destroyingOwnedResources) {
|
|
11101
|
+
return;
|
|
11102
|
+
}
|
|
11103
|
+
const errors = [];
|
|
11104
|
+
this.destroyChildren(errors);
|
|
11105
|
+
if (this._destroyRequested) {
|
|
11106
|
+
try {
|
|
11107
|
+
this.destroy();
|
|
11108
|
+
} catch (error) {
|
|
11109
|
+
errors.push(error);
|
|
11110
|
+
}
|
|
11111
|
+
}
|
|
11112
|
+
if (errors.length) {
|
|
11113
|
+
throw new AggregateError(errors, "Resource cleanup failed");
|
|
11114
|
+
}
|
|
11115
|
+
}
|
|
11116
|
+
/** Stop activity before children are destroyed. Errors are collected; this hook cannot veto cleanup. */
|
|
11117
|
+
onBeforeDestroy() {
|
|
11118
|
+
}
|
|
11119
|
+
/** Release this resource's own state after its children have been destroyed. */
|
|
11120
|
+
onDestroy() {
|
|
11121
|
+
}
|
|
11122
|
+
canChangeOwnership() {
|
|
11123
|
+
return this._state === "live" && !this._destroyingOwnedResources;
|
|
11124
|
+
}
|
|
11125
|
+
destroyChildren(errors) {
|
|
11126
|
+
this._destroyingOwnedResources = true;
|
|
11127
|
+
try {
|
|
11128
|
+
for (const resource of this._ownedResources) {
|
|
11129
|
+
try {
|
|
11130
|
+
resource.destroy();
|
|
11131
|
+
} catch (error) {
|
|
11132
|
+
errors.push(error);
|
|
11133
|
+
}
|
|
11134
|
+
}
|
|
11135
|
+
} finally {
|
|
11136
|
+
this._ownedResources.clear();
|
|
11137
|
+
this._destroyingOwnedResources = false;
|
|
11138
|
+
}
|
|
11139
|
+
}
|
|
11140
|
+
};
|
|
11141
|
+
|
|
11142
|
+
// ../core/src/api/adapter/resources/device-resource.ts
|
|
10805
11143
|
var CPU_HOTSPOT_PROFILER_MODULE = "cpu-hotspot-profiler";
|
|
10806
11144
|
var RESOURCE_COUNTS_STATS = "GPU Resource Counts";
|
|
10807
11145
|
var LEGACY_RESOURCE_COUNTS_STATS = "Resource Counts";
|
|
@@ -10857,7 +11195,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10857
11195
|
]);
|
|
10858
11196
|
var ORDERED_STATS_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10859
11197
|
var ORDERED_STAT_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10860
|
-
var
|
|
11198
|
+
var DeviceResource = class extends Resource {
|
|
10861
11199
|
/** Default properties for resource */
|
|
10862
11200
|
static defaultProps = {
|
|
10863
11201
|
id: "undefined",
|
|
@@ -10880,14 +11218,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
10880
11218
|
userData = {};
|
|
10881
11219
|
/** The device that this resource is associated with - TODO can we remove this dup? */
|
|
10882
11220
|
_device;
|
|
10883
|
-
/** Whether this resource has been destroyed */
|
|
10884
|
-
destroyed = false;
|
|
10885
11221
|
/** For resources that allocate GPU memory */
|
|
10886
11222
|
allocatedBytes = 0;
|
|
10887
11223
|
/** Stats bucket currently holding the tracked allocation */
|
|
10888
11224
|
allocatedBytesName = null;
|
|
10889
|
-
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
10890
|
-
_attachedResources = /* @__PURE__ */ new Set();
|
|
10891
11225
|
/** Whether luma.gl created and owns the underlying resource handle. */
|
|
10892
11226
|
get ownsHandle() {
|
|
10893
11227
|
return (this.props.handle === void 0 || this.props.handle === null) && !this.isHandleBorrowed;
|
|
@@ -10897,9 +11231,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
10897
11231
|
return Boolean(this.props._isHandleBorrowed);
|
|
10898
11232
|
}
|
|
10899
11233
|
/**
|
|
10900
|
-
* Create a new
|
|
11234
|
+
* Create a new DeviceResource. Called from Subclass
|
|
10901
11235
|
*/
|
|
10902
11236
|
constructor(device, props, defaultProps) {
|
|
11237
|
+
super();
|
|
10903
11238
|
if (!device) {
|
|
10904
11239
|
throw new Error("no device");
|
|
10905
11240
|
}
|
|
@@ -10911,20 +11246,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
10911
11246
|
this.userData = this.props.userData || {};
|
|
10912
11247
|
this.addStats();
|
|
10913
11248
|
}
|
|
10914
|
-
/**
|
|
10915
|
-
* destroy can be called on any resource to release it before it is garbage collected.
|
|
10916
|
-
*/
|
|
10917
|
-
destroy() {
|
|
10918
|
-
if (this.destroyed) {
|
|
10919
|
-
return;
|
|
10920
|
-
}
|
|
10921
|
-
this.destroyResource();
|
|
10922
|
-
}
|
|
10923
|
-
/** @deprecated Use destroy() */
|
|
10924
|
-
delete() {
|
|
10925
|
-
this.destroy();
|
|
10926
|
-
return this;
|
|
10927
|
-
}
|
|
10928
11249
|
/**
|
|
10929
11250
|
* Combines a map of user props and default props, only including props from defaultProps
|
|
10930
11251
|
* @returns returns a map of overridden default props
|
|
@@ -10932,46 +11253,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
10932
11253
|
getProps() {
|
|
10933
11254
|
return this.props;
|
|
10934
11255
|
}
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
* Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
|
|
10938
|
-
* Called automatically when sub resources are auto created but can be called by application
|
|
10939
|
-
*/
|
|
10940
|
-
attachResource(resource) {
|
|
10941
|
-
this._attachedResources.add(resource);
|
|
10942
|
-
}
|
|
10943
|
-
/**
|
|
10944
|
-
* Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
|
|
10945
|
-
*/
|
|
10946
|
-
detachResource(resource) {
|
|
10947
|
-
this._attachedResources.delete(resource);
|
|
10948
|
-
}
|
|
10949
|
-
/**
|
|
10950
|
-
* Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
|
|
10951
|
-
*/
|
|
10952
|
-
destroyAttachedResource(resource) {
|
|
10953
|
-
if (this._attachedResources.delete(resource)) {
|
|
10954
|
-
resource.destroy();
|
|
10955
|
-
}
|
|
10956
|
-
}
|
|
10957
|
-
/** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
|
|
10958
|
-
destroyAttachedResources() {
|
|
10959
|
-
for (const resource of this._attachedResources) {
|
|
10960
|
-
resource.destroy();
|
|
10961
|
-
}
|
|
10962
|
-
this._attachedResources = /* @__PURE__ */ new Set();
|
|
11256
|
+
/** Backend cleanup. Override this instead of destroy(); children are already destroyed. */
|
|
11257
|
+
destroyHandle() {
|
|
10963
11258
|
}
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
11259
|
+
/** Complete device bookkeeping even when backend cleanup fails. */
|
|
11260
|
+
onDestroy() {
|
|
11261
|
+
try {
|
|
11262
|
+
this.destroyHandle();
|
|
11263
|
+
} finally {
|
|
11264
|
+
this.trackDeallocatedMemory();
|
|
11265
|
+
this.removeStats();
|
|
10969
11266
|
}
|
|
10970
|
-
this.destroyAttachedResources();
|
|
10971
|
-
this.removeStats();
|
|
10972
|
-
this.destroyed = true;
|
|
10973
11267
|
}
|
|
10974
|
-
/**
|
|
11268
|
+
/** Track object destruction after backend cleanup. */
|
|
10975
11269
|
removeStats() {
|
|
10976
11270
|
const profiler = getCpuHotspotProfiler(this._device);
|
|
10977
11271
|
const startTime = profiler ? getTimestamp() : 0;
|
|
@@ -11149,7 +11443,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11149
11443
|
let prototype = Object.getPrototypeOf(resource);
|
|
11150
11444
|
while (prototype) {
|
|
11151
11445
|
const parentPrototype = Object.getPrototypeOf(prototype);
|
|
11152
|
-
if (!parentPrototype || parentPrototype ===
|
|
11446
|
+
if (!parentPrototype || parentPrototype === DeviceResource.prototype) {
|
|
11153
11447
|
return getPrototypeToStringTag(prototype) || resource[Symbol.toStringTag] || resource.constructor.name;
|
|
11154
11448
|
}
|
|
11155
11449
|
prototype = parentPrototype;
|
|
@@ -11168,7 +11462,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11168
11462
|
}
|
|
11169
11463
|
|
|
11170
11464
|
// ../core/src/api/adapter/resources/buffer.ts
|
|
11171
|
-
var Buffer4 = class _Buffer extends
|
|
11465
|
+
var Buffer4 = class _Buffer extends DeviceResource {
|
|
11172
11466
|
/** Index buffer */
|
|
11173
11467
|
static INDEX = 16;
|
|
11174
11468
|
/** Vertex buffer */
|
|
@@ -11249,7 +11543,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11249
11543
|
}
|
|
11250
11544
|
}
|
|
11251
11545
|
static defaultProps = {
|
|
11252
|
-
...
|
|
11546
|
+
...DeviceResource.defaultProps,
|
|
11253
11547
|
handle: void 0,
|
|
11254
11548
|
usage: 0,
|
|
11255
11549
|
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
@@ -11271,7 +11565,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
11271
11565
|
}
|
|
11272
11566
|
|
|
11273
11567
|
// ../core/src/shadertypes/data-types/decode-data-types.ts
|
|
11568
|
+
var dataTypeInfoCache = /* @__PURE__ */ new Map();
|
|
11274
11569
|
function getDataTypeInfo(type) {
|
|
11570
|
+
const cached = dataTypeInfoCache.get(type);
|
|
11571
|
+
if (cached) {
|
|
11572
|
+
return cached;
|
|
11573
|
+
}
|
|
11574
|
+
const decoded = Object.freeze(decodeDataTypeInfo(type));
|
|
11575
|
+
if (Object.hasOwn(NORMALIZED_TYPE_MAP, type)) {
|
|
11576
|
+
dataTypeInfoCache.set(type, decoded);
|
|
11577
|
+
}
|
|
11578
|
+
return decoded;
|
|
11579
|
+
}
|
|
11580
|
+
function decodeDataTypeInfo(type) {
|
|
11275
11581
|
const normalized2 = type.includes("norm");
|
|
11276
11582
|
const integer = !normalized2 && !type.startsWith("float");
|
|
11277
11583
|
const signed = type.startsWith("s");
|
|
@@ -11612,40 +11918,33 @@ ${getApplicationDefines(allDefines)}
|
|
|
11612
11918
|
return this.isCompressed(format) && !format.endsWith("-webgl") ? WEBGPU_CREATE_FILTER2 : 0;
|
|
11613
11919
|
}
|
|
11614
11920
|
/** Computes the memory layout for a texture, in particular including row byte alignment */
|
|
11615
|
-
computeMemoryLayout(opts) {
|
|
11616
|
-
return computeTextureMemoryLayout(opts);
|
|
11921
|
+
computeMemoryLayout(opts, result) {
|
|
11922
|
+
return computeTextureMemoryLayout(opts, result);
|
|
11617
11923
|
}
|
|
11618
11924
|
};
|
|
11619
11925
|
var textureFormatDecoder = new TextureFormatDecoder();
|
|
11620
|
-
function computeTextureMemoryLayout({
|
|
11621
|
-
format,
|
|
11622
|
-
width,
|
|
11623
|
-
height,
|
|
11624
|
-
depth,
|
|
11625
|
-
byteAlignment
|
|
11626
|
-
}) {
|
|
11926
|
+
function computeTextureMemoryLayout({ format, width, height, depth, byteAlignment }, result = {}) {
|
|
11627
11927
|
const formatInfo = textureFormatDecoder.getInfo(format);
|
|
11928
|
+
const { bytesPerPixel, blockHeight = 1, compressed = false } = formatInfo;
|
|
11929
|
+
const bytesPerRow = getTextureBytesPerRow(formatInfo, width, byteAlignment);
|
|
11930
|
+
const rowsPerImage = compressed ? Math.ceil(height / blockHeight) : height;
|
|
11931
|
+
result.bytesPerPixel = bytesPerPixel;
|
|
11932
|
+
result.bytesPerRow = bytesPerRow;
|
|
11933
|
+
result.rowsPerImage = rowsPerImage;
|
|
11934
|
+
result.depthOrArrayLayers = depth;
|
|
11935
|
+
result.bytesPerImage = bytesPerRow * rowsPerImage;
|
|
11936
|
+
result.byteLength = result.bytesPerImage * depth;
|
|
11937
|
+
return result;
|
|
11938
|
+
}
|
|
11939
|
+
function getTextureBytesPerRow(formatInfo, width, byteAlignment) {
|
|
11628
11940
|
const {
|
|
11629
11941
|
bytesPerPixel,
|
|
11630
11942
|
bytesPerBlock = bytesPerPixel,
|
|
11631
11943
|
blockWidth = 1,
|
|
11632
|
-
blockHeight = 1,
|
|
11633
11944
|
compressed = false
|
|
11634
11945
|
} = formatInfo;
|
|
11635
11946
|
const blockColumns = compressed ? Math.ceil(width / blockWidth) : width;
|
|
11636
|
-
|
|
11637
|
-
const unpaddedBytesPerRow = blockColumns * bytesPerBlock;
|
|
11638
|
-
const bytesPerRow = Math.ceil(unpaddedBytesPerRow / byteAlignment) * byteAlignment;
|
|
11639
|
-
const rowsPerImage = blockRows;
|
|
11640
|
-
const byteLength = bytesPerRow * rowsPerImage * depth;
|
|
11641
|
-
return {
|
|
11642
|
-
bytesPerPixel,
|
|
11643
|
-
bytesPerRow,
|
|
11644
|
-
rowsPerImage,
|
|
11645
|
-
depthOrArrayLayers: depth,
|
|
11646
|
-
bytesPerImage: bytesPerRow * rowsPerImage,
|
|
11647
|
-
byteLength
|
|
11648
|
-
};
|
|
11947
|
+
return Math.ceil(blockColumns * bytesPerBlock / byteAlignment) * byteAlignment;
|
|
11649
11948
|
}
|
|
11650
11949
|
function getTextureFormatCapabilities(format) {
|
|
11651
11950
|
const info = getTextureFormatDefinition(format);
|
|
@@ -11667,7 +11966,18 @@ ${getApplicationDefines(allDefines)}
|
|
|
11667
11966
|
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
11668
11967
|
return formatCapabilities;
|
|
11669
11968
|
}
|
|
11969
|
+
var textureFormatInfoCache = /* @__PURE__ */ new Map();
|
|
11670
11970
|
function getTextureFormatInfo(format) {
|
|
11971
|
+
let formatInfo = textureFormatInfoCache.get(format);
|
|
11972
|
+
if (!formatInfo) {
|
|
11973
|
+
const decoded = decodeTextureFormatInfo(format);
|
|
11974
|
+
decoded.bitsPerChannel = Object.freeze([...decoded.bitsPerChannel]);
|
|
11975
|
+
formatInfo = Object.freeze(decoded);
|
|
11976
|
+
textureFormatInfoCache.set(format, formatInfo);
|
|
11977
|
+
}
|
|
11978
|
+
return formatInfo;
|
|
11979
|
+
}
|
|
11980
|
+
function decodeTextureFormatInfo(format) {
|
|
11671
11981
|
let formatInfo = getTextureFormatInfoUsingTable(format);
|
|
11672
11982
|
if (textureFormatDecoder.isCompressed(format)) {
|
|
11673
11983
|
formatInfo.channels = "rgb";
|
|
@@ -11807,9 +12117,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
11807
12117
|
}
|
|
11808
12118
|
|
|
11809
12119
|
// ../core/src/api/adapter/resources/sampler.ts
|
|
11810
|
-
var Sampler = class _Sampler extends
|
|
12120
|
+
var Sampler = class _Sampler extends DeviceResource {
|
|
11811
12121
|
static defaultProps = {
|
|
11812
|
-
...
|
|
12122
|
+
...DeviceResource.defaultProps,
|
|
11813
12123
|
type: "color-sampler",
|
|
11814
12124
|
addressModeU: "clamp-to-edge",
|
|
11815
12125
|
addressModeV: "clamp-to-edge",
|
|
@@ -11834,8 +12144,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
11834
12144
|
return props;
|
|
11835
12145
|
}
|
|
11836
12146
|
};
|
|
12147
|
+
function setTextureSampler(texture, sampler) {
|
|
12148
|
+
const nextSampler = sampler instanceof Sampler ? sampler : texture.device.createSampler(sampler);
|
|
12149
|
+
if (nextSampler === texture.sampler) {
|
|
12150
|
+
return;
|
|
12151
|
+
}
|
|
12152
|
+
if (!(sampler instanceof Sampler)) {
|
|
12153
|
+
nextSampler.transferOwnershipTo(texture);
|
|
12154
|
+
}
|
|
12155
|
+
const previousSampler = texture.sampler;
|
|
12156
|
+
texture.sampler = nextSampler;
|
|
12157
|
+
if (previousSampler?.owner === texture) {
|
|
12158
|
+
previousSampler.destroy();
|
|
12159
|
+
}
|
|
12160
|
+
}
|
|
11837
12161
|
|
|
11838
12162
|
// ../core/src/api/adapter/resources/texture.ts
|
|
12163
|
+
var textureLayoutScratchPool = [];
|
|
12164
|
+
var emptyTextureReadOptions = Object.freeze({});
|
|
11839
12165
|
var BASE_DIMENSIONS = {
|
|
11840
12166
|
"1d": "1d",
|
|
11841
12167
|
"2d": "2d",
|
|
@@ -11844,7 +12170,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11844
12170
|
"cube-array": "2d",
|
|
11845
12171
|
"3d": "3d"
|
|
11846
12172
|
};
|
|
11847
|
-
var Texture = class _Texture extends
|
|
12173
|
+
var Texture = class _Texture extends DeviceResource {
|
|
11848
12174
|
/** The texture can be bound for use as a sampled texture in a shader */
|
|
11849
12175
|
static SAMPLE = 4;
|
|
11850
12176
|
/** The texture can be bound for use as a storage texture in a shader */
|
|
@@ -11932,7 +12258,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11932
12258
|
}
|
|
11933
12259
|
/** Set sampler props associated with this texture */
|
|
11934
12260
|
setSampler(sampler) {
|
|
11935
|
-
this
|
|
12261
|
+
setTextureSampler(this, sampler);
|
|
11936
12262
|
}
|
|
11937
12263
|
/**
|
|
11938
12264
|
* Copy raw image data (bytes) into the texture.
|
|
@@ -11954,17 +12280,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
11954
12280
|
* Calculates the memory layout of the texture, required when reading and writing data.
|
|
11955
12281
|
* @return the backend-aligned linear layout, in particular bytesPerRow which includes any required padding for buffer copy/read paths
|
|
11956
12282
|
*/
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
const
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
12283
|
+
/** The optional result is caller-owned; internal scratch never escapes this call. */
|
|
12284
|
+
computeMemoryLayout(options_ = emptyTextureReadOptions, result) {
|
|
12285
|
+
const scratch = textureLayoutScratchPool.pop() || {
|
|
12286
|
+
readOptions: {},
|
|
12287
|
+
layoutOptions: {}
|
|
12288
|
+
};
|
|
12289
|
+
try {
|
|
12290
|
+
const options = this._normalizeTextureReadOptions(options_, scratch.readOptions);
|
|
12291
|
+
const layoutOptions = scratch.layoutOptions;
|
|
12292
|
+
layoutOptions.format = this.format;
|
|
12293
|
+
layoutOptions.width = options.width;
|
|
12294
|
+
layoutOptions.height = options.height;
|
|
12295
|
+
layoutOptions.depth = options.depthOrArrayLayers;
|
|
12296
|
+
layoutOptions.byteAlignment = this.byteAlignment;
|
|
12297
|
+
return textureFormatDecoder.computeMemoryLayout(layoutOptions, result);
|
|
12298
|
+
} finally {
|
|
12299
|
+
textureLayoutScratchPool.push(scratch);
|
|
12300
|
+
}
|
|
11968
12301
|
}
|
|
11969
12302
|
/**
|
|
11970
12303
|
* Read the contents of a texture into a GPU Buffer.
|
|
@@ -12073,59 +12406,57 @@ ${getApplicationDefines(allDefines)}
|
|
|
12073
12406
|
});
|
|
12074
12407
|
}
|
|
12075
12408
|
}
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
const
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12409
|
+
/** The optional result is caller-owned scratch storage; every result field is overwritten. */
|
|
12410
|
+
_normalizeCopyImageDataOptions(options_, result = {}) {
|
|
12411
|
+
const { data, depth, depthOrArrayLayers } = options_;
|
|
12412
|
+
this._normalizeTextureWriteOptions(options_, result);
|
|
12413
|
+
if (depthOrArrayLayers === void 0 && depth !== void 0) {
|
|
12414
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> result.mipLevel) : this.depth;
|
|
12415
|
+
result.depthOrArrayLayers = Math.min(depth, mipDepth - result.z);
|
|
12416
|
+
}
|
|
12417
|
+
result.data = data;
|
|
12418
|
+
result.depth = result.depthOrArrayLayers;
|
|
12419
|
+
return result;
|
|
12083
12420
|
}
|
|
12084
|
-
_normalizeCopyExternalImageOptions(options_) {
|
|
12085
|
-
const
|
|
12086
|
-
const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
|
|
12087
|
-
const mipLevelSize = this._getMipLevelSize(mipLevel);
|
|
12421
|
+
_normalizeCopyExternalImageOptions(options_, result = {}) {
|
|
12422
|
+
const { width, height } = options_;
|
|
12088
12423
|
const size = this.device.getExternalImageSize(options_.image);
|
|
12089
|
-
const options =
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
options.
|
|
12424
|
+
const options = _Texture._normalizeOptions(
|
|
12425
|
+
options_,
|
|
12426
|
+
_Texture.defaultCopyExternalImageOptions,
|
|
12427
|
+
result
|
|
12428
|
+
);
|
|
12429
|
+
const mipWidth = Math.max(1, this.width >> options.mipLevel);
|
|
12430
|
+
const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
|
|
12431
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
|
|
12432
|
+
options.width = Math.min(width ?? size.width, mipWidth - options.x);
|
|
12433
|
+
options.height = Math.min(height ?? size.height, mipHeight - options.y);
|
|
12434
|
+
options.depth = Math.min(options.depth, mipDepth - options.z);
|
|
12098
12435
|
return options;
|
|
12099
12436
|
}
|
|
12100
|
-
_normalizeCopyElementImageOptions(options_) {
|
|
12101
|
-
const
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
|
|
12109
|
-
options.width = Math.min(options.width,
|
|
12110
|
-
options.height = Math.min(options.height,
|
|
12111
|
-
options.depth = Math.min(options.depth,
|
|
12437
|
+
_normalizeCopyElementImageOptions(options_, result = {}) {
|
|
12438
|
+
const options = _Texture._normalizeOptions(
|
|
12439
|
+
options_,
|
|
12440
|
+
_Texture.defaultCopyElementImageOptions,
|
|
12441
|
+
result
|
|
12442
|
+
);
|
|
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.depth = Math.min(options.depth, mipDepth - options.z);
|
|
12112
12449
|
return options;
|
|
12113
12450
|
}
|
|
12114
|
-
_normalizeTextureReadOptions(options_) {
|
|
12115
|
-
const
|
|
12116
|
-
const
|
|
12117
|
-
const
|
|
12118
|
-
const
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
options.width = Math.min(options.width, mipLevelSize.width - options.x);
|
|
12124
|
-
options.height = Math.min(options.height, mipLevelSize.height - options.y);
|
|
12125
|
-
options.depthOrArrayLayers = Math.min(
|
|
12126
|
-
options.depthOrArrayLayers,
|
|
12127
|
-
mipLevelSize.depthOrArrayLayers - options.z
|
|
12128
|
-
);
|
|
12451
|
+
_normalizeTextureReadOptions(options_, result = {}) {
|
|
12452
|
+
const { depthOrArrayLayers } = options_;
|
|
12453
|
+
const options = _Texture._normalizeOptions(options_, _Texture.defaultTextureReadOptions, result);
|
|
12454
|
+
const mipWidth = Math.max(1, this.width >> options.mipLevel);
|
|
12455
|
+
const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
|
|
12456
|
+
const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
|
|
12457
|
+
options.width = Math.min(options.width ?? mipWidth, mipWidth - options.x);
|
|
12458
|
+
options.height = Math.min(options.height ?? mipHeight, mipHeight - options.y);
|
|
12459
|
+
options.depthOrArrayLayers = Math.min(depthOrArrayLayers ?? mipDepth, mipDepth - options.z);
|
|
12129
12460
|
return options;
|
|
12130
12461
|
}
|
|
12131
12462
|
/**
|
|
@@ -12180,31 +12511,15 @@ ${getApplicationDefines(allDefines)}
|
|
|
12180
12511
|
throw new Error(`${this} color readback does not support format ${this.format}`);
|
|
12181
12512
|
}
|
|
12182
12513
|
}
|
|
12183
|
-
_normalizeTextureWriteOptions(options_) {
|
|
12184
|
-
const
|
|
12185
|
-
|
|
12186
|
-
const
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
options.width = Math.min(options.width, mipLevelSize.width - options.x);
|
|
12193
|
-
options.height = Math.min(options.height, mipLevelSize.height - options.y);
|
|
12194
|
-
options.depthOrArrayLayers = Math.min(
|
|
12195
|
-
options.depthOrArrayLayers,
|
|
12196
|
-
mipLevelSize.depthOrArrayLayers - options.z
|
|
12197
|
-
);
|
|
12198
|
-
const layout = textureFormatDecoder.computeMemoryLayout({
|
|
12199
|
-
format: this.format,
|
|
12200
|
-
width: options.width,
|
|
12201
|
-
height: options.height,
|
|
12202
|
-
depth: options.depthOrArrayLayers,
|
|
12203
|
-
byteAlignment: this.byteAlignment
|
|
12204
|
-
});
|
|
12205
|
-
const minimumBytesPerRow = layout.bytesPerPixel * options.width;
|
|
12206
|
-
options.bytesPerRow = optionsWithoutUndefined.bytesPerRow ?? layout.bytesPerRow;
|
|
12207
|
-
options.rowsPerImage = optionsWithoutUndefined.rowsPerImage ?? options.height;
|
|
12514
|
+
_normalizeTextureWriteOptions(options_, result = {}) {
|
|
12515
|
+
const { byteOffset = 0, bytesPerRow, rowsPerImage } = options_;
|
|
12516
|
+
this._normalizeTextureReadOptions(options_, result);
|
|
12517
|
+
const options = result;
|
|
12518
|
+
options.byteOffset = byteOffset;
|
|
12519
|
+
const formatInfo = this.device.getTextureFormatInfo(this.format);
|
|
12520
|
+
const minimumBytesPerRow = formatInfo.bytesPerPixel * options.width;
|
|
12521
|
+
options.bytesPerRow = bytesPerRow ?? getTextureBytesPerRow(formatInfo, options.width, this.byteAlignment);
|
|
12522
|
+
options.rowsPerImage = rowsPerImage ?? options.height;
|
|
12208
12523
|
if (options.bytesPerRow < minimumBytesPerRow) {
|
|
12209
12524
|
throw new Error(
|
|
12210
12525
|
`bytesPerRow (${options.bytesPerRow}) must be at least ${minimumBytesPerRow} for ${this.format}`
|
|
@@ -12215,7 +12530,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12215
12530
|
`rowsPerImage (${options.rowsPerImage}) must be at least ${options.height} for ${this.format}`
|
|
12216
12531
|
);
|
|
12217
12532
|
}
|
|
12218
|
-
const bytesPerPixel =
|
|
12533
|
+
const { bytesPerPixel } = formatInfo;
|
|
12219
12534
|
if (bytesPerPixel && options.bytesPerRow % bytesPerPixel !== 0) {
|
|
12220
12535
|
throw new Error(
|
|
12221
12536
|
`bytesPerRow (${options.bytesPerRow}) must be a multiple of bytesPerPixel (${bytesPerPixel}) for ${this.format}`
|
|
@@ -12243,13 +12558,15 @@ ${getApplicationDefines(allDefines)}
|
|
|
12243
12558
|
}
|
|
12244
12559
|
return allocatedByteLength * this.samples;
|
|
12245
12560
|
}
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12561
|
+
/** Fill every declared field, resetting stale scratch values without allocating entries or spreads. */
|
|
12562
|
+
static _normalizeOptions(options, defaults, result) {
|
|
12563
|
+
for (const key in defaults) {
|
|
12564
|
+
result[key] = options[key] === void 0 ? defaults[key] : options[key];
|
|
12565
|
+
}
|
|
12566
|
+
return result;
|
|
12250
12567
|
}
|
|
12251
12568
|
static defaultProps = {
|
|
12252
|
-
...
|
|
12569
|
+
...DeviceResource.defaultProps,
|
|
12253
12570
|
data: null,
|
|
12254
12571
|
dimension: "2d",
|
|
12255
12572
|
format: "rgba8unorm",
|
|
@@ -12323,19 +12640,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
12323
12640
|
mipLevel: 0,
|
|
12324
12641
|
aspect: "all"
|
|
12325
12642
|
};
|
|
12326
|
-
static defaultTextureWriteOptions = {
|
|
12327
|
-
byteOffset: 0,
|
|
12328
|
-
bytesPerRow: void 0,
|
|
12329
|
-
rowsPerImage: void 0,
|
|
12330
|
-
x: 0,
|
|
12331
|
-
y: 0,
|
|
12332
|
-
z: 0,
|
|
12333
|
-
width: void 0,
|
|
12334
|
-
height: void 0,
|
|
12335
|
-
depthOrArrayLayers: 1,
|
|
12336
|
-
mipLevel: 0,
|
|
12337
|
-
aspect: "all"
|
|
12338
|
-
};
|
|
12339
12643
|
};
|
|
12340
12644
|
|
|
12341
12645
|
// ../core/src/api/adapter-utils/bind-groups.ts
|
|
@@ -13351,13 +13655,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
13351
13655
|
var GPUVectorModel = class _GPUVectorModel {
|
|
13352
13656
|
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
13353
13657
|
static async createAsync(device, props) {
|
|
13354
|
-
const ownsCompilation = !
|
|
13355
|
-
const asyncCompilation = ownsCompilation ?
|
|
13658
|
+
const ownsCompilation = !import_core13.PipelineFactory.getAsyncCompilation(device);
|
|
13659
|
+
const asyncCompilation = ownsCompilation ? import_core13.PipelineFactory.beginAsyncCompilation(device) : import_core13.PipelineFactory.getAsyncCompilation(device);
|
|
13356
13660
|
let model;
|
|
13357
13661
|
try {
|
|
13358
13662
|
model = new this(device, props);
|
|
13359
13663
|
} finally {
|
|
13360
|
-
if (ownsCompilation)
|
|
13664
|
+
if (ownsCompilation) import_core13.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
13361
13665
|
}
|
|
13362
13666
|
try {
|
|
13363
13667
|
if (ownsCompilation) {
|
|
@@ -13372,7 +13676,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13372
13676
|
}
|
|
13373
13677
|
}
|
|
13374
13678
|
static defaultProps = {
|
|
13375
|
-
...
|
|
13679
|
+
...import_core13.RenderPipeline.defaultProps,
|
|
13376
13680
|
inferDrawCount: "no",
|
|
13377
13681
|
enforceMatchingVectorLengths: true,
|
|
13378
13682
|
geometry: null,
|
|
@@ -13556,7 +13860,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13556
13860
|
const isWebGPU = this.device.type === "webgpu";
|
|
13557
13861
|
if (isWebGPU && this.props.source) {
|
|
13558
13862
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13559
|
-
(0,
|
|
13863
|
+
(0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
13560
13864
|
const {
|
|
13561
13865
|
source: source4,
|
|
13562
13866
|
getUniforms: getUniforms2,
|
|
@@ -13568,7 +13872,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13568
13872
|
...this.props,
|
|
13569
13873
|
modules,
|
|
13570
13874
|
defines,
|
|
13571
|
-
|
|
13875
|
+
pluginInjectionTargets: resolvedPlugins.injectionTargets,
|
|
13572
13876
|
pluginInjections: resolvedPlugins.injections,
|
|
13573
13877
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13574
13878
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13593,13 +13897,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
13593
13897
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
13594
13898
|
} else {
|
|
13595
13899
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13596
|
-
(0,
|
|
13900
|
+
(0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
|
|
13597
13901
|
const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
|
|
13598
13902
|
platformInfo,
|
|
13599
13903
|
...this.props,
|
|
13600
13904
|
modules,
|
|
13601
13905
|
defines,
|
|
13602
|
-
|
|
13906
|
+
pluginInjectionTargets: resolvedPlugins.injectionTargets,
|
|
13603
13907
|
pluginInjections: resolvedPlugins.injections,
|
|
13604
13908
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13605
13909
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13609,9 +13913,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13609
13913
|
this._getModuleUniforms = getUniforms2;
|
|
13610
13914
|
this._bindingTable = [];
|
|
13611
13915
|
}
|
|
13612
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
13613
|
-
this.shaderFactory = props.shaderFactory ||
|
|
13614
|
-
const asyncCompilation =
|
|
13916
|
+
this.pipelineFactory = props.pipelineFactory || import_core13.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
13917
|
+
this.shaderFactory = props.shaderFactory || import_core13.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
13918
|
+
const asyncCompilation = import_core13.PipelineFactory.getAsyncCompilation(this.device);
|
|
13615
13919
|
if (asyncCompilation) {
|
|
13616
13920
|
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
13617
13921
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -13717,9 +14021,26 @@ ${getApplicationDefines(allDefines)}
|
|
|
13717
14021
|
/**
|
|
13718
14022
|
* Issue one draw call.
|
|
13719
14023
|
* @param renderPass - render pass to draw into
|
|
14024
|
+
* @param options - Optional dynamic parameters restored after drawing, including on errors.
|
|
13720
14025
|
* @returns `true` if the draw call was executed, `false` if resources were not ready.
|
|
13721
14026
|
*/
|
|
13722
|
-
draw(renderPass) {
|
|
14027
|
+
draw(renderPass, options) {
|
|
14028
|
+
if (options?.parameters) {
|
|
14029
|
+
return this._withDrawParameters(renderPass, options.parameters, () => this._draw(renderPass));
|
|
14030
|
+
}
|
|
14031
|
+
return this._draw(renderPass);
|
|
14032
|
+
}
|
|
14033
|
+
/** Applies draw overrides around the complete model batch, including failure paths. */
|
|
14034
|
+
_withDrawParameters(renderPass, parameters, draw) {
|
|
14035
|
+
const state = renderPass.getParameters();
|
|
14036
|
+
try {
|
|
14037
|
+
renderPass.setParameters(parameters);
|
|
14038
|
+
return draw();
|
|
14039
|
+
} finally {
|
|
14040
|
+
renderPass.setParameters(state);
|
|
14041
|
+
}
|
|
14042
|
+
}
|
|
14043
|
+
_draw(renderPass) {
|
|
13723
14044
|
if (this.indexVector?.length === 0) {
|
|
13724
14045
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
13725
14046
|
this._needsRedraw = false;
|
|
@@ -13729,12 +14050,12 @@ ${getApplicationDefines(allDefines)}
|
|
|
13729
14050
|
return this.drawVectorGroups(renderPass);
|
|
13730
14051
|
}
|
|
13731
14052
|
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
13732
|
-
|
|
14053
|
+
import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
13733
14054
|
return false;
|
|
13734
14055
|
}
|
|
13735
14056
|
const loadingBinding = this._areBindingsLoading();
|
|
13736
14057
|
if (loadingBinding) {
|
|
13737
|
-
|
|
14058
|
+
import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
13738
14059
|
return false;
|
|
13739
14060
|
}
|
|
13740
14061
|
this._syncAttachmentFormats(renderPass);
|
|
@@ -13758,7 +14079,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13758
14079
|
this.pipeline = this._updatePipeline();
|
|
13759
14080
|
pipelineErrored = this.pipeline.isErrored;
|
|
13760
14081
|
if (pipelineErrored) {
|
|
13761
|
-
|
|
14082
|
+
import_core13.log.info(
|
|
13762
14083
|
LOG_DRAW_PRIORITY,
|
|
13763
14084
|
`>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
|
|
13764
14085
|
)();
|
|
@@ -13766,7 +14087,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13766
14087
|
} else {
|
|
13767
14088
|
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
13768
14089
|
if (drawValidationError) {
|
|
13769
|
-
|
|
14090
|
+
import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
13770
14091
|
this._drawBlockedReason = drawValidationError;
|
|
13771
14092
|
drawSuccess = false;
|
|
13772
14093
|
} else {
|
|
@@ -13841,7 +14162,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13841
14162
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
13842
14163
|
this.syncVectorBindings();
|
|
13843
14164
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
13844
|
-
(0,
|
|
14165
|
+
(0, import_core13.assert)(
|
|
13845
14166
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
13846
14167
|
);
|
|
13847
14168
|
if (this.props.inferDrawCount === "vertex")
|
|
@@ -13878,7 +14199,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13878
14199
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
13879
14200
|
if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
|
|
13880
14201
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
13881
|
-
(0,
|
|
14202
|
+
(0, import_core13.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
13882
14203
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
13883
14204
|
}
|
|
13884
14205
|
}
|
|
@@ -13889,9 +14210,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13889
14210
|
/** Replaces the borrowed contiguous uint16/uint32 index vector. */
|
|
13890
14211
|
setIndexVector(vector) {
|
|
13891
14212
|
if (vector) {
|
|
13892
|
-
(0,
|
|
13893
|
-
(0,
|
|
13894
|
-
(0,
|
|
14213
|
+
(0, import_core13.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
|
|
14214
|
+
(0, import_core13.assert)(vector.data.length <= 1);
|
|
14215
|
+
(0, import_core13.assert)(
|
|
13895
14216
|
vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
|
|
13896
14217
|
);
|
|
13897
14218
|
}
|
|
@@ -13903,7 +14224,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13903
14224
|
const chunk = vector?.data[0];
|
|
13904
14225
|
if (chunk && this.indexVector) {
|
|
13905
14226
|
const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
|
|
13906
|
-
(0,
|
|
14227
|
+
(0, import_core13.assert)(
|
|
13907
14228
|
buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
|
|
13908
14229
|
);
|
|
13909
14230
|
}
|
|
@@ -13977,7 +14298,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13977
14298
|
/** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
|
|
13978
14299
|
setGPUVectors(vectors, options) {
|
|
13979
14300
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
13980
|
-
(0,
|
|
14301
|
+
(0, import_core13.assert)(batches.length <= 1);
|
|
13981
14302
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
13982
14303
|
if (batches[0]) this.setGPUData(batches[0].data);
|
|
13983
14304
|
this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
|
|
@@ -14016,7 +14337,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14016
14337
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
14017
14338
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
14018
14339
|
for (const name of Object.keys(vectors)) {
|
|
14019
|
-
(0,
|
|
14340
|
+
(0, import_core13.assert)(!vectors[name] || this.currentAttributes[name]);
|
|
14020
14341
|
}
|
|
14021
14342
|
const previousAttributes = { ...this.currentAttributes };
|
|
14022
14343
|
const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
|
|
@@ -14026,7 +14347,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14026
14347
|
const previousIsInstanced = this.isInstanced;
|
|
14027
14348
|
const previousVertexCountSet = this._vertexCountSet;
|
|
14028
14349
|
const drawingVectorBatches = this.drawingVectorBatches;
|
|
14029
|
-
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new
|
|
14350
|
+
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core13.UniformStore(this.device, this.shaderInputs.modules) : void 0;
|
|
14030
14351
|
if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
|
|
14031
14352
|
this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
|
|
14032
14353
|
let batchByteLength = 0;
|
|
@@ -14087,7 +14408,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14087
14408
|
Object.entries(data).map(([name, chunk]) => {
|
|
14088
14409
|
const layout = this.bufferLayout.find((layout2) => layout2.name === name);
|
|
14089
14410
|
const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
|
|
14090
|
-
(0,
|
|
14411
|
+
(0, import_core13.assert)(byteOffset >= 0);
|
|
14091
14412
|
return [name, byteOffset];
|
|
14092
14413
|
})
|
|
14093
14414
|
)
|
|
@@ -14095,7 +14416,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14095
14416
|
);
|
|
14096
14417
|
}
|
|
14097
14418
|
validateVectorLengthPolicy() {
|
|
14098
|
-
(0,
|
|
14419
|
+
(0, import_core13.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
|
|
14099
14420
|
}
|
|
14100
14421
|
setBatchDrawCount(rowCount, count = this.props.inferDrawCount === "no" ? "none" : this.props.inferDrawCount) {
|
|
14101
14422
|
if (count === "instance") {
|
|
@@ -14218,7 +14539,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14218
14539
|
/** Set the shader inputs */
|
|
14219
14540
|
setShaderInputs(shaderInputs) {
|
|
14220
14541
|
this.shaderInputs = shaderInputs;
|
|
14221
|
-
this._uniformStore = new
|
|
14542
|
+
this._uniformStore = new import_core13.UniformStore(this.device, this.shaderInputs.modules);
|
|
14222
14543
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14223
14544
|
if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
|
|
14224
14545
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -14289,7 +14610,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14289
14610
|
this._drawBlockedReason = false;
|
|
14290
14611
|
const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
|
|
14291
14612
|
if (buffers["indices"]) {
|
|
14292
|
-
|
|
14613
|
+
import_core13.log.warn(
|
|
14293
14614
|
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
14294
14615
|
)();
|
|
14295
14616
|
}
|
|
@@ -14303,7 +14624,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14303
14624
|
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
14304
14625
|
if (!bufferLayout) {
|
|
14305
14626
|
if (!disableWarnings) {
|
|
14306
|
-
|
|
14627
|
+
import_core13.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
14307
14628
|
}
|
|
14308
14629
|
continue;
|
|
14309
14630
|
}
|
|
@@ -14315,7 +14636,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14315
14636
|
const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
|
|
14316
14637
|
if (bufferSlot === null) {
|
|
14317
14638
|
if (!disableWarnings) {
|
|
14318
|
-
|
|
14639
|
+
import_core13.log.warn(
|
|
14319
14640
|
`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
|
|
14320
14641
|
)();
|
|
14321
14642
|
}
|
|
@@ -14336,7 +14657,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14336
14657
|
}
|
|
14337
14658
|
}
|
|
14338
14659
|
if (!set2 && !disableWarnings) {
|
|
14339
|
-
|
|
14660
|
+
import_core13.log.warn(
|
|
14340
14661
|
`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
|
|
14341
14662
|
)();
|
|
14342
14663
|
}
|
|
@@ -14357,7 +14678,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14357
14678
|
if (attributeInfo) {
|
|
14358
14679
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
14359
14680
|
} else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
|
|
14360
|
-
|
|
14681
|
+
import_core13.log.warn(
|
|
14361
14682
|
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
14362
14683
|
)();
|
|
14363
14684
|
}
|
|
@@ -14394,7 +14715,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14394
14715
|
* @param bindings GPUVectorModel bindings already resolved for this draw preparation.
|
|
14395
14716
|
*/
|
|
14396
14717
|
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
14397
|
-
return shaderLayout.bindings.length ? (0,
|
|
14718
|
+
return shaderLayout.bindings.length ? (0, import_core13.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
|
|
14398
14719
|
}
|
|
14399
14720
|
_getBindGroupCacheKeys() {
|
|
14400
14721
|
return {};
|
|
@@ -14409,9 +14730,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
14409
14730
|
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
14410
14731
|
}
|
|
14411
14732
|
for (const binding of Object.values(this.bindings)) {
|
|
14412
|
-
if (binding instanceof
|
|
14733
|
+
if (binding instanceof import_core13.TextureView) {
|
|
14413
14734
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
14414
|
-
} else if (binding instanceof
|
|
14735
|
+
} else if (binding instanceof import_core13.Buffer || binding instanceof import_core13.Texture || binding instanceof import_core13.ExternalTexture) {
|
|
14415
14736
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
14416
14737
|
} else if (binding instanceof DynamicBuffer) {
|
|
14417
14738
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -14470,7 +14791,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14470
14791
|
const previousVertexShader = this.pipeline?.vs ?? null;
|
|
14471
14792
|
const previousFragmentShader = this.pipeline?.fs ?? null;
|
|
14472
14793
|
if (this.pipeline) {
|
|
14473
|
-
|
|
14794
|
+
import_core13.log.log(
|
|
14474
14795
|
1,
|
|
14475
14796
|
`GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
|
|
14476
14797
|
)();
|
|
@@ -14520,7 +14841,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14520
14841
|
};
|
|
14521
14842
|
}
|
|
14522
14843
|
_finishPipelineUpdate(update) {
|
|
14523
|
-
this._attributeInfos = (0,
|
|
14844
|
+
this._attributeInfos = (0, import_core13.getAttributeInfosFromLayouts)(
|
|
14524
14845
|
this.pipeline.shaderLayout,
|
|
14525
14846
|
this.bufferLayout
|
|
14526
14847
|
);
|
|
@@ -14536,24 +14857,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
14536
14857
|
_lastLogTime = 0;
|
|
14537
14858
|
_logOpen = false;
|
|
14538
14859
|
_logDrawCallStart() {
|
|
14539
|
-
const logDrawTimeout =
|
|
14540
|
-
if (
|
|
14860
|
+
const logDrawTimeout = import_core13.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
14861
|
+
if (import_core13.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
14541
14862
|
return;
|
|
14542
14863
|
}
|
|
14543
14864
|
this._lastLogTime = Date.now();
|
|
14544
14865
|
this._logOpen = true;
|
|
14545
|
-
|
|
14866
|
+
import_core13.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core13.log.level <= 2 })();
|
|
14546
14867
|
}
|
|
14547
14868
|
_logDrawCallEnd() {
|
|
14548
14869
|
if (this._logOpen) {
|
|
14549
14870
|
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
14550
|
-
|
|
14871
|
+
import_core13.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
14551
14872
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
14552
|
-
|
|
14873
|
+
import_core13.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
14553
14874
|
const attributeTable = this._getAttributeDebugTable();
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14875
|
+
import_core13.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
14876
|
+
import_core13.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
14877
|
+
import_core13.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
14557
14878
|
this._logOpen = false;
|
|
14558
14879
|
}
|
|
14559
14880
|
}
|
|
@@ -14593,8 +14914,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
14593
14914
|
}
|
|
14594
14915
|
// TODO - fix typing of luma data types
|
|
14595
14916
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
14596
|
-
const TypedArrayConstructor =
|
|
14597
|
-
const typedArray = attribute instanceof
|
|
14917
|
+
const TypedArrayConstructor = import_core13.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
14918
|
+
const typedArray = attribute instanceof import_core13.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
14598
14919
|
return typedArray.toString();
|
|
14599
14920
|
}
|
|
14600
14921
|
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
@@ -14678,7 +14999,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14678
14999
|
}
|
|
14679
15000
|
|
|
14680
15001
|
// src/geometry/gpu-geometry.ts
|
|
14681
|
-
var
|
|
15002
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
14682
15003
|
var GPUGeometry = class {
|
|
14683
15004
|
/** Application-provided or generated identifier. */
|
|
14684
15005
|
id;
|
|
@@ -14703,7 +15024,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14703
15024
|
this.vertexCount = props.vertexCount;
|
|
14704
15025
|
this.bufferLayout = props.bufferLayout || [];
|
|
14705
15026
|
if (this.indices) {
|
|
14706
|
-
if (!(this.indices.usage &
|
|
15027
|
+
if (!(this.indices.usage & import_core14.Buffer.INDEX)) {
|
|
14707
15028
|
throw new Error("Index buffer must have INDEX usage");
|
|
14708
15029
|
}
|
|
14709
15030
|
}
|
|
@@ -14752,7 +15073,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14752
15073
|
return void 0;
|
|
14753
15074
|
}
|
|
14754
15075
|
const data = geometry.indices.value;
|
|
14755
|
-
return device.createBuffer({ usage:
|
|
15076
|
+
return device.createBuffer({ usage: import_core14.Buffer.INDEX, data });
|
|
14756
15077
|
}
|
|
14757
15078
|
function getAttributeBuffersFromGeometry(device, geometry) {
|
|
14758
15079
|
const attributes = {};
|
|
@@ -14792,7 +15113,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14792
15113
|
};
|
|
14793
15114
|
|
|
14794
15115
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
14795
|
-
var
|
|
15116
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
14796
15117
|
function makeGPUVectorGeometry(device, geometry) {
|
|
14797
15118
|
const gpuGeometry = makeGPUGeometry(device, geometry);
|
|
14798
15119
|
try {
|
|
@@ -14809,7 +15130,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14809
15130
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|
|
14810
15131
|
const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
|
|
14811
15132
|
const format = bufferLayout?.format;
|
|
14812
|
-
const byteStride2 = bufferLayout?.byteStride ?? (format ?
|
|
15133
|
+
const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core15.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
|
|
14813
15134
|
const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
|
|
14814
15135
|
attributes[name] = {
|
|
14815
15136
|
name,
|
|
@@ -14972,7 +15293,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14972
15293
|
};
|
|
14973
15294
|
|
|
14974
15295
|
// src/material/material.ts
|
|
14975
|
-
var
|
|
15296
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
14976
15297
|
|
|
14977
15298
|
// src/material/material-factory.ts
|
|
14978
15299
|
var MATERIAL_BIND_GROUP = 3;
|
|
@@ -15050,6 +15371,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
15050
15371
|
var Material = class {
|
|
15051
15372
|
/** Application-provided identifier. */
|
|
15052
15373
|
id;
|
|
15374
|
+
/** Structured metadata associated with this material. */
|
|
15375
|
+
metadata = {};
|
|
15053
15376
|
/** Device that owns the material resources. */
|
|
15054
15377
|
device;
|
|
15055
15378
|
/** Factory that defines the material schema. */
|
|
@@ -15074,7 +15397,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15074
15397
|
])
|
|
15075
15398
|
);
|
|
15076
15399
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
15077
|
-
this._uniformStore = new
|
|
15400
|
+
this._uniformStore = new import_core16.UniformStore(this.device, this.shaderInputs.modules);
|
|
15078
15401
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
15079
15402
|
if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
|
|
15080
15403
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -15106,6 +15429,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15106
15429
|
if (props.moduleProps) {
|
|
15107
15430
|
material.setProps(props.moduleProps);
|
|
15108
15431
|
}
|
|
15432
|
+
material.metadata = { ...this.metadata };
|
|
15109
15433
|
material.updateShaderInputs();
|
|
15110
15434
|
return material;
|
|
15111
15435
|
}
|
|
@@ -15188,9 +15512,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
15188
15512
|
getBindingsUpdateTimestamp() {
|
|
15189
15513
|
let timestamp = 0;
|
|
15190
15514
|
for (const binding of Object.values(this.bindings)) {
|
|
15191
|
-
if (binding instanceof
|
|
15515
|
+
if (binding instanceof import_core16.TextureView) {
|
|
15192
15516
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
15193
|
-
} else if (binding instanceof
|
|
15517
|
+
} else if (binding instanceof import_core16.Buffer || binding instanceof import_core16.Texture || binding instanceof import_core16.ExternalTexture) {
|
|
15194
15518
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
15195
15519
|
} else if (binding instanceof DynamicBuffer) {
|
|
15196
15520
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -15258,7 +15582,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15258
15582
|
}
|
|
15259
15583
|
|
|
15260
15584
|
// src/compute/buffer-transform.ts
|
|
15261
|
-
var
|
|
15585
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
15262
15586
|
var import_shaders4 = __toESM(require_shaders(), 1);
|
|
15263
15587
|
var GL_INTERLEAVED_ATTRIBS = 35980;
|
|
15264
15588
|
var GL_SEPARATE_ATTRIBS = 35981;
|
|
@@ -15332,14 +15656,14 @@ ${getApplicationDefines(allDefines)}
|
|
|
15332
15656
|
/** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
|
|
15333
15657
|
setOutputVectors(vectors) {
|
|
15334
15658
|
const batches = getGPUVectorModelBatches(this.model.id, vectors);
|
|
15335
|
-
(0,
|
|
15336
|
-
(0,
|
|
15659
|
+
(0, import_core17.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
|
|
15660
|
+
(0, import_core17.assert)(batches.length <= 1);
|
|
15337
15661
|
this.outputVectorBindings = vectors;
|
|
15338
15662
|
this.transformFeedback.setBuffers({
|
|
15339
15663
|
...this.outputBuffers,
|
|
15340
15664
|
...Object.fromEntries(
|
|
15341
15665
|
Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
|
|
15342
|
-
(0,
|
|
15666
|
+
(0, import_core17.assert)(data.byteStride === data.rowByteLength);
|
|
15343
15667
|
return [
|
|
15344
15668
|
name,
|
|
15345
15669
|
{
|
|
@@ -15363,7 +15687,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15363
15687
|
if (!result) {
|
|
15364
15688
|
throw new Error("BufferTransform#getBuffer");
|
|
15365
15689
|
}
|
|
15366
|
-
if (result instanceof
|
|
15690
|
+
if (result instanceof import_core17.Buffer) {
|
|
15367
15691
|
return result.readAsync();
|
|
15368
15692
|
}
|
|
15369
15693
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
@@ -15925,11 +16249,11 @@ void main(void) {
|
|
|
15925
16249
|
destroyManagedInstanceBuffers(this._managedBuffers);
|
|
15926
16250
|
this._managedBuffers = {};
|
|
15927
16251
|
}
|
|
15928
|
-
draw(renderPass) {
|
|
16252
|
+
draw(renderPass, options) {
|
|
15929
16253
|
if (this.instanceCount === 0) {
|
|
15930
16254
|
return true;
|
|
15931
16255
|
}
|
|
15932
|
-
return super.draw(renderPass);
|
|
16256
|
+
return super.draw(renderPass, options);
|
|
15933
16257
|
}
|
|
15934
16258
|
setProps(props) {
|
|
15935
16259
|
this.lightModelProps = { ...this.lightModelProps, ...props };
|
|
@@ -16312,7 +16636,7 @@ void main(void) {
|
|
|
16312
16636
|
};
|
|
16313
16637
|
|
|
16314
16638
|
// src/scenegraph/scenegraph-node.ts
|
|
16315
|
-
function
|
|
16639
|
+
function assert11(condition, message) {
|
|
16316
16640
|
if (!condition) {
|
|
16317
16641
|
throw new Error(message);
|
|
16318
16642
|
}
|
|
@@ -16321,9 +16645,15 @@ void main(void) {
|
|
|
16321
16645
|
id;
|
|
16322
16646
|
matrix = new Matrix4();
|
|
16323
16647
|
display = true;
|
|
16648
|
+
/** Local selection eligibility, independent of visibility. */
|
|
16649
|
+
selectable = true;
|
|
16650
|
+
/** Local hover eligibility, independent of visibility. */
|
|
16651
|
+
hoverable = true;
|
|
16324
16652
|
position = new Vector3();
|
|
16325
16653
|
rotation = new Vector3();
|
|
16326
16654
|
scale = new Vector3(1, 1, 1);
|
|
16655
|
+
/** Structured metadata associated with this scene node. */
|
|
16656
|
+
metadata = {};
|
|
16327
16657
|
userData = {};
|
|
16328
16658
|
props = {};
|
|
16329
16659
|
constructor(props = {}) {
|
|
@@ -16348,17 +16678,17 @@ void main(void) {
|
|
|
16348
16678
|
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
16349
16679
|
}
|
|
16350
16680
|
setPosition(position) {
|
|
16351
|
-
|
|
16681
|
+
assert11(position.length === 3, "setPosition requires vector argument");
|
|
16352
16682
|
this.position = position;
|
|
16353
16683
|
return this;
|
|
16354
16684
|
}
|
|
16355
16685
|
setRotation(rotation) {
|
|
16356
|
-
|
|
16686
|
+
assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
16357
16687
|
this.rotation = rotation;
|
|
16358
16688
|
return this;
|
|
16359
16689
|
}
|
|
16360
16690
|
setScale(scale5) {
|
|
16361
|
-
|
|
16691
|
+
assert11(scale5.length === 3, "setScale requires vector argument");
|
|
16362
16692
|
this.scale = scale5;
|
|
16363
16693
|
return this;
|
|
16364
16694
|
}
|
|
@@ -16447,6 +16777,8 @@ void main(void) {
|
|
|
16447
16777
|
}
|
|
16448
16778
|
*/
|
|
16449
16779
|
_setScenegraphNodeProps(props) {
|
|
16780
|
+
if (props.selectable !== void 0) this.selectable = props.selectable;
|
|
16781
|
+
if (props.hoverable !== void 0) this.hoverable = props.hoverable;
|
|
16450
16782
|
if (props.display !== void 0) {
|
|
16451
16783
|
this.display = props.display;
|
|
16452
16784
|
}
|
|
@@ -16467,8 +16799,92 @@ void main(void) {
|
|
|
16467
16799
|
}
|
|
16468
16800
|
};
|
|
16469
16801
|
|
|
16802
|
+
// src/scenegraph/scenegraph-interaction.ts
|
|
16803
|
+
function isScenegraphInteractionEnabled(path, kind) {
|
|
16804
|
+
return path.length > 0 && path.every((node) => kind === "select" ? node.selectable : node.hoverable);
|
|
16805
|
+
}
|
|
16806
|
+
function getFirstScenegraphInteractionHit(hits, kind) {
|
|
16807
|
+
return hits.find((hit) => isScenegraphInteractionEnabled(hit.path, kind));
|
|
16808
|
+
}
|
|
16809
|
+
var ScenegraphInteractionManager = class {
|
|
16810
|
+
hoveredHits = /* @__PURE__ */ new Map();
|
|
16811
|
+
pendingHover = /* @__PURE__ */ new Map();
|
|
16812
|
+
onEvent;
|
|
16813
|
+
/** Creates a controller that reports bubbled selection and hover events. */
|
|
16814
|
+
constructor(onEvent) {
|
|
16815
|
+
this.onEvent = onEvent;
|
|
16816
|
+
}
|
|
16817
|
+
/** Selects the first eligible nearest-first hit and bubbles from target to root. */
|
|
16818
|
+
select(hits, controllerIndex = 0) {
|
|
16819
|
+
const hit = getFirstScenegraphInteractionHit(hits, "select");
|
|
16820
|
+
if (!hit) return void 0;
|
|
16821
|
+
this.emitPath("select", hit, 0, controllerIndex);
|
|
16822
|
+
return hit;
|
|
16823
|
+
}
|
|
16824
|
+
/** Updates hover from current hits; call after pointer, camera, object, or flag changes. */
|
|
16825
|
+
updateHover(hits, controllerIndex = 0) {
|
|
16826
|
+
const hit = getFirstScenegraphInteractionHit(hits, "hover");
|
|
16827
|
+
const queuedHit = hit ? { ...hit, path: [...hit.path] } : void 0;
|
|
16828
|
+
const activeQueue = this.pendingHover.get(controllerIndex);
|
|
16829
|
+
if (activeQueue) {
|
|
16830
|
+
activeQueue.push(queuedHit);
|
|
16831
|
+
return hit;
|
|
16832
|
+
}
|
|
16833
|
+
const queue = [queuedHit];
|
|
16834
|
+
this.pendingHover.set(controllerIndex, queue);
|
|
16835
|
+
try {
|
|
16836
|
+
while (queue.length) {
|
|
16837
|
+
const next = queue.shift();
|
|
16838
|
+
const previous = this.hoveredHits.get(controllerIndex);
|
|
16839
|
+
const previousPath = previous?.path || [];
|
|
16840
|
+
const nextPath = next?.path || [];
|
|
16841
|
+
let shared = 0;
|
|
16842
|
+
while (shared < previousPath.length && shared < nextPath.length && previousPath[shared] === nextPath[shared])
|
|
16843
|
+
shared++;
|
|
16844
|
+
if (next) this.hoveredHits.set(controllerIndex, next);
|
|
16845
|
+
else this.hoveredHits.delete(controllerIndex);
|
|
16846
|
+
if (previous) this.emitPath("hover-out", previous, shared, controllerIndex);
|
|
16847
|
+
if (next) this.emitPath("hover-in", next, shared, controllerIndex);
|
|
16848
|
+
}
|
|
16849
|
+
} finally {
|
|
16850
|
+
this.pendingHover.delete(controllerIndex);
|
|
16851
|
+
}
|
|
16852
|
+
return hit;
|
|
16853
|
+
}
|
|
16854
|
+
/** Emits exits for one controller and drops its tracked hover path. */
|
|
16855
|
+
clearHover(controllerIndex = 0) {
|
|
16856
|
+
this.updateHover([], controllerIndex);
|
|
16857
|
+
}
|
|
16858
|
+
/** Emits events from the target towards the first ancestor outside the shared subtree. */
|
|
16859
|
+
emitPath(type, hit, first, controllerIndex) {
|
|
16860
|
+
const { path } = hit;
|
|
16861
|
+
const target = path[path.length - 1];
|
|
16862
|
+
for (let index = path.length - 1; index >= first; index--) {
|
|
16863
|
+
this.onEvent({ type, target, currentTarget: path[index], controllerIndex, hit });
|
|
16864
|
+
}
|
|
16865
|
+
}
|
|
16866
|
+
};
|
|
16867
|
+
|
|
16868
|
+
// src/scenegraph/scene-metadata.ts
|
|
16869
|
+
var SceneMetadata = class {
|
|
16870
|
+
entries = /* @__PURE__ */ new Map();
|
|
16871
|
+
/** Associates metadata with a resource category and its source index. */
|
|
16872
|
+
set(category, index, metadata) {
|
|
16873
|
+
let categoryEntries = this.entries.get(category);
|
|
16874
|
+
if (!categoryEntries) {
|
|
16875
|
+
categoryEntries = /* @__PURE__ */ new Map();
|
|
16876
|
+
this.entries.set(category, categoryEntries);
|
|
16877
|
+
}
|
|
16878
|
+
categoryEntries.set(index, metadata);
|
|
16879
|
+
}
|
|
16880
|
+
/** Returns metadata for a resource, or undefined when none was supplied. */
|
|
16881
|
+
get(category, index = 0) {
|
|
16882
|
+
return this.entries.get(category)?.get(index);
|
|
16883
|
+
}
|
|
16884
|
+
};
|
|
16885
|
+
|
|
16470
16886
|
// src/scenegraph/group-node.ts
|
|
16471
|
-
var
|
|
16887
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
16472
16888
|
|
|
16473
16889
|
// src/scenegraph/scenegraph-bounds.ts
|
|
16474
16890
|
function makeEmptyScenegraphBounds() {
|
|
@@ -16510,7 +16926,7 @@ void main(void) {
|
|
|
16510
16926
|
constructor(props = {}) {
|
|
16511
16927
|
props = Array.isArray(props) ? { children: props } : props;
|
|
16512
16928
|
const { children = [] } = props;
|
|
16513
|
-
|
|
16929
|
+
import_core18.log.assert(
|
|
16514
16930
|
children.every((child) => child instanceof ScenegraphNode),
|
|
16515
16931
|
"every child must an instance of ScenegraphNode"
|
|
16516
16932
|
);
|
|
@@ -16581,7 +16997,7 @@ void main(void) {
|
|
|
16581
16997
|
const pending = [{ node: this, depth: 0 }];
|
|
16582
16998
|
while (pending.length) {
|
|
16583
16999
|
const { node, depth } = pending.pop();
|
|
16584
|
-
(0,
|
|
17000
|
+
(0, import_core18.assert)(!visited.has(node));
|
|
16585
17001
|
visited.add(node);
|
|
16586
17002
|
ancestors.length = depth;
|
|
16587
17003
|
ancestors.push(node.id);
|
|
@@ -16717,12 +17133,12 @@ void main(void) {
|
|
|
16717
17133
|
}
|
|
16718
17134
|
|
|
16719
17135
|
// src/geometry/edge-geometry.ts
|
|
16720
|
-
var
|
|
17136
|
+
var import_core19 = __toESM(require_core(), 1);
|
|
16721
17137
|
function makeEdgeGeometry(geometry, options = {}) {
|
|
16722
17138
|
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
16723
17139
|
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
16724
|
-
(0,
|
|
16725
|
-
(0,
|
|
17140
|
+
(0, import_core19.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
17141
|
+
(0, import_core19.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
16726
17142
|
const sourceIndices = geometry.indices?.value;
|
|
16727
17143
|
const sourceCount = positions.value.length / 3;
|
|
16728
17144
|
const representatives = /* @__PURE__ */ new Map();
|
|
@@ -16741,9 +17157,9 @@ void main(void) {
|
|
|
16741
17157
|
function weldPosition(index) {
|
|
16742
17158
|
const cached = representatives.get(index);
|
|
16743
17159
|
if (cached !== void 0) return cached;
|
|
16744
|
-
(0,
|
|
17160
|
+
(0, import_core19.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
16745
17161
|
const position = readPosition(index);
|
|
16746
|
-
(0,
|
|
17162
|
+
(0, import_core19.assert)(position.every(Number.isFinite));
|
|
16747
17163
|
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
16748
17164
|
const radius = weldTolerance > 0 ? 1 : 0;
|
|
16749
17165
|
for (let east = -radius; east <= radius; east++) {
|
|
@@ -16817,11 +17233,11 @@ void main(void) {
|
|
|
16817
17233
|
});
|
|
16818
17234
|
}
|
|
16819
17235
|
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
16820
|
-
(0,
|
|
17236
|
+
(0, import_core19.assert)(geometries.length > 0);
|
|
16821
17237
|
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
16822
17238
|
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
16823
17239
|
const firstAttribute = attributes[0];
|
|
16824
|
-
(0,
|
|
17240
|
+
(0, import_core19.assert)(
|
|
16825
17241
|
attributes.every(
|
|
16826
17242
|
(attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
|
|
16827
17243
|
)
|
|
@@ -16840,7 +17256,7 @@ void main(void) {
|
|
|
16840
17256
|
positions.set(attribute.value, positionOffset);
|
|
16841
17257
|
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
16842
17258
|
const index = geometry.indices?.value[offset] ?? offset;
|
|
16843
|
-
(0,
|
|
17259
|
+
(0, import_core19.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
16844
17260
|
indices[indexOffset++] = index + positionOffset / 3;
|
|
16845
17261
|
}
|
|
16846
17262
|
positionOffset += attribute.value.length;
|
|
@@ -16857,26 +17273,26 @@ void main(void) {
|
|
|
16857
17273
|
}
|
|
16858
17274
|
function getTrianglePositions(geometry, positionAttribute) {
|
|
16859
17275
|
const positions = geometry.attributes[positionAttribute];
|
|
16860
|
-
(0,
|
|
16861
|
-
(0,
|
|
16862
|
-
(0,
|
|
17276
|
+
(0, import_core19.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
|
|
17277
|
+
(0, import_core19.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
17278
|
+
(0, import_core19.assert)(
|
|
16863
17279
|
!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
|
|
16864
17280
|
);
|
|
16865
|
-
(0,
|
|
17281
|
+
(0, import_core19.assert)(
|
|
16866
17282
|
geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
|
|
16867
17283
|
);
|
|
16868
17284
|
return positions;
|
|
16869
17285
|
}
|
|
16870
17286
|
|
|
16871
17287
|
// src/geometry/stroke-geometry.ts
|
|
16872
|
-
var
|
|
17288
|
+
var import_core20 = __toESM(require_core(), 1);
|
|
16873
17289
|
function makeStrokeGeometry(path, options = {}) {
|
|
16874
17290
|
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
16875
|
-
(0,
|
|
16876
|
-
(0,
|
|
17291
|
+
(0, import_core20.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
17292
|
+
(0, import_core20.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
16877
17293
|
const points = [];
|
|
16878
17294
|
for (const position of path) {
|
|
16879
|
-
(0,
|
|
17295
|
+
(0, import_core20.assert)(
|
|
16880
17296
|
Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
|
|
16881
17297
|
);
|
|
16882
17298
|
const previous = points.at(-1);
|
|
@@ -17036,12 +17452,12 @@ void main(void) {
|
|
|
17036
17452
|
}
|
|
17037
17453
|
|
|
17038
17454
|
// src/geometry/mesh-simplification.ts
|
|
17039
|
-
var
|
|
17455
|
+
var import_core21 = __toESM(require_core(), 1);
|
|
17040
17456
|
var QUADRIC_COMPONENTS = 10;
|
|
17041
17457
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
17042
17458
|
function simplifyMesh(options) {
|
|
17043
17459
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
17044
|
-
(0,
|
|
17460
|
+
(0, import_core21.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
17045
17461
|
const targetIndexCount = Math.max(
|
|
17046
17462
|
0,
|
|
17047
17463
|
Math.min(
|
|
@@ -17134,7 +17550,7 @@ void main(void) {
|
|
|
17134
17550
|
const firstVertex = indices[indexOffset2];
|
|
17135
17551
|
const secondVertex = indices[indexOffset2 + 1];
|
|
17136
17552
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
17137
|
-
(0,
|
|
17553
|
+
(0, import_core21.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
17138
17554
|
const triangle = {
|
|
17139
17555
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
17140
17556
|
active: false
|
|
@@ -17469,7 +17885,7 @@ void main(void) {
|
|
|
17469
17885
|
}
|
|
17470
17886
|
|
|
17471
17887
|
// src/dynamic-texture/video-texture.ts
|
|
17472
|
-
var
|
|
17888
|
+
var import_core22 = __toESM(require_core(), 1);
|
|
17473
17889
|
var VideoTexture = class {
|
|
17474
17890
|
/** Device used to create copied and native external texture bindings. */
|
|
17475
17891
|
device;
|
|
@@ -17503,7 +17919,7 @@ void main(void) {
|
|
|
17503
17919
|
this._observeSource();
|
|
17504
17920
|
return this._updateTimestamp;
|
|
17505
17921
|
}
|
|
17506
|
-
/**
|
|
17922
|
+
/** DeviceResource label used by debug output. */
|
|
17507
17923
|
get [Symbol.toStringTag]() {
|
|
17508
17924
|
return "VideoTexture";
|
|
17509
17925
|
}
|
|
@@ -17518,7 +17934,7 @@ void main(void) {
|
|
|
17518
17934
|
* @param props Live video source and copied texture options.
|
|
17519
17935
|
*/
|
|
17520
17936
|
constructor(device, props) {
|
|
17521
|
-
(0,
|
|
17937
|
+
(0, import_core22.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
17522
17938
|
this.device = device;
|
|
17523
17939
|
this.id = props.id || uid("video-texture");
|
|
17524
17940
|
this._source = props.source;
|
|
@@ -17532,7 +17948,7 @@ void main(void) {
|
|
|
17532
17948
|
* @param source Next caller-owned video source to follow.
|
|
17533
17949
|
*/
|
|
17534
17950
|
setSource(source4) {
|
|
17535
|
-
(0,
|
|
17951
|
+
(0, import_core22.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
17536
17952
|
this._destroyExternalTexture();
|
|
17537
17953
|
this._source = source4;
|
|
17538
17954
|
this._sourceVersion++;
|
|
@@ -17610,7 +18026,7 @@ void main(void) {
|
|
|
17610
18026
|
width: size.width,
|
|
17611
18027
|
height: size.height,
|
|
17612
18028
|
format: "rgba8unorm",
|
|
17613
|
-
usage:
|
|
18029
|
+
usage: import_core22.Texture.SAMPLE | import_core22.Texture.COPY_DST,
|
|
17614
18030
|
mipLevels: 1,
|
|
17615
18031
|
sampler: this._sampler
|
|
17616
18032
|
});
|
|
@@ -17645,7 +18061,7 @@ void main(void) {
|
|
|
17645
18061
|
*/
|
|
17646
18062
|
_getResolvedSize() {
|
|
17647
18063
|
const size = getVideoTextureSourceSize(this._source);
|
|
17648
|
-
(0,
|
|
18064
|
+
(0, import_core22.assert)(size.width > 0 && size.height > 0);
|
|
17649
18065
|
return size;
|
|
17650
18066
|
}
|
|
17651
18067
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -17710,11 +18126,11 @@ void main(void) {
|
|
|
17710
18126
|
}
|
|
17711
18127
|
|
|
17712
18128
|
// src/passes/shader-pass-renderer.ts
|
|
17713
|
-
var
|
|
18129
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
17714
18130
|
var import_shaders7 = __toESM(require_shaders(), 1);
|
|
17715
18131
|
|
|
17716
18132
|
// src/compute/swap.ts
|
|
17717
|
-
var
|
|
18133
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
17718
18134
|
var Swap = class {
|
|
17719
18135
|
id;
|
|
17720
18136
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -17746,7 +18162,7 @@ void main(void) {
|
|
|
17746
18162
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
17747
18163
|
id: `${props.id}-texture-0`,
|
|
17748
18164
|
format: colorAttachment,
|
|
17749
|
-
usage:
|
|
18165
|
+
usage: import_core23.Texture.SAMPLE | import_core23.Texture.RENDER | import_core23.Texture.COPY_SRC | import_core23.Texture.COPY_DST,
|
|
17750
18166
|
width,
|
|
17751
18167
|
height
|
|
17752
18168
|
})
|
|
@@ -17756,7 +18172,7 @@ void main(void) {
|
|
|
17756
18172
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
17757
18173
|
id: `${props.id}-texture-1`,
|
|
17758
18174
|
format: colorAttachment,
|
|
17759
|
-
usage:
|
|
18175
|
+
usage: import_core23.Texture.SAMPLE | import_core23.Texture.RENDER | import_core23.Texture.COPY_SRC | import_core23.Texture.COPY_DST,
|
|
17760
18176
|
width,
|
|
17761
18177
|
height
|
|
17762
18178
|
})
|
|
@@ -17820,7 +18236,7 @@ void main(void) {
|
|
|
17820
18236
|
};
|
|
17821
18237
|
|
|
17822
18238
|
// src/compute/computation.ts
|
|
17823
|
-
var
|
|
18239
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
17824
18240
|
var import_shaders6 = __toESM(require_shaders(), 1);
|
|
17825
18241
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
17826
18242
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -17832,13 +18248,13 @@ void main(void) {
|
|
|
17832
18248
|
* constructor remains the synchronous compatibility path.
|
|
17833
18249
|
*/
|
|
17834
18250
|
static async createAsync(device, props) {
|
|
17835
|
-
const ownsCompilation = !
|
|
17836
|
-
const asyncCompilation = ownsCompilation ?
|
|
18251
|
+
const ownsCompilation = !import_core24.PipelineFactory.getAsyncCompilation(device);
|
|
18252
|
+
const asyncCompilation = ownsCompilation ? import_core24.PipelineFactory.beginAsyncCompilation(device) : import_core24.PipelineFactory.getAsyncCompilation(device);
|
|
17837
18253
|
let computation;
|
|
17838
18254
|
try {
|
|
17839
18255
|
computation = new _Computation(device, props);
|
|
17840
18256
|
} finally {
|
|
17841
|
-
if (ownsCompilation)
|
|
18257
|
+
if (ownsCompilation) import_core24.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
17842
18258
|
}
|
|
17843
18259
|
try {
|
|
17844
18260
|
if (ownsCompilation) {
|
|
@@ -17853,7 +18269,7 @@ void main(void) {
|
|
|
17853
18269
|
}
|
|
17854
18270
|
}
|
|
17855
18271
|
static defaultProps = {
|
|
17856
|
-
...
|
|
18272
|
+
...import_core24.ComputePipeline.defaultProps,
|
|
17857
18273
|
id: "unnamed",
|
|
17858
18274
|
handle: void 0,
|
|
17859
18275
|
userData: {},
|
|
@@ -17907,7 +18323,7 @@ void main(void) {
|
|
|
17907
18323
|
Object.assign(this.userData, props.userData);
|
|
17908
18324
|
const platformInfo = getPlatformInfo(device);
|
|
17909
18325
|
const resolvedPlugins = (0, import_shaders6.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
|
|
17910
|
-
if (resolvedPlugins.
|
|
18326
|
+
if (resolvedPlugins.injectionTargets.length > 0) {
|
|
17911
18327
|
throw new Error("Computation does not support ShaderPlugin render hooks");
|
|
17912
18328
|
}
|
|
17913
18329
|
if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.interStageVariables).length > 0) {
|
|
@@ -17928,10 +18344,10 @@ void main(void) {
|
|
|
17928
18344
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
17929
18345
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
17930
18346
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
17931
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
17932
|
-
this.shaderFactory = props.shaderFactory ||
|
|
18347
|
+
this.pipelineFactory = props.pipelineFactory || import_core24.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
18348
|
+
this.shaderFactory = props.shaderFactory || import_core24.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
17933
18349
|
const shaderAssembler = this.props.shaderAssembler;
|
|
17934
|
-
(0,
|
|
18350
|
+
(0, import_core24.assert)(shaderAssembler instanceof WGSLShaderAssembler);
|
|
17935
18351
|
const {
|
|
17936
18352
|
source: source4,
|
|
17937
18353
|
getUniforms: getUniforms2,
|
|
@@ -17955,7 +18371,7 @@ void main(void) {
|
|
|
17955
18371
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
17956
18372
|
modules
|
|
17957
18373
|
) || null;
|
|
17958
|
-
const asyncCompilation =
|
|
18374
|
+
const asyncCompilation = import_core24.PipelineFactory.getAsyncCompilation(this.device);
|
|
17959
18375
|
if (asyncCompilation) {
|
|
17960
18376
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
17961
18377
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -18022,7 +18438,7 @@ void main(void) {
|
|
|
18022
18438
|
}
|
|
18023
18439
|
setShaderInputs(shaderInputs) {
|
|
18024
18440
|
this.shaderInputs = shaderInputs;
|
|
18025
|
-
this._uniformStore = new
|
|
18441
|
+
this._uniformStore = new import_core24.UniformStore(this.device, this.shaderInputs.modules);
|
|
18026
18442
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
18027
18443
|
if (shaderModuleHasUniforms(module)) {
|
|
18028
18444
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -18091,7 +18507,7 @@ void main(void) {
|
|
|
18091
18507
|
if (!this._pipelineNeedsUpdate) return null;
|
|
18092
18508
|
const previousShader = this.pipeline ? this.shader : null;
|
|
18093
18509
|
if (this.pipeline) {
|
|
18094
|
-
|
|
18510
|
+
import_core24.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
18095
18511
|
}
|
|
18096
18512
|
this._pipelineNeedsUpdate = false;
|
|
18097
18513
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -18109,27 +18525,27 @@ void main(void) {
|
|
|
18109
18525
|
_lastLogTime = 0;
|
|
18110
18526
|
_logOpen = false;
|
|
18111
18527
|
_logDrawCallStart() {
|
|
18112
|
-
const logDrawTimeout =
|
|
18113
|
-
if (
|
|
18528
|
+
const logDrawTimeout = import_core24.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
18529
|
+
if (import_core24.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
18114
18530
|
return;
|
|
18115
18531
|
}
|
|
18116
18532
|
this._lastLogTime = Date.now();
|
|
18117
18533
|
this._logOpen = true;
|
|
18118
|
-
|
|
18534
|
+
import_core24.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core24.log.level <= 2 })();
|
|
18119
18535
|
}
|
|
18120
18536
|
_logDrawCallEnd() {
|
|
18121
18537
|
if (this._logOpen) {
|
|
18122
18538
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
18123
|
-
|
|
18124
|
-
|
|
18539
|
+
import_core24.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
18540
|
+
import_core24.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
18125
18541
|
this._logOpen = false;
|
|
18126
18542
|
}
|
|
18127
18543
|
}
|
|
18128
18544
|
_drawCount = 0;
|
|
18129
18545
|
// TODO - fix typing of luma data types
|
|
18130
18546
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
18131
|
-
const TypedArrayConstructor =
|
|
18132
|
-
const typedArray = attribute instanceof
|
|
18547
|
+
const TypedArrayConstructor = import_core24.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
18548
|
+
const typedArray = attribute instanceof import_core24.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
18133
18549
|
return typedArray.toString();
|
|
18134
18550
|
}
|
|
18135
18551
|
};
|
|
@@ -18686,7 +19102,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18686
19102
|
this.parameterBuffer = device.createBuffer({
|
|
18687
19103
|
id: `${optimization.name}-parameters`,
|
|
18688
19104
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
18689
|
-
usage:
|
|
19105
|
+
usage: import_core25.Buffer.UNIFORM | import_core25.Buffer.COPY_DST
|
|
18690
19106
|
});
|
|
18691
19107
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
18692
19108
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -18971,7 +19387,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18971
19387
|
width: targetSize[0],
|
|
18972
19388
|
height: targetSize[1],
|
|
18973
19389
|
format: spec.format || device.preferredColorFormat,
|
|
18974
|
-
usage:
|
|
19390
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core25.Texture.STORAGE : 0),
|
|
18975
19391
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
18976
19392
|
});
|
|
18977
19393
|
const framebuffer = device.createFramebuffer({
|
|
@@ -19026,7 +19442,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
19026
19442
|
}
|
|
19027
19443
|
|
|
19028
19444
|
// src/modules/picking/picking-manager.ts
|
|
19029
|
-
var
|
|
19445
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
19030
19446
|
|
|
19031
19447
|
// src/modules/picking/picking-uniforms.ts
|
|
19032
19448
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -19290,13 +19706,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
19290
19706
|
format: "rgba8unorm",
|
|
19291
19707
|
width: 1,
|
|
19292
19708
|
height: 1,
|
|
19293
|
-
usage:
|
|
19709
|
+
usage: import_core26.Texture.RENDER_ATTACHMENT
|
|
19294
19710
|
});
|
|
19295
19711
|
const pickingTexture = this.device.createTexture({
|
|
19296
19712
|
format: "rg32sint",
|
|
19297
19713
|
width: 1,
|
|
19298
19714
|
height: 1,
|
|
19299
|
-
usage:
|
|
19715
|
+
usage: import_core26.Texture.RENDER_ATTACHMENT | import_core26.Texture.COPY_SRC
|
|
19300
19716
|
});
|
|
19301
19717
|
return this.device.createFramebuffer({
|
|
19302
19718
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -19308,7 +19724,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19308
19724
|
format: "rgba8unorm",
|
|
19309
19725
|
width: 1,
|
|
19310
19726
|
height: 1,
|
|
19311
|
-
usage:
|
|
19727
|
+
usage: import_core26.Texture.RENDER_ATTACHMENT | import_core26.Texture.COPY_SRC
|
|
19312
19728
|
});
|
|
19313
19729
|
return this.device.createFramebuffer({
|
|
19314
19730
|
colorAttachments: [pickingTexture],
|
|
@@ -19330,7 +19746,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19330
19746
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19331
19747
|
const readBuffer = this.device.createBuffer({
|
|
19332
19748
|
byteLength: layout.byteLength,
|
|
19333
|
-
usage:
|
|
19749
|
+
usage: import_core26.Buffer.COPY_DST | import_core26.Buffer.MAP_READ
|
|
19334
19750
|
});
|
|
19335
19751
|
try {
|
|
19336
19752
|
pickTexture.readBuffer(
|
|
@@ -19366,7 +19782,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19366
19782
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19367
19783
|
const readBuffer = this.device.createBuffer({
|
|
19368
19784
|
byteLength: layout.byteLength,
|
|
19369
|
-
usage:
|
|
19785
|
+
usage: import_core26.Buffer.COPY_DST | import_core26.Buffer.MAP_READ
|
|
19370
19786
|
});
|
|
19371
19787
|
try {
|
|
19372
19788
|
pickTexture.readBuffer(
|
|
@@ -20048,7 +20464,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20048
20464
|
}
|
|
20049
20465
|
|
|
20050
20466
|
// src/scenegraph/controllers/skin-controller.ts
|
|
20051
|
-
var
|
|
20467
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
20052
20468
|
var SkinController = class {
|
|
20053
20469
|
bindings;
|
|
20054
20470
|
scenes;
|
|
@@ -20079,7 +20495,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20079
20495
|
target: binding.jointMatrices
|
|
20080
20496
|
});
|
|
20081
20497
|
if (binding.skinJointMatrices) {
|
|
20082
|
-
if (binding.skinJointMatrices instanceof
|
|
20498
|
+
if (binding.skinJointMatrices instanceof import_core27.Buffer) {
|
|
20083
20499
|
binding.skinJointMatrices.write(binding.jointMatrices);
|
|
20084
20500
|
} else {
|
|
20085
20501
|
binding.skinJointMatrices.writeData(binding.jointMatrices, {
|
|
@@ -20111,7 +20527,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20111
20527
|
return device.createBuffer({
|
|
20112
20528
|
id: `${id}-skin-joint-matrices`,
|
|
20113
20529
|
byteLength: jointMatrices.byteLength,
|
|
20114
|
-
usage:
|
|
20530
|
+
usage: import_core27.Buffer.STORAGE | import_core27.Buffer.COPY_DST
|
|
20115
20531
|
});
|
|
20116
20532
|
}
|
|
20117
20533
|
const width = jointMatrices.length / 4;
|
|
@@ -20123,7 +20539,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20123
20539
|
format: "rgba32float",
|
|
20124
20540
|
width,
|
|
20125
20541
|
height: 1,
|
|
20126
|
-
usage:
|
|
20542
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
|
|
20127
20543
|
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
20128
20544
|
});
|
|
20129
20545
|
}
|
|
@@ -20166,7 +20582,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20166
20582
|
};
|
|
20167
20583
|
|
|
20168
20584
|
// src/scenegraph/controllers/billboard-controller.ts
|
|
20169
|
-
var
|
|
20585
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
20170
20586
|
var BillboardController = class {
|
|
20171
20587
|
scenes;
|
|
20172
20588
|
bindings = /* @__PURE__ */ new Map();
|
|
@@ -20177,8 +20593,8 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20177
20593
|
const { definition } = binding;
|
|
20178
20594
|
const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
|
|
20179
20595
|
const up = new Vector3(definition.up || [0, 1, 0]);
|
|
20180
|
-
(0,
|
|
20181
|
-
(0,
|
|
20596
|
+
(0, import_core28.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
|
|
20597
|
+
(0, import_core28.assert)(
|
|
20182
20598
|
new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
|
|
20183
20599
|
);
|
|
20184
20600
|
this.bindings.set(binding.node, binding);
|
|
@@ -20188,7 +20604,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20188
20604
|
getDrawEntries(options) {
|
|
20189
20605
|
const { sceneIndex = 0, cameraId = "default" } = options;
|
|
20190
20606
|
const scene = this.scenes[sceneIndex];
|
|
20191
|
-
(0,
|
|
20607
|
+
(0, import_core28.assert)(scene);
|
|
20192
20608
|
const viewMatrix = new Matrix4(options.viewMatrix);
|
|
20193
20609
|
const cameraMatrix = new Matrix4(viewMatrix).invert();
|
|
20194
20610
|
const cameraPosition = new Vector3(cameraMatrix.getTranslation());
|
|
@@ -20296,8 +20712,99 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20296
20712
|
]);
|
|
20297
20713
|
}
|
|
20298
20714
|
|
|
20715
|
+
// src/scenegraph/controllers/punctual-light-controller.ts
|
|
20716
|
+
var import_shaders8 = __toESM(require_shaders(), 1);
|
|
20717
|
+
var PunctualLightController = class {
|
|
20718
|
+
constructor(bindings, useByteColors = true) {
|
|
20719
|
+
this.bindings = bindings;
|
|
20720
|
+
this.useByteColors = useByteColors;
|
|
20721
|
+
this.update();
|
|
20722
|
+
}
|
|
20723
|
+
bindings;
|
|
20724
|
+
useByteColors;
|
|
20725
|
+
lights = [];
|
|
20726
|
+
/** Refreshes the stable light array after node or light properties change. */
|
|
20727
|
+
update() {
|
|
20728
|
+
this.lights.length = 0;
|
|
20729
|
+
for (const { path, definition } of this.bindings) {
|
|
20730
|
+
if (!path.length || path.some((node) => !node.display)) continue;
|
|
20731
|
+
const worldMatrix = new Matrix4();
|
|
20732
|
+
for (const node of path) worldMatrix.multiplyRight(node.matrix);
|
|
20733
|
+
const light = makePunctualLight(definition, worldMatrix, this.useByteColors);
|
|
20734
|
+
if (light) this.lights.push(light);
|
|
20735
|
+
}
|
|
20736
|
+
}
|
|
20737
|
+
};
|
|
20738
|
+
function makePunctualLight(definition, worldMatrix, useByteColors) {
|
|
20739
|
+
const color = normalizePunctualLightColor(definition.color || [1, 1, 1], useByteColors);
|
|
20740
|
+
const intensity = definition.intensity ?? 1;
|
|
20741
|
+
switch (definition.type) {
|
|
20742
|
+
case "directional":
|
|
20743
|
+
return makeDirectionalLight(worldMatrix, color, intensity);
|
|
20744
|
+
case "point":
|
|
20745
|
+
return makePointLight(worldMatrix, color, intensity, definition.range);
|
|
20746
|
+
case "spot":
|
|
20747
|
+
return makeSpotLight(worldMatrix, color, intensity, definition.range, definition.spot);
|
|
20748
|
+
default:
|
|
20749
|
+
return void 0;
|
|
20750
|
+
}
|
|
20751
|
+
}
|
|
20752
|
+
function normalizePunctualLightColor(color, useByteColors) {
|
|
20753
|
+
if (useByteColors) {
|
|
20754
|
+
return color.map((component) => component * 255);
|
|
20755
|
+
}
|
|
20756
|
+
return (0, import_shaders8.normalizeByteColor3)(color, false);
|
|
20757
|
+
}
|
|
20758
|
+
function makePointLight(worldMatrix, color, intensity, range) {
|
|
20759
|
+
const position = getLightPosition(worldMatrix);
|
|
20760
|
+
let attenuation = [1, 0, 0];
|
|
20761
|
+
if (range !== void 0 && range > 0) {
|
|
20762
|
+
attenuation = [1, 0, 1 / (range * range)];
|
|
20763
|
+
}
|
|
20764
|
+
return {
|
|
20765
|
+
type: "point",
|
|
20766
|
+
position,
|
|
20767
|
+
color,
|
|
20768
|
+
intensity,
|
|
20769
|
+
attenuation
|
|
20770
|
+
};
|
|
20771
|
+
}
|
|
20772
|
+
function makeDirectionalLight(worldMatrix, color, intensity) {
|
|
20773
|
+
const direction = getLightDirection(worldMatrix);
|
|
20774
|
+
return {
|
|
20775
|
+
type: "directional",
|
|
20776
|
+
direction,
|
|
20777
|
+
color,
|
|
20778
|
+
intensity
|
|
20779
|
+
};
|
|
20780
|
+
}
|
|
20781
|
+
function makeSpotLight(worldMatrix, color, intensity, range, spot = {}) {
|
|
20782
|
+
const position = getLightPosition(worldMatrix);
|
|
20783
|
+
const direction = getLightDirection(worldMatrix);
|
|
20784
|
+
let attenuation = [1, 0, 0];
|
|
20785
|
+
if (range !== void 0 && range > 0) {
|
|
20786
|
+
attenuation = [1, 0, 1 / (range * range)];
|
|
20787
|
+
}
|
|
20788
|
+
return {
|
|
20789
|
+
type: "spot",
|
|
20790
|
+
position,
|
|
20791
|
+
direction,
|
|
20792
|
+
color,
|
|
20793
|
+
intensity,
|
|
20794
|
+
attenuation,
|
|
20795
|
+
innerConeAngle: spot.innerConeAngle ?? 0,
|
|
20796
|
+
outerConeAngle: spot.outerConeAngle ?? Math.PI / 4
|
|
20797
|
+
};
|
|
20798
|
+
}
|
|
20799
|
+
function getLightPosition(worldMatrix) {
|
|
20800
|
+
return worldMatrix.transformAsPoint([0, 0, 0]);
|
|
20801
|
+
}
|
|
20802
|
+
function getLightDirection(worldMatrix) {
|
|
20803
|
+
return worldMatrix.transformAsVector([0, 0, -1]);
|
|
20804
|
+
}
|
|
20805
|
+
|
|
20299
20806
|
// src/scenegraph/controllers/area-light-controller.ts
|
|
20300
|
-
var
|
|
20807
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
20301
20808
|
var AreaLightController = class {
|
|
20302
20809
|
scenes;
|
|
20303
20810
|
matrixAuthoredNodes = /* @__PURE__ */ new Set();
|
|
@@ -20307,11 +20814,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20307
20814
|
for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
|
|
20308
20815
|
for (const { node, definition, matrixAuthored } of bindings) {
|
|
20309
20816
|
if (matrixAuthored) this.matrixAuthoredNodes.add(node);
|
|
20310
|
-
(0,
|
|
20311
|
-
(0,
|
|
20312
|
-
(0,
|
|
20313
|
-
(0,
|
|
20314
|
-
(0,
|
|
20817
|
+
(0, import_core29.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
|
|
20818
|
+
(0, import_core29.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
|
|
20819
|
+
(0, import_core29.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
|
|
20820
|
+
(0, import_core29.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
|
|
20821
|
+
(0, import_core29.assert)(
|
|
20315
20822
|
(definition.color || [1, 1, 1]).every(
|
|
20316
20823
|
(component) => Number.isFinite(component) && component >= 0
|
|
20317
20824
|
)
|
|
@@ -20377,17 +20884,17 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20377
20884
|
function getMatrixRotation(matrix) {
|
|
20378
20885
|
const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
|
|
20379
20886
|
const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
|
|
20380
|
-
(0,
|
|
20887
|
+
(0, import_core29.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
|
|
20381
20888
|
horizontal.normalize();
|
|
20382
20889
|
vertical.normalize();
|
|
20383
20890
|
vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
|
|
20384
|
-
(0,
|
|
20891
|
+
(0, import_core29.assert)(vertical.magnitude() > 1e-8);
|
|
20385
20892
|
vertical.normalize();
|
|
20386
20893
|
const forward = new Vector3(horizontal).cross(vertical).normalize();
|
|
20387
20894
|
const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
|
|
20388
|
-
(0,
|
|
20895
|
+
(0, import_core29.assert)(authoredForward.magnitude() > 0);
|
|
20389
20896
|
authoredForward.normalize();
|
|
20390
|
-
(0,
|
|
20897
|
+
(0, import_core29.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
|
|
20391
20898
|
if (forward.dot(authoredForward) < 0) forward.negate();
|
|
20392
20899
|
return new Matrix4([
|
|
20393
20900
|
horizontal[0],
|
|
@@ -20945,15 +21452,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20945
21452
|
};
|
|
20946
21453
|
|
|
20947
21454
|
// src/audio/audio-graph.ts
|
|
20948
|
-
var
|
|
21455
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
20949
21456
|
var AudioGraph = class {
|
|
20950
21457
|
constructor(definition, context, destination, getEmitterInputs) {
|
|
20951
21458
|
this.definition = definition;
|
|
20952
21459
|
for (const node of definition.nodes)
|
|
20953
|
-
(0,
|
|
21460
|
+
(0, import_core30.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
|
|
20954
21461
|
const validateEndpoint = (index, port = 0) => {
|
|
20955
|
-
(0,
|
|
20956
|
-
(0,
|
|
21462
|
+
(0, import_core30.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
|
|
21463
|
+
(0, import_core30.assert)(Number.isInteger(port) && port >= 0);
|
|
20957
21464
|
};
|
|
20958
21465
|
for (const edge of definition.connections) {
|
|
20959
21466
|
validateEndpoint(edge.from.node, edge.from.output);
|
|
@@ -20961,16 +21468,16 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20961
21468
|
}
|
|
20962
21469
|
for (const input of definition.inputs || []) {
|
|
20963
21470
|
validateEndpoint(input.node, input.input);
|
|
20964
|
-
(0,
|
|
21471
|
+
(0, import_core30.assert)(Number.isInteger(input.source) && input.source >= 0);
|
|
20965
21472
|
}
|
|
20966
21473
|
for (const output of definition.outputs || []) {
|
|
20967
21474
|
validateEndpoint(output.node, output.output);
|
|
20968
|
-
(0,
|
|
21475
|
+
(0, import_core30.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
|
|
20969
21476
|
}
|
|
20970
21477
|
const visiting = /* @__PURE__ */ new Set();
|
|
20971
21478
|
const visited = /* @__PURE__ */ new Set();
|
|
20972
21479
|
const visit = (index) => {
|
|
20973
|
-
(0,
|
|
21480
|
+
(0, import_core30.assert)(definition.nodes[index] && !visiting.has(index));
|
|
20974
21481
|
if (visited.has(index)) return;
|
|
20975
21482
|
visiting.add(index);
|
|
20976
21483
|
for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
|
|
@@ -21031,7 +21538,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21031
21538
|
/** Apply a scene-driven gain change using the authored transition shape. */
|
|
21032
21539
|
setGain(index, gain, time = this.nodes[index].context.currentTime) {
|
|
21033
21540
|
const definition = this.definition.nodes[index];
|
|
21034
|
-
(0,
|
|
21541
|
+
(0, import_core30.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
|
|
21035
21542
|
const parameter = this.nodes[index].gain;
|
|
21036
21543
|
const duration = definition.params.duration ?? 0;
|
|
21037
21544
|
const initialGain = parameter.value;
|
|
@@ -21041,7 +21548,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21041
21548
|
parameter.setValueAtTime(gain, time);
|
|
21042
21549
|
} else if (definition.params.interpolation === "custom") {
|
|
21043
21550
|
const curve = definition.params.curve;
|
|
21044
|
-
(0,
|
|
21551
|
+
(0, import_core30.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
|
|
21045
21552
|
parameter.setValueCurveAtTime(
|
|
21046
21553
|
Float32Array.from(curve, (value) => value * gain),
|
|
21047
21554
|
time,
|
|
@@ -21126,7 +21633,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21126
21633
|
}
|
|
21127
21634
|
|
|
21128
21635
|
// src/audio/audio-environment.ts
|
|
21129
|
-
var
|
|
21636
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
21130
21637
|
function selectAudioEnvironmentZone(zones, position) {
|
|
21131
21638
|
let selected;
|
|
21132
21639
|
for (const zone of zones) {
|
|
@@ -21219,7 +21726,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21219
21726
|
}
|
|
21220
21727
|
};
|
|
21221
21728
|
function createParametricAudioResponse(context, parameters) {
|
|
21222
|
-
(0,
|
|
21729
|
+
(0, import_core31.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
|
|
21223
21730
|
const presets = {
|
|
21224
21731
|
generic: [1.49, 0.83, 7e-3, 0.011],
|
|
21225
21732
|
smallRoom: [0.4, 0.83, 2e-3, 3e-3],
|
|
@@ -21236,12 +21743,12 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21236
21743
|
underwater: [1.49, 0.1, 7e-3, 0.011]
|
|
21237
21744
|
};
|
|
21238
21745
|
const preset = parameters.preset ? presets[parameters.preset] : void 0;
|
|
21239
|
-
(0,
|
|
21746
|
+
(0, import_core31.assert)(!parameters.preset || preset);
|
|
21240
21747
|
const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
|
|
21241
21748
|
const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
|
|
21242
21749
|
const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
|
|
21243
21750
|
const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
|
|
21244
|
-
(0,
|
|
21751
|
+
(0, import_core31.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
|
|
21245
21752
|
const response = context.createBuffer(
|
|
21246
21753
|
2,
|
|
21247
21754
|
Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
|
|
@@ -21265,7 +21772,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21265
21772
|
}
|
|
21266
21773
|
|
|
21267
21774
|
// src/audio/audio-controller.ts
|
|
21268
|
-
var
|
|
21775
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
21269
21776
|
var AudioController = class {
|
|
21270
21777
|
gain;
|
|
21271
21778
|
definition;
|
|
@@ -21375,25 +21882,25 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21375
21882
|
/** Change a graph gain using its authored interpolation and duration. */
|
|
21376
21883
|
setGraphGain(graphIndex, nodeIndex, gain) {
|
|
21377
21884
|
const graph = this.graphs.get(graphIndex);
|
|
21378
|
-
(0,
|
|
21885
|
+
(0, import_core32.assert)(!this.destroyed && graph);
|
|
21379
21886
|
graph.setGain(nodeIndex, gain);
|
|
21380
21887
|
}
|
|
21381
21888
|
startSource(sourceIndex, startTime, autoplayOnly, connect) {
|
|
21382
21889
|
const definition = this.definition.sources[sourceIndex];
|
|
21383
|
-
(0,
|
|
21890
|
+
(0, import_core32.assert)(definition);
|
|
21384
21891
|
if (autoplayOnly && !definition.autoPlay) return;
|
|
21385
21892
|
const context = this.options.audioContext;
|
|
21386
21893
|
const extended = definition.graph;
|
|
21387
21894
|
const oscillator = extended?.oscillator;
|
|
21388
|
-
(0,
|
|
21895
|
+
(0, import_core32.assert)(!(definition.audio !== void 0 && oscillator));
|
|
21389
21896
|
let source4;
|
|
21390
21897
|
if (oscillator) {
|
|
21391
21898
|
const node = context.createOscillator();
|
|
21392
21899
|
node.frequency.value = oscillator.frequency ?? 440;
|
|
21393
21900
|
node.detune.value = oscillator.detune ?? 0;
|
|
21394
|
-
(0,
|
|
21901
|
+
(0, import_core32.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
|
|
21395
21902
|
if (oscillator.type === "custom") {
|
|
21396
|
-
(0,
|
|
21903
|
+
(0, import_core32.assert)(oscillator.periodicWave);
|
|
21397
21904
|
node.setPeriodicWave(
|
|
21398
21905
|
context.createPeriodicWave(
|
|
21399
21906
|
new Float32Array(oscillator.periodicWave.real),
|
|
@@ -21404,7 +21911,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21404
21911
|
source4 = node;
|
|
21405
21912
|
} else {
|
|
21406
21913
|
const node = context.createBufferSource();
|
|
21407
|
-
(0,
|
|
21914
|
+
(0, import_core32.assert)(definition.audio !== void 0);
|
|
21408
21915
|
node.buffer = this.buffers.get(definition.audio);
|
|
21409
21916
|
node.loop = definition.loop ?? false;
|
|
21410
21917
|
node.loopStart = extended?.loopStart ?? 0;
|
|
@@ -21549,15 +22056,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21549
22056
|
}
|
|
21550
22057
|
addEmitter(index, node) {
|
|
21551
22058
|
const definition = this.definition.emitters[index];
|
|
21552
|
-
(0,
|
|
22059
|
+
(0, import_core32.assert)(
|
|
21553
22060
|
definition && (definition.type === "global" || definition.type === "positional" && node)
|
|
21554
22061
|
);
|
|
21555
|
-
(0,
|
|
22062
|
+
(0, import_core32.assert)(
|
|
21556
22063
|
!definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
|
|
21557
22064
|
);
|
|
21558
22065
|
for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
|
|
21559
22066
|
const source4 = this.definition.sources[sourceIndex];
|
|
21560
|
-
(0,
|
|
22067
|
+
(0, import_core32.assert)(
|
|
21561
22068
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21562
22069
|
);
|
|
21563
22070
|
}
|
|
@@ -21602,7 +22109,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21602
22109
|
const audioIndices = new Set(
|
|
21603
22110
|
[...sourceIndices].map((index) => {
|
|
21604
22111
|
const source4 = this.definition.sources[index];
|
|
21605
|
-
(0,
|
|
22112
|
+
(0, import_core32.assert)(
|
|
21606
22113
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21607
22114
|
);
|
|
21608
22115
|
return source4.audio;
|
|
@@ -21639,7 +22146,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21639
22146
|
const reverb = environment.reverb;
|
|
21640
22147
|
if (!reverb) return;
|
|
21641
22148
|
const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
|
|
21642
|
-
(0,
|
|
22149
|
+
(0, import_core32.assert)(response);
|
|
21643
22150
|
const bus = new AudioReverbBus(audioContext, response, this.gain, {
|
|
21644
22151
|
...reverb,
|
|
21645
22152
|
normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
|
|
@@ -21744,11 +22251,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21744
22251
|
};
|
|
21745
22252
|
|
|
21746
22253
|
// src/modules/picking/legacy-color-picking.ts
|
|
21747
|
-
var
|
|
21748
|
-
var legacyColorPicking =
|
|
22254
|
+
var import_shaders9 = __toESM(require_shaders(), 1);
|
|
22255
|
+
var legacyColorPicking = import_shaders9.picking;
|
|
21749
22256
|
|
|
21750
22257
|
// src/geometry/ring-geometry.ts
|
|
21751
|
-
var
|
|
22258
|
+
var import_core33 = __toESM(require_core(), 1);
|
|
21752
22259
|
var RingGeometry = class extends Geometry2 {
|
|
21753
22260
|
constructor(props = {}) {
|
|
21754
22261
|
const {
|
|
@@ -21759,7 +22266,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21759
22266
|
startAngle = 0,
|
|
21760
22267
|
angle: angle2 = Math.PI * 2
|
|
21761
22268
|
} = props;
|
|
21762
|
-
(0,
|
|
22269
|
+
(0, import_core33.assert)(
|
|
21763
22270
|
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
|
|
21764
22271
|
);
|
|
21765
22272
|
const halfHeight = height / 2;
|
|
@@ -21943,7 +22450,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21943
22450
|
};
|
|
21944
22451
|
|
|
21945
22452
|
// src/scenegraph/controllers/morph-controller.ts
|
|
21946
|
-
var
|
|
22453
|
+
var import_core34 = __toESM(require_core(), 1);
|
|
21947
22454
|
function setMorphWeights(node, weights) {
|
|
21948
22455
|
node.userData["morphWeights"] = [...weights];
|
|
21949
22456
|
const meshes = node.userData["morphMeshes"] || [];
|
|
@@ -21970,7 +22477,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21970
22477
|
function updateMorphWeights(state, weights) {
|
|
21971
22478
|
state.values.fill(0);
|
|
21972
22479
|
state.values.set(weights.slice(0, state.values.length));
|
|
21973
|
-
if (state.data instanceof
|
|
22480
|
+
if (state.data instanceof import_core34.Buffer) {
|
|
21974
22481
|
state.data.write(state.values);
|
|
21975
22482
|
} else {
|
|
21976
22483
|
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|
|
@@ -21993,6 +22500,10 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21993
22500
|
return Array.from(node.userData["morphWeights"] ?? []);
|
|
21994
22501
|
case "visibility":
|
|
21995
22502
|
return [node.display ? 1 : 0];
|
|
22503
|
+
case "selectable":
|
|
22504
|
+
return [node.selectable ? 1 : 0];
|
|
22505
|
+
case "hoverable":
|
|
22506
|
+
return [node.hoverable ? 1 : 0];
|
|
21996
22507
|
}
|
|
21997
22508
|
},
|
|
21998
22509
|
setValue: (value) => {
|
|
@@ -22009,6 +22520,12 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22009
22520
|
case "weights":
|
|
22010
22521
|
setMorphWeights(node, value);
|
|
22011
22522
|
break;
|
|
22523
|
+
case "selectable":
|
|
22524
|
+
node.setProps({ selectable: value[0] !== 0 });
|
|
22525
|
+
break;
|
|
22526
|
+
case "hoverable":
|
|
22527
|
+
node.setProps({ hoverable: value[0] !== 0 });
|
|
22528
|
+
break;
|
|
22012
22529
|
case "visibility":
|
|
22013
22530
|
node.setProps({ display: value[0] !== 0 });
|
|
22014
22531
|
options.onVisibilityChange?.();
|
|
@@ -22326,7 +22843,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
22326
22843
|
}
|
|
22327
22844
|
|
|
22328
22845
|
// src/lighting/ltc-textures.ts
|
|
22329
|
-
var
|
|
22846
|
+
var import_shaders10 = __toESM(require_shaders(), 1);
|
|
22330
22847
|
|
|
22331
22848
|
// src/lighting/ltc-data.ts
|
|
22332
22849
|
var LTC_MATRIX_DATA = [
|
|
@@ -55109,7 +55626,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
55109
55626
|
width: 64,
|
|
55110
55627
|
height: 64,
|
|
55111
55628
|
format: "rgba16float",
|
|
55112
|
-
data: Uint16Array.from(data,
|
|
55629
|
+
data: Uint16Array.from(data, import_shaders10.toHalfFloat),
|
|
55113
55630
|
mipLevels: 1,
|
|
55114
55631
|
sampler: { minFilter: "nearest", magFilter: "nearest" }
|
|
55115
55632
|
});
|