@babylonjs/lite 0.1.1 → 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-CjDoht2w.js +11 -0
- package/_mat4-storage-f64-CjDoht2w.js.map +1 -0
- package/{alpha-test-fragment-CUiHCw7W.js → alpha-test-fragment-B7DjSnF7.js} +2 -2
- package/{alpha-test-fragment-CUiHCw7W.js.map → alpha-test-fragment-B7DjSnF7.js.map} +1 -1
- package/assets/splat-sort-worker-DT3eybMZ.js.map +1 -0
- package/{background-dds-skybox-yHTqabU3.js → background-dds-skybox-BEX309u3.js} +14 -14
- package/background-dds-skybox-BEX309u3.js.map +1 -0
- package/{background-ground-DIw6D3qf.js → background-ground-BU0HOcM4.js} +20 -20
- package/background-ground-BU0HOcM4.js.map +1 -0
- package/{background-hdr-skybox-c4uuTmkP.js → background-hdr-skybox--RRRic_K.js} +10 -10
- package/background-hdr-skybox--RRRic_K.js.map +1 -0
- package/{background-solid-skybox-DPGBpPbm.js → background-solid-skybox-BrH2fXSu.js} +12 -13
- package/background-solid-skybox-BrH2fXSu.js.map +1 -0
- package/{billboard-renderable-D8mlVGCd.js → billboard-renderable-BHWryAeC.js} +46 -10
- package/billboard-renderable-BHWryAeC.js.map +1 -0
- package/{clamp-block-BdII67hT.js → clamp-block-DqbwnQGW.js} +2 -2
- package/{clamp-block-BdII67hT.js.map → clamp-block-DqbwnQGW.js.map} +1 -1
- package/{clearcoat-fragment-LCiG98Rf.js → clearcoat-fragment-D6FSCie1.js} +2 -2
- package/{clearcoat-fragment-LCiG98Rf.js.map → clearcoat-fragment-D6FSCie1.js.map} +1 -1
- package/{create-skeleton-C9JdIJnb.js → create-skeleton-D_uplboC.js} +9 -9
- package/create-skeleton-D_uplboC.js.map +1 -0
- package/{cubemap-skybox-material-DvXMVc4k.js → cubemap-skybox-material-DQcMMdf-.js} +6 -7
- package/cubemap-skybox-material-DQcMMdf-.js.map +1 -0
- package/{curve-block-BlJpXVYv.js → curve-block-21rT0JjG.js} +2 -2
- package/{curve-block-BlJpXVYv.js.map → curve-block-21rT0JjG.js.map} +1 -1
- package/{emissive-fragment-BnNvbBCw.js → emissive-fragment-C5FtBs3y.js} +3 -3
- package/emissive-fragment-C5FtBs3y.js.map +1 -0
- package/{esm-shadow-view-DN9HIaM4.js → esm-shadow-view-Cl3rPGof.js} +2 -2
- package/{esm-shadow-view-DN9HIaM4.js.map → esm-shadow-view-Cl3rPGof.js.map} +1 -1
- package/{esm-shadow-view-Dk9NFtLq.js → esm-shadow-view-Gtd1LWRP.js} +2 -2
- package/{esm-shadow-view-Dk9NFtLq.js.map → esm-shadow-view-Gtd1LWRP.js.map} +1 -1
- package/{esm-shadow-view-DGKdF1NI.js → esm-shadow-view-c5YV4Eg9.js} +2 -2
- package/{esm-shadow-view-DGKdF1NI.js.map → esm-shadow-view-c5YV4Eg9.js.map} +1 -1
- package/{gaussian-splatting-pipeline-sh-DgJl7l56.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-D7uyTyO3.js → gltf-animation-K_zZxj_d.js} +7 -7
- package/gltf-animation-K_zZxj_d.js.map +1 -0
- 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-CDbPclzZ.js} +53 -18
- package/gltf-ext-basisu-CDbPclzZ.js.map +1 -0
- package/{gltf-ext-node-visibility-MafA9ot2.js → gltf-ext-node-visibility-DXCJEYr6.js} +2 -2
- package/{gltf-ext-node-visibility-MafA9ot2.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-CE_-T1Tr.js → gltf-ext-uv-transform-DgYazJBs.js} +2 -2
- package/{gltf-ext-uv-transform-CE_-T1Tr.js.map → gltf-ext-uv-transform-DgYazJBs.js.map} +1 -1
- package/{gltf-feature-animation-pointer-BjpwOOqo.js → gltf-feature-animation-pointer-D1RJRFBw.js} +9 -9
- package/gltf-feature-animation-pointer-D1RJRFBw.js.map +1 -0
- package/{gltf-feature-animations-CCizegp8.js → gltf-feature-animations-Cmc1uoIu.js} +2 -2
- package/{gltf-feature-animations-CCizegp8.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-2e_CFQnl.js → gltf-feature-gpu-instancing-n87SO6Vh.js} +7 -6
- package/gltf-feature-gpu-instancing-n87SO6Vh.js.map +1 -0
- package/{gltf-feature-lights-punctual-DDDg4j0U.js → gltf-feature-lights-punctual-Ckm3ciL8.js} +5 -5
- package/{gltf-feature-lights-punctual-DDDg4j0U.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-CKCw6tkX.js → gltf-feature-morph-Cjtu7hYa.js} +4 -4
- package/gltf-feature-morph-Cjtu7hYa.js.map +1 -0
- package/gltf-feature-registry-C63Hjp9w.js +59 -0
- package/gltf-feature-registry-C63Hjp9w.js.map +1 -0
- package/{gltf-feature-skeleton-D8hWLqi2.js → gltf-feature-skeleton-DKbOGidp.js} +3 -3
- package/{gltf-feature-skeleton-D8hWLqi2.js.map → gltf-feature-skeleton-DKbOGidp.js.map} +1 -1
- package/{gltf-feature-variants-Ds6v9byg.js → gltf-feature-variants-Cmzu0O0e.js} +2 -2
- package/{gltf-feature-variants-Ds6v9byg.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-DGnUlz28.js → gltf-interleave-gHf9_t0i.js} +14 -14
- package/gltf-interleave-gHf9_t0i.js.map +1 -0
- 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-edNcjwPf.js} +5 -5
- package/gltf-pbr-builder-ext-edNcjwPf.js.map +1 -0
- package/{gltf-variants-DFbr8EES.js → gltf-variants-CPxNdtP4.js} +4 -4
- package/{gltf-variants-DFbr8EES.js.map → gltf-variants-CPxNdtP4.js.map} +1 -1
- package/{gs-picking-pipeline-DzfMASL9.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 +2508 -119
- package/index.js +444 -302
- package/{input-block-DgAJBzN_.js → input-block-DqEedWF2.js} +2 -2
- package/{input-block-DgAJBzN_.js.map → input-block-DqEedWF2.js.map} +1 -1
- package/{iridescence-fragment-Gymp7or5.js → iridescence-fragment-BHU59-gQ.js} +2 -2
- package/{iridescence-fragment-Gymp7or5.js.map → iridescence-fragment-BHU59-gQ.js.map} +1 -1
- package/{light-block-B11ew7FA.js → light-block-Bv37V8vl.js} +2 -2
- package/{light-block-B11ew7FA.js.map → light-block-Bv37V8vl.js.map} +1 -1
- package/{loop-block-Bb23EOMb.js → loop-block-qTg8vb99.js} +2 -2
- package/{loop-block-Bb23EOMb.js.map → loop-block-qTg8vb99.js.map} +1 -1
- package/{morph-fragment-DOVo70gP.js → morph-fragment-BRCUr2wQ.js} +2 -2
- package/{morph-fragment-DOVo70gP.js.map → morph-fragment-BRCUr2wQ.js.map} +1 -1
- package/{multilight-wgsl-BGyiIOp3.js → multilight-wgsl-DMeppAdZ.js} +4 -4
- package/{multilight-wgsl-BGyiIOp3.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-Dhrw8fDQ.js → node-registry-extra-compat-dWrv7gpS.js} +2 -2
- package/{node-registry-extra-compat-Dhrw8fDQ.js.map → node-registry-extra-compat-dWrv7gpS.js.map} +1 -1
- package/{node-registry-extra-math-CsAHvIZo.js → node-registry-extra-math-Bn854sX9.js} +2 -2
- package/{node-registry-extra-math-CsAHvIZo.js.map → node-registry-extra-math-Bn854sX9.js.map} +1 -1
- package/{node-renderable-DlLIdBmd.js → node-renderable-B5G8WcdH.js} +41 -22
- package/node-renderable-B5G8WcdH.js.map +1 -0
- package/{node-shadow-DKrcqmNg.js → node-shadow-CVIUlNf0.js} +7 -7
- package/node-shadow-CVIUlNf0.js.map +1 -0
- package/{normal-map-fragment-DpsIXrJf.js → normal-map-fragment-CQSxhjCy.js} +3 -3
- package/{normal-map-fragment-DpsIXrJf.js.map → normal-map-fragment-CQSxhjCy.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 -10
- package/{parse-camera-DM3oJJeT.js → parse-camera-pBRT_6i5.js} +2 -2
- package/{parse-camera-DM3oJJeT.js.map → parse-camera-pBRT_6i5.js.map} +1 -1
- package/pbr-fog-wgsl-BqdCid6r.js +8 -0
- package/pbr-fog-wgsl-BqdCid6r.js.map +1 -0
- package/pbr-geometry-view-NiZY_juX.js +491 -0
- package/pbr-geometry-view-NiZY_juX.js.map +1 -0
- package/{pbr-metallic-roughness-block-h_KAOZrW.js → pbr-metallic-roughness-block-JBSi-tQN.js} +2 -2
- package/{pbr-metallic-roughness-block-h_KAOZrW.js.map → pbr-metallic-roughness-block-JBSi-tQN.js.map} +1 -1
- package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js → pbr-metallic-roughness-block-full-Ta9lR2cz.js} +2 -2
- package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js.map → pbr-metallic-roughness-block-full-Ta9lR2cz.js.map} +1 -1
- package/{pbr-mr-helper-core-CIwm-T1G.js → pbr-mr-helper-core-BVWNR08D.js} +2 -2
- package/{pbr-mr-helper-core-CIwm-T1G.js.map → pbr-mr-helper-core-BVWNR08D.js.map} +1 -1
- package/{pbr-refraction-DGmMSa2v.js → pbr-refraction-C9FvFmAp.js} +2 -2
- package/{pbr-refraction-DGmMSa2v.js.map → pbr-refraction-C9FvFmAp.js.map} +1 -1
- package/{pbr-renderable-BJxUtPBb.js → pbr-renderable-DzUF2QIk.js} +118 -58
- package/pbr-renderable-DzUF2QIk.js.map +1 -0
- package/{pbr-shadow-fragment-LO9SlbJj.js → pbr-shadow-fragment-CnqnbGYS.js} +6 -1
- package/pbr-shadow-fragment-CnqnbGYS.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-3tU1kqea.js} +2 -2
- package/{pbr-tracking-B3alzn91.js.map → pbr-tracking-3tU1kqea.js.map} +1 -1
- package/pbr-transmission-ext-BcLjRxfB.js +190 -0
- package/pbr-transmission-ext-BcLjRxfB.js.map +1 -0
- 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-BCrgPmrt.js → reflectance-fragment-Dbpgw3Jt.js} +2 -2
- package/{reflectance-fragment-BCrgPmrt.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-BLENkYVt.js → shader-composer-BUD_pSX4.js} +7 -55
- package/shader-composer-BUD_pSX4.js.map +1 -0
- package/{shader-renderable-D-6796KR.js → shader-renderable-D7-RyVxa.js} +62 -27
- package/shader-renderable-D7-RyVxa.js.map +1 -0
- package/shader-thin-instance-DuBotxDO.js +150 -0
- package/shader-thin-instance-DuBotxDO.js.map +1 -0
- package/shadow-fragment-core-DHN2G6FI.js.map +1 -1
- package/{sheen-fragment-Dze2f7XJ.js → sheen-fragment-1MkEMcbc.js} +2 -2
- package/{sheen-fragment-Dze2f7XJ.js.map → sheen-fragment-1MkEMcbc.js.map} +1 -1
- package/{singlelight-directional-wgsl-CmUDZxwz.js → singlelight-directional-wgsl-BsV8G456.js} +2 -2
- package/{singlelight-directional-wgsl-CmUDZxwz.js.map → singlelight-directional-wgsl-BsV8G456.js.map} +1 -1
- package/{singlelight-hemispheric-wgsl-t-83IP_s.js → singlelight-hemispheric-wgsl-Bo0jKlW5.js} +2 -2
- package/{singlelight-hemispheric-wgsl-t-83IP_s.js.map → singlelight-hemispheric-wgsl-Bo0jKlW5.js.map} +1 -1
- package/{singlelight-point-wgsl-CLzULIYV.js → singlelight-point-wgsl-DV39UP5Y.js} +2 -2
- package/{singlelight-point-wgsl-CLzULIYV.js.map → singlelight-point-wgsl-DV39UP5Y.js.map} +1 -1
- package/{singlelight-spot-wgsl-DEEUrfVM.js → singlelight-spot-wgsl-yg3od6vL.js} +2 -2
- package/{singlelight-spot-wgsl-DEEUrfVM.js.map → singlelight-spot-wgsl-yg3od6vL.js.map} +1 -1
- package/{skeleton-fragment-B_XlFbtx.js → skeleton-fragment-DdxYG6kv.js} +2 -2
- package/{skeleton-fragment-B_XlFbtx.js.map → skeleton-fragment-DdxYG6kv.js.map} +1 -1
- package/{skybox-renderable-DDwzu-PT.js → skybox-renderable-CJD4XmX5.js} +8 -9
- 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-GjxL9xSf.js → standard-pipeline-XTbHL7MY.js} +12 -257
- 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-BoUsD06w.js → std-ambient-fragment-Bjx3VFrr.js} +2 -2
- package/{std-ambient-fragment-BoUsD06w.js.map → std-ambient-fragment-Bjx3VFrr.js.map} +1 -1
- package/{std-cube-reflection-fragment-ulqc3bsP.js → std-cube-reflection-fragment-y9WWdXUt.js} +2 -2
- package/{std-cube-reflection-fragment-ulqc3bsP.js.map → std-cube-reflection-fragment-y9WWdXUt.js.map} +1 -1
- package/{std-emissive-fragment-DNGj1HdQ.js → std-emissive-fragment-C8Lnmojh.js} +2 -2
- package/{std-emissive-fragment-DNGj1HdQ.js.map → std-emissive-fragment-C8Lnmojh.js.map} +1 -1
- package/{std-lightmap-fragment-Bqj89aIe.js → std-lightmap-fragment-DFxGcoA5.js} +2 -2
- package/{std-lightmap-fragment-Bqj89aIe.js.map → std-lightmap-fragment-DFxGcoA5.js.map} +1 -1
- package/{std-opacity-fragment-KuPh5N2Z.js → std-opacity-fragment-EXzFWiSp.js} +2 -2
- package/{std-opacity-fragment-KuPh5N2Z.js.map → std-opacity-fragment-EXzFWiSp.js.map} +1 -1
- package/{std-reflection-fragment-BA5Ghn_M.js → std-reflection-fragment-BoJORqpG.js} +2 -2
- package/{std-reflection-fragment-BA5Ghn_M.js.map → std-reflection-fragment-BoJORqpG.js.map} +1 -1
- package/std-shadow-fragment-Bq-Wc8UJ.js +13 -0
- package/std-shadow-fragment-Bq-Wc8UJ.js.map +1 -0
- package/{std-specular-fragment-CE-6scqd.js → std-specular-fragment-CM5R5j2g.js} +2 -2
- package/{std-specular-fragment-CE-6scqd.js.map → std-specular-fragment-CM5R5j2g.js.map} +1 -1
- package/{std-tracking-CNKZ-hJN.js → std-tracking-Cif_wXeT.js} +2 -2
- package/{std-tracking-CNKZ-hJN.js.map → std-tracking-Cif_wXeT.js.map} +1 -1
- package/{subsurface-fragment-liM3y2-P.js → subsurface-fragment-BEaAXYXz.js} +2 -2
- package/{subsurface-fragment-liM3y2-P.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-DWKUt5ZN.js +310 -0
- package/thin-instance-cull-binding-DWKUt5ZN.js.map +1 -0
- package/{thin-instance-gpu-C9Gv_Z1w.js → thin-instance-gpu-BDdRcNAh.js} +30 -5
- package/thin-instance-gpu-BDdRcNAh.js.map +1 -0
- package/{tracking-primitives-wgdBY85t.js → tracking-primitives-CglRNTlX.js} +2 -2
- package/{tracking-primitives-wgdBY85t.js.map → tracking-primitives-CglRNTlX.js.map} +1 -1
- package/{unlit-fragment-BIlhJpz6.js → unlit-fragment-kxfZWlnp.js} +2 -2
- package/{unlit-fragment-BIlhJpz6.js.map → unlit-fragment-kxfZWlnp.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/assets/splat-sort-worker-Crg3CaCc.js.map +0 -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/background-solid-skybox-DPGBpPbm.js.map +0 -1
- package/billboard-renderable-D8mlVGCd.js.map +0 -1
- package/create-skeleton-C9JdIJnb.js.map +0 -1
- package/cubemap-skybox-material-DvXMVc4k.js.map +0 -1
- package/emissive-fragment-BnNvbBCw.js.map +0 -1
- package/gaussian-splatting-pipeline-sh-DgJl7l56.js.map +0 -1
- package/gltf-animation-D7uyTyO3.js.map +0 -1
- package/gltf-ext-basisu-CPg5kPrx.js.map +0 -1
- package/gltf-ext-quantization-CpZyLDIz.js.map +0 -1
- package/gltf-feature-animation-pointer-BjpwOOqo.js.map +0 -1
- package/gltf-feature-draco-yGSMGTE3.js.map +0 -1
- package/gltf-feature-gpu-instancing-2e_CFQnl.js.map +0 -1
- package/gltf-feature-meshopt-Des96YFI.js.map +0 -1
- package/gltf-feature-morph-CKCw6tkX.js.map +0 -1
- package/gltf-glb-parser-D6UZWFuC.js.map +0 -1
- package/gltf-interleave-DGnUlz28.js.map +0 -1
- package/gltf-pbr-builder-ext-BFOxOCnQ.js.map +0 -1
- package/gs-picking-pipeline-DzfMASL9.js.map +0 -1
- package/index-C8HOR2sB.js +0 -19222
- package/index-C8HOR2sB.js.map +0 -1
- package/mesh-features-BLENkYVt.js.map +0 -1
- package/node-env-BPZXZzBf.js.map +0 -1
- package/node-registry-DwgC4yth.js +0 -190
- package/node-registry-DwgC4yth.js.map +0 -1
- package/node-renderable-DlLIdBmd.js.map +0 -1
- package/node-shadow-DKrcqmNg.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/rgbd-decode-DCvzUYeI.js.map +0 -1
- package/scene-material-swap-C2ykv55W.js.map +0 -1
- package/shader-renderable-D-6796KR.js.map +0 -1
- package/skybox-renderable-DDwzu-PT.js.map +0 -1
- package/splat-ply-compressed-BahdBG1r.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/swapchain-overlay-DcCSFDp7.js +0 -35
- package/swapchain-overlay-DcCSFDp7.js.map +0 -1
- package/thin-instance-gpu-C9Gv_Z1w.js.map +0 -1
|
@@ -0,0 +1,3330 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
const instances = ["Recast", "Detour", "DetourNavMeshBuilder", "DetourTileCacheBuilder", "NavMeshImporter", "NavMeshExporter", "CrowdUtils", "ChunkyTriMeshUtils", "RecastDebugDraw", "DetourDebugDraw"];
|
|
5
|
+
const classes = ["rcConfig", "rcContext", "dtNavMeshParams", "dtNavMeshCreateParams", "RecastLinearAllocator", "RecastFastLZCompressor", "rcChunkyTriMesh", "dtTileCacheParams", "dtTileCacheLayerHeader", "Vec3", "BoolRef", "IntRef", "UnsignedIntRef", "UnsignedCharRef", "UnsignedShortRef", "FloatRef", "IntArray", "UnsignedIntArray", "UnsignedCharArray", "UnsignedShortArray", "FloatArray"];
|
|
6
|
+
const Raw = {
|
|
7
|
+
isNull: (obj) => {
|
|
8
|
+
return Raw.Module.getPointer(obj) === 0;
|
|
9
|
+
},
|
|
10
|
+
destroy: (obj) => {
|
|
11
|
+
Raw.Module.destroy(obj);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const Recast = {};
|
|
15
|
+
const Detour = {};
|
|
16
|
+
const init = async (impl) => {
|
|
17
|
+
if (Raw.Module !== void 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (impl) {
|
|
21
|
+
Raw.Module = await impl();
|
|
22
|
+
} else {
|
|
23
|
+
const defaultExport = (await import("./recast-navigation.wasm-compat-C-Bf2ylB.js")).default;
|
|
24
|
+
Raw.Module = await defaultExport();
|
|
25
|
+
}
|
|
26
|
+
for (const instance of instances) {
|
|
27
|
+
Raw[instance] = new Raw.Module[instance]();
|
|
28
|
+
}
|
|
29
|
+
for (const clazz of classes) {
|
|
30
|
+
Raw[clazz] = Raw.Module[clazz];
|
|
31
|
+
}
|
|
32
|
+
Recast.RC_BORDER_REG = Raw.Recast.BORDER_REG;
|
|
33
|
+
Recast.RC_MULTIPLE_REGS = Raw.Recast.MULTIPLE_REGS;
|
|
34
|
+
Recast.RC_BORDER_VERTEX = Raw.Recast.BORDER_VERTEX;
|
|
35
|
+
Recast.RC_AREA_BORDER = Raw.Recast.AREA_BORDER;
|
|
36
|
+
Recast.RC_CONTOUR_REG_MASK = Raw.Recast.CONTOUR_REG_MASK;
|
|
37
|
+
Recast.RC_MESH_NULL_IDX = Raw.Recast.MESH_NULL_IDX;
|
|
38
|
+
Recast.RC_NULL_AREA = Raw.Recast.NULL_AREA;
|
|
39
|
+
Recast.RC_WALKABLE_AREA = Raw.Recast.WALKABLE_AREA;
|
|
40
|
+
Recast.RC_NOT_CONNECTED = Raw.Recast.NOT_CONNECTED;
|
|
41
|
+
Recast.RC_CONTOUR_TESS_WALL_EDGES = Raw.Module.RC_CONTOUR_TESS_WALL_EDGES;
|
|
42
|
+
Recast.RC_CONTOUR_TESS_AREA_EDGES = Raw.Module.RC_CONTOUR_TESS_AREA_EDGES;
|
|
43
|
+
Recast.RC_LOG_PROGRESS = Raw.Module.RC_LOG_PROGRESS;
|
|
44
|
+
Recast.RC_LOG_WARNING = Raw.Module.RC_LOG_WARNING;
|
|
45
|
+
Recast.RC_LOG_ERROR = Raw.Module.RC_LOG_ERROR;
|
|
46
|
+
Recast.RC_TIMER_TOTAL = Raw.Module.RC_TIMER_TOTAL;
|
|
47
|
+
Recast.RC_TIMER_TEMP = Raw.Module.RC_TIMER_TEMP;
|
|
48
|
+
Recast.RC_TIMER_RASTERIZE_TRIANGLES = Raw.Module.RC_TIMER_RASTERIZE_TRIANGLES;
|
|
49
|
+
Recast.RC_TIMER_BUILD_COMPACTHEIGHTFIELD = Raw.Module.RC_TIMER_BUILD_COMPACTHEIGHTFIELD;
|
|
50
|
+
Recast.RC_TIMER_BUILD_CONTOURS = Raw.Module.RC_TIMER_BUILD_CONTOURS;
|
|
51
|
+
Recast.RC_TIMER_BUILD_CONTOURS_TRACE = Raw.Module.RC_TIMER_BUILD_CONTOURS_TRACE;
|
|
52
|
+
Recast.RC_TIMER_BUILD_CONTOURS_SIMPLIFY = Raw.Module.RC_TIMER_BUILD_CONTOURS_SIMPLIFY;
|
|
53
|
+
Recast.RC_TIMER_FILTER_BORDER = Raw.Module.RC_TIMER_FILTER_BORDER;
|
|
54
|
+
Recast.RC_TIMER_FILTER_WALKABLE = Raw.Module.RC_TIMER_FILTER_WALKABLE;
|
|
55
|
+
Recast.RC_TIMER_MEDIAN_AREA = Raw.Module.RC_TIMER_MEDIAN_AREA;
|
|
56
|
+
Recast.RC_TIMER_FILTER_LOW_OBSTACLES = Raw.Module.RC_TIMER_FILTER_LOW_OBSTACLES;
|
|
57
|
+
Recast.RC_TIMER_BUILD_POLYMESH = Raw.Module.RC_TIMER_BUILD_POLYMESH;
|
|
58
|
+
Recast.RC_TIMER_MERGE_POLYMESH = Raw.Module.RC_TIMER_MERGE_POLYMESH;
|
|
59
|
+
Recast.RC_TIMER_ERODE_AREA = Raw.Module.RC_TIMER_ERODE_AREA;
|
|
60
|
+
Recast.RC_TIMER_MARK_BOX_AREA = Raw.Module.RC_TIMER_MARK_BOX_AREA;
|
|
61
|
+
Recast.RC_TIMER_MARK_CYLINDER_AREA = Raw.Module.RC_TIMER_MARK_CYLINDER_AREA;
|
|
62
|
+
Recast.RC_TIMER_MARK_CONVEXPOLY_AREA = Raw.Module.RC_TIMER_MARK_CONVEXPOLY_AREA;
|
|
63
|
+
Recast.RC_TIMER_BUILD_DISTANCEFIELD = Raw.Module.RC_TIMER_BUILD_DISTANCEFIELD;
|
|
64
|
+
Recast.RC_TIMER_BUILD_DISTANCEFIELD_DIST = Raw.Module.RC_TIMER_BUILD_DISTANCEFIELD_DIST;
|
|
65
|
+
Recast.RC_TIMER_BUILD_DISTANCEFIELD_BLUR = Raw.Module.RC_TIMER_BUILD_DISTANCEFIELD_BLUR;
|
|
66
|
+
Recast.RC_TIMER_BUILD_REGIONS = Raw.Module.RC_TIMER_BUILD_REGIONS;
|
|
67
|
+
Recast.RC_TIMER_BUILD_REGIONS_WATERSHED = Raw.Module.RC_TIMER_BUILD_REGIONS_WATERSHED;
|
|
68
|
+
Recast.RC_TIMER_BUILD_REGIONS_EXPAND = Raw.Module.RC_TIMER_BUILD_REGIONS_EXPAND;
|
|
69
|
+
Recast.RC_TIMER_BUILD_REGIONS_FLOOD = Raw.Module.RC_TIMER_BUILD_REGIONS_FLOOD;
|
|
70
|
+
Recast.RC_TIMER_BUILD_REGIONS_FILTER = Raw.Module.RC_TIMER_BUILD_REGIONS_FILTER;
|
|
71
|
+
Recast.RC_TIMER_BUILD_LAYERS = Raw.Module.RC_TIMER_BUILD_LAYERS;
|
|
72
|
+
Recast.RC_TIMER_BUILD_POLYMESHDETAIL = Raw.Module.RC_TIMER_BUILD_POLYMESHDETAIL;
|
|
73
|
+
Recast.RC_TIMER_MERGE_POLYMESHDETAIL = Raw.Module.RC_TIMER_MERGE_POLYMESHDETAIL;
|
|
74
|
+
Recast.RC_MAX_TIMERS = Raw.Module.RC_MAX_TIMERS;
|
|
75
|
+
Detour.DT_FAILURE = Raw.Detour.FAILURE;
|
|
76
|
+
Detour.DT_SUCCESS = Raw.Detour.SUCCESS;
|
|
77
|
+
Detour.DT_IN_PROGRESS = Raw.Detour.IN_PROGRESS;
|
|
78
|
+
Detour.DT_STATUS_DETAIL_MASK = Raw.Detour.STATUS_DETAIL_MASK;
|
|
79
|
+
Detour.DT_WRONG_MAGIC = Raw.Detour.WRONG_MAGIC;
|
|
80
|
+
Detour.DT_WRONG_VERSION = Raw.Detour.WRONG_VERSION;
|
|
81
|
+
Detour.DT_OUT_OF_MEMORY = Raw.Detour.OUT_OF_MEMORY;
|
|
82
|
+
Detour.DT_INVALID_PARAM = Raw.Detour.INVALID_PARAM;
|
|
83
|
+
Detour.DT_BUFFER_TOO_SMALL = Raw.Detour.BUFFER_TOO_SMALL;
|
|
84
|
+
Detour.DT_OUT_OF_NODES = Raw.Detour.OUT_OF_NODES;
|
|
85
|
+
Detour.DT_PARTIAL_RESULT = Raw.Detour.PARTIAL_RESULT;
|
|
86
|
+
Detour.DT_ALREADY_OCCUPIED = Raw.Detour.ALREADY_OCCUPIED;
|
|
87
|
+
Detour.DT_VERTS_PER_POLYGON = Raw.Detour.VERTS_PER_POLYGON;
|
|
88
|
+
Detour.DT_NAVMESH_MAGIC = Raw.Detour.NAVMESH_MAGIC;
|
|
89
|
+
Detour.DT_NAVMESH_VERSION = Raw.Detour.NAVMESH_VERSION;
|
|
90
|
+
Detour.DT_NAVMESH_STATE_MAGIC = Raw.Detour.NAVMESH_STATE_MAGIC;
|
|
91
|
+
Detour.DT_NAVMESH_STATE_VERSION = Raw.Detour.NAVMESH_STATE_VERSION;
|
|
92
|
+
Detour.DT_TILECACHE_MAGIC = Raw.Detour.TILECACHE_MAGIC;
|
|
93
|
+
Detour.DT_TILECACHE_VERSION = Raw.Detour.TILECACHE_VERSION;
|
|
94
|
+
Detour.DT_TILECACHE_NULL_AREA = Raw.Detour.TILECACHE_NULL_AREA;
|
|
95
|
+
Detour.DT_TILECACHE_WALKABLE_AREA = Raw.Detour.TILECACHE_WALKABLE_AREA;
|
|
96
|
+
Detour.DT_TILECACHE_NULL_IDX = Raw.Detour.TILECACHE_NULL_IDX;
|
|
97
|
+
Detour.DT_NULL_LINK = Raw.Detour.NULL_LINK;
|
|
98
|
+
Detour.DT_NULL_LINK = Raw.Detour.NULL_LINK;
|
|
99
|
+
Detour.DT_EXT_LINK = Raw.Detour.EXT_LINK;
|
|
100
|
+
Detour.DT_OFFMESH_CON_BIDIR = Raw.Detour.OFFMESH_CON_BIDIR;
|
|
101
|
+
Detour.DT_STRAIGHTPATH_START = Raw.Module.DT_STRAIGHTPATH_START;
|
|
102
|
+
Detour.DT_STRAIGHTPATH_END = Raw.Module.DT_STRAIGHTPATH_END;
|
|
103
|
+
Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION = Raw.Module.DT_STRAIGHTPATH_OFFMESH_CONNECTION;
|
|
104
|
+
Detour.DT_STRAIGHTPATH_AREA_CROSSINGS = Raw.Module.DT_STRAIGHTPATH_AREA_CROSSINGS;
|
|
105
|
+
Detour.DT_STRAIGHTPATH_ALL_CROSSINGS = Raw.Module.DT_STRAIGHTPATH_ALL_CROSSINGS;
|
|
106
|
+
Detour.DT_FINDPATH_ANY_ANGLE = Raw.Module.DT_FINDPATH_ANY_ANGLE;
|
|
107
|
+
Detour.DT_RAYCAST_USE_COSTS = Raw.Module.DT_RAYCAST_USE_COSTS;
|
|
108
|
+
Detour.DT_CROWDAGENT_STATE_INVALID = Raw.Module.DT_CROWDAGENT_STATE_INVALID;
|
|
109
|
+
Detour.DT_CROWDAGENT_STATE_WALKING = Raw.Module.DT_CROWDAGENT_STATE_WALKING;
|
|
110
|
+
Detour.DT_CROWDAGENT_STATE_OFFMESH = Raw.Module.DT_CROWDAGENT_STATE_OFFMESH;
|
|
111
|
+
Detour.DT_CROWDAGENT_TARGET_NONE = Raw.Module.DT_CROWDAGENT_TARGET_NONE;
|
|
112
|
+
Detour.DT_CROWDAGENT_TARGET_FAILED = Raw.Module.DT_CROWDAGENT_TARGET_FAILED;
|
|
113
|
+
Detour.DT_CROWDAGENT_TARGET_VALID = Raw.Module.DT_CROWDAGENT_TARGET_VALID;
|
|
114
|
+
Detour.DT_CROWDAGENT_TARGET_REQUESTING = Raw.Module.DT_CROWDAGENT_TARGET_REQUESTING;
|
|
115
|
+
Detour.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE = Raw.Module.DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE;
|
|
116
|
+
Detour.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH = Raw.Module.DT_CROWDAGENT_TARGET_WAITING_FOR_PATH;
|
|
117
|
+
Detour.DT_CROWDAGENT_TARGET_VELOCITY = Raw.Module.DT_CROWDAGENT_TARGET_VELOCITY;
|
|
118
|
+
Detour.DT_COMPRESSEDTILE_FREE_DATA = Raw.Module.DT_COMPRESSEDTILE_FREE_DATA;
|
|
119
|
+
Detour.DT_TILE_FREE_DATA = Raw.Module.DT_TILE_FREE_DATA;
|
|
120
|
+
};
|
|
121
|
+
class BaseArray {
|
|
122
|
+
get size() {
|
|
123
|
+
return this.raw.size;
|
|
124
|
+
}
|
|
125
|
+
constructor(raw) {
|
|
126
|
+
this.raw = raw;
|
|
127
|
+
}
|
|
128
|
+
get(i) {
|
|
129
|
+
return this.raw.get(i);
|
|
130
|
+
}
|
|
131
|
+
set(i, value) {
|
|
132
|
+
this.raw.set(i, value);
|
|
133
|
+
}
|
|
134
|
+
resize(size) {
|
|
135
|
+
this.raw.resize(size);
|
|
136
|
+
}
|
|
137
|
+
copy(data) {
|
|
138
|
+
this.raw.resize(data.length);
|
|
139
|
+
const view = this.getHeapView();
|
|
140
|
+
view.set(data);
|
|
141
|
+
}
|
|
142
|
+
destroy() {
|
|
143
|
+
Raw.destroy(this.raw);
|
|
144
|
+
}
|
|
145
|
+
getHeapView() {
|
|
146
|
+
const heap = this.getHeap();
|
|
147
|
+
const dataHeap = new this.typedArrayClass(heap.buffer, this.raw.getDataPointer(), this.size);
|
|
148
|
+
return dataHeap;
|
|
149
|
+
}
|
|
150
|
+
toTypedArray() {
|
|
151
|
+
const view = this.getHeapView();
|
|
152
|
+
const data = new this.typedArrayClass(this.size);
|
|
153
|
+
data.set(view);
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
class IntArray extends BaseArray {
|
|
158
|
+
constructor(raw) {
|
|
159
|
+
super(raw ?? new Raw.Module.IntArray());
|
|
160
|
+
__publicField(this, "typedArrayClass", Int32Array);
|
|
161
|
+
}
|
|
162
|
+
getHeap() {
|
|
163
|
+
return Raw.Module.HEAP32;
|
|
164
|
+
}
|
|
165
|
+
static fromRaw(raw) {
|
|
166
|
+
return new IntArray(raw);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
class UnsignedIntArray extends BaseArray {
|
|
170
|
+
constructor(raw) {
|
|
171
|
+
super(raw ?? new Raw.Module.UnsignedIntArray());
|
|
172
|
+
__publicField(this, "typedArrayClass", Uint32Array);
|
|
173
|
+
}
|
|
174
|
+
getHeap() {
|
|
175
|
+
return Raw.Module.HEAPU32;
|
|
176
|
+
}
|
|
177
|
+
static fromRaw(raw) {
|
|
178
|
+
return new UnsignedIntArray(raw);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
class UnsignedCharArray extends BaseArray {
|
|
182
|
+
constructor(raw) {
|
|
183
|
+
super(raw ?? new Raw.Module.UnsignedCharArray());
|
|
184
|
+
__publicField(this, "typedArrayClass", Uint8Array);
|
|
185
|
+
}
|
|
186
|
+
getHeap() {
|
|
187
|
+
return Raw.Module.HEAPU8;
|
|
188
|
+
}
|
|
189
|
+
static fromRaw(raw) {
|
|
190
|
+
return new UnsignedCharArray(raw);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
class UnsignedShortArray extends BaseArray {
|
|
194
|
+
constructor(raw) {
|
|
195
|
+
super(raw ?? new Raw.Module.UnsignedShortArray());
|
|
196
|
+
__publicField(this, "typedArrayClass", Uint16Array);
|
|
197
|
+
}
|
|
198
|
+
getHeap() {
|
|
199
|
+
return Raw.Module.HEAPU16;
|
|
200
|
+
}
|
|
201
|
+
static fromRaw(raw) {
|
|
202
|
+
return new UnsignedShortArray(raw);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
class FloatArray extends BaseArray {
|
|
206
|
+
constructor(raw) {
|
|
207
|
+
super(raw ?? new Raw.Module.FloatArray());
|
|
208
|
+
__publicField(this, "typedArrayClass", Float32Array);
|
|
209
|
+
}
|
|
210
|
+
getHeap() {
|
|
211
|
+
return Raw.Module.HEAPF32;
|
|
212
|
+
}
|
|
213
|
+
static fromRaw(raw) {
|
|
214
|
+
return new FloatArray(raw);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const VerticesArray = FloatArray;
|
|
218
|
+
const TrianglesArray = IntArray;
|
|
219
|
+
const TriangleAreasArray = UnsignedCharArray;
|
|
220
|
+
const ChunkIdsArray = IntArray;
|
|
221
|
+
const TileCacheData = UnsignedCharArray;
|
|
222
|
+
const vec3 = {
|
|
223
|
+
toRaw: ({
|
|
224
|
+
x,
|
|
225
|
+
y,
|
|
226
|
+
z
|
|
227
|
+
}, existing) => {
|
|
228
|
+
if (existing) {
|
|
229
|
+
existing.x = x;
|
|
230
|
+
existing.y = y;
|
|
231
|
+
existing.z = z;
|
|
232
|
+
return existing;
|
|
233
|
+
}
|
|
234
|
+
return new Raw.Module.Vec3(x, y, z);
|
|
235
|
+
},
|
|
236
|
+
fromRaw: (vec32) => {
|
|
237
|
+
const {
|
|
238
|
+
x,
|
|
239
|
+
y,
|
|
240
|
+
z
|
|
241
|
+
} = vec32;
|
|
242
|
+
return {
|
|
243
|
+
x,
|
|
244
|
+
y,
|
|
245
|
+
z
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
fromArray: ([x, y, z]) => {
|
|
249
|
+
return {
|
|
250
|
+
x,
|
|
251
|
+
y,
|
|
252
|
+
z
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
toArray: ({
|
|
256
|
+
x,
|
|
257
|
+
y,
|
|
258
|
+
z
|
|
259
|
+
}) => {
|
|
260
|
+
return [x, y, z];
|
|
261
|
+
},
|
|
262
|
+
lerp: (a, b, t, out = {
|
|
263
|
+
x: 0,
|
|
264
|
+
y: 0,
|
|
265
|
+
z: 0
|
|
266
|
+
}) => {
|
|
267
|
+
out.x = a.x + (b.x - a.x) * t;
|
|
268
|
+
out.y = a.y + (b.y - a.y) * t;
|
|
269
|
+
out.z = a.z + (b.z - a.z) * t;
|
|
270
|
+
},
|
|
271
|
+
copy: (source, out = {
|
|
272
|
+
x: 0,
|
|
273
|
+
y: 0,
|
|
274
|
+
z: 0
|
|
275
|
+
}) => {
|
|
276
|
+
out.x = source.x;
|
|
277
|
+
out.y = source.y;
|
|
278
|
+
out.z = source.z;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
const array = (getter, count) => {
|
|
282
|
+
const array2 = [];
|
|
283
|
+
for (let i = 0; i < count; i++) {
|
|
284
|
+
array2.push(getter(i));
|
|
285
|
+
}
|
|
286
|
+
return array2;
|
|
287
|
+
};
|
|
288
|
+
const statusSucceed = (status) => {
|
|
289
|
+
return Raw.Detour.statusSucceed(status);
|
|
290
|
+
};
|
|
291
|
+
const statusFailed = (status) => {
|
|
292
|
+
return Raw.Detour.statusFailed(status);
|
|
293
|
+
};
|
|
294
|
+
const statusInProgress = (status) => {
|
|
295
|
+
return Raw.Detour.statusInProgress(status);
|
|
296
|
+
};
|
|
297
|
+
const statusDetail = (status, detail) => {
|
|
298
|
+
return Raw.Detour.statusDetail(status, detail);
|
|
299
|
+
};
|
|
300
|
+
const statusToReadableString = (status) => {
|
|
301
|
+
if (Raw.Detour.statusSucceed(status)) {
|
|
302
|
+
return "success";
|
|
303
|
+
}
|
|
304
|
+
if (Raw.Detour.statusInProgress(status)) {
|
|
305
|
+
return "in progress";
|
|
306
|
+
}
|
|
307
|
+
if (Raw.Detour.statusFailed(status)) {
|
|
308
|
+
let reason;
|
|
309
|
+
const DT_STATUS_REASONS = {
|
|
310
|
+
DT_WRONG_MAGIC: Detour.DT_WRONG_MAGIC,
|
|
311
|
+
DT_WRONG_VERSION: Detour.DT_WRONG_VERSION,
|
|
312
|
+
DT_OUT_OF_MEMORY: Detour.DT_OUT_OF_MEMORY,
|
|
313
|
+
DT_INVALID_PARAM: Detour.DT_INVALID_PARAM,
|
|
314
|
+
DT_BUFFER_TOO_SMALL: Detour.DT_BUFFER_TOO_SMALL,
|
|
315
|
+
DT_OUT_OF_NODES: Detour.DT_OUT_OF_NODES,
|
|
316
|
+
DT_PARTIAL_RESULT: Detour.DT_PARTIAL_RESULT,
|
|
317
|
+
DT_ALREADY_OCCUPIED: Detour.DT_ALREADY_OCCUPIED
|
|
318
|
+
};
|
|
319
|
+
for (const [reasonName, reasonMask] of Object.entries(DT_STATUS_REASONS)) {
|
|
320
|
+
if (Raw.Detour.statusDetail(status, reasonMask)) {
|
|
321
|
+
reason = reasonName;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (reason) {
|
|
326
|
+
return `failed - ${reason}`;
|
|
327
|
+
}
|
|
328
|
+
return `failed - unknown`;
|
|
329
|
+
}
|
|
330
|
+
return "unknown";
|
|
331
|
+
};
|
|
332
|
+
class DetourPolyDetail {
|
|
333
|
+
constructor(raw) {
|
|
334
|
+
this.raw = raw;
|
|
335
|
+
}
|
|
336
|
+
vertBase() {
|
|
337
|
+
return this.raw.vertBase;
|
|
338
|
+
}
|
|
339
|
+
triBase() {
|
|
340
|
+
return this.raw.triBase;
|
|
341
|
+
}
|
|
342
|
+
vertCount() {
|
|
343
|
+
return this.raw.vertCount;
|
|
344
|
+
}
|
|
345
|
+
triCount() {
|
|
346
|
+
return this.raw.triCount;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
class DetourLink {
|
|
350
|
+
constructor(raw) {
|
|
351
|
+
this.raw = raw;
|
|
352
|
+
}
|
|
353
|
+
ref() {
|
|
354
|
+
return this.raw.ref;
|
|
355
|
+
}
|
|
356
|
+
next() {
|
|
357
|
+
return this.raw.next;
|
|
358
|
+
}
|
|
359
|
+
edge() {
|
|
360
|
+
return this.raw.edge;
|
|
361
|
+
}
|
|
362
|
+
side() {
|
|
363
|
+
return this.raw.side;
|
|
364
|
+
}
|
|
365
|
+
bmin() {
|
|
366
|
+
return this.raw.bmin;
|
|
367
|
+
}
|
|
368
|
+
bmax() {
|
|
369
|
+
return this.raw.bmax;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
class DetourBVNode {
|
|
373
|
+
constructor(raw) {
|
|
374
|
+
this.raw = raw;
|
|
375
|
+
}
|
|
376
|
+
bmin() {
|
|
377
|
+
return vec3.fromArray(array((i) => this.raw.get_bmin(i), 3));
|
|
378
|
+
}
|
|
379
|
+
bmax() {
|
|
380
|
+
return vec3.fromArray(array((i) => this.raw.get_bmax(i), 3));
|
|
381
|
+
}
|
|
382
|
+
i() {
|
|
383
|
+
return this.raw.i;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
class DetourOffMeshConnection {
|
|
387
|
+
constructor(raw) {
|
|
388
|
+
this.raw = raw;
|
|
389
|
+
}
|
|
390
|
+
pos(index) {
|
|
391
|
+
return this.raw.get_pos(index);
|
|
392
|
+
}
|
|
393
|
+
rad() {
|
|
394
|
+
return this.raw.rad;
|
|
395
|
+
}
|
|
396
|
+
poly() {
|
|
397
|
+
return this.raw.poly;
|
|
398
|
+
}
|
|
399
|
+
flags() {
|
|
400
|
+
return this.raw.flags;
|
|
401
|
+
}
|
|
402
|
+
side() {
|
|
403
|
+
return this.raw.side;
|
|
404
|
+
}
|
|
405
|
+
userId() {
|
|
406
|
+
return this.raw.userId;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
class DetourMeshHeader {
|
|
410
|
+
constructor(raw) {
|
|
411
|
+
this.raw = raw;
|
|
412
|
+
}
|
|
413
|
+
magic() {
|
|
414
|
+
return this.raw.magic;
|
|
415
|
+
}
|
|
416
|
+
version() {
|
|
417
|
+
return this.raw.version;
|
|
418
|
+
}
|
|
419
|
+
x() {
|
|
420
|
+
return this.raw.x;
|
|
421
|
+
}
|
|
422
|
+
y() {
|
|
423
|
+
return this.raw.y;
|
|
424
|
+
}
|
|
425
|
+
layer() {
|
|
426
|
+
return this.raw.layer;
|
|
427
|
+
}
|
|
428
|
+
userId() {
|
|
429
|
+
return this.raw.userId;
|
|
430
|
+
}
|
|
431
|
+
polyCount() {
|
|
432
|
+
return this.raw.polyCount;
|
|
433
|
+
}
|
|
434
|
+
vertCount() {
|
|
435
|
+
return this.raw.vertCount;
|
|
436
|
+
}
|
|
437
|
+
maxLinkCount() {
|
|
438
|
+
return this.raw.maxLinkCount;
|
|
439
|
+
}
|
|
440
|
+
detailMeshCount() {
|
|
441
|
+
return this.raw.detailMeshCount;
|
|
442
|
+
}
|
|
443
|
+
detailVertCount() {
|
|
444
|
+
return this.raw.detailVertCount;
|
|
445
|
+
}
|
|
446
|
+
detailTriCount() {
|
|
447
|
+
return this.raw.detailTriCount;
|
|
448
|
+
}
|
|
449
|
+
bvNodeCount() {
|
|
450
|
+
return this.raw.bvNodeCount;
|
|
451
|
+
}
|
|
452
|
+
offMeshConCount() {
|
|
453
|
+
return this.raw.offMeshConCount;
|
|
454
|
+
}
|
|
455
|
+
offMeshBase() {
|
|
456
|
+
return this.raw.offMeshBase;
|
|
457
|
+
}
|
|
458
|
+
walkableHeight() {
|
|
459
|
+
return this.raw.walkableHeight;
|
|
460
|
+
}
|
|
461
|
+
walkableRadius() {
|
|
462
|
+
return this.raw.walkableRadius;
|
|
463
|
+
}
|
|
464
|
+
walkableClimb() {
|
|
465
|
+
return this.raw.walkableClimb;
|
|
466
|
+
}
|
|
467
|
+
bmin(index) {
|
|
468
|
+
return this.raw.get_bmin(index);
|
|
469
|
+
}
|
|
470
|
+
bmax(index) {
|
|
471
|
+
return this.raw.get_bmax(index);
|
|
472
|
+
}
|
|
473
|
+
bvQuantFactor() {
|
|
474
|
+
return this.raw.bvQuantFactor;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
class DetourPoly {
|
|
478
|
+
constructor(raw) {
|
|
479
|
+
this.raw = raw;
|
|
480
|
+
}
|
|
481
|
+
firstLink() {
|
|
482
|
+
return this.raw.firstLink;
|
|
483
|
+
}
|
|
484
|
+
verts(index) {
|
|
485
|
+
return this.raw.get_verts(index);
|
|
486
|
+
}
|
|
487
|
+
neis(index) {
|
|
488
|
+
return this.raw.get_neis(index);
|
|
489
|
+
}
|
|
490
|
+
flags() {
|
|
491
|
+
return this.raw.flags;
|
|
492
|
+
}
|
|
493
|
+
vertCount() {
|
|
494
|
+
return this.raw.vertCount;
|
|
495
|
+
}
|
|
496
|
+
areaAndType() {
|
|
497
|
+
return this.raw.get_areaAndtype();
|
|
498
|
+
}
|
|
499
|
+
getType() {
|
|
500
|
+
return this.raw.getType();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
class DetourMeshTile {
|
|
504
|
+
constructor(raw) {
|
|
505
|
+
this.raw = raw;
|
|
506
|
+
}
|
|
507
|
+
salt() {
|
|
508
|
+
return this.raw.salt;
|
|
509
|
+
}
|
|
510
|
+
linksFreeList() {
|
|
511
|
+
return this.raw.linksFreeList;
|
|
512
|
+
}
|
|
513
|
+
header() {
|
|
514
|
+
return !Raw.isNull(this.raw.header) ? new DetourMeshHeader(this.raw.header) : null;
|
|
515
|
+
}
|
|
516
|
+
polys(index) {
|
|
517
|
+
return new DetourPoly(this.raw.get_polys(index));
|
|
518
|
+
}
|
|
519
|
+
verts(index) {
|
|
520
|
+
return this.raw.get_verts(index);
|
|
521
|
+
}
|
|
522
|
+
links(index) {
|
|
523
|
+
return new DetourLink(this.raw.get_links(index));
|
|
524
|
+
}
|
|
525
|
+
detailMeshes(index) {
|
|
526
|
+
return new DetourPolyDetail(this.raw.get_detailMeshes(index));
|
|
527
|
+
}
|
|
528
|
+
detailVerts(index) {
|
|
529
|
+
return this.raw.get_detailVerts(index);
|
|
530
|
+
}
|
|
531
|
+
detailTris(index) {
|
|
532
|
+
return this.raw.get_detailTris(index);
|
|
533
|
+
}
|
|
534
|
+
bvTree(index) {
|
|
535
|
+
return new DetourBVNode(this.raw.get_bvTree(index));
|
|
536
|
+
}
|
|
537
|
+
offMeshCons(index) {
|
|
538
|
+
return new DetourOffMeshConnection(this.raw.get_offMeshCons(index));
|
|
539
|
+
}
|
|
540
|
+
data(index) {
|
|
541
|
+
return this.raw.get_data(index);
|
|
542
|
+
}
|
|
543
|
+
dataSize() {
|
|
544
|
+
return this.raw.dataSize;
|
|
545
|
+
}
|
|
546
|
+
flags() {
|
|
547
|
+
return this.raw.flags;
|
|
548
|
+
}
|
|
549
|
+
next() {
|
|
550
|
+
return new DetourMeshTile(this.raw.next);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const createNavMeshData = (navMeshCreateParams) => {
|
|
554
|
+
const result = Raw.DetourNavMeshBuilder.createNavMeshData(navMeshCreateParams.raw);
|
|
555
|
+
return {
|
|
556
|
+
success: result.success,
|
|
557
|
+
navMeshData: UnsignedCharArray.fromRaw(result.navMeshData)
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
class NavMeshCreateParams {
|
|
561
|
+
constructor(raw) {
|
|
562
|
+
this.raw = raw ?? new Raw.Module.dtNavMeshCreateParams();
|
|
563
|
+
}
|
|
564
|
+
setPolyMeshCreateParams(polyMesh) {
|
|
565
|
+
Raw.DetourNavMeshBuilder.setPolyMeshCreateParams(this.raw, polyMesh.raw);
|
|
566
|
+
}
|
|
567
|
+
setPolyMeshDetailCreateParams(polyMeshDetail) {
|
|
568
|
+
Raw.DetourNavMeshBuilder.setPolyMeshDetailCreateParams(this.raw, polyMeshDetail.raw);
|
|
569
|
+
}
|
|
570
|
+
setOffMeshConnections(offMeshConnections) {
|
|
571
|
+
if (offMeshConnections.length <= 0) return;
|
|
572
|
+
const verts = [];
|
|
573
|
+
const rads = [];
|
|
574
|
+
const dir = [];
|
|
575
|
+
const areas = [];
|
|
576
|
+
const flags = [];
|
|
577
|
+
const userIds = [];
|
|
578
|
+
for (let i = 0; i < offMeshConnections.length; i++) {
|
|
579
|
+
const connection = offMeshConnections[i];
|
|
580
|
+
verts.push(connection.startPosition.x, connection.startPosition.y, connection.startPosition.z);
|
|
581
|
+
verts.push(connection.endPosition.x, connection.endPosition.y, connection.endPosition.z);
|
|
582
|
+
rads.push(connection.radius);
|
|
583
|
+
dir.push(connection.bidirectional ? 1 : 0);
|
|
584
|
+
areas.push(connection.area ?? 0);
|
|
585
|
+
flags.push(connection.flags ?? 1);
|
|
586
|
+
userIds.push(connection.userId ?? 1e3 + i);
|
|
587
|
+
}
|
|
588
|
+
Raw.DetourNavMeshBuilder.setOffMeshConnections(this.raw, offMeshConnections.length, verts, rads, dir, areas, flags, userIds);
|
|
589
|
+
}
|
|
590
|
+
verts(index) {
|
|
591
|
+
return this.raw.get_verts(index);
|
|
592
|
+
}
|
|
593
|
+
setVerts(index, value) {
|
|
594
|
+
this.raw.set_verts(index, value);
|
|
595
|
+
}
|
|
596
|
+
vertCount() {
|
|
597
|
+
return this.raw.vertCount;
|
|
598
|
+
}
|
|
599
|
+
polys(index) {
|
|
600
|
+
return this.raw.get_polys(index);
|
|
601
|
+
}
|
|
602
|
+
setPolys(index, value) {
|
|
603
|
+
this.raw.set_polys(index, value);
|
|
604
|
+
}
|
|
605
|
+
polyAreas(index) {
|
|
606
|
+
return this.raw.get_polyAreas(index);
|
|
607
|
+
}
|
|
608
|
+
setPolyAreas(index, value) {
|
|
609
|
+
this.raw.set_polyAreas(index, value);
|
|
610
|
+
}
|
|
611
|
+
polyFlags(index) {
|
|
612
|
+
return this.raw.get_polyFlags(index);
|
|
613
|
+
}
|
|
614
|
+
setPolyFlags(index, value) {
|
|
615
|
+
this.raw.set_polyFlags(index, value);
|
|
616
|
+
}
|
|
617
|
+
polyCount() {
|
|
618
|
+
return this.raw.polyCount;
|
|
619
|
+
}
|
|
620
|
+
nvp() {
|
|
621
|
+
return this.raw.nvp;
|
|
622
|
+
}
|
|
623
|
+
setNvp(value) {
|
|
624
|
+
this.raw.nvp = value;
|
|
625
|
+
}
|
|
626
|
+
detailMeshes(index) {
|
|
627
|
+
return this.raw.get_detailMeshes(index);
|
|
628
|
+
}
|
|
629
|
+
setDetailMeshes(index, value) {
|
|
630
|
+
this.raw.set_detailMeshes(index, value);
|
|
631
|
+
}
|
|
632
|
+
detailVerts(index) {
|
|
633
|
+
return this.raw.get_detailVerts(index);
|
|
634
|
+
}
|
|
635
|
+
setDetailVerts(index, value) {
|
|
636
|
+
this.raw.set_detailVerts(index, value);
|
|
637
|
+
}
|
|
638
|
+
detailVertsCount() {
|
|
639
|
+
return this.raw.detailVertsCount;
|
|
640
|
+
}
|
|
641
|
+
detailTris(index) {
|
|
642
|
+
return this.raw.get_detailTris(index);
|
|
643
|
+
}
|
|
644
|
+
setDetailTris(index, value) {
|
|
645
|
+
this.raw.set_detailTris(index, value);
|
|
646
|
+
}
|
|
647
|
+
detailTriCount() {
|
|
648
|
+
return this.raw.detailTriCount;
|
|
649
|
+
}
|
|
650
|
+
offMeshConVerts(index) {
|
|
651
|
+
return this.raw.get_offMeshConVerts(index);
|
|
652
|
+
}
|
|
653
|
+
offMeshConRad(index) {
|
|
654
|
+
return this.raw.get_offMeshConRad(index);
|
|
655
|
+
}
|
|
656
|
+
offMeshConDir(index) {
|
|
657
|
+
return this.raw.get_offMeshConDir(index);
|
|
658
|
+
}
|
|
659
|
+
offMeshConAreas(index) {
|
|
660
|
+
return this.raw.get_offMeshConAreas(index);
|
|
661
|
+
}
|
|
662
|
+
offMeshConFlags(index) {
|
|
663
|
+
return this.raw.get_offMeshConFlags(index);
|
|
664
|
+
}
|
|
665
|
+
offMeshConUserID(index) {
|
|
666
|
+
return this.raw.get_offMeshConUserID(index);
|
|
667
|
+
}
|
|
668
|
+
offMeshConCount() {
|
|
669
|
+
return this.raw.offMeshConCount;
|
|
670
|
+
}
|
|
671
|
+
userId() {
|
|
672
|
+
return this.raw.userId;
|
|
673
|
+
}
|
|
674
|
+
tileX() {
|
|
675
|
+
return this.raw.tileX;
|
|
676
|
+
}
|
|
677
|
+
setTileX(value) {
|
|
678
|
+
this.raw.tileX = value;
|
|
679
|
+
}
|
|
680
|
+
tileY() {
|
|
681
|
+
return this.raw.tileY;
|
|
682
|
+
}
|
|
683
|
+
setTileY(value) {
|
|
684
|
+
this.raw.tileY = value;
|
|
685
|
+
}
|
|
686
|
+
tileLayer() {
|
|
687
|
+
return this.raw.tileLayer;
|
|
688
|
+
}
|
|
689
|
+
setTileLayer(value) {
|
|
690
|
+
this.raw.tileLayer = value;
|
|
691
|
+
}
|
|
692
|
+
boundsMin() {
|
|
693
|
+
return array((i) => this.raw.get_bmin(i), 3);
|
|
694
|
+
}
|
|
695
|
+
setBoundsMin(value) {
|
|
696
|
+
this.raw.set_bmin(0, value[0]);
|
|
697
|
+
this.raw.set_bmin(1, value[1]);
|
|
698
|
+
this.raw.set_bmin(2, value[2]);
|
|
699
|
+
}
|
|
700
|
+
boundsMax() {
|
|
701
|
+
return array((i) => this.raw.get_bmax(i), 3);
|
|
702
|
+
}
|
|
703
|
+
setBoundsMax(value) {
|
|
704
|
+
this.raw.set_bmax(0, value[0]);
|
|
705
|
+
this.raw.set_bmax(1, value[1]);
|
|
706
|
+
this.raw.set_bmax(2, value[2]);
|
|
707
|
+
}
|
|
708
|
+
walkableHeight() {
|
|
709
|
+
return this.raw.walkableHeight;
|
|
710
|
+
}
|
|
711
|
+
setWalkableHeight(value) {
|
|
712
|
+
this.raw.walkableHeight = value;
|
|
713
|
+
}
|
|
714
|
+
walkableRadius() {
|
|
715
|
+
return this.raw.walkableRadius;
|
|
716
|
+
}
|
|
717
|
+
setWalkableRadius(value) {
|
|
718
|
+
this.raw.walkableRadius = value;
|
|
719
|
+
}
|
|
720
|
+
walkableClimb() {
|
|
721
|
+
return this.raw.walkableClimb;
|
|
722
|
+
}
|
|
723
|
+
setWalkableClimb(value) {
|
|
724
|
+
this.raw.walkableClimb = value;
|
|
725
|
+
}
|
|
726
|
+
cellSize() {
|
|
727
|
+
return this.raw.cs;
|
|
728
|
+
}
|
|
729
|
+
setCellSize(value) {
|
|
730
|
+
this.raw.cs = value;
|
|
731
|
+
}
|
|
732
|
+
cellHeight() {
|
|
733
|
+
return this.raw.ch;
|
|
734
|
+
}
|
|
735
|
+
setCellHeight(value) {
|
|
736
|
+
this.raw.ch = value;
|
|
737
|
+
}
|
|
738
|
+
buildBvTree() {
|
|
739
|
+
return this.raw.buildBvTree;
|
|
740
|
+
}
|
|
741
|
+
setBuildBvTree(value) {
|
|
742
|
+
this.raw.buildBvTree = value;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
class QueryFilter {
|
|
746
|
+
get includeFlags() {
|
|
747
|
+
return this.raw.getIncludeFlags();
|
|
748
|
+
}
|
|
749
|
+
set includeFlags(flags) {
|
|
750
|
+
this.raw.setIncludeFlags(flags);
|
|
751
|
+
}
|
|
752
|
+
get excludeFlags() {
|
|
753
|
+
return this.raw.getExcludeFlags();
|
|
754
|
+
}
|
|
755
|
+
set excludeFlags(flags) {
|
|
756
|
+
this.raw.setExcludeFlags(flags);
|
|
757
|
+
}
|
|
758
|
+
constructor(raw) {
|
|
759
|
+
this.raw = raw ?? new Raw.Module.dtQueryFilter();
|
|
760
|
+
}
|
|
761
|
+
getAreaCost(i) {
|
|
762
|
+
return this.raw.getAreaCost(i);
|
|
763
|
+
}
|
|
764
|
+
setAreaCost(i, cost) {
|
|
765
|
+
this.raw.setAreaCost(i, cost);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
class NavMeshQuery {
|
|
769
|
+
constructor(value, params) {
|
|
770
|
+
/**
|
|
771
|
+
* Default query filter.
|
|
772
|
+
*/
|
|
773
|
+
/**
|
|
774
|
+
* Default search distance along each axis.
|
|
775
|
+
*/
|
|
776
|
+
__publicField(this, "defaultQueryHalfExtents", {
|
|
777
|
+
x: 1,
|
|
778
|
+
y: 1,
|
|
779
|
+
z: 1
|
|
780
|
+
});
|
|
781
|
+
if (value instanceof Raw.Module.NavMeshQuery) {
|
|
782
|
+
this.raw = value;
|
|
783
|
+
} else {
|
|
784
|
+
this.raw = new Raw.Module.NavMeshQuery();
|
|
785
|
+
this.raw.init(value.raw, (params == null ? void 0 : params.maxNodes) ?? 2048);
|
|
786
|
+
}
|
|
787
|
+
if (params == null ? void 0 : params.defaultQueryFilter) {
|
|
788
|
+
this.defaultFilter = params.defaultQueryFilter;
|
|
789
|
+
} else {
|
|
790
|
+
this.defaultFilter = new QueryFilter();
|
|
791
|
+
this.defaultFilter.includeFlags = 65535;
|
|
792
|
+
this.defaultFilter.excludeFlags = 0;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Finds the polygon nearest to the given position.
|
|
797
|
+
*/
|
|
798
|
+
findNearestPoly(position, options) {
|
|
799
|
+
var _a;
|
|
800
|
+
const nearestRefRaw = new Raw.UnsignedIntRef();
|
|
801
|
+
const nearestPointRaw = new Raw.Vec3();
|
|
802
|
+
const isOverPolyRaw = new Raw.BoolRef();
|
|
803
|
+
const status = this.raw.findNearestPoly(vec3.toArray(position), vec3.toArray((options == null ? void 0 : options.halfExtents) ?? this.defaultQueryHalfExtents), ((_a = options == null ? void 0 : options.filter) == null ? void 0 : _a.raw) ?? this.defaultFilter.raw, nearestRefRaw, nearestPointRaw, isOverPolyRaw);
|
|
804
|
+
const nearestPoint = vec3.fromRaw(nearestPointRaw);
|
|
805
|
+
Raw.destroy(nearestPointRaw);
|
|
806
|
+
const nearestRef = nearestRefRaw.value;
|
|
807
|
+
Raw.destroy(nearestRefRaw);
|
|
808
|
+
const isOverPoly = isOverPolyRaw.value;
|
|
809
|
+
Raw.destroy(isOverPolyRaw);
|
|
810
|
+
return {
|
|
811
|
+
success: statusSucceed(status),
|
|
812
|
+
status,
|
|
813
|
+
nearestRef,
|
|
814
|
+
nearestPoint,
|
|
815
|
+
isOverPoly
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Finds the polygons along the navigation graph that touch the specified circle.
|
|
820
|
+
* @param startRef Reference of polygon to start search from
|
|
821
|
+
* @param centerPos Center of circle
|
|
822
|
+
* @param radius Radius of circle
|
|
823
|
+
* @param options
|
|
824
|
+
*/
|
|
825
|
+
findPolysAroundCircle(startRef, centerPos, radius, options) {
|
|
826
|
+
const filter = (options == null ? void 0 : options.filter) ?? this.defaultFilter;
|
|
827
|
+
const maxPolys = (options == null ? void 0 : options.maxPolys) ?? 256;
|
|
828
|
+
const resultRefArray = new UnsignedIntArray();
|
|
829
|
+
const resultParentArray = new UnsignedIntArray();
|
|
830
|
+
const resultCostArray = new FloatArray();
|
|
831
|
+
resultRefArray.resize(maxPolys);
|
|
832
|
+
resultParentArray.resize(maxPolys);
|
|
833
|
+
resultCostArray.resize(maxPolys);
|
|
834
|
+
const resultCountRef = new Raw.IntRef();
|
|
835
|
+
const status = this.raw.findPolysAroundCircle(startRef, vec3.toArray(centerPos), radius, filter.raw, resultRefArray.raw, resultParentArray.raw, resultCostArray.raw, resultCountRef, maxPolys);
|
|
836
|
+
const resultRefs = [...resultRefArray.getHeapView()];
|
|
837
|
+
resultRefArray.destroy();
|
|
838
|
+
const resultParents = [...resultParentArray.getHeapView()];
|
|
839
|
+
resultParentArray.destroy();
|
|
840
|
+
const resultCost = [...resultCostArray.getHeapView()];
|
|
841
|
+
resultCostArray.destroy();
|
|
842
|
+
const resultCount = resultCountRef.value;
|
|
843
|
+
Raw.destroy(resultCountRef);
|
|
844
|
+
return {
|
|
845
|
+
success: statusSucceed(status),
|
|
846
|
+
status,
|
|
847
|
+
resultRefs,
|
|
848
|
+
resultParents,
|
|
849
|
+
resultCost,
|
|
850
|
+
resultCount
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Finds polygons that overlap the search box.
|
|
855
|
+
* @param center The center of the search box
|
|
856
|
+
* @param halfExtents The search distance along each axis
|
|
857
|
+
* @param options
|
|
858
|
+
*/
|
|
859
|
+
queryPolygons(center, halfExtents, options) {
|
|
860
|
+
const filter = (options == null ? void 0 : options.filter) ?? this.defaultFilter;
|
|
861
|
+
const maxPolys = (options == null ? void 0 : options.maxPolys) ?? 256;
|
|
862
|
+
const polysRefsArray = new UnsignedIntArray();
|
|
863
|
+
polysRefsArray.resize(maxPolys);
|
|
864
|
+
const polyCountRef = new Raw.IntRef();
|
|
865
|
+
const status = this.raw.queryPolygons(vec3.toArray(center), vec3.toArray(halfExtents), filter.raw, polysRefsArray.raw, polyCountRef, maxPolys);
|
|
866
|
+
const polyCount = polyCountRef.value;
|
|
867
|
+
Raw.destroy(polyCountRef);
|
|
868
|
+
const polyRefs = [...polysRefsArray.getHeapView()].slice(0, polyCount);
|
|
869
|
+
polysRefsArray.destroy();
|
|
870
|
+
return {
|
|
871
|
+
success: statusSucceed(status),
|
|
872
|
+
status,
|
|
873
|
+
polyRefs
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Returns the closest point on the given polygon to the given position.
|
|
878
|
+
*
|
|
879
|
+
* @param polyRef The reference of the polygon
|
|
880
|
+
* @param position The position to find the closest point to
|
|
881
|
+
*/
|
|
882
|
+
closestPointOnPoly(polyRef, position) {
|
|
883
|
+
const closestPointRaw = new Raw.Vec3();
|
|
884
|
+
const positionOverPolyRaw = new Raw.BoolRef();
|
|
885
|
+
const status = this.raw.closestPointOnPoly(polyRef, vec3.toArray(position), closestPointRaw, positionOverPolyRaw);
|
|
886
|
+
const closestPoint = vec3.fromRaw(closestPointRaw);
|
|
887
|
+
Raw.destroy(closestPointRaw);
|
|
888
|
+
const isPointOverPoly = positionOverPolyRaw.value;
|
|
889
|
+
Raw.destroy(positionOverPolyRaw);
|
|
890
|
+
return {
|
|
891
|
+
success: statusSucceed(status),
|
|
892
|
+
status,
|
|
893
|
+
closestPoint,
|
|
894
|
+
isPointOverPoly
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Finds the closest point on the NavMesh to the given position.
|
|
899
|
+
* @param position the position to find the closest point to
|
|
900
|
+
* @param options additional options
|
|
901
|
+
* @returns the result of the find closest point operation
|
|
902
|
+
*/
|
|
903
|
+
findClosestPoint(position, options) {
|
|
904
|
+
const filter = (options == null ? void 0 : options.filter) ?? this.defaultFilter;
|
|
905
|
+
const halfExtents = (options == null ? void 0 : options.halfExtents) ?? this.defaultQueryHalfExtents;
|
|
906
|
+
const resultPolyRef = new Raw.UnsignedIntRef();
|
|
907
|
+
const resultPoint = new Raw.Vec3();
|
|
908
|
+
const resultPointOverPoly = new Raw.BoolRef();
|
|
909
|
+
const status = this.raw.findClosestPoint(vec3.toArray(position), vec3.toArray(halfExtents), filter.raw, resultPolyRef, resultPoint, resultPointOverPoly);
|
|
910
|
+
const polyRef = resultPolyRef.value;
|
|
911
|
+
Raw.destroy(resultPolyRef);
|
|
912
|
+
const point = vec3.fromRaw(resultPoint);
|
|
913
|
+
Raw.destroy(resultPoint);
|
|
914
|
+
const isPointOverPoly = resultPointOverPoly.value;
|
|
915
|
+
Raw.destroy(resultPointOverPoly);
|
|
916
|
+
return {
|
|
917
|
+
success: statusSucceed(status),
|
|
918
|
+
status,
|
|
919
|
+
polyRef,
|
|
920
|
+
point,
|
|
921
|
+
isPointOverPoly
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Returns a random point on the NavMesh within the given radius of the given position.
|
|
926
|
+
*
|
|
927
|
+
* @param position the center of the search circle
|
|
928
|
+
* @param radius the radius of the search circle
|
|
929
|
+
* @param options additional options
|
|
930
|
+
*/
|
|
931
|
+
findRandomPointAroundCircle(position, radius, options) {
|
|
932
|
+
const filter = (options == null ? void 0 : options.filter) ?? this.defaultFilter;
|
|
933
|
+
const halfExtents = (options == null ? void 0 : options.halfExtents) ?? this.defaultQueryHalfExtents;
|
|
934
|
+
let startRef;
|
|
935
|
+
if (options == null ? void 0 : options.startRef) {
|
|
936
|
+
startRef = options.startRef;
|
|
937
|
+
} else {
|
|
938
|
+
const nearestPoly = this.findNearestPoly(position, {
|
|
939
|
+
filter,
|
|
940
|
+
halfExtents
|
|
941
|
+
});
|
|
942
|
+
if (!nearestPoly.success) {
|
|
943
|
+
return {
|
|
944
|
+
success: false,
|
|
945
|
+
status: nearestPoly.status,
|
|
946
|
+
randomPolyRef: 0,
|
|
947
|
+
randomPoint: {
|
|
948
|
+
x: 0,
|
|
949
|
+
y: 0,
|
|
950
|
+
z: 0
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
startRef = nearestPoly.nearestRef;
|
|
955
|
+
}
|
|
956
|
+
const randomPolyRefRaw = new Raw.UnsignedIntRef();
|
|
957
|
+
const randomPointRaw = new Raw.Vec3();
|
|
958
|
+
const status = this.raw.findRandomPointAroundCircle(startRef, vec3.toArray(position), radius, filter.raw, randomPolyRefRaw, randomPointRaw);
|
|
959
|
+
const randomPolyRef = randomPolyRefRaw.value;
|
|
960
|
+
Raw.destroy(randomPolyRefRaw);
|
|
961
|
+
const randomPoint = vec3.fromRaw(randomPointRaw);
|
|
962
|
+
Raw.destroy(randomPointRaw);
|
|
963
|
+
return {
|
|
964
|
+
success: statusSucceed(status),
|
|
965
|
+
status,
|
|
966
|
+
randomPolyRef,
|
|
967
|
+
randomPoint
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Moves from the start to the end position constrained to the navigation mesh.
|
|
972
|
+
*
|
|
973
|
+
* @param startRef the reference id of the start polygon.
|
|
974
|
+
* @param startPosition a position of the mover within the start polygon.
|
|
975
|
+
* @param endPosition the desired end position of the mover.
|
|
976
|
+
*
|
|
977
|
+
* @returns The result of the move along surface operation.
|
|
978
|
+
*/
|
|
979
|
+
moveAlongSurface(startRef, startPosition, endPosition, options) {
|
|
980
|
+
var _a;
|
|
981
|
+
const maxVisitedSize = (options == null ? void 0 : options.maxVisitedSize) ?? 256;
|
|
982
|
+
const resultPositionRaw = new Raw.Vec3();
|
|
983
|
+
const visitedArray = new UnsignedIntArray();
|
|
984
|
+
const filter = ((_a = options == null ? void 0 : options.filter) == null ? void 0 : _a.raw) ?? this.defaultFilter.raw;
|
|
985
|
+
const status = this.raw.moveAlongSurface(startRef, vec3.toArray(startPosition), vec3.toArray(endPosition), filter, resultPositionRaw, visitedArray.raw, maxVisitedSize);
|
|
986
|
+
const resultPosition = vec3.fromRaw(resultPositionRaw);
|
|
987
|
+
Raw.destroy(resultPositionRaw);
|
|
988
|
+
const visited = [...visitedArray.getHeapView()];
|
|
989
|
+
visitedArray.destroy();
|
|
990
|
+
return {
|
|
991
|
+
success: statusSucceed(status),
|
|
992
|
+
status,
|
|
993
|
+
resultPosition,
|
|
994
|
+
visited
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Returns a random point on the navmesh.
|
|
999
|
+
* @param options additional options
|
|
1000
|
+
* @returns a random point on the navmesh
|
|
1001
|
+
*/
|
|
1002
|
+
findRandomPoint(options) {
|
|
1003
|
+
var _a;
|
|
1004
|
+
const randomPolyRefRaw = new Raw.UnsignedIntRef();
|
|
1005
|
+
const randomPointRaw = new Raw.Vec3();
|
|
1006
|
+
const status = this.raw.findRandomPoint(((_a = options == null ? void 0 : options.filter) == null ? void 0 : _a.raw) ?? this.defaultFilter.raw, randomPolyRefRaw, randomPointRaw);
|
|
1007
|
+
const randomPolyRef = randomPolyRefRaw.value;
|
|
1008
|
+
Raw.destroy(randomPolyRefRaw);
|
|
1009
|
+
const randomPoint = vec3.fromRaw(randomPointRaw);
|
|
1010
|
+
Raw.destroy(randomPointRaw);
|
|
1011
|
+
return {
|
|
1012
|
+
success: statusSucceed(status),
|
|
1013
|
+
status,
|
|
1014
|
+
randomPolyRef,
|
|
1015
|
+
randomPoint
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Gets the height of the polygon at the provided position using the height detail.
|
|
1020
|
+
*
|
|
1021
|
+
* @param polyRef the reference id of the polygon.
|
|
1022
|
+
* @param position a position within the xz-bounds of the polygon.
|
|
1023
|
+
*/
|
|
1024
|
+
getPolyHeight(polyRef, position) {
|
|
1025
|
+
const floatRef = new Raw.FloatRef();
|
|
1026
|
+
const status = this.raw.getPolyHeight(polyRef, vec3.toArray(position), floatRef);
|
|
1027
|
+
const height = floatRef.value;
|
|
1028
|
+
Raw.destroy(floatRef);
|
|
1029
|
+
return {
|
|
1030
|
+
success: statusSucceed(status),
|
|
1031
|
+
status,
|
|
1032
|
+
height
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Finds a straight path from the start position to the end position.
|
|
1037
|
+
*
|
|
1038
|
+
* @param start the start position
|
|
1039
|
+
* @param end the end position
|
|
1040
|
+
* @param options additional options
|
|
1041
|
+
*
|
|
1042
|
+
* @returns an array of Vector3 positions that make up the path, or an empty array if no path was found.
|
|
1043
|
+
*/
|
|
1044
|
+
computePath(start, end, options) {
|
|
1045
|
+
const filter = (options == null ? void 0 : options.filter) ?? this.defaultFilter;
|
|
1046
|
+
const halfExtents = (options == null ? void 0 : options.halfExtents) ?? this.defaultQueryHalfExtents;
|
|
1047
|
+
const startNearestPolyResult = this.findNearestPoly(start, {
|
|
1048
|
+
filter,
|
|
1049
|
+
halfExtents
|
|
1050
|
+
});
|
|
1051
|
+
if (!startNearestPolyResult.success) {
|
|
1052
|
+
return {
|
|
1053
|
+
success: false,
|
|
1054
|
+
error: {
|
|
1055
|
+
name: "findNearestPoly for start position failed",
|
|
1056
|
+
status: startNearestPolyResult.status
|
|
1057
|
+
},
|
|
1058
|
+
path: []
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
const endNearestPolyResult = this.findNearestPoly(end, {
|
|
1062
|
+
filter,
|
|
1063
|
+
halfExtents
|
|
1064
|
+
});
|
|
1065
|
+
if (!endNearestPolyResult.success) {
|
|
1066
|
+
return {
|
|
1067
|
+
success: false,
|
|
1068
|
+
error: {
|
|
1069
|
+
name: "findNearestPoly for end position failed",
|
|
1070
|
+
status: endNearestPolyResult.status
|
|
1071
|
+
},
|
|
1072
|
+
path: []
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
const startRef = startNearestPolyResult.nearestRef;
|
|
1076
|
+
const endRef = endNearestPolyResult.nearestRef;
|
|
1077
|
+
const maxPathPolys = (options == null ? void 0 : options.maxPathPolys) ?? 256;
|
|
1078
|
+
const findPathResult = this.findPath(startRef, endRef, start, end, {
|
|
1079
|
+
filter,
|
|
1080
|
+
maxPathPolys
|
|
1081
|
+
});
|
|
1082
|
+
if (!findPathResult.success) {
|
|
1083
|
+
return {
|
|
1084
|
+
success: false,
|
|
1085
|
+
error: {
|
|
1086
|
+
name: "findPath unsuccessful",
|
|
1087
|
+
status: findPathResult.status
|
|
1088
|
+
},
|
|
1089
|
+
path: []
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
if (findPathResult.polys.size <= 0) {
|
|
1093
|
+
return {
|
|
1094
|
+
success: false,
|
|
1095
|
+
error: {
|
|
1096
|
+
name: "no polygon path found"
|
|
1097
|
+
},
|
|
1098
|
+
path: []
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
const lastPoly = findPathResult.polys.get(findPathResult.polys.size - 1);
|
|
1102
|
+
let closestEnd = {
|
|
1103
|
+
x: end.x,
|
|
1104
|
+
y: end.y,
|
|
1105
|
+
z: end.z
|
|
1106
|
+
};
|
|
1107
|
+
if (lastPoly !== endRef) {
|
|
1108
|
+
const lastPolyClosestPointResult = this.closestPointOnPoly(lastPoly, end);
|
|
1109
|
+
if (!lastPolyClosestPointResult.success) {
|
|
1110
|
+
return {
|
|
1111
|
+
success: false,
|
|
1112
|
+
error: {
|
|
1113
|
+
name: "no closest point on last polygon found",
|
|
1114
|
+
status: lastPolyClosestPointResult.status
|
|
1115
|
+
},
|
|
1116
|
+
path: []
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
closestEnd = lastPolyClosestPointResult.closestPoint;
|
|
1120
|
+
}
|
|
1121
|
+
const maxStraightPathPoints = options == null ? void 0 : options.maxStraightPathPoints;
|
|
1122
|
+
const findStraightPathResult = this.findStraightPath(start, closestEnd, findPathResult.polys, {
|
|
1123
|
+
maxStraightPathPoints
|
|
1124
|
+
});
|
|
1125
|
+
if (!findStraightPathResult.success) {
|
|
1126
|
+
return {
|
|
1127
|
+
success: false,
|
|
1128
|
+
error: {
|
|
1129
|
+
name: "findStraightPath unsuccessful",
|
|
1130
|
+
status: findStraightPathResult.status
|
|
1131
|
+
},
|
|
1132
|
+
path: []
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
const {
|
|
1136
|
+
straightPath,
|
|
1137
|
+
straightPathCount
|
|
1138
|
+
} = findStraightPathResult;
|
|
1139
|
+
const points = [];
|
|
1140
|
+
for (let i = 0; i < straightPathCount; i++) {
|
|
1141
|
+
points.push({
|
|
1142
|
+
x: straightPath.get(i * 3),
|
|
1143
|
+
y: straightPath.get(i * 3 + 1),
|
|
1144
|
+
z: straightPath.get(i * 3 + 2)
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
findPathResult.polys.destroy();
|
|
1148
|
+
findStraightPathResult.straightPath.destroy();
|
|
1149
|
+
findStraightPathResult.straightPathFlags.destroy();
|
|
1150
|
+
findStraightPathResult.straightPathRefs.destroy();
|
|
1151
|
+
return {
|
|
1152
|
+
success: true,
|
|
1153
|
+
path: points
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Finds a path from the start polygon to the end polygon.
|
|
1158
|
+
* @param startRef the reference id of the start polygon.
|
|
1159
|
+
* @param endRef the reference id of the end polygon.
|
|
1160
|
+
* @param startPosition position within the start polygon.
|
|
1161
|
+
* @param endPosition position within the end polygon.
|
|
1162
|
+
* @param options additional options
|
|
1163
|
+
* @returns
|
|
1164
|
+
*
|
|
1165
|
+
* The `polys` array returned must be freed after use.
|
|
1166
|
+
*
|
|
1167
|
+
* ```ts
|
|
1168
|
+
* findPathResult.polys.destroy();
|
|
1169
|
+
* ```
|
|
1170
|
+
*/
|
|
1171
|
+
findPath(startRef, endRef, startPosition, endPosition, options) {
|
|
1172
|
+
const filter = (options == null ? void 0 : options.filter) ?? this.defaultFilter;
|
|
1173
|
+
const maxPathPolys = (options == null ? void 0 : options.maxPathPolys) ?? 256;
|
|
1174
|
+
const polysArray = new UnsignedIntArray();
|
|
1175
|
+
polysArray.resize(maxPathPolys);
|
|
1176
|
+
const status = this.raw.findPath(startRef, endRef, vec3.toArray(startPosition), vec3.toArray(endPosition), filter.raw, polysArray.raw, maxPathPolys);
|
|
1177
|
+
return {
|
|
1178
|
+
success: statusSucceed(status),
|
|
1179
|
+
status,
|
|
1180
|
+
polys: polysArray
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Finds the straight path from the start to the end position within the polygon corridor.
|
|
1185
|
+
*
|
|
1186
|
+
* This method peforms what is often called 'string pulling'.
|
|
1187
|
+
*
|
|
1188
|
+
* The start position is clamped to the first polygon in the path, and the
|
|
1189
|
+
* end position is clamped to the last. So the start and end positions should
|
|
1190
|
+
* normally be within or very near the first and last polygons respectively.
|
|
1191
|
+
*
|
|
1192
|
+
* The returned polygon references represent the reference id of the polygon
|
|
1193
|
+
* that is entered at the associated path position. The reference id associated
|
|
1194
|
+
* with the end point will always be zero. This allows, for example, matching
|
|
1195
|
+
* off-mesh link points to their representative polygons.
|
|
1196
|
+
*
|
|
1197
|
+
* If the provided result arrays are too small for the entire result set,
|
|
1198
|
+
* they will be filled as far as possible from the start toward the end
|
|
1199
|
+
* position.
|
|
1200
|
+
*
|
|
1201
|
+
* @param start path start position
|
|
1202
|
+
* @param end path end position
|
|
1203
|
+
* @param path an array of polygon references that represent the path corridor
|
|
1204
|
+
* @param options additional options
|
|
1205
|
+
* @returns the straight path result
|
|
1206
|
+
*
|
|
1207
|
+
* The straightPath, straightPathFlags, and straightPathRefs arrays returned must be freed after use.
|
|
1208
|
+
*
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* findStraightPathResult.straightPath.destroy();
|
|
1211
|
+
* findStraightPathResult.straightPathFlags.destroy();
|
|
1212
|
+
* findStraightPathResult.straightPathRefs.destroy();
|
|
1213
|
+
* ```
|
|
1214
|
+
*/
|
|
1215
|
+
findStraightPath(start, end, path, options) {
|
|
1216
|
+
const maxStraightPathPoints = (options == null ? void 0 : options.maxStraightPathPoints) ?? 256;
|
|
1217
|
+
const straightPathOptions = (options == null ? void 0 : options.straightPathOptions) ?? 0;
|
|
1218
|
+
let pathPolys;
|
|
1219
|
+
if (Array.isArray(path)) {
|
|
1220
|
+
pathPolys = new UnsignedIntArray();
|
|
1221
|
+
pathPolys.copy(path);
|
|
1222
|
+
} else {
|
|
1223
|
+
pathPolys = path;
|
|
1224
|
+
}
|
|
1225
|
+
const straightPath = new FloatArray();
|
|
1226
|
+
straightPath.resize(maxStraightPathPoints * 3);
|
|
1227
|
+
const straightPathFlags = new UnsignedCharArray();
|
|
1228
|
+
straightPathFlags.resize(maxStraightPathPoints);
|
|
1229
|
+
const straightPathRefs = new UnsignedIntArray();
|
|
1230
|
+
straightPathRefs.resize(maxStraightPathPoints);
|
|
1231
|
+
const straightPathCountRaw = new Raw.IntRef();
|
|
1232
|
+
const status = this.raw.findStraightPath(vec3.toArray(start), vec3.toArray(end), pathPolys.raw, straightPath.raw, straightPathFlags.raw, straightPathRefs.raw, straightPathCountRaw, maxStraightPathPoints, straightPathOptions);
|
|
1233
|
+
const straightPathCount = straightPathCountRaw.value;
|
|
1234
|
+
Raw.destroy(straightPathCountRaw);
|
|
1235
|
+
if (Array.isArray(path)) {
|
|
1236
|
+
pathPolys.destroy();
|
|
1237
|
+
}
|
|
1238
|
+
return {
|
|
1239
|
+
success: statusSucceed(status),
|
|
1240
|
+
status,
|
|
1241
|
+
straightPath,
|
|
1242
|
+
straightPathFlags,
|
|
1243
|
+
straightPathRefs,
|
|
1244
|
+
straightPathCount
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Casts a 'walkability' ray along the surface of the navigation mesh from the start position toward the end position.
|
|
1249
|
+
*
|
|
1250
|
+
* This method is meant to be used for quick, short distance checks.
|
|
1251
|
+
*
|
|
1252
|
+
* If the path array is too small to hold the result, it will be filled as far as possible from the start postion toward the end position.
|
|
1253
|
+
*
|
|
1254
|
+
* The raycast ignores the y-value of the end position. (2D check.) This places significant limits on how it can be used.
|
|
1255
|
+
*
|
|
1256
|
+
* <b>Using the Hit Parameter (t)</b>
|
|
1257
|
+
*
|
|
1258
|
+
* If the hit parameter is a very high value, then the ray has hit
|
|
1259
|
+
* the end position. In this case the path represents a valid corridor to the
|
|
1260
|
+
* end position and the value of hitNormal is undefined.
|
|
1261
|
+
*
|
|
1262
|
+
* If the hit parameter is zero, then the start position is on the wall that
|
|
1263
|
+
* was hit and the value of hitNormal is undefined.
|
|
1264
|
+
*
|
|
1265
|
+
* If 0 < t < 1.0 then the following applies:
|
|
1266
|
+
*
|
|
1267
|
+
* ```
|
|
1268
|
+
* distanceToHitBorder = distanceToEndPosition * t
|
|
1269
|
+
* hitPoint = startPos + (endPos - startPos) * t
|
|
1270
|
+
* ```
|
|
1271
|
+
*
|
|
1272
|
+
* <b>Use Case Restriction</b>
|
|
1273
|
+
*
|
|
1274
|
+
* Consider a scene where there is a main floor with a second floor balcony that hangs over the main floor.
|
|
1275
|
+
* So the first floor mesh extends below the balcony mesh.
|
|
1276
|
+
* The start position is somewhere on the first floor.
|
|
1277
|
+
* The end position is on the balcony.
|
|
1278
|
+
*
|
|
1279
|
+
* The raycast will search toward the end position along the first floor mesh.
|
|
1280
|
+
* If it reaches the end position's xz-coordinates it will indicate FLT_MAX,(no wall hit), meaning it reached the end position.
|
|
1281
|
+
* This is one example of why this method is meant for short distance checks.
|
|
1282
|
+
*
|
|
1283
|
+
* @param startRef the reference id of the start polygon.
|
|
1284
|
+
* @param startPosition a position within the start polygon representing the start of the ray
|
|
1285
|
+
* @param endPosition the position to cast the ray toward.
|
|
1286
|
+
* @param options additional options
|
|
1287
|
+
*/
|
|
1288
|
+
raycast(startRef, startPosition, endPosition, options) {
|
|
1289
|
+
var _a;
|
|
1290
|
+
const raycastHit = new Raw.Module.dtRaycastHit();
|
|
1291
|
+
const raycastOptions = (options == null ? void 0 : options.raycastOptions) ?? 0;
|
|
1292
|
+
const prevRef = (options == null ? void 0 : options.prevRef) ?? 0;
|
|
1293
|
+
const queryFilter = ((_a = options == null ? void 0 : options.filter) == null ? void 0 : _a.raw) ?? this.defaultFilter.raw;
|
|
1294
|
+
const status = this.raw.raycast(startRef, vec3.toArray(startPosition), vec3.toArray(endPosition), queryFilter, raycastOptions, raycastHit, prevRef);
|
|
1295
|
+
const result = {
|
|
1296
|
+
success: statusSucceed(status),
|
|
1297
|
+
status,
|
|
1298
|
+
t: raycastHit.t,
|
|
1299
|
+
hitNormal: vec3.fromArray(array((i) => raycastHit.get_hitNormal(i), 3)),
|
|
1300
|
+
hitEdgeIndex: raycastHit.hitEdgeIndex,
|
|
1301
|
+
path: array((i) => raycastHit.get_path(i), raycastHit.pathCount),
|
|
1302
|
+
maxPath: raycastHit.maxPath,
|
|
1303
|
+
pathCost: raycastHit.pathCost
|
|
1304
|
+
};
|
|
1305
|
+
Raw.destroy(raycastHit);
|
|
1306
|
+
return result;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Destroys the NavMeshQuery instance
|
|
1310
|
+
*/
|
|
1311
|
+
destroy() {
|
|
1312
|
+
this.raw.destroy();
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
const crowdAgentParamsDefaults = {
|
|
1316
|
+
radius: 0.5,
|
|
1317
|
+
height: 1,
|
|
1318
|
+
maxAcceleration: 20,
|
|
1319
|
+
maxSpeed: 6,
|
|
1320
|
+
collisionQueryRange: 2.5,
|
|
1321
|
+
pathOptimizationRange: 0,
|
|
1322
|
+
separationWeight: 0,
|
|
1323
|
+
updateFlags: 7,
|
|
1324
|
+
obstacleAvoidanceType: 0,
|
|
1325
|
+
queryFilterType: 0,
|
|
1326
|
+
userData: 0
|
|
1327
|
+
};
|
|
1328
|
+
class CrowdAgent {
|
|
1329
|
+
constructor(crowd, agentIndex) {
|
|
1330
|
+
/**
|
|
1331
|
+
* The interpolated position of the agent.
|
|
1332
|
+
*
|
|
1333
|
+
* Use this if stepping the crowd with interpolation.
|
|
1334
|
+
* This will not be updated if stepping the crowd without interpolation.
|
|
1335
|
+
*/
|
|
1336
|
+
__publicField(this, "interpolatedPosition", {
|
|
1337
|
+
x: 0,
|
|
1338
|
+
y: 0,
|
|
1339
|
+
z: 0
|
|
1340
|
+
});
|
|
1341
|
+
this.crowd = crowd;
|
|
1342
|
+
this.agentIndex = agentIndex;
|
|
1343
|
+
this.raw = crowd.raw.getEditableAgent(agentIndex);
|
|
1344
|
+
this.interpolatedPosition = this.position();
|
|
1345
|
+
}
|
|
1346
|
+
get radius() {
|
|
1347
|
+
return this.raw.params.radius;
|
|
1348
|
+
}
|
|
1349
|
+
set radius(value) {
|
|
1350
|
+
this.raw.params.radius = value;
|
|
1351
|
+
}
|
|
1352
|
+
get height() {
|
|
1353
|
+
return this.raw.params.height;
|
|
1354
|
+
}
|
|
1355
|
+
set height(value) {
|
|
1356
|
+
this.raw.params.height = value;
|
|
1357
|
+
}
|
|
1358
|
+
get maxAcceleration() {
|
|
1359
|
+
return this.raw.params.maxAcceleration;
|
|
1360
|
+
}
|
|
1361
|
+
set maxAcceleration(value) {
|
|
1362
|
+
this.raw.params.maxAcceleration = value;
|
|
1363
|
+
}
|
|
1364
|
+
get maxSpeed() {
|
|
1365
|
+
return this.raw.params.maxSpeed;
|
|
1366
|
+
}
|
|
1367
|
+
set maxSpeed(value) {
|
|
1368
|
+
this.raw.params.maxSpeed = value;
|
|
1369
|
+
}
|
|
1370
|
+
get collisionQueryRange() {
|
|
1371
|
+
return this.raw.params.collisionQueryRange;
|
|
1372
|
+
}
|
|
1373
|
+
set collisionQueryRange(value) {
|
|
1374
|
+
this.raw.params.collisionQueryRange = value;
|
|
1375
|
+
}
|
|
1376
|
+
get pathOptimizationRange() {
|
|
1377
|
+
return this.raw.params.pathOptimizationRange;
|
|
1378
|
+
}
|
|
1379
|
+
set pathOptimizationRange(value) {
|
|
1380
|
+
this.raw.params.pathOptimizationRange = value;
|
|
1381
|
+
}
|
|
1382
|
+
get separationWeight() {
|
|
1383
|
+
return this.raw.params.separationWeight;
|
|
1384
|
+
}
|
|
1385
|
+
set separationWeight(value) {
|
|
1386
|
+
this.raw.params.separationWeight = value;
|
|
1387
|
+
}
|
|
1388
|
+
get updateFlags() {
|
|
1389
|
+
return this.raw.params.updateFlags;
|
|
1390
|
+
}
|
|
1391
|
+
set updateFlags(value) {
|
|
1392
|
+
this.raw.params.updateFlags = value;
|
|
1393
|
+
}
|
|
1394
|
+
get obstacleAvoidanceType() {
|
|
1395
|
+
return this.raw.params.obstacleAvoidanceType;
|
|
1396
|
+
}
|
|
1397
|
+
set obstacleAvoidanceType(value) {
|
|
1398
|
+
this.raw.params.obstacleAvoidanceType = value;
|
|
1399
|
+
}
|
|
1400
|
+
get queryFilterType() {
|
|
1401
|
+
return this.raw.params.queryFilterType;
|
|
1402
|
+
}
|
|
1403
|
+
set queryFilterType(value) {
|
|
1404
|
+
this.raw.params.queryFilterType = value;
|
|
1405
|
+
}
|
|
1406
|
+
get userData() {
|
|
1407
|
+
return this.raw.params.userData;
|
|
1408
|
+
}
|
|
1409
|
+
set userData(value) {
|
|
1410
|
+
this.raw.params.userData = value;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Updates the agent's target.
|
|
1414
|
+
* @param position The new target position.
|
|
1415
|
+
* @returns True if the request was successful.
|
|
1416
|
+
*/
|
|
1417
|
+
requestMoveTarget(position) {
|
|
1418
|
+
const {
|
|
1419
|
+
nearestPoint,
|
|
1420
|
+
nearestRef
|
|
1421
|
+
} = this.crowd.navMeshQuery.findNearestPoly(position, {
|
|
1422
|
+
halfExtents: this.crowd.navMeshQuery.defaultQueryHalfExtents,
|
|
1423
|
+
filter: this.crowd.navMeshQuery.defaultFilter
|
|
1424
|
+
});
|
|
1425
|
+
return this.crowd.raw.requestMoveTarget(this.agentIndex, nearestRef, vec3.toArray(nearestPoint));
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Submits a new move request for the specified agent.
|
|
1429
|
+
* @param velocity The desired velocity of the agent.
|
|
1430
|
+
* @returns True if the request was successful.
|
|
1431
|
+
*/
|
|
1432
|
+
requestMoveVelocity(velocity) {
|
|
1433
|
+
return this.crowd.raw.requestMoveVelocity(this.agentIndex, vec3.toArray(velocity));
|
|
1434
|
+
}
|
|
1435
|
+
/**
|
|
1436
|
+
* Resets the current move request for the specified agent.
|
|
1437
|
+
*/
|
|
1438
|
+
resetMoveTarget() {
|
|
1439
|
+
this.crowd.raw.resetMoveTarget(this.agentIndex);
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Teleports the agent to the specified position.
|
|
1443
|
+
* @param position
|
|
1444
|
+
*/
|
|
1445
|
+
teleport(position) {
|
|
1446
|
+
Raw.CrowdUtils.agentTeleport(this.crowd.raw, this.agentIndex, vec3.toArray(position), vec3.toArray(this.crowd.navMeshQuery.defaultQueryHalfExtents), this.crowd.navMeshQuery.defaultFilter.raw);
|
|
1447
|
+
vec3.copy(position, this.interpolatedPosition);
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* The position of the agent.
|
|
1451
|
+
* @returns
|
|
1452
|
+
*/
|
|
1453
|
+
position() {
|
|
1454
|
+
return {
|
|
1455
|
+
x: this.raw.get_npos(0),
|
|
1456
|
+
y: this.raw.get_npos(1),
|
|
1457
|
+
z: this.raw.get_npos(2)
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* The actual velocity of the agent. The change from velocityDesiredObstacleAdjusted -> velocity is constrained by max acceleration.
|
|
1462
|
+
*/
|
|
1463
|
+
velocity() {
|
|
1464
|
+
return {
|
|
1465
|
+
x: this.raw.get_vel(0),
|
|
1466
|
+
y: this.raw.get_vel(1),
|
|
1467
|
+
z: this.raw.get_vel(2)
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* The desired velocity of the agent. Based on the current path, calculated from scratch each frame.
|
|
1472
|
+
*/
|
|
1473
|
+
desiredVelocity() {
|
|
1474
|
+
return {
|
|
1475
|
+
x: this.raw.get_dvel(0),
|
|
1476
|
+
y: this.raw.get_dvel(1),
|
|
1477
|
+
z: this.raw.get_dvel(2)
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* The desired velocity adjusted by obstacle avoidance, calculated from scratch each frame.
|
|
1482
|
+
*/
|
|
1483
|
+
desiredVelocityObstacleAdjusted() {
|
|
1484
|
+
return {
|
|
1485
|
+
x: this.raw.get_nvel(0),
|
|
1486
|
+
y: this.raw.get_nvel(1),
|
|
1487
|
+
z: this.raw.get_nvel(2)
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Returns the state of the agent.
|
|
1492
|
+
*
|
|
1493
|
+
* 0 = DT_CROWDAGENT_STATE_INVALID
|
|
1494
|
+
* 1 = DT_CROWDAGENT_STATE_WALKING
|
|
1495
|
+
* 2 = DT_CROWDAGENT_STATE_OFFMESH
|
|
1496
|
+
*/
|
|
1497
|
+
state() {
|
|
1498
|
+
return this.raw.state;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Returns the next target position on the path to the target
|
|
1502
|
+
* @returns
|
|
1503
|
+
*/
|
|
1504
|
+
target() {
|
|
1505
|
+
return {
|
|
1506
|
+
x: this.raw.get_targetPos(0),
|
|
1507
|
+
y: this.raw.get_targetPos(1),
|
|
1508
|
+
z: this.raw.get_targetPos(2)
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Returns the next target position on the path to the target
|
|
1513
|
+
* @returns
|
|
1514
|
+
*/
|
|
1515
|
+
nextTargetInPath() {
|
|
1516
|
+
return {
|
|
1517
|
+
x: this.raw.get_cornerVerts(0),
|
|
1518
|
+
y: this.raw.get_cornerVerts(1),
|
|
1519
|
+
z: this.raw.get_cornerVerts(2)
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Returns the local path corridor corners for the agent
|
|
1524
|
+
* @returns
|
|
1525
|
+
*/
|
|
1526
|
+
corners() {
|
|
1527
|
+
const points = [];
|
|
1528
|
+
for (let i = 0; i < this.raw.ncorners; i++) {
|
|
1529
|
+
points.push({
|
|
1530
|
+
x: this.raw.get_cornerVerts(i * 3),
|
|
1531
|
+
y: this.raw.get_cornerVerts(i * 3 + 1),
|
|
1532
|
+
z: this.raw.get_cornerVerts(i * 3 + 2)
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
return points;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Returns the agents parameters.
|
|
1539
|
+
* @returns
|
|
1540
|
+
*/
|
|
1541
|
+
parameters() {
|
|
1542
|
+
const {
|
|
1543
|
+
params
|
|
1544
|
+
} = this.raw;
|
|
1545
|
+
return {
|
|
1546
|
+
radius: params.radius,
|
|
1547
|
+
height: params.height,
|
|
1548
|
+
maxAcceleration: params.maxAcceleration,
|
|
1549
|
+
maxSpeed: params.maxSpeed,
|
|
1550
|
+
collisionQueryRange: params.collisionQueryRange,
|
|
1551
|
+
pathOptimizationRange: params.pathOptimizationRange,
|
|
1552
|
+
separationWeight: params.separationWeight,
|
|
1553
|
+
updateFlags: params.updateFlags,
|
|
1554
|
+
obstacleAvoidanceType: params.obstacleAvoidanceType,
|
|
1555
|
+
queryFilterType: params.queryFilterType,
|
|
1556
|
+
userData: params.userData
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Updates the agent's parameters.
|
|
1561
|
+
* Any parameters not specified in the crowdAgentParams object will be unchanged.
|
|
1562
|
+
* @param crowdAgentParams agent parameters to update.
|
|
1563
|
+
*/
|
|
1564
|
+
updateParameters(crowdAgentParams) {
|
|
1565
|
+
const params = {
|
|
1566
|
+
...this.parameters(),
|
|
1567
|
+
...crowdAgentParams
|
|
1568
|
+
};
|
|
1569
|
+
this.setParameters(params);
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Sets the agent's parameters.
|
|
1573
|
+
* Any parameters not specified in the crowdAgentParams object will be set to their default values.
|
|
1574
|
+
* @param crowdAgentParams agent parameters
|
|
1575
|
+
*/
|
|
1576
|
+
setParameters(crowdAgentParams) {
|
|
1577
|
+
const params = {
|
|
1578
|
+
...crowdAgentParamsDefaults,
|
|
1579
|
+
...crowdAgentParams
|
|
1580
|
+
};
|
|
1581
|
+
const dtCrowdAgentParams = new Raw.Module.dtCrowdAgentParams();
|
|
1582
|
+
dtCrowdAgentParams.radius = params.radius;
|
|
1583
|
+
dtCrowdAgentParams.height = params.height;
|
|
1584
|
+
dtCrowdAgentParams.maxAcceleration = params.maxAcceleration;
|
|
1585
|
+
dtCrowdAgentParams.maxSpeed = params.maxSpeed;
|
|
1586
|
+
dtCrowdAgentParams.collisionQueryRange = params.collisionQueryRange;
|
|
1587
|
+
dtCrowdAgentParams.pathOptimizationRange = params.pathOptimizationRange;
|
|
1588
|
+
dtCrowdAgentParams.separationWeight = params.separationWeight;
|
|
1589
|
+
dtCrowdAgentParams.updateFlags = params.updateFlags;
|
|
1590
|
+
dtCrowdAgentParams.obstacleAvoidanceType = params.obstacleAvoidanceType;
|
|
1591
|
+
dtCrowdAgentParams.queryFilterType = params.queryFilterType;
|
|
1592
|
+
dtCrowdAgentParams.userData = params.userData;
|
|
1593
|
+
this.crowd.raw.updateAgentParameters(this.agentIndex, dtCrowdAgentParams);
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Returns whether the agent is over an off-mesh connection.
|
|
1597
|
+
* @returns
|
|
1598
|
+
*/
|
|
1599
|
+
overOffMeshConnection() {
|
|
1600
|
+
return Raw.CrowdUtils.overOffMeshConnection(this.crowd.raw, this.agentIndex);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
class Crowd {
|
|
1604
|
+
/**
|
|
1605
|
+
*
|
|
1606
|
+
* @param navMesh the navmesh the crowd will use for planning
|
|
1607
|
+
* @param param1 the crowd parameters
|
|
1608
|
+
*
|
|
1609
|
+
* @example
|
|
1610
|
+
* ```ts
|
|
1611
|
+
* const crowd = new Crowd(navMesh, {
|
|
1612
|
+
* maxAgents: 100,
|
|
1613
|
+
* maxAgentRadius: 1,
|
|
1614
|
+
* });
|
|
1615
|
+
* ```
|
|
1616
|
+
*/
|
|
1617
|
+
constructor(navMesh, {
|
|
1618
|
+
maxAgents,
|
|
1619
|
+
maxAgentRadius
|
|
1620
|
+
}) {
|
|
1621
|
+
/**
|
|
1622
|
+
* The agents in the crowd.
|
|
1623
|
+
*/
|
|
1624
|
+
__publicField(this, "agents", {});
|
|
1625
|
+
/**
|
|
1626
|
+
* The NavMesh the crowd is interacting with.
|
|
1627
|
+
*/
|
|
1628
|
+
/**
|
|
1629
|
+
* The NavMeshQuery used to find nearest polys for commands
|
|
1630
|
+
*/
|
|
1631
|
+
/**
|
|
1632
|
+
* Accumulator for fixed updates with interpolation
|
|
1633
|
+
*/
|
|
1634
|
+
__publicField(this, "accumulator", 0);
|
|
1635
|
+
this.navMesh = navMesh;
|
|
1636
|
+
this.raw = Raw.Detour.allocCrowd();
|
|
1637
|
+
this.raw.init(maxAgents, maxAgentRadius, navMesh.raw.getNavMesh());
|
|
1638
|
+
this.navMeshQuery = new NavMeshQuery(new Raw.Module.NavMeshQuery(this.raw.getNavMeshQuery()));
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Steps the crowd forward in time with a fixed time step.
|
|
1642
|
+
*
|
|
1643
|
+
* There are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take.
|
|
1644
|
+
*
|
|
1645
|
+
* @param dt The fixed time step size to use.
|
|
1646
|
+
* @param timeSinceLastCalled The time elapsed since the function was last called.
|
|
1647
|
+
* @param maxSubSteps Maximum number of fixed steps to take per function call.
|
|
1648
|
+
*
|
|
1649
|
+
* @example fixed time stepping
|
|
1650
|
+
* ```ts
|
|
1651
|
+
* const deltaTime = 1 / 60;
|
|
1652
|
+
* crowd.update(deltaTime);
|
|
1653
|
+
* ```
|
|
1654
|
+
*
|
|
1655
|
+
* @example variable time stepping
|
|
1656
|
+
* ```ts
|
|
1657
|
+
* crowd.update(timeSinceLastUpdate);
|
|
1658
|
+
* ```
|
|
1659
|
+
*
|
|
1660
|
+
* @example fixed time stepping with interpolation
|
|
1661
|
+
* ```ts
|
|
1662
|
+
* const deltaTime = 1 / 60;
|
|
1663
|
+
* const maxSubSteps = 10;
|
|
1664
|
+
* crowd.update(deltaTime, timeSinceLastUpdate, maxSubSteps);
|
|
1665
|
+
*
|
|
1666
|
+
* console.log(agent.interpolatedPosition);
|
|
1667
|
+
* ```
|
|
1668
|
+
*/
|
|
1669
|
+
update(dt, timeSinceLastCalled, maxSubSteps = 10) {
|
|
1670
|
+
if (timeSinceLastCalled === void 0) {
|
|
1671
|
+
this.raw.update(dt, void 0);
|
|
1672
|
+
} else {
|
|
1673
|
+
this.accumulator += timeSinceLastCalled;
|
|
1674
|
+
let substeps = 0;
|
|
1675
|
+
while (this.accumulator >= dt && substeps < maxSubSteps) {
|
|
1676
|
+
this.raw.update(dt, void 0);
|
|
1677
|
+
this.accumulator -= dt;
|
|
1678
|
+
substeps++;
|
|
1679
|
+
}
|
|
1680
|
+
const t = this.accumulator % dt / dt;
|
|
1681
|
+
const agents = this.getAgents();
|
|
1682
|
+
for (const agent of agents) {
|
|
1683
|
+
vec3.lerp(agent.interpolatedPosition, agent.position(), t, agent.interpolatedPosition);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Adds a new agent to the crowd.
|
|
1689
|
+
*/
|
|
1690
|
+
addAgent(position, crowdAgentParams) {
|
|
1691
|
+
const params = {
|
|
1692
|
+
...crowdAgentParamsDefaults,
|
|
1693
|
+
...crowdAgentParams
|
|
1694
|
+
};
|
|
1695
|
+
const dtCrowdAgentParams = new Raw.Module.dtCrowdAgentParams();
|
|
1696
|
+
dtCrowdAgentParams.radius = params.radius;
|
|
1697
|
+
dtCrowdAgentParams.height = params.height;
|
|
1698
|
+
dtCrowdAgentParams.maxAcceleration = params.maxAcceleration;
|
|
1699
|
+
dtCrowdAgentParams.maxSpeed = params.maxSpeed;
|
|
1700
|
+
dtCrowdAgentParams.collisionQueryRange = params.collisionQueryRange;
|
|
1701
|
+
dtCrowdAgentParams.pathOptimizationRange = params.pathOptimizationRange;
|
|
1702
|
+
dtCrowdAgentParams.separationWeight = params.separationWeight;
|
|
1703
|
+
dtCrowdAgentParams.updateFlags = params.updateFlags;
|
|
1704
|
+
dtCrowdAgentParams.obstacleAvoidanceType = params.obstacleAvoidanceType;
|
|
1705
|
+
dtCrowdAgentParams.queryFilterType = params.queryFilterType;
|
|
1706
|
+
dtCrowdAgentParams.userData = params.userData;
|
|
1707
|
+
const agentIndex = this.raw.addAgent(vec3.toArray(position), dtCrowdAgentParams);
|
|
1708
|
+
const agent = new CrowdAgent(this, agentIndex);
|
|
1709
|
+
this.agents[agentIndex] = agent;
|
|
1710
|
+
return agent;
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Gets the agent for the specified index, or null if no agent has the given index.
|
|
1714
|
+
* @param agentIndex
|
|
1715
|
+
* @returns
|
|
1716
|
+
*/
|
|
1717
|
+
getAgent(agentIndex) {
|
|
1718
|
+
const agent = this.agents[agentIndex];
|
|
1719
|
+
if (!agent) {
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
return agent;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Removes the agent from the crowd.
|
|
1726
|
+
*/
|
|
1727
|
+
removeAgent(agent) {
|
|
1728
|
+
const agentIndex = typeof agent === "number" ? agent : agent.agentIndex;
|
|
1729
|
+
this.raw.removeAgent(agentIndex);
|
|
1730
|
+
delete this.agents[agentIndex];
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Returns the maximum number of agents that can be managed by the crowd.
|
|
1734
|
+
*/
|
|
1735
|
+
getAgentCount() {
|
|
1736
|
+
return this.raw.getAgentCount();
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Returns the number of active agents in the crowd.
|
|
1740
|
+
*/
|
|
1741
|
+
getActiveAgentCount() {
|
|
1742
|
+
return Raw.CrowdUtils.getActiveAgentCount(this.raw);
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Returns all the agents managed by the crowd.
|
|
1746
|
+
*/
|
|
1747
|
+
getAgents() {
|
|
1748
|
+
return Object.values(this.agents);
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Gets the query filter for the specified index.
|
|
1752
|
+
* @param filterIndex the index of the query filter to retrieve, (min 0, max 15)
|
|
1753
|
+
* @returns the query filter
|
|
1754
|
+
*/
|
|
1755
|
+
getFilter(filterIndex) {
|
|
1756
|
+
return new QueryFilter(this.raw.getEditableFilter(filterIndex));
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Destroys the crowd.
|
|
1760
|
+
*/
|
|
1761
|
+
destroy() {
|
|
1762
|
+
Raw.Detour.freeCrowd(this.raw);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
class DebugDrawerUtils {
|
|
1766
|
+
constructor() {
|
|
1767
|
+
__publicField(this, "currentPrimitiveType", 0);
|
|
1768
|
+
__publicField(this, "currentVertices", []);
|
|
1769
|
+
__publicField(this, "primitives", []);
|
|
1770
|
+
this.debugDrawImpl = new Raw.Module.DebugDrawImpl();
|
|
1771
|
+
this.debugDrawImpl.handleBegin = (primitive, _size) => {
|
|
1772
|
+
this.currentPrimitiveType = primitive;
|
|
1773
|
+
this.currentVertices = [];
|
|
1774
|
+
};
|
|
1775
|
+
this.debugDrawImpl.handleDepthMask = (_state) => {
|
|
1776
|
+
};
|
|
1777
|
+
this.debugDrawImpl.handleTexture = (_state) => {
|
|
1778
|
+
};
|
|
1779
|
+
this.debugDrawImpl.handleVertexWithColor = (x, y, z, color) => {
|
|
1780
|
+
this.vertex(x, y, z, color);
|
|
1781
|
+
};
|
|
1782
|
+
this.debugDrawImpl.handleVertexWithColorAndUV = (x, y, z, color, _u, _v) => {
|
|
1783
|
+
this.vertex(x, y, z, color);
|
|
1784
|
+
};
|
|
1785
|
+
const primitiveMap = {
|
|
1786
|
+
[Raw.Module.DU_DRAW_LINES]: "lines",
|
|
1787
|
+
[Raw.Module.DU_DRAW_TRIS]: "tris",
|
|
1788
|
+
[Raw.Module.DU_DRAW_QUADS]: "quads",
|
|
1789
|
+
[Raw.Module.DU_DRAW_POINTS]: "points"
|
|
1790
|
+
};
|
|
1791
|
+
this.debugDrawImpl.handleEnd = () => {
|
|
1792
|
+
const type = primitiveMap[this.currentPrimitiveType];
|
|
1793
|
+
this.primitives.push({
|
|
1794
|
+
type,
|
|
1795
|
+
vertices: this.currentVertices
|
|
1796
|
+
});
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
flush() {
|
|
1800
|
+
const cur = this.primitives;
|
|
1801
|
+
this.primitives = [];
|
|
1802
|
+
return cur;
|
|
1803
|
+
}
|
|
1804
|
+
drawHeightfieldSolid(hf) {
|
|
1805
|
+
Raw.RecastDebugDraw.debugDrawHeightfieldSolid(this.debugDrawImpl, hf.raw);
|
|
1806
|
+
return this.flush();
|
|
1807
|
+
}
|
|
1808
|
+
drawHeightfieldWalkable(hf) {
|
|
1809
|
+
Raw.RecastDebugDraw.debugDrawHeightfieldWalkable(this.debugDrawImpl, hf.raw);
|
|
1810
|
+
return this.flush();
|
|
1811
|
+
}
|
|
1812
|
+
drawCompactHeightfieldSolid(chf) {
|
|
1813
|
+
Raw.RecastDebugDraw.debugDrawCompactHeightfieldSolid(this.debugDrawImpl, chf.raw);
|
|
1814
|
+
return this.flush();
|
|
1815
|
+
}
|
|
1816
|
+
drawCompactHeightfieldRegions(chf) {
|
|
1817
|
+
Raw.RecastDebugDraw.debugDrawCompactHeightfieldRegions(this.debugDrawImpl, chf.raw);
|
|
1818
|
+
return this.flush();
|
|
1819
|
+
}
|
|
1820
|
+
drawCompactHeightfieldDistance(chf) {
|
|
1821
|
+
Raw.RecastDebugDraw.debugDrawCompactHeightfieldDistance(this.debugDrawImpl, chf.raw);
|
|
1822
|
+
return this.flush();
|
|
1823
|
+
}
|
|
1824
|
+
drawHeightfieldLayer(layer, idx) {
|
|
1825
|
+
Raw.RecastDebugDraw.debugDrawHeightfieldLayer(this.debugDrawImpl, layer.raw, idx);
|
|
1826
|
+
return this.flush();
|
|
1827
|
+
}
|
|
1828
|
+
drawHeightfieldLayers(lset) {
|
|
1829
|
+
Raw.RecastDebugDraw.debugDrawHeightfieldLayers(this.debugDrawImpl, lset.raw);
|
|
1830
|
+
return this.flush();
|
|
1831
|
+
}
|
|
1832
|
+
drawRegionConnections(cset, alpha = 1) {
|
|
1833
|
+
Raw.RecastDebugDraw.debugDrawRegionConnections(this.debugDrawImpl, cset.raw, alpha);
|
|
1834
|
+
return this.flush();
|
|
1835
|
+
}
|
|
1836
|
+
drawRawContours(cset, alpha = 1) {
|
|
1837
|
+
Raw.RecastDebugDraw.debugDrawRawContours(this.debugDrawImpl, cset.raw, alpha);
|
|
1838
|
+
return this.flush();
|
|
1839
|
+
}
|
|
1840
|
+
drawContours(cset, alpha = 1) {
|
|
1841
|
+
Raw.RecastDebugDraw.debugDrawContours(this.debugDrawImpl, cset.raw, alpha);
|
|
1842
|
+
return this.flush();
|
|
1843
|
+
}
|
|
1844
|
+
drawPolyMesh(mesh) {
|
|
1845
|
+
Raw.RecastDebugDraw.debugDrawPolyMesh(this.debugDrawImpl, mesh.raw);
|
|
1846
|
+
return this.flush();
|
|
1847
|
+
}
|
|
1848
|
+
drawPolyMeshDetail(dmesh) {
|
|
1849
|
+
Raw.RecastDebugDraw.debugDrawPolyMeshDetail(this.debugDrawImpl, dmesh.raw);
|
|
1850
|
+
return this.flush();
|
|
1851
|
+
}
|
|
1852
|
+
drawNavMesh(mesh, flags = 0) {
|
|
1853
|
+
Raw.DetourDebugDraw.debugDrawNavMesh(this.debugDrawImpl, mesh.raw.getNavMesh(), flags);
|
|
1854
|
+
return this.flush();
|
|
1855
|
+
}
|
|
1856
|
+
drawNavMeshWithClosedList(mesh, query, flags = 0) {
|
|
1857
|
+
Raw.DetourDebugDraw.debugDrawNavMeshWithClosedList(this.debugDrawImpl, mesh.raw.m_navMesh, query.raw.m_navQuery, flags);
|
|
1858
|
+
return this.flush();
|
|
1859
|
+
}
|
|
1860
|
+
drawNavMeshNodes(query) {
|
|
1861
|
+
Raw.DetourDebugDraw.debugDrawNavMeshNodes(this.debugDrawImpl, query.raw.m_navQuery);
|
|
1862
|
+
return this.flush();
|
|
1863
|
+
}
|
|
1864
|
+
drawNavMeshBVTree(mesh) {
|
|
1865
|
+
Raw.DetourDebugDraw.debugDrawNavMeshBVTree(this.debugDrawImpl, mesh.raw.m_navMesh);
|
|
1866
|
+
return this.flush();
|
|
1867
|
+
}
|
|
1868
|
+
drawNavMeshPortals(mesh) {
|
|
1869
|
+
Raw.DetourDebugDraw.debugDrawNavMeshPortals(this.debugDrawImpl, mesh.raw.m_navMesh);
|
|
1870
|
+
return this.flush();
|
|
1871
|
+
}
|
|
1872
|
+
drawNavMeshPolysWithFlags(mesh, flags, col) {
|
|
1873
|
+
Raw.DetourDebugDraw.debugDrawNavMeshPolysWithFlags(this.debugDrawImpl, mesh.raw.m_navMesh, flags, col);
|
|
1874
|
+
return this.flush();
|
|
1875
|
+
}
|
|
1876
|
+
drawNavMeshPoly(mesh, ref, col) {
|
|
1877
|
+
Raw.DetourDebugDraw.debugDrawNavMeshPoly(this.debugDrawImpl, mesh.raw.m_navMesh, ref, col);
|
|
1878
|
+
return this.flush();
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Disposes of the debug drawer and releases resources.
|
|
1882
|
+
*/
|
|
1883
|
+
dispose() {
|
|
1884
|
+
Raw.Module.destroy(this.debugDrawImpl);
|
|
1885
|
+
}
|
|
1886
|
+
vertex(x, y, z, color) {
|
|
1887
|
+
const r = (color & 255) / 255;
|
|
1888
|
+
const g = (color >> 8 & 255) / 255;
|
|
1889
|
+
const b = (color >> 16 & 255) / 255;
|
|
1890
|
+
const a = (color >> 24 & 255) / 255;
|
|
1891
|
+
this.currentVertices.push([x, y, z, r, g, b, a]);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
const rgbToDuRgba = (hexColor) => {
|
|
1895
|
+
const r = hexColor >> 16 & 255;
|
|
1896
|
+
const g = hexColor >> 8 & 255;
|
|
1897
|
+
const b = hexColor & 255;
|
|
1898
|
+
return r | g << 8 | b << 16 | 255 << 24;
|
|
1899
|
+
};
|
|
1900
|
+
class NavMeshGetTilesAtResult {
|
|
1901
|
+
constructor(raw) {
|
|
1902
|
+
this.raw = raw;
|
|
1903
|
+
}
|
|
1904
|
+
tiles(index) {
|
|
1905
|
+
return new DetourMeshTile(this.raw.get_tiles(index));
|
|
1906
|
+
}
|
|
1907
|
+
tileCount() {
|
|
1908
|
+
return this.raw.tileCount;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
class NavMeshRemoveTileResult {
|
|
1912
|
+
constructor(raw) {
|
|
1913
|
+
this.raw = raw;
|
|
1914
|
+
}
|
|
1915
|
+
data() {
|
|
1916
|
+
return array((i) => this.raw.get_data(i), this.raw.dataSize);
|
|
1917
|
+
}
|
|
1918
|
+
dataSize() {
|
|
1919
|
+
return this.raw.dataSize;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
class NavMeshCalcTileLocResult {
|
|
1923
|
+
constructor(raw) {
|
|
1924
|
+
this.raw = raw;
|
|
1925
|
+
}
|
|
1926
|
+
tileX() {
|
|
1927
|
+
return this.raw.tileX;
|
|
1928
|
+
}
|
|
1929
|
+
tileY() {
|
|
1930
|
+
return this.raw.tileY;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
class NavMeshStoreTileStateResult {
|
|
1934
|
+
constructor(raw) {
|
|
1935
|
+
this.raw = raw;
|
|
1936
|
+
}
|
|
1937
|
+
data() {
|
|
1938
|
+
return array((i) => this.raw.get_data(i), this.raw.dataSize);
|
|
1939
|
+
}
|
|
1940
|
+
dataSize() {
|
|
1941
|
+
return this.raw.dataSize;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
class NavMeshParams {
|
|
1945
|
+
constructor(raw) {
|
|
1946
|
+
this.raw = raw;
|
|
1947
|
+
}
|
|
1948
|
+
static create(params) {
|
|
1949
|
+
const raw = new Raw.Module.dtNavMeshParams();
|
|
1950
|
+
raw.set_orig(0, params.orig.x);
|
|
1951
|
+
raw.set_orig(1, params.orig.y);
|
|
1952
|
+
raw.set_orig(2, params.orig.z);
|
|
1953
|
+
raw.tileWidth = params.tileWidth;
|
|
1954
|
+
raw.tileHeight = params.tileHeight;
|
|
1955
|
+
raw.maxTiles = params.maxTiles;
|
|
1956
|
+
raw.maxPolys = params.maxPolys;
|
|
1957
|
+
return new NavMeshParams(raw);
|
|
1958
|
+
}
|
|
1959
|
+
clone() {
|
|
1960
|
+
return NavMeshParams.create({
|
|
1961
|
+
orig: {
|
|
1962
|
+
x: this.raw.get_orig(0),
|
|
1963
|
+
y: this.raw.get_orig(1),
|
|
1964
|
+
z: this.raw.get_orig(2)
|
|
1965
|
+
},
|
|
1966
|
+
tileWidth: this.raw.tileWidth,
|
|
1967
|
+
tileHeight: this.raw.tileHeight,
|
|
1968
|
+
maxTiles: this.raw.maxTiles,
|
|
1969
|
+
maxPolys: this.raw.maxPolys
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
class NavMesh {
|
|
1974
|
+
constructor(raw) {
|
|
1975
|
+
this.raw = raw ?? new Raw.Module.NavMesh();
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Initializes the NavMesh for use with a single tile.
|
|
1979
|
+
* @param navMeshData the nav mesh data
|
|
1980
|
+
* @returns the status of the operation
|
|
1981
|
+
*/
|
|
1982
|
+
initSolo(navMeshData) {
|
|
1983
|
+
return this.raw.initSolo(navMeshData.raw);
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Initializes the NavMesh for use with multiple tiles.
|
|
1987
|
+
* @param params parameters for the NavMesh
|
|
1988
|
+
* @returns the status of the operation
|
|
1989
|
+
*/
|
|
1990
|
+
initTiled(params) {
|
|
1991
|
+
return this.raw.initTiled(params.raw);
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Adds a tile to the NavMesh.
|
|
1995
|
+
* @param navMeshData the nav mesh data
|
|
1996
|
+
* @param flags the flags to use when building the nav mesh
|
|
1997
|
+
* @param lastRef
|
|
1998
|
+
* @returns the status of the operation and the reference of the added tile
|
|
1999
|
+
*/
|
|
2000
|
+
addTile(navMeshData, flags, lastRef) {
|
|
2001
|
+
const tileRefRaw = new Raw.UnsignedIntRef();
|
|
2002
|
+
const status = this.raw.addTile(navMeshData.raw, flags, lastRef, tileRefRaw);
|
|
2003
|
+
const tileRef = tileRefRaw.value;
|
|
2004
|
+
Raw.destroy(tileRefRaw);
|
|
2005
|
+
return {
|
|
2006
|
+
status,
|
|
2007
|
+
tileRef
|
|
2008
|
+
};
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Decodes a standard polygon reference.
|
|
2012
|
+
* @param polyRef The polygon reference to decode
|
|
2013
|
+
* @returns the decoded polygon reference
|
|
2014
|
+
*/
|
|
2015
|
+
decodePolyId(polyRef) {
|
|
2016
|
+
const saltRef = new Raw.UnsignedIntRef();
|
|
2017
|
+
const itRef = new Raw.UnsignedIntRef();
|
|
2018
|
+
const ipRef = new Raw.UnsignedIntRef();
|
|
2019
|
+
this.raw.decodePolyId(polyRef, saltRef, itRef, ipRef);
|
|
2020
|
+
const tileSalt = saltRef.value;
|
|
2021
|
+
Raw.destroy(saltRef);
|
|
2022
|
+
const tileIndex = itRef.value;
|
|
2023
|
+
Raw.destroy(itRef);
|
|
2024
|
+
const tilePolygonIndex = ipRef.value;
|
|
2025
|
+
Raw.destroy(ipRef);
|
|
2026
|
+
return {
|
|
2027
|
+
tileSalt,
|
|
2028
|
+
tileIndex,
|
|
2029
|
+
tilePolygonIndex
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Derives a standard polygon reference.
|
|
2034
|
+
* @param salt The tile's salt value.
|
|
2035
|
+
* @param tileIndex The index of the tile. `it` in the C++ api.
|
|
2036
|
+
* @param tilePolygonIndex The index of the polygon within the tile. `ip` in the C++ api.
|
|
2037
|
+
* @returns the derived polygon reference
|
|
2038
|
+
*/
|
|
2039
|
+
encodePolyId(salt, tileIndex, tilePolygonIndex) {
|
|
2040
|
+
return this.raw.encodePolyId(salt, tileIndex, tilePolygonIndex);
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Removes a tile from the NavMesh
|
|
2044
|
+
* @param ref the tile ref
|
|
2045
|
+
* @returns the nav mesh data, so it can be added back later
|
|
2046
|
+
*/
|
|
2047
|
+
removeTile(ref) {
|
|
2048
|
+
return new NavMeshRemoveTileResult(this.raw.removeTile(ref));
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Calculates the tile grid location for the specified world position.
|
|
2052
|
+
* @param pos The world position for the query. [(x, y, z)]
|
|
2053
|
+
* @returns
|
|
2054
|
+
*/
|
|
2055
|
+
calcTileLoc(pos) {
|
|
2056
|
+
return new NavMeshCalcTileLocResult(this.raw.calcTileLoc(vec3.toArray(pos)));
|
|
2057
|
+
}
|
|
2058
|
+
/**
|
|
2059
|
+
* Gets the tile at the specified grid location.
|
|
2060
|
+
* @param x The tile's x-location. (x, y, layer)
|
|
2061
|
+
* @param y The tile's y-location. (x, y, layer)
|
|
2062
|
+
* @param layer The tile's layer. (x, y, layer)
|
|
2063
|
+
* @returns The tile, or null if the tile does not exist.
|
|
2064
|
+
*/
|
|
2065
|
+
getTileAt(x, y, layer) {
|
|
2066
|
+
const tile = this.raw.getTileAt(x, y, layer);
|
|
2067
|
+
return !Raw.isNull(tile) ? new DetourMeshTile(tile) : null;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Gets all tiles at the specified grid location. (All layers.)
|
|
2071
|
+
* @param x The tile's x-location. (x, y)
|
|
2072
|
+
* @param y The tile's y-location. (x, y)
|
|
2073
|
+
* @param maxTiles The maximum tiles the tiles parameter can hold.
|
|
2074
|
+
*/
|
|
2075
|
+
getTilesAt(x, y, maxTiles) {
|
|
2076
|
+
return new NavMeshGetTilesAtResult(this.raw.getTilesAt(x, y, maxTiles));
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* Gets the tile reference for the tile at specified grid location.
|
|
2080
|
+
* @param x The tile's x-location. (x, y, layer)
|
|
2081
|
+
* @param y The tile's y-location. (x, y, layer)
|
|
2082
|
+
* @param layer The tile's layer. (x, y, layer)
|
|
2083
|
+
* @returns The tile reference of the tile, or 0 if there is none.
|
|
2084
|
+
*/
|
|
2085
|
+
getTileRefAt(x, y, layer) {
|
|
2086
|
+
return this.raw.getTileRefAt(x, y, layer);
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Gets the tile reference for the specified tile.
|
|
2090
|
+
* @param tile
|
|
2091
|
+
* @returns
|
|
2092
|
+
*/
|
|
2093
|
+
getTileRef(tile) {
|
|
2094
|
+
return this.raw.getTileRef(tile.raw);
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Gets the tile for the specified tile reference.
|
|
2098
|
+
* @param ref The tile reference of the tile to retrieve.
|
|
2099
|
+
* @returns The tile for the specified reference, or null if the reference is invalid.
|
|
2100
|
+
*/
|
|
2101
|
+
getTileByRef(ref) {
|
|
2102
|
+
const tile = this.raw.getTileByRef(ref);
|
|
2103
|
+
return !Raw.isNull(tile) ? new DetourMeshTile(tile) : null;
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Returns the maximum number of tiles supported by the navigation mesh.
|
|
2107
|
+
*/
|
|
2108
|
+
getMaxTiles() {
|
|
2109
|
+
return this.raw.getMaxTiles();
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Gets the tile at the specified index.
|
|
2113
|
+
* @param i the tile index. [Limit: 0 >= index < #getMaxTiles()]
|
|
2114
|
+
* @returns
|
|
2115
|
+
*/
|
|
2116
|
+
getTile(i) {
|
|
2117
|
+
return new DetourMeshTile(this.raw.getTile(i));
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Gets the tile and polygon for the specified polygon reference.
|
|
2121
|
+
* @param ref The reference for the a polygon.
|
|
2122
|
+
* @returns
|
|
2123
|
+
*/
|
|
2124
|
+
getTileAndPolyByRef(ref) {
|
|
2125
|
+
const result = this.raw.getTileAndPolyByRef(ref);
|
|
2126
|
+
const tile = new DetourMeshTile(result.tile);
|
|
2127
|
+
const poly = new DetourPoly(result.poly);
|
|
2128
|
+
return {
|
|
2129
|
+
success: statusSucceed(result.status),
|
|
2130
|
+
status: result.status,
|
|
2131
|
+
tile,
|
|
2132
|
+
poly
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* Gets the tile and polygon for the specified polygon reference.
|
|
2137
|
+
* @param ref A known valid reference for a polygon.
|
|
2138
|
+
* @returns
|
|
2139
|
+
*/
|
|
2140
|
+
getTileAndPolyByRefUnsafe(ref) {
|
|
2141
|
+
const result = this.raw.getTileAndPolyByRef(ref);
|
|
2142
|
+
const tile = new DetourMeshTile(result.tile);
|
|
2143
|
+
const poly = new DetourPoly(result.poly);
|
|
2144
|
+
return {
|
|
2145
|
+
tile,
|
|
2146
|
+
poly
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Checks the validity of a polygon reference.
|
|
2151
|
+
* @param ref
|
|
2152
|
+
* @returns
|
|
2153
|
+
*/
|
|
2154
|
+
isValidPolyRef(ref) {
|
|
2155
|
+
return this.raw.isValidPolyRef(ref);
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Gets the polygon reference for the tile's base polygon.
|
|
2159
|
+
* @param tile
|
|
2160
|
+
* @returns
|
|
2161
|
+
*/
|
|
2162
|
+
getPolyRefBase(tile) {
|
|
2163
|
+
return this.raw.getPolyRefBase(tile.raw);
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Gets the endpoints for an off-mesh connection, ordered by "direction of travel".
|
|
2167
|
+
* @param prevRef The reference of the polygon before the connection.
|
|
2168
|
+
* @param polyRef The reference of the off-mesh connection polygon.
|
|
2169
|
+
* @returns
|
|
2170
|
+
*/
|
|
2171
|
+
getOffMeshConnectionPolyEndPoints(prevRef, polyRef) {
|
|
2172
|
+
const startRaw = new Raw.Vec3();
|
|
2173
|
+
const endRaw = new Raw.Vec3();
|
|
2174
|
+
const status = this.raw.getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startRaw, endRaw);
|
|
2175
|
+
const start = vec3.fromRaw(startRaw);
|
|
2176
|
+
Raw.destroy(startRaw);
|
|
2177
|
+
const end = vec3.fromRaw(endRaw);
|
|
2178
|
+
Raw.destroy(endRaw);
|
|
2179
|
+
return {
|
|
2180
|
+
success: statusSucceed(status),
|
|
2181
|
+
status,
|
|
2182
|
+
start,
|
|
2183
|
+
end
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
/**
|
|
2187
|
+
* Gets the specified off-mesh connection.
|
|
2188
|
+
* @param ref The polygon reference of the off-mesh connection.
|
|
2189
|
+
* @returns
|
|
2190
|
+
*/
|
|
2191
|
+
getOffMeshConnectionByRef(ref) {
|
|
2192
|
+
return new DetourOffMeshConnection(this.raw.getOffMeshConnectionByRef(ref));
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Sets the user defined flags for the specified polygon.
|
|
2196
|
+
* @param ref The polygon reference.
|
|
2197
|
+
* @param flags The new flags for the polygon.
|
|
2198
|
+
*/
|
|
2199
|
+
setPolyFlags(ref, flags) {
|
|
2200
|
+
return this.raw.setPolyFlags(ref, flags);
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* Gets the user defined flags for the specified polygon.
|
|
2204
|
+
* @param ref The polygon reference.
|
|
2205
|
+
* @returns
|
|
2206
|
+
*/
|
|
2207
|
+
getPolyFlags(ref) {
|
|
2208
|
+
const flagsRaw = new Raw.UnsignedShortRef();
|
|
2209
|
+
const status = this.raw.getPolyFlags(ref, flagsRaw);
|
|
2210
|
+
const flags = flagsRaw.value;
|
|
2211
|
+
Raw.destroy(flagsRaw);
|
|
2212
|
+
return {
|
|
2213
|
+
status,
|
|
2214
|
+
flags
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Sets the user defined area for the specified polygon.
|
|
2219
|
+
* @param ref The polygon reference.
|
|
2220
|
+
* @param flags The new flags for the polygon.
|
|
2221
|
+
*/
|
|
2222
|
+
setPolyArea(ref, area) {
|
|
2223
|
+
return this.raw.setPolyArea(ref, area);
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Gets the user defined area for the specified polygon.
|
|
2227
|
+
* @param ref The polygon reference.
|
|
2228
|
+
* @returns
|
|
2229
|
+
*/
|
|
2230
|
+
getPolyArea(ref) {
|
|
2231
|
+
const areaRaw = new Raw.UnsignedCharRef();
|
|
2232
|
+
const status = this.raw.getPolyArea(ref, areaRaw);
|
|
2233
|
+
const area = areaRaw.value;
|
|
2234
|
+
Raw.destroy(areaRaw);
|
|
2235
|
+
return {
|
|
2236
|
+
status,
|
|
2237
|
+
area
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Gets the size of the buffer required by #storeTileState to store the specified tile's state.
|
|
2242
|
+
* @param tile
|
|
2243
|
+
* @returns The size of the buffer required to store the state.
|
|
2244
|
+
*/
|
|
2245
|
+
getTileStateSize(tile) {
|
|
2246
|
+
return this.raw.getTileStateSize(tile.raw);
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* Stores the non-structural state of the tile in the specified buffer. (Flags, area ids, etc.)
|
|
2250
|
+
* @param tile The tile.
|
|
2251
|
+
* @param maxDataSize The size of the data buffer. [Limit: >= #getTileStateSize]
|
|
2252
|
+
* @returns
|
|
2253
|
+
*/
|
|
2254
|
+
storeTileState(tile, maxDataSize) {
|
|
2255
|
+
return new NavMeshStoreTileStateResult(this.raw.storeTileState(tile.raw, maxDataSize));
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Restores the state of the tile.
|
|
2259
|
+
* @param tile The tile.
|
|
2260
|
+
* @param data The new state. (Obtained from @see storeTileState)
|
|
2261
|
+
* @param maxDataSize The size of the state within the data buffer.
|
|
2262
|
+
* @returns
|
|
2263
|
+
*/
|
|
2264
|
+
restoreTileState(tile, data, maxDataSize) {
|
|
2265
|
+
return this.raw.restoreTileState(tile.raw, data, maxDataSize);
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Destroys the NavMesh.
|
|
2269
|
+
*/
|
|
2270
|
+
destroy() {
|
|
2271
|
+
this.raw.destroy();
|
|
2272
|
+
Raw.Module.destroy(this.raw);
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
const getNavMeshPositionsAndIndices = (navMesh, flags) => {
|
|
2276
|
+
const positions = [];
|
|
2277
|
+
const indices = [];
|
|
2278
|
+
let tri = 0;
|
|
2279
|
+
const maxTiles = navMesh.getMaxTiles();
|
|
2280
|
+
for (let tileIndex = 0; tileIndex < maxTiles; tileIndex++) {
|
|
2281
|
+
const tile = navMesh.getTile(tileIndex);
|
|
2282
|
+
const tileHeader = tile.header();
|
|
2283
|
+
if (!tileHeader) continue;
|
|
2284
|
+
const tilePolyCount = tileHeader.polyCount();
|
|
2285
|
+
for (let tilePolyIndex = 0; tilePolyIndex < tilePolyCount; ++tilePolyIndex) {
|
|
2286
|
+
const poly = tile.polys(tilePolyIndex);
|
|
2287
|
+
if (flags !== void 0 && (poly.flags() & flags) === 0) continue;
|
|
2288
|
+
if (poly.getType() === 1) continue;
|
|
2289
|
+
const polyVertCount = poly.vertCount();
|
|
2290
|
+
const polyDetail = tile.detailMeshes(tilePolyIndex);
|
|
2291
|
+
const polyDetailTriBase = polyDetail.triBase();
|
|
2292
|
+
const polyDetailTriCount = polyDetail.triCount();
|
|
2293
|
+
for (let polyDetailTriIndex = 0; polyDetailTriIndex < polyDetailTriCount; ++polyDetailTriIndex) {
|
|
2294
|
+
const detailTrisBaseIndex = (polyDetailTriBase + polyDetailTriIndex) * 4;
|
|
2295
|
+
for (let trianglePoint = 0; trianglePoint < 3; ++trianglePoint) {
|
|
2296
|
+
if (tile.detailTris(detailTrisBaseIndex + trianglePoint) < polyVertCount) {
|
|
2297
|
+
const tileVertsBaseIndex = poly.verts(tile.detailTris(detailTrisBaseIndex + trianglePoint)) * 3;
|
|
2298
|
+
positions.push(tile.verts(tileVertsBaseIndex), tile.verts(tileVertsBaseIndex + 1), tile.verts(tileVertsBaseIndex + 2));
|
|
2299
|
+
} else {
|
|
2300
|
+
const tileVertsBaseIndex = (polyDetail.vertBase() + tile.detailTris(detailTrisBaseIndex + trianglePoint) - poly.vertCount()) * 3;
|
|
2301
|
+
positions.push(tile.detailVerts(tileVertsBaseIndex), tile.detailVerts(tileVertsBaseIndex + 1), tile.detailVerts(tileVertsBaseIndex + 2));
|
|
2302
|
+
}
|
|
2303
|
+
indices.push(tri++);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
return [positions, indices];
|
|
2309
|
+
};
|
|
2310
|
+
const floodFillPruneNavMesh = (navMesh, startPolyRefs) => {
|
|
2311
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2312
|
+
const openList = [];
|
|
2313
|
+
for (const startPolyRef of startPolyRefs) {
|
|
2314
|
+
visited.add(startPolyRef);
|
|
2315
|
+
openList.push(startPolyRef);
|
|
2316
|
+
}
|
|
2317
|
+
while (openList.length > 0) {
|
|
2318
|
+
const ref = openList.pop();
|
|
2319
|
+
const {
|
|
2320
|
+
poly,
|
|
2321
|
+
tile
|
|
2322
|
+
} = navMesh.getTileAndPolyByRefUnsafe(ref);
|
|
2323
|
+
for (let i = poly.firstLink(); i !== Detour.DT_NULL_LINK; i = tile.links(i).next()) {
|
|
2324
|
+
const neiRef = tile.links(i).ref();
|
|
2325
|
+
if (!neiRef || visited.has(neiRef)) continue;
|
|
2326
|
+
visited.add(neiRef);
|
|
2327
|
+
openList.push(neiRef);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
for (let tileIndex = 0; tileIndex < navMesh.getMaxTiles(); tileIndex++) {
|
|
2331
|
+
const tile = navMesh.getTile(tileIndex);
|
|
2332
|
+
if (!tile || !tile.header()) continue;
|
|
2333
|
+
const tileHeader = tile.header();
|
|
2334
|
+
const base = navMesh.getPolyRefBase(tile);
|
|
2335
|
+
for (let i = 0; i < tileHeader.polyCount(); i++) {
|
|
2336
|
+
const ref = base | i;
|
|
2337
|
+
if (!visited.has(ref)) {
|
|
2338
|
+
navMesh.setPolyFlags(ref, 0);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
const getRandomSeed = () => {
|
|
2344
|
+
return Raw.Module.FastRand.prototype.getSeed();
|
|
2345
|
+
};
|
|
2346
|
+
const setRandomSeed = (seed) => {
|
|
2347
|
+
Raw.Module.FastRand.prototype.setSeed(seed);
|
|
2348
|
+
};
|
|
2349
|
+
const recastConfigDefaults = {
|
|
2350
|
+
borderSize: 0,
|
|
2351
|
+
tileSize: 0,
|
|
2352
|
+
cs: 0.2,
|
|
2353
|
+
ch: 0.2,
|
|
2354
|
+
walkableSlopeAngle: 60,
|
|
2355
|
+
walkableHeight: 2,
|
|
2356
|
+
walkableClimb: 2,
|
|
2357
|
+
walkableRadius: 0.5,
|
|
2358
|
+
maxEdgeLen: 12,
|
|
2359
|
+
maxSimplificationError: 1.3,
|
|
2360
|
+
minRegionArea: 8,
|
|
2361
|
+
mergeRegionArea: 20,
|
|
2362
|
+
maxVertsPerPoly: 6,
|
|
2363
|
+
detailSampleDist: 6,
|
|
2364
|
+
detailSampleMaxError: 1
|
|
2365
|
+
};
|
|
2366
|
+
const createRcConfig = (partialConfig) => {
|
|
2367
|
+
const config = {
|
|
2368
|
+
...recastConfigDefaults,
|
|
2369
|
+
...partialConfig
|
|
2370
|
+
};
|
|
2371
|
+
const rcConfig = new Raw.Module.rcConfig();
|
|
2372
|
+
rcConfig.borderSize = config.borderSize;
|
|
2373
|
+
rcConfig.tileSize = config.tileSize;
|
|
2374
|
+
rcConfig.cs = config.cs;
|
|
2375
|
+
rcConfig.ch = config.ch;
|
|
2376
|
+
rcConfig.walkableSlopeAngle = config.walkableSlopeAngle;
|
|
2377
|
+
rcConfig.walkableHeight = config.walkableHeight;
|
|
2378
|
+
rcConfig.walkableClimb = config.walkableClimb;
|
|
2379
|
+
rcConfig.walkableRadius = config.walkableRadius;
|
|
2380
|
+
rcConfig.maxEdgeLen = config.maxEdgeLen;
|
|
2381
|
+
rcConfig.maxSimplificationError = config.maxSimplificationError;
|
|
2382
|
+
rcConfig.minRegionArea = config.minRegionArea;
|
|
2383
|
+
rcConfig.mergeRegionArea = config.mergeRegionArea;
|
|
2384
|
+
rcConfig.maxVertsPerPoly = config.maxVertsPerPoly;
|
|
2385
|
+
rcConfig.detailSampleDist = config.detailSampleDist;
|
|
2386
|
+
rcConfig.detailSampleMaxError = config.detailSampleMaxError;
|
|
2387
|
+
return rcConfig;
|
|
2388
|
+
};
|
|
2389
|
+
const cloneRcConfig = (rcConfig) => {
|
|
2390
|
+
const clone = new Raw.Module.rcConfig();
|
|
2391
|
+
clone.set_bmin(0, rcConfig.get_bmin(0));
|
|
2392
|
+
clone.set_bmin(1, rcConfig.get_bmin(1));
|
|
2393
|
+
clone.set_bmin(2, rcConfig.get_bmin(2));
|
|
2394
|
+
clone.set_bmax(0, rcConfig.get_bmax(0));
|
|
2395
|
+
clone.set_bmax(1, rcConfig.get_bmax(1));
|
|
2396
|
+
clone.set_bmax(2, rcConfig.get_bmax(2));
|
|
2397
|
+
clone.width = rcConfig.width;
|
|
2398
|
+
clone.height = rcConfig.height;
|
|
2399
|
+
clone.borderSize = rcConfig.borderSize;
|
|
2400
|
+
clone.tileSize = rcConfig.tileSize;
|
|
2401
|
+
clone.cs = rcConfig.cs;
|
|
2402
|
+
clone.ch = rcConfig.ch;
|
|
2403
|
+
clone.walkableSlopeAngle = rcConfig.walkableSlopeAngle;
|
|
2404
|
+
clone.walkableHeight = rcConfig.walkableHeight;
|
|
2405
|
+
clone.walkableClimb = rcConfig.walkableClimb;
|
|
2406
|
+
clone.walkableRadius = rcConfig.walkableRadius;
|
|
2407
|
+
clone.maxEdgeLen = rcConfig.maxEdgeLen;
|
|
2408
|
+
clone.maxSimplificationError = rcConfig.maxSimplificationError;
|
|
2409
|
+
clone.minRegionArea = rcConfig.minRegionArea;
|
|
2410
|
+
clone.mergeRegionArea = rcConfig.mergeRegionArea;
|
|
2411
|
+
clone.maxVertsPerPoly = rcConfig.maxVertsPerPoly;
|
|
2412
|
+
clone.detailSampleDist = rcConfig.detailSampleDist;
|
|
2413
|
+
clone.detailSampleMaxError = rcConfig.detailSampleMaxError;
|
|
2414
|
+
return clone;
|
|
2415
|
+
};
|
|
2416
|
+
class RecastBuildContext {
|
|
2417
|
+
constructor(timersAndLogsEnabled = true) {
|
|
2418
|
+
__publicField(this, "logs", []);
|
|
2419
|
+
__publicField(this, "startTimes", {});
|
|
2420
|
+
__publicField(this, "accumulatedTimes", {});
|
|
2421
|
+
const impl = new Raw.Module.RecastBuildContextJsImpl();
|
|
2422
|
+
impl.log = (category, msg, len) => {
|
|
2423
|
+
if (!this.raw.logEnabled()) return;
|
|
2424
|
+
const msgPointer = msg;
|
|
2425
|
+
const view = new Uint8Array(Raw.Module.HEAPU8.buffer, msgPointer, len);
|
|
2426
|
+
const data = new Uint8Array(len);
|
|
2427
|
+
data.set(view);
|
|
2428
|
+
const msgString = new TextDecoder().decode(data);
|
|
2429
|
+
this.log(category, msgString);
|
|
2430
|
+
};
|
|
2431
|
+
impl.resetLog = () => {
|
|
2432
|
+
this.resetLog();
|
|
2433
|
+
};
|
|
2434
|
+
impl.startTimer = (label) => {
|
|
2435
|
+
if (!this.raw.timerEnabled()) return;
|
|
2436
|
+
this.startTimer(label);
|
|
2437
|
+
};
|
|
2438
|
+
impl.stopTimer = (label) => {
|
|
2439
|
+
if (!this.raw.timerEnabled()) return;
|
|
2440
|
+
this.stopTimer(label);
|
|
2441
|
+
};
|
|
2442
|
+
impl.getAccumulatedTime = (label) => {
|
|
2443
|
+
if (!this.raw.timerEnabled()) return -1;
|
|
2444
|
+
return this.getAccumulatedTime(label);
|
|
2445
|
+
};
|
|
2446
|
+
impl.resetTimers = () => {
|
|
2447
|
+
if (!this.raw.timerEnabled()) return;
|
|
2448
|
+
this.startTimes = {};
|
|
2449
|
+
this.accumulatedTimes = {};
|
|
2450
|
+
};
|
|
2451
|
+
this.raw = new Raw.Module.RecastBuildContext(impl);
|
|
2452
|
+
this.raw.enableTimer(timersAndLogsEnabled);
|
|
2453
|
+
this.raw.enableLog(timersAndLogsEnabled);
|
|
2454
|
+
this.resetTimers();
|
|
2455
|
+
}
|
|
2456
|
+
log(category, msg) {
|
|
2457
|
+
this.logs.push({
|
|
2458
|
+
category,
|
|
2459
|
+
msg
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
resetLog() {
|
|
2463
|
+
this.logs = [];
|
|
2464
|
+
}
|
|
2465
|
+
startTimer(label) {
|
|
2466
|
+
this.startTimes[label] = performance.now();
|
|
2467
|
+
}
|
|
2468
|
+
stopTimer(label) {
|
|
2469
|
+
const endTime = performance.now();
|
|
2470
|
+
const deltaTime = endTime - this.startTimes[label];
|
|
2471
|
+
if (this.accumulatedTimes[label] === -1) {
|
|
2472
|
+
this.accumulatedTimes[label] = deltaTime;
|
|
2473
|
+
} else {
|
|
2474
|
+
this.accumulatedTimes[label] += deltaTime;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
getAccumulatedTime(label) {
|
|
2478
|
+
return this.accumulatedTimes[label];
|
|
2479
|
+
}
|
|
2480
|
+
resetTimers() {
|
|
2481
|
+
for (let i = 0; i < Recast.RC_MAX_TIMERS; i++) {
|
|
2482
|
+
this.startTimes[i] = -1;
|
|
2483
|
+
this.accumulatedTimes[i] = -1;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
class RecastChunkyTriMesh {
|
|
2488
|
+
constructor(raw) {
|
|
2489
|
+
this.raw = raw ?? new Raw.rcChunkyTriMesh();
|
|
2490
|
+
}
|
|
2491
|
+
init(verts, tris, ntris, trisPerChunk) {
|
|
2492
|
+
return Raw.ChunkyTriMeshUtils.createChunkyTriMesh(verts.raw, tris.raw, ntris, trisPerChunk, this.raw);
|
|
2493
|
+
}
|
|
2494
|
+
getChunksOverlappingRect(boundsMin, boundsMax, chunks, maxChunks) {
|
|
2495
|
+
return Raw.ChunkyTriMeshUtils.getChunksOverlappingRect(this.raw, boundsMin, boundsMax, chunks.raw, maxChunks);
|
|
2496
|
+
}
|
|
2497
|
+
getNodeTris(nodeId) {
|
|
2498
|
+
return IntArray.fromRaw(Raw.ChunkyTriMeshUtils.getChunkyTriMeshNodeTris(this.raw, nodeId));
|
|
2499
|
+
}
|
|
2500
|
+
nodes(index) {
|
|
2501
|
+
return this.raw.get_nodes(index);
|
|
2502
|
+
}
|
|
2503
|
+
maxTrisPerChunk() {
|
|
2504
|
+
return this.raw.maxTrisPerChunk;
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
class RecastSpan {
|
|
2508
|
+
constructor(raw) {
|
|
2509
|
+
this.raw = raw;
|
|
2510
|
+
}
|
|
2511
|
+
smin() {
|
|
2512
|
+
return this.raw.smin;
|
|
2513
|
+
}
|
|
2514
|
+
smax() {
|
|
2515
|
+
return this.raw.smax;
|
|
2516
|
+
}
|
|
2517
|
+
area() {
|
|
2518
|
+
return this.raw.area;
|
|
2519
|
+
}
|
|
2520
|
+
next() {
|
|
2521
|
+
return !Raw.isNull(this.raw.next) ? new RecastSpan(this.raw.next) : null;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
class RecastSpanPool {
|
|
2525
|
+
constructor(raw) {
|
|
2526
|
+
this.raw = raw;
|
|
2527
|
+
}
|
|
2528
|
+
next() {
|
|
2529
|
+
return !Raw.isNull(this.raw.next) ? new RecastSpanPool(this.raw.next) : null;
|
|
2530
|
+
}
|
|
2531
|
+
items(index) {
|
|
2532
|
+
return new RecastSpan(this.raw.get_items(index));
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
class RecastHeightfield {
|
|
2536
|
+
constructor(raw) {
|
|
2537
|
+
this.raw = raw;
|
|
2538
|
+
}
|
|
2539
|
+
width() {
|
|
2540
|
+
return this.raw.width;
|
|
2541
|
+
}
|
|
2542
|
+
height() {
|
|
2543
|
+
return this.raw.height;
|
|
2544
|
+
}
|
|
2545
|
+
bmin() {
|
|
2546
|
+
return vec3.fromArray(array((i) => this.raw.get_bmin(i), 3));
|
|
2547
|
+
}
|
|
2548
|
+
bmax() {
|
|
2549
|
+
return vec3.fromArray(array((i) => this.raw.get_bmax(i), 3));
|
|
2550
|
+
}
|
|
2551
|
+
cs() {
|
|
2552
|
+
return this.raw.cs;
|
|
2553
|
+
}
|
|
2554
|
+
ch() {
|
|
2555
|
+
return this.raw.ch;
|
|
2556
|
+
}
|
|
2557
|
+
spans(index) {
|
|
2558
|
+
return new RecastSpan(this.raw.get_spans(index));
|
|
2559
|
+
}
|
|
2560
|
+
pools(index) {
|
|
2561
|
+
return new RecastSpanPool(this.raw.get_pools(index));
|
|
2562
|
+
}
|
|
2563
|
+
freelist(index) {
|
|
2564
|
+
return new RecastSpan(this.raw.get_freelist(index));
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
class RecastCompactCell {
|
|
2568
|
+
constructor(raw) {
|
|
2569
|
+
this.raw = raw;
|
|
2570
|
+
}
|
|
2571
|
+
index() {
|
|
2572
|
+
return this.raw.get_index();
|
|
2573
|
+
}
|
|
2574
|
+
count() {
|
|
2575
|
+
return this.raw.get_count();
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
class RecastCompactSpan {
|
|
2579
|
+
constructor(raw) {
|
|
2580
|
+
this.raw = raw;
|
|
2581
|
+
}
|
|
2582
|
+
y() {
|
|
2583
|
+
return this.raw.get_y();
|
|
2584
|
+
}
|
|
2585
|
+
reg() {
|
|
2586
|
+
return this.raw.get_reg();
|
|
2587
|
+
}
|
|
2588
|
+
con() {
|
|
2589
|
+
return this.raw.get_con();
|
|
2590
|
+
}
|
|
2591
|
+
h() {
|
|
2592
|
+
return this.raw.get_h();
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
class RecastCompactHeightfield {
|
|
2596
|
+
constructor(raw) {
|
|
2597
|
+
this.raw = raw;
|
|
2598
|
+
}
|
|
2599
|
+
width() {
|
|
2600
|
+
return this.raw.width;
|
|
2601
|
+
}
|
|
2602
|
+
height() {
|
|
2603
|
+
return this.raw.height;
|
|
2604
|
+
}
|
|
2605
|
+
spanCount() {
|
|
2606
|
+
return this.raw.spanCount;
|
|
2607
|
+
}
|
|
2608
|
+
walkableHeight() {
|
|
2609
|
+
return this.raw.walkableHeight;
|
|
2610
|
+
}
|
|
2611
|
+
walkableClimb() {
|
|
2612
|
+
return this.raw.walkableClimb;
|
|
2613
|
+
}
|
|
2614
|
+
borderSize() {
|
|
2615
|
+
return this.raw.borderSize;
|
|
2616
|
+
}
|
|
2617
|
+
maxDistance() {
|
|
2618
|
+
return this.raw.maxDistance;
|
|
2619
|
+
}
|
|
2620
|
+
maxRegions() {
|
|
2621
|
+
return this.raw.maxRegions;
|
|
2622
|
+
}
|
|
2623
|
+
bmin() {
|
|
2624
|
+
return vec3.fromArray(array((i) => this.raw.get_bmin(i), 3));
|
|
2625
|
+
}
|
|
2626
|
+
bmax() {
|
|
2627
|
+
return vec3.fromArray(array((i) => this.raw.get_bmax(i), 3));
|
|
2628
|
+
}
|
|
2629
|
+
cs() {
|
|
2630
|
+
return this.raw.cs;
|
|
2631
|
+
}
|
|
2632
|
+
ch() {
|
|
2633
|
+
return this.raw.ch;
|
|
2634
|
+
}
|
|
2635
|
+
cells(index) {
|
|
2636
|
+
return new RecastCompactCell(this.raw.get_cells(index));
|
|
2637
|
+
}
|
|
2638
|
+
spans(index) {
|
|
2639
|
+
return new RecastCompactSpan(this.raw.get_spans(index));
|
|
2640
|
+
}
|
|
2641
|
+
dist(index) {
|
|
2642
|
+
return this.raw.get_dist(index);
|
|
2643
|
+
}
|
|
2644
|
+
areas(index) {
|
|
2645
|
+
return this.raw.get_areas(index);
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
class RecastContour {
|
|
2649
|
+
constructor(raw) {
|
|
2650
|
+
this.raw = raw;
|
|
2651
|
+
}
|
|
2652
|
+
verts(index) {
|
|
2653
|
+
return this.raw.get_verts(index);
|
|
2654
|
+
}
|
|
2655
|
+
nverts() {
|
|
2656
|
+
return this.raw.nverts;
|
|
2657
|
+
}
|
|
2658
|
+
rverts(index) {
|
|
2659
|
+
return this.raw.get_rverts(index);
|
|
2660
|
+
}
|
|
2661
|
+
nrverts() {
|
|
2662
|
+
return this.raw.nrverts;
|
|
2663
|
+
}
|
|
2664
|
+
reg() {
|
|
2665
|
+
return this.raw.reg;
|
|
2666
|
+
}
|
|
2667
|
+
area() {
|
|
2668
|
+
return this.raw.area;
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
class RecastContourSet {
|
|
2672
|
+
constructor(raw) {
|
|
2673
|
+
this.raw = raw;
|
|
2674
|
+
}
|
|
2675
|
+
conts(index) {
|
|
2676
|
+
return new RecastContour(this.raw.get_conts(index));
|
|
2677
|
+
}
|
|
2678
|
+
nconts() {
|
|
2679
|
+
return this.raw.nconts;
|
|
2680
|
+
}
|
|
2681
|
+
bmin() {
|
|
2682
|
+
return vec3.fromArray(array((i) => this.raw.get_bmin(i), 3));
|
|
2683
|
+
}
|
|
2684
|
+
bmax() {
|
|
2685
|
+
return vec3.fromArray(array((i) => this.raw.get_bmax(i), 3));
|
|
2686
|
+
}
|
|
2687
|
+
cs() {
|
|
2688
|
+
return this.raw.cs;
|
|
2689
|
+
}
|
|
2690
|
+
ch() {
|
|
2691
|
+
return this.raw.ch;
|
|
2692
|
+
}
|
|
2693
|
+
width() {
|
|
2694
|
+
return this.raw.width;
|
|
2695
|
+
}
|
|
2696
|
+
height() {
|
|
2697
|
+
return this.raw.height;
|
|
2698
|
+
}
|
|
2699
|
+
borderSize() {
|
|
2700
|
+
return this.raw.borderSize;
|
|
2701
|
+
}
|
|
2702
|
+
maxError() {
|
|
2703
|
+
return this.raw.maxError;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
class RecastHeightfieldLayer {
|
|
2707
|
+
constructor(raw) {
|
|
2708
|
+
this.raw = raw;
|
|
2709
|
+
}
|
|
2710
|
+
bmin() {
|
|
2711
|
+
return vec3.fromArray(array((i) => this.raw.get_bmin(i), 3));
|
|
2712
|
+
}
|
|
2713
|
+
bmax() {
|
|
2714
|
+
return vec3.fromArray(array((i) => this.raw.get_bmax(i), 3));
|
|
2715
|
+
}
|
|
2716
|
+
cs() {
|
|
2717
|
+
return this.raw.cs;
|
|
2718
|
+
}
|
|
2719
|
+
ch() {
|
|
2720
|
+
return this.raw.ch;
|
|
2721
|
+
}
|
|
2722
|
+
width() {
|
|
2723
|
+
return this.raw.width;
|
|
2724
|
+
}
|
|
2725
|
+
height() {
|
|
2726
|
+
return this.raw.height;
|
|
2727
|
+
}
|
|
2728
|
+
minx() {
|
|
2729
|
+
return this.raw.minx;
|
|
2730
|
+
}
|
|
2731
|
+
maxx() {
|
|
2732
|
+
return this.raw.maxx;
|
|
2733
|
+
}
|
|
2734
|
+
miny() {
|
|
2735
|
+
return this.raw.miny;
|
|
2736
|
+
}
|
|
2737
|
+
maxy() {
|
|
2738
|
+
return this.raw.maxy;
|
|
2739
|
+
}
|
|
2740
|
+
hmin() {
|
|
2741
|
+
return this.raw.hmin;
|
|
2742
|
+
}
|
|
2743
|
+
hmax() {
|
|
2744
|
+
return this.raw.hmax;
|
|
2745
|
+
}
|
|
2746
|
+
heights(index) {
|
|
2747
|
+
return this.raw.get_heights(index);
|
|
2748
|
+
}
|
|
2749
|
+
areas(index) {
|
|
2750
|
+
return this.raw.get_areas(index);
|
|
2751
|
+
}
|
|
2752
|
+
cons(index) {
|
|
2753
|
+
return this.raw.get_cons(index);
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
class RecastHeightfieldLayerSet {
|
|
2757
|
+
constructor(raw) {
|
|
2758
|
+
this.raw = raw;
|
|
2759
|
+
}
|
|
2760
|
+
layers(index) {
|
|
2761
|
+
return new RecastHeightfieldLayer(this.raw.get_layers(index));
|
|
2762
|
+
}
|
|
2763
|
+
nlayers() {
|
|
2764
|
+
return this.raw.nlayers;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
class RecastPolyMesh {
|
|
2768
|
+
constructor(raw) {
|
|
2769
|
+
this.raw = raw;
|
|
2770
|
+
}
|
|
2771
|
+
verts(index) {
|
|
2772
|
+
return this.raw.get_verts(index);
|
|
2773
|
+
}
|
|
2774
|
+
polys(index) {
|
|
2775
|
+
return this.raw.get_polys(index);
|
|
2776
|
+
}
|
|
2777
|
+
regs(index) {
|
|
2778
|
+
return this.raw.get_regs(index);
|
|
2779
|
+
}
|
|
2780
|
+
flags(index) {
|
|
2781
|
+
return this.raw.get_flags(index);
|
|
2782
|
+
}
|
|
2783
|
+
setFlags(index, value) {
|
|
2784
|
+
this.raw.set_flags(index, value);
|
|
2785
|
+
}
|
|
2786
|
+
areas(index) {
|
|
2787
|
+
return this.raw.get_areas(index);
|
|
2788
|
+
}
|
|
2789
|
+
setAreas(index, value) {
|
|
2790
|
+
this.raw.set_areas(index, value);
|
|
2791
|
+
}
|
|
2792
|
+
nverts() {
|
|
2793
|
+
return this.raw.nverts;
|
|
2794
|
+
}
|
|
2795
|
+
npolys() {
|
|
2796
|
+
return this.raw.npolys;
|
|
2797
|
+
}
|
|
2798
|
+
maxpolys() {
|
|
2799
|
+
return this.raw.maxpolys;
|
|
2800
|
+
}
|
|
2801
|
+
nvp() {
|
|
2802
|
+
return this.raw.nvp;
|
|
2803
|
+
}
|
|
2804
|
+
bmin() {
|
|
2805
|
+
return vec3.fromArray(array((i) => this.raw.get_bmin(i), 3));
|
|
2806
|
+
}
|
|
2807
|
+
bmax() {
|
|
2808
|
+
return vec3.fromArray(array((i) => this.raw.get_bmax(i), 3));
|
|
2809
|
+
}
|
|
2810
|
+
cs() {
|
|
2811
|
+
return this.raw.cs;
|
|
2812
|
+
}
|
|
2813
|
+
ch() {
|
|
2814
|
+
return this.raw.ch;
|
|
2815
|
+
}
|
|
2816
|
+
borderSize() {
|
|
2817
|
+
return this.raw.borderSize;
|
|
2818
|
+
}
|
|
2819
|
+
maxEdgeError() {
|
|
2820
|
+
return this.raw.maxEdgeError;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
class RecastPolyMeshDetail {
|
|
2824
|
+
constructor(raw) {
|
|
2825
|
+
this.raw = raw;
|
|
2826
|
+
}
|
|
2827
|
+
meshes(index) {
|
|
2828
|
+
return this.raw.get_meshes(index);
|
|
2829
|
+
}
|
|
2830
|
+
verts(index) {
|
|
2831
|
+
return this.raw.get_verts(index);
|
|
2832
|
+
}
|
|
2833
|
+
tris(index) {
|
|
2834
|
+
return this.raw.get_tris(index);
|
|
2835
|
+
}
|
|
2836
|
+
nmeshes() {
|
|
2837
|
+
return this.raw.nmeshes;
|
|
2838
|
+
}
|
|
2839
|
+
nverts() {
|
|
2840
|
+
return this.raw.nverts;
|
|
2841
|
+
}
|
|
2842
|
+
ntris() {
|
|
2843
|
+
return this.raw.ntris;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
const calcBounds = (verts, nv) => {
|
|
2847
|
+
return Raw.Recast.calcBounds(verts.raw, nv);
|
|
2848
|
+
};
|
|
2849
|
+
const calcGridSize = (bmin, bmax, cs) => {
|
|
2850
|
+
return Raw.Recast.calcGridSize(bmin, bmax, cs);
|
|
2851
|
+
};
|
|
2852
|
+
const createHeightfield = (buildContext, heightfield, width, height, bmin, bmax, cs, ch) => {
|
|
2853
|
+
return Raw.Recast.createHeightfield(buildContext.raw, heightfield.raw, width, height, bmin, bmax, cs, ch);
|
|
2854
|
+
};
|
|
2855
|
+
const markWalkableTriangles = (buildContext, walkableSlopeAngle, verts, nv, tris, nt, areas) => {
|
|
2856
|
+
return Raw.Recast.markWalkableTriangles(buildContext.raw, walkableSlopeAngle, verts.raw, nv, tris.raw, nt, areas.raw);
|
|
2857
|
+
};
|
|
2858
|
+
const clearUnwalkableTriangles = (buildContext, walkableSlopeAngle, verts, nv, tris, nt, areas) => {
|
|
2859
|
+
return Raw.Recast.clearUnwalkableTriangles(buildContext.raw, walkableSlopeAngle, verts.raw, nv, tris.raw, nt, areas.raw);
|
|
2860
|
+
};
|
|
2861
|
+
const rasterizeTriangles = (buildContext, verts, nv, tris, areas, nt, heightfield, flagMergeThreshold = 1) => {
|
|
2862
|
+
return Raw.Recast.rasterizeTriangles(buildContext.raw, verts.raw, nv, tris.raw, areas.raw, nt, heightfield.raw, flagMergeThreshold);
|
|
2863
|
+
};
|
|
2864
|
+
const filterLowHangingWalkableObstacles = (buildContext, walkableClimb, heightfield) => {
|
|
2865
|
+
return Raw.Recast.filterLowHangingWalkableObstacles(buildContext.raw, walkableClimb, heightfield.raw);
|
|
2866
|
+
};
|
|
2867
|
+
const filterLedgeSpans = (buildContext, walkableHeight, walkableClimb, heightfield) => {
|
|
2868
|
+
return Raw.Recast.filterLedgeSpans(buildContext.raw, walkableHeight, walkableClimb, heightfield.raw);
|
|
2869
|
+
};
|
|
2870
|
+
const filterWalkableLowHeightSpans = (buildContext, walkableHeight, heightfield) => {
|
|
2871
|
+
return Raw.Recast.filterWalkableLowHeightSpans(buildContext.raw, walkableHeight, heightfield.raw);
|
|
2872
|
+
};
|
|
2873
|
+
const getHeightFieldSpanCount = (buildContext, heightfield) => {
|
|
2874
|
+
return Raw.Recast.getHeightFieldSpanCount(buildContext.raw, heightfield.raw);
|
|
2875
|
+
};
|
|
2876
|
+
const buildCompactHeightfield = (buildContext, walkableHeight, walkableClimb, heightfield, compactHeightfield) => {
|
|
2877
|
+
return Raw.Recast.buildCompactHeightfield(buildContext.raw, walkableHeight, walkableClimb, heightfield.raw, compactHeightfield.raw);
|
|
2878
|
+
};
|
|
2879
|
+
const erodeWalkableArea = (buildContext, radius, compactHeightfield) => {
|
|
2880
|
+
return Raw.Recast.erodeWalkableArea(buildContext.raw, radius, compactHeightfield.raw);
|
|
2881
|
+
};
|
|
2882
|
+
const medianFilterWalkableArea = (buildContext, compactHeightfield) => {
|
|
2883
|
+
return Raw.Recast.medianFilterWalkableArea(buildContext.raw, compactHeightfield.raw);
|
|
2884
|
+
};
|
|
2885
|
+
const markBoxArea = (buildContext, bmin, bmax, areaId, compactHeightfield) => {
|
|
2886
|
+
return Raw.Recast.markBoxArea(buildContext.raw, bmin, bmax, areaId, compactHeightfield.raw);
|
|
2887
|
+
};
|
|
2888
|
+
const markConvexPolyArea = (buildContext, verts, nverts, hmin, hmax, areaId, compactHeightfield) => {
|
|
2889
|
+
return Raw.Recast.markConvexPolyArea(buildContext.raw, verts.raw, nverts, hmin, hmax, areaId, compactHeightfield.raw);
|
|
2890
|
+
};
|
|
2891
|
+
const markCylinderArea = (buildContext, pos, radius, height, areaId, compactHeightfield) => {
|
|
2892
|
+
return Raw.Recast.markCylinderArea(buildContext.raw, pos, radius, height, areaId, compactHeightfield.raw);
|
|
2893
|
+
};
|
|
2894
|
+
const buildDistanceField = (buildContext, compactHeightfield) => {
|
|
2895
|
+
return Raw.Recast.buildDistanceField(buildContext.raw, compactHeightfield.raw);
|
|
2896
|
+
};
|
|
2897
|
+
const buildRegions = (buildContext, compactHeightfield, borderSize, minRegionArea, mergeRegionArea) => {
|
|
2898
|
+
return Raw.Recast.buildRegions(buildContext.raw, compactHeightfield.raw, borderSize, minRegionArea, mergeRegionArea);
|
|
2899
|
+
};
|
|
2900
|
+
const buildLayerRegions = (buildContext, compactHeightfield, borderSize, minRegionArea) => {
|
|
2901
|
+
return Raw.Recast.buildLayerRegions(buildContext.raw, compactHeightfield.raw, borderSize, minRegionArea);
|
|
2902
|
+
};
|
|
2903
|
+
const buildRegionsMonotone = (buildContext, compactHeightfield, borderSize, minRegionArea, mergeRegionArea) => {
|
|
2904
|
+
return Raw.Recast.buildRegionsMonotone(buildContext.raw, compactHeightfield.raw, borderSize, minRegionArea, mergeRegionArea);
|
|
2905
|
+
};
|
|
2906
|
+
const setCon = (compactSpan, dir, i) => {
|
|
2907
|
+
return Raw.Recast.setCon(compactSpan.raw, dir, i);
|
|
2908
|
+
};
|
|
2909
|
+
const getCon = (compactSpan, dir) => {
|
|
2910
|
+
return Raw.Recast.getCon(compactSpan.raw, dir);
|
|
2911
|
+
};
|
|
2912
|
+
const getDirOffsetX = (dir) => {
|
|
2913
|
+
return Raw.Recast.getDirOffsetX(dir);
|
|
2914
|
+
};
|
|
2915
|
+
const getDirOffsetY = (dir) => {
|
|
2916
|
+
return Raw.Recast.getDirOffsetY(dir);
|
|
2917
|
+
};
|
|
2918
|
+
const getDirForOffset = (x, y) => {
|
|
2919
|
+
return Raw.Recast.getDirForOffset(x, y);
|
|
2920
|
+
};
|
|
2921
|
+
const buildHeightfieldLayers = (buildContext, compactHeightfield, borderSize, walkableHeight, heightfieldLayerSet) => {
|
|
2922
|
+
return Raw.Recast.buildHeightfieldLayers(buildContext.raw, compactHeightfield.raw, borderSize, walkableHeight, heightfieldLayerSet.raw);
|
|
2923
|
+
};
|
|
2924
|
+
const buildContours = (buildContext, compactHeightfield, maxError, maxEdgeLen, contourSet, buildFlags = Recast.RC_CONTOUR_TESS_WALL_EDGES) => {
|
|
2925
|
+
return Raw.Recast.buildContours(buildContext.raw, compactHeightfield.raw, maxError, maxEdgeLen, contourSet.raw, buildFlags);
|
|
2926
|
+
};
|
|
2927
|
+
const buildPolyMesh = (buildContext, contourSet, nvp, polyMesh) => {
|
|
2928
|
+
return Raw.Recast.buildPolyMesh(buildContext.raw, contourSet.raw, nvp, polyMesh.raw);
|
|
2929
|
+
};
|
|
2930
|
+
const mergePolyMeshes = (buildContext, meshes, outPolyMesh) => {
|
|
2931
|
+
return Raw.Recast.mergePolyMeshes(buildContext.raw, meshes.map((m) => m.raw), meshes.length, outPolyMesh.raw);
|
|
2932
|
+
};
|
|
2933
|
+
const buildPolyMeshDetail = (buildContext, mesh, compactHeightfield, sampleDist, sampleMaxError, polyMeshDetail) => {
|
|
2934
|
+
return Raw.Recast.buildPolyMeshDetail(buildContext.raw, mesh.raw, compactHeightfield.raw, sampleDist, sampleMaxError, polyMeshDetail.raw);
|
|
2935
|
+
};
|
|
2936
|
+
const copyPolyMesh = (buildContext, src, dest) => {
|
|
2937
|
+
return Raw.Recast.copyPolyMesh(buildContext.raw, src.raw, dest.raw);
|
|
2938
|
+
};
|
|
2939
|
+
const mergePolyMeshDetails = (buildContext, meshes, out) => {
|
|
2940
|
+
return Raw.Recast.mergePolyMeshDetails(buildContext.raw, meshes.map((m) => m.raw), meshes.length, out.raw);
|
|
2941
|
+
};
|
|
2942
|
+
const getHeightfieldLayerHeights = (heightfieldLayer) => {
|
|
2943
|
+
return UnsignedCharArray.fromRaw(Raw.Recast.getHeightfieldLayerHeights(heightfieldLayer.raw));
|
|
2944
|
+
};
|
|
2945
|
+
const getHeightfieldLayerAreas = (heightfieldLayer) => {
|
|
2946
|
+
return UnsignedCharArray.fromRaw(Raw.Recast.getHeightfieldLayerAreas(heightfieldLayer.raw));
|
|
2947
|
+
};
|
|
2948
|
+
const getHeightfieldLayerCons = (heightfieldLayer) => {
|
|
2949
|
+
return UnsignedCharArray.fromRaw(Raw.Recast.getHeightfieldLayerCons(heightfieldLayer.raw));
|
|
2950
|
+
};
|
|
2951
|
+
const allocHeightfield = () => {
|
|
2952
|
+
return new RecastHeightfield(Raw.Recast.allocHeightfield());
|
|
2953
|
+
};
|
|
2954
|
+
const freeHeightfield = (heightfield) => {
|
|
2955
|
+
return Raw.Recast.freeHeightfield(heightfield.raw);
|
|
2956
|
+
};
|
|
2957
|
+
const allocCompactHeightfield = () => {
|
|
2958
|
+
return new RecastCompactHeightfield(Raw.Recast.allocCompactHeightfield());
|
|
2959
|
+
};
|
|
2960
|
+
const freeCompactHeightfield = (compactHeightfield) => {
|
|
2961
|
+
return Raw.Recast.freeCompactHeightfield(compactHeightfield.raw);
|
|
2962
|
+
};
|
|
2963
|
+
const allocHeightfieldLayerSet = () => {
|
|
2964
|
+
return new RecastHeightfieldLayerSet(Raw.Recast.allocHeightfieldLayerSet());
|
|
2965
|
+
};
|
|
2966
|
+
const freeHeightfieldLayerSet = (heightfieldLayerSet) => {
|
|
2967
|
+
return Raw.Recast.freeHeightfieldLayerSet(heightfieldLayerSet.raw);
|
|
2968
|
+
};
|
|
2969
|
+
const allocContourSet = () => {
|
|
2970
|
+
return new RecastContourSet(Raw.Recast.allocContourSet());
|
|
2971
|
+
};
|
|
2972
|
+
const freeContourSet = (contourSet) => {
|
|
2973
|
+
return Raw.Recast.freeContourSet(contourSet.raw);
|
|
2974
|
+
};
|
|
2975
|
+
const allocPolyMesh = () => {
|
|
2976
|
+
return new RecastPolyMesh(Raw.Recast.allocPolyMesh());
|
|
2977
|
+
};
|
|
2978
|
+
const freePolyMesh = (polyMesh) => {
|
|
2979
|
+
return Raw.Recast.freePolyMesh(polyMesh.raw);
|
|
2980
|
+
};
|
|
2981
|
+
const allocPolyMeshDetail = () => {
|
|
2982
|
+
return new RecastPolyMeshDetail(Raw.Recast.allocPolyMeshDetail());
|
|
2983
|
+
};
|
|
2984
|
+
const freePolyMeshDetail = (polyMeshDetail) => {
|
|
2985
|
+
return Raw.Recast.freePolyMeshDetail(polyMeshDetail.raw);
|
|
2986
|
+
};
|
|
2987
|
+
const exportImpl = (navMesh, tileCache) => {
|
|
2988
|
+
const navMeshExport = Raw.NavMeshExporter.exportNavMesh(navMesh.raw, tileCache == null ? void 0 : tileCache.raw);
|
|
2989
|
+
const arrView = new Uint8Array(Raw.Module.HEAPU8.buffer, navMeshExport.dataPointer, navMeshExport.size);
|
|
2990
|
+
const data = new Uint8Array(navMeshExport.size);
|
|
2991
|
+
data.set(arrView);
|
|
2992
|
+
Raw.NavMeshExporter.freeNavMeshExport(navMeshExport);
|
|
2993
|
+
return data;
|
|
2994
|
+
};
|
|
2995
|
+
const exportNavMesh = (navMesh) => {
|
|
2996
|
+
return exportImpl(navMesh);
|
|
2997
|
+
};
|
|
2998
|
+
const exportTileCache = (navMesh, tileCache) => {
|
|
2999
|
+
return exportImpl(navMesh, tileCache);
|
|
3000
|
+
};
|
|
3001
|
+
class DetourTileCacheParams {
|
|
3002
|
+
constructor(raw) {
|
|
3003
|
+
this.raw = raw;
|
|
3004
|
+
}
|
|
3005
|
+
static create(config) {
|
|
3006
|
+
const tileCacheParams = new Raw.Module.dtTileCacheParams();
|
|
3007
|
+
tileCacheParams.set_orig(0, config.orig[0]);
|
|
3008
|
+
tileCacheParams.set_orig(1, config.orig[1]);
|
|
3009
|
+
tileCacheParams.set_orig(2, config.orig[2]);
|
|
3010
|
+
tileCacheParams.set_cs(config.cs);
|
|
3011
|
+
tileCacheParams.set_ch(config.ch);
|
|
3012
|
+
tileCacheParams.set_width(config.width);
|
|
3013
|
+
tileCacheParams.set_height(config.height);
|
|
3014
|
+
tileCacheParams.set_walkableHeight(config.walkableHeight);
|
|
3015
|
+
tileCacheParams.set_walkableRadius(config.walkableRadius);
|
|
3016
|
+
tileCacheParams.set_walkableClimb(config.walkableClimb);
|
|
3017
|
+
tileCacheParams.set_maxSimplificationError(config.maxSimplificationError);
|
|
3018
|
+
tileCacheParams.set_maxTiles(config.maxTiles);
|
|
3019
|
+
tileCacheParams.set_maxObstacles(config.maxObstacles);
|
|
3020
|
+
return new DetourTileCacheParams(tileCacheParams);
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
class TileCache {
|
|
3024
|
+
constructor(raw) {
|
|
3025
|
+
__publicField(this, "obstacles", /* @__PURE__ */ new Map());
|
|
3026
|
+
this.raw = raw ?? new Raw.Module.TileCache();
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Initialises the TileCache
|
|
3030
|
+
* @param params
|
|
3031
|
+
*/
|
|
3032
|
+
init(params, alloc, compressor, meshProcess) {
|
|
3033
|
+
return this.raw.init(params.raw, alloc, compressor, meshProcess.raw);
|
|
3034
|
+
}
|
|
3035
|
+
/**
|
|
3036
|
+
* Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
|
|
3037
|
+
*
|
|
3038
|
+
* After adding or removing obstacles you can call `tileCache.update(navMesh)` to rebuild navmesh tiles.
|
|
3039
|
+
*
|
|
3040
|
+
* Adding or removing an obstacle will internally create an "obstacle request".
|
|
3041
|
+
* TileCache supports queuing up to 64 obstacle requests.
|
|
3042
|
+
*
|
|
3043
|
+
* The `tileCache.update` method returns `upToDate`, whether the tile cache is fully up to date with obstacle requests and tile rebuilds.
|
|
3044
|
+
* Each update call processes up to 64 tiles touched by added or removed obstacles.
|
|
3045
|
+
* If the tile cache isn't up to date another call will continue processing obstacle requests and tile rebuilds; otherwise it will have no effect.
|
|
3046
|
+
*
|
|
3047
|
+
* If not many obstacle requests occur between updates, an easy pattern is to call `tileCache.update` periodically, such as every game update.
|
|
3048
|
+
* If many obstacle requests have been made and you need to avoid reaching the 64 obstacle request limit, you can call `tileCache.update` multiple times, bailing out when `upToDate` is true or after a maximum number of updates.
|
|
3049
|
+
*
|
|
3050
|
+
* @example
|
|
3051
|
+
* ```ts
|
|
3052
|
+
* const { success, status, upToDate } = tileCache.update(navMesh);
|
|
3053
|
+
* ```
|
|
3054
|
+
*/
|
|
3055
|
+
update(navMesh) {
|
|
3056
|
+
const {
|
|
3057
|
+
status,
|
|
3058
|
+
upToDate
|
|
3059
|
+
} = this.raw.update(navMesh.raw);
|
|
3060
|
+
return {
|
|
3061
|
+
success: statusSucceed(status),
|
|
3062
|
+
status,
|
|
3063
|
+
upToDate
|
|
3064
|
+
};
|
|
3065
|
+
}
|
|
3066
|
+
/**
|
|
3067
|
+
* Creates a cylinder obstacle and adds it to the navigation mesh.
|
|
3068
|
+
*/
|
|
3069
|
+
addCylinderObstacle(position, radius, height) {
|
|
3070
|
+
const result = this.raw.addCylinderObstacle(vec3.toRaw(position), radius, height);
|
|
3071
|
+
if (result.status !== Detour.DT_SUCCESS) {
|
|
3072
|
+
return {
|
|
3073
|
+
success: false,
|
|
3074
|
+
status: result.status
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
const ref = result.ref;
|
|
3078
|
+
const obstacle = {
|
|
3079
|
+
type: "cylinder",
|
|
3080
|
+
ref,
|
|
3081
|
+
position,
|
|
3082
|
+
radius,
|
|
3083
|
+
height
|
|
3084
|
+
};
|
|
3085
|
+
this.obstacles.set(ref, obstacle);
|
|
3086
|
+
return {
|
|
3087
|
+
success: true,
|
|
3088
|
+
status: result.status,
|
|
3089
|
+
obstacle
|
|
3090
|
+
};
|
|
3091
|
+
}
|
|
3092
|
+
/**
|
|
3093
|
+
* Creates a box obstacle and adds it to the navigation mesh.
|
|
3094
|
+
*/
|
|
3095
|
+
addBoxObstacle(position, halfExtents, angle) {
|
|
3096
|
+
const rawPosition = vec3.toRaw(position);
|
|
3097
|
+
const rawHalfExtents = vec3.toRaw(halfExtents);
|
|
3098
|
+
const result = this.raw.addBoxObstacle(rawPosition, rawHalfExtents, angle);
|
|
3099
|
+
Raw.destroy(rawPosition);
|
|
3100
|
+
Raw.destroy(rawHalfExtents);
|
|
3101
|
+
if (result.status !== Detour.DT_SUCCESS) {
|
|
3102
|
+
return {
|
|
3103
|
+
success: false,
|
|
3104
|
+
status: result.status
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
const ref = result.ref;
|
|
3108
|
+
const obstacle = {
|
|
3109
|
+
type: "box",
|
|
3110
|
+
ref,
|
|
3111
|
+
position,
|
|
3112
|
+
halfExtents,
|
|
3113
|
+
angle
|
|
3114
|
+
};
|
|
3115
|
+
this.obstacles.set(ref, obstacle);
|
|
3116
|
+
return {
|
|
3117
|
+
success: true,
|
|
3118
|
+
status: result.status,
|
|
3119
|
+
obstacle
|
|
3120
|
+
};
|
|
3121
|
+
}
|
|
3122
|
+
/**
|
|
3123
|
+
* Removes an obstacle from the navigation mesh.
|
|
3124
|
+
*/
|
|
3125
|
+
removeObstacle(obstacle) {
|
|
3126
|
+
let ref;
|
|
3127
|
+
if (typeof obstacle === "object") {
|
|
3128
|
+
ref = obstacle.ref;
|
|
3129
|
+
} else {
|
|
3130
|
+
ref = obstacle;
|
|
3131
|
+
}
|
|
3132
|
+
this.obstacles.delete(ref);
|
|
3133
|
+
const status = this.raw.removeObstacle(ref);
|
|
3134
|
+
return {
|
|
3135
|
+
success: statusSucceed(status),
|
|
3136
|
+
status
|
|
3137
|
+
};
|
|
3138
|
+
}
|
|
3139
|
+
addTile(data, flags = Detour.DT_COMPRESSEDTILE_FREE_DATA) {
|
|
3140
|
+
return this.raw.addTile(data.raw, flags);
|
|
3141
|
+
}
|
|
3142
|
+
buildNavMeshTile(ref, navMesh) {
|
|
3143
|
+
return this.raw.buildNavMeshTile(ref, navMesh.raw);
|
|
3144
|
+
}
|
|
3145
|
+
buildNavMeshTilesAt(tx, ty, navMesh) {
|
|
3146
|
+
return this.raw.buildNavMeshTilesAt(tx, ty, navMesh.raw);
|
|
3147
|
+
}
|
|
3148
|
+
destroy() {
|
|
3149
|
+
this.raw.destroy();
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
class TileCacheMeshProcess {
|
|
3153
|
+
constructor(process) {
|
|
3154
|
+
this.raw = new Raw.Module.TileCacheMeshProcess();
|
|
3155
|
+
this.raw.process = (paramsPtr, polyAreasArrayPtr, polyFlagsArrayPtr) => {
|
|
3156
|
+
const params = new NavMeshCreateParams(Raw.Module.wrapPointer(paramsPtr, Raw.Module.dtNavMeshCreateParams));
|
|
3157
|
+
const polyAreasArray = Raw.Module.wrapPointer(polyAreasArrayPtr, Raw.Module.UnsignedCharArray);
|
|
3158
|
+
const polyFlagsArray = Raw.Module.wrapPointer(polyFlagsArrayPtr, Raw.Module.UnsignedShortArray);
|
|
3159
|
+
process(params, UnsignedCharArray.fromRaw(polyAreasArray), UnsignedShortArray.fromRaw(polyFlagsArray));
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
const buildTileCacheLayer = (comp, header, heights, areas, cons, tileCacheData) => {
|
|
3164
|
+
return Raw.DetourTileCacheBuilder.buildTileCacheLayer(comp, header, heights.raw, areas.raw, cons.raw, tileCacheData.raw);
|
|
3165
|
+
};
|
|
3166
|
+
const createNavMeshExport = (data) => {
|
|
3167
|
+
const nDataBytes = data.length * data.BYTES_PER_ELEMENT;
|
|
3168
|
+
const dataPtr = Raw.Module._malloc(nDataBytes);
|
|
3169
|
+
const dataHeap = new Uint8Array(Raw.Module.HEAPU8.buffer, dataPtr, nDataBytes);
|
|
3170
|
+
dataHeap.set(data);
|
|
3171
|
+
const navMeshExport = new Raw.Module.NavMeshExport();
|
|
3172
|
+
navMeshExport.dataPointer = dataHeap.byteOffset;
|
|
3173
|
+
navMeshExport.size = data.length;
|
|
3174
|
+
return {
|
|
3175
|
+
navMeshExport,
|
|
3176
|
+
dataHeap
|
|
3177
|
+
};
|
|
3178
|
+
};
|
|
3179
|
+
const importNavMesh = (data) => {
|
|
3180
|
+
const {
|
|
3181
|
+
navMeshExport,
|
|
3182
|
+
dataHeap
|
|
3183
|
+
} = createNavMeshExport(data);
|
|
3184
|
+
const result = Raw.NavMeshImporter.importNavMesh(navMeshExport, void 0);
|
|
3185
|
+
Raw.Module._free(dataHeap.byteOffset);
|
|
3186
|
+
const navMesh = new NavMesh(result.navMesh);
|
|
3187
|
+
return {
|
|
3188
|
+
navMesh
|
|
3189
|
+
};
|
|
3190
|
+
};
|
|
3191
|
+
const importTileCache = (data, tileCacheMeshProcess) => {
|
|
3192
|
+
const {
|
|
3193
|
+
navMeshExport,
|
|
3194
|
+
dataHeap
|
|
3195
|
+
} = createNavMeshExport(data);
|
|
3196
|
+
const result = Raw.NavMeshImporter.importNavMesh(navMeshExport, tileCacheMeshProcess.raw);
|
|
3197
|
+
Raw.Module._free(dataHeap.byteOffset);
|
|
3198
|
+
const navMesh = new NavMesh(result.navMesh);
|
|
3199
|
+
const tileCache = new TileCache(result.tileCache);
|
|
3200
|
+
const allocator = result.allocator;
|
|
3201
|
+
const compressor = result.compressor;
|
|
3202
|
+
return {
|
|
3203
|
+
navMesh,
|
|
3204
|
+
tileCache,
|
|
3205
|
+
allocator,
|
|
3206
|
+
compressor
|
|
3207
|
+
};
|
|
3208
|
+
};
|
|
3209
|
+
export {
|
|
3210
|
+
ChunkIdsArray,
|
|
3211
|
+
Crowd,
|
|
3212
|
+
CrowdAgent,
|
|
3213
|
+
DebugDrawerUtils,
|
|
3214
|
+
Detour,
|
|
3215
|
+
DetourBVNode,
|
|
3216
|
+
DetourLink,
|
|
3217
|
+
DetourMeshHeader,
|
|
3218
|
+
DetourMeshTile,
|
|
3219
|
+
DetourOffMeshConnection,
|
|
3220
|
+
DetourPoly,
|
|
3221
|
+
DetourPolyDetail,
|
|
3222
|
+
DetourTileCacheParams,
|
|
3223
|
+
FloatArray,
|
|
3224
|
+
IntArray,
|
|
3225
|
+
NavMesh,
|
|
3226
|
+
NavMeshCalcTileLocResult,
|
|
3227
|
+
NavMeshCreateParams,
|
|
3228
|
+
NavMeshGetTilesAtResult,
|
|
3229
|
+
NavMeshParams,
|
|
3230
|
+
NavMeshQuery,
|
|
3231
|
+
NavMeshRemoveTileResult,
|
|
3232
|
+
NavMeshStoreTileStateResult,
|
|
3233
|
+
QueryFilter,
|
|
3234
|
+
Raw,
|
|
3235
|
+
Recast,
|
|
3236
|
+
RecastBuildContext,
|
|
3237
|
+
RecastChunkyTriMesh,
|
|
3238
|
+
RecastCompactCell,
|
|
3239
|
+
RecastCompactHeightfield,
|
|
3240
|
+
RecastCompactSpan,
|
|
3241
|
+
RecastContour,
|
|
3242
|
+
RecastContourSet,
|
|
3243
|
+
RecastHeightfield,
|
|
3244
|
+
RecastHeightfieldLayer,
|
|
3245
|
+
RecastHeightfieldLayerSet,
|
|
3246
|
+
RecastPolyMesh,
|
|
3247
|
+
RecastPolyMeshDetail,
|
|
3248
|
+
RecastSpan,
|
|
3249
|
+
RecastSpanPool,
|
|
3250
|
+
TileCache,
|
|
3251
|
+
TileCacheData,
|
|
3252
|
+
TileCacheMeshProcess,
|
|
3253
|
+
TriangleAreasArray,
|
|
3254
|
+
TrianglesArray,
|
|
3255
|
+
UnsignedCharArray,
|
|
3256
|
+
UnsignedIntArray,
|
|
3257
|
+
UnsignedShortArray,
|
|
3258
|
+
VerticesArray,
|
|
3259
|
+
allocCompactHeightfield,
|
|
3260
|
+
allocContourSet,
|
|
3261
|
+
allocHeightfield,
|
|
3262
|
+
allocHeightfieldLayerSet,
|
|
3263
|
+
allocPolyMesh,
|
|
3264
|
+
allocPolyMeshDetail,
|
|
3265
|
+
array,
|
|
3266
|
+
buildCompactHeightfield,
|
|
3267
|
+
buildContours,
|
|
3268
|
+
buildDistanceField,
|
|
3269
|
+
buildHeightfieldLayers,
|
|
3270
|
+
buildLayerRegions,
|
|
3271
|
+
buildPolyMesh,
|
|
3272
|
+
buildPolyMeshDetail,
|
|
3273
|
+
buildRegions,
|
|
3274
|
+
buildRegionsMonotone,
|
|
3275
|
+
buildTileCacheLayer,
|
|
3276
|
+
calcBounds,
|
|
3277
|
+
calcGridSize,
|
|
3278
|
+
clearUnwalkableTriangles,
|
|
3279
|
+
cloneRcConfig,
|
|
3280
|
+
copyPolyMesh,
|
|
3281
|
+
createHeightfield,
|
|
3282
|
+
createNavMeshData,
|
|
3283
|
+
createRcConfig,
|
|
3284
|
+
crowdAgentParamsDefaults,
|
|
3285
|
+
erodeWalkableArea,
|
|
3286
|
+
exportNavMesh,
|
|
3287
|
+
exportTileCache,
|
|
3288
|
+
filterLedgeSpans,
|
|
3289
|
+
filterLowHangingWalkableObstacles,
|
|
3290
|
+
filterWalkableLowHeightSpans,
|
|
3291
|
+
floodFillPruneNavMesh,
|
|
3292
|
+
freeCompactHeightfield,
|
|
3293
|
+
freeContourSet,
|
|
3294
|
+
freeHeightfield,
|
|
3295
|
+
freeHeightfieldLayerSet,
|
|
3296
|
+
freePolyMesh,
|
|
3297
|
+
freePolyMeshDetail,
|
|
3298
|
+
getCon,
|
|
3299
|
+
getDirForOffset,
|
|
3300
|
+
getDirOffsetX,
|
|
3301
|
+
getDirOffsetY,
|
|
3302
|
+
getHeightFieldSpanCount,
|
|
3303
|
+
getHeightfieldLayerAreas,
|
|
3304
|
+
getHeightfieldLayerCons,
|
|
3305
|
+
getHeightfieldLayerHeights,
|
|
3306
|
+
getNavMeshPositionsAndIndices,
|
|
3307
|
+
getRandomSeed,
|
|
3308
|
+
importNavMesh,
|
|
3309
|
+
importTileCache,
|
|
3310
|
+
init,
|
|
3311
|
+
markBoxArea,
|
|
3312
|
+
markConvexPolyArea,
|
|
3313
|
+
markCylinderArea,
|
|
3314
|
+
markWalkableTriangles,
|
|
3315
|
+
medianFilterWalkableArea,
|
|
3316
|
+
mergePolyMeshDetails,
|
|
3317
|
+
mergePolyMeshes,
|
|
3318
|
+
rasterizeTriangles,
|
|
3319
|
+
recastConfigDefaults,
|
|
3320
|
+
rgbToDuRgba,
|
|
3321
|
+
setCon,
|
|
3322
|
+
setRandomSeed,
|
|
3323
|
+
statusDetail,
|
|
3324
|
+
statusFailed,
|
|
3325
|
+
statusInProgress,
|
|
3326
|
+
statusSucceed,
|
|
3327
|
+
statusToReadableString,
|
|
3328
|
+
vec3
|
|
3329
|
+
};
|
|
3330
|
+
//# sourceMappingURL=index-SMJ67XwT.js.map
|