@fleox/agent3d 0.0.0-stage → 0.2.1

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 (455) hide show
  1. package/LICENSE +143 -0
  2. package/README.md +396 -2
  3. package/changelog.json +68 -0
  4. package/dist/agent/agent3d.mjs +11242 -0
  5. package/dist/agent/chunks/assets-BUUM9TUB.mjs +2448 -0
  6. package/dist/agent/chunks/browser-t_JL_B82.mjs +226 -0
  7. package/dist/agent/chunks/cdp-Bdtm4fBN.mjs +178 -0
  8. package/dist/agent/chunks/check-CBO3Ekx1.mjs +971 -0
  9. package/dist/agent/chunks/export-BCI8vKw8.mjs +1130 -0
  10. package/dist/agent/chunks/gif-DQznzHTL.mjs +319 -0
  11. package/dist/agent/chunks/gltf-f_f0-OiV.mjs +207 -0
  12. package/dist/agent/chunks/imageCodec-Dz9PFxi9.mjs +101 -0
  13. package/dist/agent/chunks/jsonPath-DUCe1JpS.mjs +155 -0
  14. package/dist/agent/chunks/meshoptimizer-C-tN9jn5.mjs +1165 -0
  15. package/dist/agent/chunks/mp4-aOALfp3s.mjs +130 -0
  16. package/dist/agent/chunks/objects-DBAws7uf.mjs +53 -0
  17. package/dist/agent/chunks/optimizeSizing-CkZ3fZRp.mjs +540 -0
  18. package/dist/agent/chunks/package-BOIyp_2B.mjs +75 -0
  19. package/dist/agent/chunks/png-DXfSGJZt.mjs +91 -0
  20. package/dist/agent/chunks/render-CN4mgGLQ.mjs +1511 -0
  21. package/dist/agent/chunks/rolldown-runtime-ebOQtxsr.mjs +18 -0
  22. package/dist/agent/chunks/scene-BgajNvBf.mjs +444 -0
  23. package/dist/agent/chunks/server-CACCerkZ.mjs +237 -0
  24. package/dist/agent/chunks/suggest-Cpcgv1RP.mjs +46 -0
  25. package/dist/agent/chunks/tools-DT2tetIK.mjs +1412 -0
  26. package/dist/agent/chunks/tree-BrNYGui2.mjs +75 -0
  27. package/dist/agent/chunks/webpAnim-qaq9YgKl.mjs +132 -0
  28. package/dist/runtime/agent3d-runtime.js +373 -0
  29. package/dist/runtime/agent3d-runtime.single.js +7360 -0
  30. package/dist/runtime/chunks/BufferGeometryUtils-XmME4f7Z.js +1 -0
  31. package/dist/runtime/chunks/EXRLoader-CBdIpBMT.js +1 -0
  32. package/dist/runtime/chunks/FontLoader-dVu9WH2X.js +2 -0
  33. package/dist/runtime/chunks/GLTFLoader-Z9Inv-Xm.js +1 -0
  34. package/dist/runtime/chunks/GroundedSkybox-g1ASZWNu.js +1 -0
  35. package/dist/runtime/chunks/HDRLoader-DBOMWa7O.js +5 -0
  36. package/dist/runtime/chunks/OrbitControls-BIpWXK4x.js +1 -0
  37. package/dist/runtime/chunks/RectAreaLightUniformsLib-4ZzgX9vp.js +1 -0
  38. package/dist/runtime/chunks/RoomEnvironment-CXgfLJdO.js +1 -0
  39. package/dist/runtime/chunks/RoundedBoxGeometry-BViRogcJ.js +1 -0
  40. package/dist/runtime/chunks/SVGLoader-CV0U1EIF.js +1 -0
  41. package/dist/runtime/chunks/SkeletonUtils-DHlReJx3.js +1 -0
  42. package/dist/runtime/chunks/Sky-DGJXlPb_.js +243 -0
  43. package/dist/runtime/chunks/audio-DbVNbf-r.js +1 -0
  44. package/dist/runtime/chunks/catalog-DL6sgPay.js +1 -0
  45. package/dist/runtime/chunks/easing-CXSz2e6P.js +1 -0
  46. package/dist/runtime/chunks/extrude-D6WnITQq.js +1 -0
  47. package/dist/runtime/chunks/game-BoEiyZrL.js +20 -0
  48. package/dist/runtime/chunks/generators-D5JUo0jp.js +331 -0
  49. package/dist/runtime/chunks/materials-Dn-bYrZd.js +107 -0
  50. package/dist/runtime/chunks/meshGradient.glsl-BMatplLA.js +88 -0
  51. package/dist/runtime/chunks/meshopt_decoder.module-DXTYc6wn.js +1 -0
  52. package/dist/runtime/chunks/model-BCVF3QzB.js +1 -0
  53. package/dist/runtime/chunks/params-C2uoUDJ0.js +1 -0
  54. package/dist/runtime/chunks/physicsHost-ChPgysMQ.js +1 -0
  55. package/dist/runtime/chunks/postfx-UgKCbmZs.js +1527 -0
  56. package/dist/runtime/chunks/postfx-i_J5Vf-l.js +1 -0
  57. package/dist/runtime/chunks/random-eeej60NW.js +1 -0
  58. package/dist/runtime/chunks/shaders-Dw6zHdu_.js +443 -0
  59. package/dist/runtime/chunks/svg-CmlFY_8O.js +1 -0
  60. package/dist/runtime/chunks/text-D1EQpdSU.js +2 -0
  61. package/dist/runtime/chunks/three.module-DnaBiDAJ.js +4225 -0
  62. package/dist/runtime/chunks/toon-BsvVk_nK.js +6 -0
  63. package/dist/runtime/chunks/util-CyaW1fcW.js +1 -0
  64. package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +1 -0
  65. package/dist/studio/assets/EXRLoader-BKkzlNd8.js +1 -0
  66. package/dist/studio/assets/FontLoader-Bzjx8mXt.js +2 -0
  67. package/dist/studio/assets/GLTFLoader-1Zd9N406.js +1 -0
  68. package/dist/studio/assets/GroundedSkybox-BEMqNCBD.js +1 -0
  69. package/dist/studio/assets/HDRLoader-DxB0kxPH.js +5 -0
  70. package/dist/studio/assets/OrbitControls-MlE9XiCg.js +1 -0
  71. package/dist/studio/assets/RectAreaLightUniformsLib-ClHrtYY6.js +1 -0
  72. package/dist/studio/assets/RoomEnvironment-MJ-jIEC8.js +1 -0
  73. package/dist/studio/assets/SVGLoader-CIYl0nEy.js +1 -0
  74. package/dist/studio/assets/SkeletonUtils-CG5akqME.js +1 -0
  75. package/dist/studio/assets/Sky-DNMfpp92.js +243 -0
  76. package/dist/studio/assets/audio-JD1kyX0A.js +1 -0
  77. package/dist/studio/assets/camera-7sEn13L-.js +2 -0
  78. package/dist/studio/assets/editor-CnbvVkhU.js +53 -0
  79. package/dist/studio/assets/extrude-9bG8hr2C.js +1 -0
  80. package/dist/studio/assets/game-B04KGAK0.js +19 -0
  81. package/dist/studio/assets/generators-LSni1Yfc.js +331 -0
  82. package/dist/studio/assets/index-3LL5NEIH.js +479 -0
  83. package/dist/studio/assets/index-BQT0otii.css +1 -0
  84. package/dist/studio/assets/meshopt_decoder.module-DXTYc6wn.js +1 -0
  85. package/dist/studio/assets/meshoptimizer-BCSwHBL3.js +1 -0
  86. package/dist/studio/assets/model-CNddhwmA.js +2 -0
  87. package/dist/studio/assets/physicsHost-hMU_SDiX.js +1 -0
  88. package/dist/studio/assets/postfx-BcCZS0Bq.js +1527 -0
  89. package/dist/studio/assets/runtime-DY_KqD1x.js +572 -0
  90. package/dist/studio/assets/shaders-BhMCstyv.js +443 -0
  91. package/dist/studio/assets/svg-CNKK-h7H.js +2 -0
  92. package/dist/studio/assets/text-BSPI7dk1.js +3 -0
  93. package/dist/studio/assets/three.module-CnI50X0U.js +4225 -0
  94. package/dist/studio/index.html +16 -0
  95. package/library/LICENSES.md +77 -0
  96. package/library/fonts/LICENSES.md +42 -0
  97. package/library/fonts/anton.typeface.json +1 -0
  98. package/library/fonts/bebas-neue.typeface.json +1 -0
  99. package/library/fonts/display.typeface.json +1 -0
  100. package/library/fonts/inter-black.typeface.json +1 -0
  101. package/library/fonts/lobster.typeface.json +1 -0
  102. package/library/fonts/mono.typeface.json +1 -0
  103. package/library/fonts/montserrat-extrabold.typeface.json +1 -0
  104. package/library/fonts/pacifico.typeface.json +1 -0
  105. package/library/fonts/sans-bold.typeface.json +1 -0
  106. package/library/fonts/sans.typeface.json +1 -0
  107. package/library/fonts/serif-bold.typeface.json +1 -0
  108. package/library/fonts/serif.typeface.json +1 -0
  109. package/library/fonts/space-grotesk-bold.typeface.json +1 -0
  110. package/library/hdri/beach.hdr +0 -0
  111. package/library/hdri/beach.jpg +0 -0
  112. package/library/hdri/city.hdr +0 -0
  113. package/library/hdri/city.jpg +0 -0
  114. package/library/hdri/forest.hdr +0 -0
  115. package/library/hdri/forest.jpg +0 -0
  116. package/library/hdri/night-city.hdr +0 -0
  117. package/library/hdri/night-city.jpg +0 -0
  118. package/library/hdri/night.hdr +0 -0
  119. package/library/hdri/night.jpg +0 -0
  120. package/library/hdri/sky.hdr +0 -0
  121. package/library/hdri/sky.jpg +0 -0
  122. package/library/hdri/softbox.hdr +0 -0
  123. package/library/hdri/softbox.jpg +0 -0
  124. package/library/hdri/studio.hdr +0 -0
  125. package/library/hdri/studio.jpg +0 -0
  126. package/library/hdri/sunset.hdr +0 -0
  127. package/library/hdri/sunset.jpg +0 -0
  128. package/library/hdri/warehouse.hdr +0 -0
  129. package/library/hdri/warehouse.jpg +0 -0
  130. package/library/index.json +5510 -0
  131. package/library/models/animals/fish.glb +0 -0
  132. package/library/models/animals/fox.glb +0 -0
  133. package/library/models/buildings/castle.glb +0 -0
  134. package/library/models/buildings/house.glb +0 -0
  135. package/library/models/buildings/market.glb +0 -0
  136. package/library/models/buildings/tavern.glb +0 -0
  137. package/library/models/buildings/tower.glb +0 -0
  138. package/library/models/buildings/windmill.glb +0 -0
  139. package/library/models/characters/barbarian.glb +0 -0
  140. package/library/models/characters/knight.glb +0 -0
  141. package/library/models/characters/mage.glb +0 -0
  142. package/library/models/characters/mini-soldier.glb +0 -0
  143. package/library/models/characters/platformer-hero.glb +0 -0
  144. package/library/models/characters/robot.glb +0 -0
  145. package/library/models/characters/rogue.glb +0 -0
  146. package/library/models/characters/skeleton.glb +0 -0
  147. package/library/models/city/building-a.glb +0 -0
  148. package/library/models/city/building-b.glb +0 -0
  149. package/library/models/city/building-tall.glb +0 -0
  150. package/library/models/city/fire-hydrant.glb +0 -0
  151. package/library/models/city/road-corner.glb +0 -0
  152. package/library/models/city/road-crossing.glb +0 -0
  153. package/library/models/city/road-junction.glb +0 -0
  154. package/library/models/city/road-straight.glb +0 -0
  155. package/library/models/city/streetlight.glb +0 -0
  156. package/library/models/city/suburban-house.glb +0 -0
  157. package/library/models/city/traffic-light.glb +0 -0
  158. package/library/models/city/water-tower.glb +0 -0
  159. package/library/models/food/apple.glb +0 -0
  160. package/library/models/food/avocado.glb +0 -0
  161. package/library/models/food/baguette.glb +0 -0
  162. package/library/models/food/bread-loaf.glb +0 -0
  163. package/library/models/food/burger.glb +0 -0
  164. package/library/models/food/carrot.glb +0 -0
  165. package/library/models/food/cheese.glb +0 -0
  166. package/library/models/food/cookie.glb +0 -0
  167. package/library/models/food/croissant.glb +0 -0
  168. package/library/models/food/cupcake.glb +0 -0
  169. package/library/models/food/dinner-plate.glb +0 -0
  170. package/library/models/food/donut.glb +0 -0
  171. package/library/models/food/ketchup.glb +0 -0
  172. package/library/models/food/mug.glb +0 -0
  173. package/library/models/food/pain-au-chocolat.glb +0 -0
  174. package/library/models/food/stew.glb +0 -0
  175. package/library/models/food/tomato.glb +0 -0
  176. package/library/models/food/veggie-burger.glb +0 -0
  177. package/library/models/nature/bush.glb +0 -0
  178. package/library/models/nature/cactus.glb +0 -0
  179. package/library/models/nature/cloud.glb +0 -0
  180. package/library/models/nature/fir-tree.glb +0 -0
  181. package/library/models/nature/forest-patch.glb +0 -0
  182. package/library/models/nature/grass-small.glb +0 -0
  183. package/library/models/nature/grass.glb +0 -0
  184. package/library/models/nature/hex-grass.glb +0 -0
  185. package/library/models/nature/hex-water.glb +0 -0
  186. package/library/models/nature/hills.glb +0 -0
  187. package/library/models/nature/mountain.glb +0 -0
  188. package/library/models/nature/pine-autumn.glb +0 -0
  189. package/library/models/nature/pine-tree.glb +0 -0
  190. package/library/models/nature/pumpkin.glb +0 -0
  191. package/library/models/nature/rock-flat.glb +0 -0
  192. package/library/models/nature/rock.glb +0 -0
  193. package/library/models/nature/tree-dead.glb +0 -0
  194. package/library/models/nature/tree-slim.glb +0 -0
  195. package/library/models/nature/trees-cluster.glb +0 -0
  196. package/library/models/nature/waterlily.glb +0 -0
  197. package/library/models/platformer/blaster.glb +0 -0
  198. package/library/models/platformer/block-coin.glb +0 -0
  199. package/library/models/platformer/brick.glb +0 -0
  200. package/library/models/platformer/coin.glb +0 -0
  201. package/library/models/platformer/enemy-flying.glb +0 -0
  202. package/library/models/platformer/flag.glb +0 -0
  203. package/library/models/platformer/platform-falling.glb +0 -0
  204. package/library/models/platformer/platform-grass-round.glb +0 -0
  205. package/library/models/platformer/platform-large.glb +0 -0
  206. package/library/models/platformer/platform-medium.glb +0 -0
  207. package/library/models/platformer/platform.glb +0 -0
  208. package/library/models/platformer/target.glb +0 -0
  209. package/library/models/platformer/track-corner.glb +0 -0
  210. package/library/models/platformer/track-straight.glb +0 -0
  211. package/library/models/platformer/wall-low.glb +0 -0
  212. package/library/models/products/boombox.glb +0 -0
  213. package/library/models/products/iridescent-lamp.glb +0 -0
  214. package/library/models/products/lantern.glb +0 -0
  215. package/library/models/products/lounge-chair.glb +0 -0
  216. package/library/models/products/sneaker.glb +0 -0
  217. package/library/models/products/velvet-sofa.glb +0 -0
  218. package/library/models/products/water-bottle.glb +0 -0
  219. package/library/models/props/alarm-clock.glb +0 -0
  220. package/library/models/props/armchair.glb +0 -0
  221. package/library/models/props/barrel.glb +0 -0
  222. package/library/models/props/bench.glb +0 -0
  223. package/library/models/props/brass-vase.glb +0 -0
  224. package/library/models/props/chest.glb +0 -0
  225. package/library/models/props/coffee-table.glb +0 -0
  226. package/library/models/props/coin-stack.glb +0 -0
  227. package/library/models/props/coin.glb +0 -0
  228. package/library/models/props/couch.glb +0 -0
  229. package/library/models/props/crate.glb +0 -0
  230. package/library/models/props/flag.glb +0 -0
  231. package/library/models/props/gravestone.glb +0 -0
  232. package/library/models/props/key.glb +0 -0
  233. package/library/models/props/lamp.glb +0 -0
  234. package/library/models/props/lantern.glb +0 -0
  235. package/library/models/props/marble-bust.glb +0 -0
  236. package/library/models/props/modern-armchair.glb +0 -0
  237. package/library/models/props/potted-succulent.glb +0 -0
  238. package/library/models/props/rubber-duck.glb +0 -0
  239. package/library/models/props/shield.glb +0 -0
  240. package/library/models/props/sword-shield.glb +0 -0
  241. package/library/models/props/sword.glb +0 -0
  242. package/library/models/props/table.glb +0 -0
  243. package/library/models/props/tent.glb +0 -0
  244. package/library/models/props/torch.glb +0 -0
  245. package/library/models/props/trophy.glb +0 -0
  246. package/library/models/space/base-module.glb +0 -0
  247. package/library/models/space/lander.glb +0 -0
  248. package/library/models/space/landing-pad.glb +0 -0
  249. package/library/models/space/rocks.glb +0 -0
  250. package/library/models/space/solar-panel.glb +0 -0
  251. package/library/models/space/space-truck.glb +0 -0
  252. package/library/models/space/wind-turbine.glb +0 -0
  253. package/library/models/vehicles/car.glb +0 -0
  254. package/library/models/vehicles/hatchback.glb +0 -0
  255. package/library/models/vehicles/motorcycle.glb +0 -0
  256. package/library/models/vehicles/police-car.glb +0 -0
  257. package/library/models/vehicles/taxi.glb +0 -0
  258. package/library/models/vehicles/truck.glb +0 -0
  259. package/library/sources.json +2856 -0
  260. package/library/textures/brick-color.jpg +0 -0
  261. package/library/textures/brick-normal.jpg +0 -0
  262. package/library/textures/brick-roughness.jpg +0 -0
  263. package/library/textures/concrete-color.jpg +0 -0
  264. package/library/textures/concrete-normal.jpg +0 -0
  265. package/library/textures/concrete-roughness.jpg +0 -0
  266. package/library/textures/fabric-color.jpg +0 -0
  267. package/library/textures/fabric-normal.jpg +0 -0
  268. package/library/textures/fabric-roughness.jpg +0 -0
  269. package/library/textures/grass-ground-color.jpg +0 -0
  270. package/library/textures/grass-ground-normal.jpg +0 -0
  271. package/library/textures/grass-ground-roughness.jpg +0 -0
  272. package/library/textures/rusty-metal-color.jpg +0 -0
  273. package/library/textures/rusty-metal-normal.jpg +0 -0
  274. package/library/textures/rusty-metal-roughness.jpg +0 -0
  275. package/library/textures/wood-planks-color.jpg +0 -0
  276. package/library/textures/wood-planks-normal.jpg +0 -0
  277. package/library/textures/wood-planks-roughness.jpg +0 -0
  278. package/package.json +67 -4
  279. package/plugin/.claude-plugin/plugin.json +19 -0
  280. package/plugin/skills/agent3d-assets/SKILL.md +140 -0
  281. package/plugin/skills/agent3d-assets/references/sources.md +33 -0
  282. package/plugin/skills/agent3d-create/SKILL.md +141 -0
  283. package/plugin/skills/agent3d-create/references/art-direction.md +144 -0
  284. package/plugin/skills/agent3d-create/references/recipes.md +1357 -0
  285. package/plugin/skills/agent3d-edit/SKILL.md +121 -0
  286. package/plugin/skills/agent3d-edit/references/patch-ops.md +278 -0
  287. package/plugin/skills/agent3d-game/SKILL.md +111 -0
  288. package/plugin/skills/agent3d-game/references/game-patterns.md +262 -0
  289. package/plugin/skills/agent3d-game/references/script-api.md +211 -0
  290. package/plugin/skills/agent3d-publish/SKILL.md +161 -0
  291. package/plugin/skills/agent3d-publish/references/integrations.md +221 -0
  292. package/templates/banner-aurora-night/README.md +15 -0
  293. package/templates/banner-aurora-night/agent3d.json +8 -0
  294. package/templates/banner-aurora-night/preview.png +0 -0
  295. package/templates/banner-aurora-night/scene.json +327 -0
  296. package/templates/banner-aurora-night/template.json +24 -0
  297. package/templates/banner-data-bars/README.md +15 -0
  298. package/templates/banner-data-bars/agent3d.json +8 -0
  299. package/templates/banner-data-bars/preview.png +0 -0
  300. package/templates/banner-data-bars/scene.json +222 -0
  301. package/templates/banner-data-bars/template.json +25 -0
  302. package/templates/banner-floating-shapes/README.md +15 -0
  303. package/templates/banner-floating-shapes/agent3d.json +8 -0
  304. package/templates/banner-floating-shapes/preview.png +0 -0
  305. package/templates/banner-floating-shapes/scene.json +703 -0
  306. package/templates/banner-floating-shapes/template.json +24 -0
  307. package/templates/banner-gradient-blob/README.md +16 -0
  308. package/templates/banner-gradient-blob/agent3d.json +8 -0
  309. package/templates/banner-gradient-blob/preview.png +0 -0
  310. package/templates/banner-gradient-blob/scene.json +330 -0
  311. package/templates/banner-gradient-blob/template.json +21 -0
  312. package/templates/banner-liquid-chrome/README.md +16 -0
  313. package/templates/banner-liquid-chrome/agent3d.json +8 -0
  314. package/templates/banner-liquid-chrome/preview.png +0 -0
  315. package/templates/banner-liquid-chrome/scene.json +290 -0
  316. package/templates/banner-liquid-chrome/template.json +24 -0
  317. package/templates/banner-logo-extrude/README.md +24 -0
  318. package/templates/banner-logo-extrude/agent3d.json +8 -0
  319. package/templates/banner-logo-extrude/assets/logo.svg +6 -0
  320. package/templates/banner-logo-extrude/assets/manifest.json +13 -0
  321. package/templates/banner-logo-extrude/preview.png +0 -0
  322. package/templates/banner-logo-extrude/scene.json +332 -0
  323. package/templates/banner-logo-extrude/template.json +22 -0
  324. package/templates/banner-neon-title/README.md +18 -0
  325. package/templates/banner-neon-title/agent3d.json +8 -0
  326. package/templates/banner-neon-title/preview.png +0 -0
  327. package/templates/banner-neon-title/scene.json +494 -0
  328. package/templates/banner-neon-title/template.json +25 -0
  329. package/templates/banner-wave-grid/README.md +18 -0
  330. package/templates/banner-wave-grid/agent3d.json +8 -0
  331. package/templates/banner-wave-grid/preview.png +0 -0
  332. package/templates/banner-wave-grid/scene.json +217 -0
  333. package/templates/banner-wave-grid/template.json +23 -0
  334. package/templates/card-hover-3d/README.md +16 -0
  335. package/templates/card-hover-3d/agent3d.json +8 -0
  336. package/templates/card-hover-3d/preview.png +0 -0
  337. package/templates/card-hover-3d/scene.json +359 -0
  338. package/templates/card-hover-3d/template.json +21 -0
  339. package/templates/card-product-tilt/README.md +14 -0
  340. package/templates/card-product-tilt/agent3d.json +8 -0
  341. package/templates/card-product-tilt/preview.png +0 -0
  342. package/templates/card-product-tilt/scene.json +296 -0
  343. package/templates/card-product-tilt/template.json +23 -0
  344. package/templates/character-mascot-hero/README.md +19 -0
  345. package/templates/character-mascot-hero/agent3d.json +8 -0
  346. package/templates/character-mascot-hero/preview.png +0 -0
  347. package/templates/character-mascot-hero/scene.json +512 -0
  348. package/templates/character-mascot-hero/template.json +8 -0
  349. package/templates/character-showcase/README.md +27 -0
  350. package/templates/character-showcase/agent3d.json +8 -0
  351. package/templates/character-showcase/preview.png +0 -0
  352. package/templates/character-showcase/scene.json +440 -0
  353. package/templates/character-showcase/template.json +24 -0
  354. package/templates/diorama-city/README.md +21 -0
  355. package/templates/diorama-city/agent3d.json +8 -0
  356. package/templates/diorama-city/preview.png +0 -0
  357. package/templates/diorama-city/scene.json +432 -0
  358. package/templates/diorama-city/template.json +21 -0
  359. package/templates/game-basket/README.md +25 -0
  360. package/templates/game-basket/agent3d.json +8 -0
  361. package/templates/game-basket/preview.png +0 -0
  362. package/templates/game-basket/scene.json +640 -0
  363. package/templates/game-basket/scripts/basket.js +176 -0
  364. package/templates/game-basket/template.json +8 -0
  365. package/templates/game-coin-collector/README.md +28 -0
  366. package/templates/game-coin-collector/agent3d.json +8 -0
  367. package/templates/game-coin-collector/preview.png +0 -0
  368. package/templates/game-coin-collector/scene.json +900 -0
  369. package/templates/game-coin-collector/scripts/collector.js +210 -0
  370. package/templates/game-coin-collector/template.json +19 -0
  371. package/templates/game-maze/README.md +24 -0
  372. package/templates/game-maze/agent3d.json +8 -0
  373. package/templates/game-maze/preview.png +0 -0
  374. package/templates/game-maze/scene.json +315 -0
  375. package/templates/game-maze/scripts/maze.js +168 -0
  376. package/templates/game-maze/template.json +18 -0
  377. package/templates/game-physics-playground/README.md +30 -0
  378. package/templates/game-physics-playground/agent3d.json +8 -0
  379. package/templates/game-physics-playground/preview.png +0 -0
  380. package/templates/game-physics-playground/scene.json +1712 -0
  381. package/templates/game-physics-playground/scripts/playground.js +151 -0
  382. package/templates/game-physics-playground/template.json +19 -0
  383. package/templates/game-platformer/README.md +26 -0
  384. package/templates/game-platformer/agent3d.json +8 -0
  385. package/templates/game-platformer/preview.png +0 -0
  386. package/templates/game-platformer/scene.json +1063 -0
  387. package/templates/game-platformer/scripts/platformer.js +222 -0
  388. package/templates/game-platformer/template.json +8 -0
  389. package/templates/game-runner/README.md +30 -0
  390. package/templates/game-runner/agent3d.json +8 -0
  391. package/templates/game-runner/preview.png +0 -0
  392. package/templates/game-runner/scene.json +1317 -0
  393. package/templates/game-runner/scripts/runner.js +263 -0
  394. package/templates/game-runner/template.json +18 -0
  395. package/templates/game-tap-targets/README.md +21 -0
  396. package/templates/game-tap-targets/agent3d.json +8 -0
  397. package/templates/game-tap-targets/preview.png +0 -0
  398. package/templates/game-tap-targets/scene.json +924 -0
  399. package/templates/game-tap-targets/scripts/targets.js +159 -0
  400. package/templates/game-tap-targets/template.json +19 -0
  401. package/templates/hero-floating-island/README.md +18 -0
  402. package/templates/hero-floating-island/agent3d.json +8 -0
  403. package/templates/hero-floating-island/preview.png +0 -0
  404. package/templates/hero-floating-island/scene.json +658 -0
  405. package/templates/hero-floating-island/template.json +8 -0
  406. package/templates/hero-perfume-luxury/README.md +18 -0
  407. package/templates/hero-perfume-luxury/agent3d.json +8 -0
  408. package/templates/hero-perfume-luxury/preview.png +0 -0
  409. package/templates/hero-perfume-luxury/scene.json +529 -0
  410. package/templates/hero-perfume-luxury/template.json +27 -0
  411. package/templates/hero-product-turntable/README.md +16 -0
  412. package/templates/hero-product-turntable/agent3d.json +8 -0
  413. package/templates/hero-product-turntable/preview.png +0 -0
  414. package/templates/hero-product-turntable/scene.json +225 -0
  415. package/templates/hero-product-turntable/template.json +21 -0
  416. package/templates/hero-saas-globe/README.md +16 -0
  417. package/templates/hero-saas-globe/agent3d.json +8 -0
  418. package/templates/hero-saas-globe/preview.png +0 -0
  419. package/templates/hero-saas-globe/scene.json +318 -0
  420. package/templates/hero-saas-globe/template.json +24 -0
  421. package/templates/hero-scroll-story/README.md +26 -0
  422. package/templates/hero-scroll-story/agent3d.json +8 -0
  423. package/templates/hero-scroll-story/preview.png +0 -0
  424. package/templates/hero-scroll-story/scene.json +642 -0
  425. package/templates/hero-scroll-story/template.json +22 -0
  426. package/templates/hero-sneaker-showcase/README.md +19 -0
  427. package/templates/hero-sneaker-showcase/agent3d.json +8 -0
  428. package/templates/hero-sneaker-showcase/preview.png +0 -0
  429. package/templates/hero-sneaker-showcase/scene.json +523 -0
  430. package/templates/hero-sneaker-showcase/template.json +23 -0
  431. package/templates/hero-space-planet/README.md +17 -0
  432. package/templates/hero-space-planet/agent3d.json +8 -0
  433. package/templates/hero-space-planet/preview.png +0 -0
  434. package/templates/hero-space-planet/scene.json +330 -0
  435. package/templates/hero-space-planet/template.json +21 -0
  436. package/templates/landscape-island/README.md +21 -0
  437. package/templates/landscape-island/agent3d.json +8 -0
  438. package/templates/landscape-island/preview.png +0 -0
  439. package/templates/landscape-island/scene.json +716 -0
  440. package/templates/landscape-island/template.json +24 -0
  441. package/templates/landscape-night-galaxy/README.md +25 -0
  442. package/templates/landscape-night-galaxy/agent3d.json +8 -0
  443. package/templates/landscape-night-galaxy/preview.png +0 -0
  444. package/templates/landscape-night-galaxy/scene.json +403 -0
  445. package/templates/landscape-night-galaxy/template.json +8 -0
  446. package/templates/landscape-valley-sunset/README.md +20 -0
  447. package/templates/landscape-valley-sunset/agent3d.json +8 -0
  448. package/templates/landscape-valley-sunset/preview.png +0 -0
  449. package/templates/landscape-valley-sunset/scene.json +265 -0
  450. package/templates/landscape-valley-sunset/template.json +22 -0
  451. package/templates/scene-cozy-room/README.md +21 -0
  452. package/templates/scene-cozy-room/agent3d.json +8 -0
  453. package/templates/scene-cozy-room/preview.png +0 -0
  454. package/templates/scene-cozy-room/scene.json +728 -0
  455. package/templates/scene-cozy-room/template.json +8 -0
