@babylonjs/lite 0.1.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/_math-factory-C-QqW-Wi.js +55 -0
- package/_math-factory-C-QqW-Wi.js.map +1 -0
- package/add-block-CikX5gWy.js +6 -0
- package/add-block-CikX5gWy.js.map +1 -0
- package/alpha-test-fragment-CUiHCw7W.js +22 -0
- package/alpha-test-fragment-CUiHCw7W.js.map +1 -0
- package/ambient-occlusion-block-DForhWL3.js +77 -0
- package/ambient-occlusion-block-DForhWL3.js.map +1 -0
- package/anisotropy-block-D5fXH_OY.js +12 -0
- package/anisotropy-block-D5fXH_OY.js.map +1 -0
- package/anisotropy-fragment-HgasXS7l.js +89 -0
- package/anisotropy-fragment-HgasXS7l.js.map +1 -0
- package/arc-tan2-block-d8sWt_x0.js +12 -0
- package/arc-tan2-block-d8sWt_x0.js.map +1 -0
- package/assets/splat-sort-worker-Crg3CaCc.js.map +1 -0
- package/background-dds-skybox-yHTqabU3.js +221 -0
- package/background-dds-skybox-yHTqabU3.js.map +1 -0
- package/background-ground-DIw6D3qf.js +235 -0
- package/background-ground-DIw6D3qf.js.map +1 -0
- package/background-hdr-skybox-c4uuTmkP.js +179 -0
- package/background-hdr-skybox-c4uuTmkP.js.map +1 -0
- package/background-solid-skybox-DPGBpPbm.js +235 -0
- package/background-solid-skybox-DPGBpPbm.js.map +1 -0
- package/bake-local-matrix-Dfpd3b06.js +28 -0
- package/bake-local-matrix-Dfpd3b06.js.map +1 -0
- package/billboard-renderable-D8mlVGCd.js +242 -0
- package/billboard-renderable-D8mlVGCd.js.map +1 -0
- package/biplanar-block-DZnKuV81.js +115 -0
- package/biplanar-block-DZnKuV81.js.map +1 -0
- package/bones-block-D6IhqUVV.js +31 -0
- package/bones-block-D6IhqUVV.js.map +1 -0
- package/clamp-block-BdII67hT.js +21 -0
- package/clamp-block-BdII67hT.js.map +1 -0
- package/clearcoat-block-BGML4npi.js +12 -0
- package/clearcoat-block-BGML4npi.js.map +1 -0
- package/clearcoat-fragment-LCiG98Rf.js +256 -0
- package/clearcoat-fragment-LCiG98Rf.js.map +1 -0
- package/clip-planes-block-BPfFJrbf.js +26 -0
- package/clip-planes-block-BPfFJrbf.js.map +1 -0
- package/cloud-block-BeVrangc.js +90 -0
- package/cloud-block-BeVrangc.js.map +1 -0
- package/color-converter-block-CvwKiW4k.js +123 -0
- package/color-converter-block-CvwKiW4k.js.map +1 -0
- package/color-merger-CCu21ZII.js +57 -0
- package/color-merger-CCu21ZII.js.map +1 -0
- package/color-splitter-CGn1G4ow.js +33 -0
- package/color-splitter-CGn1G4ow.js.map +1 -0
- package/conditional-block-Cd2pbejI.js +51 -0
- package/conditional-block-Cd2pbejI.js.map +1 -0
- package/create-skeleton-C9JdIJnb.js +44 -0
- package/create-skeleton-C9JdIJnb.js.map +1 -0
- package/cross-block-DCrLwCpt.js +12 -0
- package/cross-block-DCrLwCpt.js.map +1 -0
- package/cubemap-skybox-material-DvXMVc4k.js +79 -0
- package/cubemap-skybox-material-DvXMVc4k.js.map +1 -0
- package/curve-block-BlJpXVYv.js +89 -0
- package/curve-block-BlJpXVYv.js.map +1 -0
- package/debug-block-D2pg4Yf6.js +14 -0
- package/debug-block-D2pg4Yf6.js.map +1 -0
- package/derivative-block-B8KjtaWs.js +20 -0
- package/derivative-block-B8KjtaWs.js.map +1 -0
- package/desaturate-block-C1RghNSB.js +15 -0
- package/desaturate-block-C1RghNSB.js.map +1 -0
- package/discard-block-B2jKjaEL.js +21 -0
- package/discard-block-B2jKjaEL.js.map +1 -0
- package/distance-block-3NkgFZ3f.js +16 -0
- package/distance-block-3NkgFZ3f.js.map +1 -0
- package/divide-block-ZyepIg_-.js +6 -0
- package/divide-block-ZyepIg_-.js.map +1 -0
- package/dot-block-VlfAC6cD.js +16 -0
- package/dot-block-VlfAC6cD.js.map +1 -0
- package/elbow-block-NEOiIxzO.js +10 -0
- package/elbow-block-NEOiIxzO.js.map +1 -0
- package/emissive-fragment-BnNvbBCw.js +39 -0
- package/emissive-fragment-BnNvbBCw.js.map +1 -0
- package/esm-shadow-view-DGKdF1NI.js +18 -0
- package/esm-shadow-view-DGKdF1NI.js.map +1 -0
- package/esm-shadow-view-DN9HIaM4.js +15 -0
- package/esm-shadow-view-DN9HIaM4.js.map +1 -0
- package/esm-shadow-view-Dk9NFtLq.js +15 -0
- package/esm-shadow-view-Dk9NFtLq.js.map +1 -0
- package/fog-block-DJ9hEolm.js +41 -0
- package/fog-block-DJ9hEolm.js.map +1 -0
- package/frag-coord-block-DzXfFgfV.js +25 -0
- package/frag-coord-block-DzXfFgfV.js.map +1 -0
- package/frag-depth-block-UQbeKP2D.js +34 -0
- package/frag-depth-block-UQbeKP2D.js.map +1 -0
- package/fragment-output-BOphkIeh.js +26 -0
- package/fragment-output-BOphkIeh.js.map +1 -0
- package/fresnel-block-DefHWeO-.js +20 -0
- package/fresnel-block-DefHWeO-.js.map +1 -0
- package/front-facing-0d6aiyrv.js +11 -0
- package/front-facing-0d6aiyrv.js.map +1 -0
- package/gaussian-splatting-pipeline-sh-DgJl7l56.js +500 -0
- package/gaussian-splatting-pipeline-sh-DgJl7l56.js.map +1 -0
- package/gltf-animation-D7uyTyO3.js +245 -0
- package/gltf-animation-D7uyTyO3.js.map +1 -0
- package/gltf-ext-anisotropy-CknJiJK8.js +22 -0
- package/gltf-ext-anisotropy-CknJiJK8.js.map +1 -0
- package/gltf-ext-basisu-CPg5kPrx.js +452 -0
- package/gltf-ext-basisu-CPg5kPrx.js.map +1 -0
- package/gltf-ext-clearcoat-CLH2SVph.js +31 -0
- package/gltf-ext-clearcoat-CLH2SVph.js.map +1 -0
- package/gltf-ext-dielectric-qHzlnvdl.js +105 -0
- package/gltf-ext-dielectric-qHzlnvdl.js.map +1 -0
- package/gltf-ext-emissive-strength-nzGZXZVK.js +19 -0
- package/gltf-ext-emissive-strength-nzGZXZVK.js.map +1 -0
- package/gltf-ext-iridescence-C6bq7jiM.js +26 -0
- package/gltf-ext-iridescence-C6bq7jiM.js.map +1 -0
- package/gltf-ext-node-visibility-MafA9ot2.js +25 -0
- package/gltf-ext-node-visibility-MafA9ot2.js.map +1 -0
- package/gltf-ext-orm-CT18G_vQ.js +33 -0
- package/gltf-ext-orm-CT18G_vQ.js.map +1 -0
- package/gltf-ext-quantization-CpZyLDIz.js +94 -0
- package/gltf-ext-quantization-CpZyLDIz.js.map +1 -0
- package/gltf-ext-sheen-BgIxUzyZ.js +25 -0
- package/gltf-ext-sheen-BgIxUzyZ.js.map +1 -0
- package/gltf-ext-spec-gloss-D0LJLBUM.js +24 -0
- package/gltf-ext-spec-gloss-D0LJLBUM.js.map +1 -0
- package/gltf-ext-unlit-D2ANui0V.js +16 -0
- package/gltf-ext-unlit-D2ANui0V.js.map +1 -0
- package/gltf-ext-uv-transform-CE_-T1Tr.js +38 -0
- package/gltf-ext-uv-transform-CE_-T1Tr.js.map +1 -0
- package/gltf-feature-animation-pointer-BjpwOOqo.js +88 -0
- package/gltf-feature-animation-pointer-BjpwOOqo.js.map +1 -0
- package/gltf-feature-animations-CCizegp8.js +15 -0
- package/gltf-feature-animations-CCizegp8.js.map +1 -0
- package/gltf-feature-draco-yGSMGTE3.js +124 -0
- package/gltf-feature-draco-yGSMGTE3.js.map +1 -0
- package/gltf-feature-gpu-instancing-2e_CFQnl.js +151 -0
- package/gltf-feature-gpu-instancing-2e_CFQnl.js.map +1 -0
- package/gltf-feature-lights-punctual-DDDg4j0U.js +71 -0
- package/gltf-feature-lights-punctual-DDDg4j0U.js.map +1 -0
- package/gltf-feature-meshopt-Des96YFI.js +84 -0
- package/gltf-feature-meshopt-Des96YFI.js.map +1 -0
- package/gltf-feature-morph-CKCw6tkX.js +29 -0
- package/gltf-feature-morph-CKCw6tkX.js.map +1 -0
- package/gltf-feature-skeleton-D8hWLqi2.js +36 -0
- package/gltf-feature-skeleton-D8hWLqi2.js.map +1 -0
- package/gltf-feature-variants-Ds6v9byg.js +17 -0
- package/gltf-feature-variants-Ds6v9byg.js.map +1 -0
- package/gltf-feature-xmp-BUfq_IVG.js +15 -0
- package/gltf-feature-xmp-BUfq_IVG.js.map +1 -0
- package/gltf-glb-parser-D6UZWFuC.js +27 -0
- package/gltf-glb-parser-D6UZWFuC.js.map +1 -0
- package/gltf-interleave-DGnUlz28.js +241 -0
- package/gltf-interleave-DGnUlz28.js.map +1 -0
- package/gltf-pbr-builder-ext-BFOxOCnQ.js +85 -0
- package/gltf-pbr-builder-ext-BFOxOCnQ.js.map +1 -0
- package/gltf-variants-DFbr8EES.js +88 -0
- package/gltf-variants-DFbr8EES.js.map +1 -0
- package/gradient-block-DL_60sDc.js +50 -0
- package/gradient-block-DL_60sDc.js.map +1 -0
- package/gs-picking-pipeline-DzfMASL9.js +280 -0
- package/gs-picking-pipeline-DzfMASL9.js.map +1 -0
- package/height-to-normal-block-DhPHkDFg.js +65 -0
- package/height-to-normal-block-DhPHkDFg.js.map +1 -0
- package/ibl-fragment-DqQVi8k0.js +91 -0
- package/ibl-fragment-DqQVi8k0.js.map +1 -0
- package/ibl-skybox-wgsl-DCah0kWV.js +13 -0
- package/ibl-skybox-wgsl-DCah0kWV.js.map +1 -0
- package/image-processing-block-DwrhhmuF.js +40 -0
- package/image-processing-block-DwrhhmuF.js.map +1 -0
- package/image-source-BuMJgd9-.js +17 -0
- package/image-source-BuMJgd9-.js.map +1 -0
- package/index-C8HOR2sB.js +19222 -0
- package/index-C8HOR2sB.js.map +1 -0
- package/index.d.ts +4611 -0
- package/index.js +309 -0
- package/index.js.map +1 -0
- package/input-block-DgAJBzN_.js +109 -0
- package/input-block-DgAJBzN_.js.map +1 -0
- package/instances-block-BaSSiz8m.js +12 -0
- package/instances-block-BaSSiz8m.js.map +1 -0
- package/iridescence-block-B0pRFoOU.js +67 -0
- package/iridescence-block-B0pRFoOU.js.map +1 -0
- package/iridescence-fragment-Gymp7or5.js +243 -0
- package/iridescence-fragment-Gymp7or5.js.map +1 -0
- package/length-block-ChOkeiHR.js +11 -0
- package/length-block-ChOkeiHR.js.map +1 -0
- package/lerp-block-DjI2SfmI.js +18 -0
- package/lerp-block-DjI2SfmI.js.map +1 -0
- package/light-block-B11ew7FA.js +123 -0
- package/light-block-B11ew7FA.js.map +1 -0
- package/light-information-VJbW0jbs.js +19 -0
- package/light-information-VJbW0jbs.js.map +1 -0
- package/loop-block-Bb23EOMb.js +71 -0
- package/loop-block-Bb23EOMb.js.map +1 -0
- package/manifold-AS8POaOr.js +3022 -0
- package/manifold-AS8POaOr.js.map +1 -0
- package/manifold-RCa7RkKz.js +5 -0
- package/manifold-RCa7RkKz.js.map +1 -0
- package/matrix-blocks-acWn_V6g.js +51 -0
- package/matrix-blocks-acWn_V6g.js.map +1 -0
- package/max-block-CjFgljZ7.js +6 -0
- package/max-block-CjFgljZ7.js.map +1 -0
- package/mesh-attribute-exists-block-BfK8UiSL.js +44 -0
- package/mesh-attribute-exists-block-BfK8UiSL.js.map +1 -0
- package/mesh-features-BLENkYVt.js +341 -0
- package/mesh-features-BLENkYVt.js.map +1 -0
- package/min-block-CHtBngNl.js +6 -0
- package/min-block-CHtBngNl.js.map +1 -0
- package/mod-block-Ceizv8Y7.js +6 -0
- package/mod-block-Ceizv8Y7.js.map +1 -0
- package/morph-fragment-DOVo70gP.js +59 -0
- package/morph-fragment-DOVo70gP.js.map +1 -0
- package/morph-targets-55z342ZB.js +35 -0
- package/morph-targets-55z342ZB.js.map +1 -0
- package/multilight-wgsl-BGyiIOp3.js +112 -0
- package/multilight-wgsl-BGyiIOp3.js.map +1 -0
- package/multiply-block-DaXLJ7Ud.js +6 -0
- package/multiply-block-DaXLJ7Ud.js.map +1 -0
- package/negate-block-9CSLc5pM.js +6 -0
- package/negate-block-9CSLc5pM.js.map +1 -0
- package/nlerp-block-BNK1adIb.js +21 -0
- package/nlerp-block-BNK1adIb.js.map +1 -0
- package/node-env-BPZXZzBf.js +39 -0
- package/node-env-BPZXZzBf.js.map +1 -0
- package/node-registry-DwgC4yth.js +190 -0
- package/node-registry-DwgC4yth.js.map +1 -0
- package/node-registry-extra-advanced-2DJVt67-.js +45 -0
- package/node-registry-extra-advanced-2DJVt67-.js.map +1 -0
- package/node-registry-extra-compat-Dhrw8fDQ.js +41 -0
- package/node-registry-extra-compat-Dhrw8fDQ.js.map +1 -0
- package/node-registry-extra-math-CsAHvIZo.js +49 -0
- package/node-registry-extra-math-CsAHvIZo.js.map +1 -0
- package/node-registry-extra-procedural-5pLQ3Bhz.js +45 -0
- package/node-registry-extra-procedural-5pLQ3Bhz.js.map +1 -0
- package/node-renderable-DlLIdBmd.js +269 -0
- package/node-renderable-DlLIdBmd.js.map +1 -0
- package/node-shadow-DKrcqmNg.js +122 -0
- package/node-shadow-DKrcqmNg.js.map +1 -0
- package/node-snippet-DUMm9qEO.js +22 -0
- package/node-snippet-DUMm9qEO.js.map +1 -0
- package/normal-blend-block-BfH_nBoj.js +29 -0
- package/normal-blend-block-BfH_nBoj.js.map +1 -0
- package/normal-map-fragment-DpsIXrJf.js +38 -0
- package/normal-map-fragment-DpsIXrJf.js.map +1 -0
- package/normalize-block-F2bLNj9K.js +6 -0
- package/normalize-block-F2bLNj9K.js.map +1 -0
- package/oneminus-block-BP9x4Dc3.js +6 -0
- package/oneminus-block-BP9x4Dc3.js.map +1 -0
- package/opposite-block-Cnqmm-lH.js +6 -0
- package/opposite-block-Cnqmm-lH.js.map +1 -0
- package/package.json +26 -0
- package/panner-block-BwMQq-6Y.js +13 -0
- package/panner-block-BwMQq-6Y.js.map +1 -0
- package/parse-camera-DM3oJJeT.js +23 -0
- package/parse-camera-DM3oJJeT.js.map +1 -0
- package/pbr-aces-wgsl-HpiQHGN_.js +13 -0
- package/pbr-aces-wgsl-HpiQHGN_.js.map +1 -0
- package/pbr-metallic-roughness-block-full-6vMm1Jk6.js +763 -0
- package/pbr-metallic-roughness-block-full-6vMm1Jk6.js.map +1 -0
- package/pbr-metallic-roughness-block-h_KAOZrW.js +104 -0
- package/pbr-metallic-roughness-block-h_KAOZrW.js.map +1 -0
- package/pbr-mr-helper-core-CIwm-T1G.js +237 -0
- package/pbr-mr-helper-core-CIwm-T1G.js.map +1 -0
- package/pbr-refraction-DGmMSa2v.js +17 -0
- package/pbr-refraction-DGmMSa2v.js.map +1 -0
- package/pbr-renderable-BJxUtPBb.js +961 -0
- package/pbr-renderable-BJxUtPBb.js.map +1 -0
- package/pbr-shadow-fragment-LO9SlbJj.js +14 -0
- package/pbr-shadow-fragment-LO9SlbJj.js.map +1 -0
- package/pbr-template-ext-8q7BcTDf.js +88 -0
- package/pbr-template-ext-8q7BcTDf.js.map +1 -0
- package/pbr-tracking-B3alzn91.js +31 -0
- package/pbr-tracking-B3alzn91.js.map +1 -0
- package/pbr-transmission-ext-BxW4CEGu.js +581 -0
- package/pbr-transmission-ext-BxW4CEGu.js.map +1 -0
- package/perturb-normal-0Q8EM9ig.js +39 -0
- package/perturb-normal-0Q8EM9ig.js.map +1 -0
- package/posterize-block-DfdKsbEf.js +28 -0
- package/posterize-block-DfdKsbEf.js.map +1 -0
- package/pow-block-DI5ICzhc.js +13 -0
- package/pow-block-DI5ICzhc.js.map +1 -0
- package/random-number-block-2OyRYljF.js +15 -0
- package/random-number-block-2OyRYljF.js.map +1 -0
- package/reciprocal-block-Ck3CW-j-.js +14 -0
- package/reciprocal-block-Ck3CW-j-.js.map +1 -0
- package/reflect-block-CizpzrX4.js +12 -0
- package/reflect-block-CizpzrX4.js.map +1 -0
- package/reflectance-fragment-BCrgPmrt.js +143 -0
- package/reflectance-fragment-BCrgPmrt.js.map +1 -0
- package/reflection-block-DqcwyYqr.js +12 -0
- package/reflection-block-DqcwyYqr.js.map +1 -0
- package/reflection-texture-base-block-1xmJ0HDj.js +10 -0
- package/reflection-texture-base-block-1xmJ0HDj.js.map +1 -0
- package/reflection-texture-block-C3QtzoV8.js +60 -0
- package/reflection-texture-block-C3QtzoV8.js.map +1 -0
- package/refract-block-HHiAk-7U.js +13 -0
- package/refract-block-HHiAk-7U.js.map +1 -0
- package/refraction-block-U8y6XiXs.js +11 -0
- package/refraction-block-U8y6XiXs.js.map +1 -0
- package/refraction-dispersion-wgsl-DdQCyyO1.js +16 -0
- package/refraction-dispersion-wgsl-DdQCyyO1.js.map +1 -0
- package/remap-block-DxK1W1vp.js +27 -0
- package/remap-block-DxK1W1vp.js.map +1 -0
- package/replace-color-block-1m--hiru.js +17 -0
- package/replace-color-block-1m--hiru.js.map +1 -0
- package/rgbd-decode-DCvzUYeI.js +110 -0
- package/rgbd-decode-DCvzUYeI.js.map +1 -0
- package/rotate2d-block-nEe1N2MJ.js +15 -0
- package/rotate2d-block-nEe1N2MJ.js.map +1 -0
- package/scale-block-C5Z8159G.js +13 -0
- package/scale-block-C5Z8159G.js.map +1 -0
- package/scene-material-swap-C2ykv55W.js +34 -0
- package/scene-material-swap-C2ykv55W.js.map +1 -0
- package/screen-size-block-BVNnOvE8.js +21 -0
- package/screen-size-block-BVNnOvE8.js.map +1 -0
- package/screen-space-block-CwaxdfSe.js +28 -0
- package/screen-space-block-CwaxdfSe.js.map +1 -0
- package/shader-renderable-D-6796KR.js +531 -0
- package/shader-renderable-D-6796KR.js.map +1 -0
- package/shadow-fragment-core-DHN2G6FI.js +110 -0
- package/shadow-fragment-core-DHN2G6FI.js.map +1 -0
- package/shadow-map-CQNQC-Fw.js +13 -0
- package/shadow-map-CQNQC-Fw.js.map +1 -0
- package/sheen-block-BugfJqK3.js +12 -0
- package/sheen-block-BugfJqK3.js.map +1 -0
- package/sheen-fragment-Dze2f7XJ.js +215 -0
- package/sheen-fragment-Dze2f7XJ.js.map +1 -0
- package/simplex-perlin-3d-block-CcMtofzV.js +58 -0
- package/simplex-perlin-3d-block-CcMtofzV.js.map +1 -0
- package/singlelight-directional-wgsl-CmUDZxwz.js +39 -0
- package/singlelight-directional-wgsl-CmUDZxwz.js.map +1 -0
- package/singlelight-hemispheric-wgsl-t-83IP_s.js +40 -0
- package/singlelight-hemispheric-wgsl-t-83IP_s.js.map +1 -0
- package/singlelight-point-wgsl-CLzULIYV.js +45 -0
- package/singlelight-point-wgsl-CLzULIYV.js.map +1 -0
- package/singlelight-spot-wgsl-DEEUrfVM.js +47 -0
- package/singlelight-spot-wgsl-DEEUrfVM.js.map +1 -0
- package/skeleton-fragment-B_XlFbtx.js +71 -0
- package/skeleton-fragment-B_XlFbtx.js.map +1 -0
- package/skybox-renderable-DDwzu-PT.js +92 -0
- package/skybox-renderable-DDwzu-PT.js.map +1 -0
- package/skybox.vertex-DJgi072W.js +5 -0
- package/skybox.vertex-DJgi072W.js.map +1 -0
- package/smoothstep-block-Di4t37x-.js +15 -0
- package/smoothstep-block-Di4t37x-.js.map +1 -0
- package/splat-ply-compressed-BahdBG1r.js +394 -0
- package/splat-ply-compressed-BahdBG1r.js.map +1 -0
- package/standard-renderable-GjxL9xSf.js +636 -0
- package/standard-renderable-GjxL9xSf.js.map +1 -0
- package/std-ambient-fragment-BoUsD06w.js +37 -0
- package/std-ambient-fragment-BoUsD06w.js.map +1 -0
- package/std-cube-reflection-fragment-ulqc3bsP.js +31 -0
- package/std-cube-reflection-fragment-ulqc3bsP.js.map +1 -0
- package/std-emissive-fragment-DNGj1HdQ.js +40 -0
- package/std-emissive-fragment-DNGj1HdQ.js.map +1 -0
- package/std-lightmap-fragment-Bqj89aIe.js +37 -0
- package/std-lightmap-fragment-Bqj89aIe.js.map +1 -0
- package/std-opacity-fragment-KuPh5N2Z.js +37 -0
- package/std-opacity-fragment-KuPh5N2Z.js.map +1 -0
- package/std-reflection-fragment-BA5Ghn_M.js +57 -0
- package/std-reflection-fragment-BA5Ghn_M.js.map +1 -0
- package/std-shadow-fragment-FNQfrJuC.js +8 -0
- package/std-shadow-fragment-FNQfrJuC.js.map +1 -0
- package/std-specular-fragment-CE-6scqd.js +37 -0
- package/std-specular-fragment-CE-6scqd.js.map +1 -0
- package/std-tracking-CNKZ-hJN.js +15 -0
- package/std-tracking-CNKZ-hJN.js.map +1 -0
- package/step-block-BkywzTYm.js +13 -0
- package/step-block-BkywzTYm.js.map +1 -0
- package/storage-read-block-BdzhJfln.js +25 -0
- package/storage-read-block-BdzhJfln.js.map +1 -0
- package/storage-write-block-DjLKZ0Ro.js +11 -0
- package/storage-write-block-DjLKZ0Ro.js.map +1 -0
- package/subsurface-block-CBhxT9ui.js +12 -0
- package/subsurface-block-CBhxT9ui.js.map +1 -0
- package/subsurface-fragment-liM3y2-P.js +158 -0
- package/subsurface-fragment-liM3y2-P.js.map +1 -0
- package/subtract-block-NPfKvzQP.js +6 -0
- package/subtract-block-NPfKvzQP.js.map +1 -0
- package/swapchain-overlay-DcCSFDp7.js +35 -0
- package/swapchain-overlay-DcCSFDp7.js.map +1 -0
- package/tbn-block-ByOI6Y43.js +43 -0
- package/tbn-block-ByOI6Y43.js.map +1 -0
- package/teleport-in-block-BMa17cqq.js +10 -0
- package/teleport-in-block-BMa17cqq.js.map +1 -0
- package/teleport-out-block-5AkB25H6.js +19 -0
- package/teleport-out-block-5AkB25H6.js.map +1 -0
- package/texture-block-rr21KIL_.js +70 -0
- package/texture-block-rr21KIL_.js.map +1 -0
- package/thin-instance-fragment-hsv-RyDs.js +69 -0
- package/thin-instance-fragment-hsv-RyDs.js.map +1 -0
- package/thin-instance-gpu-C9Gv_Z1w.js +62 -0
- package/thin-instance-gpu-C9Gv_Z1w.js.map +1 -0
- package/tracking-primitives-wgdBY85t.js +82 -0
- package/tracking-primitives-wgdBY85t.js.map +1 -0
- package/transform-block-DbRph9JI.js +32 -0
- package/transform-block-DbRph9JI.js.map +1 -0
- package/trigonometry-block-BYQcTHiD.js +36 -0
- package/trigonometry-block-BYQcTHiD.js.map +1 -0
- package/triplanar-block-BZHkD9hX.js +148 -0
- package/triplanar-block-BZHkD9hX.js.map +1 -0
- package/twirl-block-78WtdiBd.js +39 -0
- package/twirl-block-78WtdiBd.js.map +1 -0
- package/unlit-fragment-BIlhJpz6.js +43 -0
- package/unlit-fragment-BIlhJpz6.js.map +1 -0
- package/uv-transform-fragment-hYujGpZg.js +47 -0
- package/uv-transform-fragment-hYujGpZg.js.map +1 -0
- package/vector-merger-CrW-ONB0.js +43 -0
- package/vector-merger-CrW-ONB0.js.map +1 -0
- package/vector-splitter-BoJuHrAU.js +34 -0
- package/vector-splitter-BoJuHrAU.js.map +1 -0
- package/vertex-output-Cvft64y0.js +14 -0
- package/vertex-output-Cvft64y0.js.map +1 -0
- package/view-direction-CWVucfnT.js +12 -0
- package/view-direction-CWVucfnT.js.map +1 -0
- package/voronoi-noise-block-iNQxa_Ls.js +43 -0
- package/voronoi-noise-block-iNQxa_Ls.js.map +1 -0
- package/wave-block-CY_mk1ec.js +41 -0
- package/wave-block-CY_mk1ec.js.map +1 -0
- package/wgsl-helpers-DyzNzCeE.js +48 -0
- package/wgsl-helpers-DyzNzCeE.js.map +1 -0
- package/worley-noise-3d-block-CyR2-k4s.js +58 -0
- package/worley-noise-3d-block-CyR2-k4s.js.map +1 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { aT as getCompressedFormat, aU as acquireTexture, aO as getOrCreateSampler, r as resolveAccessor } from "./index-C8HOR2sB.js";
|
|
2
|
+
const KTX2_DECODER_URL = "https://cdn.babylonjs.com/babylon.ktx2Decoder.js";
|
|
3
|
+
let _ktx2DecoderPromise = null;
|
|
4
|
+
const GL_RGBA8 = 32856;
|
|
5
|
+
const GL_R8 = 33321;
|
|
6
|
+
const GL_RG8 = 33323;
|
|
7
|
+
const RGBA_CAPS = { astc: false, bptc: false, s3tc: false, pvrtc: false, etc2: false, etc1: false };
|
|
8
|
+
function loadKtx2Decoder() {
|
|
9
|
+
if (_ktx2DecoderPromise) {
|
|
10
|
+
return _ktx2DecoderPromise;
|
|
11
|
+
}
|
|
12
|
+
_ktx2DecoderPromise = new Promise((resolve, reject) => {
|
|
13
|
+
const w = globalThis;
|
|
14
|
+
const init = () => {
|
|
15
|
+
const mod = w.KTX2DECODER;
|
|
16
|
+
if (!mod) {
|
|
17
|
+
reject(new Error("KTX2: decoder global KTX2DECODER not found after script load"));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
mod.MSCTranscoder.UseFromWorkerThread = false;
|
|
21
|
+
mod.WASMMemoryManager.LoadBinariesFromCurrentThread = true;
|
|
22
|
+
resolve(new mod.KTX2Decoder());
|
|
23
|
+
};
|
|
24
|
+
if (w.KTX2DECODER) {
|
|
25
|
+
init();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const script = document.createElement("script");
|
|
29
|
+
script.src = KTX2_DECODER_URL;
|
|
30
|
+
script.async = true;
|
|
31
|
+
script.onload = init;
|
|
32
|
+
script.onerror = () => reject(new Error(`KTX2: failed to load ${script.src}`));
|
|
33
|
+
document.head.appendChild(script);
|
|
34
|
+
});
|
|
35
|
+
_ktx2DecoderPromise.catch(() => {
|
|
36
|
+
_ktx2DecoderPromise = null;
|
|
37
|
+
});
|
|
38
|
+
return _ktx2DecoderPromise;
|
|
39
|
+
}
|
|
40
|
+
function srgbFormat(format) {
|
|
41
|
+
switch (format) {
|
|
42
|
+
case "rgba8unorm":
|
|
43
|
+
return "rgba8unorm-srgb";
|
|
44
|
+
case "bc1-rgba-unorm":
|
|
45
|
+
return "bc1-rgba-unorm-srgb";
|
|
46
|
+
case "bc2-rgba-unorm":
|
|
47
|
+
return "bc2-rgba-unorm-srgb";
|
|
48
|
+
case "bc3-rgba-unorm":
|
|
49
|
+
return "bc3-rgba-unorm-srgb";
|
|
50
|
+
case "bc7-rgba-unorm":
|
|
51
|
+
return "bc7-rgba-unorm-srgb";
|
|
52
|
+
case "etc2-rgb8unorm":
|
|
53
|
+
return "etc2-rgb8unorm-srgb";
|
|
54
|
+
case "etc2-rgb8a1unorm":
|
|
55
|
+
return "etc2-rgb8a1unorm-srgb";
|
|
56
|
+
case "etc2-rgba8unorm":
|
|
57
|
+
return "etc2-rgba8unorm-srgb";
|
|
58
|
+
case "astc-4x4-unorm":
|
|
59
|
+
return "astc-4x4-unorm-srgb";
|
|
60
|
+
case "astc-5x4-unorm":
|
|
61
|
+
return "astc-5x4-unorm-srgb";
|
|
62
|
+
case "astc-5x5-unorm":
|
|
63
|
+
return "astc-5x5-unorm-srgb";
|
|
64
|
+
case "astc-6x5-unorm":
|
|
65
|
+
return "astc-6x5-unorm-srgb";
|
|
66
|
+
case "astc-6x6-unorm":
|
|
67
|
+
return "astc-6x6-unorm-srgb";
|
|
68
|
+
case "astc-8x5-unorm":
|
|
69
|
+
return "astc-8x5-unorm-srgb";
|
|
70
|
+
case "astc-8x6-unorm":
|
|
71
|
+
return "astc-8x6-unorm-srgb";
|
|
72
|
+
case "astc-8x8-unorm":
|
|
73
|
+
return "astc-8x8-unorm-srgb";
|
|
74
|
+
case "astc-10x5-unorm":
|
|
75
|
+
return "astc-10x5-unorm-srgb";
|
|
76
|
+
case "astc-10x6-unorm":
|
|
77
|
+
return "astc-10x6-unorm-srgb";
|
|
78
|
+
case "astc-10x8-unorm":
|
|
79
|
+
return "astc-10x8-unorm-srgb";
|
|
80
|
+
case "astc-10x10-unorm":
|
|
81
|
+
return "astc-10x10-unorm-srgb";
|
|
82
|
+
case "astc-12x10-unorm":
|
|
83
|
+
return "astc-12x10-unorm-srgb";
|
|
84
|
+
case "astc-12x12-unorm":
|
|
85
|
+
return "astc-12x12-unorm-srgb";
|
|
86
|
+
default:
|
|
87
|
+
return format;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function uncompressedInfo(glFormat) {
|
|
91
|
+
switch (glFormat) {
|
|
92
|
+
case GL_RGBA8:
|
|
93
|
+
return { format: "rgba8unorm", bytesPerPixel: 4 };
|
|
94
|
+
case GL_R8:
|
|
95
|
+
return { format: "r8unorm", bytesPerPixel: 1 };
|
|
96
|
+
case GL_RG8:
|
|
97
|
+
return { format: "rg8unorm", bytesPerPixel: 2 };
|
|
98
|
+
default:
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function validateDecoded(decoded) {
|
|
103
|
+
var _a;
|
|
104
|
+
if (decoded.errors) {
|
|
105
|
+
throw new Error(`KTX2: ${decoded.errors}`);
|
|
106
|
+
}
|
|
107
|
+
if (!decoded.mipmaps.length) {
|
|
108
|
+
throw new Error("KTX2: decoder produced no mipmaps");
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < decoded.mipmaps.length; i++) {
|
|
111
|
+
if (!((_a = decoded.mipmaps[i]) == null ? void 0 : _a.data)) {
|
|
112
|
+
throw new Error(`KTX2: decoder produced an empty mip ${i}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return decoded.mipmaps;
|
|
116
|
+
}
|
|
117
|
+
function makeSampler(engine, mipCount) {
|
|
118
|
+
return getOrCreateSampler(engine, {
|
|
119
|
+
addressModeU: "repeat",
|
|
120
|
+
addressModeV: "repeat",
|
|
121
|
+
minFilter: "linear",
|
|
122
|
+
magFilter: "linear",
|
|
123
|
+
mipmapFilter: mipCount > 1 ? "linear" : "nearest",
|
|
124
|
+
maxAnisotropy: mipCount > 1 ? 4 : 1
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function uploadCompressed(engine, mips, format, sRGB) {
|
|
128
|
+
if (!engine._device.features.has(format.feature)) {
|
|
129
|
+
throw new Error(`KTX2: device does not support ${format.feature}`);
|
|
130
|
+
}
|
|
131
|
+
const width = mips[0].width;
|
|
132
|
+
const height = mips[0].height;
|
|
133
|
+
const texture = engine._device.createTexture({
|
|
134
|
+
size: { width, height },
|
|
135
|
+
format: sRGB ? srgbFormat(format.gpuFormat) : format.gpuFormat,
|
|
136
|
+
mipLevelCount: mips.length,
|
|
137
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
138
|
+
});
|
|
139
|
+
for (let level = 0; level < mips.length; level++) {
|
|
140
|
+
const mip = mips[level];
|
|
141
|
+
const rowBytes = Math.ceil(mip.width / format.blockW) * format.blockBytes;
|
|
142
|
+
engine._device.queue.writeTexture({ texture, mipLevel: level }, mip.data, { bytesPerRow: rowBytes }, { width: mip.width, height: mip.height });
|
|
143
|
+
}
|
|
144
|
+
const tex2d = { texture, view: texture.createView(), sampler: makeSampler(engine, mips.length), width, height, invertY: true };
|
|
145
|
+
acquireTexture(tex2d);
|
|
146
|
+
return tex2d;
|
|
147
|
+
}
|
|
148
|
+
function uploadUncompressed(engine, mips, info, sRGB) {
|
|
149
|
+
const width = mips[0].width;
|
|
150
|
+
const height = mips[0].height;
|
|
151
|
+
const texture = engine._device.createTexture({
|
|
152
|
+
size: { width, height },
|
|
153
|
+
format: sRGB ? srgbFormat(info.format) : info.format,
|
|
154
|
+
mipLevelCount: mips.length,
|
|
155
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
156
|
+
});
|
|
157
|
+
for (let level = 0; level < mips.length; level++) {
|
|
158
|
+
const mip = mips[level];
|
|
159
|
+
const expected = mip.width * mip.height * info.bytesPerPixel;
|
|
160
|
+
if (mip.data.length !== expected) {
|
|
161
|
+
throw new Error(`KTX2: uncompressed mip ${level} has ${mip.data.length} bytes, expected ${expected}`);
|
|
162
|
+
}
|
|
163
|
+
engine._device.queue.writeTexture(
|
|
164
|
+
{ texture, mipLevel: level },
|
|
165
|
+
mip.data,
|
|
166
|
+
{ bytesPerRow: mip.width * info.bytesPerPixel },
|
|
167
|
+
{ width: mip.width, height: mip.height }
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
const tex2d = { texture, view: texture.createView(), sampler: makeSampler(engine, mips.length), width, height, invertY: true };
|
|
171
|
+
acquireTexture(tex2d);
|
|
172
|
+
return tex2d;
|
|
173
|
+
}
|
|
174
|
+
async function uploadKtx2Texture2D(engine, buffer, sRGB) {
|
|
175
|
+
const decoder = await loadKtx2Decoder();
|
|
176
|
+
const decoded = await decoder.decode(new Uint8Array(buffer), RGBA_CAPS, { forceRGBA: true });
|
|
177
|
+
const mips = validateDecoded(decoded);
|
|
178
|
+
const compressed = getCompressedFormat(decoded.transcodedFormat);
|
|
179
|
+
if (compressed) {
|
|
180
|
+
return uploadCompressed(engine, mips, compressed, sRGB);
|
|
181
|
+
}
|
|
182
|
+
const uncompressed = uncompressedInfo(decoded.transcodedFormat);
|
|
183
|
+
if (uncompressed) {
|
|
184
|
+
return uploadUncompressed(engine, mips, uncompressed, sRGB);
|
|
185
|
+
}
|
|
186
|
+
throw new Error(`KTX2: unsupported transcoded format 0x${decoded.transcodedFormat.toString(16)}`);
|
|
187
|
+
}
|
|
188
|
+
async function decodeKtx2ImageBitmapFromBuffer(buffer) {
|
|
189
|
+
const decoder = await loadKtx2Decoder();
|
|
190
|
+
const decoded = await decoder.decode(new Uint8Array(buffer), RGBA_CAPS, { forceRGBA: true });
|
|
191
|
+
const mip0 = validateDecoded(decoded)[0];
|
|
192
|
+
if (mip0.data.length !== mip0.width * mip0.height * 4) {
|
|
193
|
+
throw new Error("KTX2: RGBA decode size does not match image dimensions");
|
|
194
|
+
}
|
|
195
|
+
const pixels = new Uint8ClampedArray(mip0.data.length);
|
|
196
|
+
pixels.set(mip0.data);
|
|
197
|
+
return createImageBitmap(new ImageData(pixels, mip0.width, mip0.height));
|
|
198
|
+
}
|
|
199
|
+
const NAME = "KHR_texture_basisu";
|
|
200
|
+
const FLOAT = 5126;
|
|
201
|
+
const TYPE_SIZES = {
|
|
202
|
+
SCALAR: 1,
|
|
203
|
+
VEC2: 2,
|
|
204
|
+
VEC3: 3,
|
|
205
|
+
VEC4: 4,
|
|
206
|
+
MAT2: 4,
|
|
207
|
+
MAT3: 9,
|
|
208
|
+
MAT4: 16
|
|
209
|
+
};
|
|
210
|
+
const BASISU_MATERIAL_DATA = "__basisuMaterialData";
|
|
211
|
+
function basisSourceIndex(tex) {
|
|
212
|
+
var _a, _b;
|
|
213
|
+
const source = (_b = (_a = tex == null ? void 0 : tex.extensions) == null ? void 0 : _a.KHR_texture_basisu) == null ? void 0 : _b.source;
|
|
214
|
+
return typeof source === "number" ? source : null;
|
|
215
|
+
}
|
|
216
|
+
function textureIndex(texInfo) {
|
|
217
|
+
const index = texInfo == null ? void 0 : texInfo.index;
|
|
218
|
+
return typeof index === "number" ? index : null;
|
|
219
|
+
}
|
|
220
|
+
function textureUsesBasisu(json, texInfo) {
|
|
221
|
+
var _a;
|
|
222
|
+
const index = textureIndex(texInfo);
|
|
223
|
+
return index !== null && basisSourceIndex((_a = json.textures) == null ? void 0 : _a[index]) !== null;
|
|
224
|
+
}
|
|
225
|
+
function stripBasisuTexture(json, owner, slot, data) {
|
|
226
|
+
if (!textureUsesBasisu(json, owner == null ? void 0 : owner[slot])) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
data[slot] = owner[slot];
|
|
230
|
+
delete owner[slot];
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
function prepareBasisuMaterials(json, binChunk, baseUrl) {
|
|
234
|
+
var _a;
|
|
235
|
+
for (const mat of json.materials ?? []) {
|
|
236
|
+
const data = { json, binChunk, baseUrl };
|
|
237
|
+
const pbr = mat.pbrMetallicRoughness ?? {};
|
|
238
|
+
let hasBasisu = stripBasisuTexture(json, pbr, "baseColorTexture", data);
|
|
239
|
+
hasBasisu = stripBasisuTexture(json, pbr, "metallicRoughnessTexture", data) || hasBasisu;
|
|
240
|
+
hasBasisu = stripBasisuTexture(json, mat, "normalTexture", data) || hasBasisu;
|
|
241
|
+
hasBasisu = stripBasisuTexture(json, mat, "occlusionTexture", data) || hasBasisu;
|
|
242
|
+
hasBasisu = stripBasisuTexture(json, mat, "emissiveTexture", data) || hasBasisu;
|
|
243
|
+
const spec = (_a = mat.extensions) == null ? void 0 : _a.KHR_materials_specular;
|
|
244
|
+
if (spec) {
|
|
245
|
+
hasBasisu = stripBasisuTexture(json, spec, "specularTexture", data) || hasBasisu;
|
|
246
|
+
hasBasisu = stripBasisuTexture(json, spec, "specularColorTexture", data) || hasBasisu;
|
|
247
|
+
}
|
|
248
|
+
if (hasBasisu) {
|
|
249
|
+
Object.defineProperty(mat, BASISU_MATERIAL_DATA, { value: data });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async function resolveImageBuffer(ctx, imageIdx) {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
const image = (_a = ctx.json.images) == null ? void 0 : _a[imageIdx];
|
|
256
|
+
if (!image) {
|
|
257
|
+
throw new Error(`${NAME}: image ${imageIdx} not found`);
|
|
258
|
+
}
|
|
259
|
+
if (image.bufferView !== void 0) {
|
|
260
|
+
const bv = (_b = ctx.json.bufferViews) == null ? void 0 : _b[image.bufferView];
|
|
261
|
+
if (!bv) {
|
|
262
|
+
throw new Error(`${NAME}: bufferView ${image.bufferView} not found`);
|
|
263
|
+
}
|
|
264
|
+
const offset = ctx.binChunk.byteOffset + (bv.byteOffset ?? 0);
|
|
265
|
+
const copy = new Uint8Array(bv.byteLength);
|
|
266
|
+
copy.set(new Uint8Array(ctx.binChunk.buffer, offset, bv.byteLength));
|
|
267
|
+
return copy.buffer;
|
|
268
|
+
}
|
|
269
|
+
if (image.uri) {
|
|
270
|
+
const url = new URL(image.uri, ctx.baseUrl + "x").href;
|
|
271
|
+
const response = await fetch(url);
|
|
272
|
+
if (!response.ok) {
|
|
273
|
+
throw new Error(`${NAME}: failed to load image ${response.status} ${response.statusText}`);
|
|
274
|
+
}
|
|
275
|
+
return response.arrayBuffer();
|
|
276
|
+
}
|
|
277
|
+
throw new Error(`${NAME}: image has neither bufferView nor uri`);
|
|
278
|
+
}
|
|
279
|
+
async function loadBasisuBitmap(data, texInfo) {
|
|
280
|
+
var _a;
|
|
281
|
+
const index = textureIndex(texInfo);
|
|
282
|
+
if (index === null) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
const source = basisSourceIndex((_a = data.json.textures) == null ? void 0 : _a[index]);
|
|
286
|
+
if (source === null) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
data.bitmaps ?? (data.bitmaps = /* @__PURE__ */ new Map());
|
|
290
|
+
let bitmap = data.bitmaps.get(index);
|
|
291
|
+
if (!bitmap) {
|
|
292
|
+
bitmap = resolveImageBuffer(data, source).then(decodeKtx2ImageBitmapFromBuffer);
|
|
293
|
+
data.bitmaps.set(index, bitmap);
|
|
294
|
+
}
|
|
295
|
+
return bitmap;
|
|
296
|
+
}
|
|
297
|
+
async function uploadBasisuTexture(data, ctx, texInfo, sRGB) {
|
|
298
|
+
var _a;
|
|
299
|
+
const index = textureIndex(texInfo);
|
|
300
|
+
if (index === null) {
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
303
|
+
data.textures ?? (data.textures = /* @__PURE__ */ new Map());
|
|
304
|
+
const key = `${index}:${sRGB ? 1 : 0}`;
|
|
305
|
+
let tex = data.textures.get(key);
|
|
306
|
+
if (!tex) {
|
|
307
|
+
const source = basisSourceIndex((_a = data.json.textures) == null ? void 0 : _a[index]);
|
|
308
|
+
if (source === null) {
|
|
309
|
+
return void 0;
|
|
310
|
+
}
|
|
311
|
+
tex = await uploadKtx2Texture2D(ctx._engine, await resolveImageBuffer(data, source), sRGB);
|
|
312
|
+
data.textures.set(key, tex);
|
|
313
|
+
}
|
|
314
|
+
return tex;
|
|
315
|
+
}
|
|
316
|
+
async function compositeOrm(mr, occ) {
|
|
317
|
+
const w = mr.width;
|
|
318
|
+
const h = mr.height;
|
|
319
|
+
const c1 = new OffscreenCanvas(w, h);
|
|
320
|
+
const x1 = c1.getContext("2d");
|
|
321
|
+
x1.drawImage(mr, 0, 0, w, h);
|
|
322
|
+
const d1 = x1.getImageData(0, 0, w, h);
|
|
323
|
+
const c2 = new OffscreenCanvas(w, h);
|
|
324
|
+
const x2 = c2.getContext("2d");
|
|
325
|
+
x2.drawImage(occ, 0, 0, w, h);
|
|
326
|
+
const d2 = x2.getImageData(0, 0, w, h);
|
|
327
|
+
for (let j = 0; j < d1.data.length; j += 4) {
|
|
328
|
+
d1.data[j] = d2.data[j];
|
|
329
|
+
}
|
|
330
|
+
x1.putImageData(d1, 0, 0);
|
|
331
|
+
return createImageBitmap(c1);
|
|
332
|
+
}
|
|
333
|
+
async function uploadOrmTexture(data, ctx) {
|
|
334
|
+
const mrInfo = data.metallicRoughnessTexture;
|
|
335
|
+
const occInfo = data.occlusionTexture;
|
|
336
|
+
const mrIndex = textureIndex(mrInfo);
|
|
337
|
+
const occIndex = textureIndex(occInfo);
|
|
338
|
+
if (mrIndex === null && occIndex === null) {
|
|
339
|
+
return void 0;
|
|
340
|
+
}
|
|
341
|
+
if (mrIndex === null || occIndex === null || mrIndex === occIndex) {
|
|
342
|
+
return uploadBasisuTexture(data, ctx, mrInfo ?? occInfo, false);
|
|
343
|
+
}
|
|
344
|
+
data.textures ?? (data.textures = /* @__PURE__ */ new Map());
|
|
345
|
+
const key = `orm:${mrIndex}:${occIndex}`;
|
|
346
|
+
let tex = data.textures.get(key);
|
|
347
|
+
if (!tex) {
|
|
348
|
+
const [mr, occ] = await Promise.all([loadBasisuBitmap(data, mrInfo), loadBasisuBitmap(data, occInfo)]);
|
|
349
|
+
if (!mr || !occ) {
|
|
350
|
+
return void 0;
|
|
351
|
+
}
|
|
352
|
+
tex = ctx._uploadImage(await compositeOrm(mr, occ), false);
|
|
353
|
+
data.textures.set(key, tex);
|
|
354
|
+
}
|
|
355
|
+
return tex;
|
|
356
|
+
}
|
|
357
|
+
function readStridedFloat(json, binChunk, accessorIdx) {
|
|
358
|
+
const accessor = json.accessors[accessorIdx];
|
|
359
|
+
const bufferView = json.bufferViews[accessor.bufferView];
|
|
360
|
+
if (accessor.componentType !== FLOAT) {
|
|
361
|
+
throw new Error(`${NAME}: strided accessor ${accessorIdx} uses unsupported component type: ${accessor.componentType}`);
|
|
362
|
+
}
|
|
363
|
+
const componentCount = TYPE_SIZES[accessor.type] ?? 1;
|
|
364
|
+
const elementBytes = componentCount * 4;
|
|
365
|
+
const byteStride = bufferView.byteStride ?? elementBytes;
|
|
366
|
+
if (byteStride < elementBytes) {
|
|
367
|
+
throw new Error(`${NAME}: invalid accessor stride ${byteStride} for accessor ${accessorIdx}`);
|
|
368
|
+
}
|
|
369
|
+
const baseOffset = binChunk.byteOffset + (bufferView.byteOffset ?? 0) + (accessor.byteOffset ?? 0);
|
|
370
|
+
const view = new DataView(binChunk.buffer);
|
|
371
|
+
const out = new Float32Array(accessor.count * componentCount);
|
|
372
|
+
for (let i = 0, o = 0; i < accessor.count; i++) {
|
|
373
|
+
const src = baseOffset + i * byteStride;
|
|
374
|
+
for (let c = 0; c < componentCount; c++, o++) {
|
|
375
|
+
out[o] = view.getFloat32(src + c * 4, true);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return out;
|
|
379
|
+
}
|
|
380
|
+
const ext = {
|
|
381
|
+
id: NAME,
|
|
382
|
+
async preMesh(json, binChunk, baseUrl) {
|
|
383
|
+
var _a, _b;
|
|
384
|
+
const gltf = json;
|
|
385
|
+
prepareBasisuMaterials(gltf, binChunk, baseUrl);
|
|
386
|
+
const decoded = /* @__PURE__ */ new Map();
|
|
387
|
+
for (const mesh of gltf.meshes ?? []) {
|
|
388
|
+
for (const primitive of mesh.primitives ?? []) {
|
|
389
|
+
const attrs = primitive.attributes ?? {};
|
|
390
|
+
const strided = Object.keys(attrs).some((name) => {
|
|
391
|
+
var _a2, _b2, _c, _d;
|
|
392
|
+
return ((_d = (_c = gltf.bufferViews) == null ? void 0 : _c[(_b2 = (_a2 = gltf.accessors) == null ? void 0 : _a2[attrs[name]]) == null ? void 0 : _b2.bufferView]) == null ? void 0 : _d.byteStride) !== void 0;
|
|
393
|
+
});
|
|
394
|
+
if (!strided) {
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const attributes = /* @__PURE__ */ new Map();
|
|
398
|
+
for (const name of Object.keys(attrs)) {
|
|
399
|
+
const accessorIdx = attrs[name];
|
|
400
|
+
const accessor = gltf.accessors[accessorIdx];
|
|
401
|
+
if (((_b = (_a = gltf.bufferViews) == null ? void 0 : _a[accessor.bufferView]) == null ? void 0 : _b.byteStride) !== void 0) {
|
|
402
|
+
attributes.set(name, readStridedFloat(gltf, binChunk, accessorIdx));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const posAcc = gltf.accessors[attrs.POSITION];
|
|
406
|
+
const idx = primitive.indices === void 0 ? new Uint32Array(0) : new Uint32Array(resolveAccessor(gltf, binChunk, primitive.indices)._data);
|
|
407
|
+
decoded.set(primitive, {
|
|
408
|
+
_attributes: attributes,
|
|
409
|
+
_indices: idx,
|
|
410
|
+
_vertexCount: posAcc.count,
|
|
411
|
+
_indexCount: idx.length
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return decoded;
|
|
416
|
+
},
|
|
417
|
+
async applyMaterial(mat, ctx) {
|
|
418
|
+
var _a, _b;
|
|
419
|
+
const data = (_a = mat._rawMatDef) == null ? void 0 : _a[BASISU_MATERIAL_DATA];
|
|
420
|
+
if (!data) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const [baseColorTexture, ormTexture, normalTexture, emissiveTexture, specularTexture, specularColorTexture] = await Promise.all([
|
|
424
|
+
uploadBasisuTexture(data, ctx, data.baseColorTexture, true),
|
|
425
|
+
uploadOrmTexture(data, ctx),
|
|
426
|
+
uploadBasisuTexture(data, ctx, data.normalTexture, false),
|
|
427
|
+
uploadBasisuTexture(data, ctx, data.emissiveTexture, true),
|
|
428
|
+
uploadBasisuTexture(data, ctx, data.specularTexture, false),
|
|
429
|
+
uploadBasisuTexture(data, ctx, data.specularColorTexture, true)
|
|
430
|
+
]);
|
|
431
|
+
const out = {
|
|
432
|
+
...baseColorTexture ? { baseColorTexture } : void 0,
|
|
433
|
+
...ormTexture ? {
|
|
434
|
+
ormTexture,
|
|
435
|
+
...data.metallicRoughnessTexture ? { metallicFactor: mat._metallicFactor, roughnessFactor: mat._roughnessFactor } : void 0,
|
|
436
|
+
...data.occlusionTexture ? { occlusionStrength: 1, occlusionTexCoord: data.occlusionTexture.texCoord ?? 0 } : void 0
|
|
437
|
+
} : void 0,
|
|
438
|
+
...normalTexture ? { normalTexture, normalTextureScale: ((_b = data.normalTexture) == null ? void 0 : _b.scale) ?? 1 } : void 0,
|
|
439
|
+
...emissiveTexture ? { emissiveTexture } : void 0,
|
|
440
|
+
...specularTexture ? { metallicReflectanceTexture: specularTexture, useOnlyMetallicFromMetallicReflectanceTexture: true } : void 0,
|
|
441
|
+
...specularColorTexture ? { reflectanceTexture: specularColorTexture } : void 0
|
|
442
|
+
};
|
|
443
|
+
if (!out.baseColorTexture && !out.ormTexture && !out.normalTexture && !out.emissiveTexture && !out.metallicReflectanceTexture && !out.reflectanceTexture) {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
return out;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
export {
|
|
450
|
+
ext as default
|
|
451
|
+
};
|
|
452
|
+
//# sourceMappingURL=gltf-ext-basisu-CPg5kPrx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-ext-basisu-CPg5kPrx.js","sources":["../src/texture/ktx2-loader.ts","../src/loader-gltf/gltf-ext-basisu.ts"],"sourcesContent":["/** KTX2/Basis Universal decoder for glTF KHR_texture_basisu.\n *\n * Kept separate from `basis-loader.ts` so existing `.basis` texture scenes do\n * not pay for KTX2 decoder glue. The CDN decoder is still fetched lazily only\n * after an asset declares KHR_texture_basisu.\n */\n\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { acquireTexture, getOrCreateSampler } from \"../resource/gpu-pool.js\";\nimport type { Texture2D } from \"./texture-2d.js\";\nimport { getCompressedFormat } from \"./compressed-formats.js\";\nimport type { CompressedFormatInfo } from \"./compressed-formats.js\";\n\ninterface Ktx2DecoderCaps {\n astc: boolean;\n bptc: boolean;\n s3tc: boolean;\n pvrtc: boolean;\n etc2: boolean;\n etc1: boolean;\n}\n\ninterface Ktx2DecodedMip {\n width: number;\n height: number;\n data: Uint8Array;\n}\n\ninterface Ktx2DecodedData {\n width: number;\n height: number;\n transcodedFormat: number;\n isInGammaSpace: boolean;\n hasAlpha: boolean;\n transcoderName: string;\n errors?: string;\n mipmaps: Ktx2DecodedMip[];\n}\n\ninterface Ktx2Decoder {\n decode(data: Uint8Array, caps: Ktx2DecoderCaps, options?: { forceRGBA?: boolean }): Promise<Ktx2DecodedData>;\n}\n\ninterface Ktx2DecoderModule {\n KTX2Decoder: new () => Ktx2Decoder;\n MSCTranscoder: { UseFromWorkerThread: boolean };\n WASMMemoryManager: { LoadBinariesFromCurrentThread: boolean };\n}\n\nconst KTX2_DECODER_URL = \"https://cdn.babylonjs.com/babylon.ktx2Decoder.js\";\nlet _ktx2DecoderPromise: Promise<Ktx2Decoder> | null = null;\n\nconst GL_RGBA8 = 0x8058;\nconst GL_R8 = 0x8229;\nconst GL_RG8 = 0x822b;\nconst RGBA_CAPS: Ktx2DecoderCaps = { astc: false, bptc: false, s3tc: false, pvrtc: false, etc2: false, etc1: false };\n\nfunction loadKtx2Decoder(): Promise<Ktx2Decoder> {\n if (_ktx2DecoderPromise) {\n return _ktx2DecoderPromise;\n }\n _ktx2DecoderPromise = new Promise<Ktx2Decoder>((resolve, reject) => {\n const w = globalThis as unknown as { KTX2DECODER?: Ktx2DecoderModule };\n const init = (): void => {\n const mod = w.KTX2DECODER;\n if (!mod) {\n reject(new Error(\"KTX2: decoder global KTX2DECODER not found after script load\"));\n return;\n }\n mod.MSCTranscoder.UseFromWorkerThread = false;\n mod.WASMMemoryManager.LoadBinariesFromCurrentThread = true;\n resolve(new mod.KTX2Decoder());\n };\n if (w.KTX2DECODER) {\n init();\n return;\n }\n const script = document.createElement(\"script\");\n script.src = KTX2_DECODER_URL;\n script.async = true;\n script.onload = init;\n script.onerror = (): void => reject(new Error(`KTX2: failed to load ${script.src}`));\n document.head.appendChild(script);\n });\n _ktx2DecoderPromise.catch(() => {\n _ktx2DecoderPromise = null;\n });\n return _ktx2DecoderPromise;\n}\n\nfunction srgbFormat(format: GPUTextureFormat): GPUTextureFormat {\n switch (format) {\n case \"rgba8unorm\":\n return \"rgba8unorm-srgb\";\n case \"bc1-rgba-unorm\":\n return \"bc1-rgba-unorm-srgb\";\n case \"bc2-rgba-unorm\":\n return \"bc2-rgba-unorm-srgb\";\n case \"bc3-rgba-unorm\":\n return \"bc3-rgba-unorm-srgb\";\n case \"bc7-rgba-unorm\":\n return \"bc7-rgba-unorm-srgb\";\n case \"etc2-rgb8unorm\":\n return \"etc2-rgb8unorm-srgb\";\n case \"etc2-rgb8a1unorm\":\n return \"etc2-rgb8a1unorm-srgb\";\n case \"etc2-rgba8unorm\":\n return \"etc2-rgba8unorm-srgb\";\n case \"astc-4x4-unorm\":\n return \"astc-4x4-unorm-srgb\";\n case \"astc-5x4-unorm\":\n return \"astc-5x4-unorm-srgb\";\n case \"astc-5x5-unorm\":\n return \"astc-5x5-unorm-srgb\";\n case \"astc-6x5-unorm\":\n return \"astc-6x5-unorm-srgb\";\n case \"astc-6x6-unorm\":\n return \"astc-6x6-unorm-srgb\";\n case \"astc-8x5-unorm\":\n return \"astc-8x5-unorm-srgb\";\n case \"astc-8x6-unorm\":\n return \"astc-8x6-unorm-srgb\";\n case \"astc-8x8-unorm\":\n return \"astc-8x8-unorm-srgb\";\n case \"astc-10x5-unorm\":\n return \"astc-10x5-unorm-srgb\";\n case \"astc-10x6-unorm\":\n return \"astc-10x6-unorm-srgb\";\n case \"astc-10x8-unorm\":\n return \"astc-10x8-unorm-srgb\";\n case \"astc-10x10-unorm\":\n return \"astc-10x10-unorm-srgb\";\n case \"astc-12x10-unorm\":\n return \"astc-12x10-unorm-srgb\";\n case \"astc-12x12-unorm\":\n return \"astc-12x12-unorm-srgb\";\n default:\n return format;\n }\n}\n\nfunction uncompressedInfo(glFormat: number): { format: GPUTextureFormat; bytesPerPixel: number } | null {\n switch (glFormat) {\n case GL_RGBA8:\n return { format: \"rgba8unorm\", bytesPerPixel: 4 };\n case GL_R8:\n return { format: \"r8unorm\", bytesPerPixel: 1 };\n case GL_RG8:\n return { format: \"rg8unorm\", bytesPerPixel: 2 };\n default:\n return null;\n }\n}\n\nfunction validateDecoded(decoded: Ktx2DecodedData): Ktx2DecodedMip[] {\n if (decoded.errors) {\n throw new Error(`KTX2: ${decoded.errors}`);\n }\n if (!decoded.mipmaps.length) {\n throw new Error(\"KTX2: decoder produced no mipmaps\");\n }\n for (let i = 0; i < decoded.mipmaps.length; i++) {\n if (!decoded.mipmaps[i]?.data) {\n throw new Error(`KTX2: decoder produced an empty mip ${i}`);\n }\n }\n return decoded.mipmaps;\n}\n\nfunction makeSampler(engine: EngineContext, mipCount: number): GPUSampler {\n return getOrCreateSampler(engine, {\n addressModeU: \"repeat\",\n addressModeV: \"repeat\",\n minFilter: \"linear\",\n magFilter: \"linear\",\n mipmapFilter: mipCount > 1 ? \"linear\" : \"nearest\",\n maxAnisotropy: mipCount > 1 ? 4 : 1,\n });\n}\n\nfunction uploadCompressed(engine: EngineContext, mips: Ktx2DecodedMip[], format: CompressedFormatInfo, sRGB: boolean): Texture2D {\n if (!engine._device.features.has(format.feature as GPUFeatureName)) {\n throw new Error(`KTX2: device does not support ${format.feature}`);\n }\n const width = mips[0]!.width;\n const height = mips[0]!.height;\n const texture = engine._device.createTexture({\n size: { width, height },\n format: sRGB ? srgbFormat(format.gpuFormat) : format.gpuFormat,\n mipLevelCount: mips.length,\n usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,\n });\n for (let level = 0; level < mips.length; level++) {\n const mip = mips[level]!;\n const rowBytes = Math.ceil(mip.width / format.blockW) * format.blockBytes;\n engine._device.queue.writeTexture({ texture, mipLevel: level }, mip.data as Uint8Array<ArrayBuffer>, { bytesPerRow: rowBytes }, { width: mip.width, height: mip.height });\n }\n const tex2d: Texture2D = { texture, view: texture.createView(), sampler: makeSampler(engine, mips.length), width, height, invertY: true };\n acquireTexture(tex2d);\n return tex2d;\n}\n\nfunction uploadUncompressed(engine: EngineContext, mips: Ktx2DecodedMip[], info: { format: GPUTextureFormat; bytesPerPixel: number }, sRGB: boolean): Texture2D {\n const width = mips[0]!.width;\n const height = mips[0]!.height;\n const texture = engine._device.createTexture({\n size: { width, height },\n format: sRGB ? srgbFormat(info.format) : info.format,\n mipLevelCount: mips.length,\n usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,\n });\n for (let level = 0; level < mips.length; level++) {\n const mip = mips[level]!;\n const expected = mip.width * mip.height * info.bytesPerPixel;\n if (mip.data.length !== expected) {\n throw new Error(`KTX2: uncompressed mip ${level} has ${mip.data.length} bytes, expected ${expected}`);\n }\n engine._device.queue.writeTexture(\n { texture, mipLevel: level },\n mip.data as Uint8Array<ArrayBuffer>,\n { bytesPerRow: mip.width * info.bytesPerPixel },\n { width: mip.width, height: mip.height }\n );\n }\n const tex2d: Texture2D = { texture, view: texture.createView(), sampler: makeSampler(engine, mips.length), width, height, invertY: true };\n acquireTexture(tex2d);\n return tex2d;\n}\n\n/** Decode a KTX2 texture with the current WebGPU compression caps and upload the\n * decoder-provided full mip chain directly to a Texture2D. */\nexport async function uploadKtx2Texture2D(engine: EngineContext, buffer: ArrayBuffer, sRGB: boolean): Promise<Texture2D> {\n const decoder = await loadKtx2Decoder();\n const decoded = await decoder.decode(new Uint8Array(buffer), RGBA_CAPS, { forceRGBA: true });\n const mips = validateDecoded(decoded);\n\n const compressed = getCompressedFormat(decoded.transcodedFormat);\n if (compressed) {\n return uploadCompressed(engine, mips, compressed, sRGB);\n }\n\n const uncompressed = uncompressedInfo(decoded.transcodedFormat);\n if (uncompressed) {\n return uploadUncompressed(engine, mips, uncompressed, sRGB);\n }\n\n throw new Error(`KTX2: unsupported transcoded format 0x${decoded.transcodedFormat.toString(16)}`);\n}\n\n/** Decode the first mip level of a KTX2 texture into an ImageBitmap so glTF\n * material extensions can reuse the core image upload path. */\nexport async function decodeKtx2ImageBitmapFromBuffer(buffer: ArrayBuffer): Promise<ImageBitmap> {\n const decoder = await loadKtx2Decoder();\n const decoded = await decoder.decode(new Uint8Array(buffer), RGBA_CAPS, { forceRGBA: true });\n const mip0 = validateDecoded(decoded)[0]!;\n if (mip0.data.length !== mip0.width * mip0.height * 4) {\n throw new Error(\"KTX2: RGBA decode size does not match image dimensions\");\n }\n const pixels = new Uint8ClampedArray(mip0.data.length);\n pixels.set(mip0.data);\n return createImageBitmap(new ImageData(pixels, mip0.width, mip0.height));\n}\n","/** KHR_texture_basisu glTF texture-source extension.\n *\n * The extension redirects textureInfos whose glTF texture declares\n * `extensions.KHR_texture_basisu.source` to the referenced KTX2 image and\n * uploads it through the lazily fetched KTX2 decoder. Core glTF\n * material parsing remains extension-agnostic: this module only loads when the\n * asset lists KHR_texture_basisu in `extensionsUsed`.\n */\n\nimport type { GltfMatExtCtx } from \"./gltf-material.js\";\nimport type { GltfFeature } from \"./gltf-feature.js\";\nimport type { DecodedPrimitive } from \"./gltf-feature.js\";\nimport type { PbrMaterialProps } from \"../material/pbr/pbr-material.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { resolveAccessor } from \"./gltf-parser.js\";\nimport { decodeKtx2ImageBitmapFromBuffer, uploadKtx2Texture2D } from \"../texture/ktx2-loader.js\";\n\nconst NAME = \"KHR_texture_basisu\";\nconst FLOAT = 5126;\nconst TYPE_SIZES: Record<string, number> = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16,\n};\nconst BASISU_MATERIAL_DATA = \"__basisuMaterialData\";\n\ninterface BasisuMaterialData {\n json: any;\n binChunk: DataView;\n baseUrl: string;\n baseColorTexture?: any;\n metallicRoughnessTexture?: any;\n normalTexture?: any;\n occlusionTexture?: any;\n emissiveTexture?: any;\n specularTexture?: any;\n specularColorTexture?: any;\n bitmaps?: Map<number, Promise<ImageBitmap>>;\n textures?: Map<string, Texture2D>;\n}\n\nfunction basisSourceIndex(tex: unknown): number | null {\n const source = (tex as { extensions?: { KHR_texture_basisu?: { source?: unknown } } } | undefined)?.extensions?.KHR_texture_basisu?.source;\n return typeof source === \"number\" ? source : null;\n}\n\nfunction textureIndex(texInfo: unknown): number | null {\n const index = (texInfo as { index?: unknown } | undefined)?.index;\n return typeof index === \"number\" ? index : null;\n}\n\nfunction textureUsesBasisu(json: any, texInfo: unknown): boolean {\n const index = textureIndex(texInfo);\n return index !== null && basisSourceIndex(json.textures?.[index]) !== null;\n}\n\nfunction stripBasisuTexture(json: any, owner: any, slot: keyof BasisuMaterialData, data: BasisuMaterialData): boolean {\n if (!textureUsesBasisu(json, owner?.[slot])) {\n return false;\n }\n data[slot] = owner[slot];\n delete owner[slot];\n return true;\n}\n\nfunction prepareBasisuMaterials(json: any, binChunk: DataView, baseUrl: string): void {\n for (const mat of json.materials ?? []) {\n const data: BasisuMaterialData = { json, binChunk, baseUrl };\n const pbr = mat.pbrMetallicRoughness ?? {};\n let hasBasisu = stripBasisuTexture(json, pbr, \"baseColorTexture\", data);\n hasBasisu = stripBasisuTexture(json, pbr, \"metallicRoughnessTexture\", data) || hasBasisu;\n hasBasisu = stripBasisuTexture(json, mat, \"normalTexture\", data) || hasBasisu;\n hasBasisu = stripBasisuTexture(json, mat, \"occlusionTexture\", data) || hasBasisu;\n hasBasisu = stripBasisuTexture(json, mat, \"emissiveTexture\", data) || hasBasisu;\n const spec = mat.extensions?.KHR_materials_specular;\n if (spec) {\n hasBasisu = stripBasisuTexture(json, spec, \"specularTexture\", data) || hasBasisu;\n hasBasisu = stripBasisuTexture(json, spec, \"specularColorTexture\", data) || hasBasisu;\n }\n if (hasBasisu) {\n Object.defineProperty(mat, BASISU_MATERIAL_DATA, { value: data });\n }\n }\n}\n\nasync function resolveImageBuffer(ctx: BasisuMaterialData, imageIdx: number): Promise<ArrayBuffer> {\n const image = ctx.json.images?.[imageIdx];\n if (!image) {\n throw new Error(`${NAME}: image ${imageIdx} not found`);\n }\n if (image.bufferView !== undefined) {\n const bv = ctx.json.bufferViews?.[image.bufferView];\n if (!bv) {\n throw new Error(`${NAME}: bufferView ${image.bufferView} not found`);\n }\n const offset = ctx.binChunk.byteOffset + (bv.byteOffset ?? 0);\n const copy = new Uint8Array(bv.byteLength);\n copy.set(new Uint8Array(ctx.binChunk.buffer, offset, bv.byteLength));\n return copy.buffer;\n }\n if (image.uri) {\n const url = new URL(image.uri, ctx.baseUrl + \"x\").href;\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`${NAME}: failed to load image ${response.status} ${response.statusText}`);\n }\n return response.arrayBuffer();\n }\n throw new Error(`${NAME}: image has neither bufferView nor uri`);\n}\n\nasync function loadBasisuBitmap(data: BasisuMaterialData, texInfo: unknown): Promise<ImageBitmap | null> {\n const index = textureIndex(texInfo);\n if (index === null) {\n return null;\n }\n const source = basisSourceIndex(data.json.textures?.[index]);\n if (source === null) {\n return null;\n }\n data.bitmaps ??= new Map();\n let bitmap = data.bitmaps.get(index);\n if (!bitmap) {\n bitmap = resolveImageBuffer(data, source).then(decodeKtx2ImageBitmapFromBuffer);\n data.bitmaps.set(index, bitmap);\n }\n return bitmap;\n}\n\nasync function uploadBasisuTexture(data: BasisuMaterialData, ctx: GltfMatExtCtx, texInfo: unknown, sRGB: boolean): Promise<Texture2D | undefined> {\n const index = textureIndex(texInfo);\n if (index === null) {\n return undefined;\n }\n data.textures ??= new Map();\n const key = `${index}:${sRGB ? 1 : 0}`;\n let tex = data.textures.get(key);\n if (!tex) {\n const source = basisSourceIndex(data.json.textures?.[index]);\n if (source === null) {\n return undefined;\n }\n tex = await uploadKtx2Texture2D(ctx._engine, await resolveImageBuffer(data, source), sRGB);\n data.textures.set(key, tex);\n }\n return tex;\n}\n\nasync function compositeOrm(mr: ImageBitmap, occ: ImageBitmap): Promise<ImageBitmap> {\n const w = mr.width;\n const h = mr.height;\n const c1 = new OffscreenCanvas(w, h);\n const x1 = c1.getContext(\"2d\")!;\n x1.drawImage(mr, 0, 0, w, h);\n const d1 = x1.getImageData(0, 0, w, h);\n const c2 = new OffscreenCanvas(w, h);\n const x2 = c2.getContext(\"2d\")!;\n x2.drawImage(occ, 0, 0, w, h);\n const d2 = x2.getImageData(0, 0, w, h);\n for (let j = 0; j < d1.data.length; j += 4) {\n d1.data[j] = d2.data[j]!;\n }\n x1.putImageData(d1, 0, 0);\n return createImageBitmap(c1);\n}\n\nasync function uploadOrmTexture(data: BasisuMaterialData, ctx: GltfMatExtCtx): Promise<Texture2D | undefined> {\n const mrInfo = data.metallicRoughnessTexture;\n const occInfo = data.occlusionTexture;\n const mrIndex = textureIndex(mrInfo);\n const occIndex = textureIndex(occInfo);\n if (mrIndex === null && occIndex === null) {\n return undefined;\n }\n if (mrIndex === null || occIndex === null || mrIndex === occIndex) {\n return uploadBasisuTexture(data, ctx, mrInfo ?? occInfo, false);\n }\n data.textures ??= new Map();\n const key = `orm:${mrIndex}:${occIndex}`;\n let tex = data.textures.get(key);\n if (!tex) {\n const [mr, occ] = await Promise.all([loadBasisuBitmap(data, mrInfo), loadBasisuBitmap(data, occInfo)]);\n if (!mr || !occ) {\n return undefined;\n }\n tex = ctx._uploadImage(await compositeOrm(mr, occ), false);\n data.textures.set(key, tex);\n }\n return tex;\n}\n\nfunction readStridedFloat(json: any, binChunk: DataView, accessorIdx: number): Float32Array {\n const accessor = json.accessors[accessorIdx];\n const bufferView = json.bufferViews[accessor.bufferView];\n if (accessor.componentType !== FLOAT) {\n throw new Error(`${NAME}: strided accessor ${accessorIdx} uses unsupported component type: ${accessor.componentType}`);\n }\n const componentCount = TYPE_SIZES[accessor.type] ?? 1;\n const elementBytes = componentCount * 4;\n const byteStride = bufferView.byteStride ?? elementBytes;\n if (byteStride < elementBytes) {\n throw new Error(`${NAME}: invalid accessor stride ${byteStride} for accessor ${accessorIdx}`);\n }\n const baseOffset = binChunk.byteOffset + (bufferView.byteOffset ?? 0) + (accessor.byteOffset ?? 0);\n const view = new DataView(binChunk.buffer);\n const out = new Float32Array(accessor.count * componentCount);\n for (let i = 0, o = 0; i < accessor.count; i++) {\n const src = baseOffset + i * byteStride;\n for (let c = 0; c < componentCount; c++, o++) {\n out[o] = view.getFloat32(src + c * 4, true);\n }\n }\n return out;\n}\n\nconst ext: GltfFeature = {\n id: NAME,\n async preMesh(json, binChunk, baseUrl) {\n const gltf = json as any;\n prepareBasisuMaterials(gltf, binChunk, baseUrl);\n const decoded = new Map<unknown, DecodedPrimitive>();\n for (const mesh of gltf.meshes ?? []) {\n for (const primitive of mesh.primitives ?? []) {\n const attrs = primitive.attributes ?? {};\n const strided = Object.keys(attrs).some((name) => gltf.bufferViews?.[gltf.accessors?.[attrs[name]]?.bufferView]?.byteStride !== undefined);\n if (!strided) {\n continue;\n }\n const attributes = new Map<string, Float32Array>();\n for (const name of Object.keys(attrs)) {\n const accessorIdx = attrs[name];\n const accessor = gltf.accessors[accessorIdx];\n if (gltf.bufferViews?.[accessor.bufferView]?.byteStride !== undefined) {\n attributes.set(name, readStridedFloat(gltf, binChunk, accessorIdx));\n }\n }\n const posAcc = gltf.accessors[attrs.POSITION];\n const idx =\n primitive.indices === undefined\n ? new Uint32Array(0)\n : new Uint32Array(resolveAccessor(gltf, binChunk, primitive.indices)._data as Uint16Array | Uint32Array | Uint8Array);\n decoded.set(primitive, {\n _attributes: attributes,\n _indices: idx,\n _vertexCount: posAcc.count,\n _indexCount: idx.length,\n });\n }\n }\n return decoded;\n },\n async applyMaterial(mat, ctx) {\n const data = mat._rawMatDef?.[BASISU_MATERIAL_DATA] as BasisuMaterialData | undefined;\n if (!data) {\n return null;\n }\n const [baseColorTexture, ormTexture, normalTexture, emissiveTexture, specularTexture, specularColorTexture] = await Promise.all([\n uploadBasisuTexture(data, ctx, data.baseColorTexture, true),\n uploadOrmTexture(data, ctx),\n uploadBasisuTexture(data, ctx, data.normalTexture, false),\n uploadBasisuTexture(data, ctx, data.emissiveTexture, true),\n uploadBasisuTexture(data, ctx, data.specularTexture, false),\n uploadBasisuTexture(data, ctx, data.specularColorTexture, true),\n ]);\n const out: Partial<PbrMaterialProps> = {\n ...(baseColorTexture ? { baseColorTexture } : undefined),\n ...(ormTexture\n ? {\n ormTexture,\n ...(data.metallicRoughnessTexture ? { metallicFactor: mat._metallicFactor, roughnessFactor: mat._roughnessFactor } : undefined),\n ...(data.occlusionTexture ? { occlusionStrength: 1.0, occlusionTexCoord: data.occlusionTexture.texCoord ?? 0 } : undefined),\n }\n : undefined),\n ...(normalTexture ? { normalTexture, normalTextureScale: data.normalTexture?.scale ?? 1 } : undefined),\n ...(emissiveTexture ? { emissiveTexture } : undefined),\n ...(specularTexture ? { metallicReflectanceTexture: specularTexture, useOnlyMetallicFromMetallicReflectanceTexture: true } : undefined),\n ...(specularColorTexture ? { reflectanceTexture: specularColorTexture } : undefined),\n };\n if (!out.baseColorTexture && !out.ormTexture && !out.normalTexture && !out.emissiveTexture && !out.metallicReflectanceTexture && !out.reflectanceTexture) {\n return null;\n }\n return out;\n },\n};\n\nexport default ext;\n"],"names":["_b","_a"],"mappings":";AAiDA,MAAM,mBAAmB;AACzB,IAAI,sBAAmD;AAEvD,MAAM,WAAW;AACjB,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,YAA6B,EAAE,MAAM,OAAO,MAAM,OAAO,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO,MAAM,MAAA;AAE7G,SAAS,kBAAwC;AAC7C,MAAI,qBAAqB;AACrB,WAAO;AAAA,EACX;AACA,wBAAsB,IAAI,QAAqB,CAAC,SAAS,WAAW;AAChE,UAAM,IAAI;AACV,UAAM,OAAO,MAAY;AACrB,YAAM,MAAM,EAAE;AACd,UAAI,CAAC,KAAK;AACN,eAAO,IAAI,MAAM,8DAA8D,CAAC;AAChF;AAAA,MACJ;AACA,UAAI,cAAc,sBAAsB;AACxC,UAAI,kBAAkB,gCAAgC;AACtD,cAAQ,IAAI,IAAI,aAAa;AAAA,IACjC;AACA,QAAI,EAAE,aAAa;AACf,WAAA;AACA;AAAA,IACJ;AACA,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM;AACb,WAAO,QAAQ;AACf,WAAO,SAAS;AAChB,WAAO,UAAU,MAAY,OAAO,IAAI,MAAM,wBAAwB,OAAO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AAkB,EAAE,4BAA4B,iBAAiB,+CAA+C,SAAS;AAAA,MAC7H,GAAI,uBAAuB,EAAE,oBAAoB,yBAAyB;AAAA,IAAA;AAE9E,QAAI,CAAC,IAAI,oBAAoB,CAAC,IAAI,cAAc,CAAC,IAAI,iBAAiB,CAAC,IAAI,mBAAmB,CAAC,IAAI,8BAA8B,CAAC,IAAI,oBAAoB;AACtJ,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AACJ;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const ext = {
|
|
2
|
+
id: "KHR_materials_clearcoat",
|
|
3
|
+
async applyMaterial(mat, ctx) {
|
|
4
|
+
var _a, _b, _c;
|
|
5
|
+
const c = (_b = (_a = mat._rawMatDef) == null ? void 0 : _a.extensions) == null ? void 0 : _b.KHR_materials_clearcoat;
|
|
6
|
+
if (!c) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const [tex, rough, normal] = await Promise.all([
|
|
10
|
+
ctx._texture(c.clearcoatTexture, false),
|
|
11
|
+
ctx._texture(c.clearcoatRoughnessTexture, false),
|
|
12
|
+
ctx._texture(c.clearcoatNormalTexture, false)
|
|
13
|
+
]);
|
|
14
|
+
return {
|
|
15
|
+
clearCoat: {
|
|
16
|
+
isEnabled: true,
|
|
17
|
+
intensity: c.clearcoatFactor ?? (c.clearcoatTexture ? 1 : 0),
|
|
18
|
+
roughness: c.clearcoatRoughnessFactor ?? (c.clearcoatRoughnessTexture ? 1 : 0),
|
|
19
|
+
texture: tex,
|
|
20
|
+
roughnessTexture: rough,
|
|
21
|
+
bumpTexture: normal,
|
|
22
|
+
bumpTextureScale: ((_c = c.clearcoatNormalTexture) == null ? void 0 : _c.scale) ?? 1,
|
|
23
|
+
useF0Remap: false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
ext as default
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=gltf-ext-clearcoat-CLH2SVph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-ext-clearcoat-CLH2SVph.js","sources":["../src/loader-gltf/gltf-ext-clearcoat.ts"],"sourcesContent":["/** glTF KHR_materials_clearcoat extension. */\nimport type { GltfFeature } from \"./gltf-feature.js\";\n\nconst ext: GltfFeature = {\n id: \"KHR_materials_clearcoat\",\n async applyMaterial(mat, ctx) {\n const c = mat._rawMatDef?.extensions?.KHR_materials_clearcoat;\n if (!c) {\n return null;\n }\n const [tex, rough, normal] = await Promise.all([\n ctx._texture(c.clearcoatTexture, false),\n ctx._texture(c.clearcoatRoughnessTexture, false),\n ctx._texture(c.clearcoatNormalTexture, false),\n ]);\n return {\n clearCoat: {\n isEnabled: true,\n intensity: c.clearcoatFactor ?? (c.clearcoatTexture ? 1 : 0),\n roughness: c.clearcoatRoughnessFactor ?? (c.clearcoatRoughnessTexture ? 1 : 0),\n texture: tex,\n roughnessTexture: rough,\n bumpTexture: normal,\n bumpTextureScale: c.clearcoatNormalTexture?.scale ?? 1,\n useF0Remap: false,\n },\n };\n },\n};\nexport default ext;\n"],"names":[],"mappings":"AAGA,MAAM,MAAmB;AAAA,EACrB,IAAI;AAAA,EACJ,MAAM,cAAc,KAAK,KAAK;AAFlC;AAGQ,UAAM,KAAI,eAAI,eAAJ,mBAAgB,eAAhB,mBAA4B;AACtC,QAAI,CAAC,GAAG;AACJ,aAAO;AAAA,IACX;AACA,UAAM,CAAC,KAAK,OAAO,MAAM,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC3C,IAAI,SAAS,EAAE,kBAAkB,KAAK;AAAA,MACtC,IAAI,SAAS,EAAE,2BAA2B,KAAK;AAAA,MAC/C,IAAI,SAAS,EAAE,wBAAwB,KAAK;AAAA,IAAA,CAC/C;AACD,WAAO;AAAA,MACH,WAAW;AAAA,QACP,WAAW;AAAA,QACX,WAAW,EAAE,oBAAoB,EAAE,mBAAmB,IAAI;AAAA,QAC1D,WAAW,EAAE,6BAA6B,EAAE,4BAA4B,IAAI;AAAA,QAC5E,SAAS;AAAA,QACT,kBAAkB;AAAA,QAClB,aAAa;AAAA,QACb,oBAAkB,OAAE,2BAAF,mBAA0B,UAAS;AAAA,QACrD,YAAY;AAAA,MAAA;AAAA,IAChB;AAAA,EAER;AACJ;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const ext = {
|
|
2
|
+
id: "KHR_materials_dielectric",
|
|
3
|
+
async applyMaterial(mat, ctx) {
|
|
4
|
+
var _a;
|
|
5
|
+
const exts = (_a = mat._rawMatDef) == null ? void 0 : _a.extensions;
|
|
6
|
+
if (!exts) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const eIor = exts.KHR_materials_ior;
|
|
10
|
+
const eSp = exts.KHR_materials_specular;
|
|
11
|
+
const eVol = exts.KHR_materials_volume;
|
|
12
|
+
const eTx = exts.KHR_materials_transmission;
|
|
13
|
+
const eDisp = exts.KHR_materials_dispersion;
|
|
14
|
+
if (!eIor && !eSp && !eVol && !eTx && !eDisp) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const [specTex, specColTex, thickTex, transTex] = await Promise.all([
|
|
18
|
+
ctx._texture(eSp == null ? void 0 : eSp.specularTexture, false),
|
|
19
|
+
ctx._texture(eSp == null ? void 0 : eSp.specularColorTexture, true),
|
|
20
|
+
ctx._texture(eVol == null ? void 0 : eVol.thicknessTexture, false),
|
|
21
|
+
ctx._texture(eTx == null ? void 0 : eTx.transmissionTexture, false)
|
|
22
|
+
]);
|
|
23
|
+
const out = {};
|
|
24
|
+
const subsurface = {};
|
|
25
|
+
if (eIor) {
|
|
26
|
+
const ior = typeof eIor.ior === "number" ? eIor.ior : 1.5;
|
|
27
|
+
if (ior !== 1.5) {
|
|
28
|
+
out.metallicF0Factor = ((ior - 1) / (ior + 1)) ** 2 / 0.04;
|
|
29
|
+
out.specularWeight = 1;
|
|
30
|
+
out._hasReflExt = true;
|
|
31
|
+
}
|
|
32
|
+
subsurface.refraction = { indexOfRefraction: ior };
|
|
33
|
+
}
|
|
34
|
+
if (eSp) {
|
|
35
|
+
if (typeof eSp.specularFactor === "number") {
|
|
36
|
+
if (Math.abs(eSp.specularFactor - 1) > 1e-6) {
|
|
37
|
+
out.metallicF0Factor = eSp.specularFactor;
|
|
38
|
+
out.specularWeight = eSp.specularFactor;
|
|
39
|
+
out._hasReflExt = true;
|
|
40
|
+
} else {
|
|
41
|
+
delete out.metallicF0Factor;
|
|
42
|
+
delete out.specularWeight;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(eSp.specularColorFactor) && eSp.specularColorFactor.length === 3) {
|
|
46
|
+
if (eSp.specularColorFactor[0] !== 1 || eSp.specularColorFactor[1] !== 1 || eSp.specularColorFactor[2] !== 1) {
|
|
47
|
+
out.metallicReflectanceColor = [eSp.specularColorFactor[0], eSp.specularColorFactor[1], eSp.specularColorFactor[2]];
|
|
48
|
+
out._hasReflExt = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (specTex) {
|
|
52
|
+
out.metallicReflectanceTexture = specTex;
|
|
53
|
+
out.useOnlyMetallicFromMetallicReflectanceTexture = true;
|
|
54
|
+
}
|
|
55
|
+
if (specColTex) {
|
|
56
|
+
out.reflectanceTexture = specColTex;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (eVol) {
|
|
60
|
+
const thicknessFactor = typeof eVol.thicknessFactor === "number" ? eVol.thicknessFactor : 0;
|
|
61
|
+
if (thicknessFactor > 0 || thickTex) {
|
|
62
|
+
subsurface.thickness = {
|
|
63
|
+
min: 0,
|
|
64
|
+
max: thicknessFactor || 1,
|
|
65
|
+
useGlTFChannel: true,
|
|
66
|
+
...thickTex ? { texture: thickTex } : void 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const color = Array.isArray(eVol.attenuationColor) && eVol.attenuationColor.length === 3 ? eVol.attenuationColor : void 0;
|
|
70
|
+
const atDistance = typeof eVol.attenuationDistance === "number" ? eVol.attenuationDistance : void 0;
|
|
71
|
+
if (color || atDistance !== void 0) {
|
|
72
|
+
subsurface.tint = {
|
|
73
|
+
...color ? { color } : void 0,
|
|
74
|
+
...atDistance !== void 0 ? { atDistance } : void 0
|
|
75
|
+
};
|
|
76
|
+
} else if (subsurface.thickness) {
|
|
77
|
+
subsurface.tint = { color: [1, 1, 1], atDistance: 1 };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (eTx) {
|
|
81
|
+
const intensity = typeof eTx.transmissionFactor === "number" ? eTx.transmissionFactor : 0;
|
|
82
|
+
if (intensity > 0 || transTex) {
|
|
83
|
+
out.transmissive = true;
|
|
84
|
+
const refraction = {
|
|
85
|
+
...subsurface.refraction ?? {},
|
|
86
|
+
intensity,
|
|
87
|
+
useThicknessAsDepth: !!subsurface.thickness,
|
|
88
|
+
...transTex ? { texture: transTex } : void 0
|
|
89
|
+
};
|
|
90
|
+
subsurface.refraction = refraction;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (eDisp && typeof eDisp.dispersion === "number" && eDisp.dispersion > 0 && subsurface.refraction && subsurface.thickness) {
|
|
94
|
+
subsurface.refraction = { ...subsurface.refraction, dispersion: 20 / eDisp.dispersion };
|
|
95
|
+
}
|
|
96
|
+
if (Object.keys(subsurface).length > 0) {
|
|
97
|
+
out.subsurface = subsurface;
|
|
98
|
+
}
|
|
99
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
ext as default
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=gltf-ext-dielectric-qHzlnvdl.js.map
|