@auraindustry/aurajs 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/README.md +98 -2
  2. package/benchmarks/perf-thresholds.json +54 -0
  3. package/package.json +4 -7
  4. package/src/asset-pack.mjs +5 -1
  5. package/src/authored-project.mjs +1449 -0
  6. package/src/authored-runtime.mjs +2016 -0
  7. package/src/authoring/avatar-animation-graph.mjs +648 -0
  8. package/src/bin-integrity.mjs +272 -0
  9. package/src/build-contract/assets.mjs +130 -0
  10. package/src/build-contract/capabilities.mjs +116 -0
  11. package/src/build-contract/constants.mjs +6 -0
  12. package/src/build-contract/helpers.mjs +44 -0
  13. package/src/build-contract/web-templates.mjs +5993 -0
  14. package/src/build-contract.mjs +27 -2910
  15. package/src/bundler.mjs +188 -55
  16. package/src/cli.mjs +4825 -1512
  17. package/src/commands/project-authoring.mjs +434 -0
  18. package/src/config.mjs +27 -0
  19. package/src/conformance/cases/app-and-ui-runtime-cases.mjs +3309 -0
  20. package/src/conformance/cases/core-runtime-cases.mjs +1431 -0
  21. package/src/conformance/cases/index.mjs +11 -0
  22. package/src/conformance/cases/scene3d-and-media-cases.mjs +2094 -0
  23. package/src/conformance/cases/systems-and-gameplay-cases.mjs +1776 -0
  24. package/src/conformance/shared.mjs +27 -0
  25. package/src/conformance-runner.mjs +25 -13
  26. package/src/conformance.mjs +619 -4020
  27. package/src/cutscene.mjs +362 -5
  28. package/src/dev-cli-action.mjs +249 -0
  29. package/src/dev-cli-inspect.mjs +92 -0
  30. package/src/dev-cli-state.mjs +80 -0
  31. package/src/external-asset-cache.mjs +587 -0
  32. package/src/external-asset-policy.mjs +217 -0
  33. package/src/external-package-surface.mjs +206 -0
  34. package/src/game-action-runtime.mjs +869 -0
  35. package/src/game-state-runtime.mjs +206 -6
  36. package/src/headless-action.mjs +186 -0
  37. package/src/headless-test/runtime-animation.mjs +1173 -0
  38. package/src/headless-test/runtime-coordinator.mjs +1514 -0
  39. package/src/headless-test/runtime-primitives.mjs +320 -0
  40. package/src/headless-test/runtime-world.mjs +2253 -0
  41. package/src/headless-test.mjs +392 -4298
  42. package/src/host-binary.mjs +342 -14
  43. package/src/icon-discovery.mjs +64 -0
  44. package/src/make-catalog.mjs +109 -0
  45. package/src/make.mjs +197 -0
  46. package/src/package-integrity.mjs +586 -0
  47. package/src/perf-benchmark.mjs +353 -0
  48. package/src/postinstall.mjs +5 -5
  49. package/src/prefabs/index.mjs +34 -0
  50. package/src/prefabs/scene-serialization.mjs +184 -0
  51. package/src/project-importer.mjs +620 -0
  52. package/src/project-registry.mjs +24 -0
  53. package/src/publish-command.mjs +195 -0
  54. package/src/publish-env-example.mjs +83 -0
  55. package/src/publish-validation.mjs +708 -0
  56. package/src/retro/assets/compile.mjs +232 -0
  57. package/src/retro/backend-gba/authoring.mjs +1029 -0
  58. package/src/retro/backend-gba/rom.mjs +363 -0
  59. package/src/retro/backend-gbc/rom.mjs +85 -0
  60. package/src/retro/build.mjs +278 -0
  61. package/src/retro/cli/commands.mjs +292 -0
  62. package/src/retro/cli/templates.mjs +84 -0
  63. package/src/retro/diagnostics/catalog.mjs +110 -0
  64. package/src/retro/diagnostics/emit.mjs +72 -0
  65. package/src/retro/emulator/case-overlay.mjs +64 -0
  66. package/src/retro/emulator/discovery.mjs +158 -0
  67. package/src/retro/emulator/macos-case-overlay.swift +220 -0
  68. package/src/retro/emulator/profiles.mjs +146 -0
  69. package/src/retro/emulator/runner.mjs +289 -0
  70. package/src/retro/frontend/load-project.mjs +98 -0
  71. package/src/retro/index.mjs +30 -0
  72. package/src/retro/ir/build-ir.mjs +108 -0
  73. package/src/retro/runtime-gba/contract.mjs +151 -0
  74. package/src/retro/runtime-gbc/contract.mjs +117 -0
  75. package/src/retro/shared/span.mjs +26 -0
  76. package/src/retro/shared/targets.mjs +64 -0
  77. package/src/retro/validator/check-project.mjs +114 -0
  78. package/src/runtime-hotspot-audit.mjs +707 -0
  79. package/src/scaffold/config.mjs +1000 -0
  80. package/src/scaffold/fs.mjs +56 -0
  81. package/src/scaffold/layout.mjs +318 -0
  82. package/src/scaffold/project-docs.mjs +438 -0
  83. package/src/scaffold.mjs +93 -596
  84. package/src/scene-composition/index.mjs +326 -0
  85. package/src/scene-composition/runtime.mjs +751 -0
  86. package/src/self-hosted-assets.mjs +604 -0
  87. package/src/session-client.mjs +750 -0
  88. package/src/session-native-launcher.mjs +74 -0
  89. package/src/session-protocol.mjs +75 -0
  90. package/src/session-runtime.mjs +321 -0
  91. package/src/session-server.mjs +360 -0
  92. package/src/shader-kits/index.mjs +773 -0
  93. package/src/starter-content-registry.mjs +292 -0
  94. package/src/state-artifacts.mjs +662 -24
  95. package/src/state-dev-reload.mjs +99 -2
  96. package/src/terminal-ui.mjs +245 -0
  97. package/src/web-conformance.mjs +219 -0
  98. package/templates/create/2d/config/gameplay/shooter.config.js +26 -0
  99. package/templates/create/2d/content/gameplay/waves.json +26 -0
  100. package/templates/create/2d/content/registries/.gitkeep +1 -0
  101. package/templates/create/2d/docs/design/.gitkeep +1 -0
  102. package/templates/create/2d/docs/design/loop.md +5 -0
  103. package/templates/create/2d/prefabs/enemies.prefab.js +90 -0
  104. package/templates/create/2d/prefabs/enemy-basic.prefab.js +18 -0
  105. package/templates/create/2d/prefabs/player.prefab.js +36 -0
  106. package/templates/create/2d/prefabs/projectiles.prefab.js +35 -0
  107. package/templates/create/2d/scenes/boot.scene.js +12 -0
  108. package/templates/create/2d/scenes/gameplay.scene.js +230 -0
  109. package/templates/create/2d/scenes/menu.scene.js +9 -0
  110. package/templates/create/2d/src/main.js +6 -185
  111. package/templates/create/2d/src/runtime/app.js +49 -0
  112. package/templates/create/2d/src/runtime/capabilities.js +35 -0
  113. package/templates/create/2d/ui/hud.screen.js +40 -0
  114. package/templates/create/2d/ui/pause.screen.js +149 -0
  115. package/templates/create/2d/ui/settings.screen.js +347 -0
  116. package/templates/create/2d/ui/title.screen.js +13 -0
  117. package/templates/create/2d-adventure/aura.config.json +28 -0
  118. package/templates/create/2d-adventure/config/gameplay/adventure.config.js +14 -0
  119. package/templates/create/2d-adventure/content/gameplay/world.js +46 -0
  120. package/templates/create/2d-adventure/content/registries/.gitkeep +1 -0
  121. package/templates/create/2d-adventure/docs/design/loop.md +5 -0
  122. package/templates/create/2d-adventure/prefabs/player.prefab.js +54 -0
  123. package/templates/create/2d-adventure/prefabs/relic.prefab.js +38 -0
  124. package/templates/create/2d-adventure/prefabs/world.prefab.js +125 -0
  125. package/templates/create/2d-adventure/scenes/gameplay.scene.js +256 -0
  126. package/templates/create/2d-adventure/src/runtime/capabilities.js +34 -0
  127. package/templates/create/2d-adventure/ui/hud.screen.js +60 -0
  128. package/templates/create/2d-survivor/config/gameplay/survivor.config.js +33 -0
  129. package/templates/create/2d-survivor/content/gameplay/spawn-zones.json +29 -0
  130. package/templates/create/2d-survivor/content/registries/.gitkeep +1 -0
  131. package/templates/create/2d-survivor/docs/design/.gitkeep +1 -0
  132. package/templates/create/2d-survivor/docs/design/loop.md +5 -0
  133. package/templates/create/2d-survivor/prefabs/enemies.prefab.js +178 -0
  134. package/templates/create/2d-survivor/prefabs/enemy-swarm.prefab.js +18 -0
  135. package/templates/create/2d-survivor/prefabs/player.prefab.js +42 -0
  136. package/templates/create/2d-survivor/prefabs/projectiles.prefab.js +56 -0
  137. package/templates/create/2d-survivor/scenes/boot.scene.js +12 -0
  138. package/templates/create/2d-survivor/scenes/gameplay.scene.js +314 -0
  139. package/templates/create/2d-survivor/scenes/menu.scene.js +9 -0
  140. package/templates/create/2d-survivor/src/main.js +5 -332
  141. package/templates/create/2d-survivor/src/runtime/app.js +49 -0
  142. package/templates/create/2d-survivor/src/runtime/capabilities.js +35 -0
  143. package/templates/create/2d-survivor/ui/hud.screen.js +45 -0
  144. package/templates/create/2d-survivor/ui/title.screen.js +13 -0
  145. package/templates/create/3d/assets/models/starter-avatar.gltf +184 -0
  146. package/templates/create/3d/config/gameplay/.gitkeep +1 -0
  147. package/templates/create/3d/content/gameplay/checkpoints.json +33 -0
  148. package/templates/create/3d/content/gameplay/course.js +40 -0
  149. package/templates/create/3d/content/registries/.gitkeep +1 -0
  150. package/templates/create/3d/docs/design/.gitkeep +1 -0
  151. package/templates/create/3d/docs/design/loop.md +5 -0
  152. package/templates/create/3d/prefabs/checkpoint.prefab.js +15 -0
  153. package/templates/create/3d/prefabs/player.prefab.js +204 -0
  154. package/templates/create/3d/prefabs/world.prefab.js +112 -0
  155. package/templates/create/3d/scenes/boot.scene.js +12 -0
  156. package/templates/create/3d/scenes/checkpoint.scene.js +9 -0
  157. package/templates/create/3d/scenes/gameplay.scene.js +292 -0
  158. package/templates/create/3d/src/main.js +6 -295
  159. package/templates/create/3d/src/runtime/app.js +49 -0
  160. package/templates/create/3d/src/runtime/capabilities.js +53 -0
  161. package/templates/create/3d/src/runtime/materials.js +34 -0
  162. package/templates/create/3d/src/runtime/state.js +39 -0
  163. package/templates/create/3d/ui/hud.screen.js +75 -0
  164. package/templates/create/3d/ui/pause.screen.js +166 -0
  165. package/templates/create/3d/ui/settings.screen.js +387 -0
  166. package/templates/create/3d-adventure/assets/models/starter-avatar.gltf +184 -0
  167. package/templates/create/3d-adventure/aura.config.json +28 -0
  168. package/templates/create/3d-adventure/config/gameplay/adventure.config.js +9 -0
  169. package/templates/create/3d-adventure/content/gameplay/course.js +62 -0
  170. package/templates/create/3d-adventure/content/registries/.gitkeep +1 -0
  171. package/templates/create/3d-adventure/docs/design/loop.md +5 -0
  172. package/templates/create/3d-adventure/prefabs/player.prefab.js +168 -0
  173. package/templates/create/3d-adventure/prefabs/relic.prefab.js +35 -0
  174. package/templates/create/3d-adventure/prefabs/world.prefab.js +119 -0
  175. package/templates/create/3d-adventure/scenes/gameplay.scene.js +358 -0
  176. package/templates/create/3d-adventure/src/runtime/capabilities.js +56 -0
  177. package/templates/create/3d-adventure/src/runtime/materials.js +39 -0
  178. package/templates/create/3d-adventure/src/runtime/state.js +31 -0
  179. package/templates/create/3d-adventure/ui/hud.screen.js +70 -0
  180. package/templates/create/3d-adventure/ui/pause.screen.js +437 -0
  181. package/templates/create/3d-collectathon/assets/models/starter-avatar.gltf +184 -0
  182. package/templates/create/3d-collectathon/config/gameplay/.gitkeep +1 -0
  183. package/templates/create/3d-collectathon/content/gameplay/collectibles.json +26 -0
  184. package/templates/create/3d-collectathon/content/gameplay/course.js +46 -0
  185. package/templates/create/3d-collectathon/content/registries/.gitkeep +1 -0
  186. package/templates/create/3d-collectathon/docs/design/.gitkeep +1 -0
  187. package/templates/create/3d-collectathon/docs/design/loop.md +5 -0
  188. package/templates/create/3d-collectathon/prefabs/collectible.prefab.js +15 -0
  189. package/templates/create/3d-collectathon/prefabs/player.prefab.js +207 -0
  190. package/templates/create/3d-collectathon/prefabs/world.prefab.js +112 -0
  191. package/templates/create/3d-collectathon/scenes/boot.scene.js +12 -0
  192. package/templates/create/3d-collectathon/scenes/checkpoint.scene.js +9 -0
  193. package/templates/create/3d-collectathon/scenes/gameplay.scene.js +200 -0
  194. package/templates/create/3d-collectathon/src/main.js +5 -355
  195. package/templates/create/3d-collectathon/src/runtime/app.js +49 -0
  196. package/templates/create/3d-collectathon/src/runtime/capabilities.js +53 -0
  197. package/templates/create/3d-collectathon/src/runtime/materials.js +34 -0
  198. package/templates/create/3d-collectathon/src/runtime/state.js +27 -0
  199. package/templates/create/3d-collectathon/ui/hud.screen.js +66 -0
  200. package/templates/create/3d-collectathon/ui/pause.screen.js +13 -0
  201. package/templates/create/blank/config/gameplay/.gitkeep +1 -0
  202. package/templates/create/blank/content/gameplay/.gitkeep +1 -0
  203. package/templates/create/blank/content/registries/.gitkeep +1 -0
  204. package/templates/create/blank/docs/design/.gitkeep +1 -0
  205. package/templates/create/blank/docs/design/loop.md +5 -0
  206. package/templates/create/blank/prefabs/.gitkeep +1 -0
  207. package/templates/create/blank/scenes/.gitkeep +1 -0
  208. package/templates/create/blank/src/runtime/.gitkeep +1 -0
  209. package/templates/create/blank/ui/.gitkeep +1 -0
  210. package/templates/create/deckbuilder-2d/assets/audio/.gitkeep +1 -0
  211. package/templates/create/deckbuilder-2d/assets/fonts/.gitkeep +1 -0
  212. package/templates/create/deckbuilder-2d/assets/sprites/.gitkeep +1 -0
  213. package/templates/create/deckbuilder-2d/assets/starter/README.md +11 -0
  214. package/templates/create/deckbuilder-2d/assets/ui/.gitkeep +1 -0
  215. package/templates/create/deckbuilder-2d/aura.config.json +28 -0
  216. package/templates/create/deckbuilder-2d/config/gameplay/deckbuilder.config.js +26 -0
  217. package/templates/create/deckbuilder-2d/content/cards/guard.card.js +19 -0
  218. package/templates/create/deckbuilder-2d/content/cards/spark.card.js +20 -0
  219. package/templates/create/deckbuilder-2d/content/cards/starter.deck.js +69 -0
  220. package/templates/create/deckbuilder-2d/content/cards/strike.card.js +19 -0
  221. package/templates/create/deckbuilder-2d/content/cards/survey.card.js +20 -0
  222. package/templates/create/deckbuilder-2d/content/encounters/training-battle.encounter.js +14 -0
  223. package/templates/create/deckbuilder-2d/content/encounters/training-battle.js +65 -0
  224. package/templates/create/deckbuilder-2d/content/enemies/training-automaton.enemy.js +48 -0
  225. package/templates/create/deckbuilder-2d/content/gameplay/.gitkeep +1 -0
  226. package/templates/create/deckbuilder-2d/content/registries/cards.registry.js +26 -0
  227. package/templates/create/deckbuilder-2d/content/registries/encounters.registry.js +20 -0
  228. package/templates/create/deckbuilder-2d/content/registries/enemies.registry.js +20 -0
  229. package/templates/create/deckbuilder-2d/content/registries/relics.registry.js +20 -0
  230. package/templates/create/deckbuilder-2d/content/relics/ember-charm.relic.js +18 -0
  231. package/templates/create/deckbuilder-2d/docs/design/loop.md +12 -0
  232. package/templates/create/deckbuilder-2d/prefabs/.gitkeep +1 -0
  233. package/templates/create/deckbuilder-2d/scenes/boot.scene.js +84 -0
  234. package/templates/create/deckbuilder-2d/scenes/gameplay.scene.js +641 -0
  235. package/templates/create/deckbuilder-2d/src/components/.gitkeep +1 -0
  236. package/templates/create/deckbuilder-2d/src/main.js +17 -0
  237. package/templates/create/deckbuilder-2d/src/runtime/capabilities.js +22 -0
  238. package/templates/create/deckbuilder-2d/src/shared/.gitkeep +1 -0
  239. package/templates/create/deckbuilder-2d/src/systems/.gitkeep +1 -0
  240. package/templates/create/deckbuilder-2d/tests/smoke/.gitkeep +1 -0
  241. package/templates/create/deckbuilder-2d/ui/hud.screen.js +80 -0
  242. package/templates/create/deckbuilder-2d/ui/pause.screen.js +146 -0
  243. package/templates/create/deckbuilder-2d/ui/settings.screen.js +342 -0
  244. package/templates/create/local-multiplayer/aura.config.json +40 -0
  245. package/templates/create/local-multiplayer/config/gameplay/local-multiplayer.config.js +26 -0
  246. package/templates/create/local-multiplayer/content/gameplay/room-layout.js +13 -0
  247. package/templates/create/local-multiplayer/content/registries/.gitkeep +1 -0
  248. package/templates/create/local-multiplayer/docs/design/loop.md +14 -0
  249. package/templates/create/local-multiplayer/prefabs/player.prefab.js +99 -0
  250. package/templates/create/local-multiplayer/scenes/boot.scene.js +12 -0
  251. package/templates/create/local-multiplayer/scenes/gameplay.scene.js +443 -0
  252. package/templates/create/local-multiplayer/src/main.js +17 -0
  253. package/templates/create/local-multiplayer/src/runtime/capabilities.js +28 -0
  254. package/templates/create/local-multiplayer/ui/hud.screen.js +60 -0
  255. package/templates/create/shared/src/runtime/project-inspector.js +105 -0
  256. package/templates/create/shared/src/runtime/scene-flow.js +290 -0
  257. package/templates/create/shared/src/runtime/screen-shell.js +222 -0
  258. package/templates/create/shared/src/runtime/ui-forms.js +209 -0
  259. package/templates/create/shared/src/runtime/ui-settings.js +237 -0
  260. package/templates/create/shared/src/runtime/ui-theme.js +352 -0
  261. package/templates/create/shared/src/starter-utils/adventure-objectives.js +102 -0
  262. package/templates/create/shared/src/starter-utils/animation-2d.js +337 -0
  263. package/templates/create/shared/src/starter-utils/avatar-3d.js +404 -0
  264. package/templates/create/shared/src/starter-utils/combat-feedback-2d.js +320 -0
  265. package/templates/create/shared/src/starter-utils/core.js +39 -3
  266. package/templates/create/shared/src/starter-utils/index.js +8 -2
  267. package/templates/create/shared/src/starter-utils/platformer-3d.js +34 -3
  268. package/templates/create/shared/src/starter-utils/triggers.js +662 -0
  269. package/templates/create/shared/src/starter-utils/tween-2d.js +615 -0
  270. package/templates/create/video-cutscene/assets/video/.gitkeep +0 -0
  271. package/templates/create/video-cutscene/aura.config.json +28 -0
  272. package/templates/create/video-cutscene/config/gameplay/.gitkeep +0 -0
  273. package/templates/create/video-cutscene/content/gameplay/.gitkeep +0 -0
  274. package/templates/create/video-cutscene/content/registries/.gitkeep +0 -0
  275. package/templates/create/video-cutscene/docs/design/loop.md +22 -0
  276. package/templates/create/video-cutscene/prefabs/.gitkeep +0 -0
  277. package/templates/create/video-cutscene/scenes/boot.scene.js +11 -0
  278. package/templates/create/video-cutscene/scenes/cutscene.scene.js +113 -0
  279. package/templates/create/video-cutscene/scenes/gameplay.scene.js +50 -0
  280. package/templates/create/video-cutscene/src/main.js +17 -0
  281. package/templates/create/video-cutscene/src/runtime/app.js +52 -0
  282. package/templates/create/video-cutscene/src/runtime/capabilities.js +35 -0
  283. package/templates/create/video-cutscene/src/runtime/state.js +13 -0
  284. package/templates/create/video-cutscene/ui/.gitkeep +0 -0
  285. package/templates/create-bin/play.js +1187 -0
  286. package/templates/make/README.md +46 -0
  287. package/templates/make/catalog.json +51 -0
  288. package/templates/make/component/files/{{MAKE_NAME}}.component.js +20 -0
  289. package/templates/make/component/manifest.json +9 -0
  290. package/templates/make/data/files/{{MAKE_NAME}}.json +14 -0
  291. package/templates/make/data/manifest.json +9 -0
  292. package/templates/make/material/files/{{MAKE_NAME}}.material.json +17 -0
  293. package/templates/make/material/manifest.json +9 -0
  294. package/templates/make/prefab/files/{{MAKE_NAME}}.prefab.js +20 -0
  295. package/templates/make/prefab/manifest.json +9 -0
  296. package/templates/make/scene/files/{{MAKE_NAME}}.scene.js +31 -0
  297. package/templates/make/scene/manifest.json +9 -0
  298. package/templates/make/shader/files/{{MAKE_NAME}}.shader.js +23 -0
  299. package/templates/make/shader/manifest.json +9 -0
  300. package/templates/make/system/files/{{MAKE_NAME}}.system.js +15 -0
  301. package/templates/make/system/manifest.json +9 -0
  302. package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.js +16 -0
  303. package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.json +23 -0
  304. package/templates/make/ui-screen/manifest.json +10 -0
  305. package/templates/make-starters/deckbuilder-2d/card/files/{{MAKE_NAME}}.card.js +22 -0
  306. package/templates/make-starters/deckbuilder-2d/card/manifest.json +9 -0
  307. package/templates/make-starters/deckbuilder-2d/catalog.json +34 -0
  308. package/templates/make-starters/deckbuilder-2d/encounter/files/{{MAKE_NAME}}.encounter.js +18 -0
  309. package/templates/make-starters/deckbuilder-2d/encounter/manifest.json +9 -0
  310. package/templates/make-starters/deckbuilder-2d/enemy/files/{{MAKE_NAME}}.enemy.js +28 -0
  311. package/templates/make-starters/deckbuilder-2d/enemy/manifest.json +9 -0
  312. package/templates/make-starters/deckbuilder-2d/relic/files/{{MAKE_NAME}}.relic.js +23 -0
  313. package/templates/make-starters/deckbuilder-2d/relic/manifest.json +9 -0
  314. package/templates/retro/platformer/README.md +10 -0
  315. package/templates/retro/platformer/assets/retro/assets.json +91 -0
  316. package/templates/retro/platformer/aura.config.json +7 -0
  317. package/templates/retro/platformer/package.json +5 -0
  318. package/templates/retro/platformer/src/main.js +40 -0
  319. package/templates/retro/puzzle-grid/README.md +10 -0
  320. package/templates/retro/puzzle-grid/assets/retro/assets.json +90 -0
  321. package/templates/retro/puzzle-grid/aura.config.json +7 -0
  322. package/templates/retro/puzzle-grid/package.json +5 -0
  323. package/templates/retro/puzzle-grid/src/main.js +29 -0
  324. package/templates/retro/tactics-grid/README.md +10 -0
  325. package/templates/retro/tactics-grid/assets/retro/assets.json +90 -0
  326. package/templates/retro/tactics-grid/aura.config.json +7 -0
  327. package/templates/retro/tactics-grid/package.json +5 -0
  328. package/templates/retro/tactics-grid/src/main.js +35 -0
  329. package/templates/retro/topdown-adventure/README.md +10 -0
  330. package/templates/retro/topdown-adventure/assets/retro/assets.json +95 -0
  331. package/templates/retro/topdown-adventure/aura.config.json +7 -0
  332. package/templates/retro/topdown-adventure/package.json +5 -0
  333. package/templates/retro/topdown-adventure/src/main.js +29 -0
  334. package/templates/skills/aurajs/SKILL.md +61 -5
