@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,971 @@
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 { C as GENERATORS, M as readJsonOr, O as KB, S as CATALOG, _ as expandPostFx, a as ASSET_MANIFEST_FILE, b as isLibraryRef, g as validateScene, p as DEFAULT_BUDGET_KB, s as SCENE_FILE, u as readSceneFile, v as postfxCost, w as catalogEntry, x as libraryId, y as findLibraryAsset } from "../agent3d.mjs";
9
+ import { t as closest } from "./suggest-Cpcgv1RP.mjs";
10
+ import { o as walkObjects } from "./tree-BrNYGui2.mjs";
11
+ import { i as modelInfo } from "./gltf-f_f0-OiV.mjs";
12
+ import { a as collectAssetRefs, o as gltfDependencies, r as optimizeSuggestions } from "./optimizeSizing-CkZ3fZRp.mjs";
13
+ // src/ops/budget.ts
14
+ function evalCost(formula, vars) {
15
+ const src = formula.replace(/~/g, "");
16
+ let i = 0;
17
+ const peek = () => {
18
+ while (src[i] === " ") i++;
19
+ return src[i];
20
+ };
21
+ const expr = () => {
22
+ let v = term();
23
+ for (let c = peek(); c === "+" || c === "-"; c = peek()) {
24
+ i++;
25
+ v = c === "+" ? v + term() : v - term();
26
+ }
27
+ return v;
28
+ };
29
+ const term = () => {
30
+ let v = power();
31
+ for (let c = peek(); c === "*" || c === "/"; c = peek()) {
32
+ i++;
33
+ const r = power();
34
+ v = c === "*" ? v * r : r === 0 ? 0 : v / r;
35
+ }
36
+ return v;
37
+ };
38
+ const power = () => {
39
+ const b = atom();
40
+ if (peek() === "^") {
41
+ i++;
42
+ return b ** power();
43
+ }
44
+ return b;
45
+ };
46
+ const atom = () => {
47
+ const c = peek();
48
+ if (c === "(") {
49
+ i++;
50
+ const v = expr();
51
+ if (peek() === ")") i++;
52
+ return v;
53
+ }
54
+ if (c === "-") {
55
+ i++;
56
+ return -atom();
57
+ }
58
+ const m = /^(\d+(?:\.\d+)?)|^([A-Za-z_]\w*)/.exec(src.slice(i));
59
+ if (!m) {
60
+ i = src.length;
61
+ return 0;
62
+ }
63
+ i += m[0].length;
64
+ if (m[1]) return Number(m[1]);
65
+ const v = vars[m[2]];
66
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
67
+ };
68
+ const v = expr();
69
+ return Number.isFinite(v) ? Math.max(0, Math.round(v)) : 0;
70
+ }
71
+ function paramVars(entry, params) {
72
+ const vars = {};
73
+ for (const p of entry.params) {
74
+ const v = params[p.name] !== void 0 ? params[p.name] : p.default;
75
+ if (typeof v === "number") vars[p.name] = v;
76
+ else if (Array.isArray(v)) {
77
+ vars[p.name] = v.length;
78
+ vars[`${p.name}Cells`] = v.reduce((a, x) => a + (Array.isArray(x) ? x.length : 1), 0);
79
+ }
80
+ }
81
+ return vars;
82
+ }
83
+ function geometryTriangles(geometry) {
84
+ const entry = typeof geometry?.type === "string" ? catalogEntry("geometries", geometry.type) : void 0;
85
+ if (!entry?.cost) return 0;
86
+ return evalCost(entry.cost, paramVars(entry, geometry));
87
+ }
88
+ function instanceCount(layout) {
89
+ const l = layout;
90
+ if (!l) return 0;
91
+ if (l.type === "grid" && Array.isArray(l.count)) return l.count.reduce((a, b) => a * (Number(b) || 0), 1);
92
+ if (l.type === "list") return Array.isArray(l.items) ? l.items.length : 0;
93
+ return typeof l.count === "number" ? l.count : 0;
94
+ }
95
+ var TRIS_PER_GLYPH_SEGMENT = {
96
+ "sans-bold": 9.9,
97
+ sans: 10.4,
98
+ "inter-black": 9.4,
99
+ "montserrat-extrabold": 9.2,
100
+ "space-grotesk-bold": 8.4,
101
+ "bebas-neue": 5.1,
102
+ anton: 6.5,
103
+ "serif-bold": 18.3,
104
+ serif: 18.1,
105
+ mono: 8.4,
106
+ display: 13.4,
107
+ pacifico: 24,
108
+ lobster: 14.9
109
+ };
110
+ function textCurveSegments(o) {
111
+ const size = typeof o.size === "number" ? o.size : 1;
112
+ const depth = typeof o.depth === "number" ? o.depth : .2;
113
+ const cs = typeof o.curveSegments === "number" ? o.curveSegments : depth > 0 ? 5 + size * 3 : 8 + size * 4;
114
+ return Math.round(Math.max(2, Math.min(32, cs)));
115
+ }
116
+ function textTriangles(o) {
117
+ const chars = String(o.text ?? "").replace(/\s/g, "").length;
118
+ const face = (TRIS_PER_GLYPH_SEGMENT[typeof o.font === "string" ? o.font : "sans-bold"] ?? 12) * textCurveSegments(o);
119
+ const depth = typeof o.depth === "number" ? o.depth : .2;
120
+ const bevel = depth > 0 && (typeof o.bevel === "number" ? o.bevel : 1) > 0;
121
+ const body = depth <= 0 ? 1 : bevel ? 16.6 : 4.1;
122
+ return Math.round(chars * face * (body + (o.outline ? 4.8 : 0)));
123
+ }
124
+ function objectTriangles(o, models) {
125
+ switch (o.kind) {
126
+ case "mesh": return geometryTriangles(o.geometry);
127
+ case "instances": return geometryTriangles(o.geometry) * instanceCount(o.layout);
128
+ case "text": return textTriangles(o);
129
+ case "model": {
130
+ const src = o.src;
131
+ return typeof src === "string" ? models?.(src) ?? 0 : 0;
132
+ }
133
+ case "generator": {
134
+ const entry = typeof o.generator === "string" ? catalogEntry("generators", o.generator) : void 0;
135
+ return entry?.cost ? evalCost(entry.cost, paramVars(entry, o.params ?? {})) : 0;
136
+ }
137
+ case "particles": return (o.count ?? 200) * 2;
138
+ case "svg": return 2e3;
139
+ default: return 0;
140
+ }
141
+ }
142
+ function estimateTriangles(scene, opts = {}) {
143
+ const byObject = [];
144
+ walkObjects(scene.objects, (o) => {
145
+ if (o.visible === false) return false;
146
+ const t = objectTriangles(o, opts.models);
147
+ if (t) byObject.push({
148
+ id: o.id,
149
+ triangles: t
150
+ });
151
+ });
152
+ byObject.sort((a, b) => b.triangles - a.triangles);
153
+ return {
154
+ total: byObject.reduce((a, b) => a + b.triangles, 0),
155
+ byObject
156
+ };
157
+ }
158
+ var PREPASS_EFFECTS = /* @__PURE__ */ new Set([
159
+ "ao",
160
+ "dof",
161
+ "godrays",
162
+ "outline"
163
+ ]);
164
+ function frameTriangles(scene, geometry, opts = {}) {
165
+ const noCast = /* @__PURE__ */ new Set();
166
+ walkObjects(scene.objects ?? [], (o) => {
167
+ const d = o;
168
+ if (d.castShadow === false || d.kind === "particles") {
169
+ noCast.add(o.id);
170
+ if (d.castShadow === false) walkObjects(o.children ?? [], (c) => void noCast.add(c.id));
171
+ }
172
+ });
173
+ const casters = geometry.byObject.filter((o) => !noCast.has(o.id)).reduce((a, o) => a + o.triangles, 0);
174
+ const env = scene.environment ?? {};
175
+ let shadowLights = 0;
176
+ if (scene.target?.shadows !== false) {
177
+ for (const l of scene.lights ?? []) if (l.castShadow && [
178
+ "directional",
179
+ "spot",
180
+ "point"
181
+ ].includes(l.type)) shadowLights += l.type === "point" ? 6 : 1;
182
+ const rig = env.rig;
183
+ if (rig && (typeof rig === "string" || rig.castShadow !== false)) shadowLights += 1;
184
+ const sky = env.background && typeof env.background === "object" ? env.background.sky : void 0;
185
+ if (sky && (sky.physical || sky.preset) && sky.sun !== false && sky.sun?.light !== false && sky.sun?.castShadow !== false) shadowLights += 1;
186
+ }
187
+ const prepass = (opts.expandPostFx ? opts.expandPostFx(scene.postfx) : scene.postfx ?? []).some((d) => PREPASS_EFFECTS.has(d.type)) ? geometry.total : 0;
188
+ const contact = env.contactShadows ? casters : 0;
189
+ const passes = {
190
+ main: geometry.total,
191
+ shadowMaps: casters * shadowLights,
192
+ prepass,
193
+ contactShadows: contact
194
+ };
195
+ return {
196
+ perFrame: passes.main + passes.shadowMaps + passes.prepass + passes.contactShadows,
197
+ passes,
198
+ shadowLights
199
+ };
200
+ }
201
+ var TRIANGLE_AIM = {
202
+ banner: 15e4,
203
+ card: 15e4,
204
+ square: 25e4,
205
+ inline: 25e4,
206
+ hero: 4e5,
207
+ fullscreen: 6e5,
208
+ game: 3e5
209
+ };
210
+ var TRIANGLE_LIMIT = {
211
+ banner: 5e5,
212
+ card: 4e5,
213
+ square: 5e5,
214
+ inline: 5e5,
215
+ hero: 1e6,
216
+ fullscreen: 2e6,
217
+ game: 2e6
218
+ };
219
+ CATALOG.geometries, CATALOG.generators;
220
+ // src/ops/postfxCheck.ts
221
+ function postfxReport(scene) {
222
+ const quality = scene.target?.quality ?? "auto";
223
+ const cost = postfxCost(scene.postfx);
224
+ const issues = [];
225
+ const kind = scene.target?.kind;
226
+ const heavy = cost.effects.filter((e) => e.gpu === "high").map((e) => e.type);
227
+ if (kind === "game" && heavy.length) issues.push({
228
+ severity: "warning",
229
+ code: "postfx-cost",
230
+ path: "postfx",
231
+ message: `${heavy.join(", ")} on a game target: ${heavy.length > 1 ? "these effects re-render" : "this effect re-renders"} the scene depth / normals and sample${heavy.length > 1 ? "" : "s"} heavily every frame — frame drops on laptops and phones.`,
232
+ hint: "Games need a steady 60 fps: remove them, or keep cheap effects only (bloom, grading, vignette, fxaa). target.quality \"auto\" also drops them on weak devices."
233
+ });
234
+ if (cost.level === "heavy") issues.push({
235
+ severity: kind === "game" || kind === "fullscreen" ? "warning" : "info",
236
+ code: "postfx-cost",
237
+ path: "postfx",
238
+ message: `Post-processing costs ~${cost.passes} fullscreen passes per frame (${cost.effects.map((e) => e.type).join(", ")}).`,
239
+ hint: "Keep the effects that change the image the most; grading / vignette / film / chromatic / sharpen are merged into one pass and nearly free, ao / dof / smaa / bloom are not."
240
+ });
241
+ if (quality === "ultra" && kind !== "fullscreen" && kind !== "hero") issues.push({
242
+ severity: "info",
243
+ code: "quality",
244
+ path: "target.quality",
245
+ message: `quality "ultra" on a ${kind}: full-resolution effects and MSAA 8 for every visitor.`,
246
+ hint: "Use \"auto\" (adapts to the device and frame rate) or \"high\"."
247
+ });
248
+ if (quality === "low" && heavy.length) issues.push({
249
+ severity: "info",
250
+ code: "quality",
251
+ path: "target.quality",
252
+ message: `quality "low" disables ${heavy.join(", ")} (cost "high").`,
253
+ hint: "Remove them from postfx, or use quality \"auto\" / \"medium\"."
254
+ });
255
+ return {
256
+ gpu: {
257
+ ...cost,
258
+ quality
259
+ },
260
+ issues
261
+ };
262
+ }
263
+ // src/ops/scriptLint.ts
264
+ var FORBIDDEN = {
265
+ fetch: "network access",
266
+ XMLHttpRequest: "network access",
267
+ WebSocket: "network access",
268
+ EventSource: "network access",
269
+ eval: "dynamic code execution",
270
+ Function: "dynamic code execution",
271
+ document: "DOM access outside the HUD",
272
+ window: "global page access",
273
+ globalThis: "global page access",
274
+ self: "global page access",
275
+ localStorage: "storage (use api.storage)",
276
+ sessionStorage: "storage (use api.storage)",
277
+ indexedDB: "storage (use api.storage)",
278
+ parent: "access to the parent page",
279
+ top: "access to the top page",
280
+ opener: "access to the opener page",
281
+ postMessage: "cross-frame messaging",
282
+ importScripts: "loading remote code",
283
+ navigator: "device / network APIs",
284
+ location: "page navigation",
285
+ Worker: "spawning code"
286
+ };
287
+ var AMBIGUOUS = /* @__PURE__ */ new Set([
288
+ "parent",
289
+ "top",
290
+ "self",
291
+ "location",
292
+ "opener"
293
+ ]);
294
+ function stripCode(src) {
295
+ let out = "";
296
+ let i = 0;
297
+ const n = src.length;
298
+ const tpl = [];
299
+ let braceDepth = 0;
300
+ const blank = (s) => s.replace(/[^\n]/g, " ");
301
+ let prevSignificant = "";
302
+ while (i < n) {
303
+ const c = src[i];
304
+ const d = src[i + 1];
305
+ if (c === "/" && d === "/") {
306
+ const end = src.indexOf("\n", i);
307
+ const stop = end < 0 ? n : end;
308
+ out += blank(src.slice(i, stop));
309
+ i = stop;
310
+ continue;
311
+ }
312
+ if (c === "/" && d === "*") {
313
+ const end = src.indexOf("*/", i + 2);
314
+ const stop = end < 0 ? n : end + 2;
315
+ out += blank(src.slice(i, stop));
316
+ i = stop;
317
+ continue;
318
+ }
319
+ if (c === "\"" || c === "'") {
320
+ let j = i + 1;
321
+ while (j < n && src[j] !== c && src[j] !== "\n") j += src[j] === "\\" ? 2 : 1;
322
+ out += c + blank(src.slice(i + 1, j)) + (j < n ? src[j] : "");
323
+ i = j + 1;
324
+ prevSignificant = c;
325
+ continue;
326
+ }
327
+ if (c === "`" || c === "}" && tpl.length && tpl[tpl.length - 1] === braceDepth) {
328
+ if (c === "}") tpl.pop();
329
+ let j = i + 1;
330
+ let opened = false;
331
+ while (j < n) {
332
+ if (src[j] === "\\") {
333
+ j += 2;
334
+ continue;
335
+ }
336
+ if (src[j] === "`") break;
337
+ if (src[j] === "$" && src[j + 1] === "{") {
338
+ opened = true;
339
+ break;
340
+ }
341
+ j++;
342
+ }
343
+ out += c + blank(src.slice(i + 1, j));
344
+ if (opened) {
345
+ out += "${";
346
+ tpl.push(braceDepth);
347
+ i = j + 2;
348
+ } else {
349
+ out += j < n ? "`" : "";
350
+ i = j + 1;
351
+ }
352
+ prevSignificant = "`";
353
+ continue;
354
+ }
355
+ if (c === "/" && /^$|[(,=:[!&|?{};+\-*%<>~^]$/.test(prevSignificant)) {
356
+ let j = i + 1;
357
+ let inClass = false;
358
+ while (j < n && src[j] !== "\n") {
359
+ if (src[j] === "\\") {
360
+ j += 2;
361
+ continue;
362
+ }
363
+ if (src[j] === "[") inClass = true;
364
+ else if (src[j] === "]") inClass = false;
365
+ else if (src[j] === "/" && !inClass) break;
366
+ j++;
367
+ }
368
+ if (j < n && src[j] === "/") {
369
+ out += "/" + blank(src.slice(i + 1, j)) + "/";
370
+ i = j + 1;
371
+ prevSignificant = "/x";
372
+ continue;
373
+ }
374
+ }
375
+ if (c === "{") braceDepth++;
376
+ if (c === "}") braceDepth--;
377
+ out += c;
378
+ if (!/\s/.test(c)) prevSignificant = c;
379
+ i++;
380
+ }
381
+ return out;
382
+ }
383
+ function lineOf(src, index) {
384
+ let line = 1;
385
+ for (let i = 0; i < index && i < src.length; i++) if (src.charCodeAt(i) === 10) line++;
386
+ return line;
387
+ }
388
+ function lintScript(source, path) {
389
+ const issues = [];
390
+ const code = stripCode(source);
391
+ const declared = /* @__PURE__ */ new Set();
392
+ for (const m of code.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g)) declared.add(m[1]);
393
+ for (const m of code.matchAll(/[A-Za-z_$][\w$]*/g)) {
394
+ const word = m[0];
395
+ const idx = m.index ?? 0;
396
+ if (word === "import") {
397
+ const after = code.slice(idx + 6).trimStart();
398
+ if (code.slice(0, idx).trimEnd().endsWith(".")) continue;
399
+ if (after.startsWith("(")) issues.push(issue(path, lineOf(source, idx), "Dynamic import() is forbidden in scripts.", "Scripts cannot load code: everything they need comes from the `api` argument."));
400
+ else if (after.startsWith(".meta")) issues.push(issue(path, lineOf(source, idx), "import.meta is forbidden in scripts.", "Use api.data for configuration."));
401
+ else if (/^[\w${*]/.test(after) || after.startsWith("\"") || after.startsWith("'")) issues.push(issue(path, lineOf(source, idx), "Static imports are not allowed in scripts.", "Scripts are self-contained modules: remove the import and use the `api` passed to the default export."));
402
+ continue;
403
+ }
404
+ const why = FORBIDDEN[word];
405
+ if (!why) continue;
406
+ const after = code.slice(idx + word.length).trimStart();
407
+ const prevChar = code.slice(Math.max(0, idx - 200), idx).trimEnd().slice(-1);
408
+ if (prevChar === ".") continue;
409
+ if (after.startsWith("(") && /^\s*\)\s*\{/.test(code.slice(idx + word.length).replace(/^\s*\([^)]*/, ""))) {
410
+ if (prevChar === "{" || prevChar === "," || prevChar === "}") continue;
411
+ }
412
+ if (after.startsWith(":") && (prevChar === "{" || prevChar === ",")) continue;
413
+ if (AMBIGUOUS.has(word) && declared.has(word)) continue;
414
+ if (AMBIGUOUS.has(word) && !/^[.([]/.test(after)) continue;
415
+ issues.push(issue(path, lineOf(source, idx), `Forbidden global "${word}" (${why}).`, hintFor(word)));
416
+ }
417
+ if (/\bdocument\s*\.\s*cookie\b|\.cookie\b/.test(code) && !issues.some((i) => i.message.includes("document"))) {
418
+ const idx = code.search(/\.cookie\b/);
419
+ issues.push(issue(path, lineOf(source, idx), "Cookie access is forbidden in scripts.", "Use api.storage.get/set for small persistent values."));
420
+ }
421
+ if (!/\bexport\s+default\b/.test(code)) issues.push({
422
+ severity: "error",
423
+ code: "forbidden-script",
424
+ path,
425
+ message: "The script has no `export default` factory.",
426
+ hint: "Write `export default function (api) { return { start() {}, update(dt, t) {} }; }`."
427
+ });
428
+ return dedupe(issues);
429
+ }
430
+ function hintFor(word) {
431
+ if ([
432
+ "fetch",
433
+ "XMLHttpRequest",
434
+ "WebSocket",
435
+ "EventSource"
436
+ ].includes(word)) return "Scenes never call the network at run time. Put data in scene.data (api.data) or in project assets.";
437
+ if ([
438
+ "localStorage",
439
+ "sessionStorage",
440
+ "indexedDB"
441
+ ].includes(word)) return "Use api.storage.get(key) / api.storage.set(key, value).";
442
+ if (word === "document" || word === "window" || word === "globalThis" || word === "self") return "Use the api: api.ui.set(id, { text }) for the HUD, api.input for keys/pointer, api.state for shared values.";
443
+ if (word === "eval" || word === "Function") return "Write the logic directly; dynamic code is not allowed.";
444
+ return "Remove it — scripts only get the `api` argument (see ScriptApi).";
445
+ }
446
+ function issue(path, line, message, hint) {
447
+ return {
448
+ severity: "error",
449
+ code: "forbidden-script",
450
+ path: `${path}:${line}`,
451
+ message,
452
+ hint
453
+ };
454
+ }
455
+ function dedupe(issues) {
456
+ const seen = /* @__PURE__ */ new Set();
457
+ return issues.filter((i) => {
458
+ const k = `${i.path}|${i.message}`;
459
+ if (seen.has(k)) return false;
460
+ seen.add(k);
461
+ return true;
462
+ });
463
+ }
464
+ // src/ops/check.ts
465
+ var check_exports = /* @__PURE__ */ __exportAll({ checkProject: () => checkProject });
466
+ var isCc0 = (l) => /^(cc0|cc-?0|public ?domain)/i.test(l.trim());
467
+ function attributionText(a) {
468
+ if (a.attribution) return a.attribution;
469
+ return `"${a.title ?? a.path?.split("/").pop() ?? "Asset"}"${a.author ? ` by ${a.author}` : ""}${a.sourceUrl ? ` (${a.sourceUrl})` : ""}, licensed under ${a.license}.`;
470
+ }
471
+ async function checkProject(fs, opts = {}) {
472
+ const issues = [];
473
+ const scene = await readSceneFile(fs);
474
+ issues.push(...validateScene(scene));
475
+ const kind = scene.target?.kind ?? "banner";
476
+ const manifest = await readJsonOr(fs, ASSET_MANIFEST_FILE, { assets: [] });
477
+ const entries = new Map((manifest.assets ?? []).map((a) => [a.path, a]));
478
+ let assetBytes = 0;
479
+ const counted = /* @__PURE__ */ new Set();
480
+ const licences = [];
481
+ const projectFiles = await fs.list("assets/");
482
+ const addLicence = (l) => {
483
+ if (!licences.some((x) => x.path === l.path)) licences.push(l);
484
+ };
485
+ const fileBytes = /* @__PURE__ */ new Map();
486
+ const countFile = async (path) => {
487
+ if (counted.has(path)) return;
488
+ counted.add(path);
489
+ const n = await fs.size(path);
490
+ fileBytes.set(path, n);
491
+ assetBytes += n;
492
+ };
493
+ for (const ref of collectAssetRefs(scene)) {
494
+ if (isLibraryRef(ref.path)) {
495
+ const id = libraryId(ref.path);
496
+ if (!opts.library) continue;
497
+ const asset = findLibraryAsset(opts.library, id);
498
+ if (!asset) {
499
+ const s = closest(id, opts.library.assets.map((a) => a.id));
500
+ issues.push({
501
+ severity: "error",
502
+ code: "unknown-library-id",
503
+ path: ref.at,
504
+ message: `Library asset "${id}" does not exist.`,
505
+ hint: `${s ? `Did you mean "library:${s}"? ` : ""}List the library with library_list (CLI: agent3d assets library --query <word>).`
506
+ });
507
+ continue;
508
+ }
509
+ if (!counted.has(ref.path)) {
510
+ counted.add(ref.path);
511
+ assetBytes += asset.bytes;
512
+ fileBytes.set(ref.path, asset.bytes);
513
+ }
514
+ if (!isCc0(asset.license)) addLicence({
515
+ path: ref.path,
516
+ license: asset.license,
517
+ author: asset.author,
518
+ attribution: attributionText({
519
+ ...asset,
520
+ title: asset.id
521
+ })
522
+ });
523
+ continue;
524
+ }
525
+ if (!ref.path || /^[a-z]+:/i.test(ref.path)) continue;
526
+ if (!await fs.exists(ref.path)) {
527
+ const s = closest(ref.path, projectFiles);
528
+ issues.push({
529
+ severity: "error",
530
+ code: "missing-asset",
531
+ path: ref.at,
532
+ message: `Asset file "${ref.path}" does not exist in the project.`,
533
+ hint: `${s ? `Did you mean "${s}"? ` : ""}Add it with assets_add / \`agent3d assets add\`, or point ${ref.at} at an existing file (assets_list).`
534
+ });
535
+ continue;
536
+ }
537
+ await countFile(ref.path);
538
+ if (ref.path.toLowerCase().endsWith(".gltf")) for (const dep of gltfDependencies(ref.path, await fs.readText(ref.path))) if (await fs.exists(dep)) await countFile(dep);
539
+ else issues.push({
540
+ severity: "error",
541
+ code: "missing-asset",
542
+ path: ref.at,
543
+ message: `"${ref.path}" references "${dep}", which is missing.`,
544
+ hint: "Copy the .bin / texture files next to the .gltf, or convert it to a single .glb."
545
+ });
546
+ const entry = entries.get(ref.path);
547
+ if (!entry) issues.push({
548
+ severity: "info",
549
+ code: "unregistered-asset",
550
+ path: ref.at,
551
+ message: `"${ref.path}" is not listed in assets/manifest.json (licence unknown).`,
552
+ hint: "Register it with assets_add (CLI: agent3d assets add <file> --license CC0-1.0 --author …) so the export can credit it."
553
+ });
554
+ else if (!isCc0(entry.license)) addLicence({
555
+ path: entry.path,
556
+ license: entry.license,
557
+ author: entry.author,
558
+ attribution: attributionText(entry)
559
+ });
560
+ }
561
+ for (const l of licences) issues.push({
562
+ severity: "info",
563
+ code: "attribution",
564
+ path: l.path,
565
+ message: `${l.path} is ${l.license}: it requires attribution.`,
566
+ hint: `Show this credit near the embed (the export's index.html lists it): ${l.attribution}`
567
+ });
568
+ let scriptBytes = 0;
569
+ for (const [i, path] of (scene.scripts ?? []).entries()) {
570
+ if (typeof path !== "string" || !path.startsWith("scripts/")) continue;
571
+ if (!await fs.exists(path)) {
572
+ const s = closest(path, await fs.list("scripts/"));
573
+ issues.push({
574
+ severity: "error",
575
+ code: "missing-script",
576
+ path: `scripts[${i}]`,
577
+ message: `Script "${path}" does not exist.`,
578
+ hint: `${s ? `Did you mean "${s}"? ` : ""}Create ${path} with \`export default function (api) { return { update(dt, t) {} }; }\`, or remove it from scene.scripts.`
579
+ });
580
+ continue;
581
+ }
582
+ const src = await fs.readText(path);
583
+ scriptBytes += new TextEncoder().encode(src).byteLength;
584
+ issues.push(...lintScript(src, path));
585
+ }
586
+ const listed = new Set(scene.scripts ?? []);
587
+ for (const file of await fs.list("scripts/")) if (/\.m?js$/.test(file) && !listed.has(file)) issues.push({
588
+ severity: "info",
589
+ code: "unused-script",
590
+ path: file,
591
+ message: `${file} is not listed in scene.scripts (it will not run or be exported).`,
592
+ hint: `Add "${file}" to scene.scripts, or delete it.`
593
+ });
594
+ const modelTris = /* @__PURE__ */ new Map();
595
+ for (const ref of collectAssetRefs(scene)) {
596
+ if (ref.kind !== "model" || modelTris.has(ref.path)) continue;
597
+ if (isLibraryRef(ref.path)) {
598
+ const t = opts.library ? findLibraryAsset(opts.library, libraryId(ref.path))?.triangles : void 0;
599
+ if (typeof t === "number") modelTris.set(ref.path, t);
600
+ } else if (/\.(glb|gltf)$/i.test(ref.path) && await fs.exists(ref.path)) {
601
+ const info = modelInfo(ref.path, await fs.readBytes(ref.path));
602
+ if (info) modelTris.set(ref.path, info.triangles);
603
+ }
604
+ }
605
+ const tris = estimateTriangles(scene, { models: (src) => modelTris.get(src) });
606
+ const frame = frameTriangles(scene, tris, { expandPostFx: (d) => expandPostFx(d) });
607
+ const sceneBytes = await fs.exists("scene.json") ? await fs.size(SCENE_FILE) : 0;
608
+ const budgetKb = scene.target?.budgetKb ?? DEFAULT_BUDGET_KB[kind] ?? 600;
609
+ const totalKb = KB(assetBytes + scriptBytes + sceneBytes);
610
+ if (totalKb > budgetKb) {
611
+ const heaviest = [...fileBytes.entries()].sort((a, b) => b[1] - a[1]).slice(0, 3);
612
+ budgetIssue: {
613
+ const hdris = heaviest.filter(([p]) => /\.(hdr|exr)$/i.test(p)).map(([p]) => p);
614
+ if (hdris.length) {
615
+ const others = heaviest.filter(([p]) => !hdris.includes(p));
616
+ issues.push({
617
+ severity: "warning",
618
+ code: "budget",
619
+ path: "target.budgetKb",
620
+ message: `The bundle weighs ~${totalKb} KB (runtime excluded), above the ${budgetKb} KB budget for a ${kind}.`,
621
+ hint: `Heaviest files: ${heaviest.map(([p, n]) => `${p} (${KB(n)} KB)`).join(", ")}. ${hdris.join(", ")} ${hdris.length > 1 ? "are HDRIs" : "is an HDRI"}: \`assets optimize\` never shrinks .hdr files. Use a lighter HDRI (a smaller download: \`assets add --hit … --resolution 1k\`; library sizes: \`agent3d assets library --kind hdri\`), or light without one — \`environment.lighting: "studio"\` (or "soft" / "sunset" / "night", built in, 0 KB), \`"sky"\` with a sky background, or a light rig (\`environment.rig\`, see \`agent3d catalog lightRigs\`) — and drop the background HDRI (\`environment.background\`: a colour, gradient or sky).${others.length ? ` For ${others.map(([p]) => p).join(", ")}: \`agent3d assets optimize --all\` (plan, then --yes).` : ""} Raise target.budgetKb only if the page can afford it.`
622
+ });
623
+ break budgetIssue;
624
+ }
625
+ issues.push({
626
+ severity: "warning",
627
+ code: "budget",
628
+ path: "target.budgetKb",
629
+ message: `The bundle weighs ~${totalKb} KB (runtime excluded), above the ${budgetKb} KB budget for a ${kind}.`,
630
+ hint: `${heaviest.length ? `Heaviest files: ${heaviest.map(([p, n]) => `${p} (${KB(n)} KB)`).join(", ")}. ` : ""}Run \`agent3d assets optimize --all\` (shows the plan: a size per texture from how the scene uses it, WebP, meshopt geometry; then add --yes; --dry-run reports the real savings), download smaller resolutions (\`assets add --hit … --resolution 512\`), or replace heavy models with catalog geometries / generators (zero bytes). Raise target.budgetKb only if the page can afford it.`
631
+ });
632
+ }
633
+ }
634
+ const optimizable = await optimizeSuggestions(fs, scene, { library: opts.library }).catch(() => null);
635
+ if (optimizable && (optimizable.models.length || optimizable.textures.length)) {
636
+ const list = [...optimizable.textures.map((t) => `${t.path} (${t.size} px, the scene needs ~${t.maxSize})`), ...optimizable.models.map((m) => `${m.path} (${m.kb} KB, geometry not compressed)`)];
637
+ issues.push({
638
+ severity: "info",
639
+ code: "optimizable",
640
+ path: list.length === 1 ? optimizable.textures[0]?.path ?? optimizable.models[0].path : "assets/",
641
+ message: `${list.length} asset(s) are heavier than this scene needs: ${list.slice(0, 4).join(", ")}${list.length > 4 ? ", …" : ""}.`,
642
+ hint: "Run `agent3d assets optimize --all` to see the plan (per-texture size + reason, WebP, meshopt geometry), then add --yes (assets_optimize { all: true, dryRun: true } first from an agent)."
643
+ });
644
+ }
645
+ const triLimit = TRIANGLE_LIMIT[kind] ?? 5e5;
646
+ const triAim = TRIANGLE_AIM[kind] ?? 15e4;
647
+ const heaviestLine = tris.byObject.slice(0, 3).map((o) => `${o.id} (~${o.triangles.toLocaleString("en-US")})`).join(", ") || "n/a";
648
+ const passLine = passesLine(frame);
649
+ if (frame.perFrame > triLimit && !opts.runtimeStats) issues.push({
650
+ severity: "warning",
651
+ code: "triangles",
652
+ path: tris.byObject[0] ? `objects#${tris.byObject[0].id}` : "objects",
653
+ message: `Estimated ${frame.perFrame.toLocaleString("en-US")} triangles per frame (${passLine}), above ${triLimit.toLocaleString("en-US")} for a ${kind}.`,
654
+ hint: `Heaviest: ${heaviestLine}. Lower segments / resolution / detail / count params, use "instances" for repeated meshes, or simplify project models (\`agent3d assets optimize <model.glb> --simplify 0.5\`).${passHint(frame)}`
655
+ });
656
+ else if (frame.perFrame > triAim && !opts.runtimeStats) issues.push({
657
+ severity: "info",
658
+ code: "triangles-aim",
659
+ path: tris.byObject[0] ? `objects#${tris.byObject[0].id}` : "objects",
660
+ message: `Estimated ${frame.perFrame.toLocaleString("en-US")} triangles per frame (${passLine}), above the ~${triAim.toLocaleString("en-US")} to aim for on a ${kind} (fast on a mid-range phone; limit ${triLimit.toLocaleString("en-US")}).`,
661
+ hint: `Heaviest: ${heaviestLine}.${passHint(frame)} \`check --render\` measures the real number.`
662
+ });
663
+ if (opts.inspect) issues.push(...framingIssues(scene, opts.inspect));
664
+ if (opts.runtimeStats) {
665
+ const st = opts.runtimeStats;
666
+ if (st.drawCalls > 150) {
667
+ const causes = drawCallCauses(scene, frame.shadowLights, !!frame.passes.prepass);
668
+ issues.push({
669
+ severity: "warning",
670
+ code: "draw-calls",
671
+ path: causes[0] ? `objects#${causes[0].id}` : "objects",
672
+ message: `${st.drawCalls} draw calls per frame (limit 150).${causes.length ? ` Most draw calls: ${causes.slice(0, 5).map((c) => `${c.id} (~${c.drawCalls}: ${c.why})`).join(", ")}.` : ""}`,
673
+ hint: `${causes.some((c) => /splitLetters|per-letter/.test(c.why)) ? "Per-letter text (splitLetters / a per-letter reveal) draws every glyph separately — and twice with an outline: reveal by word or line, or drop the outline on split text. " : ""}${causes.some((c) => /copies/.test(c.why)) ? "Repeated copies of the same object: use one \"instances\" object (or a generator) instead. " : ""}Merge repeated meshes into an "instances" object, group static decoration into fewer meshes, reduce particle systems and post effects${frame.shadowLights ? "; every shadow-casting light re-draws each caster (castShadow: false on small / distant objects)" : ""}.`
674
+ });
675
+ }
676
+ if (st.triangles > triLimit) issues.push({
677
+ severity: "warning",
678
+ code: "triangles",
679
+ path: tris.byObject[0] ? `objects#${tris.byObject[0].id}` : "objects",
680
+ message: `The runtime renders ${st.triangles.toLocaleString("en-US")} triangles per frame, all passes included (limit ${triLimit.toLocaleString("en-US")} for a ${kind}; geometry estimate ~${tris.total.toLocaleString("en-US")}).`,
681
+ hint: `Heaviest: ${heaviestLine}. Lower geometry segments / generator resolution or counts, use lighter models (decimate them); shadow-casting lights re-draw every caster (castShadow only where it shows).${passHint(frame)}`
682
+ });
683
+ else if (st.triangles > triAim) issues.push({
684
+ severity: "warning",
685
+ code: "triangles-aim",
686
+ path: tris.byObject[0] ? `objects#${tris.byObject[0].id}` : "objects",
687
+ message: `The runtime renders ${st.triangles.toLocaleString("en-US")} triangles per frame (all passes), above the ~${triAim.toLocaleString("en-US")} to aim for on a ${kind} (limit ${triLimit.toLocaleString("en-US")}; estimate ${frame.perFrame.toLocaleString("en-US")}: ${passLine}).`,
688
+ hint: `It works, but mid-range phones will struggle. Heaviest: ${heaviestLine}.${passHint(frame)}`
689
+ });
690
+ const files = textureFiles(scene);
691
+ if (files.length > 12) issues.push({
692
+ severity: "info",
693
+ code: "textures",
694
+ path: "objects",
695
+ message: `${files.length} texture files used by materials / the environment (${st.textures} GPU textures in all, including generated ones).`,
696
+ hint: "Share textures between materials and prefer 1k maps for web embeds (`agent3d assets optimize --all`)."
697
+ });
698
+ else if (st.textures > 24 && !files.length) issues.push({
699
+ severity: "info",
700
+ code: "textures",
701
+ path: "objects",
702
+ message: `${st.textures} GPU textures, none from image files: they are generated (procedural textures, gradients, text / HUD canvases, shadow maps, post-processing targets) — no download.`,
703
+ hint: "Nothing to do unless memory is tight: fewer procedural maps / post effects lower it."
704
+ });
705
+ if (st.fps !== void 0 && st.fps < 30) issues.push({
706
+ severity: "warning",
707
+ code: "fps",
708
+ path: "target",
709
+ message: `Measured ${Math.round(st.fps)} fps in the headless render.`,
710
+ hint: "Headless rendering is slower than a real GPU, but simplify if it drops below ~20: fewer post effects, lower maxDpr, fewer shadows."
711
+ });
712
+ }
713
+ const pfx = postfxReport(scene);
714
+ issues.push(...pfx.issues);
715
+ if (!scene.ariaLabel) issues.push({
716
+ severity: "info",
717
+ code: "aria-label",
718
+ path: "ariaLabel",
719
+ message: `No ariaLabel: screen readers will announce the title "${scene.title ?? ""}".`,
720
+ hint: "Set \"ariaLabel\" to a one-sentence description of what the animation shows."
721
+ });
722
+ const animated = !!scene.timeline?.loop || hasBehaviours(scene) || !!scene.camera?.autoRotate;
723
+ if (scene.target?.reducedMotion === "ignore" && animated && kind !== "game") issues.push({
724
+ severity: "warning",
725
+ code: "reduced-motion",
726
+ path: "target.reducedMotion",
727
+ message: `reducedMotion "ignore" on a looping ${kind}: visitors who asked for less motion will still see it move.`,
728
+ hint: "Use \"static\" (freeze at posterTime) or \"slow\"."
729
+ });
730
+ if (scene.target?.lazy === false && kind !== "fullscreen" && kind !== "game") issues.push({
731
+ severity: "info",
732
+ code: "lazy",
733
+ path: "target.lazy",
734
+ message: "lazy is off: the scene starts rendering before it is visible.",
735
+ hint: "Keep lazy: true (default) for embeds below the fold."
736
+ });
737
+ if ((scene.target?.maxDpr ?? 2) > 2) issues.push({
738
+ severity: "info",
739
+ code: "dpr",
740
+ path: "target.maxDpr",
741
+ message: `maxDpr ${scene.target?.maxDpr} renders up to ${(scene.target?.maxDpr ?? 2) ** 2}× the pixels on retina screens.`,
742
+ hint: "2 is plenty for web embeds; 1.5 for heavy scenes."
743
+ });
744
+ const counts = {
745
+ errors: 0,
746
+ warnings: 0,
747
+ infos: 0
748
+ };
749
+ for (const i of issues) counts[i.severity === "error" ? "errors" : i.severity === "warning" ? "warnings" : "infos"]++;
750
+ const order = {
751
+ error: 0,
752
+ warning: 1,
753
+ info: 2
754
+ };
755
+ issues.sort((a, b) => order[a.severity] - order[b.severity]);
756
+ return {
757
+ ok: counts.errors === 0,
758
+ issues,
759
+ counts,
760
+ budget: {
761
+ estimatedTriangles: tris.total,
762
+ estimatedFrameTriangles: frame.perFrame,
763
+ passes: frame.passes,
764
+ triangleAim: triAim,
765
+ ...opts.runtimeStats ? { runtimeTriangles: opts.runtimeStats.triangles } : {},
766
+ triangles: opts.runtimeStats ? opts.runtimeStats.triangles : frame.perFrame,
767
+ trianglesSource: opts.runtimeStats ? "runtime" : "estimate",
768
+ heaviestObjects: tris.byObject.slice(0, 5),
769
+ assetsKb: KB(assetBytes),
770
+ scriptsKb: KB(scriptBytes),
771
+ sceneKb: KB(sceneBytes),
772
+ totalKb,
773
+ budgetKb,
774
+ runtimeKb: opts.runtimeKb ?? 0,
775
+ gpu: pfx.gpu
776
+ },
777
+ licences
778
+ };
779
+ }
780
+ function passesLine(f) {
781
+ const p = f.passes;
782
+ return [
783
+ `geometry ${p.main.toLocaleString("en-US")}`,
784
+ ...p.shadowMaps ? [`shadow maps ${p.shadowMaps.toLocaleString("en-US")} (${f.shadowLights} light${f.shadowLights > 1 ? "s" : ""})`] : [],
785
+ ...p.prepass ? [`ao / dof depth-normal pre-pass ${p.prepass.toLocaleString("en-US")}`] : [],
786
+ ...p.contactShadows ? [`contact shadows ${p.contactShadows.toLocaleString("en-US")}`] : []
787
+ ].join(" + ");
788
+ }
789
+ function passHint(f) {
790
+ const p = f.passes;
791
+ const parts = [];
792
+ if (p.prepass) parts.push("the ao / dof / godrays / outline post effect re-draws the whole scene once more (drop it, or keep it for heroes)");
793
+ if (p.shadowMaps) parts.push("each shadow-casting light re-draws every caster (castShadow: false on text and small objects)");
794
+ if (p.contactShadows) parts.push("contactShadows re-draws the casters from below");
795
+ return parts.length ? ` Passes: ${parts.join("; ")}.` : "";
796
+ }
797
+ function textureFiles(scene) {
798
+ return [...new Set(collectAssetRefs(scene).filter((r) => r.kind === "texture" || r.kind === "hdri").map((r) => r.path))];
799
+ }
800
+ function drawCallCauses(scene, shadowLights = 0, prepass = false) {
801
+ const passes = 1 + shadowLights + (prepass ? 1 : 0);
802
+ const perLetter = /* @__PURE__ */ new Set();
803
+ for (const tr of scene.timeline?.tracks ?? []) {
804
+ const t = String(tr?.target ?? "");
805
+ for (const part of t.split(".")[0].split(",")) {
806
+ const m = /^(.+)\/\d+$/.exec(part.trim());
807
+ if (m) perLetter.add(m[1]);
808
+ }
809
+ }
810
+ const repeated = /* @__PURE__ */ new Map();
811
+ const out = [];
812
+ for (const top of scene.objects ?? []) {
813
+ let calls = 0;
814
+ const why = [];
815
+ walkObjects([top], (o) => {
816
+ const d = o;
817
+ if (d.kind === "text") {
818
+ const glyphs = String(d.text ?? "").replace(/\s/g, "").length;
819
+ const split = d.splitLetters === true || !!d.reveal || perLetter.has(o.id);
820
+ const layers = d.outline ? 2 : 1;
821
+ if (split) {
822
+ calls += glyphs * layers;
823
+ why.push(`"${o.id}" per-letter text (splitLetters / reveal), ${glyphs} glyphs${layers > 1 ? " × outline" : ""}`);
824
+ } else calls += layers;
825
+ } else if (d.kind === "mesh" || d.kind === "instances" || d.kind === "particles" || d.kind === "svg") calls += 1;
826
+ else if (d.kind === "model" || d.kind === "generator") {
827
+ calls += d.kind === "model" ? 4 : 2;
828
+ const key = d.kind === "model" ? `model:${String(d.src)}` : `generator:${String(d.generator)}:${JSON.stringify(d.params ?? {})}`;
829
+ repeated.set(key, [...repeated.get(key) ?? [], o.id]);
830
+ }
831
+ });
832
+ if (calls) out.push({
833
+ id: top.id,
834
+ drawCalls: calls * passes,
835
+ why: why.join(", ") || "meshes"
836
+ });
837
+ }
838
+ for (const [key, ids] of repeated) {
839
+ if (ids.length < 3) continue;
840
+ const top = out.find((o) => o.id === ids[0]);
841
+ const label = `${ids.length} copies of ${key.split(":").slice(0, 2).join(" ")} (${ids.slice(0, 4).join(", ")}${ids.length > 4 ? ", …" : ""})`;
842
+ out.push({
843
+ id: ids[0],
844
+ drawCalls: ids.length * (key.startsWith("model") ? 4 : 2) * passes,
845
+ why: label
846
+ });
847
+ if (top && top.why === "meshes") top.why = label;
848
+ }
849
+ return out.sort((a, b) => b.drawCalls - a.drawCalls);
850
+ }
851
+ function hasBehaviours(scene) {
852
+ let found = false;
853
+ walkObjects(scene.objects, (o) => {
854
+ if (o.behaviours?.length) found = true;
855
+ });
856
+ return found || (scene.lights ?? []).some((l) => l.behaviours?.length);
857
+ }
858
+ function framingIssues(scene, inspect) {
859
+ const issues = [];
860
+ const hidden = /* @__PURE__ */ new Set();
861
+ walkObjects(scene.objects, (o) => {
862
+ if (o.visible === false) hidden.add(o.id);
863
+ });
864
+ const declared = /* @__PURE__ */ new Set();
865
+ const spread = /* @__PURE__ */ new Set();
866
+ const scatter = new Set(GENERATORS.filter((g) => g.params.some((p) => p.name === "area")).map((g) => g.id));
867
+ walkObjects(scene.objects, (o) => {
868
+ declared.add(o.id);
869
+ const def = o;
870
+ if (def.kind === "particles" || def.kind === "generator" && def.generator && scatter.has(def.generator)) spread.add(o.id);
871
+ });
872
+ const animated = /* @__PURE__ */ new Set();
873
+ let cameraMoves = (scene.camera?.shots?.length ?? 0) > 0;
874
+ const tagged = (tag) => {
875
+ walkObjects(scene.objects, (o) => {
876
+ if (o.tags?.includes(tag)) animated.add(o.id);
877
+ });
878
+ };
879
+ const hiddenAtStart = /* @__PURE__ */ new Set();
880
+ const startsHidden = (prop, keys) => {
881
+ const first = Array.isArray(keys) ? keys.find((k) => Array.isArray(k)) : void 0;
882
+ if (!Array.isArray(first) || typeof first[0] !== "number" || first[0] > 1e-6) return false;
883
+ const v = first[1];
884
+ if (/^(material\.)?opacity$/.test(prop)) return v === 0;
885
+ if (prop === "visible") return v === false || v === 0;
886
+ if (/^scale$/.test(prop)) return v === 0 || Array.isArray(v) && v.every((x) => x === 0);
887
+ return false;
888
+ };
889
+ for (const tr of scene.timeline?.tracks ?? []) {
890
+ const target = typeof tr?.target === "string" ? tr.target : "";
891
+ const dot = target.indexOf(".");
892
+ if (dot < 1) continue;
893
+ const head = target.slice(0, dot), prop = target.slice(dot + 1);
894
+ if (head === "camera") {
895
+ cameraMoves = true;
896
+ continue;
897
+ }
898
+ if (!/^(position|scale|rotation|visible|material\.opacity|opacity)/.test(prop)) continue;
899
+ const ids = [];
900
+ if (head.startsWith("tag:")) {
901
+ const before = new Set(animated);
902
+ tagged(head.slice(4));
903
+ for (const id of animated) if (!before.has(id)) ids.push(id);
904
+ } else if (head.startsWith("children:")) {
905
+ const id = head.slice(9);
906
+ ids.push(id);
907
+ walkObjects(scene.objects, (o) => {
908
+ if (o.id === id) for (const c of o.children ?? []) ids.push(c.id);
909
+ });
910
+ } else for (const h of head.split(",")) ids.push(h.trim().replace(/\/\d+$/, ""));
911
+ for (const id of ids) animated.add(id);
912
+ if (startsHidden(prop, tr.keys)) for (const id of ids) hiddenAtStart.add(id);
913
+ }
914
+ const attached = new Set((scene.objects ?? []).filter((o) => o.attach === "camera").map((o) => o.id));
915
+ for (const id of [...attached]) walkObjects(scene.objects.find((o) => o.id === id)?.children ?? [], (c) => void attached.add(c.id));
916
+ const objs = inspect.objects.filter((o) => !hidden.has(o.id) && declared.has(o.id) && !attached.has(o.id));
917
+ const cam = `camera position ${JSON.stringify(inspect.camera.position)} looking at ${JSON.stringify(inspect.camera.target)}`;
918
+ if (inspect.camera.insideObject) issues.push({
919
+ severity: "warning",
920
+ code: "camera-inside",
921
+ path: `objects#${inspect.camera.insideObject}`,
922
+ message: `The camera is inside "${inspect.camera.insideObject}" (${cam}).`,
923
+ hint: `Move camera.position outside its bounding box, or scale / move "${inspect.camera.insideObject}".`
924
+ });
925
+ for (const o of objs) {
926
+ const size = o.max.map((v, i) => Math.round((v - o.min[i]) * 100) / 100);
927
+ const centre = o.max.map((v, i) => Math.round((v + o.min[i]) / 2 * 100) / 100);
928
+ const big = Math.max(...size) > 30;
929
+ const scroll = scene.timeline?.trigger === "scroll";
930
+ const later = scroll ? "further down the page" : "later in the timeline";
931
+ const checkHint = scroll ? "Check the other scroll states with `agent3d render --count 8` (or --scroll 0.5)." : "Check later frames with `agent3d render --count 6` (or --frames …).";
932
+ if (hiddenAtStart.has(o.id) && o.inView !== "none") issues.push({
933
+ severity: "info",
934
+ code: "out-of-view-at-start",
935
+ path: `objects#${o.id}`,
936
+ message: `"${o.id}" is hidden at the checked frame (t = 0): the timeline starts it transparent / invisible / at scale 0 and reveals it ${later}.`,
937
+ hint: checkHint
938
+ });
939
+ else if (o.inView === "none" && scroll && (cameraMoves || animated.has(o.id))) issues.push({
940
+ severity: "info",
941
+ code: "out-of-view-at-start",
942
+ path: `objects#${o.id}`,
943
+ message: `"${o.id}" is outside the camera view at the checked frame (t = 0)${hiddenAtStart.has(o.id) ? " and hidden by the timeline" : ""}; the ${scroll ? "scroll-driven " : ""}${animated.has(o.id) ? "timeline animates it" : "camera moves"}, so it may come into view ${later}.`,
944
+ hint: checkHint
945
+ });
946
+ else if (o.inView === "none") issues.push({
947
+ severity: "warning",
948
+ code: "out-of-view",
949
+ path: `objects#${o.id}`,
950
+ message: `"${o.id}" is completely outside the camera view (centre ${JSON.stringify(centre)}, size ${JSON.stringify(size)}; ${cam}).`,
951
+ hint: `Move it toward camera.target, widen camera.fov / move the camera back, or set "visible": false if it is meant to enter later.${animated.has(o.id) || cameraMoves ? " The timeline animates it: if it enters later on purpose, check later frames (`agent3d render --count 6`) and ignore this." : ""}`
952
+ });
953
+ else if (o.inView === "partial" && !big && !spread.has(o.id)) issues.push({
954
+ severity: "info",
955
+ code: "clipped",
956
+ path: `objects#${o.id}`,
957
+ message: `"${o.id}" is clipped by the frame edges (centre ${JSON.stringify(centre)}, size ${JSON.stringify(size)}).`,
958
+ hint: "If unintended, move it inward, scale it down or move the camera back. For wide banners, keep content within the central ~80% of the width."
959
+ });
960
+ }
961
+ const coverage = Math.min(1, objs.reduce((a, o) => a + (o.inView === "none" ? 0 : o.screenCoverage), 0));
962
+ if (objs.length && coverage < .05) issues.push({
963
+ severity: "warning",
964
+ code: "too-small",
965
+ path: "camera",
966
+ message: `The objects cover only ${(coverage * 100).toFixed(1)}% of the frame: the scene looks empty.`,
967
+ hint: "Move camera.position closer to camera.target (or lower camera.fov), or scale the main objects up."
968
+ });
969
+ return issues;
970
+ }
971
+ export { checkProject as n, check_exports as r, attributionText as t };