threedog 0.1.0 → 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.
- package/core/Animator.js +1 -0
- package/core/Assets.js +16 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +14 -3
- package/core/Engine.js +32 -69
- 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 +45 -0
- package/core/describeText.js +11 -4
- package/core/errorCodes.js +33 -0
- package/core/errorHints.js +6 -1
- 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 +15 -14
- 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 +21 -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 +2 -2
- 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 +83 -109
- package/docs/API.md +7 -8
- package/docs/CODEMAP.md +63 -51
- package/docs/COMMANDS.md +17 -5
- package/docs/CONVENTIONS.md +17 -6
- package/docs/THREE.md +3 -3
- package/docs/api/assets.md +2 -0
- package/docs/api/characters.md +2 -0
- package/docs/api/collision.md +4 -0
- package/docs/api/content.md +1 -0
- package/docs/api/engine.md +20 -11
- 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 +3 -3
- package/docs/api/tools.md +2 -0
- package/docs/api/weather.md +1 -1
- package/docs/recipes/02-npc.md +16 -0
- package/docs/recipes/03-items-pickups.md +1 -1
- package/docs/recipes/06-clock-events.md +13 -0
- package/docs/recipes/07-flow-scenes-pause.md +4 -0
- package/docs/recipes/08-weather-sky.md +1 -1
- package/docs/recipes/09-style-pack.md +5 -5
- package/docs/recipes/12-navmesh.md +22 -0
- package/docs/recipes/13-animation.md +3 -0
- package/docs/recipes/15-perf.md +1 -1
- package/docs/recipes/16-dev-bridge.md +51 -17
- package/docs/recipes/21-camera.md +51 -2
- package/docs/recipes/23-ops.md +45 -9
- package/docs/recipes/27-net.md +1 -1
- package/docs/recipes/29-grid.md +1 -1
- package/docs/recipes/34-environment-lighting.md +9 -8
- package/docs/recipes/38-environment-look-hooks.md +8 -6
- package/docs/recipes/40-scene.md +29 -0
- package/docs/recipes/41-thing-registry.md +29 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +2 -0
- package/docs/recipes/44-water-weather-look-hooks.md +6 -4
- package/docs/recipes/45-cascaded-shadows.md +1 -1
- package/docs/recipes/46-blender-art-route.md +22 -0
- 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 +108 -0
- package/examples/action/GAMEMAP.md +5 -5
- package/examples/action/content/index.js +2 -1
- package/examples/action/content/views.js +6 -0
- package/examples/sheepisland/GAMEMAP.md +2 -3
- package/examples/styletest/GAMEMAP.md +3 -3
- package/examples/styletest/main.js +1 -1
- package/examples/styletest/panel.js +3 -3
- package/examples/world/GAMEMAP.md +3 -3
- package/index.d.ts +27 -0
- package/index.js +3 -1
- package/llms.txt +5 -0
- 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 +29 -17
- 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 +5 -1
- 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 +2 -0
- 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 +5 -3
- 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 +2 -1
- package/modules/vegetation/index.js +6 -3
- package/modules/vegetation/lookWind.js +37 -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 +1 -1
- package/render/PostFX.js +48 -51
- 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 +216 -24
- package/types/gameplay.d.ts +10 -0
- 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 +16 -6
- 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/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,15 +61,22 @@ 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…
|
|
@@ -93,6 +84,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
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…
|
|
95
86
|
- ground.js: Ground API (part of Engine, mixed into Engine.prototype): w…
|
|
87
|
+
- holds.js: Who holds the engine still: pause / resume, freeze / unfree…
|
|
96
88
|
- inputContext.js: Input contexts (like Unity's Action Maps): a stack of named…
|
|
97
89
|
- inputDefaults.js: Input defaults and strings (split out of Input.js): neutral…
|
|
98
90
|
- inputPad.js: Gamepad (standard layout) button names; like keyboard key n…
|
|
@@ -100,16 +92,26 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
100
92
|
- inputTouch.js: The touch part of input: which on-screen controls the game …
|
|
101
93
|
- lifecycle.js: Engine lifecycle (part of Engine, mixed into Engine.prototy…
|
|
102
94
|
- lightWatch.js: Dev-only check (called from loop.js after each render once …
|
|
95
|
+
- look/coreParts.js: look.tone, lights, clouds
|
|
96
|
+
- look/layers.js: The layer arithmetic behind a LookPart (part.js): where a k…
|
|
97
|
+
- look/part.js: engine.look.<part>: set / patch / replace and the layers
|
|
98
|
+
- look/report.js: describe().look, catalog('look.*')
|
|
99
|
+
- look/write.js: How a value gets into a LookPart: normalize, flatten, check…
|
|
103
100
|
- loop.js: Main loop (part of Engine, mixed into Engine.prototype): fi…
|
|
104
101
|
- math.js: Small shared helpers (used by several modules)
|
|
105
102
|
- modules.js: Module installation (part of Engine, mixed into Engine.prot…
|
|
106
103
|
- movement.js: One shared definition of "can walk there": character radius…
|
|
107
104
|
- mulberry32.js: mulberry32, the one copy (engine.random and terrain placeme…
|
|
105
|
+
- opsAtomic.js: Atomic ops (op definition atomic: true): world records, inv…
|
|
108
106
|
- opsCheck.js: Dev checks for engine.ops (split out of Ops.js): op definit…
|
|
107
|
+
- opsFail.js: Structured op failures
|
|
109
108
|
- opsGuard.js: The dev guard of engine.ops (split out of Ops.js): reports …
|
|
110
109
|
- opsHistory.js: The history of engine.ops (split out of Ops.js): a ring of …
|
|
110
|
+
- opsRun.js: ops.run itself (split out of Ops.js)
|
|
111
111
|
- page.js: engine.page: the one place that listens to the browser wind…
|
|
112
|
+
- params.js: Param schemas: one plain-object description per field, shar…
|
|
112
113
|
- pureWorker.js: Worker that runs pure-function batches for engine.threads (…
|
|
114
|
+
- renamed.js: The ONE list of names renamed in 0.2: plain data with no im…
|
|
113
115
|
- saveApply.js: Applying a save (split out of Saves.js): every part is chec…
|
|
114
116
|
- saveFiles.js: Save files (.json download / restore), split out of Saves.j…
|
|
115
117
|
- saveIds.js: Record ids inside save data, for upgrade steps (saves.regis…
|
|
@@ -117,6 +119,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
117
119
|
- scatter.js: Scatter by rule: where instances go in one ground chunk (pl…
|
|
118
120
|
- sceneMethods.js: Scene and render settings on the engine (split out of Engin…
|
|
119
121
|
- screenToGround.js: Screen point -> ground point: what clicking the ground mean…
|
|
122
|
+
- services.js: Engine services: the objects every engine owns besides rend…
|
|
120
123
|
- session.js: engine.session: one playthrough, from "new game" or "load" …
|
|
121
124
|
- shadowTypes.js: three 0.187 shadow filters
|
|
122
125
|
- skip.js: Skipping time (part of Engine, mixed into Engine.prototype)…
|
|
@@ -125,19 +128,21 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
125
128
|
- streamSources.js: Stream sources (internal half of engine.stream): the places…
|
|
126
129
|
- styleParts.js: A style built from parts: createEngine({ style: [lowpoly, {…
|
|
127
130
|
- targeting.js: Target selection: pure functions (no camera, input or engin…
|
|
131
|
+
- thingExplain.js: engine.thing(id).explain(): everything known about one id i…
|
|
128
132
|
- thingOps.js: engine.thing and the two built-in ops on things (thing.set …
|
|
129
133
|
- things.js: Object registry behind engine.thing: every root handed to e…
|
|
130
134
|
- threadPure.js: Pure functions for workers: a function is sent as its sourc…
|
|
131
135
|
- threadServe.js: Worker side of engine.threads lanes: serve(handler) answers…
|
|
132
136
|
- tier.js: Device tier: Engine uses it at construction to pick default…
|
|
137
|
+
- util.js: Small helpers several core files need
|
|
133
138
|
- validate.js: Runtime checks: when an option or name is misspelled, print…
|
|
134
139
|
|
|
135
140
|
**modules/** (one line per folder: what it does; its files)
|
|
136
141
|
- 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
|
|
142
|
+
- camera/ Camera module collection — FirstPersonCamera.js, FixedCamera.js, FollowCamera.js, RtsCamera.js, common.js, index.js, projection.js
|
|
143
|
+
- 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
144
|
- 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
|
|
145
|
+
- 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
146
|
- debug/ Performance panel + time/weather debugging + stress test — DebugPanel.js
|
|
142
147
|
- entities/ Entities — Entities.js, build.js, index.js
|
|
143
148
|
- flow/ Game flow: states (title, playing, paused, game over...) and scene transitions … — index.js
|
|
@@ -154,14 +159,14 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
154
159
|
- photo/ Photo mode: while taking the shot, temporarily raise resolution and shadow prec… — Photo.js
|
|
155
160
|
- rigid/ Real physics (Rapier): objects that topple, roll, get pushed and float on water — RigidBodies.js, Vehicles.js, sync.js
|
|
156
161
|
- 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
|
|
162
|
+
- 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
|
|
163
|
+
- 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
164
|
- timeline/ Timeline: cutscenes, camera moves, scripted movement — Timeline.js, Tween.js, letterbox.js, shots.js
|
|
160
165
|
- 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
|
|
166
|
+
- vegetation/ Vegetation module factory: engine.use(vegetation(...)) — Vegetation.js, groundChunks.js, index.js, lookWind.js, modelGeometry.js
|
|
167
|
+
- water/ Water module: draws the global water plane (sea, big lakes; snaps to a grid fol… — Water.js, look.js, surface.js
|
|
168
|
+
- weather/ Weather: the game's table of weather types (weather({ types })); without one on… — Weather.js, look.js, particles.js, shaders.js, strings.js
|
|
169
|
+
- 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
170
|
|
|
166
171
|
**render/**
|
|
167
172
|
- PostFX.js: Post-processing as an ordered list of named effects in four…
|
|
@@ -171,8 +176,10 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
171
176
|
- fuse.js: Fused post pass: several effects that each carry a small GL…
|
|
172
177
|
- lighting.js: The `lighting` surface patch and the toon ramp: extra, opti…
|
|
173
178
|
- lights.js: Default lights every engine has (engine.lights, the mechani…
|
|
179
|
+
- lookSurface.js: look.materials and look.surface (render/materials.js reads …
|
|
174
180
|
- materials.js: Materials and shaders: Material factory makeMaterial(role, …
|
|
175
181
|
- patches.js: Named shader patches: one way to add shader code to any thr…
|
|
182
|
+
- postLook.js: look.post: the post-processing chain as a look part (recipe…
|
|
176
183
|
- surface.js: Surface keys of a material spec (used by makeMaterial): tex…
|
|
177
184
|
- uniformDecl.js: Declares style-supplied GLSL uniforms (sky clouds, wind): {…
|
|
178
185
|
|
|
@@ -237,7 +244,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
237
244
|
| quest:start | gameplay | — |
|
|
238
245
|
| quest:step | gameplay | — |
|
|
239
246
|
| save:imported | core/saveFiles.js | photo |
|
|
240
|
-
| save:loaded | core/saveApply.js |
|
|
247
|
+
| save:loaded | core/saveApply.js | characters |
|
|
241
248
|
| save:written | core/Saves.js | — |
|
|
242
249
|
| season:change | sky | sky |
|
|
243
250
|
| session:end | core/session.js | core/skip.js, flow, gameplay, hud, music, timeline, triggers |
|
|
@@ -251,8 +258,8 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
251
258
|
| timeline:start | timeline | — |
|
|
252
259
|
| trigger:enter | triggers | camera, content |
|
|
253
260
|
| trigger:exit | triggers | content |
|
|
254
|
-
| ui:close | ui/Parts.js, ui/UI.js | core/
|
|
255
|
-
| ui:open | ui/Parts.js, ui/UI.js | core/
|
|
261
|
+
| ui:close | ui/Parts.js, ui/UI.js | core/services.js, settings |
|
|
262
|
+
| ui:open | ui/Parts.js, ui/UI.js | core/services.js, settings |
|
|
256
263
|
| vegetation:remove | vegetation | — |
|
|
257
264
|
| vegetation:restore | vegetation | — |
|
|
258
265
|
| vehicle:enter | characters | characters |
|
|
@@ -313,7 +320,7 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
313
320
|
- modules/settings/strings.js: settings.* (42)
|
|
314
321
|
- modules/timeline/Timeline.js: timeline.* (2)
|
|
315
322
|
- modules/triggers/index.js: triggers.* (1)
|
|
316
|
-
- modules/weather/
|
|
323
|
+
- modules/weather/strings.js: weather.* (8)
|
|
317
324
|
- ui/defaults.js: title.* (3)
|
|
318
325
|
|
|
319
326
|
## Style pack keys (who reads engine.style.xxx)
|
|
@@ -321,13 +328,18 @@ Per-frame hook order: by stage (control → world → environment → gameplay
|
|
|
321
328
|
| Key | Read in |
|
|
322
329
|
|---|---|
|
|
323
330
|
| character | characters |
|
|
331
|
+
| clouds | core/look/coreParts.js |
|
|
332
|
+
| exposure | core/look/coreParts.js |
|
|
324
333
|
| grid | grid |
|
|
334
|
+
| lighting | render/lookSurface.js |
|
|
335
|
+
| materials | render/lookSurface.js |
|
|
325
336
|
| palette | core/Assets.js, core/assetLoad.js |
|
|
326
337
|
| particles | particles |
|
|
327
338
|
| pickup | gameplay |
|
|
328
339
|
| seasons | sky |
|
|
329
340
|
| sky | sky |
|
|
330
341
|
| terrain | terrain |
|
|
342
|
+
| toneMapping | core/look/coreParts.js |
|
|
331
343
|
| triggers | triggers |
|
|
332
344
|
| ui | gameplay, hud, ui/LoadingScreen.js, ui/UI.js |
|
|
333
345
|
| 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
|
|
@@ -40,15 +40,27 @@ export const specs = [{
|
|
|
40
40
|
| Command | When to use |
|
|
41
41
|
|---|---|
|
|
42
42
|
| `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 |
|
|
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, `-- -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) |
|
|
44
44
|
| `npm run types` | Type check only (does game code misuse the engine API) |
|
|
45
45
|
| `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
46
|
| `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
47
|
| `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
48
|
| `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
|
|
49
|
+
| `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 |
|
|
50
|
+
| `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 |
|
|
51
|
+
| `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 |
|
|
52
|
+
| `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` |
|
|
53
|
+
| `threedog how "<task>"` | Ranks the AI.md task rows and recipe headings for a task in your own words (also in Chinese). `recipes/51-capability-catalog.md` section 5 |
|
|
54
|
+
| `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` |
|
|
55
|
+
| `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 |
|
|
56
|
+
| `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` |
|
|
57
|
+
| `threedog loading [task]` | Loading progress and what failed, also while `start()` is stuck. `recipes/05-props-bake.md` |
|
|
58
|
+
| `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
|
|
59
|
+
| `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
|
|
60
|
+
| `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` |
|
|
61
|
+
| `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
62
|
| `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 |
|
|
63
|
+
| 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
64
|
| `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
65
|
| `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
66
|
| `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 +70,7 @@ export const specs = [{
|
|
|
58
70
|
| `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
71
|
| `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld); compare with `PERF.md` |
|
|
60
72
|
| `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 |
|
|
73
|
+
| `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
74
|
| `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
75
|
| `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
76
|
| `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 |
|
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
|
|
@@ -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 (`new Character(e, { rig })` over `style.character.create`; `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.
|
|
@@ -132,3 +140,6 @@ inside template strings, which then throw on the first call).
|
|
|
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
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
- `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
16
|
- `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
17
|
- `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)
|
|
18
|
+
- `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
|
|
19
|
+
- `assets.reportText(nameOrRoot: string | Object3D) → string` — assets.report as text for the console / describe
|
|
18
20
|
- Properties:
|
|
19
21
|
- `cacheMinMs: number` Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20
|
|
20
22
|
- `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)
|
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
|
package/docs/api/content.md
CHANGED
|
@@ -57,6 +57,7 @@ Conditions are used in quest step done, dialogue option if and line variant if;
|
|
|
57
57
|
- `props.js` props (list: model, position, facing, collision; or { template, x, z } = an instance of a template; or { id, grid, item, cell } = a grid item), streamed in on demand
|
|
58
58
|
- `templates.js` reusable objects (name -> model, collide, interact, container, sound, animate, state defaults, physics body); shared read-only definitions
|
|
59
59
|
- `audio.js` sounds by asset name, ambience and music rules as data, footsteps (sounds, ambience, music: { tracks, rules }, footsteps)
|
|
60
|
+
- `views.js` named fixed camera views (name -> { position: [x, y, z], target?: [x, y, z], fov? }); engine.views.show(name), ?view=name, npm run shot -- -w game --view name
|
|
60
61
|
- `grids.js` placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved
|
|
61
62
|
- `renames.js` renamed or deleted authored ids (old id -> new id, or null = deleted on purpose): the player's saved changes follow the new id
|
|
62
63
|
- `rules.js` condition words added by the game ({ conditions }); actions are ops, not effect words
|
package/docs/api/engine.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
- `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required; style is the style pack
|
|
4
4
|
- Options `EngineOptions`:
|
|
5
|
-
- `canvas
|
|
5
|
+
- `canvas?: HTMLCanvasElement | HTMLElement` Canvas element (required unless renderer is given), e.g. document.getElementById('view')
|
|
6
|
+
- `renderer?: any` A ready three.js renderer (WebGLRenderer or compatible) to use instead of creating one; canvas then defaults to renderer.domElement. The engine configures (pixel ratio, size, tone mapping, shadows) only a renderer it created itself. WebGL is the fully supported path; WebGPU-style renderers may not run shader patches or post effects (recipe 48)
|
|
6
7
|
- `style?: StyleInput` Style pack (looks only: materials, sky, lighting, post, UI look), e.g. import lowpoly from '@threedog/style-lowpoly', or a list of parts deep-merged left to right: [lowpoly, { sky: { sunSize: 600 } }]. Without one: neutral gray placeholders
|
|
7
8
|
- `shadows?: boolean` Real-time shadows, default true
|
|
8
|
-
- `shadowType?: 'basic' | 'pcf' | 'vsm'` Shadow filter: 'basic' (hard edge) / 'pcf' / 'vsm' (softest, costliest), default 'pcf'. Change later with engine.
|
|
9
|
+
- `shadowType?: 'basic' | 'pcf' | 'vsm'` Shadow filter: 'basic' (hard edge) / 'pcf' / 'vsm' (softest, costliest), default 'pcf'. Change later with engine.look.shadow.set({ type })
|
|
9
10
|
- `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default style.antialias, else on for desktop and off for low-tier devices
|
|
10
11
|
- `post?: Record<string, boolean>` Turn style post effects on or off by name at startup, e.g. { bloom: false }; default: each effect's own setting (costly ones off on low-tier devices)
|
|
11
12
|
- `pixelRatio?: number` Render resolution, default min(device pixel ratio, 1.5)
|
|
@@ -31,10 +32,13 @@
|
|
|
31
32
|
- `movement?: Partial<MovementProfile>` Shared "can walk there" parameters (meters / degrees): collision, the Rapier capsule, navigation and level steps all read them by default. Default { radius: 0.4, height: 1.8, maxSlope: 48, stepHeight: 0.45 }
|
|
32
33
|
- `threads?: 'auto' | number | false` (experimental) Worker pool size for engine.threads: 'auto' (default: cores - 1, at most 4), a worker count, or false (all on the main thread, same results, no workers created)
|
|
33
34
|
- `pauseOnBlur?: boolean` Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page)
|
|
35
|
+
- `lights?: boolean` false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. Default true
|
|
34
36
|
- `batching?: false | BatchingOptions` Automatic instancing of repeated static models (engine.batching): false turns it off; default { minCount: 8, cell: engine.stream.cellSize }
|
|
35
37
|
|
|
36
38
|
## engine methods
|
|
37
39
|
- `engine.actorPosition(id?: string) → { x, y, z } | null` — Where an actor is now (default engine.actor): the player's position for 'player' (engine.focus without a player), else its model or world record position; null when unknown. Example: `engine.actor = 'boat_1'; engine.actorPosition()`
|
|
40
|
+
- `engine.catalog(id?: string | { find?: string }) → any` — What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas). No argument: short list; a module id / op name: that entry expanded (null if unknown); { find }: the short list filtered. recipes/51-capability-catalog.md. Example: `engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']`
|
|
41
|
+
- `engine.takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>) → OwnerHandle` — Take the camera over (camera modules leave it alone) until remove(); the latest holder is in charge, releasing hands it back to the previous one
|
|
38
42
|
- `engine.setCamera(kind: CameraKind, opts?: object) → CameraRig` — Switch the camera at runtime (only exists with a camera module installed): the target and horizontal heading carry over; the first-person camera hides the character body automatically (the shadow stays) and locks / releases the mouse; the camera switched out is kept, with its parameters, for switching back. Passing opts rebuilds this kind of camera with the new parameters. A wrong kind throws and lists the available options. Example: `engine.onFrame(() => { if (engine.input.pressedRaw('toggleView')) engine.setCamera(engine.cameraRig.kind === 'follow' ? 'firstPerson' : 'follow'); });`
|
|
39
43
|
- `engine.use(...mods: ModuleInput[])` — Install one or more modules (in order; dependencies must be installed first)
|
|
40
44
|
- `engine.has(name: string) → boolean` — Whether a module is installed
|
|
@@ -56,20 +60,21 @@
|
|
|
56
60
|
- `engine.setPixelRatio(p: number)` — Render resolution
|
|
57
61
|
- `engine.setShadows(on: boolean)` — Shadow toggle
|
|
58
62
|
- `engine.setFogFar(d: number)` — Fog distance (meters), also adjusts the camera far plane
|
|
59
|
-
- `engine.setToneMapping(kind: 'aces' | 'agx' | 'neutral' | 'none')` — Tone mapping at run time ('aces' / 'agx' / 'neutral' / 'none'); materials recompile on their next draw, so not every frame
|
|
60
|
-
- `engine.setExposure(v: number | [number, number][] | ((sky: any) => number))` — Exposure at run time: a number, [[time 0-1, exposure], ...] over the day or (sky) => number (both evaluated by the sky module each frame); replaces style.exposure. Example: `engine.setExposure(1.4); engine.setExposure(sky => sky.isDay ? 1 : 1.5);`
|
|
61
63
|
- `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit)
|
|
62
64
|
- `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)
|
|
63
65
|
- `engine.spawn(name: string, at: any, fields?: { id?, rot?, scale?, y?, items?, … }) → import('./generated/modules/world…` — New runtime instance of a content template (inside an op or fixed step), saved whole; returns the world record (kind = template name). Needs content(). e.g. engine.spawn('chest', { x: 10, z: 4 }, { opened: true })
|
|
64
66
|
- `engine.applyState(params: StateParams) → Promise<void>` — Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done
|
|
65
67
|
- `engine.defineState(name: string, params: StateParams)` — Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name
|
|
66
68
|
- `engine.start() → Promise<this>` — Start: initialize modules, preload assets, wait for the world to be ready
|
|
67
|
-
- `engine.pause()` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu pause
|
|
68
|
-
- `engine.resume()` — Resume the real-time loop
|
|
69
|
-
- `engine.
|
|
70
|
-
- `engine.
|
|
69
|
+
- `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 (for tests and screenshots). Use freeze() for a game menu pause
|
|
70
|
+
- `engine.resume(owner?: string | { owner?: string })` — Resume the real-time loop (only this owner's pause)
|
|
71
|
+
- `engine.nextFixed(fn: () => T) → Promise<T>` — Run fn at the start of the next fixed step (via commits); a Promise of fn's value
|
|
72
|
+
- `engine.freeze(owner?: string | { owner?, kind? }, opts?: { kind?: 'title' }) → ChainedHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, the game clock and engine.elapsed all stop), frame hooks and rendering continue and the UI works. So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's name, default 'game'
|
|
73
|
+
- `engine.unfreeze(owner?: string | { owner?: string })` — Release the freeze of owner (gameplay resumes only when all freezers are released)
|
|
71
74
|
- `engine.step(seconds: number, opts?: { render?, frameEvery?, describe? }) → GameState | null` — Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render), negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; when timeScale is not 1, game seconds clock.now and sky time of day run faster or slower than it; frame hooks run once every frameEvery fixed steps, default 2; describe: false returns null instead of building describe()). jobs ignore real time and finish every frame; results of stream's synchronous build are attached to the scene before returning. When render is true (default) one frame is rendered at the end. Returns the describe() result after advancing
|
|
72
75
|
- `engine.skip(opts: SkipOptions) → Promise<{ seconds: number; clock:…` — Skip game time forward (sleep until morning, wait an hour) without stepping every fixed step. clock.after / every, sky.at / daily / between, day:start and season:change fire in time order as if stepped (each crossing once); world records with far catch up the span in one far(rec, dt). onFixed, module fixed hooks, physics and near simulation do not run; engine.elapsed does not move. Input is locked and gameplay frozen during the skip; emits time:skip. fade 0 (default): the time has moved when skip returns. fade > 0: fade out, jump, save, fade in; the Promise resolves after the fade in (it needs frames). session.newGame / load / quit cancel a running skip: it resolves null. Example: `await engine.skip({ to: '06:00' })`
|
|
76
|
+
- `engine.checkSkip(seconds: number, opts?: { ignore?: string[] }) → Promise<{ ok: boolean; diffs: { p…` — Consistency check: engine.skip({ seconds }) vs stepping the same span in fixed steps; compares the saved state. Leaves the world at the stepped state (use a scratch playthrough or a test). Example: `const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);`
|
|
77
|
+
- `engine.checkSave(opts?: { ignore?: string[] }) → Promise<{ ok: boolean; diffs: { p…` — Consistency check: save -> load gives the same saved state back (nothing is written to the browser). Example: `const r = await engine.checkSave(); if (!r.ok) console.log(r.diffs);`
|
|
73
78
|
- `engine.describeText(opts?: { radius?, full?, path? }) → string` — The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, one line per module with its key counts), ending with how to expand. { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data). Example: `engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })`
|
|
74
79
|
- `engine.explain(q: { op, args?, actor? } | Record<string, any>) → { ok, reason?, text, detail?, recent?, events?, … }` — Why something is the way it is. { op, args?, actor? }: text says whether it can run now, and if not the reason and the op's note on fixing it (reason first); detail has the last attempt and the events around it; recent / events are the raw last 5 attempts and event names within a step of the last one. Other keys are answered by modules (definition field explain: { key(e, value, query) { return { ok, text } } }); the quests module answers { quest: id }. Example: `engine.explain({ op: 'shop.buy', args: { shop: 'bakery', item: 'bread' } }).text // 'shop.buy {...} cannot run now: noMoney (Not enough gold)'`
|
|
75
80
|
- `engine.profile(on: boolean)` / `profile() → Record<string, number> | null` — Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns { moduleName: average milliseconds per rendered frame } and resets, or null when not on
|
|
@@ -86,7 +91,7 @@
|
|
|
86
91
|
- `camera: import('three').PerspectiveCamera` three.js perspective camera
|
|
87
92
|
- `focus: Vector3` Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the player by default), which does not follow the camera
|
|
88
93
|
- `shadows: boolean` Whether shadows are on
|
|
89
|
-
- `shadowType: 'basic' | 'pcf' | 'vsm'` Shadow filter in use; change it with
|
|
94
|
+
- `shadowType: 'basic' | 'pcf' | 'vsm'` Shadow filter in use; change it with look.shadow.set({ type })
|
|
90
95
|
- `ground: Ground` Current ground
|
|
91
96
|
- `movement: Readonly<MovementProfile>` Shared parameters for whether a character can walk somewhere (set by createEngine({ movement }), read-only); same-named options of individual modules are only overrides
|
|
92
97
|
- `player: Character | null` The player (exists only after characters.createPlayer()). Its position belongs to the character's mover: other systems request movement (placeAt / move / vehicle enter), don't modify position directly
|
|
@@ -112,11 +117,13 @@
|
|
|
112
117
|
- `assets: Assets` Assets
|
|
113
118
|
- `loading: Loading` Observable loading: every asset load, module init / isReady and track() step as a task (phase, error, source manifest)
|
|
114
119
|
- `post: PostFX` Post-processing: named effects in slots (add / get / enable / list)
|
|
120
|
+
- `look: Look` Every look in one place: engine.look.<part>.set / patch / replace (recipes/52-look.md)
|
|
115
121
|
- `ui: UIParts` UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md)
|
|
116
122
|
- `adaptive: AdaptiveState` Automatic resolution state
|
|
117
123
|
- `cpuMs: number` Main-thread CPU milliseconds of the last real-time frame: input, fixed steps, frame hooks, render submission and afterRender hooks (not GPU time, not the wait for the next frame). Only the real-time loop updates it; step() does not.
|
|
118
124
|
- `cpuPhases: { fixed, frame, render, afterRender }` cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks
|
|
119
|
-
- `cameraOverride: CameraOverride | null`
|
|
125
|
+
- `cameraOverride: CameraOverride | null` The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Assigning { owner } / null is the old alias of takeCamera
|
|
126
|
+
- `runState: RunState` Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is
|
|
120
127
|
- `decoders: string` Draco/KTX2 decoder directory
|
|
121
128
|
- `clock: Clock` Game clock: game seconds now, after / every (clock-time / season timers are on engine.sky)
|
|
122
129
|
- `vars: Vars` Story flags and counters (autosaved)
|
|
@@ -126,6 +133,7 @@
|
|
|
126
133
|
- `commits: Commits` Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits
|
|
127
134
|
- `threads: Threads` (experimental) Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays. Results that affect gameplay go through commits
|
|
128
135
|
- `ops: Ops` One entry point for actions players and NPCs decide to do: define / run / can / list / recent, see Ops and recipes/23-ops.md
|
|
136
|
+
- `views: Views` Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md)
|
|
129
137
|
- `tick: number` Fixed-step count (the gameplay timeline: does not advance while frozen; commits due times, event history and the operation log use it)
|
|
130
138
|
- `random: Random` Seeded random numbers (use for gameplay randomness: reproducible and saved with the game)
|
|
131
139
|
- `stream: Stream` Spatial stream-in and the stream sources (where the world is loaded: terrain, colliders, models, stream entries; built-in player and camera sources, add one for a teleport destination)
|
|
@@ -134,7 +142,8 @@
|
|
|
134
142
|
- `elapsed: number` Run seconds: unaffected by the sky time scale, does not advance while frozen or paused; for presentation animation (swaying, floating). The other two "times": game seconds engine.clock.now (= fixed-step seconds x clock.timeScale, saved); sky time of day engine.sky.timeOfDay (0–1, one day = dayLength game seconds)
|
|
135
143
|
- `uniforms: EngineUniforms` This engine's shader uniforms, read by the built-in effects (wind, clouds, season, water, sky, rain). Share these objects in your own ShaderMaterial or patch instead of making your own uTime. Weather and sky write them; uTime follows engine.elapsed. Example: `new THREE.ShaderMaterial({ uniforms: { uTime: engine.uniforms.uTime }, vertexShader, fragmentShader });`
|
|
136
144
|
- `waterLevel: number` Global water level (meters); -Infinity when there is no water
|
|
137
|
-
- `
|
|
145
|
+
- `debug: DebugOverrides & { panel: DebugPanel | null }` Diagnostic overrides and view modes with an owner (override / clear / view: core, always there); panel is the F3 panel, null without the debug() module
|
|
146
|
+
- `exposureDriver: ((sky: any) => number) | null` Exposure per frame from style.exposure / look.tone keyframes or function, null for a plain number; the sky module calls it with engine.sky
|
|
138
147
|
- `stateApplied: boolean` Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it: page.waitForFunction(() => window.engine?.stateApplied)
|
|
139
148
|
- `headless: boolean` Whether in headless mode (createEngine({ headless: true }))
|
|
140
149
|
- `paused: boolean` Whether paused (headless mode is paused by default, only step() advances)
|