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,87 @@
1
+ // The exhibits that are not in the lowpoly asset pack, built in code and registered by name in main.js (content/templates.js places them).
2
+ // Every surface goes through makeMaterial(role), so the style decides the feel: roles wood, stone, metal, glass, building.
3
+ // Shadow flags are set here, on the model (the engine does not guess them).
4
+ import { THREE, mergeColored, makeMaterial } from '../../index.js';
5
+
6
+ const mesh = (geo, role, params = {}) => {
7
+ const m = new THREE.Mesh(geo, makeMaterial(role, params));
8
+ m.castShadow = m.receiveShadow = true;
9
+ return m;
10
+ };
11
+ const box = (w, h, d, x, y, z, color) => [new THREE.BoxGeometry(w, h, d).translate(x, y, z), color];
12
+
13
+ /** A wooden crate: planks on a frame */
14
+ export function woodBlock() {
15
+ const g = new THREE.Group();
16
+ g.add(mesh(new THREE.BoxGeometry(1.6, 1.6, 1.6).translate(0, 0.8, 0), 'wood', { color: 0xb08850 }));
17
+ for (const y of [0.35, 0.8, 1.25]) g.add(mesh(new THREE.BoxGeometry(1.64, 0.06, 1.64).translate(0, y, 0), 'wood', { color: 0x8a6a3c }));
18
+ return g;
19
+ }
20
+
21
+ /** A rough stone block (faceted) */
22
+ export function stoneBlock() {
23
+ const geo = new THREE.DodecahedronGeometry(1, 0).scale(1.1, 0.95, 1).translate(0, 0.85, 0);
24
+ return mesh(geo, 'stone', { color: 0x8f897d, flatShading: true });
25
+ }
26
+
27
+ /** A metal ball on a plinth: the surface that needs environment light to look like metal */
28
+ export function metalBall() {
29
+ const g = new THREE.Group();
30
+ g.add(mesh(new THREE.CylinderGeometry(0.7, 0.8, 0.3, 12).translate(0, 0.15, 0), 'stone', { color: 0x7a766e }));
31
+ g.add(mesh(new THREE.SphereGeometry(0.85, 24, 16).translate(0, 1.2, 0), 'metal', { color: 0xc8ccd2 }));
32
+ return g;
33
+ }
34
+
35
+ /** Two glass panes in front of a colored block: shows transparency, sorting and what is seen through it */
36
+ export function glassPanes() {
37
+ const g = new THREE.Group();
38
+ g.add(mesh(new THREE.BoxGeometry(1.4, 1.4, 0.4).translate(0, 0.9, -0.9), 'building', { color: 0xd8604a }));
39
+ for (const [x, z, color] of [[-0.4, 0, 0xbfe3f0], [0.5, 0.5, 0xf0d8a8]]) {
40
+ const pane = mesh(new THREE.BoxGeometry(1.5, 2, 0.06).translate(x, 1, z), 'glass', { color, transparent: true, opacity: 0.35, depthWrite: false });
41
+ pane.castShadow = false;
42
+ g.add(pane);
43
+ }
44
+ return g;
45
+ }
46
+
47
+ /** A pale slab with a pillar and a ball standing on it: the shadow receiver (edge softness, shadow darkness, acne) */
48
+ export function shadowStage() {
49
+ const g = new THREE.Group();
50
+ g.add(mesh(new THREE.BoxGeometry(5, 0.15, 5).translate(0, 0.075, 0), 'building', { color: 0xf0ece4 }));
51
+ g.add(mesh(new THREE.BoxGeometry(0.7, 2.4, 0.7).translate(-1, 1.35, -0.6), 'building', { color: 0xe8e2d6 }));
52
+ g.add(mesh(new THREE.IcosahedronGeometry(0.6, 1).translate(1, 0.75, 0.4), 'building', { color: 0xe8e2d6 }));
53
+ return g;
54
+ }
55
+
56
+ /**
57
+ * A small room, 6 x 5 m, front (+z) toward the overview camera. Walls with a window and a door, a flat roof, a table, a bed and a lamp named 'lamp'
58
+ * (main.js lights it at night). Outside it shows the walls in sun; inside, the window light against the dark corners.
59
+ */
60
+ export function room() {
61
+ const g = new THREE.Group();
62
+ const WALL = 0xe8dcc4, TRIM = 0x6b4a32;
63
+ const parts = [
64
+ box(6.4, 0.2, 5.4, 0, 0.1, 0, 0x9a8468), // floor slab
65
+ box(6, 3, 0.2, 0, 1.6, -2.4, WALL), box(0.2, 3, 5, -2.9, 1.6, 0, WALL), box(0.2, 3, 5, 2.9, 1.6, 0, WALL), // back, left, right walls
66
+ // front wall (z = +2.4) with a window (x -2.2..-0.8, y 1..2.2) and a door (x 1.4..2.4)
67
+ box(0.8, 3, 0.2, -2.6, 1.6, 2.4, WALL), box(1.4, 0.8, 0.2, -1.5, 0.7 + 0.2, 2.4, WALL), box(1.4, 0.8, 0.2, -1.5, 2.6 + 0.2, 2.4, WALL),
68
+ box(2.2, 3, 0.2, 0.3, 1.6, 2.4, WALL), box(1, 0.8, 0.2, 1.9, 2.6 + 0.2, 2.4, WALL), box(0.6, 3, 0.2, 2.7, 1.6, 2.4, WALL),
69
+ box(1.6, 0.08, 0.3, -1.5, 1.04 + 0.2, 2.5, TRIM), // window sill
70
+ box(6.8, 0.25, 5.8, 0, 3.3, 0, 0xa4553c), // flat roof
71
+ ];
72
+ const shell = mesh(mergeColored(/** @type {any} */ (parts)), 'building', { vertexColors: true });
73
+ g.add(shell);
74
+ // furniture: a table and a bed in the dark half of the room
75
+ g.add(mesh(new THREE.BoxGeometry(1.4, 0.1, 0.8).translate(1.2, 0.85, -1.2), 'wood', { color: 0x8a6a3c }));
76
+ for (const [x, z] of [[0.6, -1.5], [1.8, -1.5], [0.6, -0.9], [1.8, -0.9]]) g.add(mesh(new THREE.BoxGeometry(0.08, 0.7, 0.08).translate(x, 0.5, z), 'wood', { color: 0x6b4a32 }));
77
+ g.add(mesh(new THREE.BoxGeometry(1.2, 0.4, 2).translate(-2, 0.5, -1.2), 'wood', { color: 0x9a7a52 }));
78
+ g.add(mesh(new THREE.BoxGeometry(1.1, 0.15, 1.2).translate(-2, 0.78, -1.6), 'building', { color: 0xd8d4cc }));
79
+ // window glass and the lamp
80
+ const glass = mesh(new THREE.BoxGeometry(1.4, 1.2, 0.04).translate(-1.5, 1.6, 2.4), 'glass', { color: 0xbfe3f0, transparent: true, opacity: 0.3, depthWrite: false });
81
+ glass.castShadow = false;
82
+ g.add(glass);
83
+ const lamp = mesh(new THREE.BoxGeometry(0.3, 0.3, 0.3).translate(0, 2.8, 0), 'lamp', { color: 0x6b5a40, emissive: 0xffc070, emissiveIntensity: 0 });
84
+ lamp.name = 'lamp';
85
+ g.add(lamp);
86
+ return g;
87
+ }
@@ -0,0 +1,33 @@
1
+ // What the style workbench exports: the values the user changed, as a plain object literal to paste into `style: [lowpoly, { ... }]`.
2
+ // Pure functions (no DOM, no engine) so a test can run them on their own.
3
+
4
+ /** Set a value at a path of keys inside a nested plain object, creating the objects on the way */
5
+ export function putAt(obj, path, value) {
6
+ let o = obj;
7
+ for (const k of path.slice(0, -1)) o = o[k] ??= {};
8
+ o[path.at(-1)] = value;
9
+ }
10
+
11
+ /** '#rrggbb' <-> 0xrrggbb (the pack's color form); other strings (rgba(...)) pass through */
12
+ export const hexOf = n => '#' + n.toString(16).padStart(6, '0');
13
+ export const numOf = s => (/^#[0-9a-f]{6}$/i.test(s) ? parseInt(s.slice(1), 16) : s);
14
+
15
+ /**
16
+ * Object literal source of the changes. A number under a key listed in `colors` (dotted paths such as 'palette.pine') prints as 0xrrggbb,
17
+ * other numbers as they are rounded to 3 decimals, strings quoted.
18
+ * @param {Record<string, any>} obj @param {Set<string>} [colors] @param {string} [prefix] @param {number} [depth]
19
+ */
20
+ export function literal(obj, colors = new Set(), prefix = '', depth = 0) {
21
+ const pad = ' '.repeat(depth + 1), keys = Object.keys(obj);
22
+ if (!keys.length) return '{}';
23
+ const rows = keys.map(k => {
24
+ const v = obj[k], path = prefix ? `${prefix}.${k}` : k, name = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
25
+ let src;
26
+ if (v === null) src = 'null';
27
+ else if (typeof v === 'object') src = literal(v, colors, path, depth + 1);
28
+ else if (typeof v === 'number') src = colors.has(path) ? '0x' + v.toString(16).padStart(6, '0') : String(+v.toFixed(3));
29
+ else src = JSON.stringify(v);
30
+ return `${pad}${name}: ${src},`;
31
+ });
32
+ return `{\n${rows.join('\n')}\n${' '.repeat(depth)}}`;
33
+ }
@@ -0,0 +1,135 @@
1
+ // Style workbench (?panel=1): sliders and color pickers over the running style test, plus an export of what changed.
2
+ // Tweakpane is a dev tool, not an engine dependency: it is a devDependency of the repo and found at build time by the glob below.
3
+ // If it is not installed the page says so and runs on without the panel.
4
+ //
5
+ // Two kinds of values, never mixed up in the panel:
6
+ // live the engine has an API that changes it while running: renderer exposure, sky time, environment lighting, water color, fog,
7
+ // post effects, UI colors (CSS variables). The picture changes at once.
8
+ // rebuild values read once at startup (the procedural models' palette, terrain colors, wave shape). The panel keeps them and
9
+ // "apply and rebuild" reloads the page with them as an extra style part (?ov=...). The picture does NOT change until then.
10
+ // The exported object holds style fields only (what `style: [lowpoly, {...}]` accepts); the running engine.style and the pack are never written.
11
+ import { putAt, hexOf, numOf, literal } from './overrides.js';
12
+
13
+ // @ts-ignore Vite's import.meta.glob (not in ImportMeta outside Vite); empty when the package is not installed
14
+ const loaders = import.meta.glob('../../../../node_modules/tweakpane/dist/tweakpane.js');
15
+ const UI_KEYS = ['bg', 'fg', 'muted', 'accent', 'good', 'line'];
16
+ const LIVE = 'live', REBUILD = ' [needs rebuild]';
17
+ const HOW = 'Run `npm install` in the repository root (tweakpane is a devDependency), then reload. 风格工作台需要 tweakpane:先运行 npm install。';
18
+
19
+ /** Show why there is no panel, in the page (not only the console) */
20
+ function note(text) {
21
+ const el = document.getElementById('panel-note');
22
+ if (el) { el.textContent = text; el.hidden = false; }
23
+ console.warn('styletest panel: ' + text);
24
+ }
25
+
26
+ /**
27
+ * @param {any} engine
28
+ * @param {Record<string, any> | null} base overrides already in the URL (?ov=), kept and extended
29
+ * @returns {Promise<boolean>} whether the panel is open
30
+ */
31
+ export async function openPanel(engine, base) {
32
+ const load = Object.values(loaders)[0];
33
+ if (!load) { note('Style workbench needs the dev package "tweakpane", which is not installed. ' + HOW); return false; }
34
+ /** @type {any} */ let Pane;
35
+ try { ({ Pane } = await load()); } catch (e) { note(`Style workbench could not load tweakpane (${String(e).slice(0, 100)}). ` + HOW); return false; }
36
+ const changes = structuredClone(base ?? {}), colors = new Set();
37
+ const notes = new Map(); // post effect -> changed params (an effect list cannot be written as a style literal)
38
+ const put = (path, v, isColor = false) => { putAt(changes, path, v); if (isColor) colors.add(path.join('.')); };
39
+ const host = document.createElement('div');
40
+ host.style.cssText = 'position:fixed;top:8px;right:8px;width:310px;max-height:calc(100vh - 16px);overflow:auto;z-index:1000';
41
+ document.body.appendChild(host);
42
+ const pane = new Pane({ title: 'Style workbench', container: host });
43
+
44
+ // ---- live: exposure, sky time, light multipliers (preview aids: not style fields, never exported) ----
45
+ const sky = pane.addFolder({ title: `Light (${LIVE})` });
46
+ const light = { exposure: engine.renderer.toneMappingExposure, time: engine.sky.timeOfDay * 24, sun: 1, ambient: 1, fog: 1 };
47
+ sky.addBinding(light, 'exposure', { min: 0.2, max: 3, step: 0.01, label: '曝光 exposure' })
48
+ .on('change', e => { engine.renderer.toneMappingExposure = e.value; put(['exposure'], e.value); });
49
+ sky.addBinding(light, 'time', { min: 0, max: 24, step: 0.1, label: '天空时间 hour (preview)' })
50
+ .on('change', e => { engine.sky.timeOfDay = e.value / 24 % 1; });
51
+ const layer = () => engine.sky.modify('workbench', { sun: light.sun, ambient: light.ambient, fog: light.fog });
52
+ for (const [k, label] of [['sun', '阳光倍率 sun x (preview)'], ['ambient', '环境光倍率 ambient x (preview)'], ['fog', '雾距离倍率 fog x (preview)']]) {
53
+ sky.addBinding(light, k, { min: 0.1, max: 3, step: 0.05, label }).on('change', layer);
54
+ }
55
+
56
+ // ---- live: environment lighting ----
57
+ const envState = { on: !!engine.sky.environment, intensity: engine.sky.environment?.intensity ?? 0.8 };
58
+ const env = pane.addFolder({ title: `环境照明 (${LIVE})` });
59
+ const applyEnv = () => {
60
+ const on = envState.on, opts = { source: 'sky', intensity: envState.intensity };
61
+ (on ? (engine.look.env.replace('sky'), engine.look.env.set({ intensity: opts.intensity })) : engine.look.env.replace(false));
62
+ put(['sky', 'environment'], on ? opts : null);
63
+ };
64
+ env.addBinding(envState, 'on', { label: '开 on' }).on('change', applyEnv);
65
+ env.addBinding(envState, 'intensity', { min: 0, max: 2, step: 0.05, label: '强度 intensity' }).on('change', () => { if (envState.on) applyEnv(); });
66
+
67
+ // ---- live: water color (the shared water material) ----
68
+ const wm = engine.water?.material;
69
+ if (wm?.color) {
70
+ const water = { color: hexOf(wm.color.getHex()) };
71
+ pane.addFolder({ title: `水 (${LIVE})` }).addBinding(water, 'color', { label: '颜色 color' })
72
+ .on('change', e => { wm.color.set(e.value); put(['water', 'color'], numOf(e.value), true); });
73
+ }
74
+
75
+ // ---- live: post effects, from engine.post.list() / get() / set() ----
76
+ const post = pane.addFolder({ title: `后期 post (${LIVE})`, expanded: false });
77
+ for (const { name, enabled } of engine.post.list()) {
78
+ const h = engine.post.get(name), f = post.addFolder({ title: name, expanded: false });
79
+ const noteOf = () => notes.get(name) ?? notes.set(name, {}).get(name);
80
+ f.addBinding({ enabled }, 'enabled', { label: '开 on' }).on('change', e => { engine.look.post.set({ [name + '.enabled']: e.value }); noteOf().enabled = e.value; });
81
+ for (const [k, v] of Object.entries(h.params)) {
82
+ if (typeof v !== 'number' && typeof v !== 'boolean') continue; // lut textures, functions...: not editable here
83
+ const range = typeof v === 'number' ? { step: Math.abs(v) >= 10 ? 1 : 0.01, min: Math.min(0, v * 2), max: Math.max(1, v * 3) } : {};
84
+ f.addBinding({ [k]: v }, k, range).on('change', e => { engine.look.post.set({ [name + '.' + k]: e.value }); noteOf()[k] = e.value; });
85
+ }
86
+ }
87
+
88
+ // ---- live: UI colors, CSS variables on engine.uiRoot ----
89
+ const css = getComputedStyle(engine.uiRoot), uiVals = {};
90
+ for (const k of UI_KEYS) { const v = css.getPropertyValue('--threedog-' + k).trim(); if (v) uiVals[k] = v; }
91
+ const ui = pane.addFolder({ title: `界面颜色 ui (${LIVE})`, expanded: false });
92
+ for (const k of Object.keys(uiVals)) ui.addBinding(uiVals, k).on('change', e => { engine.uiRoot.style.setProperty('--threedog-' + k, e.value); put(['ui', k], e.value); });
93
+
94
+ // ---- rebuild: values the engine reads at startup ----
95
+ const rb = pane.addFolder({ title: 'Needs rebuild (press "apply and rebuild")', expanded: false });
96
+ const style = engine.style ?? {};
97
+ for (const [path, src, title] of [['palette', style.palette, '材质用途/模型色 palette'], ['terrain.colors', style.terrain?.colors, '地形色 terrain.colors']]) {
98
+ if (!src) continue;
99
+ const f = rb.addFolder({ title: title + REBUILD, expanded: false }), vals = {};
100
+ for (const [k, v] of Object.entries(src)) if (typeof v === 'number') vals[k] = hexOf(v);
101
+ for (const k of Object.keys(vals)) f.addBinding(vals, k).on('change', e => put([...path.split('.'), k], numOf(e.value), true));
102
+ }
103
+ if (style.water) {
104
+ const f = rb.addFolder({ title: '水波 water' + REBUILD, expanded: false }), vals = {};
105
+ for (const k of ['waveHeight', 'waveScale', 'waveSpeed', 'fresnel']) if (typeof style.water[k] === 'number') vals[k] = style.water[k];
106
+ for (const k of Object.keys(vals)) f.addBinding(vals, k, { step: 0.01 }).on('change', e => put(['water', k], e.value));
107
+ }
108
+
109
+ // ---- export / rebuild ----
110
+ const out = { text: '' };
111
+ const exportText = () => {
112
+ let s = `// paste into createEngine({ style: [lowpoly, { ... }] }):\n${literal(changes, colors)}`;
113
+ const posts = [...notes].filter(([, v]) => Object.keys(v).length);
114
+ if (posts.length) {
115
+ s += '\n// post effects are a list, not a literal: call the factory again with these (postAdd(bloom({ strength: 0.6 }))):\n';
116
+ s += posts.map(([n, v]) => `// ${n}: ${JSON.stringify(v)}`).join('\n');
117
+ }
118
+ return s;
119
+ };
120
+ const ex = pane.addFolder({ title: '导出 / 重建' });
121
+ const mon = ex.addBinding(out, 'text', { readonly: true, multiline: true, rows: 8, label: '' });
122
+ const show = () => { out.text = exportText(); mon.refresh(); return out.text; };
123
+ ex.addButton({ title: '导出覆盖配置 export overrides' }).on('click', () => { navigator.clipboard?.writeText(show()).catch(() => {}); });
124
+ const reload = ov => {
125
+ const u = new URL(location.href);
126
+ if (ov) u.searchParams.set('ov', JSON.stringify(ov)); else u.searchParams.delete('ov');
127
+ location.href = u.href;
128
+ };
129
+ ex.addButton({ title: '应用并重建预览 apply and rebuild' }).on('click', () => reload(changes));
130
+ ex.addButton({ title: '清除覆盖 clear overrides' }).on('click', () => reload(null));
131
+
132
+ engine.describe.add('stylePanel', () => ({ open: true, changes: JSON.parse(JSON.stringify(changes)) }));
133
+ /** @type {any} */ (engine).styleWorkbench = { pane, export: show, changes }; // for tests and the dev bridge
134
+ return true;
135
+ }
@@ -0,0 +1,32 @@
1
+ // URL parameters of the style test page. Import this file first in main.js: it rewrites word values into the forms the engine's own
2
+ // URL state understands (time=dusk -> 18:30, weather=雨 -> rain) before createEngine reads the URL.
3
+ // time day | dusk | night, or HH:MM weather clear | rain | snow (晴 雨 雪), or any engine weather name
4
+ // style lowpoly | none env 1 = environment lighting from the sky (default 0)
5
+ // view overview | character | water | room | path | ui (总览 角色特写 水面 室内 移动镜头路径 界面)
6
+ // panel 1 = the style workbench (needs the tweakpane dev package)
7
+ // ov style overrides the workbench exports for "rebuild preview" (JSON, URL-encoded)
8
+ /** @type {Record<string, string>} */
9
+ const TIME = { day: '12:00', 白天: '12:00', dusk: '18:30', 黄昏: '18:30', night: '23:00', 夜晚: '23:00' };
10
+ /** @type {Record<string, string>} */
11
+ const WEATHER = { 晴: 'clear', 雨: 'rain', 雪: 'snow' };
12
+ /** @type {Record<string, string>} */
13
+ export const VIEWS = { 总览: 'overview', 角色特写: 'character', 水面: 'water', 室内: 'room', 移动镜头路径: 'path', 界面: 'ui' };
14
+ export const VIEW_NAMES = ['overview', 'character', 'water', 'room', 'path', 'ui'];
15
+
16
+ const url = new URL(location.href), q = url.searchParams;
17
+ let changed = false;
18
+ for (const [key, map] of /** @type {[string, Record<string, string>][]} */ ([['time', TIME], ['weather', WEATHER]])) {
19
+ const v = q.get(key);
20
+ if (v && map[v]) { q.set(key, map[v]); changed = true; }
21
+ }
22
+ if (changed) history.replaceState(null, '', url);
23
+
24
+ const view = VIEWS[q.get('view')] ?? q.get('view') ?? 'overview';
25
+ export const params = Object.freeze({
26
+ view: VIEW_NAMES.includes(view) ? view : 'overview',
27
+ style: q.get('style') === 'none' ? 'none' : 'lowpoly',
28
+ env: q.get('env') === '1',
29
+ panel: q.get('panel') === '1',
30
+ overrides: q.get('ov') ? JSON.parse(q.get('ov')) : null,
31
+ badView: q.has('view') && !VIEW_NAMES.includes(view) ? q.get('view') : null,
32
+ });
@@ -0,0 +1,31 @@
1
+ // Named camera positions of the style test. Same name = same framing every time, so two screenshots differ only by style.
2
+ // A view is a function of the stage (its flat spot) and the water point, both found at startup because terrain is procedural.
3
+ // Positions are [x, y, z] in world space; y is measured above the ground at the stage unless noted.
4
+
5
+ /** Path speed, meters per second: slow enough to see grass blades and shadow edges crawl or flicker */
6
+ export const PATH_SPEED = 2.5;
7
+
8
+ /** @param {{ x: number, z: number }} stage @param {{ x: number, z: number }} water @param {any} engine */
9
+ export function makeViews(engine, stage, water) {
10
+ const h = engine.surface(stage.x, stage.z);
11
+ const at = (dx, dy, dz) => [stage.x + dx, h + dy, stage.z + dz];
12
+ const room = (dx, dy, dz) => at(14 + dx, dy, -2 + dz); // room-local coordinates (the room stands at stage + (14, -2))
13
+ // water: stand back from the water point on the stage side and look at the surface
14
+ const wl = engine.waterLevel, dx = water.x - stage.x, dz = water.z - stage.z, len = Math.hypot(dx, dz) || 1;
15
+ const bx = water.x - dx / len * 22, bz = water.z - dz / len * 22, eye = [bx, Math.max(engine.surface(bx, bz), wl) + 6, bz];
16
+ const front = [[-12, 3.5, 15], [12, 3.5, 15]]; // the path: a straight line in front of the exhibits, looking at their middle
17
+ return {
18
+ overview: { pos: at(4, 12, 26), look: at(4, 1.5, -2) },
19
+ character: { pos: at(5.2, 1.7, 7.4), look: at(2.5, 1.1, 4) },
20
+ water: { pos: eye, look: [water.x, wl, water.z] },
21
+ room: { pos: room(2.3, 1.6, -1.8), look: room(-1.5, 1.4, 2.4) },
22
+ ui: { pos: at(4, 12, 26), look: at(4, 1.5, -2) },
23
+ path: { pos: at(...front[0]), look: at(2, 1.2, -2), to: at(...front[1]), speed: PATH_SPEED },
24
+ };
25
+ }
26
+
27
+ /** Where the path camera is `seconds` after it was chosen: back and forth along its line at constant speed (a triangle wave: no easing, no pauses at the ends) */
28
+ export function pathAt(v, seconds) {
29
+ const len = Math.hypot(v.to[0] - v.pos[0], v.to[2] - v.pos[2]), s = (seconds * v.speed) % (2 * len), k = (s < len ? s : 2 * len - s) / len;
30
+ return v.pos.map((a, i) => a + (v.to[i] - a) * k);
31
+ }
@@ -0,0 +1,5 @@
1
+ # Design decisions
2
+
3
+ - **The pace is "slow"**: no combat, no failure; the player progresses by taking photos and wandering. For any new mechanic, first ask "will it make people feel rushed?"; if so, leave it out.
4
+ - **Film is the only limited resource**: each photo uses one (photo:taken in main.js); the only sources are the start, the old fisherman's dialogue, and quest rewards. Be careful when adding new ways to get it, so film never becomes unlimited.
5
+ - **Terrain is procedural, so coordinates cannot be hard-coded**: the cabin position (home) and the riverside (river) are computed at startup; everything in content/ is placed relative to them with `{ place: 'home', x, z }`.
@@ -0,0 +1,171 @@
1
+ # Game map: world (generated, do not edit by hand)
2
+
3
+ > Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /, 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 3 · containers 1 · dialogues 1 · items 4 · npcs 1 · pickups 8 · places 3 · props 8 (from templates 1) · quests 1 · templates 1 · vegetation 5 · kinds: bodies 8
7
+
8
+ ## Design decisions (hand-written, from DESIGN.md)
9
+
10
+ - **The pace is "slow"**: no combat, no failure; the player progresses by taking photos and wandering. For any new mechanic, first ask "will it make people feel rushed?"; if so, leave it out.
11
+ - **Film is the only limited resource**: each photo uses one (photo:taken in main.js); the only sources are the start, the old fisherman's dialogue, and quest rewards. Be careful when adding new ways to get it, so film never becomes unlimited.
12
+ - **Terrain is procedural, so coordinates cannot be hard-coded**: the cabin position (home) and the riverside (river) are computed at startup; everything in content/ is placed relative to them with `{ place: 'home', x, z }`.
13
+
14
+ ## Engine modules (engine.use)
15
+
16
+ - createEngine: { style: lowpoly, strings: terrainStrings, ui: { loading: { title: '慢慢走' } } }
17
+ - openWorld preset ({ camera: 'follow', seed: SEED, terrain: terrainPreset(), flatten: [{ x: home.x, z: home.z, radius:…) → world, terrain, vegetation, sky, weather, water, collision, rigid, characters, ambience, settings, debug
18
+ - interactions ({ ...presets.interactions.nearest })
19
+ - dialogue
20
+ - inventory ({ ...presets.keys.inventory })
21
+ - quests ({ ...presets.keys.quests })
22
+ - photo ({ ...presets.keys.photo })
23
+ - timeline
24
+ - triggers
25
+ - entities
26
+ - particles
27
+ - music ({ duckDialogue: 0.35 })
28
+ - hud
29
+
30
+ ## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
31
+
32
+ - world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
33
+ - terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
34
+ - vegetation: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/vegetation.md`
35
+ - sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
36
+ - weather: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/weather.md`
37
+ - water: `node_modules/threedog/docs/recipes/44-water-weather-look-hooks.md` · `node_modules/threedog/docs/api/water.md`
38
+ - collision: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/collision.md`
39
+ - rigid: `node_modules/threedog/docs/recipes/11-vehicles.md` · `node_modules/threedog/docs/api/rigid.md`
40
+ - characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
41
+ - ambience: `node_modules/threedog/docs/recipes/31-audio.md` · `node_modules/threedog/docs/api/ambience.md`
42
+ - …12 more modules: their pages are in `node_modules/threedog/docs/api/`
43
+
44
+ Not used yet (check these before writing the system yourself):
45
+
46
+ - grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
47
+
48
+ ## Files
49
+
50
+ 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…).
51
+
52
+ | File | Lines | Description |
53
+ |---|---|---|
54
+ | content/actions.js | 9 | |
55
+ | content/audio.js | 26 | |
56
+ | content/bodies.js | 13 | |
57
+ | content/containers.js | 5 | |
58
+ | content/dialogues.js | 34 | |
59
+ | content/index.js | 18 | |
60
+ | content/items.js | 11 | |
61
+ | content/npcs.js | 15 | |
62
+ | content/pickups.js | 12 | |
63
+ | content/places.js | 7 | |
64
+ | content/props.js | 13 | |
65
+ | content/quests.js | 16 | |
66
+ | content/rules.js | 24 | |
67
+ | content/templates.js | 6 | |
68
+ | content/vegetation.js | 33 | |
69
+ | main.js | 169 | Open-world example (slow photography life): riverside cabin + an old fisherman who walks by the clo… |
70
+ | models.js | 29 | Models this game builds in code: the cabin (registered by name in main.js, placed by content/props.… |
71
+
72
+ ## NPCs (content/npcs.js)
73
+
74
+ | id | Name | Schedule | Dialogue entry |
75
+ |---|---|---|---|
76
+ | fisher | 老渔夫 | 06:00 river · 12:00 home(-4,4) · 19:12 home(1,4.5) | fisher → start |
77
+
78
+ ## Dialogues (content/dialogues.js, node → destination)
79
+
80
+ - **fisher** (老渔夫): start (3 line variants: flag metFisher and after 17:00; flag metFisher…)[set flag metFisher]→ask · ask→sunset / forest / film(if fewer than film×6) / barter(if can barter.buy shop=fisher-basket item=berry)[op barter.buy shop=fisher-basket item=berry] / walk · sunset→end · forest→end · film[give film×6]→end · barter→end · walk→end
81
+
82
+ ## Items (content/items.js)
83
+
84
+ | id | Name | Description | Stack |
85
+ |---|---|---|---|
86
+ | film | 🎞 胶卷 | 每拍一张用掉一格 | 36 |
87
+ | berry | 🫐 野莓 | 路边摘的,有点酸 | 99 |
88
+ | feather | 🪶 羽毛 | 不知道是什么鸟的 | 99 |
89
+ | wood | 🪵 木头 | 砍树得到的 | 99 |
90
+
91
+ Starting inventory: film×12. Pickups: 8: feather×3, berry×5 (respawn after 120 s).
92
+
93
+ ## Quests (content/quests.js)
94
+
95
+ - **first-light** 第一缕光 (starts on engine:ready), reward: give film×12
96
+ 1. 和老渔夫聊聊(靠近按 E) ⟶ flag metFisher (target: NPC fisher)
97
+ 2. 收集 3 个野莓 ⟶ has berry×3
98
+ 3. 在 17:00–19:00 之间拍一张照片(按 P) ⟶ counter sunsetPhotos≥1
99
+
100
+ ## Game content kinds (content/rules.js kinds)
101
+
102
+ - **bodies** (content/bodies.js) physics props (id -> { shape: crate | ball | barrel, place, x, z, float? }): world records of kind body, given a rigid body in main.js
103
+ - 8 entries: crate-0, crate-1, crate-2, crate-3, crate-4, crate-5, ball, barrel
104
+
105
+ ## Trigger zones, level markers, places
106
+
107
+ - Place home: cabin (a flat spot found on the terrain at startup; the cabin stands here)
108
+ - Place river: nearest riverside to the cabin (found at startup; the old fisherman goes here in the morning)
109
+ - Place water: the water just past that riverside (found at startup; the barrel floats here)
110
+
111
+ ## Conditions/effects the game adds (content/rules.js)
112
+
113
+ - Condition **timeAfter** (clock): the day has passed this clock time
114
+
115
+ ## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
116
+
117
+ | Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
118
+ |---|---|---|---|---|---|---|
119
+ | cabin | cabin | box | — | — | — | 1 placed (home) |
120
+
121
+ ## Placements (the level is content; counts per content file)
122
+
123
+ - content/props.js: 8 (pine×2, roundTree×1, rock×2, flower×2, template cabin×1); 1 with an explicit id, places: home
124
+ - content/pickups.js: 8 (feather×3, berry×5)
125
+ - content/npcs.js: 1 (fisher)
126
+ - content/containers.js: 1 (fisher-basket)
127
+ - content/vegetation.js: 5 rules (instances generated from each rule)
128
+ - content/bodies.js (game kind): 8 (crate×6, ball×1, barrel×1)
129
+
130
+ Code that breaks saves or manages world models: none (rule R33).
131
+
132
+ ## Timed events (engine.clock, engine.sky)
133
+
134
+ - between('18:00', '06:00') — main.js
135
+
136
+ ## Objective markers and HUD (hud module)
137
+
138
+ - Quest first-light step 1 is marked automatically
139
+ - hud.counter('film') — main.js
140
+
141
+ ## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
142
+
143
+ | Action | Default keys | Label | Handled in |
144
+ |---|---|---|---|
145
+ | save | KeyK | 存档 | main.js |
146
+ | load | KeyL | 读档 | main.js |
147
+ | kick | KeyF | 推/踢 | main.js |
148
+ | chop | KeyC | 砍树 | main.js |
149
+
150
+ ## Events the game emits / listens to
151
+
152
+ | Event | Emitted by the game | Listened to by the game |
153
+ |---|---|---|
154
+ | character:land | — | main.js |
155
+ | engine:ready | — | main.js, quests.js (starts first-light) |
156
+ | photo:denied | — | main.js |
157
+ | photo:taken | — | main.js |
158
+
159
+ ## Saves
160
+
161
+ - Save prefix saveKey: default
162
+ - Save slots: slot1
163
+ - Autosave: every 3 minutes
164
+ - Saved parts of the engine modules (vars, inventory, quests, timers, world...): `npx threedog catalog` (saves per module)
165
+
166
+ ## Style pack keys
167
+
168
+ - Style pack: lowpoly
169
+ - Models (asset names): pine, pineLow, roundTree, roundTreeLow, rock, grass, flower, cabin
170
+ - Particle presets (style.particles): smoke, leaves, dust
171
+ - Vegetation (content/vegetation.js): 松树, 圆树, 石头, 草, 野花
@@ -0,0 +1,8 @@
1
+ // Game-specific key actions: action name -> default key and display label. What a press does lives in main.js (engine.input.pressed('action name')).
2
+ // Built-in module actions (move, jump, interact E, inventory I, quests J, photo P...) need no entry here.
3
+ export default {
4
+ save: { keys: ['KeyK'], label: '存档' },
5
+ load: { keys: ['KeyL'], label: '读档' },
6
+ kick: { keys: ['KeyF'], label: '推/踢' },
7
+ chop: { keys: ['KeyC'], label: '砍树' },
8
+ };
@@ -0,0 +1,25 @@
1
+ // This game's sounds, as content data (content.load reads the audio table): sounds are the game's, not the style pack's. 'synth' plays the
2
+ // engine's synthesized sound; any other string is a sound name from an asset pack (engine.assets.manifest({ sounds })); anything omitted is silent.
3
+ // Data only, so no functions: conditions compare measures (daylight from sky, rain / snow / wind from weather, nearWater / altitude from ambience).
4
+ const step = surface => ({ synth: 'footstep', params: { surface } });
5
+
6
+ export default {
7
+ sounds: {
8
+ // footsteps per surface (built-in footstep synth); a file version: 'step.grass': ['grass-1', 'grass-2'] (asset pack sound names)
9
+ 'step.grass': step('grass'), 'step.sand': step('sand'), 'step.rock': step('rock'), 'step.snow': step('snow'), 'step.water': step('water'),
10
+ shutter: 'synth', thunder: 'synth',
11
+ wind: 'synth', rain: 'synth', water: 'synth', birds: 'synth', crickets: 'synth', // ambience synths (ambience() module)
12
+ },
13
+ // Ambience rule table: while `when` holds the sound plays at `volume`; `every` makes it a one-shot at random gaps
14
+ ambience: [
15
+ // stronger with wind and higher up: 0.15 more at 40 m above sea level (altitude factor 0.15 / 40)
16
+ { sound: 'wind', volume: { base: 0.05, add: { wind: 0.08, altitude: 0.00375 }, max: 0.5 }, fade: 0.8 },
17
+ { sound: 'rain', volume: { add: { rain: 0.22 } } }, // volume 0 = off: the loop fades out and stops
18
+ { sound: 'water', volume: { add: { nearWater: 0.12 } } },
19
+ { sound: 'birds', when: { daylight: { gt: 0.15 }, rain: { lt: 0.2 } }, every: [1.5, 6.5] },
20
+ { sound: 'crickets', when: { daylight: { lt: 0.05 }, rain: { lt: 0.2 }, snow: { lt: 0.2 } }, every: [0.4, 1.6] },
21
+ ],
22
+ // Ground type (terrainPreset biome names) -> footstep sound; water while swimming; default for anything else
23
+ footsteps: { beach: 'step.sand', rock: 'step.rock', snow: 'step.snow', water: 'step.water', default: 'step.grass' },
24
+ // Background music (asset pack sound names): music: { tracks: { day: 'music-day' }, rules: [{ track: 'night', when: { time: 'night' } }, { track: 'day' }] }
25
+ };
@@ -0,0 +1,12 @@
1
+ // Physics props (a game kind, declared in rules.js): id -> { shape, place, x, z, float? }. Each entry is a world record of kind 'body' with a stable id;
2
+ // main.js gives it a mesh and a rigid body, and a pushed crate's position is saved as a change on top of this data. float: starts above the water surface.
3
+ export default {
4
+ 'crate-0': { shape: 'crate', place: 'home', x: 5, z: -1 },
5
+ 'crate-1': { shape: 'crate', place: 'home', x: 5.85, z: -1 },
6
+ 'crate-2': { shape: 'crate', place: 'home', x: 6.7, z: -1 },
7
+ 'crate-3': { shape: 'crate', place: 'home', x: 5, z: -0.1 },
8
+ 'crate-4': { shape: 'crate', place: 'home', x: 5.85, z: -0.1 },
9
+ 'crate-5': { shape: 'crate', place: 'home', x: 6.7, z: -0.1 },
10
+ ball: { shape: 'ball', place: 'home', x: 2, z: 9 },
11
+ barrel: { shape: 'barrel', place: 'water', x: 0, z: 0, float: true },
12
+ };
@@ -0,0 +1,4 @@
1
+ // Containers: id -> { capacity, items: starting goods (placed only the first time, then saved). The fisher's basket is the shelf of the barter.buy op in main.js.
2
+ export default {
3
+ 'fisher-basket': { capacity: 4, items: { berry: 3, feather: 1 } },
4
+ };
@@ -0,0 +1,33 @@
1
+ // Dialogues: each starts at the start node. next points to the next node ('end' finishes); choices are the options;
2
+ // if is a condition, do is an effect (syntax in packages/engine/modules/content/rules.js; timeAfter is a word this game adds, see its rules.js); text may be several variants, the first whose condition holds is used.
3
+ export default {
4
+ fisher: {
5
+ speaker: '老渔夫',
6
+ nodes: {
7
+ start: {
8
+ text: [
9
+ { if: { flag: 'metFisher', timeAfter: '17:00' }, text: '又见面了。这会儿的光最好,快去拍吧。' },
10
+ { if: { flag: 'metFisher' }, text: '又见面了。今天拍到好照片了吗?' },
11
+ { text: '哟,背着相机的年轻人。很少有人走到这边来。' },
12
+ ],
13
+ do: { setFlag: 'metFisher' },
14
+ next: 'ask',
15
+ },
16
+ ask: {
17
+ text: '你想拍什么?',
18
+ choices: [
19
+ { text: '日落', next: 'sunset' },
20
+ { text: '森林', next: 'forest' },
21
+ { text: '有胶卷卖吗?', next: 'film', if: { lacks: { film: 6 } } },
22
+ { text: '用胶卷换点野莓', next: 'barter', if: { can: ['barter.buy', { shop: 'fisher-basket', item: 'berry' }] }, do: { op: ['barter.buy', { shop: 'fisher-basket', item: 'berry' }] } },
23
+ { text: '没想好,随便走走', next: 'walk' },
24
+ ],
25
+ },
26
+ sunset: { text: '傍晚五六点,往高处走,太阳会从树梢后面落下去。', next: 'end' },
27
+ forest: { text: '林子里的光早上最好。起风的时候草会晃,别急着按快门。', next: 'end' },
28
+ film: { text: '拿去吧,我年轻时也拍过。', do: { give: { film: 6 } }, next: 'end' },
29
+ barter: { text: '一卷换一把,刚摘的。', next: 'end' },
30
+ walk: { text: '那也不错。慢慢走,路会告诉你该拍什么。', next: 'end' },
31
+ },
32
+ },
33
+ };
@@ -0,0 +1,17 @@
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 places from './places.js';
3
+ import items, { startItems } from './items.js';
4
+ import containers from './containers.js';
5
+ import pickups from './pickups.js';
6
+ import npcs from './npcs.js';
7
+ import dialogues from './dialogues.js';
8
+ import quests from './quests.js';
9
+ import actions from './actions.js';
10
+ import vegetation from './vegetation.js';
11
+ import templates from './templates.js';
12
+ import props from './props.js';
13
+ import bodies from './bodies.js';
14
+ import rules from './rules.js';
15
+ import audio from './audio.js';
16
+
17
+ export default { places, items, startItems, containers, pickups, npcs, dialogues, quests, actions, vegetation, templates, props, bodies, rules, audio };
@@ -0,0 +1,10 @@
1
+ // Items: id -> name, icon, description. stack is the max per slot (default 99); color is the color when dropped on the ground.
2
+ export default {
3
+ film: { name: '胶卷', icon: '🎞', desc: '每拍一张用掉一格', stack: 36 },
4
+ berry: { name: '野莓', icon: '🫐', desc: '路边摘的,有点酸', color: 0x6a5acd },
5
+ feather: { name: '羽毛', icon: '🪶', desc: '不知道是什么鸟的', color: 0xf4efe2 },
6
+ wood: { name: '木头', icon: '🪵', desc: '砍树得到的', color: 0x8a5a36 },
7
+ };
8
+
9
+ // Starting inventory
10
+ export const startItems = { film: 12 };
@@ -0,0 +1,14 @@
1
+ // NPCs: in a schedule, at is a clock time ('06:00'); at that time the NPC walks to the spot. talk is a dialogue id (dialogues.js).
2
+ export default {
3
+ fisher: {
4
+ name: '老渔夫',
5
+ colors: { body: 0x4f6d8f, legs: 0x5b4a3a, hair: 0xd8d4cc },
6
+ start: { place: 'home', x: 1, z: 5 },
7
+ schedule: [
8
+ { at: '06:00', place: 'river' }, // go to the riverside
9
+ { at: '12:00', place: 'home', x: -4, z: 4 }, // go home
10
+ { at: '19:12', place: 'home', x: 1, z: 4.5 }, // sit at the doorway
11
+ ],
12
+ talk: 'fisher',
13
+ },
14
+ };