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
package/core/claims.js ADDED
@@ -0,0 +1,51 @@
1
+ // claims(): one small "who holds this" primitive shared by pause, freeze, the camera takeover and debug views.
2
+ // Why one primitive: those four each grew their own owner rules (pause warned, freeze was silent, the camera had no owner at all, a debug view checked
3
+ // its owner only on 'off'), so a tool could not predict what release by a non-owner does. Here the rules are the same everywhere:
4
+ // - take(owner, data) -> { owner, remove() }: the same owner taking again updates its data, keeps its place and time (one claim per owner)
5
+ // - only the owner releases: release(owner) / handle.remove() drop that owner's claim and nothing else; a stale handle (the owner released and took
6
+ // again since) removes nothing, so an old handle cannot cancel a newer claim
7
+ // - owners() -> [{ owner, at }] is what describe shows, the same shape for every user
8
+ // Look layers, the input stack and sky.modify keep their own owner models on purpose (layered values, a stack, blended layers): different semantics.
9
+ import { codedError } from './errorHints.js';
10
+
11
+ /**
12
+ * @param {{ what: string, now?: () => number, onChange?: () => void }} o what names the user in error messages; now gives `at`; onChange runs after any take / release
13
+ */
14
+ export function claims({ what, now = () => 0, onChange = () => {} }) {
15
+ /** @type {Map<string, { owner: string, at: number, data: any }>} */
16
+ const held = new Map();
17
+ const drop = (owner, c) => { if (c && held.get(owner) !== c) return false; if (!held.delete(owner)) return false; onChange(); return true; };
18
+ return {
19
+ /** @param {string} owner @param {any} [data] */
20
+ take(owner, data) {
21
+ if (!owner || typeof owner !== 'string') throw codedError('claim-owner', `${what}: owner is a non-empty string naming who holds it, e.g. 'my-menu', got ${JSON.stringify(owner)}`);
22
+ let c = held.get(owner);
23
+ if (c) c.data = data; else held.set(owner, c = { owner, at: now(), data });
24
+ onChange();
25
+ return { owner, remove: () => { drop(owner, c); } };
26
+ },
27
+ /** Drop owner's claim; false when it held none @param {string} owner */
28
+ release(owner) { return drop(owner); },
29
+ /** @param {string} owner */
30
+ has(owner) { return held.has(owner); },
31
+ get size() { return held.size; },
32
+ /** Owner names in take order */
33
+ names() { return [...held.keys()]; },
34
+ /** @returns {{ owner: string, at: number }[]} */
35
+ owners() { return [...held.values()].map(({ owner, at }) => ({ owner, at })); },
36
+ /** The claim taken last (the one in charge where only one can act: the camera), or null */
37
+ top() { let t = null; for (const c of held.values()) t = c; return t; },
38
+ /** Claims whose data matches pred (pause kinds) @param {(data: any) => boolean} pred */
39
+ some(pred) { for (const c of held.values()) if (pred(c.data)) return true; return false; },
40
+ clear() { if (!held.size) return; held.clear(); onChange(); },
41
+ };
42
+ }
43
+
44
+ /**
45
+ * pause('x') and pause({ owner: 'x' }) both work: look parts pass { owner }, the loop kept a positional owner; both spellings are accepted everywhere
46
+ * @param {string | { owner?: string } | undefined} a @param {any} [b] @returns {{ owner: string, opts: any }}
47
+ */
48
+ export function ownerArgs(a, b, fallback = 'game') {
49
+ if (a && typeof a === 'object') return { owner: a.owner ?? fallback, opts: a };
50
+ return { owner: a ?? fallback, opts: b ?? {} };
51
+ }
@@ -0,0 +1,15 @@
1
+ // Clock-time conversion (pure functions): sky time of day `timeOfDay` is the fraction of a day, 0-1, and 'HH:MM' is just another way to write it. engine.sky timers, npc schedules and music conditions all use it.
2
+ /** 'HH:MM' or 0-1 (a number, or text such as '0.25' from a URL) -> fraction of a day, 0-1 (hoursPerDay = hours in a day, default 24) */
3
+ export function parseClock(v, hoursPerDay = 24) {
4
+ if (typeof v === 'number' || !String(v).includes(':')) return +v;
5
+ const [h, m = 0] = String(v).split(':').map(Number);
6
+ return (h + m / 60) / hoursPerDay;
7
+ }
8
+ /** Is time t (0-1) inside the window [from, to)? (from and to are 'HH:MM' or 0-1; from > to wraps past midnight). sky.between and the audio rule condition { time: [from, to] } both use it */
9
+ export function inRange(t, from, to, hoursPerDay = 24) { return inFrac(t, parseClock(from, hoursPerDay), parseClock(to, hoursPerDay)); }
10
+ export const inFrac = (t, a, b) => (a <= b ? t >= a && t < b : t >= a || t < b);
11
+ /** Fraction of a day 0-1 -> 'HH:MM' */
12
+ export function formatClock(t, hoursPerDay = 24) {
13
+ const h = Math.floor(t * hoursPerDay), m = Math.floor((t * hoursPerDay - h) * 60);
14
+ return String(h).padStart(2, '0') + ':' + String(m).padStart(2, '0');
15
+ }
@@ -0,0 +1,76 @@
1
+ // Diagnostic view modes behind engine.debug.view('albedo' | 'lighting' | 'shadow' | 'normals' | 'off') (DebugOverrides.js).
2
+ // Temporary and owner-scoped: it changes how the scene is drawn (material swap / scene.overrideMaterial / lights hidden) and puts everything back on 'off'
3
+ // or when its owner clears (engine.debug.clear(owner)). Never saved, never part of the game's state; describe().render says so while one is active,
4
+ // so an AI reading a screenshot does not take "all white clay" for the real look.
5
+ // Why a view is an entry of the debug override chain and not its own material swap: two independent swaps on one mesh restored each other's stale
6
+ // material and disposed the real one (review H3). In the chain, the albedo view is a { material: 'flat' } entry on the scene and the other modes an apply()
7
+ // entry whose undo only puts back what it changed, and only disposes the override material it created.
8
+ // One view at a time, held as a claim (core/claims.js): only its owner (or force) switches it or turns it off.
9
+ import * as THREE from 'three';
10
+ import { warnMissing } from './validate.js';
11
+ import { claims } from './claims.js';
12
+
13
+ const VIEW_MODES = ['albedo', 'lighting', 'shadow', 'normals', 'off'];
14
+ const EXPLAIN = {
15
+ albedo: 'unlit base color and texture only (no lights, no shadows)',
16
+ lighting: 'every surface plain white matte: shows only what the lights do (no textures)',
17
+ shadow: 'plain white matte lit by direct lights only (ambient and hemisphere lights hidden): shadows read as black',
18
+ normals: 'surface normals as color (x/y/z -> r/g/b); a normal map shows here, flat shading looks faceted',
19
+ };
20
+
21
+ /** apply() for the scene-wide modes: returns an undo that restores only what this call changed */
22
+ function sceneMode(mode) {
23
+ return scene => {
24
+ // plain three materials on purpose: a diagnostic must not depend on the style pack it diagnoses
25
+ const mat = mode === 'normals' ? new THREE.MeshNormalMaterial() : new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 1, metalness: 0 }); // debug view only
26
+ const was = scene.overrideMaterial, hidden = [];
27
+ scene.overrideMaterial = mat;
28
+ if (mode === 'shadow') scene.traverse(o => { if ((o.isAmbientLight || o.isHemisphereLight || o.isLightProbe) && o.visible) { o.visible = false; hidden.push(o); } });
29
+ return () => {
30
+ if (scene.overrideMaterial === mat) scene.overrideMaterial = was;
31
+ mat.dispose(); // ours: created above
32
+ for (const l of hidden) if (!l.visible) l.visible = true;
33
+ };
34
+ };
35
+ }
36
+
37
+ export class DebugView {
38
+ /** @param {any} engine @param {any} debug the engine.debug override chain it lives in */
39
+ constructor(engine, debug) {
40
+ this.engine = engine; this.debug = debug;
41
+ /** @type {{ mode: string, owner: string } | null} the active view (null = the real look) */
42
+ this.active = null;
43
+ this._holder = claims({ what: 'engine.debug.view', now: () => engine.elapsed ?? 0 });
44
+ this._entry = null;
45
+ }
46
+ /**
47
+ * Show a diagnostic view; 'off' restores the real look. Temporary: never saved, and a game that reads it must not branch on it.
48
+ * owner names who asked ('debug' by default): while one owner's view is on, another owner can neither switch it nor turn it off unless it passes force.
49
+ * @param {'albedo' | 'lighting' | 'shadow' | 'normals' | 'off'} mode
50
+ * @param {{ owner?: string, force?: boolean }} [opts]
51
+ * @returns {{ mode: string, owner: string | null, what?: string, note?: string }}
52
+ */
53
+ set(mode, { owner = 'debug', force = false } = {}) {
54
+ if (!VIEW_MODES.includes(mode)) { warnMissing('debug view', String(mode), VIEW_MODES); return this.state(); }
55
+ const a = this.active;
56
+ if (a && a.owner !== owner && !force) return { ...this.state(), note: `view "${a.mode}" belongs to "${a.owner}"; pass { owner: '${a.owner}' } or force: true to ${mode === 'off' ? 'clear' : 'switch'} it` };
57
+ this._off();
58
+ if (mode === 'off') return this.state();
59
+ const e = this.engine, scene = e.scene;
60
+ const patch = mode === 'albedo' ? { material: 'flat' } : { apply: sceneMode(mode) };
61
+ this._entry = this.debug._add({ owner, id: 'view:' + mode, byId: false, obj: scene, patch, undo: null, view: true });
62
+ this._holder.take(owner, { mode });
63
+ this.active = { mode, owner };
64
+ return this.state();
65
+ }
66
+ /** Turn off the view if owner holds it (engine.debug.clear(owner)); true when it did */
67
+ releaseOwner(owner) { if (this.active?.owner !== owner) return false; this._off(); return true; }
68
+ /** @returns {{ mode: string, owner: string | null, what?: string }} the active view, or { mode: 'off' } */
69
+ state() { return this.active ? { ...this.active, what: EXPLAIN[this.active.mode] } : { mode: 'off', owner: null }; }
70
+ /** Who holds the view, the same shape as every other claim: [{ owner, at }] */
71
+ owners() { return this._holder.owners(); }
72
+ _off() {
73
+ this._entry?.remove(); this._entry = null;
74
+ this._holder.clear(); this.active = null;
75
+ }
76
+ }
@@ -0,0 +1,45 @@
1
+ // describe().render: what the renderer, lights and post effects are set to now (facts read from three.js and the post chain).
2
+ // Who set a value lives in one place, describe().look: each `by` here is the path of that record ('look.tone.exposure'), not a second
3
+ // answer worked out again (review r2 #11); 'engine' when no look part covers it. The text line shows the look record's tag for reading.
4
+ // This is information only: the engine never warns when a game changes the renderer or lights.
5
+ import { SHADOW_TYPES } from './shadowTypes.js';
6
+ import { describeLook } from './look/report.js';
7
+ import { r1 } from './math.js';
8
+
9
+ const shadowName = v => Object.keys(SHADOW_TYPES).find(k => SHADOW_TYPES[k].three === v) ?? String(v);
10
+
11
+ /**
12
+ * Record how the renderer was made.
13
+ * @param {any} e
14
+ * @param {{ owned: boolean }} o owned: false when the game passed its own renderer (then the style's tone mapping / exposure were not applied by the engine)
15
+ */
16
+ export function recordRender(e, { owned }) {
17
+ e._renderBase = { owned };
18
+ }
19
+
20
+ /** The render section: structured data plus one compact text block (`text`) @param {any} e */
21
+ export function describeRender(e) {
22
+ const r = e.renderer, b = e._renderBase;
23
+ if (!b) return undefined;
24
+ const look = describeLook(e) ?? {};
25
+ const who = (part, key) => (look[part]?.[key] ? `look.${part}.${key}` : 'engine'); // the record to read in describe().look
26
+ const tag = path => { const [, part, ...k] = path.split('.'); return look[part]?.[k.join('.')]?.by ?? 'engine'; }; // for the text line only
27
+ const tone = { value: look.tone?.mapping?.value, by: who('tone', 'mapping') };
28
+ const exposure = { value: r1(r.toneMappingExposure), by: who('tone', 'exposure') }; // keyframes / a function: the value used this frame
29
+ const shadows = { enabled: r.shadowMap.enabled, type: shadowName(r.shadowMap.type), by: who('shadow', 'type') };
30
+ const post = (e.post?._list || []).map(h => ({ name: h.name, on: h.enabled, params: { ...h.params }, by: who('post', `${h.name}.enabled`),
31
+ ...(e.post._offWhy?.[h.name] && !h.enabled ? { why: e.post._offWhy[h.name] } : {}) }));
32
+ const lights = Object.entries(e.lights || {}).filter(([, l]) => l.parent)
33
+ .map(([name, l]) => ({ name, type: l.type, intensity: r1(l.intensity), source: 'engine-default', by: who('lights', `${name}.intensity`) }));
34
+ const kv = x => Object.entries(x).map(([k, v]) => `${k}=${typeof v === 'number' ? r1(v) : v}`).join(' ');
35
+ const srgb = r.outputColorSpace === 'srgb' ? '' : ' (WRONG: colors are encoded for srgb; color textures must be srgb, data maps linear, see assets.report)';
36
+ let text = [
37
+ `renderer: ${tone.value} (${tag(tone.by)}) exposure ${exposure.value} (${tag(exposure.by)}) shadows ${shadows.enabled ? shadows.type : 'off'} (${tag(shadows.by)})${b.owned ? '' : ' [game-supplied renderer]'} output ${r.outputColorSpace}${srgb}`,
38
+ `post: ${post.map(x => `${x.name}${x.on ? '' : x.why ? ' off (low-tier default)' : ' off'}${Object.keys(x.params).length ? `{${kv(x.params)}}` : ''} (${tag(x.by)})`).join(', ') || 'none'}${e.post?.antialias ? ' + MSAA' : ''}`,
39
+ `lights (engine-added defaults; extra scene lights are not listed): ${lights.map(l => `${l.name} ${l.type} ${l.intensity} (${tag(l.by)})`).join(', ')}`,
40
+ ].join('\n');
41
+ const dv0 = e.debug?.viewState?.(), dv = dv0 && dv0.mode !== 'off' ? dv0 : null;
42
+ if (dv) text = `DEBUG VIEW "${dv.mode}" (by ${dv.owner}) is ON: ${dv.what}. This is NOT the real look; the debug view 'off' restores it.
43
+ ` + text;
44
+ return { debugView: dv, toneMapping: tone, exposure, shadows, post, lights, text };
45
+ }
@@ -0,0 +1,143 @@
1
+ // engine.describeText(): write describe() as plain English for an AI to read, summary first to save context.
2
+ // describeText() summary (at most 30 lines): standard lines, the 5 nearest things, one line per module with its key counts and state
3
+ // describeText({ path: 'world.byKind' }) one part of describe() as JSON (a dotted path)
4
+ // describeText({ full: true }) every nearby thing and every module's full data
5
+ // describe() itself (the object) is always complete.
6
+ // Always English, whatever the locale: it is developer output, not player-facing. Ground and weather names come from the
7
+ // describe result (groundName / weather.label, via the string tables) so no style pack's names are hardcoded here.
8
+ const STRINGS = {
9
+ head: '[Game state] running {s} s{flags}',
10
+ actions: 'Can do (engine.ops): {list}',
11
+ error: '[Error, gameplay frozen] {where}: {message}',
12
+ errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled presentation modules (they threw): {list}',
13
+ paused: ', paused', headless: ', headless', notReady: ', still loading',
14
+ waiting: 'Loading: {waiting} ({pending} pending, {done}/{total} done)', loadFailed: 'Load failed{blocked}: {list}', blocked: ' (start blocked)',
15
+ loadWarn: 'Loaded with missing references: {list}',
16
+ time: 'Time: {clock}, day {day}{season}, {dayNight}',
17
+ day: 'daytime', night: 'night',
18
+ weather: 'Weather: {name}{changing} (rain {rain}, snow {snow}, fog {fog}){shown}',
19
+ weatherShown: ', on screen: {what}', rainShown: 'raindrops', snowShown: 'snowflakes',
20
+ changing: ', transitioning ({pct}%)',
21
+ player: 'Player: ({x}, {y}, {z}), ground {ground}, {water}, state {state}',
22
+ inWater: 'in water', dry: 'not in water', noPlayer: 'Player: none',
23
+ pointerLock: 'Pointer lock: {state}',
24
+ camera: 'Camera: {type}, position ({x}, {y}, {z}), focus ({fx}, {fz}){over}',
25
+ override: ', taken over by "{owner}"',
26
+ cutscene: 'Cutscene: {n} playing{skip}',
27
+ overrides: 'Diagnostic overrides active (the screen is not the real state): {list}',
28
+ skippable: ' (skippable)',
29
+ dialogue: 'Dialogue: {speaker}: "{text}"{choices}',
30
+ choices: ' Choices: {list}',
31
+ windows: 'Open windows: {list}', inputLocked: ' (game input locked)',
32
+ nearHead: 'Within {r} m ({n}, by distance):',
33
+ nearNone: 'Within {r} m: nothing',
34
+ nearItem: ' - {name} [{kind}] {dist} m, {dir}, {rel}{use}',
35
+ use: ', interact: {label}',
36
+ modules: 'Modules: {list}',
37
+ perf: 'Perf: fps {fps}, CPU {cpu} ms/frame, draw calls {calls}, triangles {tris}{chunks}',
38
+ chunks: ', chunks loaded {loaded} / visible {visible} / queued {queued}',
39
+ extra: '{name}: {json}',
40
+ more: '... ({n} more lines omitted)',
41
+ nearMore: ' ... {n} more',
42
+ expand: 'More: describeText({ path: \'<module>\' }) for one part, describeText({ full: true }) for everything (CLI: threedog describe <path> / --full)',
43
+ noPath: 'describe() has no "{path}"; top-level keys: {keys}',
44
+ none: 'none',
45
+ state: { idle: 'standing', walk: 'walking', run: 'running', jump: 'jumping', fall: 'falling', swim: 'swimming' },
46
+ kind: { npc: 'NPC', pickup: 'pickup', interactable: 'interactable', trigger: 'trigger', entity: 'entity' },
47
+ dir: { N: 'north', NE: 'northeast', E: 'east', SE: 'southeast', S: 'south', SW: 'southwest', W: 'west', NW: 'northwest' },
48
+ rel: { front: 'ahead', 'front-right': 'ahead right', right: 'right', 'back-right': 'behind right', back: 'behind', 'back-left': 'behind left', left: 'left',
49
+ 'front-left': 'ahead left' },
50
+ season: { spring: 'spring', summer: 'summer', autumn: 'autumn', winter: 'winter' },
51
+ camType: { follow: 'follow camera', first: 'first person', fixed: 'fixed camera', rts: 'top-down strategy camera' },
52
+ };
53
+ import { fmt } from './validate.js';
54
+ import { r1 } from './math.js';
55
+ import { getPath } from './util.js';
56
+
57
+ const NEAR_SUMMARY = 5, LINE = 110;
58
+ const tr = (table, k) => (k != null && STRINGS[table][k]) || (k ?? STRINGS.none);
59
+ const n1 = v => (typeof v === 'number' ? r1(v) : v);
60
+ // Standard fields get sentences above; data from other modules is squeezed into one JSON line
61
+ const SHOWN = new Set(['nearbyRadius', 'ready', 'error', 'disabledModules', 'loading', 'time', 'player', 'camera', 'nearby', 'actions', 'ui', 'cutscene',
62
+ 'modules', 'perf', 'weather', 'render']);
63
+ const argText = a => Object.entries(a || {}).map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(',') : v}`).join(' ');
64
+
65
+ /** One module's data in a line: scalars as k=v, arrays as k[n], objects as k{n keys} (nested data is one describeText({ path }) away) */
66
+ function summary(v) {
67
+ if (v == null || typeof v !== 'object') return String(v);
68
+ if (Array.isArray(v)) return `[${v.length}]`;
69
+ const one = x => (typeof x === 'string' && x.length > 24 ? x.slice(0, 23) + '…' : x);
70
+ const parts = Object.entries(v).map(([k, x]) => x == null || typeof x !== 'object' ? `${k}=${one(x)}`
71
+ : Array.isArray(x) ? `${k}[${x.length}]` : `${k}{${Object.keys(x).length}}`);
72
+ const s = parts.join(', ');
73
+ return s.length > LINE ? s.slice(0, LINE - 1) + '…' : s;
74
+ }
75
+
76
+ /** describe() at a dotted path as JSON text, or why there is nothing there */
77
+ function atPath(d, path) {
78
+ const v = getPath(d, path);
79
+ return v === undefined ? fmt(STRINGS.noPath, { path, keys: Object.keys(d).join(', ') }) : `${path}: ${JSON.stringify(v, null, 1)}`;
80
+ }
81
+
82
+ /**
83
+ * Write the describe() result as English text: a summary (at most maxLines lines), one part (path), or everything (full).
84
+ * @param {any} d a describe() result
85
+ * @param {{ full?: boolean, path?: string, maxLines?: number }} [opts]
86
+ */
87
+ export function describeText(d, { full = false, path, maxLines = 30 } = {}) {
88
+ if (path) return atPath(d, path);
89
+ const L = [], t = d.time;
90
+ const flags = (t.paused ? STRINGS.paused : '') + (t.headless ? STRINGS.headless : '') + (d.loading.done ? '' : STRINGS.notReady);
91
+ if (d.error) L.push(fmt(STRINGS.error, d.error)
92
+ + (d.error.fix ? fmt(STRINGS.errorHint, { code: d.error.code, fix: d.error.fix, docs: d.error.docs.join(', ') }) : ''));
93
+ L.push(fmt(STRINGS.head, { s: t.elapsed, flags }));
94
+ const ld = d.loading;
95
+ if (!ld.done) L.push(fmt(STRINGS.waiting, { waiting: ld.waiting, pending: ld.counts.pending, done: ld.counts.done, total: ld.counts.total }));
96
+ if (ld.failed.length) L.push(fmt(STRINGS.loadFailed,
97
+ { blocked: ld.blocked ? STRINGS.blocked : '',
98
+ list: ld.failed.map(f => `${f.kind} "${f.name}" ${f.error.url ?? ''} ${f.error.message}${f.fallback ? ` -> ${f.fallback}` : ''}`).join('; ') }));
99
+ if (ld.warnings.length) L.push(fmt(STRINGS.loadWarn, { list: ld.warnings.map(w => `"${w.name}" missing ${w.missing.join(', ')}`).join('; ') }));
100
+ if (d.disabledModules?.length) L.push(fmt(STRINGS.disabled, { list: d.disabledModules.join(', ') }));
101
+ if (t.clock) L.push(fmt(STRINGS.time, { clock: t.clock, day: t.day, season: t.season ? ', ' + tr('season', t.season) : '', dayNight: t.isDay ? STRINGS.day
102
+ : STRINGS.night }));
103
+ const w = d.weather;
104
+ if (w) L.push(fmt(STRINGS.weather, { name: w.label ?? w.name, rain: n1(w.rain), snow: n1(w.snow), fog: n1(w.fog),
105
+ changing: w.progress < 1 ? fmt(STRINGS.changing, { pct: Math.round(w.progress * 100) }) : '',
106
+ shown: w.rainVisible || w.snowVisible ? fmt(STRINGS.weatherShown,
107
+ { what: [w.rainVisible && STRINGS.rainShown, w.snowVisible && STRINGS.snowShown].filter(Boolean).join(', ') }) : '' }));
108
+ const p = d.player;
109
+ const water = p?.inWater ? STRINGS.inWater : STRINGS.dry;
110
+ L.push(p ? fmt(STRINGS.player, { ...p, ground: p.groundName ?? p.ground, water, state: tr('state', p.state) }) : STRINGS.noPlayer);
111
+ const c = d.camera;
112
+ L.push(fmt(STRINGS.camera, { type: tr('camType', c.type), x: c.x, y: c.y, z: c.z, fx: c.focus.x, fz: c.focus.z, over: c.override
113
+ ? fmt(STRINGS.override, { owner: c.override }) : '' }));
114
+ const pl = c.pointerLock; // state machine from lockView (camera/common.js); only cameras with click-to-lock report a line
115
+ if (pl?.configured) L.push(fmt(STRINGS.pointerLock, { state: pl.state + (pl.lastFailure ? ` (${pl.lastFailure.reason}, ${pl.lastFailure.agoSec} s ago)` : '')
116
+ + (pl.covered ? `; canvas centre covered by ${pl.covered}` : '') + (pl.cameraOverride ? `; cameraOverride ${pl.cameraOverride} blocks locking` : '') }));
117
+ if (d.scene?.overrides) L.push(fmt(STRINGS.overrides, { list: d.scene.overrides.map(o => `${o.owner}:${o.target}`).join(', ') }));
118
+ if (d.cutscene) L.push(fmt(STRINGS.cutscene, { n: d.cutscene.count, skip: d.cutscene.skippable ? STRINGS.skippable : '' }));
119
+ const dl = d.ui.dialogue;
120
+ if (dl) L.push(fmt(STRINGS.dialogue, { speaker: dl.speaker, text: dl.text, choices: dl.choices.length
121
+ ? fmt(STRINGS.choices, { list: dl.choices.map((x, i) => `${i + 1}. ${x}`).join(' ') }) : '' }));
122
+ if (d.ui.windows.length || d.ui.inputLocked) L.push(fmt(STRINGS.windows, { list: d.ui.windows.join(', ') || STRINGS.none })
123
+ + (d.ui.inputLocked ? STRINGS.inputLocked : ''));
124
+ const r = d.nearbyRadius;
125
+ L.push(d.nearby.length ? fmt(STRINGS.nearHead, { r, n: d.nearby.length }) : fmt(STRINGS.nearNone, { r }));
126
+ const near = full ? d.nearby : d.nearby.slice(0, NEAR_SUMMARY);
127
+ for (const it of near) L.push(fmt(STRINGS.nearItem,
128
+ { name: it.name, kind: tr('kind', it.kind), dist: it.dist, dir: tr('dir', it.dir), rel: tr('rel', it.rel), use: it.use ? fmt(STRINGS.use, { label: it.use })
129
+ : '' }));
130
+ if (near.length < d.nearby.length) L.push(fmt(STRINGS.nearMore, { n: d.nearby.length - near.length }));
131
+ if (d.actions) L.push(fmt(STRINGS.actions,
132
+ { list: d.actions.map(a => `${a.ok ? '✓' : '✗'} ${a.op}${a.args && Object.keys(a.args).length ? ' ' + argText(a.args) : ''}${a.ok ? '' : ` (${a.code})`}`).join(' · ') }));
133
+ const pf = d.perf;
134
+ L.push(fmt(STRINGS.perf, { fps: pf.fps ?? '-', cpu: pf.cpuMs ?? '-', calls: pf.drawCalls, tris: pf.triangles, chunks: pf.chunks
135
+ ? fmt(STRINGS.chunks, pf.chunks) : '' }));
136
+ if (full && d.render?.text) L.push(d.render.text); // render block only in the full text; the summary stays short (describe render shows it)
137
+ L.push(fmt(STRINGS.modules, { list: d.modules.join(', ') }));
138
+ for (const k in d) if (!SHOWN.has(k)) L.push(fmt(STRINGS.extra, { name: k, json: full ? JSON.stringify(d[k]) : summary(d[k]) }));
139
+ if (full) return L.join('\n');
140
+ if (L.length > maxLines - 1) { const cut = L.length - maxLines + 2; L.splice(maxLines - 2, cut, fmt(STRINGS.more, { n: cut })); }
141
+ L.push(STRINGS.expand);
142
+ return L.join('\n');
143
+ }
package/core/easing.js ADDED
@@ -0,0 +1,34 @@
1
+ // Easing functions: input progress 0..1, output 0..1 (back/elastic overshoot slightly).
2
+ // Names are used by the ease param of tween, camera moves and path moves; you can also pass a function directly, e.g. t => t*t.
3
+ // linear · inQuad outQuad inOutQuad · inCubic outCubic inOutCubic · inSine outSine inOutSine
4
+ // inExpo outExpo inOutExpo · inBack outBack inOutBack · outElastic · outBounce · smooth(= smoothstep)
5
+ import { warnMissing } from './validate.js';
6
+ const c1 = 1.70158, c2 = c1 * 1.525, c3 = c1 + 1;
7
+ const outBounce = t => {
8
+ const n = 7.5625, d = 2.75;
9
+ if (t < 1 / d) return n * t * t;
10
+ if (t < 2 / d) return n * (t -= 1.5 / d) * t + 0.75;
11
+ if (t < 2.5 / d) return n * (t -= 2.25 / d) * t + 0.9375;
12
+ return n * (t -= 2.625 / d) * t + 0.984375;
13
+ };
14
+
15
+ export const EASINGS = {
16
+ linear: t => t,
17
+ smooth: t => t * t * (3 - 2 * t),
18
+ inQuad: t => t * t, outQuad: t => 1 - (1 - t) * (1 - t), inOutQuad: t => t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2,
19
+ inCubic: t => t ** 3, outCubic: t => 1 - (1 - t) ** 3, inOutCubic: t => t < 0.5 ? 4 * t ** 3 : 1 - (-2 * t + 2) ** 3 / 2,
20
+ inSine: t => 1 - Math.cos(t * Math.PI / 2), outSine: t => Math.sin(t * Math.PI / 2), inOutSine: t => -(Math.cos(Math.PI * t) - 1) / 2,
21
+ inExpo: t => t === 0 ? 0 : 2 ** (10 * t - 10), outExpo: t => t === 1 ? 1 : 1 - 2 ** (-10 * t),
22
+ inOutExpo: t => t === 0 ? 0 : t === 1 ? 1 : t < 0.5 ? 2 ** (20 * t - 10) / 2 : (2 - 2 ** (-20 * t + 10)) / 2,
23
+ inBack: t => c3 * t ** 3 - c1 * t * t, outBack: t => 1 + c3 * (t - 1) ** 3 + c1 * (t - 1) ** 2,
24
+ inOutBack: t => t < 0.5 ? ((2 * t) ** 2 * ((c2 + 1) * 2 * t - c2)) / 2 : ((2 * t - 2) ** 2 * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2,
25
+ outElastic: t => t === 0 ? 0 : t === 1 ? 1 : 2 ** (-10 * t) * Math.sin((t * 10 - 0.75) * (2 * Math.PI) / 3) + 1,
26
+ outBounce,
27
+ };
28
+
29
+ /** Name or function -> easing function (an unknown name falls back to linear, with a warning) */
30
+ export function ease(e) {
31
+ if (typeof e === 'function') return e;
32
+ if (e != null && !EASINGS[e]) warnMissing('ease', e, Object.keys(EASINGS));
33
+ return EASINGS[e] || EASINGS.linear;
34
+ }
@@ -0,0 +1,205 @@
1
+ // Stable error codes: errors the engine raises by name end their message with "[code]" and carry err.code / err.fix / err.docs (codedError in errorHints.js).
2
+ // Plain data with no imports (node tools load it through threedog/error-hints). A code never changes meaning once shipped: tools and tests match on it.
3
+
4
+ // Naming rule for a NEW code: `<area>-<problem>` in lowercase with hyphens (save-version, look-verb, unknown-name): the area first so the codes sort
5
+ // and grep by subsystem. Codes already published keep their names even where they do not follow it (renaming would break the tools and tests that match them).
6
+
7
+ /**
8
+ * Errors the engine raises by name (the message ends with "[code]"): code -> { fix, docs }. Codes are stable: tools and tests may match on them.
9
+ * @type {Record<string, { fix: string, docs: string[] }>}
10
+ */
11
+ export const ERROR_CODES = {
12
+ 'save-part-threw': {
13
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
14
+ fix: 'A save part\'s save() threw, so nothing was written and the previous save is kept. Fix the save() named in the message ' +
15
+ '(it must return plain data).' },
16
+ 'save-load-threw': {
17
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
18
+ fix: 'A save part\'s load() threw, so the game was rolled back to how it was before the load. Fix the load() named in the ' +
19
+ 'message.' },
20
+ 'save-refused': {
21
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
22
+ fix: 'The save is unreadable, from a newer build, or a migrate step is missing; nothing changed. Add the migrate step, or run ' +
23
+ 'the newer build.' },
24
+ 'save-version': {
25
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
26
+ fix: 'saves.register(key, { version, migrate }): version is a whole number >= 1; migrate keys are older versions, each a ' +
27
+ 'function data => newData.' },
28
+ 'save-import': {
29
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
30
+ fix: 'Import only text or files made by saves.export / exportFile; attachments must be data: URLs. Nothing was fetched or ' +
31
+ 'changed.' },
32
+ 'save-autosave': {
33
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
34
+ fix: 'saves.autosave(minutes) takes a positive number of minutes of play.' },
35
+ 'session-early': {
36
+ docs: ['recipes/20-content-actions-save.md', 'api/engine.md'],
37
+ fix: 'engine.session needs the new-game state that start() captures: call it from a button or after `await engine.start()`.' },
38
+ 'session-handle': {
39
+ docs: ['api/engine.md'],
40
+ fix: 'session.track(handle) takes something with remove(), such as the result of events.on / onFixed / clock.after.' },
41
+ 'clock-interval': {
42
+ docs: ['recipes/06-clock-events.md', 'api/clock.md'],
43
+ fix: 'clock.after / every take a finite number of game seconds (every needs > 0). For every fixed step use engine.onFixed.' },
44
+ 'threads-option': {
45
+ docs: ['recipes/15-perf.md', 'api/engine.md'],
46
+ fix: 'createEngine({ threads }) takes \'auto\', a worker count (0 = none) or false.' },
47
+ 'threads-transfer': {
48
+ docs: ['recipes/15-perf.md', 'api/engine.md'],
49
+ fix: 'The worker died after the task moved its buffers away (transfer), so the task cannot rerun on the main thread. Resend ' +
50
+ 'it, or send it without transfer.' },
51
+ 'pure-function': {
52
+ docs: ['recipes/18-world.md', 'recipes/15-perf.md'],
53
+ fix: 'A worker function sees only its parameters and worker-safe globals (Math, JSON, Number...): no closure variables, ' +
54
+ 'engine, window or document. Pass values in, or store them on the record.' },
55
+ 'asset-name-clash': {
56
+ docs: ['recipes/05-props-bake.md', 'api/assets.md'],
57
+ fix: 'One name was registered as two asset types (models / textures / sounds). Give each its own name, e.g. grass and ' +
58
+ 'grass_tex.' },
59
+ 'audio-name-clash': {
60
+ docs: ['recipes/31-audio.md', 'api/audio.md'],
61
+ fix: 'One audio name is defined twice: a sound / footstep in both createEngine({ audio }) and a content pack, or a rule key that ' +
62
+ 'is both a condition and a measure. Keep each name in one place.' },
63
+ 'engine-disposed': {
64
+ docs: ['api/engine.md'],
65
+ fix: 'engine.dispose() ran while start() was still loading, so start() stopped. Create a new engine instead of starting a ' +
66
+ 'disposed one.' },
67
+ 'skip-amount': {
68
+ docs: ['recipes/06-clock-events.md', 'api/engine.md'],
69
+ fix: 'engine.skip takes { to: \'06:00\' } (needs the sky module) or { seconds: 600 } (game seconds, > 0).' },
70
+ 'stream-timeout': {
71
+ docs: ['recipes/18-world.md', 'api/stream.md'],
72
+ fix: 'The teleport destination did not finish loading in time (terrain, colliders, nearby models). Read describe().loading or ' +
73
+ '`threedog loading`; raise { timeout } or check the place exists.' },
74
+ 'stream-removed': {
75
+ docs: ['recipes/18-world.md', 'api/stream.md'],
76
+ fix: 'A stream source was removed (remove(), its until, or engine.dispose) before it was ready, so its whenReady rejects. Await ' +
77
+ 'whenReady only on a source you keep.' },
78
+ 'stream-option': {
79
+ docs: ['recipes/18-world.md', 'api/stream.md'],
80
+ fix: 'stream.source(position, { detail }) takes \'full\' or \'simple\'.' },
81
+ 'op-misuse': {
82
+ docs: ['recipes/23-ops.md', 'api/engine.md'],
83
+ fix: 'Ops are defined with ops.define(name, { can, run }) and run with ops.run(name, args); args are plain data and can() only ' +
84
+ 'reads. The message says which rule was broken.' },
85
+ 'pause-owner': {
86
+ docs: ['recipes/23-ops.md', 'api/engine.md'],
87
+ fix: 'engine.pause(owner) and engine.resume(owner) must use the same owner name; the loop resumes only when every owner has resumed.' },
88
+ 'claim-owner': {
89
+ docs: ['api/engine.md'],
90
+ fix: 'pause / freeze / takeCamera / debug.view name who holds them with a non-empty owner string; only that owner releases it (resume, unfreeze, handle.remove()).' },
91
+ 'views-define': {
92
+ docs: ['recipes/46-blender-art-route.md', 'api/engine.md'],
93
+ fix: "engine.views.define(name, { position: [x, y, z], target?: [x, y, z], fov? }): position and target are 3-number arrays." },
94
+ 'renamed-api': {
95
+ docs: ['recipes/52-look.md'],
96
+ fix: 'The call was renamed in 0.2 and the old name now throws; the message names the new call. The table is in recipes/52-look.md "Renamed in 0.2".' },
97
+ 'ops-guard': {
98
+ docs: ['recipes/23-ops.md'],
99
+ fix: 'Gameplay state (world, containers, vars, quests) was changed outside a fixed step and outside an op. Do it inside ' +
100
+ 'engine.ops.run(...) or an onFixed / module fixed hook.' },
101
+ 'quest-step': {
102
+ docs: ['recipes/04-quests.md', 'api/quests.md'],
103
+ fix: 'A saved quest step or part id no longer exists in the quest definition. Keep step ids stable (steps: [{ id, text, done ' +
104
+ '}]) or add a migrate step to the quests save part.' },
105
+ 'save-write': {
106
+ docs: ['recipes/20-content-actions-save.md', 'api/saves.md'],
107
+ fix: 'The browser refused to store the save (storage full, private mode, blocked IndexedDB); the previous save is kept. Free ' +
108
+ 'space or export the save as a file.' },
109
+ 'budget-over': {
110
+ docs: ['recipes/15-perf.md', 'api/budget.md'],
111
+ fix: 'A performance budget set with createEngine({ budget }) was exceeded; the message names the biggest costs. Measure with ' +
112
+ 'describe().perf or npm run perf.' },
113
+ 'jobs-slow': {
114
+ docs: ['recipes/15-perf.md', 'api/jobs.md'],
115
+ fix: 'A job step ran too long or a job queued too many steps. Yield more often inside the generator (engine.jobs.add(function* ' +
116
+ '() { ...; yield; })).' },
117
+ 'threads-crash': {
118
+ docs: ['recipes/15-perf.md', 'api/engine.md'],
119
+ fix: 'A worker failed (the error is printed with it); the lane now runs on the main thread with the same results, only slower. ' +
120
+ 'Fix the worker file or its imports.' },
121
+ 'input-binding': {
122
+ docs: ['api/input.md'],
123
+ fix: 'An action was defined again with different keys; the later keys win. Define each action once, or change keys with ' +
124
+ 'input.rebind(action, keys).' },
125
+ 'asset-cache': {
126
+ docs: ['recipes/05-props-bake.md', 'api/assets.md'],
127
+ fix: 'The dev model cache could not be used, so code-generated models are built from code. Run the game through its vite ' +
128
+ 'config (threedog gameConfig); npm run bake once a model is final.' },
129
+ 'webgl-lost': {
130
+ docs: ['api/engine.md'],
131
+ fix: 'The browser dropped the WebGL context (GPU reset, too many tabs); gameplay waits until it is restored. Nothing to fix ' +
132
+ 'unless it repeats: then lower quality or texture sizes.' },
133
+ 'module-params': {
134
+ docs: ['recipes/51-capability-catalog.md'],
135
+ fix: 'A module option does not fit the module params schema (unknown key, wrong type, out of range or not one of the allowed values). ' +
136
+ 'The message names the option and what it should be; engine.catalog(name).params lists every option with its default.' },
137
+ 'module-dispose': {
138
+ docs: ['recipes/14-custom-module.md'],
139
+ fix: 'A module\'s dispose(e) threw; the other modules and core were still cleaned up. Fix that module\'s dispose.' },
140
+ 'module-order': {
141
+ docs: ['recipes/14-custom-module.md', 'api/engine.md'],
142
+ fix: 'A module\'s before / after contradicts the stage order (stages always run in order; before / after only order modules inside one ' +
143
+ 'stage). Give both modules the same stage, or remove the before / after.' },
144
+ 'module-critical': {
145
+ docs: ['recipes/14-custom-module.md', 'api/engine.md'],
146
+ fix: 'A module declared critical: true failed in init(), so start() stopped instead of starting a broken game. The message names the module ' +
147
+ 'and the reason: fix its init(), or drop critical if the game can run without it.' },
148
+ 'module-not-ready': {
149
+ docs: ['recipes/14-custom-module.md', 'api/engine.md'],
150
+ fix: 'start() waited longer than engine.loading.timeoutMs for modules whose isReady(e) stays false. Fix what that module waits for, ' +
151
+ 'or raise engine.loading.timeoutMs if the load is only slow. engine.loading.view().waiting names the current item.' },
152
+ 'step-seconds': {
153
+ docs: ['api/engine.md'],
154
+ fix: 'engine.step(seconds) takes a finite number >= 0 in game seconds: 0 advances nothing, 0.5 is half a second, 1 / 60 is one fixed step.' },
155
+ 'player-control': {
156
+ docs: ['recipes/01-new-game.md', 'api/characters.md'],
157
+ fix: "createPlayer() has no default feel: give control. Usually createPlayer({ ...presets.player.thirdPerson, spawn }); else control: 'camera' | " +
158
+ "'none' | (player, input, dt) => ({ x, z }), plus runKeys / jumpKeys / cameraFollow as wanted." },
159
+ 'interaction-setup': {
160
+ docs: ['recipes/02-npc.md', 'api/interactions.md'],
161
+ fix: 'interactions() has no default pick or key: use interactions({ ...presets.interactions.nearest }) or interactions({ pick, keys: ' +
162
+ "['KeyE'] }); keys may be left out only when createEngine({ bindings }) already binds the action." },
163
+ 'open-world-camera': {
164
+ docs: ['recipes/21-camera.md', 'api/openWorld.md'],
165
+ fix: "openWorld() installs no camera on its own: pass camera: 'follow' | 'firstPerson' | 'rts' | 'fixed' | a camera module | false." },
166
+ 'look-param': {
167
+ docs: ['recipes/52-look.md'],
168
+ fix: 'A look part was given a key it does not have, a value of the wrong type, or a spec without a default. engine.catalog("look.<part>").params lists every key, its default, why and how to turn it off.' },
169
+ 'look-verb': {
170
+ docs: ['recipes/52-look.md'],
171
+ fix: 'This look part does not support that verb (set / patch / replace), or the hook name is unknown. engine.catalog("look.<part>").verbs lists what it supports; the message names the verb to use instead.' },
172
+ 'debug-override': {
173
+ docs: ['recipes/41-thing-registry.md'],
174
+ fix: "engine.debug.override(owner, target, patch): owner names who sets it (engine.debug.clear(owner) removes all of them), target is a thing id or Object3D, " +
175
+ "patch is { visible?, material?: 'flat' | 'wire', apply? }. Overrides change only what the screen shows and are never saved." },
176
+ 'thing-id': {
177
+ docs: ['recipes/41-thing-registry.md'],
178
+ fix: "Ids given to engine.add(obj, { id }) are non-empty strings without '#', unique across engine.add objects and world records. " +
179
+ 'engine.thing(id) takes such an id, a world record id, an object name or an Object3D; the message suggests the closest id.' },
180
+ 'thing-owned': {
181
+ docs: ['recipes/41-thing-registry.md', 'recipes/18-world.md'],
182
+ fix: "Two systems manage one object: a world model is placed by world every frame. Change the record (ops.run('thing.set', { id, " +
183
+ "position }), world.set / world.move) instead of the model, and never engine.add a model world built." },
184
+ 'thing-unsaved': {
185
+ docs: ['recipes/41-thing-registry.md'],
186
+ fix: 'An object you expect to keep cannot be saved: it has no stable id or was added during play. Give it an id at setup ' +
187
+ "(engine.add(obj, { id })), or make it a template and create it inside an op with engine.spawn(name, at)." },
188
+ 'thing-orphan': {
189
+ docs: ['recipes/41-thing-registry.md'],
190
+ fix: "The 'scene' save part names an id no engine.add object has: the code that added it changed its id or no longer runs. " +
191
+ 'The data is kept in the save; restore the id, or ignore it if the object was deleted on purpose.' },
192
+ 'engine-misuse': {
193
+ docs: ['api/engine.md'],
194
+ fix: 'An engine call got an argument it cannot use; the message names the call and the accepted forms.' },
195
+ 'many-lights': {
196
+ docs: ['recipes/09-style-pack.md', 'api/lightPool.md'],
197
+ fix: 'More than 8 real-time lights are in the scene. Use engine.use(lightPool({ point: 8 })) and register torches / lamps with ' +
198
+ 'engine.lightPool.add(...) so a fixed small set of real lights follows the nearest sources.' },
199
+ 'light-recompile': {
200
+ docs: ['recipes/09-style-pack.md', 'api/lightPool.md'],
201
+ fix: 'The number of lights changed during play, so three.js compiled new shader programs (a long frame). Keep the light ' +
202
+ 'count fixed: engine.use(lightPool({ point: 8 })) before engine.start() and register torches / lamps with ' +
203
+ 'engine.lightPool.add(...), or create your own lights before start and fade them with intensity instead of adding, ' +
204
+ 'removing or hiding them.' },
205
+ };