@@ -0,0 +1,200 @@
1
+ import {
2
+ axisFromKeys,
3
+ createGoalZone,
4
+ distanceSquared3D,
5
+ isGoalReached,
6
+ respawnAtCheckpoint,
7
+ setAvatarInput3D,
8
+ spawnCharacterAvatar3D,
9
+ stepMovingPlatform3D,
10
+ tickCharacterAvatar3D,
11
+ updateCheckpointProgress,
12
+ } from '../src/starter-utils/index.js';
13
+ import {
14
+ GOAL_ZONE,
15
+ TARGET_COLLECTIBLES,
16
+ WORLD_LIMIT,
17
+ } from '../content/gameplay/course.js';
18
+ import { ensureUiState } from '../src/runtime/app-state.js';
19
+ import { bindPlayerAvatarVisual, drawCollectathonActors, loadPlayerAvatarVisual } from '../prefabs/player.prefab.js';
20
+ import { drawCollectathonCourse, syncCollectathonCharacterObstacles } from '../prefabs/world.prefab.js';
21
+ import { createCollectathonMaterials } from '../src/runtime/materials.js';
22
+ import { createCollectathonRunState } from '../src/runtime/state.js';
23
+ import { drawCollectathonHud } from '../ui/hud.screen.js';
24
+
25
+ function createCollectathonSessionSeed() {
26
+ return {
27
+ runsStarted: 0,
28
+ bestScore: 0,
29
+ lastOutcome: 'idle',
30
+ lastSceneId: 'gameplay',
31
+ };
32
+ }
33
+
34
+ function ensureCollectathonSession(context, appState) {
35
+ if (typeof context.ensureSessionState === 'function') {
36
+ return context.ensureSessionState('collectathon', createCollectathonSessionSeed());
37
+ }
38
+ if (!appState.session || typeof appState.session !== 'object' || Array.isArray(appState.session)) {
39
+ appState.session = {};
40
+ }
41
+ if (!appState.session.collectathon || typeof appState.session.collectathon !== 'object' || Array.isArray(appState.session.collectathon)) {
42
+ appState.session.collectathon = createCollectathonSessionSeed();
43
+ }
44
+ return appState.session.collectathon;
45
+ }
46
+
47
+ function createCollectathonUiStateSeed() {
48
+ return {
49
+ showControlsHint: true,
50
+ };
51
+ }
52
+
53
+ function ensureCollectathonUiState(context, appState) {
54
+ if (typeof context.ensureUiState === 'function') {
55
+ return context.ensureUiState('collectathonHud', createCollectathonUiStateSeed());
56
+ }
57
+ if (!appState.ui || typeof appState.ui !== 'object' || Array.isArray(appState.ui)) {
58
+ appState.ui = {};
59
+ }
60
+ if (!appState.ui.collectathonHud || typeof appState.ui.collectathonHud !== 'object' || Array.isArray(appState.ui.collectathonHud)) {
61
+ appState.ui.collectathonHud = createCollectathonUiStateSeed();
62
+ }
63
+ return appState.ui.collectathonHud;
64
+ }
65
+
66
+ export function createGameplayScene(context = {}) {
67
+ const appState = context.appState || {};
68
+ const collectathonSession = ensureCollectathonSession(context, appState);
69
+ const collectathonUiState = ensureCollectathonUiState(context, appState);
70
+ const projectTitle = context.projectTitle || 'AuraJS Game';
71
+ const goalZone = createGoalZone(GOAL_ZONE);
72
+ let boxMesh = null;
73
+ let materials = null;
74
+ let playerVisual = null;
75
+ let sceneState = createCollectathonRunState();
76
+
77
+ function syncSessionState() {
78
+ collectathonSession.lastSceneId = 'gameplay';
79
+ collectathonSession.bestScore = Math.max(Number(collectathonSession.bestScore || 0), sceneState.score);
80
+ collectathonSession.lastScore = sceneState.score;
81
+ collectathonSession.lastTimerRemaining = Number(sceneState.timerRemaining.toFixed(2));
82
+ collectathonSession.lastOutcome = sceneState.runComplete
83
+ ? 'course-cleared'
84
+ : (sceneState.runFailed ? 'failed' : 'running');
85
+ }
86
+
87
+ function resetRun() {
88
+ sceneState = createCollectathonRunState(sceneState?.player ?? null);
89
+ if (!playerVisual) return;
90
+ bindPlayerAvatarVisual(sceneState.player, playerVisual);
91
+ syncCollectathonCharacterObstacles(sceneState.movingPlatform);
92
+ spawnCharacterAvatar3D(aura, sceneState.player, { position: sceneState.player.position });
93
+ collectathonSession.runsStarted += 1;
94
+ syncSessionState();
95
+ }
96
+
97
+ function updateMovement(dt) {
98
+ const moveX = axisFromKeys(aura.input, ['arrowleft', 'a'], ['arrowright', 'd']);
99
+ const moveZ = axisFromKeys(aura.input, ['arrowup', 'w'], ['arrowdown', 's']);
100
+ setAvatarInput3D(sceneState.player, {
101
+ moveX,
102
+ moveZ,
103
+ jump: aura.input.isKeyPressed('space'),
104
+ run: aura.input.isKeyDown('shift') || aura.input.isKeyDown('shiftleft') || aura.input.isKeyDown('shiftright'),
105
+ });
106
+ tickCharacterAvatar3D(aura, sceneState.player, dt);
107
+ sceneState.player.position.x = Math.max(-WORLD_LIMIT, Math.min(WORLD_LIMIT, sceneState.player.position.x));
108
+ sceneState.player.position.z = Math.max(-WORLD_LIMIT, Math.min(WORLD_LIMIT, sceneState.player.position.z));
109
+ spawnCharacterAvatar3D(aura, sceneState.player, { position: sceneState.player.position });
110
+ }
111
+
112
+ function updateRespawnAndCheckpoints() {
113
+ if (sceneState.player.position.y < -10) {
114
+ if (!respawnAtCheckpoint(sceneState.checkpointSystem, sceneState.player)) {
115
+ resetRun();
116
+ return false;
117
+ }
118
+ spawnCharacterAvatar3D(aura, sceneState.player, { position: sceneState.player.position });
119
+ }
120
+
121
+ updateCheckpointProgress(sceneState.checkpointSystem, sceneState.player);
122
+ return true;
123
+ }
124
+
125
+ function collectNearbyPickups() {
126
+ for (const collectible of sceneState.collectibles) {
127
+ if (collectible.collected) continue;
128
+ if (distanceSquared3D(sceneState.player, collectible) > 0.95) continue;
129
+ collectible.collected = true;
130
+ sceneState.score += 1;
131
+ }
132
+ }
133
+
134
+ return {
135
+ setup() {
136
+ boxMesh = aura.mesh.createBox();
137
+ materials = createCollectathonMaterials();
138
+ playerVisual = loadPlayerAvatarVisual();
139
+
140
+ aura.light.ambient({ r: 1, g: 1, b: 1 }, 0.23);
141
+ aura.light.directional({ x: 0.55, y: -1.0, z: -0.35 }, { r: 1, g: 1, b: 1 }, 1.0);
142
+ aura.camera3d.perspective(62, 0.1, 150);
143
+
144
+ resetRun();
145
+ console.log(`${projectTitle} started (3D collectathon template)`);
146
+ },
147
+ update(dt) {
148
+ if (aura.input.isKeyPressed('h')) {
149
+ collectathonUiState.showControlsHint = collectathonUiState.showControlsHint !== true;
150
+ }
151
+ sceneState.elapsed += dt;
152
+ stepMovingPlatform3D(sceneState.movingPlatform, dt);
153
+ syncCollectathonCharacterObstacles(sceneState.movingPlatform);
154
+
155
+ if (sceneState.runFailed || sceneState.runComplete) {
156
+ if (aura.input.isKeyPressed('enter')) resetRun();
157
+ return;
158
+ }
159
+
160
+ sceneState.timerRemaining = Math.max(0, sceneState.timerRemaining - dt);
161
+ if (sceneState.timerRemaining <= 0) {
162
+ sceneState.runFailed = true;
163
+ syncSessionState();
164
+ return;
165
+ }
166
+
167
+ updateMovement(dt);
168
+ if (!updateRespawnAndCheckpoints()) return;
169
+ collectNearbyPickups();
170
+
171
+ if (sceneState.score >= TARGET_COLLECTIBLES && isGoalReached(goalZone, sceneState.player)) {
172
+ sceneState.runComplete = true;
173
+ }
174
+ syncSessionState();
175
+ },
176
+ draw() {
177
+ aura.draw3d.clear3d({ r: 0.06, g: 0.08, b: 0.12 });
178
+ drawCollectathonCourse({
179
+ mesh: boxMesh,
180
+ floorMaterial: materials.floor,
181
+ platformMaterial: materials.platform,
182
+ movingPlatform: sceneState.movingPlatform,
183
+ });
184
+ drawCollectathonActors({
185
+ mesh: boxMesh,
186
+ materials,
187
+ state: sceneState,
188
+ goalZone,
189
+ });
190
+ aura.scene3d.submitRenderBindings();
191
+ drawCollectathonHud({
192
+ score: sceneState.score,
193
+ timerRemaining: sceneState.timerRemaining,
194
+ runFailed: sceneState.runFailed,
195
+ runComplete: sceneState.runComplete,
196
+ showControlsHint: collectathonUiState.showControlsHint !== false,
197
+ });
198
+ },
199
+ };
200
+ }
@@ -1,367 +1,17 @@
1
1
  // {{PROJECT_TITLE}} - AuraJS 3D collectathon starter
