@babylonjs/lite 0.1.1 → 0.2.0
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/_mat4-storage-f64-Bvh5TymE.js +10 -0
- package/_mat4-storage-f64-Bvh5TymE.js.map +1 -0
- package/{alpha-test-fragment-CUiHCw7W.js → alpha-test-fragment-BCChpzaV.js} +2 -2
- package/{alpha-test-fragment-CUiHCw7W.js.map → alpha-test-fragment-BCChpzaV.js.map} +1 -1
- package/{background-dds-skybox-yHTqabU3.js → background-dds-skybox-ZjrSIxrT.js} +4 -4
- package/background-dds-skybox-ZjrSIxrT.js.map +1 -0
- package/{background-ground-DIw6D3qf.js → background-ground-B2Mie-MI.js} +3 -3
- package/background-ground-B2Mie-MI.js.map +1 -0
- package/{background-hdr-skybox-c4uuTmkP.js → background-hdr-skybox-DDRJYuT2.js} +3 -3
- package/background-hdr-skybox-DDRJYuT2.js.map +1 -0
- package/{background-solid-skybox-DPGBpPbm.js → background-solid-skybox-fjXlnWaD.js} +3 -3
- package/{background-solid-skybox-DPGBpPbm.js.map → background-solid-skybox-fjXlnWaD.js.map} +1 -1
- package/{billboard-renderable-D8mlVGCd.js → billboard-renderable-DKmlOgbM.js} +2 -2
- package/{billboard-renderable-D8mlVGCd.js.map → billboard-renderable-DKmlOgbM.js.map} +1 -1
- package/{clamp-block-BdII67hT.js → clamp-block-CxRBPlUq.js} +2 -2
- package/{clamp-block-BdII67hT.js.map → clamp-block-CxRBPlUq.js.map} +1 -1
- package/{clearcoat-fragment-LCiG98Rf.js → clearcoat-fragment-KbZAa0TA.js} +2 -2
- package/{clearcoat-fragment-LCiG98Rf.js.map → clearcoat-fragment-KbZAa0TA.js.map} +1 -1
- package/{create-skeleton-C9JdIJnb.js → create-skeleton-BBI5urcj.js} +2 -2
- package/{create-skeleton-C9JdIJnb.js.map → create-skeleton-BBI5urcj.js.map} +1 -1
- package/{cubemap-skybox-material-DvXMVc4k.js → cubemap-skybox-material-DvW81drX.js} +2 -2
- package/{cubemap-skybox-material-DvXMVc4k.js.map → cubemap-skybox-material-DvW81drX.js.map} +1 -1
- package/{curve-block-BlJpXVYv.js → curve-block-Dh_xdUj-.js} +2 -2
- package/{curve-block-BlJpXVYv.js.map → curve-block-Dh_xdUj-.js.map} +1 -1
- package/{emissive-fragment-BnNvbBCw.js → emissive-fragment-DD8cvHyx.js} +2 -2
- package/{emissive-fragment-BnNvbBCw.js.map → emissive-fragment-DD8cvHyx.js.map} +1 -1
- package/{esm-shadow-view-DGKdF1NI.js → esm-shadow-view-15S4JK6p.js} +2 -2
- package/{esm-shadow-view-DGKdF1NI.js.map → esm-shadow-view-15S4JK6p.js.map} +1 -1
- package/{esm-shadow-view-Dk9NFtLq.js → esm-shadow-view-DHVS9r7H.js} +2 -2
- package/{esm-shadow-view-Dk9NFtLq.js.map → esm-shadow-view-DHVS9r7H.js.map} +1 -1
- package/{esm-shadow-view-DN9HIaM4.js → esm-shadow-view-DYAc62Kl.js} +2 -2
- package/{esm-shadow-view-DN9HIaM4.js.map → esm-shadow-view-DYAc62Kl.js.map} +1 -1
- package/{gaussian-splatting-pipeline-sh-DgJl7l56.js → gaussian-splatting-pipeline-sh-BvkUhA9V.js} +2 -2
- package/{gaussian-splatting-pipeline-sh-DgJl7l56.js.map → gaussian-splatting-pipeline-sh-BvkUhA9V.js.map} +1 -1
- package/{gltf-animation-D7uyTyO3.js → gltf-animation-KnPzeOIY.js} +3 -3
- package/{gltf-animation-D7uyTyO3.js.map → gltf-animation-KnPzeOIY.js.map} +1 -1
- package/gltf-color-normalize-Qxl-9C48.js +29 -0
- package/gltf-color-normalize-Qxl-9C48.js.map +1 -0
- package/{gltf-ext-basisu-CPg5kPrx.js → gltf-ext-basisu-kmth3UWX.js} +7 -4
- package/gltf-ext-basisu-kmth3UWX.js.map +1 -0
- package/{gltf-ext-node-visibility-MafA9ot2.js → gltf-ext-node-visibility-BjRRd6si.js} +2 -2
- package/{gltf-ext-node-visibility-MafA9ot2.js.map → gltf-ext-node-visibility-BjRRd6si.js.map} +1 -1
- package/{gltf-ext-uv-transform-CE_-T1Tr.js → gltf-ext-uv-transform-MHmR-YyM.js} +2 -2
- package/{gltf-ext-uv-transform-CE_-T1Tr.js.map → gltf-ext-uv-transform-MHmR-YyM.js.map} +1 -1
- package/{gltf-feature-animation-pointer-BjpwOOqo.js → gltf-feature-animation-pointer-rFqLfbO_.js} +3 -3
- package/{gltf-feature-animation-pointer-BjpwOOqo.js.map → gltf-feature-animation-pointer-rFqLfbO_.js.map} +1 -1
- package/{gltf-feature-animations-CCizegp8.js → gltf-feature-animations-DikONdzi.js} +2 -2
- package/{gltf-feature-animations-CCizegp8.js.map → gltf-feature-animations-DikONdzi.js.map} +1 -1
- package/{gltf-feature-gpu-instancing-2e_CFQnl.js → gltf-feature-gpu-instancing-Cj1XjmM6.js} +5 -4
- package/gltf-feature-gpu-instancing-Cj1XjmM6.js.map +1 -0
- package/{gltf-feature-lights-punctual-DDDg4j0U.js → gltf-feature-lights-punctual-C-0SlGmD.js} +5 -5
- package/{gltf-feature-lights-punctual-DDDg4j0U.js.map → gltf-feature-lights-punctual-C-0SlGmD.js.map} +1 -1
- package/{gltf-feature-morph-CKCw6tkX.js → gltf-feature-morph-BAcY14XU.js} +3 -3
- package/{gltf-feature-morph-CKCw6tkX.js.map → gltf-feature-morph-BAcY14XU.js.map} +1 -1
- package/gltf-feature-registry-97sY_x5O.js +59 -0
- package/gltf-feature-registry-97sY_x5O.js.map +1 -0
- package/{gltf-feature-skeleton-D8hWLqi2.js → gltf-feature-skeleton-lVjkDfIU.js} +3 -3
- package/{gltf-feature-skeleton-D8hWLqi2.js.map → gltf-feature-skeleton-lVjkDfIU.js.map} +1 -1
- package/{gltf-feature-variants-Ds6v9byg.js → gltf-feature-variants-BphF4JmV.js} +2 -2
- package/{gltf-feature-variants-Ds6v9byg.js.map → gltf-feature-variants-BphF4JmV.js.map} +1 -1
- package/{gltf-interleave-DGnUlz28.js → gltf-interleave-C9eBqH_F.js} +2 -2
- package/{gltf-interleave-DGnUlz28.js.map → gltf-interleave-C9eBqH_F.js.map} +1 -1
- package/gltf-normals-b2h74380.js +37 -0
- package/gltf-normals-b2h74380.js.map +1 -0
- package/{gltf-pbr-builder-ext-BFOxOCnQ.js → gltf-pbr-builder-ext-DPC0zg_u.js} +2 -2
- package/{gltf-pbr-builder-ext-BFOxOCnQ.js.map → gltf-pbr-builder-ext-DPC0zg_u.js.map} +1 -1
- package/{gltf-variants-DFbr8EES.js → gltf-variants-CnBEZr0o.js} +4 -4
- package/{gltf-variants-DFbr8EES.js.map → gltf-variants-CnBEZr0o.js.map} +1 -1
- package/{gs-picking-pipeline-DzfMASL9.js → gs-picking-pipeline-Bx8LTav6.js} +2 -2
- package/{gs-picking-pipeline-DzfMASL9.js.map → gs-picking-pipeline-Bx8LTav6.js.map} +1 -1
- package/{index-C8HOR2sB.js → index-B7Qhw0xL.js} +3047 -1037
- package/index-B7Qhw0xL.js.map +1 -0
- package/index.d.ts +504 -17
- package/index.js +322 -304
- package/{input-block-DgAJBzN_.js → input-block-Coi_aZwl.js} +2 -2
- package/{input-block-DgAJBzN_.js.map → input-block-Coi_aZwl.js.map} +1 -1
- package/{iridescence-fragment-Gymp7or5.js → iridescence-fragment-DwZcCTdD.js} +2 -2
- package/{iridescence-fragment-Gymp7or5.js.map → iridescence-fragment-DwZcCTdD.js.map} +1 -1
- package/{light-block-B11ew7FA.js → light-block-Np_h5gPI.js} +2 -2
- package/{light-block-B11ew7FA.js.map → light-block-Np_h5gPI.js.map} +1 -1
- package/{loop-block-Bb23EOMb.js → loop-block-BFkLFYGm.js} +2 -2
- package/{loop-block-Bb23EOMb.js.map → loop-block-BFkLFYGm.js.map} +1 -1
- package/{mesh-features-BLENkYVt.js → mesh-features-BAJpbMog.js} +6 -3
- package/mesh-features-BAJpbMog.js.map +1 -0
- package/{morph-fragment-DOVo70gP.js → morph-fragment-DqH-w61u.js} +2 -2
- package/{morph-fragment-DOVo70gP.js.map → morph-fragment-DqH-w61u.js.map} +1 -1
- package/{multilight-wgsl-BGyiIOp3.js → multilight-wgsl-B9Mf9d-q.js} +4 -4
- package/{multilight-wgsl-BGyiIOp3.js.map → multilight-wgsl-B9Mf9d-q.js.map} +1 -1
- package/no-color-view-DsyLSL-W.js +8 -0
- package/no-color-view-DsyLSL-W.js.map +1 -0
- package/{node-registry-DwgC4yth.js → node-registry-Bd-AlrgC.js} +8 -8
- package/{node-registry-DwgC4yth.js.map → node-registry-Bd-AlrgC.js.map} +1 -1
- package/{node-registry-extra-compat-Dhrw8fDQ.js → node-registry-extra-compat-Ch7ApZHF.js} +2 -2
- package/{node-registry-extra-compat-Dhrw8fDQ.js.map → node-registry-extra-compat-Ch7ApZHF.js.map} +1 -1
- package/{node-registry-extra-math-CsAHvIZo.js → node-registry-extra-math-6ezzTkPj.js} +2 -2
- package/{node-registry-extra-math-CsAHvIZo.js.map → node-registry-extra-math-6ezzTkPj.js.map} +1 -1
- package/{node-renderable-DlLIdBmd.js → node-renderable-CS0CmsSp.js} +28 -11
- package/node-renderable-CS0CmsSp.js.map +1 -0
- package/{node-shadow-DKrcqmNg.js → node-shadow-CpnrdvtJ.js} +2 -2
- package/{node-shadow-DKrcqmNg.js.map → node-shadow-CpnrdvtJ.js.map} +1 -1
- package/{normal-map-fragment-DpsIXrJf.js → normal-map-fragment-DradEMl-.js} +3 -3
- package/{normal-map-fragment-DpsIXrJf.js.map → normal-map-fragment-DradEMl-.js.map} +1 -1
- package/pack-mat4-with-offset-BqB8Jqo7.js +37 -0
- package/pack-mat4-with-offset-BqB8Jqo7.js.map +1 -0
- package/package.json +3 -3
- package/{parse-camera-DM3oJJeT.js → parse-camera-CgV4bWc0.js} +2 -2
- package/{parse-camera-DM3oJJeT.js.map → parse-camera-CgV4bWc0.js.map} +1 -1
- package/pbr-fog-wgsl-BqdCid6r.js +8 -0
- package/pbr-fog-wgsl-BqdCid6r.js.map +1 -0
- package/{pbr-metallic-roughness-block-h_KAOZrW.js → pbr-metallic-roughness-block-BFwZj2Nw.js} +2 -2
- package/{pbr-metallic-roughness-block-h_KAOZrW.js.map → pbr-metallic-roughness-block-BFwZj2Nw.js.map} +1 -1
- package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js → pbr-metallic-roughness-block-full-5t0HT3xl.js} +2 -2
- package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js.map → pbr-metallic-roughness-block-full-5t0HT3xl.js.map} +1 -1
- package/{pbr-mr-helper-core-CIwm-T1G.js → pbr-mr-helper-core-R5tOZ8Ap.js} +2 -2
- package/{pbr-mr-helper-core-CIwm-T1G.js.map → pbr-mr-helper-core-R5tOZ8Ap.js.map} +1 -1
- package/{pbr-refraction-DGmMSa2v.js → pbr-refraction-Dd11HnaI.js} +2 -2
- package/{pbr-refraction-DGmMSa2v.js.map → pbr-refraction-Dd11HnaI.js.map} +1 -1
- package/{pbr-renderable-BJxUtPBb.js → pbr-renderable-BHAdF5Vw.js} +80 -38
- package/pbr-renderable-BHAdF5Vw.js.map +1 -0
- package/{pbr-shadow-fragment-LO9SlbJj.js → pbr-shadow-fragment-BxUrFJYZ.js} +6 -1
- package/pbr-shadow-fragment-BxUrFJYZ.js.map +1 -0
- package/{pbr-template-ext-8q7BcTDf.js → pbr-template-ext-CGgB2n2y.js} +3 -2
- package/{pbr-template-ext-8q7BcTDf.js.map → pbr-template-ext-CGgB2n2y.js.map} +1 -1
- package/{pbr-tracking-B3alzn91.js → pbr-tracking-D6i3yPb7.js} +2 -2
- package/{pbr-tracking-B3alzn91.js.map → pbr-tracking-D6i3yPb7.js.map} +1 -1
- package/pbr-transmission-ext-Dll8EYwE.js +190 -0
- package/pbr-transmission-ext-Dll8EYwE.js.map +1 -0
- package/{reflectance-fragment-BCrgPmrt.js → reflectance-fragment-ejMJ4O1o.js} +2 -2
- package/{reflectance-fragment-BCrgPmrt.js.map → reflectance-fragment-ejMJ4O1o.js.map} +1 -1
- package/{shader-renderable-D-6796KR.js → shader-renderable-BMf_vvO0.js} +41 -12
- package/shader-renderable-BMf_vvO0.js.map +1 -0
- package/shader-thin-instance-5_WUfi3m.js +150 -0
- package/shader-thin-instance-5_WUfi3m.js.map +1 -0
- package/shadow-fragment-core-DHN2G6FI.js.map +1 -1
- package/{sheen-fragment-Dze2f7XJ.js → sheen-fragment-CS6z29Fs.js} +2 -2
- package/{sheen-fragment-Dze2f7XJ.js.map → sheen-fragment-CS6z29Fs.js.map} +1 -1
- package/{singlelight-directional-wgsl-CmUDZxwz.js → singlelight-directional-wgsl-4MIgZMeC.js} +2 -2
- package/{singlelight-directional-wgsl-CmUDZxwz.js.map → singlelight-directional-wgsl-4MIgZMeC.js.map} +1 -1
- package/{singlelight-hemispheric-wgsl-t-83IP_s.js → singlelight-hemispheric-wgsl-CK-GUYWe.js} +2 -2
- package/{singlelight-hemispheric-wgsl-t-83IP_s.js.map → singlelight-hemispheric-wgsl-CK-GUYWe.js.map} +1 -1
- package/{singlelight-point-wgsl-CLzULIYV.js → singlelight-point-wgsl-CYtzqCbP.js} +2 -2
- package/{singlelight-point-wgsl-CLzULIYV.js.map → singlelight-point-wgsl-CYtzqCbP.js.map} +1 -1
- package/{singlelight-spot-wgsl-DEEUrfVM.js → singlelight-spot-wgsl-DVbaVufF.js} +2 -2
- package/{singlelight-spot-wgsl-DEEUrfVM.js.map → singlelight-spot-wgsl-DVbaVufF.js.map} +1 -1
- package/{skeleton-fragment-B_XlFbtx.js → skeleton-fragment-BOVmc8YS.js} +2 -2
- package/{skeleton-fragment-B_XlFbtx.js.map → skeleton-fragment-BOVmc8YS.js.map} +1 -1
- package/{skybox-renderable-DDwzu-PT.js → skybox-renderable-DDcCPSly.js} +3 -3
- package/{skybox-renderable-DDwzu-PT.js.map → skybox-renderable-DDcCPSly.js.map} +1 -1
- package/{standard-renderable-GjxL9xSf.js → standard-renderable-D1bhoF0K.js} +27 -81
- package/standard-renderable-D1bhoF0K.js.map +1 -0
- package/{std-ambient-fragment-BoUsD06w.js → std-ambient-fragment-C6WNm8dQ.js} +2 -2
- package/{std-ambient-fragment-BoUsD06w.js.map → std-ambient-fragment-C6WNm8dQ.js.map} +1 -1
- package/{std-cube-reflection-fragment-ulqc3bsP.js → std-cube-reflection-fragment-Bqutpy2q.js} +2 -2
- package/{std-cube-reflection-fragment-ulqc3bsP.js.map → std-cube-reflection-fragment-Bqutpy2q.js.map} +1 -1
- package/{std-emissive-fragment-DNGj1HdQ.js → std-emissive-fragment-B-A83rqX.js} +2 -2
- package/{std-emissive-fragment-DNGj1HdQ.js.map → std-emissive-fragment-B-A83rqX.js.map} +1 -1
- package/{std-lightmap-fragment-Bqj89aIe.js → std-lightmap-fragment-Df7KJezh.js} +2 -2
- package/{std-lightmap-fragment-Bqj89aIe.js.map → std-lightmap-fragment-Df7KJezh.js.map} +1 -1
- package/{std-opacity-fragment-KuPh5N2Z.js → std-opacity-fragment-D9et2jip.js} +2 -2
- package/{std-opacity-fragment-KuPh5N2Z.js.map → std-opacity-fragment-D9et2jip.js.map} +1 -1
- package/{std-reflection-fragment-BA5Ghn_M.js → std-reflection-fragment-DBJeT-yg.js} +2 -2
- package/{std-reflection-fragment-BA5Ghn_M.js.map → std-reflection-fragment-DBJeT-yg.js.map} +1 -1
- package/std-shadow-fragment-C6fD8rW-.js +13 -0
- package/std-shadow-fragment-C6fD8rW-.js.map +1 -0
- package/{std-specular-fragment-CE-6scqd.js → std-specular-fragment-C2ZOss-t.js} +2 -2
- package/{std-specular-fragment-CE-6scqd.js.map → std-specular-fragment-C2ZOss-t.js.map} +1 -1
- package/{std-tracking-CNKZ-hJN.js → std-tracking-C4L4nQGc.js} +2 -2
- package/{std-tracking-CNKZ-hJN.js.map → std-tracking-C4L4nQGc.js.map} +1 -1
- package/{subsurface-fragment-liM3y2-P.js → subsurface-fragment-C1H4ytqK.js} +2 -2
- package/{subsurface-fragment-liM3y2-P.js.map → subsurface-fragment-C1H4ytqK.js.map} +1 -1
- package/thin-instance-cull-binding-CCxrPNO6.js +310 -0
- package/thin-instance-cull-binding-CCxrPNO6.js.map +1 -0
- package/{thin-instance-gpu-C9Gv_Z1w.js → thin-instance-gpu-E8DBd8XL.js} +20 -3
- package/thin-instance-gpu-E8DBd8XL.js.map +1 -0
- package/{tracking-primitives-wgdBY85t.js → tracking-primitives-w4BVV9p9.js} +2 -2
- package/{tracking-primitives-wgdBY85t.js.map → tracking-primitives-w4BVV9p9.js.map} +1 -1
- package/{unlit-fragment-BIlhJpz6.js → unlit-fragment-DU9_mhzZ.js} +2 -2
- package/{unlit-fragment-BIlhJpz6.js.map → unlit-fragment-DU9_mhzZ.js.map} +1 -1
- package/{wgsl-helpers-DyzNzCeE.js → wgsl-helpers-D8sl1VVA.js} +4 -4
- package/{wgsl-helpers-DyzNzCeE.js.map → wgsl-helpers-D8sl1VVA.js.map} +1 -1
- package/background-dds-skybox-yHTqabU3.js.map +0 -1
- package/background-ground-DIw6D3qf.js.map +0 -1
- package/background-hdr-skybox-c4uuTmkP.js.map +0 -1
- package/gltf-ext-basisu-CPg5kPrx.js.map +0 -1
- package/gltf-feature-gpu-instancing-2e_CFQnl.js.map +0 -1
- package/index-C8HOR2sB.js.map +0 -1
- package/mesh-features-BLENkYVt.js.map +0 -1
- package/node-renderable-DlLIdBmd.js.map +0 -1
- package/pbr-renderable-BJxUtPBb.js.map +0 -1
- package/pbr-shadow-fragment-LO9SlbJj.js.map +0 -1
- package/pbr-transmission-ext-BxW4CEGu.js +0 -581
- package/pbr-transmission-ext-BxW4CEGu.js.map +0 -1
- package/shader-renderable-D-6796KR.js.map +0 -1
- package/standard-renderable-GjxL9xSf.js.map +0 -1
- package/std-shadow-fragment-FNQfrJuC.js +0 -8
- package/std-shadow-fragment-FNQfrJuC.js.map +0 -1
- package/thin-instance-gpu-C9Gv_Z1w.js.map +0 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
function _defaultAllocate() {
|
|
5
|
+
return new Float32Array(16);
|
|
6
|
+
}
|
|
7
|
+
let _allocate;
|
|
8
|
+
function allocateMat4() {
|
|
9
|
+
return (_allocate ?? _defaultAllocate)();
|
|
10
|
+
}
|
|
11
|
+
function _setHpmAllocator(allocate) {
|
|
12
|
+
_allocate = allocate;
|
|
13
|
+
}
|
|
4
14
|
const VERSION = "0.1.0";
|
|
5
15
|
let _vis = 0;
|
|
6
16
|
function bumpVisibilityEpoch() {
|
|
@@ -56,6 +66,25 @@ async function createEngine(canvas, options) {
|
|
|
56
66
|
canvas.setAttribute("data-engine", versionToLog);
|
|
57
67
|
}
|
|
58
68
|
const msaaSamples = (options == null ? void 0 : options.msaaSamples) === 1 ? 1 : 4;
|
|
69
|
+
const useHpm = (options == null ? void 0 : options.useHighPrecisionMatrix) === true;
|
|
70
|
+
const useFO = (options == null ? void 0 : options.useFloatingOrigin) === true;
|
|
71
|
+
if (useFO && !useHpm) {
|
|
72
|
+
throw new Error("Babylon Lite: useFloatingOrigin requires useHighPrecisionMatrix on the engine.");
|
|
73
|
+
}
|
|
74
|
+
if (useHpm) {
|
|
75
|
+
const { allocateF64Mat4 } = await import("./_mat4-storage-f64-Bvh5TymE.js");
|
|
76
|
+
_setHpmAllocator(allocateF64Mat4);
|
|
77
|
+
}
|
|
78
|
+
let _wrapRenderableForFO;
|
|
79
|
+
let _makePackMeshWorld;
|
|
80
|
+
if (useFO) {
|
|
81
|
+
const [{ wrapRenderableForFO: wrapRenderableForFO2 }, { makePackMeshWorld }] = await Promise.all([
|
|
82
|
+
Promise.resolve().then(() => floatingOrigin),
|
|
83
|
+
import("./pack-mat4-with-offset-BqB8Jqo7.js")
|
|
84
|
+
]);
|
|
85
|
+
_wrapRenderableForFO = wrapRenderableForFO2;
|
|
86
|
+
_makePackMeshWorld = makePackMeshWorld;
|
|
87
|
+
}
|
|
59
88
|
const engine = {
|
|
60
89
|
_device: device,
|
|
61
90
|
_context: context,
|
|
@@ -64,6 +93,8 @@ async function createEngine(canvas, options) {
|
|
|
64
93
|
canvas,
|
|
65
94
|
msaaSamples,
|
|
66
95
|
drawCallCount: 0,
|
|
96
|
+
useHighPrecisionMatrix: useHpm,
|
|
97
|
+
useFloatingOrigin: useFO,
|
|
67
98
|
maxDevicePixelRatio: (options == null ? void 0 : options.maxDevicePixelRatio) ?? Infinity,
|
|
68
99
|
_animFrameId: 0,
|
|
69
100
|
_renderFn: null,
|
|
@@ -71,7 +102,9 @@ async function createEngine(canvas, options) {
|
|
|
71
102
|
_currentEncoder: void 0,
|
|
72
103
|
_swapchainView: void 0,
|
|
73
104
|
_currentDelta: 0,
|
|
74
|
-
_cbs: []
|
|
105
|
+
_cbs: [],
|
|
106
|
+
_wrapRenderableForFO,
|
|
107
|
+
_makePackMeshWorld
|
|
75
108
|
};
|
|
76
109
|
resizeEngine(engine);
|
|
77
110
|
return engine;
|
|
@@ -287,7 +320,9 @@ function disposeRenderTarget(rt) {
|
|
|
287
320
|
rt._colorView = null;
|
|
288
321
|
}
|
|
289
322
|
if (rt._depthTexture) {
|
|
290
|
-
rt.
|
|
323
|
+
if (rt._ownsDepthTexture !== false) {
|
|
324
|
+
rt._depthTexture.destroy();
|
|
325
|
+
}
|
|
291
326
|
rt._depthTexture = null;
|
|
292
327
|
rt._depthView = null;
|
|
293
328
|
}
|
|
@@ -346,14 +381,15 @@ function mat4PerspectiveLHToRef(out, fov, aspect, near, far) {
|
|
|
346
381
|
}
|
|
347
382
|
function getViewMatrix(camera) {
|
|
348
383
|
const ver = camera.worldMatrixVersion;
|
|
349
|
-
if (camera._viewVer === ver
|
|
384
|
+
if (camera._viewVer === ver) {
|
|
350
385
|
return camera._viewCache;
|
|
351
386
|
}
|
|
352
|
-
if (!camera._viewCache) {
|
|
353
|
-
camera._viewCache = new Float32Array(16);
|
|
354
|
-
}
|
|
355
387
|
const v = camera._viewCache;
|
|
356
388
|
const w = camera.worldMatrix;
|
|
389
|
+
const useFO = camera._useFloatingOrigin;
|
|
390
|
+
const cx = useFO ? 0 : w[12];
|
|
391
|
+
const cy = useFO ? 0 : w[13];
|
|
392
|
+
const cz = useFO ? 0 : w[14];
|
|
357
393
|
v[0] = w[0];
|
|
358
394
|
v[1] = w[4];
|
|
359
395
|
v[2] = w[8];
|
|
@@ -366,38 +402,34 @@ function getViewMatrix(camera) {
|
|
|
366
402
|
v[9] = w[6];
|
|
367
403
|
v[10] = w[10];
|
|
368
404
|
v[11] = 0;
|
|
369
|
-
v[12] = -(w[0] *
|
|
370
|
-
v[13] = -(w[4] *
|
|
371
|
-
v[14] = -(w[8] *
|
|
405
|
+
v[12] = -(w[0] * cx + w[1] * cy + w[2] * cz);
|
|
406
|
+
v[13] = -(w[4] * cx + w[5] * cy + w[6] * cz);
|
|
407
|
+
v[14] = -(w[8] * cx + w[9] * cy + w[10] * cz);
|
|
372
408
|
v[15] = 1;
|
|
373
409
|
camera._viewVer = ver;
|
|
374
410
|
return v;
|
|
375
411
|
}
|
|
376
412
|
function getProjectionMatrix(camera, aspectRatio) {
|
|
377
413
|
const ver = camera.worldMatrixVersion;
|
|
378
|
-
if (camera._projVer === ver && camera._projAspect === aspectRatio
|
|
414
|
+
if (camera._projVer === ver && camera._projAspect === aspectRatio) {
|
|
379
415
|
return camera._projCache;
|
|
380
416
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
mat4PerspectiveLHToRef(camera._projCache, camera.fov, aspectRatio, camera.nearPlane, camera.farPlane);
|
|
417
|
+
const p = camera._projCache;
|
|
418
|
+
mat4PerspectiveLHToRef(p, camera.fov, aspectRatio, camera.nearPlane, camera.farPlane);
|
|
385
419
|
camera._projVer = ver;
|
|
386
420
|
camera._projAspect = aspectRatio;
|
|
387
|
-
return
|
|
421
|
+
return p;
|
|
388
422
|
}
|
|
389
423
|
function getViewProjectionMatrix(camera, aspectRatio) {
|
|
390
424
|
const ver = camera.worldMatrixVersion;
|
|
391
|
-
if (camera._vpVer === ver && camera._vpAspect === aspectRatio
|
|
425
|
+
if (camera._vpVer === ver && camera._vpAspect === aspectRatio) {
|
|
392
426
|
return camera._vpCache;
|
|
393
427
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
mat4MultiplyInto(camera._vpCache, 0, getProjectionMatrix(camera, aspectRatio), 0, getViewMatrix(camera), 0);
|
|
428
|
+
const vp = camera._vpCache;
|
|
429
|
+
mat4MultiplyInto(vp, 0, getProjectionMatrix(camera, aspectRatio), 0, getViewMatrix(camera), 0);
|
|
398
430
|
camera._vpVer = ver;
|
|
399
431
|
camera._vpAspect = aspectRatio;
|
|
400
|
-
return
|
|
432
|
+
return vp;
|
|
401
433
|
}
|
|
402
434
|
function getCameraPosition(camera) {
|
|
403
435
|
const w = camera.worldMatrix;
|
|
@@ -444,6 +476,31 @@ function createDefaultPipelineDescriptor(opts) {
|
|
|
444
476
|
primitive: { topology: "triangle-list", cullMode: opts._cullMode ?? "back", frontFace: opts._flipY ? "cw" : "ccw" }
|
|
445
477
|
};
|
|
446
478
|
}
|
|
479
|
+
function packMat4IntoF32(view, mat, offsetFloats = 0, srcOffsetFloats = 0) {
|
|
480
|
+
const src = mat;
|
|
481
|
+
if (srcOffsetFloats === 0 && src.length === 16) {
|
|
482
|
+
view.set(src, offsetFloats);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const s = srcOffsetFloats;
|
|
486
|
+
const o = offsetFloats;
|
|
487
|
+
view[o + 0] = src[s + 0];
|
|
488
|
+
view[o + 1] = src[s + 1];
|
|
489
|
+
view[o + 2] = src[s + 2];
|
|
490
|
+
view[o + 3] = src[s + 3];
|
|
491
|
+
view[o + 4] = src[s + 4];
|
|
492
|
+
view[o + 5] = src[s + 5];
|
|
493
|
+
view[o + 6] = src[s + 6];
|
|
494
|
+
view[o + 7] = src[s + 7];
|
|
495
|
+
view[o + 8] = src[s + 8];
|
|
496
|
+
view[o + 9] = src[s + 9];
|
|
497
|
+
view[o + 10] = src[s + 10];
|
|
498
|
+
view[o + 11] = src[s + 11];
|
|
499
|
+
view[o + 12] = src[s + 12];
|
|
500
|
+
view[o + 13] = src[s + 13];
|
|
501
|
+
view[o + 14] = src[s + 14];
|
|
502
|
+
view[o + 15] = src[s + 15];
|
|
503
|
+
}
|
|
447
504
|
function align(n, to) {
|
|
448
505
|
return n + to - 1 & ~(to - 1);
|
|
449
506
|
}
|
|
@@ -688,6 +745,9 @@ function createRenderTask(config, engine, scene) {
|
|
|
688
745
|
return task;
|
|
689
746
|
}
|
|
690
747
|
function removeMeshFromTask(task, mesh) {
|
|
748
|
+
if (!task._renderables) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
691
751
|
let removed = false;
|
|
692
752
|
for (let i = task._renderables.length - 1; i >= 0; i--) {
|
|
693
753
|
if (task._renderables[i].mesh === mesh) {
|
|
@@ -855,7 +915,7 @@ function executePassBody(task, pass) {
|
|
|
855
915
|
sampleCount: desc.sampleCount ?? 1
|
|
856
916
|
});
|
|
857
917
|
be.setBindGroup(0, sceneBG);
|
|
858
|
-
drawList(be, opaqueBindings, eng);
|
|
918
|
+
drawList$1(be, opaqueBindings, eng);
|
|
859
919
|
opaqueBundles[0] = be.finish();
|
|
860
920
|
task._lastVersion = scene._renderableVersion;
|
|
861
921
|
task._lastVis = _vis;
|
|
@@ -863,8 +923,8 @@ function executePassBody(task, pass) {
|
|
|
863
923
|
let draws = opaqueBindings.length;
|
|
864
924
|
pass.executeBundles(opaqueBundles);
|
|
865
925
|
pass.setBindGroup(0, sceneBG);
|
|
866
|
-
draws += drawList(pass, task._directBindings, eng);
|
|
867
|
-
draws += drawList(pass, task._transparentBindings, eng);
|
|
926
|
+
draws += drawList$1(pass, task._directBindings, eng);
|
|
927
|
+
draws += drawList$1(pass, task._transparentBindings, eng);
|
|
868
928
|
return draws;
|
|
869
929
|
}
|
|
870
930
|
function refreshTaskSceneBindGroup(task, eng) {
|
|
@@ -911,41 +971,35 @@ function writePassSceneUBO(task, eng, scene, camera, flipY) {
|
|
|
911
971
|
const viewProj = getViewProjectionMatrix(camera, aspect);
|
|
912
972
|
const viewMat = getViewMatrix(camera);
|
|
913
973
|
const wm = camera.worldMatrix;
|
|
914
|
-
data
|
|
974
|
+
packMat4IntoF32(data, viewProj, 0);
|
|
915
975
|
if (flipY) {
|
|
916
976
|
data[1] = -data[1];
|
|
917
977
|
data[5] = -data[5];
|
|
918
978
|
data[9] = -data[9];
|
|
919
979
|
data[13] = -data[13];
|
|
920
980
|
}
|
|
921
|
-
data
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
data[
|
|
928
|
-
data[
|
|
929
|
-
data[
|
|
930
|
-
data[84] = fog.color[0];
|
|
931
|
-
data[85] = fog.color[1];
|
|
932
|
-
data[86] = fog.color[2];
|
|
981
|
+
packMat4IntoF32(data, viewMat, 16);
|
|
982
|
+
if (eng.useFloatingOrigin) {
|
|
983
|
+
data[32] = 0;
|
|
984
|
+
data[33] = 0;
|
|
985
|
+
data[34] = 0;
|
|
986
|
+
} else {
|
|
987
|
+
data[32] = wm[12];
|
|
988
|
+
data[33] = wm[13];
|
|
989
|
+
data[34] = wm[14];
|
|
933
990
|
}
|
|
934
991
|
data[87] = eng.canvas.width;
|
|
935
992
|
data[36] = envRotationY;
|
|
936
|
-
if (envTextures == null ? void 0 : envTextures.sphericalHarmonics) {
|
|
937
|
-
data.set(envTextures.sphericalHarmonics, 40);
|
|
938
|
-
}
|
|
939
993
|
data[76] = img.exposure;
|
|
940
994
|
data[77] = img.contrast;
|
|
941
995
|
data[78] = (envTextures == null ? void 0 : envTextures.lodGenerationScale) ?? 0.8;
|
|
942
996
|
data[79] = +img.toneMappingEnabled;
|
|
943
997
|
data[37] = eng.canvas.height;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
998
|
+
const contribs = scene._sceneUboContributors;
|
|
999
|
+
if (contribs) {
|
|
1000
|
+
for (const c of contribs) {
|
|
1001
|
+
c(data, scene);
|
|
1002
|
+
}
|
|
949
1003
|
}
|
|
950
1004
|
eng._device.queue.writeBuffer(task._sceneUBO, 0, data);
|
|
951
1005
|
}
|
|
@@ -955,7 +1009,7 @@ function updateBindings(list, context) {
|
|
|
955
1009
|
(_a = b.update) == null ? void 0 : _a.call(b, context);
|
|
956
1010
|
}
|
|
957
1011
|
}
|
|
958
|
-
function drawList(enc, list, engine) {
|
|
1012
|
+
function drawList$1(enc, list, engine) {
|
|
959
1013
|
let lp = null;
|
|
960
1014
|
let draws = 0;
|
|
961
1015
|
for (const b of list) {
|
|
@@ -1029,6 +1083,11 @@ function createSceneContext(engine, options) {
|
|
|
1029
1083
|
_drawCallsPre: 0,
|
|
1030
1084
|
_update() {
|
|
1031
1085
|
var _a;
|
|
1086
|
+
if (eng.useFloatingOrigin && ctx.camera && !ctx.camera._useFloatingOrigin) {
|
|
1087
|
+
ctx.camera._useFloatingOrigin = true;
|
|
1088
|
+
ctx.camera._viewVer = -1;
|
|
1089
|
+
ctx.camera._vpVer = -1;
|
|
1090
|
+
}
|
|
1032
1091
|
const d = ctx.fixedDeltaMs > 0 ? ctx.fixedDeltaMs : eng._currentDelta;
|
|
1033
1092
|
const encoder = eng._currentEncoder;
|
|
1034
1093
|
let draws = 0;
|
|
@@ -1101,7 +1160,7 @@ function addDeferredSceneRenderables(scene, build) {
|
|
|
1101
1160
|
});
|
|
1102
1161
|
}
|
|
1103
1162
|
function addToScene(scene, entity) {
|
|
1104
|
-
var _a
|
|
1163
|
+
var _a;
|
|
1105
1164
|
const ctx = scene;
|
|
1106
1165
|
if ("entities" in entity) {
|
|
1107
1166
|
const result = entity;
|
|
@@ -1132,7 +1191,7 @@ function addToScene(scene, entity) {
|
|
|
1132
1191
|
const mesh = entity;
|
|
1133
1192
|
ctx.meshes.push(mesh);
|
|
1134
1193
|
installMaterialSetter(ctx, mesh);
|
|
1135
|
-
const build =
|
|
1194
|
+
const build = mesh.material ? mesh.material._buildGroup : void 0;
|
|
1136
1195
|
if (build) {
|
|
1137
1196
|
let group = ctx._groups.get(build);
|
|
1138
1197
|
if (!group) {
|
|
@@ -1319,7 +1378,7 @@ function createWorldMatrixState(getLocalMatrix) {
|
|
|
1319
1378
|
let _worldVersion = 0;
|
|
1320
1379
|
let _lastSeenParentVersion = -1;
|
|
1321
1380
|
let _cachedWorld = null;
|
|
1322
|
-
const _ownedWorld =
|
|
1381
|
+
const _ownedWorld = allocateMat4();
|
|
1323
1382
|
let _parent = null;
|
|
1324
1383
|
let _parentState = null;
|
|
1325
1384
|
const _children = [];
|
|
@@ -1467,10 +1526,28 @@ function createArcRotateCamera(alpha, beta, radius, target) {
|
|
|
1467
1526
|
z: cam.target.z + cam.radius * sinA * sinB
|
|
1468
1527
|
};
|
|
1469
1528
|
}
|
|
1529
|
+
const _localMat = allocateMat4();
|
|
1470
1530
|
function cameraLocalWorldMatrix() {
|
|
1471
1531
|
const eye = localEyePosition();
|
|
1472
1532
|
const v = mat4LookAtLH(eye, cam.target, Vec3Up);
|
|
1473
|
-
|
|
1533
|
+
const m = _localMat;
|
|
1534
|
+
m[0] = v[0];
|
|
1535
|
+
m[1] = v[4];
|
|
1536
|
+
m[2] = v[8];
|
|
1537
|
+
m[3] = 0;
|
|
1538
|
+
m[4] = v[1];
|
|
1539
|
+
m[5] = v[5];
|
|
1540
|
+
m[6] = v[9];
|
|
1541
|
+
m[7] = 0;
|
|
1542
|
+
m[8] = v[2];
|
|
1543
|
+
m[9] = v[6];
|
|
1544
|
+
m[10] = v[10];
|
|
1545
|
+
m[11] = 0;
|
|
1546
|
+
m[12] = eye.x;
|
|
1547
|
+
m[13] = eye.y;
|
|
1548
|
+
m[14] = eye.z;
|
|
1549
|
+
m[15] = 1;
|
|
1550
|
+
return _localMat;
|
|
1474
1551
|
}
|
|
1475
1552
|
const wm = createWorldMatrixState(cameraLocalWorldMatrix);
|
|
1476
1553
|
const onDirty = () => wm.markLocalDirty();
|
|
@@ -1492,6 +1569,12 @@ function createArcRotateCamera(alpha, beta, radius, target) {
|
|
|
1492
1569
|
inertialRadiusOffset: 0,
|
|
1493
1570
|
inertialPanningX: 0,
|
|
1494
1571
|
inertialPanningY: 0,
|
|
1572
|
+
// Matrix caches use the process-global allocator — F32 by default,
|
|
1573
|
+
// F64 after an HPM engine is created. Same backing as the camera world
|
|
1574
|
+
// matrix above, so the camera's storage precision is uniform.
|
|
1575
|
+
_viewCache: allocateMat4(),
|
|
1576
|
+
_projCache: allocateMat4(),
|
|
1577
|
+
_vpCache: allocateMat4(),
|
|
1495
1578
|
get parent() {
|
|
1496
1579
|
return wm.parent;
|
|
1497
1580
|
},
|
|
@@ -1509,9 +1592,11 @@ function createArcRotateCamera(alpha, beta, radius, target) {
|
|
|
1509
1592
|
Object.defineProperty(cam, key, {
|
|
1510
1593
|
get: () => scalars[key],
|
|
1511
1594
|
set: (v) => {
|
|
1595
|
+
var _a;
|
|
1512
1596
|
if (scalars[key] !== v) {
|
|
1513
1597
|
scalars[key] = v;
|
|
1514
1598
|
onDirty();
|
|
1599
|
+
(_a = cam._clampToLimits) == null ? void 0 : _a.call(cam);
|
|
1515
1600
|
}
|
|
1516
1601
|
},
|
|
1517
1602
|
configurable: true,
|
|
@@ -1608,7 +1693,7 @@ function removeFromScene(scene, mesh) {
|
|
|
1608
1693
|
mesh._materialDirty = false;
|
|
1609
1694
|
mesh.parent = null;
|
|
1610
1695
|
for (const task of scene._frameGraph._tasks) {
|
|
1611
|
-
if ("
|
|
1696
|
+
if ("_renderables" in task) {
|
|
1612
1697
|
removeMeshFromTask(task, mesh);
|
|
1613
1698
|
}
|
|
1614
1699
|
}
|
|
@@ -1625,6 +1710,75 @@ function cascade(node, v) {
|
|
|
1625
1710
|
cascade(kids[i], v);
|
|
1626
1711
|
}
|
|
1627
1712
|
}
|
|
1713
|
+
function writeFogUbo(data, scene) {
|
|
1714
|
+
const fog = scene.fog;
|
|
1715
|
+
if (fog) {
|
|
1716
|
+
data[80] = fog.mode;
|
|
1717
|
+
data[81] = fog.start;
|
|
1718
|
+
data[82] = fog.end;
|
|
1719
|
+
data[83] = fog.density;
|
|
1720
|
+
data[84] = fog.color[0];
|
|
1721
|
+
data[85] = fog.color[1];
|
|
1722
|
+
data[86] = fog.color[2];
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
function writeClipPlaneUbo(data, scene) {
|
|
1726
|
+
const clipPlane = scene.clipPlane;
|
|
1727
|
+
if (clipPlane) {
|
|
1728
|
+
data[88] = clipPlane[0];
|
|
1729
|
+
data[89] = clipPlane[1];
|
|
1730
|
+
data[90] = clipPlane[2];
|
|
1731
|
+
data[91] = clipPlane[3];
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
function writeEnvShUbo(data, scene) {
|
|
1735
|
+
var _a;
|
|
1736
|
+
const sh = (_a = scene._envTextures) == null ? void 0 : _a.sphericalHarmonics;
|
|
1737
|
+
if (sh) {
|
|
1738
|
+
data.set(sh, 40);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
function registerContributor(scene, contributor) {
|
|
1742
|
+
const list = scene._sceneUboContributors ?? (scene._sceneUboContributors = []);
|
|
1743
|
+
if (!list.includes(contributor)) {
|
|
1744
|
+
list.push(contributor);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
function setFog(scene, config) {
|
|
1748
|
+
scene.fog = config;
|
|
1749
|
+
registerContributor(scene, writeFogUbo);
|
|
1750
|
+
}
|
|
1751
|
+
function setClipPlane(scene, plane) {
|
|
1752
|
+
scene.clipPlane = plane;
|
|
1753
|
+
registerContributor(scene, writeClipPlaneUbo);
|
|
1754
|
+
}
|
|
1755
|
+
function registerEnvSceneUniforms(scene) {
|
|
1756
|
+
registerContributor(scene, writeEnvShUbo);
|
|
1757
|
+
}
|
|
1758
|
+
function getFloatingOriginOffset(scene) {
|
|
1759
|
+
const cam = scene.camera;
|
|
1760
|
+
if (!cam) {
|
|
1761
|
+
return { x: 0, y: 0, z: 0 };
|
|
1762
|
+
}
|
|
1763
|
+
const w = cam.worldMatrix;
|
|
1764
|
+
return { x: w[12], y: w[13], z: w[14] };
|
|
1765
|
+
}
|
|
1766
|
+
function wrapRenderableForFO(inner, scene, invalidate) {
|
|
1767
|
+
let _lastCameraVersion = -1;
|
|
1768
|
+
return () => {
|
|
1769
|
+
const cv = scene.camera ? scene.camera.worldMatrixVersion : -1;
|
|
1770
|
+
if (cv !== _lastCameraVersion) {
|
|
1771
|
+
invalidate();
|
|
1772
|
+
_lastCameraVersion = cv;
|
|
1773
|
+
}
|
|
1774
|
+
inner();
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
const floatingOrigin = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1778
|
+
__proto__: null,
|
|
1779
|
+
getFloatingOriginOffset,
|
|
1780
|
+
wrapRenderableForFO
|
|
1781
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1628
1782
|
function addPassDependencies(pass, deps) {
|
|
1629
1783
|
if (Array.isArray(deps)) {
|
|
1630
1784
|
for (const dep of deps) {
|
|
@@ -2118,115 +2272,616 @@ function createRenderTargetTexture(engine, descriptor) {
|
|
|
2118
2272
|
};
|
|
2119
2273
|
return { rt, texture };
|
|
2120
2274
|
}
|
|
2121
|
-
const
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
_bindGroup: null,
|
|
2133
|
-
_bindGroupDirty: true,
|
|
2134
|
-
_pipelines: null,
|
|
2135
|
-
_uniforms: [],
|
|
2136
|
-
_textures: []
|
|
2137
|
-
};
|
|
2138
|
-
createBindingSlots(wrapper);
|
|
2139
|
-
return wrapper;
|
|
2275
|
+
const _trilinearAnisotropicDesc = {
|
|
2276
|
+
magFilter: "linear",
|
|
2277
|
+
minFilter: "linear",
|
|
2278
|
+
mipmapFilter: "linear",
|
|
2279
|
+
addressModeU: "repeat",
|
|
2280
|
+
addressModeV: "repeat",
|
|
2281
|
+
addressModeW: "repeat",
|
|
2282
|
+
maxAnisotropy: 4
|
|
2283
|
+
};
|
|
2284
|
+
function getTrilinearAnisotropicSampler(engine) {
|
|
2285
|
+
return getOrCreateSampler(engine, _trilinearAnisotropicDesc);
|
|
2140
2286
|
}
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2287
|
+
const BLIT_SHADER$1 = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;
|
|
2288
|
+
struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};
|
|
2289
|
+
@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1),p*vec2f(.5,-.5)+.5);}
|
|
2290
|
+
@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;
|
|
2291
|
+
let pipelineCache = null;
|
|
2292
|
+
let shaderModule = null;
|
|
2293
|
+
let linearSampler = null;
|
|
2294
|
+
let bindGroupLayout = null;
|
|
2295
|
+
let cachedDevice = null;
|
|
2296
|
+
function clearCache() {
|
|
2297
|
+
pipelineCache == null ? void 0 : pipelineCache.clear();
|
|
2298
|
+
pipelineCache = null;
|
|
2299
|
+
shaderModule = null;
|
|
2300
|
+
linearSampler = null;
|
|
2301
|
+
bindGroupLayout = null;
|
|
2302
|
+
cachedDevice = null;
|
|
2303
|
+
}
|
|
2304
|
+
function ensureResources(engine) {
|
|
2305
|
+
const device = engine._device;
|
|
2306
|
+
if (device !== cachedDevice) {
|
|
2307
|
+
clearCache();
|
|
2308
|
+
cachedDevice = device;
|
|
2309
|
+
}
|
|
2310
|
+
shaderModule ?? (shaderModule = device.createShaderModule({ code: BLIT_SHADER$1 }));
|
|
2311
|
+
linearSampler ?? (linearSampler = getBilinearSampler(engine));
|
|
2312
|
+
bindGroupLayout ?? (bindGroupLayout = device.createBindGroupLayout({
|
|
2313
|
+
entries: [
|
|
2314
|
+
{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "float" } },
|
|
2315
|
+
{ binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} }
|
|
2316
|
+
]
|
|
2317
|
+
}));
|
|
2318
|
+
}
|
|
2319
|
+
function getPipeline(engine, format) {
|
|
2320
|
+
const device = engine._device;
|
|
2321
|
+
ensureResources(engine);
|
|
2322
|
+
pipelineCache ?? (pipelineCache = /* @__PURE__ */ new Map());
|
|
2323
|
+
let pipeline = pipelineCache.get(format);
|
|
2324
|
+
if (!pipeline) {
|
|
2325
|
+
pipeline = device.createRenderPipeline({
|
|
2326
|
+
layout: device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] }),
|
|
2327
|
+
vertex: { module: shaderModule, entryPoint: "vs" },
|
|
2328
|
+
fragment: { module: shaderModule, entryPoint: "fs", targets: [{ format }] },
|
|
2329
|
+
primitive: { topology: "triangle-list" }
|
|
2330
|
+
});
|
|
2331
|
+
pipelineCache.set(format, pipeline);
|
|
2332
|
+
}
|
|
2333
|
+
return pipeline;
|
|
2334
|
+
}
|
|
2335
|
+
function generateMipmaps(engine, texture, face) {
|
|
2336
|
+
const device = engine._device;
|
|
2337
|
+
const encoder = device.createCommandEncoder();
|
|
2338
|
+
recordMipmaps(engine, texture, encoder, face);
|
|
2339
|
+
device.queue.submit([encoder.finish()]);
|
|
2340
|
+
}
|
|
2341
|
+
function recordMipmaps(engine, texture, encoder, face) {
|
|
2342
|
+
if (texture.mipLevelCount <= 1) {
|
|
2149
2343
|
return;
|
|
2150
2344
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2345
|
+
const device = engine._device;
|
|
2346
|
+
const pipeline = getPipeline(engine, texture.format);
|
|
2347
|
+
const vp = face != null ? { dimension: "2d", baseArrayLayer: face, arrayLayerCount: 1 } : {};
|
|
2348
|
+
for (let mip = 1; mip < texture.mipLevelCount; mip++) {
|
|
2349
|
+
const srcView = texture.createView({ baseMipLevel: mip - 1, mipLevelCount: 1, ...vp });
|
|
2350
|
+
const dstView = texture.createView({ baseMipLevel: mip, mipLevelCount: 1, ...vp });
|
|
2351
|
+
const bindGroup = device.createBindGroup({
|
|
2352
|
+
layout: bindGroupLayout,
|
|
2353
|
+
entries: [
|
|
2354
|
+
{ binding: 0, resource: srcView },
|
|
2355
|
+
{ binding: 1, resource: linearSampler }
|
|
2356
|
+
]
|
|
2357
|
+
});
|
|
2358
|
+
const pass = encoder.beginRenderPass({
|
|
2359
|
+
colorAttachments: [{ view: dstView, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
2360
|
+
});
|
|
2361
|
+
pass.setPipeline(pipeline);
|
|
2362
|
+
pass.setBindGroup(0, bindGroup);
|
|
2363
|
+
pass.draw(3);
|
|
2364
|
+
pass.end();
|
|
2157
2365
|
}
|
|
2158
2366
|
}
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2367
|
+
const generateMipmaps$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2368
|
+
__proto__: null,
|
|
2369
|
+
generateMipmaps,
|
|
2370
|
+
recordMipmaps
|
|
2371
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2372
|
+
function mipLevelCount(width, height) {
|
|
2373
|
+
return Math.floor(Math.log2(Math.max(width, height))) + 1;
|
|
2374
|
+
}
|
|
2375
|
+
function biasedMipLevelCount(width, height, lodBias) {
|
|
2376
|
+
const maxDim = Math.max(width, height);
|
|
2377
|
+
return Math.max(1, Math.floor(Math.log2(maxDim) - lodBias) + 1);
|
|
2378
|
+
}
|
|
2379
|
+
const BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;
|
|
2380
|
+
const BLIT_MSAA_SHADER = `@group(0)@binding(0)var t:texture_multisampled_2d<f32>;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}fn l(p:vec2i)->vec4f{let n=textureNumSamples(t);var c=vec4f(0);for(var i=0u;i<n;i++){c+=textureLoad(t,p,i);}return c/f32(n);}@fragment fn fs(v:V)->@location(0)vec4f{let d=vec2i(textureDimensions(t));let q=clamp(v.u*vec2f(d)-.5,vec2f(0),vec2f(d-vec2i(1)));let p=vec2i(floor(q));let f=fract(q);let p1=min(p+vec2i(1),d-vec2i(1));return mix(mix(l(p),l(vec2i(p1.x,p.y)),f.x),mix(l(vec2i(p.x,p1.y)),l(p1),f.x),f.y);}`;
|
|
2381
|
+
const REFRACTION_LOD_BIAS = 4;
|
|
2382
|
+
let blitPipelines = null;
|
|
2383
|
+
let blitShader = null;
|
|
2384
|
+
let blitMsaaShader = null;
|
|
2385
|
+
let blitBgl = null;
|
|
2386
|
+
let blitMsaaBgl = null;
|
|
2387
|
+
let blitDevice = null;
|
|
2388
|
+
function enableSceneTransmission(scene, engine) {
|
|
2389
|
+
markPbrMaterialsLinear(scene);
|
|
2390
|
+
let lastRenderTask = null;
|
|
2391
|
+
for (const task of scene._frameGraph._tasks) {
|
|
2392
|
+
if ("_renderables" in task) {
|
|
2393
|
+
const renderTask = task;
|
|
2394
|
+
enableRenderTaskTransmission(renderTask, engine);
|
|
2395
|
+
lastRenderTask = renderTask;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
if (lastRenderTask && !scene._frameGraph._tasks.some((task) => task.name === "transmission-image-processing")) {
|
|
2399
|
+
scene._frameGraph._tasks.push(createImageProcessingTask({ name: "transmission-image-processing", source: lastRenderTask._config.rt }, engine, scene));
|
|
2164
2400
|
}
|
|
2165
|
-
slot.texture = texture;
|
|
2166
|
-
internal._bindGroupDirty = true;
|
|
2167
2401
|
}
|
|
2168
|
-
function
|
|
2169
|
-
|
|
2170
|
-
const
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
const targetSignature = {
|
|
2175
|
-
_colorFormat: rt._descriptor.colorFormat,
|
|
2176
|
-
_sampleCount: sampleCount
|
|
2177
|
-
};
|
|
2178
|
-
const colorAttachment = { loadOp: "clear", storeOp: "store" };
|
|
2179
|
-
const task = {
|
|
2180
|
-
name: config.name,
|
|
2181
|
-
_config: config,
|
|
2182
|
-
engine: eng,
|
|
2183
|
-
scene,
|
|
2184
|
-
_passes: [],
|
|
2185
|
-
_rt: rt,
|
|
2186
|
-
_targetSignature: targetSignature,
|
|
2187
|
-
_renderPassDescriptor: { label: config.name, colorAttachments: [colorAttachment] },
|
|
2188
|
-
_colorAttachment: colorAttachment,
|
|
2189
|
-
_pipeline: null,
|
|
2190
|
-
_bindGroup: null,
|
|
2191
|
-
record() {
|
|
2192
|
-
buildRenderTarget(rt, eng);
|
|
2193
|
-
task._pipeline = getEffectPipeline(effect, task._targetSignature);
|
|
2194
|
-
task._bindGroup = getEffectBindGroup(effect);
|
|
2195
|
-
},
|
|
2196
|
-
execute() {
|
|
2197
|
-
const pipeline = task._pipeline;
|
|
2198
|
-
if (!pipeline) {
|
|
2199
|
-
throw new Error(`EffectRenderTask "${task.name}" executed before record().`);
|
|
2200
|
-
}
|
|
2201
|
-
task._bindGroup = getEffectBindGroup(effect);
|
|
2202
|
-
applyColorAttachmentState$2(task._colorAttachment, rt, eng, task._config.clear !== false, task._config.clearColor);
|
|
2203
|
-
const pass = eng._currentEncoder.beginRenderPass(task._renderPassDescriptor);
|
|
2204
|
-
pass.setPipeline(pipeline);
|
|
2205
|
-
if (task._bindGroup) {
|
|
2206
|
-
pass.setBindGroup(0, task._bindGroup);
|
|
2207
|
-
}
|
|
2208
|
-
pass.draw(3);
|
|
2209
|
-
pass.end();
|
|
2210
|
-
return 1;
|
|
2211
|
-
},
|
|
2212
|
-
dispose() {
|
|
2213
|
-
task._passes.length = 0;
|
|
2214
|
-
disposeRenderTarget(task._rt);
|
|
2215
|
-
task._pipeline = null;
|
|
2216
|
-
task._bindGroup = null;
|
|
2402
|
+
function enableRenderTaskTransmission(task, engine, options) {
|
|
2403
|
+
var _a, _b;
|
|
2404
|
+
const linear = (options == null ? void 0 : options.linear) !== false;
|
|
2405
|
+
const grab = {
|
|
2406
|
+
get texture() {
|
|
2407
|
+
return task._targetSignature._transmissionTexture ?? null;
|
|
2217
2408
|
}
|
|
2218
2409
|
};
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
function disposeEffectWrapper(wrapper) {
|
|
2222
|
-
var _a;
|
|
2223
|
-
const internal = wrapper;
|
|
2224
|
-
for (const slot of internal._uniforms) {
|
|
2225
|
-
slot.buffer.destroy();
|
|
2410
|
+
if (task._executeWithTransmission) {
|
|
2411
|
+
return grab;
|
|
2226
2412
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2413
|
+
if (linear) {
|
|
2414
|
+
retargetRenderTaskToLinearOffscreen(task, engine);
|
|
2415
|
+
}
|
|
2416
|
+
let state = null;
|
|
2417
|
+
const record = task.record.bind(task);
|
|
2418
|
+
const execute = (_a = task.execute) == null ? void 0 : _a.bind(task);
|
|
2419
|
+
const dispose = (_b = task.dispose) == null ? void 0 : _b.bind(task);
|
|
2420
|
+
task.record = () => {
|
|
2421
|
+
disposeRenderTaskTransmission(state);
|
|
2422
|
+
state = createRenderTaskTransmission(task, engine);
|
|
2423
|
+
task._targetSignature._transmissionTexture = state.texture;
|
|
2424
|
+
record();
|
|
2425
|
+
configureTransmissionSource(state, task, engine);
|
|
2426
|
+
};
|
|
2427
|
+
if (linear && execute) {
|
|
2428
|
+
task.execute = () => executeRenderTaskLinear(task.scene, execute);
|
|
2429
|
+
}
|
|
2430
|
+
task.dispose = () => {
|
|
2431
|
+
disposeRenderTaskTransmission(state);
|
|
2432
|
+
state = null;
|
|
2433
|
+
dispose == null ? void 0 : dispose();
|
|
2434
|
+
};
|
|
2435
|
+
task._executeWithTransmission = (sampleCount) => executePassWithTransmission(task, engine, state, sampleCount);
|
|
2436
|
+
return grab;
|
|
2437
|
+
}
|
|
2438
|
+
function retargetRenderTaskToLinearOffscreen(task, engine) {
|
|
2439
|
+
const desc = task._config.rt._descriptor;
|
|
2440
|
+
if (desc.resolveToSwapchain) {
|
|
2441
|
+
desc.resolveToSwapchain = false;
|
|
2442
|
+
desc.colorFormat = "rgba16float";
|
|
2443
|
+
desc.flipY = false;
|
|
2444
|
+
task._opaqueBundles.length = 0;
|
|
2445
|
+
task._lastVersion = -1;
|
|
2446
|
+
} else if (!desc.colorFormat) {
|
|
2447
|
+
desc.colorFormat = "rgba16float";
|
|
2448
|
+
}
|
|
2449
|
+
desc.sampleCount = engine.msaaSamples;
|
|
2450
|
+
const sig = task._targetSignature;
|
|
2451
|
+
sig._colorFormat = desc.colorFormat;
|
|
2452
|
+
sig._depthStencilFormat = desc.depthStencilFormat;
|
|
2453
|
+
sig._depthCompare = desc._depthCompare;
|
|
2454
|
+
sig._sampleCount = desc.sampleCount;
|
|
2455
|
+
sig._flipY = desc.flipY ?? true;
|
|
2456
|
+
}
|
|
2457
|
+
function executeRenderTaskLinear(scene, execute) {
|
|
2458
|
+
const imageProcessing = scene.imageProcessing;
|
|
2459
|
+
const toneMappingEnabled = imageProcessing.toneMappingEnabled;
|
|
2460
|
+
const clearColor = scene.clearColor;
|
|
2461
|
+
const linearClearColor = inverseImageProcessedColor(clearColor, imageProcessing.exposure, imageProcessing.contrast, toneMappingEnabled === true);
|
|
2462
|
+
imageProcessing.toneMappingEnabled = -1;
|
|
2463
|
+
scene.clearColor = linearClearColor;
|
|
2464
|
+
try {
|
|
2465
|
+
return execute();
|
|
2466
|
+
} finally {
|
|
2467
|
+
scene.clearColor = clearColor;
|
|
2468
|
+
imageProcessing.toneMappingEnabled = toneMappingEnabled;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
function inverseImageProcessedColor(color, exposure, contrast, toneMapping) {
|
|
2472
|
+
return {
|
|
2473
|
+
r: inverseImageProcessedChannel(color.r, exposure, contrast, toneMapping),
|
|
2474
|
+
g: inverseImageProcessedChannel(color.g, exposure, contrast, toneMapping),
|
|
2475
|
+
b: inverseImageProcessedChannel(color.b, exposure, contrast, toneMapping),
|
|
2476
|
+
a: color.a
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
function inverseImageProcessedChannel(value, exposure, contrast, toneMapping) {
|
|
2480
|
+
let c = clamp01$1(value);
|
|
2481
|
+
if (contrast < 1) {
|
|
2482
|
+
c = contrast > 0 ? clamp01$1((c - 0.5 * (1 - contrast)) / contrast) : 0.5;
|
|
2483
|
+
} else if (contrast > 1) {
|
|
2484
|
+
const mixAmount = contrast - 1;
|
|
2485
|
+
let lo = 0;
|
|
2486
|
+
let hi = 1;
|
|
2487
|
+
for (let i = 0; i < 16; i++) {
|
|
2488
|
+
const mid = (lo + hi) * 0.5;
|
|
2489
|
+
const high = mid * mid * (3 - 2 * mid);
|
|
2490
|
+
const out = mid + (high - mid) * mixAmount;
|
|
2491
|
+
if (out < c) {
|
|
2492
|
+
lo = mid;
|
|
2493
|
+
} else {
|
|
2494
|
+
hi = mid;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
c = (lo + hi) * 0.5;
|
|
2498
|
+
}
|
|
2499
|
+
c = c ** 2.2;
|
|
2500
|
+
if (toneMapping) {
|
|
2501
|
+
c = -Math.log2(Math.max(1 - c, 1e-6)) / 1.5905790328979492;
|
|
2502
|
+
}
|
|
2503
|
+
return exposure > 0 ? c / exposure : c;
|
|
2504
|
+
}
|
|
2505
|
+
function clamp01$1(v) {
|
|
2506
|
+
return Math.min(Math.max(v, 0), 1);
|
|
2507
|
+
}
|
|
2508
|
+
function markPbrMaterialsLinear(scene) {
|
|
2509
|
+
for (const mesh of scene.meshes) {
|
|
2510
|
+
const mat = mesh.material;
|
|
2511
|
+
if (mat) {
|
|
2512
|
+
mat._linearImageProcessing = true;
|
|
2513
|
+
mat._renderFeatures = void 0;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
function createRenderTaskTransmission(task, engine) {
|
|
2518
|
+
const rt = task._config.rt;
|
|
2519
|
+
const width = 1024;
|
|
2520
|
+
const height = 1024;
|
|
2521
|
+
const format = "rgba16float";
|
|
2522
|
+
const generateMipmaps2 = shouldGenerateMipmaps(task._config.transmission);
|
|
2523
|
+
const texture = engine._device.createTexture({
|
|
2524
|
+
label: task.name,
|
|
2525
|
+
size: { width, height },
|
|
2526
|
+
format,
|
|
2527
|
+
mipLevelCount: generateMipmaps2 ? biasedMipLevelCount(width, height, REFRACTION_LOD_BIAS) : 1,
|
|
2528
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
2529
|
+
});
|
|
2530
|
+
const tex = {
|
|
2531
|
+
texture,
|
|
2532
|
+
view: texture.createView(),
|
|
2533
|
+
sampler: getTrilinearAnisotropicSampler(engine),
|
|
2534
|
+
width,
|
|
2535
|
+
height,
|
|
2536
|
+
invertY: false
|
|
2537
|
+
};
|
|
2538
|
+
return {
|
|
2539
|
+
texture: tex,
|
|
2540
|
+
_baseView: texture.createView({ baseMipLevel: 0, mipLevelCount: 1 }),
|
|
2541
|
+
_sourceWidth: rt._width,
|
|
2542
|
+
_sourceHeight: rt._height,
|
|
2543
|
+
_sourceTexture: null,
|
|
2544
|
+
_blit: null,
|
|
2545
|
+
_copyCount: normalizeCopyCount(task._config.transmission),
|
|
2546
|
+
_generateMipmaps: generateMipmaps2,
|
|
2547
|
+
_copies: 0
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
function configureTransmissionSource(state, task, engine) {
|
|
2551
|
+
const rt = task._config.rt;
|
|
2552
|
+
state._sourceWidth = rt._width;
|
|
2553
|
+
state._sourceHeight = rt._height;
|
|
2554
|
+
state._sourceTexture = rt._colorTexture;
|
|
2555
|
+
const sampleCount = task._targetSignature._sampleCount;
|
|
2556
|
+
if (!state._sourceTexture) {
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
state._blit = shouldBlitTransmission(state, sampleCount) ? createTransmissionBlit(state, engine, state._sourceTexture, sampleCount > 1) : null;
|
|
2560
|
+
}
|
|
2561
|
+
function disposeRenderTaskTransmission(state) {
|
|
2562
|
+
state == null ? void 0 : state.texture.texture.destroy();
|
|
2563
|
+
}
|
|
2564
|
+
function executePassWithTransmission(task, engine, state, sampleCount) {
|
|
2565
|
+
var _a;
|
|
2566
|
+
state._copies = 0;
|
|
2567
|
+
const transparent = task._transparentBindings;
|
|
2568
|
+
let pass = beginTaskPass(task, null, sampleCount, false);
|
|
2569
|
+
let draws = drawBaseTask(task, pass);
|
|
2570
|
+
let lastPipeline = null;
|
|
2571
|
+
let overlay = null;
|
|
2572
|
+
for (let i = 0; i < transparent.length; i++) {
|
|
2573
|
+
const binding = transparent[i];
|
|
2574
|
+
if (((_a = binding.renderable.mesh) == null ? void 0 : _a.renderOnTop) === true) {
|
|
2575
|
+
(overlay ?? (overlay = [])).push(binding);
|
|
2576
|
+
continue;
|
|
2577
|
+
}
|
|
2578
|
+
const transmissive = binding.renderable._transmissive === true;
|
|
2579
|
+
if (transmissive && canUpdateTransmission(state)) {
|
|
2580
|
+
pass.end();
|
|
2581
|
+
updateTransmissionTexture(state, engine);
|
|
2582
|
+
pass = beginTaskPass(task, null, sampleCount, true);
|
|
2583
|
+
setPassState(task, pass);
|
|
2584
|
+
lastPipeline = null;
|
|
2585
|
+
}
|
|
2586
|
+
const mesh = binding.renderable.mesh;
|
|
2587
|
+
if (mesh && mesh.visible === false) {
|
|
2588
|
+
continue;
|
|
2589
|
+
}
|
|
2590
|
+
if (binding.pipeline !== lastPipeline) {
|
|
2591
|
+
pass.setPipeline(binding.pipeline);
|
|
2592
|
+
lastPipeline = binding.pipeline;
|
|
2593
|
+
}
|
|
2594
|
+
draws += binding.draw(pass, engine);
|
|
2595
|
+
}
|
|
2596
|
+
if (overlay) {
|
|
2597
|
+
draws += drawList(pass, overlay, engine);
|
|
2598
|
+
}
|
|
2599
|
+
pass.end();
|
|
2600
|
+
return draws;
|
|
2601
|
+
}
|
|
2602
|
+
function updateTransmissionTexture(state, engine) {
|
|
2603
|
+
if (!state._sourceTexture) {
|
|
2604
|
+
throw new Error("No transmission source");
|
|
2605
|
+
}
|
|
2606
|
+
if (state._blit) {
|
|
2607
|
+
blitToTransmission(state, engine);
|
|
2608
|
+
} else {
|
|
2609
|
+
engine._currentEncoder.copyTextureToTexture(
|
|
2610
|
+
{ texture: state._sourceTexture },
|
|
2611
|
+
{ texture: state.texture.texture },
|
|
2612
|
+
{ width: state.texture.width, height: state.texture.height }
|
|
2613
|
+
);
|
|
2614
|
+
}
|
|
2615
|
+
if (state._generateMipmaps) {
|
|
2616
|
+
recordMipmaps(engine, state.texture.texture, engine._currentEncoder);
|
|
2617
|
+
}
|
|
2618
|
+
state._copies++;
|
|
2619
|
+
}
|
|
2620
|
+
function getBlitPipeline(engine, format, multisampled) {
|
|
2621
|
+
const device = engine._device;
|
|
2622
|
+
if (device !== blitDevice) {
|
|
2623
|
+
blitPipelines == null ? void 0 : blitPipelines.clear();
|
|
2624
|
+
blitPipelines = null;
|
|
2625
|
+
blitShader = null;
|
|
2626
|
+
blitMsaaShader = null;
|
|
2627
|
+
blitBgl = null;
|
|
2628
|
+
blitMsaaBgl = null;
|
|
2629
|
+
blitDevice = device;
|
|
2630
|
+
}
|
|
2631
|
+
if (multisampled) {
|
|
2632
|
+
blitMsaaShader ?? (blitMsaaShader = device.createShaderModule({ code: BLIT_MSAA_SHADER }));
|
|
2633
|
+
blitMsaaBgl ?? (blitMsaaBgl = device.createBindGroupLayout({
|
|
2634
|
+
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "unfilterable-float", multisampled: true } }]
|
|
2635
|
+
}));
|
|
2636
|
+
} else {
|
|
2637
|
+
blitShader ?? (blitShader = device.createShaderModule({ code: BLIT_SHADER }));
|
|
2638
|
+
blitBgl ?? (blitBgl = device.createBindGroupLayout({
|
|
2639
|
+
entries: [
|
|
2640
|
+
{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "float" } },
|
|
2641
|
+
{ binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} }
|
|
2642
|
+
]
|
|
2643
|
+
}));
|
|
2644
|
+
}
|
|
2645
|
+
blitPipelines ?? (blitPipelines = /* @__PURE__ */ new Map());
|
|
2646
|
+
const key = `${format}:${multisampled ? "msaa" : ""}`;
|
|
2647
|
+
let pipeline = blitPipelines.get(key);
|
|
2648
|
+
if (!pipeline) {
|
|
2649
|
+
const bgl = multisampled ? blitMsaaBgl : blitBgl;
|
|
2650
|
+
pipeline = device.createRenderPipeline({
|
|
2651
|
+
label: "transmission-copy",
|
|
2652
|
+
layout: device.createPipelineLayout({ bindGroupLayouts: [bgl] }),
|
|
2653
|
+
vertex: { module: multisampled ? blitMsaaShader : blitShader, entryPoint: "vs" },
|
|
2654
|
+
fragment: { module: multisampled ? blitMsaaShader : blitShader, entryPoint: "fs", targets: [{ format }] },
|
|
2655
|
+
primitive: { topology: "triangle-list" }
|
|
2656
|
+
});
|
|
2657
|
+
blitPipelines.set(key, pipeline);
|
|
2658
|
+
}
|
|
2659
|
+
return pipeline;
|
|
2660
|
+
}
|
|
2661
|
+
function shouldBlitTransmission(state, sampleCount) {
|
|
2662
|
+
return sampleCount > 1 || state._sourceWidth !== state.texture.width || state._sourceHeight !== state.texture.height;
|
|
2663
|
+
}
|
|
2664
|
+
function createTransmissionBlit(state, engine, source, multisampled) {
|
|
2665
|
+
const device = engine._device;
|
|
2666
|
+
const pipeline = getBlitPipeline(engine, state.texture.texture.format, multisampled);
|
|
2667
|
+
const bindGroup = device.createBindGroup({
|
|
2668
|
+
layout: multisampled ? blitMsaaBgl : blitBgl,
|
|
2669
|
+
entries: multisampled ? [{ binding: 0, resource: source.createView() }] : [
|
|
2670
|
+
{ binding: 0, resource: source.createView() },
|
|
2671
|
+
{ binding: 1, resource: getBilinearSampler(engine) }
|
|
2672
|
+
]
|
|
2673
|
+
});
|
|
2674
|
+
return { _pipeline: pipeline, _bindGroup: bindGroup };
|
|
2675
|
+
}
|
|
2676
|
+
function blitToTransmission(state, engine) {
|
|
2677
|
+
const blit = state._blit;
|
|
2678
|
+
const pass = engine._currentEncoder.beginRenderPass({
|
|
2679
|
+
colorAttachments: [{ view: state._baseView, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
2680
|
+
});
|
|
2681
|
+
pass.setPipeline(blit._pipeline);
|
|
2682
|
+
pass.setBindGroup(0, blit._bindGroup);
|
|
2683
|
+
pass.draw(3);
|
|
2684
|
+
pass.end();
|
|
2685
|
+
}
|
|
2686
|
+
function canUpdateTransmission(state) {
|
|
2687
|
+
return state._copyCount === 0 || state._copies < state._copyCount;
|
|
2688
|
+
}
|
|
2689
|
+
function beginTaskPass(task, resolveTarget, sampleCount, load) {
|
|
2690
|
+
const att = task._colorAttachment;
|
|
2691
|
+
const depthLoadOp = load || !task._config.clr ? "load" : "clear";
|
|
2692
|
+
if (load) {
|
|
2693
|
+
att.loadOp = "load";
|
|
2694
|
+
}
|
|
2695
|
+
const depthAttachment = task._renderPassDescriptor.depthStencilAttachment;
|
|
2696
|
+
if (depthAttachment) {
|
|
2697
|
+
depthAttachment.depthLoadOp = depthLoadOp;
|
|
2698
|
+
if (depthAttachment.stencilLoadOp) {
|
|
2699
|
+
depthAttachment.stencilLoadOp = depthLoadOp;
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
if (sampleCount > 1) {
|
|
2703
|
+
att.resolveTarget = void 0;
|
|
2704
|
+
} else {
|
|
2705
|
+
att.resolveTarget = void 0;
|
|
2706
|
+
}
|
|
2707
|
+
return task.engine._currentEncoder.beginRenderPass(task._renderPassDescriptor);
|
|
2708
|
+
}
|
|
2709
|
+
function setPassState(task, pass) {
|
|
2710
|
+
const cfg = task._config;
|
|
2711
|
+
const rt = cfg.rt;
|
|
2712
|
+
const scene = task.scene;
|
|
2713
|
+
const camera = cfg.cam ?? scene.camera;
|
|
2714
|
+
const v = camera == null ? void 0 : camera.viewport;
|
|
2715
|
+
if (v) {
|
|
2716
|
+
const rw = rt._width;
|
|
2717
|
+
const rh = rt._height;
|
|
2718
|
+
const x = Math.floor(v.x * rw);
|
|
2719
|
+
const y = Math.floor((1 - v.y - v.height) * rh);
|
|
2720
|
+
const w = Math.ceil((v.x + v.width) * rw) - x;
|
|
2721
|
+
const h = Math.ceil((1 - v.y) * rh) - y;
|
|
2722
|
+
pass.setViewport(x, y, w, h, 0, 1);
|
|
2723
|
+
pass.setScissorRect(x, y, w, h);
|
|
2724
|
+
}
|
|
2725
|
+
pass.setBindGroup(0, task._sceneBG);
|
|
2726
|
+
}
|
|
2727
|
+
function drawBaseTask(task, pass) {
|
|
2728
|
+
const eng = task.engine;
|
|
2729
|
+
const rt = task._config.rt;
|
|
2730
|
+
const scene = task.scene;
|
|
2731
|
+
const opaqueBindings = task._opaqueBindings;
|
|
2732
|
+
const opaqueBundles = task._opaqueBundles;
|
|
2733
|
+
setPassState(task, pass);
|
|
2734
|
+
if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {
|
|
2735
|
+
const desc = rt._descriptor;
|
|
2736
|
+
const be = eng._device.createRenderBundleEncoder({
|
|
2737
|
+
colorFormats: desc.colorFormat ? [desc.colorFormat] : [],
|
|
2738
|
+
depthStencilFormat: desc.depthStencilFormat,
|
|
2739
|
+
sampleCount: desc.sampleCount ?? 1
|
|
2740
|
+
});
|
|
2741
|
+
be.setBindGroup(0, task._sceneBG);
|
|
2742
|
+
drawList(be, opaqueBindings, eng);
|
|
2743
|
+
opaqueBundles[0] = be.finish();
|
|
2744
|
+
task._lastVersion = scene._renderableVersion;
|
|
2745
|
+
task._lastVis = _vis;
|
|
2746
|
+
}
|
|
2747
|
+
let draws = opaqueBindings.length;
|
|
2748
|
+
pass.executeBundles(opaqueBundles);
|
|
2749
|
+
pass.setBindGroup(0, task._sceneBG);
|
|
2750
|
+
draws += drawList(pass, task._directBindings, eng);
|
|
2751
|
+
return draws;
|
|
2752
|
+
}
|
|
2753
|
+
function drawList(enc, list, engine) {
|
|
2754
|
+
let lp = null;
|
|
2755
|
+
let draws = 0;
|
|
2756
|
+
for (const b of list) {
|
|
2757
|
+
const mesh = b.renderable.mesh;
|
|
2758
|
+
if (mesh && mesh.visible === false) {
|
|
2759
|
+
continue;
|
|
2760
|
+
}
|
|
2761
|
+
if (b.pipeline !== lp) {
|
|
2762
|
+
enc.setPipeline(b.pipeline);
|
|
2763
|
+
lp = b.pipeline;
|
|
2764
|
+
}
|
|
2765
|
+
draws += b.draw(enc, engine);
|
|
2766
|
+
}
|
|
2767
|
+
return draws;
|
|
2768
|
+
}
|
|
2769
|
+
function normalizeCopyCount(cfg) {
|
|
2770
|
+
const count = (cfg == null ? void 0 : cfg.copyCount) ?? 1;
|
|
2771
|
+
return count === Infinity ? 0 : Math.max(0, count | 0);
|
|
2772
|
+
}
|
|
2773
|
+
function shouldGenerateMipmaps(cfg) {
|
|
2774
|
+
return (cfg == null ? void 0 : cfg.generateMipmaps) !== false;
|
|
2775
|
+
}
|
|
2776
|
+
const DEFAULT_VERTEX_WGSL$1 = `struct EffectVertexOutput{@builtin(position) position:vec4<f32>,@location(0) uv:vec2<f32>};
|
|
2777
|
+
@vertex fn effectFullscreenVertex(@builtin(vertex_index) vertexIndex:u32)->EffectVertexOutput{var positions=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));let p=positions[vertexIndex];var out:EffectVertexOutput;out.position=vec4<f32>(p,0.0,1.0);out.uv=p*0.5+vec2<f32>(0.5,0.5);return out;}`;
|
|
2778
|
+
function createEffectWrapper(engine, options) {
|
|
2779
|
+
const eng = engine;
|
|
2780
|
+
const wrapper = {
|
|
2781
|
+
name: options.name ?? "effect-wrapper",
|
|
2782
|
+
options,
|
|
2783
|
+
_engine: eng,
|
|
2784
|
+
_shader: null,
|
|
2785
|
+
_bindGroupLayout: null,
|
|
2786
|
+
_pipelineLayout: null,
|
|
2787
|
+
_bindGroup: null,
|
|
2788
|
+
_bindGroupDirty: true,
|
|
2789
|
+
_pipelines: null,
|
|
2790
|
+
_uniforms: [],
|
|
2791
|
+
_textures: []
|
|
2792
|
+
};
|
|
2793
|
+
createBindingSlots(wrapper);
|
|
2794
|
+
return wrapper;
|
|
2795
|
+
}
|
|
2796
|
+
function setEffectUniforms(wrapper, data) {
|
|
2797
|
+
const internal = wrapper;
|
|
2798
|
+
if (isBufferData(data)) {
|
|
2799
|
+
const slot = internal._uniforms[0];
|
|
2800
|
+
if (!slot) {
|
|
2801
|
+
throw new Error("setEffectUniforms: wrapper has no uniform binding.");
|
|
2802
|
+
}
|
|
2803
|
+
writeUniformSlot(internal, slot, data);
|
|
2804
|
+
return;
|
|
2805
|
+
}
|
|
2806
|
+
for (const key of Object.keys(data)) {
|
|
2807
|
+
const slot = findUniformSlot(internal, key);
|
|
2808
|
+
if (!slot) {
|
|
2809
|
+
throw new Error(`setEffectUniforms: unknown uniform binding "${key}".`);
|
|
2810
|
+
}
|
|
2811
|
+
writeUniformSlot(internal, slot, data[key]);
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
function setEffectTexture(wrapper, bindingNameOrIndex, texture) {
|
|
2815
|
+
const internal = wrapper;
|
|
2816
|
+
const slot = findTextureSlot(internal, bindingNameOrIndex);
|
|
2817
|
+
if (!slot) {
|
|
2818
|
+
throw new Error(`setEffectTexture: unknown texture binding "${String(bindingNameOrIndex)}".`);
|
|
2819
|
+
}
|
|
2820
|
+
slot.texture = texture;
|
|
2821
|
+
internal._bindGroupDirty = true;
|
|
2822
|
+
}
|
|
2823
|
+
function createEffectRenderTask(config, engine, scene) {
|
|
2824
|
+
const eng = engine;
|
|
2825
|
+
const effect = config.effect;
|
|
2826
|
+
const rt = config.target;
|
|
2827
|
+
config.clearColor ?? (config.clearColor = { r: 0, g: 0, b: 0, a: 1 });
|
|
2828
|
+
const sampleCount = rt._descriptor.sampleCount ?? 1;
|
|
2829
|
+
const targetSignature = {
|
|
2830
|
+
_colorFormat: rt._descriptor.colorFormat,
|
|
2831
|
+
_sampleCount: sampleCount
|
|
2832
|
+
};
|
|
2833
|
+
const colorAttachment = { loadOp: "clear", storeOp: "store" };
|
|
2834
|
+
const task = {
|
|
2835
|
+
name: config.name,
|
|
2836
|
+
_config: config,
|
|
2837
|
+
engine: eng,
|
|
2838
|
+
scene,
|
|
2839
|
+
_passes: [],
|
|
2840
|
+
_rt: rt,
|
|
2841
|
+
_targetSignature: targetSignature,
|
|
2842
|
+
_renderPassDescriptor: { label: config.name, colorAttachments: [colorAttachment] },
|
|
2843
|
+
_colorAttachment: colorAttachment,
|
|
2844
|
+
_pipeline: null,
|
|
2845
|
+
_bindGroup: null,
|
|
2846
|
+
record() {
|
|
2847
|
+
buildRenderTarget(rt, eng);
|
|
2848
|
+
task._pipeline = getEffectPipeline(effect, task._targetSignature);
|
|
2849
|
+
task._bindGroup = getEffectBindGroup(effect);
|
|
2850
|
+
},
|
|
2851
|
+
execute() {
|
|
2852
|
+
const pipeline = task._pipeline;
|
|
2853
|
+
if (!pipeline) {
|
|
2854
|
+
throw new Error(`EffectRenderTask "${task.name}" executed before record().`);
|
|
2855
|
+
}
|
|
2856
|
+
task._bindGroup = getEffectBindGroup(effect);
|
|
2857
|
+
applyColorAttachmentState$2(task._colorAttachment, rt, eng, task._config.clear !== false, task._config.clearColor);
|
|
2858
|
+
const pass = eng._currentEncoder.beginRenderPass(task._renderPassDescriptor);
|
|
2859
|
+
pass.setPipeline(pipeline);
|
|
2860
|
+
if (task._bindGroup) {
|
|
2861
|
+
pass.setBindGroup(0, task._bindGroup);
|
|
2862
|
+
}
|
|
2863
|
+
pass.draw(3);
|
|
2864
|
+
pass.end();
|
|
2865
|
+
return 1;
|
|
2866
|
+
},
|
|
2867
|
+
dispose() {
|
|
2868
|
+
task._passes.length = 0;
|
|
2869
|
+
disposeRenderTarget(task._rt);
|
|
2870
|
+
task._pipeline = null;
|
|
2871
|
+
task._bindGroup = null;
|
|
2872
|
+
}
|
|
2873
|
+
};
|
|
2874
|
+
return task;
|
|
2875
|
+
}
|
|
2876
|
+
function disposeEffectWrapper(wrapper) {
|
|
2877
|
+
var _a;
|
|
2878
|
+
const internal = wrapper;
|
|
2879
|
+
for (const slot of internal._uniforms) {
|
|
2880
|
+
slot.buffer.destroy();
|
|
2881
|
+
}
|
|
2882
|
+
internal._uniforms.length = 0;
|
|
2883
|
+
internal._textures.length = 0;
|
|
2884
|
+
(_a = internal._pipelines) == null ? void 0 : _a.clear();
|
|
2230
2885
|
internal._pipelines = null;
|
|
2231
2886
|
internal._shader = null;
|
|
2232
2887
|
internal._bindGroupLayout = null;
|
|
@@ -3508,6 +4163,57 @@ function resolveSourceSize(source, engine) {
|
|
|
3508
4163
|
}
|
|
3509
4164
|
return desc.size;
|
|
3510
4165
|
}
|
|
4166
|
+
function clampCameraToLimits(camera) {
|
|
4167
|
+
if (camera.lowerRadiusLimit !== void 0 && camera.radius < camera.lowerRadiusLimit) {
|
|
4168
|
+
camera.radius = camera.lowerRadiusLimit;
|
|
4169
|
+
camera.inertialRadiusOffset = 0;
|
|
4170
|
+
} else if (camera.upperRadiusLimit !== void 0 && camera.radius > camera.upperRadiusLimit) {
|
|
4171
|
+
camera.radius = camera.upperRadiusLimit;
|
|
4172
|
+
camera.inertialRadiusOffset = 0;
|
|
4173
|
+
}
|
|
4174
|
+
if (camera.lowerBetaLimit !== void 0 && camera.beta < camera.lowerBetaLimit) {
|
|
4175
|
+
camera.beta = camera.lowerBetaLimit;
|
|
4176
|
+
camera.inertialBetaOffset = 0;
|
|
4177
|
+
} else if (camera.upperBetaLimit !== void 0 && camera.beta > camera.upperBetaLimit) {
|
|
4178
|
+
camera.beta = camera.upperBetaLimit;
|
|
4179
|
+
camera.inertialBetaOffset = 0;
|
|
4180
|
+
}
|
|
4181
|
+
if (camera.lowerAlphaLimit !== void 0 && camera.alpha < camera.lowerAlphaLimit) {
|
|
4182
|
+
camera.alpha = camera.lowerAlphaLimit;
|
|
4183
|
+
camera.inertialAlphaOffset = 0;
|
|
4184
|
+
} else if (camera.upperAlphaLimit !== void 0 && camera.alpha > camera.upperAlphaLimit) {
|
|
4185
|
+
camera.alpha = camera.upperAlphaLimit;
|
|
4186
|
+
camera.inertialAlphaOffset = 0;
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
function setCameraLimits(camera, limits, scene) {
|
|
4190
|
+
if ("lowerAlphaLimit" in limits) {
|
|
4191
|
+
camera.lowerAlphaLimit = limits.lowerAlphaLimit;
|
|
4192
|
+
}
|
|
4193
|
+
if ("upperAlphaLimit" in limits) {
|
|
4194
|
+
camera.upperAlphaLimit = limits.upperAlphaLimit;
|
|
4195
|
+
}
|
|
4196
|
+
if ("lowerBetaLimit" in limits) {
|
|
4197
|
+
camera.lowerBetaLimit = limits.lowerBetaLimit;
|
|
4198
|
+
}
|
|
4199
|
+
if ("upperBetaLimit" in limits) {
|
|
4200
|
+
camera.upperBetaLimit = limits.upperBetaLimit;
|
|
4201
|
+
}
|
|
4202
|
+
if ("lowerRadiusLimit" in limits) {
|
|
4203
|
+
camera.lowerRadiusLimit = limits.lowerRadiusLimit;
|
|
4204
|
+
}
|
|
4205
|
+
if ("upperRadiusLimit" in limits) {
|
|
4206
|
+
camera.upperRadiusLimit = limits.upperRadiusLimit;
|
|
4207
|
+
}
|
|
4208
|
+
const enforce = () => clampCameraToLimits(camera);
|
|
4209
|
+
camera._clampToLimits = enforce;
|
|
4210
|
+
enforce();
|
|
4211
|
+
return () => {
|
|
4212
|
+
if (camera._clampToLimits === enforce) {
|
|
4213
|
+
camera._clampToLimits = void 0;
|
|
4214
|
+
}
|
|
4215
|
+
};
|
|
4216
|
+
}
|
|
3511
4217
|
function attachControl(camera, canvas, scene) {
|
|
3512
4218
|
const angularSensibility = 1e3;
|
|
3513
4219
|
const panningSensibility = 50;
|
|
@@ -3519,7 +4225,6 @@ function attachControl(camera, canvas, scene) {
|
|
|
3519
4225
|
let isPanning = false;
|
|
3520
4226
|
let lastX = 0;
|
|
3521
4227
|
let lastY = 0;
|
|
3522
|
-
let animFrameId = 0;
|
|
3523
4228
|
const activeTouches = /* @__PURE__ */ new Map();
|
|
3524
4229
|
let pinchStartDist = 0;
|
|
3525
4230
|
let pinchStartRadius = 0;
|
|
@@ -3536,13 +4241,16 @@ function attachControl(camera, canvas, scene) {
|
|
|
3536
4241
|
}
|
|
3537
4242
|
}
|
|
3538
4243
|
function onPointerMove(e) {
|
|
3539
|
-
if (!isDragging && !isPanning) {
|
|
3540
|
-
return;
|
|
3541
|
-
}
|
|
3542
4244
|
const dx = e.clientX - lastX;
|
|
3543
4245
|
const dy = e.clientY - lastY;
|
|
3544
4246
|
lastX = e.clientX;
|
|
3545
4247
|
lastY = e.clientY;
|
|
4248
|
+
if (activeTouches.size >= 2) {
|
|
4249
|
+
return;
|
|
4250
|
+
}
|
|
4251
|
+
if (!isDragging && !isPanning) {
|
|
4252
|
+
return;
|
|
4253
|
+
}
|
|
3546
4254
|
if (isDragging) {
|
|
3547
4255
|
camera.inertialAlphaOffset -= dx / angularSensibility;
|
|
3548
4256
|
camera.inertialBetaOffset -= dy / angularSensibility;
|
|
@@ -3569,12 +4277,15 @@ function attachControl(camera, canvas, scene) {
|
|
|
3569
4277
|
const touch = e.changedTouches[i];
|
|
3570
4278
|
activeTouches.set(touch.identifier, { x: touch.clientX, y: touch.clientY });
|
|
3571
4279
|
}
|
|
3572
|
-
if (activeTouches.size
|
|
4280
|
+
if (activeTouches.size >= 2) {
|
|
4281
|
+
isDragging = false;
|
|
4282
|
+
isPanning = false;
|
|
3573
4283
|
const iter = activeTouches.values();
|
|
3574
4284
|
const p0 = iter.next().value;
|
|
3575
4285
|
const p1 = iter.next().value;
|
|
3576
4286
|
pinchStartDist = Math.hypot(p1.x - p0.x, p1.y - p0.y);
|
|
3577
4287
|
pinchStartRadius = camera.radius;
|
|
4288
|
+
e.preventDefault();
|
|
3578
4289
|
}
|
|
3579
4290
|
}
|
|
3580
4291
|
function onTouchMove(e) {
|
|
@@ -3582,12 +4293,13 @@ function attachControl(camera, canvas, scene) {
|
|
|
3582
4293
|
const touch = e.changedTouches[i];
|
|
3583
4294
|
activeTouches.set(touch.identifier, { x: touch.clientX, y: touch.clientY });
|
|
3584
4295
|
}
|
|
3585
|
-
if (activeTouches.size
|
|
4296
|
+
if (activeTouches.size >= 2) {
|
|
4297
|
+
e.preventDefault();
|
|
3586
4298
|
const iter = activeTouches.values();
|
|
3587
4299
|
const p0 = iter.next().value;
|
|
3588
4300
|
const p1 = iter.next().value;
|
|
3589
4301
|
const dist = Math.hypot(p1.x - p0.x, p1.y - p0.y);
|
|
3590
|
-
if (pinchStartDist > 0) {
|
|
4302
|
+
if (pinchStartDist > 0 && dist > 0) {
|
|
3591
4303
|
camera.radius = pinchStartRadius * (pinchStartDist / dist);
|
|
3592
4304
|
camera.radius = Math.max(0.01, camera.radius);
|
|
3593
4305
|
}
|
|
@@ -3597,6 +4309,17 @@ function attachControl(camera, canvas, scene) {
|
|
|
3597
4309
|
for (let i = 0; i < e.changedTouches.length; i++) {
|
|
3598
4310
|
activeTouches.delete(e.changedTouches[i].identifier);
|
|
3599
4311
|
}
|
|
4312
|
+
if (activeTouches.size === 1) {
|
|
4313
|
+
const p = activeTouches.values().next().value;
|
|
4314
|
+
lastX = p.x;
|
|
4315
|
+
lastY = p.y;
|
|
4316
|
+
}
|
|
4317
|
+
if (activeTouches.size < 2) {
|
|
4318
|
+
pinchStartDist = 0;
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
function onGesture(e) {
|
|
4322
|
+
e.preventDefault();
|
|
3600
4323
|
}
|
|
3601
4324
|
function applyInertia() {
|
|
3602
4325
|
if (camera.inertialAlphaOffset !== 0 || camera.inertialBetaOffset !== 0) {
|
|
@@ -3639,14 +4362,9 @@ function attachControl(camera, canvas, scene) {
|
|
|
3639
4362
|
camera.inertialPanningY = 0;
|
|
3640
4363
|
}
|
|
3641
4364
|
}
|
|
3642
|
-
if (!scene) {
|
|
3643
|
-
animFrameId = requestAnimationFrame(applyInertia);
|
|
3644
|
-
}
|
|
3645
4365
|
}
|
|
3646
4366
|
if (scene) {
|
|
3647
4367
|
scene._beforeRender.push(applyInertia);
|
|
3648
|
-
} else {
|
|
3649
|
-
animFrameId = requestAnimationFrame(applyInertia);
|
|
3650
4368
|
}
|
|
3651
4369
|
const listeners = [
|
|
3652
4370
|
["pointerdown", onPointerDown],
|
|
@@ -3654,17 +4372,17 @@ function attachControl(camera, canvas, scene) {
|
|
|
3654
4372
|
["pointerup", onPointerUp],
|
|
3655
4373
|
["wheel", onWheel, { passive: false }],
|
|
3656
4374
|
["contextmenu", onContextMenu],
|
|
3657
|
-
["touchstart", onTouchStart, { passive:
|
|
3658
|
-
["touchmove", onTouchMove, { passive:
|
|
3659
|
-
["touchend", onTouchEnd]
|
|
4375
|
+
["touchstart", onTouchStart, { passive: false }],
|
|
4376
|
+
["touchmove", onTouchMove, { passive: false }],
|
|
4377
|
+
["touchend", onTouchEnd],
|
|
4378
|
+
["gesturestart", onGesture, { passive: false }],
|
|
4379
|
+
["gesturechange", onGesture, { passive: false }],
|
|
4380
|
+
["gestureend", onGesture, { passive: false }]
|
|
3660
4381
|
];
|
|
3661
4382
|
for (const [ev, h, opts] of listeners) {
|
|
3662
4383
|
canvas.addEventListener(ev, h, opts);
|
|
3663
4384
|
}
|
|
3664
4385
|
return () => {
|
|
3665
|
-
if (animFrameId) {
|
|
3666
|
-
cancelAnimationFrame(animFrameId);
|
|
3667
|
-
}
|
|
3668
4386
|
if (scene) {
|
|
3669
4387
|
const idx = scene._beforeRender.indexOf(applyInertia);
|
|
3670
4388
|
if (idx >= 0) {
|
|
@@ -3680,25 +4398,26 @@ function createFreeCamera(position, target) {
|
|
|
3680
4398
|
const dx = target.x - position.x;
|
|
3681
4399
|
const dy = target.y - position.y;
|
|
3682
4400
|
const dz = target.z - position.z;
|
|
3683
|
-
const _localMat =
|
|
4401
|
+
const _localMat = allocateMat4();
|
|
3684
4402
|
function cameraLocalWorldMatrix() {
|
|
3685
4403
|
const view = mat4LookAtLH(cam.position, cam.target, Vec3Up);
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
4404
|
+
const m = _localMat;
|
|
4405
|
+
m[0] = view[0];
|
|
4406
|
+
m[1] = view[4];
|
|
4407
|
+
m[2] = view[8];
|
|
4408
|
+
m[3] = 0;
|
|
4409
|
+
m[4] = view[1];
|
|
4410
|
+
m[5] = view[5];
|
|
4411
|
+
m[6] = view[9];
|
|
4412
|
+
m[7] = 0;
|
|
4413
|
+
m[8] = view[2];
|
|
4414
|
+
m[9] = view[6];
|
|
4415
|
+
m[10] = view[10];
|
|
4416
|
+
m[11] = 0;
|
|
4417
|
+
m[12] = cam.position.x;
|
|
4418
|
+
m[13] = cam.position.y;
|
|
4419
|
+
m[14] = cam.position.z;
|
|
4420
|
+
m[15] = 1;
|
|
3702
4421
|
return _localMat;
|
|
3703
4422
|
}
|
|
3704
4423
|
const wm = createWorldMatrixState(cameraLocalWorldMatrix);
|
|
@@ -3715,6 +4434,10 @@ function createFreeCamera(position, target) {
|
|
|
3715
4434
|
angularSensitivity: 2e3,
|
|
3716
4435
|
inertia: 0.9,
|
|
3717
4436
|
children: [],
|
|
4437
|
+
// Matrix caches use the process-global allocator.
|
|
4438
|
+
_viewCache: allocateMat4(),
|
|
4439
|
+
_projCache: allocateMat4(),
|
|
4440
|
+
_vpCache: allocateMat4(),
|
|
3718
4441
|
get parent() {
|
|
3719
4442
|
return wm.parent;
|
|
3720
4443
|
},
|
|
@@ -3953,7 +4676,8 @@ function localMatrixFromDirection(dx, dy, dz, px = 0, py = 0, pz = 0, out) {
|
|
|
3953
4676
|
rx /= rlen;
|
|
3954
4677
|
rz /= rlen;
|
|
3955
4678
|
const ux = fy * rz - fz * ry, uy = fz * rx - fx * rz, uz = fx * ry - fy * rx;
|
|
3956
|
-
const
|
|
4679
|
+
const out4 = out ?? new Float32Array(16);
|
|
4680
|
+
const m = out4;
|
|
3957
4681
|
m[0] = rx;
|
|
3958
4682
|
m[1] = ry;
|
|
3959
4683
|
m[2] = rz;
|
|
@@ -3970,11 +4694,13 @@ function localMatrixFromDirection(dx, dy, dz, px = 0, py = 0, pz = 0, out) {
|
|
|
3970
4694
|
m[13] = py;
|
|
3971
4695
|
m[14] = pz;
|
|
3972
4696
|
m[15] = 1;
|
|
3973
|
-
return
|
|
4697
|
+
return out4;
|
|
3974
4698
|
}
|
|
3975
4699
|
function createHemisphericLight(direction = [0, 1, 0], intensity = 1) {
|
|
3976
|
-
const _localMatrix =
|
|
3977
|
-
const { wm, onDirty, lvs } = createLightBase(() =>
|
|
4700
|
+
const _localMatrix = allocateMat4();
|
|
4701
|
+
const { wm, onDirty, lvs } = createLightBase(() => {
|
|
4702
|
+
return localMatrixFromDirection(light.direction.x, light.direction.y, light.direction.z, 0, 0, 0, _localMatrix);
|
|
4703
|
+
});
|
|
3978
4704
|
const light = applyWorldMatrixAccessors(
|
|
3979
4705
|
{
|
|
3980
4706
|
lightType: "hemispheric",
|
|
@@ -4007,15 +4733,19 @@ function createHemisphericLight(direction = [0, 1, 0], intensity = 1) {
|
|
|
4007
4733
|
);
|
|
4008
4734
|
return light;
|
|
4009
4735
|
}
|
|
4010
|
-
function mat4Translation(x, y, z) {
|
|
4011
|
-
const out = mat4Identity();
|
|
4012
|
-
out[12] = x;
|
|
4013
|
-
out[13] = y;
|
|
4014
|
-
out[14] = z;
|
|
4015
|
-
return out;
|
|
4016
|
-
}
|
|
4017
4736
|
function createPointLight(position, intensity = 1) {
|
|
4018
|
-
const
|
|
4737
|
+
const m = allocateMat4();
|
|
4738
|
+
m[0] = 1;
|
|
4739
|
+
m[5] = 1;
|
|
4740
|
+
m[10] = 1;
|
|
4741
|
+
m[15] = 1;
|
|
4742
|
+
const _localMatrix = m;
|
|
4743
|
+
const { wm, onDirty, lvs } = createLightBase(() => {
|
|
4744
|
+
m[12] = light.position.x;
|
|
4745
|
+
m[13] = light.position.y;
|
|
4746
|
+
m[14] = light.position.z;
|
|
4747
|
+
return _localMatrix;
|
|
4748
|
+
});
|
|
4019
4749
|
const light = applyWorldMatrixAccessors(
|
|
4020
4750
|
{
|
|
4021
4751
|
lightType: "point",
|
|
@@ -4051,10 +4781,10 @@ const pointLight = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
4051
4781
|
createPointLight
|
|
4052
4782
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4053
4783
|
function createDirectionalLight(direction, intensity = 1) {
|
|
4054
|
-
const _localMatrix =
|
|
4055
|
-
const { wm, onDirty, lvs } = createLightBase(
|
|
4056
|
-
|
|
4057
|
-
);
|
|
4784
|
+
const _localMatrix = allocateMat4();
|
|
4785
|
+
const { wm, onDirty, lvs } = createLightBase(() => {
|
|
4786
|
+
return localMatrixFromDirection(light.direction.x, light.direction.y, light.direction.z, light.position.x, light.position.y, light.position.z, _localMatrix);
|
|
4787
|
+
});
|
|
4058
4788
|
const light = applyWorldMatrixAccessors(
|
|
4059
4789
|
{
|
|
4060
4790
|
lightType: "directional",
|
|
@@ -4090,10 +4820,10 @@ const directionalLight = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
|
|
|
4090
4820
|
createDirectionalLight
|
|
4091
4821
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4092
4822
|
function createSpotLight(position, direction, angle, exponent, intensity = 1) {
|
|
4093
|
-
const _localMatrix =
|
|
4094
|
-
const { wm, onDirty, lvs } = createLightBase(
|
|
4095
|
-
|
|
4096
|
-
);
|
|
4823
|
+
const _localMatrix = allocateMat4();
|
|
4824
|
+
const { wm, onDirty, lvs } = createLightBase(() => {
|
|
4825
|
+
return localMatrixFromDirection(light.direction.x, light.direction.y, light.direction.z, light.position.x, light.position.y, light.position.z, _localMatrix);
|
|
4826
|
+
});
|
|
4097
4827
|
let _angle = angle;
|
|
4098
4828
|
let _cosHalfAngle = Math.cos(angle * 0.5);
|
|
4099
4829
|
const light = applyWorldMatrixAccessors(
|
|
@@ -4153,6 +4883,420 @@ const spotLight = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
4153
4883
|
__proto__: null,
|
|
4154
4884
|
createSpotLight
|
|
4155
4885
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4886
|
+
const PBR_HAS_NORMAL_MAP = 1 << 0;
|
|
4887
|
+
const PBR_HAS_EMISSIVE = 1 << 1;
|
|
4888
|
+
const PBR_HAS_ENV = 1 << 2;
|
|
4889
|
+
const PBR_HAS_ALPHA_TEST = 1 << 3;
|
|
4890
|
+
const PBR_HAS_TONEMAP = 1 << 4;
|
|
4891
|
+
const PBR_HAS_FOG = 1 << 5;
|
|
4892
|
+
const PBR_HAS_ALPHA_BLEND = 1 << 6;
|
|
4893
|
+
const PBR_HAS_SPEC_GLOSS = 1 << 7;
|
|
4894
|
+
const PBR_HAS_DOUBLE_SIDED = 1 << 8;
|
|
4895
|
+
const PBR_HAS_METALLIC_REFLECTANCE_MAP = 1 << 10;
|
|
4896
|
+
const PBR_HAS_REFLECTANCE_MAP = 1 << 11;
|
|
4897
|
+
const PBR_HAS_USE_ALPHA_ONLY_MR = 1 << 12;
|
|
4898
|
+
const PBR_HAS_OCCLUSION = 1 << 15;
|
|
4899
|
+
const PBR_HAS_SPECULAR_AA = 1 << 17;
|
|
4900
|
+
const PBR_HAS_CLEARCOAT = 1 << 20;
|
|
4901
|
+
const PBR_HAS_EMISSIVE_COLOR = 1 << 21;
|
|
4902
|
+
const PBR_HAS_SHEEN = 1 << 22;
|
|
4903
|
+
const PBR_HAS_SHEEN_TEXTURE = 1 << 23;
|
|
4904
|
+
const PBR_HAS_GAMMA_ALBEDO = 1 << 25;
|
|
4905
|
+
const PBR_HAS_ANISOTROPY = 1 << 26;
|
|
4906
|
+
const PBR_HAS_SUBSURFACE = 1 << 27;
|
|
4907
|
+
const PBR_HAS_THICKNESS_MAP = 1 << 28;
|
|
4908
|
+
const PBR_HAS_SKYBOX = 1 << 29;
|
|
4909
|
+
const PBR_HAS_SHEEN_ALBEDO_SCALING = 1 << 30;
|
|
4910
|
+
const PBR2_CC_INT_MAP = 1 << 0;
|
|
4911
|
+
const PBR2_CC_ROUGH_MAP = 1 << 1;
|
|
4912
|
+
const PBR2_CC_NORMAL_MAP = 1 << 2;
|
|
4913
|
+
const PBR2_CC_F0_REMAP_OFF = 1 << 3;
|
|
4914
|
+
const PBR2_HAS_REFRACTION = 1 << 4;
|
|
4915
|
+
const PBR2_HAS_VOLUME = 1 << 5;
|
|
4916
|
+
const PBR2_HAS_REFRACTION_MAP = 1 << 6;
|
|
4917
|
+
const PBR2_HAS_THICKNESS_GLTF_CHANNEL = 1 << 7;
|
|
4918
|
+
const PBR2_HAS_UNLIT = 1 << 8;
|
|
4919
|
+
const PBR2_HAS_UV_TRANSFORM = 1 << 9;
|
|
4920
|
+
const PBR2_HAS_REFLECTANCE_FACTORS = 1 << 10;
|
|
4921
|
+
const PBR2_HAS_UV2 = 1 << 11;
|
|
4922
|
+
const PBR2_HAS_BASE_COLOR_FACTOR = 1 << 12;
|
|
4923
|
+
const PBR2_HAS_SHEEN_UV_TX = 1 << 13;
|
|
4924
|
+
const PBR2_LINEAR_IMAGE_PROCESSING = 1 << 14;
|
|
4925
|
+
const PBR2_NO_COLOR_OUTPUT = 1 << 15;
|
|
4926
|
+
const PBR2_ESM_SHADOW_OUTPUT = 1 << 16;
|
|
4927
|
+
const PBR2_HAS_IRIDESCENCE = 1 << 17;
|
|
4928
|
+
const PBR2_HAS_IRIDESCENCE_MAP = 1 << 18;
|
|
4929
|
+
const PBR2_HAS_IRIDESCENCE_THICKNESS_MAP = 1 << 19;
|
|
4930
|
+
const PBR2_HAS_DISPERSION = 1 << 20;
|
|
4931
|
+
let _pbrExts = null;
|
|
4932
|
+
let _pbrExtsSorted = null;
|
|
4933
|
+
function _registerPbrExt(ext) {
|
|
4934
|
+
(_pbrExts ?? (_pbrExts = /* @__PURE__ */ new Map())).set(ext.id, ext);
|
|
4935
|
+
_pbrExtsSorted = null;
|
|
4936
|
+
}
|
|
4937
|
+
function _getPbrExts() {
|
|
4938
|
+
return _pbrExts ?? (_pbrExts = /* @__PURE__ */ new Map());
|
|
4939
|
+
}
|
|
4940
|
+
function _getPbrExtsSorted() {
|
|
4941
|
+
if (!_pbrExtsSorted) {
|
|
4942
|
+
const map = _pbrExts;
|
|
4943
|
+
_pbrExtsSorted = map ? Array.from(map.values()).sort((a, b) => a.id.localeCompare(b.id)) : [];
|
|
4944
|
+
}
|
|
4945
|
+
return _pbrExtsSorted;
|
|
4946
|
+
}
|
|
4947
|
+
const CLUSTERED_LIGHT_STRUCTS = `
|
|
4948
|
+
struct clusteredLightParamsUniforms {
|
|
4949
|
+
tileCountX: u32,
|
|
4950
|
+
tileCountY: u32,
|
|
4951
|
+
zSlices: u32,
|
|
4952
|
+
lightCount: u32,
|
|
4953
|
+
sliceScale: f32,
|
|
4954
|
+
sliceBias: f32,
|
|
4955
|
+
dataTextureWidth: u32,
|
|
4956
|
+
batchCount: u32,
|
|
4957
|
+
};
|
|
4958
|
+
fn clusteredTexel(index:u32)->vec2<u32>{return vec2<u32>(index%clusteredLightParams.dataTextureWidth,index/clusteredLightParams.dataTextureWidth);}
|
|
4959
|
+
`;
|
|
4960
|
+
const CLUSTERED_LIGHT_BLOCK = `
|
|
4961
|
+
{
|
|
4962
|
+
let clip=scene.viewProjection*vec4<f32>(input.worldPos,1.0);
|
|
4963
|
+
let ndc=clip.xyz/clip.w;
|
|
4964
|
+
let tx=clamp(u32((ndc.x*0.5+0.5)*f32(clusteredLightParams.tileCountX)),0u,clusteredLightParams.tileCountX-1u);
|
|
4965
|
+
let ty=clamp(u32((0.5-ndc.y*0.5)*f32(clusteredLightParams.tileCountY)),0u,clusteredLightParams.tileCountY-1u);
|
|
4966
|
+
let viewPos=scene.view*vec4<f32>(input.worldPos,1.0);
|
|
4967
|
+
let tzi=clamp(i32(log(max(viewPos.z,0.0001))*clusteredLightParams.sliceScale+clusteredLightParams.sliceBias),0,i32(clusteredLightParams.zSlices)-1);
|
|
4968
|
+
let slice=textureLoad(clusteredCells,clusteredTexel(u32(tzi)),0);
|
|
4969
|
+
let directRoughnessCluster=max(roughness,AA_factor_x);
|
|
4970
|
+
let directAlphaGCluster=directRoughnessCluster*directRoughnessCluster+0.0005;
|
|
4971
|
+
if(slice.x<=slice.y){
|
|
4972
|
+
let firstLight=slice.x;
|
|
4973
|
+
let lastLight=min(slice.y,clusteredLightParams.lightCount-1u);
|
|
4974
|
+
let firstBatch=firstLight/32u;
|
|
4975
|
+
let lastBatch=lastLight/32u;
|
|
4976
|
+
for(var batch=firstBatch;batch<=lastBatch;batch++){
|
|
4977
|
+
let batchOffset=batch*32u;
|
|
4978
|
+
let tileMaskIndex=(tx*clusteredLightParams.tileCountY+ty)*clusteredLightParams.batchCount+batch;
|
|
4979
|
+
var mask=textureLoad(clusteredIndices,clusteredTexel(tileMaskIndex),0).x;
|
|
4980
|
+
let maskOffset=max(firstLight,batchOffset)-batchOffset;
|
|
4981
|
+
let maskWidth=min(lastLight-batchOffset+1u,32u);
|
|
4982
|
+
mask=extractBits(mask,maskOffset,maskWidth);
|
|
4983
|
+
while(mask!=0u){
|
|
4984
|
+
let trailing=firstTrailingBit(mask);
|
|
4985
|
+
mask^=1u<<trailing;
|
|
4986
|
+
let li=batchOffset+maskOffset+trailing;
|
|
4987
|
+
let lightTexel=li*2u;
|
|
4988
|
+
let positionRange=textureLoad(clusteredLights,clusteredTexel(lightTexel),0);
|
|
4989
|
+
let colorIntensity=textureLoad(clusteredLights,clusteredTexel(lightTexel+1u),0);
|
|
4990
|
+
let toLight=positionRange.xyz-input.worldPos;
|
|
4991
|
+
let d2=dot(toLight,toLight);
|
|
4992
|
+
let dist=sqrt(d2);
|
|
4993
|
+
let range=max(positionRange.w,0.0001);
|
|
4994
|
+
if(dist<range){
|
|
4995
|
+
let Lc=toLight/max(dist,0.0001);
|
|
4996
|
+
let NdotLc=max(dot(N,Lc),0.0);
|
|
4997
|
+
let range2=max(range*range,0.0000001);
|
|
4998
|
+
let falloffFactor=d2/range2;
|
|
4999
|
+
var rangeAtt=1.0/max(d2,0.0000001);
|
|
5000
|
+
var smoothRange=saturate(1.0-falloffFactor*falloffFactor);
|
|
5001
|
+
smoothRange*=smoothRange;
|
|
5002
|
+
rangeAtt*=smoothRange;
|
|
5003
|
+
let lightRadiance=colorIntensity.rgb*colorIntensity.a*rangeAtt*material.directIntensity;
|
|
5004
|
+
directDiffuse+=surfaceAlbedo*(1.0/PI)*NdotLc*lightRadiance;
|
|
5005
|
+
if(NdotLc>0.0){
|
|
5006
|
+
let Hc=normalize(V+Lc);
|
|
5007
|
+
let NdotHc=clamp(dot(N,Hc),0.0000001,1.0);
|
|
5008
|
+
let VdotHc=saturate(dot(V,Hc));
|
|
5009
|
+
let Dc=distributionGGX(NdotHc,directAlphaGCluster);
|
|
5010
|
+
let Gc=geometrySmithGGX(NdotLc,NdotV,directAlphaGCluster);
|
|
5011
|
+
let Fc=fresnelSchlick(VdotHc,colorF0,colorF90);
|
|
5012
|
+
directSpecular+=Fc*Dc*Gc*NdotLc*lightRadiance;
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
`;
|
|
5020
|
+
const PBR2_HAS_CLUSTERED_LIGHTS = 1 << 17;
|
|
5021
|
+
const MAX_DATA_TEXTURE_WIDTH = 8192;
|
|
5022
|
+
const CLUSTER_BATCH_SIZE = 32;
|
|
5023
|
+
const EMPTY_SLICE_FIRST = 4294967295;
|
|
5024
|
+
function createClusteredLightContainer(options) {
|
|
5025
|
+
return {
|
|
5026
|
+
kind: "clusteredLightContainer",
|
|
5027
|
+
pointLights: [],
|
|
5028
|
+
horizontalTiles: (options == null ? void 0 : options.horizontalTiles) ?? 64,
|
|
5029
|
+
verticalTiles: (options == null ? void 0 : options.verticalTiles) ?? 64,
|
|
5030
|
+
zSlices: (options == null ? void 0 : options.zSlices) ?? 16,
|
|
5031
|
+
_version: 0
|
|
5032
|
+
};
|
|
5033
|
+
}
|
|
5034
|
+
function createClusteredPointLight(container, options) {
|
|
5035
|
+
const light = {
|
|
5036
|
+
position: options.position,
|
|
5037
|
+
diffuse: options.diffuse,
|
|
5038
|
+
range: options.range ?? 1,
|
|
5039
|
+
intensity: options.intensity ?? 1
|
|
5040
|
+
};
|
|
5041
|
+
container.pointLights.push(light);
|
|
5042
|
+
container._version++;
|
|
5043
|
+
return light;
|
|
5044
|
+
}
|
|
5045
|
+
function markClusteredLightContainerDirty(container) {
|
|
5046
|
+
container._version++;
|
|
5047
|
+
}
|
|
5048
|
+
function addClusteredLightContainer(scene, container) {
|
|
5049
|
+
const ctx = scene;
|
|
5050
|
+
ctx._clusteredLightContainer = container;
|
|
5051
|
+
_registerPbrExt(clusteredPbrExt);
|
|
5052
|
+
const state = buildClusteredLightGpuState(ctx.engine, ctx, container);
|
|
5053
|
+
ctx._clusteredLightUpdater = (camera, targetWidth, targetHeight) => state.refresh(camera, targetWidth, targetHeight);
|
|
5054
|
+
ctx._disposables.push(() => state.dispose());
|
|
5055
|
+
for (const mesh of ctx.meshes) {
|
|
5056
|
+
if (mesh.material) {
|
|
5057
|
+
const mat = mesh.material;
|
|
5058
|
+
mat._clusteredLightState = state;
|
|
5059
|
+
mat._renderFeatures = void 0;
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
const clusteredPbrExt = {
|
|
5064
|
+
id: "clustered-lights",
|
|
5065
|
+
phase: "fragment",
|
|
5066
|
+
detect(mat) {
|
|
5067
|
+
return mat._clusteredLightState ? { f: 0, f2: PBR2_HAS_CLUSTERED_LIGHTS } : { f: 0, f2: 0 };
|
|
5068
|
+
},
|
|
5069
|
+
frag(ctx) {
|
|
5070
|
+
if ((ctx._features2 & PBR2_HAS_CLUSTERED_LIGHTS) === 0) {
|
|
5071
|
+
return null;
|
|
5072
|
+
}
|
|
5073
|
+
return {
|
|
5074
|
+
_id: "clustered-lights",
|
|
5075
|
+
_bindings: [
|
|
5076
|
+
{ _name: "clusteredLightParams", _type: { _kind: "uniform-buffer" }, _visibility: GPUShaderStage.FRAGMENT },
|
|
5077
|
+
{ _name: "clusteredLights", _type: { _kind: "texture", _textureType: "texture_2d<f32>", _sampleType: "unfilterable-float" }, _visibility: GPUShaderStage.FRAGMENT },
|
|
5078
|
+
{ _name: "clusteredCells", _type: { _kind: "texture", _textureType: "texture_2d<u32>" }, _visibility: GPUShaderStage.FRAGMENT },
|
|
5079
|
+
{ _name: "clusteredIndices", _type: { _kind: "texture", _textureType: "texture_2d<u32>" }, _visibility: GPUShaderStage.FRAGMENT }
|
|
5080
|
+
],
|
|
5081
|
+
_helperFunctions: CLUSTERED_LIGHT_STRUCTS,
|
|
5082
|
+
_fragmentSlots: { AD: CLUSTERED_LIGHT_BLOCK, BL: CLUSTERED_LIGHT_BLOCK }
|
|
5083
|
+
};
|
|
5084
|
+
},
|
|
5085
|
+
bind(ctx, entries, b) {
|
|
5086
|
+
const state = ctx._material._clusteredLightState;
|
|
5087
|
+
if (!state) {
|
|
5088
|
+
return b;
|
|
5089
|
+
}
|
|
5090
|
+
entries.push({ binding: b++, resource: { buffer: state.paramsBuffer } });
|
|
5091
|
+
entries.push({ binding: b++, resource: state.lightsView });
|
|
5092
|
+
entries.push({ binding: b++, resource: state.cellsView });
|
|
5093
|
+
entries.push({ binding: b++, resource: state.indicesView });
|
|
5094
|
+
return b;
|
|
5095
|
+
}
|
|
5096
|
+
};
|
|
5097
|
+
function buildClusteredLightGpuState(engine, scene, container) {
|
|
5098
|
+
const camera = scene.camera;
|
|
5099
|
+
if (!camera) {
|
|
5100
|
+
throw new Error("buildClusteredLightGpuState: scene.camera is required");
|
|
5101
|
+
}
|
|
5102
|
+
const width = Math.max(1, engine.canvas.width);
|
|
5103
|
+
const height = Math.max(1, engine.canvas.height);
|
|
5104
|
+
const tileCountX = Math.max(1, container.horizontalTiles | 0);
|
|
5105
|
+
const tileCountY = Math.max(1, container.verticalTiles | 0);
|
|
5106
|
+
const zSlices = Math.max(1, container.zSlices | 0);
|
|
5107
|
+
const dataTextureWidth = Math.max(1, Math.min(MAX_DATA_TEXTURE_WIDTH, engine._device.limits.maxTextureDimension2D));
|
|
5108
|
+
const batchCount = Math.max(1, Math.ceil(container.pointLights.length / CLUSTER_BATCH_SIZE));
|
|
5109
|
+
const lightTexels = Math.max(1, container.pointLights.length * 2);
|
|
5110
|
+
const lightData = new Float32Array(textureElementCount(lightTexels, 4, dataTextureWidth));
|
|
5111
|
+
const sliceData = new Uint32Array(textureElementCount(zSlices, 4, dataTextureWidth));
|
|
5112
|
+
const maskTexels = Math.max(1, tileCountX * tileCountY * batchCount);
|
|
5113
|
+
const maskData = new Uint32Array(textureElementCount(maskTexels, 1, dataTextureWidth));
|
|
5114
|
+
const params = new ArrayBuffer(32);
|
|
5115
|
+
const paramsU = new Uint32Array(params);
|
|
5116
|
+
const paramsF = new Float32Array(params);
|
|
5117
|
+
paramsU[0] = tileCountX;
|
|
5118
|
+
paramsU[1] = tileCountY;
|
|
5119
|
+
paramsU[2] = zSlices;
|
|
5120
|
+
paramsU[3] = container.pointLights.length;
|
|
5121
|
+
paramsF[4] = camera.nearPlane;
|
|
5122
|
+
paramsF[5] = camera.farPlane;
|
|
5123
|
+
paramsU[6] = dataTextureWidth;
|
|
5124
|
+
paramsU[7] = batchCount;
|
|
5125
|
+
const paramsBuffer = createUniformBuffer$1(engine, paramsF, "clustered-light-params");
|
|
5126
|
+
const lightsTexture = createDataTexture(engine, lightData, "rgba32float", 4, lightTexels, "clustered-light-data", dataTextureWidth);
|
|
5127
|
+
const cellsTexture = createDataTexture(engine, sliceData, "rgba32uint", 4, zSlices, "clustered-slice-data", dataTextureWidth);
|
|
5128
|
+
const indicesTexture = createDataTexture(engine, maskData, "r32uint", 1, maskTexels, "clustered-tile-mask-data", dataTextureWidth);
|
|
5129
|
+
let lastCamera;
|
|
5130
|
+
let lastCameraVersion = -1;
|
|
5131
|
+
let lastTargetWidth = 0;
|
|
5132
|
+
let lastTargetHeight = 0;
|
|
5133
|
+
let lastContainerVersion = -1;
|
|
5134
|
+
const state = {
|
|
5135
|
+
paramsBuffer,
|
|
5136
|
+
lightsView: lightsTexture.createView(),
|
|
5137
|
+
cellsView: cellsTexture.createView(),
|
|
5138
|
+
indicesView: indicesTexture.createView(),
|
|
5139
|
+
refresh(activeCamera, targetWidth, targetHeight) {
|
|
5140
|
+
if (!activeCamera) {
|
|
5141
|
+
return;
|
|
5142
|
+
}
|
|
5143
|
+
const safeWidth = Math.max(1, targetWidth);
|
|
5144
|
+
const safeHeight = Math.max(1, targetHeight);
|
|
5145
|
+
if (activeCamera === lastCamera && activeCamera.worldMatrixVersion === lastCameraVersion && safeWidth === lastTargetWidth && safeHeight === lastTargetHeight && container._version === lastContainerVersion) {
|
|
5146
|
+
return;
|
|
5147
|
+
}
|
|
5148
|
+
if (container.pointLights.length * 2 > lightTexels || Math.ceil(container.pointLights.length / CLUSTER_BATCH_SIZE) > batchCount) {
|
|
5149
|
+
throw new Error("ClusteredLightContainer: light count cannot grow after GPU state creation.");
|
|
5150
|
+
}
|
|
5151
|
+
sliceData.fill(0);
|
|
5152
|
+
maskData.fill(0);
|
|
5153
|
+
const aspect = safeWidth / safeHeight;
|
|
5154
|
+
const view = getViewMatrix(activeCamera);
|
|
5155
|
+
const proj = getProjectionMatrix(activeCamera, aspect);
|
|
5156
|
+
const nearZ = activeCamera.nearPlane;
|
|
5157
|
+
const farZ = activeCamera.farPlane;
|
|
5158
|
+
const logFarNear = Math.log(farZ / nearZ);
|
|
5159
|
+
const sliceScale = zSlices / logFarNear;
|
|
5160
|
+
const sliceBias = -(zSlices * Math.log(nearZ)) / logFarNear;
|
|
5161
|
+
const sortedLights = container.pointLights.map((light) => ({ light, depth: viewZ(light.position, view) })).sort((a, b) => a.depth - b.depth);
|
|
5162
|
+
for (let i = 0; i < zSlices; i++) {
|
|
5163
|
+
const off = i * 4;
|
|
5164
|
+
sliceData[off] = EMPTY_SLICE_FIRST;
|
|
5165
|
+
sliceData[off + 1] = 0;
|
|
5166
|
+
}
|
|
5167
|
+
for (let i = 0; i < sortedLights.length; i++) {
|
|
5168
|
+
const { light, depth } = sortedLights[i];
|
|
5169
|
+
const off = i * 8;
|
|
5170
|
+
lightData[off] = light.position[0];
|
|
5171
|
+
lightData[off + 1] = light.position[1];
|
|
5172
|
+
lightData[off + 2] = light.position[2];
|
|
5173
|
+
lightData[off + 3] = light.range;
|
|
5174
|
+
lightData[off + 4] = light.diffuse[0];
|
|
5175
|
+
lightData[off + 5] = light.diffuse[1];
|
|
5176
|
+
lightData[off + 6] = light.diffuse[2];
|
|
5177
|
+
lightData[off + 7] = light.intensity;
|
|
5178
|
+
addLightToClusters(sliceData, maskData, light, depth, i, view, proj, tileCountX, tileCountY, zSlices, sliceScale, sliceBias, batchCount);
|
|
5179
|
+
}
|
|
5180
|
+
paramsU[0] = tileCountX;
|
|
5181
|
+
paramsU[1] = tileCountY;
|
|
5182
|
+
paramsU[2] = zSlices;
|
|
5183
|
+
paramsU[3] = sortedLights.length;
|
|
5184
|
+
paramsF[4] = sliceScale;
|
|
5185
|
+
paramsF[5] = sliceBias;
|
|
5186
|
+
paramsU[7] = batchCount;
|
|
5187
|
+
engine._device.queue.writeBuffer(paramsBuffer, 0, paramsF);
|
|
5188
|
+
writeDataTexture(engine, lightsTexture, lightData, 4, lightTexels, dataTextureWidth);
|
|
5189
|
+
writeDataTexture(engine, cellsTexture, sliceData, 4, zSlices, dataTextureWidth);
|
|
5190
|
+
writeDataTexture(engine, indicesTexture, maskData, 1, maskTexels, dataTextureWidth);
|
|
5191
|
+
lastCamera = activeCamera;
|
|
5192
|
+
lastCameraVersion = activeCamera.worldMatrixVersion;
|
|
5193
|
+
lastTargetWidth = safeWidth;
|
|
5194
|
+
lastTargetHeight = safeHeight;
|
|
5195
|
+
lastContainerVersion = container._version;
|
|
5196
|
+
},
|
|
5197
|
+
dispose() {
|
|
5198
|
+
paramsBuffer.destroy();
|
|
5199
|
+
lightsTexture.destroy();
|
|
5200
|
+
cellsTexture.destroy();
|
|
5201
|
+
indicesTexture.destroy();
|
|
5202
|
+
}
|
|
5203
|
+
};
|
|
5204
|
+
state.refresh(camera, width, height);
|
|
5205
|
+
return state;
|
|
5206
|
+
}
|
|
5207
|
+
function textureElementCount(texels, components, dataTextureWidth) {
|
|
5208
|
+
return dataTextureWidth * Math.max(1, Math.ceil(texels / dataTextureWidth)) * components;
|
|
5209
|
+
}
|
|
5210
|
+
function createDataTexture(engine, data, format, components, texels, label, dataTextureWidth) {
|
|
5211
|
+
const height = Math.max(1, Math.ceil(texels / dataTextureWidth));
|
|
5212
|
+
const texture = engine._device.createTexture({
|
|
5213
|
+
label,
|
|
5214
|
+
size: { width: dataTextureWidth, height },
|
|
5215
|
+
format,
|
|
5216
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
5217
|
+
});
|
|
5218
|
+
writeDataTexture(engine, texture, data, components, texels, dataTextureWidth);
|
|
5219
|
+
return texture;
|
|
5220
|
+
}
|
|
5221
|
+
function writeDataTexture(engine, texture, data, components, texels, dataTextureWidth) {
|
|
5222
|
+
const height = Math.max(1, Math.ceil(texels / dataTextureWidth));
|
|
5223
|
+
engine._device.queue.writeTexture({ texture }, data.buffer, { bytesPerRow: dataTextureWidth * components * 4, rowsPerImage: height }, { width: dataTextureWidth, height });
|
|
5224
|
+
}
|
|
5225
|
+
function addLightToClusters(sliceData, maskData, light, viewDepth, lightIndex, view, proj, tileCountX, tileCountY, zSlices, sliceScale, sliceBias, batchCount) {
|
|
5226
|
+
const vx = view[0] * light.position[0] + view[4] * light.position[1] + view[8] * light.position[2] + view[12];
|
|
5227
|
+
const vy = view[1] * light.position[0] + view[5] * light.position[1] + view[9] * light.position[2] + view[13];
|
|
5228
|
+
const vz = viewDepth;
|
|
5229
|
+
const range = Math.max(0, light.range);
|
|
5230
|
+
const firstSlice = getSliceIndex(vz - range, sliceScale, sliceBias);
|
|
5231
|
+
const lastSlice = getSliceIndex(vz + range, sliceScale, sliceBias);
|
|
5232
|
+
if (lastSlice < 0 || firstSlice >= zSlices) {
|
|
5233
|
+
return;
|
|
5234
|
+
}
|
|
5235
|
+
const bounds = projectedSphereBounds(vx, vy, vz, range, proj, tileCountX, tileCountY);
|
|
5236
|
+
const minX = bounds[0];
|
|
5237
|
+
const maxX = bounds[1];
|
|
5238
|
+
const minY = bounds[2];
|
|
5239
|
+
const maxY = bounds[3];
|
|
5240
|
+
const z0 = clampInt(firstSlice, 0, zSlices - 1);
|
|
5241
|
+
const z1 = clampInt(lastSlice, 0, zSlices - 1);
|
|
5242
|
+
for (let z = z0; z <= z1; z++) {
|
|
5243
|
+
const off = z * 4;
|
|
5244
|
+
sliceData[off] = Math.min(sliceData[off], lightIndex);
|
|
5245
|
+
sliceData[off + 1] = Math.max(sliceData[off + 1], lightIndex);
|
|
5246
|
+
}
|
|
5247
|
+
const batch = Math.floor(lightIndex / CLUSTER_BATCH_SIZE);
|
|
5248
|
+
const bit = 1 << lightIndex % CLUSTER_BATCH_SIZE;
|
|
5249
|
+
for (let y = minY; y <= maxY; y++) {
|
|
5250
|
+
for (let x = minX; x <= maxX; x++) {
|
|
5251
|
+
const maskIndex = (x * tileCountY + y) * batchCount + batch;
|
|
5252
|
+
maskData[maskIndex] = maskData[maskIndex] | bit;
|
|
5253
|
+
}
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
function viewZ(position, view) {
|
|
5257
|
+
return view[2] * position[0] + view[6] * position[1] + view[10] * position[2] + view[14];
|
|
5258
|
+
}
|
|
5259
|
+
function getSliceIndex(depth, sliceScale, sliceBias) {
|
|
5260
|
+
return depth > 0 ? Math.floor(Math.log(depth) * sliceScale + sliceBias) : -1;
|
|
5261
|
+
}
|
|
5262
|
+
function clampInt(v, min, max) {
|
|
5263
|
+
return v < min ? min : v > max ? max : v;
|
|
5264
|
+
}
|
|
5265
|
+
function projectedSphereBounds(vx, vy, vz, range, proj, tileCountX, tileCountY) {
|
|
5266
|
+
const rangeSq = range * range;
|
|
5267
|
+
let minNdcX = -1;
|
|
5268
|
+
let maxNdcX = 1;
|
|
5269
|
+
let minNdcY = -1;
|
|
5270
|
+
let maxNdcY = 1;
|
|
5271
|
+
if (vz > range) {
|
|
5272
|
+
const x0 = projectedSphereEdge(vx, vz, rangeSq, proj[0], -1);
|
|
5273
|
+
const x1 = projectedSphereEdge(vx, vz, rangeSq, proj[0], 1);
|
|
5274
|
+
minNdcX = Math.min(x0, x1);
|
|
5275
|
+
maxNdcX = Math.max(x0, x1);
|
|
5276
|
+
const y0 = projectedSphereEdge(vy, vz, rangeSq, proj[5], -1);
|
|
5277
|
+
const y1 = projectedSphereEdge(vy, vz, rangeSq, proj[5], 1);
|
|
5278
|
+
minNdcY = Math.min(y0, y1);
|
|
5279
|
+
maxNdcY = Math.max(y0, y1);
|
|
5280
|
+
}
|
|
5281
|
+
return [
|
|
5282
|
+
clampInt(Math.floor((minNdcX * 0.5 + 0.5) * tileCountX) - 1, 0, tileCountX - 1),
|
|
5283
|
+
clampInt(Math.floor((maxNdcX * 0.5 + 0.5) * tileCountX) + 1, 0, tileCountX - 1),
|
|
5284
|
+
clampInt(Math.floor((0.5 - maxNdcY * 0.5) * tileCountY) - 1, 0, tileCountY - 1),
|
|
5285
|
+
clampInt(Math.floor((0.5 - minNdcY * 0.5) * tileCountY) + 1, 0, tileCountY - 1)
|
|
5286
|
+
];
|
|
5287
|
+
}
|
|
5288
|
+
function projectedSphereEdge(axis, depth, rangeSq, projectionScale, side) {
|
|
5289
|
+
const distSq = axis * axis + depth * depth;
|
|
5290
|
+
if (distSq <= rangeSq) {
|
|
5291
|
+
return side;
|
|
5292
|
+
}
|
|
5293
|
+
const sinSq = rangeSq / distSq;
|
|
5294
|
+
const cosSq = Math.max(1 - sinSq, 0.01);
|
|
5295
|
+
const sinCos = side * Math.sqrt(sinSq * cosSq);
|
|
5296
|
+
const rotatedAxis = cosSq * axis + sinCos * depth;
|
|
5297
|
+
const rotatedDepth = -sinCos * axis + cosSq * depth;
|
|
5298
|
+
return projectionScale * rotatedAxis / Math.max(rotatedDepth, 0.01);
|
|
5299
|
+
}
|
|
4156
5300
|
function mat4ComposeInto(dst, off, tx, ty, tz, qx, qy, qz, qw, sx, sy, sz) {
|
|
4157
5301
|
const xx = qx * qx, yy = qy * qy, zz = qz * qz;
|
|
4158
5302
|
const xy = qx * qy, xz = qx * qz, yz = qy * qz;
|
|
@@ -4186,18 +5330,26 @@ class ObservableQuat {
|
|
|
4186
5330
|
__publicField(this, "_z");
|
|
4187
5331
|
__publicField(this, "_w");
|
|
4188
5332
|
__publicField(this, "_onDirty");
|
|
5333
|
+
/** Bumped on every value change. Lets derived caches (e.g. the Euler proxy) detect
|
|
5334
|
+
* external quaternion writes and re-sync only when needed. */
|
|
5335
|
+
__publicField(this, "_version", 0);
|
|
4189
5336
|
this._x = x;
|
|
4190
5337
|
this._y = y;
|
|
4191
5338
|
this._z = z;
|
|
4192
5339
|
this._w = w;
|
|
4193
5340
|
this._onDirty = onDirty;
|
|
4194
5341
|
}
|
|
5342
|
+
/** Monotonic change counter — incremented whenever any component changes. */
|
|
5343
|
+
get version() {
|
|
5344
|
+
return this._version;
|
|
5345
|
+
}
|
|
4195
5346
|
get x() {
|
|
4196
5347
|
return this._x;
|
|
4197
5348
|
}
|
|
4198
5349
|
set x(v) {
|
|
4199
5350
|
if (this._x !== v) {
|
|
4200
5351
|
this._x = v;
|
|
5352
|
+
this._version++;
|
|
4201
5353
|
this._onDirty();
|
|
4202
5354
|
}
|
|
4203
5355
|
}
|
|
@@ -4207,6 +5359,7 @@ class ObservableQuat {
|
|
|
4207
5359
|
set y(v) {
|
|
4208
5360
|
if (this._y !== v) {
|
|
4209
5361
|
this._y = v;
|
|
5362
|
+
this._version++;
|
|
4210
5363
|
this._onDirty();
|
|
4211
5364
|
}
|
|
4212
5365
|
}
|
|
@@ -4216,6 +5369,7 @@ class ObservableQuat {
|
|
|
4216
5369
|
set z(v) {
|
|
4217
5370
|
if (this._z !== v) {
|
|
4218
5371
|
this._z = v;
|
|
5372
|
+
this._version++;
|
|
4219
5373
|
this._onDirty();
|
|
4220
5374
|
}
|
|
4221
5375
|
}
|
|
@@ -4225,6 +5379,7 @@ class ObservableQuat {
|
|
|
4225
5379
|
set w(v) {
|
|
4226
5380
|
if (this._w !== v) {
|
|
4227
5381
|
this._w = v;
|
|
5382
|
+
this._version++;
|
|
4228
5383
|
this._onDirty();
|
|
4229
5384
|
}
|
|
4230
5385
|
}
|
|
@@ -4234,6 +5389,7 @@ class ObservableQuat {
|
|
|
4234
5389
|
this._y = y;
|
|
4235
5390
|
this._z = z;
|
|
4236
5391
|
this._w = w;
|
|
5392
|
+
this._version++;
|
|
4237
5393
|
this._onDirty();
|
|
4238
5394
|
}
|
|
4239
5395
|
/** Copy values from another quaternion. */
|
|
@@ -4262,34 +5418,53 @@ function quatToEulerXYZ(qx, qy, qz, qw) {
|
|
|
4262
5418
|
return [rx, ry, rz];
|
|
4263
5419
|
}
|
|
4264
5420
|
function createEulerProxy(rq) {
|
|
4265
|
-
|
|
4266
|
-
|
|
5421
|
+
let ex = 0;
|
|
5422
|
+
let ey = 0;
|
|
5423
|
+
let ez = 0;
|
|
5424
|
+
let syncedVersion = -1;
|
|
5425
|
+
const sync = () => {
|
|
5426
|
+
if (rq.version !== syncedVersion) {
|
|
5427
|
+
const e = quatToEulerXYZ(rq.x, rq.y, rq.z, rq.w);
|
|
5428
|
+
ex = e[0];
|
|
5429
|
+
ey = e[1];
|
|
5430
|
+
ez = e[2];
|
|
5431
|
+
syncedVersion = rq.version;
|
|
5432
|
+
}
|
|
5433
|
+
};
|
|
5434
|
+
const apply = (x, y, z) => {
|
|
5435
|
+
ex = x;
|
|
5436
|
+
ey = y;
|
|
5437
|
+
ez = z;
|
|
4267
5438
|
const [a, b, c, d] = eulerToQuat(x, y, z);
|
|
4268
5439
|
rq.set(a, b, c, d);
|
|
5440
|
+
syncedVersion = rq.version;
|
|
4269
5441
|
};
|
|
4270
5442
|
return {
|
|
4271
5443
|
get x() {
|
|
4272
|
-
|
|
5444
|
+
sync();
|
|
5445
|
+
return ex;
|
|
4273
5446
|
},
|
|
4274
5447
|
set x(v) {
|
|
4275
|
-
|
|
4276
|
-
|
|
5448
|
+
sync();
|
|
5449
|
+
apply(v, ey, ez);
|
|
4277
5450
|
},
|
|
4278
5451
|
get y() {
|
|
4279
|
-
|
|
5452
|
+
sync();
|
|
5453
|
+
return ey;
|
|
4280
5454
|
},
|
|
4281
5455
|
set y(v) {
|
|
4282
|
-
|
|
4283
|
-
|
|
5456
|
+
sync();
|
|
5457
|
+
apply(ex, v, ez);
|
|
4284
5458
|
},
|
|
4285
5459
|
get z() {
|
|
4286
|
-
|
|
5460
|
+
sync();
|
|
5461
|
+
return ez;
|
|
4287
5462
|
},
|
|
4288
5463
|
set z(v) {
|
|
4289
|
-
|
|
4290
|
-
|
|
5464
|
+
sync();
|
|
5465
|
+
apply(ex, ey, v);
|
|
4291
5466
|
},
|
|
4292
|
-
set:
|
|
5467
|
+
set: apply
|
|
4293
5468
|
};
|
|
4294
5469
|
}
|
|
4295
5470
|
function createSceneNode(name, px = 0, py = 0, pz = 0, qx = 0, qy = 0, qz = 0, qw = 1, sx = 1, sy = 1, sz = 1) {
|
|
@@ -4867,6 +6042,150 @@ function createTorusData(opts = {}) {
|
|
|
4867
6042
|
}
|
|
4868
6043
|
return { positions, normals, uvs, indices };
|
|
4869
6044
|
}
|
|
6045
|
+
function computeNormals(positions, indices) {
|
|
6046
|
+
const n = positions.length;
|
|
6047
|
+
const pos = new Float64Array(n);
|
|
6048
|
+
for (let i = 0; i < n; i++) {
|
|
6049
|
+
pos[i] = positions[i];
|
|
6050
|
+
}
|
|
6051
|
+
const idx = new Uint32Array(indices.length);
|
|
6052
|
+
for (let i = 0; i < indices.length; i++) {
|
|
6053
|
+
idx[i] = indices[i];
|
|
6054
|
+
}
|
|
6055
|
+
const normals = new Float64Array(n);
|
|
6056
|
+
const nbFaces = indices.length / 3 | 0;
|
|
6057
|
+
for (let f = 0; f < nbFaces; f++) {
|
|
6058
|
+
const v1x = idx[f * 3] * 3;
|
|
6059
|
+
const v2x = idx[f * 3 + 1] * 3;
|
|
6060
|
+
const v3x = idx[f * 3 + 2] * 3;
|
|
6061
|
+
const p1p2x = pos[v1x] - pos[v2x];
|
|
6062
|
+
const p1p2y = pos[v1x + 1] - pos[v2x + 1];
|
|
6063
|
+
const p1p2z = pos[v1x + 2] - pos[v2x + 2];
|
|
6064
|
+
const p3p2x = pos[v3x] - pos[v2x];
|
|
6065
|
+
const p3p2y = pos[v3x + 1] - pos[v2x + 1];
|
|
6066
|
+
const p3p2z = pos[v3x + 2] - pos[v2x + 2];
|
|
6067
|
+
let nx = p1p2y * p3p2z - p1p2z * p3p2y;
|
|
6068
|
+
let ny = p1p2z * p3p2x - p1p2x * p3p2z;
|
|
6069
|
+
let nz = p1p2x * p3p2y - p1p2y * p3p2x;
|
|
6070
|
+
let len2 = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
6071
|
+
if (len2 === 0) {
|
|
6072
|
+
len2 = 1;
|
|
6073
|
+
}
|
|
6074
|
+
nx /= len2;
|
|
6075
|
+
ny /= len2;
|
|
6076
|
+
nz /= len2;
|
|
6077
|
+
normals[v1x] = normals[v1x] + nx;
|
|
6078
|
+
normals[v1x + 1] = normals[v1x + 1] + ny;
|
|
6079
|
+
normals[v1x + 2] = normals[v1x + 2] + nz;
|
|
6080
|
+
normals[v2x] = normals[v2x] + nx;
|
|
6081
|
+
normals[v2x + 1] = normals[v2x + 1] + ny;
|
|
6082
|
+
normals[v2x + 2] = normals[v2x + 2] + nz;
|
|
6083
|
+
normals[v3x] = normals[v3x] + nx;
|
|
6084
|
+
normals[v3x + 1] = normals[v3x + 1] + ny;
|
|
6085
|
+
normals[v3x + 2] = normals[v3x + 2] + nz;
|
|
6086
|
+
}
|
|
6087
|
+
const nVerts = n / 3 | 0;
|
|
6088
|
+
const out = new Array(n);
|
|
6089
|
+
for (let i = 0; i < nVerts; i++) {
|
|
6090
|
+
const x = normals[i * 3];
|
|
6091
|
+
const y = normals[i * 3 + 1];
|
|
6092
|
+
const z = normals[i * 3 + 2];
|
|
6093
|
+
let len2 = Math.sqrt(x * x + y * y + z * z);
|
|
6094
|
+
if (len2 === 0) {
|
|
6095
|
+
len2 = 1;
|
|
6096
|
+
}
|
|
6097
|
+
out[i * 3] = x / len2;
|
|
6098
|
+
out[i * 3 + 1] = y / len2;
|
|
6099
|
+
out[i * 3 + 2] = z / len2;
|
|
6100
|
+
}
|
|
6101
|
+
return out;
|
|
6102
|
+
}
|
|
6103
|
+
function createTorusKnotData(opts = {}) {
|
|
6104
|
+
const radius = opts.radius ?? 2;
|
|
6105
|
+
const tube = opts.tube ?? 0.5;
|
|
6106
|
+
const radialSegments = opts.radialSegments ?? 32;
|
|
6107
|
+
const tubularSegments = opts.tubularSegments ?? 32;
|
|
6108
|
+
const p = opts.p ?? 2;
|
|
6109
|
+
const q = opts.q ?? 3;
|
|
6110
|
+
const positions = [];
|
|
6111
|
+
const uvs = [];
|
|
6112
|
+
const indices = [];
|
|
6113
|
+
const getPos = (angle) => {
|
|
6114
|
+
const cu = Math.cos(angle);
|
|
6115
|
+
const su = Math.sin(angle);
|
|
6116
|
+
const quOverP = q / p * angle;
|
|
6117
|
+
const cs = Math.cos(quOverP);
|
|
6118
|
+
const tx = radius * (2 + cs) * 0.5 * cu;
|
|
6119
|
+
const ty = radius * (2 + cs) * su * 0.5;
|
|
6120
|
+
const tz = radius * Math.sin(quOverP) * 0.5;
|
|
6121
|
+
return [tx, ty, tz];
|
|
6122
|
+
};
|
|
6123
|
+
for (let i = 0; i <= radialSegments; i++) {
|
|
6124
|
+
const modI = i % radialSegments;
|
|
6125
|
+
const u = modI / radialSegments * 2 * p * Math.PI;
|
|
6126
|
+
const p1 = getPos(u);
|
|
6127
|
+
const p2 = getPos(u + 0.01);
|
|
6128
|
+
const tangX = p2[0] - p1[0];
|
|
6129
|
+
const tangY = p2[1] - p1[1];
|
|
6130
|
+
const tangZ = p2[2] - p1[2];
|
|
6131
|
+
let nX = p2[0] + p1[0];
|
|
6132
|
+
let nY = p2[1] + p1[1];
|
|
6133
|
+
let nZ = p2[2] + p1[2];
|
|
6134
|
+
let bitanX = tangY * nZ - tangZ * nY;
|
|
6135
|
+
let bitanY = tangZ * nX - tangX * nZ;
|
|
6136
|
+
let bitanZ = tangX * nY - tangY * nX;
|
|
6137
|
+
nX = bitanY * tangZ - bitanZ * tangY;
|
|
6138
|
+
nY = bitanZ * tangX - bitanX * tangZ;
|
|
6139
|
+
nZ = bitanX * tangY - bitanY * tangX;
|
|
6140
|
+
let bitanLen = Math.sqrt(bitanX * bitanX + bitanY * bitanY + bitanZ * bitanZ);
|
|
6141
|
+
if (bitanLen === 0) {
|
|
6142
|
+
bitanLen = 1;
|
|
6143
|
+
}
|
|
6144
|
+
bitanX /= bitanLen;
|
|
6145
|
+
bitanY /= bitanLen;
|
|
6146
|
+
bitanZ /= bitanLen;
|
|
6147
|
+
let nLen = Math.sqrt(nX * nX + nY * nY + nZ * nZ);
|
|
6148
|
+
if (nLen === 0) {
|
|
6149
|
+
nLen = 1;
|
|
6150
|
+
}
|
|
6151
|
+
nX /= nLen;
|
|
6152
|
+
nY /= nLen;
|
|
6153
|
+
nZ /= nLen;
|
|
6154
|
+
for (let j = 0; j < tubularSegments; j++) {
|
|
6155
|
+
const modJ = j % tubularSegments;
|
|
6156
|
+
const v = modJ / tubularSegments * 2 * Math.PI;
|
|
6157
|
+
const cx = -tube * Math.cos(v);
|
|
6158
|
+
const cy = tube * Math.sin(v);
|
|
6159
|
+
positions.push(p1[0] + cx * nX + cy * bitanX);
|
|
6160
|
+
positions.push(p1[1] + cx * nY + cy * bitanY);
|
|
6161
|
+
positions.push(p1[2] + cx * nZ + cy * bitanZ);
|
|
6162
|
+
uvs.push(i / radialSegments);
|
|
6163
|
+
uvs.push(j / tubularSegments);
|
|
6164
|
+
}
|
|
6165
|
+
}
|
|
6166
|
+
for (let i = 0; i < radialSegments; i++) {
|
|
6167
|
+
for (let j = 0; j < tubularSegments; j++) {
|
|
6168
|
+
const jNext = (j + 1) % tubularSegments;
|
|
6169
|
+
const a = i * tubularSegments + j;
|
|
6170
|
+
const b = (i + 1) * tubularSegments + j;
|
|
6171
|
+
const c = (i + 1) * tubularSegments + jNext;
|
|
6172
|
+
const d = i * tubularSegments + jNext;
|
|
6173
|
+
indices.push(d);
|
|
6174
|
+
indices.push(b);
|
|
6175
|
+
indices.push(a);
|
|
6176
|
+
indices.push(d);
|
|
6177
|
+
indices.push(c);
|
|
6178
|
+
indices.push(b);
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
const normals = computeNormals(positions, indices);
|
|
6182
|
+
return {
|
|
6183
|
+
positions: new Float32Array(positions),
|
|
6184
|
+
normals: new Float32Array(normals),
|
|
6185
|
+
uvs: new Float32Array(uvs),
|
|
6186
|
+
indices: new Uint32Array(indices)
|
|
6187
|
+
};
|
|
6188
|
+
}
|
|
4870
6189
|
function createFlatGroundData(opts = {}) {
|
|
4871
6190
|
var _a, _b;
|
|
4872
6191
|
const width = opts.width ?? 1;
|
|
@@ -5615,64 +6934,6 @@ const POLYHEDRA = [
|
|
|
5615
6934
|
]
|
|
5616
6935
|
}
|
|
5617
6936
|
];
|
|
5618
|
-
function computeNormals(positions, indices) {
|
|
5619
|
-
const n = positions.length;
|
|
5620
|
-
const pos = new Float64Array(n);
|
|
5621
|
-
for (let i = 0; i < n; i++) {
|
|
5622
|
-
pos[i] = positions[i];
|
|
5623
|
-
}
|
|
5624
|
-
const idx = new Uint32Array(indices.length);
|
|
5625
|
-
for (let i = 0; i < indices.length; i++) {
|
|
5626
|
-
idx[i] = indices[i];
|
|
5627
|
-
}
|
|
5628
|
-
const normals = new Float64Array(n);
|
|
5629
|
-
const nbFaces = indices.length / 3 | 0;
|
|
5630
|
-
for (let f = 0; f < nbFaces; f++) {
|
|
5631
|
-
const v1x = idx[f * 3] * 3;
|
|
5632
|
-
const v2x = idx[f * 3 + 1] * 3;
|
|
5633
|
-
const v3x = idx[f * 3 + 2] * 3;
|
|
5634
|
-
const p1p2x = pos[v1x] - pos[v2x];
|
|
5635
|
-
const p1p2y = pos[v1x + 1] - pos[v2x + 1];
|
|
5636
|
-
const p1p2z = pos[v1x + 2] - pos[v2x + 2];
|
|
5637
|
-
const p3p2x = pos[v3x] - pos[v2x];
|
|
5638
|
-
const p3p2y = pos[v3x + 1] - pos[v2x + 1];
|
|
5639
|
-
const p3p2z = pos[v3x + 2] - pos[v2x + 2];
|
|
5640
|
-
let nx = p1p2y * p3p2z - p1p2z * p3p2y;
|
|
5641
|
-
let ny = p1p2z * p3p2x - p1p2x * p3p2z;
|
|
5642
|
-
let nz = p1p2x * p3p2y - p1p2y * p3p2x;
|
|
5643
|
-
let len2 = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
5644
|
-
if (len2 === 0) {
|
|
5645
|
-
len2 = 1;
|
|
5646
|
-
}
|
|
5647
|
-
nx /= len2;
|
|
5648
|
-
ny /= len2;
|
|
5649
|
-
nz /= len2;
|
|
5650
|
-
normals[v1x] = normals[v1x] + nx;
|
|
5651
|
-
normals[v1x + 1] = normals[v1x + 1] + ny;
|
|
5652
|
-
normals[v1x + 2] = normals[v1x + 2] + nz;
|
|
5653
|
-
normals[v2x] = normals[v2x] + nx;
|
|
5654
|
-
normals[v2x + 1] = normals[v2x + 1] + ny;
|
|
5655
|
-
normals[v2x + 2] = normals[v2x + 2] + nz;
|
|
5656
|
-
normals[v3x] = normals[v3x] + nx;
|
|
5657
|
-
normals[v3x + 1] = normals[v3x + 1] + ny;
|
|
5658
|
-
normals[v3x + 2] = normals[v3x + 2] + nz;
|
|
5659
|
-
}
|
|
5660
|
-
const nVerts = n / 3 | 0;
|
|
5661
|
-
const out = new Array(n);
|
|
5662
|
-
for (let i = 0; i < nVerts; i++) {
|
|
5663
|
-
const x = normals[i * 3];
|
|
5664
|
-
const y = normals[i * 3 + 1];
|
|
5665
|
-
const z = normals[i * 3 + 2];
|
|
5666
|
-
let len2 = Math.sqrt(x * x + y * y + z * z);
|
|
5667
|
-
if (len2 === 0) {
|
|
5668
|
-
len2 = 1;
|
|
5669
|
-
}
|
|
5670
|
-
out[i * 3] = x / len2;
|
|
5671
|
-
out[i * 3 + 1] = y / len2;
|
|
5672
|
-
out[i * 3 + 2] = z / len2;
|
|
5673
|
-
}
|
|
5674
|
-
return out;
|
|
5675
|
-
}
|
|
5676
6937
|
function createPolyhedronData(options = {}) {
|
|
5677
6938
|
const type = options.type !== void 0 && (options.type < 0 || options.type >= POLYHEDRA.length) ? 0 : options.type ?? 0;
|
|
5678
6939
|
const size = options.size;
|
|
@@ -6178,6 +7439,10 @@ function createTorus(engine, options) {
|
|
|
6178
7439
|
const data = createTorusData(options);
|
|
6179
7440
|
return createMeshFromData(engine, "torus", data.positions, data.normals, data.indices, data.uvs);
|
|
6180
7441
|
}
|
|
7442
|
+
function createTorusKnot(engine, options) {
|
|
7443
|
+
const data = createTorusKnotData(options);
|
|
7444
|
+
return createMeshFromData(engine, "torusKnot", data.positions, data.normals, data.indices, data.uvs);
|
|
7445
|
+
}
|
|
6181
7446
|
async function createGroundFromHeightMap(engine, url, options) {
|
|
6182
7447
|
const data = await createGroundFromHeightMap$1(url, options);
|
|
6183
7448
|
return createMeshFromData(engine, "ground", data.positions, data.normals, data.indices, data.uvs);
|
|
@@ -6214,7 +7479,8 @@ function createExtrudeShape(engine, options) {
|
|
|
6214
7479
|
const data = createExtrudeShapeData(options);
|
|
6215
7480
|
return createMeshFromData(engine, "extrude", data.positions, data.normals, data.indices, data.uvs);
|
|
6216
7481
|
}
|
|
6217
|
-
function mat4Invert(
|
|
7482
|
+
function mat4Invert(input) {
|
|
7483
|
+
const m = input;
|
|
6218
7484
|
const a00 = m[0], a01 = m[1], a02 = m[2], a03 = m[3];
|
|
6219
7485
|
const a10 = m[4], a11 = m[5], a12 = m[6], a13 = m[7];
|
|
6220
7486
|
const a20 = m[8], a21 = m[9], a22 = m[10], a23 = m[11];
|
|
@@ -6842,6 +8108,21 @@ function createTexture2DFromPixels(engine, data, width, height, options = {}) {
|
|
|
6842
8108
|
acquireTexture(tex);
|
|
6843
8109
|
return tex;
|
|
6844
8110
|
}
|
|
8111
|
+
function updateTexture2DFromPixels(engine, tex, data, x = 0, y = 0, width = tex.width, height = tex.height) {
|
|
8112
|
+
if (width < 1 || height < 1) {
|
|
8113
|
+
throw new Error(`updateTexture2DFromPixels: width/height must be >= 1 (got ${width}x${height})`);
|
|
8114
|
+
}
|
|
8115
|
+
const expected = width * height * 4;
|
|
8116
|
+
if (data.length < expected) {
|
|
8117
|
+
throw new Error(`updateTexture2DFromPixels: data too short — need ${expected} bytes for ${width}x${height} RGBA, got ${data.length}`);
|
|
8118
|
+
}
|
|
8119
|
+
engine._device.queue.writeTexture(
|
|
8120
|
+
{ texture: tex.texture, origin: { x, y } },
|
|
8121
|
+
data,
|
|
8122
|
+
{ bytesPerRow: width * 4, rowsPerImage: height },
|
|
8123
|
+
{ width, height }
|
|
8124
|
+
);
|
|
8125
|
+
}
|
|
6845
8126
|
function cloneTexture2D(base, transform) {
|
|
6846
8127
|
return { ...base, ...transform };
|
|
6847
8128
|
}
|
|
@@ -7072,7 +8353,9 @@ function uploadCompressed(engine, parsed, opts) {
|
|
|
7072
8353
|
const mip = parsed.mips[i];
|
|
7073
8354
|
const blocksPerRow = Math.ceil(mip.width / fmt.blockW);
|
|
7074
8355
|
const rowBytes = blocksPerRow * fmt.blockBytes;
|
|
7075
|
-
|
|
8356
|
+
const copyW = blocksPerRow * fmt.blockW;
|
|
8357
|
+
const copyH = Math.ceil(mip.height / fmt.blockH) * fmt.blockH;
|
|
8358
|
+
device.queue.writeTexture({ texture, mipLevel: i }, mip.data, { bytesPerRow: rowBytes }, { width: copyW, height: copyH });
|
|
7076
8359
|
}
|
|
7077
8360
|
const minF = opts.minFilter ?? "linear";
|
|
7078
8361
|
const magF = opts.magFilter ?? "linear";
|
|
@@ -7354,35 +8637,47 @@ function _getStdExtsSorted() {
|
|
|
7354
8637
|
const NEEDS_UV = HAS_DIFFUSE_TEXTURE | HAS_EMISSIVE_TEXTURE | HAS_BUMP_TEXTURE | HAS_SPECULAR_TEXTURE | HAS_AMBIENT_TEXTURE | HAS_LIGHTMAP_TEXTURE | HAS_OPACITY_TEXTURE;
|
|
7355
8638
|
const NEEDS_UV2 = LIGHTMAP_USES_UV2 | AMBIENT_USES_UV2 | DIFFUSE_USES_UV2 | SPECULAR_USES_UV2;
|
|
7356
8639
|
const _STD_MAT_EXTS = [
|
|
7357
|
-
["bumpTexture", () => import("./normal-map-fragment-
|
|
7358
|
-
["emissiveTexture", () => import("./std-emissive-fragment-
|
|
7359
|
-
["specularTexture", () => import("./std-specular-fragment-
|
|
7360
|
-
["ambientTexture", () => import("./std-ambient-fragment-
|
|
7361
|
-
["lightmapTexture", () => import("./std-lightmap-fragment-
|
|
7362
|
-
["opacityTexture", () => import("./std-opacity-fragment-
|
|
7363
|
-
["reflectionTexture", () => import("./std-reflection-fragment-
|
|
7364
|
-
["reflectionCubeTexture", () => import("./std-cube-reflection-fragment-
|
|
8640
|
+
["bumpTexture", () => import("./normal-map-fragment-DradEMl-.js"), "bumpStdExt"],
|
|
8641
|
+
["emissiveTexture", () => import("./std-emissive-fragment-B-A83rqX.js"), "stdEmissiveExt"],
|
|
8642
|
+
["specularTexture", () => import("./std-specular-fragment-C2ZOss-t.js"), "stdSpecularExt"],
|
|
8643
|
+
["ambientTexture", () => import("./std-ambient-fragment-C6WNm8dQ.js"), "stdAmbientExt"],
|
|
8644
|
+
["lightmapTexture", () => import("./std-lightmap-fragment-Df7KJezh.js"), "stdLightmapExt"],
|
|
8645
|
+
["opacityTexture", () => import("./std-opacity-fragment-D9et2jip.js"), "stdOpacityExt"],
|
|
8646
|
+
["reflectionTexture", () => import("./std-reflection-fragment-DBJeT-yg.js"), "stdReflectionExt"],
|
|
8647
|
+
["reflectionCubeTexture", () => import("./std-cube-reflection-fragment-Bqutpy2q.js"), "stdCubeReflectionExt"]
|
|
7365
8648
|
];
|
|
7366
8649
|
const standardGroupBuilder = async (scene, meshes) => {
|
|
7367
8650
|
const hasTI = meshes.some((m) => !!m.thinInstances);
|
|
8651
|
+
const hasCulling = meshes.some((m) => {
|
|
8652
|
+
var _a;
|
|
8653
|
+
return !!((_a = m.thinInstances) == null ? void 0 : _a._gpuCullingEnabled);
|
|
8654
|
+
});
|
|
7368
8655
|
const hasShadow = meshes.some((m) => m.receiveShadows) && scene.lights.some((l) => !!l.shadowGenerator);
|
|
7369
8656
|
let tiSync;
|
|
7370
8657
|
let tiFragment;
|
|
7371
8658
|
let shadowFragment;
|
|
8659
|
+
let cull;
|
|
7372
8660
|
const imports = [];
|
|
7373
8661
|
if (hasTI) {
|
|
7374
8662
|
imports.push(
|
|
7375
|
-
import("./thin-instance-gpu-
|
|
8663
|
+
import("./thin-instance-gpu-E8DBd8XL.js").then((m) => {
|
|
7376
8664
|
tiSync = m.syncThinInstanceBuffers;
|
|
7377
8665
|
}),
|
|
7378
8666
|
import("./thin-instance-fragment-hsv-RyDs.js").then((m) => {
|
|
7379
8667
|
tiFragment = m.createThinInstanceFragment;
|
|
7380
8668
|
})
|
|
7381
8669
|
);
|
|
8670
|
+
if (hasCulling) {
|
|
8671
|
+
imports.push(
|
|
8672
|
+
import("./thin-instance-cull-binding-CCxrPNO6.js").then((m) => {
|
|
8673
|
+
cull = m;
|
|
8674
|
+
})
|
|
8675
|
+
);
|
|
8676
|
+
}
|
|
7382
8677
|
}
|
|
7383
8678
|
if (hasShadow) {
|
|
7384
8679
|
imports.push(
|
|
7385
|
-
import("./std-shadow-fragment-
|
|
8680
|
+
import("./std-shadow-fragment-C6fD8rW-.js").then((m) => {
|
|
7386
8681
|
shadowFragment = m.createStdShadowFragment;
|
|
7387
8682
|
})
|
|
7388
8683
|
);
|
|
@@ -7395,12 +8690,8 @@ const standardGroupBuilder = async (scene, meshes) => {
|
|
|
7395
8690
|
if (imports.length > 0) {
|
|
7396
8691
|
await Promise.all(imports);
|
|
7397
8692
|
}
|
|
7398
|
-
const renderableMod = await import("./standard-renderable-
|
|
7399
|
-
const result = renderableMod.buildStandardMeshRenderables(scene, meshes, {
|
|
7400
|
-
tiSync,
|
|
7401
|
-
tiFragment,
|
|
7402
|
-
shadowFragment
|
|
7403
|
-
});
|
|
8693
|
+
const renderableMod = await import("./standard-renderable-D1bhoF0K.js");
|
|
8694
|
+
const result = renderableMod.buildStandardMeshRenderables(scene, meshes, { tiSync, tiFragment, shadowFragment, cull });
|
|
7404
8695
|
standardGroupBuilder._rebuildSingle = result.rebuildSingle;
|
|
7405
8696
|
return result;
|
|
7406
8697
|
};
|
|
@@ -7472,69 +8763,9 @@ const noColorView$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defin
|
|
|
7472
8763
|
__proto__: null,
|
|
7473
8764
|
createStandardNoColorMaterialView: createStandardNoColorMaterialView$1
|
|
7474
8765
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
7475
|
-
const PBR_HAS_NORMAL_MAP = 1 << 0;
|
|
7476
|
-
const PBR_HAS_EMISSIVE = 1 << 1;
|
|
7477
|
-
const PBR_HAS_ENV = 1 << 2;
|
|
7478
|
-
const PBR_HAS_ALPHA_TEST = 1 << 3;
|
|
7479
|
-
const PBR_HAS_TONEMAP = 1 << 4;
|
|
7480
|
-
const PBR_HAS_ALPHA_BLEND = 1 << 6;
|
|
7481
|
-
const PBR_HAS_SPEC_GLOSS = 1 << 7;
|
|
7482
|
-
const PBR_HAS_DOUBLE_SIDED = 1 << 8;
|
|
7483
|
-
const PBR_HAS_METALLIC_REFLECTANCE_MAP = 1 << 10;
|
|
7484
|
-
const PBR_HAS_REFLECTANCE_MAP = 1 << 11;
|
|
7485
|
-
const PBR_HAS_USE_ALPHA_ONLY_MR = 1 << 12;
|
|
7486
|
-
const PBR_HAS_OCCLUSION = 1 << 15;
|
|
7487
|
-
const PBR_HAS_SPECULAR_AA = 1 << 17;
|
|
7488
|
-
const PBR_HAS_CLEARCOAT = 1 << 20;
|
|
7489
|
-
const PBR_HAS_EMISSIVE_COLOR = 1 << 21;
|
|
7490
|
-
const PBR_HAS_SHEEN = 1 << 22;
|
|
7491
|
-
const PBR_HAS_SHEEN_TEXTURE = 1 << 23;
|
|
7492
|
-
const PBR_HAS_GAMMA_ALBEDO = 1 << 25;
|
|
7493
|
-
const PBR_HAS_ANISOTROPY = 1 << 26;
|
|
7494
|
-
const PBR_HAS_SUBSURFACE = 1 << 27;
|
|
7495
|
-
const PBR_HAS_THICKNESS_MAP = 1 << 28;
|
|
7496
|
-
const PBR_HAS_SKYBOX = 1 << 29;
|
|
7497
|
-
const PBR_HAS_SHEEN_ALBEDO_SCALING = 1 << 30;
|
|
7498
|
-
const PBR2_CC_INT_MAP = 1 << 0;
|
|
7499
|
-
const PBR2_CC_ROUGH_MAP = 1 << 1;
|
|
7500
|
-
const PBR2_CC_NORMAL_MAP = 1 << 2;
|
|
7501
|
-
const PBR2_CC_F0_REMAP_OFF = 1 << 3;
|
|
7502
|
-
const PBR2_HAS_REFRACTION = 1 << 4;
|
|
7503
|
-
const PBR2_HAS_VOLUME = 1 << 5;
|
|
7504
|
-
const PBR2_HAS_REFRACTION_MAP = 1 << 6;
|
|
7505
|
-
const PBR2_HAS_THICKNESS_GLTF_CHANNEL = 1 << 7;
|
|
7506
|
-
const PBR2_HAS_UNLIT = 1 << 8;
|
|
7507
|
-
const PBR2_HAS_UV_TRANSFORM = 1 << 9;
|
|
7508
|
-
const PBR2_HAS_REFLECTANCE_FACTORS = 1 << 10;
|
|
7509
|
-
const PBR2_HAS_UV2 = 1 << 11;
|
|
7510
|
-
const PBR2_HAS_BASE_COLOR_FACTOR = 1 << 12;
|
|
7511
|
-
const PBR2_HAS_SHEEN_UV_TX = 1 << 13;
|
|
7512
|
-
const PBR2_LINEAR_IMAGE_PROCESSING = 1 << 14;
|
|
7513
|
-
const PBR2_NO_COLOR_OUTPUT = 1 << 15;
|
|
7514
|
-
const PBR2_ESM_SHADOW_OUTPUT = 1 << 16;
|
|
7515
|
-
const PBR2_HAS_IRIDESCENCE = 1 << 17;
|
|
7516
|
-
const PBR2_HAS_IRIDESCENCE_MAP = 1 << 18;
|
|
7517
|
-
const PBR2_HAS_IRIDESCENCE_THICKNESS_MAP = 1 << 19;
|
|
7518
|
-
const PBR2_HAS_DISPERSION = 1 << 20;
|
|
7519
|
-
let _pbrExts = null;
|
|
7520
|
-
let _pbrExtsSorted = null;
|
|
7521
|
-
function _registerPbrExt(ext) {
|
|
7522
|
-
(_pbrExts ?? (_pbrExts = /* @__PURE__ */ new Map())).set(ext.id, ext);
|
|
7523
|
-
_pbrExtsSorted = null;
|
|
7524
|
-
}
|
|
7525
|
-
function _getPbrExts() {
|
|
7526
|
-
return _pbrExts ?? (_pbrExts = /* @__PURE__ */ new Map());
|
|
7527
|
-
}
|
|
7528
|
-
function _getPbrExtsSorted() {
|
|
7529
|
-
if (!_pbrExtsSorted) {
|
|
7530
|
-
const map = _pbrExts;
|
|
7531
|
-
_pbrExtsSorted = map ? Array.from(map.values()).sort((a, b) => a.id.localeCompare(b.id)) : [];
|
|
7532
|
-
}
|
|
7533
|
-
return _pbrExtsSorted;
|
|
7534
|
-
}
|
|
7535
8766
|
const pbrGroupBuilder = async (scene, meshes) => {
|
|
7536
8767
|
const envTex = scene._envTextures;
|
|
7537
|
-
const renderableMod = await import("./pbr-renderable-
|
|
8768
|
+
const renderableMod = await import("./pbr-renderable-BHAdF5Vw.js");
|
|
7538
8769
|
const result = await renderableMod.buildPbrRenderables(scene, meshes, envTex);
|
|
7539
8770
|
pbrGroupBuilder._rebuildSingle = result.rebuildSingle;
|
|
7540
8771
|
return result;
|
|
@@ -7612,11 +8843,12 @@ function collectPbrBoundTextures(mat) {
|
|
|
7612
8843
|
return t;
|
|
7613
8844
|
}
|
|
7614
8845
|
const shaderGroupBuilder = async (scene, meshes) => {
|
|
7615
|
-
const {
|
|
7616
|
-
const result =
|
|
8846
|
+
const { buildShaderGroup } = await import("./shader-renderable-BMf_vvO0.js");
|
|
8847
|
+
const result = await buildShaderGroup(scene, meshes);
|
|
7617
8848
|
shaderGroupBuilder._rebuildSingle = result.rebuildSingle;
|
|
7618
8849
|
return result;
|
|
7619
8850
|
};
|
|
8851
|
+
shaderGroupBuilder._materialFamily = "shader";
|
|
7620
8852
|
function isIdentifier(name) {
|
|
7621
8853
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
|
|
7622
8854
|
}
|
|
@@ -7677,7 +8909,12 @@ function createShaderMaterial(options) {
|
|
|
7677
8909
|
const samplerDecls = [];
|
|
7678
8910
|
const textureSlots = /* @__PURE__ */ new Map();
|
|
7679
8911
|
for (const opt of options.samplers ?? []) {
|
|
7680
|
-
const decl = typeof opt === "string" ? { name: opt, sampleType: "float" } : {
|
|
8912
|
+
const decl = typeof opt === "string" ? { name: opt, sampleType: "float" } : {
|
|
8913
|
+
name: opt.name,
|
|
8914
|
+
sampleType: opt.sampleType ?? (opt.comparison ? "depth" : "float"),
|
|
8915
|
+
viewDimension: opt.viewDimension ?? "2d",
|
|
8916
|
+
comparison: opt.comparison ?? false
|
|
8917
|
+
};
|
|
7681
8918
|
assertIdentifier("sampler", decl.name);
|
|
7682
8919
|
assertUniqueName(usedNames, "sampler", decl.name);
|
|
7683
8920
|
assertUniqueName(usedNames, "sampler", `${decl.name}Sampler`);
|
|
@@ -7694,6 +8931,9 @@ function createShaderMaterial(options) {
|
|
|
7694
8931
|
defines.push({ name, value });
|
|
7695
8932
|
}
|
|
7696
8933
|
defines.sort((a, b) => a.name.localeCompare(b.name));
|
|
8934
|
+
if (options.transmissive && !(options.needAlphaBlending ?? false)) {
|
|
8935
|
+
throw new Error("ShaderMaterial: `transmissive` requires `needAlphaBlending` (the surface composites over the grabbed opaque scene color).");
|
|
8936
|
+
}
|
|
7697
8937
|
return {
|
|
7698
8938
|
name: options.name,
|
|
7699
8939
|
vertexSource: options.vertexSource,
|
|
@@ -7704,6 +8944,7 @@ function createShaderMaterial(options) {
|
|
|
7704
8944
|
defines,
|
|
7705
8945
|
needAlphaBlending: options.needAlphaBlending ?? false,
|
|
7706
8946
|
blendMode: options.blendMode ?? "alpha",
|
|
8947
|
+
transmissive: options.transmissive ?? false,
|
|
7707
8948
|
needAlphaTesting: options.needAlphaTesting ?? false,
|
|
7708
8949
|
backFaceCulling: options.backFaceCulling ?? true,
|
|
7709
8950
|
depthWrite: options.depthWrite ?? true,
|
|
@@ -7784,7 +9025,7 @@ function setShaderTexture(material, name, texture) {
|
|
|
7784
9025
|
throw new Error(`ShaderMaterial: sampler "${name}" was not declared.`);
|
|
7785
9026
|
}
|
|
7786
9027
|
if (texture) {
|
|
7787
|
-
const expectsDepth = slot.decl.sampleType === "depth";
|
|
9028
|
+
const expectsDepth = slot.decl.sampleType === "depth" || slot.decl.comparison === true;
|
|
7788
9029
|
const isDepthTexture = texture._sampleType === "depth";
|
|
7789
9030
|
if (expectsDepth && !isDepthTexture) {
|
|
7790
9031
|
throw new Error(`ShaderMaterial: sampler "${name}" expects a depth Texture2D.`);
|
|
@@ -7803,7 +9044,7 @@ function setShaderVector3(material, name, value) {
|
|
|
7803
9044
|
setShaderUniform(material, name, value);
|
|
7804
9045
|
}
|
|
7805
9046
|
function setShaderMatrix(material, name, value) {
|
|
7806
|
-
setShaderUniform(material, name, value);
|
|
9047
|
+
setShaderUniform(material, name, value instanceof Float32Array ? value : Array.from(value));
|
|
7807
9048
|
}
|
|
7808
9049
|
function buildVertexOutputStruct(hasOpacity) {
|
|
7809
9050
|
return `struct VertexOutput{@builtin(position) position:vec4<f32>,@location(0) vPosition:vec3<f32>,@location(1) vNormal:vec3<f32>,${hasOpacity ? "@location(2) vUv:vec2<f32>," : ""}};`;
|
|
@@ -8098,7 +9339,7 @@ function bridgeVarying(state, varyingName, value, from, to) {
|
|
|
8098
9339
|
}
|
|
8099
9340
|
let defaultRegistry = null;
|
|
8100
9341
|
async function defaultBlockLoader(className) {
|
|
8101
|
-
defaultRegistry ?? (defaultRegistry = import("./node-registry-
|
|
9342
|
+
defaultRegistry ?? (defaultRegistry = import("./node-registry-Bd-AlrgC.js"));
|
|
8102
9343
|
return (await defaultRegistry).loadBlockEmitter(className);
|
|
8103
9344
|
}
|
|
8104
9345
|
function pbrMrBlockNeedsFullEmitter(block) {
|
|
@@ -8589,7 +9830,7 @@ async function parseNodeMaterialFromSnippet(engine, snippetId, options = {}) {
|
|
|
8589
9830
|
}
|
|
8590
9831
|
let _shadowEmitter;
|
|
8591
9832
|
if (options.shadowGenerators && options.shadowGenerators.length > 0) {
|
|
8592
|
-
_shadowEmitter = (await import("./node-shadow-
|
|
9833
|
+
_shadowEmitter = (await import("./node-shadow-CpnrdvtJ.js")).emitShadow;
|
|
8593
9834
|
}
|
|
8594
9835
|
const compile = compileNodePipeline(state, vertexWgsl, fragmentWgsl, {
|
|
8595
9836
|
_engine: engine,
|
|
@@ -8678,7 +9919,7 @@ async function parseNodeMaterialFromSnippet(engine, snippetId, options = {}) {
|
|
|
8678
9919
|
inputs[tb._name] = handle;
|
|
8679
9920
|
}
|
|
8680
9921
|
const _buildGroup = async (scene, meshes) => {
|
|
8681
|
-
const { buildNodeMeshRenderables } = await import("./node-renderable-
|
|
9922
|
+
const { buildNodeMeshRenderables } = await import("./node-renderable-CS0CmsSp.js");
|
|
8682
9923
|
const result = buildNodeMeshRenderables(scene, meshes);
|
|
8683
9924
|
_buildGroup._rebuildSingle = result.rebuildSingle;
|
|
8684
9925
|
return result;
|
|
@@ -8715,7 +9956,7 @@ async function resolvePbrMrHelpers(state) {
|
|
|
8715
9956
|
if (state.pbrMrHelperRequests.some((request) => !isCorePbrMrRequest(request))) {
|
|
8716
9957
|
throw new Error("NodeMaterial: advanced PBR-MR helper request must be emitted by the full PBR-MR block");
|
|
8717
9958
|
}
|
|
8718
|
-
const core = await import("./pbr-mr-helper-core-
|
|
9959
|
+
const core = await import("./pbr-mr-helper-core-R5tOZ8Ap.js");
|
|
8719
9960
|
for (const request of state.pbrMrHelperRequests) {
|
|
8720
9961
|
state.fragment.helpers.set(request.key, core.buildPbrMrHelperCore(request));
|
|
8721
9962
|
}
|
|
@@ -8884,13 +10125,355 @@ function rebuildSceneMesh(ctx, mesh) {
|
|
|
8884
10125
|
}
|
|
8885
10126
|
ctx._renderables.splice(i, 0, renderable);
|
|
8886
10127
|
}
|
|
10128
|
+
const STAGE_FRAGMENT$1 = 2;
|
|
10129
|
+
const STD_PLUGIN_UBO = "pluginUbo";
|
|
10130
|
+
const FRAG_POINT_TO_SLOTS = {
|
|
10131
|
+
CUSTOM_FRAGMENT_MAIN_BEGIN: ["SV"],
|
|
10132
|
+
CUSTOM_FRAGMENT_UPDATE_ALPHA: ["AT"],
|
|
10133
|
+
CUSTOM_FRAGMENT_UPDATE_DIFFUSE: ["AC"],
|
|
10134
|
+
CUSTOM_FRAGMENT_BEFORE_LIGHTS: ["MF"],
|
|
10135
|
+
CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: ["AI", "NI"],
|
|
10136
|
+
CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: ["BC"]
|
|
10137
|
+
};
|
|
10138
|
+
const VERT_POINT_TO_SLOT = {
|
|
10139
|
+
CUSTOM_VERTEX_MAIN_BEGIN: "VR",
|
|
10140
|
+
CUSTOM_VERTEX_UPDATE_WORLDPOS: "VW",
|
|
10141
|
+
CUSTOM_VERTEX_MAIN_END: "VB"
|
|
10142
|
+
};
|
|
10143
|
+
function enabledPlugins(plugins) {
|
|
10144
|
+
return plugins.filter((p) => p.isEnabled !== false).sort((a, b) => (a.priority ?? 500) - (b.priority ?? 500));
|
|
10145
|
+
}
|
|
10146
|
+
function pluginSignature(plugins) {
|
|
10147
|
+
var _a, _b, _c, _d;
|
|
10148
|
+
const parts = [];
|
|
10149
|
+
for (const p of plugins) {
|
|
10150
|
+
const on = p.isEnabled !== false;
|
|
10151
|
+
parts.push(`${p.name}${on ? "+" : "-"}${p.priority ?? 500}:${JSON.stringify(p.defines ?? null)}`);
|
|
10152
|
+
if (on) {
|
|
10153
|
+
parts.push(JSON.stringify(((_a = p.getCustomCode) == null ? void 0 : _a.call(p, "fragment")) ?? null));
|
|
10154
|
+
parts.push(JSON.stringify(((_b = p.getCustomCode) == null ? void 0 : _b.call(p, "vertex")) ?? null));
|
|
10155
|
+
parts.push(JSON.stringify(((_c = p.getUniforms) == null ? void 0 : _c.call(p)) ?? null));
|
|
10156
|
+
parts.push(JSON.stringify(((_d = p.getSamplers) == null ? void 0 : _d.call(p)) ?? null));
|
|
10157
|
+
}
|
|
10158
|
+
}
|
|
10159
|
+
return parts.join("|");
|
|
10160
|
+
}
|
|
10161
|
+
function buildPluginFragment(plugins, index, forStandard) {
|
|
10162
|
+
var _a, _b, _c, _d, _e;
|
|
10163
|
+
const enabled = enabledPlugins(plugins);
|
|
10164
|
+
if (enabled.length === 0) {
|
|
10165
|
+
return { _fragment: { _id: `plugin-${index}` }, _stdUboSpec: null };
|
|
10166
|
+
}
|
|
10167
|
+
let helpers = "";
|
|
10168
|
+
const fragmentSlots = {};
|
|
10169
|
+
const vertexSlots = {};
|
|
10170
|
+
const uboFields = [];
|
|
10171
|
+
const bindings = [];
|
|
10172
|
+
const append = (bucket, key, code) => {
|
|
10173
|
+
bucket[key] = (bucket[key] ?? "") + "\n" + code;
|
|
10174
|
+
};
|
|
10175
|
+
for (const p of enabled) {
|
|
10176
|
+
const frag = (_a = p.getCustomCode) == null ? void 0 : _a.call(p, "fragment");
|
|
10177
|
+
if (frag) {
|
|
10178
|
+
for (const point of Object.keys(frag)) {
|
|
10179
|
+
const code = frag[point];
|
|
10180
|
+
if (!code) {
|
|
10181
|
+
continue;
|
|
10182
|
+
}
|
|
10183
|
+
if (point === "CUSTOM_FRAGMENT_DEFINITIONS") {
|
|
10184
|
+
helpers += "\n" + code;
|
|
10185
|
+
continue;
|
|
10186
|
+
}
|
|
10187
|
+
const slots = FRAG_POINT_TO_SLOTS[point];
|
|
10188
|
+
if (slots) {
|
|
10189
|
+
for (const s of slots) {
|
|
10190
|
+
append(fragmentSlots, s, code);
|
|
10191
|
+
}
|
|
10192
|
+
}
|
|
10193
|
+
}
|
|
10194
|
+
}
|
|
10195
|
+
const vert = (_b = p.getCustomCode) == null ? void 0 : _b.call(p, "vertex");
|
|
10196
|
+
if (vert) {
|
|
10197
|
+
for (const point of Object.keys(vert)) {
|
|
10198
|
+
const code = vert[point];
|
|
10199
|
+
const slot = VERT_POINT_TO_SLOT[point];
|
|
10200
|
+
if (code && slot) {
|
|
10201
|
+
append(vertexSlots, slot, code);
|
|
10202
|
+
}
|
|
10203
|
+
}
|
|
10204
|
+
}
|
|
10205
|
+
const ubo = (_d = (_c = p.getUniforms) == null ? void 0 : _c.call(p)) == null ? void 0 : _d.ubo;
|
|
10206
|
+
if (ubo) {
|
|
10207
|
+
for (const f of ubo) {
|
|
10208
|
+
uboFields.push({ _name: f.name, _type: f.type });
|
|
10209
|
+
}
|
|
10210
|
+
}
|
|
10211
|
+
const samplers = (_e = p.getSamplers) == null ? void 0 : _e.call(p);
|
|
10212
|
+
if (samplers) {
|
|
10213
|
+
for (const s of samplers) {
|
|
10214
|
+
bindings.push(
|
|
10215
|
+
{ _name: s.texture, _type: { _kind: "texture", _textureType: s.textureType ?? "texture_2d<f32>" }, _visibility: STAGE_FRAGMENT$1 },
|
|
10216
|
+
{ _name: s.sampler, _type: { _kind: "sampler", _samplerType: s.samplerType ?? "sampler" }, _visibility: STAGE_FRAGMENT$1 }
|
|
10217
|
+
);
|
|
10218
|
+
}
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10221
|
+
let stdUboSpec = null;
|
|
10222
|
+
let stdUboFields = uboFields.length ? uboFields : void 0;
|
|
10223
|
+
if (forStandard && uboFields.length) {
|
|
10224
|
+
stdUboSpec = computeUboLayout(uboFields);
|
|
10225
|
+
helpers = `struct ${STD_PLUGIN_UBO}Uniforms{
|
|
10226
|
+
${stdUboSpec._structBody}
|
|
10227
|
+
}
|
|
10228
|
+
` + helpers;
|
|
10229
|
+
bindings.unshift({ _name: STD_PLUGIN_UBO, _type: { _kind: "uniform-buffer" }, _group: "mesh", _visibility: STAGE_FRAGMENT$1 });
|
|
10230
|
+
stdUboFields = void 0;
|
|
10231
|
+
}
|
|
10232
|
+
return {
|
|
10233
|
+
_fragment: {
|
|
10234
|
+
_id: `plugin-${index}`,
|
|
10235
|
+
_helperFunctions: helpers || void 0,
|
|
10236
|
+
_fragmentSlots: Object.keys(fragmentSlots).length ? fragmentSlots : void 0,
|
|
10237
|
+
_vertexSlots: Object.keys(vertexSlots).length ? vertexSlots : void 0,
|
|
10238
|
+
_uboFields: stdUboFields,
|
|
10239
|
+
_bindings: bindings.length ? bindings : void 0
|
|
10240
|
+
},
|
|
10241
|
+
_stdUboSpec: stdUboSpec
|
|
10242
|
+
};
|
|
10243
|
+
}
|
|
10244
|
+
function writePluginUbo(plugins, data, offsets) {
|
|
10245
|
+
var _a;
|
|
10246
|
+
for (const p of enabledPlugins(plugins)) {
|
|
10247
|
+
(_a = p.writeUbo) == null ? void 0 : _a.call(p, data, offsets);
|
|
10248
|
+
}
|
|
10249
|
+
}
|
|
10250
|
+
function bindPluginTextures(plugins, entries, b) {
|
|
10251
|
+
for (const p of enabledPlugins(plugins)) {
|
|
10252
|
+
if (!p.bindTextures) {
|
|
10253
|
+
continue;
|
|
10254
|
+
}
|
|
10255
|
+
const out = [];
|
|
10256
|
+
p.bindTextures(out);
|
|
10257
|
+
for (const binding of out) {
|
|
10258
|
+
entries.push({ binding: b++, resource: binding.texture.view });
|
|
10259
|
+
entries.push({ binding: b++, resource: binding.texture.sampler });
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
return b;
|
|
10263
|
+
}
|
|
10264
|
+
const PLUGIN_INDEX_SHIFT$1 = 24;
|
|
10265
|
+
let _sigToIndex$1 = null;
|
|
10266
|
+
let _indexToEntry$1 = null;
|
|
10267
|
+
let _counter$1 = 0;
|
|
10268
|
+
function _resetState$1() {
|
|
10269
|
+
_sigToIndex$1 = /* @__PURE__ */ new Map();
|
|
10270
|
+
_indexToEntry$1 = /* @__PURE__ */ new Map();
|
|
10271
|
+
_counter$1 = 0;
|
|
10272
|
+
}
|
|
10273
|
+
function _indexFor$1(plugins) {
|
|
10274
|
+
const sig = pluginSignature(plugins);
|
|
10275
|
+
const map = _sigToIndex$1 ?? (_sigToIndex$1 = /* @__PURE__ */ new Map());
|
|
10276
|
+
let idx = map.get(sig);
|
|
10277
|
+
if (idx === void 0) {
|
|
10278
|
+
idx = ++_counter$1;
|
|
10279
|
+
map.set(sig, idx);
|
|
10280
|
+
(_indexToEntry$1 ?? (_indexToEntry$1 = /* @__PURE__ */ new Map())).set(idx, { _plugins: plugins, _fragment: buildPluginFragment(plugins, idx, false)._fragment });
|
|
10281
|
+
}
|
|
10282
|
+
return idx;
|
|
10283
|
+
}
|
|
10284
|
+
const pbrPluginExt = {
|
|
10285
|
+
id: "plugin",
|
|
10286
|
+
phase: "fragment",
|
|
10287
|
+
detect(mat) {
|
|
10288
|
+
const plugins = mat.plugins;
|
|
10289
|
+
if (!(plugins == null ? void 0 : plugins.length)) {
|
|
10290
|
+
return { f: 0, f2: 0 };
|
|
10291
|
+
}
|
|
10292
|
+
return { f: 0, f2: _indexFor$1(plugins) << PLUGIN_INDEX_SHIFT$1 };
|
|
10293
|
+
},
|
|
10294
|
+
frag(ctx) {
|
|
10295
|
+
var _a;
|
|
10296
|
+
const idx = ctx._features2 >>> PLUGIN_INDEX_SHIFT$1 & 255;
|
|
10297
|
+
if (!idx) {
|
|
10298
|
+
return null;
|
|
10299
|
+
}
|
|
10300
|
+
return ((_a = _indexToEntry$1 == null ? void 0 : _indexToEntry$1.get(idx)) == null ? void 0 : _a._fragment) ?? null;
|
|
10301
|
+
},
|
|
10302
|
+
writeUbo(data, mat, offsets) {
|
|
10303
|
+
const plugins = mat.plugins;
|
|
10304
|
+
if (plugins == null ? void 0 : plugins.length) {
|
|
10305
|
+
writePluginUbo(plugins, data, offsets);
|
|
10306
|
+
}
|
|
10307
|
+
},
|
|
10308
|
+
bind(ctx, entries, b) {
|
|
10309
|
+
const plugins = ctx._material.plugins;
|
|
10310
|
+
return (plugins == null ? void 0 : plugins.length) ? bindPluginTextures(plugins, entries, b) : b;
|
|
10311
|
+
},
|
|
10312
|
+
textures(mat, out) {
|
|
10313
|
+
var _a;
|
|
10314
|
+
const plugins = mat.plugins;
|
|
10315
|
+
if (!(plugins == null ? void 0 : plugins.length)) {
|
|
10316
|
+
return;
|
|
10317
|
+
}
|
|
10318
|
+
for (const p of enabledPlugins(plugins)) {
|
|
10319
|
+
(_a = p.getActiveTextures) == null ? void 0 : _a.call(p, out);
|
|
10320
|
+
}
|
|
10321
|
+
}
|
|
10322
|
+
};
|
|
10323
|
+
function registerPbrPlugins(register) {
|
|
10324
|
+
_resetState$1();
|
|
10325
|
+
register(pbrPluginExt);
|
|
10326
|
+
}
|
|
10327
|
+
function _computeStandardMaterialFeatures(m) {
|
|
10328
|
+
let f = 0;
|
|
10329
|
+
if (m.diffuseTexture) {
|
|
10330
|
+
f |= HAS_DIFFUSE_TEXTURE;
|
|
10331
|
+
if (m.diffuseCoordIndex === 1) {
|
|
10332
|
+
f |= DIFFUSE_USES_UV2;
|
|
10333
|
+
}
|
|
10334
|
+
}
|
|
10335
|
+
if (m.emissiveTexture) {
|
|
10336
|
+
f |= HAS_EMISSIVE_TEXTURE;
|
|
10337
|
+
if (m.emissiveTexture._sampleType === "depth") {
|
|
10338
|
+
f |= HAS_DEPTH_EMISSIVE_TEXTURE;
|
|
10339
|
+
}
|
|
10340
|
+
}
|
|
10341
|
+
if (m.bumpTexture) {
|
|
10342
|
+
f |= HAS_BUMP_TEXTURE;
|
|
10343
|
+
}
|
|
10344
|
+
if (m.specularTexture) {
|
|
10345
|
+
f |= HAS_SPECULAR_TEXTURE;
|
|
10346
|
+
if (m.specularCoordIndex === 1) {
|
|
10347
|
+
f |= SPECULAR_USES_UV2;
|
|
10348
|
+
}
|
|
10349
|
+
}
|
|
10350
|
+
if (m.ambientTexture) {
|
|
10351
|
+
f |= HAS_AMBIENT_TEXTURE;
|
|
10352
|
+
if (m.ambientCoordIndex === 1) {
|
|
10353
|
+
f |= AMBIENT_USES_UV2;
|
|
10354
|
+
}
|
|
10355
|
+
}
|
|
10356
|
+
if (m.lightmapTexture) {
|
|
10357
|
+
f |= HAS_LIGHTMAP_TEXTURE;
|
|
10358
|
+
if (m.lightmapCoordIndex === 1) {
|
|
10359
|
+
f |= LIGHTMAP_USES_UV2;
|
|
10360
|
+
}
|
|
10361
|
+
}
|
|
10362
|
+
if (m.opacityTexture) {
|
|
10363
|
+
f |= HAS_OPACITY_TEXTURE;
|
|
10364
|
+
if (m.opacityFromRGB) {
|
|
10365
|
+
f |= OPACITY_FROM_RGB;
|
|
10366
|
+
}
|
|
10367
|
+
}
|
|
10368
|
+
if (!m.backFaceCulling) {
|
|
10369
|
+
f |= DOUBLE_SIDED;
|
|
10370
|
+
}
|
|
10371
|
+
if (m.reflectionTexture) {
|
|
10372
|
+
f |= HAS_REFLECTION_TEXTURE;
|
|
10373
|
+
}
|
|
10374
|
+
if (m.reflectionCubeTexture) {
|
|
10375
|
+
f |= HAS_CUBE_REFLECTION;
|
|
10376
|
+
}
|
|
10377
|
+
if (m.disableLighting) {
|
|
10378
|
+
f |= DISABLE_LIGHTING;
|
|
10379
|
+
}
|
|
10380
|
+
if (m.alpha < 1) {
|
|
10381
|
+
f |= MATERIAL_ALPHA_BLEND;
|
|
10382
|
+
}
|
|
10383
|
+
return f;
|
|
10384
|
+
}
|
|
10385
|
+
function _standardFeatureKey(features, meshFeatures, variant = "") {
|
|
10386
|
+
return variant ? `${features}:${meshFeatures}:${variant}` : `${features}:${meshFeatures}`;
|
|
10387
|
+
}
|
|
10388
|
+
function _standardShaderVariantKey(shadowLights) {
|
|
10389
|
+
return shadowLights.length === 0 ? "" : shadowLights.map((sl) => `${sl.lightIndex}${sl.shadowType === "pcf" ? "p" : "e"}`).join(",");
|
|
10390
|
+
}
|
|
10391
|
+
const PLUGIN_INDEX_SHIFT = 24;
|
|
10392
|
+
const PLUGIN_INDEX_MASK = 127;
|
|
10393
|
+
let _sigToIndex = null;
|
|
10394
|
+
let _indexToEntry = null;
|
|
10395
|
+
let _counter = 0;
|
|
10396
|
+
function _resetState() {
|
|
10397
|
+
_sigToIndex = /* @__PURE__ */ new Map();
|
|
10398
|
+
_indexToEntry = /* @__PURE__ */ new Map();
|
|
10399
|
+
_counter = 0;
|
|
10400
|
+
}
|
|
10401
|
+
function _indexFor(plugins, engine) {
|
|
10402
|
+
const sig = pluginSignature(plugins);
|
|
10403
|
+
const map = _sigToIndex ?? (_sigToIndex = /* @__PURE__ */ new Map());
|
|
10404
|
+
let idx = map.get(sig);
|
|
10405
|
+
if (idx === void 0) {
|
|
10406
|
+
idx = ++_counter;
|
|
10407
|
+
map.set(sig, idx);
|
|
10408
|
+
const built = buildPluginFragment(plugins, idx, true);
|
|
10409
|
+
let uboBuffer = null;
|
|
10410
|
+
if (built._stdUboSpec && built._stdUboSpec._totalBytes > 0) {
|
|
10411
|
+
const data = new Float32Array(built._stdUboSpec._totalBytes / 4);
|
|
10412
|
+
writePluginUbo(plugins, data, built._stdUboSpec._offsets);
|
|
10413
|
+
uboBuffer = createUniformBuffer$1(engine, data, "plugin-ubo");
|
|
10414
|
+
}
|
|
10415
|
+
(_indexToEntry ?? (_indexToEntry = /* @__PURE__ */ new Map())).set(idx, { _plugins: plugins, _fragment: built._fragment, _uboBuffer: uboBuffer });
|
|
10416
|
+
}
|
|
10417
|
+
return idx;
|
|
10418
|
+
}
|
|
10419
|
+
function _entryFor(plugins) {
|
|
10420
|
+
const idx = _sigToIndex == null ? void 0 : _sigToIndex.get(pluginSignature(plugins));
|
|
10421
|
+
return idx ? _indexToEntry == null ? void 0 : _indexToEntry.get(idx) : void 0;
|
|
10422
|
+
}
|
|
10423
|
+
const stdPluginExt = {
|
|
10424
|
+
_id: "plugin",
|
|
10425
|
+
_phase: "mesh",
|
|
10426
|
+
_feature: PLUGIN_INDEX_MASK << PLUGIN_INDEX_SHIFT,
|
|
10427
|
+
_frag(features) {
|
|
10428
|
+
var _a;
|
|
10429
|
+
const idx = features >>> PLUGIN_INDEX_SHIFT & PLUGIN_INDEX_MASK;
|
|
10430
|
+
return ((_a = _indexToEntry == null ? void 0 : _indexToEntry.get(idx)) == null ? void 0 : _a._fragment) ?? { _id: "plugin-0" };
|
|
10431
|
+
},
|
|
10432
|
+
_bind(mat, entries, b) {
|
|
10433
|
+
const plugins = mat.plugins;
|
|
10434
|
+
if (!(plugins == null ? void 0 : plugins.length)) {
|
|
10435
|
+
return b;
|
|
10436
|
+
}
|
|
10437
|
+
const entry = _entryFor(plugins);
|
|
10438
|
+
if (entry == null ? void 0 : entry._uboBuffer) {
|
|
10439
|
+
entries.push({ binding: b++, resource: { buffer: entry._uboBuffer } });
|
|
10440
|
+
}
|
|
10441
|
+
return bindPluginTextures(plugins, entries, b);
|
|
10442
|
+
},
|
|
10443
|
+
_textures(mat, out) {
|
|
10444
|
+
var _a;
|
|
10445
|
+
const plugins = mat.plugins;
|
|
10446
|
+
if (!(plugins == null ? void 0 : plugins.length)) {
|
|
10447
|
+
return;
|
|
10448
|
+
}
|
|
10449
|
+
for (const p of enabledPlugins(plugins)) {
|
|
10450
|
+
(_a = p.getActiveTextures) == null ? void 0 : _a.call(p, out);
|
|
10451
|
+
}
|
|
10452
|
+
}
|
|
10453
|
+
};
|
|
10454
|
+
function registerStdPlugins(meshes, engine, register) {
|
|
10455
|
+
var _a;
|
|
10456
|
+
_resetState();
|
|
10457
|
+
register(stdPluginExt);
|
|
10458
|
+
for (const m of meshes) {
|
|
10459
|
+
const mat = m.material;
|
|
10460
|
+
if (((_a = mat == null ? void 0 : mat.plugins) == null ? void 0 : _a.length) && mat._buildGroup === standardGroupBuilder) {
|
|
10461
|
+
const idx = _indexFor(mat.plugins, engine);
|
|
10462
|
+
mat._renderFeatures = { features: _computeStandardMaterialFeatures(mat) | idx << PLUGIN_INDEX_SHIFT };
|
|
10463
|
+
}
|
|
10464
|
+
}
|
|
10465
|
+
}
|
|
10466
|
+
function enableMaterialPlugins(scene) {
|
|
10467
|
+
registerPbrPlugins(_registerPbrExt);
|
|
10468
|
+
registerStdPlugins(scene.meshes, scene.engine, _registerStdExt);
|
|
10469
|
+
}
|
|
8887
10470
|
async function enableMaterialTracking(material) {
|
|
8888
10471
|
const source = getMaterialSource(material);
|
|
8889
10472
|
if ("specularPower" in source) {
|
|
8890
|
-
const { installStdTracking } = await import("./std-tracking-
|
|
10473
|
+
const { installStdTracking } = await import("./std-tracking-C4L4nQGc.js");
|
|
8891
10474
|
installStdTracking(source);
|
|
8892
10475
|
} else {
|
|
8893
|
-
const { installPbrTracking } = await import("./pbr-tracking-
|
|
10476
|
+
const { installPbrTracking } = await import("./pbr-tracking-D6i3yPb7.js");
|
|
8894
10477
|
installPbrTracking(source);
|
|
8895
10478
|
}
|
|
8896
10479
|
}
|
|
@@ -8946,6 +10529,18 @@ function cloneTransformNode(src) {
|
|
|
8946
10529
|
}
|
|
8947
10530
|
return clone;
|
|
8948
10531
|
}
|
|
10532
|
+
let _tmpLocal = null;
|
|
10533
|
+
let _tmpAnim = null;
|
|
10534
|
+
let _tmpInstance = null;
|
|
10535
|
+
function getLoaderTmpLocal() {
|
|
10536
|
+
return _tmpLocal ?? (_tmpLocal = allocateMat4());
|
|
10537
|
+
}
|
|
10538
|
+
function getLoaderTmpAnim() {
|
|
10539
|
+
return _tmpAnim ?? (_tmpAnim = allocateMat4());
|
|
10540
|
+
}
|
|
10541
|
+
function getLoaderTmpInstance() {
|
|
10542
|
+
return _tmpInstance ?? (_tmpInstance = allocateMat4());
|
|
10543
|
+
}
|
|
8949
10544
|
const FLOAT = 5126;
|
|
8950
10545
|
const UNSIGNED_SHORT = 5123;
|
|
8951
10546
|
const UNSIGNED_INT = 5125;
|
|
@@ -8984,6 +10579,29 @@ function getTextureImageIndex(tex) {
|
|
|
8984
10579
|
var _a, _b;
|
|
8985
10580
|
return ((_b = (_a = tex.extensions) == null ? void 0 : _a.EXT_texture_webp) == null ? void 0 : _b.source) ?? tex.source;
|
|
8986
10581
|
}
|
|
10582
|
+
function anyPrimitive(json, pred) {
|
|
10583
|
+
for (const m of json.meshes ?? []) {
|
|
10584
|
+
for (const p of m.primitives ?? []) {
|
|
10585
|
+
if (pred(p)) {
|
|
10586
|
+
return true;
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
}
|
|
10590
|
+
return false;
|
|
10591
|
+
}
|
|
10592
|
+
function needsOrmComposite(json) {
|
|
10593
|
+
var _a;
|
|
10594
|
+
const mats = json.materials ?? [];
|
|
10595
|
+
const textures = json.textures ?? [];
|
|
10596
|
+
for (const m of mats) {
|
|
10597
|
+
const mr = (_a = m.pbrMetallicRoughness) == null ? void 0 : _a.metallicRoughnessTexture;
|
|
10598
|
+
const occ = m.occlusionTexture;
|
|
10599
|
+
if (mr && occ && textures[mr.index] && textures[occ.index] && getTextureImageIndex(textures[mr.index]) !== getTextureImageIndex(textures[occ.index])) {
|
|
10600
|
+
return true;
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10603
|
+
return false;
|
|
10604
|
+
}
|
|
8987
10605
|
async function resolveImage(json, binChunk, imageIdx, baseUrl) {
|
|
8988
10606
|
const image = json.images[imageIdx];
|
|
8989
10607
|
if (image.bufferView !== void 0) {
|
|
@@ -9037,22 +10655,15 @@ function computeNodeWorldMatrix(json, nodeIdx, parentMap, cache) {
|
|
|
9037
10655
|
const t = node.translation ?? [0, 0, 0];
|
|
9038
10656
|
const r = node.rotation ?? [0, 0, 0, 1];
|
|
9039
10657
|
const s = node.scale ?? [1, 1, 1];
|
|
9040
|
-
const
|
|
9041
|
-
mat4ComposeInto(
|
|
9042
|
-
localBuf =
|
|
10658
|
+
const local = getLoaderTmpLocal();
|
|
10659
|
+
mat4ComposeInto(local, 0, t[0], t[1], t[2], r[0], r[1], r[2], r[3], s[0], s[1], s[2]);
|
|
10660
|
+
localBuf = local;
|
|
9043
10661
|
}
|
|
9044
10662
|
const world = new Float32Array(16);
|
|
9045
10663
|
mat4MultiplyInto(world, 0, parentWorld, 0, localBuf, 0);
|
|
9046
10664
|
cache.set(nodeIdx, world);
|
|
9047
10665
|
return world;
|
|
9048
10666
|
}
|
|
9049
|
-
let _localScratch = null;
|
|
9050
|
-
function _getLocalScratch() {
|
|
9051
|
-
if (!_localScratch) {
|
|
9052
|
-
_localScratch = new Float32Array(16);
|
|
9053
|
-
}
|
|
9054
|
-
return _localScratch;
|
|
9055
|
-
}
|
|
9056
10667
|
async function assembleMaterial(json, binChunk, materialIdx, baseUrl, imageCache) {
|
|
9057
10668
|
var _a, _b, _c;
|
|
9058
10669
|
const mat = (_a = json.materials) == null ? void 0 : _a[materialIdx];
|
|
@@ -9118,13 +10729,6 @@ function makeImageFetcher(json, binChunk, baseUrl, imageCache) {
|
|
|
9118
10729
|
return resolveImage(json, binChunk, imgIdx, baseUrl);
|
|
9119
10730
|
};
|
|
9120
10731
|
}
|
|
9121
|
-
function mipLevelCount(width, height) {
|
|
9122
|
-
return Math.floor(Math.log2(Math.max(width, height))) + 1;
|
|
9123
|
-
}
|
|
9124
|
-
function biasedMipLevelCount(width, height, lodBias) {
|
|
9125
|
-
const maxDim = Math.max(width, height);
|
|
9126
|
-
return Math.max(1, Math.floor(Math.log2(maxDim) - lodBias) + 1);
|
|
9127
|
-
}
|
|
9128
10732
|
function linearToSrgbByte(v) {
|
|
9129
10733
|
const c = Math.max(0, Math.min(1, v));
|
|
9130
10734
|
return Math.round((c <= 31308e-7 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055) * 255);
|
|
@@ -9228,14 +10832,14 @@ async function runMatExts(mat, exts, ctx) {
|
|
|
9228
10832
|
}
|
|
9229
10833
|
let _interleavePromise;
|
|
9230
10834
|
function loadInterleave() {
|
|
9231
|
-
return _interleavePromise ?? (_interleavePromise = import("./gltf-interleave-
|
|
10835
|
+
return _interleavePromise ?? (_interleavePromise = import("./gltf-interleave-C9eBqH_F.js"));
|
|
9232
10836
|
}
|
|
9233
10837
|
async function loadGltf(engine, url) {
|
|
9234
10838
|
var _a;
|
|
9235
10839
|
const { json, binChunk, baseUrl } = await fetchGltfAsset(url);
|
|
9236
10840
|
const parentMap = buildParentMap(json);
|
|
9237
10841
|
const worldMatrixCache = /* @__PURE__ */ new Map();
|
|
9238
|
-
const features = await loadGltfFeatures(json);
|
|
10842
|
+
const features = assetUsesGltfFeatures(json) ? await (await import("./gltf-feature-registry-97sY_x5O.js")).loadGltfFeatures(json) : [];
|
|
9239
10843
|
let activeBin = binChunk;
|
|
9240
10844
|
for (const f of features) {
|
|
9241
10845
|
if (f.preParse) {
|
|
@@ -9278,108 +10882,37 @@ async function loadGltf(engine, url) {
|
|
|
9278
10882
|
Object.assign(container, rest);
|
|
9279
10883
|
}
|
|
9280
10884
|
return container;
|
|
9281
|
-
}
|
|
9282
|
-
async function fetchGltfAsset(url) {
|
|
9283
|
-
var _a;
|
|
9284
|
-
const baseUrl = url.substring(0, url.lastIndexOf("/") + 1);
|
|
9285
|
-
if (url.toLowerCase().endsWith(".glb")) {
|
|
9286
|
-
const buffer = await fetch(url).then((r) => r.arrayBuffer());
|
|
9287
|
-
const { parseGlbContainer } = await import("./gltf-glb-parser-D6UZWFuC.js");
|
|
9288
|
-
const { json: json2, binChunk: binChunk2 } = parseGlbContainer(buffer);
|
|
9289
|
-
return { json: json2, binChunk: binChunk2, baseUrl };
|
|
9290
|
-
}
|
|
9291
|
-
const json = await fetch(url).then((r) => r.json());
|
|
9292
|
-
const bufferDef = (_a = json.buffers) == null ? void 0 : _a[0];
|
|
9293
|
-
let binChunk;
|
|
9294
|
-
if (bufferDef == null ? void 0 : bufferDef.uri) {
|
|
9295
|
-
const binUrl = new URL(bufferDef.uri, baseUrl + "x").href;
|
|
9296
|
-
const binBuffer = await fetch(binUrl).then((r) => r.arrayBuffer());
|
|
9297
|
-
binChunk = new DataView(binBuffer);
|
|
9298
|
-
} else {
|
|
9299
|
-
binChunk = new DataView(new ArrayBuffer(0));
|
|
9300
|
-
}
|
|
9301
|
-
return { json, binChunk, baseUrl };
|
|
9302
|
-
}
|
|
9303
|
-
function anyPrimitive(json, pred) {
|
|
9304
|
-
for (const m of json.meshes ?? []) {
|
|
9305
|
-
for (const p of m.primitives ?? []) {
|
|
9306
|
-
if (pred(p)) {
|
|
9307
|
-
return true;
|
|
9308
|
-
}
|
|
9309
|
-
}
|
|
9310
|
-
}
|
|
9311
|
-
return false;
|
|
9312
|
-
}
|
|
9313
|
-
const _MAT_EXT = "KHR_materials_";
|
|
9314
|
-
const hasMatExt = (suffix) => (json) => {
|
|
9315
|
-
var _a;
|
|
9316
|
-
return (_a = json.extensionsUsed) == null ? void 0 : _a.includes(_MAT_EXT + suffix);
|
|
9317
|
-
};
|
|
9318
|
-
const hasExt = (name) => (json) => {
|
|
9319
|
-
var _a;
|
|
9320
|
-
return (_a = json.extensionsUsed) == null ? void 0 : _a.includes(name);
|
|
9321
|
-
};
|
|
9322
|
-
function needsOrmComposite(json) {
|
|
9323
|
-
var _a;
|
|
9324
|
-
const mats = json.materials ?? [];
|
|
9325
|
-
const textures = json.textures ?? [];
|
|
9326
|
-
for (const m of mats) {
|
|
9327
|
-
const mr = (_a = m.pbrMetallicRoughness) == null ? void 0 : _a.metallicRoughnessTexture;
|
|
9328
|
-
const occ = m.occlusionTexture;
|
|
9329
|
-
if (mr && occ && textures[mr.index] && textures[occ.index] && getTextureImageIndex(textures[mr.index]) !== getTextureImageIndex(textures[occ.index])) {
|
|
9330
|
-
return true;
|
|
9331
|
-
}
|
|
10885
|
+
}
|
|
10886
|
+
async function fetchGltfAsset(url) {
|
|
10887
|
+
var _a;
|
|
10888
|
+
const baseUrl = url.substring(0, url.lastIndexOf("/") + 1);
|
|
10889
|
+
if (url.toLowerCase().endsWith(".glb")) {
|
|
10890
|
+
const buffer = await fetch(url).then((r) => r.arrayBuffer());
|
|
10891
|
+
const { parseGlbContainer } = await import("./gltf-glb-parser-D6UZWFuC.js");
|
|
10892
|
+
const { json: json2, binChunk: binChunk2 } = parseGlbContainer(buffer);
|
|
10893
|
+
return { json: json2, binChunk: binChunk2, baseUrl };
|
|
9332
10894
|
}
|
|
9333
|
-
|
|
10895
|
+
const json = await fetch(url).then((r) => r.json());
|
|
10896
|
+
const bufferDef = (_a = json.buffers) == null ? void 0 : _a[0];
|
|
10897
|
+
let binChunk;
|
|
10898
|
+
if (bufferDef == null ? void 0 : bufferDef.uri) {
|
|
10899
|
+
const binUrl = new URL(bufferDef.uri, baseUrl + "x").href;
|
|
10900
|
+
const binBuffer = await fetch(binUrl).then((r) => r.arrayBuffer());
|
|
10901
|
+
binChunk = new DataView(binBuffer);
|
|
10902
|
+
} else {
|
|
10903
|
+
binChunk = new DataView(new ArrayBuffer(0));
|
|
10904
|
+
}
|
|
10905
|
+
return { json, binChunk, baseUrl };
|
|
9334
10906
|
}
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
[hasMatExt("iridescence"), () => import("./gltf-ext-iridescence-C6bq7jiM.js")],
|
|
9345
|
-
[hasMatExt("emissive_strength"), () => import("./gltf-ext-emissive-strength-nzGZXZVK.js")],
|
|
9346
|
-
[hasMatExt("sheen"), () => import("./gltf-ext-sheen-BgIxUzyZ.js")],
|
|
9347
|
-
[hasMatExt("anisotropy"), () => import("./gltf-ext-anisotropy-CknJiJK8.js")],
|
|
9348
|
-
[hasMatExt("unlit"), () => import("./gltf-ext-unlit-D2ANui0V.js")],
|
|
9349
|
-
[hasMatExt("pbrSpecularGlossiness"), () => import("./gltf-ext-spec-gloss-D0LJLBUM.js")],
|
|
9350
|
-
// Dielectric cluster (ior/specular/transmission/volume) — any of the four triggers the loader;
|
|
9351
|
-
// transmission refraction is wired dynamically by the PBR material path when the loaded material needs it.
|
|
9352
|
-
[(j) => ["transmission", "volume", "ior", "specular", "dispersion"].some((e) => hasMatExt(e)(j)), () => import("./gltf-ext-dielectric-qHzlnvdl.js")],
|
|
9353
|
-
[hasExt("KHR_texture_transform"), () => import("./gltf-ext-uv-transform-CE_-T1Tr.js")],
|
|
9354
|
-
[hasExt("KHR_texture_basisu"), () => import("./gltf-ext-basisu-CPg5kPrx.js")],
|
|
9355
|
-
[needsOrmComposite, () => import("./gltf-ext-orm-CT18G_vQ.js")],
|
|
9356
|
-
// Per-mesh features (predicates inlined to avoid eager imports)
|
|
9357
|
-
[(json) => {
|
|
9358
|
-
var _a;
|
|
9359
|
-
return !!((_a = json.skins) == null ? void 0 : _a.length) && anyPrimitive(json, (p) => {
|
|
9360
|
-
var _a2;
|
|
9361
|
-
return ((_a2 = p.attributes) == null ? void 0 : _a2.JOINTS_0) !== void 0;
|
|
9362
|
-
});
|
|
9363
|
-
}, () => import("./gltf-feature-skeleton-D8hWLqi2.js")],
|
|
9364
|
-
[(json) => anyPrimitive(json, (p) => {
|
|
9365
|
-
var _a;
|
|
9366
|
-
return !!((_a = p.targets) == null ? void 0 : _a.length);
|
|
9367
|
-
}), () => import("./gltf-feature-morph-CKCw6tkX.js")],
|
|
9368
|
-
// Per-asset features
|
|
9369
|
-
[hasExt("KHR_lights_punctual"), () => import("./gltf-feature-lights-punctual-DDDg4j0U.js")],
|
|
9370
|
-
[(json) => {
|
|
9371
|
-
var _a;
|
|
9372
|
-
return !!((_a = json.animations) == null ? void 0 : _a.length);
|
|
9373
|
-
}, () => import("./gltf-feature-animations-CCizegp8.js")],
|
|
9374
|
-
[hasMatExt("variants"), () => import("./gltf-feature-variants-Ds6v9byg.js")],
|
|
9375
|
-
[hasExt("KHR_node_visibility"), () => import("./gltf-ext-node-visibility-MafA9ot2.js")],
|
|
9376
|
-
[hasExt("KHR_animation_pointer"), () => import("./gltf-feature-animation-pointer-BjpwOOqo.js")],
|
|
9377
|
-
[hasExt("EXT_mesh_gpu_instancing"), () => import("./gltf-feature-gpu-instancing-2e_CFQnl.js")],
|
|
9378
|
-
[hasExt("KHR_xmp_json_ld"), () => import("./gltf-feature-xmp-BUfq_IVG.js")]
|
|
9379
|
-
];
|
|
9380
|
-
async function loadGltfFeatures(json) {
|
|
9381
|
-
const mods = await Promise.all(_features.flatMap(([needs, load]) => needs(json) ? [load()] : []));
|
|
9382
|
-
return mods.map((m) => m.default);
|
|
10907
|
+
function assetUsesGltfFeatures(json) {
|
|
10908
|
+
var _a, _b, _c;
|
|
10909
|
+
return !!(((_a = json.extensionsUsed) == null ? void 0 : _a.length) || ((_b = json.animations) == null ? void 0 : _b.length) || ((_c = json.skins) == null ? void 0 : _c.length) && anyPrimitive(json, (p) => {
|
|
10910
|
+
var _a2;
|
|
10911
|
+
return ((_a2 = p.attributes) == null ? void 0 : _a2.JOINTS_0) !== void 0;
|
|
10912
|
+
}) || anyPrimitive(json, (p) => {
|
|
10913
|
+
var _a2;
|
|
10914
|
+
return !!((_a2 = p.targets) == null ? void 0 : _a2.length);
|
|
10915
|
+
}) || needsOrmComposite(json));
|
|
9383
10916
|
}
|
|
9384
10917
|
function buildNodeHierarchy(json, meshes, meshDatas) {
|
|
9385
10918
|
var _a, _b, _c;
|
|
@@ -9482,16 +11015,18 @@ async function extractAllMeshes(json, binChunk, baseUrl, parentMap, worldMatrixC
|
|
|
9482
11015
|
const uv2Data = resolveAttr("TEXCOORD_1");
|
|
9483
11016
|
const tanData = resolveAttr("TANGENT");
|
|
9484
11017
|
const colorData = resolveAttr("COLOR_0");
|
|
11018
|
+
const colors = colorData ? (await import("./gltf-color-normalize-Qxl-9C48.js")).normalizeColorToVec3(colorData._data, colorData._count, colorData._componentCount) : null;
|
|
9485
11019
|
const idxData = decoded ? { _data: decoded._indices, _count: decoded._indexCount } : primitive.indices !== void 0 ? resolveAccessor(json, binChunk, primitive.indices) : null;
|
|
9486
11020
|
const indices = idxData ? idxData._data instanceof Uint32Array ? new Uint32Array(idxData._data) : idxData._data instanceof Uint8Array ? Uint16Array.from(idxData._data) : new Uint16Array(idxData._data.buffer, idxData._data.byteOffset, idxData._count) : new Uint16Array(0);
|
|
9487
11021
|
matPromises.push(getMat(primitive.material));
|
|
11022
|
+
const normals = normData ? normData._data : (await import("./gltf-normals-b2h74380.js")).computeSmoothNormals(posData._data, indices, posData._count);
|
|
9488
11023
|
partials.push({
|
|
9489
11024
|
_positions: posData._data,
|
|
9490
|
-
_normals:
|
|
11025
|
+
_normals: normals,
|
|
9491
11026
|
_tangents: tanData ? tanData._data : null,
|
|
9492
11027
|
_uvs: uvData ? uvData._data : new Float32Array(posData._count * 2),
|
|
9493
11028
|
_uv2s: uv2Data ? uv2Data._data : null,
|
|
9494
|
-
_colors:
|
|
11029
|
+
_colors: colors,
|
|
9495
11030
|
_indices: indices,
|
|
9496
11031
|
_vertexCount: posData._count,
|
|
9497
11032
|
_indexCount: (idxData == null ? void 0 : idxData._count) ?? 0,
|
|
@@ -9562,7 +11097,7 @@ async function uploadMeshes(meshDatas, features, ctx) {
|
|
|
9562
11097
|
}
|
|
9563
11098
|
}
|
|
9564
11099
|
let _pbrExtPromise = null;
|
|
9565
|
-
const _ensurePbrExt = () => _pbrExtPromise ?? (_pbrExtPromise = import("./gltf-pbr-builder-ext-
|
|
11100
|
+
const _ensurePbrExt = () => _pbrExtPromise ?? (_pbrExtPromise = import("./gltf-pbr-builder-ext-DPC0zg_u.js"));
|
|
9566
11101
|
const builtMaterialCache = /* @__PURE__ */ new Map();
|
|
9567
11102
|
async function buildPbrFromGltfMat(mat) {
|
|
9568
11103
|
let cached = builtMaterialCache.get(mat);
|
|
@@ -10001,7 +11536,7 @@ async function loadBabylon(engine, url, opts = {}) {
|
|
|
10001
11536
|
}
|
|
10002
11537
|
}
|
|
10003
11538
|
const camData = opts.loadCamera !== false && ((_v = data.cameras) == null ? void 0 : _v.length) ? (data.activeCameraID ? data.cameras.find((c) => c.id === data.activeCameraID) : null) ?? data.cameras[0] : null;
|
|
10004
|
-
const camera = camData ? (await import("./parse-camera-
|
|
11539
|
+
const camera = camData ? (await import("./parse-camera-CgV4bWc0.js")).parseBabylonCamera(camData) : void 0;
|
|
10005
11540
|
const rootMeshes = allMeshes.filter((m) => !childNodeIds.has(m.id));
|
|
10006
11541
|
const rootTransformNodes = [];
|
|
10007
11542
|
for (const [id, node] of nodeMap) {
|
|
@@ -10108,6 +11643,7 @@ async function loadEnvironment(scene, url, options) {
|
|
|
10108
11643
|
brdfImage.close();
|
|
10109
11644
|
const textures = assembleEnvironmentTextures(specularCube, brdfLut, irradianceSH, 0.8, engine);
|
|
10110
11645
|
scene._envTextures = textures;
|
|
11646
|
+
registerEnvSceneUniforms(scene);
|
|
10111
11647
|
acquireGPUTexture(specularCube);
|
|
10112
11648
|
acquireGPUTexture(brdfLut);
|
|
10113
11649
|
scene._disposables.push(() => {
|
|
@@ -10131,19 +11667,19 @@ async function loadEnvironment(scene, url, options) {
|
|
|
10131
11667
|
const { groundSize, skyboxSize: autoSkyboxSize, rootPosition } = computeSceneSize(scene, options == null ? void 0 : options.skyboxSize);
|
|
10132
11668
|
const skyHalfSize = autoSkyboxSize / 2;
|
|
10133
11669
|
if (!bgOptions.skipSkybox) {
|
|
10134
|
-
const { buildSolidSkyboxRenderable } = await import("./background-solid-skybox-
|
|
11670
|
+
const { buildSolidSkyboxRenderable } = await import("./background-solid-skybox-fjXlnWaD.js");
|
|
10135
11671
|
scene._renderables.push(buildSolidSkyboxRenderable(scene, textures, skyHalfSize, rootPosition, primaryColor));
|
|
10136
11672
|
}
|
|
10137
11673
|
if (!bgOptions.skipGround) {
|
|
10138
|
-
const { buildGroundRenderable } = await import("./background-ground-
|
|
11674
|
+
const { buildGroundRenderable } = await import("./background-ground-B2Mie-MI.js");
|
|
10139
11675
|
scene._renderables.push(await buildGroundRenderable(engine, groundSize, rootPosition, primaryColor, groundUrl, groundTexPromise));
|
|
10140
11676
|
}
|
|
10141
11677
|
if (skyboxIsDds) {
|
|
10142
|
-
const { buildDdsSkyboxRenderable } = await import("./background-dds-skybox-
|
|
11678
|
+
const { buildDdsSkyboxRenderable } = await import("./background-dds-skybox-ZjrSIxrT.js");
|
|
10143
11679
|
scene._renderables.push(await buildDdsSkyboxRenderable(scene, skyHalfSize, rootPosition, primaryColor, skyboxUrl));
|
|
10144
11680
|
}
|
|
10145
11681
|
if (skyboxIsEnv) {
|
|
10146
|
-
const { buildHdrSkyboxRenderable } = await import("./background-hdr-skybox-
|
|
11682
|
+
const { buildHdrSkyboxRenderable } = await import("./background-hdr-skybox-DDRJYuT2.js");
|
|
10147
11683
|
scene._renderables.push(buildHdrSkyboxRenderable(scene, textures, skyHalfSize, rootPosition, primaryColor));
|
|
10148
11684
|
}
|
|
10149
11685
|
});
|
|
@@ -10530,6 +12066,7 @@ async function loadHdrEnvironment(scene, url, options) {
|
|
|
10530
12066
|
const brdfLut = generateBrdfLut(engine);
|
|
10531
12067
|
const textures = assembleEnvironmentTextures(specularCube, brdfLut, irradianceSH, 1, engine);
|
|
10532
12068
|
scene._envTextures = textures;
|
|
12069
|
+
registerEnvSceneUniforms(scene);
|
|
10533
12070
|
acquireGPUTexture(specularCube);
|
|
10534
12071
|
acquireGPUTexture(brdfLut);
|
|
10535
12072
|
scene._disposables.push(() => {
|
|
@@ -10546,7 +12083,7 @@ async function loadHdrEnvironment(scene, url, options) {
|
|
|
10546
12083
|
const { computeSceneSize: computeSceneSize2 } = await Promise.resolve().then(() => sceneSize);
|
|
10547
12084
|
const { skyboxSize: autoSkyboxSize, rootPosition } = computeSceneSize2(scene, options == null ? void 0 : options.skyboxSize);
|
|
10548
12085
|
const primaryColor = scene.environmentPrimaryColor ?? [0.08697355964132344, 0.08697355964132344, 0.2122208331110881];
|
|
10549
|
-
const { buildHdrSkyboxRenderable } = await import("./background-hdr-skybox-
|
|
12086
|
+
const { buildHdrSkyboxRenderable } = await import("./background-hdr-skybox-DDRJYuT2.js");
|
|
10550
12087
|
scene._renderables.push(buildHdrSkyboxRenderable(scene, textures, autoSkyboxSize / 2, rootPosition, primaryColor));
|
|
10551
12088
|
}
|
|
10552
12089
|
if (!useHdr || !skipGround) {
|
|
@@ -10554,102 +12091,17 @@ async function loadHdrEnvironment(scene, url, options) {
|
|
|
10554
12091
|
const { computeSceneSize: computeSceneSize2 } = await Promise.resolve().then(() => sceneSize);
|
|
10555
12092
|
const { groundSize, skyboxSize: autoSkyboxSize, rootPosition } = computeSceneSize2(scene, options == null ? void 0 : options.skyboxSize);
|
|
10556
12093
|
if (!useHdr) {
|
|
10557
|
-
const { buildSolidSkyboxRenderable } = await import("./background-solid-skybox-
|
|
12094
|
+
const { buildSolidSkyboxRenderable } = await import("./background-solid-skybox-fjXlnWaD.js");
|
|
10558
12095
|
scene._renderables.push(buildSolidSkyboxRenderable(scene, textures, autoSkyboxSize / 2, rootPosition, primaryColor));
|
|
10559
12096
|
}
|
|
10560
12097
|
if (!skipGround) {
|
|
10561
|
-
const { buildGroundRenderable } = await import("./background-ground-
|
|
12098
|
+
const { buildGroundRenderable } = await import("./background-ground-B2Mie-MI.js");
|
|
10562
12099
|
scene._renderables.push(await buildGroundRenderable(engine, groundSize, rootPosition, primaryColor));
|
|
10563
12100
|
}
|
|
10564
12101
|
}
|
|
10565
12102
|
});
|
|
10566
12103
|
return textures;
|
|
10567
12104
|
}
|
|
10568
|
-
const BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;
|
|
10569
|
-
struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};
|
|
10570
|
-
@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1),p*vec2f(.5,-.5)+.5);}
|
|
10571
|
-
@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;
|
|
10572
|
-
let pipelineCache = null;
|
|
10573
|
-
let shaderModule = null;
|
|
10574
|
-
let linearSampler = null;
|
|
10575
|
-
let bindGroupLayout = null;
|
|
10576
|
-
let cachedDevice = null;
|
|
10577
|
-
function clearCache() {
|
|
10578
|
-
pipelineCache == null ? void 0 : pipelineCache.clear();
|
|
10579
|
-
pipelineCache = null;
|
|
10580
|
-
shaderModule = null;
|
|
10581
|
-
linearSampler = null;
|
|
10582
|
-
bindGroupLayout = null;
|
|
10583
|
-
cachedDevice = null;
|
|
10584
|
-
}
|
|
10585
|
-
function ensureResources(engine) {
|
|
10586
|
-
const device = engine._device;
|
|
10587
|
-
if (device !== cachedDevice) {
|
|
10588
|
-
clearCache();
|
|
10589
|
-
cachedDevice = device;
|
|
10590
|
-
}
|
|
10591
|
-
shaderModule ?? (shaderModule = device.createShaderModule({ code: BLIT_SHADER }));
|
|
10592
|
-
linearSampler ?? (linearSampler = getBilinearSampler(engine));
|
|
10593
|
-
bindGroupLayout ?? (bindGroupLayout = device.createBindGroupLayout({
|
|
10594
|
-
entries: [
|
|
10595
|
-
{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "float" } },
|
|
10596
|
-
{ binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} }
|
|
10597
|
-
]
|
|
10598
|
-
}));
|
|
10599
|
-
}
|
|
10600
|
-
function getPipeline(engine, format) {
|
|
10601
|
-
const device = engine._device;
|
|
10602
|
-
ensureResources(engine);
|
|
10603
|
-
pipelineCache ?? (pipelineCache = /* @__PURE__ */ new Map());
|
|
10604
|
-
let pipeline = pipelineCache.get(format);
|
|
10605
|
-
if (!pipeline) {
|
|
10606
|
-
pipeline = device.createRenderPipeline({
|
|
10607
|
-
layout: device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] }),
|
|
10608
|
-
vertex: { module: shaderModule, entryPoint: "vs" },
|
|
10609
|
-
fragment: { module: shaderModule, entryPoint: "fs", targets: [{ format }] },
|
|
10610
|
-
primitive: { topology: "triangle-list" }
|
|
10611
|
-
});
|
|
10612
|
-
pipelineCache.set(format, pipeline);
|
|
10613
|
-
}
|
|
10614
|
-
return pipeline;
|
|
10615
|
-
}
|
|
10616
|
-
function generateMipmaps(engine, texture, face) {
|
|
10617
|
-
const device = engine._device;
|
|
10618
|
-
const encoder = device.createCommandEncoder();
|
|
10619
|
-
recordMipmaps(engine, texture, encoder, face);
|
|
10620
|
-
device.queue.submit([encoder.finish()]);
|
|
10621
|
-
}
|
|
10622
|
-
function recordMipmaps(engine, texture, encoder, face) {
|
|
10623
|
-
if (texture.mipLevelCount <= 1) {
|
|
10624
|
-
return;
|
|
10625
|
-
}
|
|
10626
|
-
const device = engine._device;
|
|
10627
|
-
const pipeline = getPipeline(engine, texture.format);
|
|
10628
|
-
const vp = face != null ? { dimension: "2d", baseArrayLayer: face, arrayLayerCount: 1 } : {};
|
|
10629
|
-
for (let mip = 1; mip < texture.mipLevelCount; mip++) {
|
|
10630
|
-
const srcView = texture.createView({ baseMipLevel: mip - 1, mipLevelCount: 1, ...vp });
|
|
10631
|
-
const dstView = texture.createView({ baseMipLevel: mip, mipLevelCount: 1, ...vp });
|
|
10632
|
-
const bindGroup = device.createBindGroup({
|
|
10633
|
-
layout: bindGroupLayout,
|
|
10634
|
-
entries: [
|
|
10635
|
-
{ binding: 0, resource: srcView },
|
|
10636
|
-
{ binding: 1, resource: linearSampler }
|
|
10637
|
-
]
|
|
10638
|
-
});
|
|
10639
|
-
const pass = encoder.beginRenderPass({
|
|
10640
|
-
colorAttachments: [{ view: dstView, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
10641
|
-
});
|
|
10642
|
-
pass.setPipeline(pipeline);
|
|
10643
|
-
pass.setBindGroup(0, bindGroup);
|
|
10644
|
-
pass.draw(3);
|
|
10645
|
-
pass.end();
|
|
10646
|
-
}
|
|
10647
|
-
}
|
|
10648
|
-
const generateMipmaps$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10649
|
-
__proto__: null,
|
|
10650
|
-
generateMipmaps,
|
|
10651
|
-
recordMipmaps
|
|
10652
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
10653
12105
|
let _cc = null;
|
|
10654
12106
|
function loadCubeTexture(engine, baseUrl, ext = ".jpg") {
|
|
10655
12107
|
const device = engine._device;
|
|
@@ -10724,7 +12176,7 @@ async function loadSkybox(scene, baseUrl, ext, size = 100) {
|
|
|
10724
12176
|
idxCount: boxData.indices.length,
|
|
10725
12177
|
worldMatrix: world
|
|
10726
12178
|
};
|
|
10727
|
-
const { buildSkyboxRenderable } = await import("./skybox-renderable-
|
|
12179
|
+
const { buildSkyboxRenderable } = await import("./skybox-renderable-DDcCPSly.js");
|
|
10728
12180
|
scene._renderables.push(buildSkyboxRenderable(scene, skyboxData));
|
|
10729
12181
|
}
|
|
10730
12182
|
const SH_C0$2 = 0.28209479177387814;
|
|
@@ -11005,6 +12457,14 @@ function mat4Scale(x, y, z) {
|
|
|
11005
12457
|
out[15] = 1;
|
|
11006
12458
|
return out;
|
|
11007
12459
|
}
|
|
12460
|
+
function mat4Translation(x, y, z) {
|
|
12461
|
+
const out = mat4Identity();
|
|
12462
|
+
const s = out;
|
|
12463
|
+
s[12] = x;
|
|
12464
|
+
s[13] = y;
|
|
12465
|
+
s[14] = z;
|
|
12466
|
+
return out;
|
|
12467
|
+
}
|
|
11008
12468
|
function createGaussianSplattingMesh(engine, name, geom, worker, parsed) {
|
|
11009
12469
|
const device = engine._device;
|
|
11010
12470
|
const queue = device.queue;
|
|
@@ -11464,7 +12924,7 @@ async function attachParsedSplat(scene, name, parsed, fragments) {
|
|
|
11464
12924
|
const eng = scene.engine;
|
|
11465
12925
|
const mesh = createGaussianSplattingMesh(eng, name, geom, worker, parsed);
|
|
11466
12926
|
if (parsed.sh && parsed.shDegree && parsed.shDegree > 0) {
|
|
11467
|
-
const { attachGaussianSplattingMeshSH } = await import("./gaussian-splatting-pipeline-sh-
|
|
12927
|
+
const { attachGaussianSplattingMeshSH } = await import("./gaussian-splatting-pipeline-sh-BvkUhA9V.js");
|
|
11468
12928
|
attachGaussianSplattingMeshSH(scene, mesh, parsed.sh, fragments);
|
|
11469
12929
|
} else {
|
|
11470
12930
|
attachGaussianSplattingMesh(scene, mesh, fragments);
|
|
@@ -12162,7 +13622,7 @@ function createLinearDepthMaterial(options = {}) {
|
|
|
12162
13622
|
});
|
|
12163
13623
|
}
|
|
12164
13624
|
function writeShadowUboFields(out, sg) {
|
|
12165
|
-
out
|
|
13625
|
+
packMat4IntoF32(out, sg._lightMatrix, 0);
|
|
12166
13626
|
out[16] = sg._depthValues[0];
|
|
12167
13627
|
out[17] = sg._depthValues[1];
|
|
12168
13628
|
out[18] = 0;
|
|
@@ -12234,7 +13694,10 @@ function createShadowRenderTarget(sg, colorTexture = null, depthTexture = sg._de
|
|
|
12234
13694
|
_depthView: depthTexture.createView(),
|
|
12235
13695
|
_width: mapSize,
|
|
12236
13696
|
_height: mapSize,
|
|
12237
|
-
_eager: true
|
|
13697
|
+
_eager: true,
|
|
13698
|
+
// Borrowed: the depth map is the generator's shared shadow map (persists for the generator's
|
|
13699
|
+
// lifetime); per-task render-target disposal must NOT destroy it (it's reused after rebuilds).
|
|
13700
|
+
_ownsDepthTexture: false
|
|
12238
13701
|
};
|
|
12239
13702
|
}
|
|
12240
13703
|
function createSharedShadowUBO(engine, _lightMatrix, _depthValues, _shadowsInfo) {
|
|
@@ -12256,6 +13719,9 @@ function createShadowCamera(sg) {
|
|
|
12256
13719
|
nearPlane: 1,
|
|
12257
13720
|
farPlane: 1,
|
|
12258
13721
|
children: [],
|
|
13722
|
+
_viewCache: allocateMat4(),
|
|
13723
|
+
_projCache: allocateMat4(),
|
|
13724
|
+
_vpCache: allocateMat4(),
|
|
12259
13725
|
get worldMatrix() {
|
|
12260
13726
|
return sg._light.worldMatrix;
|
|
12261
13727
|
},
|
|
@@ -12304,21 +13770,21 @@ async function preloadEsmShadowTaskState(casterMeshes) {
|
|
|
12304
13770
|
}
|
|
12305
13771
|
if (needsStandard && !createStandardEsmShadowMaterialView) {
|
|
12306
13772
|
loads.push(
|
|
12307
|
-
import("./esm-shadow-view-
|
|
13773
|
+
import("./esm-shadow-view-DHVS9r7H.js").then((module) => {
|
|
12308
13774
|
createStandardEsmShadowMaterialView = module.createStandardEsmShadowMaterialView;
|
|
12309
13775
|
})
|
|
12310
13776
|
);
|
|
12311
13777
|
}
|
|
12312
13778
|
if (needsPbr && !createPbrEsmShadowMaterialView) {
|
|
12313
13779
|
loads.push(
|
|
12314
|
-
import("./esm-shadow-view-
|
|
13780
|
+
import("./esm-shadow-view-15S4JK6p.js").then((module) => {
|
|
12315
13781
|
createPbrEsmShadowMaterialView = module.createPbrEsmShadowMaterialView;
|
|
12316
13782
|
})
|
|
12317
13783
|
);
|
|
12318
13784
|
}
|
|
12319
13785
|
if (needsNode && !createNodeEsmShadowMaterialView) {
|
|
12320
13786
|
loads.push(
|
|
12321
|
-
import("./esm-shadow-view-
|
|
13787
|
+
import("./esm-shadow-view-DYAc62Kl.js").then((module) => {
|
|
12322
13788
|
createNodeEsmShadowMaterialView = module.createNodeEsmShadowMaterialView;
|
|
12323
13789
|
})
|
|
12324
13790
|
);
|
|
@@ -12492,7 +13958,7 @@ function renderEsmShadowMap(engine, sg, state) {
|
|
|
12492
13958
|
}
|
|
12493
13959
|
const matrix = _computeDirectionalLightMatrix$1(sg._light, casterMeshes, sg._config._orthoMinZ, sg._config._orthoMaxZ);
|
|
12494
13960
|
if (shadowMatrixChanged(sg._lightMatrix, matrix._viewProj)) {
|
|
12495
|
-
sg._lightMatrix
|
|
13961
|
+
packMat4IntoF32(sg._lightMatrix, matrix._viewProj, 0);
|
|
12496
13962
|
sg._version++;
|
|
12497
13963
|
writeShadowUboFields(resources._shadowUboData, sg);
|
|
12498
13964
|
engine._device.queue.writeBuffer(sg._shadowUBO, 0, resources._shadowUboData);
|
|
@@ -12681,17 +14147,20 @@ function createEsmDirectionalShadowGenerator(engine, _light, cfg = {}) {
|
|
|
12681
14147
|
let createStandardNoColorMaterialView;
|
|
12682
14148
|
let createPbrNoColorMaterialView;
|
|
12683
14149
|
let createNodeNoColorMaterialView;
|
|
14150
|
+
let createShaderNoColorMaterialView;
|
|
12684
14151
|
async function preloadPcfShadowTaskState(casterMeshes) {
|
|
12685
14152
|
var _a;
|
|
12686
14153
|
const loads = [];
|
|
12687
14154
|
let needsStandard = false;
|
|
12688
14155
|
let needsPbr = false;
|
|
12689
14156
|
let needsNode = false;
|
|
14157
|
+
let needsShader = false;
|
|
12690
14158
|
for (const mesh of casterMeshes) {
|
|
12691
14159
|
const family = (_a = mesh.material) == null ? void 0 : _a._buildGroup._materialFamily;
|
|
12692
14160
|
needsStandard || (needsStandard = family === "standard");
|
|
12693
14161
|
needsPbr || (needsPbr = family === "pbr");
|
|
12694
14162
|
needsNode || (needsNode = family === "node");
|
|
14163
|
+
needsShader || (needsShader = family === "shader");
|
|
12695
14164
|
}
|
|
12696
14165
|
if (needsStandard && !createStandardNoColorMaterialView) {
|
|
12697
14166
|
loads.push(
|
|
@@ -12714,6 +14183,13 @@ async function preloadPcfShadowTaskState(casterMeshes) {
|
|
|
12714
14183
|
})
|
|
12715
14184
|
);
|
|
12716
14185
|
}
|
|
14186
|
+
if (needsShader && !createShaderNoColorMaterialView) {
|
|
14187
|
+
loads.push(
|
|
14188
|
+
import("./no-color-view-DsyLSL-W.js").then((module) => {
|
|
14189
|
+
createShaderNoColorMaterialView = module.createShaderNoColorMaterialView;
|
|
14190
|
+
})
|
|
14191
|
+
);
|
|
14192
|
+
}
|
|
12717
14193
|
await Promise.all(loads);
|
|
12718
14194
|
}
|
|
12719
14195
|
function ensurePcfShadowTaskState(engine, scene, sg, casterMeshes, existingState) {
|
|
@@ -12764,7 +14240,7 @@ function renderPcfShadowMap(engine, sg, state, computeLightMatrix) {
|
|
|
12764
14240
|
const matrix = computeLightMatrix(casterMeshes);
|
|
12765
14241
|
const matrixChanged = sg._light.lightType === "directional" || lightVersion !== state._lastLightVersion;
|
|
12766
14242
|
if (matrixChanged) {
|
|
12767
|
-
sg._lightMatrix
|
|
14243
|
+
packMat4IntoF32(sg._lightMatrix, matrix._viewProj, 0);
|
|
12768
14244
|
sg._version++;
|
|
12769
14245
|
writeShadowUboFields(state._shadowUboData, sg);
|
|
12770
14246
|
engine._device.queue.writeBuffer(sg._shadowUBO, 0, state._shadowUboData);
|
|
@@ -12802,6 +14278,8 @@ function getNoColorView(material, cache) {
|
|
|
12802
14278
|
view = createPbrNoColorMaterialView(material);
|
|
12803
14279
|
} else if (family === "node") {
|
|
12804
14280
|
view = createNodeNoColorMaterialView(material);
|
|
14281
|
+
} else if (family === "shader") {
|
|
14282
|
+
view = createShaderNoColorMaterialView(material);
|
|
12805
14283
|
}
|
|
12806
14284
|
cache.set(material, view);
|
|
12807
14285
|
return view;
|
|
@@ -12965,6 +14443,513 @@ function createPcfDirectionalShadowGenerator(engine, _light, cfg = {}) {
|
|
|
12965
14443
|
};
|
|
12966
14444
|
return sg;
|
|
12967
14445
|
}
|
|
14446
|
+
const preloadCsmShadowTaskState = preloadPcfShadowTaskState;
|
|
14447
|
+
function ensureCsmShadowTaskState(engine, scene, sg, cfg, casterMeshes, existingState) {
|
|
14448
|
+
const existing = existingState;
|
|
14449
|
+
if (existing) {
|
|
14450
|
+
if (existing._casterMeshes === casterMeshes) {
|
|
14451
|
+
return existing;
|
|
14452
|
+
}
|
|
14453
|
+
existing._task.dispose();
|
|
14454
|
+
}
|
|
14455
|
+
const materialViews = /* @__PURE__ */ new Map();
|
|
14456
|
+
const n = cfg._numCascades;
|
|
14457
|
+
const tasks = [];
|
|
14458
|
+
const cameras = [];
|
|
14459
|
+
for (let i = 0; i < n; i++) {
|
|
14460
|
+
const layerView = sg._depthTexture.createView({ dimension: "2d", baseArrayLayer: i, arrayLayerCount: 1 });
|
|
14461
|
+
const rt = {
|
|
14462
|
+
_descriptor: {
|
|
14463
|
+
size: { width: cfg._mapSize, height: cfg._mapSize },
|
|
14464
|
+
depthStencilFormat: "depth32float",
|
|
14465
|
+
_depthClearValue: 1,
|
|
14466
|
+
_depthCompare: "less-equal",
|
|
14467
|
+
sampleCount: 1,
|
|
14468
|
+
flipY: false
|
|
14469
|
+
},
|
|
14470
|
+
_colorTexture: null,
|
|
14471
|
+
_colorView: null,
|
|
14472
|
+
_depthTexture: sg._depthTexture,
|
|
14473
|
+
_depthView: layerView,
|
|
14474
|
+
_width: cfg._mapSize,
|
|
14475
|
+
_height: cfg._mapSize,
|
|
14476
|
+
_eager: true,
|
|
14477
|
+
_ownsDepthTexture: false
|
|
14478
|
+
// borrowed: the shared CSM depth array is owned by the generator
|
|
14479
|
+
};
|
|
14480
|
+
const camera = createShadowCamera(sg);
|
|
14481
|
+
const task = createRenderTask({ name: `csm${i}`, rt, clr: true, cam: camera }, engine, scene);
|
|
14482
|
+
for (const mesh of casterMeshes) {
|
|
14483
|
+
const material = mesh.material;
|
|
14484
|
+
if (material) {
|
|
14485
|
+
task.addMesh(mesh, { material: getNoColorView(material, materialViews) });
|
|
14486
|
+
}
|
|
14487
|
+
}
|
|
14488
|
+
tasks.push(task);
|
|
14489
|
+
cameras.push(camera);
|
|
14490
|
+
}
|
|
14491
|
+
const compositeTask = {
|
|
14492
|
+
record() {
|
|
14493
|
+
for (const t of tasks) {
|
|
14494
|
+
t.record();
|
|
14495
|
+
}
|
|
14496
|
+
},
|
|
14497
|
+
execute() {
|
|
14498
|
+
var _a;
|
|
14499
|
+
let draws = 0;
|
|
14500
|
+
for (const t of tasks) {
|
|
14501
|
+
draws += ((_a = t.execute) == null ? void 0 : _a.call(t)) ?? 0;
|
|
14502
|
+
}
|
|
14503
|
+
return draws;
|
|
14504
|
+
},
|
|
14505
|
+
dispose() {
|
|
14506
|
+
for (const t of tasks) {
|
|
14507
|
+
t.dispose();
|
|
14508
|
+
}
|
|
14509
|
+
}
|
|
14510
|
+
};
|
|
14511
|
+
return {
|
|
14512
|
+
_task: compositeTask,
|
|
14513
|
+
_tasks: tasks,
|
|
14514
|
+
_cameras: cameras,
|
|
14515
|
+
_scene: scene,
|
|
14516
|
+
_cameraVersion: 0,
|
|
14517
|
+
_lastCasterVersion: -1,
|
|
14518
|
+
_lastLightVersion: -1,
|
|
14519
|
+
_lastCamVersion: -1,
|
|
14520
|
+
_uboData: new Float32Array(80),
|
|
14521
|
+
_casterMeshes: casterMeshes
|
|
14522
|
+
};
|
|
14523
|
+
}
|
|
14524
|
+
function renderCsmShadowMap(engine, sg, state, cfg) {
|
|
14525
|
+
var _a, _b;
|
|
14526
|
+
const casterMeshes = state._casterMeshes;
|
|
14527
|
+
const camera = state._scene.camera;
|
|
14528
|
+
if (!camera) {
|
|
14529
|
+
return 0;
|
|
14530
|
+
}
|
|
14531
|
+
const casterVersion = casterVersionSum(casterMeshes);
|
|
14532
|
+
const lightVersion = sg._light.worldMatrixVersion;
|
|
14533
|
+
const camVersion = camera.worldMatrixVersion;
|
|
14534
|
+
if (!cfg._forceRefreshEveryFrame && casterVersion === state._lastCasterVersion && lightVersion === state._lastLightVersion && camVersion === state._lastCamVersion) {
|
|
14535
|
+
return 0;
|
|
14536
|
+
}
|
|
14537
|
+
const cascades = _computeCsmCascades(engine, camera, sg._light, cfg, casterMeshes);
|
|
14538
|
+
_writeCsmUbo(state._uboData, cascades, cfg);
|
|
14539
|
+
sg._version++;
|
|
14540
|
+
engine._device.queue.writeBuffer(sg._shadowUBO, 0, state._uboData);
|
|
14541
|
+
const receiverCbs = sg._onReceiverData;
|
|
14542
|
+
if (receiverCbs) {
|
|
14543
|
+
for (let i = 0; i < receiverCbs.length; i++) {
|
|
14544
|
+
receiverCbs[i](state._uboData);
|
|
14545
|
+
}
|
|
14546
|
+
}
|
|
14547
|
+
state._cameraVersion++;
|
|
14548
|
+
for (let i = 0; i < cascades._transforms.length; i++) {
|
|
14549
|
+
const cam = state._cameras[i];
|
|
14550
|
+
cam.fov = 1;
|
|
14551
|
+
updateShadowCameraBase(cam, state._cameraVersion, cascades._near[i], cascades._far[i], cascades._views[i], _biasViewProjection(cascades._biased[i], cfg._bias));
|
|
14552
|
+
}
|
|
14553
|
+
state._lastCasterVersion = casterVersion;
|
|
14554
|
+
state._lastLightVersion = lightVersion;
|
|
14555
|
+
state._lastCamVersion = camVersion;
|
|
14556
|
+
return ((_b = (_a = state._task).execute) == null ? void 0 : _b.call(_a)) ?? 0;
|
|
14557
|
+
}
|
|
14558
|
+
const FRUSTUM_NDC = [
|
|
14559
|
+
[-1, 1, 1],
|
|
14560
|
+
[1, 1, 1],
|
|
14561
|
+
[1, -1, 1],
|
|
14562
|
+
[-1, -1, 1],
|
|
14563
|
+
[-1, 1, 0],
|
|
14564
|
+
[1, 1, 0],
|
|
14565
|
+
[1, -1, 0],
|
|
14566
|
+
[-1, -1, 0]
|
|
14567
|
+
];
|
|
14568
|
+
function transformCoord(m, x, y, z) {
|
|
14569
|
+
const X = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
14570
|
+
const Y = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
14571
|
+
const Z = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
14572
|
+
const W = m[3] * x + m[7] * y + m[11] * z + m[15];
|
|
14573
|
+
return [X / W, Y / W, Z / W];
|
|
14574
|
+
}
|
|
14575
|
+
function orthoOffCenterLH(l, r, b, t, n, f) {
|
|
14576
|
+
const m = new Float32Array(16);
|
|
14577
|
+
m[0] = 2 / (r - l);
|
|
14578
|
+
m[5] = 2 / (t - b);
|
|
14579
|
+
m[10] = 1 / (f - n);
|
|
14580
|
+
m[12] = -(r + l) / (r - l);
|
|
14581
|
+
m[13] = -(t + b) / (t - b);
|
|
14582
|
+
m[14] = -n / (f - n);
|
|
14583
|
+
m[15] = 1;
|
|
14584
|
+
return m;
|
|
14585
|
+
}
|
|
14586
|
+
function _computeCsmCascades(engine, camera, light, cfg, casterMeshes) {
|
|
14587
|
+
const near = camera.nearPlane;
|
|
14588
|
+
const far = camera.farPlane;
|
|
14589
|
+
const cameraRange = far - near;
|
|
14590
|
+
const shadowMaxZ = cfg._shadowMaxZ ?? far;
|
|
14591
|
+
const maxDistance = shadowMaxZ < far && shadowMaxZ >= near ? Math.min((shadowMaxZ - near) / (far - near), 1) : 1;
|
|
14592
|
+
const minDistance = 0;
|
|
14593
|
+
const minZ = near + minDistance * cameraRange;
|
|
14594
|
+
const maxZ = near + maxDistance * cameraRange;
|
|
14595
|
+
const range = maxZ - minZ;
|
|
14596
|
+
const ratio = maxZ / minZ;
|
|
14597
|
+
const n = cfg._numCascades;
|
|
14598
|
+
const breakDist = [];
|
|
14599
|
+
const viewFrustumZ = [];
|
|
14600
|
+
const frustumLengths = [];
|
|
14601
|
+
for (let i = 0; i < n; i++) {
|
|
14602
|
+
const p = (i + 1) / n;
|
|
14603
|
+
const log = minZ * ratio ** p;
|
|
14604
|
+
const uniform = minZ + range * p;
|
|
14605
|
+
const d = cfg._lambda * (log - uniform) + uniform;
|
|
14606
|
+
const prevBreak = i === 0 ? minDistance : breakDist[i - 1];
|
|
14607
|
+
breakDist[i] = (d - near) / cameraRange;
|
|
14608
|
+
viewFrustumZ[i] = d;
|
|
14609
|
+
frustumLengths[i] = (breakDist[i] - prevBreak) * cameraRange;
|
|
14610
|
+
}
|
|
14611
|
+
let dx = light.direction.x;
|
|
14612
|
+
let dy = light.direction.y;
|
|
14613
|
+
let dz = light.direction.z;
|
|
14614
|
+
const dl = Math.hypot(dx, dy, dz) || 1;
|
|
14615
|
+
dx /= dl;
|
|
14616
|
+
dy /= dl;
|
|
14617
|
+
dz /= dl;
|
|
14618
|
+
if (Math.abs(dy) >= 1) {
|
|
14619
|
+
dz = 1e-13;
|
|
14620
|
+
}
|
|
14621
|
+
const aspect = engine.canvas.width / engine.canvas.height;
|
|
14622
|
+
const vp = getViewProjectionMatrix(camera, aspect);
|
|
14623
|
+
const inv = mat4Invert(vp);
|
|
14624
|
+
const invViewProj = inv ?? vp;
|
|
14625
|
+
const aabb = _castersWorldAabb(casterMeshes);
|
|
14626
|
+
const transforms = [];
|
|
14627
|
+
const views = [];
|
|
14628
|
+
const nearOut = [];
|
|
14629
|
+
const farOut = [];
|
|
14630
|
+
for (let c = 0; c < n; c++) {
|
|
14631
|
+
const prevSplit = c === 0 ? 0 : breakDist[c - 1];
|
|
14632
|
+
const split = breakDist[c];
|
|
14633
|
+
const corners = [];
|
|
14634
|
+
for (let k = 0; k < 8; k++) {
|
|
14635
|
+
const ndc = FRUSTUM_NDC[k];
|
|
14636
|
+
corners.push(transformCoord(invViewProj, ndc[0], ndc[1], ndc[2]));
|
|
14637
|
+
}
|
|
14638
|
+
for (let k = 0; k < 4; k++) {
|
|
14639
|
+
const nearC = corners[k];
|
|
14640
|
+
const farC = corners[k + 4];
|
|
14641
|
+
const rx = farC[0] - nearC[0];
|
|
14642
|
+
const ry = farC[1] - nearC[1];
|
|
14643
|
+
const rz = farC[2] - nearC[2];
|
|
14644
|
+
corners[k + 4] = [nearC[0] + rx * split, nearC[1] + ry * split, nearC[2] + rz * split];
|
|
14645
|
+
corners[k] = [nearC[0] + rx * prevSplit, nearC[1] + ry * prevSplit, nearC[2] + rz * prevSplit];
|
|
14646
|
+
}
|
|
14647
|
+
let cx = 0, cy = 0, cz = 0;
|
|
14648
|
+
for (const p of corners) {
|
|
14649
|
+
cx += p[0];
|
|
14650
|
+
cy += p[1];
|
|
14651
|
+
cz += p[2];
|
|
14652
|
+
}
|
|
14653
|
+
cx /= 8;
|
|
14654
|
+
cy /= 8;
|
|
14655
|
+
cz /= 8;
|
|
14656
|
+
let minX, maxX, minY, maxY, minEz, maxEz;
|
|
14657
|
+
if (cfg._stabilizeCascades) {
|
|
14658
|
+
let radius = 0;
|
|
14659
|
+
for (const p of corners) {
|
|
14660
|
+
radius = Math.max(radius, Math.hypot(p[0] - cx, p[1] - cy, p[2] - cz));
|
|
14661
|
+
}
|
|
14662
|
+
radius = Math.ceil(radius * 16) / 16;
|
|
14663
|
+
minX = minY = minEz = -radius;
|
|
14664
|
+
maxX = maxY = maxEz = radius;
|
|
14665
|
+
} else {
|
|
14666
|
+
const tmpView = buildLightViewMatrix(dx, dy, dz, cx, cy, cz);
|
|
14667
|
+
minX = minY = minEz = Infinity;
|
|
14668
|
+
maxX = maxY = maxEz = -Infinity;
|
|
14669
|
+
for (const p of corners) {
|
|
14670
|
+
const lp = transformCoord(tmpView, p[0], p[1], p[2]);
|
|
14671
|
+
minX = Math.min(minX, lp[0]);
|
|
14672
|
+
maxX = Math.max(maxX, lp[0]);
|
|
14673
|
+
minY = Math.min(minY, lp[1]);
|
|
14674
|
+
maxY = Math.max(maxY, lp[1]);
|
|
14675
|
+
minEz = Math.min(minEz, lp[2]);
|
|
14676
|
+
maxEz = Math.max(maxEz, lp[2]);
|
|
14677
|
+
}
|
|
14678
|
+
}
|
|
14679
|
+
const eyeX = cx + dx * minEz;
|
|
14680
|
+
const eyeY = cy + dy * minEz;
|
|
14681
|
+
const eyeZ = cz + dz * minEz;
|
|
14682
|
+
const view = buildLightViewMatrix(dx, dy, dz, eyeX, eyeY, eyeZ);
|
|
14683
|
+
let viewMinZ = 0;
|
|
14684
|
+
let viewMaxZ = maxEz - minEz;
|
|
14685
|
+
if (aabb) {
|
|
14686
|
+
let cMinZ = Infinity;
|
|
14687
|
+
let cMaxZ = -Infinity;
|
|
14688
|
+
for (let k = 0; k < 8; k++) {
|
|
14689
|
+
const wx = k & 1 ? aabb._max[0] : aabb._min[0];
|
|
14690
|
+
const wy = k & 2 ? aabb._max[1] : aabb._min[1];
|
|
14691
|
+
const wz = k & 4 ? aabb._max[2] : aabb._min[2];
|
|
14692
|
+
const lz = view[2] * wx + view[6] * wy + view[10] * wz + view[14];
|
|
14693
|
+
cMinZ = Math.min(cMinZ, lz);
|
|
14694
|
+
cMaxZ = Math.max(cMaxZ, lz);
|
|
14695
|
+
}
|
|
14696
|
+
if (cMinZ <= viewMaxZ) {
|
|
14697
|
+
viewMinZ = Math.min(viewMinZ, cMinZ);
|
|
14698
|
+
viewMaxZ = Math.min(viewMaxZ, cMaxZ);
|
|
14699
|
+
}
|
|
14700
|
+
}
|
|
14701
|
+
const proj0 = orthoOffCenterLH(minX, maxX, minY, maxY, viewMinZ, viewMaxZ);
|
|
14702
|
+
let transform = multiply4x4(proj0, view);
|
|
14703
|
+
const ox = transform[12] * (cfg._mapSize / 2);
|
|
14704
|
+
const oy = transform[13] * (cfg._mapSize / 2);
|
|
14705
|
+
const offX = (Math.round(ox) - ox) * (2 / cfg._mapSize);
|
|
14706
|
+
const offY = (Math.round(oy) - oy) * (2 / cfg._mapSize);
|
|
14707
|
+
const snap = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, offX, offY, 0, 1]);
|
|
14708
|
+
const proj = multiply4x4(snap, proj0);
|
|
14709
|
+
transform = multiply4x4(proj, view);
|
|
14710
|
+
transforms.push(transform);
|
|
14711
|
+
views.push(view);
|
|
14712
|
+
nearOut.push(viewMinZ);
|
|
14713
|
+
farOut.push(viewMaxZ);
|
|
14714
|
+
}
|
|
14715
|
+
return {
|
|
14716
|
+
_transforms: transforms,
|
|
14717
|
+
_biased: transforms.map((t) => new Float32Array(t)),
|
|
14718
|
+
_views: views,
|
|
14719
|
+
_near: nearOut,
|
|
14720
|
+
_far: farOut,
|
|
14721
|
+
_viewFrustumZ: viewFrustumZ,
|
|
14722
|
+
_frustumLengths: frustumLengths
|
|
14723
|
+
};
|
|
14724
|
+
}
|
|
14725
|
+
function _castersWorldAabb(casterMeshes) {
|
|
14726
|
+
let minX = Infinity, minY = Infinity, minZ = Infinity, maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
|
|
14727
|
+
for (const mesh of casterMeshes) {
|
|
14728
|
+
const world = mesh.worldMatrix;
|
|
14729
|
+
const bmin = mesh.boundMin ?? [-0.5, -0.5, -0.5];
|
|
14730
|
+
const bmax = mesh.boundMax ?? [0.5, 0.5, 0.5];
|
|
14731
|
+
for (let k = 0; k < 8; k++) {
|
|
14732
|
+
const lx = k & 1 ? bmax[0] : bmin[0];
|
|
14733
|
+
const ly = k & 2 ? bmax[1] : bmin[1];
|
|
14734
|
+
const lz = k & 4 ? bmax[2] : bmin[2];
|
|
14735
|
+
const wx = world[0] * lx + world[4] * ly + world[8] * lz + world[12];
|
|
14736
|
+
const wy = world[1] * lx + world[5] * ly + world[9] * lz + world[13];
|
|
14737
|
+
const wz = world[2] * lx + world[6] * ly + world[10] * lz + world[14];
|
|
14738
|
+
minX = Math.min(minX, wx);
|
|
14739
|
+
maxX = Math.max(maxX, wx);
|
|
14740
|
+
minY = Math.min(minY, wy);
|
|
14741
|
+
maxY = Math.max(maxY, wy);
|
|
14742
|
+
minZ = Math.min(minZ, wz);
|
|
14743
|
+
maxZ = Math.max(maxZ, wz);
|
|
14744
|
+
}
|
|
14745
|
+
}
|
|
14746
|
+
if (!Number.isFinite(minX)) {
|
|
14747
|
+
return null;
|
|
14748
|
+
}
|
|
14749
|
+
return { _min: [minX, minY, minZ], _max: [maxX, maxY, maxZ] };
|
|
14750
|
+
}
|
|
14751
|
+
function _writeCsmUbo(out, cascades, cfg) {
|
|
14752
|
+
out.fill(0);
|
|
14753
|
+
const n = cascades._transforms.length;
|
|
14754
|
+
for (let i = 0; i < n; i++) {
|
|
14755
|
+
out.set(cascades._transforms[i], i * 16);
|
|
14756
|
+
}
|
|
14757
|
+
for (let i = 0; i < n; i++) {
|
|
14758
|
+
out[64 + i] = cascades._viewFrustumZ[i];
|
|
14759
|
+
out[68 + i] = cascades._frustumLengths[i];
|
|
14760
|
+
}
|
|
14761
|
+
out[72] = cfg._darkness;
|
|
14762
|
+
out[73] = cfg._mapSize;
|
|
14763
|
+
out[74] = 1 / cfg._mapSize;
|
|
14764
|
+
out[75] = cfg._frustumEdgeFalloff;
|
|
14765
|
+
out[76] = n;
|
|
14766
|
+
out[77] = cfg._cascadeBlendPercentage === 0 ? 1e4 : 1 / cfg._cascadeBlendPercentage;
|
|
14767
|
+
}
|
|
14768
|
+
function _biasViewProjection(viewProj, bias) {
|
|
14769
|
+
const biased = new Float32Array(viewProj);
|
|
14770
|
+
const b = bias * 0.5;
|
|
14771
|
+
for (let col = 0; col < 4; col++) {
|
|
14772
|
+
const z = 2 + col * 4;
|
|
14773
|
+
const w = 3 + col * 4;
|
|
14774
|
+
biased[z] = biased[z] + b * biased[w];
|
|
14775
|
+
}
|
|
14776
|
+
return biased;
|
|
14777
|
+
}
|
|
14778
|
+
let _stdFactory = null;
|
|
14779
|
+
function setCsmStdReceiverFactory(f) {
|
|
14780
|
+
_stdFactory = f;
|
|
14781
|
+
}
|
|
14782
|
+
function getCsmStdReceiverFactory() {
|
|
14783
|
+
return _stdFactory;
|
|
14784
|
+
}
|
|
14785
|
+
let _pbrFactory = null;
|
|
14786
|
+
function setCsmPbrReceiverFactory(f) {
|
|
14787
|
+
_pbrFactory = f;
|
|
14788
|
+
}
|
|
14789
|
+
function getCsmPbrReceiverFactory() {
|
|
14790
|
+
return _pbrFactory;
|
|
14791
|
+
}
|
|
14792
|
+
const STAGE_FRAGMENT = 2;
|
|
14793
|
+
function createCsmShadowFragment(id, shadowLights, opts = {}) {
|
|
14794
|
+
const worldPosExpr = opts.worldPosExpr ?? "input.vp";
|
|
14795
|
+
const viewZExpr = opts.viewZExpr ?? "input.vf.z";
|
|
14796
|
+
const outputSlot = opts.outputSlot ?? "AD";
|
|
14797
|
+
const varyings = [];
|
|
14798
|
+
const bindings = [];
|
|
14799
|
+
const fragmentLines = [];
|
|
14800
|
+
const helperParts = [];
|
|
14801
|
+
for (const slot of shadowLights) {
|
|
14802
|
+
const li = slot.lightIndex;
|
|
14803
|
+
const suffix = `_${li}`;
|
|
14804
|
+
bindings.push(
|
|
14805
|
+
{ _name: `csmTex${suffix}`, _type: { _kind: "texture", _textureType: "texture_depth_2d_array", _sampleType: "depth" }, _group: "shadow", _visibility: STAGE_FRAGMENT },
|
|
14806
|
+
{ _name: `csmComp${suffix}`, _type: { _kind: "sampler", _samplerType: "sampler_comparison" }, _group: "shadow", _visibility: STAGE_FRAGMENT },
|
|
14807
|
+
{ _name: `csmInfo${suffix}`, _type: { _kind: "uniform-buffer" }, _group: "shadow", _visibility: STAGE_FRAGMENT }
|
|
14808
|
+
);
|
|
14809
|
+
helperParts.push(
|
|
14810
|
+
`struct csmInfo${suffix}Uniforms { cascadeTransforms: array<mat4x4<f32>, 4>, viewFrustumZ: vec4<f32>, frustumLengths: vec4<f32>, shadowsInfo: vec4<f32>, csmParams: vec4<f32> };`
|
|
14811
|
+
);
|
|
14812
|
+
helperParts.push(`
|
|
14813
|
+
fn computeFallOffCsm${suffix}(value: f32, clipSpace: vec2<f32>, frustumEdgeFalloff: f32) -> f32 {
|
|
14814
|
+
let mask = smoothstep(1.0 - frustumEdgeFalloff, 1.00000012, clamp(dot(clipSpace, clipSpace), 0.0, 1.0));
|
|
14815
|
+
return mix(value, 1.0, mask);
|
|
14816
|
+
}
|
|
14817
|
+
fn csmSample${suffix}(layer: i32, worldPos: vec4<f32>) -> f32 {
|
|
14818
|
+
let posFromLight = csmInfo${suffix}.cascadeTransforms[layer] * worldPos;
|
|
14819
|
+
let clipSpace = posFromLight.xyz / posFromLight.w;
|
|
14820
|
+
let uv = vec2<f32>(0.5 * clipSpace.x + 0.5, 0.5 - 0.5 * clipSpace.y);
|
|
14821
|
+
let depthRef = clamp(clipSpace.z, 0.0, 0.99999994);
|
|
14822
|
+
let mapSz = csmInfo${suffix}.shadowsInfo.y;
|
|
14823
|
+
let invMapSz = csmInfo${suffix}.shadowsInfo.z;
|
|
14824
|
+
var tc = uv * mapSz + 0.5;
|
|
14825
|
+
let st = fract(tc);
|
|
14826
|
+
let base = (floor(tc) - 0.5) * invMapSz;
|
|
14827
|
+
let uvw0 = 4.0 - 3.0 * st;
|
|
14828
|
+
let uvw1 = vec2<f32>(7.0);
|
|
14829
|
+
let uvw2 = 1.0 + 3.0 * st;
|
|
14830
|
+
let u = vec3<f32>((3.0 - 2.0 * st.x) / uvw0.x - 2.0, (3.0 + st.x) / uvw1.x, st.x / uvw2.x + 2.0) * invMapSz;
|
|
14831
|
+
let v = vec3<f32>((3.0 - 2.0 * st.y) / uvw0.y - 2.0, (3.0 + st.y) / uvw1.y, st.y / uvw2.y + 2.0) * invMapSz;
|
|
14832
|
+
var sh = 0.0;
|
|
14833
|
+
sh += uvw0.x * uvw0.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[0], v[0]), layer, depthRef);
|
|
14834
|
+
sh += uvw1.x * uvw0.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[1], v[0]), layer, depthRef);
|
|
14835
|
+
sh += uvw2.x * uvw0.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[2], v[0]), layer, depthRef);
|
|
14836
|
+
sh += uvw0.x * uvw1.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[0], v[1]), layer, depthRef);
|
|
14837
|
+
sh += uvw1.x * uvw1.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[1], v[1]), layer, depthRef);
|
|
14838
|
+
sh += uvw2.x * uvw1.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[2], v[1]), layer, depthRef);
|
|
14839
|
+
sh += uvw0.x * uvw2.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[0], v[2]), layer, depthRef);
|
|
14840
|
+
sh += uvw1.x * uvw2.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[1], v[2]), layer, depthRef);
|
|
14841
|
+
sh += uvw2.x * uvw2.y * textureSampleCompareLevel(csmTex${suffix}, csmComp${suffix}, base + vec2<f32>(u[2], v[2]), layer, depthRef);
|
|
14842
|
+
sh /= 144.0;
|
|
14843
|
+
sh = mix(csmInfo${suffix}.shadowsInfo.x, 1.0, sh);
|
|
14844
|
+
return computeFallOffCsm${suffix}(sh, clipSpace.xy, csmInfo${suffix}.shadowsInfo.w);
|
|
14845
|
+
}
|
|
14846
|
+
fn computeShadowCSM${suffix}(worldPos: vec4<f32>, viewZ: f32) -> f32 {
|
|
14847
|
+
let nCascades = i32(csmInfo${suffix}.csmParams.x);
|
|
14848
|
+
var idx = -1;
|
|
14849
|
+
var diff = 0.0;
|
|
14850
|
+
for (var i = 0; i < nCascades; i = i + 1) {
|
|
14851
|
+
diff = csmInfo${suffix}.viewFrustumZ[i] - viewZ;
|
|
14852
|
+
if (diff >= 0.0) { idx = i; break; }
|
|
14853
|
+
}
|
|
14854
|
+
if (idx < 0) { idx = nCascades - 1; }
|
|
14855
|
+
var shadow = csmSample${suffix}(idx, worldPos);
|
|
14856
|
+
let frustumLength = csmInfo${suffix}.frustumLengths[idx];
|
|
14857
|
+
let diffRatio = clamp(diff / frustumLength, 0.0, 1.0) * csmInfo${suffix}.csmParams.y;
|
|
14858
|
+
if (idx < nCascades - 1 && diffRatio < 1.0) {
|
|
14859
|
+
let nextShadow = csmSample${suffix}(idx + 1, worldPos);
|
|
14860
|
+
shadow = mix(nextShadow, shadow, diffRatio);
|
|
14861
|
+
}
|
|
14862
|
+
return shadow;
|
|
14863
|
+
}`);
|
|
14864
|
+
fragmentLines.push(`shadowFactors[${li}] = computeShadowCSM${suffix}(vec4<f32>(${worldPosExpr}, 1.0), ${viewZExpr});`);
|
|
14865
|
+
}
|
|
14866
|
+
return {
|
|
14867
|
+
_id: id,
|
|
14868
|
+
_varyings: varyings,
|
|
14869
|
+
_bindings: bindings,
|
|
14870
|
+
_helperFunctions: helperParts.join("\n"),
|
|
14871
|
+
_fragmentSlots: {
|
|
14872
|
+
[outputSlot]: fragmentLines.join("\n")
|
|
14873
|
+
}
|
|
14874
|
+
};
|
|
14875
|
+
}
|
|
14876
|
+
function createStdCsmShadowFragment(shadowLights) {
|
|
14877
|
+
return createCsmShadowFragment("std-csm-shadow", shadowLights);
|
|
14878
|
+
}
|
|
14879
|
+
function createPbrCsmShadowFragment(shadowLights) {
|
|
14880
|
+
return createCsmShadowFragment("pbr-csm-shadow", shadowLights, {
|
|
14881
|
+
worldPosExpr: "input.worldPos",
|
|
14882
|
+
viewZExpr: "(scene.view * vec4<f32>(input.worldPos, 1.0)).z",
|
|
14883
|
+
outputSlot: "AS"
|
|
14884
|
+
});
|
|
14885
|
+
}
|
|
14886
|
+
function createCsmDirectionalShadowGenerator(engine, _light, cfg = {}) {
|
|
14887
|
+
setCsmStdReceiverFactory(createStdCsmShadowFragment);
|
|
14888
|
+
setCsmPbrReceiverFactory(createPbrCsmShadowFragment);
|
|
14889
|
+
const device = engine._device;
|
|
14890
|
+
const mapSize = cfg.mapSize ?? 1024;
|
|
14891
|
+
const numCascades = Math.min(cfg.numCascades ?? 4, 4);
|
|
14892
|
+
const bias = cfg.bias ?? 5e-5;
|
|
14893
|
+
const darkness = cfg.darkness ?? 0;
|
|
14894
|
+
const frustumEdgeFalloff = cfg.frustumEdgeFalloff ?? 0;
|
|
14895
|
+
const csmCfg = {
|
|
14896
|
+
_numCascades: numCascades,
|
|
14897
|
+
_lambda: cfg.lambda ?? 0.5,
|
|
14898
|
+
_cascadeBlendPercentage: cfg.cascadeBlendPercentage ?? 0.1,
|
|
14899
|
+
_stabilizeCascades: cfg.stabilizeCascades ?? false,
|
|
14900
|
+
_shadowMaxZ: cfg.shadowMaxZ ?? null,
|
|
14901
|
+
_bias: bias,
|
|
14902
|
+
_darkness: darkness,
|
|
14903
|
+
_frustumEdgeFalloff: frustumEdgeFalloff,
|
|
14904
|
+
_mapSize: mapSize,
|
|
14905
|
+
_forceRefreshEveryFrame: cfg.forceRefreshEveryFrame ?? false
|
|
14906
|
+
};
|
|
14907
|
+
const depthTexture = device.createTexture({
|
|
14908
|
+
size: { width: mapSize, height: mapSize, depthOrArrayLayers: numCascades },
|
|
14909
|
+
format: "depth32float",
|
|
14910
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
14911
|
+
});
|
|
14912
|
+
const _shadowsInfo = new Float32Array([darkness, mapSize, 1 / mapSize, frustumEdgeFalloff]);
|
|
14913
|
+
const sg = {
|
|
14914
|
+
_shadowType: "csm",
|
|
14915
|
+
_light,
|
|
14916
|
+
_depthTexture: depthTexture,
|
|
14917
|
+
_depthSampler: device.createSampler({ compare: "less", magFilter: "linear", minFilter: "linear" }),
|
|
14918
|
+
_lightMatrix: new Float32Array(16),
|
|
14919
|
+
_shadowsInfo,
|
|
14920
|
+
_depthValues: new Float32Array([0, 1]),
|
|
14921
|
+
_shadowParamsUBO: createShadowParamsUBO(engine, bias, 1 / mapSize),
|
|
14922
|
+
_shadowUBO: createUniformBuffer$1(engine, new Float32Array(80)),
|
|
14923
|
+
_config: {
|
|
14924
|
+
_mapSize: mapSize,
|
|
14925
|
+
_bias: bias,
|
|
14926
|
+
_forceRefreshEveryFrame: csmCfg._forceRefreshEveryFrame
|
|
14927
|
+
},
|
|
14928
|
+
_version: 0,
|
|
14929
|
+
_csmCascadeCount: numCascades
|
|
14930
|
+
};
|
|
14931
|
+
sg._preloadShadowTask = preloadCsmShadowTaskState;
|
|
14932
|
+
sg._ensureShadowTaskState = (eng, scene, casterMeshes) => {
|
|
14933
|
+
const state = ensureCsmShadowTaskState(eng, scene, sg, csmCfg, casterMeshes, sg._shadowTaskState ?? null);
|
|
14934
|
+
sg._shadowTaskState = state;
|
|
14935
|
+
return state;
|
|
14936
|
+
};
|
|
14937
|
+
sg._renderShadowMap = (eng, state) => renderCsmShadowMap(eng, sg, state, csmCfg);
|
|
14938
|
+
return sg;
|
|
14939
|
+
}
|
|
14940
|
+
function onCsmReceiverUpdate(sg, cb) {
|
|
14941
|
+
(sg._onReceiverData ?? (sg._onReceiverData = [])).push(cb);
|
|
14942
|
+
return () => {
|
|
14943
|
+
const list = sg._onReceiverData;
|
|
14944
|
+
if (!list) {
|
|
14945
|
+
return;
|
|
14946
|
+
}
|
|
14947
|
+
const i = list.indexOf(cb);
|
|
14948
|
+
if (i >= 0) {
|
|
14949
|
+
list.splice(i, 1);
|
|
14950
|
+
}
|
|
14951
|
+
};
|
|
14952
|
+
}
|
|
12968
14953
|
const INTERP_LINEAR = 0;
|
|
12969
14954
|
const INTERP_STEP = 1;
|
|
12970
14955
|
const INTERP_CUBICSPLINE = 2;
|
|
@@ -14990,7 +16975,7 @@ async function pickAsync(picker, x, y) {
|
|
|
14990
16975
|
const gsMeshCount = gsMeshes.length;
|
|
14991
16976
|
const gsNextIdStart = nextId;
|
|
14992
16977
|
if (gsMeshCount > 0) {
|
|
14993
|
-
const gsModule = await import("./gs-picking-pipeline-
|
|
16978
|
+
const gsModule = await import("./gs-picking-pipeline-Bx8LTav6.js");
|
|
14994
16979
|
gsModule.computeGsPickMatrix(_gsPickMatrix, px, py, w, h);
|
|
14995
16980
|
gsModule.gsPickWritePickMatrixAndBind(pass, engine, _gsPickMatrix);
|
|
14996
16981
|
const resMap = picker._gsMeshResources ?? (picker._gsMeshResources = /* @__PURE__ */ new Map());
|
|
@@ -15097,7 +17082,7 @@ function disposePicker(picker) {
|
|
|
15097
17082
|
picker._sceneBG = null;
|
|
15098
17083
|
}
|
|
15099
17084
|
if (picker._gsMeshResources) {
|
|
15100
|
-
void import("./gs-picking-pipeline-
|
|
17085
|
+
void import("./gs-picking-pipeline-Bx8LTav6.js").then((m) => {
|
|
15101
17086
|
if (!picker._gsMeshResources) {
|
|
15102
17087
|
return;
|
|
15103
17088
|
}
|
|
@@ -17504,7 +19489,7 @@ function isBillboardSpriteHandleAlive(handle) {
|
|
|
17504
19489
|
}
|
|
17505
19490
|
function addBillboardSystem(scene, system) {
|
|
17506
19491
|
addDeferredSceneRenderables(scene, async (engine) => {
|
|
17507
|
-
const { buildBillboardRenderable } = await import("./billboard-renderable-
|
|
19492
|
+
const { buildBillboardRenderable } = await import("./billboard-renderable-DKmlOgbM.js");
|
|
17508
19493
|
const built = buildBillboardRenderable(engine, system);
|
|
17509
19494
|
return { renderables: [built.renderable], dispose: built.dispose };
|
|
17510
19495
|
});
|
|
@@ -18762,461 +20747,486 @@ function _assertTileCache(plugin) {
|
|
|
18762
20747
|
}
|
|
18763
20748
|
}
|
|
18764
20749
|
export {
|
|
18765
|
-
|
|
18766
|
-
|
|
18767
|
-
|
|
18768
|
-
|
|
18769
|
-
|
|
18770
|
-
|
|
18771
|
-
|
|
18772
|
-
|
|
18773
|
-
|
|
18774
|
-
|
|
18775
|
-
|
|
18776
|
-
|
|
18777
|
-
|
|
20750
|
+
HAS_EMISSIVE_TEXTURE as $,
|
|
20751
|
+
createMaterialView as A,
|
|
20752
|
+
MATERIAL_ALPHA_BLEND as B,
|
|
20753
|
+
PBR_HAS_ALPHA_BLEND as C,
|
|
20754
|
+
encodeIdToColor as D,
|
|
20755
|
+
ESM_SHADOW_OUTPUT as E,
|
|
20756
|
+
getPickingSceneBGL as F,
|
|
20757
|
+
gsGpuPickingFragment as G,
|
|
20758
|
+
BILLBOARD_INDEX_DATA as H,
|
|
20759
|
+
createEmptyUniformBuffer as I,
|
|
20760
|
+
BILLBOARD_SYSTEM_UBO_BYTES as J,
|
|
20761
|
+
createBillboardInstanceBuffer as K,
|
|
20762
|
+
createBillboardInstanceSortScratch as L,
|
|
18778
20763
|
MAX_LIGHTS as M,
|
|
18779
20764
|
NODE_ESM_SHADOW_OUTPUT as N,
|
|
18780
|
-
|
|
18781
|
-
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
|
|
20765
|
+
getOrCreateBillboardPipeline as O,
|
|
20766
|
+
PBR2_ESM_SHADOW_OUTPUT as P,
|
|
20767
|
+
createBillboardSystemBindGroup as Q,
|
|
20768
|
+
resetBillboardPipelineCache as R,
|
|
20769
|
+
ensureBillboardInstanceBuffer as S,
|
|
18785
20770
|
TYPE_SIZES as T,
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
|
|
18789
|
-
|
|
18790
|
-
|
|
18791
|
-
|
|
18792
|
-
|
|
20771
|
+
uploadSortedBillboardInstances as U,
|
|
20772
|
+
uploadBillboardInstances as V,
|
|
20773
|
+
buildBillboardSystemUbo as W,
|
|
20774
|
+
writeBillboardSystemUboIfDirty as X,
|
|
20775
|
+
createBillboardPipelineCache as Y,
|
|
20776
|
+
HAS_BUMP_TEXTURE as Z,
|
|
20777
|
+
_getBillboardFxHook as _,
|
|
18793
20778
|
writeMeshLightSelection as a,
|
|
18794
|
-
|
|
18795
|
-
|
|
18796
|
-
|
|
18797
|
-
|
|
18798
|
-
|
|
18799
|
-
|
|
18800
|
-
|
|
18801
|
-
|
|
18802
|
-
|
|
18803
|
-
|
|
18804
|
-
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
|
|
18809
|
-
|
|
18810
|
-
|
|
18811
|
-
|
|
18812
|
-
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18819
|
-
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
18841
|
-
|
|
18842
|
-
|
|
18843
|
-
|
|
18844
|
-
|
|
18845
|
-
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
20779
|
+
SCENE_UBO_WGSL as a$,
|
|
20780
|
+
HAS_DEPTH_EMISSIVE_TEXTURE as a0,
|
|
20781
|
+
HAS_SPECULAR_TEXTURE as a1,
|
|
20782
|
+
SPECULAR_USES_UV2 as a2,
|
|
20783
|
+
HAS_AMBIENT_TEXTURE as a3,
|
|
20784
|
+
AMBIENT_USES_UV2 as a4,
|
|
20785
|
+
HAS_LIGHTMAP_TEXTURE as a5,
|
|
20786
|
+
LIGHTMAP_USES_UV2 as a6,
|
|
20787
|
+
HAS_OPACITY_TEXTURE as a7,
|
|
20788
|
+
OPACITY_FROM_RGB as a8,
|
|
20789
|
+
HAS_REFLECTION_TEXTURE as a9,
|
|
20790
|
+
PBR2_HAS_UNLIT as aA,
|
|
20791
|
+
setMaxLights as aB,
|
|
20792
|
+
computeNodeWorldMatrix as aC,
|
|
20793
|
+
setSubtreeVisible as aD,
|
|
20794
|
+
mat4Invert as aE,
|
|
20795
|
+
mat4Identity as aF,
|
|
20796
|
+
getLoaderTmpAnim as aG,
|
|
20797
|
+
mat4MultiplyInto as aH,
|
|
20798
|
+
INTERP_CUBICSPLINE as aI,
|
|
20799
|
+
INTERP_STEP as aJ,
|
|
20800
|
+
INTERP_LINEAR as aK,
|
|
20801
|
+
PATH_WEIGHTS as aL,
|
|
20802
|
+
PATH_SCALE as aM,
|
|
20803
|
+
PATH_ROTATION as aN,
|
|
20804
|
+
PATH_TRANSLATION as aO,
|
|
20805
|
+
findParent as aP,
|
|
20806
|
+
setThinInstances as aQ,
|
|
20807
|
+
mat4ComposeInto as aR,
|
|
20808
|
+
getLoaderTmpInstance as aS,
|
|
20809
|
+
mat4Multiply as aT,
|
|
20810
|
+
WGSL$1 as aU,
|
|
20811
|
+
identityTexWrap as aV,
|
|
20812
|
+
getOrCreateSampler as aW,
|
|
20813
|
+
assembleMaterial as aX,
|
|
20814
|
+
runMatExts as aY,
|
|
20815
|
+
makeImageFetcher as aZ,
|
|
20816
|
+
createUniformBuffer$1 as a_,
|
|
20817
|
+
HAS_CUBE_REFLECTION as aa,
|
|
20818
|
+
getCsmStdReceiverFactory as ab,
|
|
20819
|
+
getCsmPbrReceiverFactory as ac,
|
|
20820
|
+
PBR_HAS_ALPHA_TEST as ad,
|
|
20821
|
+
PBR_HAS_METALLIC_REFLECTANCE_MAP as ae,
|
|
20822
|
+
PBR_HAS_REFLECTANCE_MAP as af,
|
|
20823
|
+
PBR2_HAS_REFLECTANCE_FACTORS as ag,
|
|
20824
|
+
PBR2_HAS_UV2 as ah,
|
|
20825
|
+
PBR_HAS_USE_ALPHA_ONLY_MR as ai,
|
|
20826
|
+
PBR_HAS_CLEARCOAT as aj,
|
|
20827
|
+
PBR2_CC_INT_MAP as ak,
|
|
20828
|
+
PBR2_CC_ROUGH_MAP as al,
|
|
20829
|
+
PBR2_CC_NORMAL_MAP as am,
|
|
20830
|
+
PBR2_CC_F0_REMAP_OFF as an,
|
|
20831
|
+
PBR_HAS_SHEEN_TEXTURE as ao,
|
|
20832
|
+
PBR_HAS_SHEEN as ap,
|
|
20833
|
+
PBR2_HAS_SHEEN_UV_TX as aq,
|
|
20834
|
+
PBR_HAS_SHEEN_ALBEDO_SCALING as ar,
|
|
20835
|
+
PBR2_HAS_IRIDESCENCE_MAP as as,
|
|
20836
|
+
PBR2_HAS_IRIDESCENCE_THICKNESS_MAP as at,
|
|
20837
|
+
PBR2_HAS_IRIDESCENCE as au,
|
|
20838
|
+
PBR_HAS_THICKNESS_MAP as av,
|
|
20839
|
+
PBR_HAS_SUBSURFACE as aw,
|
|
20840
|
+
PBR2_HAS_THICKNESS_GLTF_CHANNEL as ax,
|
|
20841
|
+
PBR_HAS_EMISSIVE_COLOR as ay,
|
|
20842
|
+
PBR_HAS_EMISSIVE as az,
|
|
18858
20843
|
NODE_NO_COLOR_OUTPUT as b,
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
|
|
18865
|
-
|
|
18866
|
-
|
|
18867
|
-
|
|
18868
|
-
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
|
|
18879
|
-
|
|
18880
|
-
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
-
|
|
18892
|
-
|
|
18893
|
-
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
18897
|
-
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
|
|
18921
|
-
|
|
18922
|
-
|
|
20844
|
+
addAnimationGroup as b$,
|
|
20845
|
+
createSingleUniformBGL as b0,
|
|
20846
|
+
computeUboLayout as b1,
|
|
20847
|
+
getViewProjectionMatrix as b2,
|
|
20848
|
+
_isShaderSystemUniform as b3,
|
|
20849
|
+
acquireTexture as b4,
|
|
20850
|
+
releaseTexture as b5,
|
|
20851
|
+
getEffectiveAspectRatio as b6,
|
|
20852
|
+
getCompressedFormat as b7,
|
|
20853
|
+
PATH_POINTER as b8,
|
|
20854
|
+
PBR2_HAS_REFRACTION as b9,
|
|
20855
|
+
_registerPbrExt as bA,
|
|
20856
|
+
clearSamplerCache as bB,
|
|
20857
|
+
_computePbrMaterialFeatures as bC,
|
|
20858
|
+
collectPbrBoundTextures as bD,
|
|
20859
|
+
_getStdExts as bE,
|
|
20860
|
+
clearSceneBGLCache as bF,
|
|
20861
|
+
_getStdExtsSorted as bG,
|
|
20862
|
+
_standardFeatureKey as bH,
|
|
20863
|
+
HAS_DIFFUSE_TEXTURE as bI,
|
|
20864
|
+
NEEDS_UV as bJ,
|
|
20865
|
+
DOUBLE_SIDED as bK,
|
|
20866
|
+
NO_COLOR_OUTPUT as bL,
|
|
20867
|
+
DISABLE_LIGHTING as bM,
|
|
20868
|
+
DIFFUSE_USES_UV2 as bN,
|
|
20869
|
+
NEEDS_UV2 as bO,
|
|
20870
|
+
_computeStandardMaterialFeatures as bP,
|
|
20871
|
+
_standardShaderVariantKey as bQ,
|
|
20872
|
+
CAP_ALL as bR,
|
|
20873
|
+
CAP_END as bS,
|
|
20874
|
+
CAP_NONE as bT,
|
|
20875
|
+
CAP_START as bU,
|
|
20876
|
+
ObservableQuat as bV,
|
|
20877
|
+
ObservableVec3 as bW,
|
|
20878
|
+
PhysicsMotionType as bX,
|
|
20879
|
+
PhysicsShapeType as bY,
|
|
20880
|
+
VERSION as bZ,
|
|
20881
|
+
addAgent as b_,
|
|
20882
|
+
PBR2_HAS_REFRACTION_MAP as ba,
|
|
20883
|
+
getTrilinearAnisotropicSampler as bb,
|
|
20884
|
+
PBR2_LINEAR_IMAGE_PROCESSING as bc,
|
|
20885
|
+
PBR2_HAS_DISPERSION as bd,
|
|
20886
|
+
PBR2_HAS_VOLUME as be,
|
|
20887
|
+
enableSceneTransmission as bf,
|
|
20888
|
+
getBilinearSampler as bg,
|
|
20889
|
+
_getPbrExtsSorted as bh,
|
|
20890
|
+
PBR_HAS_SPEC_GLOSS as bi,
|
|
20891
|
+
REVERSE_DEPTH_COMPARE as bj,
|
|
20892
|
+
PBR_HAS_NORMAL_MAP as bk,
|
|
20893
|
+
PBR2_NO_COLOR_OUTPUT as bl,
|
|
20894
|
+
PBR_HAS_DOUBLE_SIDED as bm,
|
|
20895
|
+
appendMeshLightUboFields as bn,
|
|
20896
|
+
meshLightIndexWGSL as bo,
|
|
20897
|
+
_getPbrExts as bp,
|
|
20898
|
+
PBR2_HAS_UV_TRANSFORM as bq,
|
|
20899
|
+
PBR_HAS_ANISOTROPY as br,
|
|
20900
|
+
PBR_HAS_SKYBOX as bs,
|
|
20901
|
+
PBR_HAS_SPECULAR_AA as bt,
|
|
20902
|
+
PBR_HAS_ENV as bu,
|
|
20903
|
+
PBR_HAS_FOG as bv,
|
|
20904
|
+
PBR_HAS_OCCLUSION as bw,
|
|
20905
|
+
PBR2_HAS_BASE_COLOR_FACTOR as bx,
|
|
20906
|
+
PBR_HAS_GAMMA_ALBEDO as by,
|
|
20907
|
+
PBR_HAS_TONEMAP as bz,
|
|
18923
20908
|
compileNodePipeline as c,
|
|
18924
|
-
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
|
-
|
|
18931
|
-
|
|
18932
|
-
|
|
18933
|
-
|
|
18934
|
-
|
|
18935
|
-
|
|
18936
|
-
|
|
18937
|
-
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
18952
|
-
|
|
18953
|
-
|
|
18954
|
-
|
|
18955
|
-
|
|
18956
|
-
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
|
|
18960
|
-
|
|
18961
|
-
|
|
18962
|
-
|
|
18963
|
-
|
|
18964
|
-
|
|
18965
|
-
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
18969
|
-
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
18982
|
-
|
|
18983
|
-
|
|
18984
|
-
|
|
18985
|
-
|
|
18986
|
-
|
|
18987
|
-
|
|
20909
|
+
createEffectRenderer as c$,
|
|
20910
|
+
addAnimationGroups as c0,
|
|
20911
|
+
addAnimationTask as c1,
|
|
20912
|
+
addAxisLockedBillboardSystem as c2,
|
|
20913
|
+
addBillboardSprite as c3,
|
|
20914
|
+
addBillboardSpriteIndex as c4,
|
|
20915
|
+
addBoxObstacle as c5,
|
|
20916
|
+
addClusteredLightContainer as c6,
|
|
20917
|
+
addCylinderObstacle as c7,
|
|
20918
|
+
addDepthHostedSpriteLayer as c8,
|
|
20919
|
+
addFacingBillboardSystem as c9,
|
|
20920
|
+
clearSpriteAnimations as cA,
|
|
20921
|
+
cloneTransformNode as cB,
|
|
20922
|
+
computePath as cC,
|
|
20923
|
+
createAnaglyphPostProcessTask as cD,
|
|
20924
|
+
createAnimationController as cE,
|
|
20925
|
+
createAnimationGroups as cF,
|
|
20926
|
+
createAnimationManager as cG,
|
|
20927
|
+
createAnimationTask as cH,
|
|
20928
|
+
createArcRotateCamera as cI,
|
|
20929
|
+
createAxisLockedBillboardSystem as cJ,
|
|
20930
|
+
createBillboardCustomShader as cK,
|
|
20931
|
+
createBlackAndWhitePostProcessTask as cL,
|
|
20932
|
+
createBloomPostProcessTask as cM,
|
|
20933
|
+
createBlurPostProcessTask as cN,
|
|
20934
|
+
createBox as cO,
|
|
20935
|
+
createChromaticAberrationPostProcessTask as cP,
|
|
20936
|
+
createClusteredLightContainer as cQ,
|
|
20937
|
+
createClusteredPointLight as cR,
|
|
20938
|
+
createCsg2FromMesh as cS,
|
|
20939
|
+
createCsgFromMesh as cT,
|
|
20940
|
+
createCsmDirectionalShadowGenerator as cU,
|
|
20941
|
+
createCylinder as cV,
|
|
20942
|
+
createDebugNavMeshGeometry as cW,
|
|
20943
|
+
createDefaultCamera as cX,
|
|
20944
|
+
createDirectionalLight as cY,
|
|
20945
|
+
createDisc as cZ,
|
|
20946
|
+
createEffectRenderTask as c_,
|
|
20947
|
+
addPassDependencies as ca,
|
|
20948
|
+
addRenderPass as cb,
|
|
20949
|
+
addSprite2D as cc,
|
|
20950
|
+
addSprite2DIndex as cd,
|
|
20951
|
+
addSpriteAnimation as ce,
|
|
20952
|
+
addSpriteAnimationManager as cf,
|
|
20953
|
+
addSpriteRendererLayer as cg,
|
|
20954
|
+
addTask as ch,
|
|
20955
|
+
addTaskAtStart as ci,
|
|
20956
|
+
addTaskBefore as cj,
|
|
20957
|
+
addThinInstance as ck,
|
|
20958
|
+
addToScene as cl,
|
|
20959
|
+
agentGoto as cm,
|
|
20960
|
+
attachControl as cn,
|
|
20961
|
+
attachFreeControl as co,
|
|
20962
|
+
attachSpriteAnimationsToRenderer as cp,
|
|
20963
|
+
attachSpriteAnimationsToScene as cq,
|
|
20964
|
+
bakeCurrentTransformIntoVertices as cr,
|
|
20965
|
+
bakeTransformIntoVertices as cs,
|
|
20966
|
+
billboardBlendAdditive as ct,
|
|
20967
|
+
billboardBlendAlpha as cu,
|
|
20968
|
+
billboardBlendCutout as cv,
|
|
20969
|
+
billboardBlendPremultiplied as cw,
|
|
20970
|
+
clearAnimationManager as cx,
|
|
20971
|
+
clearBillboardSprites as cy,
|
|
20972
|
+
clearSprite2DLayer as cz,
|
|
18988
20973
|
computeAabb as d,
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
19006
|
-
|
|
19007
|
-
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19012
|
-
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
|
|
19034
|
-
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
20974
|
+
createTube as d$,
|
|
20975
|
+
createEffectWrapper as d0,
|
|
20976
|
+
createEngine as d1,
|
|
20977
|
+
createEsmDirectionalShadowGenerator as d2,
|
|
20978
|
+
createExtractHighlightsPostProcessTask as d3,
|
|
20979
|
+
createExtrudeShape as d4,
|
|
20980
|
+
createFacingBillboardSystem as d5,
|
|
20981
|
+
createFrameGraphContext as d6,
|
|
20982
|
+
createGpuPicker as d7,
|
|
20983
|
+
createGridMaterial as d8,
|
|
20984
|
+
createGridSpriteAtlas as d9,
|
|
20985
|
+
createProceduralGaussianSplattingMesh as dA,
|
|
20986
|
+
createPropertyAnimationClip as dB,
|
|
20987
|
+
createPropertyAnimationGroup as dC,
|
|
20988
|
+
createRenderTarget as dD,
|
|
20989
|
+
createRenderTargetTexture as dE,
|
|
20990
|
+
createRenderTask as dF,
|
|
20991
|
+
createRibbon as dG,
|
|
20992
|
+
createSceneContext as dH,
|
|
20993
|
+
createShaderMaterial as dI,
|
|
20994
|
+
createShadowTask as dJ,
|
|
20995
|
+
createSolidTexture2D as dK,
|
|
20996
|
+
createSphere as dL,
|
|
20997
|
+
createSphereData as dM,
|
|
20998
|
+
createSpotLight as dN,
|
|
20999
|
+
createSprite2DCustomShader as dO,
|
|
21000
|
+
createSprite2DLayer as dP,
|
|
21001
|
+
createSpriteAnimationManager as dQ,
|
|
21002
|
+
createSpriteAtlasFromFrames as dR,
|
|
21003
|
+
createSpriteFrameAnimation as dS,
|
|
21004
|
+
createSpriteRenderer as dT,
|
|
21005
|
+
createStandardMaterial as dU,
|
|
21006
|
+
createStandardNoColorMaterialView$1 as dV,
|
|
21007
|
+
createTexture2DFromPixels as dW,
|
|
21008
|
+
createTorus as dX,
|
|
21009
|
+
createTorusKnot as dY,
|
|
21010
|
+
createTorusKnotData as dZ,
|
|
21011
|
+
createTransformNode as d_,
|
|
21012
|
+
createGround as da,
|
|
21013
|
+
createGroundFromHeightMap as db,
|
|
21014
|
+
createHavokWorld as dc,
|
|
21015
|
+
createHemisphericLight as dd,
|
|
21016
|
+
createImageProcessingTask as de,
|
|
21017
|
+
createLinearDepthMaterial as df,
|
|
21018
|
+
createMeshFromCsg as dg,
|
|
21019
|
+
createMeshFromCsg2 as dh,
|
|
21020
|
+
createMeshFromData as di,
|
|
21021
|
+
createMeshesFromCsg2 as dj,
|
|
21022
|
+
createMorphTargets as dk,
|
|
21023
|
+
createNavCrowd as dl,
|
|
21024
|
+
createNavMesh as dm,
|
|
21025
|
+
createNavigationPluginAsync as dn,
|
|
21026
|
+
createNodeNoColorMaterialView$1 as dp,
|
|
21027
|
+
createPbrMaterial as dq,
|
|
21028
|
+
createPbrNoColorMaterialView$1 as dr,
|
|
21029
|
+
createPcfDirectionalShadowGenerator as ds,
|
|
21030
|
+
createPcfSpotlightShadowGenerator as dt,
|
|
21031
|
+
createPhysicsAggregate as du,
|
|
21032
|
+
createPhysicsBody as dv,
|
|
21033
|
+
createPhysicsShape as dw,
|
|
21034
|
+
createPlane as dx,
|
|
21035
|
+
createPointLight as dy,
|
|
21036
|
+
createPolyhedron as dz,
|
|
19052
21037
|
createMappedBuffer as e,
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19061
|
-
|
|
19062
|
-
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19070
|
-
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
|
|
19074
|
-
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19078
|
-
|
|
19079
|
-
|
|
19080
|
-
|
|
19081
|
-
|
|
19082
|
-
|
|
19083
|
-
|
|
19084
|
-
|
|
19085
|
-
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19089
|
-
|
|
19090
|
-
|
|
19091
|
-
|
|
19092
|
-
|
|
19093
|
-
|
|
19094
|
-
|
|
19095
|
-
|
|
19096
|
-
|
|
19097
|
-
|
|
19098
|
-
|
|
19099
|
-
|
|
19100
|
-
|
|
19101
|
-
|
|
19102
|
-
|
|
19103
|
-
|
|
19104
|
-
|
|
19105
|
-
|
|
19106
|
-
|
|
19107
|
-
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
|
|
19111
|
-
|
|
19112
|
-
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
|
|
19147
|
-
|
|
19148
|
-
|
|
19149
|
-
|
|
19150
|
-
|
|
19151
|
-
|
|
19152
|
-
|
|
19153
|
-
|
|
19154
|
-
|
|
19155
|
-
|
|
19156
|
-
|
|
19157
|
-
|
|
19158
|
-
|
|
19159
|
-
|
|
19160
|
-
|
|
19161
|
-
|
|
19162
|
-
|
|
19163
|
-
|
|
19164
|
-
|
|
19165
|
-
|
|
19166
|
-
|
|
19167
|
-
|
|
19168
|
-
|
|
19169
|
-
|
|
19170
|
-
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
|
|
19188
|
-
|
|
19189
|
-
|
|
19190
|
-
|
|
19191
|
-
|
|
19192
|
-
|
|
19193
|
-
|
|
19194
|
-
|
|
19195
|
-
|
|
19196
|
-
pointLight as
|
|
19197
|
-
directionalLight as
|
|
19198
|
-
spotLight as
|
|
19199
|
-
|
|
19200
|
-
|
|
19201
|
-
|
|
19202
|
-
|
|
21038
|
+
loadSpriteAtlas as e$,
|
|
21039
|
+
createUniformEffectRenderTask as e0,
|
|
21040
|
+
createUniformEffectWrapper as e1,
|
|
21041
|
+
crossFadeAnimationGroups as e2,
|
|
21042
|
+
csg2Add as e3,
|
|
21043
|
+
csg2Intersect as e4,
|
|
21044
|
+
csg2Subtract as e5,
|
|
21045
|
+
csgIntersect as e6,
|
|
21046
|
+
csgSubtract as e7,
|
|
21047
|
+
csgUnion as e8,
|
|
21048
|
+
disposeCsg2 as e9,
|
|
21049
|
+
getFloatingOriginOffset as eA,
|
|
21050
|
+
getFrameGraph as eB,
|
|
21051
|
+
getNavigationRandomSeed as eC,
|
|
21052
|
+
getPhysicsGravity as eD,
|
|
21053
|
+
getPhysicsTimestep as eE,
|
|
21054
|
+
getPhysicsVelocityLimits as eF,
|
|
21055
|
+
getPickedNormal as eG,
|
|
21056
|
+
getPickedUV as eH,
|
|
21057
|
+
getSprite2DHandleIndex as eI,
|
|
21058
|
+
getVariantNames as eJ,
|
|
21059
|
+
goToFrame as eK,
|
|
21060
|
+
gsAlphaBlendedDepthFragment as eL,
|
|
21061
|
+
gsLinearDepthFragment as eM,
|
|
21062
|
+
initializeCsg2Async as eN,
|
|
21063
|
+
isBillboardSpriteHandleAlive as eO,
|
|
21064
|
+
isCsg2Ready as eP,
|
|
21065
|
+
isSprite2DHandleAlive as eQ,
|
|
21066
|
+
loadBabylon as eR,
|
|
21067
|
+
loadBasisTexture2D as eS,
|
|
21068
|
+
loadEnvironment as eT,
|
|
21069
|
+
loadGltf as eU,
|
|
21070
|
+
loadHdrEnvironment as eV,
|
|
21071
|
+
loadKtxTexture2D as eW,
|
|
21072
|
+
loadSOG as eX,
|
|
21073
|
+
loadSPZ as eY,
|
|
21074
|
+
loadSkybox as eZ,
|
|
21075
|
+
loadSplat as e_,
|
|
21076
|
+
disposeEffectRenderer as ea,
|
|
21077
|
+
disposeEffectWrapper as eb,
|
|
21078
|
+
disposeEngine as ec,
|
|
21079
|
+
disposeFrameGraphContext as ed,
|
|
21080
|
+
disposePhysics as ee,
|
|
21081
|
+
disposePicker as ef,
|
|
21082
|
+
disposeScene as eg,
|
|
21083
|
+
disposeSpriteAnimationBinding as eh,
|
|
21084
|
+
disposeSpriteRenderer as ei,
|
|
21085
|
+
disposeUniformEffectWrapper as ej,
|
|
21086
|
+
enableAnimationBlending as ek,
|
|
21087
|
+
enableDetailedPicking as el,
|
|
21088
|
+
enableMaterialPlugins as em,
|
|
21089
|
+
enableMaterialTracking as en,
|
|
21090
|
+
enablePropertyAnimationBlending as eo,
|
|
21091
|
+
enableRenderTaskTransmission as ep,
|
|
21092
|
+
enableThinInstanceGpuCulling as eq,
|
|
21093
|
+
fadeAnimationWeight as er,
|
|
21094
|
+
findRandomPoint as es,
|
|
21095
|
+
findRandomPointAroundCircle as et,
|
|
21096
|
+
flushThinInstances as eu,
|
|
21097
|
+
getAgentPosition as ev,
|
|
21098
|
+
getAgentVelocity as ew,
|
|
21099
|
+
getAnimationGroups as ex,
|
|
21100
|
+
getBillboardSpriteHandleIndex as ey,
|
|
21101
|
+
getClosestPoint as ez,
|
|
21102
|
+
anyPrimitive as f,
|
|
21103
|
+
setShaderFloat as f$,
|
|
21104
|
+
loadTexture2D as f0,
|
|
21105
|
+
markClusteredLightContainerDirty as f1,
|
|
21106
|
+
mat4Compose as f2,
|
|
21107
|
+
mat4Scale as f3,
|
|
21108
|
+
mat4Translation as f4,
|
|
21109
|
+
normalizeVec3 as f5,
|
|
21110
|
+
onBeforeRender as f6,
|
|
21111
|
+
onCsmReceiverUpdate as f7,
|
|
21112
|
+
onSceneDispose as f8,
|
|
21113
|
+
parseNodeMaterialFromSnippet as f9,
|
|
21114
|
+
removeSpriteRendererLayer as fA,
|
|
21115
|
+
removeThinInstance as fB,
|
|
21116
|
+
resetVariant as fC,
|
|
21117
|
+
resizeEngine as fD,
|
|
21118
|
+
resolveCameraViewport as fE,
|
|
21119
|
+
selectVariant as fF,
|
|
21120
|
+
setAnimationAdditive as fG,
|
|
21121
|
+
setAnimationTaskCategoryHandler as fH,
|
|
21122
|
+
setAnimationWeight as fI,
|
|
21123
|
+
setBillboardShaderParams as fJ,
|
|
21124
|
+
setBillboardSpriteFrame as fK,
|
|
21125
|
+
setBillboardSpriteFrameIndex as fL,
|
|
21126
|
+
setCameraLimits as fM,
|
|
21127
|
+
setClipPlane as fN,
|
|
21128
|
+
setEffectTexture as fO,
|
|
21129
|
+
setEffectUniforms as fP,
|
|
21130
|
+
setEngineSize as fQ,
|
|
21131
|
+
setFog as fR,
|
|
21132
|
+
setMorphTargetWeights as fS,
|
|
21133
|
+
setNavigationRandomSeed as fT,
|
|
21134
|
+
setParent as fU,
|
|
21135
|
+
setPhysicsBodyMass as fV,
|
|
21136
|
+
setPhysicsBodyShape as fW,
|
|
21137
|
+
setPhysicsGravity as fX,
|
|
21138
|
+
setPhysicsShapeMaterial as fY,
|
|
21139
|
+
setPhysicsTimestep as fZ,
|
|
21140
|
+
setPhysicsVelocityLimits as f_,
|
|
21141
|
+
pauseAnimation as fa,
|
|
21142
|
+
pickAsync as fb,
|
|
21143
|
+
playAnimation as fc,
|
|
21144
|
+
playBillboardSpriteAnimation as fd,
|
|
21145
|
+
playBillboardSpriteIndexAnimation as fe,
|
|
21146
|
+
playSprite2DAnimation as ff,
|
|
21147
|
+
playSprite2DIndexAnimation as fg,
|
|
21148
|
+
playSpriteFrameAnimation as fh,
|
|
21149
|
+
raycast as fi,
|
|
21150
|
+
rebuildMaterial as fj,
|
|
21151
|
+
registerEffectRenderer as fk,
|
|
21152
|
+
registerFrameGraphContext as fl,
|
|
21153
|
+
registerScene as fm,
|
|
21154
|
+
registerSceneWithShadowSupport as fn,
|
|
21155
|
+
registerSpriteRenderer as fo,
|
|
21156
|
+
removeAnimationGroup as fp,
|
|
21157
|
+
removeAnimationTask as fq,
|
|
21158
|
+
removeBillboardSprite as fr,
|
|
21159
|
+
removeBillboardSpriteIndex as fs,
|
|
21160
|
+
removeFromScene as ft,
|
|
21161
|
+
removeMeshFromTask as fu,
|
|
21162
|
+
removeObstacle as fv,
|
|
21163
|
+
removeSprite2D as fw,
|
|
21164
|
+
removeSprite2DIndex as fx,
|
|
21165
|
+
removeSpriteAnimation as fy,
|
|
21166
|
+
removeSpriteAnimationManager as fz,
|
|
21167
|
+
createFreeCamera as g,
|
|
21168
|
+
setShaderMatrix as g0,
|
|
21169
|
+
setShaderTexture as g1,
|
|
21170
|
+
setShaderUniform as g2,
|
|
21171
|
+
setShaderVector3 as g3,
|
|
21172
|
+
setShadowTaskCasterMeshes as g4,
|
|
21173
|
+
setSprite2DFrame as g5,
|
|
21174
|
+
setSprite2DFrameIndex as g6,
|
|
21175
|
+
setSprite2DShaderParams as g7,
|
|
21176
|
+
setSprite2DUvOffset as g8,
|
|
21177
|
+
setThinInstanceColors as g9,
|
|
21178
|
+
updateSpriteAnimationManager as gA,
|
|
21179
|
+
updateTexture2DFromPixels as gB,
|
|
21180
|
+
generateMipmaps$1 as gC,
|
|
21181
|
+
pointLight as gD,
|
|
21182
|
+
directionalLight as gE,
|
|
21183
|
+
spotLight as gF,
|
|
21184
|
+
animationGroup as gG,
|
|
21185
|
+
createMorphTargets$1 as gH,
|
|
21186
|
+
setThinInstanceMatrix as ga,
|
|
21187
|
+
setUniformEffectUniforms as gb,
|
|
21188
|
+
spriteBlendAdditive as gc,
|
|
21189
|
+
spriteBlendAlpha as gd,
|
|
21190
|
+
spriteBlendMultiply as ge,
|
|
21191
|
+
spriteBlendPremultiplied as gf,
|
|
21192
|
+
startAnimationManager as gg,
|
|
21193
|
+
startEngine as gh,
|
|
21194
|
+
startSpriteAnimationManager as gi,
|
|
21195
|
+
stopAnimation as gj,
|
|
21196
|
+
stopAnimationManager as gk,
|
|
21197
|
+
stopEngine as gl,
|
|
21198
|
+
stopSpriteAnimation as gm,
|
|
21199
|
+
stopSpriteAnimationManager as gn,
|
|
21200
|
+
unregisterEffectRenderer as go,
|
|
21201
|
+
unregisterFrameGraphContext as gp,
|
|
21202
|
+
unregisterScene as gq,
|
|
21203
|
+
unregisterSpriteRenderer as gr,
|
|
21204
|
+
updateAnimationManager as gs,
|
|
21205
|
+
updateBillboardSprite as gt,
|
|
21206
|
+
updateBillboardSpriteIndex as gu,
|
|
21207
|
+
updateMeshPositions as gv,
|
|
21208
|
+
updateNavCrowd as gw,
|
|
21209
|
+
updateNavMeshObstacles as gx,
|
|
21210
|
+
updateSprite2D as gy,
|
|
21211
|
+
updateSprite2DIndex as gz,
|
|
21212
|
+
createDefaultPipelineDescriptor as h,
|
|
19203
21213
|
initMeshTransform as i,
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
21214
|
+
getSceneBindGroupLayout as j,
|
|
21215
|
+
pbrGroupBuilder as k,
|
|
21216
|
+
linearToSrgbByte as l,
|
|
19207
21217
|
markMaterialUboDirty as m,
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19211
|
-
|
|
21218
|
+
needsOrmComposite as n,
|
|
21219
|
+
cloneTexture2D as o,
|
|
21220
|
+
packMat4IntoF32 as p,
|
|
21221
|
+
disposeGaussianSplattingMesh as q,
|
|
19212
21222
|
resolveAccessor as r,
|
|
19213
|
-
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
|
|
21223
|
+
applyGsFragments as s,
|
|
21224
|
+
targetSignatureKey as t,
|
|
21225
|
+
uploadTex as u,
|
|
21226
|
+
getRenderTargetSize as v,
|
|
19217
21227
|
writeNodeUBO as w,
|
|
19218
|
-
|
|
19219
|
-
|
|
19220
|
-
|
|
21228
|
+
getViewMatrix as x,
|
|
21229
|
+
getProjectionMatrix as y,
|
|
21230
|
+
getCameraPosition as z
|
|
19221
21231
|
};
|
|
19222
|
-
//# sourceMappingURL=index-
|
|
21232
|
+
//# sourceMappingURL=index-B7Qhw0xL.js.map
|