@cimplify/sdk 0.108.0 → 0.110.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/advanced.d.mts +4 -3
- package/dist/advanced.d.ts +4 -3
- package/dist/advanced.js +24 -24
- package/dist/advanced.mjs +5 -5
- package/dist/animation-4EXBXRVX.js +27 -0
- package/dist/animation-6DICNWUP.mjs +6 -0
- package/dist/audio-DhvyjqdA.d.mts +249 -0
- package/dist/audio-m0w8cnxq.d.ts +249 -0
- package/dist/avatars.d.mts +110 -0
- package/dist/avatars.d.ts +110 -0
- package/dist/avatars.js +82 -0
- package/dist/avatars.mjs +5 -0
- package/dist/backend-gUCzs5Kg.d.mts +3866 -0
- package/dist/backend-gUCzs5Kg.d.ts +3866 -0
- package/dist/{catalogue-B4eLL8Mi.d.ts → catalogue-CPTMyBUz.d.mts} +109 -221
- package/dist/catalogue-DzrTXP3v.d.mts +541 -0
- package/dist/catalogue-DzrTXP3v.d.ts +541 -0
- package/dist/{catalogue-OT89_Ifs.d.mts → catalogue-OTuS5zp-.d.ts} +109 -221
- package/dist/chunk-22BD3RHN.mjs +1809 -0
- package/dist/chunk-25T4JHEA.mjs +21 -0
- package/dist/chunk-2AQ237Y4.js +508 -0
- package/dist/chunk-2IC4H6OV.mjs +48 -0
- package/dist/chunk-2LHLG4OB.mjs +71 -0
- package/dist/chunk-2O2CG465.js +1709 -0
- package/dist/chunk-2Q4DTHXK.js +316 -0
- package/dist/chunk-2QTQ6BUH.mjs +46 -0
- package/dist/chunk-2UN4SFLR.mjs +100 -0
- package/dist/chunk-2V75I7K3.js +454 -0
- package/dist/chunk-2V7IL4HC.js +10 -0
- package/dist/chunk-34XBXUMW.js +296 -0
- package/dist/chunk-3C4C654I.js +71 -0
- package/dist/chunk-3DAD2LDF.mjs +72 -0
- package/dist/chunk-3GXH2NFD.mjs +4 -0
- package/dist/chunk-3O47ZFW3.js +961 -0
- package/dist/chunk-3OY3VYNF.mjs +11 -0
- package/dist/chunk-3S6WPBZL.js +2936 -0
- package/dist/chunk-3TUOUP5T.js +399 -0
- package/dist/chunk-3VEH23I5.mjs +1380 -0
- package/dist/chunk-3ZYSAW2T.mjs +263 -0
- package/dist/chunk-4ANVF274.js +103 -0
- package/dist/chunk-4C7I3ELN.js +388 -0
- package/dist/chunk-4DYKAYFO.mjs +8 -0
- package/dist/chunk-4ZDR72SG.js +329 -0
- package/dist/chunk-52YS45RR.js +1066 -0
- package/dist/chunk-5325XSCH.js +107 -0
- package/dist/chunk-5AD5X6AV.js +13 -0
- package/dist/chunk-5BYDGGWO.mjs +197 -0
- package/dist/chunk-5C3C7VDM.mjs +55 -0
- package/dist/chunk-5HFMY3D7.js +660 -0
- package/dist/chunk-5LH2QN3T.js +1862 -0
- package/dist/chunk-5PJEXSOW.js +44 -0
- package/dist/chunk-5SXDH3Y7.js +90 -0
- package/dist/chunk-5YFBGGCK.mjs +502 -0
- package/dist/chunk-5YWN6H5Q.mjs +133 -0
- package/dist/chunk-66QP3SMN.js +402 -0
- package/dist/chunk-6DAEZKIG.mjs +385 -0
- package/dist/chunk-6DATW7TB.mjs +420 -0
- package/dist/{chunk-JRGK3NXR.mjs → chunk-6ETDAU62.mjs} +72 -212
- package/dist/chunk-6H254EVP.mjs +178 -0
- package/dist/chunk-6PFNJPBJ.mjs +820 -0
- package/dist/chunk-6PJWXIFX.mjs +357 -0
- package/dist/chunk-6SWKWCMS.js +80 -0
- package/dist/chunk-6VVXXX7S.js +808 -0
- package/dist/chunk-6WUBSMTX.js +1403 -0
- package/dist/chunk-73SGZLAQ.mjs +35 -0
- package/dist/chunk-76L2V6KD.mjs +4 -0
- package/dist/chunk-7AAIAVAA.js +1531 -0
- package/dist/chunk-7ARSJPV3.mjs +93 -0
- package/dist/chunk-7BHW5GTC.mjs +1234 -0
- package/dist/chunk-7DQSDKDU.js +6 -0
- package/dist/chunk-7IQQQENP.mjs +401 -0
- package/dist/chunk-7KFTYENS.js +11357 -0
- package/dist/chunk-7SM6XSPZ.js +3171 -0
- package/dist/chunk-7SXOHAIR.mjs +28 -0
- package/dist/chunk-A2MAX6S4.js +90 -0
- package/dist/chunk-A33OORT7.mjs +1530 -0
- package/dist/{chunk-U6ACF76H.mjs → chunk-A36JRXXH.mjs} +1075 -1845
- package/dist/chunk-A7BU3BK4.js +52 -0
- package/dist/chunk-A7MQSN2V.mjs +77 -0
- package/dist/chunk-A7V4L2IT.mjs +416 -0
- package/dist/chunk-AABEK6XU.js +226 -0
- package/dist/chunk-AGV33FWC.mjs +5005 -0
- package/dist/chunk-AHNR3BXI.js +108 -0
- package/dist/chunk-AQ5RLBU2.mjs +286 -0
- package/dist/chunk-AQOE6WCG.js +1270 -0
- package/dist/chunk-ATAWRACV.mjs +62 -0
- package/dist/chunk-ATCURNUV.js +14 -0
- package/dist/chunk-AWPV33OO.js +6 -0
- package/dist/chunk-AYJPHKYV.js +337 -0
- package/dist/chunk-AZ5BGWHB.js +162 -0
- package/dist/chunk-AZAXD44P.js +1373 -0
- package/dist/chunk-BBGKQIJJ.mjs +406 -0
- package/dist/chunk-BP4JLSUA.js +1453 -0
- package/dist/{chunk-SUCE7FWA.mjs → chunk-BTUSVHIE.mjs} +539 -978
- package/dist/chunk-BU6OK542.mjs +818 -0
- package/dist/chunk-CVSRWM6W.js +418 -0
- package/dist/chunk-CYBMFMJD.mjs +247 -0
- package/dist/chunk-DDJLDOUX.mjs +217 -0
- package/dist/{chunk-V32BCG7M.js → chunk-DFZWHNRG.js} +75 -215
- package/dist/chunk-DJ2C7AVG.js +644 -0
- package/dist/chunk-DS2VU4WW.mjs +102 -0
- package/dist/chunk-DSAG7T5P.js +7290 -0
- package/dist/chunk-E2QPPH7I.js +327 -0
- package/dist/chunk-E65WCTIG.mjs +1187 -0
- package/dist/{chunk-33VCYWVL.mjs → chunk-E6QQKDNE.mjs} +30 -42
- package/dist/chunk-ECDK6QBF.mjs +981 -0
- package/dist/chunk-EIB4OWVQ.mjs +620 -0
- package/dist/chunk-EQUZYCGO.js +250 -0
- package/dist/chunk-F3UJ6ZRM.mjs +313 -0
- package/dist/chunk-F63N2ZTQ.js +7023 -0
- package/dist/chunk-F6XRYEM3.mjs +26 -0
- package/dist/chunk-FE6VCE4K.js +5030 -0
- package/dist/chunk-FLWD6GRR.js +1372 -0
- package/dist/chunk-FQBFWJBS.mjs +110 -0
- package/dist/chunk-FXVJ2HFU.js +26 -0
- package/dist/chunk-FZMQMQBW.js +312 -0
- package/dist/chunk-G3EEC44R.js +53 -0
- package/dist/{chunk-KG3WT4PR.mjs → chunk-GCKWKLZF.mjs} +73 -104
- package/dist/chunk-GCX7TY4D.mjs +6826 -0
- package/dist/chunk-GDB6TCSD.js +450 -0
- package/dist/chunk-GDCV4IWO.mjs +21 -0
- package/dist/chunk-GDZT5LZ5.js +170 -0
- package/dist/chunk-GHPUYD4I.mjs +213 -0
- package/dist/chunk-GHS6MIL6.mjs +1432 -0
- package/dist/chunk-GPS2THCL.mjs +11 -0
- package/dist/{chunk-EV2EVOYS.js → chunk-GTJWQAGU.js} +31 -42
- package/dist/chunk-GVTI6UJQ.mjs +130 -0
- package/dist/chunk-GXKI64OT.mjs +1138 -0
- package/dist/chunk-GYDYF2WX.js +275 -0
- package/dist/chunk-GYLP6UG4.mjs +705 -0
- package/dist/chunk-H3OQKK6X.js +1158 -0
- package/dist/chunk-H5DFSCJ6.js +40 -0
- package/dist/chunk-HAGEIC2L.mjs +186 -0
- package/dist/chunk-HAJ4JRFO.js +293 -0
- package/dist/chunk-HDR72GB6.js +188 -0
- package/dist/chunk-HF5HPS4T.mjs +40 -0
- package/dist/chunk-HK6LOFDS.js +218 -0
- package/dist/chunk-HMWYTXCY.mjs +143 -0
- package/dist/chunk-HPCSRCMA.js +89 -0
- package/dist/chunk-HSEO6TPU.js +247 -0
- package/dist/chunk-I5FOHCLH.js +132 -0
- package/dist/chunk-IDLW4NWA.mjs +85 -0
- package/dist/chunk-IIDZ5WUX.js +61 -0
- package/dist/chunk-IR74FJHU.js +2332 -0
- package/dist/chunk-IRVFYAKP.mjs +100 -0
- package/dist/{chunk-XBL3TMPC.mjs → chunk-IZDWAL53.mjs} +1795 -3287
- package/dist/chunk-J2KZXIU3.js +51 -0
- package/dist/chunk-J2U6PJSO.js +91 -0
- package/dist/chunk-J5AJNY2N.js +283 -0
- package/dist/chunk-J6KQZ4FO.mjs +821 -0
- package/dist/{chunk-OWW5GUSB.js → chunk-JGBCIKJV.js} +7 -6
- package/dist/chunk-JKGTBMU7.mjs +25 -0
- package/dist/chunk-JR3TNEQC.js +422 -0
- package/dist/chunk-JURRXY2J.mjs +29 -0
- package/dist/chunk-K3HW5I2A.mjs +317 -0
- package/dist/chunk-K46SMZ66.mjs +103 -0
- package/dist/chunk-K4UDGE3Z.mjs +6 -0
- package/dist/chunk-KDQOR4QQ.mjs +350 -0
- package/dist/chunk-KDTVOLHI.mjs +288 -0
- package/dist/chunk-KGHJH5KJ.mjs +35 -0
- package/dist/chunk-KIZOA5LX.mjs +140 -0
- package/dist/chunk-KK6HYVBI.mjs +242 -0
- package/dist/chunk-KMKWGXMK.js +856 -0
- package/dist/chunk-KPA6K5IB.js +80 -0
- package/dist/chunk-KU7O4IXU.mjs +260 -0
- package/dist/chunk-KVFNRJOR.mjs +11142 -0
- package/dist/chunk-KZJRSXHK.js +2432 -0
- package/dist/chunk-LHWPRUJL.js +79 -0
- package/dist/chunk-LIV3KXJG.mjs +369 -0
- package/dist/chunk-LKV4LACG.js +21 -0
- package/dist/chunk-LUY45X3U.mjs +263 -0
- package/dist/chunk-LYEZZEEF.mjs +17 -0
- package/dist/chunk-M5EXQZYY.mjs +1519 -0
- package/dist/chunk-ME6HGG4I.mjs +1338 -0
- package/dist/chunk-MEXP6DA6.js +31 -0
- package/dist/chunk-MG52AW3H.js +902 -0
- package/dist/chunk-MIPO6F72.js +334 -0
- package/dist/{chunk-5QW7CQBA.js → chunk-MKIJQL5Q.js} +211 -321
- package/dist/chunk-MN3YETVN.mjs +17 -0
- package/dist/chunk-MOBSBXVE.mjs +2391 -0
- package/dist/chunk-MOMOZEUM.mjs +88 -0
- package/dist/chunk-MRFUNRAP.js +62 -0
- package/dist/chunk-MTIHEW2M.js +433 -0
- package/dist/chunk-N4RGGDEL.mjs +73 -0
- package/dist/chunk-NH654HAT.js +10 -0
- package/dist/chunk-NHJUGZUR.mjs +253 -0
- package/dist/chunk-NMQT4HG3.mjs +757 -0
- package/dist/chunk-NPSYB6DC.mjs +906 -0
- package/dist/chunk-NW2GPMSO.js +857 -0
- package/dist/chunk-NXKQOQ6L.js +76 -0
- package/dist/chunk-NXLAZIJZ.js +309 -0
- package/dist/chunk-NYWNA5CF.js +148 -0
- package/dist/chunk-NZTKLY2W.js +1442 -0
- package/dist/chunk-O2ICABUD.js +36 -0
- package/dist/chunk-OIVVQQ22.js +862 -0
- package/dist/chunk-OKC2B4O3.mjs +312 -0
- package/dist/chunk-OLWFPDBK.js +2220 -0
- package/dist/chunk-OMTVH334.js +3779 -0
- package/dist/chunk-OQRVEM56.mjs +362 -0
- package/dist/chunk-OXMIBOD4.js +337 -0
- package/dist/chunk-PBL6YL5L.mjs +288 -0
- package/dist/chunk-PDOELNNQ.js +97 -0
- package/dist/chunk-PDQJY2GZ.js +136 -0
- package/dist/chunk-PKOZXD2Q.js +1274 -0
- package/dist/chunk-PPF2BYFL.mjs +2191 -0
- package/dist/chunk-PQTQKNKD.js +539 -0
- package/dist/chunk-PRSR4FAV.mjs +81 -0
- package/dist/chunk-PTRNO5UD.js +95 -0
- package/dist/chunk-Q2Y3VMKH.js +2000 -0
- package/dist/chunk-QCZOE65N.js +96 -0
- package/dist/chunk-QDYFLATW.mjs +52 -0
- package/dist/chunk-QQABGCMM.js +22 -0
- package/dist/chunk-QS6TRHMR.js +345 -0
- package/dist/chunk-R56P64LB.mjs +208 -0
- package/dist/chunk-RCQ2MPBV.js +428 -0
- package/dist/chunk-RFVRPYR2.mjs +856 -0
- package/dist/chunk-RKBLPGPV.js +11521 -0
- package/dist/chunk-RM2V4IND.mjs +327 -0
- package/dist/chunk-RQXN5A34.mjs +613 -0
- package/dist/chunk-RUVGVNOF.mjs +2687 -0
- package/dist/chunk-SAFJIGYB.mjs +165 -0
- package/dist/chunk-SKQFLBDD.js +263 -0
- package/dist/chunk-SMK6JU2F.mjs +2092 -0
- package/dist/{chunk-UVRPC2P7.js → chunk-SNNEOS5Z.js} +1984 -3476
- package/dist/chunk-SPCRQ6NO.mjs +1246 -0
- package/dist/chunk-SWX4SALA.mjs +19 -0
- package/dist/{chunk-JVODCGFP.mjs → chunk-SYEO2WV4.mjs} +128 -238
- package/dist/chunk-T2QQMX2N.js +10 -0
- package/dist/chunk-T3AFF3L7.mjs +57 -0
- package/dist/chunk-T6Z2EXYL.js +712 -0
- package/dist/chunk-T7LOXGYX.js +118 -0
- package/dist/chunk-TJCAE7RC.mjs +1315 -0
- package/dist/chunk-TJI3K6RP.js +137 -0
- package/dist/chunk-TL2SVO4P.mjs +55 -0
- package/dist/chunk-TM63CYGN.mjs +399 -0
- package/dist/chunk-TU5RYTYU.mjs +13 -0
- package/dist/chunk-TVJZ4GPS.js +1553 -0
- package/dist/chunk-TWM6DLYF.js +371 -0
- package/dist/chunk-U63OC4TQ.js +30 -0
- package/dist/{chunk-L5GKVQVJ.js → chunk-U6BVSJZ6.js} +25 -57
- package/dist/chunk-U6UVWEAK.mjs +792 -0
- package/dist/chunk-UCEPNO6N.mjs +11048 -0
- package/dist/{chunk-ANT574FD.js → chunk-UCR5HRYM.js} +74 -105
- package/dist/chunk-UG5BTOTF.mjs +334 -0
- package/dist/chunk-UGH37BQW.mjs +157 -0
- package/dist/chunk-V7ZRH3PY.mjs +271 -0
- package/dist/chunk-VBGHBL3E.mjs +1394 -0
- package/dist/chunk-VRBDAS5I.js +920 -0
- package/dist/chunk-VVE3Y76O.js +230 -0
- package/dist/chunk-W65JIRI4.mjs +1182 -0
- package/dist/chunk-WHYKAT7G.js +62 -0
- package/dist/{chunk-YOIVZ6OA.mjs → chunk-WIZRUIZB.mjs} +25 -57
- package/dist/chunk-WKWTDZS7.js +385 -0
- package/dist/chunk-WLMINRC4.mjs +78 -0
- package/dist/chunk-WOF3AD3J.js +22 -0
- package/dist/chunk-WWKMOA76.js +1262 -0
- package/dist/chunk-X5A5FOWW.js +615 -0
- package/dist/chunk-X6CN6KQF.mjs +192 -0
- package/dist/chunk-XD2PMH46.mjs +517 -0
- package/dist/chunk-XJA2NGTI.mjs +88 -0
- package/dist/chunk-XJIHN3BY.mjs +8 -0
- package/dist/chunk-XK6UDWJS.js +203 -0
- package/dist/chunk-XPG3N5CF.mjs +415 -0
- package/dist/chunk-XVZ2NKSU.mjs +74 -0
- package/dist/chunk-XYP45OLE.js +117 -0
- package/dist/chunk-XZSDGZX6.mjs +301 -0
- package/dist/chunk-Y2EMGN4T.mjs +120 -0
- package/dist/chunk-Y3XWP5XW.mjs +298 -0
- package/dist/chunk-Y4K22JL6.js +228 -0
- package/dist/chunk-Y65LXQGA.mjs +3164 -0
- package/dist/chunk-Y66WVMO5.mjs +87 -0
- package/dist/chunk-Y7JWLB25.mjs +7280 -0
- package/dist/chunk-YCDXAJKU.js +175 -0
- package/dist/chunk-YRDQCCIS.js +152 -0
- package/dist/chunk-YV52DGSA.js +111 -0
- package/dist/chunk-YXGZQPUD.js +94 -0
- package/dist/chunk-Z3A3AFVU.mjs +102 -0
- package/dist/chunk-ZCY6YKKP.mjs +475 -0
- package/dist/chunk-ZEQHXVU5.js +215 -0
- package/dist/chunk-ZF7JCXCI.js +284 -0
- package/dist/chunk-ZJBRUH6V.js +29 -0
- package/dist/chunk-ZMIL4ZOA.js +365 -0
- package/dist/chunk-ZR5ULMN2.mjs +337 -0
- package/dist/chunk-ZXREOYOW.js +87 -0
- package/dist/{client-BSP9U1O1.d.mts → client-CX_WR0-J.d.mts} +2 -2
- package/dist/client-Dytx_ZTC.d.ts +230 -0
- package/dist/{client-B878xeAP.d.ts → client-dqOhP9Nc.d.ts} +2 -2
- package/dist/client-hTKbCuhG.d.mts +230 -0
- package/dist/clock-B-UAjkKa.d.mts +5 -0
- package/dist/clock-B-UAjkKa.d.ts +5 -0
- package/dist/config-BlXQluJR.d.mts +36 -0
- package/dist/config-BlXQluJR.d.ts +36 -0
- package/dist/courier-Cnn-edJ4.d.ts +95 -0
- package/dist/courier-FmGfkvIN.d.mts +95 -0
- package/dist/crowd-DdHFbqKK.d.ts +186 -0
- package/dist/crowd-hOVSAmA3.d.mts +186 -0
- package/dist/danfo-BEBapFlX.d.mts +146 -0
- package/dist/danfo-UQ_PTIIx.d.ts +146 -0
- package/dist/{elements-Bty6Qs_N.d.mts → elements-DdsRig-2.d.mts} +1548 -257
- package/dist/{elements-Bty6Qs_N.d.ts → elements-DdsRig-2.d.ts} +1548 -257
- package/dist/engines/godot.d.mts +56 -0
- package/dist/engines/godot.d.ts +56 -0
- package/dist/engines/godot.js +28 -0
- package/dist/engines/godot.mjs +3 -0
- package/dist/engines/wasm.d.mts +11 -0
- package/dist/engines/wasm.d.ts +11 -0
- package/dist/engines/wasm.js +178 -0
- package/dist/engines/wasm.mjs +176 -0
- package/dist/fallback-CrG_lTFk.d.mts +270 -0
- package/dist/fallback-CrG_lTFk.d.ts +270 -0
- package/dist/fallback-KDB4Y2CE.mjs +6 -0
- package/dist/fallback-Y26TQENE.js +19 -0
- package/dist/features-CZB4rmcD.d.mts +118 -0
- package/dist/features-CZB4rmcD.d.ts +118 -0
- package/dist/fit-BWiE7rgA.d.mts +44 -0
- package/dist/fit-DK0oT7zO.d.ts +44 -0
- package/dist/five-a-side-Bv1AOUy3.d.mts +115 -0
- package/dist/five-a-side-EC51SJY1.d.ts +115 -0
- package/dist/fluid-ARr0qUIL.d.ts +939 -0
- package/dist/fluid-DLlEj2cs.d.mts +939 -0
- package/dist/game/conformance.d.mts +84 -0
- package/dist/game/conformance.d.ts +84 -0
- package/dist/game/conformance.js +1025 -0
- package/dist/game/conformance.mjs +994 -0
- package/dist/game/heap.d.mts +40 -0
- package/dist/game/heap.d.ts +40 -0
- package/dist/game/heap.js +48 -0
- package/dist/game/heap.mjs +7 -0
- package/dist/game/kit/canvas.d.mts +240 -0
- package/dist/game/kit/canvas.d.ts +240 -0
- package/dist/game/kit/canvas.js +3566 -0
- package/dist/game/kit/canvas.mjs +1039 -0
- package/dist/game/kit/courier.d.mts +17 -0
- package/dist/game/kit/courier.d.ts +17 -0
- package/dist/game/kit/courier.js +66 -0
- package/dist/game/kit/courier.mjs +49 -0
- package/dist/game/kit/danfo.d.mts +11 -0
- package/dist/game/kit/danfo.d.ts +11 -0
- package/dist/game/kit/danfo.js +109 -0
- package/dist/game/kit/danfo.mjs +44 -0
- package/dist/game/kit/engine.d.mts +29 -0
- package/dist/game/kit/engine.d.ts +29 -0
- package/dist/game/kit/engine.js +183 -0
- package/dist/game/kit/engine.mjs +30 -0
- package/dist/game/kit/five-a-side.d.mts +11 -0
- package/dist/game/kit/five-a-side.d.ts +11 -0
- package/dist/game/kit/five-a-side.js +86 -0
- package/dist/game/kit/five-a-side.mjs +41 -0
- package/dist/game/kit/frontier.d.mts +344 -0
- package/dist/game/kit/frontier.d.ts +344 -0
- package/dist/game/kit/frontier.js +435 -0
- package/dist/game/kit/frontier.mjs +14 -0
- package/dist/game/kit/genesis.d.mts +752 -0
- package/dist/game/kit/genesis.d.ts +752 -0
- package/dist/game/kit/genesis.js +380 -0
- package/dist/game/kit/genesis.mjs +15 -0
- package/dist/game/kit/ludo.d.mts +15 -0
- package/dist/game/kit/ludo.d.ts +15 -0
- package/dist/game/kit/ludo.js +87 -0
- package/dist/game/kit/ludo.mjs +42 -0
- package/dist/game/kit/runner.d.mts +12 -0
- package/dist/game/kit/runner.d.ts +12 -0
- package/dist/game/kit/runner.js +83 -0
- package/dist/game/kit/runner.mjs +46 -0
- package/dist/game/kit/shootout.d.mts +13 -0
- package/dist/game/kit/shootout.d.ts +13 -0
- package/dist/game/kit/shootout.js +122 -0
- package/dist/game/kit/shootout.mjs +57 -0
- package/dist/game/kit/slots.d.mts +392 -0
- package/dist/game/kit/slots.d.ts +392 -0
- package/dist/game/kit/slots.js +215 -0
- package/dist/game/kit/slots.mjs +6 -0
- package/dist/game/kit/tycoon.d.mts +16 -0
- package/dist/game/kit/tycoon.d.ts +16 -0
- package/dist/game/kit/tycoon.js +145 -0
- package/dist/game/kit/tycoon.mjs +44 -0
- package/dist/game/kit/word.d.mts +11 -0
- package/dist/game/kit/word.d.ts +11 -0
- package/dist/game/kit/word.js +78 -0
- package/dist/game/kit/word.mjs +41 -0
- package/dist/game/kit/worlds.d.mts +18 -0
- package/dist/game/kit/worlds.d.ts +18 -0
- package/dist/game/kit/worlds.js +74 -0
- package/dist/game/kit/worlds.mjs +49 -0
- package/dist/game/kit.d.mts +53 -0
- package/dist/game/kit.d.ts +53 -0
- package/dist/game/kit.js +2610 -0
- package/dist/game/kit.mjs +101 -0
- package/dist/game/prepared.d.mts +14 -0
- package/dist/game/prepared.d.ts +14 -0
- package/dist/game/prepared.js +81 -0
- package/dist/game/prepared.mjs +32 -0
- package/dist/game-Bx8onkhX.d.mts +1451 -0
- package/dist/game-fgQy2YIm.d.ts +1451 -0
- package/dist/game-theme-CBTw1b_d.d.mts +35 -0
- package/dist/game-theme-Dg-ict5A.d.ts +35 -0
- package/dist/game.d.mts +3546 -0
- package/dist/game.d.ts +3546 -0
- package/dist/game.js +4455 -0
- package/dist/game.mjs +50 -0
- package/dist/graphics-C6YjWYvP.d.ts +5 -0
- package/dist/graphics-Dk2yQnYN.d.mts +5 -0
- package/dist/guest-DrsA00XD.d.mts +732 -0
- package/dist/guest-wIdfoT05.d.ts +732 -0
- package/dist/hit-stop-BKkVwTq7.d.mts +43 -0
- package/dist/hit-stop-D-8pPYnM.d.ts +43 -0
- package/dist/hot-Crn9XpHJ.d.ts +29 -0
- package/dist/hot-DH3nOhQD.d.mts +29 -0
- package/dist/{index-CQStGb3B.d.mts → index-6gkHMGAq.d.mts} +2 -2
- package/dist/index-B8ybCKJI.d.ts +41 -0
- package/dist/{index-DJwXmoaP.d.ts → index-B98Xac8e.d.ts} +2 -2
- package/dist/{index-B7oA_1XI.d.ts → index-B_ByTtIT.d.ts} +2 -2
- package/dist/index-DHjNHb1c.d.mts +41 -0
- package/dist/{index-DhUSTAhT.d.mts → index-DbAN_VQE.d.mts} +2 -2
- package/dist/index.d.mts +134 -24
- package/dist/index.d.ts +134 -24
- package/dist/index.js +407 -248
- package/dist/index.mjs +184 -58
- package/dist/interactives-authoring.d.mts +231 -0
- package/dist/interactives-authoring.d.ts +231 -0
- package/dist/interactives-authoring.js +1743 -0
- package/dist/interactives-authoring.mjs +1704 -0
- package/dist/interactives-canvas.global.js +148 -0
- package/dist/interactives-guest.d.mts +20 -0
- package/dist/interactives-guest.d.ts +20 -0
- package/dist/interactives-guest.js +63 -0
- package/dist/interactives-guest.json +1 -0
- package/dist/interactives-guest.mjs +61 -0
- package/dist/interactives-jsc.global.js +9357 -0
- package/dist/interactives-meters.d.mts +93 -0
- package/dist/interactives-meters.d.ts +93 -0
- package/dist/interactives-meters.js +252 -0
- package/dist/interactives-meters.mjs +68 -0
- package/dist/interactives-production.d.mts +430 -0
- package/dist/interactives-production.d.ts +430 -0
- package/dist/interactives-production.js +1231 -0
- package/dist/interactives-production.mjs +1170 -0
- package/dist/interactives-record.d.mts +112 -0
- package/dist/interactives-record.d.ts +112 -0
- package/dist/interactives-record.js +302 -0
- package/dist/interactives-record.mjs +295 -0
- package/dist/interactives-runtime.d.mts +61 -0
- package/dist/interactives-runtime.d.ts +61 -0
- package/dist/interactives-runtime.js +442 -0
- package/dist/interactives-runtime.mjs +25 -0
- package/dist/interactives-studio-kernel.global.js +1 -0
- package/dist/interactives-studio.d.mts +806 -0
- package/dist/interactives-studio.d.ts +806 -0
- package/dist/interactives-studio.js +5741 -0
- package/dist/interactives-studio.mjs +5651 -0
- package/dist/interactives-tick.d.mts +90 -0
- package/dist/interactives-tick.d.ts +90 -0
- package/dist/interactives-tick.js +203 -0
- package/dist/interactives-tick.mjs +6 -0
- package/dist/interactives-web.d.mts +762 -0
- package/dist/interactives-web.d.ts +762 -0
- package/dist/interactives-web.js +5000 -0
- package/dist/interactives-web.mjs +4628 -0
- package/dist/interactives.d.mts +2430 -0
- package/dist/interactives.d.ts +2430 -0
- package/dist/interactives.js +5723 -0
- package/dist/interactives.mjs +4333 -0
- package/dist/juice-CoHxlpKA.d.ts +42 -0
- package/dist/juice-DQztFS43.d.mts +42 -0
- package/dist/launch-T2f4_Di4.d.mts +151 -0
- package/dist/launch-d6oreMzR.d.ts +151 -0
- package/dist/library-DXYaMFhi.d.mts +69 -0
- package/dist/library-DXYaMFhi.d.ts +69 -0
- package/dist/link-BUTqGmyi.d.mts +38 -0
- package/dist/link-BUTqGmyi.d.ts +38 -0
- package/dist/lint.js +104 -204
- package/dist/lint.mjs +103 -203
- package/dist/local-D8_I6UeL.d.mts +6967 -0
- package/dist/local-VZkqsCzR.d.ts +6967 -0
- package/dist/lockstep-BLf6dglI.d.mts +321 -0
- package/dist/lockstep-D50Ia0JW.d.ts +321 -0
- package/dist/ludo-B8ClkDqr.d.ts +205 -0
- package/dist/ludo-BOuohQ-M.d.mts +205 -0
- package/dist/mock/cli.mjs +200 -56
- package/dist/mock/library.js +200 -56
- package/dist/mock/library.mjs +200 -56
- package/dist/mock/msw.js +200 -56
- package/dist/mock/msw.mjs +200 -56
- package/dist/native-BodxSh03.d.mts +16 -0
- package/dist/native-DUHMT8gA.d.ts +16 -0
- package/dist/network-ZXLD7l1b.d.mts +19 -0
- package/dist/network-ZXLD7l1b.d.ts +19 -0
- package/dist/online-XeymeM9s.d.ts +381 -0
- package/dist/online-d7W_Al9a.d.mts +381 -0
- package/dist/params-DxFb5G_U.d.mts +155 -0
- package/dist/params-DxFb5G_U.d.ts +155 -0
- package/dist/play-BRRlfLhX.d.ts +940 -0
- package/dist/play-ClrMd_e8.d.mts +940 -0
- package/dist/policy-CCw8tXLm.d.mts +3078 -0
- package/dist/policy-CMqOSQIu.d.ts +3078 -0
- package/dist/ports-B_0v_P3A.d.mts +13 -0
- package/dist/ports-CGU_3e_0.d.ts +13 -0
- package/dist/prefetch-BHnicOQj.d.ts +117 -0
- package/dist/prefetch-CBXgYacv.d.mts +117 -0
- package/dist/{price-CSztR02F.d.mts → price-BOzexBww.d.mts} +1 -1
- package/dist/{price-C_vasx9A.d.ts → price-C1h9sPxE.d.ts} +1 -1
- package/dist/protocol-C8qbpUbT.d.mts +242 -0
- package/dist/protocol-C8qbpUbT.d.ts +242 -0
- package/dist/rapier-AZHT4YI7.js +7886 -0
- package/dist/rapier-ODEPCQA6.mjs +7792 -0
- package/dist/react.d.mts +157 -15
- package/dist/react.d.ts +157 -15
- package/dist/react.js +5564 -5904
- package/dist/react.mjs +5451 -5808
- package/dist/runner-CQcLL7By.d.ts +189 -0
- package/dist/runner-D46Yj-wE.d.mts +189 -0
- package/dist/runtime-BRWfkf_q.d.mts +51 -0
- package/dist/runtime-DyuBMkKM.d.ts +51 -0
- package/dist/scheduling-D2ajXpMC.d.ts +224 -0
- package/dist/scheduling-DSRbbaZb.d.mts +224 -0
- package/dist/schema-BrWxzKp6.d.mts +63 -0
- package/dist/schema-BrWxzKp6.d.ts +63 -0
- package/dist/server/evict.js +34 -37
- package/dist/server/evict.mjs +34 -37
- package/dist/server/tanstack.d.mts +49 -3
- package/dist/server/tanstack.d.ts +49 -3
- package/dist/server/tanstack.js +169 -117
- package/dist/server/tanstack.mjs +166 -118
- package/dist/{server-Dckg4Vdr.d.ts → server-D29IIuDV.d.ts} +136 -130
- package/dist/{server-B6dW7-Lj.d.mts → server-DQMWPnc8.d.mts} +136 -130
- package/dist/server.d.mts +45 -5
- package/dist/server.d.ts +45 -5
- package/dist/server.js +171 -227
- package/dist/server.mjs +165 -225
- package/dist/session-grant-CJ27DwrT.d.mts +19 -0
- package/dist/session-grant-CJ27DwrT.d.ts +19 -0
- package/dist/shootout-BJZeX6FG.d.ts +140 -0
- package/dist/shootout-tcZd1Rxt.d.mts +140 -0
- package/dist/state-replica-stMtdkVD.d.mts +42 -0
- package/dist/state-replica-stMtdkVD.d.ts +42 -0
- package/dist/studio-CowqWqez.d.mts +14 -0
- package/dist/studio-CowqWqez.d.ts +14 -0
- package/dist/styles.css +1 -1
- package/dist/template-AhCdB1kW.d.mts +190 -0
- package/dist/template-BkEGVTQj.d.ts +190 -0
- package/dist/terrain-BMxEc6Oc.d.ts +429 -0
- package/dist/terrain-C-XC1Oui.d.mts +429 -0
- package/dist/testing/msw.d.mts +28 -4
- package/dist/testing/msw.d.ts +28 -4
- package/dist/testing/msw.js +15 -21
- package/dist/testing/msw.mjs +15 -21
- package/dist/testing/suite.d.mts +6 -5
- package/dist/testing/suite.d.ts +6 -5
- package/dist/testing/suite.js +89 -124
- package/dist/testing/suite.mjs +81 -116
- package/dist/testing.d.mts +27 -1227
- package/dist/testing.d.ts +27 -1227
- package/dist/testing.js +127 -131
- package/dist/testing.mjs +19 -23
- package/dist/tick-transport-C8QEh8Uw.d.mts +50 -0
- package/dist/tick-transport-UjHY3xK1.d.ts +50 -0
- package/dist/timeline-protocol-hp6e8zFB.d.mts +47 -0
- package/dist/timeline-protocol-hp6e8zFB.d.ts +47 -0
- package/dist/tokens-DhanQRQS.d.mts +21 -0
- package/dist/tokens-K8yxwd6G.d.ts +21 -0
- package/dist/tree-C-Io2Hbx.d.mts +35 -0
- package/dist/tree-CP_qSW4H.d.ts +35 -0
- package/dist/tycoon-B5KHk2Xx.d.mts +255 -0
- package/dist/tycoon-hmHo-3HX.d.ts +255 -0
- package/dist/types-BQkxPwZP.d.mts +219 -0
- package/dist/types-D_f6UUxM.d.ts +219 -0
- package/dist/ui-DwHicuFv.d.mts +563 -0
- package/dist/ui-hi7S2YcH.d.ts +563 -0
- package/dist/{sign-in-DQlIdqsi.d.mts → url-52ndUruG.d.mts} +15 -1
- package/dist/{sign-in-DQlIdqsi.d.ts → url-52ndUruG.d.ts} +15 -1
- package/dist/utils.d.mts +3 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +37 -37
- package/dist/utils.mjs +4 -4
- package/dist/vars-Dc_PrhBK.d.mts +511 -0
- package/dist/vars-Dc_PrhBK.d.ts +511 -0
- package/dist/vm-IUARFFAI.mjs +63 -0
- package/dist/vm-N7L6MGGH.js +65 -0
- package/dist/weave-delivery-CW-Kstut.d.mts +360 -0
- package/dist/weave-delivery-CW-Kstut.d.ts +360 -0
- package/dist/web-Dss74a7v.d.ts +883 -0
- package/dist/web-f9ZQPoyw.d.mts +883 -0
- package/dist/web-transport-C7MkBL0a.d.ts +19 -0
- package/dist/web-transport-aYEqXMd9.d.mts +19 -0
- package/dist/weight-CPGjsgjV.d.ts +92 -0
- package/dist/weight-tF1ODR1p.d.mts +92 -0
- package/dist/word-BcX9Jcmv.d.mts +70 -0
- package/dist/word-C7sVPLHm.d.ts +70 -0
- package/dist/world-PvILHDR1.d.ts +2285 -0
- package/dist/world-qekkXjJv.d.mts +2285 -0
- package/dist/worlds-Br2Pb0Cs.d.ts +109 -0
- package/dist/worlds-D5ydYr7d.d.mts +109 -0
- package/engines/c/cimplify.h +108 -0
- package/engines/c/cimplify.lib.js +11 -0
- package/engines/godot/addons/cimplify/cimplify.gd +97 -0
- package/engines/rust/interactives-ctx/Cargo.toml +9 -0
- package/engines/rust/interactives-ctx/src/lib.rs +189 -0
- package/package.json +189 -3
- package/vendor/rapier3d-compat/LICENSE +201 -0
- package/vendor/rapier3d-compat/PATCHES.md +61 -0
- package/dist/chunk-2P4KXFB6.js +0 -274
- package/dist/chunk-3G6RQLXK.mjs +0 -21
- package/dist/chunk-3V4DVXV3.mjs +0 -254
- package/dist/chunk-EDK3LNM6.js +0 -2436
- package/dist/chunk-F7J3HK27.js +0 -4549
- package/dist/chunk-U4MW6PYU.mjs +0 -23
- package/dist/chunk-XREIZ56K.js +0 -26
|
@@ -0,0 +1,1138 @@
|
|
|
1
|
+
import { JOINT_AXES, POSE_STRIDE, NO_PARENT } from './chunk-NHJUGZUR.mjs';
|
|
2
|
+
import { VECTOR_SURFACE_CAPS, VECTOR_SURFACE_TIERS, FftAnalyser } from './chunk-E65WCTIG.mjs';
|
|
3
|
+
import { OCCLUSION_WORDS, MUSIC_POSITION_WORDS, MAX_STEMS, SPATIAL_WORDS, EMITTER_COLUMNS, METER_PEAK, METER_RMS, detuneRate, ANALYSER_FREQUENCY, AUDIO_PREVIEW_SUFFIX, DEFAULT_PRIORITY, PRIORITY_MASK, PLAY_PRIORITY_SHIFT, PHRASE_QUANTIZE_SHIFT } from './chunk-5YFBGGCK.mjs';
|
|
4
|
+
import { COLUMN_ALIGN, ERROR_UNSUPPORTED, ERROR_UNKNOWN_RESOURCE, ERROR_DEAD_ENTITY, ERROR_CAPACITY_EXCEEDED } from './chunk-A33OORT7.mjs';
|
|
5
|
+
import { GameError } from './chunk-XJIHN3BY.mjs';
|
|
6
|
+
|
|
7
|
+
// src/game/backends/engine/vector-surfaces.ts
|
|
8
|
+
var ENGINE_VECTOR_SURFACE_EXPORT_NAMES = [
|
|
9
|
+
"engine_render_vector_load",
|
|
10
|
+
"engine_render_vector_unload",
|
|
11
|
+
"engine_render_vector_surface",
|
|
12
|
+
"engine_render_vector_surface_destroy",
|
|
13
|
+
"engine_render_vector_surface_node",
|
|
14
|
+
"engine_render_vector_surface_play",
|
|
15
|
+
"engine_render_vector_surface_input_index",
|
|
16
|
+
"engine_render_vector_surface_input",
|
|
17
|
+
"engine_render_vector_surface_data_index",
|
|
18
|
+
"engine_render_vector_surface_data_set",
|
|
19
|
+
"engine_render_vector_surface_pointer",
|
|
20
|
+
"engine_render_vector_surface_pick",
|
|
21
|
+
"engine_render_vector_frame",
|
|
22
|
+
"engine_render_vector_events",
|
|
23
|
+
"engine_render_vector_event_count",
|
|
24
|
+
"engine_render_vector_surface_tier",
|
|
25
|
+
"engine_render_vector_surface_stats"
|
|
26
|
+
], ENGINE_VECTOR_SURFACE_SEEK_EXPORT = "engine_render_vector_surface_seek";
|
|
27
|
+
function engineVectorSurfaceExports(symbols) {
|
|
28
|
+
for (let name of ENGINE_VECTOR_SURFACE_EXPORT_NAMES) if (typeof symbols[name] != "function") return null;
|
|
29
|
+
return symbols;
|
|
30
|
+
}
|
|
31
|
+
var VECTOR_SURFACE_PHASES = { down: 0, move: 1, up: 2, cancel: 3 }, VECTOR_SURFACE_PLAYS = { machine: 0, animation: 1, stop: 2 }, VECTOR_SURFACE_SEEKS = { machine: 0, animation: 1 }, VECTOR_SURFACE_DATA_KINDS = { number: 0, bool: 1, color: 2, id: 3, fire: 4 }, VECTOR_SURFACE_EVENT_BYTES = 32, VECTOR_SURFACE_EVENT_KIND = 14, VECTOR_SURFACE_STATS_WORDS = 8, VECTOR_SURFACE_RAY_WORDS = 7, EVENT_KIND_OFFSET = 0, EVENT_NODE_OFFSET = 4, EVENT_VALUE_OFFSET = 24, STAT_CAP = 0, STAT_LIVE = 1, STAT_ENCODED = 2, STAT_UNCHANGED = 3, STAT_OFFSCREEN = 4, STAT_OCCLUDED = 5, STAT_OVER_CAP = 6, STAT_DROPPED = 7, NO_NODE = 0, NO_SURFACE = 0, CONSUMED = 1, MICROS_PER_SECOND = 1e6, RAY_FAR = 6, UTF8 = new TextEncoder();
|
|
32
|
+
function failure(code, what) {
|
|
33
|
+
switch (code) {
|
|
34
|
+
case ERROR_CAPACITY_EXCEEDED:
|
|
35
|
+
return new GameError("capacity_exceeded", `${what}: capacity exceeded`);
|
|
36
|
+
case ERROR_DEAD_ENTITY:
|
|
37
|
+
case ERROR_UNKNOWN_RESOURCE:
|
|
38
|
+
return new GameError("unknown_resource", `${what}: unknown resource`);
|
|
39
|
+
case ERROR_UNSUPPORTED:
|
|
40
|
+
return new GameError("unsupported_feature", `${what}: unsupported`);
|
|
41
|
+
default:
|
|
42
|
+
return new GameError("invalid_argument", `${what}: invalid argument`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function checked(code, what) {
|
|
46
|
+
if (code < 0) throw failure(code, what);
|
|
47
|
+
return code;
|
|
48
|
+
}
|
|
49
|
+
var EngineVectorSurfaces = class {
|
|
50
|
+
constructor(exports, host) {
|
|
51
|
+
this.exports = exports;
|
|
52
|
+
this.host = host;
|
|
53
|
+
this.surfaces = 0;
|
|
54
|
+
this.tier = "mid";
|
|
55
|
+
this.ray = new Float32Array((7));
|
|
56
|
+
this.rayBytes = new Uint8Array(this.ray.buffer);
|
|
57
|
+
}
|
|
58
|
+
get cap() {
|
|
59
|
+
return VECTOR_SURFACE_CAPS[this.tier];
|
|
60
|
+
}
|
|
61
|
+
get handle() {
|
|
62
|
+
return this.host.handle;
|
|
63
|
+
}
|
|
64
|
+
load(bytes) {
|
|
65
|
+
if (bytes.byteLength === 0) throw new GameError("invalid_argument", "a vector asset needs its bytes");
|
|
66
|
+
let at = this.host.stage(bytes);
|
|
67
|
+
return checked(this.exports.engine_render_vector_load(this.handle, at, bytes.byteLength), "load vector");
|
|
68
|
+
}
|
|
69
|
+
unload(asset) {
|
|
70
|
+
checked(this.exports.engine_render_vector_unload(this.handle, asset), "unload vector");
|
|
71
|
+
}
|
|
72
|
+
create(desc) {
|
|
73
|
+
this.host.flush();
|
|
74
|
+
let surface = checked(
|
|
75
|
+
this.exports.engine_render_vector_surface(this.handle, desc.asset, desc.artboard ?? 0, desc.target, desc.node ?? (0)),
|
|
76
|
+
"create vector surface"
|
|
77
|
+
);
|
|
78
|
+
return this.surfaces++, surface;
|
|
79
|
+
}
|
|
80
|
+
destroy(surface) {
|
|
81
|
+
checked(this.exports.engine_render_vector_surface_destroy(this.handle, surface), "destroy vector surface"), this.surfaces--;
|
|
82
|
+
}
|
|
83
|
+
setNode(surface, node) {
|
|
84
|
+
this.host.flush(), checked(this.exports.engine_render_vector_surface_node(this.handle, surface, node ?? (0)), "vector surface node");
|
|
85
|
+
}
|
|
86
|
+
play(surface, kind, index) {
|
|
87
|
+
checked(this.exports.engine_render_vector_surface_play(this.handle, surface, VECTOR_SURFACE_PLAYS[kind], index), "play vector surface");
|
|
88
|
+
}
|
|
89
|
+
seek(surface, kind, index, seconds) {
|
|
90
|
+
let seekExport = this.exports[ENGINE_VECTOR_SURFACE_SEEK_EXPORT];
|
|
91
|
+
if (seekExport === void 0) throw new GameError("unsupported_feature", "this engine cannot seek vector surfaces");
|
|
92
|
+
checked(seekExport(this.handle, surface, VECTOR_SURFACE_SEEKS[kind], index, seconds), "seek vector surface");
|
|
93
|
+
}
|
|
94
|
+
inputIndex(surface, name) {
|
|
95
|
+
let bytes = UTF8.encode(name);
|
|
96
|
+
if (bytes.byteLength === 0) throw new GameError("invalid_argument", "a vector input needs a name");
|
|
97
|
+
let at = this.host.stage(bytes);
|
|
98
|
+
return checked(this.exports.engine_render_vector_surface_input_index(this.handle, surface, at, bytes.byteLength), `vector input ${name}`);
|
|
99
|
+
}
|
|
100
|
+
setInput(surface, input, value) {
|
|
101
|
+
checked(this.exports.engine_render_vector_surface_input(this.handle, surface, input, value), "vector input");
|
|
102
|
+
}
|
|
103
|
+
dataIndex(surface, path) {
|
|
104
|
+
let bytes = UTF8.encode(path);
|
|
105
|
+
if (bytes.byteLength === 0) throw new GameError("invalid_argument", "vector data needs a path");
|
|
106
|
+
let at = this.host.stage(bytes);
|
|
107
|
+
return checked(this.exports.engine_render_vector_surface_data_index(this.handle, surface, at, bytes.byteLength), `vector data ${path}`);
|
|
108
|
+
}
|
|
109
|
+
setData(surface, handle, kind, value) {
|
|
110
|
+
let bits = kind === "color" || kind === "id" ? value >>> 0 : 0;
|
|
111
|
+
checked(
|
|
112
|
+
this.exports.engine_render_vector_surface_data_set(this.handle, surface, handle, VECTOR_SURFACE_DATA_KINDS[kind], value, bits),
|
|
113
|
+
"vector data"
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
pointer(surface, phase, u, v) {
|
|
117
|
+
return checked(this.exports.engine_render_vector_surface_pointer(this.handle, surface, VECTOR_SURFACE_PHASES[phase], u, v), "vector pointer") === (1);
|
|
118
|
+
}
|
|
119
|
+
pick(origin, direction, far, phase) {
|
|
120
|
+
this.host.flush();
|
|
121
|
+
let ray = this.ray;
|
|
122
|
+
ray[0] = origin[0], ray[1] = origin[1], ray[2] = origin[2], ray[3] = direction[0], ray[4] = direction[1], ray[5] = direction[2], ray[(6)] = far;
|
|
123
|
+
let at = this.host.stage(this.rayBytes), surface = checked(this.exports.engine_render_vector_surface_pick(this.handle, VECTOR_SURFACE_PHASES[phase], at), "pick vector surface");
|
|
124
|
+
return surface === (0) ? null : surface;
|
|
125
|
+
}
|
|
126
|
+
events(out) {
|
|
127
|
+
let count = this.exports.engine_render_vector_event_count(this.handle);
|
|
128
|
+
if (count === 0)
|
|
129
|
+
return out.length = 0, 0;
|
|
130
|
+
let view2 = new DataView(this.host.buffer(), this.exports.engine_render_vector_events(this.handle), count * (32)), written = 0;
|
|
131
|
+
for (let k = 0; k < count; k++) {
|
|
132
|
+
let at = k * (32);
|
|
133
|
+
if (view2.getUint8(at + (0)) !== (14)) continue;
|
|
134
|
+
let surface = view2.getUint32(at + (4), true), event = view2.getFloat32(at + (24), true), slot = out[written];
|
|
135
|
+
slot === void 0 ? out.push({ surface, event }) : (slot.surface = surface, slot.event = event), written++;
|
|
136
|
+
}
|
|
137
|
+
return out.length = written, written;
|
|
138
|
+
}
|
|
139
|
+
stats(out) {
|
|
140
|
+
let at = this.exports.engine_render_vector_surface_stats(this.handle);
|
|
141
|
+
if (at === 0) throw new GameError("unknown_resource", "vector surface stats are unavailable");
|
|
142
|
+
let words = new Uint32Array(this.host.buffer(), at, (8));
|
|
143
|
+
out.cap = words[(0)], out.live = words[(1)], out.encoded = words[(2)], out.unchanged = words[(3)], out.offscreen = words[(4)], out.occluded = words[(5)], out.overCap = words[(6)], out.droppedEvents = words[(7)];
|
|
144
|
+
}
|
|
145
|
+
setTier(tier) {
|
|
146
|
+
checked(this.exports.engine_render_vector_surface_tier(this.handle, VECTOR_SURFACE_TIERS[tier]), "vector surface tier"), this.tier = tier;
|
|
147
|
+
}
|
|
148
|
+
frame(seconds) {
|
|
149
|
+
this.surfaces !== 0 && checked(this.exports.engine_render_vector_frame(this.handle, Math.round(seconds * (1e6))), "vector surface frame");
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/game/backends/engine/memory.ts
|
|
154
|
+
var NULL_POINTER = 0;
|
|
155
|
+
function view(buffer, scalar, pointer, length) {
|
|
156
|
+
switch (scalar) {
|
|
157
|
+
case "f32":
|
|
158
|
+
return new Float32Array(buffer, pointer, length);
|
|
159
|
+
case "f64":
|
|
160
|
+
return new Float64Array(buffer, pointer, length);
|
|
161
|
+
case "i8":
|
|
162
|
+
return new Int8Array(buffer, pointer, length);
|
|
163
|
+
case "i16":
|
|
164
|
+
return new Int16Array(buffer, pointer, length);
|
|
165
|
+
case "i32":
|
|
166
|
+
return new Int32Array(buffer, pointer, length);
|
|
167
|
+
case "u8":
|
|
168
|
+
return new Uint8Array(buffer, pointer, length);
|
|
169
|
+
case "u16":
|
|
170
|
+
return new Uint16Array(buffer, pointer, length);
|
|
171
|
+
case "u32":
|
|
172
|
+
return new Uint32Array(buffer, pointer, length);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
var SCALAR_BYTES = { f32: 4, f64: 8, i8: 1, i16: 2, i32: 4, u8: 1, u16: 2, u32: 4 }, ENGINE_ARENA_EXPORT_NAMES = ["engine_arena_committed", "engine_arena_ceiling", "engine_arena_set_ceiling", "engine_arena_release"], NOTHING_RELEASED = 0;
|
|
176
|
+
function sizeQuery(symbols, name) {
|
|
177
|
+
let query = symbols[name];
|
|
178
|
+
return typeof query == "function" ? query : null;
|
|
179
|
+
}
|
|
180
|
+
function engineArenaStats(symbols) {
|
|
181
|
+
let used = sizeQuery(symbols, "engine_memory_used"), committed = sizeQuery(symbols, "engine_arena_committed"), ceiling = sizeQuery(symbols, "engine_arena_ceiling");
|
|
182
|
+
return used === null || committed === null || ceiling === null ? null : { used: used(), committed: committed(), ceiling: ceiling() };
|
|
183
|
+
}
|
|
184
|
+
function releaseEngineArena(symbols) {
|
|
185
|
+
return sizeQuery(symbols, "engine_arena_release")?.() ?? (0);
|
|
186
|
+
}
|
|
187
|
+
function arenaDetail(symbols) {
|
|
188
|
+
let stats = engineArenaStats(symbols);
|
|
189
|
+
return stats === null ? "" : ` (using ${stats.used} of a ${stats.ceiling} byte ceiling, ${stats.committed} committed)`;
|
|
190
|
+
}
|
|
191
|
+
var EngineMemory = class {
|
|
192
|
+
constructor(runtime) {
|
|
193
|
+
this.pointers = [];
|
|
194
|
+
this.sizes = [];
|
|
195
|
+
this.runtime = runtime;
|
|
196
|
+
}
|
|
197
|
+
owns(array) {
|
|
198
|
+
return array.buffer === this.runtime.memory.buffer;
|
|
199
|
+
}
|
|
200
|
+
allocate(scalar, length) {
|
|
201
|
+
let bytes = Math.max(length * SCALAR_BYTES[scalar], COLUMN_ALIGN), pointer = this.runtime.exports.engine_alloc(bytes, COLUMN_ALIGN);
|
|
202
|
+
if (pointer === (0)) throw new GameError("capacity_exceeded", `engine memory cannot hold ${bytes} more bytes${arenaDetail(this.runtime.symbols)}`);
|
|
203
|
+
return this.pointers.push(pointer), this.sizes.push(bytes), view(this.runtime.memory.buffer, scalar, pointer, length);
|
|
204
|
+
}
|
|
205
|
+
release() {
|
|
206
|
+
for (let i = 0; i < this.pointers.length; i++)
|
|
207
|
+
this.runtime.exports.engine_free(this.pointers[i], this.sizes[i], COLUMN_ALIGN);
|
|
208
|
+
this.pointers.length = 0, this.sizes.length = 0;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/game/rollback-state.ts
|
|
213
|
+
function bytesOf(view2) {
|
|
214
|
+
return new Uint8Array(view2.buffer, view2.byteOffset, view2.byteLength);
|
|
215
|
+
}
|
|
216
|
+
var StateRing = class {
|
|
217
|
+
constructor(frames, engine = null) {
|
|
218
|
+
this.states = [];
|
|
219
|
+
this.known = [];
|
|
220
|
+
this.copies = [];
|
|
221
|
+
this.stride = 0;
|
|
222
|
+
this.slots = new Uint8Array(0);
|
|
223
|
+
this.slices = [];
|
|
224
|
+
this.stale = true;
|
|
225
|
+
this.breaks = 0;
|
|
226
|
+
this.frames = frames, this.engine = engine, this.ticks = new Float64Array(frames).fill(-1);
|
|
227
|
+
}
|
|
228
|
+
attach(state) {
|
|
229
|
+
this.states.includes(state) || (this.states.push(state), this.stale = true);
|
|
230
|
+
}
|
|
231
|
+
save(tick) {
|
|
232
|
+
this.changed() && this.relayout();
|
|
233
|
+
let slot = this.slot(tick), copies = this.copies, slices = this.slices, base = slot * copies.length;
|
|
234
|
+
for (let i = 0; i < copies.length; i++) slices[base + i].set(copies[i]);
|
|
235
|
+
this.ticks[slot] = tick;
|
|
236
|
+
}
|
|
237
|
+
has(tick) {
|
|
238
|
+
return !this.changed() && this.ticks[this.slot(tick)] === tick;
|
|
239
|
+
}
|
|
240
|
+
restore(tick) {
|
|
241
|
+
if (!this.has(tick)) return false;
|
|
242
|
+
let copies = this.copies, slices = this.slices, base = this.slot(tick) * copies.length;
|
|
243
|
+
for (let i = 0; i < copies.length; i++) copies[i].set(slices[base + i]);
|
|
244
|
+
for (let s = 0; s < this.frames; s++) this.ticks[s] > tick && (this.ticks[s] = -1);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
clear() {
|
|
248
|
+
this.ticks.fill(-1);
|
|
249
|
+
}
|
|
250
|
+
dropAfter(tick) {
|
|
251
|
+
for (let s = 0; s < this.frames; s++) this.ticks[s] > tick && (this.ticks[s] = -1);
|
|
252
|
+
}
|
|
253
|
+
slot(tick) {
|
|
254
|
+
return (tick % this.frames + this.frames) % this.frames;
|
|
255
|
+
}
|
|
256
|
+
changed() {
|
|
257
|
+
if (this.stale) return true;
|
|
258
|
+
let index = 0, known = this.known, states = this.states;
|
|
259
|
+
for (let s = 0; s < states.length; s++) {
|
|
260
|
+
let views = states[s].rollbackViews();
|
|
261
|
+
for (let v = 0; v < views.length; v++) {
|
|
262
|
+
if (known[index] !== views[v]) return true;
|
|
263
|
+
index++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return index !== known.length;
|
|
267
|
+
}
|
|
268
|
+
relayout() {
|
|
269
|
+
let known = [], copies = [], stride = 0;
|
|
270
|
+
for (let state of this.states)
|
|
271
|
+
for (let view2 of state.rollbackViews()) {
|
|
272
|
+
if (known.push(view2), this.engine !== null && this.engine.owns(view2)) {
|
|
273
|
+
this.engine.adopt(view2);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
let bytes = bytesOf(view2);
|
|
277
|
+
copies.push(bytes), stride += bytes.byteLength;
|
|
278
|
+
}
|
|
279
|
+
this.known = known, this.copies = copies, (stride !== this.stride || this.slots.byteLength !== stride * this.frames) && (this.stride = stride, this.slots = new Uint8Array(stride * this.frames));
|
|
280
|
+
let slices = [];
|
|
281
|
+
for (let slot = 0, at = 0; slot < this.frames; slot++)
|
|
282
|
+
for (let bytes of copies)
|
|
283
|
+
slices.push(this.slots.subarray(at, at + bytes.byteLength)), at += bytes.byteLength;
|
|
284
|
+
this.slices = slices, (!this.stale || this.ticks.some((tick) => tick !== -1)) && this.breaks++, this.ticks.fill(-1), this.stale = false;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// src/game/physics/rollback.ts
|
|
289
|
+
var ENGINE_ROLLBACK_EXPORT_NAMES = [
|
|
290
|
+
"engine_world_rollback_create",
|
|
291
|
+
"engine_world_snapshot_save",
|
|
292
|
+
"engine_world_snapshot_restore",
|
|
293
|
+
"engine_world_snapshot_clear",
|
|
294
|
+
"engine_world_snapshot_track",
|
|
295
|
+
"engine_world_snapshot_track_table",
|
|
296
|
+
"engine_world_snapshot_untrack",
|
|
297
|
+
"engine_world_snapshot_mark",
|
|
298
|
+
"engine_world_snapshot_registers",
|
|
299
|
+
"engine_world_snapshot_digest"
|
|
300
|
+
], ROLLBACK_CONFIG_WORDS = 4, ROLLBACK_CONFIG_REGION = 0, ROLLBACK_CONFIG_TRACKED = 1, ROLLBACK_CONFIG_JOURNAL = 2, ROLLBACK_CONFIG_FRAMES = 3, SNAPSHOT_POLICY_SCAN = 0, SNAPSHOT_POLICY_MARKED = 1, SNAPSHOT_REGISTER_WORDS = 16, SNAPSHOT_NO_FRAME = 4294967295, DEFAULT_ROLLBACK_REGION_BYTES = 16 * 1024 * 1024, DEFAULT_ROLLBACK_TRACKED_BYTES = 4 * 1024 * 1024, DEFAULT_ROLLBACK_JOURNAL_BYTES = 8 * 1024 * 1024, DEFAULT_ROLLBACK_FRAMES = 8, MAX_ROLLBACK_FRAMES = 64, REG_DEPTH = 0, REG_NEWEST = 1, REG_OLDEST = 2, REG_DIRTY = 3, REG_SCANNED = 4, REG_RESTORED = 5, REG_SAVE_NS = 6, REG_RESTORE_NS = 7, REG_EVICTED = 8, REG_HEAP_BYTES = 9, REG_TRACKED = 10, REG_SPILLS = 11, REG_BREAKS = 12, REG_RESIDENTS = 13, REG_QUIET = 14, REG_MISSED = 15, ERROR_UNKNOWN_RESOURCE2 = -3, ERROR_CAPACITY_EXCEEDED2 = -1, NANOS_PER_MS = 1e6, DIGEST_BYTES = 8, DIGEST_ALIGN = 8;
|
|
301
|
+
function hasRollback(symbols) {
|
|
302
|
+
return ENGINE_ROLLBACK_EXPORT_NAMES.every((name) => typeof symbols[name] == "function");
|
|
303
|
+
}
|
|
304
|
+
function writeRollbackConfig(out, desc) {
|
|
305
|
+
let frames = desc.frames ?? (8);
|
|
306
|
+
if (!Number.isInteger(frames) || frames < 2 || frames > (64)) throw new GameError("invalid_argument", `rollback frames must be 2..${(64)}`);
|
|
307
|
+
out[(0)] = desc.regionBytes ?? DEFAULT_ROLLBACK_REGION_BYTES, out[(1)] = desc.trackedBytes ?? DEFAULT_ROLLBACK_TRACKED_BYTES, out[(2)] = desc.journalBytes ?? DEFAULT_ROLLBACK_JOURNAL_BYTES, out[(3)] = frames;
|
|
308
|
+
}
|
|
309
|
+
function policyCode(policy) {
|
|
310
|
+
return policy === "marked" ? (1) : (0);
|
|
311
|
+
}
|
|
312
|
+
function optionalFrame(word) {
|
|
313
|
+
return word === (4294967295) ? null : word;
|
|
314
|
+
}
|
|
315
|
+
var ENGINE_KEYFRAME_EXPORT_NAMES = [
|
|
316
|
+
"engine_world_keyframes_enable",
|
|
317
|
+
"engine_world_keyframe_save",
|
|
318
|
+
"engine_world_keyframe_seek",
|
|
319
|
+
"engine_world_keyframe_nearest",
|
|
320
|
+
"engine_world_keyframe_truncate",
|
|
321
|
+
"engine_world_keyframe_registers"
|
|
322
|
+
], KEYFRAME_REGISTER_WORDS = 8, DEFAULT_KEYFRAME_EVERY = 60, DEFAULT_KEYFRAME_SLOTS = 64, DEFAULT_KEYFRAME_LEAVES = 16384, KEY_COUNT = 0, KEY_OLDEST = 1, KEY_NEWEST = 2, KEY_LEAVES_USED = 3, KEY_LEAVES_SHARED = 4, KEY_CAPTURES = 5, KEY_EVICTED = 6, KEY_INSTALLS = 7;
|
|
323
|
+
function keyframeExports(symbols) {
|
|
324
|
+
let s = symbols;
|
|
325
|
+
return ENGINE_KEYFRAME_EXPORT_NAMES.every((name) => typeof s[name] == "function") ? symbols : null;
|
|
326
|
+
}
|
|
327
|
+
var WorldSnapshots = class _WorldSnapshots {
|
|
328
|
+
constructor(exports, memory, world, beforeRestore, frames) {
|
|
329
|
+
this.exports = exports;
|
|
330
|
+
this.memory = memory;
|
|
331
|
+
this.world = world;
|
|
332
|
+
this.beforeRestore = beforeRestore;
|
|
333
|
+
this.view = new Uint32Array(0);
|
|
334
|
+
this.digestAt = 0;
|
|
335
|
+
this.keyRing = null;
|
|
336
|
+
this.keyframes = null;
|
|
337
|
+
this.every = (60);
|
|
338
|
+
this.states = [];
|
|
339
|
+
this.ring = new StateRing(frames, {
|
|
340
|
+
owns: (view2) => view2.buffer === this.memory.buffer,
|
|
341
|
+
adopt: (view2) => this.adopt(view2)
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
static bind(symbols, memory, world, beforeRestore = () => {
|
|
345
|
+
}, frames = (8)) {
|
|
346
|
+
if (!hasRollback(symbols) || typeof symbols.engine_alloc != "function") return null;
|
|
347
|
+
let exports = symbols;
|
|
348
|
+
return exports.engine_world_snapshot_registers(world) === 0 ? null : new _WorldSnapshots(exports, memory, world, beforeRestore, frames);
|
|
349
|
+
}
|
|
350
|
+
attach(state) {
|
|
351
|
+
this.ring.attach(state), this.keyRing?.attach(state), this.states.push(state);
|
|
352
|
+
}
|
|
353
|
+
enableKeyframes(desc) {
|
|
354
|
+
let keyframes = keyframeExports(this.exports);
|
|
355
|
+
if (keyframes === null) return false;
|
|
356
|
+
let every = desc.every ?? (60), slots = desc.slots ?? (64);
|
|
357
|
+
if (!Number.isInteger(every) || every < 1) throw new GameError("invalid_argument", "keyframes come every whole number of ticks");
|
|
358
|
+
this.check(keyframes.engine_world_keyframes_enable(this.world, desc.leaves ?? (16384), slots), "keyframes enable"), this.keyframes = keyframes, this.every = every, this.keyRing = new StateRing(slots, {
|
|
359
|
+
owns: (view2) => view2.buffer === this.memory.buffer,
|
|
360
|
+
adopt: (view2) => this.adopt(view2)
|
|
361
|
+
});
|
|
362
|
+
for (let state of this.states) this.keyRing.attach(state);
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
get keyframeEvery() {
|
|
366
|
+
return this.every;
|
|
367
|
+
}
|
|
368
|
+
keyframe(tick) {
|
|
369
|
+
let keyframes = this.keyframes, ring = this.keyRing;
|
|
370
|
+
return keyframes === null || ring === null || tick % this.every !== 0 ? false : (this.check(keyframes.engine_world_keyframe_save(this.world, tick >>> 0), "keyframe save"), ring.save(tick / this.every), true);
|
|
371
|
+
}
|
|
372
|
+
nearestKeyframe(at) {
|
|
373
|
+
let keyframes = this.keyframes;
|
|
374
|
+
if (keyframes === null) return null;
|
|
375
|
+
let label = keyframes.engine_world_keyframe_nearest(this.world, at >>> 0);
|
|
376
|
+
return label === (-3) ? null : this.check(label, "keyframe nearest");
|
|
377
|
+
}
|
|
378
|
+
seekKeyframe(tick) {
|
|
379
|
+
let keyframes = this.keyframes, ring = this.keyRing;
|
|
380
|
+
if (keyframes === null || ring === null || tick % this.every !== 0 || (this.beforeRestore(), !ring.has(tick / this.every))) return false;
|
|
381
|
+
let code = keyframes.engine_world_keyframe_seek(this.world, tick >>> 0);
|
|
382
|
+
return code === (-3) ? false : (this.check(code, "keyframe seek"), ring.restore(tick / this.every), this.ring.clear(), this.truncateKeyframes(tick), true);
|
|
383
|
+
}
|
|
384
|
+
truncateKeyframes(after) {
|
|
385
|
+
this.keyframes !== null && (this.check(this.keyframes.engine_world_keyframe_truncate(this.world, after >>> 0), "keyframe truncate"), this.keyRing?.dropAfter(Math.floor(after / this.every)));
|
|
386
|
+
}
|
|
387
|
+
clearKeyframes() {
|
|
388
|
+
this.keyframes !== null && (this.clear(), this.keyRing?.clear());
|
|
389
|
+
}
|
|
390
|
+
keyframeStats() {
|
|
391
|
+
if (this.keyframes === null) return null;
|
|
392
|
+
let at = this.keyframes.engine_world_keyframe_registers(this.world), r = new Uint32Array(this.memory.buffer, at, (8));
|
|
393
|
+
return {
|
|
394
|
+
frames: r[(0)],
|
|
395
|
+
oldest: optionalFrame(r[(1)]),
|
|
396
|
+
newest: optionalFrame(r[(2)]),
|
|
397
|
+
leavesUsed: r[(3)],
|
|
398
|
+
leavesShared: r[(4)],
|
|
399
|
+
captures: r[(5)],
|
|
400
|
+
evicted: r[(6)],
|
|
401
|
+
installs: r[(7)]
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
get stateBreaks() {
|
|
405
|
+
return this.ring.breaks;
|
|
406
|
+
}
|
|
407
|
+
save(tick) {
|
|
408
|
+
let dirty = this.check(this.exports.engine_world_snapshot_save(this.world, tick >>> 0), "snapshot save");
|
|
409
|
+
return this.ring.save(tick >>> 0), dirty;
|
|
410
|
+
}
|
|
411
|
+
restore(tick) {
|
|
412
|
+
if (this.beforeRestore(), !this.ring.has(tick >>> 0)) return false;
|
|
413
|
+
let code = this.exports.engine_world_snapshot_restore(this.world, tick >>> 0);
|
|
414
|
+
return code === (-3) ? false : (this.check(code, "snapshot restore"), this.ring.restore(tick >>> 0));
|
|
415
|
+
}
|
|
416
|
+
clear() {
|
|
417
|
+
this.check(this.exports.engine_world_snapshot_clear(this.world), "snapshot clear"), this.ring.clear();
|
|
418
|
+
}
|
|
419
|
+
adopt(view2) {
|
|
420
|
+
if (this.exports.engine_world_snapshot_track(this.world, view2.byteOffset, view2.byteLength, (0)) === (-1)) throw new GameError("capacity_exceeded", "rollback trackedBytes is too small for the game's engine-memory state");
|
|
421
|
+
}
|
|
422
|
+
track(view2, policy = "scan") {
|
|
423
|
+
this.owned(view2), this.check(this.exports.engine_world_snapshot_track(this.world, view2.byteOffset, view2.byteLength, policyCode(policy)), "snapshot track");
|
|
424
|
+
}
|
|
425
|
+
trackTable(table, policy = "scan") {
|
|
426
|
+
this.check(this.exports.engine_world_snapshot_track_table(this.world, table, policyCode(policy)), "snapshot track table");
|
|
427
|
+
}
|
|
428
|
+
untrack(view2) {
|
|
429
|
+
this.owned(view2), this.check(this.exports.engine_world_snapshot_untrack(this.world, view2.byteOffset), "snapshot untrack");
|
|
430
|
+
}
|
|
431
|
+
mark(view2, from = 0, to) {
|
|
432
|
+
let stride = view2.BYTES_PER_ELEMENT, end = Math.min(to ?? view2.byteLength / stride, view2.byteLength / stride);
|
|
433
|
+
return end <= from ? false : this.exports.engine_world_snapshot_mark(this.world, view2.byteOffset + from * stride, (end - from) * stride) === 1;
|
|
434
|
+
}
|
|
435
|
+
digest() {
|
|
436
|
+
return this.digestAt === 0 && (this.digestAt = this.exports.engine_alloc((8), (8))), this.check(this.exports.engine_world_snapshot_digest(this.world, this.digestAt), "snapshot digest"), new DataView(this.memory.buffer, this.digestAt, (8)).getBigUint64(0, true);
|
|
437
|
+
}
|
|
438
|
+
stats() {
|
|
439
|
+
let r = this.registers();
|
|
440
|
+
return {
|
|
441
|
+
depth: r[(0)],
|
|
442
|
+
newest: optionalFrame(r[(1)]),
|
|
443
|
+
oldest: optionalFrame(r[(2)]),
|
|
444
|
+
dirtyPages: r[(3)],
|
|
445
|
+
scannedPages: r[(4)],
|
|
446
|
+
restoredPages: r[(5)],
|
|
447
|
+
saveMs: r[(6)] / (1e6),
|
|
448
|
+
restoreMs: r[(7)] / (1e6),
|
|
449
|
+
evicted: r[(8)],
|
|
450
|
+
heapBytes: r[(9)],
|
|
451
|
+
trackedPages: r[(10)],
|
|
452
|
+
spilled: r[(11)] !== 0,
|
|
453
|
+
breaks: r[(12)] + this.ring.breaks,
|
|
454
|
+
residents: r[(13)],
|
|
455
|
+
quietPages: r[(14)],
|
|
456
|
+
missedPages: r[(15)]
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
registers() {
|
|
460
|
+
let at = this.exports.engine_world_snapshot_registers(this.world), buffer = this.memory.buffer;
|
|
461
|
+
return (this.view.buffer !== buffer || this.view.byteOffset !== at) && (this.view = new Uint32Array(buffer, at, (16))), this.view;
|
|
462
|
+
}
|
|
463
|
+
owned(view2) {
|
|
464
|
+
if (view2.buffer !== this.memory.buffer) throw new GameError("invalid_argument", "rolled-back views must live in engine memory");
|
|
465
|
+
}
|
|
466
|
+
check(code, what) {
|
|
467
|
+
if (code >= 0) return code;
|
|
468
|
+
throw new GameError(code === (-3) ? "unknown_resource" : "invalid_argument", `${what} failed (${code})`);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// src/game/audio/engine.ts
|
|
473
|
+
var MUSIC_EXPORTS = [
|
|
474
|
+
"engine_audio_music_tempo",
|
|
475
|
+
"engine_audio_music_play",
|
|
476
|
+
"engine_audio_music_layer",
|
|
477
|
+
"engine_audio_music_stinger",
|
|
478
|
+
"engine_audio_music_stop",
|
|
479
|
+
"engine_audio_music_position"
|
|
480
|
+
], WORD_BYTES = 4, DOUBLE_WORD_BYTES = 8, MUSIC_POSITION_OFFSET = 2 * MAX_STEMS * (4), MUSIC_OCCLUSION_OFFSET = MUSIC_POSITION_OFFSET + MUSIC_POSITION_WORDS * (8), MUSIC_STAGING_BYTES = MUSIC_OCCLUSION_OFFSET + OCCLUSION_WORDS * (4), ENGINE_SAMPLE_RATE = 48e3, ENGINE_AUDIO_EXPORT_NAMES = [
|
|
481
|
+
"engine_audio_bound",
|
|
482
|
+
"engine_audio_load_pcm",
|
|
483
|
+
"engine_audio_load_wav",
|
|
484
|
+
"engine_audio_release",
|
|
485
|
+
"engine_audio_create_bus",
|
|
486
|
+
"engine_audio_set_bus_gain",
|
|
487
|
+
"engine_audio_set_bus_filter",
|
|
488
|
+
"engine_audio_set_duck",
|
|
489
|
+
"engine_audio_play",
|
|
490
|
+
"engine_audio_stop",
|
|
491
|
+
"engine_audio_set_voice_gain",
|
|
492
|
+
"engine_audio_set_voice_rate",
|
|
493
|
+
"engine_audio_is_playing",
|
|
494
|
+
"engine_audio_set_listener",
|
|
495
|
+
"engine_audio_place",
|
|
496
|
+
"engine_audio_set_voice_spatial",
|
|
497
|
+
"engine_audio_registers",
|
|
498
|
+
"engine_audio_update",
|
|
499
|
+
"engine_audio_meter",
|
|
500
|
+
"engine_audio_suspend",
|
|
501
|
+
"engine_audio_resume",
|
|
502
|
+
"engine_audio_reset"
|
|
503
|
+
];
|
|
504
|
+
var ENGINE_AUDIO_LOCKSTEP_EXPORTS = [
|
|
505
|
+
"engine_audio_lockstep",
|
|
506
|
+
"engine_audio_clock",
|
|
507
|
+
"engine_audio_create_emitters",
|
|
508
|
+
"engine_audio_feed_emitters",
|
|
509
|
+
"engine_audio_release_emitters"
|
|
510
|
+
], ENGINE_AUDIO_WORKLET_EXPORTS = ["engine_audio_relay_create", "engine_audio_relay_pump", "engine_audio_relay_receive"], STREAM_EXPORTS = [
|
|
511
|
+
"engine_audio_stream_open",
|
|
512
|
+
"engine_audio_stream_feed",
|
|
513
|
+
"engine_audio_stream_space",
|
|
514
|
+
"engine_audio_stream_play",
|
|
515
|
+
"engine_audio_stream_gain",
|
|
516
|
+
"engine_audio_stream_flush",
|
|
517
|
+
"engine_audio_stream_time",
|
|
518
|
+
"engine_audio_stream_close"
|
|
519
|
+
], COMPRESSED_STREAM_EXPORTS = [
|
|
520
|
+
"engine_audio_stream_open_opus",
|
|
521
|
+
"engine_audio_stream_seek",
|
|
522
|
+
"engine_audio_stream_loop",
|
|
523
|
+
"engine_audio_stream_duration",
|
|
524
|
+
"engine_audio_stream_time"
|
|
525
|
+
], STREAM_BUFFER_SECONDS = 2, STREAM_CHUNK_FRAMES = 4096, STREAM_FADE_SECONDS = 0.02, DOUBLE_BYTES = 8, OPUS_RATE = 48e3, OGG_MAGIC = 1399285583;
|
|
526
|
+
function isOgg(bytes) {
|
|
527
|
+
return bytes.byteLength >= (4) && new DataView(bytes.buffer, bytes.byteOffset).getUint32(0, true) === (1399285583);
|
|
528
|
+
}
|
|
529
|
+
var FULL_SOUND_PRIORITY = 1, PREVIEW_HANDOVER_SECONDS = 0.03, PREVIEW_RELEASE_MS = 1e3;
|
|
530
|
+
function decodeWith(decoder, bytes) {
|
|
531
|
+
return new Promise((resolve, reject) => {
|
|
532
|
+
decoder(bytes, (samples, channels, sampleRate) => {
|
|
533
|
+
if (samples === null || channels < 1 || sampleRate <= 0 || samples.length % channels !== 0) {
|
|
534
|
+
reject(new GameError("asset_load_failed", "the host could not decode the sound"));
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
resolve({ samples, channels, sampleRate });
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
var NO_HANDLE = 0, NO_VOICE = -1, SILENT = -1, MASTER_BUS = 0, MASTER_PARENT = -1, PLAY_LOOP = 1, PLAY_SPATIAL = 2, FLOAT_BYTES = 4, WAV_MAGIC = 1179011410, REGISTERS = 4, REGISTER_DELTA_SECONDS = 0, EngineAudioPort = class {
|
|
542
|
+
constructor(host, maxVoices = 64) {
|
|
543
|
+
this.name = "cimplify-audio";
|
|
544
|
+
this.pending = 0;
|
|
545
|
+
this.unlockedValue = false;
|
|
546
|
+
this.busCount = 0;
|
|
547
|
+
this.sampleRate = (48e3);
|
|
548
|
+
this.analysers = [];
|
|
549
|
+
this.analyserBus = [];
|
|
550
|
+
this.capture = 0;
|
|
551
|
+
this.captureBytes = 0;
|
|
552
|
+
this.captureFloats = null;
|
|
553
|
+
this.streams = /* @__PURE__ */ new Map();
|
|
554
|
+
/** Each previewed sound's full file, once decoded: plays use it in place of the preview. */
|
|
555
|
+
this.refined = /* @__PURE__ */ new Map();
|
|
556
|
+
this.streamList = [];
|
|
557
|
+
this.streamPointer = 0;
|
|
558
|
+
this.streamBytes = 0;
|
|
559
|
+
this.streamFloats = null;
|
|
560
|
+
this.emitterColumns = 0;
|
|
561
|
+
this.musicStaging = 0;
|
|
562
|
+
this.occlusionWorld = null;
|
|
563
|
+
if (this.host = host, this.handle = host.handle ?? host.exports.engine_audio_bound(), this.handle === (0)) throw new GameError("unsupported_feature", "the host has no native audio engine bound");
|
|
564
|
+
this.maxVoices = maxVoices;
|
|
565
|
+
let floats = 16 * (maxVoices + 1);
|
|
566
|
+
this.stagingBytes = (floats + 2 * maxVoices) * (4), this.staging = host.allocate(this.stagingBytes);
|
|
567
|
+
let buffer = host.memory.buffer;
|
|
568
|
+
this.listener = new Float32Array(buffer, this.staging, 16), this.column = new Float32Array(buffer, this.staging + 16 * (4), 16 * maxVoices), this.voices = new Int32Array(buffer, this.staging + floats * (4), maxVoices), this.offsets = new Uint32Array(buffer, this.staging + (floats + maxVoices) * (4), maxVoices);
|
|
569
|
+
for (let i = 0; i < maxVoices; i++) this.offsets[i] = i * 16;
|
|
570
|
+
this.registers = new Float32Array(buffer, host.exports.engine_audio_registers(this.handle), (4));
|
|
571
|
+
let has = (name) => typeof host.exports[name] == "function";
|
|
572
|
+
this.caps = {
|
|
573
|
+
spatial: true,
|
|
574
|
+
filters: true,
|
|
575
|
+
meters: true,
|
|
576
|
+
analyser: has("engine_audio_capture"),
|
|
577
|
+
reverb: has("engine_audio_create_convolver"),
|
|
578
|
+
sends: has("engine_audio_set_bus_send"),
|
|
579
|
+
loopPoints: has("engine_audio_set_voice_loop"),
|
|
580
|
+
streaming: STREAM_EXPORTS.every(has) && (host.decode !== void 0 && host.decode !== null || COMPRESSED_STREAM_EXPORTS.every(has)),
|
|
581
|
+
detune: true,
|
|
582
|
+
procedural: true,
|
|
583
|
+
emitters: ENGINE_AUDIO_LOCKSTEP_EXPORTS.every(has),
|
|
584
|
+
lockstep: ENGINE_AUDIO_LOCKSTEP_EXPORTS.every(has),
|
|
585
|
+
voiceLimits: has("engine_audio_set_sound_limit") && has("engine_audio_set_voice_budget"),
|
|
586
|
+
voiceFilters: has("engine_audio_set_voice_filter"),
|
|
587
|
+
limiter: has("engine_audio_set_limiter"),
|
|
588
|
+
scheduling: has("engine_audio_now") && has("engine_audio_play_at") && has("engine_audio_stop_at"),
|
|
589
|
+
music: MUSIC_EXPORTS.every(has),
|
|
590
|
+
binaural: has("engine_audio_set_voice_binaural"),
|
|
591
|
+
occlusion: has("engine_audio_set_voice_occlusion") && has("engine_audio_occlude")
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
/** The physics world occlusion rays are cast against, read once per frame. */
|
|
595
|
+
bindOcclusionWorld(world) {
|
|
596
|
+
this.occlusionWorld = world;
|
|
597
|
+
}
|
|
598
|
+
musicView() {
|
|
599
|
+
this.musicStaging === 0 && (this.musicStaging = this.host.allocate(MUSIC_STAGING_BYTES));
|
|
600
|
+
let buffer = this.host.memory.buffer, base = this.musicStaging;
|
|
601
|
+
return {
|
|
602
|
+
sounds: new Int32Array(buffer, base, MAX_STEMS),
|
|
603
|
+
gains: new Float32Array(buffer, base + MAX_STEMS * (4), MAX_STEMS),
|
|
604
|
+
position: new Float64Array(buffer, base + MUSIC_POSITION_OFFSET, MUSIC_POSITION_WORDS),
|
|
605
|
+
occlusion: new Float32Array(buffer, base + MUSIC_OCCLUSION_OFFSET, OCCLUSION_WORDS)
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
nowFrame() {
|
|
609
|
+
let now = this.host.exports.engine_audio_now;
|
|
610
|
+
if (!now) throw unsupported("sample-accurate scheduling");
|
|
611
|
+
let view2 = this.musicView().position;
|
|
612
|
+
if (now(this.handle, view2.byteOffset) < 0) throw new GameError("invalid_argument", "the audio clock could not be read");
|
|
613
|
+
return view2[0];
|
|
614
|
+
}
|
|
615
|
+
playOn(previewed, bus, gain, rate, loop, spatial, priority, frame) {
|
|
616
|
+
let playAt = this.host.exports.engine_audio_play_at;
|
|
617
|
+
if (!playAt) throw unsupported("sample-accurate scheduling");
|
|
618
|
+
let sound = this.refined.get(previewed) ?? previewed;
|
|
619
|
+
if (sound === (-1)) return (-1);
|
|
620
|
+
let flags = (loop ? (1) : 0) | (spatial ? (2) : 0) | (priority & PRIORITY_MASK) << PLAY_PRIORITY_SHIFT, voice = playAt(this.handle, sound, bus, gain, rate, flags, frame);
|
|
621
|
+
return voice < 0 ? (-1) : voice;
|
|
622
|
+
}
|
|
623
|
+
stopOn(voice, frame, fadeSeconds) {
|
|
624
|
+
voice !== (-1) && this.host.exports.engine_audio_stop_at?.(this.handle, voice, frame, fadeSeconds);
|
|
625
|
+
}
|
|
626
|
+
setVoiceBinaural(voice, binaural) {
|
|
627
|
+
let set = this.host.exports.engine_audio_set_voice_binaural;
|
|
628
|
+
if (!set) throw unsupported("binaural rendering");
|
|
629
|
+
if (voice !== (-1) && set(this.handle, voice, binaural ? 1 : 0) < 0) throw new GameError("unsupported_feature", "this engine build has no HRTF set");
|
|
630
|
+
}
|
|
631
|
+
setVoiceOcclusion(voice, params) {
|
|
632
|
+
let set = this.host.exports.engine_audio_set_voice_occlusion;
|
|
633
|
+
if (!set) throw unsupported("occlusion");
|
|
634
|
+
if (voice === (-1)) return;
|
|
635
|
+
if (params === null) {
|
|
636
|
+
set(this.handle, voice, 0);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
let view2 = this.musicView().occlusion;
|
|
640
|
+
view2.set(params.subarray(0, OCCLUSION_WORDS)), set(this.handle, voice, view2.byteOffset);
|
|
641
|
+
}
|
|
642
|
+
musicTempo(bpm, beatsPerBar, quantize) {
|
|
643
|
+
return this.host.exports.engine_audio_music_tempo?.(this.handle, bpm, beatsPerBar, quantize) ?? -1;
|
|
644
|
+
}
|
|
645
|
+
musicPlay(sounds, gains, bars, bus, quantize, fadeSeconds) {
|
|
646
|
+
let play = this.host.exports.engine_audio_music_play;
|
|
647
|
+
if (!play) return -1;
|
|
648
|
+
let view2 = this.musicView();
|
|
649
|
+
for (let i = 0; i < sounds.length; i++) view2.sounds[i] = this.refined.get(sounds[i]) ?? sounds[i];
|
|
650
|
+
view2.gains.set(gains);
|
|
651
|
+
let phrase = bars | quantize << PHRASE_QUANTIZE_SHIFT;
|
|
652
|
+
return play(this.handle, view2.sounds.byteOffset, view2.gains.byteOffset, sounds.length, phrase, bus, fadeSeconds);
|
|
653
|
+
}
|
|
654
|
+
musicLayer(layer, gain, rampSeconds) {
|
|
655
|
+
this.host.exports.engine_audio_music_layer?.(this.handle, layer, gain, rampSeconds);
|
|
656
|
+
}
|
|
657
|
+
musicStinger(previewed, bus, gain, quantize) {
|
|
658
|
+
let sound = this.refined.get(previewed) ?? previewed;
|
|
659
|
+
return this.host.exports.engine_audio_music_stinger?.(this.handle, sound, bus, gain, quantize) ?? -1;
|
|
660
|
+
}
|
|
661
|
+
musicStop(quantize, fadeSeconds) {
|
|
662
|
+
return this.host.exports.engine_audio_music_stop?.(this.handle, quantize, fadeSeconds) ?? -1;
|
|
663
|
+
}
|
|
664
|
+
musicPosition(out) {
|
|
665
|
+
let position = this.host.exports.engine_audio_music_position;
|
|
666
|
+
if (!position) return false;
|
|
667
|
+
let view2 = this.musicView().position;
|
|
668
|
+
return position(this.handle, view2.byteOffset) < 0 ? false : (out.set(view2), true);
|
|
669
|
+
}
|
|
670
|
+
setVoiceFilter(voice, kind, frequency, q, gainDb) {
|
|
671
|
+
let filter = this.host.exports.engine_audio_set_voice_filter;
|
|
672
|
+
if (!filter) throw unsupported("voice filters");
|
|
673
|
+
if (voice !== (-1) && filter(this.handle, voice, kind, frequency, q, gainDb) < 0) throw new GameError("invalid_argument", `voice ${voice} filter was rejected`);
|
|
674
|
+
}
|
|
675
|
+
setLimiter(enabled, ceilingDb, releaseSeconds) {
|
|
676
|
+
let limiter = this.host.exports.engine_audio_set_limiter;
|
|
677
|
+
if (!limiter) throw unsupported("a master limiter");
|
|
678
|
+
if (limiter(this.handle, enabled ? 1 : 0, ceilingDb, releaseSeconds) < 0) throw new GameError("invalid_argument", "the master limiter settings were rejected");
|
|
679
|
+
}
|
|
680
|
+
setSoundLimit(sound, voices, steal) {
|
|
681
|
+
let limit = this.host.exports.engine_audio_set_sound_limit;
|
|
682
|
+
if (!limit) throw unsupported("sound voice limits");
|
|
683
|
+
if (limit(this.handle, sound, voices, steal) < 0) throw new GameError("invalid_argument", `sound ${sound} cannot take that voice limit`);
|
|
684
|
+
}
|
|
685
|
+
setVoiceBudget(voices) {
|
|
686
|
+
let budget = this.host.exports.engine_audio_set_voice_budget;
|
|
687
|
+
if (!budget) throw unsupported("a voice budget");
|
|
688
|
+
if (budget(this.handle, voices) < 0) throw new GameError("invalid_argument", `the mixer cannot take a budget of ${voices} voices`);
|
|
689
|
+
}
|
|
690
|
+
lockstep(step, stepsPerSecond) {
|
|
691
|
+
this.host.exports.engine_audio_lockstep?.(this.handle, step >>> 0, stepsPerSecond);
|
|
692
|
+
}
|
|
693
|
+
flush() {
|
|
694
|
+
this.host.relay?.pump();
|
|
695
|
+
}
|
|
696
|
+
createEmitters(sound, bus, capacity, params) {
|
|
697
|
+
let create = this.host.exports.engine_audio_create_emitters;
|
|
698
|
+
if (!create) throw unsupported("emitter tables");
|
|
699
|
+
let pointer = 0;
|
|
700
|
+
if (params !== null) {
|
|
701
|
+
for (let i = 0; i < SPATIAL_WORDS; i++) this.listener[i] = params[i];
|
|
702
|
+
pointer = this.listener.byteOffset;
|
|
703
|
+
}
|
|
704
|
+
return create(this.handle, sound, bus, capacity, pointer);
|
|
705
|
+
}
|
|
706
|
+
feedEmitters(bank, table, columns) {
|
|
707
|
+
let feed = this.host.exports.engine_audio_feed_emitters;
|
|
708
|
+
return feed ? (this.emitterColumns === 0 && (this.emitterColumns = this.host.allocate(EMITTER_COLUMNS * (4))), new Uint32Array(this.host.memory.buffer, this.emitterColumns, EMITTER_COLUMNS).set(columns), feed(this.handle, bank, table, this.emitterColumns)) : 0;
|
|
709
|
+
}
|
|
710
|
+
releaseEmitters(bank) {
|
|
711
|
+
this.host.exports.engine_audio_release_emitters?.(this.handle, bank);
|
|
712
|
+
}
|
|
713
|
+
meter(bus, out) {
|
|
714
|
+
let pointer = this.listener.byteOffset;
|
|
715
|
+
this.host.exports.engine_audio_meter(this.handle, bus, pointer), out[METER_PEAK] = this.listener[0], out[METER_RMS] = this.listener[1];
|
|
716
|
+
}
|
|
717
|
+
get capabilities() {
|
|
718
|
+
return this.caps;
|
|
719
|
+
}
|
|
720
|
+
createSound(samples, channels, sampleRate) {
|
|
721
|
+
if (channels < 1 || sampleRate <= 0 || samples.length % channels !== 0) throw new GameError("invalid_argument", "sound PCM must be interleaved whole frames");
|
|
722
|
+
let pointer = this.host.allocate(samples.byteLength);
|
|
723
|
+
try {
|
|
724
|
+
return new Float32Array(this.host.memory.buffer, pointer, samples.length).set(samples), this.check(this.host.exports.engine_audio_load_pcm(this.handle, pointer, samples.length / channels, channels, sampleRate), "load sound");
|
|
725
|
+
} finally {
|
|
726
|
+
this.host.release(pointer, samples.byteLength);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
setVoiceGain(voice, gain, rampSeconds) {
|
|
730
|
+
voice !== (-1) && this.host.exports.engine_audio_set_voice_gain(this.handle, voice, gain, rampSeconds);
|
|
731
|
+
}
|
|
732
|
+
setVoiceRate(voice, rate, detuneCents) {
|
|
733
|
+
voice !== (-1) && this.host.exports.engine_audio_set_voice_rate(this.handle, voice, detuneRate(rate, detuneCents));
|
|
734
|
+
}
|
|
735
|
+
setVoiceSpatial(voice, params) {
|
|
736
|
+
if (voice !== (-1)) {
|
|
737
|
+
for (let i = 0; i < SPATIAL_WORDS; i++) this.listener[i] = params[i];
|
|
738
|
+
this.host.exports.engine_audio_set_voice_spatial(this.handle, voice, this.listener.byteOffset);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
setVoiceLoop(voice, loop, startSeconds, endSeconds) {
|
|
742
|
+
let setLoop = this.host.exports.engine_audio_set_voice_loop;
|
|
743
|
+
if (!setLoop) throw unsupported("loop points");
|
|
744
|
+
voice !== (-1) && setLoop(this.handle, voice, loop ? 1 : 0, startSeconds, endSeconds);
|
|
745
|
+
}
|
|
746
|
+
setBusFilter(bus, kind, frequency, q, gainDb) {
|
|
747
|
+
if (this.host.exports.engine_audio_set_bus_filter(this.handle, bus, kind, frequency, q, gainDb) < 0) throw new GameError("invalid_argument", `bus ${bus} filter was rejected`);
|
|
748
|
+
}
|
|
749
|
+
createAnalyser(bus, settings) {
|
|
750
|
+
if (!this.host.exports.engine_audio_capture) throw unsupported("the analyser");
|
|
751
|
+
let bytes = settings.fftSize * (4);
|
|
752
|
+
return bytes > this.captureBytes && (this.capture !== 0 && this.host.release(this.capture, this.captureBytes), this.capture = this.host.allocate(bytes), this.captureBytes = bytes), this.analysers.push(new FftAnalyser(settings)), this.analyserBus.push(bus), this.analysers.length - 1;
|
|
753
|
+
}
|
|
754
|
+
readAnalyser(analyser, mode, out) {
|
|
755
|
+
let capture = this.host.exports.engine_audio_capture, found = this.analysers[analyser];
|
|
756
|
+
if (!capture || !found) throw new GameError("unknown_resource", `analyser ${analyser} does not exist`);
|
|
757
|
+
let frames = capture(this.handle, this.analyserBus[analyser], this.capture, found.fftSize);
|
|
758
|
+
frames > 0 && found.push(this.captureView(), 0, Math.min(frames, found.fftSize)), mode === ANALYSER_FREQUENCY ? found.frequency(out) : found.timeDomain(out);
|
|
759
|
+
}
|
|
760
|
+
captureView() {
|
|
761
|
+
let buffer = this.host.memory.buffer, view2 = this.captureFloats;
|
|
762
|
+
return (view2 === null || view2.buffer !== buffer || view2.byteOffset !== this.capture) && (view2 = new Float32Array(buffer, this.capture, this.captureBytes / (4)), this.captureFloats = view2), view2;
|
|
763
|
+
}
|
|
764
|
+
createReverb(parent, impulse) {
|
|
765
|
+
let create = this.host.exports.engine_audio_create_convolver;
|
|
766
|
+
if (!create) throw unsupported("convolution reverb");
|
|
767
|
+
let bus = create(this.handle, parent, impulse);
|
|
768
|
+
if (bus < 0) throw new GameError("capacity_exceeded", "the audio mixer has no free reverb bus");
|
|
769
|
+
return this.busCount++, bus;
|
|
770
|
+
}
|
|
771
|
+
setBusSend(bus, target, gain) {
|
|
772
|
+
let send = this.host.exports.engine_audio_set_bus_send;
|
|
773
|
+
if (!send) throw unsupported("bus sends");
|
|
774
|
+
if (send(this.handle, bus, target, gain, 0) < 0) throw new GameError("invalid_argument", `bus ${bus} cannot send to ${target}`);
|
|
775
|
+
}
|
|
776
|
+
async openStream(source, bus) {
|
|
777
|
+
let exports = this.host.exports, open = exports.engine_audio_stream_open;
|
|
778
|
+
if (!this.caps.streaming || !open) throw unsupported("streaming music");
|
|
779
|
+
let bytes = await this.bytes(source);
|
|
780
|
+
if (isOgg(bytes) && COMPRESSED_STREAM_EXPORTS.every((name) => typeof exports[name] == "function")) return this.openCompressed(bytes, bus);
|
|
781
|
+
if (!this.host.decode) throw unsupported("streaming music");
|
|
782
|
+
let pcm = await decodeWith(this.host.decode, bytes), id = open(this.handle, bus, pcm.channels, pcm.sampleRate, Math.ceil(pcm.sampleRate * (2)));
|
|
783
|
+
if (id < 0) throw new GameError("capacity_exceeded", "the audio mixer has no free stream");
|
|
784
|
+
let entry = {
|
|
785
|
+
id,
|
|
786
|
+
pcm,
|
|
787
|
+
frames: pcm.samples.length / pcm.channels,
|
|
788
|
+
sampleRate: pcm.sampleRate,
|
|
789
|
+
cursor: 0,
|
|
790
|
+
loop: false,
|
|
791
|
+
playing: false,
|
|
792
|
+
fed: 0,
|
|
793
|
+
baseSeconds: 0,
|
|
794
|
+
baseFed: 0
|
|
795
|
+
};
|
|
796
|
+
return this.streams.set(id, entry), this.streamList.push(entry), this.streamStaging((4096) * pcm.channels), this.feedStream(this.stream(id)), id;
|
|
797
|
+
}
|
|
798
|
+
/** An Ogg Opus file the engine keeps compressed and decodes a buffer ahead of the mixer. */
|
|
799
|
+
openCompressed(bytes, bus) {
|
|
800
|
+
let exports = this.host.exports, open = exports.engine_audio_stream_open_opus, duration = exports.engine_audio_stream_duration;
|
|
801
|
+
if (!open || !duration) throw unsupported("compressed streaming");
|
|
802
|
+
let pointer = this.host.allocate(bytes.byteLength), id;
|
|
803
|
+
try {
|
|
804
|
+
new Uint8Array(this.host.memory.buffer, pointer, bytes.byteLength).set(bytes), id = open(this.handle, bus, pointer, bytes.byteLength, Math.ceil((48e3) * (2)));
|
|
805
|
+
} finally {
|
|
806
|
+
this.host.release(pointer, bytes.byteLength);
|
|
807
|
+
}
|
|
808
|
+
if (id < 0) throw new GameError("asset_load_failed", `the stream could not open (${id})`);
|
|
809
|
+
this.streamStaging((4096)), duration(this.handle, id, this.streamPointer);
|
|
810
|
+
let seconds = new DataView(this.host.memory.buffer).getFloat64(this.streamPointer, true), entry = {
|
|
811
|
+
id,
|
|
812
|
+
pcm: null,
|
|
813
|
+
frames: Math.round(seconds * (48e3)),
|
|
814
|
+
sampleRate: (48e3),
|
|
815
|
+
cursor: 0,
|
|
816
|
+
loop: false,
|
|
817
|
+
playing: false,
|
|
818
|
+
fed: 0,
|
|
819
|
+
baseSeconds: 0,
|
|
820
|
+
baseFed: 0
|
|
821
|
+
};
|
|
822
|
+
return this.streams.set(id, entry), this.streamList.push(entry), id;
|
|
823
|
+
}
|
|
824
|
+
stream(id) {
|
|
825
|
+
let found = this.streams.get(id);
|
|
826
|
+
if (!found) throw new GameError("unknown_resource", `stream ${id} is not open`);
|
|
827
|
+
return found;
|
|
828
|
+
}
|
|
829
|
+
streamStaging(floats) {
|
|
830
|
+
let bytes = Math.max(floats * (4), (8));
|
|
831
|
+
bytes <= this.streamBytes || (this.streamPointer !== 0 && this.host.release(this.streamPointer, this.streamBytes), this.streamPointer = this.host.allocate(bytes), this.streamBytes = bytes);
|
|
832
|
+
}
|
|
833
|
+
streamView() {
|
|
834
|
+
let buffer = this.host.memory.buffer, view2 = this.streamFloats;
|
|
835
|
+
return (view2 === null || view2.buffer !== buffer || view2.byteOffset !== this.streamPointer || view2.byteLength !== this.streamBytes) && (view2 = new Float32Array(buffer, this.streamPointer, this.streamBytes / (4)), this.streamFloats = view2), view2;
|
|
836
|
+
}
|
|
837
|
+
feedStream(stream) {
|
|
838
|
+
let exports = this.host.exports, feed = exports.engine_audio_stream_feed, space = exports.engine_audio_stream_space, pcm = stream.pcm;
|
|
839
|
+
if (!feed || !space || pcm === null) return;
|
|
840
|
+
let channels = pcm.channels, room = space(this.handle, stream.id);
|
|
841
|
+
for (; room > 0; ) {
|
|
842
|
+
if (stream.cursor >= stream.frames) {
|
|
843
|
+
if (!stream.loop) return;
|
|
844
|
+
stream.cursor = 0;
|
|
845
|
+
}
|
|
846
|
+
let frames = Math.min(room, (4096), stream.frames - stream.cursor), view2 = this.streamView(), source = pcm.samples, from = stream.cursor * channels;
|
|
847
|
+
for (let i = 0; i < frames * channels; i++) view2[i] = source[from + i];
|
|
848
|
+
let accepted = feed(this.handle, stream.id, this.streamPointer, frames, channels);
|
|
849
|
+
if (accepted <= 0) return;
|
|
850
|
+
stream.cursor += accepted, stream.fed += accepted, room -= accepted;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
playStream(stream, gain, loop) {
|
|
854
|
+
let found = this.stream(stream);
|
|
855
|
+
found.loop = loop, found.playing = true, found.pcm === null && this.host.exports.engine_audio_stream_loop?.(this.handle, stream, loop ? 1 : 0), this.feedStream(found), this.host.exports.engine_audio_stream_gain?.(this.handle, stream, gain, 0), this.host.exports.engine_audio_stream_play?.(this.handle, stream, 1, (0.02));
|
|
856
|
+
}
|
|
857
|
+
pauseStream(stream) {
|
|
858
|
+
this.stream(stream).playing = false, this.host.exports.engine_audio_stream_play?.(this.handle, stream, 0, (0.02));
|
|
859
|
+
}
|
|
860
|
+
seekStream(stream, seconds) {
|
|
861
|
+
let found = this.stream(stream), clamped = Math.min(Math.max(seconds, 0), found.frames / found.sampleRate);
|
|
862
|
+
if (found.pcm === null) {
|
|
863
|
+
this.host.exports.engine_audio_stream_seek?.(this.handle, stream, clamped);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
this.host.exports.engine_audio_stream_flush?.(this.handle, stream), found.cursor = Math.floor(clamped * found.sampleRate), found.baseSeconds = clamped, found.baseFed = found.fed, this.feedStream(found);
|
|
867
|
+
}
|
|
868
|
+
streamTime(stream) {
|
|
869
|
+
let found = this.stream(stream), time = this.host.exports.engine_audio_stream_time;
|
|
870
|
+
if (!time) return found.baseSeconds;
|
|
871
|
+
time(this.handle, stream, this.streamPointer);
|
|
872
|
+
let consumed = new DataView(this.host.memory.buffer).getFloat64(this.streamPointer, true), duration = found.frames / found.sampleRate;
|
|
873
|
+
if (found.pcm === null) return Math.min(consumed, duration);
|
|
874
|
+
let played = found.baseSeconds + Math.max(0, consumed - found.baseFed / found.sampleRate);
|
|
875
|
+
return found.loop && duration > 0 ? played % duration : Math.min(played, duration);
|
|
876
|
+
}
|
|
877
|
+
streamDuration(stream) {
|
|
878
|
+
let found = this.stream(stream);
|
|
879
|
+
return found.frames / found.sampleRate;
|
|
880
|
+
}
|
|
881
|
+
closeStream(stream) {
|
|
882
|
+
let found = this.stream(stream);
|
|
883
|
+
this.host.exports.engine_audio_stream_close?.(this.handle, stream), this.streams.delete(stream), this.streamList.splice(this.streamList.indexOf(found), 1);
|
|
884
|
+
}
|
|
885
|
+
get unlocked() {
|
|
886
|
+
return this.unlockedValue;
|
|
887
|
+
}
|
|
888
|
+
unlock() {
|
|
889
|
+
this.unlockedValue = true;
|
|
890
|
+
}
|
|
891
|
+
async decode(source) {
|
|
892
|
+
let assets = this.host.assets;
|
|
893
|
+
if ("url" in source && assets?.has?.(source.url + AUDIO_PREVIEW_SUFFIX) === true) {
|
|
894
|
+
let preview = await this.decodeBytes(await assets.take(source.url + AUDIO_PREVIEW_SUFFIX));
|
|
895
|
+
return this.refine(preview, assets, source.url), preview;
|
|
896
|
+
}
|
|
897
|
+
return this.decodeBytes(await this.bytes(source));
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Decodes a sound's full file after its preview, moves every voice playing the preview onto it at the same moment
|
|
901
|
+
* with a short crossfade, and plays the full file from then on. The preview is freed once its fade has finished.
|
|
902
|
+
*/
|
|
903
|
+
async refine(preview, assets, url) {
|
|
904
|
+
let full;
|
|
905
|
+
try {
|
|
906
|
+
full = await this.decodeBytes(await assets.take(url, (1), !1));
|
|
907
|
+
} catch {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
this.refined.set(preview, full);
|
|
911
|
+
let replace = this.host.exports.engine_audio_replace;
|
|
912
|
+
replace === void 0 || replace(this.handle, preview, full, (0.03)) < 0 || setTimeout(() => this.host.exports.engine_audio_release(this.handle, preview), (1e3));
|
|
913
|
+
}
|
|
914
|
+
async decodeBytes(bytes) {
|
|
915
|
+
if (bytes.byteLength >= (4) && new DataView(bytes.buffer, bytes.byteOffset).getUint32(0, true) === (1179011410)) return this.loadWave(bytes);
|
|
916
|
+
if (!this.host.decode) throw new GameError("asset_load_failed", "compressed audio needs the host decoder");
|
|
917
|
+
let pcm = await decodeWith(this.host.decode, bytes), frames = pcm.samples.length / pcm.channels, pointer = this.host.allocate(pcm.samples.byteLength);
|
|
918
|
+
try {
|
|
919
|
+
return new Float32Array(this.host.memory.buffer, pointer, pcm.samples.length).set(pcm.samples), this.check(this.host.exports.engine_audio_load_pcm(this.handle, pointer, frames, pcm.channels, pcm.sampleRate), "load sound");
|
|
920
|
+
} finally {
|
|
921
|
+
this.host.release(pointer, pcm.samples.byteLength);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
loadWave(bytes) {
|
|
925
|
+
let pointer = this.host.allocate(bytes.byteLength);
|
|
926
|
+
try {
|
|
927
|
+
return new Uint8Array(this.host.memory.buffer, pointer, bytes.byteLength).set(bytes), this.check(this.host.exports.engine_audio_load_wav(this.handle, pointer, bytes.byteLength), "load sound");
|
|
928
|
+
} finally {
|
|
929
|
+
this.host.release(pointer, bytes.byteLength);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
async bytes(source) {
|
|
933
|
+
if ("bytes" in source) return new Uint8Array(source.bytes);
|
|
934
|
+
if (!("url" in source)) throw new GameError("asset_load_failed", "sounds load from bytes or a url");
|
|
935
|
+
if (this.host.assets) return this.host.assets.take(source.url);
|
|
936
|
+
let response = await fetch(source.url);
|
|
937
|
+
if (!response.ok) throw new GameError("asset_load_failed", `sound ${source.url} failed with ${response.status}`);
|
|
938
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
939
|
+
}
|
|
940
|
+
check(code, what) {
|
|
941
|
+
if (code < 0) throw new GameError("asset_load_failed", `${what} failed with ${code}`);
|
|
942
|
+
return code;
|
|
943
|
+
}
|
|
944
|
+
createBus(_name, parent) {
|
|
945
|
+
if (parent === (-1))
|
|
946
|
+
return this.busCount = Math.max(this.busCount, 1), (0);
|
|
947
|
+
let bus = this.host.exports.engine_audio_create_bus(this.handle, parent);
|
|
948
|
+
if (bus < 0) throw new GameError("capacity_exceeded", "the audio mixer has no free bus");
|
|
949
|
+
return this.busCount++, bus;
|
|
950
|
+
}
|
|
951
|
+
setBusGain(bus, gain, rampSeconds) {
|
|
952
|
+
this.host.exports.engine_audio_set_bus_gain(this.handle, bus, gain, rampSeconds);
|
|
953
|
+
}
|
|
954
|
+
play(previewed, bus, gain, rate, loop, spatial, priority = DEFAULT_PRIORITY) {
|
|
955
|
+
let sound = this.refined.get(previewed) ?? previewed;
|
|
956
|
+
if (sound === (-1)) return (-1);
|
|
957
|
+
let flags = (loop ? (1) : 0) | (spatial ? (2) : 0) | (priority & PRIORITY_MASK) << PLAY_PRIORITY_SHIFT, voice = this.host.exports.engine_audio_play(this.handle, sound, bus, gain, rate, flags);
|
|
958
|
+
return voice < 0 ? (-1) : voice;
|
|
959
|
+
}
|
|
960
|
+
stop(voice, fadeSeconds) {
|
|
961
|
+
voice !== (-1) && this.host.exports.engine_audio_stop(this.handle, voice, fadeSeconds);
|
|
962
|
+
}
|
|
963
|
+
isPlaying(voice) {
|
|
964
|
+
return voice !== (-1) && this.host.exports.engine_audio_is_playing(this.handle, voice) === 1;
|
|
965
|
+
}
|
|
966
|
+
setVoicePosition(voice, matrix, offset) {
|
|
967
|
+
if (voice === (-1) || this.pending === this.maxVoices) return;
|
|
968
|
+
let slot = this.pending++;
|
|
969
|
+
this.voices[slot] = voice;
|
|
970
|
+
for (let i = 0; i < 16; i++) this.column[slot * 16 + i] = matrix[offset + i];
|
|
971
|
+
}
|
|
972
|
+
setListener(matrix, offset) {
|
|
973
|
+
for (let i = 0; i < 16; i++) this.listener[i] = matrix[offset + i];
|
|
974
|
+
this.host.exports.engine_audio_set_listener(this.handle, this.listener.byteOffset);
|
|
975
|
+
}
|
|
976
|
+
commit(frame, at) {
|
|
977
|
+
let exports = this.host.exports;
|
|
978
|
+
this.pending > 0 && (exports.engine_audio_place(this.handle, this.voices.byteOffset, this.offsets.byteOffset, this.pending, this.column.byteOffset, this.pending * 16), this.pending = 0), this.registers[(0)] = frame[at];
|
|
979
|
+
let world = this.occlusionWorld?.() ?? (0);
|
|
980
|
+
world !== (0) && exports.engine_audio_occlude?.(this.handle, world), exports.engine_audio_update(this.handle);
|
|
981
|
+
let list = this.streamList;
|
|
982
|
+
for (let i = 0; i < list.length; i++) list[i].playing && this.feedStream(list[i]);
|
|
983
|
+
}
|
|
984
|
+
suspend() {
|
|
985
|
+
this.host.exports.engine_audio_suspend(this.handle), this.host.relay?.pump(), this.host.relay?.suspend?.();
|
|
986
|
+
}
|
|
987
|
+
resume() {
|
|
988
|
+
this.host.exports.engine_audio_resume(this.handle), this.host.relay?.resume?.(), this.host.relay?.pump();
|
|
989
|
+
}
|
|
990
|
+
dispose() {
|
|
991
|
+
this.host.exports.engine_audio_reset(this.handle), this.host.release(this.staging, this.stagingBytes), this.capture !== 0 && this.host.release(this.capture, this.captureBytes), this.streamPointer !== 0 && this.host.release(this.streamPointer, this.streamBytes), this.emitterColumns !== 0 && this.host.release(this.emitterColumns, EMITTER_COLUMNS * (4)), this.musicStaging !== 0 && this.host.release(this.musicStaging, MUSIC_STAGING_BYTES), this.musicStaging = 0, this.emitterColumns = 0, this.capture = 0, this.captureBytes = 0, this.streamPointer = 0, this.streamBytes = 0, this.streams.clear(), this.streamList.length = 0;
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
function unsupported(feature) {
|
|
995
|
+
return new GameError("unsupported_feature", `this engine build has no ${feature}; update the app to use it`);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// src/game/backends/engine/joints.ts
|
|
999
|
+
var ENGINE_JOINT_EXPORT_NAMES = [
|
|
1000
|
+
"engine_joint_drive",
|
|
1001
|
+
"engine_joint_drive_clear",
|
|
1002
|
+
"engine_joint_target",
|
|
1003
|
+
"engine_joint_breakable",
|
|
1004
|
+
"engine_joint_enable",
|
|
1005
|
+
"engine_joint_contacts",
|
|
1006
|
+
"engine_joint_broken",
|
|
1007
|
+
"engine_joint_load",
|
|
1008
|
+
"engine_joint_break_count",
|
|
1009
|
+
"engine_joint_breaks"
|
|
1010
|
+
], ENGINE_RAGDOLL_EXPORT_NAMES = [
|
|
1011
|
+
"engine_ragdoll_create",
|
|
1012
|
+
"engine_ragdoll_destroy",
|
|
1013
|
+
"engine_ragdoll_drive",
|
|
1014
|
+
"engine_ragdoll_place",
|
|
1015
|
+
"engine_ragdoll_read",
|
|
1016
|
+
"engine_ragdoll_root",
|
|
1017
|
+
"engine_ragdoll_bodies",
|
|
1018
|
+
"engine_ragdoll_bone_count"
|
|
1019
|
+
], DRIVE_TARGET = 0, DRIVE_VELOCITY = 1, DRIVE_STIFFNESS = 2, DRIVE_DAMPING = 3, DRIVE_MAX_FORCE = 4, TARGET_ROTATION = 0, TARGET_STIFFNESS = 4, TARGET_DAMPING = 5, TARGET_MAX_TORQUE = 6, BREAK_FORCE = 0, BREAK_TORQUE = 1, LOAD_FORCE = 0, LOAD_TORQUE = 1, RAGDOLL_BONE_COUNT = 0, RAGDOLL_JOINT_COUNT = 1, RAGDOLL_ROOT_POSITION = 2;
|
|
1020
|
+
var RAGDOLL_LINEAR_DAMPING = 12, RAGDOLL_ANGULAR_DAMPING = 13, RAGDOLL_FRICTION = 14, RAGDOLL_FLAGS = 15, RAGDOLL_HEADER = 16, RAGDOLL_FLAG_ENTITIES = 1, RAGDOLL_NO_PARENT = 4294967295, RAGDOLL_BONE_JOINT = 0, RAGDOLL_BONE_AXIS = 1, RAGDOLL_BONE_LENGTH = 4, RAGDOLL_BONE_RADIUS = 5, RAGDOLL_BONE_DENSITY = 6, RAGDOLL_BONE_SWING = 7, RAGDOLL_BONE_TWIST = 8, RAGDOLL_BONE_ENTITY = 10, RAGDOLL_BONE_WORDS = 11, RAGDOLL_DRIVE_STIFFNESS = 0, RAGDOLL_DRIVE_DAMPING = 1, RAGDOLL_DRIVE_MAX_TORQUE = 2, RAGDOLL_ROOT_OUT = 0, NO_POINTER = 0, UNLIMITED = Number.MAX_VALUE, DEFAULT_DENSITY = 1e3, DEFAULT_SWING = Math.PI / 4, DEFAULT_TWIST = [-Math.PI / 8, Math.PI / 8], DEFAULT_AXIS = [0, 1, 0], ORIGIN = [0, 0, 0], IDENTITY = [0, 0, 0, 1], UNIT_SCALE = [1, 1, 1], AXES = 3, QUATERNION = 4, EMPTY_BREAKS = new Uint32Array(0);
|
|
1021
|
+
function engineJointExports(symbols) {
|
|
1022
|
+
for (let name of [...ENGINE_JOINT_EXPORT_NAMES, ...ENGINE_RAGDOLL_EXPORT_NAMES]) if (typeof symbols[name] != "function") return null;
|
|
1023
|
+
return symbols;
|
|
1024
|
+
}
|
|
1025
|
+
function engineJoints(session) {
|
|
1026
|
+
let exports = engineJointExports(session.symbols);
|
|
1027
|
+
return exports ? new EngineJoints(session, exports) : null;
|
|
1028
|
+
}
|
|
1029
|
+
function writeRoot(floats, at, root) {
|
|
1030
|
+
let position = root.position ?? ORIGIN, rotation = root.rotation ?? IDENTITY, scale = root.scale ?? UNIT_SCALE;
|
|
1031
|
+
for (let k = 0; k < (3); k++) floats[at + k] = position[k];
|
|
1032
|
+
for (let k = 0; k < (4); k++) floats[at + (3) + k] = rotation[k];
|
|
1033
|
+
for (let k = 0; k < (3); k++) floats[at + (3) + (4) + k] = scale[k];
|
|
1034
|
+
}
|
|
1035
|
+
var EngineRagdoll = class {
|
|
1036
|
+
constructor(session, exports, id, pose, bones) {
|
|
1037
|
+
this.live = true;
|
|
1038
|
+
this.session = session, this.exports = exports, this.id = id, this.pose = pose;
|
|
1039
|
+
let bodies = exports.engine_ragdoll_bodies(session.require(), id);
|
|
1040
|
+
if (bodies === (0)) throw new GameError("unknown_resource", `ragdoll ${id} has no bodies`);
|
|
1041
|
+
this.bodies = new Uint32Array(session.buffer, bodies, bones);
|
|
1042
|
+
}
|
|
1043
|
+
world() {
|
|
1044
|
+
if (!this.live) throw new GameError("unknown_resource", `ragdoll ${this.id} was destroyed`);
|
|
1045
|
+
let s = this.session;
|
|
1046
|
+
return s.flush(), s.require();
|
|
1047
|
+
}
|
|
1048
|
+
drive(drive) {
|
|
1049
|
+
let world = this.world(), floats = this.session.registerFloats;
|
|
1050
|
+
floats[(0)] = drive.stiffness, floats[(1)] = drive.damping, floats[(2)] = drive.maxTorque, this.session.check(this.exports.engine_ragdoll_drive(world, this.id, this.pose.byteOffset, this.pose.length), "drive ragdoll");
|
|
1051
|
+
}
|
|
1052
|
+
place() {
|
|
1053
|
+
let world = this.world();
|
|
1054
|
+
this.session.check(this.exports.engine_ragdoll_place(world, this.id, this.pose.byteOffset, this.pose.length), "place ragdoll");
|
|
1055
|
+
}
|
|
1056
|
+
read() {
|
|
1057
|
+
let world = this.world();
|
|
1058
|
+
return this.session.check(this.exports.engine_ragdoll_read(world, this.id, this.pose.byteOffset, this.pose.length), "read ragdoll"), this.pose;
|
|
1059
|
+
}
|
|
1060
|
+
setRoot(root) {
|
|
1061
|
+
let world = this.world();
|
|
1062
|
+
writeRoot(this.session.registerFloats, (0), root), this.session.check(this.exports.engine_ragdoll_root(world, this.id), "ragdoll root");
|
|
1063
|
+
}
|
|
1064
|
+
destroy() {
|
|
1065
|
+
let world = this.world();
|
|
1066
|
+
this.session.check(this.exports.engine_ragdoll_destroy(world, this.id), "destroy ragdoll"), this.live = false;
|
|
1067
|
+
}
|
|
1068
|
+
}, EngineJoints = class {
|
|
1069
|
+
constructor(session, exports) {
|
|
1070
|
+
this.breakView = EMPTY_BREAKS;
|
|
1071
|
+
this.session = session, this.exports = exports;
|
|
1072
|
+
}
|
|
1073
|
+
world() {
|
|
1074
|
+
let s = this.session;
|
|
1075
|
+
return s.flush(), s.require();
|
|
1076
|
+
}
|
|
1077
|
+
setDrive(joint, axis, drive) {
|
|
1078
|
+
let world = this.world(), floats = this.session.registerFloats;
|
|
1079
|
+
floats[(0)] = drive.targetPosition ?? 0, floats[(1)] = drive.targetVelocity ?? 0, floats[(2)] = drive.stiffness, floats[(3)] = drive.damping, floats[(4)] = drive.maxForce ?? UNLIMITED, this.session.check(this.exports.engine_joint_drive(world, joint, JOINT_AXES[axis]), "joint drive");
|
|
1080
|
+
}
|
|
1081
|
+
clearDrive(joint, axis) {
|
|
1082
|
+
this.session.check(this.exports.engine_joint_drive_clear(this.world(), joint, JOINT_AXES[axis]), "clear joint drive");
|
|
1083
|
+
}
|
|
1084
|
+
setTarget(joint, rotation, drive) {
|
|
1085
|
+
let world = this.world(), floats = this.session.registerFloats;
|
|
1086
|
+
for (let k = 0; k < (4); k++) floats[(0) + k] = rotation[k];
|
|
1087
|
+
floats[(4)] = drive.stiffness, floats[(5)] = drive.damping, floats[(6)] = drive.maxTorque, this.session.check(this.exports.engine_joint_target(world, joint), "joint target");
|
|
1088
|
+
}
|
|
1089
|
+
setBreakable(joint, force, torque) {
|
|
1090
|
+
let world = this.world(), floats = this.session.registerFloats;
|
|
1091
|
+
floats[(0)] = force, floats[(1)] = torque, this.session.check(this.exports.engine_joint_breakable(world, joint), "breakable joint");
|
|
1092
|
+
}
|
|
1093
|
+
setEnabled(joint, enabled) {
|
|
1094
|
+
this.session.check(this.exports.engine_joint_enable(this.world(), joint, enabled ? 1 : 0), "enable joint");
|
|
1095
|
+
}
|
|
1096
|
+
setContacts(joint, enabled) {
|
|
1097
|
+
this.session.check(this.exports.engine_joint_contacts(this.world(), joint, enabled ? 1 : 0), "joint contacts");
|
|
1098
|
+
}
|
|
1099
|
+
broken(joint) {
|
|
1100
|
+
return this.session.check(this.exports.engine_joint_broken(this.world(), joint), "joint broken") !== 0;
|
|
1101
|
+
}
|
|
1102
|
+
load(joint, out) {
|
|
1103
|
+
this.session.check(this.exports.engine_joint_load(this.world(), joint), "joint load");
|
|
1104
|
+
let floats = this.session.registerFloats;
|
|
1105
|
+
out.force = floats[(0)], out.torque = floats[(1)];
|
|
1106
|
+
}
|
|
1107
|
+
breaks() {
|
|
1108
|
+
let world = this.world(), count = this.exports.engine_joint_break_count(world);
|
|
1109
|
+
if (count === 0) return EMPTY_BREAKS;
|
|
1110
|
+
let pointer = this.exports.engine_joint_breaks(world), buffer = this.session.buffer;
|
|
1111
|
+
return (this.breakView.byteOffset !== pointer || this.breakView.buffer !== buffer || this.breakView.length !== count) && (this.breakView = new Uint32Array(buffer, pointer, count)), this.breakView;
|
|
1112
|
+
}
|
|
1113
|
+
createRagdoll(desc) {
|
|
1114
|
+
let joints = desc.parents.length;
|
|
1115
|
+
if (desc.pose.length < joints * POSE_STRIDE) throw new GameError("invalid_argument", `a ragdoll pose needs ${POSE_STRIDE} floats per joint`);
|
|
1116
|
+
let bones = desc.bones.length, words = (16) + joints + joints * POSE_STRIDE + bones * (11), s = this.session, scratch = s.memory.allocate("u32", words), floats = new Float32Array(scratch.buffer, scratch.byteOffset, words);
|
|
1117
|
+
scratch[(0)] = bones, scratch[(1)] = joints, writeRoot(floats, (2), desc.root ?? {}), floats[(12)] = desc.linearDamping ?? 0, floats[(13)] = desc.angularDamping ?? 0, floats[(14)] = desc.friction ?? Number.NaN;
|
|
1118
|
+
let entities = desc.bones.some((bone) => bone.entity !== void 0);
|
|
1119
|
+
scratch[(15)] = entities ? (1) : 0;
|
|
1120
|
+
for (let j = 0; j < joints; j++) {
|
|
1121
|
+
let parent = desc.parents[j];
|
|
1122
|
+
scratch[(16) + j] = parent === NO_PARENT ? (4294967295) : parent;
|
|
1123
|
+
}
|
|
1124
|
+
let poseAt = (16) + joints;
|
|
1125
|
+
floats.set(desc.pose.subarray(0, joints * POSE_STRIDE), poseAt);
|
|
1126
|
+
let bonesAt = poseAt + joints * POSE_STRIDE;
|
|
1127
|
+
for (let b = 0; b < bones; b++) {
|
|
1128
|
+
let bone = desc.bones[b], at = bonesAt + b * (11), axis = bone.axis ?? DEFAULT_AXIS, twist = bone.twist ?? DEFAULT_TWIST;
|
|
1129
|
+
scratch[at + (0)] = bone.joint;
|
|
1130
|
+
for (let k = 0; k < (3); k++) floats[at + (1) + k] = axis[k];
|
|
1131
|
+
floats[at + (4)] = bone.length, floats[at + (5)] = bone.radius, floats[at + (6)] = bone.density ?? (1e3), floats[at + (7)] = bone.swing ?? DEFAULT_SWING, floats[at + (8)] = twist[0], floats[at + (8) + 1] = twist[1], scratch[at + (10)] = bone.entity ?? (4294967295);
|
|
1132
|
+
}
|
|
1133
|
+
let world = this.world(), id = s.check(this.exports.engine_ragdoll_create(world, scratch.byteOffset, words), "create ragdoll"), pose = s.memory.allocate("f32", joints * POSE_STRIDE);
|
|
1134
|
+
return pose.set(desc.pose.subarray(0, joints * POSE_STRIDE)), new EngineRagdoll(s, this.exports, id, pose, bones);
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
export { DEFAULT_ROLLBACK_FRAMES, ENGINE_ARENA_EXPORT_NAMES, ENGINE_AUDIO_EXPORT_NAMES, ENGINE_AUDIO_LOCKSTEP_EXPORTS, ENGINE_AUDIO_WORKLET_EXPORTS, ENGINE_JOINT_EXPORT_NAMES, ENGINE_RAGDOLL_EXPORT_NAMES, ENGINE_ROLLBACK_EXPORT_NAMES, ENGINE_VECTOR_SURFACE_EXPORT_NAMES, EngineAudioPort, EngineMemory, EngineVectorSurfaces, ROLLBACK_CONFIG_WORDS, WorldSnapshots, engineJoints, engineVectorSurfaceExports, hasRollback, releaseEngineArena, writeRollbackConfig };
|