@luma.gl/engine 10.0.0-alpha.9 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -4
- package/THIRD-PARTY-NOTICES.md +185 -0
- package/dist/animation/node-animation-binding.cjs +10 -0
- package/dist/animation/node-animation-binding.d.ts +1 -1
- package/dist/animation/node-animation-binding.d.ts.map +1 -1
- package/dist/animation/node-animation-binding.js +10 -0
- package/dist/animation/node-animation-binding.js.map +1 -1
- package/dist/arrow/index.cjs.map +2 -2
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +12 -13
- 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 +22 -17
- 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/compute/computation.cjs +1 -1
- package/dist/compute/computation.js +1 -1
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts +2 -2
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +887 -381
- 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/gltf/gltf/animations/animations.d.ts +1 -1
- package/dist/gltf/gltf/animations/animations.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.cjs +3 -0
- package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.js +4 -0
- package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +80 -12
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +8 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +82 -14
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.cjs +6 -1
- package/dist/gltf/gltf/gltf-billboard.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.js +6 -1
- package/dist/gltf/gltf/gltf-billboard.js.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.cjs +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
- package/dist/gltf/index.cjs +2 -0
- package/dist/gltf/index.cjs.map +3 -3
- package/dist/gltf/index.d.ts +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 +36 -72
- package/dist/gltf/parsers/parse-gltf-lights.d.ts +6 -2
- package/dist/gltf/parsers/parse-gltf-lights.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.js +34 -91
- package/dist/gltf/parsers/parse-gltf-lights.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-metadata.cjs +60 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts +5 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts.map +1 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js +39 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js.map +1 -0
- package/dist/gltf/parsers/parse-gltf.cjs +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 +13 -3
- package/dist/gltf/parsers/parse-pbr-material.d.ts +7 -2
- package/dist/gltf/parsers/parse-pbr-material.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-pbr-material.js +17 -5
- package/dist/gltf/parsers/parse-pbr-material.js.map +1 -1
- package/dist/gltf/pbr/pbr-environment.cjs +21 -3
- package/dist/gltf/pbr/pbr-environment.d.ts +3 -0
- package/dist/gltf/pbr/pbr-environment.d.ts.map +1 -1
- package/dist/gltf/pbr/pbr-environment.js +19 -1
- package/dist/gltf/pbr/pbr-environment.js.map +1 -1
- package/dist/gltf/pbr/pbr-material.d.ts +3 -3
- package/dist/gltf/pbr/pbr-material.d.ts.map +1 -1
- package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-json-schema.js +1 -0
- package/dist/gltf/types/gltf-json-schema.js.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.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 +1 -1
- package/dist/graph/models/path/path-attribute-model.cjs +4 -1
- package/dist/graph/models/path/path-attribute-model.d.ts +3 -1
- package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-attribute-model.js +6 -1
- package/dist/graph/models/path/path-attribute-model.js.map +1 -1
- package/dist/graph/models/path/path-storage-model.cjs +4 -1
- package/dist/graph/models/path/path-storage-model.d.ts +3 -1
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-storage-model.js +6 -1
- package/dist/graph/models/path/path-storage-model.js.map +1 -1
- package/dist/graph/physics/index.cjs.map +2 -2
- package/dist/graph/physics/physics-controller.cjs +42 -0
- package/dist/graph/physics/physics-controller.d.ts +12 -1
- package/dist/graph/physics/physics-controller.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller.js +41 -0
- package/dist/graph/physics/physics-controller.js.map +1 -1
- package/dist/graph/physics/scenegraph-instance.cjs +7 -0
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +8 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/tables/gpu-table-model.cjs +2 -2
- package/dist/graph/tables/gpu-table-model.d.ts +2 -1
- package/dist/graph/tables/gpu-table-model.d.ts.map +1 -1
- package/dist/graph/tables/gpu-table-model.js +2 -2
- package/dist/graph/tables/gpu-table-model.js.map +1 -1
- package/dist/graph/tables/index.cjs.map +1 -1
- package/dist/index.cjs +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 +31 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -0
- package/dist/lighting/ambient-occlusion-pass.js +108 -0
- package/dist/lighting/ambient-occlusion-pass.js.map +1 -0
- package/dist/lighting/clustered-light-grid.cjs +378 -0
- package/dist/lighting/clustered-light-grid.d.ts +94 -0
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -0
- package/dist/lighting/clustered-light-grid.js +370 -0
- package/dist/lighting/clustered-light-grid.js.map +1 -0
- package/dist/lighting/contact-shadow-composite.cjs +80 -0
- package/dist/lighting/contact-shadow-composite.d.ts +6 -0
- package/dist/lighting/contact-shadow-composite.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-composite.js +59 -0
- package/dist/lighting/contact-shadow-composite.js.map +1 -0
- package/dist/lighting/contact-shadow-pass.cjs +102 -0
- package/dist/lighting/contact-shadow-pass.d.ts +23 -0
- package/dist/lighting/contact-shadow-pass.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-pass.js +85 -0
- package/dist/lighting/contact-shadow-pass.js.map +1 -0
- package/dist/lighting/index.cjs +128 -0
- package/dist/lighting/index.cjs.map +6 -0
- package/dist/lighting/index.d.ts +35 -0
- package/dist/lighting/index.d.ts.map +1 -0
- package/dist/lighting/index.js +22 -0
- package/dist/lighting/index.js.map +1 -0
- package/dist/lighting/lightmap-atlas.cjs +246 -0
- package/dist/lighting/lightmap-atlas.d.ts +53 -0
- package/dist/lighting/lightmap-atlas.d.ts.map +1 -0
- package/dist/lighting/lightmap-atlas.js +279 -0
- package/dist/lighting/lightmap-atlas.js.map +1 -0
- package/dist/lighting/lightmap-baker.cjs +238 -0
- package/dist/lighting/lightmap-baker.d.ts +62 -0
- package/dist/lighting/lightmap-baker.d.ts.map +1 -0
- package/dist/lighting/lightmap-baker.js +236 -0
- package/dist/lighting/lightmap-baker.js.map +1 -0
- package/dist/lighting/lightmap-data.cjs +117 -0
- package/dist/lighting/lightmap-data.d.ts +20 -0
- package/dist/lighting/lightmap-data.d.ts.map +1 -0
- package/dist/lighting/lightmap-data.js +110 -0
- package/dist/lighting/lightmap-data.js.map +1 -0
- package/dist/lighting/lightmap-environment.cjs +61 -0
- package/dist/lighting/lightmap-environment.d.ts +18 -0
- package/dist/lighting/lightmap-environment.d.ts.map +1 -0
- package/dist/lighting/lightmap-environment.js +46 -0
- package/dist/lighting/lightmap-environment.js.map +1 -0
- package/dist/lighting/pbr-environment.cjs +45 -0
- package/dist/lighting/pbr-environment.d.ts +25 -0
- package/dist/lighting/pbr-environment.d.ts.map +1 -0
- package/dist/lighting/pbr-environment.js +30 -0
- package/dist/lighting/pbr-environment.js.map +1 -0
- package/dist/lighting/pbr-material.cjs +75 -0
- package/dist/lighting/pbr-material.d.ts +33 -0
- package/dist/lighting/pbr-material.d.ts.map +1 -0
- package/dist/lighting/pbr-material.js +52 -0
- package/dist/lighting/pbr-material.js.map +1 -0
- package/dist/lighting/pbr-model.cjs +579 -0
- package/dist/lighting/pbr-model.d.ts +45 -0
- package/dist/lighting/pbr-model.d.ts.map +1 -0
- package/dist/lighting/pbr-model.js +545 -0
- package/dist/lighting/pbr-model.js.map +1 -0
- package/dist/lighting/pbr-surface-pass.cjs +116 -0
- package/dist/lighting/pbr-surface-pass.d.ts +35 -0
- package/dist/lighting/pbr-surface-pass.d.ts.map +1 -0
- package/dist/lighting/pbr-surface-pass.js +98 -0
- package/dist/lighting/pbr-surface-pass.js.map +1 -0
- package/dist/lighting/prefiltered-environment.cjs +275 -0
- package/dist/lighting/prefiltered-environment.d.ts +56 -0
- package/dist/lighting/prefiltered-environment.d.ts.map +1 -0
- package/dist/lighting/prefiltered-environment.js +264 -0
- package/dist/lighting/prefiltered-environment.js.map +1 -0
- package/dist/lighting/reflection-probe.cjs +321 -0
- package/dist/lighting/reflection-probe.d.ts +77 -0
- package/dist/lighting/reflection-probe.d.ts.map +1 -0
- package/dist/lighting/reflection-probe.js +298 -0
- package/dist/lighting/reflection-probe.js.map +1 -0
- package/dist/lighting/shadow-map-renderer.cjs +631 -0
- package/dist/lighting/shadow-map-renderer.d.ts +92 -0
- package/dist/lighting/shadow-map-renderer.d.ts.map +1 -0
- package/dist/lighting/shadow-map-renderer.js +622 -0
- package/dist/lighting/shadow-map-renderer.js.map +1 -0
- package/dist/lighting/shadow-quality.cjs +58 -0
- package/dist/lighting/shadow-quality.d.ts +13 -0
- package/dist/lighting/shadow-quality.d.ts.map +1 -0
- package/dist/lighting/shadow-quality.js +37 -0
- package/dist/lighting/shadow-quality.js.map +1 -0
- package/dist/material/material.cjs +3 -0
- package/dist/material/material.d.ts +2 -0
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +3 -0
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-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/models/light-model-utils.cjs +2 -2
- package/dist/models/light-model-utils.d.ts +2 -1
- package/dist/models/light-model-utils.d.ts.map +1 -1
- package/dist/models/light-model-utils.js +2 -2
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/scenegraph/controllers/punctual-light-controller.cjs +121 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js +117 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js.map +1 -0
- package/dist/scenegraph/scene-metadata.cjs +43 -0
- package/dist/scenegraph/scene-metadata.d.ts +9 -0
- package/dist/scenegraph/scene-metadata.d.ts.map +1 -0
- package/dist/scenegraph/scene-metadata.js +21 -0
- package/dist/scenegraph/scene-metadata.js.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.cjs +99 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts +47 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.js +79 -0
- package/dist/scenegraph/scenegraph-interaction.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.cjs +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +10 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/text/experimental.cjs.map +1 -1
- package/dist/text/fonts/atlas/text-utils.cjs +1 -1
- package/dist/text/fonts/atlas/text-utils.js +1 -1
- package/dist/text/fonts/atlas/text-utils.js.map +1 -1
- package/dist/text/fonts/index.cjs.map +1 -1
- package/dist/text/index.cjs +2 -0
- package/dist/text/index.cjs.map +2 -2
- package/dist/text/index.d.ts +1 -1
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +1 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/text-2d/index.cjs +3 -0
- package/dist/text/text-2d/index.d.ts +1 -0
- package/dist/text/text-2d/index.d.ts.map +1 -1
- package/dist/text/text-2d/index.js +1 -0
- package/dist/text/text-2d/index.js.map +1 -1
- package/dist/text/text-2d/model-utils/text-code-point-source.cjs +41 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.d.ts +8 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.d.ts.map +1 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.js +23 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.js.map +1 -0
- package/dist/text/text-2d/models/text-attribute-model.cjs +4 -1
- package/dist/text/text-2d/models/text-attribute-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-attribute-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-attribute-model.js +6 -1
- package/dist/text/text-2d/models/text-attribute-model.js.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.cjs +4 -1
- package/dist/text/text-2d/models/text-dictionary-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-dictionary-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.js +6 -1
- package/dist/text/text-2d/models/text-dictionary-model.js.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.cjs +4 -1
- package/dist/text/text-2d/models/text-storage-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-storage-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.js +6 -1
- package/dist/text/text-2d/models/text-storage-model.js.map +1 -1
- package/licenses/cesium.txt +207 -0
- package/licenses/deck-community.txt +19 -0
- package/licenses/deck.txt +19 -0
- package/licenses/glfx.txt +19 -0
- package/licenses/gltf-loader-ts.txt +21 -0
- package/licenses/magenta-font.txt +13 -0
- package/licenses/nvidia-fxaa.txt +25 -0
- package/licenses/philogl.txt +19 -0
- package/licenses/spark.txt +21 -0
- package/licenses/three.txt +21 -0
- package/package.json +17 -9
- package/src/animation/node-animation-binding.ts +18 -1
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +23 -19
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +1 -1
- package/src/compute/computation.ts +1 -1
- package/src/compute/swap.ts +2 -2
- package/src/dynamic-texture/video-texture.ts +9 -3
- package/src/effects/passes/postprocessing/fxaa/fxaa.ts +2 -1
- package/src/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/denoise.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/noise.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/sepia.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/vibrance.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/vignette.ts +2 -0
- package/src/gltf/gltf/animations/animations.ts +8 -1
- package/src/gltf/gltf/create-gltf-model.ts +4 -0
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
- package/src/gltf/gltf/gltf-billboard.ts +6 -1
- package/src/gltf/gltf/gltf-extension-support.ts +2 -2
- package/src/gltf/index.ts +1 -0
- package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
- package/src/gltf/parsers/parse-gltf-lights.ts +42 -130
- package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
- package/src/gltf/parsers/parse-gltf.ts +11 -2
- package/src/gltf/parsers/parse-pbr-material.ts +35 -7
- package/src/gltf/pbr/pbr-environment.ts +27 -1
- package/src/gltf/pbr/pbr-material.ts +8 -3
- package/src/gltf/types/gltf-json-schema.ts +1 -0
- package/src/gltf/types/gltf-postprocessed-schema.ts +1 -0
- package/src/graph/models/path/path-attribute-model.ts +10 -1
- package/src/graph/models/path/path-storage-model.ts +10 -1
- package/src/graph/physics/physics-controller.ts +55 -1
- package/src/graph/physics/scenegraph-instance.ts +10 -0
- package/src/graph/tables/gpu-table-model.ts +3 -2
- package/src/index.ts +17 -0
- package/src/lighting/ambient-occlusion-pass.ts +130 -0
- package/src/lighting/clustered-light-grid.ts +481 -0
- package/src/lighting/contact-shadow-composite.ts +67 -0
- package/src/lighting/contact-shadow-pass.ts +107 -0
- package/src/lighting/index.ts +125 -0
- package/src/lighting/lightmap-atlas.ts +348 -0
- package/src/lighting/lightmap-baker.ts +306 -0
- package/src/lighting/lightmap-data.ts +138 -0
- package/src/lighting/lightmap-environment.ts +70 -0
- package/src/lighting/pbr-environment.ts +55 -0
- package/src/lighting/pbr-material.ts +85 -0
- package/src/lighting/pbr-model.ts +608 -0
- package/src/lighting/pbr-surface-pass.ts +122 -0
- package/src/lighting/prefiltered-environment.ts +354 -0
- package/src/lighting/reflection-probe.ts +360 -0
- package/src/lighting/shadow-map-renderer.ts +918 -0
- package/src/lighting/shadow-quality.ts +50 -0
- package/src/material/material.ts +3 -0
- package/src/model/gpu-vector-model.ts +42 -4
- package/src/models/light-model-utils.ts +3 -2
- package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
- package/src/scenegraph/scene-metadata.ts +23 -0
- package/src/scenegraph/scenegraph-interaction.ts +131 -0
- package/src/scenegraph/scenegraph-node.ts +12 -0
- package/src/splats/README.md +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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert, type Device, type Texture} from '@luma.gl/core';
|
|
5
|
+
import {
|
|
6
|
+
contactShadowTrace,
|
|
7
|
+
contactShadowBilateralBlur,
|
|
8
|
+
type CompositeShaderPass,
|
|
9
|
+
type ContactTraceUniforms
|
|
10
|
+
} from '@luma.gl/shaders';
|
|
11
|
+
import {Matrix4, type NumberArray3, type NumberArray16} from '@math.gl/core';
|
|
12
|
+
import {ShaderPassRenderer} from '../passes/shader-pass-renderer';
|
|
13
|
+
import {SHADOW_QUALITY_SETTINGS} from './shadow-quality';
|
|
14
|
+
|
|
15
|
+
export type ContactShadowPassProps = {quality?: 'low' | 'balanced' | 'cinematic'};
|
|
16
|
+
export type ContactShadowRenderOptions = Partial<
|
|
17
|
+
Omit<ContactTraceUniforms, 'projectionMatrix' | 'inverseProjectionMatrix' | 'lightDirectionView'>
|
|
18
|
+
> & {
|
|
19
|
+
projectionMatrix: Readonly<Matrix4 | NumberArray16>;
|
|
20
|
+
lightDirectionView: Readonly<NumberArray3>;
|
|
21
|
+
depthTexture: Texture;
|
|
22
|
+
normalTexture: Texture;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Prepares a screen-space visibility texture for one directional light. No history or submission. */
|
|
26
|
+
export class ContactShadowPass {
|
|
27
|
+
readonly device: Device;
|
|
28
|
+
private readonly renderer: ShaderPassRenderer;
|
|
29
|
+
private destroyed = false;
|
|
30
|
+
|
|
31
|
+
constructor(device: Device, props: ContactShadowPassProps = {}) {
|
|
32
|
+
this.device = device;
|
|
33
|
+
const settings = SHADOW_QUALITY_SETTINGS[props.quality ?? 'balanced'];
|
|
34
|
+
const shaderPass: CompositeShaderPass<'contactShadowRaw' | 'contactShadowScratch'> = {
|
|
35
|
+
name: 'contactShadowVisibility',
|
|
36
|
+
renderTargets: {
|
|
37
|
+
contactShadowRaw: {
|
|
38
|
+
scale: [settings.contactScale, settings.contactScale],
|
|
39
|
+
format: 'rgba8unorm'
|
|
40
|
+
},
|
|
41
|
+
contactShadowScratch: {
|
|
42
|
+
scale: [settings.contactScale, settings.contactScale],
|
|
43
|
+
format: 'rgba8unorm'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
steps: [
|
|
47
|
+
{
|
|
48
|
+
shaderPass: contactShadowTrace,
|
|
49
|
+
inputs: {sourceTexture: 'original'},
|
|
50
|
+
output: 'contactShadowRaw',
|
|
51
|
+
uniforms: {stepCount: settings.contactStepCount}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
shaderPass: contactShadowBilateralBlur,
|
|
55
|
+
inputs: {sourceTexture: 'contactShadowRaw'},
|
|
56
|
+
output: 'contactShadowScratch',
|
|
57
|
+
uniforms: {direction: [1, 0]}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
shaderPass: contactShadowBilateralBlur,
|
|
61
|
+
inputs: {sourceTexture: 'contactShadowScratch'},
|
|
62
|
+
output: 'previous',
|
|
63
|
+
uniforms: {direction: [0, 1]}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
this.renderer = new ShaderPassRenderer(device, {
|
|
68
|
+
shaderPasses: [shaderPass],
|
|
69
|
+
colorFormat: 'rgba8unorm'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Uses the backend-native projection and view-space normals/direction of the same camera. */
|
|
74
|
+
render(options: ContactShadowRenderOptions): Texture {
|
|
75
|
+
// Inputs must be same-device, single-sample targets of the same camera and resolution.
|
|
76
|
+
assert(
|
|
77
|
+
!this.destroyed &&
|
|
78
|
+
options.depthTexture.device === this.device &&
|
|
79
|
+
options.normalTexture.device === this.device
|
|
80
|
+
);
|
|
81
|
+
assert(
|
|
82
|
+
options.depthTexture.width === options.normalTexture.width &&
|
|
83
|
+
options.depthTexture.height === options.normalTexture.height
|
|
84
|
+
);
|
|
85
|
+
this.renderer.resize([options.normalTexture.width, options.normalTexture.height]);
|
|
86
|
+
const {depthTexture, normalTexture, ...traceProps} = options;
|
|
87
|
+
const texture = this.renderer.renderToTexture({
|
|
88
|
+
sourceTexture: normalTexture,
|
|
89
|
+
bindings: {depthTexture, normalTexture},
|
|
90
|
+
uniforms: {
|
|
91
|
+
contactShadowTrace: {
|
|
92
|
+
...traceProps,
|
|
93
|
+
inverseProjectionMatrix: new Matrix4(options.projectionMatrix).invert()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
// Concrete texture inputs always produce an output; deferred uploads are not accepted here.
|
|
98
|
+
assert(texture);
|
|
99
|
+
return texture;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
destroy(): void {
|
|
103
|
+
if (this.destroyed) return;
|
|
104
|
+
this.destroyed = true;
|
|
105
|
+
this.renderer.destroy();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
createPrefilteredEnvironment,
|
|
7
|
+
PrefilteredEnvironmentGenerator,
|
|
8
|
+
PrefilteredEnvironment
|
|
9
|
+
} from './prefiltered-environment';
|
|
10
|
+
export type {
|
|
11
|
+
PrefilteredEnvironmentOptions,
|
|
12
|
+
PrefilteredEnvironmentTextures
|
|
13
|
+
} from './prefiltered-environment';
|
|
14
|
+
export {createAreaLightLTCTextures} from './ltc-textures';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
createPBRMaterial,
|
|
18
|
+
createPBRMaterialFactory,
|
|
19
|
+
getPBRMaterialMapUniforms
|
|
20
|
+
} from './pbr-material';
|
|
21
|
+
export type {CreatePBRMaterialOptions, PBRMaterial, PBRMaterialResources} from './pbr-material';
|
|
22
|
+
export {getPBREnvironmentBindings, getPBREnvironmentUniforms} from './pbr-environment';
|
|
23
|
+
export type {PBRLightingEnvironment, PBRLightingEnvironmentOptions} from './pbr-environment';
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
createPBRModel,
|
|
27
|
+
createPBRShadowModel,
|
|
28
|
+
createPBRSurfaceModel,
|
|
29
|
+
getPBRGeometryDefines,
|
|
30
|
+
getPBRTextureDefines,
|
|
31
|
+
getPBRModelWGSL,
|
|
32
|
+
PBR_MODEL_WGSL_SHADER
|
|
33
|
+
} from './pbr-model';
|
|
34
|
+
export type {CreatePBRModelOptions, PBRModelShaderHooks} from './pbr-model';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ShadowMapRenderer,
|
|
38
|
+
getDirectionalCascadeViews,
|
|
39
|
+
getPointShadowViews,
|
|
40
|
+
getPracticalCascadeSplits,
|
|
41
|
+
getSpotShadowView
|
|
42
|
+
} from './shadow-map-renderer';
|
|
43
|
+
export type {
|
|
44
|
+
DirectionalShadowLight,
|
|
45
|
+
PointShadowFace,
|
|
46
|
+
PointShadowLight,
|
|
47
|
+
ShadowCamera,
|
|
48
|
+
ShadowMapRendererProps,
|
|
49
|
+
ShadowRenderOptions,
|
|
50
|
+
ShadowRenderView,
|
|
51
|
+
ShadowShaderProps,
|
|
52
|
+
SpotShadowLight
|
|
53
|
+
} from './shadow-map-renderer';
|
|
54
|
+
export {SHADOW_QUALITY_SETTINGS} from './shadow-quality';
|
|
55
|
+
export type {ShadowQualitySettings} from './shadow-quality';
|
|
56
|
+
|
|
57
|
+
export {PBRSurfacePass} from './pbr-surface-pass';
|
|
58
|
+
export type {
|
|
59
|
+
PBRSurfacePassProps,
|
|
60
|
+
PBRSurfaceRenderOptions,
|
|
61
|
+
PBRSurfaceRenderView
|
|
62
|
+
} from './pbr-surface-pass';
|
|
63
|
+
|
|
64
|
+
export {createContactShadowCompositeShaderPass} from './contact-shadow-composite';
|
|
65
|
+
|
|
66
|
+
export {ContactShadowPass} from './contact-shadow-pass';
|
|
67
|
+
export type {ContactShadowPassProps, ContactShadowRenderOptions} from './contact-shadow-pass';
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
ClusteredLightGrid,
|
|
71
|
+
CLUSTERED_POINT_LIGHT_LAYOUT,
|
|
72
|
+
MAX_CLUSTERED_POINT_LIGHTS,
|
|
73
|
+
DEFAULT_CLUSTER_DIMENSIONS,
|
|
74
|
+
DEFAULT_MAX_LIGHTS_PER_CLUSTER
|
|
75
|
+
} from './clustered-light-grid';
|
|
76
|
+
export type {
|
|
77
|
+
ClusteredLightGridProps,
|
|
78
|
+
ClusteredLightGridEncodeOptions,
|
|
79
|
+
ClusteredLightGridBindings,
|
|
80
|
+
ClusteredLightGridUniforms,
|
|
81
|
+
ClusteredLightGridShaderPassUniforms
|
|
82
|
+
} from './clustered-light-grid';
|
|
83
|
+
export {AmbientOcclusionPass} from './ambient-occlusion-pass';
|
|
84
|
+
export type {
|
|
85
|
+
AmbientOcclusionMode,
|
|
86
|
+
AmbientOcclusionPassProps,
|
|
87
|
+
AmbientOcclusionRenderOptions
|
|
88
|
+
} from './ambient-occlusion-pass';
|
|
89
|
+
|
|
90
|
+
export {createPBRLightmapModel} from './pbr-model';
|
|
91
|
+
export type {CreatePBRLightmapModelOptions} from './pbr-model';
|
|
92
|
+
export {LightmapBaker, LightmapBakeResult} from './lightmap-baker';
|
|
93
|
+
export type {
|
|
94
|
+
LightmapBakerProps,
|
|
95
|
+
LightmapBakeOptions,
|
|
96
|
+
LightmapBakeView,
|
|
97
|
+
LightmapTextures
|
|
98
|
+
} from './lightmap-baker';
|
|
99
|
+
export {
|
|
100
|
+
readLightmapData,
|
|
101
|
+
createLightmapFromData,
|
|
102
|
+
encodeLightmapData,
|
|
103
|
+
decodeLightmapData
|
|
104
|
+
} from './lightmap-data';
|
|
105
|
+
export type {LightmapData} from './lightmap-data';
|
|
106
|
+
export {sampleLightmapEnvironment} from './lightmap-environment';
|
|
107
|
+
export type {LightmapEnvironment, LightmapEnvironmentSample} from './lightmap-environment';
|
|
108
|
+
|
|
109
|
+
export {ReflectionProbe} from './reflection-probe';
|
|
110
|
+
export type {
|
|
111
|
+
ReflectionProbeProps,
|
|
112
|
+
ReflectionProbeUpdate,
|
|
113
|
+
ReflectionProbeView
|
|
114
|
+
} from './reflection-probe';
|
|
115
|
+
export {
|
|
116
|
+
createLightmapAtlas,
|
|
117
|
+
validateLightmapAtlas,
|
|
118
|
+
getLightmapAtlasDebugData
|
|
119
|
+
} from './lightmap-atlas';
|
|
120
|
+
export type {
|
|
121
|
+
LightmapAtlas,
|
|
122
|
+
LightmapAtlasInput,
|
|
123
|
+
LightmapAtlasOptions,
|
|
124
|
+
LightmapAtlasChart
|
|
125
|
+
} from './lightmap-atlas';
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert} from '@luma.gl/core';
|
|
5
|
+
import {Matrix4, Vector3} from '@math.gl/core';
|
|
6
|
+
import {Geometry, type GeometryAttribute} from '../geometry/geometry';
|
|
7
|
+
|
|
8
|
+
export type LightmapAtlasInput = {
|
|
9
|
+
/** Stable application-owned identity; unique within an atlas. */
|
|
10
|
+
id: string;
|
|
11
|
+
geometry: Geometry;
|
|
12
|
+
/** Used only to measure world-space texel density. Output positions stay in object space. */
|
|
13
|
+
modelMatrix?: Matrix4;
|
|
14
|
+
};
|
|
15
|
+
export type LightmapAtlasOptions = {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
texelsPerUnit: number;
|
|
19
|
+
padding?: number;
|
|
20
|
+
uvSet?: 0 | 1;
|
|
21
|
+
/** Join consecutive coplanar triangles that form a quad. */
|
|
22
|
+
mergeCoplanarPairs?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type LightmapAtlasChart = {
|
|
25
|
+
id: number;
|
|
26
|
+
meshId: string;
|
|
27
|
+
firstVertex: number;
|
|
28
|
+
vertexCount: number;
|
|
29
|
+
/** Integer pixel rectangle including padding, measured from the atlas top left. */
|
|
30
|
+
rectangle: {x: number; y: number; width: number; height: number};
|
|
31
|
+
worldArea: number;
|
|
32
|
+
};
|
|
33
|
+
export type LightmapAtlas = Required<Omit<LightmapAtlasOptions, 'mergeCoplanarPairs'>> & {
|
|
34
|
+
meshes: {id: string; geometry: Geometry}[];
|
|
35
|
+
charts: LightmapAtlasChart[];
|
|
36
|
+
/** Independent row-major r32float data, suitable for LightmapBaker chartTexture. Zero is unused. */
|
|
37
|
+
chartOwners: Float32Array;
|
|
38
|
+
/** Fraction of atlas pixels reserved by chart rectangles, including gutters. */
|
|
39
|
+
occupancy: number;
|
|
40
|
+
};
|
|
41
|
+
type PendingChart = LightmapAtlasChart & {coordinates: number[]; meshIndex: number};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Prepare an independent CPU atlas. Each triangle receives a planar chart; no seam heuristics,
|
|
45
|
+
* GPU allocation, texture upload, submission, or source mutation occurs here.
|
|
46
|
+
*/
|
|
47
|
+
export function createLightmapAtlas(
|
|
48
|
+
inputs: readonly LightmapAtlasInput[],
|
|
49
|
+
options: LightmapAtlasOptions
|
|
50
|
+
): LightmapAtlas {
|
|
51
|
+
const {width, height, texelsPerUnit, padding = 2, uvSet = 1} = options;
|
|
52
|
+
// Dimensions, density and gutters must be explicit and finite. Chart IDs stay exact in float16.
|
|
53
|
+
assert(Number.isSafeInteger(width) && width > 0 && Number.isSafeInteger(height) && height > 0);
|
|
54
|
+
assert(Number.isFinite(texelsPerUnit) && texelsPerUnit > 0);
|
|
55
|
+
assert(Number.isInteger(padding) && padding >= 0 && padding <= 16);
|
|
56
|
+
assert(uvSet === 0 || uvSet === 1);
|
|
57
|
+
assert(new Set(inputs.map(input => input.id)).size === inputs.length);
|
|
58
|
+
const charts: PendingChart[] = [];
|
|
59
|
+
const meshes = inputs.map((input, meshIndex) => {
|
|
60
|
+
const source = input.geometry;
|
|
61
|
+
const positions = source.attributes['POSITION'];
|
|
62
|
+
// Only tightly packed, per-vertex triangle-list attributes are supported.
|
|
63
|
+
assert(source.topology === 'triangle-list' && positions?.size === 3 && !positions.normalized);
|
|
64
|
+
const indices = source.indices?.value;
|
|
65
|
+
const vertexCount = source.vertexCount;
|
|
66
|
+
assert(!indices || vertexCount <= indices.length);
|
|
67
|
+
assert(vertexCount > 0 && vertexCount % 3 === 0);
|
|
68
|
+
const attributes: Record<string, GeometryAttribute> = {};
|
|
69
|
+
for (const [name, attribute] of Object.entries(source.attributes)) {
|
|
70
|
+
const {size, value} = attribute;
|
|
71
|
+
assert(
|
|
72
|
+
size &&
|
|
73
|
+
!attribute.constant &&
|
|
74
|
+
value.length === (positions.value.length / 3) * size &&
|
|
75
|
+
!attribute['byteStride'] &&
|
|
76
|
+
!attribute['byteOffset'] &&
|
|
77
|
+
!attribute['divisor']
|
|
78
|
+
);
|
|
79
|
+
const copied = value.slice(0, 0);
|
|
80
|
+
// Keep the original numeric storage type, including normalized integer attributes.
|
|
81
|
+
const expanded = new (copied.constructor as typeof Float32Array)(vertexCount * size);
|
|
82
|
+
for (let vertex = 0; vertex < vertexCount; vertex++) {
|
|
83
|
+
const sourceVertex = indices ? indices[vertex] : vertex;
|
|
84
|
+
assert(
|
|
85
|
+
Number.isInteger(sourceVertex) && sourceVertex >= 0 && sourceVertex < value.length / size
|
|
86
|
+
);
|
|
87
|
+
for (let component = 0; component < size; component++)
|
|
88
|
+
expanded[vertex * size + component] = value[sourceVertex * size + component];
|
|
89
|
+
}
|
|
90
|
+
attributes[name] = {...attribute, value: expanded};
|
|
91
|
+
}
|
|
92
|
+
const coordinates = new Float32Array(vertexCount * 2);
|
|
93
|
+
attributes[`TEXCOORD_${uvSet}`] = {size: 2, value: coordinates};
|
|
94
|
+
const matrix = input.modelMatrix ?? new Matrix4();
|
|
95
|
+
// Affine transforms only; a projective matrix has no uniform world-space density.
|
|
96
|
+
assert(
|
|
97
|
+
matrix.every(Number.isFinite) &&
|
|
98
|
+
matrix[3] === 0 &&
|
|
99
|
+
matrix[7] === 0 &&
|
|
100
|
+
matrix[11] === 0 &&
|
|
101
|
+
matrix[15] === 1
|
|
102
|
+
);
|
|
103
|
+
const getPoints = (firstVertex: number) =>
|
|
104
|
+
[0, 1, 2].map(offset => {
|
|
105
|
+
const vertex = indices ? indices[firstVertex + offset] : firstVertex + offset;
|
|
106
|
+
const point = new Vector3(positions.value.slice(vertex * 3, vertex * 3 + 3));
|
|
107
|
+
assert(point.every(Number.isFinite));
|
|
108
|
+
return point.transformAsPoint(matrix);
|
|
109
|
+
});
|
|
110
|
+
for (let firstVertex = 0; firstVertex < vertexCount; ) {
|
|
111
|
+
const points = getPoints(firstVertex);
|
|
112
|
+
const edges = points.map((point, index) =>
|
|
113
|
+
new Vector3(points[(index + 1) % 3]).subtract(point)
|
|
114
|
+
);
|
|
115
|
+
const lengths = edges.map(edge => edge.len());
|
|
116
|
+
const start = lengths.indexOf(Math.max(...lengths));
|
|
117
|
+
const end = (start + 1) % 3;
|
|
118
|
+
const third = (start + 2) % 3;
|
|
119
|
+
const horizontal = edges[start].clone().normalize();
|
|
120
|
+
const relative = new Vector3(points[third]).subtract(points[start]);
|
|
121
|
+
const projected = relative.dot(horizontal);
|
|
122
|
+
const altitude = new Vector3(edges[start]).cross(relative).len() / lengths[start];
|
|
123
|
+
// Degenerate transformed triangles cannot receive lightmap samples.
|
|
124
|
+
assert(Number.isFinite(altitude) && altitude > 0 && lengths[start] > 0);
|
|
125
|
+
const local = new Array<number>(6).fill(0);
|
|
126
|
+
local[end * 2] = lengths[start] * texelsPerUnit;
|
|
127
|
+
local[third * 2] = projected * texelsPerUnit;
|
|
128
|
+
local[third * 2 + 1] = altitude * texelsPerUnit;
|
|
129
|
+
let worldArea = (lengths[start] * altitude) / 2;
|
|
130
|
+
if (options.mergeCoplanarPairs && firstVertex + 6 <= vertexCount) {
|
|
131
|
+
const second = getPoints(firstVertex + 3);
|
|
132
|
+
const shared = second.map(point =>
|
|
133
|
+
points.findIndex(candidate =>
|
|
134
|
+
candidate.every((component, index) => component === point[index])
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
if (shared.filter(index => index >= 0).length === 2 && new Set(shared).size === 3) {
|
|
138
|
+
const normal = edges[start].clone().cross(relative).normalize();
|
|
139
|
+
const vertical = normal.clone().cross(horizontal);
|
|
140
|
+
const opposite = shared.indexOf(-1);
|
|
141
|
+
const delta = second[opposite].clone().subtract(points[start]);
|
|
142
|
+
const projectedPoint = [delta.dot(horizontal), delta.dot(vertical)];
|
|
143
|
+
const [sharedFirst, sharedSecond] = shared.filter(index => index >= 0);
|
|
144
|
+
const unshared = [0, 1, 2].find(index => !shared.includes(index))!;
|
|
145
|
+
const side = (x: number, y: number) =>
|
|
146
|
+
(local[sharedSecond * 2] - local[sharedFirst * 2]) * (y - local[sharedFirst * 2 + 1]) -
|
|
147
|
+
(local[sharedSecond * 2 + 1] - local[sharedFirst * 2 + 1]) *
|
|
148
|
+
(x - local[sharedFirst * 2]);
|
|
149
|
+
const secondArea = second[1]
|
|
150
|
+
.clone()
|
|
151
|
+
.subtract(second[0])
|
|
152
|
+
.cross(second[2].clone().subtract(second[0]));
|
|
153
|
+
if (
|
|
154
|
+
Math.abs(delta.dot(normal)) <= 1e-7 * delta.len() &&
|
|
155
|
+
secondArea.dot(normal) > 0 &&
|
|
156
|
+
side(local[unshared * 2], local[unshared * 2 + 1]) *
|
|
157
|
+
side(projectedPoint[0] * texelsPerUnit, projectedPoint[1] * texelsPerUnit) <
|
|
158
|
+
0
|
|
159
|
+
) {
|
|
160
|
+
for (const index of shared) {
|
|
161
|
+
if (index >= 0) local.push(local[index * 2], local[index * 2 + 1]);
|
|
162
|
+
else local.push(projectedPoint[0] * texelsPerUnit, projectedPoint[1] * texelsPerUnit);
|
|
163
|
+
}
|
|
164
|
+
worldArea += secondArea.len() / 2;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const horizontalCoordinates = local.filter((_, index) => index % 2 === 0);
|
|
169
|
+
const verticalCoordinates = local.filter((_, index) => index % 2 === 1);
|
|
170
|
+
const chartVertexCount = local.length / 2;
|
|
171
|
+
const minimumX = chartVertexCount === 3 ? 0 : Math.min(...horizontalCoordinates);
|
|
172
|
+
const minimumY = chartVertexCount === 3 ? 0 : Math.min(...verticalCoordinates);
|
|
173
|
+
charts.push({
|
|
174
|
+
id: charts.length + 1,
|
|
175
|
+
meshId: input.id,
|
|
176
|
+
meshIndex,
|
|
177
|
+
firstVertex,
|
|
178
|
+
vertexCount: chartVertexCount,
|
|
179
|
+
rectangle: {
|
|
180
|
+
x: 0,
|
|
181
|
+
y: 0,
|
|
182
|
+
width:
|
|
183
|
+
Math.ceil(
|
|
184
|
+
chartVertexCount === 3
|
|
185
|
+
? lengths[start] * texelsPerUnit
|
|
186
|
+
: Math.max(...horizontalCoordinates) - minimumX
|
|
187
|
+
) +
|
|
188
|
+
1 +
|
|
189
|
+
padding * 2,
|
|
190
|
+
height: Math.ceil(Math.max(...verticalCoordinates) - minimumY) + 1 + padding * 2
|
|
191
|
+
},
|
|
192
|
+
worldArea,
|
|
193
|
+
coordinates: local.map((value, index) => value - (index % 2 ? minimumY : minimumX))
|
|
194
|
+
});
|
|
195
|
+
firstVertex += chartVertexCount;
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
id: input.id,
|
|
199
|
+
geometry: new Geometry({
|
|
200
|
+
id: `${source.id}-lightmap`,
|
|
201
|
+
topology: 'triangle-list',
|
|
202
|
+
vertexCount,
|
|
203
|
+
attributes
|
|
204
|
+
})
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
// Positive integer chart IDs must survive the default rgba16float bake target exactly.
|
|
208
|
+
assert(charts.length <= 2048);
|
|
209
|
+
let cursorX = 0;
|
|
210
|
+
let cursorY = 0;
|
|
211
|
+
let shelfHeight = 0;
|
|
212
|
+
let allocatedPixels = 0;
|
|
213
|
+
for (const chart of [...charts].sort(
|
|
214
|
+
(left, right) =>
|
|
215
|
+
right.rectangle.height - left.rectangle.height ||
|
|
216
|
+
right.rectangle.width - left.rectangle.width ||
|
|
217
|
+
left.id - right.id
|
|
218
|
+
)) {
|
|
219
|
+
const rectangle = chart.rectangle;
|
|
220
|
+
if (cursorX + rectangle.width > width) {
|
|
221
|
+
cursorX = 0;
|
|
222
|
+
cursorY += shelfHeight;
|
|
223
|
+
shelfHeight = 0;
|
|
224
|
+
}
|
|
225
|
+
// Packing never silently changes density. Increase dimensions or lower texelsPerUnit.
|
|
226
|
+
assert(rectangle.width <= width && cursorY + rectangle.height <= height);
|
|
227
|
+
rectangle.x = cursorX;
|
|
228
|
+
rectangle.y = cursorY;
|
|
229
|
+
cursorX += rectangle.width;
|
|
230
|
+
shelfHeight = Math.max(shelfHeight, rectangle.height);
|
|
231
|
+
allocatedPixels += rectangle.width * rectangle.height;
|
|
232
|
+
const coordinates = meshes[chart.meshIndex].geometry.attributes[`TEXCOORD_${uvSet}`].value;
|
|
233
|
+
for (let vertex = 0; vertex < chart.vertexCount; vertex++) {
|
|
234
|
+
coordinates[(chart.firstVertex + vertex) * 2] =
|
|
235
|
+
(rectangle.x + padding + 0.5 + chart.coordinates[vertex * 2]) / width;
|
|
236
|
+
coordinates[(chart.firstVertex + vertex) * 2 + 1] =
|
|
237
|
+
(rectangle.y + padding + 0.5 + chart.coordinates[vertex * 2 + 1]) / height;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const chartOwners = new Float32Array(width * height);
|
|
241
|
+
for (const {id, rectangle} of charts)
|
|
242
|
+
for (let row = rectangle.y; row < rectangle.y + rectangle.height; row++)
|
|
243
|
+
chartOwners.fill(id, row * width + rectangle.x, row * width + rectangle.x + rectangle.width);
|
|
244
|
+
return {
|
|
245
|
+
width,
|
|
246
|
+
height,
|
|
247
|
+
texelsPerUnit,
|
|
248
|
+
padding,
|
|
249
|
+
uvSet,
|
|
250
|
+
meshes,
|
|
251
|
+
charts: charts.map(({coordinates, meshIndex, ...chart}) => chart),
|
|
252
|
+
chartOwners,
|
|
253
|
+
occupancy: allocatedPixels / (width * height)
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Explicit diagnostic pass; returns actionable chart errors without allocating GPU resources. */
|
|
258
|
+
export function validateLightmapAtlas(atlas: LightmapAtlas): string[] {
|
|
259
|
+
const errors: string[] = [];
|
|
260
|
+
if (
|
|
261
|
+
!Number.isSafeInteger(atlas.width) ||
|
|
262
|
+
atlas.width <= 0 ||
|
|
263
|
+
!Number.isSafeInteger(atlas.height) ||
|
|
264
|
+
atlas.height <= 0 ||
|
|
265
|
+
atlas.chartOwners.length !== atlas.width * atlas.height
|
|
266
|
+
)
|
|
267
|
+
return ['Invalid atlas dimensions or ownership data length'];
|
|
268
|
+
const occupied = new Uint8Array(atlas.width * atlas.height);
|
|
269
|
+
const identifiers = new Set<number>();
|
|
270
|
+
for (const chart of atlas.charts) {
|
|
271
|
+
const {x, y, width, height} = chart.rectangle;
|
|
272
|
+
if (
|
|
273
|
+
!Number.isInteger(chart.id) ||
|
|
274
|
+
chart.id <= 0 ||
|
|
275
|
+
chart.id > 2048 ||
|
|
276
|
+
identifiers.has(chart.id)
|
|
277
|
+
)
|
|
278
|
+
errors.push(`Invalid chart ID ${chart.id}`);
|
|
279
|
+
identifiers.add(chart.id);
|
|
280
|
+
if (
|
|
281
|
+
![x, y, width, height].every(Number.isInteger) ||
|
|
282
|
+
x < 0 ||
|
|
283
|
+
y < 0 ||
|
|
284
|
+
width <= 0 ||
|
|
285
|
+
height <= 0 ||
|
|
286
|
+
x + width > atlas.width ||
|
|
287
|
+
y + height > atlas.height
|
|
288
|
+
) {
|
|
289
|
+
errors.push(`Chart ${chart.id} is outside the atlas`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
let overlaps = false;
|
|
293
|
+
let ownershipMismatch = false;
|
|
294
|
+
for (let row = y; row < y + height; row++)
|
|
295
|
+
for (let column = x; column < x + width; column++) {
|
|
296
|
+
const pixel = row * atlas.width + column;
|
|
297
|
+
overlaps ||= Boolean(occupied[pixel]);
|
|
298
|
+
occupied[pixel] = 1;
|
|
299
|
+
ownershipMismatch ||= atlas.chartOwners[pixel] !== chart.id;
|
|
300
|
+
}
|
|
301
|
+
if (overlaps) errors.push(`Chart ${chart.id} overlaps another chart`);
|
|
302
|
+
if (ownershipMismatch) errors.push(`Chart ${chart.id} has inconsistent gutter ownership`);
|
|
303
|
+
const mesh = atlas.meshes.find(candidate => candidate.id === chart.meshId);
|
|
304
|
+
const coordinates = mesh?.geometry.attributes[`TEXCOORD_${atlas.uvSet}`]?.value;
|
|
305
|
+
if (
|
|
306
|
+
!coordinates ||
|
|
307
|
+
!Number.isInteger(chart.firstVertex) ||
|
|
308
|
+
!Number.isInteger(chart.vertexCount) ||
|
|
309
|
+
chart.vertexCount <= 0 ||
|
|
310
|
+
chart.firstVertex < 0 ||
|
|
311
|
+
chart.firstVertex + chart.vertexCount > coordinates.length / 2
|
|
312
|
+
) {
|
|
313
|
+
errors.push(`Chart ${chart.id} has an invalid draw range`);
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
for (let vertex = chart.firstVertex; vertex < chart.firstVertex + chart.vertexCount; vertex++) {
|
|
317
|
+
const horizontal = coordinates[vertex * 2] * atlas.width;
|
|
318
|
+
const vertical = coordinates[vertex * 2 + 1] * atlas.height;
|
|
319
|
+
if (
|
|
320
|
+
!Number.isFinite(horizontal) ||
|
|
321
|
+
!Number.isFinite(vertical) ||
|
|
322
|
+
horizontal < x + atlas.padding ||
|
|
323
|
+
horizontal > x + width - atlas.padding ||
|
|
324
|
+
vertical < y + atlas.padding ||
|
|
325
|
+
vertical > y + height - atlas.padding
|
|
326
|
+
) {
|
|
327
|
+
errors.push(`Chart ${chart.id} has UVs outside its padded rectangle`);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (atlas.chartOwners.some((owner, pixel) => !occupied[pixel] && owner !== 0))
|
|
333
|
+
errors.push('Unallocated pixels have chart owners');
|
|
334
|
+
return errors;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Independent RGBA8 chart-ownership preview. Unallocated pixels are opaque black. */
|
|
338
|
+
export function getLightmapAtlasDebugData(atlas: LightmapAtlas): Uint8ClampedArray {
|
|
339
|
+
const pixels = new Uint8ClampedArray(atlas.width * atlas.height * 4);
|
|
340
|
+
for (let pixel = 0; pixel < atlas.chartOwners.length; pixel++) {
|
|
341
|
+
const identifier = atlas.chartOwners[pixel];
|
|
342
|
+
pixels[pixel * 4] = identifier ? 64 + ((identifier * 67) % 192) : 0;
|
|
343
|
+
pixels[pixel * 4 + 1] = identifier ? 64 + ((identifier * 103) % 192) : 0;
|
|
344
|
+
pixels[pixel * 4 + 2] = identifier ? 64 + ((identifier * 137) % 192) : 0;
|
|
345
|
+
pixels[pixel * 4 + 3] = 255;
|
|
346
|
+
}
|
|
347
|
+
return pixels;
|
|
348
|
+
}
|