2
2
 
3
- import { activeCheckpoint, axisFromKeys, clamp, createCheckpointSystem, createGoalZone, createMovingPlatform3D, distanceSquared3D, isGoalReached, respawnAtCheckpoint, stepMovingPlatform3D, stepVerticalMotion, tryJump, updateCheckpointProgress } from './starter-utils/index.js';
3
+ import { createApp } from './runtime/app.js';
4
4
 
5
- const PLAYER_HALF = { x: 0.45, y: 0.55, z: 0.45 };
6
- const MOVE_SPEED = 5.6;
7
- const JUMP_SPEED = 8.4;
8
- const GRAVITY = 20.0;
9
- const WORLD_LIMIT = 9.2;
10
- const TARGET_COLLECTIBLES = 5;
11
- const START_TIMER_SECONDS = 95;
12
-
13
- const WORLD_PLATFORMS = [
14
- { x: -3.2, y: 1.2, z: 2.6, sx: 3.0, sy: 0.5, sz: 2.3 },
15
- { x: 2.5, y: 2.2, z: 1.2, sx: 2.8, sy: 0.5, sz: 2.1 },
16
- { x: 4.9, y: 3.3, z: -1.8, sx: 2.8, sy: 0.5, sz: 2.0 },
17
- { x: -1.0, y: 3.7, z: -3.3, sx: 3.0, sy: 0.5, sz: 2.2 },
18
- { x: 3.8, y: 4.8, z: -5.1, sx: 2.8, sy: 0.5, sz: 2.0 },
19
- ];
20
-
21
- const CHECKPOINTS = [
22
- { x: 0.0, y: 1.1, z: 5.8, radius: 1.4 },
23
- { x: -3.2, y: 2.0, z: 2.6, radius: 1.2 },
24
- { x: 2.5, y: 3.0, z: 1.2, radius: 1.2 },
25
- { x: -1.0, y: 4.5, z: -3.3, radius: 1.25 },
26
- { x: 3.8, y: 5.7, z: -5.1, radius: 1.3 },
27
- ];
28
-
29
- const COLLECTIBLE_SPAWNS = [
30
- { x: -3.2, y: 2.0, z: 2.6 },
31
- { x: 2.5, y: 3.0, z: 1.2 },
32
- { x: 4.9, y: 4.1, z: -1.8 },
33
- { x: -1.0, y: 4.5, z: -3.3 },
34
- { x: 3.8, y: 5.7, z: -5.1 },
35
- { x: 0.2, y: 2.8, z: -0.8 },
36
- ];
37
-
38
- let boxMesh;
39
- let floorMat;
40
- let platformMat;
41
- let playerMat;
42
- let collectibleMat;
43
- let checkpointMat;
44
- let goalMat;
45
-
46
- let player = { x: 0, y: 1.1, z: 5.8, vy: 0, onGround: false };
47
- let collectibles = [];
48
- let score = 0;
49
- let elapsed = 0;
50
- let timerRemaining = START_TIMER_SECONDS;
51
- let runFailed = false;
52
- let runComplete = false;
53
- let checkpointSystem = createCheckpointSystem({ checkpoints: CHECKPOINTS });
54
- let movingPlatform = createMovingPlatform3D({
55
- from: { x: 0.7, y: 2.1, z: -0.5 },
56
- to: { x: 3.2, y: 3.1, z: -2.1 },
57
- size: { x: 2.2, y: 0.4, z: 1.8 },
58
- periodSeconds: 3.0,
59
- });
60
- const goalZone = createGoalZone({ x: 3.8, y: 5.9, z: -5.1, radius: 1.15 });
61
-
62
- function hasMethod(obj, method) {
63
- return Boolean(obj) && typeof obj[method] === 'function';
64
- }
65
-
66
- function failWithReason(reasonCode, message) {
67
- throw new Error(`[3d-collectathon-template] ${message} [reason:${reasonCode}]`);
68
- }
69
-
70
- function assertRuntimeCapabilities() {
71
- const missing = [];
72
- if (!hasMethod(aura.mesh, 'createBox')) missing.push('aura.mesh.createBox');
73
- if (!hasMethod(aura.material, 'create')) missing.push('aura.material.create');
74
- if (!hasMethod(aura.light, 'ambient')) missing.push('aura.light.ambient');
75
- if (!hasMethod(aura.light, 'directional')) missing.push('aura.light.directional');
76
- if (!hasMethod(aura.camera3d, 'perspective')) missing.push('aura.camera3d.perspective');
77
- if (!hasMethod(aura.camera3d, 'setPosition')) missing.push('aura.camera3d.setPosition');
78
- if (!hasMethod(aura.camera3d, 'lookAt')) missing.push('aura.camera3d.lookAt');
79
- if (!hasMethod(aura.input, 'isKeyDown')) missing.push('aura.input.isKeyDown');
80
- if (!hasMethod(aura.input, 'isKeyPressed')) missing.push('aura.input.isKeyPressed');
81
- if (!hasMethod(aura.draw3d, 'clear3d')) missing.push('aura.draw3d.clear3d');
82
- if (!hasMethod(aura.draw3d, 'drawMesh')) missing.push('aura.draw3d.drawMesh');
83
- if (!hasMethod(aura.draw2d, 'text')) missing.push('aura.draw2d.text');
84
- if (!hasMethod(aura.draw2d, 'measureText')) missing.push('aura.draw2d.measureText');
85
- if (typeof aura.rgb !== 'function') missing.push('aura.rgb');
86
- if (!aura.Color || !aura.Color.WHITE) missing.push('aura.Color.WHITE');
87
-
88
- if (missing.length > 0) {
89
- failWithReason('missing_runtime_api', `runtime missing required APIs: ${missing.join(', ')}`);
90
- }
91
-
92
- const small = aura.draw2d.measureText('Probe', { size: 8 });
93
- const large = aura.draw2d.measureText('Probe', { size: 24 });
94
- if (!Number.isFinite(Number(small?.width)) || !Number.isFinite(Number(large?.width)) || Number(large.width) <= Number(small.width)) {
95
- failWithReason(
96
- 'placeholder_runtime_behavior',
97
- 'draw2d.measureText appears to be placeholder behavior (size does not affect width).',
98
- );
99
- }
100
- }
101
-
102
- function buildCollectibles() {
103
- return COLLECTIBLE_SPAWNS.map((entry, index) => ({
104
- id: `c-${index + 1}`,
105
- x: entry.x,
106
- y: entry.y,
107
- z: entry.z,
108
- collected: false,
109
- }));
110
- }
111
-
112
- function resetRun() {
113
- player = { x: 0, y: 1.1, z: 5.8, vy: 0, onGround: false };
114
- collectibles = buildCollectibles();
115
- score = 0;
116
- elapsed = 0;
117
- timerRemaining = START_TIMER_SECONDS;
118
- runFailed = false;
119
- runComplete = false;
120
- checkpointSystem = createCheckpointSystem({ checkpoints: CHECKPOINTS });
121
- movingPlatform = createMovingPlatform3D({
122
- from: { x: 0.7, y: 2.1, z: -0.5 },
123
- to: { x: 3.2, y: 3.1, z: -2.1 },
124
- size: { x: 2.2, y: 0.4, z: 1.8 },
125
- periodSeconds: 3.0,
126
- });
127
- }
128
-
129
- function findSupportTop(x, z) {
130
- let top = 0;
131
-
132
- const includePlatform = (platform) => {
133
- const halfX = platform.sx * 0.5;
134
- const halfZ = platform.sz * 0.5;
135
- if (Math.abs(x - platform.x) > halfX || Math.abs(z - platform.z) > halfZ) return;
136
- top = Math.max(top, platform.y + (platform.sy * 0.5));
137
- };
138
-
139
- for (const platform of WORLD_PLATFORMS) {
140
- includePlatform(platform);
141
- }
142
-
143
- includePlatform({
144
- x: movingPlatform.position.x,
145
- y: movingPlatform.position.y,
146
- z: movingPlatform.position.z,
147
- sx: movingPlatform.size.x,
148
- sy: movingPlatform.size.y,
149
- sz: movingPlatform.size.z,
150
- });
151
-
152
- return top;
153
- }
154
-
155
- function collectNearbyPickups() {
156
- for (const collectible of collectibles) {
157
- if (collectible.collected) continue;
158
- const pickupDistanceSq = distanceSquared3D(player, collectible);
159
- if (pickupDistanceSq > 0.95) continue;
160
- collectible.collected = true;
161
- score += 1;
162
- }
163
- }
5
+ const app = createApp();
164
6
 
