@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,1234 @@
|
|
|
1
|
+
import { mat4Frustum, mat4Orthographic } from './chunk-KIZOA5LX.mjs';
|
|
2
|
+
import { materialTint } from './chunk-TL2SVO4P.mjs';
|
|
3
|
+
import { CORE_MATERIAL_SLOTS, MATERIAL_SLOTS, OP_SET_LOD, STAT_GPU_LAST_NS, STAT_GPU_P50_NS, STAT_GPU_P95_NS, STAT_GPU_BYTES_LOW, STAT_GPU_BYTES_HIGH, STAT_THERMAL_TIER, STAT_PARTICLES_ALIVE, STAT_RAW_DISPATCHES, STAT_RAW_GPU_NS, STAT_RAW_DISABLED, STAT_TRANSPARENT_SORTED, STAT_TEXT_GLYPHS, STAT_DRAW_CALLS, STAT_TRIANGLES, FftAnalyser, BLEND_EQUATIONS, BLEND_FACTORS, STENCIL_OPERATIONS, COMPARE_FUNCTIONS } from './chunk-E65WCTIG.mjs';
|
|
4
|
+
import { FULL_AUDIO_CAPABILITIES, SPATIAL_WORDS, FILTER_OFF, METER_PEAK, METER_RMS, ANALYSER_FREQUENCY, STREAM_STOPPED, STREAM_PLAYING, STREAM_PAUSED, FILTER_KINDS, DISTANCE_MODELS, SPATIAL_MODEL, SPATIAL_REF_DISTANCE, SPATIAL_MAX_DISTANCE, SPATIAL_ROLLOFF, SPATIAL_CONE_INNER, SPATIAL_CONE_OUTER, SPATIAL_CONE_OUTER_GAIN } from './chunk-5YFBGGCK.mjs';
|
|
5
|
+
import { COLUMN_ALIGN } from './chunk-A33OORT7.mjs';
|
|
6
|
+
import { GameError } from './chunk-XJIHN3BY.mjs';
|
|
7
|
+
|
|
8
|
+
// src/game/render/character.ts
|
|
9
|
+
var HUMAN_SCATTER_MM = [3.67, 1.37, 0.68], DEFAULT_THICKNESS_MM = 1.5, DEFAULT_IRIS_RADIUS = 0.18, DEFAULT_IRIS_DEPTH = 0.04, DEFAULT_LIMBUS = 0.02, DEFAULT_PUPIL = 0.35, DEFAULT_MELANIN = 0.5, DEFAULT_REDNESS = 0.2, DEFAULT_AZIMUTHAL = 0.3, DEFAULT_DENSITY = 1, MAX_SCATTER_MM = 50, MAX_IRIS = 0.5, MAX_DENSITY = 8, MATERIAL_SKIN_SHEEN = 60, MATERIAL_SKIN_SHEEN_ROUGHNESS = 61, MATERIAL_SKIN_WARMTH = 62, MATERIAL_SKIN_RIM = 49, CHARACTER_KINDS = {
|
|
10
|
+
skin: 12,
|
|
11
|
+
eye: 13,
|
|
12
|
+
hair: 14
|
|
13
|
+
};
|
|
14
|
+
function clamp(value, low, high) {
|
|
15
|
+
return Math.min(Math.max(value, low), high);
|
|
16
|
+
}
|
|
17
|
+
function characterParams(desc) {
|
|
18
|
+
switch (desc.kind) {
|
|
19
|
+
case "skin": {
|
|
20
|
+
let s = desc.scatter ?? HUMAN_SCATTER_MM;
|
|
21
|
+
return [
|
|
22
|
+
clamp(s[0], 0, (50)),
|
|
23
|
+
clamp(s[1], 0, (50)),
|
|
24
|
+
clamp(s[2], 0, (50)),
|
|
25
|
+
Math.max(desc.thickness ?? (1.5), 0)
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
case "eye":
|
|
29
|
+
return [
|
|
30
|
+
clamp(desc.irisRadius ?? (0.18), 0, (0.5)),
|
|
31
|
+
clamp(desc.irisDepth ?? (0.04), 0, (0.5)),
|
|
32
|
+
clamp(desc.limbus ?? (0.02), 0, (0.5)),
|
|
33
|
+
clamp(desc.pupil ?? (0.35), 0, 1)
|
|
34
|
+
];
|
|
35
|
+
case "hair":
|
|
36
|
+
return [
|
|
37
|
+
clamp(desc.melanin ?? (0.5), 0, 1),
|
|
38
|
+
clamp(desc.redness ?? (0.2), 0, 1),
|
|
39
|
+
clamp(desc.azimuthalRoughness ?? (0.3), 0, 1),
|
|
40
|
+
clamp(desc.density ?? (1), 0, (8))
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
var FLOAT = new Float32Array(1), WORD = new Uint32Array(FLOAT.buffer);
|
|
45
|
+
function bits(value) {
|
|
46
|
+
return FLOAT[0] = value === 0 ? -0 : value, WORD[0];
|
|
47
|
+
}
|
|
48
|
+
function writeCharacterWords(desc, write) {
|
|
49
|
+
if (characterParams(desc).forEach((value, i) => write(40 + i, bits(value))), desc.kind !== "skin") return;
|
|
50
|
+
let tuned = [
|
|
51
|
+
[(60), desc.sheen],
|
|
52
|
+
[(61), desc.sheenRoughness],
|
|
53
|
+
[(62), desc.warmth],
|
|
54
|
+
[(49), desc.rim]
|
|
55
|
+
];
|
|
56
|
+
for (let [at, value] of tuned) value !== void 0 && write(at, bits(clamp(value, 0, 1)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/game/backends/engine/material-state.ts
|
|
60
|
+
var FLOAT2 = new Float32Array(1), WORD2 = new Uint32Array(FLOAT2.buffer), STENCIL_FULL_MASK = 255, RGB = 3, BYTE_BITS = 8, BYTE_MAX = 255, SRGB_KNEE = 0.04045, SRGB_SLOPE = 12.92, SRGB_OFFSET = 0.055, SRGB_GAMMA = 2.4;
|
|
61
|
+
function floatBits(value) {
|
|
62
|
+
return FLOAT2[0] = value, WORD2[0];
|
|
63
|
+
}
|
|
64
|
+
function compare(func) {
|
|
65
|
+
return func === void 0 ? 0 : 1 + COMPARE_FUNCTIONS.indexOf(func);
|
|
66
|
+
}
|
|
67
|
+
function renderState(state) {
|
|
68
|
+
let equation = state.blend?.equation ?? "add", word = compare(state.depthFunc) << 0;
|
|
69
|
+
return word |= BLEND_EQUATIONS.indexOf(equation) << 4, word |= BLEND_EQUATIONS.indexOf(state.blend?.alphaEquation ?? equation) << 7, state.alphaToCoverage && (word |= 1024), state.transparency === "oit" && (word |= 2048), state.stencil && (word |= 8192), word >>> 0;
|
|
70
|
+
}
|
|
71
|
+
function blendFactors(blend) {
|
|
72
|
+
if (!blend) return 0;
|
|
73
|
+
let src = blend.src ?? "srcAlpha", dst = blend.dst ?? "oneMinusSrcAlpha";
|
|
74
|
+
return (BLEND_FACTORS.indexOf(src) << 0 | BLEND_FACTORS.indexOf(dst) << 5 | BLEND_FACTORS.indexOf(blend.srcAlpha ?? src) << 10 | BLEND_FACTORS.indexOf(blend.dstAlpha ?? dst) << 15) >>> 0;
|
|
75
|
+
}
|
|
76
|
+
function stencil(desc) {
|
|
77
|
+
return desc ? (compare(desc.func ?? "always") << 0 | ((desc.ref ?? 0) & 255) << 4 | ((desc.readMask ?? (255)) & 255) << 12 | ((desc.writeMask ?? (255)) & 255) << 20) >>> 0 : 0;
|
|
78
|
+
}
|
|
79
|
+
function stencilOps(desc) {
|
|
80
|
+
return desc ? STENCIL_OPERATIONS.indexOf(desc.fail ?? "keep") << 0 | STENCIL_OPERATIONS.indexOf(desc.depthFail ?? "keep") << 3 | STENCIL_OPERATIONS.indexOf(desc.pass ?? "keep") << 6 : 0;
|
|
81
|
+
}
|
|
82
|
+
function writeMaterialState(state, write) {
|
|
83
|
+
let planes = state.clippingPlanes?.length ?? 0;
|
|
84
|
+
if (planes > 4) throw new RangeError(`materials clip against at most ${4} planes`);
|
|
85
|
+
write(32, renderState(state)), write(33, blendFactors(state.blend)), write(34, stencil(state.stencil)), write(35, stencilOps(state.stencil)), write(36, floatBits(state.polygonOffset?.factor ?? 0)), write(37, floatBits(state.polygonOffset?.units ?? 0)), write(38, planes), write(39, explicit(state.envMapIntensity));
|
|
86
|
+
}
|
|
87
|
+
function explicit(value) {
|
|
88
|
+
return value === void 0 ? 0 : floatBits(value === 0 ? -0 : value);
|
|
89
|
+
}
|
|
90
|
+
function linear(channel) {
|
|
91
|
+
return channel <= (0.04045) ? channel / (12.92) : ((channel + (0.055)) / (1 + (0.055))) ** (2.4);
|
|
92
|
+
}
|
|
93
|
+
function writeColor(write, at, hex, scale) {
|
|
94
|
+
if (hex !== void 0)
|
|
95
|
+
for (let i = 0; i < (3); i++) {
|
|
96
|
+
let channel = (hex >> ((3) - 1 - i) * (8) & (255)) / (255);
|
|
97
|
+
write(at + i, explicit(linear(channel) * scale));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function writeMaterialExtension(desc, write) {
|
|
101
|
+
if (writeMaterialState(desc, write), desc.kind !== "physical") return;
|
|
102
|
+
writeColor(write, 40, desc.sheenColor, desc.sheen ?? 0), write(43, explicit(desc.sheenRoughness)), writeColor(write, 44, desc.specularColor, 1), write(47, explicit(desc.specularIntensity)), write(48, explicit(desc.thickness)), write(49, explicit(desc.iridescence)), write(59, explicit(desc.clearcoatNormalScale)), writeColor(write, 28, desc.attenuationColor, 1), write(31, explicit(desc.attenuationDistance)), write(60, explicit(desc.iridescenceIOR));
|
|
103
|
+
let thickness = desc.iridescenceThicknessRange;
|
|
104
|
+
thickness !== void 0 && (write(61, explicit(thickness[0])), write(62, explicit(thickness[1])));
|
|
105
|
+
}
|
|
106
|
+
var UNDRAWN_PHYSICAL_MAPS = ["iridescenceMap", "iridescenceThicknessMap", "anisotropyMap"];
|
|
107
|
+
function refuseUndrawnPhysicalFields(desc) {
|
|
108
|
+
if (desc.kind === "physical") {
|
|
109
|
+
for (let field of UNDRAWN_PHYSICAL_MAPS)
|
|
110
|
+
if (desc[field] !== void 0)
|
|
111
|
+
throw new GameError(
|
|
112
|
+
"unsupported_feature",
|
|
113
|
+
`the engine renderer does not draw ${field} on physical materials; remove it, or bake it into the base maps`
|
|
114
|
+
);
|
|
115
|
+
if ((desc.dispersion ?? 0) > 0)
|
|
116
|
+
throw new GameError(
|
|
117
|
+
"unsupported_feature",
|
|
118
|
+
"the engine renderer does not draw dispersion on physical materials; remove it or set it to 0"
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function extraTextures(desc) {
|
|
123
|
+
return desc.kind !== "physical" ? [] : [
|
|
124
|
+
desc.clearcoatMap,
|
|
125
|
+
desc.clearcoatRoughnessMap,
|
|
126
|
+
desc.clearcoatNormalMap,
|
|
127
|
+
desc.sheenColorMap,
|
|
128
|
+
desc.sheenRoughnessMap,
|
|
129
|
+
desc.specularIntensityMap,
|
|
130
|
+
desc.specularColorMap,
|
|
131
|
+
desc.transmissionMap
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
function writePlanes(state, out) {
|
|
135
|
+
let planes = state.clippingPlanes;
|
|
136
|
+
return !planes || planes.length === 0 ? false : (planes.forEach((plane, i) => out.set(plane, i * 4)), true);
|
|
137
|
+
}
|
|
138
|
+
function writeTextureTransforms(desc, out, write) {
|
|
139
|
+
if (!desc.textureTransforms) return false;
|
|
140
|
+
let mask = 0;
|
|
141
|
+
for (let [slot, transform] of Object.entries(desc.textureTransforms)) {
|
|
142
|
+
if (!transform) continue;
|
|
143
|
+
let index = materialSlotIndex(slot), at = index * 8;
|
|
144
|
+
out[at + 0] = transform.offset?.[0] ?? 0, out[at + 0 + 1] = transform.offset?.[1] ?? 0, out[at + 2] = transform.repeat?.[0] ?? 1, out[at + 2 + 1] = transform.repeat?.[1] ?? 1, out[at + 4] = transform.rotation ?? 0, out[at + 5] = transform.center?.[0] ?? 0, out[at + 5 + 1] = transform.center?.[1] ?? 0, out[at + 7] = transform.channel ?? 0, mask |= 1 << index;
|
|
145
|
+
}
|
|
146
|
+
return write(50, mask), mask !== 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/game/backends/engine/features.ts
|
|
150
|
+
var MATERIAL_TOON = 7, MATERIAL_MATCAP = 8, SLOT_AUX = 13, NODE_BUFFER_PROBE_SH = 4, NODE_FLAG_PROBE_ENVIRONMENT = 16, SHADOW_PCF = 0, SHADOW_PCSS = 1, OP_MARK_PROBE = 49, OP_SET_SPRITE = 58, OP_SET_PROJECTION = 59, CREATE_POINT_SHADOWS = 22, PROBE_SH_FLOATS = 27, NODE_SPRITE_CENTER = 61, NODE_SPRITE_ROTATION = 63, OWNER_STAGING = 15;
|
|
151
|
+
var CAP_SPRITE_TRANSFORM = 1 << 27, CAP_CUSTOM_PROJECTION = 1 << 28, CAP_POINT_SHADOWS = 1 << 30, MAT4 = 16, UNORM16 = 65535, TAU = Math.PI * 2, DEGREES_TO_RADIANS = Math.PI / 180, DEFAULT_SPRITE_CENTER = 0.5, DEFAULT_LINE_WIDTH = 1, DEFAULT_PROBE_INTENSITY = 1, SKY_DEFAULTS = { turbidity: 10, rayleigh: 2, mie: 5e-3, mieDirectionalG: 0.8 }, CLOUD_DEFAULTS = { coverage: 0.4, density: 0.6, scale: 1, speed: 1, elevation: 0.5 }, WORD_BYTES = 4, CREATE_ALIGN = 16, LIGHT_KINDS = {
|
|
152
|
+
directional: 0,
|
|
153
|
+
point: 1,
|
|
154
|
+
spot: 2,
|
|
155
|
+
ambient: 3,
|
|
156
|
+
hemisphere: 4,
|
|
157
|
+
probe: 5,
|
|
158
|
+
rectArea: 6,
|
|
159
|
+
reflectionProbe: 7
|
|
160
|
+
}, MATERIAL_KINDS = {
|
|
161
|
+
standard: 0,
|
|
162
|
+
physical: 1,
|
|
163
|
+
toon: (7),
|
|
164
|
+
matcap: (8),
|
|
165
|
+
unlit: 2,
|
|
166
|
+
sprite: 3,
|
|
167
|
+
points: 4,
|
|
168
|
+
lines: 5,
|
|
169
|
+
shader: 6,
|
|
170
|
+
...CHARACTER_KINDS
|
|
171
|
+
}, RGB_MASK = 16777215;
|
|
172
|
+
function tintChannel(words, at, color, bit) {
|
|
173
|
+
return words[at] = color === void 0 ? 0 : (color & (16777215)) >>> 0, color === void 0 ? 0 : bit;
|
|
174
|
+
}
|
|
175
|
+
function writeTintWords(tint, words, at) {
|
|
176
|
+
let enabled = tintChannel(words, at, tint?.primary, 1) | tintChannel(words, at + 1, tint?.secondary, 2) | tintChannel(words, at + 2, tint?.tertiary, 4);
|
|
177
|
+
words[at + 3] = enabled;
|
|
178
|
+
}
|
|
179
|
+
function writeMaterialTint(desc, d) {
|
|
180
|
+
let tint = materialTint(desc);
|
|
181
|
+
return tint.tintable ? (tint.mask !== void 0 && (d[51 + (13 - CORE_MATERIAL_SLOTS)] = tint.mask), 512) : 0;
|
|
182
|
+
}
|
|
183
|
+
var SHADOW_TYPES = { pcf: (0), pcss: (1) };
|
|
184
|
+
function materialSlotIndex(slot) {
|
|
185
|
+
return slot === "gradientMap" || slot === "matcap" ? (13) : MATERIAL_SLOTS.indexOf(slot);
|
|
186
|
+
}
|
|
187
|
+
function explicitFloat(value) {
|
|
188
|
+
return floatBits(value === 0 ? -0 : value);
|
|
189
|
+
}
|
|
190
|
+
function anisotropyWord(strength, rotation) {
|
|
191
|
+
let s = Math.round(Math.min(Math.max(strength, 0), 1) * (65535)), turns = (rotation % TAU + TAU) % TAU;
|
|
192
|
+
return ((Math.round(turns / TAU * (65535)) & (65535)) << 16 | s) >>> 0;
|
|
193
|
+
}
|
|
194
|
+
function materialFeatureFlags(desc) {
|
|
195
|
+
switch (desc.kind) {
|
|
196
|
+
case "toon":
|
|
197
|
+
return 64;
|
|
198
|
+
case "matcap":
|
|
199
|
+
return desc.flatShading ? 32 : 0;
|
|
200
|
+
case "lines":
|
|
201
|
+
return desc.worldUnits ? 256 : 0;
|
|
202
|
+
case "sprite":
|
|
203
|
+
return desc.sizeAttenuation === false ? 0 : 128;
|
|
204
|
+
default:
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function linearChannel(channel) {
|
|
209
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
210
|
+
}
|
|
211
|
+
function writeLinearHex(f, at, hex) {
|
|
212
|
+
f[at] = linearChannel((hex >> 16 & 255) / 255), f[at + 1] = linearChannel((hex >> 8 & 255) / 255), f[at + 2] = linearChannel((hex & 255) / 255);
|
|
213
|
+
}
|
|
214
|
+
function writeMaterialFeatures(desc, d, f) {
|
|
215
|
+
let aux = 51 + ((13) - CORE_MATERIAL_SLOTS);
|
|
216
|
+
switch (desc.kind) {
|
|
217
|
+
case "toon":
|
|
218
|
+
d[15] = desc.map ?? 0, d[16] = desc.normalMap ?? 0, d[19] = desc.emissiveMap ?? 0, d[20] = desc.aoMap ?? 0, writeLinearHex(f, 7, desc.emissive ?? 0), f[10] = desc.emissiveIntensity ?? 1, d[aux] = desc.gradientMap ?? 0;
|
|
219
|
+
break;
|
|
220
|
+
case "matcap":
|
|
221
|
+
d[15] = desc.map ?? 0, d[16] = desc.normalMap ?? 0, d[aux] = desc.matcap ?? 0;
|
|
222
|
+
break;
|
|
223
|
+
case "lines":
|
|
224
|
+
f[21] = desc.width ?? (1), desc.dashSize !== void 0 && (d[60] = explicitFloat(desc.dashSize)), desc.gapSize !== void 0 && (d[61] = explicitFloat(desc.gapSize)), desc.dashScale !== void 0 && (d[62] = explicitFloat(desc.dashScale));
|
|
225
|
+
break;
|
|
226
|
+
case "physical":
|
|
227
|
+
desc.anisotropy !== void 0 && desc.anisotropy > 0 && (d[63] = anisotropyWord(desc.anisotropy, desc.anisotropyRotation ?? 0));
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function writeSky(desc, d, f) {
|
|
232
|
+
let sky = desc.sky;
|
|
233
|
+
if (desc.background !== void 0 && "sky" in desc.background && (d[0] = 3), !sky) {
|
|
234
|
+
d[19] = 0;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
d[19] = 1, f[20] = sky.turbidity ?? SKY_DEFAULTS.turbidity, f[21] = sky.rayleigh ?? SKY_DEFAULTS.rayleigh, f[22] = sky.mie ?? SKY_DEFAULTS.mie, f[23] = sky.mieDirectionalG ?? SKY_DEFAULTS.mieDirectionalG;
|
|
238
|
+
let clouds = sky.clouds;
|
|
239
|
+
if (!clouds) {
|
|
240
|
+
f[24] = 0;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
f[24] = clouds.coverage ?? CLOUD_DEFAULTS.coverage, f[25] = clouds.density ?? CLOUD_DEFAULTS.density, f[26] = clouds.scale ?? CLOUD_DEFAULTS.scale, f[27] = clouds.speed ?? CLOUD_DEFAULTS.speed, f[28] = clouds.elevation ?? CLOUD_DEFAULTS.elevation;
|
|
244
|
+
}
|
|
245
|
+
function writeNodeFeatures(desc, d, f, spriteRotation) {
|
|
246
|
+
let lod = desc.lod;
|
|
247
|
+
switch (lod && (f[34] = lod.near ?? 0, f[35] = lod.far ?? 0, f[36] = lod.hysteresis ?? 0), desc.kind) {
|
|
248
|
+
case "sprite":
|
|
249
|
+
d[(61)] = explicitFloat(desc.center?.[0] ?? (0.5)), d[(61) + 1] = explicitFloat(desc.center?.[1] ?? (0.5)), d[(63)] = explicitFloat(spriteRotation);
|
|
250
|
+
break;
|
|
251
|
+
case "decal":
|
|
252
|
+
d[0] = 10, d[2] = desc.material, desc.angleFade !== void 0 && (f[32] = desc.angleFade), desc.fade !== void 0 && (f[33] = desc.fade);
|
|
253
|
+
break;
|
|
254
|
+
case "light":
|
|
255
|
+
if (d[5] = LIGHT_KINDS[desc.light], desc.shadow?.type !== void 0 && (d[50] = SHADOW_TYPES[desc.shadow.type]), desc.light === "rectArea")
|
|
256
|
+
f[51] = desc.width ?? 1, f[52] = desc.height ?? 1;
|
|
257
|
+
else if (desc.light === "probe")
|
|
258
|
+
desc.fromEnvironment && (d[3] |= (16));
|
|
259
|
+
else if (desc.light === "reflectionProbe") {
|
|
260
|
+
if (desc.texture === void 0) throw new GameError("invalid_argument", "reflection probes need a cube or equirect texture");
|
|
261
|
+
d[53] = desc.texture;
|
|
262
|
+
let min = desc.boxMin ?? [-1, -1, -1], max = desc.boxMax ?? [1, 1, 1];
|
|
263
|
+
for (let i = 0; i < 3; i++)
|
|
264
|
+
f[54 + i] = min[i], f[57 + i] = max[i];
|
|
265
|
+
d[60] = explicitFloat(desc.intensity ?? (1));
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function glToEngineProjection(gl, out, offset = 0) {
|
|
271
|
+
for (let c = 0; c < 4; c++) {
|
|
272
|
+
let o = c * 4;
|
|
273
|
+
out[offset + o] = gl[o], out[offset + o + 1] = gl[o + 1], out[offset + o + 2] = 0.5 * gl[o + 3] - 0.5 * gl[o + 2], out[offset + o + 3] = gl[o + 3];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function viewOffsetProjection(camera, aspect, view, out) {
|
|
277
|
+
if (camera.perspective) {
|
|
278
|
+
let top2 = camera.near * Math.tan(DEGREES_TO_RADIANS * 0.5 * camera.fov), height = 2 * top2, width = aspect * height, left2 = -0.5 * width;
|
|
279
|
+
left2 += view.x * width / view.fullWidth, top2 -= view.y * height / view.fullHeight, width *= view.width / view.fullWidth, height *= view.height / view.fullHeight, mat4Frustum(out, 0, left2, left2 + width, top2 - height, top2, camera.near, camera.far);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
let halfHeight = camera.height / 2, halfWidth = halfHeight * aspect, scaleW = 2 * halfWidth / view.fullWidth, scaleH = 2 * halfHeight / view.fullHeight, left = -halfWidth + scaleW * view.x, right = left + scaleW * view.width, top = halfHeight - scaleH * view.y, bottom = top - scaleH * view.height;
|
|
283
|
+
mat4Orthographic(out, 0, left, right, bottom, top, camera.near, camera.far);
|
|
284
|
+
}
|
|
285
|
+
var EngineFeatures = class {
|
|
286
|
+
constructor(host) {
|
|
287
|
+
this.spriteRotations = /* @__PURE__ */ new Map();
|
|
288
|
+
this.cameras = /* @__PURE__ */ new Map();
|
|
289
|
+
this.glScratch = new Float64Array((16));
|
|
290
|
+
this.staging = null;
|
|
291
|
+
this.aspect = 1;
|
|
292
|
+
this.host = host;
|
|
293
|
+
}
|
|
294
|
+
has(cap) {
|
|
295
|
+
return (this.host.caps() & cap) !== 0;
|
|
296
|
+
}
|
|
297
|
+
require(cap, feature) {
|
|
298
|
+
if (!this.has(cap)) throw new GameError("unsupported_feature", `this engine build has no ${feature}; update the app to use it`);
|
|
299
|
+
}
|
|
300
|
+
material(id, desc) {
|
|
301
|
+
desc.kind === "sprite" && this.spriteRotations.set(id, desc.rotation ?? 0);
|
|
302
|
+
}
|
|
303
|
+
spriteRotation(material) {
|
|
304
|
+
return this.spriteRotations.get(material) ?? 0;
|
|
305
|
+
}
|
|
306
|
+
forgetMaterial(id) {
|
|
307
|
+
this.spriteRotations.delete(id);
|
|
308
|
+
}
|
|
309
|
+
node(id, desc) {
|
|
310
|
+
if (desc.kind === "camera") {
|
|
311
|
+
let perspective = desc.projection !== "orthographic";
|
|
312
|
+
this.cameras.set(id, {
|
|
313
|
+
perspective,
|
|
314
|
+
fov: desc.projection === "perspective" ? desc.fov ?? 0 : 0,
|
|
315
|
+
height: desc.projection === "orthographic" ? desc.height : 0,
|
|
316
|
+
near: desc.near ?? 0,
|
|
317
|
+
far: desc.far ?? 0,
|
|
318
|
+
offset: null,
|
|
319
|
+
custom: false
|
|
320
|
+
}), desc.projection === "custom" && this.setProjectionMatrix(id, desc.matrix, desc.near, desc.far);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
desc.kind === "light" && desc.light === "probe" && desc.sh && this.setProbeCoefficients(id, desc.sh);
|
|
324
|
+
}
|
|
325
|
+
forgetNode(id) {
|
|
326
|
+
this.cameras.delete(id);
|
|
327
|
+
}
|
|
328
|
+
perspective(id, fov, near, far) {
|
|
329
|
+
let camera = this.cameras.get(id);
|
|
330
|
+
camera && (camera.perspective = true, camera.fov = fov, camera.near = near, camera.far = far, camera.custom = false, camera.offset && this.sendOffset(id, camera));
|
|
331
|
+
}
|
|
332
|
+
perspectiveFrom(id, values, offset) {
|
|
333
|
+
let camera = this.cameras.get(id);
|
|
334
|
+
camera && (camera.perspective = true, camera.fov = values[offset], camera.near = values[offset + 1], camera.far = values[offset + 2], camera.custom = false, camera.offset && this.sendOffset(id, camera));
|
|
335
|
+
}
|
|
336
|
+
orthographic(id, height, near, far) {
|
|
337
|
+
let camera = this.cameras.get(id);
|
|
338
|
+
camera && (camera.perspective = false, camera.height = height, camera.near = near, camera.far = far, camera.custom = false, camera.offset && this.sendOffset(id, camera));
|
|
339
|
+
}
|
|
340
|
+
resize(width, height) {
|
|
341
|
+
this.aspect = width / Math.max(1, height);
|
|
342
|
+
for (let [id, camera] of this.cameras) camera.offset && this.sendOffset(id, camera);
|
|
343
|
+
}
|
|
344
|
+
setLod(node, near, far, hysteresis) {
|
|
345
|
+
let a = this.host.command(OP_SET_LOD, node);
|
|
346
|
+
this.host.floats[a] = near, this.host.floats[a + 1] = far, this.host.floats[a + 2] = hysteresis;
|
|
347
|
+
}
|
|
348
|
+
setSprite(node, rotation, centerX, centerY) {
|
|
349
|
+
this.require(CAP_SPRITE_TRANSFORM, "sprite rotation and center");
|
|
350
|
+
let a = this.host.command((58), node);
|
|
351
|
+
this.host.floats[a] = rotation, this.host.floats[a + 1] = centerX, this.host.floats[a + 2] = centerY;
|
|
352
|
+
}
|
|
353
|
+
setProbeCoefficients(node, sh) {
|
|
354
|
+
if (sh.length < (27)) throw new GameError("invalid_argument", `light probes take ${(27)} coefficients (9 RGB)`);
|
|
355
|
+
this.host.buffer(4, node, (4)).set(sh.subarray(0, (27))), this.host.command((49), node);
|
|
356
|
+
}
|
|
357
|
+
setProjectionMatrix(camera, matrix, near, far) {
|
|
358
|
+
this.require(CAP_CUSTOM_PROJECTION, "custom camera projections");
|
|
359
|
+
let state = this.cameras.get(camera);
|
|
360
|
+
state && (state.custom = matrix !== null, matrix !== null && (state.offset = null)), this.sendProjection(camera, matrix, near, far);
|
|
361
|
+
}
|
|
362
|
+
setViewOffset(camera, offset) {
|
|
363
|
+
this.require(CAP_CUSTOM_PROJECTION, "camera view offsets");
|
|
364
|
+
let state = this.cameras.get(camera);
|
|
365
|
+
if (!state) throw new GameError("unknown_resource", `node ${camera} is not a camera`);
|
|
366
|
+
if (state.offset = offset, offset === null) {
|
|
367
|
+
this.sendProjection(camera, null, state.near, state.far);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this.sendOffset(camera, state);
|
|
371
|
+
}
|
|
372
|
+
readGpuStats(out) {
|
|
373
|
+
let r = this.host.registers;
|
|
374
|
+
out.gpuLastNs = r[STAT_GPU_LAST_NS], out.gpuP50Ns = r[STAT_GPU_P50_NS], out.gpuP95Ns = r[STAT_GPU_P95_NS], out.gpuBytes = r[STAT_GPU_BYTES_LOW] + r[STAT_GPU_BYTES_HIGH] * 4294967296, out.thermalTier = r[STAT_THERMAL_TIER], out.particlesAlive = r[STAT_PARTICLES_ALIVE], out.rawDispatches = r[STAT_RAW_DISPATCHES], out.rawGpuNs = r[STAT_RAW_GPU_NS], out.rawDisabled = r[STAT_RAW_DISABLED], out.transparentSorted = r[STAT_TRANSPARENT_SORTED], out.textGlyphs = r[STAT_TEXT_GLYPHS], out.drawCalls = r[STAT_DRAW_CALLS], out.triangles = r[STAT_TRIANGLES];
|
|
375
|
+
}
|
|
376
|
+
sendOffset(camera, state) {
|
|
377
|
+
let offset = state.offset;
|
|
378
|
+
offset && (viewOffsetProjection(state, this.aspect, offset, this.glScratch), this.sendProjection(camera, this.glScratch, state.near, state.far));
|
|
379
|
+
}
|
|
380
|
+
sendProjection(camera, matrix, near, far) {
|
|
381
|
+
if (matrix === null) {
|
|
382
|
+
this.sendBase(camera);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
this.host.flush(), glToEngineProjection(matrix, this.stagingView());
|
|
386
|
+
let a = this.host.command((59), camera);
|
|
387
|
+
this.host.floats[a] = near, this.host.floats[a + 1] = far, this.host.flush();
|
|
388
|
+
}
|
|
389
|
+
sendBase(camera) {
|
|
390
|
+
let state = this.cameras.get(camera), perspective = state?.perspective ?? true, a = this.host.command(perspective ? 9 : 10, camera);
|
|
391
|
+
this.host.floats[a] = perspective ? state?.fov || 60 : state?.height ?? 1, this.host.floats[a + 1] = state?.near || 0.1, this.host.floats[a + 2] = state?.far || 1e3;
|
|
392
|
+
}
|
|
393
|
+
stagingView() {
|
|
394
|
+
return (this.staging === null || this.staging.length === 0) && (this.staging = this.host.buffer((15), 0, 0)), this.staging;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
function createWithDescriptor(runtime, options, create) {
|
|
398
|
+
let bytes = 64 * (4);
|
|
399
|
+
if (typeof runtime.exports.engine_alloc != "function") return create(0);
|
|
400
|
+
let pointer = runtime.exports.engine_alloc(bytes, (16));
|
|
401
|
+
if (pointer === 0) return create(0);
|
|
402
|
+
try {
|
|
403
|
+
let words = new Uint32Array(runtime.memory.buffer, pointer, 64);
|
|
404
|
+
return words.fill(0), words[(22)] = options.pointShadows === !1 ? 0 : 1, create(pointer);
|
|
405
|
+
} finally {
|
|
406
|
+
runtime.exports.engine_free(pointer, bytes, (16));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// src/game/audio/worklet-processor.ts
|
|
411
|
+
var WORKLET_PROCESSOR_NAME = "cimplify-audio";
|
|
412
|
+
var WORKLET_PROCESSOR_SOURCE = `
|
|
413
|
+
const RING_HEADER_WORDS = 2;
|
|
414
|
+
const RING_WRITE = 0;
|
|
415
|
+
const RING_READ = 1;
|
|
416
|
+
|
|
417
|
+
class CimplifyAudioProcessor extends AudioWorkletProcessor {
|
|
418
|
+
constructor(options) {
|
|
419
|
+
super();
|
|
420
|
+
const o = options.processorOptions;
|
|
421
|
+
const instance = new WebAssembly.Instance(o.module, {});
|
|
422
|
+
this.x = instance.exports;
|
|
423
|
+
const sizes = new Uint32Array(this.x.memory.buffer, this.x.worklet_sizes(), o.sizes.length);
|
|
424
|
+
for (let k = 0; k < o.sizes.length; k++) sizes[k] = o.sizes[k];
|
|
425
|
+
this.host = this.x.worklet_create(sampleRate, o.voices, o.inputWords);
|
|
426
|
+
this.capacity = this.x.worklet_input_words(this.host);
|
|
427
|
+
this.pending = 0;
|
|
428
|
+
this.queue = [];
|
|
429
|
+
this.queued = 0;
|
|
430
|
+
this.reportQuanta = o.reportQuanta;
|
|
431
|
+
this.quanta = 0;
|
|
432
|
+
this.buffer = null;
|
|
433
|
+
this.inbound = o.inbound === null ? null : new Int32Array(o.inbound);
|
|
434
|
+
this.outbound = o.outbound === null ? null : new Int32Array(o.outbound);
|
|
435
|
+
if (this.inbound === null) {
|
|
436
|
+
this.port.onmessage = (event) => {
|
|
437
|
+
this.queue.push(event.data);
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
views() {
|
|
443
|
+
const buffer = this.x.memory.buffer;
|
|
444
|
+
if (this.buffer === buffer) return;
|
|
445
|
+
this.buffer = buffer;
|
|
446
|
+
this.input = new Uint32Array(buffer, this.x.worklet_input(this.host), this.capacity);
|
|
447
|
+
this.left = new Float32Array(buffer, this.x.worklet_output(this.host, 0), 4096);
|
|
448
|
+
this.right = new Float32Array(buffer, this.x.worklet_output(this.host, 1), 4096);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
fromRing() {
|
|
452
|
+
const ring = this.inbound;
|
|
453
|
+
const capacity = ring.length - RING_HEADER_WORDS;
|
|
454
|
+
const write = Atomics.load(ring, RING_WRITE);
|
|
455
|
+
let read = Atomics.load(ring, RING_READ);
|
|
456
|
+
let available = (write - read) | 0;
|
|
457
|
+
const room = this.capacity - this.pending;
|
|
458
|
+
if (available > room) available = room;
|
|
459
|
+
for (let k = 0; k < available; k++) {
|
|
460
|
+
this.input[this.pending + k] = ring[RING_HEADER_WORDS + ((read + k) & (capacity - 1))];
|
|
461
|
+
}
|
|
462
|
+
this.pending += available;
|
|
463
|
+
Atomics.store(ring, RING_READ, (read + available) | 0);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
fromQueue() {
|
|
467
|
+
while (this.queue.length > 0 && this.pending < this.capacity) {
|
|
468
|
+
const head = this.queue[0];
|
|
469
|
+
const take = Math.min(head.length - this.queued, this.capacity - this.pending);
|
|
470
|
+
this.input.set(head.subarray(this.queued, this.queued + take), this.pending);
|
|
471
|
+
this.pending += take;
|
|
472
|
+
this.queued += take;
|
|
473
|
+
if (this.queued === head.length) {
|
|
474
|
+
this.queue.shift();
|
|
475
|
+
this.queued = 0;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
ingest() {
|
|
481
|
+
this.views();
|
|
482
|
+
if (this.inbound !== null) this.fromRing();
|
|
483
|
+
else this.fromQueue();
|
|
484
|
+
if (this.pending === 0) return;
|
|
485
|
+
const used = this.x.worklet_ingest(this.host, this.pending);
|
|
486
|
+
if (used > 0) {
|
|
487
|
+
this.input.copyWithin(0, used, this.pending);
|
|
488
|
+
this.pending -= used;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
report() {
|
|
493
|
+
const words = this.x.worklet_report(this.host);
|
|
494
|
+
this.views();
|
|
495
|
+
const report = new Uint32Array(this.x.memory.buffer, this.x.worklet_report_buffer(this.host), words);
|
|
496
|
+
if (this.outbound === null) {
|
|
497
|
+
this.port.postMessage(report.slice());
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const ring = this.outbound;
|
|
501
|
+
const capacity = ring.length - RING_HEADER_WORDS;
|
|
502
|
+
const write = Atomics.load(ring, RING_WRITE);
|
|
503
|
+
const read = Atomics.load(ring, RING_READ);
|
|
504
|
+
if (capacity - ((write - read) | 0) < words) return;
|
|
505
|
+
for (let k = 0; k < words; k++) ring[RING_HEADER_WORDS + ((write + k) & (capacity - 1))] = report[k];
|
|
506
|
+
Atomics.store(ring, RING_WRITE, (write + words) | 0);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
process(inputs, outputs) {
|
|
510
|
+
this.ingest();
|
|
511
|
+
const out = outputs[0];
|
|
512
|
+
const frames = out[0].length;
|
|
513
|
+
this.x.worklet_render(this.host, frames);
|
|
514
|
+
this.views();
|
|
515
|
+
out[0].set(this.left.subarray(0, frames));
|
|
516
|
+
if (out.length > 1) out[1].set(this.right.subarray(0, frames));
|
|
517
|
+
this.ingest();
|
|
518
|
+
this.quanta += 1;
|
|
519
|
+
if (this.quanta >= this.reportQuanta) {
|
|
520
|
+
this.quanta = 0;
|
|
521
|
+
this.report();
|
|
522
|
+
}
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
registerProcessor("${WORKLET_PROCESSOR_NAME}", CimplifyAudioProcessor);
|
|
528
|
+
`;
|
|
529
|
+
|
|
530
|
+
// src/game/audio/output.ts
|
|
531
|
+
var outputs = /* @__PURE__ */ new WeakMap();
|
|
532
|
+
function audioOutput(context) {
|
|
533
|
+
let output = outputs.get(context);
|
|
534
|
+
return output === void 0 ? context.destination : output;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// src/game/audio/worklet.ts
|
|
538
|
+
var ENGINE_MIX_RATE = 48e3, DEFAULT_PUMP_WORDS = 65536, DEFAULT_RING_WORDS = 1 << 20, DEFAULT_IDLE_PUMPS = 120, WORD_BYTES2 = 4, OUTPUT_CHANNELS = 2, MASTER_BUS = 0, METER_FLOATS = 2, METER_PEAK2 = 0, RUNNING = "running", DEFAULT_WORKLET_SIZES = {
|
|
539
|
+
arenaFloats: 1 << 23,
|
|
540
|
+
streamFrames: 65536,
|
|
541
|
+
reverbs: 2,
|
|
542
|
+
reverbPartitions: 1024,
|
|
543
|
+
banks: 4,
|
|
544
|
+
emitters: 2048
|
|
545
|
+
};
|
|
546
|
+
function sizeWords(sizes) {
|
|
547
|
+
return [sizes.arenaFloats, sizes.streamFrames, sizes.reverbs, sizes.reverbPartitions, sizes.banks, sizes.emitters];
|
|
548
|
+
}
|
|
549
|
+
function ring(words) {
|
|
550
|
+
return new SharedArrayBuffer((2 + words) * (4));
|
|
551
|
+
}
|
|
552
|
+
function blobUrl(source) {
|
|
553
|
+
return URL.createObjectURL(new Blob([source], { type: "application/javascript" }));
|
|
554
|
+
}
|
|
555
|
+
function defaultNode(context, name, options) {
|
|
556
|
+
let Node = globalThis.AudioWorkletNode;
|
|
557
|
+
return new Node(context, name, {
|
|
558
|
+
numberOfInputs: 0,
|
|
559
|
+
numberOfOutputs: 1,
|
|
560
|
+
outputChannelCount: [(2)],
|
|
561
|
+
processorOptions: options
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
function sharedMemoryAvailable() {
|
|
565
|
+
return typeof SharedArrayBuffer == "function" && globalThis.crossOriginIsolated === true;
|
|
566
|
+
}
|
|
567
|
+
var WorkletAudio = class _WorkletAudio {
|
|
568
|
+
constructor(engine, handle, shared, pumpWords, ringWords, context, idlePumps) {
|
|
569
|
+
this.backlog = [];
|
|
570
|
+
this.reports = [];
|
|
571
|
+
this.node = null;
|
|
572
|
+
this.failed = null;
|
|
573
|
+
this.meterView = null;
|
|
574
|
+
this.quiet = 0;
|
|
575
|
+
this.idled = false;
|
|
576
|
+
this.hidden = false;
|
|
577
|
+
this.engine = engine, this.handle = handle, this.shared = shared, this.stagingWords = pumpWords, this.staging = engine.allocate(pumpWords * (4)), this.inbound = shared ? new Int32Array(ring(ringWords)) : null, this.outbound = shared ? new Int32Array(ring(ringWords)) : null, this.context = context, this.idlePumps = idlePumps;
|
|
578
|
+
}
|
|
579
|
+
static create(engine, options) {
|
|
580
|
+
let create = engine.exports.engine_audio_relay_create;
|
|
581
|
+
if (!create) throw new GameError("unsupported_feature", "this engine build has no web audio relay");
|
|
582
|
+
let sizes = options.sizes ?? DEFAULT_WORKLET_SIZES, words = sizeWords(sizes), pointer = engine.allocate(6 * (4));
|
|
583
|
+
new Uint32Array(engine.memory.buffer, pointer, 6).set(words);
|
|
584
|
+
let voices = options.voices ?? 64, handle = create((48e3), voices, pointer);
|
|
585
|
+
if (engine.release(pointer, 6 * (4)), handle === 0) throw new GameError("invalid_argument", "the engine refused the web audio relay sizes");
|
|
586
|
+
let shared = options.shared ?? sharedMemoryAvailable(), pumpWords = options.pumpWords ?? (65536), ringWords = options.ringWords ?? DEFAULT_RING_WORDS;
|
|
587
|
+
if (ringWords & ringWords - 1 || ringWords < pumpWords) throw new GameError("invalid_argument", "the ring holds a power of two words, at least one pump");
|
|
588
|
+
let idlePumps = options.idlePumps ?? (120), audio = new _WorkletAudio(engine, handle, shared, pumpWords, ringWords, options.context, idlePumps), url = (options.moduleUrl ?? blobUrl)(WORKLET_PROCESSOR_SOURCE);
|
|
589
|
+
return Promise.all([options.context.audioWorklet.addModule(url), options.module]).then(([, module]) => {
|
|
590
|
+
let processor = {
|
|
591
|
+
module,
|
|
592
|
+
voices,
|
|
593
|
+
sizes: words,
|
|
594
|
+
inputWords: pumpWords * 2,
|
|
595
|
+
reportQuanta: options.reportQuanta ?? 8,
|
|
596
|
+
inbound: audio.inbound === null ? null : audio.inbound.buffer,
|
|
597
|
+
outbound: audio.outbound === null ? null : audio.outbound.buffer
|
|
598
|
+
};
|
|
599
|
+
audio.attach((options.createNode ?? defaultNode)(options.context, WORKLET_PROCESSOR_NAME, processor), options.context);
|
|
600
|
+
}).catch((cause) => {
|
|
601
|
+
audio.failed = cause;
|
|
602
|
+
}), audio;
|
|
603
|
+
}
|
|
604
|
+
get idle() {
|
|
605
|
+
return this.idled;
|
|
606
|
+
}
|
|
607
|
+
suspend() {
|
|
608
|
+
this.hidden = true, this.context.suspend?.();
|
|
609
|
+
}
|
|
610
|
+
resume() {
|
|
611
|
+
this.hidden = false, this.idled = false, this.quiet = 0, this.context.resume?.();
|
|
612
|
+
}
|
|
613
|
+
silent() {
|
|
614
|
+
let buffer = this.engine.memory.buffer, view = this.meterView;
|
|
615
|
+
return (view === null || view.buffer !== buffer) && (view = new Float32Array(buffer, this.staging, (2)), this.meterView = view), this.engine.exports.engine_audio_meter(this.handle, (0), this.staging), view[(0)] === 0;
|
|
616
|
+
}
|
|
617
|
+
settle(sent) {
|
|
618
|
+
if (sent > 0 || !this.silent()) {
|
|
619
|
+
this.quiet = 0, this.idled && !this.hidden && (this.idled = false, this.context.resume?.());
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
this.idled || this.hidden || this.node === null || this.context.state !== RUNNING || (this.quiet += 1, !(this.quiet < this.idlePumps) && (this.idled = true, this.context.suspend?.()));
|
|
623
|
+
}
|
|
624
|
+
get ready() {
|
|
625
|
+
return this.node !== null;
|
|
626
|
+
}
|
|
627
|
+
get error() {
|
|
628
|
+
return this.failed;
|
|
629
|
+
}
|
|
630
|
+
attach(node, context) {
|
|
631
|
+
this.node = node, this.shared || (node.port.onmessage = (event) => {
|
|
632
|
+
this.reports.push(event.data);
|
|
633
|
+
}), node.connect(audioOutput(context)), this.drainBacklog();
|
|
634
|
+
}
|
|
635
|
+
send(words) {
|
|
636
|
+
let node = this.node;
|
|
637
|
+
if (node === null) return false;
|
|
638
|
+
let ring2 = this.inbound;
|
|
639
|
+
if (ring2 === null)
|
|
640
|
+
return node.port.postMessage(words, [words.buffer]), true;
|
|
641
|
+
let capacity = ring2.length - 2, write = Atomics.load(ring2, 0), read = Atomics.load(ring2, 1);
|
|
642
|
+
if (capacity - (write - read | 0) < words.length) return false;
|
|
643
|
+
for (let k = 0; k < words.length; k++) ring2[2 + (write + k & capacity - 1)] = words[k];
|
|
644
|
+
return Atomics.store(ring2, 0, write + words.length | 0), true;
|
|
645
|
+
}
|
|
646
|
+
drainBacklog() {
|
|
647
|
+
for (; this.backlog.length > 0 && this.send(this.backlog[0]); ) this.backlog.shift();
|
|
648
|
+
}
|
|
649
|
+
receive(words) {
|
|
650
|
+
let receive = this.engine.exports.engine_audio_relay_receive;
|
|
651
|
+
if (!receive || words.length === 0) return;
|
|
652
|
+
let bytes = words.length * (4), pointer = words.length <= this.stagingWords ? this.staging : this.engine.allocate(bytes);
|
|
653
|
+
new Uint32Array(this.engine.memory.buffer, pointer, words.length).set(words), receive(this.handle, pointer, words.length), pointer !== this.staging && this.engine.release(pointer, bytes);
|
|
654
|
+
}
|
|
655
|
+
collect() {
|
|
656
|
+
if (this.outbound === null) {
|
|
657
|
+
for (let report of this.reports) this.receive(report);
|
|
658
|
+
this.reports.length = 0;
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
let ring2 = this.outbound, capacity = ring2.length - 2, write = Atomics.load(ring2, 0), read = Atomics.load(ring2, 1), available = write - read | 0;
|
|
662
|
+
if (available <= 0) return;
|
|
663
|
+
let words = new Uint32Array(available);
|
|
664
|
+
for (let k = 0; k < available; k++) words[k] = ring2[2 + (read + k & capacity - 1)];
|
|
665
|
+
Atomics.store(ring2, 1, read + available | 0), this.receive(words);
|
|
666
|
+
}
|
|
667
|
+
pump() {
|
|
668
|
+
let pump = this.engine.exports.engine_audio_relay_pump;
|
|
669
|
+
if (!pump) return;
|
|
670
|
+
this.collect(), this.drainBacklog();
|
|
671
|
+
let sent = this.backlog.length;
|
|
672
|
+
for (; ; ) {
|
|
673
|
+
let words = pump(this.handle, this.staging, this.stagingWords);
|
|
674
|
+
if (words <= 0) break;
|
|
675
|
+
sent += words;
|
|
676
|
+
let batch = new Uint32Array(this.engine.memory.buffer, this.staging, words).slice();
|
|
677
|
+
(this.backlog.length > 0 || !this.send(batch)) && this.backlog.push(batch);
|
|
678
|
+
}
|
|
679
|
+
this.settle(sent);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/game/audio/headless.ts
|
|
684
|
+
var NO_SOUND = -1, NO_BUS = -1, MATRIX_TRANSLATION = 12, FILTER_WORDS = 4, LOOP_WORDS = 3, RATE_WORDS = 2, HEADLESS_SAMPLE_RATE = 48e3, DEFAULT_STREAM_SECONDS = 180, SEND_KEY = 1024, HeadlessAudio = class {
|
|
685
|
+
constructor(maxVoices = 64) {
|
|
686
|
+
this.name = "headless";
|
|
687
|
+
this.capabilities = FULL_AUDIO_CAPABILITIES;
|
|
688
|
+
this.sampleRate = (48e3);
|
|
689
|
+
this.unlockedValue = false;
|
|
690
|
+
this.soundCount = 0;
|
|
691
|
+
this.busCount = 0;
|
|
692
|
+
this.busGains = [];
|
|
693
|
+
this.busFilters = [];
|
|
694
|
+
this.busMeters = [];
|
|
695
|
+
this.sends = /* @__PURE__ */ new Map();
|
|
696
|
+
this.reverbs = /* @__PURE__ */ new Map();
|
|
697
|
+
this.analysers = [];
|
|
698
|
+
this.analyserBus = [];
|
|
699
|
+
this.streams = [];
|
|
700
|
+
this.listener = new Float32Array(16);
|
|
701
|
+
this.nextVoice = 0;
|
|
702
|
+
this.voiceSound = new Int32Array(maxVoices).fill((-1)), this.voiceLoop = new Uint8Array(maxVoices), this.voicePosition = new Float32Array(maxVoices * 3), this.voiceGain = new Float32Array(maxVoices), this.voiceRate = new Float32Array(maxVoices * (2)), this.voiceLoopPoints = new Float32Array(maxVoices * (3)), this.voiceSpatial = new Float32Array(maxVoices * SPATIAL_WORDS);
|
|
703
|
+
}
|
|
704
|
+
get unlocked() {
|
|
705
|
+
return this.unlockedValue;
|
|
706
|
+
}
|
|
707
|
+
unlock() {
|
|
708
|
+
this.unlockedValue = true;
|
|
709
|
+
}
|
|
710
|
+
decode(_source) {
|
|
711
|
+
return Promise.resolve(this.soundCount++);
|
|
712
|
+
}
|
|
713
|
+
createSound(samples, channels, sampleRate) {
|
|
714
|
+
if (channels < 1 || sampleRate <= 0 || samples.length % channels !== 0) throw new GameError("invalid_argument", "sound PCM must be interleaved whole frames");
|
|
715
|
+
return this.soundCount++;
|
|
716
|
+
}
|
|
717
|
+
createBus(_name, _parent) {
|
|
718
|
+
this.busGains.push(1);
|
|
719
|
+
for (let i = 0; i < (4); i++) this.busFilters.push(i === 0 ? FILTER_OFF : 0);
|
|
720
|
+
return this.busMeters.push(0, 0), this.busCount++;
|
|
721
|
+
}
|
|
722
|
+
setBusGain(bus, gain, _rampSeconds) {
|
|
723
|
+
this.busGains[bus] = gain;
|
|
724
|
+
}
|
|
725
|
+
busGain(bus) {
|
|
726
|
+
return this.busGains[bus];
|
|
727
|
+
}
|
|
728
|
+
setBusFilter(bus, kind, frequency, q, gainDb) {
|
|
729
|
+
let o = bus * (4);
|
|
730
|
+
this.busFilters[o] = kind, this.busFilters[o + 1] = frequency, this.busFilters[o + 2] = q, this.busFilters[o + 3] = gainDb;
|
|
731
|
+
}
|
|
732
|
+
busFilter(bus, out) {
|
|
733
|
+
for (let i = 0; i < (4); i++) out[i] = this.busFilters[bus * (4) + i];
|
|
734
|
+
}
|
|
735
|
+
meter(bus, out) {
|
|
736
|
+
out[METER_PEAK] = this.busMeters[bus * 2] ?? 0, out[METER_RMS] = this.busMeters[bus * 2 + 1] ?? 0;
|
|
737
|
+
}
|
|
738
|
+
inject(bus, samples) {
|
|
739
|
+
let peak = 0, energy = 0;
|
|
740
|
+
for (let i = 0; i < samples.length; i++) {
|
|
741
|
+
let v = samples[i], a = v < 0 ? -v : v;
|
|
742
|
+
a > peak && (peak = a), energy += v * v;
|
|
743
|
+
}
|
|
744
|
+
this.busMeters[bus * 2] = peak, this.busMeters[bus * 2 + 1] = samples.length > 0 ? Math.sqrt(energy / samples.length) : 0;
|
|
745
|
+
for (let a = 0; a < this.analysers.length; a++)
|
|
746
|
+
this.analyserBus[a] === bus && this.analysers[a].push(samples, 0, samples.length);
|
|
747
|
+
}
|
|
748
|
+
createAnalyser(bus, settings) {
|
|
749
|
+
return this.analysers.push(new FftAnalyser(settings)), this.analyserBus.push(bus), this.analysers.length - 1;
|
|
750
|
+
}
|
|
751
|
+
readAnalyser(analyser, mode, out) {
|
|
752
|
+
let found = this.analysers[analyser];
|
|
753
|
+
if (!found) throw new GameError("unknown_resource", `analyser ${analyser} does not exist`);
|
|
754
|
+
mode === ANALYSER_FREQUENCY ? found.frequency(out) : found.timeDomain(out);
|
|
755
|
+
}
|
|
756
|
+
createReverb(parent, impulse) {
|
|
757
|
+
let bus = this.createBus("reverb", parent);
|
|
758
|
+
return this.reverbs.set(bus, impulse), bus;
|
|
759
|
+
}
|
|
760
|
+
reverbImpulse(bus) {
|
|
761
|
+
return this.reverbs.get(bus) ?? (-1);
|
|
762
|
+
}
|
|
763
|
+
setBusSend(bus, target, gain) {
|
|
764
|
+
this.sends.set(bus * (1024) + target, gain);
|
|
765
|
+
}
|
|
766
|
+
busSend(bus, target) {
|
|
767
|
+
return this.sends.get(bus * (1024) + target) ?? 0;
|
|
768
|
+
}
|
|
769
|
+
play(sound, _bus, gain, rate, loop, _spatial) {
|
|
770
|
+
let voice = this.nextVoice;
|
|
771
|
+
return this.nextVoice = (this.nextVoice + 1) % this.voiceSound.length, this.voiceSound[voice] = sound, this.voiceLoop[voice] = loop ? 1 : 0, this.voiceGain[voice] = gain, this.voiceRate[voice * (2)] = rate, this.voiceRate[voice * (2) + 1] = 0, this.voiceLoopPoints[voice * (3)] = loop ? 1 : 0, this.voiceLoopPoints[voice * (3) + 1] = 0, this.voiceLoopPoints[voice * (3) + 2] = 0, voice;
|
|
772
|
+
}
|
|
773
|
+
stop(voice, _fadeSeconds) {
|
|
774
|
+
this.voiceSound[voice] = (-1);
|
|
775
|
+
}
|
|
776
|
+
isPlaying(voice) {
|
|
777
|
+
return this.voiceSound[voice] !== (-1);
|
|
778
|
+
}
|
|
779
|
+
setVoiceGain(voice, gain, _rampSeconds) {
|
|
780
|
+
this.voiceGain[voice] = gain;
|
|
781
|
+
}
|
|
782
|
+
voiceGainOf(voice) {
|
|
783
|
+
return this.voiceGain[voice];
|
|
784
|
+
}
|
|
785
|
+
setVoiceRate(voice, rate, detuneCents) {
|
|
786
|
+
this.voiceRate[voice * (2)] = rate, this.voiceRate[voice * (2) + 1] = detuneCents;
|
|
787
|
+
}
|
|
788
|
+
voiceRateOf(voice, out) {
|
|
789
|
+
out[0] = this.voiceRate[voice * (2)], out[1] = this.voiceRate[voice * (2) + 1];
|
|
790
|
+
}
|
|
791
|
+
setVoiceSpatial(voice, params) {
|
|
792
|
+
this.voiceSpatial.set(params.subarray(0, SPATIAL_WORDS), voice * SPATIAL_WORDS);
|
|
793
|
+
}
|
|
794
|
+
voiceSpatialOf(voice, out) {
|
|
795
|
+
for (let i = 0; i < SPATIAL_WORDS; i++) out[i] = this.voiceSpatial[voice * SPATIAL_WORDS + i];
|
|
796
|
+
}
|
|
797
|
+
setVoiceLoop(voice, loop, startSeconds, endSeconds) {
|
|
798
|
+
let o = voice * (3);
|
|
799
|
+
this.voiceLoop[voice] = loop ? 1 : 0, this.voiceLoopPoints[o] = loop ? 1 : 0, this.voiceLoopPoints[o + 1] = startSeconds, this.voiceLoopPoints[o + 2] = endSeconds;
|
|
800
|
+
}
|
|
801
|
+
voiceLoopOf(voice, out) {
|
|
802
|
+
for (let i = 0; i < (3); i++) out[i] = this.voiceLoopPoints[voice * (3) + i];
|
|
803
|
+
}
|
|
804
|
+
setVoicePosition(voice, matrix, offset) {
|
|
805
|
+
let o = voice * 3;
|
|
806
|
+
this.voicePosition[o] = matrix[offset + (12)], this.voicePosition[o + 1] = matrix[offset + (12) + 1], this.voicePosition[o + 2] = matrix[offset + (12) + 2];
|
|
807
|
+
}
|
|
808
|
+
voiceX(voice) {
|
|
809
|
+
return this.voicePosition[voice * 3];
|
|
810
|
+
}
|
|
811
|
+
setListener(matrix, offset) {
|
|
812
|
+
for (let i = 0; i < 16; i++) this.listener[i] = matrix[offset + i];
|
|
813
|
+
}
|
|
814
|
+
async openStream(_source, bus) {
|
|
815
|
+
return this.streams.push({ bus, state: STREAM_STOPPED, loop: false, gain: 1, time: 0, duration: (180) }), this.streams.length - 1;
|
|
816
|
+
}
|
|
817
|
+
stream(stream) {
|
|
818
|
+
let found = this.streams[stream];
|
|
819
|
+
if (!found) throw new GameError("unknown_resource", `stream ${stream} is not open`);
|
|
820
|
+
return found;
|
|
821
|
+
}
|
|
822
|
+
playStream(stream, gain, loop) {
|
|
823
|
+
let s = this.stream(stream);
|
|
824
|
+
s.state = STREAM_PLAYING, s.gain = gain, s.loop = loop;
|
|
825
|
+
}
|
|
826
|
+
pauseStream(stream) {
|
|
827
|
+
this.stream(stream).state = STREAM_PAUSED;
|
|
828
|
+
}
|
|
829
|
+
seekStream(stream, seconds) {
|
|
830
|
+
let s = this.stream(stream);
|
|
831
|
+
s.time = Math.max(0, Math.min(s.duration, seconds));
|
|
832
|
+
}
|
|
833
|
+
streamTime(stream) {
|
|
834
|
+
return this.stream(stream).time;
|
|
835
|
+
}
|
|
836
|
+
streamDuration(stream) {
|
|
837
|
+
return this.stream(stream).duration;
|
|
838
|
+
}
|
|
839
|
+
streamState(stream) {
|
|
840
|
+
return this.stream(stream).state;
|
|
841
|
+
}
|
|
842
|
+
closeStream(stream) {
|
|
843
|
+
this.streams[stream] = null;
|
|
844
|
+
}
|
|
845
|
+
commit(frame, at) {
|
|
846
|
+
let seconds = frame[at];
|
|
847
|
+
for (let i = 0; i < this.streams.length; i++) {
|
|
848
|
+
let s = this.streams[i];
|
|
849
|
+
s === null || s.state !== STREAM_PLAYING || (s.time += seconds, s.time >= s.duration && (s.loop ? s.time -= s.duration : (s.time = s.duration, s.state = STREAM_STOPPED)));
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
suspend() {
|
|
853
|
+
}
|
|
854
|
+
resume() {
|
|
855
|
+
}
|
|
856
|
+
dispose() {
|
|
857
|
+
this.voiceSound.fill((-1)), this.streams.length = 0, this.analyserBus.fill((-1));
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// src/game/audio/web-audio.ts
|
|
862
|
+
var MASTER_PARENT = -1, MATRIX_TRANSLATION2 = 12, PANNER_REF_DISTANCE = 1, PANNER_MAX_DISTANCE = 100, RAMP_TIME_CONSTANT_DIVISOR = 3, METER_FFT_SIZE = 1024, SEND_KEY2 = 1024, WebAudioPort = class {
|
|
863
|
+
constructor(context, maxVoices = 64, options = {}) {
|
|
864
|
+
this.name = "web-audio";
|
|
865
|
+
this.buffers = [];
|
|
866
|
+
this.buses = [];
|
|
867
|
+
this.analysers = [];
|
|
868
|
+
this.sends = /* @__PURE__ */ new Map();
|
|
869
|
+
this.streams = [];
|
|
870
|
+
this.meterScratch = new Float32Array((1024));
|
|
871
|
+
this.nextVoice = 0;
|
|
872
|
+
this.context = context, this.voices = Array.from({ length: maxVoices }, () => ({ source: null, gain: null, panner: null })), this.onEnded = Array.from({ length: maxVoices }, (_, voice) => () => this.release(voice)), this.createMediaElement = options.createMediaElement ?? (typeof document > "u" ? null : () => document.createElement("audio"));
|
|
873
|
+
let streaming = this.createMediaElement !== null && typeof context.createMediaElementSource == "function";
|
|
874
|
+
this.capabilities = {
|
|
875
|
+
spatial: true,
|
|
876
|
+
filters: true,
|
|
877
|
+
meters: true,
|
|
878
|
+
analyser: true,
|
|
879
|
+
reverb: true,
|
|
880
|
+
sends: true,
|
|
881
|
+
loopPoints: true,
|
|
882
|
+
streaming,
|
|
883
|
+
detune: true,
|
|
884
|
+
procedural: true
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
get sampleRate() {
|
|
888
|
+
return this.context.sampleRate;
|
|
889
|
+
}
|
|
890
|
+
get unlocked() {
|
|
891
|
+
return this.context.state === "running";
|
|
892
|
+
}
|
|
893
|
+
unlock() {
|
|
894
|
+
this.context.state !== "running" && this.context.resume();
|
|
895
|
+
}
|
|
896
|
+
async decode(source) {
|
|
897
|
+
let bytes;
|
|
898
|
+
if ("bytes" in source) bytes = source.bytes.slice(0);
|
|
899
|
+
else if ("url" in source) bytes = await (await fetch(source.url)).arrayBuffer();
|
|
900
|
+
else throw new GameError("invalid_argument", "audio sources are bytes or a url");
|
|
901
|
+
return this.buffers.push(await this.context.decodeAudioData(bytes)), this.buffers.length - 1;
|
|
902
|
+
}
|
|
903
|
+
createSound(samples, channels, sampleRate) {
|
|
904
|
+
if (channels < 1 || sampleRate <= 0 || samples.length % channels !== 0) throw new GameError("invalid_argument", "sound PCM must be interleaved whole frames");
|
|
905
|
+
let frames = samples.length / channels, buffer = this.context.createBuffer(channels, frames, sampleRate);
|
|
906
|
+
for (let c = 0; c < channels; c++) {
|
|
907
|
+
let data = buffer.getChannelData(c);
|
|
908
|
+
for (let i = 0; i < frames; i++) data[i] = samples[i * channels + c];
|
|
909
|
+
}
|
|
910
|
+
return this.buffers.push(buffer), this.buffers.length - 1;
|
|
911
|
+
}
|
|
912
|
+
createBus(_name, parent) {
|
|
913
|
+
let input = this.context.createGain(), target = parent === (-1) ? audioOutput(this.context) : this.buses[parent].input;
|
|
914
|
+
return input.connect(target), this.buses.push({ input, parent: target, tail: input, body: input, filter: null, meter: null }), this.buses.length - 1;
|
|
915
|
+
}
|
|
916
|
+
createReverb(parent, impulse) {
|
|
917
|
+
let buffer = this.buffers[impulse];
|
|
918
|
+
if (!buffer) throw new GameError("unknown_resource", `impulse sound ${impulse} is not loaded`);
|
|
919
|
+
let input = this.context.createGain(), convolver = this.context.createConvolver();
|
|
920
|
+
convolver.normalize = true, convolver.buffer = buffer;
|
|
921
|
+
let target = parent === (-1) ? audioOutput(this.context) : this.buses[parent].input;
|
|
922
|
+
return input.connect(convolver), convolver.connect(target), this.buses.push({ input, parent: target, tail: convolver, body: convolver, filter: null, meter: null }), this.buses.length - 1;
|
|
923
|
+
}
|
|
924
|
+
setBusGain(bus, gain, rampSeconds) {
|
|
925
|
+
this.ramp(this.buses[bus].input.gain, gain, rampSeconds);
|
|
926
|
+
}
|
|
927
|
+
setBusFilter(bus, kind, frequency, q, gainDb) {
|
|
928
|
+
let b = this.buses[bus];
|
|
929
|
+
if (kind < 0) {
|
|
930
|
+
if (b.filter === null) return;
|
|
931
|
+
b.body.disconnect(b.filter), b.filter.disconnect(), b.body.connect(b.parent), b.meter && b.body.connect(b.meter), b.filter = null, b.tail = b.body;
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
let type = FILTER_KINDS[kind];
|
|
935
|
+
if (type === void 0) throw new GameError("invalid_argument", `filter kind ${kind} is unknown`);
|
|
936
|
+
let filter = b.filter;
|
|
937
|
+
filter === null && (filter = this.context.createBiquadFilter(), b.body.disconnect(b.parent), b.meter && b.body.disconnect(b.meter), b.body.connect(filter), filter.connect(b.parent), b.meter && filter.connect(b.meter), b.filter = filter, b.tail = filter), filter.type = type, filter.frequency.setValueAtTime(frequency, this.context.currentTime), filter.Q.setValueAtTime(q, this.context.currentTime), filter.gain.setValueAtTime(gainDb, this.context.currentTime);
|
|
938
|
+
}
|
|
939
|
+
meter(bus, out) {
|
|
940
|
+
let b = this.buses[bus];
|
|
941
|
+
b.meter === null && (b.meter = this.context.createAnalyser(), b.meter.fftSize = (1024), b.tail.connect(b.meter));
|
|
942
|
+
let data = this.meterScratch;
|
|
943
|
+
b.meter.getFloatTimeDomainData(data);
|
|
944
|
+
let peak = 0, energy = 0;
|
|
945
|
+
for (let i = 0; i < data.length; i++) {
|
|
946
|
+
let v = data[i], a = v < 0 ? -v : v;
|
|
947
|
+
a > peak && (peak = a), energy += v * v;
|
|
948
|
+
}
|
|
949
|
+
out[METER_PEAK] = peak, out[METER_RMS] = Math.sqrt(energy / data.length);
|
|
950
|
+
}
|
|
951
|
+
createAnalyser(bus, settings) {
|
|
952
|
+
let node = this.context.createAnalyser();
|
|
953
|
+
return node.fftSize = settings.fftSize, node.smoothingTimeConstant = settings.smoothing, node.minDecibels = settings.minDecibels, node.maxDecibels = settings.maxDecibels, this.buses[bus].tail.connect(node), this.analysers.push(node), this.analysers.length - 1;
|
|
954
|
+
}
|
|
955
|
+
readAnalyser(analyser, mode, out) {
|
|
956
|
+
let node = this.analysers[analyser];
|
|
957
|
+
if (!node) throw new GameError("unknown_resource", `analyser ${analyser} does not exist`);
|
|
958
|
+
out instanceof Uint8Array ? mode === ANALYSER_FREQUENCY ? node.getByteFrequencyData(out) : node.getByteTimeDomainData(out) : mode === ANALYSER_FREQUENCY ? node.getFloatFrequencyData(out) : node.getFloatTimeDomainData(out);
|
|
959
|
+
}
|
|
960
|
+
setBusSend(bus, target, gain) {
|
|
961
|
+
let key = bus * (1024) + target, send = this.sends.get(key);
|
|
962
|
+
send === void 0 && (send = this.context.createGain(), this.buses[bus].input.connect(send), send.connect(this.buses[target].input), this.sends.set(key, send)), send.gain.setValueAtTime(gain, this.context.currentTime);
|
|
963
|
+
}
|
|
964
|
+
play(sound, bus, gain, rate, loop, spatial) {
|
|
965
|
+
let id = this.nextVoice;
|
|
966
|
+
this.nextVoice = (this.nextVoice + 1) % this.voices.length, this.release(id);
|
|
967
|
+
let voice = this.voices[id], source = this.context.createBufferSource();
|
|
968
|
+
source.buffer = this.buffers[sound], source.loop = loop, source.playbackRate.value = rate;
|
|
969
|
+
let gainNode = this.context.createGain();
|
|
970
|
+
if (gainNode.gain.value = gain, source.connect(gainNode), spatial) {
|
|
971
|
+
let panner = this.context.createPanner();
|
|
972
|
+
panner.panningModel = "HRTF", panner.refDistance = (1), panner.maxDistance = (100), gainNode.connect(panner), panner.connect(this.buses[bus].input), voice.panner = panner;
|
|
973
|
+
} else
|
|
974
|
+
gainNode.connect(this.buses[bus].input);
|
|
975
|
+
return source.addEventListener("ended", this.onEnded[id]), source.start(), voice.source = source, voice.gain = gainNode, id;
|
|
976
|
+
}
|
|
977
|
+
stop(voice, fadeSeconds) {
|
|
978
|
+
let v = this.voices[voice];
|
|
979
|
+
if (!v.source || !v.gain) return;
|
|
980
|
+
if (fadeSeconds <= 0) {
|
|
981
|
+
v.source.stop();
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
let now = this.context.currentTime;
|
|
985
|
+
v.gain.gain.setTargetAtTime(0, now, fadeSeconds / (3)), v.source.stop(now + fadeSeconds);
|
|
986
|
+
}
|
|
987
|
+
isPlaying(voice) {
|
|
988
|
+
return this.voices[voice].source !== null;
|
|
989
|
+
}
|
|
990
|
+
setVoiceGain(voice, gain, rampSeconds) {
|
|
991
|
+
let node = this.voices[voice]?.gain;
|
|
992
|
+
node && this.ramp(node.gain, gain, rampSeconds);
|
|
993
|
+
}
|
|
994
|
+
setVoiceRate(voice, rate, detuneCents) {
|
|
995
|
+
let source = this.voices[voice]?.source;
|
|
996
|
+
if (!source) return;
|
|
997
|
+
let now = this.context.currentTime;
|
|
998
|
+
source.playbackRate.setValueAtTime(rate, now), source.detune.setValueAtTime(detuneCents, now);
|
|
999
|
+
}
|
|
1000
|
+
setVoiceSpatial(voice, params) {
|
|
1001
|
+
let panner = this.voices[voice]?.panner;
|
|
1002
|
+
panner && (panner.distanceModel = DISTANCE_MODELS[params[SPATIAL_MODEL]] ?? "inverse", panner.refDistance = params[SPATIAL_REF_DISTANCE], panner.maxDistance = params[SPATIAL_MAX_DISTANCE], panner.rolloffFactor = params[SPATIAL_ROLLOFF], panner.coneInnerAngle = params[SPATIAL_CONE_INNER], panner.coneOuterAngle = params[SPATIAL_CONE_OUTER], panner.coneOuterGain = params[SPATIAL_CONE_OUTER_GAIN]);
|
|
1003
|
+
}
|
|
1004
|
+
setVoiceLoop(voice, loop, startSeconds, endSeconds) {
|
|
1005
|
+
let source = this.voices[voice]?.source;
|
|
1006
|
+
source && (source.loop = loop, source.loopStart = startSeconds, source.loopEnd = endSeconds);
|
|
1007
|
+
}
|
|
1008
|
+
setVoicePosition(voice, matrix, offset) {
|
|
1009
|
+
let panner = this.voices[voice].panner;
|
|
1010
|
+
panner && (panner.positionX.value = matrix[offset + (12)], panner.positionY.value = matrix[offset + (12) + 1], panner.positionZ.value = matrix[offset + (12) + 2], panner.orientationX.value = -matrix[offset + 8], panner.orientationY.value = -matrix[offset + 9], panner.orientationZ.value = -matrix[offset + 10]);
|
|
1011
|
+
}
|
|
1012
|
+
setListener(matrix, offset) {
|
|
1013
|
+
let l = this.context.listener;
|
|
1014
|
+
l.positionX.value = matrix[offset + 12], l.positionY.value = matrix[offset + 13], l.positionZ.value = matrix[offset + 14], l.forwardX.value = -matrix[offset + 8], l.forwardY.value = -matrix[offset + 9], l.forwardZ.value = -matrix[offset + 10], l.upX.value = matrix[offset + 4], l.upY.value = matrix[offset + 5], l.upZ.value = matrix[offset + 6];
|
|
1015
|
+
}
|
|
1016
|
+
async openStream(source, bus) {
|
|
1017
|
+
let make = this.createMediaElement;
|
|
1018
|
+
if (make === null || !this.capabilities.streaming) throw new GameError("unsupported_feature", "this audio context cannot stream media");
|
|
1019
|
+
let element = make(), objectUrl = null;
|
|
1020
|
+
if ("url" in source) element.src = source.url;
|
|
1021
|
+
else if ("bytes" in source)
|
|
1022
|
+
objectUrl = URL.createObjectURL(new Blob([source.bytes])), element.src = objectUrl;
|
|
1023
|
+
else throw new GameError("invalid_argument", "streams play from bytes or a url");
|
|
1024
|
+
element.crossOrigin = "anonymous", element.preload = "auto";
|
|
1025
|
+
let node = this.context.createMediaElementSource(element), gain = this.context.createGain();
|
|
1026
|
+
return node.connect(gain), gain.connect(this.buses[bus].input), this.streams.push({ element, source: node, gain, objectUrl }), this.streams.length - 1;
|
|
1027
|
+
}
|
|
1028
|
+
stream(stream) {
|
|
1029
|
+
let found = this.streams[stream];
|
|
1030
|
+
if (!found) throw new GameError("unknown_resource", `stream ${stream} is not open`);
|
|
1031
|
+
return found;
|
|
1032
|
+
}
|
|
1033
|
+
playStream(stream, gain, loop) {
|
|
1034
|
+
let s = this.stream(stream);
|
|
1035
|
+
s.gain.gain.setValueAtTime(gain, this.context.currentTime), s.element.loop = loop;
|
|
1036
|
+
let started = s.element.play();
|
|
1037
|
+
started && started.catch(() => {
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
pauseStream(stream) {
|
|
1041
|
+
this.stream(stream).element.pause();
|
|
1042
|
+
}
|
|
1043
|
+
seekStream(stream, seconds) {
|
|
1044
|
+
this.stream(stream).element.currentTime = Math.max(0, seconds);
|
|
1045
|
+
}
|
|
1046
|
+
streamTime(stream) {
|
|
1047
|
+
return this.stream(stream).element.currentTime;
|
|
1048
|
+
}
|
|
1049
|
+
streamDuration(stream) {
|
|
1050
|
+
let duration = this.stream(stream).element.duration;
|
|
1051
|
+
return Number.isFinite(duration) ? duration : 0;
|
|
1052
|
+
}
|
|
1053
|
+
closeStream(stream) {
|
|
1054
|
+
let s = this.streams[stream];
|
|
1055
|
+
s && (s.element.pause(), s.source.disconnect(), s.gain.disconnect(), s.objectUrl !== null && URL.revokeObjectURL(s.objectUrl), this.streams[stream] = null);
|
|
1056
|
+
}
|
|
1057
|
+
suspend() {
|
|
1058
|
+
this.context.suspend();
|
|
1059
|
+
}
|
|
1060
|
+
resume() {
|
|
1061
|
+
this.context.resume();
|
|
1062
|
+
}
|
|
1063
|
+
dispose() {
|
|
1064
|
+
for (let i = 0; i < this.voices.length; i++) this.release(i);
|
|
1065
|
+
for (let i = 0; i < this.streams.length; i++) this.closeStream(i);
|
|
1066
|
+
this.context.close();
|
|
1067
|
+
}
|
|
1068
|
+
ramp(param, value, rampSeconds) {
|
|
1069
|
+
rampSeconds <= 0 ? param.setValueAtTime(value, this.context.currentTime) : param.setTargetAtTime(value, this.context.currentTime, rampSeconds / (3));
|
|
1070
|
+
}
|
|
1071
|
+
release(id) {
|
|
1072
|
+
let voice = this.voices[id], source = voice.source;
|
|
1073
|
+
source && (source.removeEventListener("ended", this.onEnded[id]), source.stop(), source.disconnect()), voice.gain?.disconnect(), voice.panner?.disconnect(), voice.source = null, voice.gain = null, voice.panner = null;
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
// src/game/terrain/port.ts
|
|
1078
|
+
var TERRAIN_SOURCE = { recipe: 0, pack: 1, planet: 2 }, TERRAIN_REGISTER = {
|
|
1079
|
+
requested: 0,
|
|
1080
|
+
installed: 1,
|
|
1081
|
+
inflight: 2,
|
|
1082
|
+
resident: 3,
|
|
1083
|
+
nodes: 4,
|
|
1084
|
+
touched: 5,
|
|
1085
|
+
deferred: 6,
|
|
1086
|
+
totalInstalls: 7
|
|
1087
|
+
}, BRUSH = {
|
|
1088
|
+
raise: 0,
|
|
1089
|
+
lower: 1,
|
|
1090
|
+
smooth: 2,
|
|
1091
|
+
flatten: 3,
|
|
1092
|
+
paint: 4,
|
|
1093
|
+
hole: 5,
|
|
1094
|
+
fill: 6
|
|
1095
|
+
}, NOISE = { perlin: 0, simplex2: 1, simplex3: 2, worley: 3 };
|
|
1096
|
+
|
|
1097
|
+
// src/game/terrain/engine.ts
|
|
1098
|
+
var ENGINE_TERRAIN_EXPORT_NAMES = [
|
|
1099
|
+
"engine_terrain_open",
|
|
1100
|
+
"engine_terrain_close",
|
|
1101
|
+
"engine_terrain_update",
|
|
1102
|
+
"engine_terrain_registers",
|
|
1103
|
+
"engine_terrain_height",
|
|
1104
|
+
"engine_terrain_normal",
|
|
1105
|
+
"engine_terrain_sculpt",
|
|
1106
|
+
"engine_terrain_colliders",
|
|
1107
|
+
"engine_physics_radial_gravity",
|
|
1108
|
+
"engine_terrain_grass",
|
|
1109
|
+
"engine_terrain_wind",
|
|
1110
|
+
"engine_terrain_interactors",
|
|
1111
|
+
"engine_terrain_look",
|
|
1112
|
+
"engine_terrain_scatter",
|
|
1113
|
+
"engine_noise",
|
|
1114
|
+
"engine_noise_fbm"
|
|
1115
|
+
], NULL = 0, F32_BYTES = 4, NORMAL_FLOATS = 3, GRAVITY_SURFACE = 3, GRAVITY_RADIUS = 4, SCRATCH_FLOATS = Math.max(
|
|
1116
|
+
8,
|
|
1117
|
+
12,
|
|
1118
|
+
7,
|
|
1119
|
+
6,
|
|
1120
|
+
14,
|
|
1121
|
+
16,
|
|
1122
|
+
32,
|
|
1123
|
+
64
|
|
1124
|
+
) * 2;
|
|
1125
|
+
function engineTerrainExports(runtime) {
|
|
1126
|
+
let symbols = runtime.symbols;
|
|
1127
|
+
return ENGINE_TERRAIN_EXPORT_NAMES.every((name) => typeof symbols[name] == "function") ? symbols : null;
|
|
1128
|
+
}
|
|
1129
|
+
var EngineTerrain = class {
|
|
1130
|
+
constructor(runtime, exports, render, world) {
|
|
1131
|
+
this.runtime = runtime;
|
|
1132
|
+
this.exports = exports;
|
|
1133
|
+
this.render = render;
|
|
1134
|
+
this.world = world;
|
|
1135
|
+
this.scratch = { pointer: (0), bytes: 0 };
|
|
1136
|
+
this.second = { pointer: (0), bytes: 0 };
|
|
1137
|
+
this.columns = { pointer: (0), bytes: 0 };
|
|
1138
|
+
this.buffer = null;
|
|
1139
|
+
this.floats = new Float32Array(0);
|
|
1140
|
+
this.words = new Uint32Array(0);
|
|
1141
|
+
this.bytes = new Uint8Array(0);
|
|
1142
|
+
}
|
|
1143
|
+
views() {
|
|
1144
|
+
let buffer = this.runtime.memory.buffer;
|
|
1145
|
+
buffer !== this.buffer && (this.buffer = buffer, this.floats = new Float32Array(buffer), this.words = new Uint32Array(buffer), this.bytes = new Uint8Array(buffer));
|
|
1146
|
+
}
|
|
1147
|
+
ensure(block, bytes) {
|
|
1148
|
+
if (block.bytes >= bytes) return block.pointer;
|
|
1149
|
+
if (block.pointer !== (0) && this.runtime.exports.engine_free(block.pointer, block.bytes, COLUMN_ALIGN), block.bytes = Math.max(bytes, COLUMN_ALIGN), block.pointer = this.runtime.exports.engine_alloc(block.bytes, COLUMN_ALIGN), block.pointer === (0))
|
|
1150
|
+
throw block.bytes = 0, new GameError("capacity_exceeded", "engine memory cannot hold terrain buffers");
|
|
1151
|
+
return block.pointer;
|
|
1152
|
+
}
|
|
1153
|
+
put(block, values, count = values.length) {
|
|
1154
|
+
let pointer = this.ensure(block, Math.max(SCRATCH_FLOATS, count) * (4));
|
|
1155
|
+
this.views();
|
|
1156
|
+
let at = pointer >>> 2;
|
|
1157
|
+
for (let i = 0; i < count; i++) this.floats[at + i] = values[i];
|
|
1158
|
+
return pointer;
|
|
1159
|
+
}
|
|
1160
|
+
open(desc, source, recipe, pack) {
|
|
1161
|
+
let descPointer = this.put(this.scratch, desc), recipePointer = this.put(this.second, recipe), packPointer = (0);
|
|
1162
|
+
if (pack !== null) {
|
|
1163
|
+
if (packPointer = this.runtime.exports.engine_alloc(Math.max(pack.byteLength, 1), COLUMN_ALIGN), packPointer === (0)) throw new GameError("capacity_exceeded", "engine memory cannot hold the terrain pack");
|
|
1164
|
+
this.views(), this.bytes.set(pack, packPointer);
|
|
1165
|
+
}
|
|
1166
|
+
let handle = this.exports.engine_terrain_open(this.render(), descPointer, source, recipePointer, packPointer, pack?.byteLength ?? 0);
|
|
1167
|
+
if (handle === (0)) throw new GameError("invalid_argument", "the engine refused the terrain description");
|
|
1168
|
+
return handle;
|
|
1169
|
+
}
|
|
1170
|
+
close(terrain) {
|
|
1171
|
+
this.exports.engine_terrain_close(terrain, this.render());
|
|
1172
|
+
}
|
|
1173
|
+
update(terrain, eye) {
|
|
1174
|
+
return this.exports.engine_terrain_update(terrain, this.render(), this.put(this.scratch, eye, 6));
|
|
1175
|
+
}
|
|
1176
|
+
registers(terrain) {
|
|
1177
|
+
let pointer = this.exports.engine_terrain_registers(terrain);
|
|
1178
|
+
if (pointer === (0)) throw new GameError("unknown_resource", "terrain is closed");
|
|
1179
|
+
return this.views(), this.words.subarray(pointer >>> 2, (pointer >>> 2) + 8);
|
|
1180
|
+
}
|
|
1181
|
+
height(x, z) {
|
|
1182
|
+
return this.exports.engine_terrain_height(this.render(), x, z);
|
|
1183
|
+
}
|
|
1184
|
+
normal(x, z, out) {
|
|
1185
|
+
let pointer = this.ensure(this.second, SCRATCH_FLOATS * (4));
|
|
1186
|
+
if (this.exports.engine_terrain_normal(this.render(), x, z, pointer) < 0) return false;
|
|
1187
|
+
this.views();
|
|
1188
|
+
let at = pointer >>> 2;
|
|
1189
|
+
for (let i = 0; i < (3); i++) out[i] = this.floats[at + i];
|
|
1190
|
+
return true;
|
|
1191
|
+
}
|
|
1192
|
+
sculpt(terrain, brush) {
|
|
1193
|
+
return this.exports.engine_terrain_sculpt(terrain, this.render(), this.put(this.scratch, brush, 7));
|
|
1194
|
+
}
|
|
1195
|
+
colliders(terrain, x, y, z) {
|
|
1196
|
+
let pointer = this.ensure(this.second, SCRATCH_FLOATS * (4));
|
|
1197
|
+
this.views();
|
|
1198
|
+
let f = this.floats, at = pointer >>> 2;
|
|
1199
|
+
return f[at] = x, f[at + 1] = y, f[at + 2] = z, this.exports.engine_terrain_colliders(terrain, this.render(), this.world(), pointer);
|
|
1200
|
+
}
|
|
1201
|
+
gravity(x, y, z, surface, radius) {
|
|
1202
|
+
let pointer = this.ensure(this.second, SCRATCH_FLOATS * (4));
|
|
1203
|
+
this.views();
|
|
1204
|
+
let f = this.floats, at = pointer >>> 2;
|
|
1205
|
+
return f[at] = x, f[at + 1] = y, f[at + 2] = z, f[at + (3)] = surface, f[at + (4)] = radius, this.exports.engine_physics_radial_gravity(this.world(), pointer);
|
|
1206
|
+
}
|
|
1207
|
+
grass(params) {
|
|
1208
|
+
return this.exports.engine_terrain_grass(this.render(), this.put(this.scratch, params, 14));
|
|
1209
|
+
}
|
|
1210
|
+
wind(x, z, strength, gust) {
|
|
1211
|
+
this.exports.engine_terrain_wind(this.render(), x, z, strength, gust);
|
|
1212
|
+
}
|
|
1213
|
+
interactors(data, count) {
|
|
1214
|
+
let n = Math.min(count, 8);
|
|
1215
|
+
this.exports.engine_terrain_interactors(this.render(), this.put(this.scratch, data, n * 4), n);
|
|
1216
|
+
}
|
|
1217
|
+
look(layers, count) {
|
|
1218
|
+
let n = Math.min(count, 8);
|
|
1219
|
+
this.exports.engine_terrain_look(this.render(), this.put(this.scratch, layers, n * 8), n);
|
|
1220
|
+
}
|
|
1221
|
+
scatter(rules, out, capacity) {
|
|
1222
|
+
let rulesPointer = this.put(this.scratch, rules, 16), columns = this.ensure(this.columns, capacity * 6 * (4)), written = this.exports.engine_terrain_scatter(this.render(), rulesPointer, columns, capacity);
|
|
1223
|
+
if (written < 0) throw new GameError("invalid_argument", `the engine refused the scatter rules (${written})`);
|
|
1224
|
+
return this.views(), out.set(this.floats.subarray(columns >>> 2, (columns >>> 2) + capacity * 6)), written;
|
|
1225
|
+
}
|
|
1226
|
+
noise(kind, x, y, z, seed) {
|
|
1227
|
+
return this.exports.engine_noise(kind, x, y, z, seed);
|
|
1228
|
+
}
|
|
1229
|
+
fbm(x, z, octaves, frequency, seed) {
|
|
1230
|
+
return this.exports.engine_noise_fbm(x, z, octaves, frequency, seed);
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
export { BRUSH, CAP_CUSTOM_PROJECTION, CAP_POINT_SHADOWS, DEFAULT_WORKLET_SIZES, ENGINE_MIX_RATE, ENGINE_TERRAIN_EXPORT_NAMES, EngineFeatures, EngineTerrain, HeadlessAudio, LIGHT_KINDS, MATERIAL_KINDS, NOISE, OWNER_STAGING, SHADOW_TYPES, TERRAIN_REGISTER, TERRAIN_SOURCE, WORKLET_PROCESSOR_NAME, WORKLET_PROCESSOR_SOURCE, WebAudioPort, WorkletAudio, characterParams, createWithDescriptor, engineTerrainExports, extraTextures, floatBits, materialFeatureFlags, materialSlotIndex, refuseUndrawnPhysicalFields, sharedMemoryAvailable, writeCharacterWords, writeMaterialExtension, writeMaterialFeatures, writeMaterialState, writeMaterialTint, writeNodeFeatures, writePlanes, writeSky, writeTextureTransforms, writeTintWords };
|