@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.
Files changed (608) hide show
  1. package/LICENSE +21 -0
  2. package/dist/advanced.d.mts +4 -3
  3. package/dist/advanced.d.ts +4 -3
  4. package/dist/advanced.js +24 -24
  5. package/dist/advanced.mjs +5 -5
  6. package/dist/animation-4EXBXRVX.js +27 -0
  7. package/dist/animation-6DICNWUP.mjs +6 -0
  8. package/dist/audio-DhvyjqdA.d.mts +249 -0
  9. package/dist/audio-m0w8cnxq.d.ts +249 -0
  10. package/dist/avatars.d.mts +110 -0
  11. package/dist/avatars.d.ts +110 -0
  12. package/dist/avatars.js +82 -0
  13. package/dist/avatars.mjs +5 -0
  14. package/dist/backend-gUCzs5Kg.d.mts +3866 -0
  15. package/dist/backend-gUCzs5Kg.d.ts +3866 -0
  16. package/dist/{catalogue-B4eLL8Mi.d.ts → catalogue-CPTMyBUz.d.mts} +109 -221
  17. package/dist/catalogue-DzrTXP3v.d.mts +541 -0
  18. package/dist/catalogue-DzrTXP3v.d.ts +541 -0
  19. package/dist/{catalogue-OT89_Ifs.d.mts → catalogue-OTuS5zp-.d.ts} +109 -221
  20. package/dist/chunk-22BD3RHN.mjs +1809 -0
  21. package/dist/chunk-25T4JHEA.mjs +21 -0
  22. package/dist/chunk-2AQ237Y4.js +508 -0
  23. package/dist/chunk-2IC4H6OV.mjs +48 -0
  24. package/dist/chunk-2LHLG4OB.mjs +71 -0
  25. package/dist/chunk-2O2CG465.js +1709 -0
  26. package/dist/chunk-2Q4DTHXK.js +316 -0
  27. package/dist/chunk-2QTQ6BUH.mjs +46 -0
  28. package/dist/chunk-2UN4SFLR.mjs +100 -0
  29. package/dist/chunk-2V75I7K3.js +454 -0
  30. package/dist/chunk-2V7IL4HC.js +10 -0
  31. package/dist/chunk-34XBXUMW.js +296 -0
  32. package/dist/chunk-3C4C654I.js +71 -0
  33. package/dist/chunk-3DAD2LDF.mjs +72 -0
  34. package/dist/chunk-3GXH2NFD.mjs +4 -0
  35. package/dist/chunk-3O47ZFW3.js +961 -0
  36. package/dist/chunk-3OY3VYNF.mjs +11 -0
  37. package/dist/chunk-3S6WPBZL.js +2936 -0
  38. package/dist/chunk-3TUOUP5T.js +399 -0
  39. package/dist/chunk-3VEH23I5.mjs +1380 -0
  40. package/dist/chunk-3ZYSAW2T.mjs +263 -0
  41. package/dist/chunk-4ANVF274.js +103 -0
  42. package/dist/chunk-4C7I3ELN.js +388 -0
  43. package/dist/chunk-4DYKAYFO.mjs +8 -0
  44. package/dist/chunk-4ZDR72SG.js +329 -0
  45. package/dist/chunk-52YS45RR.js +1066 -0
  46. package/dist/chunk-5325XSCH.js +107 -0
  47. package/dist/chunk-5AD5X6AV.js +13 -0
  48. package/dist/chunk-5BYDGGWO.mjs +197 -0
  49. package/dist/chunk-5C3C7VDM.mjs +55 -0
  50. package/dist/chunk-5HFMY3D7.js +660 -0
  51. package/dist/chunk-5LH2QN3T.js +1862 -0
  52. package/dist/chunk-5PJEXSOW.js +44 -0
  53. package/dist/chunk-5SXDH3Y7.js +90 -0
  54. package/dist/chunk-5YFBGGCK.mjs +502 -0
  55. package/dist/chunk-5YWN6H5Q.mjs +133 -0
  56. package/dist/chunk-66QP3SMN.js +402 -0
  57. package/dist/chunk-6DAEZKIG.mjs +385 -0
  58. package/dist/chunk-6DATW7TB.mjs +420 -0
  59. package/dist/{chunk-JRGK3NXR.mjs → chunk-6ETDAU62.mjs} +72 -212
  60. package/dist/chunk-6H254EVP.mjs +178 -0
  61. package/dist/chunk-6PFNJPBJ.mjs +820 -0
  62. package/dist/chunk-6PJWXIFX.mjs +357 -0
  63. package/dist/chunk-6SWKWCMS.js +80 -0
  64. package/dist/chunk-6VVXXX7S.js +808 -0
  65. package/dist/chunk-6WUBSMTX.js +1403 -0
  66. package/dist/chunk-73SGZLAQ.mjs +35 -0
  67. package/dist/chunk-76L2V6KD.mjs +4 -0
  68. package/dist/chunk-7AAIAVAA.js +1531 -0
  69. package/dist/chunk-7ARSJPV3.mjs +93 -0
  70. package/dist/chunk-7BHW5GTC.mjs +1234 -0
  71. package/dist/chunk-7DQSDKDU.js +6 -0
  72. package/dist/chunk-7IQQQENP.mjs +401 -0
  73. package/dist/chunk-7KFTYENS.js +11357 -0
  74. package/dist/chunk-7SM6XSPZ.js +3171 -0
  75. package/dist/chunk-7SXOHAIR.mjs +28 -0
  76. package/dist/chunk-A2MAX6S4.js +90 -0
  77. package/dist/chunk-A33OORT7.mjs +1530 -0
  78. package/dist/{chunk-U6ACF76H.mjs → chunk-A36JRXXH.mjs} +1075 -1845
  79. package/dist/chunk-A7BU3BK4.js +52 -0
  80. package/dist/chunk-A7MQSN2V.mjs +77 -0
  81. package/dist/chunk-A7V4L2IT.mjs +416 -0
  82. package/dist/chunk-AABEK6XU.js +226 -0
  83. package/dist/chunk-AGV33FWC.mjs +5005 -0
  84. package/dist/chunk-AHNR3BXI.js +108 -0
  85. package/dist/chunk-AQ5RLBU2.mjs +286 -0
  86. package/dist/chunk-AQOE6WCG.js +1270 -0
  87. package/dist/chunk-ATAWRACV.mjs +62 -0
  88. package/dist/chunk-ATCURNUV.js +14 -0
  89. package/dist/chunk-AWPV33OO.js +6 -0
  90. package/dist/chunk-AYJPHKYV.js +337 -0
  91. package/dist/chunk-AZ5BGWHB.js +162 -0
  92. package/dist/chunk-AZAXD44P.js +1373 -0
  93. package/dist/chunk-BBGKQIJJ.mjs +406 -0
  94. package/dist/chunk-BP4JLSUA.js +1453 -0
  95. package/dist/{chunk-SUCE7FWA.mjs → chunk-BTUSVHIE.mjs} +539 -978
  96. package/dist/chunk-BU6OK542.mjs +818 -0
  97. package/dist/chunk-CVSRWM6W.js +418 -0
  98. package/dist/chunk-CYBMFMJD.mjs +247 -0
  99. package/dist/chunk-DDJLDOUX.mjs +217 -0
  100. package/dist/{chunk-V32BCG7M.js → chunk-DFZWHNRG.js} +75 -215
  101. package/dist/chunk-DJ2C7AVG.js +644 -0
  102. package/dist/chunk-DS2VU4WW.mjs +102 -0
  103. package/dist/chunk-DSAG7T5P.js +7290 -0
  104. package/dist/chunk-E2QPPH7I.js +327 -0
  105. package/dist/chunk-E65WCTIG.mjs +1187 -0
  106. package/dist/{chunk-33VCYWVL.mjs → chunk-E6QQKDNE.mjs} +30 -42
  107. package/dist/chunk-ECDK6QBF.mjs +981 -0
  108. package/dist/chunk-EIB4OWVQ.mjs +620 -0
  109. package/dist/chunk-EQUZYCGO.js +250 -0
  110. package/dist/chunk-F3UJ6ZRM.mjs +313 -0
  111. package/dist/chunk-F63N2ZTQ.js +7023 -0
  112. package/dist/chunk-F6XRYEM3.mjs +26 -0
  113. package/dist/chunk-FE6VCE4K.js +5030 -0
  114. package/dist/chunk-FLWD6GRR.js +1372 -0
  115. package/dist/chunk-FQBFWJBS.mjs +110 -0
  116. package/dist/chunk-FXVJ2HFU.js +26 -0
  117. package/dist/chunk-FZMQMQBW.js +312 -0
  118. package/dist/chunk-G3EEC44R.js +53 -0
  119. package/dist/{chunk-KG3WT4PR.mjs → chunk-GCKWKLZF.mjs} +73 -104
  120. package/dist/chunk-GCX7TY4D.mjs +6826 -0
  121. package/dist/chunk-GDB6TCSD.js +450 -0
  122. package/dist/chunk-GDCV4IWO.mjs +21 -0
  123. package/dist/chunk-GDZT5LZ5.js +170 -0
  124. package/dist/chunk-GHPUYD4I.mjs +213 -0
  125. package/dist/chunk-GHS6MIL6.mjs +1432 -0
  126. package/dist/chunk-GPS2THCL.mjs +11 -0
  127. package/dist/{chunk-EV2EVOYS.js → chunk-GTJWQAGU.js} +31 -42
  128. package/dist/chunk-GVTI6UJQ.mjs +130 -0
  129. package/dist/chunk-GXKI64OT.mjs +1138 -0
  130. package/dist/chunk-GYDYF2WX.js +275 -0
  131. package/dist/chunk-GYLP6UG4.mjs +705 -0
  132. package/dist/chunk-H3OQKK6X.js +1158 -0
  133. package/dist/chunk-H5DFSCJ6.js +40 -0
  134. package/dist/chunk-HAGEIC2L.mjs +186 -0
  135. package/dist/chunk-HAJ4JRFO.js +293 -0
  136. package/dist/chunk-HDR72GB6.js +188 -0
  137. package/dist/chunk-HF5HPS4T.mjs +40 -0
  138. package/dist/chunk-HK6LOFDS.js +218 -0
  139. package/dist/chunk-HMWYTXCY.mjs +143 -0
  140. package/dist/chunk-HPCSRCMA.js +89 -0
  141. package/dist/chunk-HSEO6TPU.js +247 -0
  142. package/dist/chunk-I5FOHCLH.js +132 -0
  143. package/dist/chunk-IDLW4NWA.mjs +85 -0
  144. package/dist/chunk-IIDZ5WUX.js +61 -0
  145. package/dist/chunk-IR74FJHU.js +2332 -0
  146. package/dist/chunk-IRVFYAKP.mjs +100 -0
  147. package/dist/{chunk-XBL3TMPC.mjs → chunk-IZDWAL53.mjs} +1795 -3287
  148. package/dist/chunk-J2KZXIU3.js +51 -0
  149. package/dist/chunk-J2U6PJSO.js +91 -0
  150. package/dist/chunk-J5AJNY2N.js +283 -0
  151. package/dist/chunk-J6KQZ4FO.mjs +821 -0
  152. package/dist/{chunk-OWW5GUSB.js → chunk-JGBCIKJV.js} +7 -6
  153. package/dist/chunk-JKGTBMU7.mjs +25 -0
  154. package/dist/chunk-JR3TNEQC.js +422 -0
  155. package/dist/chunk-JURRXY2J.mjs +29 -0
  156. package/dist/chunk-K3HW5I2A.mjs +317 -0
  157. package/dist/chunk-K46SMZ66.mjs +103 -0
  158. package/dist/chunk-K4UDGE3Z.mjs +6 -0
  159. package/dist/chunk-KDQOR4QQ.mjs +350 -0
  160. package/dist/chunk-KDTVOLHI.mjs +288 -0
  161. package/dist/chunk-KGHJH5KJ.mjs +35 -0
  162. package/dist/chunk-KIZOA5LX.mjs +140 -0
  163. package/dist/chunk-KK6HYVBI.mjs +242 -0
  164. package/dist/chunk-KMKWGXMK.js +856 -0
  165. package/dist/chunk-KPA6K5IB.js +80 -0
  166. package/dist/chunk-KU7O4IXU.mjs +260 -0
  167. package/dist/chunk-KVFNRJOR.mjs +11142 -0
  168. package/dist/chunk-KZJRSXHK.js +2432 -0
  169. package/dist/chunk-LHWPRUJL.js +79 -0
  170. package/dist/chunk-LIV3KXJG.mjs +369 -0
  171. package/dist/chunk-LKV4LACG.js +21 -0
  172. package/dist/chunk-LUY45X3U.mjs +263 -0
  173. package/dist/chunk-LYEZZEEF.mjs +17 -0
  174. package/dist/chunk-M5EXQZYY.mjs +1519 -0
  175. package/dist/chunk-ME6HGG4I.mjs +1338 -0
  176. package/dist/chunk-MEXP6DA6.js +31 -0
  177. package/dist/chunk-MG52AW3H.js +902 -0
  178. package/dist/chunk-MIPO6F72.js +334 -0
  179. package/dist/{chunk-5QW7CQBA.js → chunk-MKIJQL5Q.js} +211 -321
  180. package/dist/chunk-MN3YETVN.mjs +17 -0
  181. package/dist/chunk-MOBSBXVE.mjs +2391 -0
  182. package/dist/chunk-MOMOZEUM.mjs +88 -0
  183. package/dist/chunk-MRFUNRAP.js +62 -0
  184. package/dist/chunk-MTIHEW2M.js +433 -0
  185. package/dist/chunk-N4RGGDEL.mjs +73 -0
  186. package/dist/chunk-NH654HAT.js +10 -0
  187. package/dist/chunk-NHJUGZUR.mjs +253 -0
  188. package/dist/chunk-NMQT4HG3.mjs +757 -0
  189. package/dist/chunk-NPSYB6DC.mjs +906 -0
  190. package/dist/chunk-NW2GPMSO.js +857 -0
  191. package/dist/chunk-NXKQOQ6L.js +76 -0
  192. package/dist/chunk-NXLAZIJZ.js +309 -0
  193. package/dist/chunk-NYWNA5CF.js +148 -0
  194. package/dist/chunk-NZTKLY2W.js +1442 -0
  195. package/dist/chunk-O2ICABUD.js +36 -0
  196. package/dist/chunk-OIVVQQ22.js +862 -0
  197. package/dist/chunk-OKC2B4O3.mjs +312 -0
  198. package/dist/chunk-OLWFPDBK.js +2220 -0
  199. package/dist/chunk-OMTVH334.js +3779 -0
  200. package/dist/chunk-OQRVEM56.mjs +362 -0
  201. package/dist/chunk-OXMIBOD4.js +337 -0
  202. package/dist/chunk-PBL6YL5L.mjs +288 -0
  203. package/dist/chunk-PDOELNNQ.js +97 -0
  204. package/dist/chunk-PDQJY2GZ.js +136 -0
  205. package/dist/chunk-PKOZXD2Q.js +1274 -0
  206. package/dist/chunk-PPF2BYFL.mjs +2191 -0
  207. package/dist/chunk-PQTQKNKD.js +539 -0
  208. package/dist/chunk-PRSR4FAV.mjs +81 -0
  209. package/dist/chunk-PTRNO5UD.js +95 -0
  210. package/dist/chunk-Q2Y3VMKH.js +2000 -0
  211. package/dist/chunk-QCZOE65N.js +96 -0
  212. package/dist/chunk-QDYFLATW.mjs +52 -0
  213. package/dist/chunk-QQABGCMM.js +22 -0
  214. package/dist/chunk-QS6TRHMR.js +345 -0
  215. package/dist/chunk-R56P64LB.mjs +208 -0
  216. package/dist/chunk-RCQ2MPBV.js +428 -0
  217. package/dist/chunk-RFVRPYR2.mjs +856 -0
  218. package/dist/chunk-RKBLPGPV.js +11521 -0
  219. package/dist/chunk-RM2V4IND.mjs +327 -0
  220. package/dist/chunk-RQXN5A34.mjs +613 -0
  221. package/dist/chunk-RUVGVNOF.mjs +2687 -0
  222. package/dist/chunk-SAFJIGYB.mjs +165 -0
  223. package/dist/chunk-SKQFLBDD.js +263 -0
  224. package/dist/chunk-SMK6JU2F.mjs +2092 -0
  225. package/dist/{chunk-UVRPC2P7.js → chunk-SNNEOS5Z.js} +1984 -3476
  226. package/dist/chunk-SPCRQ6NO.mjs +1246 -0
  227. package/dist/chunk-SWX4SALA.mjs +19 -0
  228. package/dist/{chunk-JVODCGFP.mjs → chunk-SYEO2WV4.mjs} +128 -238
  229. package/dist/chunk-T2QQMX2N.js +10 -0
  230. package/dist/chunk-T3AFF3L7.mjs +57 -0
  231. package/dist/chunk-T6Z2EXYL.js +712 -0
  232. package/dist/chunk-T7LOXGYX.js +118 -0
  233. package/dist/chunk-TJCAE7RC.mjs +1315 -0
  234. package/dist/chunk-TJI3K6RP.js +137 -0
  235. package/dist/chunk-TL2SVO4P.mjs +55 -0
  236. package/dist/chunk-TM63CYGN.mjs +399 -0
  237. package/dist/chunk-TU5RYTYU.mjs +13 -0
  238. package/dist/chunk-TVJZ4GPS.js +1553 -0
  239. package/dist/chunk-TWM6DLYF.js +371 -0
  240. package/dist/chunk-U63OC4TQ.js +30 -0
  241. package/dist/{chunk-L5GKVQVJ.js → chunk-U6BVSJZ6.js} +25 -57
  242. package/dist/chunk-U6UVWEAK.mjs +792 -0
  243. package/dist/chunk-UCEPNO6N.mjs +11048 -0
  244. package/dist/{chunk-ANT574FD.js → chunk-UCR5HRYM.js} +74 -105
  245. package/dist/chunk-UG5BTOTF.mjs +334 -0
  246. package/dist/chunk-UGH37BQW.mjs +157 -0
  247. package/dist/chunk-V7ZRH3PY.mjs +271 -0
  248. package/dist/chunk-VBGHBL3E.mjs +1394 -0
  249. package/dist/chunk-VRBDAS5I.js +920 -0
  250. package/dist/chunk-VVE3Y76O.js +230 -0
  251. package/dist/chunk-W65JIRI4.mjs +1182 -0
  252. package/dist/chunk-WHYKAT7G.js +62 -0
  253. package/dist/{chunk-YOIVZ6OA.mjs → chunk-WIZRUIZB.mjs} +25 -57
  254. package/dist/chunk-WKWTDZS7.js +385 -0
  255. package/dist/chunk-WLMINRC4.mjs +78 -0
  256. package/dist/chunk-WOF3AD3J.js +22 -0
  257. package/dist/chunk-WWKMOA76.js +1262 -0
  258. package/dist/chunk-X5A5FOWW.js +615 -0
  259. package/dist/chunk-X6CN6KQF.mjs +192 -0
  260. package/dist/chunk-XD2PMH46.mjs +517 -0
  261. package/dist/chunk-XJA2NGTI.mjs +88 -0
  262. package/dist/chunk-XJIHN3BY.mjs +8 -0
  263. package/dist/chunk-XK6UDWJS.js +203 -0
  264. package/dist/chunk-XPG3N5CF.mjs +415 -0
  265. package/dist/chunk-XVZ2NKSU.mjs +74 -0
  266. package/dist/chunk-XYP45OLE.js +117 -0
  267. package/dist/chunk-XZSDGZX6.mjs +301 -0
  268. package/dist/chunk-Y2EMGN4T.mjs +120 -0
  269. package/dist/chunk-Y3XWP5XW.mjs +298 -0
  270. package/dist/chunk-Y4K22JL6.js +228 -0
  271. package/dist/chunk-Y65LXQGA.mjs +3164 -0
  272. package/dist/chunk-Y66WVMO5.mjs +87 -0
  273. package/dist/chunk-Y7JWLB25.mjs +7280 -0
  274. package/dist/chunk-YCDXAJKU.js +175 -0
  275. package/dist/chunk-YRDQCCIS.js +152 -0
  276. package/dist/chunk-YV52DGSA.js +111 -0
  277. package/dist/chunk-YXGZQPUD.js +94 -0
  278. package/dist/chunk-Z3A3AFVU.mjs +102 -0
  279. package/dist/chunk-ZCY6YKKP.mjs +475 -0
  280. package/dist/chunk-ZEQHXVU5.js +215 -0
  281. package/dist/chunk-ZF7JCXCI.js +284 -0
  282. package/dist/chunk-ZJBRUH6V.js +29 -0
  283. package/dist/chunk-ZMIL4ZOA.js +365 -0
  284. package/dist/chunk-ZR5ULMN2.mjs +337 -0
  285. package/dist/chunk-ZXREOYOW.js +87 -0
  286. package/dist/{client-BSP9U1O1.d.mts → client-CX_WR0-J.d.mts} +2 -2
  287. package/dist/client-Dytx_ZTC.d.ts +230 -0
  288. package/dist/{client-B878xeAP.d.ts → client-dqOhP9Nc.d.ts} +2 -2
  289. package/dist/client-hTKbCuhG.d.mts +230 -0
  290. package/dist/clock-B-UAjkKa.d.mts +5 -0
  291. package/dist/clock-B-UAjkKa.d.ts +5 -0
  292. package/dist/config-BlXQluJR.d.mts +36 -0
  293. package/dist/config-BlXQluJR.d.ts +36 -0
  294. package/dist/courier-Cnn-edJ4.d.ts +95 -0
  295. package/dist/courier-FmGfkvIN.d.mts +95 -0
  296. package/dist/crowd-DdHFbqKK.d.ts +186 -0
  297. package/dist/crowd-hOVSAmA3.d.mts +186 -0
  298. package/dist/danfo-BEBapFlX.d.mts +146 -0
  299. package/dist/danfo-UQ_PTIIx.d.ts +146 -0
  300. package/dist/{elements-Bty6Qs_N.d.mts → elements-DdsRig-2.d.mts} +1548 -257
  301. package/dist/{elements-Bty6Qs_N.d.ts → elements-DdsRig-2.d.ts} +1548 -257
  302. package/dist/engines/godot.d.mts +56 -0
  303. package/dist/engines/godot.d.ts +56 -0
  304. package/dist/engines/godot.js +28 -0
  305. package/dist/engines/godot.mjs +3 -0
  306. package/dist/engines/wasm.d.mts +11 -0
  307. package/dist/engines/wasm.d.ts +11 -0
  308. package/dist/engines/wasm.js +178 -0
  309. package/dist/engines/wasm.mjs +176 -0
  310. package/dist/fallback-CrG_lTFk.d.mts +270 -0
  311. package/dist/fallback-CrG_lTFk.d.ts +270 -0
  312. package/dist/fallback-KDB4Y2CE.mjs +6 -0
  313. package/dist/fallback-Y26TQENE.js +19 -0
  314. package/dist/features-CZB4rmcD.d.mts +118 -0
  315. package/dist/features-CZB4rmcD.d.ts +118 -0
  316. package/dist/fit-BWiE7rgA.d.mts +44 -0
  317. package/dist/fit-DK0oT7zO.d.ts +44 -0
  318. package/dist/five-a-side-Bv1AOUy3.d.mts +115 -0
  319. package/dist/five-a-side-EC51SJY1.d.ts +115 -0
  320. package/dist/fluid-ARr0qUIL.d.ts +939 -0
  321. package/dist/fluid-DLlEj2cs.d.mts +939 -0
  322. package/dist/game/conformance.d.mts +84 -0
  323. package/dist/game/conformance.d.ts +84 -0
  324. package/dist/game/conformance.js +1025 -0
  325. package/dist/game/conformance.mjs +994 -0
  326. package/dist/game/heap.d.mts +40 -0
  327. package/dist/game/heap.d.ts +40 -0
  328. package/dist/game/heap.js +48 -0
  329. package/dist/game/heap.mjs +7 -0
  330. package/dist/game/kit/canvas.d.mts +240 -0
  331. package/dist/game/kit/canvas.d.ts +240 -0
  332. package/dist/game/kit/canvas.js +3566 -0
  333. package/dist/game/kit/canvas.mjs +1039 -0
  334. package/dist/game/kit/courier.d.mts +17 -0
  335. package/dist/game/kit/courier.d.ts +17 -0
  336. package/dist/game/kit/courier.js +66 -0
  337. package/dist/game/kit/courier.mjs +49 -0
  338. package/dist/game/kit/danfo.d.mts +11 -0
  339. package/dist/game/kit/danfo.d.ts +11 -0
  340. package/dist/game/kit/danfo.js +109 -0
  341. package/dist/game/kit/danfo.mjs +44 -0
  342. package/dist/game/kit/engine.d.mts +29 -0
  343. package/dist/game/kit/engine.d.ts +29 -0
  344. package/dist/game/kit/engine.js +183 -0
  345. package/dist/game/kit/engine.mjs +30 -0
  346. package/dist/game/kit/five-a-side.d.mts +11 -0
  347. package/dist/game/kit/five-a-side.d.ts +11 -0
  348. package/dist/game/kit/five-a-side.js +86 -0
  349. package/dist/game/kit/five-a-side.mjs +41 -0
  350. package/dist/game/kit/frontier.d.mts +344 -0
  351. package/dist/game/kit/frontier.d.ts +344 -0
  352. package/dist/game/kit/frontier.js +435 -0
  353. package/dist/game/kit/frontier.mjs +14 -0
  354. package/dist/game/kit/genesis.d.mts +752 -0
  355. package/dist/game/kit/genesis.d.ts +752 -0
  356. package/dist/game/kit/genesis.js +380 -0
  357. package/dist/game/kit/genesis.mjs +15 -0
  358. package/dist/game/kit/ludo.d.mts +15 -0
  359. package/dist/game/kit/ludo.d.ts +15 -0
  360. package/dist/game/kit/ludo.js +87 -0
  361. package/dist/game/kit/ludo.mjs +42 -0
  362. package/dist/game/kit/runner.d.mts +12 -0
  363. package/dist/game/kit/runner.d.ts +12 -0
  364. package/dist/game/kit/runner.js +83 -0
  365. package/dist/game/kit/runner.mjs +46 -0
  366. package/dist/game/kit/shootout.d.mts +13 -0
  367. package/dist/game/kit/shootout.d.ts +13 -0
  368. package/dist/game/kit/shootout.js +122 -0
  369. package/dist/game/kit/shootout.mjs +57 -0
  370. package/dist/game/kit/slots.d.mts +392 -0
  371. package/dist/game/kit/slots.d.ts +392 -0
  372. package/dist/game/kit/slots.js +215 -0
  373. package/dist/game/kit/slots.mjs +6 -0
  374. package/dist/game/kit/tycoon.d.mts +16 -0
  375. package/dist/game/kit/tycoon.d.ts +16 -0
  376. package/dist/game/kit/tycoon.js +145 -0
  377. package/dist/game/kit/tycoon.mjs +44 -0
  378. package/dist/game/kit/word.d.mts +11 -0
  379. package/dist/game/kit/word.d.ts +11 -0
  380. package/dist/game/kit/word.js +78 -0
  381. package/dist/game/kit/word.mjs +41 -0
  382. package/dist/game/kit/worlds.d.mts +18 -0
  383. package/dist/game/kit/worlds.d.ts +18 -0
  384. package/dist/game/kit/worlds.js +74 -0
  385. package/dist/game/kit/worlds.mjs +49 -0
  386. package/dist/game/kit.d.mts +53 -0
  387. package/dist/game/kit.d.ts +53 -0
  388. package/dist/game/kit.js +2610 -0
  389. package/dist/game/kit.mjs +101 -0
  390. package/dist/game/prepared.d.mts +14 -0
  391. package/dist/game/prepared.d.ts +14 -0
  392. package/dist/game/prepared.js +81 -0
  393. package/dist/game/prepared.mjs +32 -0
  394. package/dist/game-Bx8onkhX.d.mts +1451 -0
  395. package/dist/game-fgQy2YIm.d.ts +1451 -0
  396. package/dist/game-theme-CBTw1b_d.d.mts +35 -0
  397. package/dist/game-theme-Dg-ict5A.d.ts +35 -0
  398. package/dist/game.d.mts +3546 -0
  399. package/dist/game.d.ts +3546 -0
  400. package/dist/game.js +4455 -0
  401. package/dist/game.mjs +50 -0
  402. package/dist/graphics-C6YjWYvP.d.ts +5 -0
  403. package/dist/graphics-Dk2yQnYN.d.mts +5 -0
  404. package/dist/guest-DrsA00XD.d.mts +732 -0
  405. package/dist/guest-wIdfoT05.d.ts +732 -0
  406. package/dist/hit-stop-BKkVwTq7.d.mts +43 -0
  407. package/dist/hit-stop-D-8pPYnM.d.ts +43 -0
  408. package/dist/hot-Crn9XpHJ.d.ts +29 -0
  409. package/dist/hot-DH3nOhQD.d.mts +29 -0
  410. package/dist/{index-CQStGb3B.d.mts → index-6gkHMGAq.d.mts} +2 -2
  411. package/dist/index-B8ybCKJI.d.ts +41 -0
  412. package/dist/{index-DJwXmoaP.d.ts → index-B98Xac8e.d.ts} +2 -2
  413. package/dist/{index-B7oA_1XI.d.ts → index-B_ByTtIT.d.ts} +2 -2
  414. package/dist/index-DHjNHb1c.d.mts +41 -0
  415. package/dist/{index-DhUSTAhT.d.mts → index-DbAN_VQE.d.mts} +2 -2
  416. package/dist/index.d.mts +134 -24
  417. package/dist/index.d.ts +134 -24
  418. package/dist/index.js +407 -248
  419. package/dist/index.mjs +184 -58
  420. package/dist/interactives-authoring.d.mts +231 -0
  421. package/dist/interactives-authoring.d.ts +231 -0
  422. package/dist/interactives-authoring.js +1743 -0
  423. package/dist/interactives-authoring.mjs +1704 -0
  424. package/dist/interactives-canvas.global.js +148 -0
  425. package/dist/interactives-guest.d.mts +20 -0
  426. package/dist/interactives-guest.d.ts +20 -0
  427. package/dist/interactives-guest.js +63 -0
  428. package/dist/interactives-guest.json +1 -0
  429. package/dist/interactives-guest.mjs +61 -0
  430. package/dist/interactives-jsc.global.js +9357 -0
  431. package/dist/interactives-meters.d.mts +93 -0
  432. package/dist/interactives-meters.d.ts +93 -0
  433. package/dist/interactives-meters.js +252 -0
  434. package/dist/interactives-meters.mjs +68 -0
  435. package/dist/interactives-production.d.mts +430 -0
  436. package/dist/interactives-production.d.ts +430 -0
  437. package/dist/interactives-production.js +1231 -0
  438. package/dist/interactives-production.mjs +1170 -0
  439. package/dist/interactives-record.d.mts +112 -0
  440. package/dist/interactives-record.d.ts +112 -0
  441. package/dist/interactives-record.js +302 -0
  442. package/dist/interactives-record.mjs +295 -0
  443. package/dist/interactives-runtime.d.mts +61 -0
  444. package/dist/interactives-runtime.d.ts +61 -0
  445. package/dist/interactives-runtime.js +442 -0
  446. package/dist/interactives-runtime.mjs +25 -0
  447. package/dist/interactives-studio-kernel.global.js +1 -0
  448. package/dist/interactives-studio.d.mts +806 -0
  449. package/dist/interactives-studio.d.ts +806 -0
  450. package/dist/interactives-studio.js +5741 -0
  451. package/dist/interactives-studio.mjs +5651 -0
  452. package/dist/interactives-tick.d.mts +90 -0
  453. package/dist/interactives-tick.d.ts +90 -0
  454. package/dist/interactives-tick.js +203 -0
  455. package/dist/interactives-tick.mjs +6 -0
  456. package/dist/interactives-web.d.mts +762 -0
  457. package/dist/interactives-web.d.ts +762 -0
  458. package/dist/interactives-web.js +5000 -0
  459. package/dist/interactives-web.mjs +4628 -0
  460. package/dist/interactives.d.mts +2430 -0
  461. package/dist/interactives.d.ts +2430 -0
  462. package/dist/interactives.js +5723 -0
  463. package/dist/interactives.mjs +4333 -0
  464. package/dist/juice-CoHxlpKA.d.ts +42 -0
  465. package/dist/juice-DQztFS43.d.mts +42 -0
  466. package/dist/launch-T2f4_Di4.d.mts +151 -0
  467. package/dist/launch-d6oreMzR.d.ts +151 -0
  468. package/dist/library-DXYaMFhi.d.mts +69 -0
  469. package/dist/library-DXYaMFhi.d.ts +69 -0
  470. package/dist/link-BUTqGmyi.d.mts +38 -0
  471. package/dist/link-BUTqGmyi.d.ts +38 -0
  472. package/dist/lint.js +104 -204
  473. package/dist/lint.mjs +103 -203
  474. package/dist/local-D8_I6UeL.d.mts +6967 -0
  475. package/dist/local-VZkqsCzR.d.ts +6967 -0
  476. package/dist/lockstep-BLf6dglI.d.mts +321 -0
  477. package/dist/lockstep-D50Ia0JW.d.ts +321 -0
  478. package/dist/ludo-B8ClkDqr.d.ts +205 -0
  479. package/dist/ludo-BOuohQ-M.d.mts +205 -0
  480. package/dist/mock/cli.mjs +200 -56
  481. package/dist/mock/library.js +200 -56
  482. package/dist/mock/library.mjs +200 -56
  483. package/dist/mock/msw.js +200 -56
  484. package/dist/mock/msw.mjs +200 -56
  485. package/dist/native-BodxSh03.d.mts +16 -0
  486. package/dist/native-DUHMT8gA.d.ts +16 -0
  487. package/dist/network-ZXLD7l1b.d.mts +19 -0
  488. package/dist/network-ZXLD7l1b.d.ts +19 -0
  489. package/dist/online-XeymeM9s.d.ts +381 -0
  490. package/dist/online-d7W_Al9a.d.mts +381 -0
  491. package/dist/params-DxFb5G_U.d.mts +155 -0
  492. package/dist/params-DxFb5G_U.d.ts +155 -0
  493. package/dist/play-BRRlfLhX.d.ts +940 -0
  494. package/dist/play-ClrMd_e8.d.mts +940 -0
  495. package/dist/policy-CCw8tXLm.d.mts +3078 -0
  496. package/dist/policy-CMqOSQIu.d.ts +3078 -0
  497. package/dist/ports-B_0v_P3A.d.mts +13 -0
  498. package/dist/ports-CGU_3e_0.d.ts +13 -0
  499. package/dist/prefetch-BHnicOQj.d.ts +117 -0
  500. package/dist/prefetch-CBXgYacv.d.mts +117 -0
  501. package/dist/{price-CSztR02F.d.mts → price-BOzexBww.d.mts} +1 -1
  502. package/dist/{price-C_vasx9A.d.ts → price-C1h9sPxE.d.ts} +1 -1
  503. package/dist/protocol-C8qbpUbT.d.mts +242 -0
  504. package/dist/protocol-C8qbpUbT.d.ts +242 -0
  505. package/dist/rapier-AZHT4YI7.js +7886 -0
  506. package/dist/rapier-ODEPCQA6.mjs +7792 -0
  507. package/dist/react.d.mts +157 -15
  508. package/dist/react.d.ts +157 -15
  509. package/dist/react.js +5564 -5904
  510. package/dist/react.mjs +5451 -5808
  511. package/dist/runner-CQcLL7By.d.ts +189 -0
  512. package/dist/runner-D46Yj-wE.d.mts +189 -0
  513. package/dist/runtime-BRWfkf_q.d.mts +51 -0
  514. package/dist/runtime-DyuBMkKM.d.ts +51 -0
  515. package/dist/scheduling-D2ajXpMC.d.ts +224 -0
  516. package/dist/scheduling-DSRbbaZb.d.mts +224 -0
  517. package/dist/schema-BrWxzKp6.d.mts +63 -0
  518. package/dist/schema-BrWxzKp6.d.ts +63 -0
  519. package/dist/server/evict.js +34 -37
  520. package/dist/server/evict.mjs +34 -37
  521. package/dist/server/tanstack.d.mts +49 -3
  522. package/dist/server/tanstack.d.ts +49 -3
  523. package/dist/server/tanstack.js +169 -117
  524. package/dist/server/tanstack.mjs +166 -118
  525. package/dist/{server-Dckg4Vdr.d.ts → server-D29IIuDV.d.ts} +136 -130
  526. package/dist/{server-B6dW7-Lj.d.mts → server-DQMWPnc8.d.mts} +136 -130
  527. package/dist/server.d.mts +45 -5
  528. package/dist/server.d.ts +45 -5
  529. package/dist/server.js +171 -227
  530. package/dist/server.mjs +165 -225
  531. package/dist/session-grant-CJ27DwrT.d.mts +19 -0
  532. package/dist/session-grant-CJ27DwrT.d.ts +19 -0
  533. package/dist/shootout-BJZeX6FG.d.ts +140 -0
  534. package/dist/shootout-tcZd1Rxt.d.mts +140 -0
  535. package/dist/state-replica-stMtdkVD.d.mts +42 -0
  536. package/dist/state-replica-stMtdkVD.d.ts +42 -0
  537. package/dist/studio-CowqWqez.d.mts +14 -0
  538. package/dist/studio-CowqWqez.d.ts +14 -0
  539. package/dist/styles.css +1 -1
  540. package/dist/template-AhCdB1kW.d.mts +190 -0
  541. package/dist/template-BkEGVTQj.d.ts +190 -0
  542. package/dist/terrain-BMxEc6Oc.d.ts +429 -0
  543. package/dist/terrain-C-XC1Oui.d.mts +429 -0
  544. package/dist/testing/msw.d.mts +28 -4
  545. package/dist/testing/msw.d.ts +28 -4
  546. package/dist/testing/msw.js +15 -21
  547. package/dist/testing/msw.mjs +15 -21
  548. package/dist/testing/suite.d.mts +6 -5
  549. package/dist/testing/suite.d.ts +6 -5
  550. package/dist/testing/suite.js +89 -124
  551. package/dist/testing/suite.mjs +81 -116
  552. package/dist/testing.d.mts +27 -1227
  553. package/dist/testing.d.ts +27 -1227
  554. package/dist/testing.js +127 -131
  555. package/dist/testing.mjs +19 -23
  556. package/dist/tick-transport-C8QEh8Uw.d.mts +50 -0
  557. package/dist/tick-transport-UjHY3xK1.d.ts +50 -0
  558. package/dist/timeline-protocol-hp6e8zFB.d.mts +47 -0
  559. package/dist/timeline-protocol-hp6e8zFB.d.ts +47 -0
  560. package/dist/tokens-DhanQRQS.d.mts +21 -0
  561. package/dist/tokens-K8yxwd6G.d.ts +21 -0
  562. package/dist/tree-C-Io2Hbx.d.mts +35 -0
  563. package/dist/tree-CP_qSW4H.d.ts +35 -0
  564. package/dist/tycoon-B5KHk2Xx.d.mts +255 -0
  565. package/dist/tycoon-hmHo-3HX.d.ts +255 -0
  566. package/dist/types-BQkxPwZP.d.mts +219 -0
  567. package/dist/types-D_f6UUxM.d.ts +219 -0
  568. package/dist/ui-DwHicuFv.d.mts +563 -0
  569. package/dist/ui-hi7S2YcH.d.ts +563 -0
  570. package/dist/{sign-in-DQlIdqsi.d.mts → url-52ndUruG.d.mts} +15 -1
  571. package/dist/{sign-in-DQlIdqsi.d.ts → url-52ndUruG.d.ts} +15 -1
  572. package/dist/utils.d.mts +3 -3
  573. package/dist/utils.d.ts +3 -3
  574. package/dist/utils.js +37 -37
  575. package/dist/utils.mjs +4 -4
  576. package/dist/vars-Dc_PrhBK.d.mts +511 -0
  577. package/dist/vars-Dc_PrhBK.d.ts +511 -0
  578. package/dist/vm-IUARFFAI.mjs +63 -0
  579. package/dist/vm-N7L6MGGH.js +65 -0
  580. package/dist/weave-delivery-CW-Kstut.d.mts +360 -0
  581. package/dist/weave-delivery-CW-Kstut.d.ts +360 -0
  582. package/dist/web-Dss74a7v.d.ts +883 -0
  583. package/dist/web-f9ZQPoyw.d.mts +883 -0
  584. package/dist/web-transport-C7MkBL0a.d.ts +19 -0
  585. package/dist/web-transport-aYEqXMd9.d.mts +19 -0
  586. package/dist/weight-CPGjsgjV.d.ts +92 -0
  587. package/dist/weight-tF1ODR1p.d.mts +92 -0
  588. package/dist/word-BcX9Jcmv.d.mts +70 -0
  589. package/dist/word-C7sVPLHm.d.ts +70 -0
  590. package/dist/world-PvILHDR1.d.ts +2285 -0
  591. package/dist/world-qekkXjJv.d.mts +2285 -0
  592. package/dist/worlds-Br2Pb0Cs.d.ts +109 -0
  593. package/dist/worlds-D5ydYr7d.d.mts +109 -0
  594. package/engines/c/cimplify.h +108 -0
  595. package/engines/c/cimplify.lib.js +11 -0
  596. package/engines/godot/addons/cimplify/cimplify.gd +97 -0
  597. package/engines/rust/interactives-ctx/Cargo.toml +9 -0
  598. package/engines/rust/interactives-ctx/src/lib.rs +189 -0
  599. package/package.json +189 -3
  600. package/vendor/rapier3d-compat/LICENSE +201 -0
  601. package/vendor/rapier3d-compat/PATCHES.md +61 -0
  602. package/dist/chunk-2P4KXFB6.js +0 -274
  603. package/dist/chunk-3G6RQLXK.mjs +0 -21
  604. package/dist/chunk-3V4DVXV3.mjs +0 -254
  605. package/dist/chunk-EDK3LNM6.js +0 -2436
  606. package/dist/chunk-F7J3HK27.js +0 -4549
  607. package/dist/chunk-U4MW6PYU.mjs +0 -23
  608. package/dist/chunk-XREIZ56K.js +0 -26