165
7
  aura.setup = function () {
166
- assertRuntimeCapabilities();
167
- boxMesh = aura.mesh.createBox();
168
-
169
- floorMat = aura.material.create({
170
- color: { r: 0.16, g: 0.25, b: 0.2, a: 1.0 },
171
- metallic: 0.06,
172
- roughness: 0.92,
173
- });
174
-
175
- platformMat = aura.material.create({
176
- color: { r: 0.42, g: 0.54, b: 0.74, a: 1.0 },
177
- metallic: 0.1,
178
- roughness: 0.6,
179
- });
180
-
181
- playerMat = aura.material.create({
182
- color: { r: 0.98, g: 0.55, b: 0.26, a: 1.0 },
183
- metallic: 0.28,
184
- roughness: 0.32,
185
- });
186
-
187
- collectibleMat = aura.material.create({
188
- color: { r: 0.98, g: 0.92, b: 0.38, a: 1.0 },
189
- metallic: 0.7,
190
- roughness: 0.25,
191
- });
192
-
193
- checkpointMat = aura.material.create({
194
- color: { r: 0.34, g: 0.9, b: 1.0, a: 1.0 },
195
- metallic: 0.45,
196
- roughness: 0.3,
197
- });
198
-
199
- goalMat = aura.material.create({
200
- color: { r: 0.54, g: 1.0, b: 0.7, a: 1.0 },
201
- metallic: 0.38,
202
- roughness: 0.32,
203
- });
204
-
205
- aura.light.ambient({ r: 1, g: 1, b: 1 }, 0.23);
206
- aura.light.directional({ x: 0.55, y: -1.0, z: -0.35 }, { r: 1, g: 1, b: 1 }, 1.0);
207
- aura.camera3d.perspective(62, 0.1, 150);
208
-
209
- resetRun();
210
- console.log('{{PROJECT_TITLE}} started (3D collectathon template)');
8
+ app.setup();
211
9
  };
