@playdrop/playdrop-cli 0.16.16 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/config/client-meta.json +4 -4
  2. package/dist/apiClient.d.ts +1 -2
  3. package/dist/apiClient.js +1 -16
  4. package/dist/appUrls.js +4 -0
  5. package/dist/apps/build.d.ts +12 -4
  6. package/dist/apps/build.js +55 -22
  7. package/dist/apps/index.d.ts +2 -1
  8. package/dist/apps/index.js +4 -1
  9. package/dist/apps/loadCheck.d.ts +5 -1
  10. package/dist/apps/loadCheck.js +52 -18
  11. package/dist/apps/serverBuild.d.ts +17 -0
  12. package/dist/apps/serverBuild.js +155 -0
  13. package/dist/apps/staticHtml.d.ts +1 -0
  14. package/dist/apps/staticHtml.js +19 -10
  15. package/dist/apps/upload.d.ts +12 -2
  16. package/dist/apps/upload.js +127 -46
  17. package/dist/catalogue.d.ts +23 -1
  18. package/dist/catalogue.js +126 -100
  19. package/dist/commandContext.d.ts +6 -3
  20. package/dist/commandContext.js +108 -18
  21. package/dist/commands/build.js +0 -7
  22. package/dist/commands/captureListing.d.ts +3 -0
  23. package/dist/commands/captureListing.js +48 -4
  24. package/dist/commands/chat.d.ts +4 -0
  25. package/dist/commands/chat.js +133 -8
  26. package/dist/commands/check.js +34 -1
  27. package/dist/commands/create.js +30 -263
  28. package/dist/commands/dev.js +37 -3
  29. package/dist/commands/devBrowser.js +2 -2
  30. package/dist/commands/devGameServer.d.ts +16 -0
  31. package/dist/commands/devGameServer.js +237 -0
  32. package/dist/commands/devRuntimeAssets.d.ts +1 -0
  33. package/dist/commands/devRuntimeAssets.js +2 -0
  34. package/dist/commands/devServer.d.ts +3 -0
  35. package/dist/commands/devServer.js +111 -5
  36. package/dist/commands/generation.d.ts +33 -4
  37. package/dist/commands/generation.js +304 -115
  38. package/dist/commands/login.js +23 -7
  39. package/dist/commands/review.d.ts +1 -1
  40. package/dist/commands/review.js +68 -95
  41. package/dist/commands/source.d.ts +19 -0
  42. package/dist/commands/source.js +142 -0
  43. package/dist/commands/tweaks.js +5 -11
  44. package/dist/commands/upload-content.d.ts +1 -1
  45. package/dist/commands/upload-content.js +16 -12
  46. package/dist/commands/upload.d.ts +17 -1
  47. package/dist/commands/upload.js +47 -10
  48. package/dist/commands/worker/archive-staging.d.ts +1 -0
  49. package/dist/commands/worker/archive-staging.js +13 -2
  50. package/dist/commands/worker/e2e-fixtures.d.ts +32 -0
  51. package/dist/commands/worker/e2e-fixtures.js +466 -0
  52. package/dist/commands/worker/game-server-infra.d.ts +80 -0
  53. package/dist/commands/worker/game-server-infra.js +595 -0
  54. package/dist/commands/worker/game-source-git.d.ts +126 -0
  55. package/dist/commands/worker/game-source-git.js +780 -0
  56. package/dist/commands/worker/generation.d.ts +94 -0
  57. package/dist/commands/worker/generation.js +1458 -0
  58. package/dist/commands/worker/runtime.d.ts +8 -10
  59. package/dist/commands/worker/runtime.js +51 -45
  60. package/dist/commands/worker.d.ts +79 -19
  61. package/dist/commands/worker.js +1796 -419
  62. package/dist/config.d.ts +2 -0
  63. package/dist/config.js +16 -3
  64. package/dist/environment.d.ts +0 -1
  65. package/dist/environment.js +0 -8
  66. package/dist/index.js +92 -13
  67. package/dist/workerAppProject.d.ts +1 -1
  68. package/dist/workerAppProject.js +15 -2
  69. package/node_modules/@playdrop/api-client/dist/client.d.ts +72 -25
  70. package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
  71. package/node_modules/@playdrop/api-client/dist/client.js +33 -0
  72. package/node_modules/@playdrop/api-client/dist/core/request.d.ts +1 -0
  73. package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -1
  74. package/node_modules/@playdrop/api-client/dist/core/request.js +17 -11
  75. package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts +51 -6
  76. package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts.map +1 -1
  77. package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.js +338 -41
  78. package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts +24 -1
  79. package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts.map +1 -1
  80. package/node_modules/@playdrop/api-client/dist/domains/ai.js +20 -0
  81. package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +13 -8
  82. package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -1
  83. package/node_modules/@playdrop/api-client/dist/domains/apps.js +158 -90
  84. package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +4 -0
  85. package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -1
  86. package/node_modules/@playdrop/api-client/dist/domains/assets.js +27 -0
  87. package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts +35 -3
  88. package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts.map +1 -1
  89. package/node_modules/@playdrop/api-client/dist/domains/chat.js +89 -7
  90. package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts +2 -1
  91. package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts.map +1 -1
  92. package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +9 -0
  93. package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts +1 -2
  94. package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts.map +1 -1
  95. package/node_modules/@playdrop/api-client/dist/domains/playtrade.js +0 -11
  96. package/node_modules/@playdrop/api-client/dist/domains/social.d.ts +29 -0
  97. package/node_modules/@playdrop/api-client/dist/domains/social.d.ts.map +1 -0
  98. package/node_modules/@playdrop/api-client/dist/domains/social.js +79 -0
  99. package/node_modules/@playdrop/api-client/dist/index.d.ts +80 -29
  100. package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
  101. package/node_modules/@playdrop/api-client/dist/index.js +217 -56
  102. package/node_modules/@playdrop/api-client/dist/runtime.d.ts +18 -0
  103. package/node_modules/@playdrop/api-client/dist/runtime.d.ts.map +1 -0
  104. package/node_modules/@playdrop/api-client/dist/runtime.js +54 -0
  105. package/node_modules/@playdrop/api-client/package.json +7 -0
  106. package/node_modules/@playdrop/config/client-meta.json +4 -4
  107. package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts +11 -0
  108. package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts.map +1 -1
  109. package/node_modules/@playdrop/config/dist/src/creator-plans.js +13 -1
  110. package/node_modules/@playdrop/config/dist/src/deployment.d.ts +0 -1
  111. package/node_modules/@playdrop/config/dist/src/deployment.d.ts.map +1 -1
  112. package/node_modules/@playdrop/config/dist/src/deployment.js +0 -8
  113. package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts +0 -1
  114. package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts.map +1 -1
  115. package/node_modules/@playdrop/config/dist/src/public-deployment.js +0 -8
  116. package/node_modules/@playdrop/config/dist/src/runtime-service-origins.d.ts +1 -1
  117. package/node_modules/@playdrop/config/dist/src/runtime-service-origins.js +2 -2
  118. package/node_modules/@playdrop/config/dist/src/server/logging.d.ts.map +1 -1
  119. package/node_modules/@playdrop/config/dist/src/server/logging.js +31 -2
  120. package/node_modules/@playdrop/config/dist/test/creator-plans.test.js +10 -0
  121. package/node_modules/@playdrop/config/dist/test/deployment.test.js +0 -4
  122. package/node_modules/@playdrop/config/dist/test/runtime-service-origins.test.js +2 -0
  123. package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
  124. package/node_modules/@playdrop/config/package.json +6 -0
  125. package/node_modules/@playdrop/game-source-git/dist/src/archive.d.ts +9 -0
  126. package/node_modules/@playdrop/game-source-git/dist/src/archive.d.ts.map +1 -0
  127. package/node_modules/@playdrop/game-source-git/dist/src/archive.js +107 -0
  128. package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.d.ts +29 -0
  129. package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.d.ts.map +1 -0
  130. package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.js +64 -0
  131. package/node_modules/@playdrop/game-source-git/dist/src/export.d.ts +8 -0
  132. package/node_modules/@playdrop/game-source-git/dist/src/export.d.ts.map +1 -0
  133. package/node_modules/@playdrop/game-source-git/dist/src/export.js +25 -0
  134. package/node_modules/@playdrop/game-source-git/dist/src/git.d.ts +39 -0
  135. package/node_modules/@playdrop/game-source-git/dist/src/git.d.ts.map +1 -0
  136. package/node_modules/@playdrop/game-source-git/dist/src/git.js +195 -0
  137. package/node_modules/@playdrop/game-source-git/dist/src/ignore.d.ts +6 -0
  138. package/node_modules/@playdrop/game-source-git/dist/src/ignore.d.ts.map +1 -0
  139. package/node_modules/@playdrop/game-source-git/dist/src/ignore.js +51 -0
  140. package/node_modules/@playdrop/game-source-git/dist/src/index.d.ts +10 -0
  141. package/node_modules/@playdrop/game-source-git/dist/src/index.d.ts.map +1 -0
  142. package/node_modules/@playdrop/{boxel-core/dist/src/humanoid/r15 → game-source-git/dist/src}/index.js +9 -4
  143. package/node_modules/@playdrop/game-source-git/dist/src/lock.d.ts +17 -0
  144. package/node_modules/@playdrop/game-source-git/dist/src/lock.d.ts.map +1 -0
  145. package/node_modules/@playdrop/game-source-git/dist/src/lock.js +72 -0
  146. package/node_modules/@playdrop/game-source-git/dist/src/materialize.d.ts +10 -0
  147. package/node_modules/@playdrop/game-source-git/dist/src/materialize.d.ts.map +1 -0
  148. package/node_modules/@playdrop/game-source-git/dist/src/materialize.js +99 -0
  149. package/node_modules/@playdrop/game-source-git/dist/src/paths.d.ts +24 -0
  150. package/node_modules/@playdrop/game-source-git/dist/src/paths.d.ts.map +1 -0
  151. package/node_modules/@playdrop/game-source-git/dist/src/paths.js +207 -0
  152. package/node_modules/@playdrop/game-source-git/dist/src/repository.d.ts +66 -0
  153. package/node_modules/@playdrop/game-source-git/dist/src/repository.d.ts.map +1 -0
  154. package/node_modules/@playdrop/game-source-git/dist/src/repository.js +213 -0
  155. package/node_modules/@playdrop/game-source-git/dist/test/core.test.d.ts +2 -0
  156. package/node_modules/@playdrop/game-source-git/dist/test/core.test.d.ts.map +1 -0
  157. package/node_modules/@playdrop/game-source-git/dist/test/core.test.js +441 -0
  158. package/node_modules/@playdrop/game-source-git/dist/tsconfig.tsbuildinfo +1 -0
  159. package/node_modules/@playdrop/game-source-git/package.json +28 -0
  160. package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts +2 -2
  161. package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts.map +1 -1
  162. package/node_modules/@playdrop/types/dist/agent-task-terminal.js +15 -9
  163. package/node_modules/@playdrop/types/dist/api.d.ts +728 -164
  164. package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
  165. package/node_modules/@playdrop/types/dist/api.js +60 -11
  166. package/node_modules/@playdrop/types/dist/asset-pack.d.ts +2 -0
  167. package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
  168. package/node_modules/@playdrop/types/dist/asset.d.ts +22 -8
  169. package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
  170. package/node_modules/@playdrop/types/dist/asset.js +26 -26
  171. package/node_modules/@playdrop/types/dist/chat.d.ts +107 -3
  172. package/node_modules/@playdrop/types/dist/chat.d.ts.map +1 -1
  173. package/node_modules/@playdrop/types/dist/chat.js +33 -4
  174. package/node_modules/@playdrop/types/dist/index.d.ts +3 -0
  175. package/node_modules/@playdrop/types/dist/index.d.ts.map +1 -1
  176. package/node_modules/@playdrop/types/dist/index.js +7 -1
  177. package/node_modules/@playdrop/types/dist/public-cache-tags.d.ts +11 -0
  178. package/node_modules/@playdrop/types/dist/public-cache-tags.d.ts.map +1 -0
  179. package/node_modules/@playdrop/types/dist/public-cache-tags.js +78 -0
  180. package/node_modules/@playdrop/types/dist/realtime.d.ts +3 -15
  181. package/node_modules/@playdrop/types/dist/realtime.d.ts.map +1 -1
  182. package/node_modules/@playdrop/types/dist/social.d.ts +64 -0
  183. package/node_modules/@playdrop/types/dist/social.d.ts.map +1 -0
  184. package/node_modules/@playdrop/{boxel-three/dist/src/types.js → types/dist/social.js} +14 -2
  185. package/node_modules/@playdrop/types/dist/spritesheet.d.ts +51 -0
  186. package/node_modules/@playdrop/types/dist/spritesheet.d.ts.map +1 -0
  187. package/node_modules/@playdrop/types/dist/spritesheet.js +73 -0
  188. package/node_modules/@playdrop/types/dist/version.d.ts +86 -58
  189. package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
  190. package/node_modules/@playdrop/types/dist/version.js +111 -0
  191. package/node_modules/@playdrop/types/package.json +14 -0
  192. package/node_modules/@playdrop/vox-three/dist/src/index.d.ts +1 -1
  193. package/node_modules/@playdrop/vox-three/dist/src/index.js +1 -1
  194. package/node_modules/@playdrop/vox-three/dist/src/index.js.map +1 -1
  195. package/node_modules/@playdrop/vox-three/dist/src/vox.d.ts +0 -3
  196. package/node_modules/@playdrop/vox-three/dist/src/vox.js +0 -110
  197. package/node_modules/@playdrop/vox-three/dist/src/vox.js.map +1 -1
  198. package/node_modules/@playdrop/vox-three/dist/test/vox.test.js +0 -18
  199. package/node_modules/@playdrop/vox-three/dist/test/vox.test.js.map +1 -1
  200. package/node_modules/@playdrop/vox-three/package.json +8 -4
  201. package/package.json +9 -11
  202. package/dist/assets/model-artifacts.d.ts +0 -8
  203. package/dist/assets/model-artifacts.js +0 -382
  204. package/dist/assets/model-worker.d.ts +0 -22
  205. package/dist/assets/model-worker.js +0 -123
  206. package/node_modules/@playdrop/ai-client/dist/index.d.ts +0 -441
  207. package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +0 -1
  208. package/node_modules/@playdrop/ai-client/dist/index.js +0 -499
  209. package/node_modules/@playdrop/ai-client/package.json +0 -22
  210. package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.d.ts +0 -13
  211. package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js +0 -141
  212. package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js.map +0 -1
  213. package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.d.ts +0 -47
  214. package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js +0 -313
  215. package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js.map +0 -1
  216. package/node_modules/@playdrop/boxel-core/dist/src/format-utils.d.ts +0 -3
  217. package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js +0 -36
  218. package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js.map +0 -1
  219. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.d.ts +0 -23
  220. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.js +0 -11
  221. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.js.map +0 -1
  222. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.d.ts +0 -4
  223. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.js +0 -21
  224. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.js.map +0 -1
  225. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.d.ts +0 -4
  226. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.js +0 -24
  227. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.js.map +0 -1
  228. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.d.ts +0 -3
  229. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.js.map +0 -1
  230. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.d.ts +0 -3
  231. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js +0 -387
  232. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js.map +0 -1
  233. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.d.ts +0 -6
  234. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.js +0 -3
  235. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.js.map +0 -1
  236. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.d.ts +0 -3
  237. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js +0 -373
  238. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js.map +0 -1
  239. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.d.ts +0 -12
  240. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js +0 -215
  241. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js.map +0 -1
  242. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.d.ts +0 -4
  243. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js +0 -18
  244. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js.map +0 -1
  245. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.d.ts +0 -42
  246. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js +0 -145
  247. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js.map +0 -1
  248. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.d.ts +0 -26
  249. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js +0 -65
  250. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js.map +0 -1
  251. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.d.ts +0 -33
  252. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js +0 -175
  253. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js.map +0 -1
  254. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/humanoid_r15.json +0 -1517
  255. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/humanoid_r6.json +0 -61
  256. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.d.ts +0 -10
  257. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js +0 -23
  258. package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js.map +0 -1
  259. package/node_modules/@playdrop/boxel-core/dist/src/index.d.ts +0 -19
  260. package/node_modules/@playdrop/boxel-core/dist/src/index.js +0 -36
  261. package/node_modules/@playdrop/boxel-core/dist/src/index.js.map +0 -1
  262. package/node_modules/@playdrop/boxel-core/dist/src/materials.d.ts +0 -26
  263. package/node_modules/@playdrop/boxel-core/dist/src/materials.js +0 -184
  264. package/node_modules/@playdrop/boxel-core/dist/src/materials.js.map +0 -1
  265. package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.d.ts +0 -68
  266. package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js +0 -488
  267. package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js.map +0 -1
  268. package/node_modules/@playdrop/boxel-core/dist/src/serialization.d.ts +0 -4
  269. package/node_modules/@playdrop/boxel-core/dist/src/serialization.js +0 -380
  270. package/node_modules/@playdrop/boxel-core/dist/src/serialization.js.map +0 -1
  271. package/node_modules/@playdrop/boxel-core/dist/src/textures.d.ts +0 -29
  272. package/node_modules/@playdrop/boxel-core/dist/src/textures.js +0 -208
  273. package/node_modules/@playdrop/boxel-core/dist/src/textures.js.map +0 -1
  274. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.d.ts +0 -9
  275. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js +0 -312
  276. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js.map +0 -1
  277. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.d.ts +0 -9
  278. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js +0 -154
  279. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js.map +0 -1
  280. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.d.ts +0 -2
  281. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js +0 -121
  282. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js.map +0 -1
  283. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.d.ts +0 -20
  284. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js +0 -389
  285. package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js.map +0 -1
  286. package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.d.ts +0 -3
  287. package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js +0 -206
  288. package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js.map +0 -1
  289. package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.d.ts +0 -12
  290. package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js +0 -81
  291. package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js.map +0 -1
  292. package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.d.ts +0 -12
  293. package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js +0 -318
  294. package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js.map +0 -1
  295. package/node_modules/@playdrop/boxel-core/dist/src/types.d.ts +0 -168
  296. package/node_modules/@playdrop/boxel-core/dist/src/types.js +0 -3
  297. package/node_modules/@playdrop/boxel-core/dist/src/types.js.map +0 -1
  298. package/node_modules/@playdrop/boxel-core/dist/src/validation.d.ts +0 -24
  299. package/node_modules/@playdrop/boxel-core/dist/src/validation.js +0 -620
  300. package/node_modules/@playdrop/boxel-core/dist/src/validation.js.map +0 -1
  301. package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.d.ts +0 -11
  302. package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js +0 -135
  303. package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js.map +0 -1
  304. package/node_modules/@playdrop/boxel-core/dist/src/voxels.d.ts +0 -23
  305. package/node_modules/@playdrop/boxel-core/dist/src/voxels.js +0 -52
  306. package/node_modules/@playdrop/boxel-core/dist/src/voxels.js.map +0 -1
  307. package/node_modules/@playdrop/boxel-core/package.json +0 -19
  308. package/node_modules/@playdrop/boxel-three/dist/src/animations.d.ts +0 -4
  309. package/node_modules/@playdrop/boxel-three/dist/src/animations.js +0 -92
  310. package/node_modules/@playdrop/boxel-three/dist/src/builders.d.ts +0 -8
  311. package/node_modules/@playdrop/boxel-three/dist/src/builders.js +0 -363
  312. package/node_modules/@playdrop/boxel-three/dist/src/context.d.ts +0 -24
  313. package/node_modules/@playdrop/boxel-three/dist/src/context.js +0 -58
  314. package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.d.ts +0 -100
  315. package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +0 -927
  316. package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.d.ts +0 -18
  317. package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +0 -294
  318. package/node_modules/@playdrop/boxel-three/dist/src/index.d.ts +0 -17
  319. package/node_modules/@playdrop/boxel-three/dist/src/index.js +0 -64
  320. package/node_modules/@playdrop/boxel-three/dist/src/instantiate.d.ts +0 -40
  321. package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +0 -96
  322. package/node_modules/@playdrop/boxel-three/dist/src/nodes.d.ts +0 -8
  323. package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +0 -88
  324. package/node_modules/@playdrop/boxel-three/dist/src/overlays.d.ts +0 -7
  325. package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +0 -123
  326. package/node_modules/@playdrop/boxel-three/dist/src/primitives.d.ts +0 -4
  327. package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +0 -48
  328. package/node_modules/@playdrop/boxel-three/dist/src/scene.d.ts +0 -3
  329. package/node_modules/@playdrop/boxel-three/dist/src/scene.js +0 -168
  330. package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.d.ts +0 -29
  331. package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +0 -623
  332. package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.d.ts +0 -13
  333. package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +0 -133
  334. package/node_modules/@playdrop/boxel-three/dist/src/textures.d.ts +0 -17
  335. package/node_modules/@playdrop/boxel-three/dist/src/textures.js +0 -216
  336. package/node_modules/@playdrop/boxel-three/dist/src/types.d.ts +0 -112
  337. package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.d.ts +0 -28
  338. package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +0 -344
  339. package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.d.ts +0 -24
  340. package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +0 -113
  341. package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.d.ts +0 -1
  342. package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +0 -137
  343. package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.d.ts +0 -20
  344. package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +0 -85
  345. package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.d.ts +0 -1
  346. package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +0 -104
  347. package/node_modules/@playdrop/boxel-three/dist/test/index.test.d.ts +0 -1
  348. package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +0 -30
  349. package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.d.ts +0 -1
  350. package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +0 -88
  351. package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.d.ts +0 -1
  352. package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +0 -42
  353. package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.d.ts +0 -1
  354. package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +0 -73
  355. package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.d.ts +0 -1
  356. package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +0 -85
  357. package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.d.ts +0 -1
  358. package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +0 -73
  359. package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.d.ts +0 -1
  360. package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +0 -136
  361. package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.d.ts +0 -1
  362. package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +0 -42
  363. package/node_modules/@playdrop/boxel-three/package.json +0 -28
