@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,981 @@
|
|
|
1
|
+
import { clamp, wrapAt, dampFactor, yawInto, atan2Into, CameraBoom, LensDriver, interpolatedPosition, BOOM_OX, BOOM_OY, BOOM_OZ, BOOM_DX, BOOM_DY, BOOM_DZ, BOOM_DISTANCE, BOOM_FREE, placeCamera, BOOM_IO_WORDS } from './chunk-Y2EMGN4T.mjs';
|
|
2
|
+
import { STAGE_X, STAGE_Y, STAGE_TIME, InputDevice } from './chunk-22BD3RHN.mjs';
|
|
3
|
+
import { emptyClipEvent, emptyClipState } from './chunk-7ARSJPV3.mjs';
|
|
4
|
+
import { CharacterMove, RayQuery, RayHit } from './chunk-HF5HPS4T.mjs';
|
|
5
|
+
import { Vec3, ShapeCastQuery } from './chunk-XPG3N5CF.mjs';
|
|
6
|
+
import { NO_ENTITY } from './chunk-T3AFF3L7.mjs';
|
|
7
|
+
import { FRAME_STEP_SECONDS_SLOT, FRAME_SECONDS_SLOT } from './chunk-IDLW4NWA.mjs';
|
|
8
|
+
import { DEFAULT_THEME, UiAction, UiProp, parseColor } from './chunk-RFVRPYR2.mjs';
|
|
9
|
+
import { GameError } from './chunk-XJIHN3BY.mjs';
|
|
10
|
+
|
|
11
|
+
// src/game/kit/character/motor.ts
|
|
12
|
+
var CHAR_VX = 0, CHAR_VY = 1, CHAR_VZ = 2, CHAR_HEADING = 3, CHAR_SPEED = 4, CHAR_COYOTE = 5, CHAR_BUFFER = 6, CHAR_CROUCH = 7, CHAR_GROUND_NX = 8, CHAR_GROUND_NY = 9, CHAR_GROUND_NZ = 10, CHAR_PLATFORM_VX = 11, CHAR_PLATFORM_VY = 12, CHAR_PLATFORM_VZ = 13, CHAR_AIR_SECONDS = 14, CHAR_LANDING_SPEED = 15, CHAR_MOVE_X = 16, CHAR_MOVE_Z = 17, CHAR_MOVE_MAGNITUDE = 18, CHAR_SPEED_NORMALIZED = 19, PLATFORM_X = 20, PLATFORM_Y = 21, PLATFORM_Z = 22, PLATFORM_YAW = 23, ROOT_DX = 24, ROOT_DZ = 25, ROOT_YAW = 26, PLATFORM_DX = 27, PLATFORM_DY = 28, PLATFORM_DZ = 29, PLATFORM_DYAW = 30, DT = 31, CACHED_DT = 32, TURN_K = 33, CROUCH_K = 34, SCRATCH = 35, SCRATCH_WORDS = 3, STATE_WORDS = (35) + (3), MOVE_IO_X = 0, MOVE_IO_Z = 1, MOVE_IO_MAGNITUDE = 2, ROOT_IO_DX = 0, ROOT_IO_DZ = 1, ROOT_IO_YAW = 2, DEFAULT_RADIUS = 0.35, DEFAULT_HEIGHT = 1.8, DEFAULT_CROUCH_HEIGHT = 1.15, DEFAULT_WALK_SPEED = 2, DEFAULT_RUN_SPEED = 5.4, DEFAULT_SPRINT_SPEED = 8, DEFAULT_CROUCH_SPEED = 1.9, DEFAULT_GROUND_ACCELERATION = 45, DEFAULT_GROUND_DECELERATION = 60, DEFAULT_AIR_ACCELERATION = 14, DEFAULT_JUMP_HEIGHT = 1.3, DEFAULT_GRAVITY = 24, DEFAULT_FALL_SCALE = 1.55, DEFAULT_CUT_SCALE = 2.8, DEFAULT_MAX_FALL = 42, DEFAULT_COYOTE = 0.11, DEFAULT_BUFFER = 0.13, DEFAULT_MAX_SLOPE = 46, DEFAULT_SLIDE_SLOPE = 50, DEFAULT_STEP_HEIGHT = 0.35, DEFAULT_SNAP = 0.3, DEFAULT_SKIN = 0.02, DEFAULT_TURN_SHARPNESS = 16, DEFAULT_MAX_TURN_SPEED = 14, DEFAULT_CROUCH_SHARPNESS = 14, DEFAULT_GROUND_STICK = 2, PROBE_DEPTH = 0.3, MIN_GROUND_NORMAL_Y = 0.2, TURN_MIN_INPUT = 0.05, SPRINT_MIN_INPUT = 0.5, WALK_INPUT = 0.5, CEILING_BLOCK = 0.5, STAND_CLEARANCE = 0.95, MIN_STEP = 1e-6, HALF = 0.5, NONE = NO_ENTITY, PLATFORM_PROBE = 0, PLATFORM_CURRENT = 1, PLATFORM_SLOTS = 2, TUNING_SPRINT = 0, TUNING_MAX_FALL = 1, TUNING_WORDS = 2, CharacterMotor = class {
|
|
13
|
+
constructor(physics, transforms, entity, options = {}) {
|
|
14
|
+
this.state = new Float64Array(STATE_WORDS);
|
|
15
|
+
this.tuning = new Float64Array((2));
|
|
16
|
+
this.grounded = false;
|
|
17
|
+
this.crouched = false;
|
|
18
|
+
this.sprinting = false;
|
|
19
|
+
this.jumping = false;
|
|
20
|
+
this.landed = false;
|
|
21
|
+
this.jumped = false;
|
|
22
|
+
this.landings = 0;
|
|
23
|
+
this.jumps = 0;
|
|
24
|
+
this.useRootMotion = false;
|
|
25
|
+
this.faceMovement = true;
|
|
26
|
+
this.wasGrounded = false;
|
|
27
|
+
this.jumpPressed = false;
|
|
28
|
+
this.jumpHeld = false;
|
|
29
|
+
this.sprintWanted = false;
|
|
30
|
+
this.crouchWanted = false;
|
|
31
|
+
this.platform = new Uint32Array((2)).fill(NONE);
|
|
32
|
+
this.onPlatform = false;
|
|
33
|
+
this.desired = new Vec3();
|
|
34
|
+
this.moved = new CharacterMove();
|
|
35
|
+
this.ray = new RayQuery();
|
|
36
|
+
this.hit = new RayHit();
|
|
37
|
+
this.cast = new ShapeCastQuery();
|
|
38
|
+
this.physics = physics, this.transforms = transforms, this.entity = entity, this.radius = options.radius ?? (0.35), this.height = Math.max(options.height ?? (1.8), this.radius * 2), this.crouchHeight = clamp(options.crouchHeight ?? (1.15), this.radius * 2, this.height), this.walkSpeed = options.walkSpeed ?? (2), this.runSpeed = options.runSpeed ?? (5.4), this.sprintSpeed = options.sprintSpeed ?? (8), this.crouchSpeed = options.crouchSpeed ?? (1.9), this.groundAcceleration = options.groundAcceleration ?? (45), this.groundDeceleration = options.groundDeceleration ?? (60), this.airAcceleration = options.airAcceleration ?? (14), this.gravity = options.gravity ?? (24), this.jumpVelocity = Math.sqrt(2 * this.gravity * (options.jumpHeight ?? (1.3))), this.fallScale = options.fallGravityScale ?? (1.55), this.cutScale = options.jumpCutGravityScale ?? (2.8), this.maxFall = options.maxFallSpeed ?? (42), this.tuning[(0)] = this.sprintSpeed, this.tuning[(1)] = this.maxFall, this.coyoteSeconds = options.coyoteSeconds ?? (0.11), this.bufferSeconds = options.jumpBufferSeconds ?? (0.13), this.turnSharpness = options.turnSharpness ?? (16), this.maxTurnSpeed = options.maxTurnSpeed ?? (14), this.crouchSharpness = options.crouchSharpness ?? (14), this.groundStick = options.groundStickSpeed ?? (2), this.headingOffset = options.modelForward === -1 ? Math.PI : 0, this.body = physics.addBody(entity, { kind: "kinematic" });
|
|
39
|
+
let r = this.radius;
|
|
40
|
+
this.standCollider = physics.addCollider(entity, {
|
|
41
|
+
shape: { kind: "capsule", halfHeight: this.height / 2 - r, radius: r },
|
|
42
|
+
offset: [0, this.height / 2, 0]
|
|
43
|
+
}), this.crouchCollider = physics.addCollider(entity, {
|
|
44
|
+
shape: { kind: "capsule", halfHeight: this.crouchHeight / 2 - r, radius: r },
|
|
45
|
+
offset: [0, this.crouchHeight / 2, 0]
|
|
46
|
+
}), physics.setColliderEnabled(this.crouchCollider, false), this.controller = physics.createCharacterController({
|
|
47
|
+
offset: options.skin ?? (0.02),
|
|
48
|
+
maxSlopeClimbDegrees: options.maxSlopeDegrees ?? (46),
|
|
49
|
+
minSlopeSlideDegrees: options.slideSlopeDegrees ?? (50),
|
|
50
|
+
autostepMaxHeight: options.stepHeight ?? (0.35),
|
|
51
|
+
autostepMinWidth: r,
|
|
52
|
+
snapToGround: options.snapDistance ?? (0.3),
|
|
53
|
+
slide: true
|
|
54
|
+
}), this.state[(9)] = 1, this.state[(32)] = Number.NaN, this.cast.ball(r * (0.95)), this.cast.direction.set(0, 1, 0), this.ray.direction.set(0, -1, 0), this.writeRotation();
|
|
55
|
+
}
|
|
56
|
+
get collider() {
|
|
57
|
+
return this.crouched ? this.crouchCollider : this.standCollider;
|
|
58
|
+
}
|
|
59
|
+
get bodyId() {
|
|
60
|
+
return this.body;
|
|
61
|
+
}
|
|
62
|
+
get heading() {
|
|
63
|
+
return this.state[(3)];
|
|
64
|
+
}
|
|
65
|
+
set heading(value) {
|
|
66
|
+
this.state[(3)] = value, wrapAt(this.state, (3)), this.writeRotation();
|
|
67
|
+
}
|
|
68
|
+
faceView(view, yawIndex) {
|
|
69
|
+
let s = this.state;
|
|
70
|
+
s[(3)] = view[yawIndex] + Math.PI, wrapAt(s, (3)), this.writeRotation();
|
|
71
|
+
}
|
|
72
|
+
setMove(x, z, magnitude) {
|
|
73
|
+
let s = this.state;
|
|
74
|
+
s[(35)] = x, s[(35) + 1] = z, s[(35) + 2] = magnitude, this.setMoveFrom(s, (35));
|
|
75
|
+
}
|
|
76
|
+
setMoveFrom(io, at) {
|
|
77
|
+
let s = this.state, x = io[at + (0)], z = io[at + (1)], magnitude = io[at + (2)], length = (x * x + z * z) ** 0.5;
|
|
78
|
+
if (length < (1e-6) || magnitude <= 0) {
|
|
79
|
+
s[(16)] = 0, s[(17)] = 0, s[(18)] = 0;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
s[(16)] = x / length, s[(17)] = z / length, s[(18)] = magnitude > 1 ? 1 : magnitude;
|
|
83
|
+
}
|
|
84
|
+
setButtons(jumpPressed, jumpHeld, sprint, crouch) {
|
|
85
|
+
jumpPressed && (this.jumpPressed = true), this.jumpHeld = jumpHeld, this.sprintWanted = sprint, this.crouchWanted = crouch;
|
|
86
|
+
}
|
|
87
|
+
addRootMotionFrom(io, at) {
|
|
88
|
+
let s = this.state;
|
|
89
|
+
s[(24)] += io[at + (0)], s[(25)] += io[at + (1)], s[(26)] += io[at + (2)];
|
|
90
|
+
}
|
|
91
|
+
teleport(x, y, z) {
|
|
92
|
+
let v = this.desired.set(x, y, z);
|
|
93
|
+
this.physics.teleport(this.entity, v);
|
|
94
|
+
let s = this.state;
|
|
95
|
+
s[(0)] = 0, s[(1)] = 0, s[(2)] = 0, this.onPlatform = false, this.grounded = false, this.jumping = false;
|
|
96
|
+
}
|
|
97
|
+
step(clock) {
|
|
98
|
+
let s = this.state, dt = clock[FRAME_STEP_SECONDS_SLOT];
|
|
99
|
+
s[(31)] = dt, s[(32)] !== dt && (s[(32)] = dt, s[(33)] = dampFactor(this.turnSharpness, dt), s[(34)] = dampFactor(this.crouchSharpness, dt)), this.landed = false, this.jumped = false, this.updateCrouch(), this.trackPlatform(), this.grounded ? s[(5)] = this.coyoteSeconds : s[(5)] = s[(5)] > dt ? s[(5)] - dt : 0, this.jumpPressed ? s[(6)] = this.bufferSeconds : s[(6)] = s[(6)] > dt ? s[(6)] - dt : 0, this.jumpPressed = false, this.accelerate(), s[(6)] > 0 && s[(5)] > 0 && !this.crouched && (s[(1)] = this.jumpVelocity + (s[(12)] > 0 ? s[(12)] : 0), s[(0)] += s[(11)], s[(2)] += s[(13)], s[(5)] = 0, s[(6)] = 0, this.jumping = true, this.jumped = true, this.jumps++, this.grounded = false, this.onPlatform = false), this.fall(), this.move(), this.face(), this.probeGround();
|
|
100
|
+
}
|
|
101
|
+
updateCrouch() {
|
|
102
|
+
if (this.crouchWanted && !this.crouched) this.setCrouched(true);
|
|
103
|
+
else if (!this.crouchWanted && this.crouched) {
|
|
104
|
+
let p = this.transforms.row(this.entity) * 3, positions = this.transforms.store.fields.position, cast = this.cast, origin = cast.origin;
|
|
105
|
+
origin.x = positions[p], origin.y = positions[p + 1] + this.crouchHeight - this.radius, origin.z = positions[p + 2], cast.maxDistance = this.height - this.crouchHeight, cast.excludeBody = this.body, this.physics.castShape(cast, this.hit) || this.setCrouched(false);
|
|
106
|
+
}
|
|
107
|
+
let s = this.state, target = this.crouched ? 1 : 0;
|
|
108
|
+
s[(7)] += (target - s[(7)]) * s[(34)];
|
|
109
|
+
}
|
|
110
|
+
setCrouched(crouched) {
|
|
111
|
+
this.crouched = crouched, this.physics.setColliderEnabled(this.crouchCollider, crouched), this.physics.setColliderEnabled(this.standCollider, !crouched);
|
|
112
|
+
}
|
|
113
|
+
trackPlatform() {
|
|
114
|
+
let s = this.state;
|
|
115
|
+
s[(27)] = 0, s[(28)] = 0, s[(29)] = 0, s[(30)] = 0;
|
|
116
|
+
let platform = this.platform[(1)];
|
|
117
|
+
if (!this.onPlatform || !this.grounded) {
|
|
118
|
+
s[(11)] = 0, s[(12)] = 0, s[(13)] = 0;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let dt = s[(31)], fields = this.transforms.store.fields, row = this.transforms.row(platform), at = row * 3, px = fields.position[at], py = fields.position[at + 1], pz = fields.position[at + 2];
|
|
122
|
+
yawInto(fields.rotation, row * 4, s, (35)), s[(30)] = s[(35)] - s[(23)], wrapAt(s, (30));
|
|
123
|
+
let dyaw = s[(30)], me = this.transforms.row(this.entity) * 3, ox = fields.position[me] - s[(20)], oz = fields.position[me + 2] - s[(22)], c = Math.cos(dyaw), n = Math.sin(dyaw), dx = px - s[(20)] + (ox * c + oz * n - ox), dz = pz - s[(22)] + (-ox * n + oz * c - oz), dy = py - s[(21)];
|
|
124
|
+
s[(27)] = dx, s[(28)] = dy, s[(29)] = dz, s[(11)] = dx / dt, s[(12)] = dy / dt, s[(13)] = dz / dt, s[(20)] = px, s[(21)] = py, s[(22)] = pz, s[(23)] = s[(35)];
|
|
125
|
+
}
|
|
126
|
+
accelerate() {
|
|
127
|
+
let s = this.state, dt = s[(31)], magnitude = s[(18)];
|
|
128
|
+
if (this.sprinting = this.sprintWanted && !this.crouched && magnitude >= (0.5), this.useRootMotion && this.grounded) {
|
|
129
|
+
s[(0)] = s[(24)] / dt, s[(2)] = s[(25)] / dt, s[(24)] = 0, s[(25)] = 0;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
s[(24)] = 0, s[(25)] = 0;
|
|
133
|
+
let speed;
|
|
134
|
+
this.crouched ? speed = this.crouchSpeed * magnitude : this.sprinting ? speed = this.tuning[(0)] : magnitude <= (0.5) ? speed = this.walkSpeed * magnitude / (0.5) : speed = this.walkSpeed + (this.runSpeed - this.walkSpeed) * (magnitude - (0.5)) / (1 - (0.5));
|
|
135
|
+
let tx = s[(16)] * speed, tz = s[(17)] * speed, vx = s[(0)], vz = s[(2)], dvx = tx - vx, dvz = tz - vz, gap = (dvx * dvx + dvz * dvz) ** 0.5;
|
|
136
|
+
if (gap < (1e-6)) return;
|
|
137
|
+
let rate = this.airAcceleration;
|
|
138
|
+
this.grounded && (rate = tx * tx + tz * tz >= vx * vx + vz * vz ? this.groundAcceleration : this.groundDeceleration);
|
|
139
|
+
let reach = rate * dt, k = gap > reach ? reach / gap : 1;
|
|
140
|
+
s[(0)] = vx + dvx * k, s[(2)] = vz + dvz * k;
|
|
141
|
+
}
|
|
142
|
+
fall() {
|
|
143
|
+
let s = this.state;
|
|
144
|
+
if (this.grounded) {
|
|
145
|
+
s[(1)] = 0;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
let vy = s[(1)], scale = vy > 0 ? this.jumping && !this.jumpHeld ? this.cutScale : 1 : this.fallScale, next = vy - this.gravity * scale * s[(31)], floor = -this.tuning[(1)];
|
|
149
|
+
s[(1)] = next < floor ? floor : next;
|
|
150
|
+
}
|
|
151
|
+
move() {
|
|
152
|
+
let s = this.state, dt = s[(31)], vx = s[(0)], vy = s[(1)], vz = s[(2)], dy = vy * dt + s[(28)];
|
|
153
|
+
this.grounded && s[(9)] > (0.2) && (dy -= (s[(8)] * vx + s[(10)] * vz) / s[(9)] * dt);
|
|
154
|
+
let desired = this.desired;
|
|
155
|
+
desired.x = vx * dt + s[(27)], desired.y = dy, desired.z = vz * dt + s[(29)];
|
|
156
|
+
let out = this.physics.moveCharacter(this.controller, this.crouched ? this.crouchCollider : this.standCollider, desired, this.moved), rising = this.jumping && vy > 0, grounded = out.grounded && !rising;
|
|
157
|
+
vy > 0 && dy > (1e-6) && out.y < dy * (0.5) && (s[(1)] = 0), s[(0)] = (out.x - s[(27)]) / dt, s[(2)] = (out.z - s[(29)]) / dt, s[(4)] = (s[(0)] * s[(0)] + s[(2)] * s[(2)]) ** 0.5, s[(19)] = this.runSpeed > 0 ? s[(4)] / this.runSpeed : 0, this.wasGrounded = this.grounded, this.grounded = grounded, grounded ? (this.wasGrounded || (this.landed = true, this.landings++, s[(15)] = vy < 0 ? -vy : 0), this.jumping = false, s[(14)] = 0) : (this.wasGrounded && !this.jumping && (s[(1)] = -this.groundStick), s[(14)] += dt);
|
|
158
|
+
}
|
|
159
|
+
face() {
|
|
160
|
+
let s = this.state;
|
|
161
|
+
if (s[(3)] += s[(30)], this.useRootMotion && (s[(3)] += s[(26)]), s[(26)] = 0, this.faceMovement && s[(18)] > (0.05)) {
|
|
162
|
+
s[(35)] = s[(16)], s[(35) + 1] = s[(17)], atan2Into(s, (35)), s[(35)] -= s[(3)], wrapAt(s, (35)), s[(35)] *= s[(33)], s[(35) + 1] = this.maxTurnSpeed * s[(31)], s[(35) + 2] = -s[(35) + 1];
|
|
163
|
+
let pick = s[(35)] > s[(35) + 1] ? 1 : s[(35)] < s[(35) + 2] ? 2 : 0;
|
|
164
|
+
s[(3)] += s[(35) + pick];
|
|
165
|
+
}
|
|
166
|
+
wrapAt(s, (3)), this.writeRotation();
|
|
167
|
+
}
|
|
168
|
+
writeRotation() {
|
|
169
|
+
let half = (this.state[(3)] + this.headingOffset) * (0.5), rotation = this.transforms.store.fields.rotation, o = this.transforms.row(this.entity) * 4;
|
|
170
|
+
rotation[o] = 0, rotation[o + 1] = Math.sin(half), rotation[o + 2] = 0, rotation[o + 3] = Math.cos(half);
|
|
171
|
+
}
|
|
172
|
+
probeGround() {
|
|
173
|
+
let s = this.state;
|
|
174
|
+
if (!this.grounded) {
|
|
175
|
+
this.onPlatform = false;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
let p = this.transforms.row(this.entity) * 3, positions = this.transforms.store.fields.position, ray = this.ray, origin = ray.origin;
|
|
179
|
+
origin.x = positions[p], origin.y = positions[p + 1] + this.radius, origin.z = positions[p + 2], ray.maxDistance = this.radius + (0.3), ray.excludeCollider = this.crouched ? this.crouchCollider : this.standCollider;
|
|
180
|
+
let hit = this.hit;
|
|
181
|
+
if (!this.physics.raycast(ray, hit)) {
|
|
182
|
+
s[(8)] = 0, s[(9)] = 1, s[(10)] = 0, this.onPlatform = false;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
s[(8)] = hit.normalX, s[(9)] = hit.normalY, s[(10)] = hit.normalZ;
|
|
186
|
+
let slot = this.platform;
|
|
187
|
+
if (slot[(0)] = this.physics.entityOfCollider(hit.collider), slot[(0)] === NONE) {
|
|
188
|
+
this.onPlatform = false;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (this.onPlatform && slot[(0)] === slot[(1)]) return;
|
|
192
|
+
slot[(1)] = slot[(0)], this.onPlatform = true;
|
|
193
|
+
let ground = slot[(1)], fields = this.transforms.store.fields, row = this.transforms.row(ground);
|
|
194
|
+
s[(20)] = fields.position[row * 3], s[(21)] = fields.position[row * 3 + 1], s[(22)] = fields.position[row * 3 + 2], yawInto(fields.rotation, row * 4, s, (23));
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/game/kit/camera/follow.ts
|
|
199
|
+
var FOLLOW_CAMERA_X = 0, FOLLOW_CAMERA_Y = 1, FOLLOW_CAMERA_Z = 2, FOLLOW_YAW = 3, FOLLOW_PITCH = 4, FOLLOW_DISTANCE = 5, FOLLOW_PIVOT_X = 6, FOLLOW_PIVOT_Y = 7, FOLLOW_PIVOT_Z = 8, FOLLOW_SHOULDER = 9, FOLLOW_FOV = 10, FOLLOW_CLOSENESS = 11, IDLE = 12, SPRINT = 13, LOOK_X = 14, LOOK_Y = 15, RATE_X = 16, RATE_Y = 17, TARGET = 18, DT2 = 24, SCRATCH2 = 25, lockAngle = new Float64Array(2), BOOM = 26, STATE_WORDS2 = (26) + BOOM_IO_WORDS, MOVE_IN_X = 0, MOVE_IN_Y = 1, MOVE_OUT_X = 2, MOVE_OUT_Z = 3, MOVE_IO_WORDS = 4, DEFAULT_LOOK_SENSITIVITY = 62e-4, DEFAULT_GAMEPAD_LOOK_SPEED = 3.4, DEFAULT_DISTANCE = 4.2, DEFAULT_HEIGHT2 = 1.55, DEFAULT_CROUCH_HEIGHT2 = 1.05, DEFAULT_SHOULDER = 0.55, DEFAULT_PITCH = -0.3, DEFAULT_MIN_PITCH = -1.25, DEFAULT_MAX_PITCH = 0.95, DEFAULT_FOLLOW_SHARPNESS = 22, DEFAULT_VERTICAL_SHARPNESS = 8, DEFAULT_SHOULDER_SHARPNESS = 9, DEFAULT_RECOVER_SHARPNESS = 4.5, DEFAULT_RECENTER_DELAY = 1.5, DEFAULT_RECENTER_SHARPNESS = 1.8, MANUAL_RECENTER_SHARPNESS = 10, DEFAULT_FOV = 62, DEFAULT_SPRINT_KICK = 8, DEFAULT_FOV_SHARPNESS = 6, DEFAULT_LOCK_SOFT_ZONE = 0.12, DEFAULT_LOCK_SHARPNESS = 7, DEFAULT_LOCK_MAX_DISTANCE = 30, DEFAULT_LOCK_HEIGHT = 1.2, LOCK_PITCH_SHARE = 0.5, RECENTER_MIN_SPEED = 0.15, RECENTER_DONE = 0.02, CLOSE_DISTANCE = 1.1, MIN_LOCK_DISTANCE = 0.5, FollowCamera = class {
|
|
200
|
+
constructor(physics, transforms, camera, subject, options = {}) {
|
|
201
|
+
this.state = new Float64Array(STATE_WORDS2);
|
|
202
|
+
this.recenterPick = new Float64Array(2);
|
|
203
|
+
this.lockTarget = new Uint32Array(1).fill(NO_ENTITY);
|
|
204
|
+
this.locking = false;
|
|
205
|
+
this.recentering = false;
|
|
206
|
+
this.initialised = false;
|
|
207
|
+
this.transforms = transforms, this.camera = camera, this.subject = subject, this.boom = new CameraBoom(physics, options), this.distance = options.distance ?? (4.2), this.height = options.height ?? (1.55), this.crouchHeight = options.crouchHeight ?? (1.05), this.shoulder = options.shoulder ?? (0.55), this.shoulderSide = options.shoulderSide ?? 1, this.defaultPitch = options.pitch ?? (-0.3), this.minPitch = options.minPitch ?? (-1.25), this.maxPitch = options.maxPitch ?? (0.95), this.followSharpness = options.followSharpness ?? (22), this.verticalSharpness = options.verticalSharpness ?? (8), this.shoulderSharpness = options.shoulderSharpness ?? (9), this.recoverSharpness = options.recoverSharpness ?? (4.5), this.autoRecenter = options.autoRecenter ?? true, this.recenterDelay = options.recenterDelay ?? (1.5), this.recenterSharpness = options.recenterSharpness ?? (1.8), this.fov = options.fov ?? (62), this.sprintFovKick = options.sprintFovKick ?? (8), this.fovSharpness = options.fovSharpness ?? (6), this.lockSoftZone = options.lockSoftZone ?? (0.12), this.lockSharpness = options.lockSharpness ?? (7), this.lockMaxDistance = options.lockMaxDistance ?? (30), this.lockHeight = options.lockHeight ?? (1.2), this.lookSensitivity = options.lookSensitivity ?? (62e-4), this.gamepadLookSpeed = options.gamepadLookSpeed ?? (3.4), this.invertY = options.invertY ?? false, this.lens = new LensDriver(options.lens ?? null);
|
|
208
|
+
let s = this.state;
|
|
209
|
+
s[(3)] = subject.state[(3)] + Math.PI, wrapAt(s, (3)), s[(4)] = this.defaultPitch, s[(5)] = this.distance, s[(9)] = this.shoulder * this.shoulderSide, s[(10)] = this.fov;
|
|
210
|
+
}
|
|
211
|
+
get yaw() {
|
|
212
|
+
return this.state[(3)];
|
|
213
|
+
}
|
|
214
|
+
get pitch() {
|
|
215
|
+
return this.state[(4)];
|
|
216
|
+
}
|
|
217
|
+
get hasLock() {
|
|
218
|
+
return this.locking;
|
|
219
|
+
}
|
|
220
|
+
get locked() {
|
|
221
|
+
return this.lockTarget[0];
|
|
222
|
+
}
|
|
223
|
+
look(delta) {
|
|
224
|
+
this.state[(14)] += delta.x, this.state[(15)] += delta.y;
|
|
225
|
+
}
|
|
226
|
+
lookRateFrom(input, x, y) {
|
|
227
|
+
input.valueInto(x, this.state, (16)), input.valueInto(y, this.state, (17));
|
|
228
|
+
}
|
|
229
|
+
swapShoulder() {
|
|
230
|
+
this.shoulderSide = -this.shoulderSide;
|
|
231
|
+
}
|
|
232
|
+
recenter() {
|
|
233
|
+
this.recentering = true;
|
|
234
|
+
}
|
|
235
|
+
lockOn(target) {
|
|
236
|
+
this.lockTarget[0] = target, this.locking = target !== NO_ENTITY, this.locking && (this.recentering = false);
|
|
237
|
+
}
|
|
238
|
+
snap() {
|
|
239
|
+
this.initialised = false;
|
|
240
|
+
}
|
|
241
|
+
moveRelative(io, at) {
|
|
242
|
+
let yaw = this.state[(3)], sy = Math.sin(yaw), cy = Math.cos(yaw), x = io[at + (0)], y = io[at + (1)];
|
|
243
|
+
io[at + (2)] = cy * x - sy * y, io[at + (3)] = -sy * x - cy * y;
|
|
244
|
+
}
|
|
245
|
+
update(clock) {
|
|
246
|
+
let s = this.state, subject = this.subject, dt = clock[FRAME_SECONDS_SLOT];
|
|
247
|
+
s[(24)] = dt, this.applyLook(), interpolatedPosition(this.transforms, subject.entity, clock, s, (18));
|
|
248
|
+
let height = this.height + (this.crouchHeight - this.height) * subject.state[(7)], tx = s[(18)], ty = s[(18) + 1] + height, tz = s[(18) + 2];
|
|
249
|
+
if (!this.initialised)
|
|
250
|
+
s[(6)] = tx, s[(7)] = ty, s[(8)] = tz;
|
|
251
|
+
else {
|
|
252
|
+
let k = 1 - Math.exp(-this.followSharpness * dt);
|
|
253
|
+
s[(6)] += (tx - s[(6)]) * k, s[(8)] += (tz - s[(8)]) * k, s[(7)] += (ty - s[(7)]) * (1 - Math.exp(-this.verticalSharpness * dt));
|
|
254
|
+
}
|
|
255
|
+
this.steerLock() || this.steerRecenter(), s[(9)] += (this.shoulder * this.shoulderSide - s[(9)]) * (1 - Math.exp(-this.shoulderSharpness * dt)), s[(13)] += ((subject.sprinting ? 1 : 0) - s[(13)]) * (1 - Math.exp(-this.fovSharpness * dt)), s[(10)] = this.fov + this.sprintFovKick * s[(13)], this.lens.apply(s, (10)), this.place(), this.initialised = true;
|
|
256
|
+
}
|
|
257
|
+
applyLook() {
|
|
258
|
+
let s = this.state, dt = s[(24)], invert = this.invertY ? -1 : 1, yawDelta = -s[(14)] * this.lookSensitivity - s[(16)] * this.gamepadLookSpeed * dt, pitchDelta = (-s[(15)] * this.lookSensitivity - s[(17)] * this.gamepadLookSpeed * dt) * invert;
|
|
259
|
+
s[(14)] = 0, s[(15)] = 0, yawDelta !== 0 || pitchDelta !== 0 ? (s[(12)] = 0, this.recentering = false) : s[(12)] += dt, s[(3)] += yawDelta, wrapAt(s, (3));
|
|
260
|
+
let pitch = s[(4)] + pitchDelta;
|
|
261
|
+
s[(4)] = pitch < this.minPitch ? this.minPitch : pitch > this.maxPitch ? this.maxPitch : pitch;
|
|
262
|
+
}
|
|
263
|
+
steerLock() {
|
|
264
|
+
if (!this.locking) return false;
|
|
265
|
+
let target = this.lockTarget[0], s = this.state, dt = s[(24)], f = this.transforms.store.fields.position, o = this.transforms.row(target) * 3, dx = f[o] - s[(6)], dy = f[o + 1] + this.lockHeight - s[(7)], dz = f[o + 2] - s[(8)], flat = (dx * dx + dz * dz) ** 0.5;
|
|
266
|
+
if (flat < (0.5) || flat > this.lockMaxDistance) return false;
|
|
267
|
+
let angle = lockAngle;
|
|
268
|
+
angle[0] = -dx, angle[1] = -dz, atan2Into(angle, 0), s[(25)] = angle[0] - s[(3)], wrapAt(s, (25));
|
|
269
|
+
let error = s[(25)], excess = (error < 0 ? -error : error) - this.lockSoftZone;
|
|
270
|
+
excess > 0 && (s[(3)] += (error < 0 ? -excess : excess) * (1 - Math.exp(-this.lockSharpness * dt)), wrapAt(s, (3))), angle[0] = dy, angle[1] = flat, atan2Into(angle, 0);
|
|
271
|
+
let pitch = angle[0] * (0.5) + this.defaultPitch * (1 - (0.5));
|
|
272
|
+
return pitch = pitch < this.minPitch ? this.minPitch : pitch > this.maxPitch ? this.maxPitch : pitch, s[(4)] += (pitch - s[(4)]) * (1 - Math.exp(-this.lockSharpness * (0.5) * dt)), s[(12)] = 0, true;
|
|
273
|
+
}
|
|
274
|
+
steerRecenter() {
|
|
275
|
+
let s = this.state, subject = this.subject, manual = this.recentering, speedNormalized = subject.state[(19)], moving = speedNormalized > (0.15);
|
|
276
|
+
if (!manual && !(this.autoRecenter && moving && s[(12)] > this.recenterDelay)) return;
|
|
277
|
+
s[(25)] = subject.state[(3)] + Math.PI - s[(3)], wrapAt(s, (25));
|
|
278
|
+
let error = s[(25)], pick = this.recenterPick;
|
|
279
|
+
pick[0] = speedNormalized, pick[1] = 1, pick[0] = this.recenterSharpness * pick[speedNormalized < 1 ? 0 : 1], pick[1] = (10);
|
|
280
|
+
let k = 1 - Math.exp(-pick[manual ? 1 : 0] * s[(24)]);
|
|
281
|
+
s[(3)] += error * k, wrapAt(s, (3)), manual && (s[(4)] += (this.defaultPitch - s[(4)]) * k, Math.abs(error) < (0.02) && (this.recentering = false));
|
|
282
|
+
}
|
|
283
|
+
place() {
|
|
284
|
+
let s = this.state, yaw = s[(3)], pitch = s[(4)], sy = Math.sin(yaw), cy = Math.cos(yaw), sp = Math.sin(pitch), cp = Math.cos(pitch), fx = -sy * cp, fy = sp, fz = -cy * cp, px = s[(6)], py = s[(7)], pz = s[(8)], exclude = this.subject.bodyId, shoulder = s[(9)], side = shoulder < 0 ? -1 : 1;
|
|
285
|
+
s[(26) + BOOM_OX] = px, s[(26) + BOOM_OY] = py, s[(26) + BOOM_OZ] = pz, s[(26) + BOOM_DX] = cy * side, s[(26) + BOOM_DY] = 0, s[(26) + BOOM_DZ] = -sy * side, s[(26) + BOOM_DISTANCE] = shoulder * side, this.boom.cast(s, (26), exclude);
|
|
286
|
+
let lateral = s[(26) + BOOM_FREE] * side, ax = px + cy * lateral, az = pz - sy * lateral;
|
|
287
|
+
s[(26) + BOOM_OX] = ax, s[(26) + BOOM_OZ] = az, s[(26) + BOOM_DX] = -fx, s[(26) + BOOM_DY] = -fy, s[(26) + BOOM_DZ] = -fz, s[(26) + BOOM_DISTANCE] = this.distance, this.boom.cast(s, (26), exclude);
|
|
288
|
+
let allowed = s[(26) + BOOM_FREE], distance = s[(5)];
|
|
289
|
+
!this.initialised || allowed < distance ? distance = allowed : distance += (allowed - distance) * (1 - Math.exp(-this.recoverSharpness * s[(24)])), distance > allowed && (distance = allowed), s[(5)] = distance, s[(0)] = ax - fx * distance, s[(1)] = py - fy * distance, s[(2)] = az - fz * distance;
|
|
290
|
+
let close = 1 - distance / (1.1);
|
|
291
|
+
s[(11)] = close > 0 ? close : 0, placeCamera(this.transforms, this.camera, s, (0));
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// src/game/kit/character/events.ts
|
|
296
|
+
var DEFAULT_CLIP_EVENT_CAPACITY = 64, ClipEventReader = class {
|
|
297
|
+
constructor(capacity = (64)) {
|
|
298
|
+
this.count = 0;
|
|
299
|
+
this.events = Array.from({ length: capacity }, emptyClipEvent);
|
|
300
|
+
}
|
|
301
|
+
read(port) {
|
|
302
|
+
return this.count = port.readClipEvents(this.events), this.count;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
function actionListed(actions, action) {
|
|
306
|
+
for (let i = 0; i < actions.length; i++) if (actions[i] === action) return true;
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/game/kit/character/contact.ts
|
|
311
|
+
var CONTACT_WEIGHT = 0, CONTACT_PLANTED = 1, CONTACT_LOCKED = 2, CONTACT_LOCK_X = 3, CONTACT_LOCK_Y = 4, CONTACT_LOCK_Z = 5, CONTACT_LOCK_BLEND = 6, CONTACT_TILT_X = 7, CONTACT_TILT_Y = 8, CONTACT_TILT_Z = 9, CONTACT_TILT_WEIGHT = 10, CONTACT_EVENT_PLANTED = 11, CONTACT_WORDS = 12, DEFAULT_CONTACT_WEIGHT_SECONDS = 0.08, DEFAULT_CONTACT_RELEASE_SECONDS = 0.2, DEFAULT_CONTACT_MAX_SLIDE = 0.25, DEFAULT_MAX_FOOT_TILT = Math.PI / 6, DEFAULT_PLANT_THRESHOLD = 0.5, DEFAULT_FOOT_UP = [0, 1, 0], TARGET_Y = 1, TARGET_Z = 2, TARGET_WEIGHT = 3, MIN_HORIZONTAL = 1e-6, ON = 1, OFF = 0, EVENT_KIND = "event", NO_EVENT = -1;
|
|
312
|
+
function createFootTiltChain(port, root, bone, up = DEFAULT_FOOT_UP, maxTilt = DEFAULT_MAX_FOOT_TILT) {
|
|
313
|
+
return port.createIk(root, { solver: "lookAt", bones: [bone], forward: up, maxAngle: maxTilt });
|
|
314
|
+
}
|
|
315
|
+
var FootContact = class {
|
|
316
|
+
constructor(port, options, tuning = {}) {
|
|
317
|
+
this.state = new Float64Array((12));
|
|
318
|
+
this.clip = emptyClipState();
|
|
319
|
+
this.port = port;
|
|
320
|
+
let curves = options.curves ?? [];
|
|
321
|
+
if (this.footDown = options.footDown ?? (-1), this.footUp = options.footUp ?? (-1), curves.length === 0 && this.footDown === (-1))
|
|
322
|
+
throw new GameError("invalid_argument", "a foot contact needs weight curves or a footDown clip event id");
|
|
323
|
+
this.actions = Float64Array.from(options.actions ?? []), this.curveAction = Float64Array.from(curves.map((c) => c.action)), this.curveStart = new Int32Array(curves.length + 1);
|
|
324
|
+
let keys = 0;
|
|
325
|
+
for (let c of curves) {
|
|
326
|
+
if (c.times.length === 0 || c.times.length !== c.weights.length)
|
|
327
|
+
throw new GameError("invalid_argument", "foot contact curves need matching time and weight keys");
|
|
328
|
+
keys += c.times.length;
|
|
329
|
+
}
|
|
330
|
+
this.times = new Float64Array(keys), this.weights = new Float64Array(keys);
|
|
331
|
+
let k = 0;
|
|
332
|
+
curves.forEach((c, i) => {
|
|
333
|
+
this.curveStart[i] = k;
|
|
334
|
+
for (let j = 0; j < c.times.length; j++, k++)
|
|
335
|
+
this.times[k] = c.times[j], this.weights[k] = c.weights[j];
|
|
336
|
+
}), this.curveStart[curves.length] = k, this.tilt = options.tilt ?? null, this.lock = tuning.lock ?? true, this.weightSeconds = tuning.weightSeconds ?? (0.08), this.releaseSeconds = tuning.releaseSeconds ?? (0.2), this.maxSlide = tuning.maxSlide ?? (0.25);
|
|
337
|
+
let maxTilt = tuning.maxTilt ?? DEFAULT_MAX_FOOT_TILT;
|
|
338
|
+
this.tiltCos = Math.cos(maxTilt), this.tiltSin = Math.sin(maxTilt), this.threshold = tuning.plantThreshold ?? (0.5);
|
|
339
|
+
}
|
|
340
|
+
get planted() {
|
|
341
|
+
return this.state[(1)] === (1);
|
|
342
|
+
}
|
|
343
|
+
get locked() {
|
|
344
|
+
return this.state[(2)] === (1);
|
|
345
|
+
}
|
|
346
|
+
consume(events, count) {
|
|
347
|
+
if (this.footDown === (-1)) return;
|
|
348
|
+
let s = this.state;
|
|
349
|
+
for (let i = 0; i < count; i++) {
|
|
350
|
+
let e = events[i];
|
|
351
|
+
e.kind === EVENT_KIND && (this.actions.length > 0 && !actionListed(this.actions, e.action) || (e.id === this.footDown ? s[(11)] = (1) : e.id === this.footUp && (s[(11)] = (0))));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
sample(dt) {
|
|
355
|
+
let s = this.state;
|
|
356
|
+
if (this.curveAction.length > 0) {
|
|
357
|
+
let weight = 0;
|
|
358
|
+
for (let c = 0; c < this.curveAction.length; c++)
|
|
359
|
+
this.port.readClipState(this.curveAction[c], this.clip), weight += this.curveAt(c, this.clip.time) * this.clip.weight;
|
|
360
|
+
s[(0)] = weight < 0 ? 0 : weight > 1 ? 1 : weight, s[(1)] = s[(0)] >= this.threshold ? (1) : (0);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
let target = s[(11)], step = this.weightSeconds > 0 ? dt / this.weightSeconds : 1, w = s[(0)];
|
|
364
|
+
w < target ? s[(0)] = w + step >= target ? target : w + step : w > target && (s[(0)] = w - step <= target ? target : w - step), s[(1)] = target;
|
|
365
|
+
}
|
|
366
|
+
resolve(target, at, hit, nx, ny, nz, dt) {
|
|
367
|
+
let s = this.state;
|
|
368
|
+
this.lock && this.applyLock(target, at, hit, dt);
|
|
369
|
+
let weight = target[at + (3)] * s[(0)];
|
|
370
|
+
if (target[at + (3)] = weight, this.tilt === null) return;
|
|
371
|
+
let x = nx, y = ny, z = nz, horizontal = (x * x + z * z) ** 0.5;
|
|
372
|
+
if (y < this.tiltCos && horizontal > (1e-6)) {
|
|
373
|
+
let scale = this.tiltSin / horizontal;
|
|
374
|
+
x *= scale, z *= scale, y = this.tiltCos;
|
|
375
|
+
}
|
|
376
|
+
s[(7)] = target[at] + x, s[(8)] = target[at + (1)] + y, s[(9)] = target[at + (2)] + z, s[(10)] = hit ? weight : 0, this.port.setIkTargetFrom(this.tilt, s, (7));
|
|
377
|
+
}
|
|
378
|
+
applyLock(target, at, hit, dt) {
|
|
379
|
+
let s = this.state;
|
|
380
|
+
if (s[(1)] === (1) && hit) {
|
|
381
|
+
if (s[(2)] === (0)) this.latch(target, at);
|
|
382
|
+
else {
|
|
383
|
+
let dx = target[at] - s[(3)], dz = target[at + (2)] - s[(5)];
|
|
384
|
+
dx * dx + dz * dz > this.maxSlide * this.maxSlide && this.latch(target, at);
|
|
385
|
+
}
|
|
386
|
+
s[(6)] = 1;
|
|
387
|
+
} else {
|
|
388
|
+
s[(2)] = (0);
|
|
389
|
+
let step = this.releaseSeconds > 0 ? dt / this.releaseSeconds : 1, b2 = s[(6)] - step;
|
|
390
|
+
s[(6)] = b2 > 0 ? b2 : 0;
|
|
391
|
+
}
|
|
392
|
+
let b = s[(6)];
|
|
393
|
+
b <= 0 || (target[at] += (s[(3)] - target[at]) * b, target[at + (1)] += (s[(4)] - target[at + (1)]) * b, target[at + (2)] += (s[(5)] - target[at + (2)]) * b);
|
|
394
|
+
}
|
|
395
|
+
latch(target, at) {
|
|
396
|
+
let s = this.state;
|
|
397
|
+
s[(2)] = (1), s[(3)] = target[at], s[(4)] = target[at + (1)], s[(5)] = target[at + (2)];
|
|
398
|
+
}
|
|
399
|
+
curveAt(curve, time) {
|
|
400
|
+
let start = this.curveStart[curve], last = this.curveStart[curve + 1] - 1, times = this.times, weights = this.weights;
|
|
401
|
+
if (time <= times[start]) return weights[start];
|
|
402
|
+
if (time >= times[last]) return weights[last];
|
|
403
|
+
let lo = start, hi = last;
|
|
404
|
+
for (; hi - lo > 1; ) {
|
|
405
|
+
let mid = lo + hi >> 1;
|
|
406
|
+
times[mid] <= time ? lo = mid : hi = mid;
|
|
407
|
+
}
|
|
408
|
+
let span = times[hi] - times[lo], f = span > 0 ? (time - times[lo]) / span : 0;
|
|
409
|
+
return weights[lo] + (weights[hi] - weights[lo]) * f;
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
// src/game/kit/touch/layouts.ts
|
|
414
|
+
var BOTTOM_RIGHT = [1, 1];
|
|
415
|
+
function corner(dx, dy, size) {
|
|
416
|
+
return { anchor: BOTTOM_RIGHT, offset: [dx, dy], size };
|
|
417
|
+
}
|
|
418
|
+
var LEFT_STICK_RIGHT_BUTTONS = {
|
|
419
|
+
move: { zone: [0, 0.32, 0.5, 1], home: [0.16, 0.74] },
|
|
420
|
+
aim: null,
|
|
421
|
+
look: { zone: [0.5, 0, 1, 1] },
|
|
422
|
+
buttons: [corner(-82, -86, 78), corner(-176, -58, 62), corner(-70, -186, 62), corner(-166, -152, 54), corner(-250, -40, 48)]
|
|
423
|
+
}, TWIN_STICK = {
|
|
424
|
+
move: { zone: [0, 0.3, 0.5, 1], home: [0.16, 0.74] },
|
|
425
|
+
aim: { zone: [0.5, 0.3, 1, 1], home: [0.84, 0.74] },
|
|
426
|
+
look: null,
|
|
427
|
+
buttons: [corner(-70, -248, 58), corner(-146, -232, 50), corner(-212, -200, 46)]
|
|
428
|
+
}, ONE_THUMB = {
|
|
429
|
+
move: { zone: [0, 0.22, 1, 1], home: [0.5, 0.78] },
|
|
430
|
+
aim: null,
|
|
431
|
+
look: null,
|
|
432
|
+
buttons: [corner(-48, -500, 44)]
|
|
433
|
+
}, DRIVING = {
|
|
434
|
+
move: { zone: [0, 0.3, 0.5, 1], home: [0.18, 0.76] },
|
|
435
|
+
aim: null,
|
|
436
|
+
look: { zone: [0.5, 0, 1, 0.5] },
|
|
437
|
+
buttons: [corner(-84, -92, 86), corner(-190, -62, 66), corner(-74, -204, 58), corner(-176, -170, 48)]
|
|
438
|
+
};
|
|
439
|
+
function touchLayout(name) {
|
|
440
|
+
switch (name) {
|
|
441
|
+
case "twinStick":
|
|
442
|
+
return TWIN_STICK;
|
|
443
|
+
case "oneThumb":
|
|
444
|
+
return ONE_THUMB;
|
|
445
|
+
case "driving":
|
|
446
|
+
return DRIVING;
|
|
447
|
+
default:
|
|
448
|
+
return LEFT_STICK_RIGHT_BUTTONS;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/game/kit/touch/stick.ts
|
|
453
|
+
var STICK_X = 0, STICK_Y = 1, STICK_MAGNITUDE = 2, STICK_OUT_WORDS = 3, STICK_DX = 3, STICK_DY = 4, STICK_RADIUS = 5, STICK_DEAD_ZONE = 6, STICK_CURVE = 7, STICK_IO_WORDS = 8;
|
|
454
|
+
var scratch = new Float64Array(8);
|
|
455
|
+
function stickAxesCode(axes) {
|
|
456
|
+
return axes === "x" ? 1 : axes === "y" ? 2 : 0;
|
|
457
|
+
}
|
|
458
|
+
function shapeStickInto(io, axes) {
|
|
459
|
+
let dx = io[3], dy = io[4];
|
|
460
|
+
axes === 1 ? dy = 0 : axes === 2 && (dx = 0);
|
|
461
|
+
let radius = io[5], deadZone = io[6], length = (dx * dx + dy * dy) ** 0.5, travel = radius > 0 ? length / radius : 0;
|
|
462
|
+
if (travel > 1 && (travel = 1), travel <= deadZone || length === 0) {
|
|
463
|
+
io[0] = 0, io[1] = 0, io[2] = 0;
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
let magnitude = (travel - deadZone) / (1 - deadZone), curve = io[7];
|
|
467
|
+
curve !== 1 && (magnitude = Math.pow(magnitude, curve));
|
|
468
|
+
let scale = magnitude / length;
|
|
469
|
+
io[0] = dx * scale, io[1] = -dy * scale, io[2] = magnitude;
|
|
470
|
+
}
|
|
471
|
+
function shapeStick(dx, dy, radius, deadZone, curve, axes, out, offset) {
|
|
472
|
+
let io = scratch;
|
|
473
|
+
io[3] = dx, io[4] = dy, io[5] = radius, io[6] = deadZone, io[7] = curve, shapeStickInto(io, axes), out[offset + 0] = io[0], out[offset + 1] = io[1], out[offset + 2] = io[2];
|
|
474
|
+
}
|
|
475
|
+
function followOriginInto(origin, at, target, targetAt, radius, radiusAt) {
|
|
476
|
+
let dx = target[targetAt] - origin[at], dy = target[targetAt + 1] - origin[at + 1], length = (dx * dx + dy * dy) ** 0.5, r = radius[radiusAt];
|
|
477
|
+
if (length <= r || length === 0) return;
|
|
478
|
+
let pull = 1 - r / length;
|
|
479
|
+
origin[at] += dx * pull, origin[at + 1] += dy * pull;
|
|
480
|
+
}
|
|
481
|
+
function followOrigin(origin, at, x, y, radius) {
|
|
482
|
+
let io = scratch;
|
|
483
|
+
io[0] = x, io[1] = y, io[2] = radius, followOriginInto(origin, at, io, 0, io, 2);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/game/kit/touch/touch-controls.ts
|
|
487
|
+
var STICK_MOVE = 0, STICK_AIM = 1, MAX_STICKS = 2, MAX_TOUCH_BUTTONS = 8, KIND_STICK = 0, KIND_LOOK = 1, KIND_BUTTON = 2, KIND_SHIFT = 4, INDEX_MASK = (1 << (4)) - 1, NO_OWNER = -1, NO_POINTER = -1, NO_SLOT = -1, ACCESSIBLE_STEP_SECONDS = 0.4, SEEN_WIDTH = 0, SEEN_HEIGHT = 1, SEEN_TOP = 2, SEEN_RIGHT = 3, SEEN_BOTTOM = 4, SEEN_LEFT = 5, SEEN_WORDS = 6, MOVE_LABEL = "Move", AIM_LABEL = "Aim", SIZED_BASE = 0, SIZED_KNOB = 1, SIZED_BUTTON = 2, MODE_HOLD = 0, MODE_TOGGLE = 1, REFERENCE_SHORT_SIDE = 390, MIN_UI_SCALE = 0.85, MAX_UI_SCALE = 1.4, DEFAULT_VIEWPORT_WIDTH = 844, DEFAULT_VIEWPORT_HEIGHT = 390, DEFAULT_STICK_RADIUS = 58, DEFAULT_DEAD_ZONE = 0.12, DEFAULT_CURVE = 1, DEFAULT_SNAP_SECONDS = 0.12, KNOB_FRACTION = 0.46, BUTTON_SLOP = 14, TAP_MAX_MS = 220, TAP_SLOP_FRACTION = 0.25, DOUBLE_TAP_MS = 280, DEFAULT_LOOK_SENSITIVITY2 = 1, DEFAULT_LOOK_INERTIA = 0.16, FLING_RELEASE_MS = 60, MIN_FLING_SPEED = 30, VELOCITY_BLEND = 0.6, MS_PER_SECOND = 1e3, DEFAULT_IDLE_OPACITY = 0.5, ACTIVE_OPACITY = 1, COOLDOWN_OPACITY = 0.55, VISUAL_EPSILON = 0.25, COOLDOWN_EPSILON = 1 / 256, SNAP_SETTLE = 3, DEFAULT_Z = 50, BORDER = 2, ALPHA_MASK = 4294967040, KNOB_ALPHA = 217, OVERLAY_ALPHA = 179, HALF2 = 0.5, RECT_WORDS = 4, PAIR = 2, ON2 = 1, OFF2 = 0, SAFE_LEFT = 0, SAFE_TOP = 1, SAFE_RIGHT = 2, SAFE_BOTTOM = 3, R_X = 0, R_Y = 1, R_TIME = 2, R_DT = 3, R_SCALE = 4, R_WIDTH = 5, R_HEIGHT = 6, R_LOOK_SENSITIVITY = 7, R_LOOK_INERTIA = 8, R_LOOK_LAST_MS = 9, R_SHOWN_ROOT = 10, R_IDLE_OPACITY = 11, R_SAFE = 12, REGISTER_WORDS = 16, TouchControls = class {
|
|
488
|
+
constructor(input, options = {}) {
|
|
489
|
+
this.reg = new Float64Array((16));
|
|
490
|
+
this.enabledState = true;
|
|
491
|
+
this.attached = false;
|
|
492
|
+
this.pointerId = new Int32Array(10).fill((-1));
|
|
493
|
+
this.pointerOwner = new Int32Array(10).fill((-1));
|
|
494
|
+
this.stickUsed = new Uint8Array((2));
|
|
495
|
+
this.stickSlotX = new Int32Array((2)).fill((-1));
|
|
496
|
+
this.stickSlotY = new Int32Array((2)).fill((-1));
|
|
497
|
+
this.stickSlotTap = new Int32Array((2)).fill((-1));
|
|
498
|
+
this.stickFloating = new Uint8Array((2));
|
|
499
|
+
this.stickFollow = new Uint8Array((2));
|
|
500
|
+
this.stickAxes = new Uint8Array((2));
|
|
501
|
+
this.stickBaseRadius = new Float64Array((2));
|
|
502
|
+
this.stickRadius = new Float64Array((2));
|
|
503
|
+
this.stickDead = new Float64Array((2));
|
|
504
|
+
this.stickCurve = new Float64Array((2));
|
|
505
|
+
this.stickSnap = new Float64Array((2));
|
|
506
|
+
this.stickZoneFraction = new Float64Array((2) * (4));
|
|
507
|
+
this.stickHomeFraction = new Float64Array((2) * (2));
|
|
508
|
+
this.stickZone = new Float64Array((2) * (4));
|
|
509
|
+
this.stickHome = new Float64Array((2) * (2));
|
|
510
|
+
this.stickOrigin = new Float64Array((2) * (2));
|
|
511
|
+
this.stickTouch = new Float64Array((2) * (2));
|
|
512
|
+
this.stickFollowTarget = new Float64Array((2));
|
|
513
|
+
this.stickPointer = new Int32Array((2)).fill((-1));
|
|
514
|
+
this.stickDownMs = new Float64Array((2));
|
|
515
|
+
this.stickMoved = new Uint8Array((2));
|
|
516
|
+
this.stickValue = new Float64Array((2) * 3);
|
|
517
|
+
this.stickKnob = new Float64Array((2) * (2));
|
|
518
|
+
this.stickShownBase = new Float64Array((2) * (2)).fill(Number.NaN);
|
|
519
|
+
this.stickShownKnob = new Float64Array((2) * (2)).fill(Number.NaN);
|
|
520
|
+
this.stickShownOpacity = new Float64Array((2)).fill(Number.NaN);
|
|
521
|
+
this.stickBaseNode = new Int32Array((2)).fill((-1));
|
|
522
|
+
this.stickKnobNode = new Int32Array((2)).fill((-1));
|
|
523
|
+
this.stickIo = new Float64Array(8);
|
|
524
|
+
this.stickAccessibleLeft = new Float64Array((2));
|
|
525
|
+
this.viewportSource = null;
|
|
526
|
+
this.seen = new Float64Array((6)).fill(Number.NaN);
|
|
527
|
+
this.lookUsed = false;
|
|
528
|
+
this.lookZoneFraction = new Float64Array((4));
|
|
529
|
+
this.lookZone = new Float64Array((4));
|
|
530
|
+
this.lookPointer = (-1);
|
|
531
|
+
this.lookLast = new Float64Array((2));
|
|
532
|
+
this.lookVelocity = new Float64Array((2));
|
|
533
|
+
this.lookCoasting = false;
|
|
534
|
+
this.buttonCount = 0;
|
|
535
|
+
this.buttonSlot = new Int32Array((8)).fill((-1));
|
|
536
|
+
this.buttonDoubleSlot = new Int32Array((8)).fill((-1));
|
|
537
|
+
this.buttonMode = new Uint8Array((8));
|
|
538
|
+
this.buttonLookThrough = new Uint8Array((8));
|
|
539
|
+
this.buttonCooldownTotal = new Float64Array((8));
|
|
540
|
+
this.buttonCooldownLeft = new Float64Array((8));
|
|
541
|
+
this.buttonSize = new Float64Array((8));
|
|
542
|
+
this.buttonCenter = new Float64Array((8) * (2));
|
|
543
|
+
this.buttonRadius = new Float64Array((8));
|
|
544
|
+
this.buttonPointer = new Int32Array((8)).fill((-1));
|
|
545
|
+
this.buttonToggled = new Uint8Array((8));
|
|
546
|
+
this.buttonLastUpMs = new Float64Array((8)).fill(-1 / 0);
|
|
547
|
+
this.buttonLast = new Float64Array((8) * (2));
|
|
548
|
+
this.buttonShownPressed = new Int8Array((8)).fill(-1);
|
|
549
|
+
this.buttonShownCooldown = new Float64Array((8)).fill(Number.NaN);
|
|
550
|
+
this.buttonShownCenter = new Float64Array((8) * (2)).fill(Number.NaN);
|
|
551
|
+
this.buttonNode = new Int32Array((8)).fill((-1));
|
|
552
|
+
this.buttonOverlayNode = new Int32Array((8)).fill((-1));
|
|
553
|
+
this.buttonIndex = /* @__PURE__ */ new Map();
|
|
554
|
+
this.placements = [];
|
|
555
|
+
this.pair = new Float32Array((2));
|
|
556
|
+
this.single = new Float32Array(1);
|
|
557
|
+
this.shade = new Float64Array(1);
|
|
558
|
+
this.buttonHighlightNode = new Int32Array((8)).fill((-1));
|
|
559
|
+
this.rootNode = (-1);
|
|
560
|
+
this.elements = [];
|
|
561
|
+
this.sizedElements = [];
|
|
562
|
+
this.sizedKind = [];
|
|
563
|
+
this.sizedIndex = [];
|
|
564
|
+
if (this.input = input, this.ui = options.ui ?? null, this.theme = options.theme ?? DEFAULT_THEME, this.layout = typeof options.layout == "object" ? options.layout : touchLayout(options.layout ?? "leftStickRightButtons"), this.autoHide = options.autoHide ?? true, this.reg[(11)] = options.idleOpacity ?? (0.5), this.reg[(10)] = Number.NaN, this.z = options.z ?? (50), this.pressScale = this.theme.press_scale, options.move !== null && this.layout.move !== null && this.addStick((0), options.move ?? {}, this.layout.move), options.aim !== void 0 && options.aim !== null && this.layout.aim !== null && this.addStick((1), options.aim, this.layout.aim), options.look !== null && this.layout.look !== null) {
|
|
565
|
+
let look = options.look ?? {};
|
|
566
|
+
this.lookUsed = true, copyRect(this.layout.look.zone, this.lookZoneFraction), this.reg[(7)] = look.sensitivity ?? (1), this.reg[(8)] = look.inertiaSeconds ?? (0.16);
|
|
567
|
+
}
|
|
568
|
+
let buttons = options.buttons ?? [];
|
|
569
|
+
for (let i = 0; i < buttons.length && i < this.layout.buttons.length && i < (8); i++) this.addButton(buttons[i], this.layout.buttons[i]);
|
|
570
|
+
let viewport = options.viewport;
|
|
571
|
+
this.resolve(viewport?.width ?? (844), viewport?.height ?? (390), viewport?.insets ?? null), this.ui !== null && this.build(this.ui, buttons);
|
|
572
|
+
}
|
|
573
|
+
get enabled() {
|
|
574
|
+
return this.enabledState;
|
|
575
|
+
}
|
|
576
|
+
get visible() {
|
|
577
|
+
return this.reg[(10)] === (1);
|
|
578
|
+
}
|
|
579
|
+
get activeTouches() {
|
|
580
|
+
let n = 0;
|
|
581
|
+
for (let i = 0; i < 10; i++) this.pointerId[i] !== (-1) && n++;
|
|
582
|
+
return n;
|
|
583
|
+
}
|
|
584
|
+
get viewportWidth() {
|
|
585
|
+
return this.reg[(5)];
|
|
586
|
+
}
|
|
587
|
+
get viewportHeight() {
|
|
588
|
+
return this.reg[(6)];
|
|
589
|
+
}
|
|
590
|
+
attach() {
|
|
591
|
+
return this.input.setPointerFilter(this), this.attached = true, this;
|
|
592
|
+
}
|
|
593
|
+
detach() {
|
|
594
|
+
this.attached && (this.input.setPointerFilter(null), this.attached = false, this.releaseAll());
|
|
595
|
+
}
|
|
596
|
+
setEnabled(enabled) {
|
|
597
|
+
enabled !== this.enabledState && (this.enabledState = enabled, enabled || this.releaseAll());
|
|
598
|
+
}
|
|
599
|
+
setViewport(width, height, insets = null) {
|
|
600
|
+
this.resolve(width, height, insets), this.ui !== null && this.resize();
|
|
601
|
+
}
|
|
602
|
+
followViewport(source) {
|
|
603
|
+
this.viewportSource = source, this.seen.fill(Number.NaN), source !== null && this.syncViewport(source);
|
|
604
|
+
}
|
|
605
|
+
syncViewport(source) {
|
|
606
|
+
let seen = this.seen, area = source.safe_area, top = area === void 0 ? 0 : area.top, right = area === void 0 ? 0 : area.right, bottom = area === void 0 ? 0 : area.bottom, left = area === void 0 ? 0 : area.left;
|
|
607
|
+
seen[(0)] === source.width && seen[(1)] === source.height && seen[(2)] === top && seen[(3)] === right && seen[(4)] === bottom && seen[(5)] === left || (seen[(0)] = source.width, seen[(1)] = source.height, seen[(2)] = top, seen[(3)] = right, seen[(4)] = bottom, seen[(5)] = left, this.setViewport(source.width, source.height, area ?? null));
|
|
608
|
+
}
|
|
609
|
+
button(control) {
|
|
610
|
+
let index = this.buttonIndex.get(control);
|
|
611
|
+
return index === void 0 ? -1 : index;
|
|
612
|
+
}
|
|
613
|
+
cooldown(button, seconds) {
|
|
614
|
+
button < 0 || button >= this.buttonCount || (this.buttonCooldownTotal[button] = seconds, this.buttonCooldownLeft[button] = seconds);
|
|
615
|
+
}
|
|
616
|
+
cooldownRemaining(button) {
|
|
617
|
+
return button < 0 || button >= this.buttonCount ? 0 : this.buttonCooldownLeft[button];
|
|
618
|
+
}
|
|
619
|
+
readStick(index, out, offset = 0) {
|
|
620
|
+
let o = index * 3;
|
|
621
|
+
out[offset + 0] = this.stickValue[o + 0], out[offset + 1] = this.stickValue[o + 1], out[offset + 2] = this.stickValue[o + 2];
|
|
622
|
+
}
|
|
623
|
+
readStickOrigin(index, out, offset = 0) {
|
|
624
|
+
out[offset] = this.stickOrigin[index * (2)], out[offset + 1] = this.stickOrigin[index * (2) + 1];
|
|
625
|
+
}
|
|
626
|
+
readButtonCenter(index, out, offset = 0) {
|
|
627
|
+
out[offset] = this.buttonCenter[index * (2)], out[offset + 1] = this.buttonCenter[index * (2) + 1];
|
|
628
|
+
}
|
|
629
|
+
buttonNodeId(index) {
|
|
630
|
+
return index < 0 || index >= this.buttonCount ? (-1) : this.buttonNode[index];
|
|
631
|
+
}
|
|
632
|
+
stickNodeId(index) {
|
|
633
|
+
return index < 0 || index >= (2) ? (-1) : this.stickBaseNode[index];
|
|
634
|
+
}
|
|
635
|
+
readStickZone(index, out, offset = 0) {
|
|
636
|
+
for (let k = 0; k < (4); k++) out[offset + k] = this.stickZone[index * (4) + k];
|
|
637
|
+
}
|
|
638
|
+
filterPointer(phase, id, stage) {
|
|
639
|
+
let r = this.reg, px = stage[STAGE_X] * r[(5)], py = stage[STAGE_Y] * r[(6)], time = stage[STAGE_TIME];
|
|
640
|
+
r[(0)] = px, r[(1)] = py, r[(2)] = time;
|
|
641
|
+
let input = this.input, inputStage = input.stage;
|
|
642
|
+
if (phase === "down") {
|
|
643
|
+
if (!this.enabledState) return false;
|
|
644
|
+
let owner2 = (-1), bestDistance = 1 / 0, slop = (14) * r[(4)];
|
|
645
|
+
for (let b = 0; b < this.buttonCount; b++) {
|
|
646
|
+
if (this.buttonPointer[b] !== (-1)) continue;
|
|
647
|
+
let dx = px - this.buttonCenter[b * (2)], dy = py - this.buttonCenter[b * (2) + 1], reach = this.buttonRadius[b] + slop, d = dx * dx + dy * dy;
|
|
648
|
+
d <= reach * reach && d < bestDistance && (bestDistance = d, owner2 = (2) << (4) | b);
|
|
649
|
+
}
|
|
650
|
+
if (owner2 === (-1)) {
|
|
651
|
+
let zone = this.stickZone;
|
|
652
|
+
for (let s = 0; s < (2); s++) {
|
|
653
|
+
if (this.stickUsed[s] === (0) || this.stickPointer[s] !== (-1)) continue;
|
|
654
|
+
let z = s * (4);
|
|
655
|
+
if (px >= zone[z] && px <= zone[z + 2] && py >= zone[z + 1] && py <= zone[z + 3]) {
|
|
656
|
+
owner2 = (0) << (4) | s;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (owner2 === (-1) && this.lookUsed && this.lookPointer === (-1)) {
|
|
662
|
+
let zone = this.lookZone;
|
|
663
|
+
px >= zone[0] && px <= zone[2] && py >= zone[1] && py <= zone[3] && (owner2 = (1) << (4));
|
|
664
|
+
}
|
|
665
|
+
if (owner2 === (-1)) return false;
|
|
666
|
+
let slot2 = -1;
|
|
667
|
+
for (let i = 0; i < 10; i++)
|
|
668
|
+
if (this.pointerId[i] === (-1)) {
|
|
669
|
+
slot2 = i;
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
if (slot2 < 0) return false;
|
|
673
|
+
this.pointerId[slot2] = id, this.pointerOwner[slot2] = owner2;
|
|
674
|
+
let index2 = owner2 & INDEX_MASK, kind2 = owner2 >> (4);
|
|
675
|
+
if (kind2 === (0)) {
|
|
676
|
+
let o = index2 * (2);
|
|
677
|
+
if (this.stickPointer[index2] = id, this.stickDownMs[index2] = time, this.stickMoved[index2] = (0), this.stickFloating[index2] === (1)) {
|
|
678
|
+
let radius = this.stickRadius[index2], lx = r[(12) + (0)] + radius, hx = r[(12) + (2)] - radius, ly = r[(12) + (1)] + radius, hy = r[(12) + (3)] - radius;
|
|
679
|
+
this.stickOrigin[o] = lx > hx ? (lx + hx) * (0.5) : px < lx ? lx : px > hx ? hx : px, this.stickOrigin[o + 1] = ly > hy ? (ly + hy) * (0.5) : py < ly ? ly : py > hy ? hy : py;
|
|
680
|
+
} else
|
|
681
|
+
this.stickOrigin[o] = this.stickHome[o], this.stickOrigin[o + 1] = this.stickHome[o + 1];
|
|
682
|
+
this.stickTouch[o] = px, this.stickTouch[o + 1] = py, this.emitStick(index2);
|
|
683
|
+
} else if (kind2 === (1))
|
|
684
|
+
this.lookPointer = id, this.lookCoasting = false, this.lookLast[0] = px, this.lookLast[1] = py, r[(9)] = time, this.lookVelocity[0] = 0, this.lookVelocity[1] = 0;
|
|
685
|
+
else {
|
|
686
|
+
this.buttonPointer[index2] = id, this.buttonLast[index2 * (2)] = px, this.buttonLast[index2 * (2) + 1] = py;
|
|
687
|
+
let doubleSlot = this.buttonDoubleSlot[index2];
|
|
688
|
+
if (doubleSlot !== (-1) && time - this.buttonLastUpMs[index2] <= (280) && (inputStage[STAGE_X] = 1, inputStage[STAGE_TIME] = time, input.virtualStaged(doubleSlot), inputStage[STAGE_TIME] = time, input.virtualStaged(doubleSlot), this.buttonLastUpMs[index2] = -1 / 0), this.buttonCooldownLeft[index2] <= 0) {
|
|
689
|
+
let on = 1;
|
|
690
|
+
this.buttonMode[index2] === (1) && (on = this.buttonToggled[index2] === (1) ? (0) : (1), this.buttonToggled[index2] = on), inputStage[STAGE_X] = on, inputStage[STAGE_TIME] = time, input.virtualStaged(this.buttonSlot[index2]), this.buttonCooldownTotal[index2] > 0 && (this.buttonCooldownLeft[index2] = this.buttonCooldownTotal[index2]);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return true;
|
|
694
|
+
}
|
|
695
|
+
let slot = -1;
|
|
696
|
+
for (let i = 0; i < 10; i++)
|
|
697
|
+
if (this.pointerId[i] === id) {
|
|
698
|
+
slot = i;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
if (slot < 0) return false;
|
|
702
|
+
let owner = this.pointerOwner[slot], index = owner & INDEX_MASK, kind = owner >> (4);
|
|
703
|
+
if (kind === (0)) this.stickMove(index);
|
|
704
|
+
else if (kind === (1)) {
|
|
705
|
+
let sensitivity = r[(7)], dx = (px - this.lookLast[0]) * sensitivity, dy = (py - this.lookLast[1]) * sensitivity;
|
|
706
|
+
this.lookLast[0] = px, this.lookLast[1] = py, (dx !== 0 || dy !== 0) && (inputStage[STAGE_X] = dx, inputStage[STAGE_Y] = dy, inputStage[STAGE_TIME] = time, input.lookStaged());
|
|
707
|
+
let elapsed = time - r[(9)];
|
|
708
|
+
if (elapsed > 0) {
|
|
709
|
+
let v = this.lookVelocity;
|
|
710
|
+
v[0] += (dx * (1e3) / elapsed - v[0]) * (0.6), v[1] += (dy * (1e3) / elapsed - v[1]) * (0.6), r[(9)] = time;
|
|
711
|
+
}
|
|
712
|
+
} else if (this.buttonLookThrough[index] === (1)) {
|
|
713
|
+
let o = index * (2), sensitivity = r[(7)] > 0 ? r[(7)] : (1), dx = (px - this.buttonLast[o]) * sensitivity, dy = (py - this.buttonLast[o + 1]) * sensitivity;
|
|
714
|
+
this.buttonLast[o] = px, this.buttonLast[o + 1] = py, (dx !== 0 || dy !== 0) && (inputStage[STAGE_X] = dx, inputStage[STAGE_Y] = dy, inputStage[STAGE_TIME] = time, input.lookStaged());
|
|
715
|
+
}
|
|
716
|
+
if (phase === "move") return true;
|
|
717
|
+
if (this.pointerId[slot] = (-1), this.pointerOwner[slot] = (-1), kind === (0)) {
|
|
718
|
+
this.stickPointer[index] = (-1);
|
|
719
|
+
let tap = this.stickSlotTap[index];
|
|
720
|
+
tap !== (-1) && this.stickMoved[index] === (0) && time - this.stickDownMs[index] <= (220) && (inputStage[STAGE_X] = 1, inputStage[STAGE_TIME] = time, input.virtualStaged(tap), inputStage[STAGE_TIME] = time, input.virtualStaged(tap));
|
|
721
|
+
let io = this.stickIo;
|
|
722
|
+
io[0] = 0, io[1] = 0, io[2] = 0, this.publishStick(index);
|
|
723
|
+
} else if (kind === (1)) {
|
|
724
|
+
this.lookPointer = (-1);
|
|
725
|
+
let v = this.lookVelocity, fresh = time - r[(9)] <= (60);
|
|
726
|
+
this.lookCoasting = r[(8)] > 0 && fresh && v[0] * v[0] + v[1] * v[1] > (30) * (30), this.lookCoasting || (v[0] = 0, v[1] = 0);
|
|
727
|
+
} else
|
|
728
|
+
this.buttonPointer[index] = (-1), this.buttonLastUpMs[index] = time, this.buttonMode[index] === (0) && (inputStage[STAGE_X] = 0, inputStage[STAGE_TIME] = time, input.virtualStaged(this.buttonSlot[index]));
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
accessibleActivate(button, timeMs) {
|
|
732
|
+
if (button < 0 || button >= this.buttonCount || !this.enabledState || this.buttonCooldownLeft[button] > 0) return;
|
|
733
|
+
let input = this.input, stage = input.stage, slot = this.buttonSlot[button];
|
|
734
|
+
this.buttonMode[button] === (1) ? (this.buttonToggled[button] = this.buttonToggled[button] === (1) ? (0) : (1), stage[STAGE_X] = this.buttonToggled[button], stage[STAGE_TIME] = timeMs, input.virtualStaged(slot)) : (stage[STAGE_X] = 1, stage[STAGE_TIME] = timeMs, input.virtualStaged(slot), stage[STAGE_TIME] = timeMs, input.virtualStaged(slot)), this.buttonCooldownTotal[button] > 0 && (this.buttonCooldownLeft[button] = this.buttonCooldownTotal[button]);
|
|
735
|
+
}
|
|
736
|
+
accessibleStep(stick, action, timeMs) {
|
|
737
|
+
if (stick < 0 || stick >= (2) || this.stickUsed[stick] === (0) || !this.enabledState || this.stickPointer[stick] !== (-1)) return;
|
|
738
|
+
let direction = action === UiAction.increment ? 1 : action === UiAction.decrement ? -1 : 0;
|
|
739
|
+
if (direction === 0) return;
|
|
740
|
+
let io = this.stickIo, horizontal = this.stickAxes[stick] === 1;
|
|
741
|
+
io[0] = horizontal ? direction : 0, io[1] = horizontal ? 0 : direction, io[2] = 1, this.reg[(2)] = timeMs, this.publishStick(stick), this.stickAccessibleLeft[stick] = (0.4);
|
|
742
|
+
}
|
|
743
|
+
update(clock) {
|
|
744
|
+
let r = this.reg, dt = clock[FRAME_SECONDS_SLOT];
|
|
745
|
+
r[(3)] = dt, this.viewportSource !== null && this.syncViewport(this.viewportSource);
|
|
746
|
+
for (let s = 0; s < (2); s++) {
|
|
747
|
+
let left = this.stickAccessibleLeft[s];
|
|
748
|
+
if (left <= 0 || (this.stickAccessibleLeft[s] = left - dt, left - dt > 0 || this.stickPointer[s] !== (-1))) continue;
|
|
749
|
+
let io = this.stickIo;
|
|
750
|
+
io[0] = 0, io[1] = 0, io[2] = 0, this.publishStick(s);
|
|
751
|
+
}
|
|
752
|
+
for (let b = 0; b < this.buttonCount; b++) {
|
|
753
|
+
let left = this.buttonCooldownLeft[b];
|
|
754
|
+
left > 0 && (this.buttonCooldownLeft[b] = left - dt > 0 ? left - dt : 0);
|
|
755
|
+
}
|
|
756
|
+
if (this.lookCoasting) {
|
|
757
|
+
let v = this.lookVelocity, stage = this.input.stage;
|
|
758
|
+
stage[STAGE_X] = v[0] * dt, stage[STAGE_Y] = v[1] * dt, stage[STAGE_TIME] = r[(9)], this.input.lookStaged();
|
|
759
|
+
let decay = Math.exp(-dt / r[(8)]);
|
|
760
|
+
v[0] *= decay, v[1] *= decay, v[0] * v[0] + v[1] * v[1] < (30) * (30) && (v[0] = 0, v[1] = 0, this.lookCoasting = false);
|
|
761
|
+
}
|
|
762
|
+
let ui = this.ui;
|
|
763
|
+
if (ui === null) return;
|
|
764
|
+
let writer = ui.writer, records = writer.records;
|
|
765
|
+
this.drawVisibility(writer);
|
|
766
|
+
for (let s = 0; s < (2); s++) this.stickUsed[s] === (1) && this.drawStick(writer, s);
|
|
767
|
+
for (let b = 0; b < this.buttonCount; b++) this.drawButton(writer, b);
|
|
768
|
+
writer.records !== records && ui.touched();
|
|
769
|
+
}
|
|
770
|
+
dispose() {
|
|
771
|
+
this.detach();
|
|
772
|
+
for (let i = 0; i < this.elements.length; i++) this.elements[i].destroy();
|
|
773
|
+
this.elements.length = 0;
|
|
774
|
+
}
|
|
775
|
+
addStick(index, spec, placement) {
|
|
776
|
+
let input = this.input;
|
|
777
|
+
this.stickUsed[index] = (1);
|
|
778
|
+
let prefix = index === (0) ? "touch.move" : "touch.aim";
|
|
779
|
+
this.stickSlotX[index] = input.virtualControl(spec.x ?? `${prefix}.x`), this.stickSlotY[index] = input.virtualControl(spec.y ?? `${prefix}.y`), spec.tap !== void 0 && (this.stickSlotTap[index] = input.virtualControl(spec.tap));
|
|
780
|
+
let floating = (spec.mode ?? "floating") === "floating";
|
|
781
|
+
this.stickFloating[index] = floating ? (1) : (0), this.stickFollow[index] = spec.follow ?? floating ? (1) : (0), this.stickAxes[index] = stickAxesCode(spec.axes ?? "both"), this.stickBaseRadius[index] = spec.radius ?? (58), this.stickDead[index] = spec.deadZone ?? (0.12), this.stickCurve[index] = spec.curve ?? (1), this.stickSnap[index] = spec.snapSeconds ?? (0.12), copyRect(placement.zone, this.stickZoneFraction, index * (4)), this.stickHomeFraction[index * (2)] = placement.home[0], this.stickHomeFraction[index * (2) + 1] = placement.home[1];
|
|
782
|
+
}
|
|
783
|
+
addButton(spec, placement) {
|
|
784
|
+
let b = this.buttonCount++, input = this.input;
|
|
785
|
+
this.buttonSlot[b] = input.virtualControl(spec.control), spec.doubleTap !== void 0 && (this.buttonDoubleSlot[b] = input.virtualControl(spec.doubleTap)), this.buttonMode[b] = spec.mode === "toggle" ? (1) : (0), this.buttonLookThrough[b] = spec.lookThrough ? (1) : (0), this.buttonCooldownTotal[b] = spec.cooldownSeconds ?? 0, this.buttonSize[b] = spec.size ?? placement.size, this.buttonIndex.set(spec.control, b), this.placements.push(placement);
|
|
786
|
+
}
|
|
787
|
+
resolve(width, height, insets) {
|
|
788
|
+
let r = this.reg;
|
|
789
|
+
r[(5)] = width > 0 ? width : (844), r[(6)] = height > 0 ? height : (390), r[(12) + (0)] = insets?.left ?? 0, r[(12) + (1)] = insets?.top ?? 0, r[(12) + (2)] = r[(5)] - (insets?.right ?? 0), r[(12) + (3)] = r[(6)] - (insets?.bottom ?? 0);
|
|
790
|
+
let shortSide = Math.min(r[(5)], r[(6)]);
|
|
791
|
+
r[(4)] = Math.min((1.4), Math.max((0.85), shortSide / (390)));
|
|
792
|
+
let scale = r[(4)], sx = r[(12) + (0)], sy = r[(12) + (1)], sw = r[(12) + (2)] - sx, sh = r[(12) + (3)] - sy;
|
|
793
|
+
for (let s = 0; s < (2); s++) {
|
|
794
|
+
if (this.stickUsed[s] === (0)) continue;
|
|
795
|
+
this.stickRadius[s] = this.stickBaseRadius[s] * scale, this.placeRect(this.stickZoneFraction, s * (4), this.stickZone);
|
|
796
|
+
let hx = sx + sw * this.stickHomeFraction[s * (2)], hy = sy + sh * this.stickHomeFraction[s * (2) + 1];
|
|
797
|
+
this.stickHome[s * (2)] = hx, this.stickHome[s * (2) + 1] = hy, this.stickPointer[s] === (-1) && (this.stickOrigin[s * (2)] = hx, this.stickOrigin[s * (2) + 1] = hy);
|
|
798
|
+
}
|
|
799
|
+
this.lookUsed && this.placeRect(this.lookZoneFraction, 0, this.lookZone);
|
|
800
|
+
for (let b = 0; b < this.buttonCount; b++) {
|
|
801
|
+
let p = this.placements[b];
|
|
802
|
+
this.buttonRadius[b] = this.buttonSize[b] * scale / 2, this.buttonCenter[b * (2)] = sx + sw * p.anchor[0] + p.offset[0] * scale, this.buttonCenter[b * (2) + 1] = sy + sh * p.anchor[1] + p.offset[1] * scale;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
placeRect(fractions, at, out) {
|
|
806
|
+
let r = this.reg, sx = r[(12) + (0)], sy = r[(12) + (1)], w = r[(12) + (2)] - sx, h = r[(12) + (3)] - sy;
|
|
807
|
+
out[at] = sx + w * fractions[at], out[at + 1] = sy + h * fractions[at + 1], out[at + 2] = sx + w * fractions[at + 2], out[at + 3] = sy + h * fractions[at + 3];
|
|
808
|
+
}
|
|
809
|
+
stickMove(s) {
|
|
810
|
+
let r = this.reg, o = s * (2);
|
|
811
|
+
if (this.stickTouch[o] = r[(0)], this.stickTouch[o + 1] = r[(1)], this.stickFollow[s] === (1)) {
|
|
812
|
+
let axes = this.stickAxes[s], target = this.stickFollowTarget;
|
|
813
|
+
target[0] = axes === 2 ? this.stickOrigin[o] : r[(0)], target[1] = axes === 1 ? this.stickOrigin[o + 1] : r[(1)], followOriginInto(this.stickOrigin, o, target, 0, this.stickRadius, s);
|
|
814
|
+
}
|
|
815
|
+
if (this.stickMoved[s] === (0)) {
|
|
816
|
+
let dx = r[(0)] - this.stickOrigin[o], dy = r[(1)] - this.stickOrigin[o + 1], slop = this.stickRadius[s] * (0.25);
|
|
817
|
+
dx * dx + dy * dy > slop * slop && (this.stickMoved[s] = (1));
|
|
818
|
+
}
|
|
819
|
+
this.emitStick(s);
|
|
820
|
+
}
|
|
821
|
+
stickRelease(s) {
|
|
822
|
+
this.stickPointer[s] = (-1), this.stickIo[0] = 0, this.stickIo[1] = 0, this.stickIo[2] = 0, this.publishStick(s);
|
|
823
|
+
}
|
|
824
|
+
emitStick(s) {
|
|
825
|
+
let o = s * (2), io = this.stickIo;
|
|
826
|
+
io[3] = this.stickTouch[o] - this.stickOrigin[o], io[4] = this.stickTouch[o + 1] - this.stickOrigin[o + 1], io[5] = this.stickRadius[s], io[6] = this.stickDead[s], io[7] = this.stickCurve[s], shapeStickInto(io, this.stickAxes[s]), this.publishStick(s);
|
|
827
|
+
}
|
|
828
|
+
publishStick(s) {
|
|
829
|
+
let io = this.stickIo, v = this.stickValue, o = s * 3, input = this.input, stage = input.stage;
|
|
830
|
+
v[o + 0] !== io[0] && this.stickSlotX[s] !== (-1) && (stage[STAGE_X] = io[0], stage[STAGE_TIME] = this.reg[(2)], input.virtualStaged(this.stickSlotX[s])), v[o + 1] !== io[1] && this.stickSlotY[s] !== (-1) && (stage[STAGE_X] = io[1], stage[STAGE_TIME] = this.reg[(2)], input.virtualStaged(this.stickSlotY[s])), v[o + 0] = io[0], v[o + 1] = io[1], v[o + 2] = io[2];
|
|
831
|
+
}
|
|
832
|
+
buttonRelease(b) {
|
|
833
|
+
if (this.buttonPointer[b] = (-1), this.buttonMode[b] !== (0)) return;
|
|
834
|
+
let stage = this.input.stage;
|
|
835
|
+
stage[STAGE_X] = 0, stage[STAGE_TIME] = this.reg[(2)], this.input.virtualStaged(this.buttonSlot[b]);
|
|
836
|
+
}
|
|
837
|
+
releaseAll() {
|
|
838
|
+
for (let i = 0; i < 10; i++) {
|
|
839
|
+
let owner = this.pointerOwner[i];
|
|
840
|
+
if (owner === (-1)) continue;
|
|
841
|
+
this.pointerId[i] = (-1), this.pointerOwner[i] = (-1);
|
|
842
|
+
let index = owner & INDEX_MASK, kind = owner >> (4);
|
|
843
|
+
kind === (0) ? this.stickRelease(index) : kind === (1) ? (this.lookPointer = (-1), this.lookCoasting = false) : this.buttonRelease(index);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
drawVisibility(writer) {
|
|
847
|
+
let device = this.input.device, visible = this.enabledState;
|
|
848
|
+
visible && this.autoHide && (device === InputDevice.keyboard || device === InputDevice.gamepad) && this.activeTouches === 0 && (visible = false);
|
|
849
|
+
let opacity = visible ? (1) : 0;
|
|
850
|
+
opacity !== this.reg[(10)] && (this.reg[(10)] = opacity, this.single[0] = opacity, writer.propF32(this.rootNode, UiProp.opacity, this.single));
|
|
851
|
+
}
|
|
852
|
+
drawStick(writer, s) {
|
|
853
|
+
let o = s * (2), radius = this.stickRadius[s], active = this.stickPointer[s] !== (-1), knob = this.stickKnob;
|
|
854
|
+
if (active) {
|
|
855
|
+
let kx = this.stickTouch[o] - this.stickOrigin[o], ky = this.stickTouch[o + 1] - this.stickOrigin[o + 1], axes = this.stickAxes[s];
|
|
856
|
+
axes === 1 ? ky = 0 : axes === 2 && (kx = 0);
|
|
857
|
+
let length = (kx * kx + ky * ky) ** 0.5;
|
|
858
|
+
length > radius && (kx *= radius / length, ky *= radius / length), knob[o] = kx, knob[o + 1] = ky;
|
|
859
|
+
} else {
|
|
860
|
+
let k = 1 - Math.exp(-this.reg[(3)] * (3) / this.stickSnap[s]);
|
|
861
|
+
knob[o] -= knob[o] * k, knob[o + 1] -= knob[o + 1] * k, this.stickFloating[s] === (1) && (this.stickOrigin[o] = this.stickHome[o], this.stickOrigin[o + 1] = this.stickHome[o + 1]);
|
|
862
|
+
}
|
|
863
|
+
let shownBase = this.stickShownBase, baseX = this.stickOrigin[o] - radius, baseY = this.stickOrigin[o + 1] - radius;
|
|
864
|
+
Math.abs(shownBase[o] - baseX) < (0.25) && Math.abs(shownBase[o + 1] - baseY) < (0.25) || (shownBase[o] = baseX, shownBase[o + 1] = baseY, this.pair[0] = baseX, this.pair[1] = baseY, writer.propF32(this.stickBaseNode[s], UiProp.translate, this.pair));
|
|
865
|
+
let shownKnob = this.stickShownKnob;
|
|
866
|
+
Math.abs(shownKnob[o] - knob[o]) < (0.25) && Math.abs(shownKnob[o + 1] - knob[o + 1]) < (0.25) || (shownKnob[o] = knob[o], shownKnob[o + 1] = knob[o + 1], this.pair[0] = knob[o], this.pair[1] = knob[o + 1], writer.propF32(this.stickKnobNode[s], UiProp.translate, this.pair));
|
|
867
|
+
let shade = this.shade;
|
|
868
|
+
shade[0] = this.reg[(11)], active && (shade[0] = (1)), this.stickShownOpacity[s] !== shade[0] && (this.stickShownOpacity[s] = shade[0], this.single[0] = shade[0], writer.propF32(this.stickBaseNode[s], UiProp.opacity, this.single));
|
|
869
|
+
}
|
|
870
|
+
drawButton(writer, b) {
|
|
871
|
+
let node = this.buttonNode[b], o = b * (2), radius = this.buttonRadius[b], cx = this.buttonCenter[o] - radius, cy = this.buttonCenter[o + 1] - radius, shown = this.buttonShownCenter;
|
|
872
|
+
Math.abs(shown[o] - cx) < (0.25) && Math.abs(shown[o + 1] - cy) < (0.25) || (shown[o] = cx, shown[o + 1] = cy, this.pair[0] = cx, this.pair[1] = cy, writer.propF32(node, UiProp.translate, this.pair));
|
|
873
|
+
let held = this.buttonPointer[b] !== (-1) && this.buttonCooldownLeft[b] <= 0, lit = held || this.buttonMode[b] === (1) && this.buttonToggled[b] === (1), pressed = lit ? (1) : (0);
|
|
874
|
+
if (this.buttonShownPressed[b] !== pressed) {
|
|
875
|
+
this.buttonShownPressed[b] = pressed, this.single[0] = lit ? (1) : 0, writer.propF32(this.buttonHighlightNode[b], UiProp.opacity, this.single);
|
|
876
|
+
let scale = held ? this.pressScale : 1;
|
|
877
|
+
this.pair[0] = scale, this.pair[1] = scale, writer.propF32(node, UiProp.scale, this.pair);
|
|
878
|
+
}
|
|
879
|
+
let total = this.buttonCooldownTotal[b], shade = this.shade;
|
|
880
|
+
shade[0] = 0, total > 0 && (shade[0] = this.buttonCooldownLeft[b] / total);
|
|
881
|
+
let ratio = shade[0], before = this.buttonShownCooldown[b];
|
|
882
|
+
(before !== before || Math.abs(before - ratio) >= COOLDOWN_EPSILON || ratio === 0 && before !== 0) && (this.buttonShownCooldown[b] = ratio, this.pair[0] = 1, this.pair[1] = ratio, writer.propF32(this.buttonOverlayNode[b], UiProp.scale, this.pair), this.single[0] = ratio > 0 ? (0.55) : (1), writer.propF32(node, UiProp.opacity, this.single));
|
|
883
|
+
}
|
|
884
|
+
build(ui, buttons) {
|
|
885
|
+
let t = this.theme, root = ui.box({ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", pointerEvents: "none" });
|
|
886
|
+
root.transition(["opacity"], { duration: t.motion, easing: "ease_out" }), ui.root(root, { anchor: "top_left", safe_area: false, z: this.z }), this.rootNode = root.id, this.elements.push(root);
|
|
887
|
+
for (let s = 0; s < (2); s++) {
|
|
888
|
+
if (this.stickUsed[s] === (0)) continue;
|
|
889
|
+
let base = ui.box({
|
|
890
|
+
position: "absolute",
|
|
891
|
+
left: 0,
|
|
892
|
+
top: 0,
|
|
893
|
+
fill: t.track,
|
|
894
|
+
borderWidth: (2),
|
|
895
|
+
borderColor: t.border,
|
|
896
|
+
pointerEvents: "none",
|
|
897
|
+
layer: true
|
|
898
|
+
});
|
|
899
|
+
base.transition(["opacity"], { duration: t.motion, easing: "ease_out" });
|
|
900
|
+
let stick = s;
|
|
901
|
+
base.accessibility({ role: "adjustable", label: s === (0) ? MOVE_LABEL : AIM_LABEL, actions: ["increment", "decrement"] }), base.on("action", (event) => this.accessibleStep(stick, event.value, event.time_ms));
|
|
902
|
+
let knob = ui.box({ position: "absolute", fill: (parseColor(t.text) & (4294967040) | (217)) >>> 0, pointerEvents: "none", layer: true });
|
|
903
|
+
base.append(knob), root.append(base), this.stickBaseNode[s] = base.id, this.stickKnobNode[s] = knob.id, this.elements.push(base, knob), this.sized(base, (0), s), this.sized(knob, (1), s);
|
|
904
|
+
}
|
|
905
|
+
for (let b = 0; b < this.buttonCount; b++) {
|
|
906
|
+
let spec = buttons[b], button = ui.box({
|
|
907
|
+
position: "absolute",
|
|
908
|
+
left: 0,
|
|
909
|
+
top: 0,
|
|
910
|
+
alignItems: "center",
|
|
911
|
+
justify: "center",
|
|
912
|
+
fill: t.raised,
|
|
913
|
+
borderWidth: (2),
|
|
914
|
+
borderColor: t.border,
|
|
915
|
+
clip: true,
|
|
916
|
+
pointerEvents: "none",
|
|
917
|
+
layer: true,
|
|
918
|
+
origin: [(0.5), (0.5)]
|
|
919
|
+
});
|
|
920
|
+
button.transition(["scale_x", "scale_y", "opacity"], { duration: t.motion, easing: "back_out" });
|
|
921
|
+
let highlight = ui.box({
|
|
922
|
+
position: "absolute",
|
|
923
|
+
left: 0,
|
|
924
|
+
top: 0,
|
|
925
|
+
width: "100%",
|
|
926
|
+
height: "100%",
|
|
927
|
+
fill: t.accent,
|
|
928
|
+
opacity: 0,
|
|
929
|
+
pointerEvents: "none",
|
|
930
|
+
layer: true
|
|
931
|
+
});
|
|
932
|
+
highlight.transition(["opacity"], { duration: t.motion, easing: "ease_out" }), button.append(highlight);
|
|
933
|
+
let overlay = ui.box({
|
|
934
|
+
position: "absolute",
|
|
935
|
+
left: 0,
|
|
936
|
+
top: 0,
|
|
937
|
+
width: "100%",
|
|
938
|
+
height: "100%",
|
|
939
|
+
fill: (parseColor(t.surface) & (4294967040) | (179)) >>> 0,
|
|
940
|
+
origin: [(0.5), 1],
|
|
941
|
+
pointerEvents: "none",
|
|
942
|
+
layer: true
|
|
943
|
+
});
|
|
944
|
+
if (button.append(overlay), spec.icon !== void 0) {
|
|
945
|
+
let size = t.body * 2, icon = ui.image(spec.icon, [size, size], { width: size, height: size, pointerEvents: "none" });
|
|
946
|
+
button.append(icon), this.elements.push(icon);
|
|
947
|
+
} else if (spec.label !== void 0) {
|
|
948
|
+
let label = ui.text(spec.label, { fontFamily: t.font, fontSize: t.small, textColor: t.text, textAlign: "center", pointerEvents: "none" });
|
|
949
|
+
button.append(label), this.elements.push(label);
|
|
950
|
+
}
|
|
951
|
+
button.accessibility({ role: "button", label: spec.label ?? spec.control, actions: ["activate"] });
|
|
952
|
+
let index = b;
|
|
953
|
+
button.on("tap", (event) => this.accessibleActivate(index, event.time_ms)), root.append(button), this.buttonNode[b] = button.id, this.buttonOverlayNode[b] = overlay.id, this.buttonHighlightNode[b] = highlight.id, this.elements.push(button, highlight, overlay), this.sized(button, (2), b);
|
|
954
|
+
}
|
|
955
|
+
this.resize();
|
|
956
|
+
}
|
|
957
|
+
sized(element, kind, index) {
|
|
958
|
+
this.sizedElements.push(element), this.sizedKind.push(kind), this.sizedIndex.push(index);
|
|
959
|
+
}
|
|
960
|
+
resize() {
|
|
961
|
+
for (let i = 0; i < this.sizedElements.length; i++) {
|
|
962
|
+
let element = this.sizedElements[i], index = this.sizedIndex[i], kind = this.sizedKind[i];
|
|
963
|
+
if (kind === (2)) {
|
|
964
|
+
let d = this.buttonRadius[index] * 2;
|
|
965
|
+
element.style({ width: d, height: d, radius: d / 2 });
|
|
966
|
+
} else if (kind === (0)) {
|
|
967
|
+
let d = this.stickRadius[index] * 2;
|
|
968
|
+
element.style({ width: d, height: d, radius: d / 2 });
|
|
969
|
+
} else {
|
|
970
|
+
let r = this.stickRadius[index], d = r * 2 * (0.46);
|
|
971
|
+
element.style({ width: d, height: d, radius: d / 2, left: r - d / 2, top: r - d / 2 });
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
this.stickShownBase.fill(Number.NaN), this.buttonShownCenter.fill(Number.NaN);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
function copyRect(source, out, at = 0) {
|
|
978
|
+
out[at] = source[0], out[at + 1] = source[1], out[at + 2] = source[2], out[at + 3] = source[3];
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
export { CHAR_AIR_SECONDS, CHAR_BUFFER, CHAR_COYOTE, CHAR_CROUCH, CHAR_GROUND_NX, CHAR_GROUND_NY, CHAR_GROUND_NZ, CHAR_HEADING, CHAR_LANDING_SPEED, CHAR_MOVE_MAGNITUDE, CHAR_MOVE_X, CHAR_MOVE_Z, CHAR_PLATFORM_VX, CHAR_PLATFORM_VY, CHAR_PLATFORM_VZ, CHAR_SPEED, CHAR_SPEED_NORMALIZED, CHAR_VX, CHAR_VY, CHAR_VZ, CONTACT_LOCKED, CONTACT_LOCK_BLEND, CONTACT_LOCK_X, CONTACT_LOCK_Y, CONTACT_LOCK_Z, CONTACT_PLANTED, CONTACT_WEIGHT, CharacterMotor, ClipEventReader, DEFAULT_CLIP_EVENT_CAPACITY, DEFAULT_CONTACT_MAX_SLIDE, DEFAULT_CONTACT_RELEASE_SECONDS, DEFAULT_CONTACT_WEIGHT_SECONDS, DEFAULT_FOOT_UP, DEFAULT_GAMEPAD_LOOK_SPEED, DEFAULT_LOOK_SENSITIVITY, DEFAULT_MAX_FOOT_TILT, DEFAULT_PLANT_THRESHOLD, FOLLOW_CAMERA_X, FOLLOW_CAMERA_Y, FOLLOW_CAMERA_Z, FOLLOW_CLOSENESS, FOLLOW_DISTANCE, FOLLOW_FOV, FOLLOW_PITCH, FOLLOW_PIVOT_X, FOLLOW_PIVOT_Y, FOLLOW_PIVOT_Z, FOLLOW_SHOULDER, FOLLOW_YAW, FollowCamera, FootContact, MAX_TOUCH_BUTTONS, MOVE_IN_X, MOVE_IN_Y, MOVE_IO_MAGNITUDE, MOVE_IO_WORDS, MOVE_IO_X, MOVE_IO_Z, MOVE_OUT_X, MOVE_OUT_Z, ROOT_IO_DX, ROOT_IO_DZ, ROOT_IO_YAW, STICK_AIM, STICK_CURVE, STICK_DEAD_ZONE, STICK_DX, STICK_DY, STICK_IO_WORDS, STICK_MAGNITUDE, STICK_MOVE, STICK_OUT_WORDS, STICK_RADIUS, STICK_X, STICK_Y, TouchControls, actionListed, createFootTiltChain, followOrigin, followOriginInto, shapeStick, shapeStickInto, touchLayout };
|