212
10
 
213
11
  aura.update = function (dt) {
214
- elapsed += dt;
215
- stepMovingPlatform3D(movingPlatform, dt);
216
-
217
- if (runFailed || runComplete) {
218
- if (aura.input.isKeyPressed('enter')) resetRun();
219
- return;
220
- }
221
-
222
- timerRemaining = Math.max(0, timerRemaining - dt);
223
- if (timerRemaining <= 0) {
224
- runFailed = true;
225
- return;
226
- }
227
-
228
- const moveX = axisFromKeys(aura.input, ['arrowleft', 'a'], ['arrowright', 'd']);
229
- const moveZ = axisFromKeys(aura.input, ['arrowup', 'w'], ['arrowdown', 's']);
230
-
231
- player.x += moveX * MOVE_SPEED * dt;
232
- player.z += moveZ * MOVE_SPEED * dt;
233
- player.x = clamp(player.x, -WORLD_LIMIT, WORLD_LIMIT);
234
- player.z = clamp(player.z, -WORLD_LIMIT, WORLD_LIMIT);
235
-
236
- if (aura.input.isKeyPressed('space')) {
237
- tryJump(player, JUMP_SPEED);
238
- }
239
-
240
- const supportTop = findSupportTop(player.x, player.z);
241
- const floorY = supportTop + PLAYER_HALF.y;
242
- stepVerticalMotion(player, dt, GRAVITY, floorY);
243
-
244
- if (player.y < -10) {
245
- if (!respawnAtCheckpoint(checkpointSystem, player)) {
246
- resetRun();
247
- return;
248
- }
249
- }
250
-
251
- updateCheckpointProgress(checkpointSystem, player);
252
- collectNearbyPickups();
253
-
254
- if (score >= TARGET_COLLECTIBLES && isGoalReached(goalZone, player)) {
255
- runComplete = true;
256
- }
257
-
258
- aura.camera3d.setPosition(player.x + 7.8, player.y + 6.2, player.z + 8.5);
259
- aura.camera3d.lookAt(player.x, player.y + 0.2, player.z);
12
+ app.update(dt);
260
13
  };
