threedog 0.0.0-stage → 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 (506) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -2
  4. package/core/Animator.js +268 -0
  5. package/core/Assets.js +256 -0
  6. package/core/Audio.js +267 -0
  7. package/core/Baked.js +72 -0
  8. package/core/Batching.js +247 -0
  9. package/core/Budget.js +221 -0
  10. package/core/Clock.js +94 -0
  11. package/core/Commits.js +77 -0
  12. package/core/DebugOverrides.js +143 -0
  13. package/core/Describe.js +145 -0
  14. package/core/Engine.js +184 -0
  15. package/core/Events.js +153 -0
  16. package/core/I18n.js +94 -0
  17. package/core/Input.js +245 -0
  18. package/core/Inspect.js +77 -0
  19. package/core/InspectScene.js +191 -0
  20. package/core/Jobs.js +146 -0
  21. package/core/Loading.js +149 -0
  22. package/core/MaterialInfo.js +32 -0
  23. package/core/Ops.js +256 -0
  24. package/core/Random.js +52 -0
  25. package/core/Rays.js +160 -0
  26. package/core/SaveStore.js +85 -0
  27. package/core/Saves.js +254 -0
  28. package/core/Stream.js +279 -0
  29. package/core/Threads.js +158 -0
  30. package/core/UrlState.js +94 -0
  31. package/core/Vars.js +35 -0
  32. package/core/Views.js +49 -0
  33. package/core/actor.js +23 -0
  34. package/core/assetEntry.js +89 -0
  35. package/core/assetLoad.js +190 -0
  36. package/core/assetManifest.js +35 -0
  37. package/core/assetReport.js +83 -0
  38. package/core/audioRules.js +121 -0
  39. package/core/audioVoice.js +225 -0
  40. package/core/batchGroups.js +116 -0
  41. package/core/canvasBox.js +63 -0
  42. package/core/catalog.js +169 -0
  43. package/core/checks.js +67 -0
  44. package/core/claims.js +51 -0
  45. package/core/dayTime.js +15 -0
  46. package/core/debugView.js +76 -0
  47. package/core/describeRender.js +45 -0
  48. package/core/describeText.js +143 -0
  49. package/core/easing.js +34 -0
  50. package/core/errorCodes.js +205 -0
  51. package/core/errorHints.js +208 -0
  52. package/core/errors.js +40 -0
  53. package/core/events.generated.js +84 -0
  54. package/core/ground.js +102 -0
  55. package/core/holds.js +106 -0
  56. package/core/inputContext.js +69 -0
  57. package/core/inputDefaults.js +22 -0
  58. package/core/inputPad.js +35 -0
  59. package/core/inputPointer.js +48 -0
  60. package/core/inputTouch.js +48 -0
  61. package/core/lifecycle.js +69 -0
  62. package/core/lightWatch.js +56 -0
  63. package/core/look/coreParts.js +112 -0
  64. package/core/look/layers.js +136 -0
  65. package/core/look/part.js +173 -0
  66. package/core/look/report.js +79 -0
  67. package/core/look/write.js +86 -0
  68. package/core/loop.js +200 -0
  69. package/core/math.js +33 -0
  70. package/core/modules.js +196 -0
  71. package/core/movement.js +19 -0
  72. package/core/mulberry32.js +14 -0
  73. package/core/opsAtomic.js +31 -0
  74. package/core/opsCheck.js +97 -0
  75. package/core/opsFail.js +20 -0
  76. package/core/opsGuard.js +26 -0
  77. package/core/opsHistory.js +27 -0
  78. package/core/opsRun.js +77 -0
  79. package/core/page.js +78 -0
  80. package/core/params.js +132 -0
  81. package/core/pureWorker.js +5 -0
  82. package/core/renamed.js +21 -0
  83. package/core/saveApply.js +128 -0
  84. package/core/saveFiles.js +139 -0
  85. package/core/saveIds.js +53 -0
  86. package/core/saveVersions.js +97 -0
  87. package/core/scatter.js +92 -0
  88. package/core/sceneMethods.js +100 -0
  89. package/core/screenToGround.js +39 -0
  90. package/core/services.js +73 -0
  91. package/core/session.js +171 -0
  92. package/core/shadowTypes.js +15 -0
  93. package/core/skip.js +104 -0
  94. package/core/startup.js +135 -0
  95. package/core/streamCells.js +24 -0
  96. package/core/streamSources.js +73 -0
  97. package/core/styleParts.js +96 -0
  98. package/core/targeting.js +64 -0
  99. package/core/thingExplain.js +68 -0
  100. package/core/thingOps.js +168 -0
  101. package/core/things.js +212 -0
  102. package/core/threadPure.js +120 -0
  103. package/core/threadServe.js +25 -0
  104. package/core/tier.js +11 -0
  105. package/core/util.js +11 -0
  106. package/core/validate.js +204 -0
  107. package/docs/AI.md +123 -0
  108. package/docs/API.md +83 -0
  109. package/docs/CODEMAP.md +347 -0
  110. package/docs/COMMANDS.md +108 -0
  111. package/docs/CONVENTIONS.md +145 -0
  112. package/docs/PERF.md +217 -0
  113. package/docs/THREE.md +86 -0
  114. package/docs/api/ambience.md +15 -0
  115. package/docs/api/assets.md +62 -0
  116. package/docs/api/audio.md +53 -0
  117. package/docs/api/budget.md +40 -0
  118. package/docs/api/cameraRig.md +120 -0
  119. package/docs/api/characters.md +144 -0
  120. package/docs/api/clock.md +7 -0
  121. package/docs/api/collision.md +39 -0
  122. package/docs/api/content.md +64 -0
  123. package/docs/api/dialogue.md +39 -0
  124. package/docs/api/engine.md +199 -0
  125. package/docs/api/entities.md +61 -0
  126. package/docs/api/events.md +95 -0
  127. package/docs/api/flow.md +27 -0
  128. package/docs/api/grids.md +11 -0
  129. package/docs/api/ground.md +16 -0
  130. package/docs/api/hlod.md +34 -0
  131. package/docs/api/hud.md +31 -0
  132. package/docs/api/i18n.md +10 -0
  133. package/docs/api/input.md +24 -0
  134. package/docs/api/interactions.md +31 -0
  135. package/docs/api/inventory.md +66 -0
  136. package/docs/api/jobs.md +10 -0
  137. package/docs/api/level.md +41 -0
  138. package/docs/api/lightPool.md +56 -0
  139. package/docs/api/music.md +34 -0
  140. package/docs/api/nav.md +26 -0
  141. package/docs/api/net.md +14 -0
  142. package/docs/api/openWorld.md +24 -0
  143. package/docs/api/particles.md +41 -0
  144. package/docs/api/photo.md +15 -0
  145. package/docs/api/post.md +10 -0
  146. package/docs/api/quests.md +36 -0
  147. package/docs/api/rays.md +26 -0
  148. package/docs/api/rigid.md +84 -0
  149. package/docs/api/saves.md +32 -0
  150. package/docs/api/settings.md +36 -0
  151. package/docs/api/sky.md +58 -0
  152. package/docs/api/stream.md +31 -0
  153. package/docs/api/style.md +134 -0
  154. package/docs/api/terrain.md +34 -0
  155. package/docs/api/timeline.md +39 -0
  156. package/docs/api/tools.md +57 -0
  157. package/docs/api/triggers.md +56 -0
  158. package/docs/api/vars.md +9 -0
  159. package/docs/api/vegetation.md +52 -0
  160. package/docs/api/water.md +48 -0
  161. package/docs/api/weather.md +29 -0
  162. package/docs/api/world.md +30 -0
  163. package/docs/recipes/01-new-game.md +148 -0
  164. package/docs/recipes/02-npc.md +167 -0
  165. package/docs/recipes/03-items-pickups.md +158 -0
  166. package/docs/recipes/04-quests.md +83 -0
  167. package/docs/recipes/05-props-bake.md +159 -0
  168. package/docs/recipes/06-clock-events.md +117 -0
  169. package/docs/recipes/07-flow-scenes-pause.md +132 -0
  170. package/docs/recipes/08-weather-sky.md +74 -0
  171. package/docs/recipes/09-style-pack.md +234 -0
  172. package/docs/recipes/10-blender-level.md +67 -0
  173. package/docs/recipes/11-vehicles.md +55 -0
  174. package/docs/recipes/12-navmesh.md +79 -0
  175. package/docs/recipes/13-animation.md +149 -0
  176. package/docs/recipes/14-custom-module.md +91 -0
  177. package/docs/recipes/15-perf.md +78 -0
  178. package/docs/recipes/16-dev-bridge.md +180 -0
  179. package/docs/recipes/18-world.md +185 -0
  180. package/docs/recipes/19-shooting-picking.md +76 -0
  181. package/docs/recipes/20-content-actions-save.md +176 -0
  182. package/docs/recipes/21-camera.md +153 -0
  183. package/docs/recipes/22-shop-gold.md +107 -0
  184. package/docs/recipes/23-ops.md +175 -0
  185. package/docs/recipes/26-ui-parts.md +138 -0
  186. package/docs/recipes/27-net.md +96 -0
  187. package/docs/recipes/28-terrain.md +80 -0
  188. package/docs/recipes/29-grid.md +87 -0
  189. package/docs/recipes/30-templates.md +131 -0
  190. package/docs/recipes/31-audio.md +126 -0
  191. package/docs/recipes/32-action-game.md +33 -0
  192. package/docs/recipes/33-stream-sources.md +37 -0
  193. package/docs/recipes/34-environment-lighting.md +36 -0
  194. package/docs/recipes/35-style-from-reference.md +89 -0
  195. package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
  196. package/docs/recipes/37-terrain-look-hooks.md +97 -0
  197. package/docs/recipes/38-environment-look-hooks.md +83 -0
  198. package/docs/recipes/40-scene.md +108 -0
  199. package/docs/recipes/41-thing-registry.md +93 -0
  200. package/docs/recipes/42-terrain-shape.md +64 -0
  201. package/docs/recipes/43-shader-patches-surface-looks.md +120 -0
  202. package/docs/recipes/44-water-weather-look-hooks.md +135 -0
  203. package/docs/recipes/45-cascaded-shadows.md +51 -0
  204. package/docs/recipes/46-blender-art-route.md +114 -0
  205. package/docs/recipes/47-island-snow-backdrop.md +44 -0
  206. package/docs/recipes/48-make-material.md +70 -0
  207. package/docs/recipes/49-game-module-contract.md +71 -0
  208. package/docs/recipes/50-own-renderer.md +12 -0
  209. package/docs/recipes/51-capability-catalog.md +63 -0
  210. package/docs/recipes/52-look.md +108 -0
  211. package/examples/action/DESIGN.md +3 -0
  212. package/examples/action/GAMEMAP.md +127 -0
  213. package/examples/action/content/actions.js +8 -0
  214. package/examples/action/content/audio.js +9 -0
  215. package/examples/action/content/index.js +10 -0
  216. package/examples/action/content/items.js +4 -0
  217. package/examples/action/content/places.js +4 -0
  218. package/examples/action/content/props.js +11 -0
  219. package/examples/action/content/templates.js +10 -0
  220. package/examples/action/content/views.js +6 -0
  221. package/examples/action/look.js +5 -0
  222. package/examples/action/main.js +137 -0
  223. package/examples/action/models.js +25 -0
  224. package/examples/sheepisland/GAMEMAP.md +107 -0
  225. package/examples/sheepisland/content/index.js +6 -0
  226. package/examples/sheepisland/content/props.js +19 -0
  227. package/examples/sheepisland/content/templates.js +5 -0
  228. package/examples/sheepisland/content/vegetation.js +8 -0
  229. package/examples/sheepisland/main.js +71 -0
  230. package/examples/sheepisland/params.js +25 -0
  231. package/examples/sheepisland/style/index.js +79 -0
  232. package/examples/sheepisland/style/models.js +59 -0
  233. package/examples/sheepisland/views.js +9 -0
  234. package/examples/styletest/GAMEMAP.md +135 -0
  235. package/examples/styletest/content/index.js +9 -0
  236. package/examples/styletest/content/items.js +8 -0
  237. package/examples/styletest/content/npcs.js +8 -0
  238. package/examples/styletest/content/places.js +5 -0
  239. package/examples/styletest/content/props.js +16 -0
  240. package/examples/styletest/content/templates.js +9 -0
  241. package/examples/styletest/content/vegetation.js +31 -0
  242. package/examples/styletest/look.js +11 -0
  243. package/examples/styletest/main.js +95 -0
  244. package/examples/styletest/models.js +87 -0
  245. package/examples/styletest/overrides.js +33 -0
  246. package/examples/styletest/panel.js +135 -0
  247. package/examples/styletest/params.js +32 -0
  248. package/examples/styletest/views.js +31 -0
  249. package/examples/world/DESIGN.md +5 -0
  250. package/examples/world/GAMEMAP.md +171 -0
  251. package/examples/world/content/actions.js +8 -0
  252. package/examples/world/content/audio.js +25 -0
  253. package/examples/world/content/bodies.js +12 -0
  254. package/examples/world/content/containers.js +4 -0
  255. package/examples/world/content/dialogues.js +33 -0
  256. package/examples/world/content/index.js +17 -0
  257. package/examples/world/content/items.js +10 -0
  258. package/examples/world/content/npcs.js +14 -0
  259. package/examples/world/content/pickups.js +11 -0
  260. package/examples/world/content/places.js +6 -0
  261. package/examples/world/content/props.js +12 -0
  262. package/examples/world/content/quests.js +15 -0
  263. package/examples/world/content/rules.js +23 -0
  264. package/examples/world/content/templates.js +5 -0
  265. package/examples/world/content/vegetation.js +32 -0
  266. package/examples/world/main.js +168 -0
  267. package/examples/world/models.js +28 -0
  268. package/index.d.ts +306 -0
  269. package/index.js +122 -0
  270. package/llms.txt +61 -0
  271. package/modules/ambience/Ambience.js +186 -0
  272. package/modules/camera/FirstPersonCamera.js +131 -0
  273. package/modules/camera/FixedCamera.js +162 -0
  274. package/modules/camera/FollowCamera.js +91 -0
  275. package/modules/camera/RtsCamera.js +132 -0
  276. package/modules/camera/common.js +182 -0
  277. package/modules/camera/index.js +11 -0
  278. package/modules/camera/projection.js +34 -0
  279. package/modules/characters/Character.js +235 -0
  280. package/modules/characters/NPC.js +242 -0
  281. package/modules/characters/assetModel.js +42 -0
  282. package/modules/characters/astar.js +66 -0
  283. package/modules/characters/behaviors.js +72 -0
  284. package/modules/characters/footsteps.js +13 -0
  285. package/modules/characters/index.js +215 -0
  286. package/modules/characters/moveHelpers.js +29 -0
  287. package/modules/characters/movers/common.js +62 -0
  288. package/modules/characters/movers/rapier.js +74 -0
  289. package/modules/characters/movers/simple.js +43 -0
  290. package/modules/characters/npcAvoid.js +129 -0
  291. package/modules/characters/npcSim.js +150 -0
  292. package/modules/characters/npcView.js +42 -0
  293. package/modules/characters/pathAsync.js +113 -0
  294. package/modules/characters/pathJob.js +62 -0
  295. package/modules/characters/pathWorker.js +7 -0
  296. package/modules/characters/playerStrings.js +12 -0
  297. package/modules/characters/proceduralRig.js +58 -0
  298. package/modules/characters/useModel.js +22 -0
  299. package/modules/characters/walkTo.js +58 -0
  300. package/modules/collision/Collision.js +274 -0
  301. package/modules/collision/grid.js +63 -0
  302. package/modules/content/explain.js +13 -0
  303. package/modules/content/ids.js +95 -0
  304. package/modules/content/index.js +154 -0
  305. package/modules/content/loader.js +190 -0
  306. package/modules/content/models.js +69 -0
  307. package/modules/content/packs.js +69 -0
  308. package/modules/content/props.js +89 -0
  309. package/modules/content/rules.js +134 -0
  310. package/modules/content/templates.js +189 -0
  311. package/modules/debug/DebugPanel.js +174 -0
  312. package/modules/entities/Entities.js +243 -0
  313. package/modules/entities/build.js +25 -0
  314. package/modules/entities/index.js +4 -0
  315. package/modules/flow/index.js +101 -0
  316. package/modules/gameplay/Container.js +227 -0
  317. package/modules/gameplay/Containers.js +89 -0
  318. package/modules/gameplay/Dialogue.js +219 -0
  319. package/modules/gameplay/Interactions.js +253 -0
  320. package/modules/gameplay/Inventory.js +224 -0
  321. package/modules/gameplay/Quests.js +205 -0
  322. package/modules/gameplay/boxOps.js +60 -0
  323. package/modules/gameplay/dialogueBox.js +48 -0
  324. package/modules/gameplay/interactionPrompt.js +28 -0
  325. package/modules/gameplay/inventoryOps.js +137 -0
  326. package/modules/gameplay/pickups.js +115 -0
  327. package/modules/gameplay/questLog.js +54 -0
  328. package/modules/gameplay/questSave.js +71 -0
  329. package/modules/grid/Grid.js +184 -0
  330. package/modules/grid/Layer.js +142 -0
  331. package/modules/grid/index.js +236 -0
  332. package/modules/grid/ops.js +73 -0
  333. package/modules/grid/preview.js +85 -0
  334. package/modules/grid/tiles.js +79 -0
  335. package/modules/hlod/index.js +167 -0
  336. package/modules/hud/index.js +167 -0
  337. package/modules/hud/parts.js +80 -0
  338. package/modules/level/geometry.js +46 -0
  339. package/modules/level/heightfield.js +160 -0
  340. package/modules/level/index.js +233 -0
  341. package/modules/level/nodes.js +84 -0
  342. package/modules/lights/index.js +227 -0
  343. package/modules/music/Music.js +294 -0
  344. package/modules/music/index.js +2 -0
  345. package/modules/music/rules.js +28 -0
  346. package/modules/nav/index.js +156 -0
  347. package/modules/nav/navPath.js +17 -0
  348. package/modules/net/Client.js +137 -0
  349. package/modules/net/Host.js +117 -0
  350. package/modules/net/Net.js +49 -0
  351. package/modules/net/index.js +77 -0
  352. package/modules/net/sync.js +114 -0
  353. package/modules/net/transports.js +118 -0
  354. package/modules/particles/Particles.js +179 -0
  355. package/modules/particles/effect.js +112 -0
  356. package/modules/particles/shaders.js +28 -0
  357. package/modules/photo/Photo.js +146 -0
  358. package/modules/rigid/RigidBodies.js +265 -0
  359. package/modules/rigid/Vehicles.js +97 -0
  360. package/modules/rigid/sync.js +158 -0
  361. package/modules/settings/Settings.js +297 -0
  362. package/modules/settings/apply.js +21 -0
  363. package/modules/settings/index.js +3 -0
  364. package/modules/settings/sections.js +156 -0
  365. package/modules/settings/strings.js +53 -0
  366. package/modules/settings/view.js +65 -0
  367. package/modules/sky/Sky.js +259 -0
  368. package/modules/sky/calendar.js +80 -0
  369. package/modules/sky/cascades.js +125 -0
  370. package/modules/sky/clouds.js +79 -0
  371. package/modules/sky/domeLayers.js +33 -0
  372. package/modules/sky/environment.js +141 -0
  373. package/modules/sky/fog.js +139 -0
  374. package/modules/sky/frame.js +77 -0
  375. package/modules/sky/layers.js +69 -0
  376. package/modules/sky/look.js +51 -0
  377. package/modules/sky/lookFog.js +80 -0
  378. package/modules/sky/lookShadow.js +50 -0
  379. package/modules/sky/lookSky.js +108 -0
  380. package/modules/sky/schedule.js +80 -0
  381. package/modules/sky/shader.js +96 -0
  382. package/modules/sky/shadow.js +74 -0
  383. package/modules/sky/skyModule.js +60 -0
  384. package/modules/terrain/ChunkManager.js +260 -0
  385. package/modules/terrain/chunkJob.js +19 -0
  386. package/modules/terrain/chunkLevels.js +40 -0
  387. package/modules/terrain/chunkQueries.js +42 -0
  388. package/modules/terrain/chunkWorker.js +5 -0
  389. package/modules/terrain/index.js +118 -0
  390. package/modules/terrain/lookGround.js +61 -0
  391. package/modules/terrain/mountTerrain.js +32 -0
  392. package/modules/terrain/terrainColorMap.js +41 -0
  393. package/modules/terrain/terrainDefaults.js +39 -0
  394. package/modules/terrain/terrainEdit.js +139 -0
  395. package/modules/terrain/terrainGen.js +155 -0
  396. package/modules/terrain/terrainIsland.js +131 -0
  397. package/modules/terrain/terrainMesh.js +92 -0
  398. package/modules/terrain/terrainShape.js +108 -0
  399. package/modules/terrain/terrainShapeMain.js +41 -0
  400. package/modules/terrain/terrainTexture.js +44 -0
  401. package/modules/timeline/Timeline.js +253 -0
  402. package/modules/timeline/Tween.js +114 -0
  403. package/modules/timeline/letterbox.js +24 -0
  404. package/modules/timeline/shots.js +90 -0
  405. package/modules/triggers/index.js +268 -0
  406. package/modules/vegetation/Vegetation.js +256 -0
  407. package/modules/vegetation/groundChunks.js +177 -0
  408. package/modules/vegetation/index.js +43 -0
  409. package/modules/vegetation/lookWind.js +37 -0
  410. package/modules/vegetation/modelGeometry.js +21 -0
  411. package/modules/water/Water.js +160 -0
  412. package/modules/water/look.js +80 -0
  413. package/modules/water/surface.js +88 -0
  414. package/modules/weather/Weather.js +242 -0
  415. package/modules/weather/look.js +75 -0
  416. package/modules/weather/particles.js +92 -0
  417. package/modules/weather/shaders.js +49 -0
  418. package/modules/weather/strings.js +15 -0
  419. package/modules/world/World.js +231 -0
  420. package/modules/world/cells.js +42 -0
  421. package/modules/world/explain.js +11 -0
  422. package/modules/world/index.js +71 -0
  423. package/modules/world/persist.js +107 -0
  424. package/modules/world/pos.js +20 -0
  425. package/modules/world/records.js +89 -0
  426. package/modules/world/sim.js +175 -0
  427. package/modules/world/simFar.js +82 -0
  428. package/modules/world/state.js +115 -0
  429. package/modules/world/thingSource.js +44 -0
  430. package/modules/world/views.js +182 -0
  431. package/package.json +66 -4
  432. package/presets.js +96 -0
  433. package/render/PostFX.js +240 -0
  434. package/render/detail.js +105 -0
  435. package/render/effects.js +144 -0
  436. package/render/engineUniforms.js +23 -0
  437. package/render/fuse.js +84 -0
  438. package/render/lighting.js +100 -0
  439. package/render/lights.js +18 -0
  440. package/render/lookSurface.js +161 -0
  441. package/render/materials.js +220 -0
  442. package/render/patches.js +252 -0
  443. package/render/postLook.js +86 -0
  444. package/render/surface.js +69 -0
  445. package/render/uniformDecl.js +29 -0
  446. package/types/common.d.ts +34 -0
  447. package/types/core.d.ts +1965 -0
  448. package/types/gameplay.d.ts +1822 -0
  449. package/types/generated/core/Audio.d.ts +200 -0
  450. package/types/generated/core/Batching.d.ts +47 -0
  451. package/types/generated/core/Budget.d.ts +90 -0
  452. package/types/generated/core/Commits.d.ts +31 -0
  453. package/types/generated/core/DebugOverrides.d.ts +52 -0
  454. package/types/generated/core/Events.d.ts +89 -0
  455. package/types/generated/core/I18n.d.ts +30 -0
  456. package/types/generated/core/Input.d.ts +118 -0
  457. package/types/generated/core/Jobs.d.ts +41 -0
  458. package/types/generated/core/Ops.d.ts +203 -0
  459. package/types/generated/core/Random.d.ts +49 -0
  460. package/types/generated/core/Rays.d.ts +49 -0
  461. package/types/generated/core/Saves.d.ts +162 -0
  462. package/types/generated/core/Stream.d.ts +93 -0
  463. package/types/generated/core/Threads.d.ts +82 -0
  464. package/types/generated/core/Views.d.ts +33 -0
  465. package/types/generated/core/audioVoice.d.ts +47 -0
  466. package/types/generated/core/page.d.ts +18 -0
  467. package/types/generated/core/session.d.ts +48 -0
  468. package/types/generated/modules/ambience/Ambience.d.ts +48 -0
  469. package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
  470. package/types/generated/modules/flow/index.d.ts +10 -0
  471. package/types/generated/modules/grid/Grid.d.ts +151 -0
  472. package/types/generated/modules/grid/Layer.d.ts +65 -0
  473. package/types/generated/modules/grid/index.d.ts +86 -0
  474. package/types/generated/modules/hlod/index.d.ts +11 -0
  475. package/types/generated/modules/hud/index.d.ts +10 -0
  476. package/types/generated/modules/lights/index.d.ts +13 -0
  477. package/types/generated/modules/music/Music.d.ts +111 -0
  478. package/types/generated/modules/net/Net.d.ts +34 -0
  479. package/types/generated/modules/net/index.d.ts +53 -0
  480. package/types/generated/modules/net/transports.d.ts +58 -0
  481. package/types/generated/modules/particles/Particles.d.ts +69 -0
  482. package/types/generated/modules/sky/Sky.d.ts +145 -0
  483. package/types/generated/modules/sky/skyModule.d.ts +10 -0
  484. package/types/generated/modules/timeline/Timeline.d.ts +51 -0
  485. package/types/generated/modules/water/Water.d.ts +29 -0
  486. package/types/generated/modules/weather/Weather.d.ts +62 -0
  487. package/types/generated/modules/world/World.d.ts +242 -0
  488. package/types/generated/modules/world/index.d.ts +15 -0
  489. package/types/generated/render/PostFX.d.ts +125 -0
  490. package/types/generated/render/materials.d.ts +100 -0
  491. package/types/generated/render/patches.d.ts +41 -0
  492. package/types/generated/ui/Focus.d.ts +11 -0
  493. package/types/generated/ui/LoadingScreen.d.ts +2 -0
  494. package/types/generated/ui/UI.d.ts +57 -0
  495. package/types/nav.d.ts +52 -0
  496. package/types/physics.d.ts +592 -0
  497. package/types/style.d.ts +638 -0
  498. package/types/worker.d.ts +11 -0
  499. package/types/world.d.ts +772 -0
  500. package/ui/Focus.js +51 -0
  501. package/ui/LoadingScreen.js +42 -0
  502. package/ui/Parts.js +199 -0
  503. package/ui/UI.js +167 -0
  504. package/ui/defaults.js +85 -0
  505. package/ui/theme.js +124 -0
  506. package/ui/touchPart.js +49 -0