@@ -0,0 +1,1130 @@
1
+ import { createRequire as __a3dRequire } from "node:module";
2
+ import { fileURLToPath as __a3dPath } from "node:url";
3
+ import { dirname as __a3dDirname } from "node:path";
4
+ __a3dRequire(import.meta.url);
5
+ const __filename = __a3dPath(import.meta.url);
6
+ __a3dDirname(__filename);
7
+ import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
8
+ import { A as hasErrors, D as slugify, M as readJsonOr, N as validationError, O as KB, T as parseAspect, b as isLibraryRef, g as validateScene, k as OpsError, o as MANIFEST_FILE, p as DEFAULT_BUDGET_KB, u as readSceneFile, x as libraryId, y as findLibraryAsset } from "../agent3d.mjs";
9
+ import { n as clone } from "./jsonPath-DUCe1JpS.mjs";
10
+ import { t as attributionText } from "./check-CBO3Ekx1.mjs";
11
+ import { c as mimeFromPath, l as visitAssetRefs, o as gltfDependencies } from "./optimizeSizing-CkZ3fZRp.mjs";
12
+ import { c as readAssetManifest, m as crc32 } from "./assets-BUUM9TUB.mjs";
13
+ // src/core/data.ts
14
+ var DATA_PLACEHOLDER = /\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;
15
+ function lookup(data, path) {
16
+ let cur = data;
17
+ for (const k of path.split(".")) {
18
+ if (cur === null || typeof cur !== "object") return void 0;
19
+ cur = cur[k];
20
+ }
21
+ return cur;
22
+ }
23
+ function substituteData(s, data) {
24
+ if (!s.includes("{data.")) return s;
25
+ return s.replace(DATA_PLACEHOLDER, (_m, path, fallback) => {
26
+ const v = lookup(data, path);
27
+ if (v === void 0 || v === null || v === "") return fallback ?? "";
28
+ return typeof v === "object" ? JSON.stringify(v) : String(v);
29
+ });
30
+ }
31
+ // src/ops/base64.ts
32
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
33
+ function base64Encode(bytes) {
34
+ let out = "";
35
+ const n = bytes.length;
36
+ let i = 0;
37
+ for (; i + 2 < n; i += 3) {
38
+ const v = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
39
+ out += ALPHABET[v >> 18] + ALPHABET[v >> 12 & 63] + ALPHABET[v >> 6 & 63] + ALPHABET[v & 63];
40
+ }
41
+ if (i < n) {
42
+ const v = bytes[i] << 16 | (i + 1 < n ? bytes[i + 1] : 0) << 8;
43
+ out += ALPHABET[v >> 18] + ALPHABET[v >> 12 & 63] + (i + 1 < n ? ALPHABET[v >> 6 & 63] : "=") + "=";
44
+ }
45
+ return out;
46
+ }
47
+ function dataUri(bytes, mime) {
48
+ return `data:${mime};base64,${base64Encode(bytes)}`;
49
+ }
50
+ // src/ops/runtimeChunks.ts
51
+ var hasKind = (scene, kinds) => {
52
+ const walk = (objs) => !!objs?.some((o) => kinds.includes(o.kind) || walk(o.children));
53
+ return walk(scene.objects);
54
+ };
55
+ var hasBody = (scene) => {
56
+ const walk = (objs) => !!objs?.some((o) => !!o.body || walk(o.children));
57
+ return walk(scene.objects);
58
+ };
59
+ var needsGameChunk = (scene) => !!(scene.scripts?.length || scene.ui?.elements?.length || scene.physics || scene.audio || hasBody(scene));
60
+ var CHUNK_FEATURES = {
61
+ postfx: {
62
+ feature: "post effects (scene.postfx)",
63
+ needed: (s) => !!s.postfx?.length
64
+ },
65
+ generators: {
66
+ feature: "generators",
67
+ needed: (s) => hasKind(s, ["generator"])
68
+ },
69
+ shaders: {
70
+ feature: "shader materials / backgrounds",
71
+ needed: (_s, j) => /"shader"\s*:/.test(j)
72
+ },
73
+ OrbitControls: {
74
+ feature: "orbit controls",
75
+ needed: (_s, j) => /"controls"\s*:\s*"orbit"/.test(j)
76
+ },
77
+ RectAreaLightUniformsLib: {
78
+ feature: "rect lights (incl. light rigs)",
79
+ needed: (s, j) => /"type"\s*:\s*"rect"/.test(j) || !!s.environment?.rig
80
+ },
81
+ Sky: {
82
+ feature: "physical sky",
83
+ needed: (_s, j) => /"sky"\s*:/.test(j)
84
+ },
85
+ HDRLoader: {
86
+ feature: ".hdr environment",
87
+ needed: (_s, j) => /\.hdr"/i.test(j)
88
+ },
89
+ EXRLoader: {
90
+ feature: ".exr environment",
91
+ needed: (_s, j) => /\.exr"/i.test(j)
92
+ },
93
+ GroundedSkybox: {
94
+ feature: "HDRI ground projection",
95
+ needed: (_s, j) => /"groundProjection"\s*:\s*(true|\{)/.test(j)
96
+ },
97
+ RoomEnvironment: {
98
+ feature: "studio / soft image-based lighting",
99
+ needed: () => true
100
+ },
101
+ text: {
102
+ feature: "3D text",
103
+ needed: (s) => hasKind(s, ["text"])
104
+ },
105
+ svg: {
106
+ feature: "SVG objects",
107
+ needed: (s) => hasKind(s, ["svg"])
108
+ },
109
+ model: {
110
+ feature: "glTF models",
111
+ needed: (s) => hasKind(s, ["model"])
112
+ },
113
+ game: {
114
+ feature: "scripts / HUD / physics / audio",
115
+ needed: (s) => needsGameChunk(s)
116
+ },
117
+ audio: {
118
+ feature: "audio",
119
+ needed: (s) => !!s.audio
120
+ },
121
+ physicsHost: {
122
+ feature: "physics",
123
+ needed: (s) => !!s.physics || hasBody(s)
124
+ },
125
+ GLTFLoader: {
126
+ feature: "glTF models",
127
+ needed: (s) => hasKind(s, ["model"])
128
+ },
129
+ SkeletonUtils: {
130
+ feature: "glTF models",
131
+ needed: (s) => hasKind(s, ["model"])
132
+ },
133
+ meshopt_decoder: {
134
+ feature: "meshopt-compressed models",
135
+ needed: (s) => hasKind(s, ["model"])
136
+ },
137
+ FontLoader: {
138
+ feature: "3D text",
139
+ needed: (s) => hasKind(s, ["text"])
140
+ },
141
+ SVGLoader: {
142
+ feature: "SVG objects",
143
+ needed: (s) => hasKind(s, ["svg"])
144
+ },
145
+ BufferGeometryUtils: {
146
+ feature: "3D text / SVG",
147
+ needed: (s) => hasKind(s, ["text", "svg"])
148
+ }
149
+ };
150
+ function chunkBase(file) {
151
+ return file.slice(file.lastIndexOf("/") + 1).replace(/\.js$/, "").replace(/-[A-Za-z0-9_-]{6,12}$/, "").replace(/\.module$/, "");
152
+ }
153
+ function resolveRel$1(dir, rel) {
154
+ const out = [];
155
+ for (const p of (dir + rel).split("/")) {
156
+ if (p === "." || p === "") continue;
157
+ if (p === "..") out.pop();
158
+ else out.push(p);
159
+ }
160
+ return out.join("/");
161
+ }
162
+ function importGraph(files) {
163
+ const dec = new TextDecoder();
164
+ const graph = /* @__PURE__ */ new Map();
165
+ for (const [file, bytes] of Object.entries(files)) {
166
+ if (!file.endsWith(".js")) continue;
167
+ const src = dec.decode(bytes);
168
+ const dir = file.includes("/") ? file.slice(0, file.lastIndexOf("/") + 1) : "";
169
+ const stat = /* @__PURE__ */ new Set();
170
+ const dyn = /* @__PURE__ */ new Set();
171
+ for (const m of src.matchAll(/\b(?:import|export)\s*(?:[^'"`();]*?\bfrom\s*)?["'](\.{1,2}\/[^"']+)["']/g)) stat.add(resolveRel$1(dir, m[1]));
172
+ for (const m of src.matchAll(/\bimport\(\s*[`"'](\.{1,2}\/[^`"']+)[`"']\s*\)/g)) dyn.add(resolveRel$1(dir, m[1]));
173
+ for (const d of dyn) stat.delete(d);
174
+ graph.set(file, {
175
+ static: [...stat].filter((f) => files[f]),
176
+ dynamic: [...dyn].filter((f) => files[f])
177
+ });
178
+ }
179
+ return graph;
180
+ }
181
+ function pageRuntime(files, entry, scene) {
182
+ const graph = importGraph(files);
183
+ const json = JSON.stringify(scene);
184
+ const loaded = /* @__PURE__ */ new Set();
185
+ const unknown = /* @__PURE__ */ new Set();
186
+ const features = {};
187
+ const queue = [entry];
188
+ const add = (f) => {
189
+ if (loaded.has(f)) return;
190
+ loaded.add(f);
191
+ queue.push(f);
192
+ };
193
+ const eager = /* @__PURE__ */ new Set([entry]);
194
+ const todo = [entry];
195
+ while (todo.length) for (const s of graph.get(todo.pop())?.static ?? []) {
196
+ if (eager.has(s)) continue;
197
+ eager.add(s);
198
+ todo.push(s);
199
+ }
200
+ loaded.add(entry);
201
+ while (queue.length) {
202
+ const f = queue.shift();
203
+ const g = graph.get(f);
204
+ if (!g) continue;
205
+ for (const s of g.static) add(s);
206
+ for (const d of g.dynamic) {
207
+ if (eager.has(d)) {
208
+ add(d);
209
+ continue;
210
+ }
211
+ const base = chunkBase(d);
212
+ const rule = CHUNK_FEATURES[base];
213
+ if (!rule) {
214
+ unknown.add(d);
215
+ add(d);
216
+ } else if (rule.needed(scene, json)) {
217
+ features[base] = rule.feature;
218
+ add(d);
219
+ }
220
+ }
221
+ }
222
+ const js = Object.keys(files).filter((f) => f.endsWith(".js") && !f.endsWith(".single.js"));
223
+ return {
224
+ loaded: [...loaded],
225
+ skipped: js.filter((f) => !loaded.has(f)),
226
+ unknown: [...unknown],
227
+ features
228
+ };
229
+ }
230
+ async function gzipSize(chunks, gzip) {
231
+ const enc = new TextEncoder();
232
+ let total = 0;
233
+ for (const c of chunks) {
234
+ const bytes = typeof c === "string" ? enc.encode(c) : c;
235
+ if (gzip) {
236
+ total += (await gzip(bytes)).byteLength;
237
+ continue;
238
+ }
239
+ if (typeof CompressionStream === "undefined") return void 0;
240
+ const stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream("gzip"));
241
+ total += (await new Response(stream).arrayBuffer()).byteLength;
242
+ }
243
+ return total;
244
+ }
245
+ // src/ops/exportFrameworks.ts
246
+ var kebab = (k) => k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
247
+ function reactWrapper(d) {
248
+ return `"use client";
249
+ // Agent3DScene.tsx — React (and Next.js) wrapper for the <agent3d-scene> Web Component.
250
+ // Generated by \`agent3d export\` for "${d.title}". No dependency besides React (>= 17).
251
+ //
252
+ // import { Agent3DScene } from "./Agent3DScene";
253
+ // <Agent3DScene src="${d.sceneSrc}" poster=${JSON.stringify(d.posterSrc ?? "")} aspect="${d.aspect}"
254
+ // data={{ ${d.dataKeys[0] ? `${d.dataKeys[0]}: "…"` : "title: \"…\""} }} onSceneEvent={(e) => console.log(e.name)} />
255
+ //
256
+ // Next.js: this file is a client component ("use client"); the runtime is loaded
257
+ // in the browser only (a <script type="module"> added once), so it is SSR-safe.
258
+ // Copy the export's agent3d-runtime/ and ${d.name}/ folders into public/.
259
+ import { createElement, useEffect, useRef, type CSSProperties } from "react";
260
+
261
+ export const AGENT3D_RUNTIME_SRC = ${JSON.stringify(d.runtimeSrc)};
262
+
263
+ export interface Agent3DPlayer {
264
+ play(): void;
265
+ pause(): void;
266
+ seek(t: number): Promise<void>;
267
+ time(): number;
268
+ snapshot(type?: "image/png" | "image/webp", quality?: number): string;
269
+ state(): Record<string, unknown>;
270
+ }
271
+
272
+ export interface Agent3DSceneElement extends HTMLElement {
273
+ player: Agent3DPlayer | null;
274
+ ready: Promise<Agent3DPlayer>;
275
+ readonly data: Record<string, unknown>;
276
+ play(): void;
277
+ pause(): void;
278
+ seek(t: number): Promise<void>;
279
+ setData(values: Record<string, unknown>, opts?: { replace?: boolean }): Promise<void>;
280
+ trigger(name: string, payload?: unknown): void;
281
+ reload(): Promise<void>;
282
+ }
283
+
284
+ export interface Agent3DSceneProps {
285
+ src: string;
286
+ poster?: string;
287
+ aspect?: string;
288
+ alt?: string;
289
+ ariaLabel?: string;
290
+ // Values for {data.key} placeholders of the scene (texts, links) — applied live.
291
+ data?: Record<string, string | number | boolean>;
292
+ autoplay?: boolean;
293
+ paused?: boolean;
294
+ loop?: boolean | "pingpong";
295
+ quality?: "low" | "medium" | "high" | "auto";
296
+ interactive?: boolean;
297
+ runtimeSrc?: string;
298
+ className?: string;
299
+ style?: CSSProperties;
300
+ onReady?(el: Agent3DSceneElement): void;
301
+ onError?(issue: { code: string; message: string; path?: string }): void;
302
+ onSceneEvent?(e: { name: string; payload?: unknown }): void;
303
+ onSceneClick?(e: { id: string | null; x: number; y: number }): void;
304
+ }
305
+
306
+ function loadRuntime(src: string): void {
307
+ if (typeof window === "undefined" || window.customElements?.get("agent3d-scene")) return;
308
+ const abs = new URL(src, document.baseURI).href;
309
+ if ([...document.querySelectorAll<HTMLScriptElement>("script[type=module]")].some((s) => s.src === abs)) return;
310
+ const s = document.createElement("script");
311
+ s.type = "module";
312
+ s.src = abs;${d.integrity ? `\n if (src === AGENT3D_RUNTIME_SRC) s.integrity = ${JSON.stringify(d.integrity)};` : ""}
313
+ document.head.appendChild(s);
314
+ }
315
+
316
+ export function Agent3DScene(props: Agent3DSceneProps) {
317
+ const ref = useRef<Agent3DSceneElement | null>(null);
318
+ const handlers = useRef(props);
319
+ handlers.current = props;
320
+ const runtimeSrc = props.runtimeSrc ?? AGENT3D_RUNTIME_SRC;
321
+
322
+ useEffect(() => loadRuntime(runtimeSrc), [runtimeSrc]);
323
+
324
+ useEffect(() => {
325
+ const el = ref.current;
326
+ if (!el) return;
327
+ const on = (type: string, fn: (detail: never) => void) => {
328
+ const l = (e: Event) => fn((e as CustomEvent).detail as never);
329
+ el.addEventListener(type, l);
330
+ return () => el.removeEventListener(type, l);
331
+ };
332
+ const offs = [
333
+ on("agent3d:ready", () => handlers.current.onReady?.(el)),
334
+ on("agent3d:error", (d) => handlers.current.onError?.(d)),
335
+ on("agent3d:event", (d) => handlers.current.onSceneEvent?.(d)),
336
+ on("agent3d:click", (d) => handlers.current.onSceneClick?.(d)),
337
+ ];
338
+ return () => offs.forEach((off) => off());
339
+ }, []);
340
+
341
+ const dataJson = JSON.stringify(props.data ?? {});
342
+ useEffect(() => {
343
+ const el = ref.current;
344
+ if (el && typeof el.setData === "function" && props.data) void el.setData(props.data);
345
+ // eslint-disable-next-line react-hooks/exhaustive-deps
346
+ }, [dataJson]);
347
+
348
+ const attrs: Record<string, unknown> = {
349
+ ref,
350
+ src: props.src,
351
+ poster: props.poster,
352
+ aspect: props.aspect,
353
+ alt: props.alt,
354
+ "aria-label": props.ariaLabel,
355
+ class: props.className,
356
+ style: props.style,
357
+ autoplay: props.autoplay === false ? "false" : undefined,
358
+ paused: props.paused ? "" : undefined,
359
+ loop: props.loop === undefined ? undefined : String(props.loop),
360
+ quality: props.quality,
361
+ interactive: props.interactive === false ? "false" : undefined,
362
+ };
363
+ // Initial data as data-* attributes (bound before the first frame, SSR-friendly).
364
+ for (const [k, v] of Object.entries(props.data ?? {})) attrs[\`data-\${k.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase())}\`] = String(v);
365
+ return createElement("agent3d-scene", attrs);
366
+ }
367
+
368
+ export default Agent3DScene;
369
+ `;
370
+ }
371
+ function vueWrapper(d) {
372
+ return `<!--
373
+ Agent3DScene.vue — Vue 3 wrapper for the <agent3d-scene> Web Component (generated by agent3d export).
374
+ Tell Vue it is a custom element (vite.config: vue({ template: { compilerOptions: { isCustomElement: (t) => t === "agent3d-scene" } } })
375
+ or Nuxt: vue.compilerOptions.isCustomElement), then:
376
+ <Agent3DScene src="${d.sceneSrc}" aspect="${d.aspect}" :data="{ ${d.dataKeys[0] ?? "title"}: '…' }" @scene-event="(e) => …" />
377
+ Nuxt: wrap it in <ClientOnly>.
378
+ -->
379
+ <script setup lang="ts">
380
+ import { onMounted, ref, watch } from "vue";
381
+
382
+ const props = defineProps<{
383
+ src: string;
384
+ poster?: string;
385
+ aspect?: string;
386
+ alt?: string;
387
+ data?: Record<string, string | number | boolean>;
388
+ autoplay?: boolean;
389
+ paused?: boolean;
390
+ loop?: boolean | "pingpong";
391
+ quality?: "low" | "medium" | "high" | "auto";
392
+ interactive?: boolean;
393
+ runtimeSrc?: string;
394
+ }>();
395
+ const emit = defineEmits<{ ready: [el: HTMLElement]; error: [issue: unknown]; sceneEvent: [e: { name: string; payload?: unknown }]; sceneClick: [e: { id: string | null }] }>();
396
+ const el = ref<HTMLElement & { setData?: (d: Record<string, unknown>) => Promise<void> }>();
397
+
398
+ onMounted(() => {
399
+ if (!customElements.get("agent3d-scene")) {
400
+ const s = document.createElement("script");
401
+ s.type = "module";
402
+ s.src = props.runtimeSrc ?? ${JSON.stringify(d.runtimeSrc)};
403
+ document.head.appendChild(s);
404
+ }
405
+ });
406
+ watch(() => JSON.stringify(props.data ?? {}), () => props.data && el.value?.setData?.(props.data));
407
+ <\/script>
408
+
409
+ <template>
410
+ <agent3d-scene
411
+ ref="el"
412
+ :src="src"
413
+ :poster="poster"
414
+ :aspect="aspect"
415
+ :alt="alt"
416
+ :autoplay="autoplay === false ? 'false' : undefined"
417
+ :paused="paused ? '' : undefined"
418
+ :loop="loop === undefined ? undefined : String(loop)"
419
+ :quality="quality"
420
+ :interactive="interactive === false ? 'false' : undefined"
421
+ v-bind="Object.fromEntries(Object.entries(data ?? {}).map(([k, v]) => ['data-' + k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)]))"
422
+ @agent3d:ready="emit('ready', $event.target)"
423
+ @agent3d:error="emit('error', $event.detail)"
424
+ @agent3d:event="emit('sceneEvent', $event.detail)"
425
+ @agent3d:click="emit('sceneClick', $event.detail)"
426
+ />
427
+ </template>
428
+ `;
429
+ }
430
+ function svelteWrapper(d) {
431
+ return `<!--
432
+ Agent3DScene.svelte — Svelte wrapper for the <agent3d-scene> Web Component (generated by agent3d export).
433
+ <Agent3DScene src="${d.sceneSrc}" aspect="${d.aspect}" data={{ ${d.dataKeys[0] ?? "title"}: "…" }} on:sceneevent={(e) => …} />
434
+ SvelteKit: the runtime loads in onMount (browser only), so SSR is fine.
435
+ -->
436
+ <script>
437
+ import { onMount, createEventDispatcher } from "svelte";
438
+ export let src;
439
+ export let poster = undefined;
440
+ export let aspect = ${JSON.stringify(d.aspect)};
441
+ export let alt = undefined;
442
+ export let data = undefined;
443
+ export let autoplay = undefined;
444
+ export let paused = false;
445
+ export let loop = undefined;
446
+ export let quality = undefined;
447
+ export let interactive = undefined;
448
+ export let runtimeSrc = ${JSON.stringify(d.runtimeSrc)};
449
+ const dispatch = createEventDispatcher();
450
+ let el;
451
+ onMount(() => {
452
+ if (!customElements.get("agent3d-scene")) {
453
+ const s = document.createElement("script");
454
+ s.type = "module";
455
+ s.src = runtimeSrc;
456
+ document.head.appendChild(s);
457
+ }
458
+ const fwd = (type, name) => { const l = (e) => dispatch(name, e.detail); el.addEventListener(type, l); return () => el.removeEventListener(type, l); };
459
+ const offs = [fwd("agent3d:ready", "ready"), fwd("agent3d:error", "error"), fwd("agent3d:event", "sceneevent"), fwd("agent3d:click", "sceneclick")];
460
+ return () => offs.forEach((off) => off());
461
+ });
462
+ $: if (el && data && el.setData) el.setData(data);
463
+ <\/script>
464
+
465
+ <agent3d-scene bind:this={el} {src} {poster} {aspect} {alt} {quality} autoplay={autoplay === false ? "false" : undefined} paused={paused ? "" : undefined} loop={loop === undefined ? undefined : String(loop)} interactive={interactive === false ? "false" : undefined}></agent3d-scene>
466
+ `;
467
+ }
468
+ var ELEMENT_DTS = `// agent3d-scene.d.ts — types of the <agent3d-scene> element (generated by agent3d export).
469
+ export interface Agent3DSceneElement extends HTMLElement {
470
+ player: { play(): void; pause(): void; seek(t: number): Promise<void>; time(): number; snapshot(type?: string, quality?: number): string; state(): Record<string, unknown> } | null;
471
+ ready: Promise<NonNullable<Agent3DSceneElement["player"]>>;
472
+ readonly data: Record<string, unknown>;
473
+ play(): void;
474
+ pause(): void;
475
+ seek(t: number): Promise<void>;
476
+ setData(values: Record<string, unknown>, opts?: { replace?: boolean }): Promise<void>;
477
+ trigger(name: string, payload?: unknown): void;
478
+ reload(): Promise<void>;
479
+ }
480
+ export interface Agent3DSceneEventMap {
481
+ "agent3d:ready": CustomEvent<{ player: NonNullable<Agent3DSceneElement["player"]> }>;
482
+ "agent3d:error": CustomEvent<{ code: string; message: string; path?: string }>;
483
+ "agent3d:event": CustomEvent<{ name: string; payload?: unknown }>;
484
+ "agent3d:click": CustomEvent<{ id: string | null; x: number; y: number }>;
485
+ "agent3d:progress": CustomEvent<{ loaded: number; total: number }>;
486
+ }
487
+ declare global {
488
+ interface HTMLElementTagNameMap {
489
+ "agent3d-scene": Agent3DSceneElement;
490
+ }
491
+ }
492
+ `;
493
+ function embedGuide(d) {
494
+ const dataAttrs = d.dataKeys.length ? d.dataKeys.map((k) => `data-${kebab(k)}="…"`).join(" ") : "data-title=\"…\"";
495
+ return `# ${d.title} — how to put it on your website
496
+
497
+ This folder is a self-contained 3D element: no server code, no account, no
498
+ third-party requests. Upload it as-is to any static host or CMS file area.
499
+
500
+ \`\`\`
501
+ agent3d-runtime/ the player (shared by every Agent3D scene on the site)
502
+ ${d.name}/ the scene (scene.json, assets, poster${d.hasScripts ? ", scripts" : ""})
503
+ index.html a demo page
504
+ snippet.html the code to paste
505
+ frameworks/ React / Next.js, Vue and Svelte wrappers + TypeScript types
506
+ \`\`\`
507
+
508
+ ## 1. Paste the snippet
509
+
510
+ \`\`\`html
511
+ ${d.snippet}
512
+ \`\`\`
513
+
514
+ The paths are relative to the page that includes the snippet. If the page lives
515
+ elsewhere (e.g. \`/blog/post/\`), either upload the folders next to it or
516
+ re-export with \`agent3d export --base-url /assets/3d/\` (absolute URLs).
517
+ The \`<img slot="poster">\` inside the element is shown before the runtime has
518
+ loaded, without JavaScript, without WebGL and when printing — keep it.
519
+
520
+ ## 2. Platforms
521
+
522
+ - **Plain HTML / static sites** (Netlify, Vercel, GitHub Pages, Cloudflare Pages, S3): upload the folder, paste the snippet.
523
+ - **WordPress**: upload the two folders to \`wp-content/uploads/agent3d/\` (SFTP or a file-manager plugin),
524
+ re-export with \`--base-url /wp-content/uploads/agent3d/\`, then add a **Custom HTML** block with the snippet.
525
+ (Media Library uploads rename files: use SFTP for the folders.)
526
+ - **Webflow**: host the folders on your own static host / CDN (Webflow cannot host .js / .json files),
527
+ export with \`--base-url https://your-cdn.example/3d/\`, then paste the snippet in an **Embed** element.
528
+ - **Shopify**: upload the files to *Content → Files* is not folder-aware — host the folders on a static host,
529
+ export with \`--base-url\`, and paste the snippet in a **Custom Liquid** section.
530
+ - **Squarespace / Wix / Framer / Google Sites**: their embed boxes run in an iframe. Use the
531
+ single-file export (\`agent3d export --format single-html\`), host that one file and embed it with
532
+ \`<iframe src="…/${d.name}.html" style="width:100%;aspect-ratio:${d.aspect.replace(":", "/")};border:0" title="${d.title}" loading="lazy"></iframe>\`.
533
+ - **AgentCMS**: use the "Agent3D scene" editor block (integrations/agentcms).
534
+
535
+ ## 3. Frameworks
536
+
537
+ - **React / Next.js**: \`frameworks/react/Agent3DScene.tsx\` (client component, SSR-safe). Put the
538
+ folders in \`public/\` and render \`<Agent3DScene src="${d.sceneSrc}" aspect="${d.aspect}" />\`.
539
+ - **Vue / Nuxt**: \`frameworks/vue/Agent3DScene.vue\` — declare \`agent3d-scene\` as a custom element
540
+ (\`compilerOptions.isCustomElement\`); in Nuxt wrap it in \`<ClientOnly>\`.
541
+ - **Svelte / SvelteKit**: \`frameworks/svelte/Agent3DScene.svelte\`.
542
+ - **Angular**: add \`CUSTOM_ELEMENTS_SCHEMA\` to the component and use the snippet.
543
+ - Types: \`frameworks/agent3d-scene.d.ts\`.
544
+
545
+ ## 4. Personalise it (data bindings)
546
+
547
+ Texts and links of the scene written as \`{data.key}\` take their value from \`data-*\`
548
+ attributes or from JavaScript — no re-export needed:
549
+
550
+ \`\`\`html
551
+ <agent3d-scene src="${d.sceneSrc}" ${dataAttrs}></agent3d-scene>
552
+ <script>document.querySelector("agent3d-scene").setData({ ${d.dataKeys[0] ?? "title"}: "Winter sale" });<\/script>
553
+ \`\`\`
554
+ ${d.dataKeys.length ? `\nThis scene's data keys: ${d.dataKeys.map((k) => `\`${k}\``).join(", ")}.\n` : ""}
555
+ ## 5. Attributes, JavaScript API, events
556
+
557
+ | Attribute | |
558
+ |---|---|
559
+ | \`src\` | scene.json URL |
560
+ | \`poster\` / \`<img slot="poster">\` | still image before the first frame / fallback |
561
+ | \`aspect\` | "W:H" reserved before the scene loads (no layout shift) |
562
+ | \`autoplay="false"\`, \`paused\` | start paused / pause while present |
563
+ | \`loop="true\\|false\\|pingpong"\` | override the timeline loop |
564
+ | \`quality="low\\|medium\\|high\\|auto"\` | pixel-ratio cap (low also drops antialiasing, shadows, post effects) |
565
+ | \`interactive="false"\` | let clicks and scrolling pass through |
566
+ | \`data-*\` | data bindings (above) |
567
+
568
+ \`\`\`js
569
+ const el = document.querySelector("agent3d-scene");
570
+ await el.ready; // the player, once the first frame is drawn
571
+ el.pause(); el.play(); await el.seek(2.5);
572
+ el.trigger("start"); // event for the scene's scripts
573
+ el.addEventListener("agent3d:click", (e) => console.log(e.detail.id)); // object clicked
574
+ el.addEventListener("agent3d:event", (e) => console.log(e.detail.name)); // script / UI events
575
+ el.addEventListener("agent3d:error", (e) => console.warn(e.detail));
576
+ \`\`\`
577
+
578
+ Styling: \`agent3d-scene::part(poster)\`, \`::part(loading)\`, \`::part(loading-bar)\`, \`::part(fallback)\`,
579
+ \`--agent3d-background\`, \`--agent3d-loading-color\`, \`--agent3d-poster-fit\`, \`--agent3d-fade\`.
580
+ The element carries \`status="loading|ready|error|unsupported"\`.
581
+
582
+ ## 6. Performance & behaviour
583
+
584
+ - Starts when scrolled into view, pauses off-screen and in background tabs, honours
585
+ \`prefers-reduced-motion\` (shows a still frame), caps the pixel ratio, gives its WebGL
586
+ context back when far off-screen, recovers from a lost GPU context.
587
+ - Several scenes on a page share one runtime (load the script once).
588
+ - Cache: \`agent3d-runtime/\` can be cached for a long time (\`Cache-Control: max-age=31536000, immutable\`)
589
+ when exported with \`--cache-bust\` (versioned folder name).
590
+
591
+ ## 7. Content-Security-Policy
592
+
593
+ The runtime needs no \`unsafe-eval\` and no inline script:
594
+
595
+ \`\`\`
596
+ script-src 'self'; img-src 'self' data: blob:; connect-src 'self' data: blob:; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'
597
+ \`\`\`
598
+
599
+ (\`style-src 'unsafe-inline'\` is only needed by scenes with a HUD; \`blob:\` / \`data:\` for textures
600
+ decoded in the browser; add \`'wasm-unsafe-eval'\` to script-src for meshopt-compressed models (\`export --optimize\`). Scenes with scripts load them as modules from \`${d.name}/scripts/\`.
601
+ Hosting on another origin: add it to script-src / connect-src / img-src and serve with CORS.)${d.integrity ? `\nThe snippet pins the runtime with Subresource Integrity (\`integrity="${d.integrity}"\`): re-copy the snippet after updating the runtime.` : ""}
602
+ ${d.ogImage ? `\n## 8. Social preview\n\n\`${d.ogImage}\` is a 1200×630 render for link previews:\n\n\`\`\`html\n<meta property="og:image" content="https://your-site.example/${d.ogImage}">\n<meta name="twitter:card" content="summary_large_image">\n\`\`\`\n` : ""}${d.credits.length ? `\n## Credits\n\n${d.credits.map((c) => `- ${c}`).join("\n")}\n` : ""}
603
+ ---
604
+ Made with Agent3D${d.version ? ` ${d.version}` : ""}.
605
+ `;
606
+ }
607
+ // src/ops/export.ts
608
+ var export_exports = /* @__PURE__ */ __exportAll({ buildExport: () => buildExport });
609
+ var enc = new TextEncoder();
610
+ var byteLen = (v) => typeof v === "string" ? enc.encode(v).byteLength : v.byteLength;
611
+ var SINGLE_HTML_WARN_BYTES = 5242880;
612
+ var PRELOAD_MIN_BYTES = 102400;
613
+ function escapeHtml(s) {
614
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
615
+ }
616
+ function inlineJson(v) {
617
+ return JSON.stringify(v).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
618
+ }
619
+ function inlineJs(js) {
620
+ return js.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--");
621
+ }
622
+ function posterInfo(bytes) {
623
+ if (bytes[0] === 137 && bytes[1] === 80) return {
624
+ ext: "png",
625
+ mime: "image/png"
626
+ };
627
+ if (bytes[0] === 255 && bytes[1] === 216) return {
628
+ ext: "jpg",
629
+ mime: "image/jpeg"
630
+ };
631
+ return {
632
+ ext: "webp",
633
+ mime: "image/webp"
634
+ };
635
+ }
636
+ function pickRuntime(runtime, format) {
637
+ const keys = Object.keys(runtime?.files ?? {});
638
+ const js = keys.filter((k) => /\.m?js$/.test(k));
639
+ const found = format === "single-html" ? js.find((k) => k.endsWith(".single.js")) ?? (js.length === 1 ? js[0] : void 0) : js.find((k) => k === "agent3d-runtime.js") ?? js.find((k) => !k.includes("/") && !k.endsWith(".single.js"));
640
+ if (!found) throw new OpsError("invalid", `No ${format === "single-html" ? "single-file runtime (agent3d-runtime.single.js)" : "runtime entry (agent3d-runtime.js)"} in the runtime files (${keys.slice(0, 5).join(", ") || "none"}).`, "Build the runtime first (npm run build:runtime) — the front door passes dist/runtime/.");
641
+ return found;
642
+ }
643
+ function normalizeBaseUrl(base) {
644
+ const b = (base ?? "").trim();
645
+ if (!b || b === "." || b === "./") return "./";
646
+ if (/^(javascript|data|vbscript):/i.test(b) || /["'<>\s]/.test(b)) throw new OpsError("invalid", `Invalid base URL "${base}".`, "Use a path (\"/static/3d/\"), a relative path (\"../3d/\") or an https URL (\"https://cdn.example.com/3d/\").");
647
+ return b.endsWith("/") ? b : `${b}/`;
648
+ }
649
+ async function digest(algo, parts) {
650
+ const total = parts.reduce((a, p) => a + p.byteLength, 0);
651
+ const buf = new Uint8Array(total);
652
+ let o = 0;
653
+ for (const p of parts) {
654
+ buf.set(p, o);
655
+ o += p.byteLength;
656
+ }
657
+ const subtle = globalThis.crypto?.subtle;
658
+ if (!subtle) throw new OpsError("invalid", "WebCrypto is not available to hash the runtime.", "Use Node ≥ 20 or a modern browser, or export with integrity: false.");
659
+ return new Uint8Array(await subtle.digest(algo, buf));
660
+ }
661
+ async function sri(bytes) {
662
+ const h = await digest("SHA-384", [bytes]);
663
+ let bin = "";
664
+ for (const b of h) bin += String.fromCharCode(b);
665
+ return `sha384-${btoa(bin)}`;
666
+ }
667
+ async function shortHash(parts) {
668
+ return [...(await digest("SHA-256", parts)).slice(0, 5)].map((b) => b.toString(16).padStart(2, "0")).join("");
669
+ }
670
+ function staticImports(files, entry) {
671
+ const dec = new TextDecoder();
672
+ const seen = /* @__PURE__ */ new Set();
673
+ const order = [];
674
+ const visit = (file) => {
675
+ const bytes = files[file];
676
+ if (!bytes) return;
677
+ const src = dec.decode(bytes);
678
+ const dir = file.includes("/") ? file.slice(0, file.lastIndexOf("/") + 1) : "";
679
+ for (const m of src.matchAll(/\b(?:import|export)\s*(?:[^'"();]*?\bfrom\s*)?["'](\.{1,2}\/[^"']+)["']/g)) {
680
+ const target = resolveRel(dir, m[1]);
681
+ if (seen.has(target) || !files[target]) continue;
682
+ seen.add(target);
683
+ order.push(target);
684
+ visit(target);
685
+ }
686
+ };
687
+ visit(entry);
688
+ return order;
689
+ }
690
+ function resolveRel(dir, rel) {
691
+ const parts = (dir + rel).split("/");
692
+ const out = [];
693
+ for (const p of parts) {
694
+ if (p === "." || p === "") continue;
695
+ if (p === "..") out.pop();
696
+ else out.push(p);
697
+ }
698
+ return out.join("/");
699
+ }
700
+ function posterMarkup(p) {
701
+ const dims = p.size ? ` width="${Math.round(p.size.width)}" height="${Math.round(p.size.height)}"` : "";
702
+ const img = (slot) => `<img${slot ? " slot=\"poster\"" : ""} src="${escapeHtml(p.src)}" alt="${escapeHtml(p.alt)}"${dims} decoding="async" style="display:block;width:100%;height:auto">`;
703
+ if (!p.avif) return img(true);
704
+ return `<picture slot="poster"><source type="image/avif" srcset="${escapeHtml(p.avif)}">${img(false)}</picture>`;
705
+ }
706
+ async function writeZip(files, deflate) {
707
+ const defl = deflate ?? (typeof CompressionStream !== "undefined" ? async (d) => new Uint8Array(await new Response(new Blob([d]).stream().pipeThrough(new CompressionStream("deflate-raw"))).arrayBuffer()) : void 0);
708
+ const parts = [];
709
+ const central = [];
710
+ let offset = 0;
711
+ const le = (n, bytes) => {
712
+ const b = new Uint8Array(bytes);
713
+ for (let i = 0; i < bytes; i++) b[i] = n >>> 8 * i & 255;
714
+ return b;
715
+ };
716
+ const cat = (...a) => {
717
+ const out = new Uint8Array(a.reduce((x, y) => x + y.byteLength, 0));
718
+ let o = 0;
719
+ for (const p of a) out.set(p, o), o += p.byteLength;
720
+ return out;
721
+ };
722
+ for (const [name, content] of Object.entries(files)) {
723
+ const data = typeof content === "string" ? enc.encode(content) : content;
724
+ const nameBytes = enc.encode(name);
725
+ const crc = crc32(data);
726
+ let method = 0;
727
+ let body = data;
728
+ if (defl && data.byteLength > 64) {
729
+ const z = await defl(data);
730
+ if (z.byteLength < data.byteLength) {
731
+ method = 8;
732
+ body = z;
733
+ }
734
+ }
735
+ const common = cat(le(20, 2), le(2048, 2), le(method, 2), le(0, 2), le(33, 2), le(crc, 4), le(body.byteLength, 4), le(data.byteLength, 4), le(nameBytes.byteLength, 2), le(0, 2));
736
+ const local = cat(le(67324752, 4), common, nameBytes);
737
+ central.push(cat(le(33639248, 4), le(20, 2), common, le(0, 2), le(0, 2), le(0, 2), le(0, 4), le(offset, 4), nameBytes));
738
+ parts.push(local, body);
739
+ offset += local.byteLength + body.byteLength;
740
+ }
741
+ const cd = cat(...central);
742
+ const eocd = cat(le(101010256, 4), le(0, 2), le(0, 2), le(central.length, 2), le(central.length, 2), le(cd.byteLength, 4), le(offset, 4), le(0, 2));
743
+ return cat(...parts, cd, eocd);
744
+ }
745
+ async function buildExport(fs, opts) {
746
+ const format = opts.format ?? "embed";
747
+ if (format !== "embed" && format !== "single-html" && format !== "zip") throw new OpsError("invalid", `Unknown export format "${String(format)}".`, "Use \"embed\" (folder for a static site), \"zip\" (the same folder as one .zip) or \"single-html\" (one self-contained file). Poster/video exports are done by the CLI renderer.");
748
+ const baseUrl = normalizeBaseUrl(opts.baseUrl);
749
+ const source = await readSceneFile(fs);
750
+ const issues = validateScene(source).filter((i) => i.severity !== "info");
751
+ if (hasErrors(issues)) throw validationError("Cannot export an invalid scene:", issues, "Run check / scene_validate and fix the errors first.");
752
+ const projectManifest = await readJsonOr(fs, MANIFEST_FILE, null);
753
+ const name = slugify(opts.name ?? projectManifest?.name ?? source.id ?? "scene", "scene");
754
+ const runtimeEntry = pickRuntime(opts.runtime, format === "single-html" ? "single-html" : "embed");
755
+ const manifest = await readAssetManifest(fs);
756
+ const entries = new Map(manifest.assets.map((a) => [a.path, a]));
757
+ const scene = clone(source);
758
+ const assetFiles = /* @__PURE__ */ new Map();
759
+ const credits = [];
760
+ const pending = [];
761
+ const libCopies = /* @__PURE__ */ new Map();
762
+ const missing = [];
763
+ const seenPaths = /* @__PURE__ */ new Set();
764
+ visitAssetRefs(scene, (path, at) => {
765
+ if (isLibraryRef(path)) {
766
+ const id = libraryId(path);
767
+ const asset = findLibraryAsset(opts.library?.index, id);
768
+ if (!asset) {
769
+ missing.push(`${at}: unknown library asset "${id}"`);
770
+ return;
771
+ }
772
+ const ext = asset.path.includes(".") ? asset.path.slice(asset.path.lastIndexOf(".")) : "";
773
+ const rel = `assets/library/${id.endsWith(ext) ? id : id + ext}`;
774
+ if (!libCopies.has(id)) {
775
+ libCopies.set(id, rel);
776
+ pending.push((async () => {
777
+ assetFiles.set(rel, await opts.library.read(id));
778
+ })());
779
+ credits.push({
780
+ path: rel,
781
+ license: asset.license,
782
+ author: asset.author,
783
+ source: "Agent3D library",
784
+ ...asset.attribution ? { attribution: asset.attribution } : {}
785
+ });
786
+ }
787
+ return rel;
788
+ }
789
+ if (!seenPaths.has(path)) {
790
+ seenPaths.add(path);
791
+ pending.push((async () => {
792
+ if (!await fs.exists(path)) {
793
+ missing.push(`${at}: "${path}" does not exist`);
794
+ return;
795
+ }
796
+ const bytes = await fs.readBytes(path);
797
+ assetFiles.set(path, bytes);
798
+ if (path.toLowerCase().endsWith(".gltf")) for (const dep of gltfDependencies(path, new TextDecoder().decode(bytes))) if (await fs.exists(dep)) assetFiles.set(dep, await fs.readBytes(dep));
799
+ else missing.push(`${at}: "${path}" needs "${dep}"`);
800
+ })());
801
+ const e = entries.get(path);
802
+ credits.push(e ? {
803
+ path,
804
+ license: e.license,
805
+ author: e.author,
806
+ source: e.sourceUrl ?? e.source,
807
+ ...e.attribution ? { attribution: e.attribution } : {}
808
+ } : {
809
+ path,
810
+ license: "unknown"
811
+ });
812
+ }
813
+ });
814
+ await Promise.all(pending);
815
+ if (missing.length) throw new OpsError("notFound", `Missing assets: ${missing.slice(0, 5).join("; ")}${missing.length > 5 ? "; …" : ""}`, "Run check to list missing files, add them (assets_add) or fix the paths.", { missing });
816
+ const scriptFiles = /* @__PURE__ */ new Map();
817
+ for (const p of scene.scripts ?? []) {
818
+ if (!await fs.exists(p)) throw new OpsError("notFound", `Script "${p}" does not exist.`, "Create it or remove it from scene.scripts.");
819
+ scriptFiles.set(p, await fs.readText(p));
820
+ }
821
+ const kind = scene.target?.kind ?? "banner";
822
+ const budgetKb = scene.target?.budgetKb ?? DEFAULT_BUDGET_KB[kind] ?? 600;
823
+ const sceneJson = `${JSON.stringify(scene, null, 2)}\n`;
824
+ const assetsBytes = [...assetFiles.values()].reduce((a, b) => a + b.byteLength, 0);
825
+ const scriptsBytes = [...scriptFiles.values()].reduce((a, b) => a + byteLen(b), 0);
826
+ const posterBytes = opts.poster?.byteLength ?? 0;
827
+ const out = {};
828
+ const outIssues = [...issues];
829
+ const title = substituteData(scene.title ?? "", scene.data).trim() || name;
830
+ const label = scene.ariaLabel !== void 0 ? substituteData(scene.ariaLabel, scene.data).trim() || title : title;
831
+ const aspect = parseAspect(scene.target?.aspect) ?? {
832
+ width: 16,
833
+ height: 9,
834
+ ratio: 16 / 9
835
+ };
836
+ const sizeStyle = scene.target?.height ? `height:${scene.target.height}` : `aspect-ratio:${aspect.width} / ${aspect.height}`;
837
+ let snippet;
838
+ let entry;
839
+ let runtimeBytes = 0;
840
+ let runtimeDirName;
841
+ let pageRt = null;
842
+ let pruned = false;
843
+ let integrity;
844
+ let head;
845
+ if (format === "embed" || format === "zip") {
846
+ const allRuntime = Object.entries(opts.runtime.files).filter(([k]) => !k.endsWith(".single.js"));
847
+ pageRt = pageRuntime(Object.fromEntries(allRuntime), runtimeEntry, scene);
848
+ pruned = !!opts.pruneRuntime && !pageRt.unknown.length;
849
+ if (opts.pruneRuntime && pageRt.unknown.length) outIssues.push({
850
+ severity: "info",
851
+ code: "prune-runtime",
852
+ path: "runtime",
853
+ message: `Kept every runtime chunk: ${pageRt.unknown.join(", ")} ${pageRt.unknown.length > 1 ? "have" : "has"} no known feature.`,
854
+ hint: "Nothing to do — the export works; report it so the chunk gets mapped (src/ops/runtimeChunks.ts)."
855
+ });
856
+ const keep = new Set(pageRt.loaded);
857
+ const runtimeFiles = pruned ? allRuntime.filter(([k]) => keep.has(k) || !k.endsWith(".js")) : allRuntime;
858
+ runtimeDirName = opts.cacheBust ? `agent3d-runtime-${await shortHash(runtimeFiles.map(([k, v]) => [enc.encode(k), v]).flat())}` : "agent3d-runtime";
859
+ for (const [k, v] of runtimeFiles) {
860
+ out[`${runtimeDirName}/${k}`] = v;
861
+ runtimeBytes += v.byteLength;
862
+ }
863
+ out[`${name}/scene.json`] = sceneJson;
864
+ for (const [p, b] of assetFiles) out[`${name}/${p}`] = b;
865
+ for (const [p, s] of scriptFiles) out[`${name}/${p}`] = s;
866
+ const url = (rel) => `${baseUrl}${rel}`;
867
+ let posterRel;
868
+ if (opts.poster) {
869
+ const { ext } = posterInfo(opts.poster);
870
+ posterRel = `${name}/poster.${ext}`;
871
+ out[posterRel] = opts.poster;
872
+ if (opts.posterAvif) out[`${name}/poster.avif`] = opts.posterAvif;
873
+ }
874
+ let ogRel;
875
+ if (opts.ogImage) {
876
+ ogRel = `${name}/og-image.png`;
877
+ out[ogRel] = opts.ogImage;
878
+ }
879
+ const entryBytes = opts.runtime.files[runtimeEntry];
880
+ const wantSri = opts.integrity !== false;
881
+ integrity = wantSri ? await sri(entryBytes) : void 0;
882
+ const sriAttr = (b) => wantSri ? sri(b).then((h) => ` integrity="${h}"`) : Promise.resolve("");
883
+ const preloads = [];
884
+ const allPreloads = [];
885
+ for (const dep of staticImports(opts.runtime.files, runtimeEntry)) {
886
+ const link = `<link rel="modulepreload" href="${url(`${runtimeDirName}/${dep}`)}"${await sriAttr(opts.runtime.files[dep])}>`;
887
+ allPreloads.push(link);
888
+ if (opts.runtime.files[dep].byteLength >= PRELOAD_MIN_BYTES) preloads.push(link);
889
+ }
890
+ head = allPreloads.join("\n");
891
+ const cacheQ = opts.cacheBust ? `?v=${await shortHash([enc.encode(sceneJson), ...assetFiles.values()])}` : "";
892
+ const aspectAttr = scene.target?.height ? "" : ` aspect="${aspect.width}:${aspect.height}"`;
893
+ const posterQ = opts.cacheBust && opts.poster ? `?v=${await shortHash([opts.poster, ...opts.posterAvif ? [opts.posterAvif] : []])}` : "";
894
+ const posterImg = posterRel ? posterMarkup({
895
+ src: url(posterRel) + posterQ,
896
+ avif: opts.posterAvif ? url(`${name}/poster.avif`) + posterQ : void 0,
897
+ alt: label,
898
+ size: opts.posterSize
899
+ }) : "";
900
+ snippet = [
901
+ ...preloads,
902
+ `<script type="module" src="${url(`${runtimeDirName}/${runtimeEntry}`)}"${integrity ? ` integrity="${integrity}"` : ""}><\/script>`,
903
+ `<agent3d-scene src="${url(`${name}/scene.json`)}${cacheQ}"${aspectAttr} role="${kind === "game" ? "application" : "img"}" aria-label="${escapeHtml(label)}">${posterImg ? `\n ${posterImg}\n` : ""}</agent3d-scene>`
904
+ ].join("\n");
905
+ out["snippet.html"] = `${snippet}\n`;
906
+ if (head) out["head.html"] = `<!-- Optional: in the <head> of pages showing Agent3D scenes (preloads the runtime's modules). -->\n${head}\n`;
907
+ if (credits.length) out[`${name}/CREDITS.txt`] = creditsText(title, credits);
908
+ out["index.html"] = demoPage({
909
+ title,
910
+ description: scene.description === void 0 ? void 0 : substituteData(scene.description, scene.data),
911
+ snippet,
912
+ credits,
913
+ sizeStyle,
914
+ poster: posterRel ? url(posterRel) : void 0,
915
+ ogImage: ogRel ? baseUrl === "./" ? `./${ogRel}` : url(ogRel) : void 0
916
+ });
917
+ if (opts.extras !== false) {
918
+ const doc = {
919
+ name,
920
+ title,
921
+ runtimeSrc: url(`${runtimeDirName}/${runtimeEntry}`),
922
+ sceneSrc: url(`${name}/scene.json`),
923
+ posterSrc: posterRel ? url(posterRel) + posterQ : void 0,
924
+ aspect: `${aspect.width}:${aspect.height}`,
925
+ snippet,
926
+ dataKeys: Object.keys(scene.data ?? {}).filter((k) => /^[a-zA-Z][\w]*$/.test(k)),
927
+ integrity,
928
+ ogImage: ogRel,
929
+ hasScripts: scriptFiles.size > 0,
930
+ credits: credits.filter((c) => !/^(cc0|public)/i.test(c.license)).map(creditLine),
931
+ version: opts.version
932
+ };
933
+ out["EMBED.md"] = embedGuide(doc);
934
+ out["frameworks/react/Agent3DScene.tsx"] = reactWrapper(doc);
935
+ out["frameworks/vue/Agent3DScene.vue"] = vueWrapper(doc);
936
+ out["frameworks/svelte/Agent3DScene.svelte"] = svelteWrapper(doc);
937
+ out["frameworks/agent3d-scene.d.ts"] = ELEMENT_DTS;
938
+ }
939
+ entry = "index.html";
940
+ if (format === "zip") {
941
+ const zipName = `${name}-embed.zip`;
942
+ const zip = await writeZip(out, opts.deflate);
943
+ for (const k of Object.keys(out)) delete out[k];
944
+ out[zipName] = zip;
945
+ entry = zipName;
946
+ }
947
+ } else {
948
+ const runtimeJs = new TextDecoder().decode(opts.runtime.files[runtimeEntry]);
949
+ runtimeBytes = opts.runtime.files[runtimeEntry].byteLength;
950
+ const assetUrls = {};
951
+ for (const [p, b] of assetFiles) assetUrls[p] = dataUri(b, mimeFromPath(p));
952
+ const scriptSources = Object.fromEntries(scriptFiles);
953
+ const posterAttr = opts.poster ? ` poster="${dataUri(opts.poster, posterInfo(opts.poster).mime)}"` : "";
954
+ snippet = [
955
+ `<agent3d-scene aria-label="${escapeHtml(label)}"${scene.target?.height ? "" : ` aspect="${aspect.width}:${aspect.height}"`}${posterAttr} style="display:block;width:100%">`,
956
+ `<script type="application/json">${inlineJson(scene)}<\/script>`,
957
+ ...Object.keys(assetUrls).length ? [`<script type="application/json" data-assets>${inlineJson(assetUrls)}<\/script>`] : [],
958
+ ...Object.entries(scriptSources).map(([p, src]) => `<script type="text/agent3d-script" data-path="${escapeHtml(p)}">${inlineJs(src)}<\/script>`),
959
+ `</agent3d-scene>`,
960
+ `<script type="module">${inlineJs(runtimeJs)}<\/script>`
961
+ ].join("\n");
962
+ entry = `${name}.html`;
963
+ out[entry] = singlePage({
964
+ title,
965
+ body: snippet,
966
+ credits
967
+ });
968
+ const size = byteLen(out[entry]);
969
+ if (size > SINGLE_HTML_WARN_BYTES) outIssues.push({
970
+ severity: "warning",
971
+ code: "single-html-size",
972
+ path: entry,
973
+ message: `${entry} weighs ${(size / 1048576).toFixed(1)} MB (data: URIs inflate assets by ~33%).`,
974
+ hint: "Use the \"embed\" format for heavy scenes, or shrink textures / models."
975
+ });
976
+ }
977
+ const contentKb = KB(byteLen(sceneJson) + assetsBytes + scriptsBytes);
978
+ if (contentKb > budgetKb) outIssues.push({
979
+ severity: "warning",
980
+ code: "budget",
981
+ path: "target.budgetKb",
982
+ message: `The export weighs ${contentKb} KB (runtime excluded), above the ${budgetKb} KB budget for a ${kind}.`,
983
+ hint: "Shrink textures (1k, .jpg/.webp), compress or replace models, or raise target.budgetKb."
984
+ });
985
+ for (const c of credits) if (c.license === "unknown") outIssues.push({
986
+ severity: "warning",
987
+ code: "unknown-licence",
988
+ path: c.path,
989
+ message: `${c.path} has no licence in assets/manifest.json.`,
990
+ hint: "Register it with assets_add (license + author) before publishing."
991
+ });
992
+ const totalBytes = Object.values(out).reduce((a, v) => a + byteLen(v), 0);
993
+ const pageParts = format === "single-html" ? [out[entry]] : [
994
+ ...(pageRt?.loaded ?? []).map((f) => opts.runtime.files[f]).filter(Boolean),
995
+ sceneJson,
996
+ ...assetFiles.values(),
997
+ ...scriptFiles.values(),
998
+ ...opts.poster ? [opts.poster] : []
999
+ ];
1000
+ const pageBytes = pageParts.reduce((a, v) => a + byteLen(v), 0);
1001
+ const pageRuntimeBytes = format === "single-html" ? runtimeBytes : (pageRt?.loaded ?? []).reduce((a, f) => a + (opts.runtime.files[f]?.byteLength ?? 0), 0);
1002
+ const gz = await gzipSize(pageParts, opts.gzip).catch(() => void 0);
1003
+ return {
1004
+ format,
1005
+ name,
1006
+ files: out,
1007
+ snippet,
1008
+ entry,
1009
+ totalKb: KB(totalBytes),
1010
+ folderKb: KB(totalBytes),
1011
+ pageKb: KB(pageBytes),
1012
+ ...gz !== void 0 ? { pageKbGzip: KB(gz) } : {},
1013
+ page: {
1014
+ runtimeKb: KB(pageRuntimeBytes),
1015
+ runtimeFiles: format === "single-html" ? [runtimeEntry] : pageRt?.loaded ?? [],
1016
+ skippedChunks: format === "single-html" ? [] : pageRt?.skipped ?? [],
1017
+ unknownChunks: pageRt?.unknown ?? [],
1018
+ pruned
1019
+ },
1020
+ sizes: {
1021
+ runtimeKb: KB(runtimeBytes),
1022
+ sceneKb: KB(byteLen(sceneJson)),
1023
+ assetsKb: KB(assetsBytes),
1024
+ scriptsKb: KB(scriptsBytes),
1025
+ posterKb: KB(posterBytes)
1026
+ },
1027
+ credits,
1028
+ issues: outIssues,
1029
+ ...runtimeDirName ? { runtimeDir: runtimeDirName } : {},
1030
+ ...integrity ? { integrity } : {},
1031
+ ...head ? { head } : {}
1032
+ };
1033
+ }
1034
+ function creditLine(c) {
1035
+ return !/^(cc0|public)/i.test(c.license) ? attributionText({
1036
+ path: c.path,
1037
+ license: c.license,
1038
+ author: c.author,
1039
+ attribution: c.attribution,
1040
+ sourceUrl: c.source
1041
+ }) : `${c.path.split("/").pop()} — ${c.license}${c.author ? ` (${c.author})` : ""}`;
1042
+ }
1043
+ function creditsText(title, credits) {
1044
+ return [
1045
+ `Credits — ${title}`,
1046
+ "",
1047
+ ...credits.map((c) => `- ${creditLine(c)}`),
1048
+ "",
1049
+ "Made with Agent3D."
1050
+ ].join("\n") + "\n";
1051
+ }
1052
+ function creditsHtml(credits) {
1053
+ if (!credits.length) return "";
1054
+ return `<section class="credits"><h2>Credits &amp; licences</h2><ul>${credits.map((c) => `<li>${escapeHtml(creditLine(c))}</li>`).join("")}</ul></section>`;
1055
+ }
1056
+ function fileProtocolScript() {
1057
+ return `<script>
1058
+ if (location.protocol === "file:") {
1059
+ var note = document.getElementById("a3d-file-note");
1060
+ if (note) note.hidden = false;
1061
+ }
1062
+ <\/script>`;
1063
+ }
1064
+ function demoPage(p) {
1065
+ return `<!doctype html>
1066
+ <html lang="en">
1067
+ <head>
1068
+ <meta charset="utf-8">
1069
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1070
+ <title>${escapeHtml(p.title)} — Agent3D embed</title>${p.description ? `\n<meta name="description" content="${escapeHtml(p.description)}">` : ""}${p.ogImage ? `\n<meta property="og:title" content="${escapeHtml(p.title)}">\n<meta property="og:image" content="${escapeHtml(p.ogImage)}">\n<meta name="twitter:card" content="summary_large_image">` : ""}
1071
+ <style>
1072
+ :root { color-scheme: light dark; --fg: #1d1d22; --muted: #666; --bg: #f6f6f8; --card: #fff; --code: #0f1117; }
1073
+ @media (prefers-color-scheme: dark) { :root { --fg: #ececf1; --muted: #9a9aa5; --bg: #111216; --card: #1a1b21; } }
1074
+ * { box-sizing: border-box; }
1075
+ body { margin: 0; font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); }
1076
+ main { max-width: 1100px; margin: 0 auto; padding: 32px 16px 64px; }
1077
+ h1 { font-size: 1.6rem; margin: 0 0 4px; }
1078
+ p.lead { color: var(--muted); margin: 0 0 24px; }
1079
+ .stage { border-radius: 14px; overflow: hidden; background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
1080
+ agent3d-scene { display: block; width: 100%; ${p.sizeStyle}; }
1081
+ agent3d-scene:not(:defined) > img, agent3d-scene:not(:defined) > picture img { width: 100%; height: 100%; object-fit: cover; }
1082
+ h2 { font-size: 1.05rem; margin: 32px 0 8px; }
1083
+ pre { background: var(--code); color: #e6e6e6; padding: 16px; border-radius: 10px; overflow-x: auto; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
1084
+ .credits ul { padding-left: 20px; color: var(--muted); font-size: .92rem; }
1085
+ footer { margin-top: 40px; color: var(--muted); font-size: .85rem; }
1086
+ .file-note { margin: 0 0 16px; padding: 12px 16px; border-radius: 10px; background: #fff3cd; color: #5c4400; font-weight: 600; }
1087
+ .file-note code { font-weight: 700; }
1088
+ </style>
1089
+ </head>
1090
+ <body>
1091
+ <main>
1092
+ <h1>${escapeHtml(p.title)}</h1>
1093
+ <p class="lead">${escapeHtml(p.description ?? "A 3D element made with Agent3D. Paste the snippet below into any page of this site.")}</p>
1094
+ <p class="file-note" id="a3d-file-note" role="status" hidden>Open this page through a web server (file:// blocks module scripts) — e.g. <code>npx serve</code> in this folder, then open the address it prints.${p.poster ? " Showing the poster image meanwhile." : ""}</p>
1095
+ <div class="stage">
1096
+ ${p.snippet}
1097
+ </div>
1098
+ ${fileProtocolScript()}
1099
+ <h2>Embed snippet</h2>
1100
+ <pre><code>${escapeHtml(p.snippet)}</code></pre>
1101
+ <p>Upload this whole folder to your static site; the paths in the snippet are relative to the page that includes it. Several scenes can share the same runtime folder. <code>EMBED.md</code> explains WordPress, Webflow, Shopify, React / Next.js, Vue, Svelte, data bindings, the JavaScript API and the Content-Security-Policy; <code>frameworks/</code> holds ready-made wrapper components.</p>
1102
+ ${creditsHtml(p.credits)}
1103
+ <footer>Made with Agent3D — no server, no tracking, no third-party requests.</footer>
1104
+ </main>
1105
+ </body>
1106
+ </html>
1107
+ `;
1108
+ }
1109
+ function singlePage(p) {
1110
+ const credits = p.credits.filter((c) => !/^(cc0|public)/i.test(c.license));
1111
+ return `<!doctype html>
1112
+ <html lang="en">
1113
+ <head>
1114
+ <meta charset="utf-8">
1115
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1116
+ <title>${escapeHtml(p.title)}</title>
1117
+ <style>html,body{margin:0;background:transparent}body{font:14px system-ui,sans-serif}.agent3d-credits{font-size:12px;opacity:.7;padding:4px 8px}</style>
1118
+ </head>
1119
+ <body>
1120
+ ${p.body}
1121
+ ${credits.length ? `<div class="agent3d-credits">${credits.map((c) => escapeHtml(creditLine(c))).join(" · ")}</div>` : ""}
1122
+ </body>
1123
+ </html>
1124
+ `;
1125
+ }
1126
+ function prefixFiles(files, dir) {
1127
+ const d = dir.replace(/\/+$/, "");
1128
+ return Object.fromEntries(Object.entries(files).map(([k, v]) => [`${d}/${k}`, v]));
1129
+ }
1130
+ export { export_exports as n, prefixFiles as r, buildExport as t };