261
14
 
262
15
  aura.draw = function () {
263
- aura.draw3d.clear3d({ r: 0.06, g: 0.08, b: 0.12 });
264
-
265
- aura.draw3d.drawMesh(boxMesh, floorMat, {
266
- position: { x: 0, y: -0.5, z: 0 },
267
- rotation: { x: 0, y: 0, z: 0 },
268
- scale: { x: 26, y: 1, z: 26 },
269
- });
270
-
271
- for (const platform of WORLD_PLATFORMS) {
272
- aura.draw3d.drawMesh(boxMesh, platformMat, {
273
- position: { x: platform.x, y: platform.y, z: platform.z },
274
- rotation: { x: 0, y: 0, z: 0 },
275
- scale: { x: platform.sx, y: platform.sy, z: platform.sz },
276
- });
277
- }
278
-
279
- aura.draw3d.drawMesh(boxMesh, platformMat, {
280
- position: { x: movingPlatform.position.x, y: movingPlatform.position.y, z: movingPlatform.position.z },
281
- rotation: { x: 0, y: elapsed * 0.5, z: 0 },
282
- scale: { x: movingPlatform.size.x, y: movingPlatform.size.y, z: movingPlatform.size.z },
283
- });
284
-
285
- aura.draw3d.drawMesh(boxMesh, playerMat, {
286
- position: { x: player.x, y: player.y, z: player.z },
287
- rotation: { x: 0, y: elapsed * 1.1, z: 0 },
288
- scale: { x: PLAYER_HALF.x * 2, y: PLAYER_HALF.y * 2, z: PLAYER_HALF.z * 2 },
289
- });
290
-
291
- for (const collectible of collectibles) {
292
- if (collectible.collected) continue;
293
- aura.draw3d.drawMesh(boxMesh, collectibleMat, {
294
- position: {
295
- x: collectible.x,
296
- y: collectible.y + (Math.sin((elapsed * 2.2) + collectible.x) * 0.16),
297
- z: collectible.z,
298
- },
299
- rotation: { x: elapsed * 0.5, y: elapsed * 1.7, z: elapsed * 0.3 },
300
- scale: { x: 0.45, y: 0.45, z: 0.45 },
301
- });
302
- }
303
-
304
- const checkpoint = activeCheckpoint(checkpointSystem);
305
- if (checkpoint) {
306
- aura.draw3d.drawMesh(boxMesh, checkpointMat, {
307
- position: { x: checkpoint.x, y: checkpoint.y - 0.35, z: checkpoint.z },
308
- rotation: { x: 0, y: elapsed, z: 0 },
309
- scale: { x: 0.4, y: 0.4, z: 0.4 },
310
- });
311
- }
312
-
313
- aura.draw3d.drawMesh(boxMesh, goalMat, {
314
- position: { x: goalZone.x, y: goalZone.y, z: goalZone.z },
315
- rotation: { x: 0, y: elapsed * 0.9, z: 0 },
316
- scale: {
317
- x: goalZone.radius * 1.25,
318
- y: goalZone.radius * 1.25,
319
- z: goalZone.radius * 1.25,
320
- },
321
- });
322
-
323
- aura.draw2d.text('Move: Arrows/WASD Jump: Space', 12, 12, {
324
- color: aura.Color.WHITE,
325
- size: 14,
326
- align: 'left',
327
- });
328
- aura.draw2d.text(`Collectibles ${score}/${TARGET_COLLECTIBLES}`, 12, 34, {
329
- color: aura.Color.WHITE,
330
- size: 14,
331
- align: 'left',
332
- });
333
- aura.draw2d.text(`Timer ${timerRemaining.toFixed(1)}s`, 12, 56, {
334
- color: aura.Color.WHITE,
335
- size: 14,
336
- align: 'left',
337
- });
338
- aura.draw2d.text('Reach checkpoints, collect orbs, then hit the goal.', 12, 78, {
339
- color: aura.Color.WHITE,
340
- size: 13,
341
- align: 'left',
342
- });
343
-
344
- if (runComplete) {
345
- aura.draw2d.text('COURSE CLEARED', 12, 108, {
346
- color: aura.rgb(0.54, 1.0, 0.7),
347
- size: 24,
348
- align: 'left',
349
- });
350
- aura.draw2d.text('Press Enter to restart', 12, 136, {
351
- color: aura.Color.WHITE,
352
- size: 16,
353
- align: 'left',
354
- });
355
- } else if (runFailed) {
356
- aura.draw2d.text('TIME UP', 12, 108, {
357
- color: aura.rgb(1.0, 0.46, 0.46),
358
- size: 24,
359
- align: 'left',
360
- });
361
- aura.draw2d.text('Press Enter to retry', 12, 136, {
362
- color: aura.Color.WHITE,
363
- size: 16,
364
- align: 'left',
365
- });
366
- }
16
+ app.draw();
367
17
  };
