threedog 0.8.0 → 1.0.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/CHANGELOG.md +219 -4
- package/README.md +6 -6
- package/core/assets/Animator.js +2 -0
- package/core/assets/Assets.js +44 -13
- package/core/assets/assetEntry.js +87 -22
- package/core/assets/assetHot.js +2 -1
- package/core/assets/assetReport.js +1 -2
- package/core/audio/Audio.js +24 -5
- package/core/base/I18n.js +6 -3
- package/core/base/Random.js +3 -1
- package/core/base/Vars.js +14 -4
- package/core/base/errorCodes.js +54 -16
- package/core/base/errorHints.js +12 -1
- package/core/base/errors.js +6 -4
- package/core/base/events.generated.js +10 -0
- package/core/base/follows.js +26 -0
- package/core/base/math.js +15 -8
- package/core/base/params.js +2 -2
- package/core/{saves → base}/saveValues.js +24 -6
- package/core/base/sections.js +97 -0
- package/core/base/spelling.js +32 -0
- package/core/base/validate.js +8 -29
- package/core/engine/Engine.js +61 -18
- package/core/engine/Loading.js +30 -3
- package/core/engine/copies.js +1 -1
- package/core/engine/headlessLoad.js +30 -13
- package/core/engine/lifecycle.js +30 -25
- package/core/engine/loop.js +22 -4
- package/core/engine/moduleSlots.js +91 -15
- package/core/engine/moduleTypes.js +13 -0
- package/core/engine/modules.js +248 -62
- package/core/engine/page.js +25 -8
- package/core/engine/plugins.js +15 -3
- package/core/engine/services.js +3 -0
- package/core/engine/startup.js +46 -36
- package/core/input/Input.js +39 -19
- package/core/input/inputKeyboard.js +39 -0
- package/core/input/inputPad.js +23 -2
- package/core/input/inputPointer.js +3 -1
- package/core/input/inputSeat.js +66 -0
- package/core/input/inputTouch.js +23 -6
- package/core/inspect/DebugOverrides.js +13 -2
- package/core/inspect/Describe.js +10 -6
- package/core/inspect/Inspect.js +31 -4
- package/core/inspect/UrlState.js +14 -10
- package/core/inspect/catalog.js +12 -5
- package/core/inspect/describeRender.js +3 -2
- package/core/inspect/describeText.js +6 -2
- package/core/inspect/metadata.generated.js +4140 -0
- package/core/inspect/pictureWriters.js +117 -33
- package/core/inspect/toolDoor.js +21 -0
- package/core/inspect/valueHistory.js +35 -0
- package/core/ops/Ops.js +32 -7
- package/core/ops/control.js +48 -23
- package/core/ops/holds.js +4 -3
- package/core/ops/opsAtomic.js +18 -6
- package/core/ops/opsCheck.js +7 -5
- package/core/ops/opsFail.js +5 -7
- package/core/ops/opsRun.js +2 -2
- package/core/ops/owned.js +20 -3
- package/core/ops/sharedPoint.js +7 -10
- package/core/ops/stacks.js +22 -1
- package/core/saves/SaveStore.js +52 -26
- package/core/saves/Saves.js +122 -27
- package/core/saves/saveApply.js +159 -61
- package/core/saves/saveFiles.js +30 -25
- package/core/saves/saveVersions.js +20 -6
- package/core/saves/session.js +76 -33
- package/core/saves/stateReplace.js +184 -0
- package/core/scene/Rays.js +21 -5
- package/core/scene/Views.js +6 -6
- package/core/scene/adaptive.js +13 -10
- package/core/scene/canvasBox.js +2 -0
- package/core/scene/compositeGround.js +72 -0
- package/core/scene/floor.js +17 -0
- package/core/scene/grid.js +2 -0
- package/core/scene/ground.contract.js +14 -0
- package/core/scene/ground.js +52 -17
- package/core/scene/pixel.js +154 -0
- package/core/scene/pixelRatio.js +167 -0
- package/core/scene/sceneDelta.js +3 -3
- package/core/scene/sceneMethods.js +11 -6
- package/core/scene/stepPoses.js +6 -1
- package/core/scene/thingExplain.js +1 -1
- package/core/scene/thingOps.js +22 -14
- package/core/scene/things.js +1 -1
- package/core/scene/tier.js +10 -0
- package/core/scene/view.js +126 -9
- package/core/stream/Batching.js +0 -1
- package/core/stream/Stream.js +24 -12
- package/core/stream/batchGroups.js +1 -0
- package/core/stream/scatter.js +5 -2
- package/core/stream/streamSources.js +2 -1
- package/core/threads/Commits.js +12 -7
- package/core/threads/Jobs.js +15 -5
- package/core/threads/Threads.js +5 -2
- package/core/time/Clock.js +3 -1
- package/core/time/skip.js +10 -4
- package/core/time/time.js +16 -10
- package/docs/AI.md +89 -72
- package/docs/API.md +18 -14
- package/docs/CODEMAP.md +68 -40
- package/docs/COMMANDS.md +22 -23
- package/docs/CONVENTIONS.md +120 -17
- package/docs/MIGRATING-0.8.md +2 -0
- package/docs/MIGRATING-1.0.md +101 -0
- package/docs/THREE.md +65 -12
- package/docs/api/cameraRig.md +3 -0
- package/docs/api/characters.md +13 -7
- package/docs/api/collider3d.md +9 -0
- package/docs/api/content.md +16 -15
- package/docs/api/dialogue.md +2 -1
- package/docs/api/engine.md +18 -16
- package/docs/api/events.md +14 -4
- package/docs/api/ground.md +2 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +2 -1
- package/docs/api/interactions.md +1 -1
- package/docs/api/inventory.md +1 -1
- package/docs/api/level.md +3 -2
- package/docs/api/nav.md +4 -2
- package/docs/api/particles.md +8 -5
- package/docs/api/pickups.md +1 -1
- package/docs/api/post.md +3 -4
- package/docs/api/quests.md +4 -2
- package/docs/api/rays.md +2 -0
- package/docs/api/rigid.md +3 -2
- package/docs/api/saves.md +8 -7
- package/docs/api/stream.md +4 -5
- package/docs/api/terrain.md +3 -4
- package/docs/api/terrainDraw.md +1 -1
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +3 -1
- package/docs/api/triggers.md +2 -0
- package/docs/api/vegetationDraw.md +1 -1
- package/docs/api/water.md +6 -2
- package/docs/api/weather.md +19 -4
- package/docs/api/weatherDraw.md +1 -1
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +3 -3
- package/docs/recipes/02-npc.md +3 -4
- package/docs/recipes/03-items-pickups.md +11 -11
- package/docs/recipes/04-quests.md +2 -0
- package/docs/recipes/05-props-bake.md +9 -9
- package/docs/recipes/06-clock-events.md +6 -6
- package/docs/recipes/07-flow-scenes-pause.md +18 -15
- package/docs/recipes/08-weather-sky.md +5 -5
- package/docs/recipes/09-materials-lights-models.md +3 -3
- package/docs/recipes/10-blender-level.md +16 -4
- package/docs/recipes/11-vehicles.md +18 -6
- package/docs/recipes/12-navmesh.md +52 -8
- package/docs/recipes/13-animation.md +34 -8
- package/docs/recipes/14-custom-module.md +20 -8
- package/docs/recipes/15-perf.md +4 -4
- package/docs/recipes/16-dev-bridge.md +9 -8
- package/docs/recipes/18-world.md +13 -5
- package/docs/recipes/19-shooting-picking.md +3 -2
- package/docs/recipes/20-content-actions-save.md +26 -6
- package/docs/recipes/21-camera.md +17 -23
- package/docs/recipes/22-shop-gold.md +21 -12
- package/docs/recipes/23-ops.md +19 -15
- package/docs/recipes/26-ui-parts.md +3 -2
- package/docs/recipes/27-net.md +3 -3
- package/docs/recipes/28-terrain.md +3 -3
- package/docs/recipes/29-grid.md +1 -1
- package/docs/recipes/30-templates.md +10 -13
- package/docs/recipes/31-audio.md +2 -2
- package/docs/recipes/32-action-game.md +6 -5
- package/docs/recipes/33-stream-sources.md +4 -1
- package/docs/recipes/34-environment-lighting.md +7 -8
- package/docs/recipes/35-picture-from-reference.md +13 -9
- package/docs/recipes/36-ground-plants.md +3 -2
- package/docs/recipes/40-scene.md +11 -10
- package/docs/recipes/43-shader-patches-surfaces.md +7 -7
- package/docs/recipes/44-water-weather-hooks.md +9 -8
- package/docs/recipes/45-cascaded-shadows.md +3 -4
- package/docs/recipes/46-blender-art-route.md +3 -3
- package/docs/recipes/49-game-module-contract.md +2 -1
- package/docs/recipes/50-own-renderer.md +1 -0
- package/docs/recipes/51-capability-catalog.md +14 -8
- package/docs/recipes/52-around-the-picture.md +4 -4
- package/docs/recipes/55-mods-time-wrap.md +5 -4
- package/docs/recipes/56-webgpu-tsl.md +12 -1
- package/docs/recipes/57-control.md +30 -10
- package/docs/recipes/58-input.md +13 -0
- package/docs/recipes/60-judge-the-picture.md +1 -1
- package/docs/recipes/62-picture-code.md +106 -48
- package/docs/recipes/63-third-person-start.md +2 -1
- package/docs/recipes/64-particles.md +53 -4
- package/docs/recipes/65-swarm.md +2 -2
- package/docs/recipes/66-common-tasks.md +313 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +3 -3
- package/examples/perf-island/.threedog/content-index.json +1 -1
- package/examples/perf-island/GAMEMAP.md +3 -3
- package/examples/perf-island/main.js +2 -2
- package/examples/plain-picture/GAMEMAP.md +3 -1
- package/examples/rc2d/GAMEMAP.md +1 -1
- package/examples/rc2d/rc2d.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +3 -3
- package/examples/webgpu-tsl/GAMEMAP.md +1 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +5 -4
- package/examples/world/main.js +3 -3
- package/index.d.ts +8 -5
- package/index.js +22 -1
- package/llms.txt +2 -1
- package/modules/ambience/Ambience.js +5 -3
- package/modules/calendar/index.js +7 -5
- package/modules/camera/FirstPersonCamera.js +3 -3
- package/modules/camera/FixedCamera.js +34 -20
- package/modules/camera/FollowCamera.js +20 -11
- package/modules/camera/RtsCamera.js +1 -0
- package/modules/camera/common.js +33 -22
- package/modules/camera/pixelSnap.js +62 -0
- package/modules/characters/Character.js +136 -43
- package/modules/characters/NPC.js +60 -28
- package/modules/characters/assetModel.js +2 -2
- package/modules/characters/astar.js +47 -28
- package/modules/characters/character.contract.js +21 -0
- package/modules/characters/contract.js +17 -3
- package/modules/characters/index.js +94 -34
- package/modules/characters/moveHelpers.js +80 -15
- package/modules/characters/mover.contract.js +14 -0
- package/modules/characters/movers/common.js +6 -4
- package/modules/characters/movers/rapier.js +12 -5
- package/modules/characters/movers/simple.js +25 -12
- package/modules/characters/movers/support.js +18 -7
- package/modules/characters/npcAvoid.js +15 -12
- package/modules/characters/npcSim.js +75 -25
- package/modules/characters/npcView.js +13 -6
- package/modules/characters/pathAsync.js +74 -24
- package/modules/characters/pathJob.js +38 -21
- package/modules/characters/player.js +59 -47
- package/modules/characters/seat.js +56 -0
- package/modules/characters/vehicle.contract.js +8 -5
- package/modules/characters/walkTo.js +31 -18
- package/modules/collision/Collision.js +44 -26
- package/modules/collision/contract.js +2 -2
- package/modules/collision/grid.js +6 -1
- package/modules/content/explain.js +1 -1
- package/modules/content/fields.js +3 -3
- package/modules/content/ids.js +3 -1
- package/modules/content/index.js +83 -27
- package/modules/content/loader.js +110 -130
- package/modules/content/markers.js +1 -1
- package/modules/content/models.js +48 -14
- package/modules/content/packs.js +2 -1
- package/modules/content/places.js +5 -4
- package/modules/content/props.js +8 -6
- package/modules/content/rules.js +29 -47
- package/modules/content/templates.js +66 -35
- package/modules/content/words.js +19 -6
- package/modules/debug/DebugPanel.js +4 -2
- package/modules/flow/contract.js +1 -0
- package/modules/flow/index.js +24 -14
- package/modules/gameplay/Container.js +5 -2
- package/modules/gameplay/Containers.js +9 -1
- package/modules/gameplay/Dialogue.js +82 -25
- package/modules/gameplay/Interactions.js +61 -32
- package/modules/gameplay/Inventory.js +56 -13
- package/modules/gameplay/Quests.js +133 -24
- package/modules/gameplay/boxOps.js +7 -0
- package/modules/gameplay/dialogueBubbles.js +14 -9
- package/modules/gameplay/inventoryOps.js +11 -7
- package/modules/gameplay/pickups.js +43 -16
- package/modules/gameplay/questLog.js +4 -2
- package/modules/gameplay/questSave.js +6 -1
- package/modules/gameplay/quests.contract.js +1 -1
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +8 -4
- package/modules/grid/index.js +21 -15
- package/modules/grid/ops.js +43 -46
- package/modules/grid/tiles.js +1 -1
- package/modules/hlod/index.js +6 -3
- package/modules/hud/index.js +6 -4
- package/modules/hud/parts.js +4 -4
- package/modules/level/contract.js +2 -2
- package/modules/level/heightfield.js +17 -21
- package/modules/level/index.js +83 -26
- package/modules/level/load.js +165 -48
- package/modules/level/nodes.js +34 -16
- package/modules/lights/index.js +6 -3
- package/modules/lights/sources.js +3 -1
- package/modules/music/Music.js +4 -2
- package/modules/nav/contract.js +7 -5
- package/modules/nav/index.js +174 -44
- package/modules/nav/navPath.js +45 -10
- package/modules/net/index.js +1 -1
- package/modules/particles/Particles.js +85 -22
- package/modules/particles/effect.js +80 -28
- package/modules/particles/shaders.js +17 -0
- package/modules/photo/Photo.js +12 -10
- package/modules/rigid/RigidBodies.js +200 -57
- package/modules/rigid/Vehicles.js +15 -5
- package/modules/rigid/collider3d.contract.js +26 -0
- package/modules/rigid/ragdoll.js +55 -44
- package/modules/rigid/ragdollBones.js +83 -33
- package/modules/rigid/refresh.js +10 -0
- package/modules/rigid/sync.js +46 -15
- package/modules/settings/Settings.js +84 -37
- package/modules/settings/apply.js +15 -8
- package/modules/settings/sections.js +7 -4
- package/modules/settings/strings.js +2 -2
- package/modules/sky/skyModule.js +3 -1
- package/modules/swarm/Swarm.js +16 -6
- package/modules/terrain/ChunkManager.js +10 -16
- package/modules/terrain/index.js +17 -11
- package/modules/terrain/terrainEdit.js +13 -2
- package/modules/terrain/terrainGen.js +5 -3
- package/modules/terrain/terrainShape.js +1 -1
- package/modules/timeline/Timeline.js +58 -26
- package/modules/timeline/Tween.js +19 -13
- package/modules/timeline/shots.js +19 -10
- package/modules/triggers/index.js +87 -20
- package/modules/vegetation/Vegetation.js +4 -3
- package/modules/vegetation/draw.js +16 -0
- package/modules/vegetation/groundChunks.js +10 -7
- package/modules/vegetation/index.js +30 -7
- package/modules/water/Water.js +6 -2
- package/modules/weather/Weather.js +16 -15
- package/modules/weather/weatherDraw.js +7 -6
- package/modules/world/World.js +20 -7
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +13 -6
- package/modules/world/persist.js +23 -8
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +13 -7
- package/modules/world/sim.js +74 -23
- package/modules/world/simFar.js +2 -2
- package/modules/world/state.js +31 -6
- package/modules/world/thingSource.js +16 -3
- package/modules/world/views.js +19 -8
- package/package.json +7 -1
- package/render/PostFX.js +47 -29
- package/render/backend.js +5 -1
- package/render/fx/particles.tsl.js +8 -6
- package/render/fx/postWebGPU.tsl.js +3 -3
- package/render/layers.js +1 -1
- package/render/lightmap.js +23 -3
- package/render/occlusion.js +43 -12
- package/render/patches.js +2 -2
- package/render/postWebGL.js +4 -3
- package/render/probes.js +25 -0
- package/render/shadows.js +2 -2
- package/types/core.d.ts +142 -55
- package/types/gameplay.d.ts +92 -40
- package/types/generated/core/base/I18n.d.ts +2 -2
- package/types/generated/core/input/Input.d.ts +16 -2
- package/types/generated/core/input/inputSeat.d.ts +26 -0
- package/types/generated/core/inspect/DebugOverrides.d.ts +15 -1
- package/types/generated/core/ops/Ops.d.ts +2 -1
- package/types/generated/core/ops/control.d.ts +12 -2
- package/types/generated/core/saves/Saves.d.ts +26 -6
- package/types/generated/core/saves/session.d.ts +1 -1
- package/types/generated/core/scene/Views.d.ts +1 -1
- package/types/generated/core/stream/Stream.d.ts +6 -4
- package/types/generated/modules/grid/Grid.d.ts +1 -0
- package/types/generated/modules/particles/Particles.d.ts +4 -3
- package/types/generated/modules/timeline/Timeline.d.ts +5 -4
- package/types/generated/modules/weather/Weather.d.ts +1 -7
- package/types/generated/modules/world/World.d.ts +6 -4
- package/types/generated/render/PostFX.d.ts +6 -14
- package/types/nav.d.ts +36 -4
- package/types/physics.d.ts +55 -7
- package/types/pixel.d.ts +75 -0
- package/types/world.d.ts +14 -8
- package/ui/Parts.js +9 -2
- package/ui/theme.js +2 -2
- package/core/scene/engineCamera.js +0 -32
- package/modules/camera/projection.js +0 -21
package/core/input/inputTouch.js
CHANGED
|
@@ -9,14 +9,31 @@
|
|
|
9
9
|
* @param {Input} inp
|
|
10
10
|
* @param {string} action
|
|
11
11
|
* @param {string} labelKey string-table key of the button text
|
|
12
|
+
* @returns {{ remove(): void }}
|
|
12
13
|
* @internal
|
|
13
14
|
*/
|
|
14
15
|
export function touchButton(inp, action, labelKey) {
|
|
15
|
-
if (!inp.touch
|
|
16
|
-
|
|
17
|
-
inp.
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
if (!inp.touch) return { remove() {} };
|
|
17
|
+
// counted: two parties may ask for one action, and the button stays until the last of them leaves
|
|
18
|
+
let b = inp._touch.find(x => x.action === action);
|
|
19
|
+
if (!b) {
|
|
20
|
+
inp._touchKeys.set(action, 'Touch:' + action); // kept beside the bound keys, so a rebind never drops the on-screen button
|
|
21
|
+
inp._readable = null;
|
|
22
|
+
inp._touch.push(b = { action, labelKey, users: 0 });
|
|
23
|
+
touchRefresh(inp);
|
|
24
|
+
}
|
|
25
|
+
b.users++;
|
|
26
|
+
let held = true;
|
|
27
|
+
return { remove() {
|
|
28
|
+
if (!held) return;
|
|
29
|
+
held = false;
|
|
30
|
+
if (--b.users) return;
|
|
31
|
+
inp._keyUp('Touch:' + action); // a thumb on it when it goes must not leave the action down
|
|
32
|
+
inp._touchKeys.delete(action);
|
|
33
|
+
inp._readable = null;
|
|
34
|
+
inp._touch.splice(inp._touch.indexOf(b), 1);
|
|
35
|
+
touchRefresh(inp);
|
|
36
|
+
} };
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
/**
|
|
@@ -34,7 +51,7 @@ export function touchStart(inp) {
|
|
|
34
51
|
function touchRefresh(inp) {
|
|
35
52
|
if (!inp._touchOn) return;
|
|
36
53
|
const stick = inp.joystick === true || (inp.joystick === 'auto' && inp.touch);
|
|
37
|
-
if (!stick && !inp._touch.length) return;
|
|
54
|
+
if (!stick && !inp._touch.length && !inp._touchPart) return; // a drawn part still hears that its last button left
|
|
38
55
|
const e = inp.engine, first = !inp._touchPart;
|
|
39
56
|
inp._touchPart ??= e.ui.get('touch');
|
|
40
57
|
/** @type {TouchView} */
|
|
@@ -36,7 +36,7 @@ export class DebugOverrides {
|
|
|
36
36
|
/** The F3 debug panel (the debug() module), or null when it is not installed @type {any} */
|
|
37
37
|
this.panel = null;
|
|
38
38
|
// a load can replace the objects a thing id names: an override still holding the old object would show on nothing and lie in describe
|
|
39
|
-
e.events?.on?.('
|
|
39
|
+
e.events?.on?.('state:replaced', () => this._prune());
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Diagnostic view: 'albedo' | 'lighting' | 'shadow' | 'normals' to look at one part of the render, 'overdraw' (bright = many layers on a pixel),
|
|
@@ -73,6 +73,17 @@ export class DebugOverrides {
|
|
|
73
73
|
* @param {any} packs @returns {Promise<{ why: string, names: string[], copies: Record<string, number>, ms: number, partsChanged?: string[] }>}
|
|
74
74
|
*/
|
|
75
75
|
reloadAssets(packs) { return reloadAssets(this.e, packs); }
|
|
76
|
+
/**
|
|
77
|
+
* Watch one value the engine does not watch by default, on the dev server: who writes it (file:line, frame) goes into engine.explain({ value: name }), and two writers fighting
|
|
78
|
+
* over it give a one-line hint. It observes; every write goes through. In a release build it does nothing: watching is false.
|
|
79
|
+
* Only watched values are seen, and a write that leaves the value unchanged is not: a value that shows no conflict may still have one.
|
|
80
|
+
* @example engine.debug.watch('boss.hp', boss, 'hp'); engine.debug.watch('player.pos', player, 'position');
|
|
81
|
+
* @param {string} name what explain and describe('picture').picture.writers call it; a name already in use is refused (watching false)
|
|
82
|
+
* @param {any} object the object, or a Color, Vector or rotation itself
|
|
83
|
+
* @param {string} [key] a plain property; a Color, Vector or rotation held there is watched inside. A property behind a class accessor cannot be hooked (watching false)
|
|
84
|
+
* @returns {{ watching: boolean, remove(): void }} remove() forgets the name; the accessor stays until reload and passes values through
|
|
85
|
+
*/
|
|
86
|
+
watch(name, object, key) { return this.e._picture?.watchNamed(name, object, key) ?? { watching: false, remove() {} }; }
|
|
76
87
|
/** The active view ({ mode: 'off', owner: null } when none) @returns {{ mode: string, owner: string | null, what?: string }} */
|
|
77
88
|
viewState() { return this._view.state(); }
|
|
78
89
|
|
|
@@ -136,7 +147,7 @@ export class DebugOverrides {
|
|
|
136
147
|
};
|
|
137
148
|
return this._add({ owner, id: `${label}.${key}`, byId: false, obj, patch: { key, value: plain(value), apply }, undo: null });
|
|
138
149
|
}
|
|
139
|
-
/** Active overrides on one object, for engine.thing
|
|
150
|
+
/** Active overrides on one object, for engine.explain({ thing: id }) */
|
|
140
151
|
overridesOn(obj) { this._prune(); return this._l.filter(o => o.obj === obj && !o.view).map(o => ({ owner: o.owner, ...patchInfo(o.patch) })); }
|
|
141
152
|
/** Undo everything, drop / restore what the views put back, re-apply */
|
|
142
153
|
dispose() { this._rebuild(() => { this._l = []; }); this._view.active = null; }
|
package/core/inspect/Describe.js
CHANGED
|
@@ -90,16 +90,17 @@ export function describeApi(e) {
|
|
|
90
90
|
return { describe: api, describeText: text, inspect: inspectApi, explain: q => explain(e, q) };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
/** Only the modules that are not running normally (initializing / failed) appear in describe, so the common case adds nothing (null); engine.
|
|
93
|
+
/** Only the modules that are not running normally (initializing / failed / blocked) appear in describe, so the common case adds nothing (null); engine.explain({ module }) has all of them */
|
|
94
94
|
function pendingModules(e) {
|
|
95
95
|
const out = {};
|
|
96
96
|
for (const [name, st] of e._modState) if (st === 'initializing' || st === 'failed') out[name] = st;
|
|
97
|
+
for (const [name, by] of e._modBlocked) if (e._modState.get(name) !== 'failed') out[name] = `blocked by ${by.map(b => `${b.module} (${b.state})`).join(', ')}`;
|
|
97
98
|
return Object.keys(out).length ? out : null;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
// Engine tables no module hook writes into (hooks add to time / player / camera / ui / perf / cutscene / nearby): a describe({ only }) that asks
|
|
101
102
|
// for nothing else skips the hooks, describe.add and the action list
|
|
102
|
-
const TABLES = new Set(['ready', 'error', 'disabledModules', 'loading', 'audio', 'holds', 'input', 'control', 'shared', 'modules', 'slots', 'scene', 'threePatches', 'owned', 'render', 'picture', 'renderer']);
|
|
103
|
+
const TABLES = new Set(['ready', 'error', 'disabledModules', 'loading', 'audio', 'holds', 'input', 'control', 'shared', 'modules', 'slots', 'scene', 'threePatches', 'owned', 'render', 'picture', 'renderer', 'spatial']);
|
|
103
104
|
const NONE = Symbol('none'); // a conditional section that is absent this time
|
|
104
105
|
|
|
105
106
|
/**
|
|
@@ -115,7 +116,7 @@ function describe(e, { radius = NEAR_RADIUS, center: at, only } = {}, extras) {
|
|
|
115
116
|
ready: () => e.ready,
|
|
116
117
|
error: () => e.error, // gameplay error in dev / tests (gameplay is frozen)
|
|
117
118
|
unhandled: () => e._unhandled || NONE, // dev: first promise rejection nobody caught, and how many followed (errors.js)
|
|
118
|
-
disabledModules: () =>
|
|
119
|
+
disabledModules: () => Object.entries(e.moduleStates).filter(([, s]) => s === 'disabled').map(([n]) => n), // picture / ui modules switched off after an error
|
|
119
120
|
moduleStates: () => pendingModules(e) ?? NONE, // while a module is initializing or failed
|
|
120
121
|
loading: () => e.loading.view(), // what is pending / failed and whether it blocks the start (Loading.js)
|
|
121
122
|
time: () => ({ tick: e.time.tick, real: r1(e.time.now('real')), ambient: r1(e.time.now('ambient')), calendar: r1(e.clock.now), halted: e.halted, frozen: e.frozen, ...(e.frozen ? { frozenBy: e.stacks.get('freeze').names() } : {}), headless: e.headless, run: e.runState,
|
|
@@ -131,11 +132,14 @@ function describe(e, { radius = NEAR_RADIUS, center: at, only } = {}, extras) {
|
|
|
131
132
|
x: r1(p.x), y: r1(p.y), z: r1(p.z),
|
|
132
133
|
ground: e.groundType(p.x, p.z),
|
|
133
134
|
groundName: nameOf(e, 'ground.', e.groundType(p.x, p.z)),
|
|
134
|
-
inWater: e.waterAt(p.x, p.z) > p.y,
|
|
135
|
+
inWater: e.waterAt(p.x, p.z, p.y) > p.y,
|
|
135
136
|
state: e.player.state ?? null, // the character module's own state name ('walk', 'jump'...): core passes it on and never interprets it
|
|
136
137
|
} : null,
|
|
137
|
-
//
|
|
138
|
-
|
|
138
|
+
// who answers ground queries and what the world's water is, so "why is there no ground / water here" is one read (ground.js, compositeGround.js)
|
|
139
|
+
spatial: () => ({ groundHolder: e.stacks.has('ground') ? e.stacks.get('ground').value() : null, voidY: e.ground.voidY(), waterLevel: e.ground.waterLevel,
|
|
140
|
+
waterBodies: e.waterBodies.length, ownWater: e.waterBodies.filter(b => b.query).length,
|
|
141
|
+
...(p ? { under: { ground: r1(e.surface(p.x, p.z, p.y)), water: r1(e.waterAt(p.x, p.z, p.y)) } } : {}) }),
|
|
142
|
+
camera: () => ({ type: null, projection: cam.isOrthographicCamera ? 'orthographic' : 'perspective', ...(cam.isOrthographicCamera ? { orthoSize: r1(cam.top - cam.bottom) } : {}), x: r1(cam.position.x), y: r1(cam.position.y), z: r1(cam.position.z),
|
|
139
143
|
focus: { x: r1(e.focus.x), z: r1(e.focus.z) }, override: e.cameraOverride?.owner ?? null }),
|
|
140
144
|
nearbyRadius: () => radius,
|
|
141
145
|
nearby: () => [],
|
package/core/inspect/Inspect.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
// engine.inspect('npc_3') the same for another actor (world record id): "why did this enemy not attack?"
|
|
4
4
|
// engine.inspect([x, z]) things around a spot, ops as the player
|
|
5
5
|
// engine.explain({ op: 'shop.buy', args }) why an op can / cannot run now (text: reason + fix first; detail: its last attempt and the events around it)
|
|
6
|
-
// engine.explain({
|
|
6
|
+
// engine.explain({ value: 'fog.far' }) who wrote a watched value, its short history, a fight if one was seen (core/inspect/pictureWriters.js); a value not tracked says so
|
|
7
|
+
// engine.explain({ thing: 'chest-home' }) everything about one id: text says where it comes from, detail has the whole ThingExplanation
|
|
8
|
+
// engine.explain({ module: 'quests' }) whether a module runs, and what blocks it; { capability: 'ground' } who provides that, and whether it can be called
|
|
7
9
|
// engine.explain({ quest: 'first-light' }) any other key is answered by the module whose definition has explain: { quest(e, id) {...} }
|
|
8
10
|
// engine.pick(x, y).thing point -> thing: the world record a ray hit belongs to, else the engine.add object (thingOf; engine.thing is the same lookup)
|
|
9
11
|
// Built on ops because a failed op already carries its reason; explain turns that into a sentence instead of making the AI read can().
|
|
12
|
+
import { explainThing } from '../scene/thingExplain.js';
|
|
10
13
|
import { Vector3 } from 'three';
|
|
11
14
|
import { closest } from '../base/validate.js';
|
|
12
15
|
import { codedError } from '../base/errorHints.js';
|
|
@@ -59,14 +62,38 @@ export function thingOf(e, obj, hit) {
|
|
|
59
62
|
*/
|
|
60
63
|
export function explain(e, q) {
|
|
61
64
|
if (q?.op) return explainOp(e, q);
|
|
62
|
-
if (q?.
|
|
65
|
+
if (q?.value) return e._picture?.why(String(q.value)) ?? { ok: false, text: `${q.value}: ${NO_WRITERS}`, detail: null };
|
|
66
|
+
if (q?.thing != null) return thingAnswer(e, q.thing);
|
|
67
|
+
if (q?.module) return moduleAnswer(e, String(q.module));
|
|
68
|
+
if (q?.capability) return capabilityAnswer(e, String(q.capability));
|
|
63
69
|
const key = Object.keys(q || {})[0];
|
|
64
70
|
for (const m of e.modules.values()) if (m.explain?.[key]) return m.explain[key](e, q[key], q);
|
|
65
|
-
const keys = ['op', '
|
|
66
|
-
|
|
71
|
+
const keys = ['op', 'value', 'thing', 'module', 'capability', ...[...e.modules.values()].flatMap(m => Object.keys(m.explain || {}))];
|
|
72
|
+
const near = key === 'picture' ? 'value' : closest(key, keys); // the key's old name: closest() cannot see that one
|
|
73
|
+
throw codedError('unknown-name', `engine.explain({ ${key}: ... }): nothing explains '${key}'${near ? ` (did you mean '${near}'?)` : ''}. Keys: ${keys.join(', ')} (a module adds one with explain: { ${key}(e, value) { return { ok, text } } })`);
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
/** Can this op run now (text: the reason and the op's note on how to fix it), and in detail what happened around its last attempt */
|
|
77
|
+
/** One id: an unknown id is an answer, not a throw, so a tool that asks gets the sentence */
|
|
78
|
+
function thingAnswer(e, id) {
|
|
79
|
+
let t;
|
|
80
|
+
try { t = e.thing(id); } catch (x) { return { ok: false, code: x.code ?? null, text: x.message }; }
|
|
81
|
+
const detail = explainThing(e, t), at = detail.definition.at;
|
|
82
|
+
return { ok: true, text: `${detail.id}: ${detail.kind}${at ? `, defined in ${at}` : ''}, saved as ${detail.saved.tier}. ${detail.change.permanent}`, detail };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function moduleAnswer(e, name) {
|
|
86
|
+
const m = e.modules.get(name), names = [...e.modules.keys()];
|
|
87
|
+
if (!m) return { ok: false, text: `${name}: not installed${closest(name, names) ? ` (did you mean '${closest(name, names)}'?)` : ''}. engine.catalog() lists what can be installed` };
|
|
88
|
+
const state = e.moduleStates[name], blocked = e.catalog(name).blockedBy ?? [];
|
|
89
|
+
return { ok: state === 'running', text: `${name}: ${state}${blocked.map(b => `; requires ${b.requires}, and ${b.module} is ${b.state}`).join('')}`, detail: { state, blockedBy: blocked, provides: m.provides ?? [], requires: m.requires ?? [] } };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function capabilityAnswer(e, name) {
|
|
93
|
+
const by = [...e.modules.values()].filter(m => m.name === name || m.provides?.includes(name)).map(m => m.name), ok = e.usable(name);
|
|
94
|
+
return { ok, text: by.length ? `${name}: provided by ${by.join(', ')}, ${ok ? 'usable now' : 'not usable yet'}. engine.explain({ module: '${by[0]}' }) says why` : `${name}: no installed module provides it`, detail: { by, usable: ok } };
|
|
95
|
+
}
|
|
96
|
+
|
|
70
97
|
function explainOp(e, { op, args = {}, actor }) {
|
|
71
98
|
const now = e.ops.can(op, args, actor ? { actor } : undefined);
|
|
72
99
|
const recent = e.ops.recent(op).slice(-5);
|
package/core/inspect/UrlState.js
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
// that did nothing (a weather name the game lacks, a key no module handles) must not read as done. A hook refuses with { refused: { key: reason } }; it names the
|
|
21
21
|
// keys it handles in its module's stateKeys (a hook without stateKeys counts for every key, so a game's own hook is never refused for it).
|
|
22
22
|
import { warnMissing, warnOnce, DEV } from '../base/validate.js';
|
|
23
|
-
import { readParams, keysSchema } from '../base/params.js';
|
|
24
23
|
import { xzOf, yOf } from '../base/math.js';
|
|
25
24
|
import { unsettled } from '../engine/headlessLoad.js';
|
|
26
25
|
import { codedError } from '../base/errorHints.js';
|
|
@@ -30,7 +29,8 @@ const FRESH_ON = [true, 1, '1', ''], FRESH_OFF = [false, 0, '0', 'false'];
|
|
|
30
29
|
const freshOn = v => FRESH_ON.includes(v);
|
|
31
30
|
// met without a module: play has its own core path, and skipping a cutscene in a game without any has nothing left to do
|
|
32
31
|
const NOTHING_NEEDED = ['play', 'cutscene'];
|
|
33
|
-
|
|
32
|
+
// the keys core itself reads. Every other key is a module's, named in its stateKeys: core keeps no list of what modules exist
|
|
33
|
+
const KEYS = ['state', 'pos', 'at', 'save', 'wait', 'cutscene', 'view', 'play', 'fresh'];
|
|
34
34
|
|
|
35
35
|
export class UrlState {
|
|
36
36
|
constructor(engine, { fromUrl = false, dev = DEV } = {}) {
|
|
@@ -58,7 +58,6 @@ export class UrlState {
|
|
|
58
58
|
p = { ...s, ...p };
|
|
59
59
|
delete p.state;
|
|
60
60
|
}
|
|
61
|
-
readParams('applyState()', keysSchema(KEYS), p);
|
|
62
61
|
if (p.fresh != null && !freshOn(p.fresh) && !FRESH_OFF.includes(p.fresh)) throw codedError('state-value', `applyState({ fresh: ${JSON.stringify(p.fresh)} }): fresh takes true or 1 (delete the saves), false or 0 (keep them)`);
|
|
63
62
|
if (typeof p.pos === 'string') { const [x, z] = p.pos.split(',').map(Number); p.pos = { x, z }; }
|
|
64
63
|
if (p.wait != null) p.wait = +p.wait;
|
|
@@ -71,6 +70,8 @@ export class UrlState {
|
|
|
71
70
|
if (!Object.keys(part).length) return [];
|
|
72
71
|
return [...this.engine.modules.values()].filter(m => m.applyState).map(m => m.applyState(this.engine, part));
|
|
73
72
|
}
|
|
73
|
+
/** The keys of these params that a module answers @param {Record<string, any>} p */
|
|
74
|
+
_moduleKeys(p) { return Object.keys(p).filter(k => !KEYS.includes(k)); }
|
|
74
75
|
_refuse(p, key, reason) { this._refused.set(key, { key, value: p[key], reason }); }
|
|
75
76
|
/** Run the hooks for these keys and keep what they refused; a key no installed module handles is refused here, since nothing else would ever say so */
|
|
76
77
|
async _ask(p, keys) {
|
|
@@ -108,9 +109,9 @@ export class UrlState {
|
|
|
108
109
|
async _early(p) {
|
|
109
110
|
const e = this.engine;
|
|
110
111
|
if (freshOn(p.fresh)) await this._fresh();
|
|
111
|
-
if (p.save != null
|
|
112
|
+
if (p.save != null && !await e.saves.load(String(p.save))) this._refuse(p, 'save', e.saves.check(String(p.save)) ?? 'the load failed, so the game went back to how it was');
|
|
112
113
|
if (p.pos) this._place(p.pos);
|
|
113
|
-
await this._ask(p,
|
|
114
|
+
await this._ask(p, this._moduleKeys(p));
|
|
114
115
|
}
|
|
115
116
|
async _late(p) {
|
|
116
117
|
const e = this.engine;
|
|
@@ -120,10 +121,12 @@ export class UrlState {
|
|
|
120
121
|
if (p.play != null) {
|
|
121
122
|
// ended: without a title part quit leaves nothing open to press Start on, and a run that ended must still start again (session:start)
|
|
122
123
|
const started = ended || e.ui.isOpen('title');
|
|
123
|
-
|
|
124
|
+
const fresh = started && await e.session.newGame();
|
|
125
|
+
if (fresh) e.ui.close('title');
|
|
124
126
|
await this._ask(p, ['play']);
|
|
127
|
+
if (started && !fresh) this._refuse(p, 'play', 'the new game failed, so the game went back to how it was'); // after _ask, which clears the keys it is given
|
|
125
128
|
// a new run puts the player at the start, which undid the pos of _early while `state` still printed Set
|
|
126
|
-
if (
|
|
129
|
+
if (fresh && p.pos && p.at == null) { this._place(p.pos); await this._settle(); }
|
|
127
130
|
}
|
|
128
131
|
if (p.at != null) {
|
|
129
132
|
const where = (await this._ask(p, ['at'])).find(r => r && !r.refused);
|
|
@@ -131,18 +134,19 @@ export class UrlState {
|
|
|
131
134
|
if (where) { this._place(where); await this._settle(); } // the ground and models around the place, before wait and the picture
|
|
132
135
|
else if (!this._refused.has('at')) this._refuse(p, 'at', 'no installed module knows place names: install content(), or use pos=x,z');
|
|
133
136
|
}
|
|
134
|
-
await this._ask(p, ['cutscene',
|
|
137
|
+
await this._ask(p, ['cutscene', ...this._moduleKeys(p)]); // once more: an opening's own weather or time, or settings in engine:ready, may have changed them
|
|
135
138
|
if (p.wait > 0) for (let s = p.wait; s > 1e-6; s -= 0.5) { // advance in small slices so Promises (the next cutscene segment) and background threads continue between them
|
|
136
139
|
e.step(Math.min(0.5, s), { render: false, describe: false });
|
|
137
140
|
await new Promise(r => setTimeout(r, 0)); // main-loop: yield to the browser (background threads, Promise continuations) without advancing game time
|
|
138
141
|
}
|
|
139
|
-
await this._ask(p,
|
|
142
|
+
await this._ask(p, this._moduleKeys(p)); // advancing moves time and the day, so align them last
|
|
140
143
|
if (p.view && e.views.list().length && e.views.show(p.view)) { // a page with its own ?view= (no engine.views declared) handles it itself
|
|
141
144
|
if (e.headless) e._frameHooks(0, true); // one loading frame: the modules see the new focus, so _settle has something to wait for
|
|
142
145
|
await this._settle(); // a picture of the view must not be taken before the world around it has loaded
|
|
143
146
|
}
|
|
144
147
|
this.applied = true;
|
|
145
148
|
e.events.emit('state:applied', p);
|
|
149
|
+
e.events.emit('state:replaced', { undone: false }); // a scenario is a door like a load: time, weather and position moved without a step
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
/** What the last applyState or the URL could not do: applyState hands this back, but a URL has no caller, so a tool that built one reads it here @returns {{ key: string, value: any, reason: string }[]} */
|
|
@@ -164,7 +168,7 @@ export class UrlState {
|
|
|
164
168
|
early() {
|
|
165
169
|
if (!this.fromUrl) return;
|
|
166
170
|
const q = new URLSearchParams(location.search), raw = {};
|
|
167
|
-
for (const k of KEYS) if (q.has(k)) raw[k] = q.get(k);
|
|
171
|
+
for (const k of [...KEYS, ...[...this.engine.modules.values()].flatMap(m => m.stateKeys ?? [])]) if (q.has(k)) raw[k] = q.get(k);
|
|
168
172
|
if (!Object.keys(raw).length) return;
|
|
169
173
|
this.pending = this._expand(raw);
|
|
170
174
|
if (!this.dev && this.pending.fresh != null) { // after _expand: a named ?state= can carry fresh too
|
package/core/inspect/catalog.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// part keyed by the module name belongs to that module even when registered later (from game code calling into the module).
|
|
12
12
|
import { parseSchema, schemaInfo } from '../base/params.js';
|
|
13
13
|
import { ENGINE_PARAMS } from '../engine/Engine.js';
|
|
14
|
+
import { SKIP_KINDS, TIME_HOOKS } from '../engine/moduleTypes.js';
|
|
14
15
|
|
|
15
|
-
const TIME_HOOKS = ['fixed', 'frame', 'afterRender', 'skip', 'afterLoad'];
|
|
16
16
|
const MAX_API = 200; // the dev bridge narrows this to what the api page lists (tools/threedog/catalog.mjs)
|
|
17
17
|
|
|
18
18
|
const keysOf = e => [
|
|
@@ -79,10 +79,10 @@ function apiNames(api) {
|
|
|
79
79
|
return [...out];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/** Time model: which loop hooks it has, and
|
|
82
|
+
/** Time model: which loop hooks it has, and how engine.skip advances it (skipKind) */
|
|
83
83
|
function timeOf(m) {
|
|
84
84
|
const hooks = TIME_HOOKS.filter(h => typeof m[h] === 'function');
|
|
85
|
-
return { hooks, step: m.fixed ? 'fixed' : m.frame ? 'frame' : 'none', skip: !!m.skip, ...(m.noSkip ? { noSkip: m.noSkip } : {}) };
|
|
85
|
+
return { hooks, step: m.fixed ? 'fixed' : m.frame ? 'frame' : 'none', skip: !!m.skip, ...(m.skipKind ? { kind: m.skipKind } : {}), ...(m.noSkip ? { noSkip: m.noSkip } : {}) };
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function optionalOf(e, m) {
|
|
@@ -102,7 +102,11 @@ function paramsOf(m) {
|
|
|
102
102
|
function problemsOf(e, m, entry) {
|
|
103
103
|
const out = [];
|
|
104
104
|
if (entry.state === 'failed') out.push('init failed (engine.errors has the reason); no hooks run');
|
|
105
|
-
if (
|
|
105
|
+
if (entry.state === 'disabled') out.push('switched off after it threw while running; no hooks run until it is installed again');
|
|
106
|
+
for (const b of entry.blockedBy) out.push(`blocked: requires ${b.requires}, and ${b.module} is ${b.state}; no init, no hooks until it runs`);
|
|
107
|
+
for (const g of e._contractGaps()) if (g.module === m.name) out.push(`capability ${g.cap}: the contract lists ${g.missing.join(', ')}, which this module's API lacks; a caller of one crashes`);
|
|
108
|
+
if ((m.fixed || m.skip) && !m.skipKind) out.push(`no skipKind: declare how engine.skip advances it (${SKIP_KINDS.join(', ')})`);
|
|
109
|
+
if (['approx', 'step'].includes(m.skipKind) && !m.skip) out.push(`skipKind '${m.skipKind}' but no skip hook: engine.skip does not advance it`);
|
|
106
110
|
for (const o of entry.optional) if (!o.installed && o.lost) out.push(`optional ${o.name} missing: ${o.lost}`);
|
|
107
111
|
return out;
|
|
108
112
|
}
|
|
@@ -112,6 +116,8 @@ function moduleEntry(e, m) {
|
|
|
112
116
|
const entry = {
|
|
113
117
|
id, kind: 'module', ...(m.label ? { label: m.label } : {}), state: e.moduleStates[id], stage: m.stage ?? 'late', runIndex: e.moduleOrder.indexOf(id),
|
|
114
118
|
critical: !!m.critical, requires: m.requires ?? [], optional: optionalOf(e, m), time: timeOf(m), params: paramsOf(m),
|
|
119
|
+
blockedBy: e._modBlocked.get(id) ?? [],
|
|
120
|
+
resources: [...(e._modTracked.get(id) ?? [])].filter(h => h.kind).map(h => `${h.kind}:${h.id}`),
|
|
115
121
|
ops: own.op.map(n => opInfo(e, n, false)), saves: own.save.map(k => saveInfo(e, k)),
|
|
116
122
|
queries: { describe: m.describe ? `describe().${id}` : null, extra: own.describe.map(n => `describe().${n}`), api: apiNames(e[id]) },
|
|
117
123
|
...(m.docs ? { docs: m.docs } : {}),
|
|
@@ -147,6 +153,7 @@ function summary(x) {
|
|
|
147
153
|
s.saves = x.saves.map(p => p.key);
|
|
148
154
|
if (x.time) s.time = [x.time.step, x.time.skip ? 'skip' : null].filter(Boolean).join('+');
|
|
149
155
|
if (x.problems.length) s.problems = x.problems.length;
|
|
156
|
+
if (x.blockedBy?.length) s.blockedBy = x.blockedBy;
|
|
150
157
|
return s;
|
|
151
158
|
}
|
|
152
159
|
|
|
@@ -161,7 +168,7 @@ function entries(e) {
|
|
|
161
168
|
* What this game can do, from the registrations that already exist (modules, ops, save parts, describe, params schemas); no second list to keep in sync.
|
|
162
169
|
* No argument: a short list (id, state, stage, op and save names, time model, problem count). A module id: that module expanded
|
|
163
170
|
* (requires / optional, params with defaults and the values in use, ops with args schema and failure codes, saved parts and versions,
|
|
164
|
-
* time hooks, describe fields and api names, problems such as "
|
|
171
|
+
* time hooks and skip kind, describe fields and api names, problems such as "no skipKind"). An op name: that op expanded, with its last attempt.
|
|
165
172
|
* 'post' or 'shadows': that capability's entry names and what it holds now (effects in the chain, cascades on or off).
|
|
166
173
|
* The dev bridge `threedog catalog [id]` prints the same data and adds the doc, recipe and source files.
|
|
167
174
|
* @param {string | { find?: string }} [id]
|
|
@@ -10,6 +10,7 @@ import { defineOwned } from '../ops/owned.js';
|
|
|
10
10
|
import { slotHolders } from '../scene/pictureSlots.js';
|
|
11
11
|
import { isShown } from '../base/util.js';
|
|
12
12
|
import { backendFacts } from '../../render/backend.js';
|
|
13
|
+
import { pixelSizeOn } from '../scene/pixelRatio.js';
|
|
13
14
|
|
|
14
15
|
const shadowName = v => Object.keys(SHADOW_TYPES).find(k => SHADOW_TYPES[k].three === v) ?? String(v);
|
|
15
16
|
const TONE_NAMES = { [NoToneMapping]: 'none', [LinearToneMapping]: 'linear', [ReinhardToneMapping]: 'reinhard', [CineonToneMapping]: 'cineon',
|
|
@@ -119,10 +120,10 @@ probes: ${probes.map(p => `${p.count} (${p.counts.join('x')}, step ${p.step.join
|
|
|
119
120
|
` + text;
|
|
120
121
|
// render scale: the canvas resolution against the display. auto: the adaptive resolution lowered it at some point (it raises it back when frames are fast)
|
|
121
122
|
const dpr = (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1, cur = r.getPixelRatio(), ad = e.adaptive;
|
|
122
|
-
const scale = { current: Math.round(cur * 100) / 100, devicePixelRatio: dpr, upscaled: cur < dpr - 0.01, autoLowered: !!ad?.lowered && cur < (ad.max ?? cur) - 0.01,
|
|
123
|
+
const scale = { current: Math.round(cur * 100) / 100, devicePixelRatio: dpr, upscaled: cur < dpr - 0.01 && !pixelSizeOn(e), pixelSize: e._pixelSize, autoLowered: !!ad?.lowered && cur < (ad.max ?? cur) - 0.01,
|
|
123
124
|
adaptive: !!ad?.on, floor: ad?.min ?? null, max: ad?.max ?? null };
|
|
124
125
|
text += `
|
|
125
|
-
render scale: ${scale.current} of device pixel ratio ${dpr}${scale.upscaled ? ' (picture is upscaled, softer than the screen)' : ''}${scale.autoLowered ? ` (auto-lowered by adaptive resolution, floor ${scale.floor}; adaptiveResolution: false turns it off)` : ''}`;
|
|
126
|
+
render scale: ${scale.current} of device pixel ratio ${dpr}${scale.pixelSize ? ` (pixelSize ${scale.pixelSize}: one art pixel is ${scale.pixelSize} screen pixels)` : ''}${scale.upscaled ? ' (picture is upscaled, softer than the screen)' : ''}${scale.autoLowered ? ` (auto-lowered by adaptive resolution, floor ${scale.floor}; adaptiveResolution: false turns it off)` : ''}`;
|
|
126
127
|
// the lightmap (render/lightmap.js): what is baked, and what no longer matches the bake
|
|
127
128
|
const lightmap = e._lightmap?.info() ?? null;
|
|
128
129
|
if (lightmap) text += `\nlightmap: ${lightmap.meshes} mesh(es), ${lightmap.size} map from ${lightmap.file}`
|
|
@@ -9,7 +9,7 @@ const STRINGS = {
|
|
|
9
9
|
head: '[Game state] running {s} s{flags}',
|
|
10
10
|
actions: 'Can do (engine.ops): {list}',
|
|
11
11
|
error: '[Error, gameplay frozen] {where}: {message}', errorAt: ' ({at})',
|
|
12
|
-
errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled picture / ui modules (they threw): {list}',
|
|
12
|
+
errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled picture / ui modules (they threw): {list}', blocked: 'Blocked modules: {list}',
|
|
13
13
|
halted: ', halted', headless: ', headless', notReady: ', still loading',
|
|
14
14
|
waiting: 'Loading: {waiting} ({pending} pending, {done}/{total} done)', loadFailed: 'Load failed{blocked}: {list}', blocked: ' (start blocked)',
|
|
15
15
|
loadWarn: 'Loaded with missing references: {list}',
|
|
@@ -25,6 +25,7 @@ const STRINGS = {
|
|
|
25
25
|
camera: 'Camera: {type}, position ({x}, {y}, {z}), focus ({fx}, {fz}){over}',
|
|
26
26
|
override: ', taken over by "{owner}"',
|
|
27
27
|
cutscene: 'Cutscene: {n} playing{skip}',
|
|
28
|
+
cutsceneFailed: 'Cutscene failed: {why}',
|
|
28
29
|
overrides: 'Diagnostic overrides active (the screen is not the real state): {list}',
|
|
29
30
|
skippable: ' (skippable)',
|
|
30
31
|
dialogue: 'Dialogue: {speaker}: "{text}"{choices}',
|
|
@@ -106,6 +107,8 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
|
|
|
106
107
|
L.push(fmt(STRINGS.audio, { list: [...low, v.length ? 'playing ' + v.join(', ') : null].filter(Boolean).join('; ') }));
|
|
107
108
|
}
|
|
108
109
|
if (d.disabledModules?.length) L.push(fmt(STRINGS.disabled, { list: d.disabledModules.join(', ') }));
|
|
110
|
+
const blocked = Object.entries(d.moduleStates ?? {}).filter(([, s]) => s.startsWith('blocked')).map(([n, s]) => `${n} ${s}`);
|
|
111
|
+
if (blocked.length) L.push(fmt(STRINGS.blocked, { list: blocked.join('; ') }));
|
|
109
112
|
if (t.clock) L.push(fmt(STRINGS.time, { clock: t.clock, day: t.day, season: t.season ? ', ' + tr('season', t.season) : '', dayNight: t.isDay ? STRINGS.day
|
|
110
113
|
: STRINGS.night }));
|
|
111
114
|
const w = d.weather, wl = d.weatherDraw ?? {}; // weather state, and what of it is drawn (the drawing half)
|
|
@@ -123,7 +126,8 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
|
|
|
123
126
|
if (pl?.configured) L.push(fmt(STRINGS.pointerLock, { state: pl.state + (pl.lastFailure ? ` (${pl.lastFailure.reason}, ${pl.lastFailure.agoSec} s ago)` : '')
|
|
124
127
|
+ (pl.covered ? `; canvas centre covered by ${pl.covered}` : '') + (pl.cameraOverride ? `; cameraOverride ${pl.cameraOverride} blocks locking` : '') }));
|
|
125
128
|
if (d.scene?.overrides) L.push(fmt(STRINGS.overrides, { list: d.scene.overrides.map(o => `${o.owner}:${o.target}`).join(', ') }));
|
|
126
|
-
if (d.cutscene) L.push(fmt(STRINGS.cutscene, { n: d.cutscene.count, skip: d.cutscene.skippable ? STRINGS.skippable : '' }));
|
|
129
|
+
if (d.cutscene?.count) L.push(fmt(STRINGS.cutscene, { n: d.cutscene.count, skip: d.cutscene.skippable ? STRINGS.skippable : '' }));
|
|
130
|
+
if (d.cutscene?.failure) L.push(fmt(STRINGS.cutsceneFailed, { why: d.cutscene.failure }));
|
|
127
131
|
const dl = d.ui.dialogue;
|
|
128
132
|
if (dl) L.push(fmt(STRINGS.dialogue, { speaker: dl.speaker, text: dl.text, choices: dl.choices.length
|
|
129
133
|
? fmt(STRINGS.choices, { list: dl.choices.map((x, i) => `${i + 1}. ${x}`).join(' ') }) : '' }));
|