@@ -0,0 +1,108 @@
1
+ # 52 Change any look: `engine.look`
2
+
3
+ Every look part lives at `engine.look.<part>` and is changed with the same verbs. The style pack gives the starting values; the game changes them on top.
4
+
5
+ ```js
6
+ const cave = engine.look.tone.set({ exposure: 0.6 }, { owner: 'cave' }); // only the keys you give; null drops a key
7
+ engine.look.lights.set({ sun: { intensity: 0.5 } }, { owner: 'cave' });
8
+ cave.remove(); // or engine.look.tone.clear('cave'): the style value shows again
9
+ engine.look.env.replace('sky'); // take a part over whole; replace(null) gives it back
10
+ engine.describe().look.tone.exposure; // { value: 0.6, by: 'game:cave', at: 'main.js:12', under: ['style'] }
11
+ engine.catalog('look.tone'); // params with default, why, off; hooks; what replace accepts and loses
12
+ ```
13
+
14
+ - Layers, upper wins: engine default < style < game (each owner; the last one written wins) < `engine.debug.override(owner, 'look.<part>', values)`.
15
+ - `set` / `patch(name, glsl)` / `replace(impl)`: a part offers only the verbs that make sense for it; the others throw with the verb to use. A part whose verb takes other arguments (`materials.replace(role, impl)`) lists the call shape in `engine.catalog('look.<part>').signatures`, and a wrong call quotes it.
16
+ - `by` in describe is `'engine'`, `'style'`, `'game'` (owner `'game'`), `'<layer>:<owner>'` (for example game:cave or debug:probe: the layer, then the owner you passed) or `'three'`. `describe().render` keeps only renderer facts; its `by` is the path of the record to read here (`'look.tone.exposure'`).
17
+ - Look changes are not saved: after a load, set them again from your own state.
18
+ - Changing the three.js object directly (`engine.renderer.toneMappingExposure = 2`) still works; describe tags it `three` and you lose the owner and the debug layer.
19
+ - Old calls and names throw `renamed-api` and name the new call: see [Renamed in 0.2](#renamed-in-02).
20
+ - Your own module's part: `defineLookPart(engine, { id, params, style, apply })`. Every param declares `default`; a default that changes the picture declares `why` and `off`, or `neutral: true` (checked by `npm run check`; R36 checks that the part's `Look<Part>` type lists the same keys). A part author changes records only through the part's methods `write`, `ownerValue`, `extend`, `retract`, `has`, `resolved`, `restyle` (rule R25 flags `part._...`); `validate(key, value)` in the spec rejects a value before anything is written, and an `apply` that throws leaves no layer behind.
21
+
22
+ ## Atmosphere parts (sky module): fog, sky, shadow
23
+
24
+ ```js
25
+ engine.look.fog.set({ far: 220, color: '#9bb' }, { owner: 'cave' }); // kind, color, density, near, far, height, falloff, enabled
26
+ engine.look.fog.replace('manual'); // or a THREE.Fog: the sky stops writing scene.fog; replace(null) gives it back
27
+ engine.look.sky.set({ clouds: { coverage: 0.7, speed: [0.01, 0] }, backdrop: 0x335577 });
28
+ engine.look.sky.patch('layer:aurora', { glsl: '...threedogSkyLayer...', blend: 'add' }); // a named dome layer; patch('layer:aurora', null) removes it
29
+ engine.look.sky.patch('clouds', glsl); // the cloud function; replace(skyboxName | Texture | Object3D) swaps the dome
30
+ engine.look.shadow.set({ type: 'vsm', radius: 3, cascades: 3, maxFar: 150 }); // set only
31
+ ```
32
+
33
+ - `fog` shows `enabled` and `far` (fog reaches full strength at `engine.fogFar`, starting at 0.3 x that) as the visible defaults; turn off with `set({ enabled: false })`. Color, density, near, far, enabled and linear <-> exp2 are live. Kind `'exp'` / `'height'`, `height`, `falloff` and the `'fog'` hook replace three's shared fog shader chunks, so they only work before the first frame (style, `sky({ fog })`, or right after `createEngine`); later they throw and say so.
34
+ - `sky`: `clouds.*` are live uniforms of the dome (they only draw when `clouds.coverage` > 0). A hook change recompiles the dome material once. Style `layers` arrays are named by their `name` key, else `layer0`, `layer1`.
35
+ - `shadow`: no `patch` (the cascade patch is internal) and no `replace` (to own the shadows, light with your own lights: `sky({ sun: false })`).
36
+
37
+ ## Surface parts: `materials`, `surface`, `ground`, `wind`
38
+
39
+ A change to these parts reaches the materials made **after** it, with one exception: `look.materials.set` of the plain properties `color`, `emissive`, `emissiveIntensity`, `roughness`, `metalness`, `opacity`, `envMapIntensity`, `shininess` and `specular` also changes the materials already made for that role (no recompile; clearing the layer goes back to the style's value). Shader-changing keys (`type`, `steps`, `ramp`, `soften`, `repeat`, `wrap`, `detail`, `lighting`, `patch`, `replace`) and all of `look.surface` are for new materials only (a Material already handed out, or cloned by your game, is not touched; catalog and describe say so as `appliesTo`, and a debug override warns). `engine.look.<part>.object` is the three.js object behind a part; for `materials` it is a function: `engine.look.materials.object('wool')` is the last Material made for that role, `object()` all of them.
40
+
41
+ ```js
42
+ const L = engine.look;
43
+ L.materials.set({ wool: { roughness: 0.4, color: 0xf2ece0 } }, { owner: 'shop' }); // merged into style.materials.wool; any role name
44
+ L.materials.patch('dim', { glsl: { fragment: { color_fragment: 'diffuseColor.rgb *= 0.8;' } } }, { roles: ['wool'] }); // a ShaderPatch on those roles
45
+ L.materials.replace('wool', new THREE.MeshMatcapMaterial({ matcap })); // the role is this Material (or (params, purpose, engine) => Material)
46
+ L.surface.set({ lighting: { wrap: 0.3, shadowTint: { color: '#4a5a9a', strength: 0.5 } }, detail: { noise: 'grain', strength: 0.15 } });
47
+ L.surface.set({ ramp: [0.35, 0.7, 1], soften: 0.2 }); // every toon material's ramp
48
+ L.surface.patch('lighting', glsl); // your threedogLighting(...), see recipe 43
49
+ L.ground.set({ shading: 'flat', colors: { grass: '#7cc06b' } }); // colors / biomeColors / steep / variation / shading rebuild the chunks
50
+ L.ground.set({ detail: { noise: 'paper', scale: 0.4, strength: 0.25 } }); // detail layer on the ground (style.terrain.detail)
51
+ L.ground.replace((e) => myGroundMaterial(e)); // Material or (engine) => Material; replace(null) gives it back
52
+ L.wind.set({ frequency: 1.5, amplitude: 0.5 }); // live on every plant, planted ones too
53
+ L.wind.patch('sway', glsl); // threedogWind(...); read when vegetation.add runs, so patch first
54
+ ```
55
+
56
+ - `materials`: `set` / `patch` / `replace` all name a role. `set` merges into spec entries; a role whose style entry is a Material or a function is changed with `replace`. Role names are free: invent new ones (`makeMaterial('lantern-glass')`); the engine only warns on a likely typo of a known role.
57
+ - `surface`: `set` / `patch('lighting' | 'detail', glsl)`; no `replace` (swap a whole material with `materials.replace`). `style.lighting` is the style layer.
58
+ - `ground` (terrain module): `set` / `patch('detail', glsl)` / `replace`. What `terrain({ colors, shading, material })` was given shows as owner `terrain()`.
59
+ - `wind` (vegetation module): `set` / `patch('sway', glsl)`; no `replace`. `style.wind` is the style layer.
60
+ - `set({ role: { key } })` accepts a key `makeMaterial` reads (type, steps, ramp, soften, repeat, wrap, detail, lighting, or a three.js material property); a typo throws.
61
+ - `look.cloudShadow` (cloud shadows, core) stays its own part: its `shadow` is read by every material and by the weather, not only by surfaces.
62
+
63
+ ## Water, weather, post
64
+
65
+ ```js
66
+ engine.look.water.set({ opacity: 0.5, waveHeight: 2 }, { owner: 'storm' }); // live, no recompile
67
+ engine.look.water.set({ foam: { color: 0xffffff }, depthColor: { shallow: 0x88ccdd, deep: 0x003355 } }); // rebuilds the water material once
68
+ engine.look.water.patch('wave', 'float threedogWaterWave(vec3 p, float t) { return sin(p.x + t) * 0.2; }'); // hooks: wave, surface
69
+ engine.look.water.replace((engine, { uniforms, waves, surface }) => myMaterial); // the whole surface (style.water.material)
70
+
71
+ engine.look.weather.set({ 'rain.speed': 10, 'snow.size': 8, 'lightning.brightness': 0.5, overcastColor: '#667' }); // rebuilds that field's particles once
72
+ engine.look.weather.patch('rain.fragment', wholeFragmentShaderText); // rain|snow . vertex|fragment: the WHOLE shader text, not a function
73
+ engine.look.weather.replace({ ash: { shape: 'soft', color: 0x555555 }, rain: { create } }); // = weather.define; null gives the fields back
74
+
75
+ engine.look.post.set({ bloom: { strength: 0.6 }, vignette: false }); // keys: '<effect>.<param>', '<effect>.enabled'
76
+ engine.look.post.patch('tint', { glsl: 'color.rgb *= vec3(1.0, 0.9, 0.8);', slot: 'ldr', order: 5 }); // generates a fuse effect named 'tint'; patch('tint', null) removes it
77
+ engine.look.post.add({ name: 'scan', slot: 'hdr', order: 5, create: (ctx) => myPass }, { owner: 'cave' }); // ONE custom pass; returns { remove() }. Same errors as the chain (duplicate name, second 'scene' pass, depth order) and nothing is added. Tune it with set({ 'scan.<param>': v })
78
+ engine.look.post.replace([bloom(), grain()]); // swaps the whole chain; replace(null) gives the style chain back
79
+ ```
80
+
81
+ - Water: structural keys (`depthColor`, `foam`, the hooks, `replace`) rebuild the shared material once and hand it to every water mesh; the live keys only write a uniform. `water({ opacity: 0.5 })` options are the game layer.
82
+ - Weather: a field the weather table lacks (`snow` in a desert) has no particles; setting it warns once. `replace({ [field]: spec })` holds one object per owner, so list every field you replace in each call; while a field is replaced, `set` on it is ignored.
83
+ - Post: `look.post.set` writes the `game` layer (keys `<effect>.<param>` and `<effect>.enabled`); style effects (bloom, ao ...) are the style layer; `engine.post.get(name)` only reads an effect. MSAA is `engine.post.setAntialias(on)`. Costly effects start off on low-tier devices: `look.post` lists `<effect>.enabled` with `why` and `off`. `postAdd` / `postRemove` stay style-pack parts (they edit the list before the engine exists).
84
+ - `describe().render.post` reads the same records (`by`: style, game, debug).
85
+
86
+ ## sky.modify vs look.lights
87
+
88
+ Two ways to make the light darker or brighter; pick by what you want to keep.
89
+ - `engine.sky.modify('cave', { sun: 0.3, ambient: 0.4, fog: 0.5, tint, tintAmount })` is a **multiplier layer** on what the sky produces each frame (keyframes, weather, season). The time of day keeps moving underneath, layers from different owners multiply, `modify('cave', null)` removes yours, and `sky.modifiers` shows the combined result (read-only). Use it for "darker in the cave" or "ash over the ground" (`groundCover`, `coverAmount`).
90
+ - `engine.look.lights.set({ sun: { intensity: 0.5 } }, { owner: 'cave' })` is an **override layer** on the part's own values: the key you give replaces what the style or the keyframes said, whatever the hour. Use it for "the sun is exactly this".
91
+ ## Renamed in 0.2 (old call → new call)
92
+
93
+ The old calls below now throw `renamed-api` and the message names the new call (the list is `RENAMED` in `core/renamed.js`; rule R39 keeps the old names out of the repo).
94
+
95
+ | Old call | New call |
96
+ |---|---|
97
+ | `engine.setExposure(v)`, `engine.setToneMapping(m)` | `engine.look.tone.set({ exposure: v })`, `engine.look.tone.set({ mapping: m })` |
98
+ | `engine.sky.setShadow(o)` | `engine.look.shadow.set(o)` |
99
+ | `engine.sky.setEnvironment(o)` | `engine.look.env.replace('sky')` then `engine.look.env.set({ intensity, rotation })`; `replace(false)` turns it off |
100
+ | `engine.weather.define(field, spec)` | `engine.look.weather.replace({ [field]: spec })` |
101
+ | `engine.post.add(effect)` | `engine.look.post.add(effect, { owner })` (one pass, returns `{ remove() }`), `engine.look.post.patch(name, { glsl })` (a color effect) or `engine.look.post.replace([...effects])` (the whole chain) |
102
+ | `engine.post.enable(name, on)`, handle `.set` / `.enable` / `.remove` | `engine.look.post.set({ 'bloom.enabled': on })`, `engine.look.post.set({ 'bloom.strength': 0.6 })`; MSAA: `engine.post.setAntialias(on)` |
103
+ | `engine.look.clouds` | `engine.look.cloudShadow` |
104
+ | `engine.cameraOverride = { owner }` | `const cam = engine.takeCamera('owner', { focus })`; `cam.remove()` releases it |
105
+ | `engine.views.define(name, { pos })` | `engine.views.define(name, { position: [x, y, z] })` |
106
+ | failure `result.reason` (`ops.run` / `can` / `undo`) | `result.code` (reading `reason` throws) |
107
+
108
+ Not renamed (still the way to do it): per-call `makeMaterial(role, params)` keys win for that one material; `applyEffects(mat, { patches })` is the low-level form of `look.materials.patch(name, spec, { roles })`; `style.terrain.*`, `style.wind.*` and `style.lighting` are the style layer of `look.ground` / `look.wind` / `look.surface`.
@@ -0,0 +1,3 @@
1
+ - **Combat rules belong to the game, not the engine**: hp, damage, hit arcs, enemy AI, drops and death are this example's ops and fixed-step code in main.js; the engine only supplies records, ops, input, saves and pickups.
2
+ - **The level is content**: the room, the pillars and the slime (with its hp and drop) are templates plus placements with ids in content/; the drop is spawned inside an op when the slime dies.
3
+ - **Death is a choice**: `respawn` (default), `restart` or `gameover`, set in `TUNE.onDeath` or `?death=...`; restart and game over both go through `engine.session.newGame()`.
@@ -0,0 +1,127 @@
1
+ # Game map: action (generated, do not edit by hand)
2
+
3
+ > Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /action.html, entry `main.js`.
4
+ > Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
5
+
6
+ Content: actions 4 · audio 1 · items 1 · places 1 · props 8 (from templates 8) · templates 4 · views 2
7
+
8
+ ## Design decisions (hand-written, from DESIGN.md)
9
+
10
+ - **Combat rules belong to the game, not the engine**: hp, damage, hit arcs, enemy AI, drops and death are this example's ops and fixed-step code in main.js; the engine only supplies records, ops, input, saves and pickups.
11
+ - **The level is content**: the room, the pillars and the slime (with its hp and drop) are templates plus placements with ids in content/; the drop is spawned inside an op when the slime dies.
12
+ - **Death is a choice**: `respawn` (default), `restart` or `gameover`, set in `TUNE.onDeath` or `?death=...`; restart and game over both go through `engine.session.newGame()`.
13
+
14
+ ## Engine modules (engine.use)
15
+
16
+ - createEngine: { style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' }
17
+ - openWorld preset ({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetatio…) → world, sky, collision, characters, settings, debug
18
+ - interactions ({ ...presets.interactions.nearest })
19
+ - inventory ({ ...presets.keys.inventory })
20
+ - content
21
+ - hud
22
+
23
+ ## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
24
+
25
+ - world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
26
+ - sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
27
+ - collision: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/collision.md`
28
+ - characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
29
+ - settings: `node_modules/threedog/docs/recipes/26-ui-parts.md` · `node_modules/threedog/docs/api/settings.md`
30
+ - interactions: `node_modules/threedog/docs/recipes/20-content-actions-save.md` · `node_modules/threedog/docs/api/interactions.md`
31
+ - inventory: `node_modules/threedog/docs/recipes/03-items-pickups.md` · `node_modules/threedog/docs/api/inventory.md`
32
+ - content: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/content.md`
33
+ - hud: `node_modules/threedog/docs/recipes/04-quests.md` · `node_modules/threedog/docs/api/hud.md`
34
+
35
+ Not used yet (check these before writing the system yourself):
36
+
37
+ - quests: goals with steps, conditions and rewards: `quests({ ...presets.keys.quests })` (keys required), content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
38
+ - grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
39
+
40
+ ## Files
41
+
42
+ content/*.js is content data: how to write it in `node_modules/threedog/docs/recipes/` (02-npc, 03-items-pickups, 04-quests, 20-content-actions-save…).
43
+
44
+ | File | Lines | Description |
45
+ |---|---|---|
46
+ | content/actions.js | 9 | |
47
+ | content/audio.js | 10 | |
48
+ | content/index.js | 11 | |
49
+ | content/items.js | 5 | |
50
+ | content/places.js | 5 | |
51
+ | content/props.js | 12 | |
52
+ | content/templates.js | 11 | |
53
+ | content/views.js | 7 | |
54
+ | look.js | 6 | This example's look, as a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, … |
55
+ | main.js | 138 | @ts-check Action example: one room, one player, one slime, one drop. Shows how an action game wires… |
56
+ | models.js | 26 | Models this example builds in code (floor, wall, pillar, enemy), registered by name in main.js and … |
57
+
58
+ ## NPCs (content/npcs.js)
59
+
60
+ (none)
61
+
62
+ ## Dialogues (content/dialogues.js, node → destination)
63
+
64
+ (none)
65
+
66
+ ## Items (content/items.js)
67
+
68
+ | id | Name | Description | Stack |
69
+ |---|---|---|---|
70
+ | gem | 💎 Gem | Dropped by a defeated slime | 99 |
71
+
72
+ Starting inventory: empty. Pickups: 0.
73
+
74
+ ## Quests (content/quests.js)
75
+
76
+ (none)
77
+
78
+ ## Trigger zones, level markers, places
79
+
80
+ - Place room: the centre of the one room (the origin)
81
+
82
+ ## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
83
+
84
+ | Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
85
+ |---|---|---|---|---|---|---|
86
+ | floor | floor | — | — | — | — | 1 placed (room) |
87
+ | wall | wall | box | — | — | — | 4 placed (room) |
88
+ | pillar | pillar | circle | — | — | — | 2 placed (room) |
89
+ | slime | enemy | — | — | — | hp=3, maxHp=3, damage=1, cooldown=0, drop=gem | 1 placed (room) |
90
+
91
+ ## Placements (the level is content; counts per content file)
92
+
93
+ - content/props.js: 8 (template floor×1, template wall×4, template pillar×2, template slime×1); 8 with an explicit id, places: room
94
+
95
+ Code that breaks saves or manages world models: none (rule R33).
96
+
97
+ ## Objective markers and HUD (hud module)
98
+
99
+ - hud.bar('hp') — main.js
100
+ - hud.bar('enemy') — main.js
101
+ - hud.counter('gem') — main.js
102
+
103
+ ## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
104
+
105
+ | Action | Default keys | Label | Handled in |
106
+ |---|---|---|---|
107
+ | attack | Mouse0 KeyF | Attack | main.js |
108
+ | retry | KeyR | Retry | main.js |
109
+ | save | KeyK | Save | main.js |
110
+ | load | KeyL | Load | main.js |
111
+
112
+ ## Events the game emits / listens to
113
+
114
+ (none)
115
+
116
+ ## Saves
117
+
118
+ - Save prefix saveKey: threedog-action
119
+ - Save slots: slot1
120
+ - Save entries the game registers itself: ' +
121
+ 'action
122
+ - Saved parts of the engine modules (vars, inventory, quests, timers, world...): `npx threedog catalog` (saves per module)
123
+
124
+ ## Style pack keys
125
+
126
+ - Style pack: none (all neutral fallback look)
127
+ - Models (asset names): floor, wall, pillar, enemy
@@ -0,0 +1,8 @@
1
+ // This example's key actions: name -> keys and label. What a press does lives in main.js (attack in a fixed step, retry / save / load in the frame hook).
2
+ // Move, interact (E, from presets.interactions.nearest) and the bag (I, from presets.keys.inventory) come from their modules.
3
+ export default {
4
+ attack: { keys: ['Mouse0', 'KeyF'], label: 'Attack' },
5
+ retry: { keys: ['KeyR'], label: 'Retry' },
6
+ save: { keys: ['KeyK'], label: 'Save' },
7
+ load: { keys: ['KeyL'], label: 'Load' },
8
+ };
@@ -0,0 +1,9 @@
1
+ // Sounds as content data (no functions, no paths). 'blip' is a tiny synth main.js registers (engine.audio.register); a game with files names
2
+ // asset-pack sounds here instead ({ hit: ['hit-1', 'hit-2'] }).
3
+ export default {
4
+ sounds: {
5
+ hit: { synth: 'blip', params: { freq: 660 } },
6
+ hurt: { synth: 'blip', params: { freq: 170 } },
7
+ kill: { synth: 'blip', params: { freq: 990 } },
8
+ },
9
+ };
@@ -0,0 +1,10 @@
1
+ // Merge the content files into the one object main.js hands to engine.content.load(). Add a line here for each new content file.
2
+ import places from './places.js';
3
+ import items from './items.js';
4
+ import actions from './actions.js';
5
+ import templates from './templates.js';
6
+ import props from './props.js';
7
+ import audio from './audio.js';
8
+ import views from './views.js';
9
+
10
+ export default { places, items, actions, templates, props, audio, views };
@@ -0,0 +1,4 @@
1
+ // Items: id -> name, icon, description; color is the color of a dropped one on the ground.
2
+ export default {
3
+ gem: { name: 'Gem', icon: '💎', desc: 'Dropped by a defeated slime', color: 0x7fd3ff },
4
+ };
@@ -0,0 +1,4 @@
1
+ // Place names: the room is fixed (no terrain), so main.js passes its centre as { x: 0, z: 0 }; everything else is placed relative to it.
2
+ export default {
3
+ room: 'the centre of the one room (the origin)',
4
+ };
@@ -0,0 +1,11 @@
1
+ // What stands in the room (rule R33: the level is content). Every entry has a stable id so saves store only what play changed.
2
+ export default [
3
+ { id: 'floor', template: 'floor', place: 'room', x: 0, z: 0 },
4
+ { id: 'wall-n', template: 'wall', place: 'room', x: 0, z: -8 },
5
+ { id: 'wall-s', template: 'wall', place: 'room', x: 0, z: 8 },
6
+ { id: 'wall-w', template: 'wall', place: 'room', x: -8, z: 0, rot: 1.5708 },
7
+ { id: 'wall-e', template: 'wall', place: 'room', x: 8, z: 0, rot: 1.5708 },
8
+ { id: 'pillar-1', template: 'pillar', place: 'room', x: -4, z: 0 },
9
+ { id: 'pillar-2', template: 'pillar', place: 'room', x: 4, z: 0 },
10
+ { id: 'slime-1', template: 'slime', place: 'room', x: 0, z: 3 },
11
+ ];
@@ -0,0 +1,10 @@
1
+ // Templates: one reusable object = model + collision (+ state). Each placement in props.js is a world record whose kind is the template name.
2
+ // Model names are this example's own generators (models.js, registered in main.js). Recipe: docs/recipes/30-templates.md.
3
+ export default {
4
+ floor: { model: 'floor' }, // walked on; the room has no terrain
5
+ wall: { model: 'wall', collide: 'box' },
6
+ pillar: { model: 'pillar', collide: 'circle' },
7
+ // The enemy: its stats are instance state, so a placement can make a tougher one ({ template: 'slime', hp: 6, maxHp: 6 }).
8
+ // static: false keeps it out of the static ray set, because it moves; hit detection is the example's own rule in main.js.
9
+ slime: { model: 'enemy', static: false, state: { hp: 3, maxHp: 3, damage: 1, cooldown: 0, drop: 'gem' } },
10
+ };
@@ -0,0 +1,6 @@
1
+ // Named fixed camera views of the room (engine.content.load -> engine.views.define). Same name = same framing every time, so two screenshots
2
+ // differ only by time, style or code: npm run shot -- action --view corner (the page is action.html; add --compare before.png to diff a change).
3
+ export default {
4
+ corner: { position: [7, 5, -8], target: [0, 1, 0], fov: 55 }, // the whole room from a corner, a little above
5
+ door: { position: [0, 2.2, 9], target: [0, 1.2, 0] }, // from the far side looking back at the spawn
6
+ };
@@ -0,0 +1,5 @@
1
+ // This example's look, as a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, look] })). Logic never reads colors; models.js does.
2
+ export default {
3
+ name: 'action', // a part needs at least one Style field (TypeScript rejects an object that shares none), so it names itself
4
+ action: { floor: 0x5b6168, wall: 0x8a8f96, pillar: 0x9a8c78, enemy: 0x6fbf5a, eye: 0x1d2024 },
5
+ };
@@ -0,0 +1,137 @@
1
+ // @ts-check
2
+ // Action example: one room, one player, one slime, one drop. Shows how an action game wires the engine's systems; the combat rules are this file's own.
3
+ // main.js holds rules only: modules, ops (attack, damage, enemy attack, death), fixed-step logic, presentation. The room, the slime and its stats are
4
+ // content (content/templates.js + props.js, rule R33). The engine has no health, damage or death: all of that is below, as plain game state and ops.
5
+ import { createEngine, openWorld, followCamera, presets, interactions, inventory, content, hud, toast } from '../../index.js';
6
+ import lowpoly from '@threedog/style-lowpoly'; // optional style pack; ?style=none runs with the engine's gray placeholders
7
+ import look from './look.js';
8
+ import data from './content/index.js';
9
+ import { models } from './models.js';
10
+
11
+ const url = new URLSearchParams(location.search);
12
+ // Tuning of the rules (the slime's own numbers are instance state in content/templates.js)
13
+ const TUNE = Object.freeze({
14
+ hp: 5, damage: 1, reach: 1.8, arc: 0.5, attackCooldown: 0.45, // arc = cos of the half-angle in front of the player that a swing hits (60°)
15
+ aggro: 6, enemySpeed: 1.6, enemyReach: 1.3, enemyCooldown: 1.2,
16
+ spawn: Object.freeze({ x: 0, z: -4 }),
17
+ // What happens when the player dies: 'respawn' (back to the spawn, full hp, the room as it is), 'restart' (the room as at the start:
18
+ // session.newGame), 'gameover' (everything stops until R, then newGame). Pick one here or with ?death=...
19
+ onDeath: url.get('death') ?? 'respawn',
20
+ });
21
+
22
+ const style = url.get('style') === 'none' ? undefined : [lowpoly, look];
23
+ const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' });
24
+ // A room needs no terrain, plants, weather, water or physics; a fixed time of day; an over-the-shoulder camera that locks the mouse on click,
25
+ // starting behind the player looking along +Z into the room (yaw = which side of the player the camera sits on: PI = the -Z side)
26
+ engine.use(openWorld({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetation: false, weather: false, water: false, rigid: false, ambience: false,
27
+ sky: { ...presets.calendar.fixedTime, time: 0.42 }, characters: { npcs: false } }),
28
+ interactions({ ...presets.interactions.nearest }), inventory({ ...presets.keys.inventory }), content(), hud());
29
+
30
+ const m = models(engine); // the names content/templates.js uses, written out so `npm run check` can see them
31
+ engine.assets.manifest({ name: 'action', models: { floor: m.floor, wall: m.wall, pillar: m.pillar, enemy: m.enemy } });
32
+ engine.audio.register('blip', (a, p, out) => { a.tone({ freq: (p.freq ?? 440) * p.pitch, dur: 0.12, out }); return 0.12; }); // content/audio.js names it
33
+ engine.characters.createPlayer({ ...presets.player.aim, spawn: TUNE.spawn }); // face where the camera looks: a swing goes where you aim
34
+ engine.content.load(data, { places: { room: { x: 0, z: 0 } } });
35
+
36
+ // ---------- Game state: plain values, described and saved (one player, so it is not keyed by actor) ----------
37
+ /** @returns {{ hp: number, cooldown: number, over: boolean, deaths: number }} */
38
+ const fresh = () => ({ hp: TUNE.hp, cooldown: 0, over: false, deaths: 0 });
39
+ const game = fresh();
40
+ const slimes = () => engine.world.query({ kind: 'slime' }).map(r => ({ id: r.id, hp: r.hp, x: +r.position.x.toFixed(2), z: +r.position.z.toFixed(2) }));
41
+ engine.describe.add('action', () => ({ ...game, maxHp: TUNE.hp, onDeath: TUNE.onDeath, slimes: slimes() }));
42
+ engine.saves.register('action', { version: 1, save: () => ({ ...game }), load: d => { Object.assign(game, fresh(), d); } });
43
+
44
+ // ---------- Ops: every caller (mouse, key, dev bridge, MCP, tests, enemy AI) runs the same rule ----------
45
+ const dist = (a, b) => Math.hypot(a.x - b.x, a.z - b.z);
46
+ engine.ops.define('player.attack', {
47
+ desc: 'Swing at every slime within reach in front of the actor',
48
+ can: () => game.over ? 'dead' : game.cooldown > 0 ? 'cooldown' : true,
49
+ run(e, a, ctx) {
50
+ game.cooldown = TUNE.attackCooldown;
51
+ const me = e.world.get(ctx.actor), at = e.actorPosition(ctx.actor), f = me?.facing ?? 0;
52
+ let hits = 0;
53
+ for (const r of e.world.query({ kind: 'slime', near: at, radius: TUNE.reach })) {
54
+ const d = dist(r.position, at) || 1e-6, dot = (Math.sin(f) * (r.position.x - at.x) + Math.cos(f) * (r.position.z - at.z)) / d;
55
+ if (dot >= TUNE.arc && e.ops.run('enemy.damage', { id: r.id, amount: TUNE.damage }).ok) hits++;
56
+ }
57
+ return hits;
58
+ },
59
+ reasons: { dead: 'The player is dead', cooldown: 'Still recovering from the last swing' },
60
+ });
61
+ engine.ops.define('enemy.damage', {
62
+ desc: 'Take hp off a slime; at 0 it dies and leaves its drop', args: { id: 'string', amount: 'number' },
63
+ can: (e, { id }) => e.world.get(id)?.kind === 'slime' || 'noEnemy',
64
+ run(e, { id, amount }) {
65
+ const r = e.world.get(id), hp = Math.max(0, r.hp - amount);
66
+ if (hp > 0) { e.world.set(id, { hp }); e.audio.sfx('hit', { at: r.position }); return hp; }
67
+ // Death: the drop is a pickup made during play (inside an op, rule R33); a stable id ties it to this slime so a save keeps it
68
+ e.inventory.spawnPickup(r.drop, r.position, { id: `${id}-drop`, respawnSeconds: 0 });
69
+ e.world.remove(id); // the saved world remembers the slime is gone
70
+ e.vars.bump('kills');
71
+ e.audio.sfx('kill', { at: r.position });
72
+ return 0;
73
+ },
74
+ reasons: { noEnemy: 'No living slime with that id' },
75
+ });
76
+ engine.ops.define('enemy.attack', {
77
+ desc: 'The acting slime hits the player when in reach and off cooldown',
78
+ can(e, a, ctx) {
79
+ const r = e.world.get(ctx.actor);
80
+ if (r?.kind !== 'slime') return 'notEnemy';
81
+ if (game.over) return 'targetDead';
82
+ return r.cooldown > 0 ? 'cooldown' : dist(r.position, e.actorPosition('player')) > TUNE.enemyReach ? 'outOfReach' : true;
83
+ },
84
+ run(e, a, ctx) {
85
+ const r = e.world.get(ctx.actor);
86
+ r.cooldown = TUNE.enemyCooldown; // a value that changes every step: a direct field write, saved without an event
87
+ game.hp = Math.max(0, game.hp - r.damage);
88
+ e.audio.sfx('hurt');
89
+ if (game.hp === 0) e.ops.run('player.die');
90
+ return game.hp;
91
+ },
92
+ reasons: { notEnemy: 'The actor is not a slime', targetDead: 'The player is already dead', cooldown: 'Still recovering', outOfReach: 'The player is too far' },
93
+ });
94
+ engine.ops.define('player.die', {
95
+ desc: `What dying does in this example (onDeath = ${TUNE.onDeath})`,
96
+ can: () => game.over ? 'dead' : true,
97
+ run(e) {
98
+ game.deaths++;
99
+ if (TUNE.onDeath === 'respawn') { game.hp = TUNE.hp; e.player.placeAt(TUNE.spawn); return 'respawn'; }
100
+ game.over = true; // 'restart' resets at once in the frame hook, 'gameover' waits for R (session.newGame is async flow, not a step)
101
+ return TUNE.onDeath;
102
+ },
103
+ });
104
+
105
+ // ---------- Fixed step: game time (cooldowns, enemy AI, gameplay keys), the same at any frame rate ----------
106
+ engine.world.simulate('slime', {
107
+ near(rec, dt) {
108
+ rec.cooldown = Math.max(0, rec.cooldown - dt);
109
+ const p = engine.actorPosition('player'), d = dist(rec.position, p);
110
+ if (game.over || d > TUNE.aggro) return;
111
+ rec.rot = Math.atan2(p.x - rec.position.x, p.z - rec.position.z); // face the player (+Z is forward)
112
+ if (d > TUNE.enemyReach * 0.8) {
113
+ const s = Math.min(TUNE.enemySpeed * dt, d - TUNE.enemyReach * 0.8);
114
+ engine.world.move(rec.id, { x: rec.position.x + (p.x - rec.position.x) / d * s, z: rec.position.z + (p.z - rec.position.z) / d * s });
115
+ } else if (rec.cooldown === 0) engine.ops.run('enemy.attack', {}, { actor: rec.id });
116
+ },
117
+ });
118
+ engine.onFixed(dt => {
119
+ game.cooldown = Math.max(0, game.cooldown - dt);
120
+ if (engine.input.pressed('attack')) engine.ops.run('player.attack', {}, { source: 'player' });
121
+ });
122
+
123
+ // ---------- Frame: presentation and flow (HUD, death screen, save keys) ----------
124
+ let shownOver = false, restarting = null;
125
+ engine.onFrame(() => {
126
+ engine.hud.bar('hp', { value: game.hp, max: TUNE.hp, label: 'HP' });
127
+ const s = engine.world.query({ kind: 'slime', near: engine.player.position, radius: TUNE.aggro + 2 })[0];
128
+ if (s) engine.hud.bar('enemy', { value: s.hp, max: s.maxHp, label: 'Slime' }); else engine.hud.remove('enemy');
129
+ engine.hud.counter('gem', { icon: '💎', label: 'Gems', value: engine.inventory.count('gem') });
130
+ if (game.over !== shownOver && (shownOver = game.over) && TUNE.onDeath === 'gameover') toast(engine, 'You died. Press R to retry');
131
+ if (game.over && !restarting && (TUNE.onDeath === 'restart' || engine.input.pressed('retry'))) restarting = engine.session.newGame().finally(() => { restarting = null; });
132
+ if (engine.input.pressed('save')) engine.saves.save('slot1').then(ok => { if (ok) toast(engine, 'Saved'); });
133
+ if (engine.input.pressed('load')) engine.saves.load('slot1').then(ok => toast(engine, ok ? 'Loaded' : 'No save yet'));
134
+ });
135
+
136
+ window.engine = engine; // tests, the dev bridge and the console rely on it (before start)
137
+ await engine.start();
@@ -0,0 +1,25 @@
1
+ // Models this example builds in code (floor, wall, pillar, enemy), registered by name in main.js and placed by content/templates.js + props.js.
2
+ // Colors come from the style pack's `action` key (look.js, merged as a style part); with no style pack every model is the engine's neutral gray.
3
+ import { THREE, makeMaterial } from '../../index.js';
4
+
5
+ /** Model generators that read their colors from engine.style.action (missing = gray) @param {{ style: any }} engine */
6
+ export function models(engine) {
7
+ const look = () => engine.style?.action ?? {};
8
+ const mesh = (geo, role, color) => {
9
+ const m = new THREE.Mesh(geo, makeMaterial(role, color === undefined ? {} : { color, flatShading: true }));
10
+ m.castShadow = m.receiveShadow = true;
11
+ return m;
12
+ };
13
+ return {
14
+ floor: () => mesh(new THREE.BoxGeometry(16, 0.2, 16).translate(0, -0.1, 0), 'prop', look().floor),
15
+ wall: () => mesh(new THREE.BoxGeometry(16, 2.4, 0.5).translate(0, 1.2, 0), 'prop', look().wall),
16
+ pillar: () => mesh(new THREE.CylinderGeometry(0.5, 0.6, 2.8, 8).translate(0, 1.4, 0), 'prop', look().pillar),
17
+ // A squat body with two eyes: the eyes face +Z, the facing every character uses (CONVENTIONS: characters face +Z)
18
+ enemy: () => {
19
+ const g = new THREE.Group();
20
+ g.add(mesh(new THREE.SphereGeometry(0.55, 10, 8).scale(1, 0.75, 1).translate(0, 0.42, 0), 'character', look().enemy));
21
+ for (const x of [-0.2, 0.2]) g.add(mesh(new THREE.SphereGeometry(0.09, 6, 4).translate(x, 0.6, 0.48), 'character', look().eye));
22
+ return g;
23
+ },
24
+ };
25
+ }
@@ -0,0 +1,107 @@
1
+ # Game map: sheepisland (generated, do not edit by hand)
2
+
3
+ > Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /sheepisland.html, entry `main.js`.
4
+ > Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
5
+
6
+ Content: props 15 (from templates 15) · templates 2 · vegetation 1
7
+
8
+ ## Design decisions (hand-written, from DESIGN.md)
9
+
10
+ None yet, write them in `DESIGN.md` (why it is designed this way, what not to change).
11
+
12
+ ## Engine modules (engine.use)
13
+
14
+ - createEngine: { style, saveKey: 'threedog-sheepisland', ui: { loading: { title: 'sheep island' } } }
15
+ - openWorld preset ({ camera: fixedCamera(), terrain: island, water: false, rigid: false, ambience: false, sky: { ...pr…) → world, terrain, vegetation, sky, weather, collision, characters, settings, debug
16
+ - content
17
+
18
+ ## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
19
+
20
+ - world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
21
+ - terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
22
+ - vegetation: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/vegetation.md`
23
+ - sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
24
+ - weather: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/weather.md`
25
+ - collision: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/collision.md`
26
+ - characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
27
+ - settings: `node_modules/threedog/docs/recipes/26-ui-parts.md` · `node_modules/threedog/docs/api/settings.md`
28
+ - content: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/content.md`
29
+
30
+ Not used yet (check these before writing the system yourself):
31
+
32
+ - inventory: items, stacks, containers and pickups: `inventory({ ...presets.keys.inventory })` (keys required), content/items.js (node_modules/threedog/docs/recipes/03-items-pickups.md)
33
+ - saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
34
+ - interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
35
+ - quests: goals with steps, conditions and rewards: `quests({ ...presets.keys.quests })` (keys required), content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
36
+ - grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
37
+
38
+ ## Files
39
+
40
+ content/*.js is content data: how to write it in `node_modules/threedog/docs/recipes/` (02-npc, 03-items-pickups, 04-quests, 20-content-actions-save…).
41
+
42
+ | File | Lines | Description |
43
+ |---|---|---|
44
+ | content/index.js | 7 | |
45
+ | content/props.js | 20 | |
46
+ | content/templates.js | 6 | |
47
+ | content/vegetation.js | 9 | |
48
+ | main.js | 72 | @ts-check Sheep island: a small floating island built only from the engine's public entry points (t… |
49
+ | params.js | 26 | URL parameters of the sheep island page. Import this file first in main.js: it rewrites word values… |
50
+ | style/index.js | 80 | sheepisland: a style pack, LOOKS ONLY (recipes/09-style-pack.md, 35-style-from-reference.md), start… |
51
+ | style/models.js | 60 | sheepisland procedural models: a round tree, a sheep, a wheat tuft. Built in code, no files; regist… |
52
+ | views.js | 10 | Named camera positions of the sheep island. Same name = same framing every time, so two screenshots… |
53
+
54
+ ## NPCs (content/npcs.js)
55
+
56
+ (none)
57
+
58
+ ## Dialogues (content/dialogues.js, node → destination)
59
+
60
+ (none)
61
+
62
+ ## Items (content/items.js)
63
+
64
+ (none)
65
+
66
+ ## Quests (content/quests.js)
67
+
68
+ (none)
69
+
70
+ ## Trigger zones, level markers, places
71
+
72
+ (none)
73
+
74
+ ## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
75
+
76
+ | Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
77
+ |---|---|---|---|---|---|---|
78
+ | tree | roundTree | circle | — | — | — | 7 placed (world) |
79
+ | sheep | sheep | — | — | — | — | 8 placed (world) |
80
+
81
+ ## Placements (the level is content; counts per content file)
82
+
83
+ - content/props.js: 15 (template tree×7, template sheep×8); 15 with an explicit id, places: world
84
+ - content/vegetation.js: 1 rules (instances generated from each rule)
85
+
86
+ Code that breaks saves or manages world models: none (rule R33).
87
+
88
+ ## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
89
+
90
+ (none)
91
+
92
+ ## Events the game emits / listens to
93
+
94
+ | Event | Emitted by the game | Listened to by the game |
95
+ |---|---|---|
96
+ | engine:ready | — | main.js |
97
+
98
+ ## Saves
99
+
100
+ - Save prefix saveKey: threedog-sheepisland
101
+ - Saved parts of the engine modules (vars, inventory, quests, timers, world...): `npx threedog catalog` (saves per module)
102
+
103
+ ## Style pack keys
104
+
105
+ - Style pack: none (all neutral fallback look)
106
+ - Models (asset names): wheatTuft, roundTree, sheep
107
+ - Vegetation (content/vegetation.js): wheat
@@ -0,0 +1,6 @@
1
+ // Merge every content file in content/ into one object that main.js passes to engine.content.load(). Add a line here for each new content file.
2
+ import templates from './templates.js';
3
+ import props from './props.js';
4
+ import vegetation from './vegetation.js';
5
+
6
+ export default { templates, props, vegetation };