@@ -0,0 +1,1338 @@
1
+ import { TARGET_HZ, FLOW_WORDS, PrefetchLayer, FLOW_BACKLOG, FLOW_DELIVERED, SMOOTH_SHARE, STUTTER_SHARE, HOT_BUSY_SHARE, HOT_PRESSURE, WARM_BUSY_SHARE, WARM_PRESSURE, isCalibrated, passCauses, MEMORY_CEILING_BYTES, rankCauses, TIGHT_MEMORY_SHARE, calibrationFor } from './chunk-5BYDGGWO.mjs';
2
+ import { HEAP_MEMORY } from './chunk-7SXOHAIR.mjs';
3
+ import { MediumVolume } from './chunk-ATAWRACV.mjs';
4
+ import { entityIndex, NO_ENTITY } from './chunk-T3AFF3L7.mjs';
5
+ import { SH_COEFFICIENT_FLOATS, GPU_PASS_NAMES, createGpuStats } from './chunk-TL2SVO4P.mjs';
6
+ import { FRAME_SECONDS_SLOT } from './chunk-IDLW4NWA.mjs';
7
+ import { SCENERY_REGISTER, createVectorSurfaceStats } from './chunk-E65WCTIG.mjs';
8
+ import './chunk-K4UDGE3Z.mjs';
9
+ import { reusingDefinitions } from './chunk-K46SMZ66.mjs';
10
+ import { GameError } from './chunk-XJIHN3BY.mjs';
11
+
12
+ // src/game/ecs/component.ts
13
+ var SIZE = 0, VERSION = 1, STORE_COUNTERS = 2, nextComponentId = 0, definedByName = /* @__PURE__ */ new Map();
14
+ function sameSchema(a, b) {
15
+ let keys = Object.keys(a);
16
+ if (keys.length !== Object.keys(b).length) return false;
17
+ for (let key of keys) {
18
+ let x = a[key], y = b[key];
19
+ if (typeof x == "string" || typeof y == "string") {
20
+ if (x !== y) return false;
21
+ } else if (y === void 0 || x[0] !== y[0] || x[1] !== y[1]) return false;
22
+ }
23
+ return true;
24
+ }
25
+ function defineComponent(name, schema) {
26
+ let existing = definedByName.get(name);
27
+ if (existing !== void 0 && reusingDefinitions() && sameSchema(existing.schema, schema)) return existing;
28
+ let type = { id: nextComponentId++, name, schema };
29
+ return definedByName.set(name, type), type;
30
+ }
31
+ function fieldArity(spec) {
32
+ return typeof spec == "string" ? 1 : spec[1];
33
+ }
34
+ function fieldScalar(spec) {
35
+ return typeof spec == "string" ? spec : spec[0];
36
+ }
37
+ var ComponentStore = class {
38
+ constructor(type, capacity, entityCapacity, memory = HEAP_MEMORY) {
39
+ this.counters = new Uint32Array((2));
40
+ this.type = type, this.capacity = capacity, this.entities = memory.allocate("u32", capacity), this.sparse = memory.allocate("i32", entityCapacity).fill(-1);
41
+ let keys = Object.keys(type.schema);
42
+ this.arrays = [], this.arities = new Int32Array(keys.length);
43
+ let fields = {};
44
+ for (let i = 0; i < keys.length; i++) {
45
+ let spec = type.schema[keys[i]], arity = fieldArity(spec), array = memory.allocate(fieldScalar(spec), capacity * arity);
46
+ this.arrays.push(array), this.arities[i] = arity, fields[keys[i]] = array;
47
+ }
48
+ this.fields = fields, this.views = [this.counters, this.entities, this.sparse, ...this.arrays];
49
+ }
50
+ get count() {
51
+ return this.counters[(0)];
52
+ }
53
+ get version() {
54
+ return this.counters[(1)];
55
+ }
56
+ rollbackViews() {
57
+ return this.views;
58
+ }
59
+ row(entity) {
60
+ let index = entityIndex(entity);
61
+ if (index >= this.sparse.length) return -1;
62
+ let row = this.sparse[index];
63
+ return row !== -1 && this.entities[row] === entity ? row : -1;
64
+ }
65
+ has(entity) {
66
+ return this.row(entity) !== -1;
67
+ }
68
+ require(entity) {
69
+ let row = this.row(entity);
70
+ if (row === -1)
71
+ throw new GameError("missing_component", `entity ${entity} has no ${this.type.name}`);
72
+ return row;
73
+ }
74
+ add(entity) {
75
+ let existing = this.row(entity);
76
+ if (existing !== -1) return existing;
77
+ let c = this.counters;
78
+ if (c[(0)] >= this.capacity)
79
+ throw new GameError(
80
+ "capacity_exceeded",
81
+ `component ${this.type.name} capacity ${this.capacity} reached`
82
+ );
83
+ let row = c[(0)]++;
84
+ this.entities[row] = entity, this.sparse[entityIndex(entity)] = row;
85
+ for (let i = 0; i < this.arrays.length; i++) {
86
+ let arity = this.arities[i];
87
+ this.arrays[i].fill(0, row * arity, row * arity + arity);
88
+ }
89
+ return c[(1)]++, row;
90
+ }
91
+ remove(entity) {
92
+ let row = this.row(entity);
93
+ if (row === -1) return false;
94
+ let c = this.counters, last = --c[(0)];
95
+ if (row !== last) {
96
+ let moved = this.entities[last];
97
+ this.entities[row] = moved, this.sparse[entityIndex(moved)] = row;
98
+ for (let i = 0; i < this.arrays.length; i++) {
99
+ let arity = this.arities[i];
100
+ this.arrays[i].copyWithin(row * arity, last * arity, last * arity + arity);
101
+ }
102
+ }
103
+ return this.sparse[entityIndex(entity)] = -1, c[(1)]++, true;
104
+ }
105
+ entityAt(row) {
106
+ return this.entities[row];
107
+ }
108
+ };
109
+
110
+ // src/game/scenery/scenery.ts
111
+ var DEFAULT_MOTION_OFFSET = ["dx", "dy", "dz"], DEFAULT_MOTION_REST = ["rx", "ry", "rz"], MILLIMETRES_PER_METRE = 1e3, NO_RIG = 0, SCENERY_MANIFEST_MAGIC = 1297109827, SCENERY_MANIFEST_VERSION = 1, SCENERY_MANIFEST_VERSION_PARTS = 2, SCENERY_PART_WHOLE = 255, SCENERY_PART_COARSE = 0, SCENERY_PART_MIDDLE = 1, SCENERY_PART_FINE = 2, PART_FIELD = 20, PART_MASK = 255, GROUP_SHIFT = 8, SCENERY_LEVEL_STEP = 3, SCENERY_CHUNK_EXTENSION = ".cspl", HEADER_BYTES = 32, ENTRY_BYTES = 80, DIGEST_OFFSET = 48, DIGEST_BYTES = 32, VERSION_FIELD = 4, COUNT_FIELD = 8, CELL_SIZE_FIELD = 12, ORIGIN_X_FIELD = 16, ORIGIN_Z_FIELD = 20, COLS_FIELD = 24, ROWS_FIELD = 28, KIB = 1024, HEX_RADIX = 16, BYTE_VALUES = 256, ABSOLUTE = /^[a-z][a-z0-9+.-]*:/i, HEX = Array.from({ length: (256) }, (_, i) => i.toString((16)).padStart(2, "0")), CLOSED_REGISTERS = new Uint32Array(20);
112
+ function sceneryPartDrawLevel(part) {
113
+ return part === (1) ? 1 : part === (2) ? 0 : 2;
114
+ }
115
+ function sceneryPartReach(part, radii) {
116
+ let level = sceneryPartDrawLevel(part);
117
+ return level === 0 ? radii.near : level === 1 ? radii.near * (3) : radii.far;
118
+ }
119
+ function sceneryEntryRows(manifest, count) {
120
+ let rows = Array.from({ length: count }, (_, i) => i), groups = manifest.groups, parts = manifest.parts;
121
+ return groups !== void 0 && parts !== void 0 && rows.sort((a, b) => groups[a] - groups[b] || parts[a] - parts[b] || a - b), Int32Array.from(rows);
122
+ }
123
+ var ENTRY_BYTES_FIELD = 16, ENTRY_MIN_FIELD = 24, BOUND_FLOATS = 6, SCENERY_LOAD_SHARE = 1.1, SCENERY_UNLOAD_SHARE = 1.35, SCENERY_NEED_SHARE = 3, SCENERY_TIER_RADII = [
124
+ { near: 40, far: 600 },
125
+ { near: 25, far: 350 },
126
+ { near: 14, far: 180 }
127
+ ];
128
+ function sceneryTierRadii(tier) {
129
+ return SCENERY_TIER_RADII[Math.min(SCENERY_TIER_RADII.length - 1, Math.max(0, tier))];
130
+ }
131
+ function sceneryPrefetchItems(manifest, paths, radii = SCENERY_TIER_RADII[0]) {
132
+ let items = [], b = manifest.bounds, rows = sceneryEntryRows(manifest, paths.length), start = 0;
133
+ for (; start < rows.length; ) {
134
+ let group = manifest.groups?.[rows[start]] ?? rows[start], end = start + 1;
135
+ for (; end < rows.length && manifest.groups !== void 0 && manifest.groups[rows[end]] === group; ) end++;
136
+ let lo = [1 / 0, 1 / 0, 1 / 0], hi = [-1 / 0, -1 / 0, -1 / 0], levels = [];
137
+ for (let k = start; k < end; k++) {
138
+ let row = rows[k];
139
+ for (let axis = 0; axis < 3; axis++)
140
+ lo[axis] = Math.min(lo[axis], b[row * (6) + axis]), hi[axis] = Math.max(hi[axis], b[row * (6) + 3 + axis]);
141
+ let part = manifest.parts?.[row] ?? (255), fine = part === (1) || part === (2);
142
+ levels.push(fine ? { path: paths[row], bytes: manifest.bytes[row], within: sceneryPartReach(part, radii) * (1.1) } : { path: paths[row], bytes: manifest.bytes[row] });
143
+ }
144
+ let dx = hi[0] - lo[0], dy = hi[1] - lo[1], dz = hi[2] - lo[2];
145
+ items.push({
146
+ center: [(lo[0] + hi[0]) * 0.5, (lo[1] + hi[1]) * 0.5, (lo[2] + hi[2]) * 0.5],
147
+ radius: Math.sqrt(dx * dx + dy * dy + dz * dz) * 0.5,
148
+ bytes: manifest.bytes[rows[start]],
149
+ levels
150
+ }), start = end;
151
+ }
152
+ return items;
153
+ }
154
+ function sceneryFirstView(manifest, paths, view, radius) {
155
+ let items = sceneryPrefetchItems(manifest, paths), near = [];
156
+ for (let item of items) {
157
+ let gap = Math.hypot(item.center[0] - view[0], item.center[1] - view[1], item.center[2] - view[2]) - (item.radius ?? 0);
158
+ gap <= radius && near.push({ path: item.levels[0].path, gap });
159
+ }
160
+ return near.sort((a, b) => a.gap - b.gap || (a.path < b.path ? -1 : 1)), near.map((entry) => entry.path);
161
+ }
162
+ function malformed(reason) {
163
+ return new GameError("invalid_argument", `the scenery manifest is malformed: ${reason}`);
164
+ }
165
+ function digestName(bytes, at) {
166
+ let out = "";
167
+ for (let i = 0; i < (32); i++) out += HEX[bytes[at + i]];
168
+ return out + SCENERY_CHUNK_EXTENSION;
169
+ }
170
+ function parseSceneryManifest(bytes) {
171
+ if (bytes.byteLength < (32)) throw malformed("too short");
172
+ let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
173
+ if (view.getUint32(0, true) !== (1297109827)) throw malformed("not a CSPM file");
174
+ let version = view.getUint32((4), true);
175
+ if (version !== (1) && version !== (2)) throw malformed(`version ${version} is not supported`);
176
+ let count = view.getUint32((8), true);
177
+ if (bytes.byteLength < (32) + count * (80)) throw malformed(`${count} entries do not fit`);
178
+ let chunks = Array.from({ length: count }, (_, i) => digestName(bytes, (32) + i * (80) + (48))), bounds = new Float32Array(count * (6)), sizes = new Uint32Array(count), parts = new Uint8Array(count).fill((255)), groups = new Uint32Array(count);
179
+ for (let i = 0; i < count; i++) {
180
+ let at = (32) + i * (80);
181
+ sizes[i] = view.getUint32(at + (16), true);
182
+ for (let k = 0; k < (6); k++) bounds[i * (6) + k] = view.getFloat32(at + (24) + 4 * k, true);
183
+ if (groups[i] = i, version !== (2)) continue;
184
+ let tag = view.getUint32(at + (20), true), part = tag & (255);
185
+ if (part > (2)) throw malformed(`entry ${i} has part ${part}`);
186
+ parts[i] = part, groups[i] = tag >>> (8);
187
+ }
188
+ return {
189
+ bounds,
190
+ bytes: sizes,
191
+ parts,
192
+ groups,
193
+ grid: {
194
+ cellSize: view.getFloat32((12), true),
195
+ origin: [view.getFloat32((16), true), view.getFloat32((20), true)],
196
+ cols: view.getUint32((24), true),
197
+ rows: view.getUint32((28), true)
198
+ },
199
+ chunks
200
+ };
201
+ }
202
+ function sibling(manifest, name) {
203
+ if (ABSOLUTE.test(manifest)) return new URL(name, manifest).href;
204
+ let slash = manifest.lastIndexOf("/");
205
+ return slash < 0 ? name : manifest.slice(0, slash + 1) + name;
206
+ }
207
+ async function fetchBytes(url) {
208
+ let response = await fetch(url);
209
+ if (!response.ok) throw new GameError("asset_load_failed", `scenery ${url} failed with ${response.status}`);
210
+ return new Uint8Array(await response.arrayBuffer());
211
+ }
212
+ var DEFAULT_CACHE_BYTES = 8 * 1024 * 1024, ENGINE_ABSENT = 0, ENGINE_REQUESTED = 1, ENGINE_PROVIDED = 2, SWEEP_PER_FRAME = 256, SPHERE_FLOATS = 4, PRIORITY_NOW = 0, PRIORITY_SOON = 1, BUDGET_REASON = "budget";
213
+ function overBudget(error) {
214
+ return typeof error == "object" && error !== null && error.reason === BUDGET_REASON;
215
+ }
216
+ var SceneryChunks = class {
217
+ constructor(assets, cacheBytes = DEFAULT_CACHE_BYTES) {
218
+ this.assets = assets;
219
+ this.cacheBytes = cacheBytes;
220
+ this.kept = /* @__PURE__ */ new Map();
221
+ this.cache = /* @__PURE__ */ new Map();
222
+ this.cached = 0;
223
+ }
224
+ lazy(path) {
225
+ let assets = this.assets;
226
+ return assets !== null && assets.requests?.() === true && assets.lazy?.(path) === true;
227
+ }
228
+ read(path, priority = (0)) {
229
+ let assets = this.assets;
230
+ if (assets === null) return fetchBytes(path);
231
+ if (!this.lazy(path)) return this.retained(assets, path);
232
+ let hit = this.cache.get(path);
233
+ return hit !== void 0 ? (this.cache.delete(path), this.cache.set(path, hit), Promise.resolve(hit)) : assets.take(path, priority, false).catch((error) => {
234
+ if (!overBudget(error) || !this.reclaim()) throw error;
235
+ return assets.take(path, priority, false);
236
+ });
237
+ }
238
+ holds(path) {
239
+ return this.cache.has(path);
240
+ }
241
+ get reader() {
242
+ return this.assets;
243
+ }
244
+ retained(assets, path) {
245
+ let known = this.kept.get(path);
246
+ if (known !== void 0) return known;
247
+ let taken = assets.take(path);
248
+ return this.kept.set(path, taken), taken.catch(() => this.kept.delete(path)), taken;
249
+ }
250
+ delivered(path, bytes) {
251
+ if (!(!this.lazy(path) || this.cache.has(path)))
252
+ for (this.cache.set(path, bytes), this.cached += bytes.byteLength; this.cached > this.cacheBytes && this.cache.size > 0; ) this.evictColdest();
253
+ }
254
+ reclaim() {
255
+ let target = Math.floor(this.cache.size / 2);
256
+ if (this.cache.size === 0) return false;
257
+ for (; this.cache.size > target; ) this.evictColdest();
258
+ return true;
259
+ }
260
+ evictColdest() {
261
+ for (let [path, bytes] of this.cache) {
262
+ this.cache.delete(path), this.cached -= bytes.byteLength, this.assets?.release?.(path);
263
+ return;
264
+ }
265
+ }
266
+ get cachedBytes() {
267
+ return this.cached;
268
+ }
269
+ close() {
270
+ for (; this.cache.size > 0; ) this.evictColdest();
271
+ this.kept.clear();
272
+ }
273
+ }, Stats = class {
274
+ constructor(read) {
275
+ this.read = read;
276
+ }
277
+ get chunks() {
278
+ return this.read()[SCENERY_REGISTER.chunks];
279
+ }
280
+ get resident() {
281
+ return this.read()[SCENERY_REGISTER.resident];
282
+ }
283
+ get requested() {
284
+ return this.read()[SCENERY_REGISTER.requested];
285
+ }
286
+ get installed() {
287
+ return this.read()[SCENERY_REGISTER.installed];
288
+ }
289
+ get evicted() {
290
+ return this.read()[SCENERY_REGISTER.evicted];
291
+ }
292
+ get deferred() {
293
+ return this.read()[SCENERY_REGISTER.deferred];
294
+ }
295
+ get failed() {
296
+ return this.read()[SCENERY_REGISTER.failed];
297
+ }
298
+ get installedBytes() {
299
+ return this.read()[SCENERY_REGISTER.installedKib] * (1024);
300
+ }
301
+ get residentSplats() {
302
+ return this.read()[SCENERY_REGISTER.residentSplats];
303
+ }
304
+ get drawnSplats() {
305
+ return this.read()[SCENERY_REGISTER.drawnSplats];
306
+ }
307
+ get listedPages() {
308
+ return this.read()[SCENERY_REGISTER.listedPages];
309
+ }
310
+ get poolCapacity() {
311
+ return this.read()[SCENERY_REGISTER.poolCapacity];
312
+ }
313
+ get poolFreePages() {
314
+ return this.read()[SCENERY_REGISTER.poolFreePages];
315
+ }
316
+ get tier() {
317
+ return this.read()[SCENERY_REGISTER.tier];
318
+ }
319
+ get updates() {
320
+ return this.read()[SCENERY_REGISTER.updates];
321
+ }
322
+ get heroSplats() {
323
+ return this.read()[SCENERY_REGISTER.heroSplats];
324
+ }
325
+ get heroShed() {
326
+ return this.read()[SCENERY_REGISTER.heroShed];
327
+ }
328
+ get standIn() {
329
+ return this.read()[SCENERY_REGISTER.standIn] !== 0;
330
+ }
331
+ get deformedSplats() {
332
+ return this.read()[SCENERY_REGISTER.deformedSplats];
333
+ }
334
+ }, Scenery = class {
335
+ constructor(port, handle, manifest, chunkPaths, chunks, owner, options = {}) {
336
+ this.port = port;
337
+ this.handle = handle;
338
+ this.chunkPaths = chunkPaths;
339
+ this.chunks = chunks;
340
+ this.owner = owner;
341
+ this.requests = new Uint32Array(8);
342
+ this.transform = new Float32Array(8);
343
+ this.lastEye = new Float64Array(3);
344
+ this.registers = null;
345
+ this.predictor = null;
346
+ this.hasEye = false;
347
+ this.sweep = 0;
348
+ this.waiting = 0;
349
+ this.flow = new Float64Array(FLOW_WORDS);
350
+ this.closed = false;
351
+ this.editValues = new Float32Array(3);
352
+ this.standing = false;
353
+ this.kernel = null;
354
+ if (this.regionNames = options.regions ?? {}, this.standInTarget = options.standIn ?? null, options.heroBudget !== void 0) {
355
+ let caps = new Uint32Array(3);
356
+ caps.set(options.heroBudget), this.bodyPort().heroBudget(handle, caps);
357
+ }
358
+ this.grid = manifest.grid, this.stats = new Stats(() => this.view());
359
+ let rows = chunkPaths.length;
360
+ this.engineState = new Uint8Array(rows), this.entryRow = sceneryEntryRows(manifest, rows), this.rowBytes = manifest.bytes, this.rowPart = manifest.parts ?? new Uint8Array(rows).fill((255)), this.rowSphere = new Float32Array(rows * (4));
361
+ for (let i = 0; i < rows; i++) {
362
+ let b = manifest.bounds, at = i * (6), dx = b[at + 3] - b[at], dy = b[at + 4] - b[at + 1], dz = b[at + 5] - b[at + 2];
363
+ this.rowSphere[i * (4)] = (b[at] + b[at + 3]) * 0.5, this.rowSphere[i * (4) + 1] = (b[at + 1] + b[at + 4]) * 0.5, this.rowSphere[i * (4) + 2] = (b[at + 2] + b[at + 5]) * 0.5, this.rowSphere[i * (4) + 3] = Math.sqrt(dx * dx + dy * dy + dz * dz) * 0.5;
364
+ }
365
+ let radii = sceneryTierRadii(port.registers(handle)[SCENERY_REGISTER.tier] ?? 0);
366
+ this.layer = new PrefetchLayer({
367
+ name: "scenery",
368
+ items: sceneryPrefetchItems(manifest, chunkPaths, radii),
369
+ radius: () => sceneryTierRadii(this.tier()).far * (1.1),
370
+ need: () => sceneryTierRadii(this.tier()).near * (3),
371
+ cellSize: manifest.grid.cellSize > 0 ? manifest.grid.cellSize : void 0,
372
+ held: (entry) => {
373
+ let row = this.entryRow[entry];
374
+ return this.engineState[row] !== (0) || this.chunks.holds(this.chunkPaths[row]);
375
+ },
376
+ busy: () => this.waiting > 0,
377
+ flow: this.flow
378
+ });
379
+ }
380
+ tier() {
381
+ return this.closed ? 0 : this.view()[SCENERY_REGISTER.tier];
382
+ }
383
+ get prefetcher() {
384
+ return this.predictor;
385
+ }
386
+ stream(prefetch) {
387
+ if (this.predictor !== null || this.closed) return;
388
+ let reader = this.chunks.reader;
389
+ reader === null || reader.prefetch === void 0 || (this.predictor = prefetch.stream(this.layer, { stalled: () => this.stalled(), assets: reader }));
390
+ }
391
+ stalled() {
392
+ if (this.closed || !this.hasEye) return false;
393
+ let layer = this.layer, eye = this.lastEye, need = layer.needRadius() / layer.scale, cell = layer.cellSize, c0 = Math.max(0, Math.floor((eye[0] - need - layer.maxRadius - layer.originX) / cell)), c1 = Math.min(layer.cols - 1, Math.floor((eye[0] + need + layer.maxRadius - layer.originX) / cell)), r0 = Math.max(0, Math.floor((eye[2] - need - layer.maxRadius - layer.originZ) / cell)), r1 = Math.min(layer.rows - 1, Math.floor((eye[2] + need + layer.maxRadius - layer.originZ) / cell));
394
+ for (let row = r0; row <= r1; row++)
395
+ for (let col = c0; col <= c1; col++) {
396
+ let c = row * layer.cols + col;
397
+ for (let k = layer.cellStart[c]; k < layer.cellStart[c + 1]; k++) {
398
+ let item = layer.cellItems[k];
399
+ if (this.engineState[this.entryRow[layer.entryStart[item]]] === (2)) continue;
400
+ let dx = layer.x[item] - eye[0], dy = layer.y[item] - eye[1], dz = layer.z[item] - eye[2];
401
+ if (Math.sqrt(dx * dx + dy * dy + dz * dz) - layer.radius[item] <= need) return true;
402
+ }
403
+ }
404
+ return false;
405
+ }
406
+ /** True once `remove()` has run. */
407
+ get removed() {
408
+ return this.closed;
409
+ }
410
+ /** Places the scenery in the world: translation, rotation (normalised by the engine) and a uniform scale above zero. */
411
+ setTransform(position, rotation, scale = 1) {
412
+ if (this.closed) return;
413
+ if (!(scale > 0)) throw new GameError("invalid_argument", `scenery scale must be above zero, got ${scale}`);
414
+ let t = this.transform;
415
+ t[0] = position.x, t[1] = position.y, t[2] = position.z, t[3] = rotation?.x ?? 0, t[4] = rotation?.y ?? 0, t[5] = rotation?.z ?? 0, t[6] = rotation?.w ?? 1, t[7] = scale, this.port.setTransform(this.handle, t), this.layer.setPlacement(t);
416
+ }
417
+ bodyPort() {
418
+ let bodies = this.port.bodies;
419
+ if (bodies == null) throw new GameError("unsupported_feature", "this engine build does not move or edit splats");
420
+ return bodies;
421
+ }
422
+ regionOf(region) {
423
+ let id = typeof region == "string" ? this.regionNames[region] : region;
424
+ if (id === void 0 || !Number.isInteger(id) || id < 0 || id >= 256) throw new GameError("invalid_argument", `no splat region ${String(region)}`);
425
+ return id;
426
+ }
427
+ /** Recolours one baked region without recapture: hue in radians, saturation and gain as multipliers. */
428
+ edit(region, edit) {
429
+ if (this.closed) return;
430
+ let v = this.editValues;
431
+ if (v[0] = edit.hue ?? 0, v[1] = edit.saturation ?? 1, v[2] = edit.gain ?? 1, !(v[1] >= 0) || !(v[2] >= 0) || !Number.isFinite(v[0])) throw new GameError("invalid_argument", "a splat edit needs a finite hue and non-negative saturation and gain");
432
+ this.bodyPort().edit(this.handle, this.regionOf(region), v);
433
+ }
434
+ /** Drives this body from a model's pose on the rig it was baked against; null returns it to rest. Throws when the rig differs. */
435
+ bind(rig) {
436
+ this.closed || this.bodyPort().bind(this.handle, rig ?? (0));
437
+ }
438
+ /** Splats in garment region `region` follow `cloth`, which must use the mesh the region was baked with. It may be called at any point in the cloth's run. */
439
+ drape(cloth, region, options = {}) {
440
+ if (this.closed) return;
441
+ let host = cloth.engineHost;
442
+ if (host === null) throw new GameError("unsupported_feature", "this cloth is not simulated by the engine");
443
+ this.bodyPort().drape(this.handle, host, cloth.id, this.regionOf(region), options.rest ?? null);
444
+ }
445
+ /** Rows a motion table needs: one for every splat in the manifest, across all levels of detail. */
446
+ get motionRows() {
447
+ return this.closed ? 0 : this.bodyPort().motionRows(this.handle);
448
+ }
449
+ /**
450
+ * Runs a per-splat program. `kernel` is called once a frame, normally `() => game.kernels.run(wave, table, time)`;
451
+ * the engine reads what it writes before deforming, and pays only for the channels named here. Pass null to stop.
452
+ */
453
+ motion(kernel, options) {
454
+ if (this.closed) return;
455
+ let bodies = this.bodyPort();
456
+ if (kernel === null || options === void 0) {
457
+ this.kernel = null, bodies.motion(this.handle, 0, null, 0, 0);
458
+ return;
459
+ }
460
+ let table = options.table, named = options.rotation !== void 0 || options.colour !== void 0 || options.opacity !== void 0, offset = options.offset ?? (named ? void 0 : DEFAULT_MOTION_OFFSET), mask = 0, names = [...options.rest ?? DEFAULT_MOTION_REST], channel = (bit, fields) => {
461
+ fields !== void 0 && (mask |= bit, names.push(...fields));
462
+ };
463
+ channel(1, offset), channel(2, options.rotation), channel(4, options.colour), channel(8, options.opacity === void 0 ? void 0 : [options.opacity]);
464
+ let columns = new Uint32Array(14);
465
+ if (names.forEach((name, k) => {
466
+ columns[k] = table.column(name);
467
+ }), !(options.reach >= 0)) throw new GameError("invalid_argument", "a splat motion reach must not be negative");
468
+ bodies.motion(this.handle, table.id, columns, Math.ceil(options.reach * (1e3)), mask), this.kernel = () => kernel(table);
469
+ }
470
+ follow() {
471
+ this.kernel?.();
472
+ let target = this.standInTarget;
473
+ if (target === null) return;
474
+ let wanted = this.view()[SCENERY_REGISTER.standIn] !== 0;
475
+ wanted !== this.standing && (this.standing = wanted, wanted ? target.show() : target.hide());
476
+ }
477
+ /** Closes the scenery and frees its engine resources. Later calls on the handle do nothing. */
478
+ remove() {
479
+ this.closed || (this.closed = true, this.registers = null, this.predictor !== null && this.owner.unstream(this.predictor), this.predictor = null, this.owner.release(this), this.port.close(this.handle), this.chunks.close());
480
+ }
481
+ update(eye) {
482
+ if (this.closed) return;
483
+ let n = this.port.update(this.handle, eye, this.requests);
484
+ for (let i = 0; i < n; i++) this.fetch(this.requests[i], i === 0 ? (0) : (1));
485
+ this.layer.toLocal(eye, this.lastEye, 0, true), this.hasEye = true, this.forget(), this.follow();
486
+ }
487
+ forget() {
488
+ let layer = this.layer, eye = this.lastEye, radii = sceneryTierRadii(this.tier()), scale = layer.scale, states = this.engineState, sphere = this.rowSphere, sweep = this.sweep, end = Math.min(states.length, sweep + (256));
489
+ for (let row = sweep; row < end; row++) {
490
+ if (states[row] !== (2)) continue;
491
+ let at = row * (4), dx = sphere[at] - eye[0], dy = sphere[at + 1] - eye[1], dz = sphere[at + 2] - eye[2], unload = sceneryPartReach(this.rowPart[row], radii) * (1.35) / scale;
492
+ Math.sqrt(dx * dx + dy * dy + dz * dz) - sphere[at + 3] > unload && (states[row] = (0));
493
+ }
494
+ this.sweep = end >= states.length ? 0 : end;
495
+ }
496
+ fetch(index, priority) {
497
+ let path = this.chunkPaths[index];
498
+ if (path === void 0) {
499
+ this.port.fail(this.handle, index);
500
+ return;
501
+ }
502
+ this.mark(index, (1));
503
+ let reader = this.chunks.reader;
504
+ if (reader?.progressive !== void 0 && reader.isProgressive?.(path) === true && !this.chunks.holds(path)) {
505
+ let first = true;
506
+ reader.progressive(
507
+ path,
508
+ (output) => {
509
+ first ? (first = false, this.deliver(index, path, output, false)) : this.upgrade(index, output);
510
+ },
511
+ priority
512
+ ).done.then(
513
+ (bytes) => this.chunks.delivered(path, bytes),
514
+ () => {
515
+ first && this.failed(index);
516
+ }
517
+ );
518
+ return;
519
+ }
520
+ this.chunks.read(path, priority).then(
521
+ (bytes) => this.deliver(index, path, bytes, true),
522
+ () => this.failed(index)
523
+ );
524
+ }
525
+ deliver(index, path, bytes, cache) {
526
+ if (!this.closed) {
527
+ try {
528
+ this.port.provide(this.handle, index, bytes);
529
+ } catch {
530
+ this.failed(index);
531
+ return;
532
+ }
533
+ this.mark(index, (2)), cache && this.chunks.delivered(path, bytes);
534
+ }
535
+ }
536
+ upgrade(index, bytes) {
537
+ if (!(this.closed || this.engineState[index] !== (2)))
538
+ try {
539
+ this.port.provide(this.handle, index, bytes);
540
+ } catch {
541
+ return;
542
+ }
543
+ }
544
+ failed(index) {
545
+ this.closed || (this.mark(index, (0)), this.port.fail(this.handle, index));
546
+ }
547
+ mark(index, state) {
548
+ let previous = this.engineState[index], bytes = this.rowBytes[index];
549
+ previous === (1) && (this.waiting--, this.flow[FLOW_BACKLOG] -= bytes), state === (1) && (this.waiting++, this.flow[FLOW_BACKLOG] += bytes), previous === (1) && state === (2) && (this.flow[FLOW_DELIVERED] += bytes), this.engineState[index] = state;
550
+ }
551
+ view() {
552
+ if (this.closed) return CLOSED_REGISTERS;
553
+ let registers = this.registers;
554
+ return registers !== null && registers.byteLength > 0 ? registers : (this.registers = this.port.registers(this.handle), this.registers);
555
+ }
556
+ }, GraphicsScenery = class {
557
+ constructor(port, eye) {
558
+ this.port = port;
559
+ this.eye = eye;
560
+ this.live = [];
561
+ this.eyeBuffer = new Float32Array(3);
562
+ this.prefetch = null;
563
+ }
564
+ attachPrefetch(prefetch) {
565
+ if (this.prefetch = prefetch, prefetch !== null) for (let i = 0; i < this.live.length; i++) this.live[i].stream(prefetch);
566
+ }
567
+ unstream(predictor) {
568
+ this.prefetch?.removeStream(predictor);
569
+ }
570
+ /** False when this backend or engine build cannot draw splat scenery; `load` then throws. */
571
+ get supported() {
572
+ return this.port !== null;
573
+ }
574
+ /**
575
+ * Opens the scenery whose manifest is at `source` (a `splats.cspm` URL or, with `options.assets`, a package path).
576
+ * Chunk files `<sha256>.cspl` are read from the manifest's folder on demand.
577
+ * Throws `unsupported_feature` when `supported` is false.
578
+ */
579
+ load(source, options = {}) {
580
+ let port = this.port;
581
+ if (port === null) throw new GameError("unsupported_feature", "this backend does not draw splat scenery");
582
+ let manifest = typeof source == "string" ? source : source.href, assets = options.assets;
583
+ return this.open(port, manifest, new SceneryChunks(assets ?? null, options.cacheBytes), options);
584
+ }
585
+ /** Loads a splat body baked against a rig and binds it, so it follows that model's animation. */
586
+ async splatBody(options) {
587
+ let body = await this.load(options.manifest, options);
588
+ return body.bind(options.rig), body;
589
+ }
590
+ async open(port, location, chunks, options) {
591
+ let bytes = await chunks.read(location), manifest = parseSceneryManifest(bytes), paths = manifest.chunks.map((name) => sibling(location, name)), handle = port.open(bytes), scenery = new Scenery(port, handle, manifest, paths, chunks, this, options);
592
+ return this.live.push(scenery), this.prefetch !== null && scenery.stream(this.prefetch), scenery;
593
+ }
594
+ /** Number of scenery handles currently loaded. */
595
+ get count() {
596
+ return this.live.length;
597
+ }
598
+ release(scenery) {
599
+ let index = this.live.indexOf(scenery);
600
+ index >= 0 && this.live.splice(index, 1);
601
+ }
602
+ frame() {
603
+ let live = this.live;
604
+ if (!(live.length === 0 || !this.eye(this.eyeBuffer)))
605
+ for (let i = 0; i < live.length; i++) live[i].update(this.eyeBuffer);
606
+ }
607
+ dispose() {
608
+ for (let i = this.live.length - 1; i >= 0; i--) this.live[i].remove();
609
+ }
610
+ };
611
+
612
+ // src/game/render/graphics.ts
613
+ var CUBE_FACE_COUNT = 6, MAT4_TRANSLATION_X = 12, MAT4_TRANSLATION_Y = 13, MAT4_TRANSLATION_Z = 14, QUALITY_TIER_FULL = 0, QUALITY_TIER_REDUCED = 1, QUALITY_TIER_MINIMUM = 2, Renderable = defineComponent("renderable", { node: "u32" }), FEED_NO_COLUMN = 4294967295, FEED_AXES = 3, MAX_PALETTE_FRAMES = 1024;
614
+ function scalarColumn(table, field) {
615
+ if (table.schema[field] !== "f32") throw new GameError("invalid_argument", `instance feeds read f32 fields; ${field} is not one`);
616
+ return table.column(field);
617
+ }
618
+ function wordColumn(table, field) {
619
+ if (field === void 0) return (4294967295);
620
+ if (table.schema[field] !== "u32") throw new GameError("invalid_argument", `instance rotation and animation read packed u32 fields; ${field} is not one`);
621
+ return table.column(field);
622
+ }
623
+ function poseColumns(table, fields) {
624
+ if (!(fields.rotation === void 0 && fields.animation === void 0))
625
+ return [wordColumn(table, fields.rotation), wordColumn(table, fields.animation)];
626
+ }
627
+ function feedFields(fields) {
628
+ let named = typeof fields.position == "string" ? [fields.position] : [...fields.position];
629
+ return fields.scale !== void 0 && named.push(fields.scale), fields.rotation !== void 0 && named.push(fields.rotation), fields.animation !== void 0 && named.push(fields.animation), named;
630
+ }
631
+ function feedColumns(table, fields) {
632
+ let columns = [];
633
+ if (typeof fields.position == "string") {
634
+ if (table.schema[fields.position] !== "vec3") throw new GameError("invalid_argument", `instance feed position ${fields.position} must be a vec3 field`);
635
+ for (let k = 0; k < (3); k++) columns.push(table.column(fields.position, k));
636
+ } else
637
+ for (let field of fields.position) columns.push(scalarColumn(table, field));
638
+ return columns.push(fields.scale === void 0 ? (4294967295) : scalarColumn(table, fields.scale)), columns;
639
+ }
640
+ var Graphics = class {
641
+ constructor(port, world, transforms, scenery = null) {
642
+ this.fed = /* @__PURE__ */ new Map();
643
+ this.presentedByFeeds = /* @__PURE__ */ new Set();
644
+ this.cameraMatrix = new Float32Array(16);
645
+ this.activeCamera = null;
646
+ this.port = port, this.world = world, this.transforms = transforms, this.renderables = world.register(Renderable), this.nodeIds = new Uint32Array(this.renderables.capacity), this.matrixRows = new Int32Array(this.renderables.capacity), this.scenery = new GraphicsScenery(scenery, (out) => this.readCameraEye(out)), world.onDespawn(this);
647
+ }
648
+ readCameraEye(out) {
649
+ let camera = this.activeCamera;
650
+ if (camera === null) return false;
651
+ let m = this.cameraMatrix;
652
+ return this.port.readNodeMatrix(camera, m, 0), out[0] = m[(12)], out[1] = m[(13)], out[2] = m[(14)], true;
653
+ }
654
+ get capabilities() {
655
+ return this.port.capabilities;
656
+ }
657
+ get gpu() {
658
+ return this.port.gpu;
659
+ }
660
+ attach(surface) {
661
+ return this.port.attach(surface);
662
+ }
663
+ resize(width, height, pixelRatio) {
664
+ this.port.resize(width, height, pixelRatio);
665
+ }
666
+ createGeometry(desc) {
667
+ return this.port.createGeometry(desc);
668
+ }
669
+ geometryAttribute(geometry, name) {
670
+ return this.port.geometryAttribute(geometry, name);
671
+ }
672
+ markGeometryDirty(geometry, name, start = 0, count = -1) {
673
+ this.port.markGeometryDirty(geometry, name, start, count);
674
+ }
675
+ setDrawRange(geometry, start, count) {
676
+ this.port.setDrawRange(geometry, start, count);
677
+ }
678
+ destroyGeometry(geometry) {
679
+ this.port.destroyGeometry(geometry);
680
+ }
681
+ createTexture(desc) {
682
+ return this.port.createTexture(desc);
683
+ }
684
+ loadTexture(source) {
685
+ return this.port.loadTexture(source);
686
+ }
687
+ upgradeTexture(texture, source) {
688
+ return this.port.upgradeTexture || this.unsupported("texture upgrades"), this.port.upgradeTexture(texture, source);
689
+ }
690
+ upgradeModel(model, source) {
691
+ return this.port.upgradeModel || this.unsupported("model upgrades"), this.port.upgradeModel(model, source);
692
+ }
693
+ markTextureDirty(texture, region) {
694
+ this.port.markTextureDirty(texture, region);
695
+ }
696
+ pushVideoFrame(texture, frame, width, height) {
697
+ return this.port.pushVideoFrame || this.unsupported("video textures"), this.port.pushVideoFrame(texture, frame, width, height);
698
+ }
699
+ readRenderTarget(target, rect, slice = 0) {
700
+ return this.port.readRenderTarget || this.unsupported("render target readback"), this.port.readRenderTarget(target, rect, slice);
701
+ }
702
+ vectorPort() {
703
+ let port = this.port.vectorSurfaces;
704
+ return port == null && this.unsupported("vector surfaces"), port;
705
+ }
706
+ get vectorSurfaceCap() {
707
+ return this.port.vectorSurfaces?.cap ?? 0;
708
+ }
709
+ loadVector(bytes) {
710
+ return this.vectorPort().load(bytes);
711
+ }
712
+ unloadVector(asset) {
713
+ this.vectorPort().unload(asset);
714
+ }
715
+ vectorSurface(desc) {
716
+ return this.port.capabilities.renderTargets || this.unsupported("render targets"), this.vectorPort().create(desc);
717
+ }
718
+ destroyVectorSurface(surface) {
719
+ this.vectorPort().destroy(surface);
720
+ }
721
+ setVectorSurfaceNode(surface, node) {
722
+ this.vectorPort().setNode(surface, node);
723
+ }
724
+ playVectorSurface(surface, kind, index = 0) {
725
+ this.vectorPort().play(surface, kind, index);
726
+ }
727
+ seekVectorSurface(surface, kind, index, seconds) {
728
+ let port = this.vectorPort();
729
+ port.seek || this.unsupported("vector surface seeking"), port.seek(surface, kind, index, seconds);
730
+ }
731
+ vectorSurfaceInput(surface, name) {
732
+ return this.vectorPort().inputIndex(surface, name);
733
+ }
734
+ setVectorSurfaceInput(surface, input, value) {
735
+ this.vectorPort().setInput(surface, input, typeof value == "boolean" ? Number(value) : value);
736
+ }
737
+ vectorSurfaceData(surface, path) {
738
+ return this.vectorPort().dataIndex(surface, path);
739
+ }
740
+ setVectorSurfaceData(surface, handle, kind, value = 0) {
741
+ this.vectorPort().setData(surface, handle, kind, value);
742
+ }
743
+ vectorSurfacePointer(surface, phase, u, v) {
744
+ return this.vectorPort().pointer(surface, phase, u, v);
745
+ }
746
+ pickVectorSurface(origin, direction, phase, far = 1e3) {
747
+ return this.vectorPort().pick(origin, direction, far, phase);
748
+ }
749
+ vectorSurfaceEvents(out = []) {
750
+ return this.vectorPort().events(out), out;
751
+ }
752
+ vectorSurfaceStats(out = createVectorSurfaceStats()) {
753
+ return this.vectorPort().stats(out), out;
754
+ }
755
+ setVectorSurfaceTier(tier) {
756
+ this.vectorPort().setTier(tier);
757
+ }
758
+ createMaterial(desc) {
759
+ return desc.kind === "shader" && this.checkShader(desc.shader.glsl !== void 0), this.port.createMaterial(desc);
760
+ }
761
+ setMaterialColor(material, color) {
762
+ this.port.setMaterialColor(material, (color >> 16 & 255) / 255, (color >> 8 & 255) / 255, (color & 255) / 255);
763
+ }
764
+ setMaterialRgb(material, r, g, b) {
765
+ this.port.setMaterialColor(material, r, g, b);
766
+ }
767
+ setMaterialOpacity(material, opacity) {
768
+ this.port.setMaterialOpacity(material, opacity);
769
+ }
770
+ setMaterialTexture(material, slot, texture) {
771
+ this.port.setMaterialTexture(material, slot, texture);
772
+ }
773
+ setUniform(material, name, value) {
774
+ this.port.setMaterialScalar(material, name, value);
775
+ }
776
+ setUniformVector(material, name, value) {
777
+ this.port.setMaterialVector(material, name, value);
778
+ }
779
+ setUniformTexture(material, name, texture) {
780
+ this.port.setMaterialUniformTexture(material, name, texture);
781
+ }
782
+ setMaterialState(material, state) {
783
+ this.port.setMaterialState(material, state);
784
+ }
785
+ createEmitter(desc) {
786
+ return this.port.capabilities.particles || this.unsupported("particles"), this.port.createEmitter(desc);
787
+ }
788
+ particles(entity, emitter) {
789
+ return this.create(entity, { kind: "particles", emitter });
790
+ }
791
+ emit(emitter, count) {
792
+ this.port.emit(emitter, count);
793
+ }
794
+ setEmitterRate(emitter, rate) {
795
+ this.port.setEmitterRate(emitter, rate);
796
+ }
797
+ clearEmitter(emitter) {
798
+ this.port.clearEmitter(emitter);
799
+ }
800
+ destroyEmitter(emitter) {
801
+ this.port.destroyEmitter(emitter);
802
+ }
803
+ setRenderOrder(node, order) {
804
+ this.port.setRenderOrder(node, order);
805
+ }
806
+ setShadow(light, shadow) {
807
+ this.port.setShadow(light, shadow);
808
+ }
809
+ setLod(node, near, far, hysteresis = 0) {
810
+ if (near < 0 || far > 0 && far <= near || hysteresis < 0)
811
+ throw new GameError("invalid_argument", `lod range ${near}..${far} with hysteresis ${hysteresis} is invalid`);
812
+ this.port.setLod(node, near, far, hysteresis);
813
+ }
814
+ lodLevels(levels, hysteresis = 0) {
815
+ for (let i = 0; i < levels.length; i++) {
816
+ let next = i + 1 < levels.length ? levels[i + 1].distance : 0;
817
+ this.setLod(levels[i].node, levels[i].distance, next, hysteresis);
818
+ }
819
+ }
820
+ setSprite(node, rotation, centerX = 0.5, centerY = 0.5) {
821
+ this.port.setSprite(node, rotation, centerX, centerY);
822
+ }
823
+ setProbeCoefficients(light, sh) {
824
+ if (sh.length < SH_COEFFICIENT_FLOATS)
825
+ throw new GameError("invalid_argument", `light probes take ${SH_COEFFICIENT_FLOATS} coefficients (9 RGB)`);
826
+ this.port.setProbeCoefficients(light, sh);
827
+ }
828
+ decal(entity, material, options = {}) {
829
+ return this.port.capabilities.decals || this.unsupported("decals"), this.create(entity, { kind: "decal", material, ...options });
830
+ }
831
+ setProjectionMatrix(camera, matrix, near, far) {
832
+ if (matrix !== null && matrix.length < 16) throw new GameError("invalid_argument", "projection matrices hold 16 floats");
833
+ this.port.capabilities.customProjection || this.unsupported("custom projections"), this.port.setProjectionMatrix(camera, matrix, near, far);
834
+ }
835
+ setViewOffset(camera, offset) {
836
+ if (offset !== null && (offset.fullWidth <= 0 || offset.fullHeight <= 0 || offset.width <= 0 || offset.height <= 0))
837
+ throw new GameError("invalid_argument", "view offsets need positive sizes");
838
+ this.port.capabilities.customProjection || this.unsupported("view offsets"), this.port.setViewOffset(camera, offset);
839
+ }
840
+ gpuStats(out) {
841
+ return this.port.gpuStats(out);
842
+ }
843
+ attachNode(entity, node) {
844
+ this.transforms.row(entity);
845
+ let row = this.world.add(entity, Renderable);
846
+ return this.renderables.fields.node[row] = node, node;
847
+ }
848
+ create(entity, desc) {
849
+ return this.attachNode(entity, this.createDetached(desc));
850
+ }
851
+ createDetached(desc) {
852
+ return this.checkNode(desc), this.port.createNode(desc);
853
+ }
854
+ mesh(entity, geometry, material) {
855
+ return this.create(entity, { kind: "mesh", geometry, material, castShadow: true, receiveShadow: true });
856
+ }
857
+ camera(entity, fov = 60, near = 0.1, far = 1e3) {
858
+ let node = this.create(entity, { kind: "camera", projection: "perspective", fov, near, far });
859
+ return this.port.setActiveCamera(node), this.activeCamera = node, node;
860
+ }
861
+ instanced(desc) {
862
+ this.port.capabilities.instancing || this.unsupported("instancing");
863
+ let node = this.port.createNode({ kind: "instanced", ...desc });
864
+ return {
865
+ node,
866
+ capacity: desc.capacity,
867
+ matrices: this.port.instanceMatrices(node),
868
+ colors: this.port.instanceColors(node)
869
+ };
870
+ }
871
+ batchedDraw(desc) {
872
+ if (!this.port.capabilities.instancing || desc.slots <= 0) return null;
873
+ let { slots, ...rest } = desc, node = this.port.createNode({ kind: "instanced", ...rest, batchSlots: slots }), buffers = this.port.batchBuffers(node);
874
+ return buffers === null ? (this.port.destroyNode(node), null) : {
875
+ node,
876
+ capacity: desc.capacity,
877
+ matrices: this.port.instanceMatrices(node),
878
+ colors: this.port.instanceColors(node),
879
+ slots: buffers.slots,
880
+ ranges: buffers.ranges
881
+ };
882
+ }
883
+ markBatch(batch) {
884
+ this.port.markBatch(batch.node);
885
+ }
886
+ setInstanceCount(batch, count) {
887
+ if (count < 0 || count > batch.capacity)
888
+ throw new GameError("invalid_argument", `instance count ${count} exceeds ${batch.capacity}`);
889
+ this.port.setInstanceCount(batch.node, count);
890
+ }
891
+ markInstancesDirty(batch) {
892
+ this.port.markInstancesDirty(batch.node);
893
+ }
894
+ feedInstances(batch, table, fields, options = {}) {
895
+ if (!table.native || this.port.setInstanceFeed === void 0) return false;
896
+ let columns = feedColumns(table, fields), pose = poseColumns(table, fields), hostReads = options.hostReads === true;
897
+ return this.port.setInstanceFeed(batch.node, table.id, columns, hostReads, pose) ? (this.forget(batch.node), this.world.presentsKernels(table) || (this.world.presentKernels(table), this.presentedByFeeds.add(table)), this.fed.set(batch.node, table), hostReads && this.world.hostReads(table, feedFields(fields)), true) : false;
898
+ }
899
+ setInstancePalette(batch, model, desc) {
900
+ if (this.port.setInstancePalette === void 0) return false;
901
+ if (desc === null) return this.port.setInstancePalette(batch.node, model, 0, 0, 0, 0);
902
+ let skin = desc.skin ?? 0, firstClip = desc.firstClip ?? 0, whole = (value) => Number.isInteger(value) && value >= 0;
903
+ if (!whole(skin) || !whole(firstClip) || !whole(desc.clips) || desc.clips < 1 || !whole(desc.frames) || desc.frames < 1 || desc.frames > (1024))
904
+ throw new GameError("invalid_argument", `an instance palette needs whole clips of at least 1 and 1 to ${(1024)} frames per clip`);
905
+ return this.port.setInstancePalette(batch.node, model, skin, firstClip, desc.clips, desc.frames);
906
+ }
907
+ stopFeedingInstances(batch) {
908
+ this.fed.has(batch.node) && this.port.clearInstanceFeed?.(batch.node), this.forget(batch.node);
909
+ }
910
+ forget(node) {
911
+ let table = this.fed.get(node);
912
+ if (table !== void 0) {
913
+ this.fed.delete(node);
914
+ for (let other of this.fed.values()) if (other === table) return;
915
+ this.presentedByFeeds.delete(table) && this.world.presentKernels(table, false);
916
+ }
917
+ }
918
+ morphWeights(node) {
919
+ return this.port.capabilities.morphTargets || this.unsupported("morph targets"), this.port.morphWeights(node);
920
+ }
921
+ markMorphWeightsDirty(node) {
922
+ this.port.markMorphWeightsDirty(node);
923
+ }
924
+ skeletonPose(node) {
925
+ return this.port.capabilities.skinning || this.unsupported("skinning"), this.port.skeletonPose(node);
926
+ }
927
+ markSkeletonDirty(node) {
928
+ this.port.markSkeletonDirty(node);
929
+ }
930
+ setVisible(node, visible) {
931
+ this.port.setNodeVisible(node, visible);
932
+ }
933
+ setLayers(node, mask) {
934
+ this.port.setNodeLayers(node, mask);
935
+ }
936
+ setNodeMaterial(node, material) {
937
+ this.port.setNodeMaterial(node, material);
938
+ }
939
+ setText(node, text) {
940
+ this.port.setNodeText(node, text);
941
+ }
942
+ loadFont(source, family) {
943
+ return this.port.capabilities.text || this.unsupported("text"), this.port.loadFont(source, family);
944
+ }
945
+ text3d(entity, font, text, style = {}) {
946
+ return this.create(entity, { ...style, kind: "text3d", font, text });
947
+ }
948
+ setTextStyle(node, style) {
949
+ this.port.setTextStyle(node, style);
950
+ }
951
+ textBounds(node, out) {
952
+ this.port.textBounds(node, out);
953
+ }
954
+ raycast(origin, direction, out, far = 0, layers = 4294967295) {
955
+ return this.port.capabilities.picking || this.unsupported("picking"), this.port.raycast(origin, direction, far, layers, out);
956
+ }
957
+ batchHandle() {
958
+ return this.port.capabilities.picking ? this.port.batchHandle?.() ?? 0 : 0;
959
+ }
960
+ governorPressure() {
961
+ return this.port.governorPressure?.() ?? 0;
962
+ }
963
+ /** Pins the renderer's quality tier (0 full, 1 reduced, 2 minimum), or returns it to the governor with null. False when this renderer has no governor. */
964
+ forceQualityTier(tier) {
965
+ if (tier !== null && !(Number.isInteger(tier) && tier >= (0) && tier <= (2)))
966
+ throw new GameError("invalid_argument", `quality tiers run from ${(0)} to ${(2)}`);
967
+ return this.port.forceQualityTier?.(tier) ?? false;
968
+ }
969
+ qualityTier() {
970
+ return this.port.qualityTier?.() ?? (0);
971
+ }
972
+ setPerspective(camera, fovDegrees, near, far) {
973
+ this.port.setCameraPerspective(camera, fovDegrees, near, far);
974
+ }
975
+ setPerspectiveFrom(camera, values, offset = 0) {
976
+ this.port.setCameraPerspectiveFrom(camera, values, offset);
977
+ }
978
+ setOrthographic(camera, height, near, far) {
979
+ this.port.setCameraOrthographic(camera, height, near, far);
980
+ }
981
+ setActiveCamera(camera) {
982
+ this.port.setActiveCamera(camera), this.activeCamera = camera;
983
+ }
984
+ setLight(light, color, intensity) {
985
+ this.port.setLight(light, color, intensity);
986
+ }
987
+ setEnvironment(desc) {
988
+ this.port.setEnvironment(desc);
989
+ }
990
+ createRenderTarget(desc) {
991
+ return this.port.capabilities.renderTargets || this.unsupported("render targets"), this.port.createRenderTarget(desc);
992
+ }
993
+ renderTargetTexture(target) {
994
+ return this.port.renderTargetTexture(target);
995
+ }
996
+ renderTargetAttachment(target, attachment) {
997
+ return attachment === 0 ? this.port.renderTargetTexture(target) : (this.port.renderTargetAttachment || this.unsupported("multiple render target attachments"), this.port.renderTargetAttachment(target, attachment));
998
+ }
999
+ captureCube(target, camera) {
1000
+ return Array.from(
1001
+ { length: (6) },
1002
+ (_, slice) => this.port.createRenderPass({ camera, target, slice, cubeFace: true, once: true })
1003
+ );
1004
+ }
1005
+ createReflector(target, camera, plane, order = -1) {
1006
+ return this.port.createRenderPass({ camera, target, reflect: plane, order });
1007
+ }
1008
+ renderTargetDepthTexture(target) {
1009
+ return this.port.renderTargetDepthTexture || this.unsupported("sampled render target depth"), this.port.renderTargetDepthTexture(target);
1010
+ }
1011
+ resizeRenderTarget(target, width, height) {
1012
+ this.port.resizeRenderTarget(target, width, height);
1013
+ }
1014
+ createPostChain(desc) {
1015
+ this.port.capabilities.postProcessing || this.unsupported("post-processing");
1016
+ for (let effect of desc.effects)
1017
+ effect.kind === "shader" && this.checkShader(effect.shader.glsl !== void 0);
1018
+ return this.port.createPostChain(desc);
1019
+ }
1020
+ setPostChain(chain) {
1021
+ this.port.setPostChain(chain);
1022
+ }
1023
+ setWeather(state) {
1024
+ this.port.setWeather(state);
1025
+ }
1026
+ setTimeOfDay(hours, latitude, dayOfYear) {
1027
+ this.port.setTimeOfDay(hours, latitude, dayOfYear);
1028
+ }
1029
+ mediaVolume(desc) {
1030
+ let port = this.port, { createMedium, setMedium, mediumTexels, markMedium, destroyMedium } = port;
1031
+ if (createMedium === void 0 || setMedium === void 0 || mediumTexels === void 0 || markMedium === void 0 || destroyMedium === void 0)
1032
+ throw new GameError("unsupported_feature", "media volumes need the native engine with feature media_volume_1");
1033
+ let media = {
1034
+ createMedium: createMedium.bind(port),
1035
+ setMedium: setMedium.bind(port),
1036
+ mediumTexels: mediumTexels.bind(port),
1037
+ markMedium: markMedium.bind(port),
1038
+ destroyMedium: destroyMedium.bind(port)
1039
+ };
1040
+ return new MediumVolume(media, media.createMedium(desc), desc);
1041
+ }
1042
+ setPostUniform(chain, effect, name, value) {
1043
+ this.port.setPostScalar(chain, effect, name, value);
1044
+ }
1045
+ createRenderPass(desc) {
1046
+ return desc.target !== null && !this.port.capabilities.renderTargets && this.unsupported("render targets"), this.port.createRenderPass(desc);
1047
+ }
1048
+ setRenderPassEnabled(pass, enabled) {
1049
+ this.port.setRenderPassEnabled(pass, enabled);
1050
+ }
1051
+ loadModel(source) {
1052
+ return this.port.capabilities.models || this.unsupported("models"), this.port.loadModel(source);
1053
+ }
1054
+ loadClips(root, source, options) {
1055
+ return this.port.loadClips || this.unsupported("animation clip import"), this.port.loadClips(root, source, options);
1056
+ }
1057
+ setTint(node, tint) {
1058
+ this.port.setTint || this.unsupported("kit tints"), this.port.setTint(node, tint);
1059
+ }
1060
+ instantiate(entity, model) {
1061
+ return this.attachNode(entity, this.port.instantiateModel(model));
1062
+ }
1063
+ findNode(root, name) {
1064
+ return this.port.findNode(root, name);
1065
+ }
1066
+ playClip(root, clip, loop = true, fadeSeconds = 0, speed = 1) {
1067
+ return this.port.playClip(root, clip, loop, fadeSeconds, speed);
1068
+ }
1069
+ setClipWeight(action, weight) {
1070
+ this.port.setClipWeight(action, weight);
1071
+ }
1072
+ clipIndex(root, clip) {
1073
+ return this.port.clipIndex?.(root, clip) ?? -1;
1074
+ }
1075
+ playClipIndex(root, clip, loop, fadeSeconds, speed) {
1076
+ return this.port.playClipIndex === void 0 && this.unsupported("clip playback by index"), this.port.playClipIndex(root, clip, loop, fadeSeconds, speed);
1077
+ }
1078
+ setIkTarget(chain, x, y, z, weight) {
1079
+ this.clips.setIkTarget(chain, x, y, z, weight);
1080
+ }
1081
+ instanceBuffer(node, colours) {
1082
+ try {
1083
+ return colours ? this.port.instanceColors(node) : this.port.instanceMatrices(node);
1084
+ } catch {
1085
+ return null;
1086
+ }
1087
+ }
1088
+ markInstances(node) {
1089
+ this.port.markInstancesDirty(node);
1090
+ }
1091
+ stopClip(action, fadeSeconds = 0) {
1092
+ this.port.stopClip(action, fadeSeconds);
1093
+ }
1094
+ get clips() {
1095
+ return this.port.clips ?? this.unsupported("clip animation (actions, masks, blend spaces, IK, retargeting, root motion)");
1096
+ }
1097
+ get hasClipAnimation() {
1098
+ return this.port.clips !== void 0;
1099
+ }
1100
+ nodeOf(entity) {
1101
+ let row = this.renderables.row(entity);
1102
+ return row === -1 ? null : this.renderables.fields.node[row];
1103
+ }
1104
+ entityOfNode(node) {
1105
+ let nodes = this.renderables.fields.node, n = this.renderables.count;
1106
+ for (let row = 0; row < n; row++) if (nodes[row] === node) return this.renderables.entities[row];
1107
+ return NO_ENTITY;
1108
+ }
1109
+ readNodeMatrix(node, out, offset = 0) {
1110
+ this.port.readNodeMatrix(node, out, offset);
1111
+ }
1112
+ stats(out) {
1113
+ this.port.stats(out);
1114
+ }
1115
+ onDespawn(entity) {
1116
+ let row = this.renderables.row(entity);
1117
+ if (row === -1) return;
1118
+ let node = this.renderables.fields.node[row];
1119
+ node === this.activeCamera && (this.activeCamera = null), this.forget(node), this.port.destroyNode(node);
1120
+ }
1121
+ sync(time) {
1122
+ let store = this.renderables, transforms = this.transforms.store, n = store.count, count = 0;
1123
+ for (let r = 0; r < n; r++) {
1124
+ let row = transforms.row(store.entities[r]);
1125
+ row !== -1 && (this.nodeIds[count] = store.fields.node[r], this.matrixRows[count] = row, count++);
1126
+ }
1127
+ this.port.writeNodeMatrices(this.nodeIds, transforms.fields.render, this.matrixRows, count), this.port.advanceAnimations(time);
1128
+ }
1129
+ render(time) {
1130
+ this.scenery.frame(), this.port.render(time);
1131
+ }
1132
+ checkNode(desc) {
1133
+ let caps = this.port.capabilities;
1134
+ if (desc.kind === "skinned" && !caps.skinning && this.unsupported("skinning"), desc.kind === "instanced" && !caps.instancing && this.unsupported("instancing"), desc.kind === "particles" && !caps.particles && this.unsupported("particles"), desc.kind === "decal" && !caps.decals && this.unsupported("decals"), desc.kind === "camera" && desc.projection === "custom" && !caps.customProjection && this.unsupported("custom projections"), desc.kind === "light" && desc.light === "probe" && desc.sh !== void 0 && desc.sh.length < SH_COEFFICIENT_FLOATS)
1135
+ throw new GameError("invalid_argument", `light probes take ${SH_COEFFICIENT_FLOATS} coefficients (9 RGB)`);
1136
+ }
1137
+ checkShader(hasGlsl) {
1138
+ if (!(this.port.capabilities.shaderLanguages.indexOf("wgsl") >= 0) && !hasGlsl)
1139
+ throw new GameError(
1140
+ "shader_requires_translation",
1141
+ "this backend draws with WebGL2; the shader needs its admitted GLSL translation"
1142
+ );
1143
+ }
1144
+ unsupported(feature) {
1145
+ throw new GameError("unsupported_feature", `${this.port.capabilities.backend} does not support ${feature}`);
1146
+ }
1147
+ };
1148
+
1149
+ // src/interactives/meters/frames.ts
1150
+ var FRAME_WINDOW = 600, NO_MOMENT = 65535, MAX_MOMENTS = 64, MS_PER_SECOND = 1e3, NS_PER_MS = 1e6, P50 = 0.5, P95 = 0.95, P99 = 0.99;
1151
+ function percentile(sorted, share) {
1152
+ return sorted.length === 0 ? 0 : sorted[Math.min(sorted.length - 1, Math.floor(share * sorted.length))];
1153
+ }
1154
+ function smoothVerdict(fps, target = TARGET_HZ) {
1155
+ let share = fps / target;
1156
+ return share >= SMOOTH_SHARE ? "smooth" : share >= STUTTER_SHARE ? "slight" : "stutters";
1157
+ }
1158
+ function heatVerdict(busyShare, pressure) {
1159
+ return busyShare >= HOT_BUSY_SHARE || pressure >= HOT_PRESSURE ? "hot" : busyShare >= WARM_BUSY_SHARE || pressure >= WARM_PRESSURE ? "warm" : "cool";
1160
+ }
1161
+ var FrameRecorder = class {
1162
+ constructor() {
1163
+ this.frameMs = new Float64Array((600));
1164
+ this.moments = new Uint16Array((600));
1165
+ this.passNs = new Float64Array(GPU_PASS_NAMES.length);
1166
+ this.labels = [];
1167
+ this.head = 0;
1168
+ this.count = 0;
1169
+ this.moment = (65535);
1170
+ this.gpuFrames = 0;
1171
+ this.busyNs = 0;
1172
+ this.spanNs = 0;
1173
+ this.pressure = 0;
1174
+ }
1175
+ mark(label) {
1176
+ if (label === null) {
1177
+ this.moment = (65535);
1178
+ return;
1179
+ }
1180
+ let index = this.labels.indexOf(label);
1181
+ index < 0 && this.labels.length < (64) && (index = this.labels.push(label) - 1), this.moment = index < 0 ? (65535) : index;
1182
+ }
1183
+ frame(seconds) {
1184
+ !(seconds > 0) || !Number.isFinite(seconds) || (this.frameMs[this.head] = seconds * (1e3), this.moments[this.head] = this.moment, this.head = (this.head + 1) % (600), this.count < (600) && this.count++, this.spanNs += seconds * (1e3) * (1e6));
1185
+ }
1186
+ gpu(lastNs, passNs, pressure) {
1187
+ lastNs > 0 && (this.busyNs += lastNs, this.gpuFrames++);
1188
+ for (let i = 0; i < this.passNs.length && i < passNs.length; i++) this.passNs[i] += passNs[i];
1189
+ pressure > this.pressure && (this.pressure = pressure);
1190
+ }
1191
+ reset() {
1192
+ this.head = 0, this.count = 0, this.gpuFrames = 0, this.busyNs = 0, this.spanNs = 0, this.pressure = 0, this.passNs.fill(0);
1193
+ }
1194
+ get frames() {
1195
+ return this.count;
1196
+ }
1197
+ heat() {
1198
+ let samples = this.gpuFrames, average = this.count === 0 ? 0 : this.spanNs / this.count, busyShare = samples === 0 || average === 0 ? 0 : Math.min(1, this.busyNs / samples / average);
1199
+ return { busyShare, pressure: this.pressure, heat: heatVerdict(busyShare, this.pressure) };
1200
+ }
1201
+ meter(tier, calibration = null, target = TARGET_HZ) {
1202
+ let scale = isCalibrated(calibration) ? calibration.frameScale : 1, sorted = this.frameMs.slice(0, this.count).sort();
1203
+ for (let i = 0; i < sorted.length; i++) sorted[i] *= scale;
1204
+ let p95 = percentile(sorted, (0.95)), fps = p95 > 0 ? Math.min(target, (1e3) / p95) : target;
1205
+ return {
1206
+ tier,
1207
+ frames: this.count,
1208
+ p50Ms: percentile(sorted, (0.5)),
1209
+ p95Ms: p95,
1210
+ p99Ms: percentile(sorted, (0.99)),
1211
+ fps,
1212
+ targetFps: target,
1213
+ smooth: smoothVerdict(fps, target),
1214
+ worstMoment: this.worstMoment(),
1215
+ causes: passCauses(this.passNs),
1216
+ calibrated: isCalibrated(calibration),
1217
+ device: isCalibrated(calibration) ? calibration.device : null
1218
+ };
1219
+ }
1220
+ worstMoment() {
1221
+ let worst = (65535), worstMs = 0;
1222
+ for (let m = 0; m < this.labels.length; m++) {
1223
+ let mine = [];
1224
+ for (let i = 0; i < this.count; i++) this.moments[i] === m && mine.push(this.frameMs[i]);
1225
+ if (mine.length === 0) continue;
1226
+ mine.sort((a, b) => a - b);
1227
+ let ms = mine[Math.min(mine.length - 1, Math.floor((0.95) * mine.length))];
1228
+ ms > worstMs && (worstMs = ms, worst = m);
1229
+ }
1230
+ return worst === (65535) ? null : this.labels[worst];
1231
+ }
1232
+ };
1233
+
1234
+ // src/interactives/meters/memory.ts
1235
+ var MemoryPeak = class {
1236
+ constructor() {
1237
+ this.script = 0;
1238
+ this.engine = 0;
1239
+ this.graphics = 0;
1240
+ }
1241
+ note(sample) {
1242
+ sample.scriptBytes > this.script && (this.script = sample.scriptBytes), sample.engineBytes > this.engine && (this.engine = sample.engineBytes), sample.graphicsBytes > this.graphics && (this.graphics = sample.graphicsBytes);
1243
+ }
1244
+ noteScript(bytes) {
1245
+ bytes > this.script && (this.script = bytes);
1246
+ }
1247
+ noteEngine(bytes) {
1248
+ bytes > this.engine && (this.engine = bytes);
1249
+ }
1250
+ noteGraphics(bytes) {
1251
+ bytes > this.graphics && (this.graphics = bytes);
1252
+ }
1253
+ reset() {
1254
+ this.script = 0, this.engine = 0, this.graphics = 0;
1255
+ }
1256
+ get peak() {
1257
+ return { scriptBytes: this.script, engineBytes: this.engine, graphicsBytes: this.graphics };
1258
+ }
1259
+ };
1260
+ function memoryMeter(sample, tier, calibration = null) {
1261
+ let scale = isCalibrated(calibration) ? calibration.memoryScale : 1, bytes = (sample.scriptBytes + sample.engineBytes + sample.graphicsBytes) * scale, ceiling = MEMORY_CEILING_BYTES[tier];
1262
+ return {
1263
+ tier,
1264
+ bytes,
1265
+ ceilingBytes: ceiling,
1266
+ memory: bytes > ceiling ? "too_much" : bytes > ceiling * TIGHT_MEMORY_SHARE ? "tight" : "fits",
1267
+ causes: rankCauses([
1268
+ { label: "Game code and data", cost: sample.scriptBytes },
1269
+ { label: "World, physics and sound", cost: sample.engineBytes },
1270
+ { label: "Pictures, models and screens", cost: sample.graphicsBytes }
1271
+ ]),
1272
+ calibrated: isCalibrated(calibration)
1273
+ };
1274
+ }
1275
+
1276
+ // src/interactives/meters/live.ts
1277
+ var GPU_SAMPLE_FRAMES = 30, QUALITY_FOR_TIER = {
1278
+ low: (2),
1279
+ mid: (1),
1280
+ high: (0)
1281
+ }, GameMeters = class {
1282
+ constructor(game, tier, calibrations = []) {
1283
+ this.game = game;
1284
+ this.calibrations = calibrations;
1285
+ this.recorder = new FrameRecorder();
1286
+ this.memory = new MemoryPeak();
1287
+ this.stats = createGpuStats();
1288
+ this.forced = false;
1289
+ this.sinceGpu = 0;
1290
+ this.tier = tier;
1291
+ }
1292
+ get playingAs() {
1293
+ return this.tier;
1294
+ }
1295
+ get simulating() {
1296
+ return this.forced;
1297
+ }
1298
+ playAs(tier) {
1299
+ let graphics = this.game.graphics;
1300
+ if (tier === null)
1301
+ return graphics.forceQualityTier(null), this.forced = false, this.reset(), true;
1302
+ let pinned = graphics.forceQualityTier(QUALITY_FOR_TIER[tier]);
1303
+ return this.forced = pinned, pinned && (this.tier = tier), this.reset(), pinned;
1304
+ }
1305
+ measureAs(tier, pin) {
1306
+ return pin ? this.playAs(tier) : (this.forced && this.game.graphics.forceQualityTier(null), this.forced = false, this.tier = tier, this.reset(), true);
1307
+ }
1308
+ moment(label) {
1309
+ this.recorder.mark(label);
1310
+ }
1311
+ update() {
1312
+ if (this.recorder.frame(this.game.clock[FRAME_SECONDS_SLOT]), ++this.sinceGpu < (30)) return;
1313
+ this.sinceGpu = 0;
1314
+ let graphics = this.game.graphics;
1315
+ graphics.gpuStats(this.stats) && (this.recorder.gpu(this.stats.gpuP50Ns, this.stats.passNs, graphics.governorPressure()), this.memory.noteGraphics(this.stats.gpuBytes));
1316
+ }
1317
+ noteInspector(readout) {
1318
+ this.memory.noteEngine(readout.arena.highWaterBytes);
1319
+ }
1320
+ noteScriptHeap(bytes) {
1321
+ this.memory.noteScript(bytes);
1322
+ }
1323
+ reset() {
1324
+ this.recorder.reset(), this.memory.reset(), this.sinceGpu = 0;
1325
+ }
1326
+ read() {
1327
+ let calibration = calibrationFor(this.calibrations, this.tier);
1328
+ return {
1329
+ tier: this.tier,
1330
+ asTier: this.forced,
1331
+ frames: this.recorder.meter(this.tier, calibration),
1332
+ heat: this.recorder.heat(),
1333
+ memory: memoryMeter(this.memory.peak, this.tier, calibration)
1334
+ };
1335
+ }
1336
+ };
1337
+
1338
+ export { ComponentStore, FRAME_WINDOW, FrameRecorder, GPU_SAMPLE_FRAMES, GameMeters, Graphics, GraphicsScenery, MAX_MOMENTS, MemoryPeak, QUALITY_FOR_TIER, Renderable, SCENERY_CHUNK_EXTENSION, SCENERY_LOAD_SHARE, SCENERY_MANIFEST_MAGIC, SCENERY_MANIFEST_VERSION, SCENERY_MANIFEST_VERSION_PARTS, SCENERY_NEED_SHARE, SCENERY_PART_COARSE, SCENERY_PART_FINE, SCENERY_PART_MIDDLE, SCENERY_PART_WHOLE, SCENERY_TIER_RADII, Scenery, defineComponent, heatVerdict, memoryMeter, parseSceneryManifest, sceneryEntryRows, sceneryFirstView, sceneryPartDrawLevel, sceneryPartReach, sceneryPrefetchItems, sceneryTierRadii, smoothVerdict };