@@ -1,927 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var glb_exports = {};
19
- __export(glb_exports, {
20
- __testing: () => __testing,
21
- createBoxelSceneGraph: () => createBoxelSceneGraph,
22
- exportModelToGLB: () => exportModelToGLB
23
- });
24
- module.exports = __toCommonJS(glb_exports);
25
- var import_animations = require("../animations.js");
26
- var import_primitives = require("../primitives.js");
27
- var import_scene = require("../scene.js");
28
- var import_skinned_mesh = require("../skinned-mesh.js");
29
- var import_faces = require("../voxels/faces.js");
30
- const DEFAULT_COLOR = [59, 130, 246];
31
- const DEFAULT_OPACITY = 0.45;
32
- const ATLAS_PADDING = 1;
33
- const FALLBACK_TEXTURE_ID = "__fallback__";
34
- const OVERLAY_FALLBACK_TEXTURE_ID = "__overlay_fallback__";
35
- async function exportModelToGLB(options) {
36
- const { THREE, GLTFExporterCtor, model, mode = "merged", binary = true, animationIds } = options;
37
- if (mode === "skinned") {
38
- const skinned = (0, import_skinned_mesh.buildEntitySkinnedMesh)({ THREE, entity: model });
39
- const root = new THREE.Group();
40
- root.add(skinned.mesh);
41
- root.updateMatrixWorld(true);
42
- const nodeLookup = /* @__PURE__ */ new Map();
43
- skinned.boneMap.forEach((bone, nodeId) => nodeLookup.set(nodeId, bone));
44
- const animations = (0, import_animations.buildAnimations)(THREE, model, nodeLookup);
45
- const clips = animationIds === null ? [] : animations.filter((animation) => {
46
- if (!Array.isArray(animationIds) || animationIds.length === 0)
47
- return true;
48
- return animationIds.includes(animation.id);
49
- }).map((animation) => animation.clip);
50
- const exporter2 = new GLTFExporterCtor();
51
- const dispose = () => {
52
- skinned.dispose();
53
- };
54
- return new Promise((resolve, reject) => {
55
- try {
56
- exporter2.parse(root, (result) => {
57
- try {
58
- const blob = result instanceof ArrayBuffer ? new Blob([result], { type: "model/gltf-binary" }) : new Blob([JSON.stringify(result)], { type: "model/gltf+json" });
59
- dispose();
60
- resolve(blob);
61
- } catch (error) {
62
- dispose();
63
- reject(error);
64
- }
65
- }, (error) => {
66
- dispose();
67
- reject(error instanceof Error ? error : new Error("gltf_export_failed"));
68
- }, { binary, animations: clips });
69
- } catch (error) {
70
- dispose();
71
- reject(error instanceof Error ? error : new Error(String(error)));
72
- }
73
- });
74
- }
75
- const context = createExportContext(THREE, model);
76
- const sceneGraph = buildSceneGraph(context, mode);
77
- const exporter = new GLTFExporterCtor();
78
- const exportScene = new THREE.Scene();
79
- exportScene.background = null;
80
- exportScene.add(sceneGraph.root);
81
- exportScene.updateMatrixWorld(true);
82
- const animationClips = resolveAnimationClips(sceneGraph, mode, animationIds);
83
- return new Promise((resolve, reject) => {
84
- try {
85
- exporter.parse(exportScene, (result) => {
86
- try {
87
- const blob = result instanceof ArrayBuffer ? new Blob([result], { type: "model/gltf-binary" }) : new Blob([JSON.stringify(result)], { type: "model/gltf+json" });
88
- sceneGraph.dispose();
89
- disposeExportContext(context);
90
- resolve(blob);
91
- } catch (error) {
92
- sceneGraph.dispose();
93
- disposeExportContext(context);
94
- reject(error);
95
- }
96
- }, (error) => {
97
- sceneGraph.dispose();
98
- disposeExportContext(context);
99
- reject(error instanceof Error ? error : new Error("gltf_export_failed"));
100
- }, { binary, animations: animationClips });
101
- } catch (error) {
102
- sceneGraph.dispose();
103
- disposeExportContext(context);
104
- reject(error instanceof Error ? error : new Error(String(error)));
105
- }
106
- });
107
- }
108
- function createBoxelSceneGraph(options) {
109
- const { THREE, model } = options;
110
- const mode = options.mode ?? "merged";
111
- const context = createExportContext(THREE, model);
112
- const sceneGraph = buildSceneGraph(context, mode);
113
- let disposed = false;
114
- const dispose = () => {
115
- if (disposed)
116
- return;
117
- sceneGraph.dispose();
118
- disposeExportContext(context);
119
- disposed = true;
120
- };
121
- return {
122
- root: sceneGraph.root,
123
- nodeLookup: sceneGraph.nodeLookup,
124
- animations: sceneGraph.animations,
125
- dispose
126
- };
127
- }
128
- function createExportContext(THREE, model) {
129
- const materialsById = new Map(model.materials.map((material) => [material.id, material]));
130
- const primitivesById = new Map(model.primitives.map((primitive) => [primitive.id, primitive]));
131
- const texturesById = new Map(model.textures.map((texture) => [texture.id, texture]));
132
- const patternsById = new Map(model.patterns.map((pattern) => [pattern.id, pattern]));
133
- const voxelAtlasEntries = [];
134
- const voxelSurfacesByPrimitive = /* @__PURE__ */ new Map();
135
- let overlayFallbackNeeded = false;
136
- model.primitives.forEach((primitive) => {
137
- if (primitive.kind === "textured_box") {
138
- if (hasOverlayTextures(primitive)) {
139
- overlayFallbackNeeded = true;
140
- }
141
- }
142
- if (primitive.kind !== "voxel_box") {
143
- return;
144
- }
145
- const surfaces = (0, import_faces.generateVoxelFaceSurfaces)({
146
- primitive,
147
- materialsById,
148
- defaultColor: DEFAULT_COLOR
149
- });
150
- if (surfaces.length === 0) {
151
- return;
152
- }
153
- const cachedSurfaces = surfaces.map((surface, index) => {
154
- const textureId = `__voxel__${primitive.id}__${surface.face}__${index}`;
155
- voxelAtlasEntries.push({
156
- id: textureId,
157
- width: surface.textureWidth,
158
- height: surface.textureHeight,
159
- color: surface.color,
160
- emissive: surface.emissive,
161
- hasEmissive: surface.hasEmissive,
162
- hasTransparency: surface.hasTransparency
163
- });
164
- return { ...surface, textureId };
165
- });
166
- voxelSurfacesByPrimitive.set(primitive.id, cachedSurfaces);
167
- });
168
- const extraEntries = [...voxelAtlasEntries];
169
- if (overlayFallbackNeeded) {
170
- extraEntries.push(buildOverlayFallbackTexturePixels());
171
- }
172
- const usedTextureIds = collectUsedTextureIds(model, primitivesById);
173
- const atlas = buildTextureAtlas({ THREE, materialsById, texturesById, patternsById, usedTextureIds }, extraEntries);
174
- return {
175
- THREE,
176
- model,
177
- materialsById,
178
- primitivesById,
179
- texturesById,
180
- patternsById,
181
- atlas,
182
- voxelSurfacesByPrimitive,
183
- plainMaterialCache: /* @__PURE__ */ new Map()
184
- };
185
- }
186
- function disposeExportContext(context) {
187
- if (context.atlas) {
188
- context.atlas.map.dispose();
189
- context.atlas.emissiveMap?.dispose();
190
- }
191
- context.plainMaterialCache.forEach((material) => material.dispose());
192
- context.plainMaterialCache.clear();
193
- }
194
- function buildTextureAtlas(options, extraEntries = []) {
195
- const { THREE, materialsById, texturesById, patternsById, usedTextureIds } = options;
196
- if (usedTextureIds.size === 0) {
197
- if (extraEntries.length === 0) {
198
- return null;
199
- }
200
- }
201
- const entries = [];
202
- for (const textureId of usedTextureIds) {
203
- const textureDef = texturesById.get(textureId);
204
- if (!textureDef)
205
- continue;
206
- const pattern = patternsById.get(textureDef.pattern);
207
- if (!pattern)
208
- continue;
209
- entries.push(buildTexturePixels(textureDef, pattern, materialsById));
210
- }
211
- if (extraEntries.length > 0) {
212
- extraEntries.forEach((entry) => {
213
- entries.push(entry);
214
- });
215
- }
216
- const fallbackEntry = buildFallbackTexturePixels();
217
- entries.push(fallbackEntry);
218
- const paddedWidths = entries.map((entry) => entry.width + ATLAS_PADDING * 2);
219
- const paddedHeights = entries.map((entry) => entry.height + ATLAS_PADDING * 2);
220
- const cellWidth = Math.max(...paddedWidths);
221
- const cellHeight = Math.max(...paddedHeights);
222
- const textureCount = entries.length;
223
- const columns = Math.max(1, Math.ceil(Math.sqrt(textureCount)));
224
- const rows = Math.max(1, Math.ceil(textureCount / columns));
225
- const atlasWidth = THREE.MathUtils.ceilPowerOfTwo(columns * cellWidth);
226
- const atlasHeight = THREE.MathUtils.ceilPowerOfTwo(rows * cellHeight);
227
- const colorData = new Uint8Array(atlasWidth * atlasHeight * 4);
228
- const emissiveData = new Uint8Array(atlasWidth * atlasHeight * 4);
229
- let hasEmissive = false;
230
- let hasTransparency = false;
231
- const regions = /* @__PURE__ */ new Map();
232
- entries.forEach((entry, index) => {
233
- const column = index % columns;
234
- const row = Math.floor(index / columns);
235
- const originX = column * cellWidth;
236
- const originY = row * cellHeight;
237
- const paddedX = originX + ATLAS_PADDING;
238
- const paddedY = originY + ATLAS_PADDING;
239
- blitTexture(entry.color, entry.width, entry.height, atlasWidth, colorData, paddedX, paddedY);
240
- extendEdgePixels(colorData, entry.width, entry.height, atlasWidth, atlasHeight, paddedX, paddedY);
241
- if (entry.hasEmissive && entry.emissive) {
242
- blitTexture(entry.emissive, entry.width, entry.height, atlasWidth, emissiveData, paddedX, paddedY);
243
- extendEdgePixels(emissiveData, entry.width, entry.height, atlasWidth, atlasHeight, paddedX, paddedY);
244
- hasEmissive = true;
245
- } else {
246
- fillTransparentRegion(emissiveData, entry.width, entry.height, atlasWidth, paddedX, paddedY);
247
- }
248
- hasTransparency = hasTransparency || entry.hasTransparency;
249
- const region = {
250
- uMin: (paddedX + 0) / atlasWidth,
251
- vMin: (paddedY + 0) / atlasHeight,
252
- uMax: (paddedX + entry.width) / atlasWidth,
253
- vMax: (paddedY + entry.height) / atlasHeight
254
- };
255
- regions.set(entry.id, region);
256
- });
257
- const map = new THREE.DataTexture(colorData, atlasWidth, atlasHeight);
258
- map.needsUpdate = true;
259
- map.magFilter = THREE.NearestFilter;
260
- map.minFilter = THREE.NearestFilter;
261
- map.wrapS = THREE.ClampToEdgeWrapping;
262
- map.wrapT = THREE.ClampToEdgeWrapping;
263
- map.flipY = false;
264
- if ("colorSpace" in map) {
265
- map.colorSpace = THREE.SRGBColorSpace ?? map.colorSpace;
266
- } else if ("encoding" in map) {
267
- map.encoding = THREE.sRGBEncoding ?? map.encoding;
268
- }
269
- let emissiveMap = null;
270
- if (hasEmissive) {
271
- emissiveMap = new THREE.DataTexture(emissiveData, atlasWidth, atlasHeight);
272
- emissiveMap.needsUpdate = true;
273
- emissiveMap.magFilter = THREE.NearestFilter;
274
- emissiveMap.minFilter = THREE.NearestFilter;
275
- emissiveMap.wrapS = THREE.ClampToEdgeWrapping;
276
- emissiveMap.wrapT = THREE.ClampToEdgeWrapping;
277
- emissiveMap.flipY = false;
278
- }
279
- const fallbackRegion = regions.get(FALLBACK_TEXTURE_ID) ?? {
280
- uMin: 0,
281
- vMin: 0,
282
- uMax: 1,
283
- vMax: 1
284
- };
285
- return { regions, fallbackRegion, map, emissiveMap, hasTransparency };
286
- }
287
- function buildTexturePixels(textureDef, pattern, materialsById) {
288
- const [width, height] = pattern.size;
289
- const color = new Uint8Array(width * height * 4);
290
- const emissive = new Uint8Array(width * height * 4);
291
- let hasEmissive = false;
292
- let hasTransparency = false;
293
- for (let y = 0; y < height; y += 1) {
294
- for (let x = 0; x < width; x += 1) {
295
- const sourceIndex = y * width + x;
296
- const targetY = height - 1 - y;
297
- const targetIndex = (targetY * width + x) * 4;
298
- const paletteIndex = pattern.data[sourceIndex];
299
- const materialId = textureDef.materials[paletteIndex];
300
- const material = materialId ? materialsById.get(materialId) : void 0;
301
- const baseColor = material?.baseColor ?? DEFAULT_COLOR;
302
- const opacity = material?.opacity !== void 0 ? clamp(material.opacity, 0, 1) : 1;
303
- color[targetIndex] = baseColor[0];
304
- color[targetIndex + 1] = baseColor[1];
305
- color[targetIndex + 2] = baseColor[2];
306
- color[targetIndex + 3] = Math.round(opacity * 255);
307
- if (opacity < 1) {
308
- hasTransparency = true;
309
- }
310
- if (material?.emissiveColor) {
311
- emissive[targetIndex] = material.emissiveColor[0];
312
- emissive[targetIndex + 1] = material.emissiveColor[1];
313
- emissive[targetIndex + 2] = material.emissiveColor[2];
314
- emissive[targetIndex + 3] = 255;
315
- hasEmissive = true;
316
- } else {
317
- emissive[targetIndex] = 0;
318
- emissive[targetIndex + 1] = 0;
319
- emissive[targetIndex + 2] = 0;
320
- emissive[targetIndex + 3] = 0;
321
- }
322
- }
323
- }
324
- return {
325
- id: textureDef.id,
326
- width,
327
- height,
328
- color,
329
- emissive: hasEmissive ? emissive : void 0,
330
- hasEmissive,
331
- hasTransparency
332
- };
333
- }
334
- function buildFallbackTexturePixels() {
335
- const color = new Uint8Array(4);
336
- color[0] = DEFAULT_COLOR[0];
337
- color[1] = DEFAULT_COLOR[1];
338
- color[2] = DEFAULT_COLOR[2];
339
- color[3] = 255;
340
- const emissive = new Uint8Array(4);
341
- emissive[0] = 0;
342
- emissive[1] = 0;
343
- emissive[2] = 0;
344
- emissive[3] = 0;
345
- return {
346
- id: FALLBACK_TEXTURE_ID,
347
- width: 1,
348
- height: 1,
349
- color,
350
- emissive,
351
- hasEmissive: false,
352
- hasTransparency: false
353
- };
354
- }
355
- function buildOverlayFallbackTexturePixels() {
356
- const color = new Uint8Array(4);
357
- color[0] = 0;
358
- color[1] = 0;
359
- color[2] = 0;
360
- color[3] = 0;
361
- const emissive = new Uint8Array(4);
362
- emissive[0] = 0;
363
- emissive[1] = 0;
364
- emissive[2] = 0;
365
- emissive[3] = 0;
366
- return {
367
- id: OVERLAY_FALLBACK_TEXTURE_ID,
368
- width: 1,
369
- height: 1,
370
- color,
371
- emissive,
372
- hasEmissive: false,
373
- hasTransparency: true
374
- };
375
- }
376
- function blitTexture(source, width, height, atlasWidth, target, offsetX, offsetY) {
377
- for (let y = 0; y < height; y += 1) {
378
- for (let x = 0; x < width; x += 1) {
379
- const sx = x;
380
- const sy = y;
381
- const sourceIndex = (sy * width + sx) * 4;
382
- const tx = offsetX + x;
383
- const ty = offsetY + y;
384
- const targetIndex = (ty * atlasWidth + tx) * 4;
385
- target[targetIndex] = source[sourceIndex];
386
- target[targetIndex + 1] = source[sourceIndex + 1];
387
- target[targetIndex + 2] = source[sourceIndex + 2];
388
- target[targetIndex + 3] = source[sourceIndex + 3];
389
- }
390
- }
391
- }
392
- function fillTransparentRegion(target, width, height, atlasWidth, offsetX, offsetY) {
393
- for (let y = 0; y < height; y += 1) {
394
- for (let x = 0; x < width; x += 1) {
395
- const tx = offsetX + x;
396
- const ty = offsetY + y;
397
- const targetIndex = (ty * atlasWidth + tx) * 4;
398
- target[targetIndex] = 0;
399
- target[targetIndex + 1] = 0;
400
- target[targetIndex + 2] = 0;
401
- target[targetIndex + 3] = 0;
402
- }
403
- }
404
- }
405
- function extendEdgePixels(target, width, height, atlasWidth, atlasHeight, offsetX, offsetY) {
406
- const startX = offsetX;
407
- const endX = offsetX + width - 1;
408
- const startY = offsetY;
409
- const endY = offsetY + height - 1;
410
- if (startY > 0) {
411
- for (let x = startX; x <= endX; x += 1) {
412
- copyPixel(target, atlasWidth, x, startY, x, startY - 1);
413
- }
414
- }
415
- if (endY + 1 < atlasHeight) {
416
- for (let x = startX; x <= endX; x += 1) {
417
- copyPixel(target, atlasWidth, x, endY, x, endY + 1);
418
- }
419
- }
420
- if (startX > 0) {
421
- for (let y = startY; y <= endY; y += 1) {
422
- copyPixel(target, atlasWidth, startX, y, startX - 1, y);
423
- }
424
- }
425
- if (endX + 1 < atlasWidth) {
426
- for (let y = startY; y <= endY; y += 1) {
427
- copyPixel(target, atlasWidth, endX, y, endX + 1, y);
428
- }
429
- }
430
- const cornerTargets = [];
431
- if (startX > 0 && startY > 0)
432
- cornerTargets.push({ sx: startX, sy: startY, dx: startX - 1, dy: startY - 1 });
433
- if (startX > 0 && endY + 1 < atlasHeight)
434
- cornerTargets.push({ sx: startX, sy: endY, dx: startX - 1, dy: endY + 1 });
435
- if (endX + 1 < atlasWidth && startY > 0)
436
- cornerTargets.push({ sx: endX, sy: startY, dx: endX + 1, dy: startY - 1 });
437
- if (endX + 1 < atlasWidth && endY + 1 < atlasHeight)
438
- cornerTargets.push({ sx: endX, sy: endY, dx: endX + 1, dy: endY + 1 });
439
- cornerTargets.forEach(({ sx, sy, dx, dy }) => {
440
- copyPixel(target, atlasWidth, sx, sy, dx, dy);
441
- });
442
- }
443
- function copyPixel(buffer, atlasWidth, sourceX, sourceY, destX, destY) {
444
- const sourceIndex = (sourceY * atlasWidth + sourceX) * 4;
445
- const destIndex = (destY * atlasWidth + destX) * 4;
446
- buffer[destIndex] = buffer[sourceIndex];
447
- buffer[destIndex + 1] = buffer[sourceIndex + 1];
448
- buffer[destIndex + 2] = buffer[sourceIndex + 2];
449
- buffer[destIndex + 3] = buffer[sourceIndex + 3];
450
- }
451
- function clamp(value, min, max) {
452
- return Math.min(max, Math.max(min, value));
453
- }
454
- function hasOverlayTextures(box) {
455
- return Boolean(box.topOverlay || box.bottomOverlay || box.northOverlay || box.southOverlay || box.eastOverlay || box.westOverlay || box.sidesOverlay || box.allOverlay);
456
- }
457
- function collectUsedTextureIds(model, primitivesById) {
458
- const textureIds = /* @__PURE__ */ new Set();
459
- const visitPrimitive = (primitive, visited) => {
460
- if (visited.has(primitive.id))
461
- return;
462
- visited.add(primitive.id);
463
- switch (primitive.kind) {
464
- case "plain_box":
465
- case "voxel_box":
466
- break;
467
- case "textured_box": {
468
- const textured = primitive;
469
- import_faces.FACE_ORDER.forEach((face) => {
470
- const textureId = getFaceTextureId(textured, face);
471
- if (textureId)
472
- textureIds.add(textureId);
473
- });
474
- import_faces.FACE_ORDER.forEach((face) => {
475
- const overlayId = getOverlayTextureId(textured, face);
476
- if (overlayId)
477
- textureIds.add(overlayId);
478
- });
479
- break;
480
- }
481
- case "combo_box": {
482
- const combo = primitive;
483
- combo.slots.forEach((slot) => {
484
- const child = primitivesById.get(slot.primitive);
485
- if (child) {
486
- visitPrimitive(child, new Set(visited));
487
- }
488
- });
489
- break;
490
- }
491
- default:
492
- break;
493
- }
494
- };
495
- const traverseNode = (node) => {
496
- if (node.mesh) {
497
- const primitive = primitivesById.get(node.mesh);
498
- if (primitive) {
499
- visitPrimitive(primitive, /* @__PURE__ */ new Set());
500
- }
501
- }
502
- node.children.forEach(traverseNode);
503
- };
504
- traverseNode(model.geometry.root);
505
- return textureIds;
506
- }
507
- function buildSceneGraph(context, mode) {
508
- if (mode === "merged") {
509
- const scene2 = (0, import_scene.createBoxelScene)({ THREE: context.THREE, entity: context.model });
510
- const root = buildMergedGroupFromScene(context, scene2);
511
- scene2.dispose();
512
- const dispose = () => {
513
- const geometries = /* @__PURE__ */ new Set();
514
- const materials = /* @__PURE__ */ new Set();
515
- root.traverse((object) => {
516
- if (object instanceof context.THREE.Mesh) {
517
- const mesh = object;
518
- if (mesh.geometry)
519
- geometries.add(mesh.geometry);
520
- const material = mesh.material;
521
- if (Array.isArray(material))
522
- material.forEach((mat) => materials.add(mat));
523
- else if (material)
524
- materials.add(material);
525
- }
526
- });
527
- for (const geometry of geometries) {
528
- geometry.dispose?.();
529
- }
530
- for (const materialEntry of materials) {
531
- const material = materialEntry;
532
- material.map?.dispose?.();
533
- material.emissiveMap?.dispose?.();
534
- material.dispose?.();
535
- }
536
- };
537
- return { root, nodeLookup: /* @__PURE__ */ new Map(), animations: [], dispose };
538
- }
539
- if (mode === "skinned") {
540
- const skinned = (0, import_skinned_mesh.buildEntitySkinnedMesh)({ THREE: context.THREE, entity: context.model });
541
- const root = new context.THREE.Group();
542
- root.add(skinned.mesh);
543
- const nodeLookup2 = /* @__PURE__ */ new Map();
544
- skinned.boneMap.forEach((bone, nodeId) => nodeLookup2.set(nodeId, bone));
545
- const animations = (0, import_animations.buildAnimations)(context.THREE, context.model, nodeLookup2);
546
- const dispose = () => {
547
- skinned.dispose();
548
- };
549
- return {
550
- root,
551
- nodeLookup: nodeLookup2,
552
- animations,
553
- dispose
554
- };
555
- }
556
- const scene = (0, import_scene.createBoxelScene)({ THREE: context.THREE, entity: context.model });
557
- const nodeLookup = /* @__PURE__ */ new Map();
558
- scene.nodes.forEach((meta) => {
559
- nodeLookup.set(meta.id, meta.object);
560
- });
561
- return {
562
- root: scene.root,
563
- nodeLookup,
564
- animations: scene.animations,
565
- dispose: scene.dispose
566
- };
567
- }
568
- function resolveAnimationClips(sceneGraph, mode, animationIds) {
569
- if (mode !== "hierarchical")
570
- return [];
571
- if (animationIds === null)
572
- return [];
573
- if (Array.isArray(animationIds) && animationIds.length === 0)
574
- return [];
575
- const allowed = Array.isArray(animationIds) && animationIds.length > 0 ? new Set(animationIds) : null;
576
- return sceneGraph.animations.filter((animation) => allowed ? allowed.has(animation.id) : true).map((animation) => animation.clip);
577
- }
578
- function buildMergedGroupFromScene(context, scene) {
579
- const { THREE, materialsById, primitivesById, atlas, voxelSurfacesByPrimitive } = context;
580
- const group = new THREE.Group();
581
- const texturedAccumulator = atlas ? new MeshAccumulator(true) : null;
582
- const plainBuckets = /* @__PURE__ */ new Map();
583
- scene.root.updateMatrixWorld(true);
584
- scene.root.traverse((object) => {
585
- if (!(object instanceof THREE.Mesh)) {
586
- return;
587
- }
588
- const mesh = object;
589
- const primitiveId = mesh.userData?.primitiveId;
590
- const matrix = mesh.matrixWorld.clone();
591
- const sizeFromUserData = mesh.userData?.size;
592
- if (!primitiveId) {
593
- if (mesh.userData?.placeholder && sizeFromUserData) {
594
- const bucket = ensurePlainBucket({
595
- THREE,
596
- plainBuckets,
597
- options: {
598
- baseColor: DEFAULT_COLOR,
599
- emissive: null,
600
- opacity: DEFAULT_OPACITY
601
- }
602
- });
603
- appendBoxToAccumulator({
604
- THREE,
605
- accumulator: bucket.accumulator,
606
- size: sizeFromUserData,
607
- matrix
608
- });
609
- }
610
- return;
611
- }
612
- const primitive = primitivesById.get(primitiveId);
613
- if (!primitive) {
614
- console.warn("[entity-export] primitive not found for merged export", primitiveId);
615
- return;
616
- }
617
- switch (primitive.kind) {
618
- case "plain_box": {
619
- const plain = primitive;
620
- const materialDef = materialsById.get(plain.material);
621
- const bucket = ensurePlainBucket({
622
- THREE,
623
- plainBuckets,
624
- options: {
625
- baseColor: materialDef?.baseColor ?? DEFAULT_COLOR,
626
- emissive: materialDef?.emissiveColor ?? null,
627
- opacity: materialDef?.opacity ?? 1
628
- }
629
- });
630
- appendBoxToAccumulator({ THREE, accumulator: bucket.accumulator, size: plain.size, matrix });
631
- break;
632
- }
633
- case "textured_box": {
634
- const box = primitive;
635
- const isOverlayMesh = mesh.userData?.overlay === true;
636
- if (!atlas || !texturedAccumulator) {
637
- if (isOverlayMesh) {
638
- break;
639
- }
640
- const bucket = ensurePlainBucket({
641
- THREE,
642
- plainBuckets,
643
- options: { baseColor: DEFAULT_COLOR, emissive: null, opacity: 1 }
644
- });
645
- appendBoxToAccumulator({ THREE, accumulator: bucket.accumulator, size: box.size, matrix });
646
- break;
647
- }
648
- appendTexturedBoxToAccumulator({
649
- THREE,
650
- accumulator: texturedAccumulator,
651
- atlas,
652
- box,
653
- matrix,
654
- size: isOverlayMesh ? sizeFromUserData ?? box.size : void 0,
655
- getTextureId: isOverlayMesh ? (candidate, face) => getOverlayTextureId(candidate, face) ?? OVERLAY_FALLBACK_TEXTURE_ID : void 0
656
- });
657
- break;
658
- }
659
- case "voxel_box": {
660
- const voxel = primitive;
661
- if (!voxel.voxels || voxel.voxels.length === 0) {
662
- break;
663
- }
664
- const surfaces = voxelSurfacesByPrimitive.get(voxel.id);
665
- if (!atlas || !texturedAccumulator || !surfaces || surfaces.length === 0) {
666
- const fallbackSize = voxel.size ?? [1, 1, 1];
667
- const bucket = ensurePlainBucket({
668
- THREE,
669
- plainBuckets,
670
- options: { baseColor: DEFAULT_COLOR, emissive: null, opacity: DEFAULT_OPACITY }
671
- });
672
- appendBoxToAccumulator({ THREE, accumulator: bucket.accumulator, size: fallbackSize, matrix });
673
- break;
674
- }
675
- surfaces.forEach((surface) => {
676
- const region = atlas.regions.get(surface.textureId) ?? atlas.fallbackRegion;
677
- const geometry = new THREE.BufferGeometry();
678
- geometry.setAttribute("position", new THREE.Float32BufferAttribute(surface.geometry.positions, 3));
679
- geometry.setAttribute("normal", new THREE.Float32BufferAttribute(surface.geometry.normals, 3));
680
- const baseUVAttr = new THREE.Float32BufferAttribute(surface.geometry.uvs, 2);
681
- geometry.setAttribute("uv", baseUVAttr);
682
- geometry.setIndex(new THREE.BufferAttribute(surface.geometry.indices, 1));
683
- const customUVs = new Float32Array(baseUVAttr.count * 2);
684
- const uSpan = region.uMax - region.uMin;
685
- const vSpan = region.vMax - region.vMin;
686
- for (let i = 0; i < baseUVAttr.count; i += 1) {
687
- const baseU = baseUVAttr.getX(i);
688
- const baseV = baseUVAttr.getY(i);
689
- customUVs[i * 2] = region.uMin + baseU * uSpan;
690
- customUVs[i * 2 + 1] = region.vMin + baseV * vSpan;
691
- }
692
- texturedAccumulator.appendGeometry({ THREE, geometry, matrix, customUVs });
693
- });
694
- break;
695
- }
696
- case "combo_box":
697
- break;
698
- default:
699
- break;
700
- }
701
- });
702
- if (texturedAccumulator && texturedAccumulator.hasGeometry()) {
703
- const geometry = texturedAccumulator.build(THREE);
704
- const material = createTexturedMaterial(THREE, atlas);
705
- const mesh = new THREE.Mesh(geometry, material);
706
- group.add(mesh);
707
- }
708
- for (const bucket of plainBuckets.values()) {
709
- if (!bucket.accumulator.hasGeometry())
710
- continue;
711
- const geometry = bucket.accumulator.build(THREE);
712
- const mesh = new THREE.Mesh(geometry, bucket.material);
713
- group.add(mesh);
714
- }
715
- return group;
716
- }
717
- function appendTexturedBoxToAccumulator(options) {
718
- const { THREE, accumulator, atlas, box, matrix } = options;
719
- const size = options.size ?? box.size;
720
- const textureResolver = options.getTextureId ?? getFaceTextureId;
721
- const geometry = (0, import_primitives.createBoxGeometry)(THREE, size);
722
- const uvAttr = geometry.getAttribute("uv");
723
- const customUVs = new Float32Array(uvAttr.count * 2);
724
- customUVs.set(uvAttr.array);
725
- const faceVertexSets = (0, import_primitives.collectGroupVertexIndices)(geometry);
726
- if (faceVertexSets.length === 0) {
727
- geometry.dispose();
728
- return;
729
- }
730
- import_faces.FACE_ORDER.forEach((face, faceIndex) => {
731
- const resolvedId = textureResolver(box, face);
732
- const region = atlas.regions.get(resolvedId ?? FALLBACK_TEXTURE_ID) ?? atlas.fallbackRegion;
733
- const vertexIndices = faceVertexSets[faceIndex];
734
- if (!vertexIndices || vertexIndices.size === 0)
735
- return;
736
- const uSpan = region.uMax - region.uMin;
737
- const vSpan = region.vMax - region.vMin;
738
- vertexIndices.forEach((vertexIndex) => {
739
- const baseU = uvAttr.getX(vertexIndex);
740
- const baseV = uvAttr.getY(vertexIndex);
741
- customUVs[vertexIndex * 2] = region.uMin + baseU * uSpan;
742
- customUVs[vertexIndex * 2 + 1] = region.vMin + baseV * vSpan;
743
- });
744
- });
745
- accumulator.appendGeometry({ THREE, geometry, matrix, customUVs });
746
- }
747
- function appendBoxToAccumulator(options) {
748
- const { THREE, accumulator, size, matrix } = options;
749
- const geometry = (0, import_primitives.createBoxGeometry)(THREE, size);
750
- accumulator.appendGeometry({ THREE, geometry, matrix });
751
- }
752
- function getFaceTextureId(box, face) {
753
- switch (face) {
754
- case "top":
755
- return box.top ?? box.all ?? box.sides;
756
- case "bottom":
757
- return box.bottom ?? box.all ?? box.sides;
758
- case "north":
759
- return box.north ?? box.sides ?? box.all;
760
- case "south":
761
- return box.south ?? box.sides ?? box.all;
762
- case "east":
763
- return box.east ?? box.sides ?? box.all;
764
- case "west":
765
- return box.west ?? box.sides ?? box.all;
766
- default:
767
- return box.all;
768
- }
769
- }
770
- function getOverlayTextureId(box, face) {
771
- switch (face) {
772
- case "top":
773
- return box.topOverlay ?? box.allOverlay ?? box.sidesOverlay;
774
- case "bottom":
775
- return box.bottomOverlay ?? box.allOverlay ?? box.sidesOverlay;
776
- case "north":
777
- return box.northOverlay ?? box.sidesOverlay ?? box.allOverlay;
778
- case "south":
779
- return box.southOverlay ?? box.sidesOverlay ?? box.allOverlay;
780
- case "east":
781
- return box.eastOverlay ?? box.sidesOverlay ?? box.allOverlay;
782
- case "west":
783
- return box.westOverlay ?? box.sidesOverlay ?? box.allOverlay;
784
- default:
785
- return box.allOverlay ?? box.sidesOverlay;
786
- }
787
- }
788
- function createTexturedMaterial(THREE, atlas) {
789
- const params = {
790
- map: atlas.map,
791
- metalness: 0,
792
- roughness: 1,
793
- transparent: atlas.hasTransparency
794
- };
795
- if (atlas.emissiveMap) {
796
- params.emissiveMap = atlas.emissiveMap;
797
- }
798
- const material = new THREE.MeshStandardMaterial(params);
799
- if (atlas.emissiveMap) {
800
- material.emissive = new THREE.Color(1, 1, 1);
801
- }
802
- return material;
803
- }
804
- function createPlainMaterial(THREE, options) {
805
- const { baseColor, emissive, opacity } = options;
806
- const material = new THREE.MeshStandardMaterial({
807
- color: new THREE.Color(baseColor[0] / 255, baseColor[1] / 255, baseColor[2] / 255),
808
- metalness: 0,
809
- roughness: 1,
810
- transparent: opacity < 1,
811
- opacity
812
- });
813
- if (emissive) {
814
- material.emissive = new THREE.Color(emissive[0] / 255, emissive[1] / 255, emissive[2] / 255);
815
- }
816
- material.userData = material.userData ?? {};
817
- material.userData.gltfExtras = {
818
- playdropBaseColor: baseColor,
819
- playdropOpacity: opacity
820
- };
821
- return material;
822
- }
823
- function ensurePlainBucket({ THREE, plainBuckets, options }) {
824
- const key = plainMaterialKey(options);
825
- let bucket = plainBuckets.get(key);
826
- if (!bucket) {
827
- bucket = { accumulator: new MeshAccumulator(false), material: createPlainMaterial(THREE, options) };
828
- plainBuckets.set(key, bucket);
829
- }
830
- return bucket;
831
- }
832
- function plainMaterialKey(options) {
833
- const base = `${options.baseColor[0]}-${options.baseColor[1]}-${options.baseColor[2]}`;
834
- const emissive = options.emissive ? `${options.emissive[0]}-${options.emissive[1]}-${options.emissive[2]}` : "none";
835
- const opacity = options.opacity.toFixed(4);
836
- return `plain|${base}|${emissive}|${opacity}`;
837
- }
838
- class MeshAccumulator {
839
- constructor(withUVs) {
840
- this.positions = [];
841
- this.normals = [];
842
- this.indices = [];
843
- this.vertexCount = 0;
844
- this.uvs = withUVs ? [] : null;
845
- }
846
- appendGeometry(options) {
847
- const { THREE, geometry, matrix, customUVs } = options;
848
- const rawPositionAttr = geometry.getAttribute("position");
849
- const rawNormalAttr = geometry.getAttribute("normal");
850
- const rawUvAttr = geometry.getAttribute("uv");
851
- const indexAttr = geometry.index;
852
- if (!rawPositionAttr || !rawNormalAttr || !indexAttr) {
853
- geometry.dispose();
854
- return;
855
- }
856
- if (!(rawPositionAttr instanceof THREE.BufferAttribute) || !(rawNormalAttr instanceof THREE.BufferAttribute)) {
857
- geometry.dispose();
858
- return;
859
- }
860
- const positionAttr = rawPositionAttr;
861
- const normalAttr = rawNormalAttr;
862
- const uvAttr = rawUvAttr && rawUvAttr instanceof THREE.BufferAttribute ? rawUvAttr : null;
863
- if (!(indexAttr instanceof THREE.BufferAttribute)) {
864
- geometry.dispose();
865
- return;
866
- }
867
- const vertex = new THREE.Vector3();
868
- const normal = new THREE.Vector3();
869
- const uv = new THREE.Vector2();
870
- const normalMatrix = new THREE.Matrix3().getNormalMatrix(matrix);
871
- for (let i = 0; i < positionAttr.count; i += 1) {
872
- vertex.fromBufferAttribute(positionAttr, i);
873
- vertex.applyMatrix4(matrix);
874
- this.positions.push(vertex.x, vertex.y, vertex.z);
875
- normal.fromBufferAttribute(normalAttr, i);
876
- normal.applyMatrix3(normalMatrix).normalize();
877
- this.normals.push(normal.x, normal.y, normal.z);
878
- if (this.uvs) {
879
- if (customUVs) {
880
- this.uvs.push(customUVs[i * 2], customUVs[i * 2 + 1]);
881
- } else if (uvAttr) {
882
- uv.fromBufferAttribute(uvAttr, i);
883
- this.uvs.push(uv.x, uv.y);
884
- } else {
885
- this.uvs.push(0, 0);
886
- }
887
- }
888
- }
889
- const typedIndexAttr = indexAttr;
890
- const indexArray = typedIndexAttr.array;
891
- for (let i = 0; i < typedIndexAttr.count; i += 1) {
892
- this.indices.push(this.vertexCount + indexArray[i]);
893
- }
894
- this.vertexCount += positionAttr.count;
895
- geometry.dispose();
896
- }
897
- hasGeometry() {
898
- return this.positions.length > 0;
899
- }
900
- build(THREE) {
901
- const geometry = new THREE.BufferGeometry();
902
- geometry.setAttribute("position", new THREE.Float32BufferAttribute(this.positions, 3));
903
- geometry.setAttribute("normal", new THREE.Float32BufferAttribute(this.normals, 3));
904
- if (this.uvs) {
905
- geometry.setAttribute("uv", new THREE.Float32BufferAttribute(this.uvs, 2));
906
- }
907
- const indexArray = this.vertexCount > 65535 ? new Uint32Array(this.indices) : new Uint16Array(this.indices);
908
- geometry.setIndex(new THREE.BufferAttribute(indexArray, 1));
909
- geometry.computeBoundingBox();
910
- geometry.computeBoundingSphere();
911
- return geometry;
912
- }
913
- }
914
- const __testing = {
915
- buildTextureAtlas,
916
- collectUsedTextureIds,
917
- MeshAccumulator,
918
- createExportContext,
919
- buildSceneGraph,
920
- resolveAnimationClips
921
- };
922
- // Annotate the CommonJS export names for ESM import in node:
923
- 0 && (module.exports = {
924
- __testing,
925
- createBoxelSceneGraph,
926
- exportModelToGLB
927
- });