@@ -0,0 +1,49 @@
1
+ import { createSceneRegistry } from './scene-registry.js';
2
+ import { createProjectInspector } from './project-inspector.js';
3
+ import { assertRuntimeCapabilities } from './capabilities.js';
4
+
5
+ export function createApp() {
6
+ const sceneRegistry = createSceneRegistry({
7
+ projectTitle: '{{PROJECT_TITLE}}',
8
+ });
9
+ const projectInspector = createProjectInspector();
10
+ let activeSceneId = sceneRegistry.defaultSceneId || Object.keys(sceneRegistry.scenes)[0] || null;
11
+
12
+ const activeScene = () => (activeSceneId ? sceneRegistry.scenes[activeSceneId] || null : null);
13
+
14
+ return {
15
+ get activeSceneId() {
16
+ return activeSceneId;
17
+ },
18
+ get sceneRegistry() {
19
+ return sceneRegistry;
20
+ },
21
+ get projectInspectorEnabled() {
22
+ return projectInspector.enabled;
23
+ },
24
+ getProjectInspectorState() {
25
+ return projectInspector.snapshot({ activeSceneId });
26
+ },
27
+ setup() {
28
+ assertRuntimeCapabilities();
29
+ activeScene()?.setup?.();
30
+ },
31
+ update(dt) {
32
+ projectInspector.syncInput(globalThis.aura?.input || null);
33
+ activeScene()?.update?.(dt);
34
+ },
35
+ draw() {
36
+ activeScene()?.draw?.();
37
+ projectInspector.draw({ activeSceneId });
38
+ },
39
+ toggleProjectInspector(nextEnabled) {
40
+ return projectInspector.toggle(nextEnabled);
41
+ },
42
+ swapScene(nextSceneId) {
43
+ if (!sceneRegistry.scenes[nextSceneId]) {
44
+ throw new Error(`Unknown scene "${nextSceneId}".`);
45
+ }
46
+ activeSceneId = nextSceneId;
47
+ },
48
+ };
49
+ }
@@ -0,0 +1,53 @@
1
+ function hasMethod(obj, method) {
2
+ return Boolean(obj) && typeof obj[method] === 'function';
3
+ }
4
+
5
+ function failWithReason(reasonCode, message) {
6
+ throw new Error(`[3d-collectathon-template] ${message} [reason:${reasonCode}]`);
7
+ }
8
+
9
+ export function assertRuntimeCapabilities() {
10
+ const missing = [];
11
+ if (!hasMethod(aura.mesh, 'createBox')) missing.push('aura.mesh.createBox');
12
+ if (!hasMethod(aura.material, 'create')) missing.push('aura.material.create');
13
+ if (!hasMethod(aura.light, 'ambient')) missing.push('aura.light.ambient');
14
+ if (!hasMethod(aura.light, 'directional')) missing.push('aura.light.directional');
15
+ if (!hasMethod(aura.camera3d, 'perspective')) missing.push('aura.camera3d.perspective');
16
+ if (!hasMethod(aura.camera3d, 'setPosition')) missing.push('aura.camera3d.setPosition');
17
+ if (!hasMethod(aura.camera3d, 'lookAt')) missing.push('aura.camera3d.lookAt');
18
+ if (!hasMethod(aura.character3d, 'create')) missing.push('aura.character3d.create');
19
+ if (!hasMethod(aura.character3d, 'move')) missing.push('aura.character3d.move');
20
+ if (!hasMethod(aura.character3d, 'jump')) missing.push('aura.character3d.jump');
21
+ if (!hasMethod(aura.character3d, 'update')) missing.push('aura.character3d.update');
22
+ if (!hasMethod(aura.character3d, 'getState')) missing.push('aura.character3d.getState');
23
+ if (!hasMethod(aura.character3d, 'setPosition')) missing.push('aura.character3d.setPosition');
24
+ if (!hasMethod(aura.character3d, 'addObstacle')) missing.push('aura.character3d.addObstacle');
25
+ if (!hasMethod(aura.character3d, 'clearObstacles')) missing.push('aura.character3d.clearObstacles');
26
+ if (!hasMethod(aura.input, 'isKeyDown')) missing.push('aura.input.isKeyDown');
27
+ if (!hasMethod(aura.input, 'isKeyPressed')) missing.push('aura.input.isKeyPressed');
28
+ if (!hasMethod(aura.scene3d, 'loadGltfScene')) missing.push('aura.scene3d.loadGltfScene');
29
+ if (!hasMethod(aura.scene3d, 'getImportedScene')) missing.push('aura.scene3d.getImportedScene');
30
+ if (!hasMethod(aura.scene3d, 'playImportedAnimation')) missing.push('aura.scene3d.playImportedAnimation');
31
+ if (!hasMethod(aura.scene3d, 'setLocalTransform')) missing.push('aura.scene3d.setLocalTransform');
32
+ if (!hasMethod(aura.scene3d, 'updateClips')) missing.push('aura.scene3d.updateClips');
33
+ if (!hasMethod(aura.scene3d, 'submitRenderBindings')) missing.push('aura.scene3d.submitRenderBindings');
34
+ if (!hasMethod(aura.draw3d, 'clear3d')) missing.push('aura.draw3d.clear3d');
35
+ if (!hasMethod(aura.draw3d, 'drawMesh')) missing.push('aura.draw3d.drawMesh');
36
+ if (!hasMethod(aura.draw2d, 'text')) missing.push('aura.draw2d.text');
37
+ if (!hasMethod(aura.draw2d, 'measureText')) missing.push('aura.draw2d.measureText');
38
+ if (typeof aura.rgb !== 'function') missing.push('aura.rgb');
39
+ if (!aura.Color || !aura.Color.WHITE) missing.push('aura.Color.WHITE');
40
+
41
+ if (missing.length > 0) {
42
+ failWithReason('missing_runtime_api', `runtime missing required APIs: ${missing.join(', ')}`);
43
+ }
44
+
45
+ const small = aura.draw2d.measureText('Probe', { size: 8 });
46
+ const large = aura.draw2d.measureText('Probe', { size: 24 });
47
+ if (!Number.isFinite(Number(small?.width)) || !Number.isFinite(Number(large?.width)) || Number(large.width) <= Number(small.width)) {
48
+ failWithReason(
49
+ 'placeholder_runtime_behavior',
50
+ 'draw2d.measureText appears to be placeholder behavior (size does not affect width).',
51
+ );
52
+ }
53
+ }