threedog 0.1.0 → 0.2.1
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.
- package/README.md +4 -4
- package/core/Animator.js +1 -0
- package/core/Assets.js +28 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +14 -3
- package/core/Engine.js +44 -72
- package/core/Events.js +59 -1
- package/core/I18n.js +2 -2
- package/core/Inspect.js +12 -32
- package/core/InspectScene.js +7 -3
- package/core/MaterialInfo.js +32 -0
- package/core/Ops.js +43 -59
- package/core/Saves.js +5 -4
- package/core/UrlState.js +3 -2
- package/core/Vars.js +1 -0
- package/core/Views.js +49 -0
- package/core/actor.js +2 -2
- package/core/assetReport.js +83 -0
- package/core/catalog.js +169 -0
- package/core/checks.js +67 -0
- package/core/claims.js +51 -0
- package/core/debugView.js +76 -0
- package/core/describeRender.js +51 -0
- package/core/describeText.js +11 -4
- package/core/errorCodes.js +33 -0
- package/core/errorHints.js +6 -1
- package/core/grid.js +127 -0
- package/core/gridLoad.js +19 -0
- package/core/holds.js +106 -0
- package/core/lifecycle.js +1 -0
- package/core/lightWatch.js +23 -3
- package/core/look/coreParts.js +112 -0
- package/core/look/layers.js +136 -0
- package/core/look/part.js +173 -0
- package/core/look/report.js +79 -0
- package/core/look/write.js +86 -0
- package/core/loop.js +22 -16
- package/core/modules.js +19 -5
- package/core/opsAtomic.js +31 -0
- package/core/opsCheck.js +25 -14
- package/core/opsFail.js +20 -0
- package/core/opsHistory.js +6 -6
- package/core/opsRun.js +77 -0
- package/core/params.js +132 -0
- package/core/renamed.js +22 -0
- package/core/saveApply.js +2 -2
- package/core/sceneMethods.js +9 -34
- package/core/services.js +73 -0
- package/core/startup.js +3 -1
- package/core/styleParts.js +11 -9
- package/core/thingExplain.js +68 -0
- package/core/thingOps.js +35 -24
- package/core/things.js +15 -1
- package/core/util.js +11 -0
- package/core/validate.js +23 -7
- package/docs/AI.md +93 -114
- package/docs/API.md +8 -9
- package/docs/CODEMAP.md +67 -53
- package/docs/COMMANDS.md +21 -7
- package/docs/CONVENTIONS.md +22 -11
- package/docs/THREE.md +3 -3
- package/docs/api/assets.md +3 -0
- package/docs/api/characters.md +5 -2
- package/docs/api/collision.md +4 -0
- package/docs/api/content.md +1 -0
- package/docs/api/engine.md +23 -14
- package/docs/api/events.md +5 -1
- package/docs/api/post.md +5 -4
- package/docs/api/saves.md +2 -1
- package/docs/api/sky.md +3 -3
- package/docs/api/style.md +8 -8
- package/docs/api/tools.md +5 -2
- package/docs/api/vegetation.md +1 -0
- package/docs/api/weather.md +1 -1
- package/docs/recipes/01-new-game.md +41 -43
- package/docs/recipes/02-npc.md +38 -22
- package/docs/recipes/03-items-pickups.md +4 -4
- package/docs/recipes/04-quests.md +23 -23
- package/docs/recipes/05-props-bake.md +5 -5
- package/docs/recipes/06-clock-events.md +13 -0
- package/docs/recipes/07-flow-scenes-pause.md +6 -2
- package/docs/recipes/08-weather-sky.md +6 -6
- package/docs/recipes/09-style-pack.md +35 -100
- package/docs/recipes/12-navmesh.md +22 -0
- package/docs/recipes/13-animation.md +25 -6
- package/docs/recipes/14-custom-module.md +6 -7
- package/docs/recipes/15-perf.md +9 -1
- package/docs/recipes/16-dev-bridge.md +52 -18
- package/docs/recipes/18-world.md +5 -2
- package/docs/recipes/19-shooting-picking.md +9 -8
- package/docs/recipes/20-content-actions-save.md +10 -10
- package/docs/recipes/21-camera.md +51 -2
- package/docs/recipes/22-shop-gold.md +16 -16
- package/docs/recipes/23-ops.md +46 -10
- package/docs/recipes/27-net.md +3 -3
- package/docs/recipes/28-terrain.md +2 -2
- package/docs/recipes/29-grid.md +47 -27
- package/docs/recipes/34-environment-lighting.md +11 -10
- package/docs/recipes/35-style-from-reference.md +41 -46
- package/docs/recipes/36-sky-ground-plant-looks.md +22 -20
- package/docs/recipes/37-terrain-look-hooks.md +34 -13
- package/docs/recipes/38-environment-look-hooks.md +49 -42
- package/docs/recipes/40-scene.md +29 -0
- package/docs/recipes/41-thing-registry.md +29 -0
- package/docs/recipes/42-terrain-shape.md +1 -1
- package/docs/recipes/43-shader-patches-surface-looks.md +37 -20
- package/docs/recipes/44-water-weather-look-hooks.md +11 -9
- package/docs/recipes/45-cascaded-shadows.md +2 -2
- package/docs/recipes/46-blender-art-route.md +26 -4
- package/docs/recipes/47-island-snow-backdrop.md +4 -3
- package/docs/recipes/48-make-material.md +70 -0
- package/docs/recipes/49-game-module-contract.md +71 -0
- package/docs/recipes/50-own-renderer.md +12 -0
- package/docs/recipes/51-capability-catalog.md +63 -0
- package/docs/recipes/52-look.md +146 -0
- package/docs/recipes/53-ground-up-close.md +58 -0
- package/examples/action/GAMEMAP.md +7 -7
- package/examples/action/content/index.js +2 -1
- package/examples/action/content/views.js +6 -0
- package/examples/action/main.js +3 -2
- package/examples/sheepisland/GAMEMAP.md +3 -4
- package/examples/styletest/GAMEMAP.md +3 -3
- package/examples/styletest/content/npcs.js +1 -1
- package/examples/styletest/main.js +2 -2
- package/examples/styletest/panel.js +3 -3
- package/examples/world/GAMEMAP.md +3 -3
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/main.js +1 -1
- package/index.d.ts +35 -2
- package/index.js +6 -3
- package/llms.txt +13 -7
- package/modules/ambience/Ambience.js +5 -2
- package/modules/camera/FirstPersonCamera.js +3 -5
- package/modules/camera/FixedCamera.js +19 -12
- package/modules/camera/FollowCamera.js +14 -8
- package/modules/camera/RtsCamera.js +3 -5
- package/modules/camera/common.js +40 -10
- package/modules/camera/index.js +1 -1
- package/modules/camera/projection.js +34 -0
- package/modules/characters/Character.js +45 -31
- package/modules/characters/assetModel.js +35 -7
- package/modules/characters/astar.js +14 -7
- package/modules/characters/index.js +6 -3
- package/modules/characters/movers/simple.js +6 -1
- package/modules/characters/npcSim.js +8 -2
- package/modules/characters/pathAsync.js +12 -6
- package/modules/characters/pathJob.js +2 -1
- package/modules/characters/proceduralRig.js +50 -11
- package/modules/characters/useModel.js +22 -0
- package/modules/characters/walkTo.js +58 -0
- package/modules/collision/Collision.js +102 -4
- package/modules/content/explain.js +13 -0
- package/modules/content/index.js +3 -1
- package/modules/content/loader.js +3 -0
- package/modules/content/rules.js +1 -0
- package/modules/debug/DebugPanel.js +11 -5
- package/modules/entities/Entities.js +6 -2
- package/modules/flow/index.js +5 -2
- package/modules/gameplay/Dialogue.js +5 -2
- package/modules/gameplay/Interactions.js +12 -2
- package/modules/gameplay/Inventory.js +21 -11
- package/modules/gameplay/Quests.js +13 -3
- package/modules/gameplay/pickups.js +6 -4
- package/modules/grid/Layer.js +1 -1
- package/modules/grid/index.js +1 -1
- package/modules/grid/tiles.js +9 -5
- package/modules/hlod/index.js +5 -2
- package/modules/hud/index.js +5 -2
- package/modules/level/index.js +5 -3
- package/modules/lights/index.js +5 -2
- package/modules/music/Music.js +6 -2
- package/modules/nav/index.js +5 -3
- package/modules/net/Client.js +4 -3
- package/modules/net/Host.js +2 -2
- package/modules/net/index.js +5 -3
- package/modules/particles/Particles.js +1 -1
- package/modules/photo/Photo.js +10 -7
- package/modules/rigid/RigidBodies.js +5 -2
- package/modules/settings/Settings.js +6 -3
- package/modules/settings/apply.js +2 -1
- package/modules/sky/Sky.js +21 -19
- package/modules/sky/cascades.js +6 -6
- package/modules/sky/domeLayers.js +1 -1
- package/modules/sky/environment.js +39 -13
- package/modules/sky/fog.js +9 -6
- package/modules/sky/frame.js +4 -3
- package/modules/sky/look.js +3 -2
- package/modules/sky/lookFog.js +80 -0
- package/modules/sky/lookShadow.js +50 -0
- package/modules/sky/lookSky.js +108 -0
- package/modules/sky/shader.js +2 -2
- package/modules/sky/shadow.js +4 -10
- package/modules/sky/skyModule.js +4 -3
- package/modules/terrain/ChunkManager.js +2 -33
- package/modules/terrain/chunkLevels.js +40 -0
- package/modules/terrain/index.js +10 -2
- package/modules/terrain/lookGround.js +61 -0
- package/modules/timeline/Timeline.js +7 -3
- package/modules/timeline/Tween.js +3 -7
- package/modules/timeline/shots.js +6 -4
- package/modules/triggers/index.js +9 -2
- package/modules/vegetation/Vegetation.js +17 -4
- package/modules/vegetation/index.js +7 -4
- package/modules/vegetation/lookWind.js +37 -0
- package/modules/vegetation/nearFade.js +39 -0
- package/modules/water/Water.js +19 -3
- package/modules/water/look.js +80 -0
- package/modules/weather/Weather.js +22 -31
- package/modules/weather/look.js +75 -0
- package/modules/weather/particles.js +1 -1
- package/modules/weather/strings.js +15 -0
- package/modules/world/explain.js +11 -0
- package/modules/world/index.js +11 -4
- package/modules/world/thingSource.js +44 -0
- package/package.json +2 -1
- package/render/PostFX.js +48 -51
- package/render/detail.js +39 -15
- package/render/effects.js +4 -2
- package/render/fuse.js +12 -0
- package/render/lights.js +4 -2
- package/render/lookSurface.js +161 -0
- package/render/materials.js +27 -10
- package/render/postLook.js +86 -0
- package/render/surface.js +3 -1
- package/types/core.d.ts +223 -29
- package/types/gameplay.d.ts +22 -6
- package/types/generated/core/DebugOverrides.d.ts +52 -0
- package/types/generated/core/Events.d.ts +43 -0
- package/types/generated/core/Ops.d.ts +62 -21
- package/types/generated/core/Saves.d.ts +1 -0
- package/types/generated/core/Views.d.ts +33 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Layer.d.ts +1 -0
- package/types/generated/modules/sky/Sky.d.ts +10 -17
- package/types/generated/modules/weather/Weather.d.ts +5 -15
- package/types/generated/render/PostFX.d.ts +20 -23
- package/types/generated/render/materials.d.ts +10 -0
- package/types/physics.d.ts +8 -0
- package/types/style.d.ts +35 -20
- package/types/world.d.ts +7 -1
- package/ui/Parts.js +6 -2
- package/ui/UI.js +1 -1
- package/ui/defaults.js +1 -1
- package/docs/api/debug.md +0 -10
package/docs/API.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Engine API index (generated, do not edit by hand; produced by npm run map)
|
|
2
2
|
|
|
3
|
-
> **To do something, first look at the recipe in `recipes/` whose file name matches** (it has a ready-made pattern, faster than browsing the API): 01-new-game · 02-npc · 03-items-pickups · 04-quests · 05-props-bake · 06-clock-events · 07-flow-scenes-pause · 08-weather-sky · 09-style-pack · 10-blender-level · 11-vehicles · 12-navmesh · 13-animation · 14-custom-module · 15-perf · 16-dev-bridge · 18-world · 19-shooting-picking · 20-content-actions-save · 21-camera · 22-shop-gold · 23-ops · 26-ui-parts · 27-net · 28-terrain · 29-grid · 30-templates · 31-audio · 32-action-game · 33-stream-sources · 34-environment-lighting · 35-style-from-reference · 36-sky-ground-plant-looks · 37-terrain-look-hooks · 38-environment-look-hooks · 40-scene · 41-thing-registry · 42-terrain-shape · 43-shader-patches-surface-looks · 44-water-weather-look-hooks · 45-cascaded-shadows · 46-blender-art-route · 47-island-snow-backdrop
|
|
3
|
+
> **To do something, first look at the recipe in `recipes/` whose file name matches** (it has a ready-made pattern, faster than browsing the API): 01-new-game · 02-npc · 03-items-pickups · 04-quests · 05-props-bake · 06-clock-events · 07-flow-scenes-pause · 08-weather-sky · 09-style-pack · 10-blender-level · 11-vehicles · 12-navmesh · 13-animation · 14-custom-module · 15-perf · 16-dev-bridge · 18-world · 19-shooting-picking · 20-content-actions-save · 21-camera · 22-shop-gold · 23-ops · 26-ui-parts · 27-net · 28-terrain · 29-grid · 30-templates · 31-audio · 32-action-game · 33-stream-sources · 34-environment-lighting · 35-style-from-reference · 36-sky-ground-plant-looks · 37-terrain-look-hooks · 38-environment-look-hooks · 40-scene · 41-thing-registry · 42-terrain-shape · 43-shader-patches-surface-looks · 44-water-weather-look-hooks · 45-cascaded-shadows · 46-blender-art-route · 47-island-snow-backdrop · 48-make-material · 49-game-module-contract · 50-own-renderer · 51-capability-catalog · 52-look · 53-ground-up-close
|
|
4
4
|
> The api pages are generated too, do not edit them by hand; `?` in a signature means optional, what follows `→` is the return value; the full types are in `types/*.d.ts`.
|
|
5
5
|
> With no matching recipe: read this page first: the core everyday API + one line per core object / module (listing method names). For the one you need, **read only that page** `api/<name>.md` (methods, parameters, properties and data structures are all in it).
|
|
6
6
|
> Paths are relative to the package (`node_modules/threedog/`). Entry: `import { createEngine, openWorld, … } from 'threedog'` (the engine package's own examples use relative paths); a module that is not installed is undefined, so use `engine.xxx?.method()`.
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
- `engine.snapToGround(obj: T, offset?: number) → T` — Put an object on the ground under it (y = ground height + offset) and return the object
|
|
22
22
|
- `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null…
|
|
23
23
|
- `engine.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY)
|
|
24
|
-
- `engine.freeze(owner?: string)` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely…
|
|
25
|
-
- `engine.pause()` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances…
|
|
24
|
+
- `engine.freeze(owner?: string | { owner?, kind? }, opts?: { kind?: 'title' }) → ChainedHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely…
|
|
25
|
+
- `engine.pause(owner?: string | { owner?, kind? }, opts?: { kind?: 'test' }) → ChainedHandle` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances…
|
|
26
26
|
- `engine.stateApplied` — Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been …
|
|
27
27
|
- `engine.ready` — True once start() completes and the loading screen is gone…
|
|
28
28
|
- `engine.player` — The player (exists only after characters.createPlayer())
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
- `engine.camera` — three.js perspective camera
|
|
31
31
|
|
|
32
32
|
## Core objects (engine.xxx, no install needed)
|
|
33
|
-
- [`engine.events`](api/events.md) the event bus: recent on once emit; event table
|
|
33
|
+
- [`engine.events`](api/events.md) the event bus: traceFocus note trace recent on once emit; event table
|
|
34
34
|
- [`engine.input`](api/input.md) Input: read by "action": define touchButton simulate rebind keysOf label down pressed released pressedRaw push
|
|
35
35
|
- [`engine.clock`](api/clock.md) game seconds and "after how long / every how long": after every
|
|
36
36
|
- [`engine.vars`](api/vars.md) story flags and counters (autosaved): flag setFlag counter bump
|
|
37
37
|
- [`engine.saves`](api/saves.md) engine.saves handles saving: register queue flush collect check apply save load list remove export import exportFile importFile …
|
|
38
|
-
- [`engine.assets`](api/assets.md) Assets: manifest builder preload font model modelNow geometry texture release trim users forget cached
|
|
38
|
+
- [`engine.assets`](api/assets.md) Assets: manifest builder preload font model modelNow geometry gridFromImage texture release trim users forget cached …
|
|
39
39
|
- [`engine.audio`](api/audio.md) buses: addBus setVolume duck register condition measure value matches volumeOf sfx noiseBurst tone load play
|
|
40
40
|
- [`engine.i18n`](api/i18n.md) string tables: add setLocale has t
|
|
41
41
|
- [`engine.rays`](api/rays.md) engine.rays is the ray registry…: addStatic forget addProvider cast pick
|
|
42
42
|
- [`engine.jobs`](api/jobs.md) engine.jobs queues build work in a binary heap: add run
|
|
43
43
|
- [`engine.stream`](api/stream.md) engine.stream builds on demand by space: only entries n…: add setRadius source teleport readyCheck sources
|
|
44
44
|
- [`engine.budget`](api/budget.md) performance budget (turned on by createEngine: enable disable metric limitOf report checkStartup values byTag
|
|
45
|
-
- [`engine.post`](api/post.md) PostFX: add get enable list
|
|
45
|
+
- [`engine.post`](api/post.md) PostFX: add get enable setAntialias list
|
|
46
46
|
- [`engine.ground`](api/ground.md) Ground: whoever provides the ground height is the "terr…: height slope type has voidY forEachCollider viewRange chunkCollision staticTrimeshes staticVersion navGeometry
|
|
47
47
|
|
|
48
48
|
## Modules (installed with engine.use; the openWorld preset installs only world and environment, see [api/openWorld.md](api/openWorld.md))
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
- [`engine.world`](api/world.md) World data: add origin idOf get set move remove query forEachNear present view refresh …
|
|
55
55
|
- [`engine.net`](api/net.md) net: reconnect
|
|
56
56
|
- [`engine.grids`](api/grids.md) grids: add get list define preview
|
|
57
|
-
- [`engine.collision`](api/collision.md) collision() Lightweight collision: addCircle addBox addObject forEachStatic walkable walkableAt
|
|
57
|
+
- [`engine.collision`](api/collision.md) collision() Lightweight collision: addCircle addBox addSegment addBlocked blockedAt addObject forEachStatic walkable walkableAt lineClear
|
|
58
58
|
- [`engine.rigid`](api/rigid.md) rigid() Real physics, Rapier: addBox addBall addHull impulse setPosition groundReady addVehicle
|
|
59
59
|
- [`engine.cameraRig`](api/cameraRig.md) followCamera() / firstPersonCamera() / fixedCamera() / rtsCamera() Current camera: follow forward right focusPoint update onOverride onEnter onExit
|
|
60
60
|
- [`engine.timeline`](api/timeline.md) timeline() Cutscenes, tweens: tween play skip
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
- [`engine.quests`](api/quests.md) quests() Quests: define start isDone isActive isFailed check list
|
|
72
72
|
- [`engine.photo`](api/photo.md) photo() Photo mode: take subject
|
|
73
73
|
- [`engine.ambience`](api/ambience.md) ambience() Ambience: add rules nearWater
|
|
74
|
-
- [`engine.debug`](api/debug.md) debug() F3 debug panel: startBench
|
|
75
74
|
- [`engine.nav`](api/nav.md) nav() Navmesh: findPath dispose
|
|
76
75
|
- [`engine.hlod`](api/hlod.md) hlod() hlod: add
|
|
77
76
|
- [`engine.lightPool`](api/lightPool.md) lightPool() Light pool: add usage
|
|
@@ -81,4 +80,4 @@
|
|
|
81
80
|
|
|
82
81
|
## Other
|
|
83
82
|
- [Style pack Style](api/style.md): all look options (sky, weather, water, terrain, UI, materials, particles, sound, models)
|
|
84
|
-
- [Utility functions](api/tools.md): postAdd postRemove presets world net fakeNetwork webSocket grids screenToGround EASINGS ease checkOptions createTerrain terrainMaterial mergeColored applyEffects MATERIAL_PURPOSES makeMaterial materialPatches toast makeWindow
|
|
83
|
+
- [Utility functions](api/tools.md): postAdd postRemove presets world net fakeNetwork webSocket grids screenToGround EASINGS sampleGrid ease checkOptions readParams defineLookPart createTerrain terrainMaterial mergeColored applyEffects MATERIAL_PURPOSES makeMaterial materialPatches toast makeWindow …
|
package/docs/CODEMAP.md
CHANGED
|
@@ -4,45 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
## Modules (installed with engine.use)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Requires, optional, stage, run order, params, ops, saves and time model of each module: `npx threedog catalog` (and `catalog <module>`); only the file is listed here.
|
|
8
8
|
|
|
9
|
-
| Module (engine.xxx) | File |
|
|
10
|
-
|
|
11
|
-
| cameraRig (firstPersonCamera()) | modules/camera/FirstPersonCamera.js |
|
|
12
|
-
| cameraRig (fixedCamera()) | modules/camera/FixedCamera.js |
|
|
13
|
-
| cameraRig (followCamera()) | modules/camera/FollowCamera.js |
|
|
14
|
-
| cameraRig (rtsCamera()) | modules/camera/RtsCamera.js |
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| hud | modules/hud/index.js | — | inventory, content, level, quests | presentation | after particles, settings |
|
|
29
|
-
| particles | modules/particles/Particles.js | — | — | presentation | — |
|
|
30
|
-
| settings | modules/settings/Settings.js | — | terrain, vegetation | presentation | — |
|
|
31
|
-
| ambience | modules/ambience/Ambience.js | — | — | late | — |
|
|
32
|
-
| characters | modules/characters/index.js | — | cameraRig, sky, interactions, dialogue, nav, collision, rigid, world | late | — |
|
|
33
|
-
| collision | modules/collision/Collision.js | — | — | late | — |
|
|
34
|
-
| content | modules/content/index.js | — | level, sky, inventory, quests, particles, hud, vegetation, dialogue, triggers, collision, world, interactions, grids, rigid | late | — |
|
|
35
|
-
| debug | modules/debug/DebugPanel.js | — | sky, weather, terrain | late | — |
|
|
36
|
-
| flow | modules/flow/index.js | — | music | late | — |
|
|
37
|
-
| inventory | modules/gameplay/Inventory.js | — | world | late | — |
|
|
38
|
-
| quests | modules/gameplay/Quests.js | — | — | late | — |
|
|
39
|
-
| hlod | modules/hlod/index.js | — | terrain, level | late | — |
|
|
40
|
-
| lightPool | modules/lights/index.js | — | — | late | — |
|
|
41
|
-
| nav | modules/nav/index.js | — | — | late | — |
|
|
42
|
-
| net | modules/net/index.js | — | world, inventory | late | — |
|
|
43
|
-
| photo | modules/photo/Photo.js | — | cameraRig, sky, vegetation, entities | late | — |
|
|
44
|
-
| rigid | modules/rigid/RigidBodies.js | collision | interactions | late | — |
|
|
45
|
-
| music | modules/music/Music.js | — | dialogue | audio | — |
|
|
9
|
+
| Module (engine.xxx) | File |
|
|
10
|
+
|---|---|
|
|
11
|
+
| cameraRig (firstPersonCamera()) | modules/camera/FirstPersonCamera.js |
|
|
12
|
+
| cameraRig (fixedCamera()) | modules/camera/FixedCamera.js |
|
|
13
|
+
| cameraRig (followCamera()) | modules/camera/FollowCamera.js |
|
|
14
|
+
| cameraRig (rtsCamera()) | modules/camera/RtsCamera.js |
|
|
15
|
+
| terrain | modules/terrain/index.js |
|
|
16
|
+
| vegetation | modules/vegetation/index.js |
|
|
17
|
+
| world | modules/world/index.js |
|
|
18
|
+
| sky | modules/sky/skyModule.js |
|
|
19
|
+
| water | modules/water/Water.js |
|
|
20
|
+
| weather | modules/weather/Weather.js |
|
|
21
|
+
| interactions | modules/gameplay/Interactions.js |
|
|
22
|
+
| grids | modules/grid/index.js |
|
|
23
|
+
| triggers | modules/triggers/index.js |
|
|
24
|
+
| particles | modules/particles/Particles.js |
|
|
25
|
+
| content | modules/content/index.js |
|
|
26
|
+
| inventory | modules/gameplay/Inventory.js |
|
|
27
|
+
| quests | modules/gameplay/Quests.js |
|
|
46
28
|
|
|
47
29
|
## Files
|
|
48
30
|
|
|
@@ -59,6 +41,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
59
41
|
- Budget.js: Performance budget, engine.budget: the game sets limits (on…
|
|
60
42
|
- Clock.js: Game clock, engine.clock: game seconds `now` + "after a del…
|
|
61
43
|
- Commits.js: How background results take effect: engine.commits
|
|
44
|
+
- DebugOverrides.js: engine.debug: diagnostic overrides with an owner ("show me …
|
|
62
45
|
- Describe.js: Game state description: engine.describe() returns a plain o…
|
|
63
46
|
- Engine.js: Engine core: what every 3D web game needs (rendering and po…
|
|
64
47
|
- Events.js: Event bus: modules do not call each other directly; they "s…
|
|
@@ -68,6 +51,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
68
51
|
- InspectScene.js: engine.inspect.scene(): "the mesh exists but I do not see i…
|
|
69
52
|
- Jobs.js: engine.jobs: a frame-sliced job scheduler
|
|
70
53
|
- Loading.js: engine.loading: one observable view of everything startup (…
|
|
54
|
+
- MaterialInfo.js: Material provenance for engine.inspect.scene(): "why is thi…
|
|
71
55
|
- Ops.js: One entry point for actions: engine.ops
|
|
72
56
|
- Random.js: Seeded random numbers, engine.random: gameplay randomness (…
|
|
73
57
|
- Rays.js: Rays: engine.raycast / engine.pick, with the registry engin…
|
|
@@ -77,22 +61,32 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
77
61
|
- Threads.js: engine.threads: a small worker pool
|
|
78
62
|
- UrlState.js: Reproduce a scenario in one call: engine.applyState({ time,…
|
|
79
63
|
- Vars.js: Story flags and counters, engine.vars (saved automatically …
|
|
64
|
+
- Views.js: Named fixed camera views declared by the game, so a screens…
|
|
80
65
|
- actor.js: Who acts for the local user (part of Engine, mixed into Eng…
|
|
81
66
|
- assetEntry.js: The life of one engine.assets entry, split from Assets.js (…
|
|
82
67
|
- assetLoad.js: File loading for engine.assets, split into the phases engin…
|
|
83
68
|
- assetManifest.js: engine.assets.manifest(pack) (helper of Assets.js): registe…
|
|
69
|
+
- assetReport.js: Import report of a loaded glTF (engine.assets.report): what…
|
|
84
70
|
- audioRules.js: The data side of audio rules: condition keys, measures (com…
|
|
85
71
|
- audioVoice.js: One playing sound (a "voice") of engine.audio.sfx / play: s…
|
|
86
72
|
- batchGroups.js: InstancedMesh side of engine.batching (core/Batching.js): b…
|
|
87
73
|
- canvasBox.js: The canvas's CSS box and the UI root laid over it (split ou…
|
|
74
|
+
- catalog.js: engine.catalog(): what this game can do, read from the regi…
|
|
75
|
+
- checks.js: Consistency checks a game (or an AI) can call in dev and te…
|
|
76
|
+
- claims.js: claims(): one small "who holds this" primitive shared by pa…
|
|
88
77
|
- dayTime.js: Clock-time conversion (pure functions): sky time of day `ti…
|
|
78
|
+
- debugView.js: Diagnostic view modes behind engine.debug.view('albedo' / '…
|
|
79
|
+
- describeRender.js: describe().render: what the renderer, lights and post effec…
|
|
89
80
|
- describeText.js: engine.describeText(): write describe() as plain English fo…
|
|
90
81
|
- easing.js: Easing functions: input progress 0..1, output 0..1 (back/el…
|
|
91
82
|
- errorCodes.js: Stable error codes: errors the engine raises by name end th…
|
|
92
83
|
- errorHints.js: Error hints: a table of "message pattern -> likely cause + …
|
|
93
84
|
- errors.js: Error tiers: what to do when a module hook, onFixed / onFra…
|
|
94
85
|
- events.generated.js: Generated, do not edit by hand: npm run map generates it fr…
|
|
86
|
+
- grid.js: 2D grid fields: sampleGrid turns an array of numbers laid o…
|
|
87
|
+
- gridLoad.js: Load an image file as grid data (assets.gridFromImage)
|
|
95
88
|
- ground.js: Ground API (part of Engine, mixed into Engine.prototype): w…
|
|
89
|
+
- holds.js: Who holds the engine still: pause / resume, freeze / unfree…
|
|
96
90
|
- inputContext.js: Input contexts (like Unity's Action Maps): a stack of named…
|
|
97
91
|
- inputDefaults.js: Input defaults and strings (split out of Input.js): neutral…
|
|
98
92
|
- inputPad.js: Gamepad (standard layout) button names; like keyboard key n…
|
|
@@ -100,16 +94,26 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
100
94
|
- inputTouch.js: The touch part of input: which on-screen controls the game …
|
|
101
95
|
- lifecycle.js: Engine lifecycle (part of Engine, mixed into Engine.prototy…
|
|
102
96
|
- lightWatch.js: Dev-only check (called from loop.js after each render once …
|
|
97
|
+
- look/coreParts.js: look.tone, lights, clouds
|
|
98
|
+
- look/layers.js: The layer arithmetic behind a LookPart (part.js): where a k…
|
|
99
|
+
- look/part.js: engine.look.<part>: set / patch / replace and the layers
|
|
100
|
+
- look/report.js: describe().look, catalog('look.*')
|
|
101
|
+
- look/write.js: How a value gets into a LookPart: normalize, flatten, check…
|
|
103
102
|
- loop.js: Main loop (part of Engine, mixed into Engine.prototype): fi…
|
|
104
103
|
- math.js: Small shared helpers (used by several modules)
|
|
105
104
|
- modules.js: Module installation (part of Engine, mixed into Engine.prot…
|
|
106
105
|
- movement.js: One shared definition of "can walk there": character radius…
|
|
107
106
|
- mulberry32.js: mulberry32, the one copy (engine.random and terrain placeme…
|
|
107
|
+
- opsAtomic.js: Atomic ops (op definition atomic: true): world records, inv…
|
|
108
108
|
- opsCheck.js: Dev checks for engine.ops (split out of Ops.js): op definit…
|
|
109
|
+
- opsFail.js: Structured op failures
|
|
109
110
|
- opsGuard.js: The dev guard of engine.ops (split out of Ops.js): reports …
|
|
110
111
|
- opsHistory.js: The history of engine.ops (split out of Ops.js): a ring of …
|
|
112
|
+
- opsRun.js: ops.run itself (split out of Ops.js)
|
|
111
113
|
- page.js: engine.page: the one place that listens to the browser wind…
|
|
114
|
+
- params.js: Param schemas: one plain-object description per field, shar…
|
|
112
115
|
- pureWorker.js: Worker that runs pure-function batches for engine.threads (…
|
|
116
|
+
- renamed.js: The ONE list of names renamed in 0.2: plain data with no im…
|
|
113
117
|
- saveApply.js: Applying a save (split out of Saves.js): every part is chec…
|
|
114
118
|
- saveFiles.js: Save files (.json download / restore), split out of Saves.j…
|
|
115
119
|
- saveIds.js: Record ids inside save data, for upgrade steps (saves.regis…
|
|
@@ -117,27 +121,30 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
117
121
|
- scatter.js: Scatter by rule: where instances go in one ground chunk (pl…
|
|
118
122
|
- sceneMethods.js: Scene and render settings on the engine (split out of Engin…
|
|
119
123
|
- screenToGround.js: Screen point -> ground point: what clicking the ground mean…
|
|
124
|
+
- services.js: Engine services: the objects every engine owns besides rend…
|
|
120
125
|
- session.js: engine.session: one playthrough, from "new game" or "load" …
|
|
121
126
|
- shadowTypes.js: three 0.187 shadow filters
|
|
122
127
|
- skip.js: Skipping time (part of Engine, mixed into Engine.prototype)…
|
|
123
128
|
- startup.js: Startup (part of Engine, mixed into Engine.prototype): star…
|
|
124
129
|
- streamCells.js: Per-chunk view of stream sources for loaders that sync whol…
|
|
125
130
|
- streamSources.js: Stream sources (internal half of engine.stream): the places…
|
|
126
|
-
- styleParts.js: A style built from parts: createEngine({ style: [
|
|
131
|
+
- styleParts.js: A style built from parts: createEngine({ style: [basePack, …
|
|
127
132
|
- targeting.js: Target selection: pure functions (no camera, input or engin…
|
|
133
|
+
- thingExplain.js: engine.thing(id).explain(): everything known about one id i…
|
|
128
134
|
- thingOps.js: engine.thing and the two built-in ops on things (thing.set …
|
|
129
135
|
- things.js: Object registry behind engine.thing: every root handed to e…
|
|
130
136
|
- threadPure.js: Pure functions for workers: a function is sent as its sourc…
|
|
131
137
|
- threadServe.js: Worker side of engine.threads lanes: serve(handler) answers…
|
|
132
138
|
- tier.js: Device tier: Engine uses it at construction to pick default…
|
|
139
|
+
- util.js: Small helpers several core files need
|
|
133
140
|
- validate.js: Runtime checks: when an option or name is misspelled, print…
|
|
134
141
|
|
|
135
142
|
**modules/** (one line per folder: what it does; its files)
|
|
136
143
|
- ambience/ Ambience module: a rule table of background sounds — Ambience.js
|
|
137
|
-
- camera/ Camera module collection — FirstPersonCamera.js, FixedCamera.js, FollowCamera.js, RtsCamera.js, common.js, index.js
|
|
138
|
-
- characters/ Characters module: player (keyboard/stick control, camera follow, footsteps, en… — Character.js, NPC.js, assetModel.js, astar.js, behaviors.js, footsteps.js, index.js, moveHelpers.js, movers/common.js, movers/rapier.js, movers/simple.js, npcAvoid.js, npcSim.js, npcView.js, pathAsync.js, pathJob.js, pathWorker.js, playerStrings.js, proceduralRig.js
|
|
144
|
+
- camera/ Camera module collection — FirstPersonCamera.js, FixedCamera.js, FollowCamera.js, RtsCamera.js, common.js, index.js, projection.js
|
|
145
|
+
- characters/ Characters module: player (keyboard/stick control, camera follow, footsteps, en… — Character.js, NPC.js, assetModel.js, astar.js, behaviors.js, footsteps.js, index.js, moveHelpers.js, movers/common.js, movers/rapier.js, movers/simple.js, npcAvoid.js, npcSim.js, npcView.js, pathAsync.js, pathJob.js, pathWorker.js, playerStrings.js, proceduralRig.js, useModel.js, walkTo.js
|
|
139
146
|
- collision/ Lightweight collision: characters are upright cylinders, trees/rocks are circle… — Collision.js, grid.js
|
|
140
|
-
- content/ Content loader: hands the plain data in the game's content/*.js to the engine (… — ids.js, index.js, loader.js, models.js, packs.js, props.js, rules.js, templates.js
|
|
147
|
+
- content/ Content loader: hands the plain data in the game's content/*.js to the engine (… — explain.js, ids.js, index.js, loader.js, models.js, packs.js, props.js, rules.js, templates.js
|
|
141
148
|
- debug/ Performance panel + time/weather debugging + stress test — DebugPanel.js
|
|
142
149
|
- entities/ Entities — Entities.js, build.js, index.js
|
|
143
150
|
- flow/ Game flow: states (title, playing, paused, game over...) and scene transitions … — index.js
|
|
@@ -154,14 +161,14 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
154
161
|
- photo/ Photo mode: while taking the shot, temporarily raise resolution and shadow prec… — Photo.js
|
|
155
162
|
- rigid/ Real physics (Rapier): objects that topple, roll, get pushed and float on water — RigidBodies.js, Vehicles.js, sync.js
|
|
156
163
|
- settings/ Settings menu module entry — Settings.js, apply.js, index.js, sections.js, strings.js, view.js
|
|
157
|
-
- sky/ Sky module: dome shader (gradient + sun + moon + stars), sun/moon directional l… — Sky.js, calendar.js, cascades.js, clouds.js, domeLayers.js, environment.js, fog.js, frame.js, layers.js, look.js, schedule.js, shader.js, shadow.js, skyModule.js
|
|
158
|
-
- terrain/ Terrain module: chunked, streamed ground built from a height function (or a hei… — ChunkManager.js, chunkJob.js, chunkQueries.js, chunkWorker.js, index.js, mountTerrain.js, terrainColorMap.js, terrainDefaults.js, terrainEdit.js, terrainGen.js, terrainIsland.js, terrainMesh.js, terrainShape.js, terrainShapeMain.js, terrainTexture.js
|
|
164
|
+
- sky/ Sky module: dome shader (gradient + sun + moon + stars), sun/moon directional l… — Sky.js, calendar.js, cascades.js, clouds.js, domeLayers.js, environment.js, fog.js, frame.js, layers.js, look.js, lookFog.js, lookShadow.js, lookSky.js, schedule.js, shader.js, shadow.js, skyModule.js
|
|
165
|
+
- terrain/ Terrain module: chunked, streamed ground built from a height function (or a hei… — ChunkManager.js, chunkJob.js, chunkLevels.js, chunkQueries.js, chunkWorker.js, index.js, lookGround.js, mountTerrain.js, terrainColorMap.js, terrainDefaults.js, terrainEdit.js, terrainGen.js, terrainIsland.js, terrainMesh.js, terrainShape.js, terrainShapeMain.js, terrainTexture.js
|
|
159
166
|
- timeline/ Timeline: cutscenes, camera moves, scripted movement — Timeline.js, Tween.js, letterbox.js, shots.js
|
|
160
167
|
- triggers/ Trigger zone module: invisible regions in the world that notify you when the pl… — index.js
|
|
161
|
-
- vegetation/ Vegetation module factory: engine.use(vegetation(...)) — Vegetation.js, groundChunks.js, index.js, modelGeometry.js
|
|
162
|
-
- water/ Water module: draws the global water plane (sea, big lakes; snaps to a grid fol… — Water.js, surface.js
|
|
163
|
-
- weather/ Weather: the game's table of weather types (weather({ types })); without one on… — Weather.js, particles.js, shaders.js
|
|
164
|
-
- world/ world() module: installed as engine.world (world data, see World.js) — World.js, cells.js, index.js, persist.js, pos.js, records.js, sim.js, simFar.js, state.js, views.js
|
|
168
|
+
- vegetation/ Vegetation module factory: engine.use(vegetation(...)) — Vegetation.js, groundChunks.js, index.js, lookWind.js, modelGeometry.js, nearFade.js
|
|
169
|
+
- water/ Water module: draws the global water plane (sea, big lakes; snaps to a grid fol… — Water.js, look.js, surface.js
|
|
170
|
+
- weather/ Weather: the game's table of weather types (weather({ types })); without one on… — Weather.js, look.js, particles.js, shaders.js, strings.js
|
|
171
|
+
- world/ world() module: installed as engine.world (world data, see World.js) — World.js, cells.js, explain.js, index.js, persist.js, pos.js, records.js, sim.js, simFar.js, state.js, thingSource.js, views.js
|
|
165
172
|
|
|
166
173
|
**render/**
|
|
167
174
|
- PostFX.js: Post-processing as an ordered list of named effects in four…
|
|
@@ -171,8 +178,10 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
171
178
|
- fuse.js: Fused post pass: several effects that each carry a small GL…
|
|
172
179
|
- lighting.js: The `lighting` surface patch and the toon ramp: extra, opti…
|
|
173
180
|
- lights.js: Default lights every engine has (engine.lights, the mechani…
|
|
181
|
+
- lookSurface.js: look.materials and look.surface (render/materials.js reads …
|
|
174
182
|
- materials.js: Materials and shaders: Material factory makeMaterial(role, …
|
|
175
183
|
- patches.js: Named shader patches: one way to add shader code to any thr…
|
|
184
|
+
- postLook.js: look.post: the post-processing chain as a look part (recipe…
|
|
176
185
|
- surface.js: Surface keys of a material spec (used by makeMaterial): tex…
|
|
177
186
|
- uniformDecl.js: Declares style-supplied GLSL uniforms (sky clouds, wind): {…
|
|
178
187
|
|
|
@@ -237,7 +246,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
237
246
|
| quest:start | gameplay | — |
|
|
238
247
|
| quest:step | gameplay | — |
|
|
239
248
|
| save:imported | core/saveFiles.js | photo |
|
|
240
|
-
| save:loaded | core/saveApply.js |
|
|
249
|
+
| save:loaded | core/saveApply.js | characters |
|
|
241
250
|
| save:written | core/Saves.js | — |
|
|
242
251
|
| season:change | sky | sky |
|
|
243
252
|
| session:end | core/session.js | core/skip.js, flow, gameplay, hud, music, timeline, triggers |
|
|
@@ -251,8 +260,8 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
251
260
|
| timeline:start | timeline | — |
|
|
252
261
|
| trigger:enter | triggers | camera, content |
|
|
253
262
|
| trigger:exit | triggers | content |
|
|
254
|
-
| ui:close | ui/Parts.js, ui/UI.js | core/
|
|
255
|
-
| ui:open | ui/Parts.js, ui/UI.js | core/
|
|
263
|
+
| ui:close | ui/Parts.js, ui/UI.js | core/services.js, settings |
|
|
264
|
+
| ui:open | ui/Parts.js, ui/UI.js | core/services.js, settings |
|
|
256
265
|
| vegetation:remove | vegetation | — |
|
|
257
266
|
| vegetation:restore | vegetation | — |
|
|
258
267
|
| vehicle:enter | characters | characters |
|
|
@@ -313,7 +322,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
313
322
|
- modules/settings/strings.js: settings.* (42)
|
|
314
323
|
- modules/timeline/Timeline.js: timeline.* (2)
|
|
315
324
|
- modules/triggers/index.js: triggers.* (1)
|
|
316
|
-
- modules/weather/
|
|
325
|
+
- modules/weather/strings.js: weather.* (8)
|
|
317
326
|
- ui/defaults.js: title.* (3)
|
|
318
327
|
|
|
319
328
|
## Style pack keys (who reads engine.style.xxx)
|
|
@@ -321,13 +330,18 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
321
330
|
| Key | Read in |
|
|
322
331
|
|---|---|
|
|
323
332
|
| character | characters |
|
|
333
|
+
| clouds | core/look/coreParts.js |
|
|
334
|
+
| exposure | core/look/coreParts.js |
|
|
324
335
|
| grid | grid |
|
|
325
|
-
|
|
|
336
|
+
| lighting | render/lookSurface.js |
|
|
337
|
+
| materials | render/lookSurface.js |
|
|
338
|
+
| palette | core/Assets.js, core/assetLoad.js, characters |
|
|
326
339
|
| particles | particles |
|
|
327
340
|
| pickup | gameplay |
|
|
328
341
|
| seasons | sky |
|
|
329
342
|
| sky | sky |
|
|
330
343
|
| terrain | terrain |
|
|
344
|
+
| toneMapping | core/look/coreParts.js |
|
|
331
345
|
| triggers | triggers |
|
|
332
346
|
| ui | gameplay, hud, ui/LoadingScreen.js, ui/UI.js |
|
|
333
347
|
| water | water |
|
package/docs/COMMANDS.md
CHANGED
|
@@ -12,7 +12,7 @@ After `-w` write the directory or the package name (inside a game directory a pl
|
|
|
12
12
|
- Test: `npm test -w games/my-game`, or `npm test -- -w my-game`; `npm test` at the root tests every workspace (engine + each game).
|
|
13
13
|
- Build: `npm run build -w games/my-game`; `npm run build` at the root builds all (every *.html in a workspace root is bundled, no change to
|
|
14
14
|
vite.config.js needed).
|
|
15
|
-
- Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only
|
|
15
|
+
- Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--keep` timestamped file name, `--look` pixel numbers), `npm run bake -- -w my-game`, `npm run assets -- -w my-game`.
|
|
16
16
|
- A game's tests: if `games/<game>/tests/specs.mjs` exists it runs; otherwise a smoke test runs automatically (page opens, engine ready, no console
|
|
17
17
|
errors). Minimal example:
|
|
18
18
|
```js
|
|
@@ -32,7 +32,8 @@ export const specs = [{
|
|
|
32
32
|
```
|
|
33
33
|
Tests run against the built bundle (not the dev server): main.js must set `window.engine = engine;` before `await engine.start()`, otherwise the
|
|
34
34
|
test waits for the engine until timeout (the error explains why).
|
|
35
|
-
- New game: `npm run new-game name
|
|
35
|
+
- New game: `npm run new-game -- name [--example] [--style empty|<path-or-package>]` (clean start by default; `--example` adds the old sample; see `recipes/01-new-game.md`).
|
|
36
|
+
- Game in your own folder (outside this repo): after `npm install threedog three@~0.187.0 @threedog/tools`, run `npx threedog init [name] [--example] [--style empty|<path-or-package>]`: it copies the new-game template without overwriting anything, merges package.json and writes `.mcp.json`, so Claude Code opened in that folder starts the threedog MCP server by itself.
|
|
36
37
|
|
|
37
38
|
> Git Bash (MSYS) rewrites arguments that start with `/` (`/styletest.html` turns into a Windows path). Write `shot styletest`, or set `MSYS_NO_PATHCONV=1`, or use PowerShell.
|
|
38
39
|
|
|
@@ -40,15 +41,28 @@ export const specs = [{
|
|
|
40
41
|
| Command | When to use |
|
|
41
42
|
|---|---|
|
|
42
43
|
| `npm run dev` | Development. Browser errors are sent automatically to the terminal and to the workspace's `.threedog/errors.log` (e.g. `games/my-game/.threedog/errors.log`): read that file first when something breaks, before taking screenshots. Known error classes carry `Possible cause: …` and `Read: recipes/…` lines (table `core/errorHints.js`) |
|
|
43
|
-
| `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): hard rules + rule checks (`packages/tools/rules/`; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. `-- --rule R4` runs one rule, `-- --all` lists every warning |
|
|
44
|
+
| `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): hard rules + rule checks (`packages/tools/rules/`; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. `-- --rule R4` runs one rule, `-- --all` lists every warning, `-- -w game` (or `npx threedog check -w game`) checks one game only: its content validation and GAMEMAP freshness (not the engine rules/types; run plain `check` before committing engine changes) |
|
|
45
|
+
| R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls timers, `Math.random`, an inventory, grid/height blending or materials is pointed to the engine system that already does it. Off per line `// hint-off(kind)`, per file `// hint-off-file(kind)`, per project `package.json "threedog": { "hints": false | { "kind": false } }`, per run `THREEDOG_HINTS=off`. A deliberate choice goes in DESIGN.md Systems |
|
|
44
46
|
| `npm run types` | Type check only (does game code misuse the engine API) |
|
|
45
47
|
| `npm test` | Full browser tests (slow). Normally `npm test -- name` runs only the related ones (matched by test-name substring, e.g. `-- HLOD`), `-- -w game` tests one game. `-- --update-snapshots` makes tests that use `expectDescribe` write their describe baselines (`tests/snapshots/*.describe.json`) instead of comparing. `npm test -- pack` (the build test): after a real build of each game, open only dist from a static server and check that the engine is ready, no 4xx resources, no console errors |
|
|
46
48
|
| `npx threedog snap-describe save|diff name [--only a,b]` | Describe snapshot instead of a screenshot: baseline of the gameplay part of `describe()` (see recipes/16-dev-bridge.md section 7); in tests one line `expectDescribe({ check, ev }, name, { only, tolerance })` from `@threedog/tools/describe-snapshot` |
|
|
47
49
|
| `threedog play` / `play --stop` | Start the game for the AI: starts the dev server if none runs (detached, output in `.threedog/dev.log`), waits for the dev bridge and the engine, prints the page address and whether a headless or a live browser page is connected. `--stop` stops the server play started |
|
|
48
50
|
| `threedog status` | One call: engine ready, loading done, page errors, running / paused / frozen. When the bridge cannot answer it names one of four causes with one next step: no server (`threedog play`), server still starting (wait, status again), page script error (`threedog errors latest`), no dev bridge installed (use `gameConfig`) |
|
|
49
|
-
| `threedog
|
|
51
|
+
| `threedog session [--minutes N]` / `session stop` / `session status` | Optional: keeps one small local process alive (127.0.0.1, token, `.threedog/session.json`) so later bridge commands skip module loading (about 0.1 to 0.15 s less per command); exits by itself after N idle minutes (default 10). Every command works the same without it: no session, a dead one or an unreachable one falls back to a direct call. Restart it after editing the tools |
|
|
52
|
+
| `threedog js --file steps.js [--verbose]` | A script that calls `assert(cond, msg)` or `expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg)` runs as checks in ONE call: globals `engine`, `step(seconds)`, `log(...)`; failed checks are recorded and the script goes on, a throw stops it. Output: `✓ 7 checks passed`, or the failures then `✗ 2 of 7 checks failed`; exit code 1 on failure. `--verbose` adds passes, `log` lines and the return value. A script without those calls is the plain eval |
|
|
53
|
+
| `threedog verify scenario` | Run `tests/scenarios/<scenario>.json` on the running page and print PASS / FAIL, **Tested** (ops with outcomes, describe sections compared, time advanced), **Not tested** (ops never run, sections never compared, steps skipped after a failure, key path, picture), a `Layers:` line (steps by layer: direct = op/describe call, simulated-input = bridge press; real-browser-input is always 0 and printed as not verified, visual 0 because scenario snapshots are describe, not pixels), tests that mention an error code seen, and the `threedog test` command to re-run. A page error during the run fails it. JSON adds `layers` / `layerCounts` / `evidence` (per-check layers, notProven, ops / modules coverage; text: Evidence, NOT proven, Coverage: ops ran/total with refused ones marked, modules tested / indirect / untested, lists capped with "+N more"). `threedog scenario` prints its pass line plus the same Coverage block |
|
|
54
|
+
| `threedog catalog [id] [--find word] [--json]` | What this game can do: modules, ops (args, failure codes, last attempt), saves, time. `recipes/51-capability-catalog.md` |
|
|
55
|
+
| `threedog how "<task>"` | Ranks the AI.md task rows and recipe headings for a task in your own words. `recipes/51-capability-catalog.md` section 5 |
|
|
56
|
+
| `threedog explain op shop.buy shop=bakery` / `explain quest first-light` | Why an op cannot run now, or what a quest waits on (`engine.explain`). `recipes/23-ops.md` |
|
|
57
|
+
| `threedog thing <id>` | Everything about one id: definition file:line, model, materials, state, ops, save tier, how to change it (`thing.explain()`). `recipes/41-thing-registry.md` section 6 |
|
|
58
|
+
| `threedog content set <id> <field> <json> [--in props] [--dry]` (or `<id> x=12 place=home …`: several fields, one write, one check, all-or-nothing) | Write a permanent change into the content entry. `recipes/41-thing-registry.md` |
|
|
59
|
+
| `threedog loading [task]` | Loading progress and what failed, also while `start()` is stuck. `recipes/05-props-bake.md` |
|
|
60
|
+
| `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
|
|
61
|
+
| `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
|
|
62
|
+
| `threedog shot --view name [--compare before.png]` | A named camera view (`engine.views.define`) and a pixel diff against an earlier picture. `recipes/46-blender-art-route.md` |
|
|
63
|
+
| `threedog skip to=06:00` / `skip seconds=600` | Jump the clock like sleeping (`engine.skip`: op `time.skip`, sky clock and time-keeping modules catch up; optional `fade=0.6 save=auto`). Needs the sky module for `to` |
|
|
50
64
|
| `threedog errors` / `errors latest [N]` / `errors --since E5` | Page errors with id (E1…), time, tick, source and count. Plain `errors` = new since the last read; `latest` = the last N (default 3), same answer every time; `--since` = after an id, never moves the read position. Every result prints a cursor |
|
|
51
|
-
| Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game paused, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|paused|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, scenario, verify. **No game time**: op, state, eval, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it |
|
|
65
|
+
| Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game paused, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|paused|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it |
|
|
52
66
|
| `npm run map` | Regenerate CODEMAP, API.md + api/, each game's GAMEMAP and the event-name list (generated from `EventMap` in core.d.ts; add a new event to EventMap first) after changing code, JSDoc or content (run it before `check`) |
|
|
53
67
|
| `npm run shot -- / --time 18:30 --weather rain --pos x,z` | Only when you need to see the picture; by default 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`**. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time |
|
|
54
68
|
| `npm run shot -- styletest --view room --time dusk --weather rain` | The fixed style-judging scene (`examples/styletest`, page `/styletest.html`; a bare name is a page of the workspace). `--view` = a named camera (overview, character, water, room, path, ui), `--time` also takes day / dusk / night, `--weather` clear / rain / snow; same arguments every round, so only the style differs. `--panel` is not a shot option: open `/styletest.html?panel=1` in a browser for the workbench (recipes/35) |
|
|
@@ -58,7 +72,7 @@ export const specs = [{
|
|
|
58
72
|
| `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models/): the level manifest (spawns, col_ colliders, trigger_ zones, npcs, markers, template / id nodes, missing templates, duplicate ids), material and color-space suspicions (data texture in a color slot, BLEND, texture without UV, oversized texture), statistics. `--json` for tools, exit 1 on errors (`--strict`: on warnings too). `npm run check` also reads the level glbs for content validation |
|
|
59
73
|
| `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld); compare with `PERF.md` |
|
|
60
74
|
| `npx threedog content ids [-w game \| folder] [--write]` | Stateful content entries (pickups, template instances with state / container / interact / body) that rely on their index id: prints the id each has now as `-`/`+` lines (dry run); `--write` writes them into `content/*.js`. Rename later through `content/renames.js` (recipe 30) | <!-- r18-ignore-line -->
|
|
61
|
-
| `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems. Checks Node version, node_modules, workspace links, package-lock consistency, `.threedog` writable, port 5173, the dev server recorded in `.threedog/dev.json`, Playwright chromium, headless WebGL2, `EXT_disjoint_timer_query_webgl2` (software rendering normally lacks it; info only). Run it first when the environment acts strange |
|
|
75
|
+
| `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems. Checks Node version, node_modules, workspace links, package-lock consistency, `.threedog` writable, the physical copy (real path, version, package.json mtime) of engine / tools / three per context (check, run/build per game; a `MISMATCH` line when contexts use different copies, e.g. vendor/ vs node_modules), port 5173, the dev server recorded in `.threedog/dev.json`, Playwright chromium, headless WebGL2, `EXT_disjoint_timer_query_webgl2` (software rendering normally lacks it; info only). Run it first when the environment acts strange |
|
|
62
76
|
| `npm run new-style name` | New style pack from a clean template (gray neutral materials, sky, one palette, empty post, one palette-colored example model): `packages/styles/<name>`, package `@threedog/style-<name>`, workspace link and lock updated, then `style check`, `map` and `check` run. Lowercase letters, digits and hyphens only |
|
|
63
77
|
| `threedog style check [pack\|folder\|file] [--json] [--assets file]` | Check the final merged style: unknown fields (did-you-mean), world-state fields, palette keys read but not defined, color formats, post-effect conflicts, misspelled material roles / types, asset names the pack does not register; plus R34 for that pack. Exit 1 on errors. Static: it cannot prove a pack has no gameplay logic. See `recipes/35-style-from-reference.md` |
|
|
64
78
|
| `threedog style palette <image> [--n 8] [--average] [--region x,y,w,h] [--ignore-ui] [--crop out.png]` | Dominant colors of a reference picture and a one-line summary (headless Chromium reads the pixels). `--average` adds the mean color (HSL); `--region` measures one rectangle; `--ignore-ui` cuts a flat frame around the picture (edge row / column one flat color, frame 3% to 45% of the picture; a plain sky at the edge looks the same, so check with `--crop out.png`, which saves the measured area). The output says what was measured. A measurement, not a design decision |
|
|
@@ -84,7 +98,7 @@ export const specs = [{
|
|
|
84
98
|
- `modules/` modules, one folder each, installed with `engine.use`; list in `CODEMAP.md`.
|
|
85
99
|
- `render/ ui/` material factory, post-processing; UI basics (windows, UI focus stack, toast, fadeScreen, worldToScreen).
|
|
86
100
|
- `index.js index.d.ts types/` entry and API declarations (`types/generated/` is generated from source JSDoc, never edited by hand).
|
|
87
|
-
- `packages/styles/lowpoly/` (`@threedog/style-lowpoly`,
|
|
101
|
+
- `packages/styles/lowpoly/` (`@threedog/style-lowpoly`, private, example-only: not published, not a recommended look) the pack the bundled examples, tests and older games use: `index.js` holds the style pack (all
|
|
88
102
|
look parameters) and exports the asset pack `assets`, `models.js` the procedural models in it, `shapes.js` the default humanoid and pickup shapes,
|
|
89
103
|
The bloom / outline / ao effects are in `packages/post-effects/` (`@threedog/post-effects`). The terrain preset `terrainPreset()` is a separate package, `packages/terrain-noise/` (`@threedog/terrain-noise`).
|
|
90
104
|
- `examples/world/` is the engine example (open world `/`, content-only placement). The small city (level, no terrain, no style pack, top-down) and
|
package/docs/CONVENTIONS.md
CHANGED
|
@@ -23,9 +23,19 @@ The opts of `assets.texture(name, opts)` are part of the cache key: the same ima
|
|
|
23
23
|
|
|
24
24
|
## Adjusting sky brightness
|
|
25
25
|
The engine overwrites `sky.sun / sky.hemi` (intensity, color, position), `scene.fog` and the `camera` pose every frame; don't set them directly.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Change the light through `engine.look.lights` / `engine.look.fog` (overrides), or `engine.sky.modify` for a layer that multiplies the sky's own output
|
|
27
|
+
(which to pick: `recipes/52-look.md`). Take over the camera with `engine.takeCamera(owner)` (or a timeline camera step).
|
|
28
|
+
|
|
29
|
+
## Owners
|
|
30
|
+
Everything that holds the engine is named by an owner, and only that owner releases it. Positional `pause('menu')` and `pause({ owner: 'menu' })` are the same.
|
|
31
|
+
|
|
32
|
+
| What | Take | Release | Returns |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| Real-time loop | `pause(owner, { kind? })` | `resume(owner)` | handle `{ remove() }` |
|
|
35
|
+
| Gameplay freeze | `freeze(owner, { kind? })` | `unfreeze(owner)` | handle |
|
|
36
|
+
| Camera | `takeCamera(owner, { focus? })` | `handle.remove()` | handle |
|
|
37
|
+
| Debug override / view | `debug.override(owner, ...)`, `debug.view(mode, { owner })` | `debug.clear(owner)` | handle / state |
|
|
38
|
+
| Look values | `look.<part>.set(values, { owner })` | `look.<part>.clear(owner)` | handle |
|
|
29
39
|
|
|
30
40
|
## Worker limits
|
|
31
41
|
`modules/terrain/terrainGen.js` (via `chunkJob.js`) runs in a Worker and must not import three.js; a vegetation `rule` is sent to the Worker and must
|
|
@@ -98,8 +108,8 @@ inside template strings, which then throw on the first call).
|
|
|
98
108
|
|
|
99
109
|
## Core conventions
|
|
100
110
|
- Lighting without `sky`: every engine has `engine.lights = { sun, hemi }` (neutral); to light the scene yourself hide or adjust them and add three.js
|
|
101
|
-
lights. The engine ships no art: the humanoid, pickup shapes and flat shading
|
|
102
|
-
|
|
111
|
+
lights. The engine ships no art: the humanoid, pickup shapes and flat shading belong to a style pack or asset pack you add (e.g.
|
|
112
|
+
a pack with `terrain.config.shading: 'flat'`); without a style pack or model the engine shows a gray capsule, a gray box and flat gray ground at y
|
|
103
113
|
= 0, with a dev warning naming the fix.
|
|
104
114
|
- Gameplay state (world, containers, vars, quests) changes only in fixed steps or inside ops; dev warns otherwise (`.threedog/ops-guard.log` after
|
|
105
115
|
`npm test`). (game side)
|
|
@@ -113,11 +123,9 @@ inside template strings, which then throw on the first call).
|
|
|
113
123
|
- To be saved, call `engine.saves.register(key, { save, load })` (`load` may return a Promise); `saves.save / load` always return `Promise<boolean>`,
|
|
114
124
|
so `await` them. Saved data names things by stable ids, never positions; when it changes shape raise `version` and add a `migrate` step
|
|
115
125
|
(`recipes/20-content-actions-save.md` "Save format").
|
|
116
|
-
- The engine overwrites `sky.sun / sky.hemi`, `scene.fog` and the `camera` position/orientation every frame; don't set them. Adjust brightness with
|
|
117
|
-
`engine.sky.modify('layer', {...})`; take over the camera with `engine.cameraOverride = { owner }` or a timeline camera step (see "Adjusting sky
|
|
118
|
-
brightness" above).
|
|
119
126
|
- Day / night comes only from sky: read `sky.isDay`, use `sky.daylight` (0-1) for fades; don't judge by clock time yourself.
|
|
120
127
|
- A game's own look parameters (colors, materials) belong in its style pack (`style`) or the content, never hard-coded into logic.
|
|
128
|
+
- Whatever a style pack provides as a factory can also be passed at the call site, and the call site wins (`spawnPickup(item, pos, { mesh })` over `style.pickup.model`); look-driven parts (sky, clouds, water, materials) are overridden with `engine.look.<part>.set / patch / replace`. A new style factory must ship with its call-site option.
|
|
121
129
|
- Vegetation `rule` must not contain functions (it is sent to a Worker).
|
|
122
130
|
- Terrain is editable: `engine.terrain.edit(pos, { lower|raise|flatten|paint })`, only inside an op or fixed step; custom
|
|
123
131
|
`terrain({ height, groundType })` must be pure functions.
|
|
@@ -125,10 +133,13 @@ inside template strings, which then throw on the first call).
|
|
|
125
133
|
never removes its world record.
|
|
126
134
|
- Window blur, tab hidden, pointer lock and WebGL context loss are listened to only in `core/page.js`; modules read `engine.page` or listen to
|
|
127
135
|
`page:*`. Show "saved" only after `saves.save` returns true.
|
|
128
|
-
-
|
|
129
|
-
now
|
|
130
|
-
|
|
136
|
+
- Character bodies are assets, not style: `createPlayer({ ...presets.player.thirdPerson, model: 'humanoid' | 'hero' })` (a procedural builder is built
|
|
137
|
+
now; a file shows a gray capsule and is swapped in when it loads: `await player.whenReady`, event `character:model`), or `{ rig }`; a name no model
|
|
138
|
+
asset has throws. Style packs tint bodies through material roles (cloth, skin, trousers, hair).
|
|
131
139
|
- Importing the engine makes `Mesh.prototype.customDepthMaterial` / `customDistanceMaterial` default to a depth material carrying the mesh material's
|
|
132
140
|
vertex patches, so wind-swayed meshes cast swaying shadows with nothing to set up; assigning your own value still wins. Shader time, wind and cloud
|
|
133
141
|
cover are per engine in `engine.uniforms` (share them in your own `ShaderMaterial`); with two engines on a page, pass the engine to
|
|
134
142
|
`makeMaterial(role, params, engine)`.
|
|
143
|
+
|
|
144
|
+
## Failures: which shape
|
|
145
|
+
A runtime "can't" (not enough money, shelf empty) is returned as `{ ok: false, code, facts, nextActions }` (ops.run / can / undo). Misuse (a wrong call, a typo) is a thrown `codedError`. Documented exceptions: `checkSkip` / `checkSave` return `{ ok, diffs }`, `walkTo` returns `{ status }`. Read `code`; `reason` is a deprecated alias of it until 1.0.
|
package/docs/THREE.md
CHANGED
|
@@ -23,7 +23,7 @@ write it the three.js way you already know, as long as you follow the convention
|
|
|
23
23
|
| Rays | `engine.raycast(origin, direction)` / `engine.pick(ndcX, ndcY)` return three hits (`object` is the mesh, `face` and `point` unchanged); `{ targets: 'all' }` hits rigid bodies too (the hit carries `entry` and `kind: 'rigid'`); the underlying `engine.rays.ray` (THREE.Raycaster, `firstHitOnly` on) |
|
|
24
24
|
| Ray acceleration (BVH) | three-mesh-bvh: on import (`import 'threedog'`) the engine replaces `Mesh.prototype.raycast` page-wide, the way three-mesh-bvh recommends, so your own `new THREE.Raycaster()` uses it too (meshes without a `boundsTree` take three's normal path); a registered mesh has `mesh.geometry.boundsTree` (MeshBVH, built only from 256 triangles up) |
|
|
25
25
|
| Streamed-in objects | `.object` of the handle returned by `engine.stream.add({ position, build })` (the Object3D that build returned; null before it is built) |
|
|
26
|
-
| Post-processing | `engine.post.
|
|
26
|
+
| Post-processing | `engine.look.post.replace([{ name, slot, create: ctx => pass }, ...])` takes any three.js Pass as a named effect in a slot (`scene` / `hdr` / `ldr` / `final`); `look.post.set({ 'name.enabled': false })` |
|
|
27
27
|
| Where the mouse points | Ground: `screenToGround(engine, input.pointer.ndcX, ndcY)` -> Vector3; objects: `engine.pick(input.pointer.ndcX, ndcY)` (registered static objects; for any object pass `{ targets: [object] }`) |
|
|
28
28
|
|
|
29
29
|
Returned positions are all `THREE.Vector3` (the camera's `forward()/right()` are planar directions `{x, z}`; positions in photo records are saveable `{x, z}`).
|
|
@@ -55,8 +55,8 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
|
|
|
55
55
|
`engine.sky.modify('layer', { sun, ambient, fog, tint, tintAmount })` (multipliers, layers multiply; `null` removes), and don't change
|
|
56
56
|
`sky.sun.intensity` or `sky.modifiers` (the combined result, read-only). Adding your own point lights (street lamps, campfires) is fine.
|
|
57
57
|
7. **Camera**: only change properties of `engine.camera`, never replace it with a new camera (post-processing is bound to this one). When a camera
|
|
58
|
-
module is installed it places the camera every frame; to control the view yourself
|
|
59
|
-
`
|
|
58
|
+
module is installed it places the camera every frame; to control the view yourself take it with `const cam = engine.takeCamera('me')` and `cam.remove()` it
|
|
59
|
+
(`engine.cameraOverride` is read-only: it shows the holder in charge, or `null`).
|
|
60
60
|
8. Collision: the player only respects `engine.collision` (`addCircle / addBox / addObject(mesh)`); a mesh alone does not block anyone.
|
|
61
61
|
9. **Big code-generated things** (a city block, a whole group of houses): write them as a function registered in the manifest
|
|
62
62
|
`assets.manifest({ models: { block: buildBlock } })` and fetch with `assets.model('block')`; in development it is cached automatically, after
|
package/docs/api/assets.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- `assets.model(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Promise<Object3D>` — Get a model copy (name or path; geometry and materials are shared with other copies). static: true registers it in engine.rays (builds ray acceleration)
|
|
8
8
|
- `assets.modelNow(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Object3D | null` — A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs. Example: `const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');`
|
|
9
9
|
- `assets.geometry(nameOrUrl: string) → Promise<BufferGeometry>` — Get the geometry of the first mesh in a model
|
|
10
|
+
- `assets.gridFromImage(nameOrUrl: string, opts?: { channel?, range?, bits? }) → Promise<{ data: Float32Array; wid…` — An image as grid data for sampleGrid: PNG at 8 or 16 bits (jpg / webp 8). channel 'r' (default) 'g' 'b' 'a' or 0-3; range maps pixels to [min, max] (default [0, 1])
|
|
10
11
|
- `assets.texture(nameOrUrl: string, opts?: { color?, pixelated?, repeat? }) → Promise<Texture>` — Get a texture (.ktx2 compressed textures also work)
|
|
11
12
|
- `assets.release(name: string)` — Release a resource and return GPU memory. Not released while copies of the model are still in the scene; it is released when the last copy is removed with engine.remove
|
|
12
13
|
- `assets.trim() → string[]` — Release every model that has no copy in use (called automatically after level changes). Models whose shared geometry was taken by geometry() / cached() are not released automatically. Returns the released names
|
|
@@ -15,6 +16,8 @@
|
|
|
15
16
|
- `assets.cached(name: string, build: (params?: any) => T | Promise<T>, params?: any) → Promise<T>` — Code-generated model: generated only once per name + params, returns a copy (for geometry, the same one). Order: files baked by npm run bake (public/models/baked/) -> automatic dev cache (.threedog/cache, invalidated automatically when the generator or a file it imports changes) -> compute now. When the generator is newer than the baked file during development, it computes now and prints a one-time hint "run npm run bake once it is final"
|
|
16
17
|
- `assets.animate(root: Object3D, config?: AnimatorOptions) → Animator` — Create an animation state machine for a skinned model (without config it is simple play-by-name). A copy of a manifest model whose entry has `animation` starts from that mapping; config wins per state
|
|
17
18
|
- `assets.mapping(root: Object3D) → AnimatorOptions | null` — The manifest entry's animation mapping for a model copy, or null (not a manifest copy, or no mapping)
|
|
19
|
+
- `assets.report(nameOrRoot: string | Object3D) → AssetReport` — Import report of a loaded model (by name, or a copy from model()): materials, textures with colorSpace, clips, colliders, templates, and issues for what the file has but the scene lost
|
|
20
|
+
- `assets.reportText(nameOrRoot: string | Object3D) → string` — assets.report as text for the console / describe
|
|
18
21
|
- Properties:
|
|
19
22
|
- `cacheMinMs: number` Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20
|
|
20
23
|
- `shared: WeakSet<object>` Geometry and materials shared by model copies (engine.remove does not release them, use release)
|
package/docs/api/characters.md
CHANGED
|
@@ -22,11 +22,13 @@ Characters: createPlayer() (characters() module)
|
|
|
22
22
|
- `player.enter(vehicle: Vehicle)` — Board a vehicle (the vehicle returned by rigid.addVehicle)
|
|
23
23
|
- `player.exit()` — Exit the vehicle
|
|
24
24
|
- `player.playAction(name: string)` — Play a one-shot action (e.g. 'wave'); skipped if the model has no such clip
|
|
25
|
+
- `player.onPose(fn: (character, dt) => void) → { remove(): void }` — Run fn(character, dt) every frame right after the animation pose is applied (model clips or procedural rig): attach things to bones or adjust bones. h.remove() stops it. Presentation only. Example: `const h = player.onPose(() => sword.position.copy(hand.getWorldPosition(v)));`
|
|
25
26
|
- `player.dispose()` — Fully delete this character: exits the vehicle first, releases animation and movement, removes it from the scene and releases geometry and materials (used by npcs.remove / removePlayer)
|
|
26
27
|
- `player.jump()` — Request a jump
|
|
27
28
|
- `player.addTo(scene?: any)` — Add to the scene
|
|
28
29
|
- `player.placeAt(position: PositionLike)` — Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z })
|
|
29
30
|
- `player.syncRecord()` — After moving root yourself (a cutscene path, a scripted pose): write position and motion back to its world record (the player's), so a save right after has it
|
|
31
|
+
- `player.walkTo(target: Vector3 | { x: number; z: number } | [number, number, number] | …, opts?: { speed?, arrive?, turnRate?, stuckSeconds?, maxRepaths?, run? }) → Promise<{ status: 'arri… & { remove(): void }` — Walk to a point along characters.findPath on fixed steps; never rejects. One walk per character: a new walkTo, dispose() or a save load ends the old one with 'cancelled'. Transient: not saved, not fast-forwarded by engine.skip
|
|
30
32
|
- `player.move(dirX: number, dirZ: number, run: boolean, dt: number, speedOverride?: number)` — Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1), run to run, dt in seconds
|
|
31
33
|
- `player.groundType() → string` — Ground type underfoot ('water' while swimming)
|
|
32
34
|
- `player.face(target: PositionLike | number)` — Turn at once to a position, or to an angle in radians (0 = +Z)
|
|
@@ -104,7 +106,7 @@ Characters: createPlayer() (characters() module)
|
|
|
104
106
|
- `control: PlayerControl` Required, no default: 'camera' (keys relative to the camera) / 'none' (call player.move() yourself in onFixed) / (player, input, dt) => ({ x, z, run?, speed? }). Also the runtime property player.control. presets.player.* fill it
|
|
105
107
|
- `cameraFollow?: boolean` true: the camera module follows the player (and back after a vehicle, and on a new session). Omitted with a camera installed warns in dev
|
|
106
108
|
- **CharacterOptions** Character parameters (shared by the player and NPCs)
|
|
107
|
-
- `colors?: { body?, skin?, legs?, hair? }`
|
|
109
|
+
- `colors?: { body?, skin?, legs?, hair? }` Per-character part colors: recolor the body's meshes marked userData.part (a humanoid rig: body, skin, legs, hair); the style tints by material role
|
|
108
110
|
- `speed?: number` Walking speed (m/s), default 4.5
|
|
109
111
|
- `runSpeed?: number` Running speed (m/s), default 7
|
|
110
112
|
- `radius?: number` Collision radius (meters), default 0.4
|
|
@@ -119,7 +121,8 @@ Characters: createPlayer() (characters() module)
|
|
|
119
121
|
- `airControl?: number` Air control, 0–1
|
|
120
122
|
- `coyoteTime?: number` How long after walking off an edge a jump is still allowed (seconds)
|
|
121
123
|
- `canJump?: boolean` Whether it can jump, default true
|
|
122
|
-
- `model?: Object3D | string | null`
|
|
124
|
+
- `model?: Object3D | string | null` The body, one path for every kind: the name of a registered model asset, or what engine.assets.model() returned. A procedural builder name (from an asset pack) is built at once; a file model name shows a gray capsule and swaps in a copy when it loads (Character.ready / whenReady, event 'character:model'). Example: `engine.assets.manifest(yourAssets); engine.characters.createPlayer({ model: 'yourBody' }) // a generator or GLB name from an asset pack`
|
|
125
|
+
- `rig?: CharacterRig | null` A ready procedural body (CharacterRig), used instead of model (a hand-built guard / pet)
|
|
123
126
|
- `clips?: { idle?, walk?, run?, swim?, jump?, fall?, … } | null` Action name mapping { idle, walk, run, swim, jump, fall } (shorthand for animation)
|
|
124
127
|
- `animation?: AnimatorOptions | null` Skeletal animation state machine config (states, blend trees, one-shot actions), see AnimatorOptions
|
|
125
128
|
- `mover?: 'simple' | 'rapier'` Movement method: 'simple' built into the engine (default) / 'rapier' Rapier character controller (needs the rigid module)
|
package/docs/api/collision.md
CHANGED
|
@@ -13,10 +13,14 @@ Lightweight collision (collision() module): no clipping while walking, the camer
|
|
|
13
13
|
## Methods and properties
|
|
14
14
|
- `collision.addCircle(position: PositionLike, opts?: CircleColliderOptions) → Handle` — Add a circle collider (pillar, campfire): position is the center, e.g. addCircle(mesh, { radius: 1 }). Returns a handle { remove() }
|
|
15
15
|
- `collision.addBox(position: PositionLike, opts?: BoxColliderOptions) → Handle` — Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() }
|
|
16
|
+
- `collision.addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?, height?, y? }) → Handle` — Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y. A gap between segments is a gate. Returns a handle { remove() }
|
|
17
|
+
- `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure. bounds skips fn outside it. Returns a handle { remove() }
|
|
18
|
+
- `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — Is a character of this radius touching addBlocked ground at (x, z)
|
|
16
19
|
- `collision.addObject(obj: Object3D, opts?: { pad?: number }) → Handle` — Add a collider from an object's bounding box, pad expands outward (meters). Returns a handle { remove() }
|
|
17
20
|
- `collision.forEachStatic(fn: (type, data) => void)` — Iterate all static colliders added by hand
|
|
18
21
|
- `collision.walkable(position: PositionLike, opts?: { radius?: number }) → boolean` — Whether someone can stand at this position (for pathfinding): not in water, not too steep, not inside an obstacle. radius is the character radius (meters, default engine.movement.radius)
|
|
19
22
|
- `collision.walkableAt(x: number, z: number, radius?: number) → boolean` — walkable with plain numbers, allocating nothing (A* inner loops); radius defaults to engine.movement.radius
|
|
23
|
+
- `collision.lineClear(a: PositionLike, b: PositionLike, opts?: { radius?: number }) → boolean` — Line of sight with height: is the 3D segment a -> b free of boxes, circles and terrain trees? radius fattens the line; addBlocked water is ignored. Give eye heights in a / b
|
|
20
24
|
- Properties:
|
|
21
25
|
- `cameraOcclusion: 'colliders' | 'meshes' | 'both'` What camera occlusion checks (see CollisionOptions.cameraOcclusion)
|
|
22
26
|
- `circles: CircleCollider[]` Circle colliders added by hand
|