create-threenative 0.2.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 (320) hide show
  1. package/README.md +16 -0
  2. package/dist/index.d.ts +30 -0
  3. package/dist/index.js +283 -0
  4. package/dist/threenative.d.ts +6 -0
  5. package/dist/threenative.js +757 -0
  6. package/package.json +44 -0
  7. package/templates/action-rpg/.mcp.json +16 -0
  8. package/templates/action-rpg/AGENTS.md +40 -0
  9. package/templates/action-rpg/CLAUDE.md +42 -0
  10. package/templates/action-rpg/index.html +13 -0
  11. package/templates/action-rpg/kit.json +7 -0
  12. package/templates/action-rpg/package.json +47 -0
  13. package/templates/action-rpg/playtests/combat.playtest.json +61 -0
  14. package/templates/action-rpg/playtests/fail.playtest.json +21 -0
  15. package/templates/action-rpg/playtests/inventory.playtest.json +111 -0
  16. package/templates/action-rpg/playtests/progress.playtest.json +99 -0
  17. package/templates/action-rpg/playtests/survives.playtest.json +32 -0
  18. package/templates/action-rpg/playtests/win.playtest.json +30 -0
  19. package/templates/action-rpg/public/favicon.svg +5 -0
  20. package/templates/action-rpg/src/abilities/Ability.ts +45 -0
  21. package/templates/action-rpg/src/entities/Enemy.ts +143 -0
  22. package/templates/action-rpg/src/entities/Player.ts +83 -0
  23. package/templates/action-rpg/src/game.ts +40 -0
  24. package/templates/action-rpg/src/items/Inventory.ts +163 -0
  25. package/templates/action-rpg/src/loot/drops.ts +40 -0
  26. package/templates/action-rpg/src/main.ts +15 -0
  27. package/templates/action-rpg/src/physics.ts +40 -0
  28. package/templates/action-rpg/src/playtest-events.ts +15 -0
  29. package/templates/action-rpg/src/progress.ts +35 -0
  30. package/templates/action-rpg/src/render/camera.ts +26 -0
  31. package/templates/action-rpg/src/render/lighting.ts +30 -0
  32. package/templates/action-rpg/src/render/loading.ts +90 -0
  33. package/templates/action-rpg/src/render/materials.ts +40 -0
  34. package/templates/action-rpg/src/render/palette.ts +9 -0
  35. package/templates/action-rpg/src/render/postprocessing.ts +18 -0
  36. package/templates/action-rpg/src/render/shapes.ts +110 -0
  37. package/templates/action-rpg/src/render/sky.ts +18 -0
  38. package/templates/action-rpg/src/render/types.ts +3 -0
  39. package/templates/action-rpg/src/scenes/Boot.ts +12 -0
  40. package/templates/action-rpg/src/scenes/Play.ts +449 -0
  41. package/templates/action-rpg/src/state.ts +40 -0
  42. package/templates/action-rpg/src/stats/StatBlock.ts +57 -0
  43. package/templates/action-rpg/src/style.css +32 -0
  44. package/templates/action-rpg/src/ui/AbilityBar.tsx +28 -0
  45. package/templates/action-rpg/src/ui/App.tsx +21 -0
  46. package/templates/action-rpg/src/ui/CharacterPanel.tsx +31 -0
  47. package/templates/action-rpg/src/ui/Hud.tsx +29 -0
  48. package/templates/action-rpg/src/ui/InventoryPanel.tsx +37 -0
  49. package/templates/action-rpg/tailwind.config.ts +7 -0
  50. package/templates/action-rpg/threenative.config.ts +29 -0
  51. package/templates/action-rpg/tsconfig.json +17 -0
  52. package/templates/action-rpg/vite.config.ts +8 -0
  53. package/templates/defense/.mcp.json +16 -0
  54. package/templates/defense/AGENTS.md +53 -0
  55. package/templates/defense/CLAUDE.md +55 -0
  56. package/templates/defense/README.md +9 -0
  57. package/templates/defense/index.html +13 -0
  58. package/templates/defense/kit.json +7 -0
  59. package/templates/defense/package.json +46 -0
  60. package/templates/defense/playtests/leak.playtest.json +18 -0
  61. package/templates/defense/playtests/placement.playtest.json +40 -0
  62. package/templates/defense/playtests/scan.playtest.json +20 -0
  63. package/templates/defense/playtests/survive.playtest.json +26 -0
  64. package/templates/defense/playtests/survives.playtest.json +36 -0
  65. package/templates/defense/public/favicon.svg +5 -0
  66. package/templates/defense/src/attackers/Attacker.ts +104 -0
  67. package/templates/defense/src/board/Route.ts +80 -0
  68. package/templates/defense/src/economy.ts +36 -0
  69. package/templates/defense/src/entities/Player.ts +44 -0
  70. package/templates/defense/src/game.ts +30 -0
  71. package/templates/defense/src/main.ts +15 -0
  72. package/templates/defense/src/physics.ts +43 -0
  73. package/templates/defense/src/placement/Buildable.ts +49 -0
  74. package/templates/defense/src/playtest-events.ts +15 -0
  75. package/templates/defense/src/render/camera.ts +10 -0
  76. package/templates/defense/src/render/lighting.ts +32 -0
  77. package/templates/defense/src/render/loading.ts +89 -0
  78. package/templates/defense/src/render/materials.ts +13 -0
  79. package/templates/defense/src/render/palette.ts +21 -0
  80. package/templates/defense/src/render/postprocessing.ts +14 -0
  81. package/templates/defense/src/render/shapes.ts +89 -0
  82. package/templates/defense/src/render/sky.ts +45 -0
  83. package/templates/defense/src/scenes/Boot.ts +12 -0
  84. package/templates/defense/src/scenes/Defense.ts +165 -0
  85. package/templates/defense/src/state.ts +50 -0
  86. package/templates/defense/src/style.css +32 -0
  87. package/templates/defense/src/towers/Tower.ts +96 -0
  88. package/templates/defense/src/towers/targeting.ts +53 -0
  89. package/templates/defense/src/ui/App.tsx +17 -0
  90. package/templates/defense/src/ui/Hud.tsx +61 -0
  91. package/templates/defense/src/ui/Menu.tsx +7 -0
  92. package/templates/defense/src/waves.ts +40 -0
  93. package/templates/defense/tailwind.config.ts +1 -0
  94. package/templates/defense/threenative.config.ts +29 -0
  95. package/templates/defense/tsconfig.json +17 -0
  96. package/templates/defense/vite.config.ts +5 -0
  97. package/templates/minimal/.mcp.json +16 -0
  98. package/templates/minimal/AGENTS.md +400 -0
  99. package/templates/minimal/CLAUDE.md +402 -0
  100. package/templates/minimal/assets/.gitkeep +0 -0
  101. package/templates/minimal/index.html +14 -0
  102. package/templates/minimal/kit.json +7 -0
  103. package/templates/minimal/package.json +40 -0
  104. package/templates/minimal/playtests/play.playtest.json +32 -0
  105. package/templates/minimal/playtests/survives.playtest.json +32 -0
  106. package/templates/minimal/public/.gitkeep +0 -0
  107. package/templates/minimal/public/favicon.svg +4 -0
  108. package/templates/minimal/public/icon.png +0 -0
  109. package/templates/minimal/src/entities/Player.ts +66 -0
  110. package/templates/minimal/src/game.ts +28 -0
  111. package/templates/minimal/src/main.ts +17 -0
  112. package/templates/minimal/src/render/camera.ts +11 -0
  113. package/templates/minimal/src/render/hud.ts +53 -0
  114. package/templates/minimal/src/render/lighting.ts +46 -0
  115. package/templates/minimal/src/render/loading.ts +113 -0
  116. package/templates/minimal/src/render/materials.ts +16 -0
  117. package/templates/minimal/src/render/palette.ts +9 -0
  118. package/templates/minimal/src/render/postprocessing.ts +20 -0
  119. package/templates/minimal/src/render/sky.ts +41 -0
  120. package/templates/minimal/src/scenes/Boot.ts +5 -0
  121. package/templates/minimal/src/scenes/Play.ts +65 -0
  122. package/templates/minimal/src/state.ts +1 -0
  123. package/templates/minimal/src/style.css +41 -0
  124. package/templates/minimal/threenative.config.ts +32 -0
  125. package/templates/minimal/tsconfig.json +16 -0
  126. package/templates/minimal/vite.config.ts +3 -0
  127. package/templates/platformer/.mcp.json +16 -0
  128. package/templates/platformer/AGENTS.md +199 -0
  129. package/templates/platformer/CLAUDE.md +201 -0
  130. package/templates/platformer/assets/.gitkeep +0 -0
  131. package/templates/platformer/index.html +13 -0
  132. package/templates/platformer/kit.json +7 -0
  133. package/templates/platformer/package.json +50 -0
  134. package/templates/platformer/playtests/avoidance.playtest.json +23 -0
  135. package/templates/platformer/playtests/buffer.playtest.json +17 -0
  136. package/templates/platformer/playtests/chase.playtest.json +21 -0
  137. package/templates/platformer/playtests/collect.playtest.json +56 -0
  138. package/templates/platformer/playtests/collision-layers.playtest.json +36 -0
  139. package/templates/platformer/playtests/coyote.playtest.json +21 -0
  140. package/templates/platformer/playtests/damage.playtest.json +31 -0
  141. package/templates/platformer/playtests/dash.playtest.json +21 -0
  142. package/templates/platformer/playtests/jump.playtest.json +21 -0
  143. package/templates/platformer/playtests/oneway.playtest.json +17 -0
  144. package/templates/platformer/playtests/patrol.playtest.json +13 -0
  145. package/templates/platformer/playtests/performance.playtest.json +21 -0
  146. package/templates/platformer/playtests/physics.playtest.json +14 -0
  147. package/templates/platformer/playtests/respawn.playtest.json +31 -0
  148. package/templates/platformer/playtests/stomp-rise.playtest.json +41 -0
  149. package/templates/platformer/playtests/stomp.playtest.json +34 -0
  150. package/templates/platformer/playtests/survives.playtest.json +32 -0
  151. package/templates/platformer/playtests/terminal-loop-fail.playtest.json +29 -0
  152. package/templates/platformer/playtests/terminal-loop-win.playtest.json +52 -0
  153. package/templates/platformer/public/.gitkeep +0 -0
  154. package/templates/platformer/public/favicon.svg +4 -0
  155. package/templates/platformer/public/icon.png +0 -0
  156. package/templates/platformer/src/entities/Character.ts +218 -0
  157. package/templates/platformer/src/entities/Chaser.ts +118 -0
  158. package/templates/platformer/src/entities/Patrol.ts +88 -0
  159. package/templates/platformer/src/entities/Pickup.ts +72 -0
  160. package/templates/platformer/src/game.ts +27 -0
  161. package/templates/platformer/src/level/Checkpoints.ts +66 -0
  162. package/templates/platformer/src/level/Platform.ts +34 -0
  163. package/templates/platformer/src/main.ts +14 -0
  164. package/templates/platformer/src/playtest-events.ts +15 -0
  165. package/templates/platformer/src/render/camera.ts +8 -0
  166. package/templates/platformer/src/render/lighting.ts +38 -0
  167. package/templates/platformer/src/render/loading.ts +113 -0
  168. package/templates/platformer/src/render/materials.ts +11 -0
  169. package/templates/platformer/src/render/palette.ts +54 -0
  170. package/templates/platformer/src/render/postprocessing.ts +18 -0
  171. package/templates/platformer/src/render/rig.ts +60 -0
  172. package/templates/platformer/src/render/sky.ts +47 -0
  173. package/templates/platformer/src/render/terrain.ts +31 -0
  174. package/templates/platformer/src/render/touch-controls.ts +157 -0
  175. package/templates/platformer/src/render/touch-layout.ts +63 -0
  176. package/templates/platformer/src/scenes/Boot.ts +12 -0
  177. package/templates/platformer/src/scenes/Level.ts +176 -0
  178. package/templates/platformer/src/state.ts +23 -0
  179. package/templates/platformer/src/style.css +31 -0
  180. package/templates/platformer/src/ui/App.tsx +17 -0
  181. package/templates/platformer/src/ui/Hud.tsx +41 -0
  182. package/templates/platformer/src/ui/Menu.tsx +7 -0
  183. package/templates/platformer/tailwind.config.ts +2 -0
  184. package/templates/platformer/threenative.config.ts +32 -0
  185. package/templates/platformer/tsconfig.json +17 -0
  186. package/templates/platformer/vite.config.ts +5 -0
  187. package/templates/racing/.mcp.json +16 -0
  188. package/templates/racing/AGENTS.md +48 -0
  189. package/templates/racing/CLAUDE.md +50 -0
  190. package/templates/racing/index.html +13 -0
  191. package/templates/racing/kit.json +7 -0
  192. package/templates/racing/package.json +46 -0
  193. package/templates/racing/playtests/boost.playtest.json +45 -0
  194. package/templates/racing/playtests/outcome.playtest.json +78 -0
  195. package/templates/racing/playtests/ranking.playtest.json +37 -0
  196. package/templates/racing/playtests/rescue.playtest.json +28 -0
  197. package/templates/racing/playtests/reverse.playtest.json +37 -0
  198. package/templates/racing/playtests/shortcut.playtest.json +44 -0
  199. package/templates/racing/playtests/survives.playtest.json +32 -0
  200. package/templates/racing/public/favicon.svg +6 -0
  201. package/templates/racing/src/entities/RacingCar.ts +114 -0
  202. package/templates/racing/src/entities/Rival.ts +46 -0
  203. package/templates/racing/src/game.ts +29 -0
  204. package/templates/racing/src/kart/boost.ts +38 -0
  205. package/templates/racing/src/main.ts +15 -0
  206. package/templates/racing/src/playtest-events.ts +15 -0
  207. package/templates/racing/src/render/camera.ts +28 -0
  208. package/templates/racing/src/render/lighting.ts +32 -0
  209. package/templates/racing/src/render/loading.ts +58 -0
  210. package/templates/racing/src/render/materials.ts +15 -0
  211. package/templates/racing/src/render/palette.ts +30 -0
  212. package/templates/racing/src/render/postprocessing.ts +14 -0
  213. package/templates/racing/src/render/shapes.ts +37 -0
  214. package/templates/racing/src/render/sky.ts +45 -0
  215. package/templates/racing/src/scenes/Boot.ts +12 -0
  216. package/templates/racing/src/scenes/Race.ts +180 -0
  217. package/templates/racing/src/state.ts +35 -0
  218. package/templates/racing/src/style.css +32 -0
  219. package/templates/racing/src/track/Checkline.ts +19 -0
  220. package/templates/racing/src/track/Lap.ts +104 -0
  221. package/templates/racing/src/track/Ranking.ts +35 -0
  222. package/templates/racing/src/track/Track.ts +229 -0
  223. package/templates/racing/src/track/TrackSector.ts +77 -0
  224. package/templates/racing/src/track/rescue.ts +21 -0
  225. package/templates/racing/src/ui/App.tsx +17 -0
  226. package/templates/racing/src/ui/Hud.tsx +71 -0
  227. package/templates/racing/src/ui/Menu.tsx +7 -0
  228. package/templates/racing/tailwind.config.ts +2 -0
  229. package/templates/racing/threenative.config.ts +29 -0
  230. package/templates/racing/tsconfig.json +17 -0
  231. package/templates/racing/vite.config.ts +5 -0
  232. package/templates/shooter/.mcp.json +16 -0
  233. package/templates/shooter/AGENTS.md +69 -0
  234. package/templates/shooter/CLAUDE.md +71 -0
  235. package/templates/shooter/index.html +13 -0
  236. package/templates/shooter/kit.json +7 -0
  237. package/templates/shooter/package.json +46 -0
  238. package/templates/shooter/playtests/fail.playtest.json +30 -0
  239. package/templates/shooter/playtests/shooter.playtest.json +89 -0
  240. package/templates/shooter/playtests/survives.playtest.json +32 -0
  241. package/templates/shooter/public/favicon.svg +4 -0
  242. package/templates/shooter/src/combat/damage.ts +41 -0
  243. package/templates/shooter/src/entities/Pickup.ts +70 -0
  244. package/templates/shooter/src/entities/Player.ts +93 -0
  245. package/templates/shooter/src/entities/Target.ts +103 -0
  246. package/templates/shooter/src/game.ts +36 -0
  247. package/templates/shooter/src/level/SpawnPoints.ts +28 -0
  248. package/templates/shooter/src/main.ts +26 -0
  249. package/templates/shooter/src/physics.ts +49 -0
  250. package/templates/shooter/src/playtest-events.ts +15 -0
  251. package/templates/shooter/src/render/camera.ts +29 -0
  252. package/templates/shooter/src/render/lighting.ts +38 -0
  253. package/templates/shooter/src/render/loading.ts +86 -0
  254. package/templates/shooter/src/render/materials.ts +38 -0
  255. package/templates/shooter/src/render/palette.ts +9 -0
  256. package/templates/shooter/src/render/postprocessing.ts +19 -0
  257. package/templates/shooter/src/render/shapes.ts +194 -0
  258. package/templates/shooter/src/render/sky.ts +37 -0
  259. package/templates/shooter/src/render/types.ts +3 -0
  260. package/templates/shooter/src/render/ui.css +212 -0
  261. package/templates/shooter/src/render/ui.ts +59 -0
  262. package/templates/shooter/src/scenes/Boot.ts +12 -0
  263. package/templates/shooter/src/scenes/Play.ts +428 -0
  264. package/templates/shooter/src/state.ts +29 -0
  265. package/templates/shooter/src/ui/App.tsx +25 -0
  266. package/templates/shooter/src/ui/Hud.tsx +49 -0
  267. package/templates/shooter/src/ui/Menu.tsx +26 -0
  268. package/templates/shooter/src/waves.ts +50 -0
  269. package/templates/shooter/src/weapons/Hitscan.ts +43 -0
  270. package/templates/shooter/src/weapons/Projectile.ts +76 -0
  271. package/templates/shooter/tailwind.config.ts +5 -0
  272. package/templates/shooter/threenative.config.ts +29 -0
  273. package/templates/shooter/tsconfig.json +17 -0
  274. package/templates/shooter/vite.config.ts +8 -0
  275. package/templates/starter/.mcp.json +16 -0
  276. package/templates/starter/AGENTS.md +450 -0
  277. package/templates/starter/CLAUDE.md +452 -0
  278. package/templates/starter/assets/.gitkeep +0 -0
  279. package/templates/starter/index.html +13 -0
  280. package/templates/starter/kit.json +7 -0
  281. package/templates/starter/package.json +49 -0
  282. package/templates/starter/playtests/buffer.playtest.json +29 -0
  283. package/templates/starter/playtests/coyote.playtest.json +35 -0
  284. package/templates/starter/playtests/forward.playtest.json +15 -0
  285. package/templates/starter/playtests/hot-reload.playtest.json +28 -0
  286. package/templates/starter/playtests/look.playtest.json +43 -0
  287. package/templates/starter/playtests/monitoring.playtest.json +41 -0
  288. package/templates/starter/playtests/pause.playtest.json +33 -0
  289. package/templates/starter/playtests/play.playtest.json +16 -0
  290. package/templates/starter/playtests/respawn.playtest.json +28 -0
  291. package/templates/starter/playtests/restart.playtest.json +36 -0
  292. package/templates/starter/playtests/seed.playtest.json +18 -0
  293. package/templates/starter/playtests/survives.playtest.json +32 -0
  294. package/templates/starter/public/.gitkeep +0 -0
  295. package/templates/starter/public/favicon.svg +4 -0
  296. package/templates/starter/public/icon.png +0 -0
  297. package/templates/starter/public/native-proof.glb +0 -0
  298. package/templates/starter/public/native-proof.png +0 -0
  299. package/templates/starter/public/pickup.ogg +0 -0
  300. package/templates/starter/src/entities/Crate.ts +34 -0
  301. package/templates/starter/src/entities/Player.ts +80 -0
  302. package/templates/starter/src/game.ts +30 -0
  303. package/templates/starter/src/main.ts +15 -0
  304. package/templates/starter/src/render/camera.ts +57 -0
  305. package/templates/starter/src/render/lighting.ts +55 -0
  306. package/templates/starter/src/render/materials.ts +12 -0
  307. package/templates/starter/src/render/palette.ts +9 -0
  308. package/templates/starter/src/render/postprocessing.ts +18 -0
  309. package/templates/starter/src/render/shapes.ts +147 -0
  310. package/templates/starter/src/render/sky.ts +56 -0
  311. package/templates/starter/src/scenes/Play.ts +161 -0
  312. package/templates/starter/src/state.ts +10 -0
  313. package/templates/starter/src/style.css +45 -0
  314. package/templates/starter/src/ui/App.tsx +19 -0
  315. package/templates/starter/src/ui/Hud.tsx +37 -0
  316. package/templates/starter/src/ui/Menu.tsx +43 -0
  317. package/templates/starter/tailwind.config.ts +2 -0
  318. package/templates/starter/threenative.config.ts +31 -0
  319. package/templates/starter/tsconfig.json +17 -0
  320. package/templates/starter/vite.config.ts +8 -0
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "starter-look",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "artifacts": { "screenshots": "before-after" },
9
+ "steps": [
10
+ {
11
+ "kind": "input",
12
+ "label": "move-camera",
13
+ "press": "ArrowRight",
14
+ "holdTicks": 220,
15
+ "release": true
16
+ }
17
+ ],
18
+ "assert": {
19
+ "diagnostics": { "noConsoleErrors": true, "noNetworkErrors": true, "runtimeReady": true },
20
+ "camera": {
21
+ "entity": "camera.main",
22
+ "follows": "player",
23
+ "targetInViewport": true,
24
+ "within": 9.5
25
+ },
26
+ "movement": { "entity": "player", "minDistance": 4 },
27
+ "visibility": [{ "entity": "player", "minProjectedPixels": 20 }],
28
+ "visual": [
29
+ { "frameDiff": { "minChangedPixelRatio": 0.01 } },
30
+ {
31
+ "region": {
32
+ "x": 0,
33
+ "y": 0,
34
+ "width": 1280,
35
+ "height": 720,
36
+ "minNonblankPixelRatio": 0.95,
37
+ "minDarkPixelRatio": 0.2,
38
+ "maxLuminance": 0.25
39
+ }
40
+ }
41
+ ]
42
+ }
43
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "starter-area-monitoring",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "steps": [
9
+ {
10
+ "kind": "input",
11
+ "label": "collect",
12
+ "press": "ArrowRight",
13
+ "holdTicks": 100,
14
+ "release": true
15
+ },
16
+ { "kind": "input", "label": "leave", "press": "ArrowLeft", "holdTicks": 25, "release": true },
17
+ {
18
+ "kind": "input",
19
+ "label": "reenter-while-disabled",
20
+ "press": "ArrowRight",
21
+ "holdTicks": 25,
22
+ "release": true
23
+ }
24
+ ],
25
+ "assert": {
26
+ "diagnostics": { "noConsoleErrors": true, "noNetworkErrors": true, "runtimeReady": true },
27
+ "resources": [
28
+ {
29
+ "id": "GameState",
30
+ "path": "score",
31
+ "equals": 1,
32
+ "changed": true,
33
+ "atSteps": [
34
+ { "label": "collect", "equals": 1 },
35
+ { "label": "reenter-while-disabled", "equals": 1 }
36
+ ]
37
+ }
38
+ ],
39
+ "visibility": [{ "entity": "player", "minProjectedPixels": 20 }]
40
+ }
41
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "pause",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "steps": [
9
+ {
10
+ "kind": "input",
11
+ "label": "focus-pause-button",
12
+ "press": "Tab",
13
+ "holdTicks": 1,
14
+ "release": true
15
+ },
16
+ { "kind": "input", "label": "pause-button", "press": "Enter", "holdTicks": 1, "release": true },
17
+ { "kind": "wait", "label": "paused", "waitTicks": 30, "release": true },
18
+ {
19
+ "kind": "input",
20
+ "label": "movement-while-paused",
21
+ "press": "ArrowRight",
22
+ "holdTicks": 30,
23
+ "release": true
24
+ }
25
+ ],
26
+ "assert": {
27
+ "diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
28
+ "movement": {
29
+ "entity": "player",
30
+ "maxDistance": 0.1
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "play",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "steps": [
8
+ { "kind": "input", "press": "ArrowRight", "holdFrames": 120, "release": true },
9
+ { "kind": "wait", "waitFrames": 30, "release": true }
10
+ ],
11
+ "assert": {
12
+ "diagnostics": { "noConsoleErrors": true, "noNetworkErrors": true, "runtimeReady": true },
13
+ "performance": {},
14
+ "resources": [{ "id": "GameState", "path": "score", "gte": 1, "changed": true }]
15
+ }
16
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "starter-respawn",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "steps": [
9
+ {
10
+ "kind": "input",
11
+ "label": "run-off-world",
12
+ "press": "ArrowRight",
13
+ "holdTicks": 240,
14
+ "release": true
15
+ },
16
+ { "kind": "wait", "label": "respawn", "waitTicks": 90, "release": true }
17
+ ],
18
+ "assert": {
19
+ "diagnostics": { "noConsoleErrors": true, "noNetworkErrors": true, "runtimeReady": true },
20
+ "movement": {
21
+ "entity": "player",
22
+ "pathLength": 4,
23
+ "reachesPositionWithin": { "position": [-2, 0.5, 0], "maxDistance": 0.35 }
24
+ },
25
+ "resources": [{ "id": "GameState", "path": "respawns", "gte": 1, "changed": true }],
26
+ "visibility": [{ "entity": "player", "minProjectedPixels": 20 }]
27
+ }
28
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "starter-react-restart",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "steps": [
9
+ {
10
+ "kind": "input",
11
+ "label": "collected",
12
+ "press": "ArrowRight",
13
+ "holdTicks": 100,
14
+ "release": true
15
+ },
16
+ { "kind": "input", "label": "focus-pause", "press": "Tab", "holdTicks": 1, "release": true },
17
+ { "kind": "input", "label": "focus-restart", "press": "Tab", "holdTicks": 1, "release": true },
18
+ { "kind": "input", "label": "restarted", "press": "Enter", "holdTicks": 1, "release": true }
19
+ ],
20
+ "assert": {
21
+ "diagnostics": { "noConsoleErrors": true, "noNetworkErrors": true, "runtimeReady": true },
22
+ "resources": [
23
+ {
24
+ "id": "GameState",
25
+ "path": "score",
26
+ "atSteps": [{ "label": "collected", "equals": 1 }, { "label": "restarted", "equals": 0 }]
27
+ },
28
+ {
29
+ "id": "GameState",
30
+ "path": "entityCount",
31
+ "atSteps": [{ "label": "collected", "equals": 2 }, { "label": "restarted", "equals": 3 }]
32
+ }
33
+ ],
34
+ "visibility": [{ "entity": "player", "minProjectedPixels": 20 }]
35
+ }
36
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "seed",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "artifacts": { "runtimeTrace": true },
9
+ "steps": [{ "kind": "wait", "label": "seeded-level", "waitTicks": 60, "release": true }],
10
+ "assert": {
11
+ "diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
12
+ "resources": [
13
+ { "id": "GameState", "path": "levelX", "allowTrivial": true, "equals": -0.6056551518850029 }
14
+ ],
15
+ "world": { "seed": 90210 },
16
+ "visibility": [{ "entity": "player", "minProjectedPixels": 1 }]
17
+ }
18
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "survives",
3
+ "target": "web",
4
+ "schemaVersion": 1,
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "steps": [
9
+ { "kind": "input", "label": "move", "press": "ArrowUp", "holdTicks": 60, "release": true },
10
+ { "kind": "wait", "label": "settle", "waitTicks": 10, "release": true }
11
+ ],
12
+ "assert": {
13
+ "diagnostics": {
14
+ "noConsoleErrors": true,
15
+ "noNetworkErrors": true,
16
+ "noRuntimeDiagnostics": true,
17
+ "runtimeReady": true
18
+ },
19
+ "movement": { "entity": "player", "minDistance": 0.5 },
20
+ "visual": [
21
+ {
22
+ "region": {
23
+ "x": 0,
24
+ "y": 0,
25
+ "width": 1280,
26
+ "height": 720,
27
+ "minNonblankPixelRatio": 0.01
28
+ }
29
+ }
30
+ ]
31
+ }
32
+ }
File without changes
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
2
+ <rect width="32" height="32" rx="8" fill="#061018" />
3
+ <path d="M8 23 16 6l8 17-8-4-8 4Z" fill="#22d3ee" />
4
+ </svg>
@@ -0,0 +1,34 @@
1
+ import type { ICtx } from "@threenative/core";
2
+ import { CollisionShape3D, type IPhysicsContext, RigidBody3D } from "@threenative/physics";
3
+ import { type Material, Mesh } from "three";
4
+ import { roundedBox } from "../render/shapes.js";
5
+ import type { GameState } from "../state.js";
6
+
7
+ export class Crate {
8
+ readonly mesh: Mesh;
9
+ readonly body: RigidBody3D;
10
+
11
+ constructor(
12
+ ctx: ICtx<GameState, IPhysicsContext>,
13
+ x: number,
14
+ y: number,
15
+ z: number,
16
+ material: Material,
17
+ ) {
18
+ this.mesh = new Mesh(roundedBox(1, 1, 1), material);
19
+ this.mesh.position.set(x, y, z);
20
+ this.mesh.castShadow = true;
21
+ ctx.add(this.mesh);
22
+ this.body = new RigidBody3D({
23
+ mass: 8,
24
+ object: this.mesh,
25
+ physics: ctx.physics,
26
+ shape: CollisionShape3D.fromMesh(this.mesh),
27
+ });
28
+ }
29
+
30
+ dispose(): void {
31
+ this.body.dispose();
32
+ this.mesh.removeFromParent();
33
+ }
34
+ }
@@ -0,0 +1,80 @@
1
+ import type { ICtx } from "@threenative/core";
2
+ import { CharacterBody3D, CollisionShape3D, type IPhysicsContext } from "@threenative/physics";
3
+ import { type Material, Mesh } from "three";
4
+ import { roundedBox } from "../render/shapes.js";
5
+ import type { GameState } from "../state.js";
6
+
7
+ type GameCtx = ICtx<GameState, IPhysicsContext>;
8
+
9
+ // Tune these two timers for jump feel; they forgive a late or early button press.
10
+ const COYOTE_TIME = 0.12;
11
+ const JUMP_BUFFER = 0.14;
12
+ const JUMP_SPEED = 5;
13
+ const MOVE_SPEED = 2;
14
+ const SPAWN = { x: -2, y: 0.5, z: 0 } as const;
15
+
16
+ export class Player {
17
+ readonly mesh: Mesh;
18
+ readonly body: CharacterBody3D;
19
+ #coyoteTime = 0;
20
+ #jumpBuffer = 0;
21
+ #jumps = 0;
22
+ #coyoteJumps = 0;
23
+
24
+ constructor(
25
+ ctx: GameCtx,
26
+ material: Material,
27
+ spawn: { readonly x: number; readonly y: number; readonly z: number } = SPAWN,
28
+ ) {
29
+ this.mesh = new Mesh(roundedBox(0.6, 1, 0.6), material);
30
+ this.mesh.position.set(spawn.x, spawn.y, spawn.z);
31
+ this.mesh.castShadow = true;
32
+ ctx.add(this.mesh);
33
+ this.body = new CharacterBody3D({
34
+ autostep: { maxHeight: 0.4, minWidth: 0.2 },
35
+ object: this.mesh,
36
+ physics: ctx.physics,
37
+ shape: CollisionShape3D.capsule(0.2, 0.3),
38
+ });
39
+ }
40
+
41
+ update(ctx: GameCtx, dt: number): void {
42
+ const grounded = this.body.grounded;
43
+ this.#coyoteTime = Math.max(0, this.#coyoteTime - dt);
44
+ this.#jumpBuffer = Math.max(0, this.#jumpBuffer - dt);
45
+ if (grounded) this.#coyoteTime = COYOTE_TIME;
46
+ if (ctx.input.justPressed("jump")) this.#jumpBuffer = JUMP_BUFFER;
47
+ if (this.#jumpBuffer > 0 && this.#coyoteTime > 0) {
48
+ this.body.velocity.y = JUMP_SPEED;
49
+ this.#jumpBuffer = 0;
50
+ this.#coyoteTime = 0;
51
+ this.#jumps += 1;
52
+ if (!grounded) this.#coyoteJumps += 1;
53
+ }
54
+ const move = ctx.input.vector("move");
55
+ this.body.velocity.x = move.x * MOVE_SPEED;
56
+ this.body.velocity.z = -move.y * MOVE_SPEED;
57
+ this.body.moveAndSlide(dt);
58
+ if (this.body.grounded) this.#coyoteTime = COYOTE_TIME;
59
+ }
60
+
61
+ respawn(): void {
62
+ this.body.teleport(SPAWN);
63
+ this.#coyoteTime = 0;
64
+ this.#jumpBuffer = 0;
65
+ }
66
+
67
+ debug(): { coyoteJumps: number; grounded: boolean; jumps: number; position: number[] } {
68
+ return {
69
+ coyoteJumps: this.#coyoteJumps,
70
+ grounded: this.body.grounded,
71
+ jumps: this.#jumps,
72
+ position: this.mesh.position.toArray(),
73
+ };
74
+ }
75
+
76
+ dispose(): void {
77
+ this.body.dispose();
78
+ this.mesh.removeFromParent();
79
+ }
80
+ }
@@ -0,0 +1,30 @@
1
+ import { defineGame, replay } from "@threenative/core";
2
+ import { playtest } from "@threenative/core/playtest";
3
+ import type { IPhysicsContext } from "@threenative/physics";
4
+ import { rapier } from "@threenative/physics";
5
+ import config from "../threenative.config.js";
6
+ import { Play } from "./scenes/Play.js";
7
+ import type { GameState } from "./state.js";
8
+
9
+ // game.state is the single store: the fixed-step loop writes it, and React/playtests read it.
10
+ const game = defineGame<GameState, IPhysicsContext>({
11
+ input: {
12
+ // The four directions of `input.vector("move")`. Declared rather than inherited from the
13
+ // default binding, so the axis every scene reads is visible where the game is defined.
14
+ move: {
15
+ down: ["ArrowDown", "KeyS"],
16
+ left: ["ArrowLeft", "KeyA"],
17
+ right: ["ArrowRight", "KeyD"],
18
+ up: ["ArrowUp", "KeyW"],
19
+ },
20
+ jump: { buttons: [0], keys: ["Space"] },
21
+ restart: { keys: ["KeyR"] },
22
+ },
23
+ plugins: [rapier(), replay(), playtest()],
24
+ render: config.renderer,
25
+ scenes: { play: Play },
26
+ seed: 90210,
27
+ start: "play",
28
+ });
29
+
30
+ export default game;
@@ -0,0 +1,15 @@
1
+ import { acceptHotUpdate } from "@threenative/core/hot";
2
+ import { createElement } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import game from "./game.js";
5
+ import { App } from "./ui/App.js";
6
+ import "./style.css";
7
+
8
+ import.meta.hot?.accept();
9
+ acceptHotUpdate(game, import.meta.hot);
10
+ const root = document.getElementById("root");
11
+ if (root === null) throw new Error("Missing #root element.");
12
+ const appRoot = root as typeof root & { __threenativeRoot?: ReturnType<typeof createRoot> };
13
+ const reactRoot = appRoot.__threenativeRoot ?? createRoot(appRoot);
14
+ appRoot.__threenativeRoot = reactRoot;
15
+ reactRoot.render(createElement(App, { game }));
@@ -0,0 +1,57 @@
1
+ // Generated for you. This is ordinary Three.js — edit or delete it freely.
2
+ // ThreeNative does not read this file.
3
+ //
4
+ // A spring arm, after Godot's SpringArm3D: the camera trails an anchor on a
5
+ // damped spring instead of being assigned its position every frame. A plain
6
+ // `camera.position.lerp(target, 0.1)` is framerate-dependent and reads as
7
+ // rubber-banding; the exponential below is stable at any dt.
8
+ //
9
+ // Camera framing is one of the loudest things in a screenshot, so it lives
10
+ // here in your repo rather than behind a framework option.
11
+ import type { PerspectiveCamera, Vector3 } from "three";
12
+ import { Vector3 as Vec3 } from "three";
13
+
14
+ export interface ISpringArmOptions {
15
+ /** Where the camera sits relative to its target, before smoothing. */
16
+ readonly offset?: Vector3;
17
+ /** How far ahead of the target the camera looks. Lead the action. */
18
+ readonly lookAhead?: Vector3;
19
+ /** Seconds for the arm to close most of the distance. Higher trails more. */
20
+ readonly damping?: number;
21
+ }
22
+
23
+ export interface ISpringArm {
24
+ /** Call once per frame from `update(dt)`. */
25
+ readonly follow: (target: Vector3, dt: number) => void;
26
+ /** Jump the camera to its resting pose — use on spawn and respawn. */
27
+ readonly snap: (target: Vector3) => void;
28
+ }
29
+
30
+ export function createSpringArm(
31
+ camera: PerspectiveCamera,
32
+ options: ISpringArmOptions = {},
33
+ ): ISpringArm {
34
+ // Keep the starter's target-relative distance below the 9.5-unit look budget
35
+ // so the player and nearby route stay readable after the camera settles.
36
+ const offset = options.offset ?? new Vec3(0, 4.2, 8.45);
37
+ const lookAhead = options.lookAhead ?? new Vec3(0, 1, 0);
38
+ const damping = options.damping ?? 0.18;
39
+
40
+ const desired = new Vec3();
41
+ const aim = new Vec3();
42
+
43
+ const snap = (target: Vector3): void => {
44
+ camera.position.copy(target).add(offset);
45
+ camera.lookAt(aim.copy(target).add(lookAhead));
46
+ };
47
+
48
+ const follow = (target: Vector3, dt: number): void => {
49
+ desired.copy(target).add(offset);
50
+ // 1 - e^(-dt/damping): the frame-rate-independent form of a lerp. At 30fps
51
+ // and 120fps the camera ends up in the same place after the same second.
52
+ camera.position.lerp(desired, 1 - Math.exp(-dt / damping));
53
+ camera.lookAt(aim.copy(target).add(lookAhead));
54
+ };
55
+
56
+ return { follow, snap };
57
+ }
@@ -0,0 +1,55 @@
1
+ // Generated for you. This is ordinary Three.js — edit or delete it freely.
2
+ // ThreeNative does not read this file.
3
+ //
4
+ // Four lights, and the fourth is the one people forget: a cool rim from behind
5
+ // so silhouettes separate from the background instead of reading as flat
6
+ // cut-outs. Key + bounce + ambient gets you a lit scene; the rim is what makes
7
+ // it look shaded.
8
+ import {
9
+ AmbientLight,
10
+ DirectionalLight,
11
+ HemisphereLight,
12
+ PCFSoftShadowMap,
13
+ type Scene,
14
+ } from "three";
15
+ import { palette } from "./palette.js";
16
+
17
+ type ShadowRenderer = { shadowMap: { enabled: boolean; type: number } };
18
+
19
+ export function setupLighting(scene: Scene, renderer: ShadowRenderer): void {
20
+ renderer.shadowMap.enabled = true;
21
+ renderer.shadowMap.type = PCFSoftShadowMap;
22
+
23
+ // Sky above, ground bounce below. Tint the second colour toward whatever the
24
+ // floor actually is — it is the cheapest realism in the whole rig.
25
+ scene.add(new HemisphereLight(palette.skyHigh, palette.skyLow, 1.6));
26
+
27
+ const key = new DirectionalLight(palette.accent, 3);
28
+ key.position.set(4, 7, 3);
29
+ key.castShadow = true;
30
+ // 1024² is one quarter of a 2048² map's texel storage and fill work while
31
+ // retaining enough resolution for this small authored route. Increase it
32
+ // only when a larger level makes the 18-unit camera extent visibly soft.
33
+ key.shadow.mapSize.set(1024, 1024);
34
+ key.shadow.camera.near = 0.5;
35
+ key.shadow.camera.far = 60;
36
+ // A shadow camera tight enough to stay crisp cannot also cover a big level;
37
+ // this extent matches the generated route. Widen it, or move the light with
38
+ // the player, when the world grows.
39
+ const extent = 18;
40
+ key.shadow.camera.left = -extent;
41
+ key.shadow.camera.right = extent;
42
+ key.shadow.camera.top = extent;
43
+ key.shadow.camera.bottom = -extent;
44
+ key.shadow.bias = -0.0008;
45
+ // Rounded geometry self-shadows at grazing angles without this, and the bias
46
+ // alone would have to grow big enough to detach contact shadows.
47
+ key.shadow.normalBias = 0.03;
48
+ scene.add(key);
49
+
50
+ const rim = new DirectionalLight(palette.player, 0.75);
51
+ rim.position.set(-5, 3, -6);
52
+ scene.add(rim);
53
+
54
+ scene.add(new AmbientLight(palette.skyLow, 0.28));
55
+ }
@@ -0,0 +1,12 @@
1
+ // Generated for you. This is ordinary Three.js — edit or delete it freely.
2
+ // ThreeNative does not read this file.
3
+ import { MeshStandardMaterial } from "three";
4
+ import { palette } from "./palette.js";
5
+
6
+ export function createMaterials() {
7
+ return {
8
+ floor: new MeshStandardMaterial({ color: palette.floor, roughness: 0.78, metalness: 0.12 }),
9
+ player: new MeshStandardMaterial({ color: palette.player, roughness: 0.42, metalness: 0.22 }),
10
+ crate: new MeshStandardMaterial({ color: palette.crate, roughness: 0.8, metalness: 0 }),
11
+ };
12
+ }
@@ -0,0 +1,9 @@
1
+ // Generated for you. Keep the six palette roles coherent when you change the look.
2
+ export const palette = {
3
+ skyHigh: 0x12324a,
4
+ skyLow: 0x071018,
5
+ floor: 0x12384a,
6
+ player: 0x6fe8ff,
7
+ crate: 0xffb86b,
8
+ accent: 0xffd27a,
9
+ } as const;
@@ -0,0 +1,18 @@
1
+ // Generated for you: ordinary Three.js; ThreeNative does not read this file.
2
+ import { ACESFilmicToneMapping, type Camera, type Scene } from "three";
3
+ import { bloom } from "three/addons/tsl/display/BloomNode.js";
4
+ import { pass } from "three/tsl";
5
+ type OutputRenderer = {
6
+ kind: string;
7
+ raw: unknown;
8
+ setOutputNode(node: unknown): void;
9
+ };
10
+
11
+ export function setupPost(renderer: OutputRenderer, scene: Scene, camera: Camera): void {
12
+ const raw = renderer.raw as { toneMapping?: number; toneMappingExposure?: number };
13
+ raw.toneMapping = ACESFilmicToneMapping;
14
+ raw.toneMappingExposure = 1.15;
15
+ if (renderer.kind !== "webgpu") return;
16
+ const colour = pass(scene, camera).getTextureNode();
17
+ renderer.setOutputNode(colour.add(bloom(colour, 0.7, 0.5, 0.2)));
18
+ }