@babylonjs/lite 0.2.0 → 1.0.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 → _mat4-storage-f64-CjDoht2w.js} +3 -2
- package/_mat4-storage-f64-CjDoht2w.js.map +1 -0
- package/{alpha-test-fragment-BCChpzaV.js → alpha-test-fragment-B7DjSnF7.js} +2 -2
- package/{alpha-test-fragment-BCChpzaV.js.map → alpha-test-fragment-B7DjSnF7.js.map} +1 -1
- package/assets/splat-sort-worker-DT3eybMZ.js.map +1 -0
- package/{background-dds-skybox-ZjrSIxrT.js → background-dds-skybox-BEX309u3.js} +13 -13
- package/background-dds-skybox-BEX309u3.js.map +1 -0
- package/{background-ground-B2Mie-MI.js → background-ground-BU0HOcM4.js} +19 -19
- package/background-ground-BU0HOcM4.js.map +1 -0
- package/{background-hdr-skybox-DDRJYuT2.js → background-hdr-skybox--RRRic_K.js} +10 -10
- package/background-hdr-skybox--RRRic_K.js.map +1 -0
- package/{background-solid-skybox-fjXlnWaD.js → background-solid-skybox-BrH2fXSu.js} +11 -12
- package/background-solid-skybox-BrH2fXSu.js.map +1 -0
- package/{billboard-renderable-DKmlOgbM.js → billboard-renderable-BHWryAeC.js} +46 -10
- package/billboard-renderable-BHWryAeC.js.map +1 -0
- package/{clamp-block-CxRBPlUq.js → clamp-block-DqbwnQGW.js} +2 -2
- package/{clamp-block-CxRBPlUq.js.map → clamp-block-DqbwnQGW.js.map} +1 -1
- package/{clearcoat-fragment-KbZAa0TA.js → clearcoat-fragment-D6FSCie1.js} +2 -2
- package/{clearcoat-fragment-KbZAa0TA.js.map → clearcoat-fragment-D6FSCie1.js.map} +1 -1
- package/{create-skeleton-BBI5urcj.js → create-skeleton-D_uplboC.js} +9 -9
- package/create-skeleton-D_uplboC.js.map +1 -0
- package/{cubemap-skybox-material-DvW81drX.js → cubemap-skybox-material-DQcMMdf-.js} +6 -7
- package/cubemap-skybox-material-DQcMMdf-.js.map +1 -0
- package/{curve-block-Dh_xdUj-.js → curve-block-21rT0JjG.js} +2 -2
- package/{curve-block-Dh_xdUj-.js.map → curve-block-21rT0JjG.js.map} +1 -1
- package/{emissive-fragment-DD8cvHyx.js → emissive-fragment-C5FtBs3y.js} +3 -3
- package/emissive-fragment-C5FtBs3y.js.map +1 -0
- package/{esm-shadow-view-DYAc62Kl.js → esm-shadow-view-Cl3rPGof.js} +2 -2
- package/{esm-shadow-view-DYAc62Kl.js.map → esm-shadow-view-Cl3rPGof.js.map} +1 -1
- package/{esm-shadow-view-DHVS9r7H.js → esm-shadow-view-Gtd1LWRP.js} +2 -2
- package/{esm-shadow-view-DHVS9r7H.js.map → esm-shadow-view-Gtd1LWRP.js.map} +1 -1
- package/{esm-shadow-view-15S4JK6p.js → esm-shadow-view-c5YV4Eg9.js} +2 -2
- package/{esm-shadow-view-15S4JK6p.js.map → esm-shadow-view-c5YV4Eg9.js.map} +1 -1
- package/{gaussian-splatting-pipeline-sh-BvkUhA9V.js → gaussian-splatting-pipeline-sh-7J31V23x.js} +19 -19
- package/gaussian-splatting-pipeline-sh-7J31V23x.js.map +1 -0
- package/geometry-texture-output-dXk4E9uu.js +41 -0
- package/geometry-texture-output-dXk4E9uu.js.map +1 -0
- package/geometry-view-BsFJpBJa.js +404 -0
- package/geometry-view-BsFJpBJa.js.map +1 -0
- package/{gltf-animation-KnPzeOIY.js → gltf-animation-K_zZxj_d.js} +6 -6
- package/gltf-animation-K_zZxj_d.js.map +1 -0
- package/{gltf-ext-basisu-kmth3UWX.js → gltf-ext-basisu-CDbPclzZ.js} +48 -16
- package/gltf-ext-basisu-CDbPclzZ.js.map +1 -0
- package/{gltf-ext-node-visibility-BjRRd6si.js → gltf-ext-node-visibility-DXCJEYr6.js} +2 -2
- package/{gltf-ext-node-visibility-BjRRd6si.js.map → gltf-ext-node-visibility-DXCJEYr6.js.map} +1 -1
- package/{gltf-ext-quantization-CpZyLDIz.js → gltf-ext-quantization-CvHI_0Vg.js} +4 -3
- package/gltf-ext-quantization-CvHI_0Vg.js.map +1 -0
- package/{gltf-ext-uv-transform-MHmR-YyM.js → gltf-ext-uv-transform-DgYazJBs.js} +2 -2
- package/{gltf-ext-uv-transform-MHmR-YyM.js.map → gltf-ext-uv-transform-DgYazJBs.js.map} +1 -1
- package/{gltf-feature-animation-pointer-rFqLfbO_.js → gltf-feature-animation-pointer-D1RJRFBw.js} +9 -9
- package/gltf-feature-animation-pointer-D1RJRFBw.js.map +1 -0
- package/{gltf-feature-animations-DikONdzi.js → gltf-feature-animations-Cmc1uoIu.js} +2 -2
- package/{gltf-feature-animations-DikONdzi.js.map → gltf-feature-animations-Cmc1uoIu.js.map} +1 -1
- package/{gltf-feature-draco-yGSMGTE3.js → gltf-feature-draco-CKKzT5E3.js} +6 -5
- package/gltf-feature-draco-CKKzT5E3.js.map +1 -0
- package/{gltf-feature-gpu-instancing-Cj1XjmM6.js → gltf-feature-gpu-instancing-n87SO6Vh.js} +4 -4
- package/gltf-feature-gpu-instancing-n87SO6Vh.js.map +1 -0
- package/{gltf-feature-lights-punctual-C-0SlGmD.js → gltf-feature-lights-punctual-Ckm3ciL8.js} +5 -5
- package/{gltf-feature-lights-punctual-C-0SlGmD.js.map → gltf-feature-lights-punctual-Ckm3ciL8.js.map} +1 -1
- package/{gltf-feature-meshopt-Des96YFI.js → gltf-feature-meshopt-DLC4SF1E.js} +7 -6
- package/gltf-feature-meshopt-DLC4SF1E.js.map +1 -0
- package/{gltf-feature-morph-BAcY14XU.js → gltf-feature-morph-Cjtu7hYa.js} +4 -4
- package/gltf-feature-morph-Cjtu7hYa.js.map +1 -0
- package/{gltf-feature-registry-97sY_x5O.js → gltf-feature-registry-C63Hjp9w.js} +15 -15
- package/{gltf-feature-registry-97sY_x5O.js.map → gltf-feature-registry-C63Hjp9w.js.map} +1 -1
- package/{gltf-feature-skeleton-lVjkDfIU.js → gltf-feature-skeleton-DKbOGidp.js} +3 -3
- package/{gltf-feature-skeleton-lVjkDfIU.js.map → gltf-feature-skeleton-DKbOGidp.js.map} +1 -1
- package/{gltf-feature-variants-BphF4JmV.js → gltf-feature-variants-Cmzu0O0e.js} +2 -2
- package/{gltf-feature-variants-BphF4JmV.js.map → gltf-feature-variants-Cmzu0O0e.js.map} +1 -1
- package/{gltf-glb-parser-D6UZWFuC.js → gltf-glb-parser-Cj5MHS-v.js} +5 -4
- package/gltf-glb-parser-Cj5MHS-v.js.map +1 -0
- package/{gltf-interleave-C9eBqH_F.js → gltf-interleave-gHf9_t0i.js} +14 -14
- package/gltf-interleave-gHf9_t0i.js.map +1 -0
- package/{gltf-pbr-builder-ext-DPC0zg_u.js → gltf-pbr-builder-ext-edNcjwPf.js} +5 -5
- package/gltf-pbr-builder-ext-edNcjwPf.js.map +1 -0
- package/{gltf-variants-CnBEZr0o.js → gltf-variants-CPxNdtP4.js} +4 -4
- package/{gltf-variants-CnBEZr0o.js.map → gltf-variants-CPxNdtP4.js.map} +1 -1
- package/{gs-picking-pipeline-Bx8LTav6.js → gs-picking-pipeline-DYaW_Lg3.js} +14 -14
- package/gs-picking-pipeline-DYaW_Lg3.js.map +1 -0
- package/havok-floating-origin-Dr-18Nds.js +198 -0
- package/havok-floating-origin-Dr-18Nds.js.map +1 -0
- package/index-CLElg2Bo.js +39209 -0
- package/index-CLElg2Bo.js.map +1 -0
- package/index-CYZDclhF.js +918 -0
- package/index-CYZDclhF.js.map +1 -0
- package/index-SMJ67XwT.js +3330 -0
- package/index-SMJ67XwT.js.map +1 -0
- package/index.d.ts +2007 -105
- package/index.js +446 -322
- package/{input-block-Coi_aZwl.js → input-block-DqEedWF2.js} +2 -2
- package/{input-block-Coi_aZwl.js.map → input-block-DqEedWF2.js.map} +1 -1
- package/{iridescence-fragment-DwZcCTdD.js → iridescence-fragment-BHU59-gQ.js} +2 -2
- package/{iridescence-fragment-DwZcCTdD.js.map → iridescence-fragment-BHU59-gQ.js.map} +1 -1
- package/{light-block-Np_h5gPI.js → light-block-Bv37V8vl.js} +2 -2
- package/{light-block-Np_h5gPI.js.map → light-block-Bv37V8vl.js.map} +1 -1
- package/{loop-block-BFkLFYGm.js → loop-block-qTg8vb99.js} +2 -2
- package/{loop-block-BFkLFYGm.js.map → loop-block-qTg8vb99.js.map} +1 -1
- package/{morph-fragment-DqH-w61u.js → morph-fragment-BRCUr2wQ.js} +2 -2
- package/{morph-fragment-DqH-w61u.js.map → morph-fragment-BRCUr2wQ.js.map} +1 -1
- package/{multilight-wgsl-B9Mf9d-q.js → multilight-wgsl-DMeppAdZ.js} +2 -2
- package/{multilight-wgsl-B9Mf9d-q.js.map → multilight-wgsl-DMeppAdZ.js.map} +1 -1
- package/{node-env-BPZXZzBf.js → node-env-Bc559GmY.js} +6 -5
- package/node-env-Bc559GmY.js.map +1 -0
- package/node-geometry-view-COmWsRXK.js +291 -0
- package/node-geometry-view-COmWsRXK.js.map +1 -0
- package/{node-registry-extra-compat-Ch7ApZHF.js → node-registry-extra-compat-dWrv7gpS.js} +2 -2
- package/{node-registry-extra-compat-Ch7ApZHF.js.map → node-registry-extra-compat-dWrv7gpS.js.map} +1 -1
- package/{node-registry-extra-math-6ezzTkPj.js → node-registry-extra-math-Bn854sX9.js} +2 -2
- package/{node-registry-extra-math-6ezzTkPj.js.map → node-registry-extra-math-Bn854sX9.js.map} +1 -1
- package/{node-renderable-CS0CmsSp.js → node-renderable-B5G8WcdH.js} +15 -13
- package/node-renderable-B5G8WcdH.js.map +1 -0
- package/{node-shadow-CpnrdvtJ.js → node-shadow-CVIUlNf0.js} +7 -7
- package/node-shadow-CVIUlNf0.js.map +1 -0
- package/{normal-map-fragment-DradEMl-.js → normal-map-fragment-CQSxhjCy.js} +2 -2
- package/{normal-map-fragment-DradEMl-.js.map → normal-map-fragment-CQSxhjCy.js.map} +1 -1
- package/package.json +3 -10
- package/{parse-camera-CgV4bWc0.js → parse-camera-pBRT_6i5.js} +2 -2
- package/{parse-camera-CgV4bWc0.js.map → parse-camera-pBRT_6i5.js.map} +1 -1
- package/pbr-geometry-view-NiZY_juX.js +491 -0
- package/pbr-geometry-view-NiZY_juX.js.map +1 -0
- package/{pbr-metallic-roughness-block-BFwZj2Nw.js → pbr-metallic-roughness-block-JBSi-tQN.js} +2 -2
- package/{pbr-metallic-roughness-block-BFwZj2Nw.js.map → pbr-metallic-roughness-block-JBSi-tQN.js.map} +1 -1
- package/{pbr-metallic-roughness-block-full-5t0HT3xl.js → pbr-metallic-roughness-block-full-Ta9lR2cz.js} +2 -2
- package/{pbr-metallic-roughness-block-full-5t0HT3xl.js.map → pbr-metallic-roughness-block-full-Ta9lR2cz.js.map} +1 -1
- package/{pbr-mr-helper-core-R5tOZ8Ap.js → pbr-mr-helper-core-BVWNR08D.js} +2 -2
- package/{pbr-mr-helper-core-R5tOZ8Ap.js.map → pbr-mr-helper-core-BVWNR08D.js.map} +1 -1
- package/{pbr-refraction-Dd11HnaI.js → pbr-refraction-C9FvFmAp.js} +2 -2
- package/{pbr-refraction-Dd11HnaI.js.map → pbr-refraction-C9FvFmAp.js.map} +1 -1
- package/{pbr-renderable-BHAdF5Vw.js → pbr-renderable-DzUF2QIk.js} +60 -42
- package/pbr-renderable-DzUF2QIk.js.map +1 -0
- package/{pbr-shadow-fragment-BxUrFJYZ.js → pbr-shadow-fragment-CnqnbGYS.js} +2 -2
- package/{pbr-shadow-fragment-BxUrFJYZ.js.map → pbr-shadow-fragment-CnqnbGYS.js.map} +1 -1
- package/{pbr-tracking-D6i3yPb7.js → pbr-tracking-3tU1kqea.js} +2 -2
- package/{pbr-tracking-D6i3yPb7.js.map → pbr-tracking-3tU1kqea.js.map} +1 -1
- package/{pbr-transmission-ext-Dll8EYwE.js → pbr-transmission-ext-BcLjRxfB.js} +2 -2
- package/{pbr-transmission-ext-Dll8EYwE.js.map → pbr-transmission-ext-BcLjRxfB.js.map} +1 -1
- package/recast-navigation.wasm-DG_0AFuk.js +8706 -0
- package/recast-navigation.wasm-DG_0AFuk.js.map +1 -0
- package/recast-navigation.wasm-compat-C-Bf2ylB.js +8692 -0
- package/recast-navigation.wasm-compat-C-Bf2ylB.js.map +1 -0
- package/{reflectance-fragment-ejMJ4O1o.js → reflectance-fragment-Dbpgw3Jt.js} +2 -2
- package/{reflectance-fragment-ejMJ4O1o.js.map → reflectance-fragment-Dbpgw3Jt.js.map} +1 -1
- package/{rgbd-decode-DCvzUYeI.js → rgbd-decode-DoyUquy3.js} +7 -6
- package/rgbd-decode-DoyUquy3.js.map +1 -0
- package/{scene-material-swap-C2ykv55W.js → scene-material-swap-nNUH4nGn.js} +11 -4
- package/scene-material-swap-nNUH4nGn.js.map +1 -0
- package/screenshot-readback-D0Sj9qq3.js +92 -0
- package/screenshot-readback-D0Sj9qq3.js.map +1 -0
- package/{mesh-features-BAJpbMog.js → shader-composer-BUD_pSX4.js} +3 -54
- package/shader-composer-BUD_pSX4.js.map +1 -0
- package/{shader-renderable-BMf_vvO0.js → shader-renderable-D7-RyVxa.js} +25 -19
- package/shader-renderable-D7-RyVxa.js.map +1 -0
- package/{shader-thin-instance-5_WUfi3m.js → shader-thin-instance-DuBotxDO.js} +4 -4
- package/shader-thin-instance-DuBotxDO.js.map +1 -0
- package/{sheen-fragment-CS6z29Fs.js → sheen-fragment-1MkEMcbc.js} +2 -2
- package/{sheen-fragment-CS6z29Fs.js.map → sheen-fragment-1MkEMcbc.js.map} +1 -1
- package/{singlelight-directional-wgsl-4MIgZMeC.js → singlelight-directional-wgsl-BsV8G456.js} +2 -2
- package/{singlelight-directional-wgsl-4MIgZMeC.js.map → singlelight-directional-wgsl-BsV8G456.js.map} +1 -1
- package/{singlelight-hemispheric-wgsl-CK-GUYWe.js → singlelight-hemispheric-wgsl-Bo0jKlW5.js} +2 -2
- package/{singlelight-hemispheric-wgsl-CK-GUYWe.js.map → singlelight-hemispheric-wgsl-Bo0jKlW5.js.map} +1 -1
- package/{singlelight-point-wgsl-CYtzqCbP.js → singlelight-point-wgsl-DV39UP5Y.js} +2 -2
- package/{singlelight-point-wgsl-CYtzqCbP.js.map → singlelight-point-wgsl-DV39UP5Y.js.map} +1 -1
- package/{singlelight-spot-wgsl-DVbaVufF.js → singlelight-spot-wgsl-yg3od6vL.js} +2 -2
- package/{singlelight-spot-wgsl-DVbaVufF.js.map → singlelight-spot-wgsl-yg3od6vL.js.map} +1 -1
- package/{skeleton-fragment-BOVmc8YS.js → skeleton-fragment-DdxYG6kv.js} +2 -2
- package/{skeleton-fragment-BOVmc8YS.js.map → skeleton-fragment-DdxYG6kv.js.map} +1 -1
- package/{skybox-renderable-DDcCPSly.js → skybox-renderable-CJD4XmX5.js} +7 -8
- package/skybox-renderable-CJD4XmX5.js.map +1 -0
- package/{splat-ply-compressed-BahdBG1r.js → splat-ply-compressed-DHjyiVmI.js} +9 -8
- package/splat-ply-compressed-DHjyiVmI.js.map +1 -0
- package/{standard-renderable-D1bhoF0K.js → standard-pipeline-XTbHL7MY.js} +11 -202
- package/standard-pipeline-XTbHL7MY.js.map +1 -0
- package/standard-renderable-CREWLNHI.js +191 -0
- package/standard-renderable-CREWLNHI.js.map +1 -0
- package/{std-ambient-fragment-C6WNm8dQ.js → std-ambient-fragment-Bjx3VFrr.js} +2 -2
- package/{std-ambient-fragment-C6WNm8dQ.js.map → std-ambient-fragment-Bjx3VFrr.js.map} +1 -1
- package/{std-cube-reflection-fragment-Bqutpy2q.js → std-cube-reflection-fragment-y9WWdXUt.js} +2 -2
- package/{std-cube-reflection-fragment-Bqutpy2q.js.map → std-cube-reflection-fragment-y9WWdXUt.js.map} +1 -1
- package/{std-emissive-fragment-B-A83rqX.js → std-emissive-fragment-C8Lnmojh.js} +2 -2
- package/{std-emissive-fragment-B-A83rqX.js.map → std-emissive-fragment-C8Lnmojh.js.map} +1 -1
- package/{std-lightmap-fragment-Df7KJezh.js → std-lightmap-fragment-DFxGcoA5.js} +2 -2
- package/{std-lightmap-fragment-Df7KJezh.js.map → std-lightmap-fragment-DFxGcoA5.js.map} +1 -1
- package/{std-opacity-fragment-D9et2jip.js → std-opacity-fragment-EXzFWiSp.js} +2 -2
- package/{std-opacity-fragment-D9et2jip.js.map → std-opacity-fragment-EXzFWiSp.js.map} +1 -1
- package/{std-reflection-fragment-DBJeT-yg.js → std-reflection-fragment-BoJORqpG.js} +2 -2
- package/{std-reflection-fragment-DBJeT-yg.js.map → std-reflection-fragment-BoJORqpG.js.map} +1 -1
- package/{std-shadow-fragment-C6fD8rW-.js → std-shadow-fragment-Bq-Wc8UJ.js} +2 -2
- package/{std-shadow-fragment-C6fD8rW-.js.map → std-shadow-fragment-Bq-Wc8UJ.js.map} +1 -1
- package/{std-specular-fragment-C2ZOss-t.js → std-specular-fragment-CM5R5j2g.js} +2 -2
- package/{std-specular-fragment-C2ZOss-t.js.map → std-specular-fragment-CM5R5j2g.js.map} +1 -1
- package/{std-tracking-C4L4nQGc.js → std-tracking-Cif_wXeT.js} +2 -2
- package/{std-tracking-C4L4nQGc.js.map → std-tracking-Cif_wXeT.js.map} +1 -1
- package/{subsurface-fragment-C1H4ytqK.js → subsurface-fragment-BEaAXYXz.js} +2 -2
- package/{subsurface-fragment-C1H4ytqK.js.map → subsurface-fragment-BEaAXYXz.js.map} +1 -1
- package/swapchain-overlay-UCLilhbq.js +37 -0
- package/swapchain-overlay-UCLilhbq.js.map +1 -0
- package/{thin-instance-cull-binding-CCxrPNO6.js → thin-instance-cull-binding-DWKUt5ZN.js} +12 -12
- package/thin-instance-cull-binding-DWKUt5ZN.js.map +1 -0
- package/{thin-instance-gpu-E8DBd8XL.js → thin-instance-gpu-BDdRcNAh.js} +15 -7
- package/thin-instance-gpu-BDdRcNAh.js.map +1 -0
- package/{tracking-primitives-w4BVV9p9.js → tracking-primitives-CglRNTlX.js} +2 -2
- package/{tracking-primitives-w4BVV9p9.js.map → tracking-primitives-CglRNTlX.js.map} +1 -1
- package/{unlit-fragment-DU9_mhzZ.js → unlit-fragment-kxfZWlnp.js} +2 -2
- package/{unlit-fragment-DU9_mhzZ.js.map → unlit-fragment-kxfZWlnp.js.map} +1 -1
- package/_mat4-storage-f64-Bvh5TymE.js.map +0 -1
- package/assets/splat-sort-worker-Crg3CaCc.js.map +0 -1
- package/background-dds-skybox-ZjrSIxrT.js.map +0 -1
- package/background-ground-B2Mie-MI.js.map +0 -1
- package/background-hdr-skybox-DDRJYuT2.js.map +0 -1
- package/background-solid-skybox-fjXlnWaD.js.map +0 -1
- package/billboard-renderable-DKmlOgbM.js.map +0 -1
- package/create-skeleton-BBI5urcj.js.map +0 -1
- package/cubemap-skybox-material-DvW81drX.js.map +0 -1
- package/emissive-fragment-DD8cvHyx.js.map +0 -1
- package/gaussian-splatting-pipeline-sh-BvkUhA9V.js.map +0 -1
- package/gltf-animation-KnPzeOIY.js.map +0 -1
- package/gltf-ext-basisu-kmth3UWX.js.map +0 -1
- package/gltf-ext-quantization-CpZyLDIz.js.map +0 -1
- package/gltf-feature-animation-pointer-rFqLfbO_.js.map +0 -1
- package/gltf-feature-draco-yGSMGTE3.js.map +0 -1
- package/gltf-feature-gpu-instancing-Cj1XjmM6.js.map +0 -1
- package/gltf-feature-meshopt-Des96YFI.js.map +0 -1
- package/gltf-feature-morph-BAcY14XU.js.map +0 -1
- package/gltf-glb-parser-D6UZWFuC.js.map +0 -1
- package/gltf-interleave-C9eBqH_F.js.map +0 -1
- package/gltf-pbr-builder-ext-DPC0zg_u.js.map +0 -1
- package/gs-picking-pipeline-Bx8LTav6.js.map +0 -1
- package/index-B7Qhw0xL.js +0 -21232
- package/index-B7Qhw0xL.js.map +0 -1
- package/mesh-features-BAJpbMog.js.map +0 -1
- package/no-color-view-DsyLSL-W.js +0 -8
- package/no-color-view-DsyLSL-W.js.map +0 -1
- package/node-env-BPZXZzBf.js.map +0 -1
- package/node-registry-Bd-AlrgC.js +0 -190
- package/node-registry-Bd-AlrgC.js.map +0 -1
- package/node-renderable-CS0CmsSp.js.map +0 -1
- package/node-shadow-CpnrdvtJ.js.map +0 -1
- package/pbr-renderable-BHAdF5Vw.js.map +0 -1
- package/rgbd-decode-DCvzUYeI.js.map +0 -1
- package/scene-material-swap-C2ykv55W.js.map +0 -1
- package/shader-renderable-BMf_vvO0.js.map +0 -1
- package/shader-thin-instance-5_WUfi3m.js.map +0 -1
- package/skybox-renderable-DDcCPSly.js.map +0 -1
- package/splat-ply-compressed-BahdBG1r.js.map +0 -1
- package/standard-renderable-D1bhoF0K.js.map +0 -1
- package/swapchain-overlay-DcCSFDp7.js +0 -35
- package/swapchain-overlay-DcCSFDp7.js.map +0 -1
- package/thin-instance-cull-binding-CCxrPNO6.js.map +0 -1
- package/thin-instance-gpu-E8DBd8XL.js.map +0 -1
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
import { TileCacheMeshProcess, RecastBuildContext, recastConfigDefaults, createRcConfig, calcGridSize, vec3, Raw, NavMesh, VerticesArray, TrianglesArray, allocHeightfield, createHeightfield, TriangleAreasArray, markWalkableTriangles, rasterizeTriangles, filterLowHangingWalkableObstacles, filterLedgeSpans, filterWalkableLowHeightSpans, allocCompactHeightfield, buildCompactHeightfield, freeHeightfield, erodeWalkableArea, buildDistanceField, buildRegions, allocContourSet, buildContours, Recast, allocPolyMesh, buildPolyMesh, allocPolyMeshDetail, buildPolyMeshDetail, freeCompactHeightfield, freeContourSet, NavMeshCreateParams, createNavMeshData, TileCache, DetourTileCacheParams, NavMeshParams, RecastChunkyTriMesh, statusFailed, cloneRcConfig, ChunkIdsArray, Detour, statusToReadableString, freePolyMesh, freePolyMeshDetail, allocHeightfieldLayerSet, buildHeightfieldLayers, TileCacheData, getHeightfieldLayerHeights, getHeightfieldLayerAreas, getHeightfieldLayerCons, buildTileCacheLayer, freeHeightfieldLayerSet } from "./index-SMJ67XwT.js";
|
|
2
|
+
const getBoundingBox = (positions, indices) => {
|
|
3
|
+
const bbMin = {
|
|
4
|
+
x: Infinity,
|
|
5
|
+
y: Infinity,
|
|
6
|
+
z: Infinity
|
|
7
|
+
};
|
|
8
|
+
const bbMax = {
|
|
9
|
+
x: -Infinity,
|
|
10
|
+
y: -Infinity,
|
|
11
|
+
z: -Infinity
|
|
12
|
+
};
|
|
13
|
+
for (let i = 0; i < indices.length; i++) {
|
|
14
|
+
const ind = indices[i];
|
|
15
|
+
const x = positions[ind * 3];
|
|
16
|
+
const y = positions[ind * 3 + 1];
|
|
17
|
+
const z = positions[ind * 3 + 2];
|
|
18
|
+
bbMin.x = Math.min(bbMin.x, x);
|
|
19
|
+
bbMin.y = Math.min(bbMin.y, y);
|
|
20
|
+
bbMin.z = Math.min(bbMin.z, z);
|
|
21
|
+
bbMax.x = Math.max(bbMax.x, x);
|
|
22
|
+
bbMax.y = Math.max(bbMax.y, y);
|
|
23
|
+
bbMax.z = Math.max(bbMax.z, z);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
bbMin: vec3.toArray(bbMin),
|
|
27
|
+
bbMax: vec3.toArray(bbMax)
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const dtIlog2 = (v) => {
|
|
31
|
+
let r = 0;
|
|
32
|
+
let shift = 0;
|
|
33
|
+
r = Number(v > 65535) << 4;
|
|
34
|
+
v >>= r;
|
|
35
|
+
shift = Number(v > 255) << 3;
|
|
36
|
+
v >>= shift;
|
|
37
|
+
r |= shift;
|
|
38
|
+
shift = Number(v > 15) << 2;
|
|
39
|
+
v >>= shift;
|
|
40
|
+
r |= shift;
|
|
41
|
+
shift = Number(v > 3) << 1;
|
|
42
|
+
v >>= shift;
|
|
43
|
+
r |= shift;
|
|
44
|
+
r |= v >> 1;
|
|
45
|
+
return r;
|
|
46
|
+
};
|
|
47
|
+
const dtNextPow2 = (v) => {
|
|
48
|
+
v--;
|
|
49
|
+
v |= v >> 1;
|
|
50
|
+
v |= v >> 2;
|
|
51
|
+
v |= v >> 4;
|
|
52
|
+
v |= v >> 8;
|
|
53
|
+
v |= v >> 16;
|
|
54
|
+
v++;
|
|
55
|
+
return v;
|
|
56
|
+
};
|
|
57
|
+
const soloNavMeshGeneratorConfigDefaults = {
|
|
58
|
+
...recastConfigDefaults,
|
|
59
|
+
buildBvTree: true
|
|
60
|
+
};
|
|
61
|
+
const generateSoloNavMeshData = (positions, indices, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
|
|
62
|
+
const buildContext = new RecastBuildContext();
|
|
63
|
+
const intermediates = {
|
|
64
|
+
type: "solo",
|
|
65
|
+
buildContext
|
|
66
|
+
};
|
|
67
|
+
const cleanup = () => {
|
|
68
|
+
if (keepIntermediates) return;
|
|
69
|
+
if (intermediates.heightfield) {
|
|
70
|
+
freeHeightfield(intermediates.heightfield);
|
|
71
|
+
intermediates.heightfield = void 0;
|
|
72
|
+
}
|
|
73
|
+
if (intermediates.compactHeightfield) {
|
|
74
|
+
freeCompactHeightfield(intermediates.compactHeightfield);
|
|
75
|
+
intermediates.compactHeightfield = void 0;
|
|
76
|
+
}
|
|
77
|
+
if (intermediates.contourSet) {
|
|
78
|
+
freeContourSet(intermediates.contourSet);
|
|
79
|
+
intermediates.contourSet = void 0;
|
|
80
|
+
}
|
|
81
|
+
if (intermediates.polyMesh) {
|
|
82
|
+
freePolyMesh(intermediates.polyMesh);
|
|
83
|
+
intermediates.polyMesh = void 0;
|
|
84
|
+
}
|
|
85
|
+
if (intermediates.polyMeshDetail) {
|
|
86
|
+
freePolyMeshDetail(intermediates.polyMeshDetail);
|
|
87
|
+
intermediates.polyMeshDetail = void 0;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const fail = (error) => {
|
|
91
|
+
cleanup();
|
|
92
|
+
return {
|
|
93
|
+
navMeshData: void 0,
|
|
94
|
+
success: false,
|
|
95
|
+
intermediates,
|
|
96
|
+
error
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const vertices = positions;
|
|
100
|
+
const numVertices = indices.length;
|
|
101
|
+
const verticesArray = new VerticesArray();
|
|
102
|
+
verticesArray.copy(vertices);
|
|
103
|
+
const triangles = indices;
|
|
104
|
+
const numTriangles = indices.length / 3;
|
|
105
|
+
const trianglesArray = new TrianglesArray();
|
|
106
|
+
trianglesArray.copy(triangles);
|
|
107
|
+
let bbMin;
|
|
108
|
+
let bbMax;
|
|
109
|
+
if (navMeshGeneratorConfig.bounds) {
|
|
110
|
+
bbMin = navMeshGeneratorConfig.bounds[0];
|
|
111
|
+
bbMax = navMeshGeneratorConfig.bounds[1];
|
|
112
|
+
} else {
|
|
113
|
+
const boundingBox = getBoundingBox(positions, indices);
|
|
114
|
+
bbMin = boundingBox.bbMin;
|
|
115
|
+
bbMax = boundingBox.bbMax;
|
|
116
|
+
}
|
|
117
|
+
const config = {
|
|
118
|
+
...soloNavMeshGeneratorConfigDefaults,
|
|
119
|
+
...navMeshGeneratorConfig
|
|
120
|
+
};
|
|
121
|
+
const rcConfig = createRcConfig(config);
|
|
122
|
+
rcConfig.minRegionArea = rcConfig.minRegionArea * rcConfig.minRegionArea;
|
|
123
|
+
rcConfig.mergeRegionArea = rcConfig.mergeRegionArea * rcConfig.mergeRegionArea;
|
|
124
|
+
rcConfig.detailSampleDist = rcConfig.detailSampleDist < 0.9 ? 0 : rcConfig.cs * rcConfig.detailSampleDist;
|
|
125
|
+
rcConfig.detailSampleMaxError = rcConfig.ch * rcConfig.detailSampleMaxError;
|
|
126
|
+
const gridSize = calcGridSize(bbMin, bbMax, rcConfig.cs);
|
|
127
|
+
rcConfig.width = gridSize.width;
|
|
128
|
+
rcConfig.height = gridSize.height;
|
|
129
|
+
const heightfield = allocHeightfield();
|
|
130
|
+
intermediates.heightfield = heightfield;
|
|
131
|
+
if (!createHeightfield(buildContext, heightfield, rcConfig.width, rcConfig.height, bbMin, bbMax, rcConfig.cs, rcConfig.ch)) {
|
|
132
|
+
return fail("Could not create heightfield");
|
|
133
|
+
}
|
|
134
|
+
const triangleAreasArray = new TriangleAreasArray();
|
|
135
|
+
triangleAreasArray.resize(numTriangles);
|
|
136
|
+
markWalkableTriangles(buildContext, rcConfig.walkableSlopeAngle, verticesArray, numVertices, trianglesArray, numTriangles, triangleAreasArray);
|
|
137
|
+
if (!rasterizeTriangles(buildContext, verticesArray, numVertices, trianglesArray, triangleAreasArray, numTriangles, heightfield, rcConfig.walkableClimb)) {
|
|
138
|
+
return fail("Could not rasterize triangles");
|
|
139
|
+
}
|
|
140
|
+
triangleAreasArray.destroy();
|
|
141
|
+
verticesArray.destroy();
|
|
142
|
+
trianglesArray.destroy();
|
|
143
|
+
filterLowHangingWalkableObstacles(buildContext, rcConfig.walkableClimb, heightfield);
|
|
144
|
+
filterLedgeSpans(buildContext, rcConfig.walkableHeight, rcConfig.walkableClimb, heightfield);
|
|
145
|
+
filterWalkableLowHeightSpans(buildContext, rcConfig.walkableHeight, heightfield);
|
|
146
|
+
const compactHeightfield = allocCompactHeightfield();
|
|
147
|
+
intermediates.compactHeightfield = compactHeightfield;
|
|
148
|
+
if (!buildCompactHeightfield(buildContext, rcConfig.walkableHeight, rcConfig.walkableClimb, heightfield, compactHeightfield)) {
|
|
149
|
+
return fail("Failed to build compact data");
|
|
150
|
+
}
|
|
151
|
+
if (!keepIntermediates) {
|
|
152
|
+
freeHeightfield(heightfield);
|
|
153
|
+
intermediates.heightfield = void 0;
|
|
154
|
+
}
|
|
155
|
+
if (!erodeWalkableArea(buildContext, rcConfig.walkableRadius, compactHeightfield)) {
|
|
156
|
+
return fail("Failed to erode walkable area");
|
|
157
|
+
}
|
|
158
|
+
if (!buildDistanceField(buildContext, compactHeightfield)) {
|
|
159
|
+
return fail("Failed to build distance field");
|
|
160
|
+
}
|
|
161
|
+
if (!buildRegions(buildContext, compactHeightfield, rcConfig.borderSize, rcConfig.minRegionArea, rcConfig.mergeRegionArea)) {
|
|
162
|
+
return fail("Failed to build regions");
|
|
163
|
+
}
|
|
164
|
+
const contourSet = allocContourSet();
|
|
165
|
+
intermediates.contourSet = contourSet;
|
|
166
|
+
if (!buildContours(buildContext, compactHeightfield, rcConfig.maxSimplificationError, rcConfig.maxEdgeLen, contourSet, Recast.RC_CONTOUR_TESS_WALL_EDGES)) {
|
|
167
|
+
return fail("Failed to create contours");
|
|
168
|
+
}
|
|
169
|
+
const polyMesh = allocPolyMesh();
|
|
170
|
+
intermediates.polyMesh = polyMesh;
|
|
171
|
+
if (!buildPolyMesh(buildContext, contourSet, rcConfig.maxVertsPerPoly, polyMesh)) {
|
|
172
|
+
return fail("Failed to triangulate contours");
|
|
173
|
+
}
|
|
174
|
+
const polyMeshDetail = allocPolyMeshDetail();
|
|
175
|
+
intermediates.polyMeshDetail = polyMeshDetail;
|
|
176
|
+
if (!buildPolyMeshDetail(buildContext, polyMesh, compactHeightfield, rcConfig.detailSampleDist, rcConfig.detailSampleMaxError, polyMeshDetail)) {
|
|
177
|
+
return fail("Failed to build detail mesh");
|
|
178
|
+
}
|
|
179
|
+
if (!keepIntermediates) {
|
|
180
|
+
freeCompactHeightfield(compactHeightfield);
|
|
181
|
+
intermediates.compactHeightfield = void 0;
|
|
182
|
+
freeContourSet(contourSet);
|
|
183
|
+
intermediates.contourSet = void 0;
|
|
184
|
+
}
|
|
185
|
+
for (let i = 0; i < polyMesh.npolys(); i++) {
|
|
186
|
+
if (polyMesh.areas(i) === Recast.RC_WALKABLE_AREA) {
|
|
187
|
+
polyMesh.setAreas(i, 0);
|
|
188
|
+
}
|
|
189
|
+
if (polyMesh.areas(i) === 0) {
|
|
190
|
+
polyMesh.setFlags(i, 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const navMeshCreateParams = new NavMeshCreateParams();
|
|
194
|
+
navMeshCreateParams.setPolyMeshCreateParams(polyMesh);
|
|
195
|
+
navMeshCreateParams.setPolyMeshDetailCreateParams(polyMeshDetail);
|
|
196
|
+
navMeshCreateParams.setWalkableHeight(rcConfig.walkableHeight * rcConfig.ch);
|
|
197
|
+
navMeshCreateParams.setWalkableRadius(rcConfig.walkableRadius * rcConfig.cs);
|
|
198
|
+
navMeshCreateParams.setWalkableClimb(rcConfig.walkableClimb * rcConfig.ch);
|
|
199
|
+
navMeshCreateParams.setCellSize(rcConfig.cs);
|
|
200
|
+
navMeshCreateParams.setCellHeight(rcConfig.ch);
|
|
201
|
+
navMeshCreateParams.setBuildBvTree(config.buildBvTree);
|
|
202
|
+
if (navMeshGeneratorConfig.offMeshConnections) {
|
|
203
|
+
navMeshCreateParams.setOffMeshConnections(navMeshGeneratorConfig.offMeshConnections);
|
|
204
|
+
}
|
|
205
|
+
const createNavMeshDataResult = createNavMeshData(navMeshCreateParams);
|
|
206
|
+
if (!createNavMeshDataResult.success) {
|
|
207
|
+
return fail("Failed to create Detour navmesh data");
|
|
208
|
+
}
|
|
209
|
+
cleanup();
|
|
210
|
+
return {
|
|
211
|
+
navMeshData: createNavMeshDataResult.navMeshData,
|
|
212
|
+
success: true,
|
|
213
|
+
intermediates
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
const generateSoloNavMesh = (positions, indices, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
|
|
217
|
+
if (!Raw.Module) {
|
|
218
|
+
throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');
|
|
219
|
+
}
|
|
220
|
+
const createNavMeshDataResult = generateSoloNavMeshData(positions, indices, navMeshGeneratorConfig, keepIntermediates);
|
|
221
|
+
if (!createNavMeshDataResult.success) {
|
|
222
|
+
return {
|
|
223
|
+
navMesh: void 0,
|
|
224
|
+
success: false,
|
|
225
|
+
intermediates: createNavMeshDataResult.intermediates,
|
|
226
|
+
error: createNavMeshDataResult.error
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const {
|
|
230
|
+
navMeshData
|
|
231
|
+
} = createNavMeshDataResult;
|
|
232
|
+
const navMesh = new NavMesh();
|
|
233
|
+
if (!navMesh.initSolo(navMeshData)) {
|
|
234
|
+
navMeshData.destroy();
|
|
235
|
+
return {
|
|
236
|
+
navMesh: void 0,
|
|
237
|
+
success: false,
|
|
238
|
+
intermediates: createNavMeshDataResult.intermediates,
|
|
239
|
+
error: "Failed to initialize solo NavMesh"
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
success: true,
|
|
244
|
+
navMesh,
|
|
245
|
+
intermediates: createNavMeshDataResult.intermediates
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
const tileCacheGeneratorConfigDefaults = {
|
|
249
|
+
...recastConfigDefaults,
|
|
250
|
+
tileSize: 32,
|
|
251
|
+
expectedLayersPerTile: 4,
|
|
252
|
+
maxObstacles: 128
|
|
253
|
+
};
|
|
254
|
+
const createDefaultTileCacheMeshProcess = () => new TileCacheMeshProcess((navMeshCreateParams, polyAreas, polyFlags) => {
|
|
255
|
+
for (let i = 0; i < navMeshCreateParams.polyCount(); ++i) {
|
|
256
|
+
polyAreas.set(i, 0);
|
|
257
|
+
polyFlags.set(i, 1);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
const generateTileCache = (positions, indices, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
|
|
261
|
+
if (!Raw.Module) {
|
|
262
|
+
throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');
|
|
263
|
+
}
|
|
264
|
+
const buildContext = new RecastBuildContext();
|
|
265
|
+
const intermediates = {
|
|
266
|
+
type: "tilecache",
|
|
267
|
+
buildContext,
|
|
268
|
+
chunkyTriMesh: void 0,
|
|
269
|
+
tileIntermediates: []
|
|
270
|
+
};
|
|
271
|
+
const tileCache = new TileCache();
|
|
272
|
+
const navMesh = new NavMesh();
|
|
273
|
+
const vertices = positions;
|
|
274
|
+
const numVertices = indices.length;
|
|
275
|
+
const verticesArray = new VerticesArray();
|
|
276
|
+
verticesArray.copy(vertices);
|
|
277
|
+
const triangles = indices;
|
|
278
|
+
const numTriangles = indices.length / 3;
|
|
279
|
+
const trianglesArray = new TrianglesArray();
|
|
280
|
+
trianglesArray.copy(triangles);
|
|
281
|
+
let bbMin;
|
|
282
|
+
let bbMax;
|
|
283
|
+
if (navMeshGeneratorConfig.bounds) {
|
|
284
|
+
bbMin = navMeshGeneratorConfig.bounds[0];
|
|
285
|
+
bbMax = navMeshGeneratorConfig.bounds[1];
|
|
286
|
+
} else {
|
|
287
|
+
const boundingBox = getBoundingBox(positions, indices);
|
|
288
|
+
bbMin = boundingBox.bbMin;
|
|
289
|
+
bbMax = boundingBox.bbMax;
|
|
290
|
+
}
|
|
291
|
+
const {
|
|
292
|
+
expectedLayersPerTile,
|
|
293
|
+
maxObstacles,
|
|
294
|
+
...recastConfig
|
|
295
|
+
} = {
|
|
296
|
+
...tileCacheGeneratorConfigDefaults,
|
|
297
|
+
...navMeshGeneratorConfig
|
|
298
|
+
};
|
|
299
|
+
const cleanup = () => {
|
|
300
|
+
verticesArray.destroy();
|
|
301
|
+
trianglesArray.destroy();
|
|
302
|
+
if (!keepIntermediates) {
|
|
303
|
+
for (let i = 0; i < intermediates.tileIntermediates.length; i++) {
|
|
304
|
+
const tileIntermediate = intermediates.tileIntermediates[i];
|
|
305
|
+
if (tileIntermediate.heightfield) {
|
|
306
|
+
freeHeightfield(tileIntermediate.heightfield);
|
|
307
|
+
tileIntermediate.heightfield = void 0;
|
|
308
|
+
}
|
|
309
|
+
if (tileIntermediate.compactHeightfield) {
|
|
310
|
+
freeCompactHeightfield(tileIntermediate.compactHeightfield);
|
|
311
|
+
tileIntermediate.compactHeightfield = void 0;
|
|
312
|
+
}
|
|
313
|
+
if (tileIntermediate.heightfieldLayerSet) {
|
|
314
|
+
freeHeightfieldLayerSet(tileIntermediate.heightfieldLayerSet);
|
|
315
|
+
tileIntermediate.heightfieldLayerSet = void 0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const fail = (error) => {
|
|
321
|
+
cleanup();
|
|
322
|
+
tileCache.destroy();
|
|
323
|
+
navMesh.destroy();
|
|
324
|
+
return {
|
|
325
|
+
success: false,
|
|
326
|
+
navMesh: void 0,
|
|
327
|
+
tileCache: void 0,
|
|
328
|
+
intermediates,
|
|
329
|
+
error
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
const config = createRcConfig(recastConfig);
|
|
333
|
+
const gridSize = calcGridSize(bbMin, bbMax, config.cs);
|
|
334
|
+
config.width = gridSize.width;
|
|
335
|
+
config.height = gridSize.height;
|
|
336
|
+
config.minRegionArea = config.minRegionArea * config.minRegionArea;
|
|
337
|
+
config.mergeRegionArea = config.mergeRegionArea * config.mergeRegionArea;
|
|
338
|
+
config.detailSampleDist = config.detailSampleDist < 0.9 ? 0 : config.cs * config.detailSampleDist;
|
|
339
|
+
config.detailSampleMaxError = config.ch * config.detailSampleMaxError;
|
|
340
|
+
const tileSize = Math.floor(config.tileSize);
|
|
341
|
+
const tileWidth = Math.floor((config.width + tileSize - 1) / tileSize);
|
|
342
|
+
const tileHeight = Math.floor((config.height + tileSize - 1) / tileSize);
|
|
343
|
+
config.borderSize = config.walkableRadius + 3;
|
|
344
|
+
config.width = config.tileSize + config.borderSize * 2;
|
|
345
|
+
config.height = config.tileSize + config.borderSize * 2;
|
|
346
|
+
const tileCacheParams = DetourTileCacheParams.create({
|
|
347
|
+
orig: bbMin,
|
|
348
|
+
cs: config.cs,
|
|
349
|
+
ch: config.ch,
|
|
350
|
+
width: config.tileSize,
|
|
351
|
+
height: config.tileSize,
|
|
352
|
+
walkableHeight: config.walkableHeight * config.ch,
|
|
353
|
+
walkableRadius: config.walkableRadius * config.cs,
|
|
354
|
+
walkableClimb: config.walkableClimb * config.ch,
|
|
355
|
+
maxSimplificationError: config.maxSimplificationError,
|
|
356
|
+
maxTiles: tileWidth * tileHeight * expectedLayersPerTile,
|
|
357
|
+
maxObstacles
|
|
358
|
+
});
|
|
359
|
+
const allocator = new Raw.RecastLinearAllocator(32e3);
|
|
360
|
+
const compressor = new Raw.RecastFastLZCompressor();
|
|
361
|
+
const tileCacheMeshProcess = navMeshGeneratorConfig.tileCacheMeshProcess ?? createDefaultTileCacheMeshProcess();
|
|
362
|
+
if (!tileCache.init(tileCacheParams, allocator, compressor, tileCacheMeshProcess)) {
|
|
363
|
+
return fail("Failed to initialize tile cache");
|
|
364
|
+
}
|
|
365
|
+
const orig = vec3.fromArray(bbMin);
|
|
366
|
+
let tileBits = Math.min(Math.floor(dtIlog2(dtNextPow2(tileWidth * tileHeight * expectedLayersPerTile))), 14);
|
|
367
|
+
if (tileBits > 14) {
|
|
368
|
+
tileBits = 14;
|
|
369
|
+
}
|
|
370
|
+
const polyBits = 22 - tileBits;
|
|
371
|
+
const maxTiles = 1 << tileBits;
|
|
372
|
+
const maxPolysPerTile = 1 << polyBits;
|
|
373
|
+
const navMeshParams = NavMeshParams.create({
|
|
374
|
+
orig,
|
|
375
|
+
tileWidth: config.tileSize * config.cs,
|
|
376
|
+
tileHeight: config.tileSize * config.cs,
|
|
377
|
+
maxTiles,
|
|
378
|
+
maxPolys: maxPolysPerTile
|
|
379
|
+
});
|
|
380
|
+
if (!navMesh.initTiled(navMeshParams)) {
|
|
381
|
+
return fail("Failed to initialize tiled navmesh");
|
|
382
|
+
}
|
|
383
|
+
const chunkyTriMesh = new RecastChunkyTriMesh();
|
|
384
|
+
intermediates.chunkyTriMesh = chunkyTriMesh;
|
|
385
|
+
if (!chunkyTriMesh.init(verticesArray, trianglesArray, numTriangles, 256)) {
|
|
386
|
+
return fail("Failed to build chunky triangle mesh");
|
|
387
|
+
}
|
|
388
|
+
const rasterizeTileLayers = (tileX, tileY) => {
|
|
389
|
+
const tileIntermediates = {
|
|
390
|
+
tileX,
|
|
391
|
+
tileY
|
|
392
|
+
};
|
|
393
|
+
const tcs = config.tileSize * config.cs;
|
|
394
|
+
const tileConfig = cloneRcConfig(config);
|
|
395
|
+
const tileBoundsMin = [bbMin[0] + tileX * tcs, bbMin[1], bbMin[2] + tileY * tcs];
|
|
396
|
+
const tileBoundsMax = [bbMin[0] + (tileX + 1) * tcs, bbMax[1], bbMin[2] + (tileY + 1) * tcs];
|
|
397
|
+
tileBoundsMin[0] -= tileConfig.borderSize * tileConfig.cs;
|
|
398
|
+
tileBoundsMin[2] -= tileConfig.borderSize * tileConfig.cs;
|
|
399
|
+
tileBoundsMax[0] += tileConfig.borderSize * tileConfig.cs;
|
|
400
|
+
tileBoundsMax[2] += tileConfig.borderSize * tileConfig.cs;
|
|
401
|
+
tileConfig.set_bmin(0, tileBoundsMin[0]);
|
|
402
|
+
tileConfig.set_bmin(1, tileBoundsMin[1]);
|
|
403
|
+
tileConfig.set_bmin(2, tileBoundsMin[2]);
|
|
404
|
+
tileConfig.set_bmax(0, tileBoundsMax[0]);
|
|
405
|
+
tileConfig.set_bmax(1, tileBoundsMax[1]);
|
|
406
|
+
tileConfig.set_bmax(2, tileBoundsMax[2]);
|
|
407
|
+
const heightfield = allocHeightfield();
|
|
408
|
+
tileIntermediates.heightfield = heightfield;
|
|
409
|
+
if (!createHeightfield(buildContext, heightfield, tileConfig.width, tileConfig.height, tileBoundsMin, tileBoundsMax, tileConfig.cs, tileConfig.ch)) {
|
|
410
|
+
return {
|
|
411
|
+
n: 0
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
const tbmin = [tileBoundsMin[0], tileBoundsMin[2]];
|
|
415
|
+
const tbmax = [tileBoundsMax[0], tileBoundsMax[2]];
|
|
416
|
+
const maxChunkIds = 512;
|
|
417
|
+
const chunkIdsArray = new ChunkIdsArray();
|
|
418
|
+
chunkIdsArray.resize(maxChunkIds);
|
|
419
|
+
const nChunksOverlapping = chunkyTriMesh.getChunksOverlappingRect(tbmin, tbmax, chunkIdsArray, maxChunkIds);
|
|
420
|
+
if (nChunksOverlapping === 0) {
|
|
421
|
+
return {
|
|
422
|
+
n: 0
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
for (let i = 0; i < nChunksOverlapping; ++i) {
|
|
426
|
+
const nodeId = chunkIdsArray.get(i);
|
|
427
|
+
const node = chunkyTriMesh.nodes(nodeId);
|
|
428
|
+
const nNodeTris = node.n;
|
|
429
|
+
const nodeTrianglesArray = chunkyTriMesh.getNodeTris(nodeId);
|
|
430
|
+
const triangleAreasArray = new TriangleAreasArray();
|
|
431
|
+
triangleAreasArray.resize(nNodeTris);
|
|
432
|
+
markWalkableTriangles(buildContext, tileConfig.walkableSlopeAngle, verticesArray, numVertices, nodeTrianglesArray, nNodeTris, triangleAreasArray);
|
|
433
|
+
const success = rasterizeTriangles(buildContext, verticesArray, numVertices, nodeTrianglesArray, triangleAreasArray, nNodeTris, heightfield, tileConfig.walkableClimb);
|
|
434
|
+
triangleAreasArray.destroy();
|
|
435
|
+
if (!success) {
|
|
436
|
+
return {
|
|
437
|
+
n: 0
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
filterLowHangingWalkableObstacles(buildContext, config.walkableClimb, heightfield);
|
|
442
|
+
filterLedgeSpans(buildContext, config.walkableHeight, config.walkableClimb, heightfield);
|
|
443
|
+
filterWalkableLowHeightSpans(buildContext, config.walkableHeight, heightfield);
|
|
444
|
+
const compactHeightfield = allocCompactHeightfield();
|
|
445
|
+
if (!buildCompactHeightfield(buildContext, config.walkableHeight, config.walkableClimb, heightfield, compactHeightfield)) {
|
|
446
|
+
return {
|
|
447
|
+
n: 0
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
if (!keepIntermediates) {
|
|
451
|
+
freeHeightfield(tileIntermediates.heightfield);
|
|
452
|
+
tileIntermediates.heightfield = void 0;
|
|
453
|
+
}
|
|
454
|
+
if (!erodeWalkableArea(buildContext, config.walkableRadius, compactHeightfield)) {
|
|
455
|
+
return {
|
|
456
|
+
n: 0
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
const heightfieldLayerSet = allocHeightfieldLayerSet();
|
|
460
|
+
if (!buildHeightfieldLayers(buildContext, compactHeightfield, config.borderSize, config.walkableHeight, heightfieldLayerSet)) {
|
|
461
|
+
return {
|
|
462
|
+
n: 0
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
if (!keepIntermediates) {
|
|
466
|
+
freeCompactHeightfield(compactHeightfield);
|
|
467
|
+
tileIntermediates.compactHeightfield = void 0;
|
|
468
|
+
}
|
|
469
|
+
const tiles = [];
|
|
470
|
+
for (let i = 0; i < heightfieldLayerSet.nlayers(); i++) {
|
|
471
|
+
const tile = new TileCacheData();
|
|
472
|
+
const heightfieldLayer = heightfieldLayerSet.layers(i);
|
|
473
|
+
const header = new Raw.dtTileCacheLayerHeader();
|
|
474
|
+
header.magic = Detour.DT_TILECACHE_MAGIC;
|
|
475
|
+
header.version = Detour.DT_TILECACHE_VERSION;
|
|
476
|
+
header.tx = tileX;
|
|
477
|
+
header.ty = tileY;
|
|
478
|
+
header.tlayer = i;
|
|
479
|
+
const heightfieldLayerBin = heightfieldLayer.bmin();
|
|
480
|
+
const heightfieldLayerBmax = heightfieldLayer.bmax();
|
|
481
|
+
header.set_bmin(0, heightfieldLayerBin.x);
|
|
482
|
+
header.set_bmin(1, heightfieldLayerBin.y);
|
|
483
|
+
header.set_bmin(2, heightfieldLayerBin.z);
|
|
484
|
+
header.set_bmax(0, heightfieldLayerBmax.x);
|
|
485
|
+
header.set_bmax(1, heightfieldLayerBmax.y);
|
|
486
|
+
header.set_bmax(2, heightfieldLayerBmax.z);
|
|
487
|
+
header.width = heightfieldLayer.width();
|
|
488
|
+
header.height = heightfieldLayer.height();
|
|
489
|
+
header.minx = heightfieldLayer.minx();
|
|
490
|
+
header.maxx = heightfieldLayer.maxx();
|
|
491
|
+
header.miny = heightfieldLayer.miny();
|
|
492
|
+
header.maxy = heightfieldLayer.maxy();
|
|
493
|
+
header.hmin = heightfieldLayer.hmin();
|
|
494
|
+
header.hmax = heightfieldLayer.hmax();
|
|
495
|
+
const heights = getHeightfieldLayerHeights(heightfieldLayer);
|
|
496
|
+
const areas = getHeightfieldLayerAreas(heightfieldLayer);
|
|
497
|
+
const cons = getHeightfieldLayerCons(heightfieldLayer);
|
|
498
|
+
const status = buildTileCacheLayer(compressor, header, heights, areas, cons, tile);
|
|
499
|
+
if (statusFailed(status)) {
|
|
500
|
+
return {
|
|
501
|
+
n: 0
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
tiles.push(tile);
|
|
505
|
+
}
|
|
506
|
+
if (!keepIntermediates) {
|
|
507
|
+
freeHeightfieldLayerSet(heightfieldLayerSet);
|
|
508
|
+
tileIntermediates.heightfieldLayerSet = void 0;
|
|
509
|
+
}
|
|
510
|
+
intermediates.tileIntermediates.push(tileIntermediates);
|
|
511
|
+
return {
|
|
512
|
+
n: tiles.length,
|
|
513
|
+
tiles
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
for (let y = 0; y < tileHeight; ++y) {
|
|
517
|
+
for (let x = 0; x < tileWidth; ++x) {
|
|
518
|
+
const {
|
|
519
|
+
n,
|
|
520
|
+
tiles: newTiles
|
|
521
|
+
} = rasterizeTileLayers(x, y);
|
|
522
|
+
if (n > 0 && newTiles) {
|
|
523
|
+
for (let i = 0; i < n; i++) {
|
|
524
|
+
const tileCacheData = newTiles[i];
|
|
525
|
+
const addResult = tileCache.addTile(tileCacheData);
|
|
526
|
+
if (statusFailed(addResult.status)) {
|
|
527
|
+
buildContext.log(Recast.RC_LOG_WARNING, `Failed to add tile to tile cache - tx: ${x}, ty: ${y}`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
for (let y = 0; y < tileHeight; y++) {
|
|
534
|
+
for (let x = 0; x < tileWidth; x++) {
|
|
535
|
+
const dtStatus = tileCache.buildNavMeshTilesAt(x, y, navMesh);
|
|
536
|
+
if (statusFailed(dtStatus)) {
|
|
537
|
+
return fail(`Failed to build nav mesh tiles at ${x}, ${y}`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
cleanup();
|
|
542
|
+
return {
|
|
543
|
+
success: true,
|
|
544
|
+
tileCache,
|
|
545
|
+
navMesh,
|
|
546
|
+
intermediates
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
const buildTiledNavMeshRcConfig = ({
|
|
550
|
+
recastConfig,
|
|
551
|
+
navMeshBounds: [navMeshBoundsMin, navMeshBoundsMax]
|
|
552
|
+
}) => {
|
|
553
|
+
const config = createRcConfig(recastConfig);
|
|
554
|
+
const gridSize = calcGridSize(navMeshBoundsMin, navMeshBoundsMax, config.cs);
|
|
555
|
+
config.width = gridSize.width;
|
|
556
|
+
config.height = gridSize.height;
|
|
557
|
+
config.minRegionArea = config.minRegionArea * config.minRegionArea;
|
|
558
|
+
config.mergeRegionArea = config.mergeRegionArea * config.mergeRegionArea;
|
|
559
|
+
config.tileSize = Math.floor(config.tileSize);
|
|
560
|
+
config.borderSize = config.walkableRadius + 3;
|
|
561
|
+
config.width = config.tileSize + config.borderSize * 2;
|
|
562
|
+
config.height = config.tileSize + config.borderSize * 2;
|
|
563
|
+
config.detailSampleDist = config.detailSampleDist < 0.9 ? 0 : config.cs * config.detailSampleDist;
|
|
564
|
+
config.detailSampleMaxError = config.ch * config.detailSampleMaxError;
|
|
565
|
+
const tileSize = Math.floor(config.tileSize);
|
|
566
|
+
const tileWidth = Math.floor((gridSize.width + tileSize - 1) / tileSize);
|
|
567
|
+
const tileHeight = Math.floor((gridSize.height + tileSize - 1) / tileSize);
|
|
568
|
+
const tcs = config.tileSize * config.cs;
|
|
569
|
+
const orig = vec3.fromArray(navMeshBoundsMin);
|
|
570
|
+
let tileBits = Math.min(Math.floor(dtIlog2(dtNextPow2(tileWidth * tileHeight))), 14);
|
|
571
|
+
if (tileBits > 14) tileBits = 14;
|
|
572
|
+
const polyBits = 22 - tileBits;
|
|
573
|
+
const maxTiles = 1 << tileBits;
|
|
574
|
+
const maxPolysPerTile = 1 << polyBits;
|
|
575
|
+
return {
|
|
576
|
+
config,
|
|
577
|
+
gridSize,
|
|
578
|
+
tileSize,
|
|
579
|
+
tileWidth,
|
|
580
|
+
tileHeight,
|
|
581
|
+
tcs,
|
|
582
|
+
orig,
|
|
583
|
+
maxTiles,
|
|
584
|
+
maxPolysPerTile
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
const tiledNavMeshGeneratorConfigDefaults = {
|
|
588
|
+
...recastConfigDefaults,
|
|
589
|
+
chunkyTriMeshTrisPerChunk: 256,
|
|
590
|
+
buildBvTree: true
|
|
591
|
+
};
|
|
592
|
+
const generateTileNavMeshData = (positions, indices, rcConfig, chunkyTriMesh, tile, options = {}, keepIntermediates = false, buildContext = new RecastBuildContext()) => {
|
|
593
|
+
const tileIntermediate = {
|
|
594
|
+
x: tile.x,
|
|
595
|
+
y: tile.y
|
|
596
|
+
};
|
|
597
|
+
const cleanup = () => {
|
|
598
|
+
if (keepIntermediates) return;
|
|
599
|
+
if (tileIntermediate.compactHeightfield) {
|
|
600
|
+
freeCompactHeightfield(tileIntermediate.compactHeightfield);
|
|
601
|
+
tileIntermediate.compactHeightfield = void 0;
|
|
602
|
+
}
|
|
603
|
+
if (tileIntermediate.heightfield) {
|
|
604
|
+
freeHeightfield(tileIntermediate.heightfield);
|
|
605
|
+
tileIntermediate.heightfield = void 0;
|
|
606
|
+
}
|
|
607
|
+
if (tileIntermediate.contourSet) {
|
|
608
|
+
freeContourSet(tileIntermediate.contourSet);
|
|
609
|
+
tileIntermediate.contourSet = void 0;
|
|
610
|
+
}
|
|
611
|
+
if (tileIntermediate.polyMesh) {
|
|
612
|
+
freePolyMesh(tileIntermediate.polyMesh);
|
|
613
|
+
tileIntermediate.polyMesh = void 0;
|
|
614
|
+
}
|
|
615
|
+
if (tileIntermediate.polyMeshDetail) {
|
|
616
|
+
freePolyMeshDetail(tileIntermediate.polyMeshDetail);
|
|
617
|
+
tileIntermediate.polyMeshDetail = void 0;
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
const failTileMesh = (error) => {
|
|
621
|
+
buildContext.log(Recast.RC_LOG_ERROR, error);
|
|
622
|
+
cleanup();
|
|
623
|
+
return {
|
|
624
|
+
success: false,
|
|
625
|
+
error,
|
|
626
|
+
intermediates: tileIntermediate
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
const tileConfig = cloneRcConfig(rcConfig);
|
|
630
|
+
const expandedTileBoundsMin = [...tile.bmin];
|
|
631
|
+
const expandedTileBoundsMax = [...tile.bmax];
|
|
632
|
+
expandedTileBoundsMin[0] -= tileConfig.borderSize * tileConfig.cs;
|
|
633
|
+
expandedTileBoundsMin[2] -= tileConfig.borderSize * tileConfig.cs;
|
|
634
|
+
expandedTileBoundsMax[0] += tileConfig.borderSize * tileConfig.cs;
|
|
635
|
+
expandedTileBoundsMax[2] += tileConfig.borderSize * tileConfig.cs;
|
|
636
|
+
tileConfig.set_bmin(0, expandedTileBoundsMin[0]);
|
|
637
|
+
tileConfig.set_bmin(1, expandedTileBoundsMin[1]);
|
|
638
|
+
tileConfig.set_bmin(2, expandedTileBoundsMin[2]);
|
|
639
|
+
tileConfig.set_bmax(0, expandedTileBoundsMax[0]);
|
|
640
|
+
tileConfig.set_bmax(1, expandedTileBoundsMax[1]);
|
|
641
|
+
tileConfig.set_bmax(2, expandedTileBoundsMax[2]);
|
|
642
|
+
buildContext.resetTimers();
|
|
643
|
+
buildContext.startTimer(Recast.RC_TIMER_TOTAL);
|
|
644
|
+
buildContext.log(Recast.RC_LOG_PROGRESS, `Building tile at x: ${tile.x}, y: ${tile.y}`);
|
|
645
|
+
buildContext.log(Recast.RC_LOG_PROGRESS, ` - ${tileConfig.width} x ${tileConfig.height} cells`);
|
|
646
|
+
buildContext.log(Recast.RC_LOG_PROGRESS, ` - ${positions.size / 3 / 1e3}K verts, ${indices.size / 3 / 1e3}K tris`);
|
|
647
|
+
const heightfield = allocHeightfield();
|
|
648
|
+
tileIntermediate.heightfield = heightfield;
|
|
649
|
+
if (!createHeightfield(buildContext, heightfield, tileConfig.width, tileConfig.height, expandedTileBoundsMin, expandedTileBoundsMax, tileConfig.cs, tileConfig.ch)) {
|
|
650
|
+
return failTileMesh("Could not create heightfield");
|
|
651
|
+
}
|
|
652
|
+
const triAreas = new TriangleAreasArray();
|
|
653
|
+
triAreas.resize(chunkyTriMesh.maxTrisPerChunk());
|
|
654
|
+
const tbmin = [expandedTileBoundsMin[0], expandedTileBoundsMin[2]];
|
|
655
|
+
const tbmax = [expandedTileBoundsMax[0], expandedTileBoundsMax[2]];
|
|
656
|
+
const maxChunkIds = 512;
|
|
657
|
+
const chunkIdsArray = new ChunkIdsArray();
|
|
658
|
+
chunkIdsArray.resize(maxChunkIds);
|
|
659
|
+
const nChunksOverlapping = chunkyTriMesh.getChunksOverlappingRect(tbmin, tbmax, chunkIdsArray, maxChunkIds);
|
|
660
|
+
if (nChunksOverlapping === 0) {
|
|
661
|
+
return {
|
|
662
|
+
success: true,
|
|
663
|
+
intermediates: tileIntermediate
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
for (let i = 0; i < nChunksOverlapping; ++i) {
|
|
667
|
+
const nodeId = chunkIdsArray.get(i);
|
|
668
|
+
const node = chunkyTriMesh.nodes(nodeId);
|
|
669
|
+
const nNodeTris = node.n;
|
|
670
|
+
const nodeTrianglesArray = chunkyTriMesh.getNodeTris(nodeId);
|
|
671
|
+
const triangleAreasArray = new TriangleAreasArray();
|
|
672
|
+
triangleAreasArray.resize(nNodeTris);
|
|
673
|
+
markWalkableTriangles(buildContext, tileConfig.walkableSlopeAngle, positions, indices.size, nodeTrianglesArray, nNodeTris, triangleAreasArray);
|
|
674
|
+
const success = rasterizeTriangles(buildContext, positions, indices.size, nodeTrianglesArray, triangleAreasArray, nNodeTris, heightfield, tileConfig.walkableClimb);
|
|
675
|
+
triangleAreasArray.destroy();
|
|
676
|
+
if (!success) {
|
|
677
|
+
return failTileMesh("Could not rasterize triangles");
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
filterLowHangingWalkableObstacles(buildContext, tileConfig.walkableClimb, heightfield);
|
|
681
|
+
filterLedgeSpans(buildContext, tileConfig.walkableHeight, tileConfig.walkableClimb, heightfield);
|
|
682
|
+
filterWalkableLowHeightSpans(buildContext, tileConfig.walkableHeight, heightfield);
|
|
683
|
+
const compactHeightfield = allocCompactHeightfield();
|
|
684
|
+
tileIntermediate.compactHeightfield = compactHeightfield;
|
|
685
|
+
if (!buildCompactHeightfield(buildContext, tileConfig.walkableHeight, tileConfig.walkableClimb, heightfield, compactHeightfield)) {
|
|
686
|
+
return failTileMesh("Could not build compact heightfield");
|
|
687
|
+
}
|
|
688
|
+
if (!keepIntermediates) {
|
|
689
|
+
freeHeightfield(tileIntermediate.heightfield);
|
|
690
|
+
tileIntermediate.heightfield = void 0;
|
|
691
|
+
}
|
|
692
|
+
if (!erodeWalkableArea(buildContext, tileConfig.walkableRadius, compactHeightfield)) {
|
|
693
|
+
return failTileMesh("Could not erode walkable area");
|
|
694
|
+
}
|
|
695
|
+
if (!buildDistanceField(buildContext, compactHeightfield)) {
|
|
696
|
+
return failTileMesh("Failed to build distance field");
|
|
697
|
+
}
|
|
698
|
+
if (!buildRegions(buildContext, compactHeightfield, tileConfig.borderSize, tileConfig.minRegionArea, tileConfig.mergeRegionArea)) {
|
|
699
|
+
return failTileMesh("Failed to build regions");
|
|
700
|
+
}
|
|
701
|
+
const contourSet = allocContourSet();
|
|
702
|
+
tileIntermediate.contourSet = contourSet;
|
|
703
|
+
if (!buildContours(buildContext, compactHeightfield, tileConfig.maxSimplificationError, tileConfig.maxEdgeLen, contourSet, Recast.RC_CONTOUR_TESS_WALL_EDGES)) {
|
|
704
|
+
return failTileMesh("Failed to create contours");
|
|
705
|
+
}
|
|
706
|
+
const polyMesh = allocPolyMesh();
|
|
707
|
+
tileIntermediate.polyMesh = polyMesh;
|
|
708
|
+
if (!buildPolyMesh(buildContext, contourSet, tileConfig.maxVertsPerPoly, polyMesh)) {
|
|
709
|
+
return failTileMesh("Failed to triangulate contours");
|
|
710
|
+
}
|
|
711
|
+
const polyMeshDetail = allocPolyMeshDetail();
|
|
712
|
+
tileIntermediate.polyMeshDetail = polyMeshDetail;
|
|
713
|
+
if (!buildPolyMeshDetail(buildContext, polyMesh, compactHeightfield, tileConfig.detailSampleDist, tileConfig.detailSampleMaxError, polyMeshDetail)) {
|
|
714
|
+
return failTileMesh("Failed to build detail mesh");
|
|
715
|
+
}
|
|
716
|
+
if (!keepIntermediates) {
|
|
717
|
+
freeCompactHeightfield(compactHeightfield);
|
|
718
|
+
tileIntermediate.compactHeightfield = void 0;
|
|
719
|
+
freeContourSet(contourSet);
|
|
720
|
+
tileIntermediate.contourSet = void 0;
|
|
721
|
+
}
|
|
722
|
+
for (let i = 0; i < polyMesh.npolys(); i++) {
|
|
723
|
+
if (polyMesh.areas(i) === Recast.RC_WALKABLE_AREA) {
|
|
724
|
+
polyMesh.setAreas(i, 0);
|
|
725
|
+
}
|
|
726
|
+
if (polyMesh.areas(i) === 0) {
|
|
727
|
+
polyMesh.setFlags(i, 1);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const navMeshCreateParams = new NavMeshCreateParams();
|
|
731
|
+
navMeshCreateParams.setPolyMeshCreateParams(polyMesh);
|
|
732
|
+
navMeshCreateParams.setPolyMeshDetailCreateParams(polyMeshDetail);
|
|
733
|
+
navMeshCreateParams.setWalkableHeight(tileConfig.walkableHeight * tileConfig.ch);
|
|
734
|
+
navMeshCreateParams.setWalkableRadius(tileConfig.walkableRadius * tileConfig.cs);
|
|
735
|
+
navMeshCreateParams.setWalkableClimb(tileConfig.walkableClimb * tileConfig.ch);
|
|
736
|
+
navMeshCreateParams.setCellSize(tileConfig.cs);
|
|
737
|
+
navMeshCreateParams.setCellHeight(tileConfig.ch);
|
|
738
|
+
navMeshCreateParams.setBuildBvTree(options.buildBvTree ?? tiledNavMeshGeneratorConfigDefaults.buildBvTree);
|
|
739
|
+
if (options.offMeshConnections) {
|
|
740
|
+
navMeshCreateParams.setOffMeshConnections(options.offMeshConnections);
|
|
741
|
+
}
|
|
742
|
+
navMeshCreateParams.setTileX(tile.x);
|
|
743
|
+
navMeshCreateParams.setTileY(tile.y);
|
|
744
|
+
const createNavMeshDataResult = createNavMeshData(navMeshCreateParams);
|
|
745
|
+
if (!createNavMeshDataResult.success) {
|
|
746
|
+
return failTileMesh("Failed to create Detour navmesh data");
|
|
747
|
+
}
|
|
748
|
+
buildContext.log(Recast.RC_LOG_PROGRESS, `>> Polymesh: ${polyMesh.nverts()} vertices ${polyMesh.npolys()} polygons`);
|
|
749
|
+
return {
|
|
750
|
+
success: true,
|
|
751
|
+
data: createNavMeshDataResult.navMeshData,
|
|
752
|
+
intermediates: tileIntermediate
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
const generateTiledNavMesh = (positions, indices, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
|
|
756
|
+
if (!Raw.Module) {
|
|
757
|
+
throw new Error('"init" must be called before using any recast-navigation-js APIs. See: https://github.com/isaac-mason/recast-navigation-js?tab=readme-ov-file#initialization');
|
|
758
|
+
}
|
|
759
|
+
const buildContext = new RecastBuildContext();
|
|
760
|
+
const intermediates = {
|
|
761
|
+
type: "tiled",
|
|
762
|
+
buildContext,
|
|
763
|
+
chunkyTriMesh: void 0,
|
|
764
|
+
tileIntermediates: []
|
|
765
|
+
};
|
|
766
|
+
const navMesh = new NavMesh();
|
|
767
|
+
const vertices = positions;
|
|
768
|
+
const verticesArray = new VerticesArray();
|
|
769
|
+
verticesArray.copy(vertices);
|
|
770
|
+
const triangles = indices;
|
|
771
|
+
const numTriangles = indices.length / 3;
|
|
772
|
+
const trianglesArray = new TrianglesArray();
|
|
773
|
+
trianglesArray.copy(triangles);
|
|
774
|
+
const cleanup = () => {
|
|
775
|
+
verticesArray.destroy();
|
|
776
|
+
trianglesArray.destroy();
|
|
777
|
+
if (keepIntermediates) return;
|
|
778
|
+
if (intermediates.chunkyTriMesh) {
|
|
779
|
+
intermediates.chunkyTriMesh = void 0;
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
const fail = (error) => {
|
|
783
|
+
cleanup();
|
|
784
|
+
navMesh.destroy();
|
|
785
|
+
return {
|
|
786
|
+
success: false,
|
|
787
|
+
navMesh: void 0,
|
|
788
|
+
intermediates,
|
|
789
|
+
error
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
const generatorConfig = {
|
|
793
|
+
...tiledNavMeshGeneratorConfigDefaults,
|
|
794
|
+
...navMeshGeneratorConfig
|
|
795
|
+
};
|
|
796
|
+
let bbMin;
|
|
797
|
+
let bbMax;
|
|
798
|
+
if (navMeshGeneratorConfig.bounds) {
|
|
799
|
+
bbMin = navMeshGeneratorConfig.bounds[0];
|
|
800
|
+
bbMax = navMeshGeneratorConfig.bounds[1];
|
|
801
|
+
} else {
|
|
802
|
+
const boundingBox = getBoundingBox(positions, indices);
|
|
803
|
+
bbMin = boundingBox.bbMin;
|
|
804
|
+
bbMax = boundingBox.bbMax;
|
|
805
|
+
}
|
|
806
|
+
const {
|
|
807
|
+
config: rcConfig,
|
|
808
|
+
tileWidth,
|
|
809
|
+
tileHeight,
|
|
810
|
+
tcs,
|
|
811
|
+
orig,
|
|
812
|
+
maxTiles,
|
|
813
|
+
maxPolysPerTile
|
|
814
|
+
} = buildTiledNavMeshRcConfig({
|
|
815
|
+
recastConfig: generatorConfig,
|
|
816
|
+
navMeshBounds: [bbMin, bbMax]
|
|
817
|
+
});
|
|
818
|
+
const navMeshParams = NavMeshParams.create({
|
|
819
|
+
orig,
|
|
820
|
+
tileWidth: generatorConfig.tileSize * generatorConfig.cs,
|
|
821
|
+
tileHeight: generatorConfig.tileSize * generatorConfig.cs,
|
|
822
|
+
maxTiles,
|
|
823
|
+
maxPolys: maxPolysPerTile
|
|
824
|
+
});
|
|
825
|
+
if (!navMesh.initTiled(navMeshParams)) {
|
|
826
|
+
return fail("Could not init nav mesh for tiled use");
|
|
827
|
+
}
|
|
828
|
+
const chunkyTriMesh = new RecastChunkyTriMesh();
|
|
829
|
+
intermediates.chunkyTriMesh = chunkyTriMesh;
|
|
830
|
+
if (!chunkyTriMesh.init(verticesArray, trianglesArray, numTriangles, generatorConfig.chunkyTriMeshTrisPerChunk)) {
|
|
831
|
+
return fail("Failed to build chunky triangle mesh");
|
|
832
|
+
}
|
|
833
|
+
buildContext.startTimer(Recast.RC_TIMER_TEMP);
|
|
834
|
+
const lastBuiltTileBmin = [0, 0, 0];
|
|
835
|
+
const lastBuiltTileBmax = [0, 0, 0];
|
|
836
|
+
for (let y = 0; y < tileHeight; y++) {
|
|
837
|
+
for (let x = 0; x < tileWidth; x++) {
|
|
838
|
+
lastBuiltTileBmin[0] = bbMin[0] + x * tcs;
|
|
839
|
+
lastBuiltTileBmin[1] = bbMin[1];
|
|
840
|
+
lastBuiltTileBmin[2] = bbMin[2] + y * tcs;
|
|
841
|
+
lastBuiltTileBmax[0] = bbMin[0] + (x + 1) * tcs;
|
|
842
|
+
lastBuiltTileBmax[1] = bbMax[1];
|
|
843
|
+
lastBuiltTileBmax[2] = bbMin[2] + (y + 1) * tcs;
|
|
844
|
+
const tile = {
|
|
845
|
+
x,
|
|
846
|
+
y,
|
|
847
|
+
bmin: lastBuiltTileBmin,
|
|
848
|
+
bmax: lastBuiltTileBmax
|
|
849
|
+
};
|
|
850
|
+
const generatorOptions = {
|
|
851
|
+
offMeshConnections: generatorConfig.offMeshConnections,
|
|
852
|
+
buildBvTree: generatorConfig.buildBvTree
|
|
853
|
+
};
|
|
854
|
+
const result = generateTileNavMeshData(verticesArray, trianglesArray, rcConfig, chunkyTriMesh, tile, generatorOptions, keepIntermediates, buildContext);
|
|
855
|
+
intermediates.tileIntermediates.push(result.intermediates);
|
|
856
|
+
if (result.success && result.data) {
|
|
857
|
+
navMesh.removeTile(navMesh.getTileRefAt(x, y, 0));
|
|
858
|
+
const addTileResult = navMesh.addTile(result.data, Detour.DT_TILE_FREE_DATA, 0);
|
|
859
|
+
if (statusFailed(addTileResult.status)) {
|
|
860
|
+
buildContext.log(Recast.RC_LOG_WARNING, `Failed to add tile to nav mesh tx: ${x}, ty: ${y}, status: ${statusToReadableString(addTileResult.status)} (${addTileResult.status})`);
|
|
861
|
+
result.data.destroy();
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
buildContext.stopTimer(Recast.RC_TIMER_TEMP);
|
|
867
|
+
if (!keepIntermediates) {
|
|
868
|
+
cleanup();
|
|
869
|
+
}
|
|
870
|
+
return {
|
|
871
|
+
success: true,
|
|
872
|
+
navMesh,
|
|
873
|
+
intermediates
|
|
874
|
+
};
|
|
875
|
+
};
|
|
876
|
+
const mergePositionsAndIndices = (meshes) => {
|
|
877
|
+
const mergedPositions = [];
|
|
878
|
+
const mergedIndices = [];
|
|
879
|
+
const positionToIndex = {};
|
|
880
|
+
let indexCounter = 0;
|
|
881
|
+
for (const {
|
|
882
|
+
positions,
|
|
883
|
+
indices
|
|
884
|
+
} of meshes) {
|
|
885
|
+
for (let i = 0; i < indices.length; i++) {
|
|
886
|
+
const pt = indices[i] * 3;
|
|
887
|
+
const x = positions[pt];
|
|
888
|
+
const y = positions[pt + 1];
|
|
889
|
+
const z = positions[pt + 2];
|
|
890
|
+
const key = `${x}_${y}_${z}`;
|
|
891
|
+
let idx = positionToIndex[key];
|
|
892
|
+
if (!idx) {
|
|
893
|
+
positionToIndex[key] = idx = indexCounter;
|
|
894
|
+
mergedPositions.push(x, y, z);
|
|
895
|
+
indexCounter++;
|
|
896
|
+
}
|
|
897
|
+
mergedIndices.push(idx);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return [Float32Array.from(mergedPositions), Uint32Array.from(mergedIndices)];
|
|
901
|
+
};
|
|
902
|
+
export {
|
|
903
|
+
buildTiledNavMeshRcConfig,
|
|
904
|
+
createDefaultTileCacheMeshProcess,
|
|
905
|
+
dtIlog2,
|
|
906
|
+
dtNextPow2,
|
|
907
|
+
generateSoloNavMesh,
|
|
908
|
+
generateSoloNavMeshData,
|
|
909
|
+
generateTileCache,
|
|
910
|
+
generateTileNavMeshData,
|
|
911
|
+
generateTiledNavMesh,
|
|
912
|
+
getBoundingBox,
|
|
913
|
+
mergePositionsAndIndices,
|
|
914
|
+
soloNavMeshGeneratorConfigDefaults,
|
|
915
|
+
tileCacheGeneratorConfigDefaults,
|
|
916
|
+
tiledNavMeshGeneratorConfigDefaults
|
|
917
|
+
};
|
|
918
|
+
//# sourceMappingURL=index-CYZDclhF.js.map
|