threedog 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/core/Animator.js +1 -0
- package/core/Assets.js +28 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +14 -3
- package/core/Engine.js +44 -72
- package/core/Events.js +59 -1
- package/core/I18n.js +2 -2
- package/core/Inspect.js +12 -32
- package/core/InspectScene.js +7 -3
- package/core/MaterialInfo.js +32 -0
- package/core/Ops.js +43 -59
- package/core/Saves.js +5 -4
- package/core/UrlState.js +3 -2
- package/core/Vars.js +1 -0
- package/core/Views.js +49 -0
- package/core/actor.js +2 -2
- package/core/assetReport.js +83 -0
- package/core/catalog.js +169 -0
- package/core/checks.js +67 -0
- package/core/claims.js +51 -0
- package/core/debugView.js +76 -0
- package/core/describeRender.js +51 -0
- package/core/describeText.js +11 -4
- package/core/errorCodes.js +33 -0
- package/core/errorHints.js +6 -1
- package/core/grid.js +127 -0
- package/core/gridLoad.js +19 -0
- package/core/holds.js +106 -0
- package/core/lifecycle.js +1 -0
- package/core/lightWatch.js +23 -3
- package/core/look/coreParts.js +112 -0
- package/core/look/layers.js +136 -0
- package/core/look/part.js +173 -0
- package/core/look/report.js +79 -0
- package/core/look/write.js +86 -0
- package/core/loop.js +22 -16
- package/core/modules.js +19 -5
- package/core/opsAtomic.js +31 -0
- package/core/opsCheck.js +25 -14
- package/core/opsFail.js +20 -0
- package/core/opsHistory.js +6 -6
- package/core/opsRun.js +77 -0
- package/core/params.js +132 -0
- package/core/renamed.js +22 -0
- package/core/saveApply.js +2 -2
- package/core/sceneMethods.js +9 -34
- package/core/services.js +73 -0
- package/core/startup.js +3 -1
- package/core/styleParts.js +11 -9
- package/core/thingExplain.js +68 -0
- package/core/thingOps.js +35 -24
- package/core/things.js +15 -1
- package/core/util.js +11 -0
- package/core/validate.js +23 -7
- package/docs/AI.md +93 -114
- package/docs/API.md +8 -9
- package/docs/CODEMAP.md +67 -53
- package/docs/COMMANDS.md +21 -7
- package/docs/CONVENTIONS.md +22 -11
- package/docs/THREE.md +3 -3
- package/docs/api/assets.md +3 -0
- package/docs/api/characters.md +5 -2
- package/docs/api/collision.md +4 -0
- package/docs/api/content.md +1 -0
- package/docs/api/engine.md +23 -14
- package/docs/api/events.md +5 -1
- package/docs/api/post.md +5 -4
- package/docs/api/saves.md +2 -1
- package/docs/api/sky.md +3 -3
- package/docs/api/style.md +8 -8
- package/docs/api/tools.md +5 -2
- package/docs/api/vegetation.md +1 -0
- package/docs/api/weather.md +1 -1
- package/docs/recipes/01-new-game.md +41 -43
- package/docs/recipes/02-npc.md +38 -22
- package/docs/recipes/03-items-pickups.md +4 -4
- package/docs/recipes/04-quests.md +23 -23
- package/docs/recipes/05-props-bake.md +5 -5
- package/docs/recipes/06-clock-events.md +13 -0
- package/docs/recipes/07-flow-scenes-pause.md +6 -2
- package/docs/recipes/08-weather-sky.md +6 -6
- package/docs/recipes/09-style-pack.md +35 -100
- package/docs/recipes/12-navmesh.md +22 -0
- package/docs/recipes/13-animation.md +25 -6
- package/docs/recipes/14-custom-module.md +6 -7
- package/docs/recipes/15-perf.md +9 -1
- package/docs/recipes/16-dev-bridge.md +52 -18
- package/docs/recipes/18-world.md +5 -2
- package/docs/recipes/19-shooting-picking.md +9 -8
- package/docs/recipes/20-content-actions-save.md +10 -10
- package/docs/recipes/21-camera.md +51 -2
- package/docs/recipes/22-shop-gold.md +16 -16
- package/docs/recipes/23-ops.md +46 -10
- package/docs/recipes/27-net.md +3 -3
- package/docs/recipes/28-terrain.md +2 -2
- package/docs/recipes/29-grid.md +47 -27
- package/docs/recipes/34-environment-lighting.md +11 -10
- package/docs/recipes/35-style-from-reference.md +41 -46
- package/docs/recipes/36-sky-ground-plant-looks.md +22 -20
- package/docs/recipes/37-terrain-look-hooks.md +34 -13
- package/docs/recipes/38-environment-look-hooks.md +49 -42
- package/docs/recipes/40-scene.md +29 -0
- package/docs/recipes/41-thing-registry.md +29 -0
- package/docs/recipes/42-terrain-shape.md +1 -1
- package/docs/recipes/43-shader-patches-surface-looks.md +37 -20
- package/docs/recipes/44-water-weather-look-hooks.md +11 -9
- package/docs/recipes/45-cascaded-shadows.md +2 -2
- package/docs/recipes/46-blender-art-route.md +26 -4
- package/docs/recipes/47-island-snow-backdrop.md +4 -3
- package/docs/recipes/48-make-material.md +70 -0
- package/docs/recipes/49-game-module-contract.md +71 -0
- package/docs/recipes/50-own-renderer.md +12 -0
- package/docs/recipes/51-capability-catalog.md +63 -0
- package/docs/recipes/52-look.md +146 -0
- package/docs/recipes/53-ground-up-close.md +58 -0
- package/examples/action/GAMEMAP.md +7 -7
- package/examples/action/content/index.js +2 -1
- package/examples/action/content/views.js +6 -0
- package/examples/action/main.js +3 -2
- package/examples/sheepisland/GAMEMAP.md +3 -4
- package/examples/styletest/GAMEMAP.md +3 -3
- package/examples/styletest/content/npcs.js +1 -1
- package/examples/styletest/main.js +2 -2
- package/examples/styletest/panel.js +3 -3
- package/examples/world/GAMEMAP.md +3 -3
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/main.js +1 -1
- package/index.d.ts +35 -2
- package/index.js +6 -3
- package/llms.txt +13 -7
- package/modules/ambience/Ambience.js +5 -2
- package/modules/camera/FirstPersonCamera.js +3 -5
- package/modules/camera/FixedCamera.js +19 -12
- package/modules/camera/FollowCamera.js +14 -8
- package/modules/camera/RtsCamera.js +3 -5
- package/modules/camera/common.js +40 -10
- package/modules/camera/index.js +1 -1
- package/modules/camera/projection.js +34 -0
- package/modules/characters/Character.js +45 -31
- package/modules/characters/assetModel.js +35 -7
- package/modules/characters/astar.js +14 -7
- package/modules/characters/index.js +6 -3
- package/modules/characters/movers/simple.js +6 -1
- package/modules/characters/npcSim.js +8 -2
- package/modules/characters/pathAsync.js +12 -6
- package/modules/characters/pathJob.js +2 -1
- package/modules/characters/proceduralRig.js +50 -11
- package/modules/characters/useModel.js +22 -0
- package/modules/characters/walkTo.js +58 -0
- package/modules/collision/Collision.js +102 -4
- package/modules/content/explain.js +13 -0
- package/modules/content/index.js +3 -1
- package/modules/content/loader.js +3 -0
- package/modules/content/rules.js +1 -0
- package/modules/debug/DebugPanel.js +11 -5
- package/modules/entities/Entities.js +6 -2
- package/modules/flow/index.js +5 -2
- package/modules/gameplay/Dialogue.js +5 -2
- package/modules/gameplay/Interactions.js +12 -2
- package/modules/gameplay/Inventory.js +21 -11
- package/modules/gameplay/Quests.js +13 -3
- package/modules/gameplay/pickups.js +6 -4
- package/modules/grid/Layer.js +1 -1
- package/modules/grid/index.js +1 -1
- package/modules/grid/tiles.js +9 -5
- package/modules/hlod/index.js +5 -2
- package/modules/hud/index.js +5 -2
- package/modules/level/index.js +5 -3
- package/modules/lights/index.js +5 -2
- package/modules/music/Music.js +6 -2
- package/modules/nav/index.js +5 -3
- package/modules/net/Client.js +4 -3
- package/modules/net/Host.js +2 -2
- package/modules/net/index.js +5 -3
- package/modules/particles/Particles.js +1 -1
- package/modules/photo/Photo.js +10 -7
- package/modules/rigid/RigidBodies.js +5 -2
- package/modules/settings/Settings.js +6 -3
- package/modules/settings/apply.js +2 -1
- package/modules/sky/Sky.js +21 -19
- package/modules/sky/cascades.js +6 -6
- package/modules/sky/domeLayers.js +1 -1
- package/modules/sky/environment.js +39 -13
- package/modules/sky/fog.js +9 -6
- package/modules/sky/frame.js +4 -3
- package/modules/sky/look.js +3 -2
- package/modules/sky/lookFog.js +80 -0
- package/modules/sky/lookShadow.js +50 -0
- package/modules/sky/lookSky.js +108 -0
- package/modules/sky/shader.js +2 -2
- package/modules/sky/shadow.js +4 -10
- package/modules/sky/skyModule.js +4 -3
- package/modules/terrain/ChunkManager.js +2 -33
- package/modules/terrain/chunkLevels.js +40 -0
- package/modules/terrain/index.js +10 -2
- package/modules/terrain/lookGround.js +61 -0
- package/modules/timeline/Timeline.js +7 -3
- package/modules/timeline/Tween.js +3 -7
- package/modules/timeline/shots.js +6 -4
- package/modules/triggers/index.js +9 -2
- package/modules/vegetation/Vegetation.js +17 -4
- package/modules/vegetation/index.js +7 -4
- package/modules/vegetation/lookWind.js +37 -0
- package/modules/vegetation/nearFade.js +39 -0
- package/modules/water/Water.js +19 -3
- package/modules/water/look.js +80 -0
- package/modules/weather/Weather.js +22 -31
- package/modules/weather/look.js +75 -0
- package/modules/weather/particles.js +1 -1
- package/modules/weather/strings.js +15 -0
- package/modules/world/explain.js +11 -0
- package/modules/world/index.js +11 -4
- package/modules/world/thingSource.js +44 -0
- package/package.json +2 -1
- package/render/PostFX.js +48 -51
- package/render/detail.js +39 -15
- package/render/effects.js +4 -2
- package/render/fuse.js +12 -0
- package/render/lights.js +4 -2
- package/render/lookSurface.js +161 -0
- package/render/materials.js +27 -10
- package/render/postLook.js +86 -0
- package/render/surface.js +3 -1
- package/types/core.d.ts +223 -29
- package/types/gameplay.d.ts +22 -6
- package/types/generated/core/DebugOverrides.d.ts +52 -0
- package/types/generated/core/Events.d.ts +43 -0
- package/types/generated/core/Ops.d.ts +62 -21
- package/types/generated/core/Saves.d.ts +1 -0
- package/types/generated/core/Views.d.ts +33 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Layer.d.ts +1 -0
- package/types/generated/modules/sky/Sky.d.ts +10 -17
- package/types/generated/modules/weather/Weather.d.ts +5 -15
- package/types/generated/render/PostFX.d.ts +20 -23
- package/types/generated/render/materials.d.ts +10 -0
- package/types/physics.d.ts +8 -0
- package/types/style.d.ts +35 -20
- package/types/world.d.ts +7 -1
- package/ui/Parts.js +6 -2
- package/ui/UI.js +1 -1
- package/ui/defaults.js +1 -1
- package/docs/api/debug.md +0 -10
package/types/core.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
} from './world';
|
|
7
7
|
import type { World } from './generated/modules/world/World';
|
|
8
8
|
import type { Net } from './generated/modules/net/Net';
|
|
9
|
+
import type { PostEffect } from './generated/render/PostFX';
|
|
9
10
|
import type { Grids } from './generated/modules/grid/index';
|
|
10
11
|
import type { Collision, RigidBodies, CameraRig, CameraKind, CameraShotEvent, Animator, AnimatorOptions, Vehicle } from './physics';
|
|
11
12
|
import type { Nav } from './nav';
|
|
@@ -22,6 +23,8 @@ import type { Events } from './generated/core/Events';
|
|
|
22
23
|
import type { Commits } from './generated/core/Commits';
|
|
23
24
|
import type { Threads } from './generated/core/Threads';
|
|
24
25
|
import type { Ops } from './generated/core/Ops';
|
|
26
|
+
import type { Views } from './generated/core/Views';
|
|
27
|
+
import type { DebugOverrides } from './generated/core/DebugOverrides';
|
|
25
28
|
import type { Jobs } from './generated/core/Jobs';
|
|
26
29
|
import type { Random } from './generated/core/Random';
|
|
27
30
|
import type { PostFX } from './generated/render/PostFX';
|
|
@@ -188,7 +191,7 @@ export interface EventMap extends GameEvents {
|
|
|
188
191
|
/** Client (net): host state applied (full: a whole snapshot, else a diff); redraw UI from state here */
|
|
189
192
|
'net:sync': [{ tick: number; full: boolean }];
|
|
190
193
|
/** Client (net): the host's answer to an op request (seq from ops.run's return value; tick is the host's), sent after the state it caused */
|
|
191
|
-
'net:result': [{ seq: number; name: string; ok: boolean;
|
|
194
|
+
'net:result': [{ seq: number; name: string; ok: boolean; code: string | null; value?: any; tick: number }];
|
|
192
195
|
/** A gameplay error in development / testing; gameplay is frozen (error severity levels, see engine.error) */
|
|
193
196
|
'engine:error': [EngineError];
|
|
194
197
|
/** A presentation module errored and was disabled (the game continues) */
|
|
@@ -290,6 +293,8 @@ export interface SaveProvider {
|
|
|
290
293
|
load: (data: any) => void | Promise<void>;
|
|
291
294
|
/** Load before the other parts (such as the level) */
|
|
292
295
|
first?: boolean;
|
|
296
|
+
/** Join atomic ops: copied before an atomic op runs, put back if it fails (plain data; afterLoad does not run on rollback) */
|
|
297
|
+
atomic?: boolean;
|
|
293
298
|
/** This part's format version, default 1: raise it by 1 when what save() returns changes shape. A save with a newer version is refused */
|
|
294
299
|
version?: number;
|
|
295
300
|
/** Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }.
|
|
@@ -398,6 +403,8 @@ export interface Assets {
|
|
|
398
403
|
modelNow(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Object3D | null;
|
|
399
404
|
/** Get the geometry of the first mesh in a model */
|
|
400
405
|
geometry(nameOrUrl: string): Promise<BufferGeometry>;
|
|
406
|
+
/** An image as grid data for sampleGrid: PNG at 8 or 16 bits (jpg / webp 8). channel 'r' (default) 'g' 'b' 'a' or 0-3; range maps pixels to [min, max] (default [0, 1]) */
|
|
407
|
+
gridFromImage(nameOrUrl: string, opts?: { channel?: 'r' | 'g' | 'b' | 'a' | number; range?: [number, number]; bits?: 8 | 16 }): Promise<{ data: Float32Array; width: number; height: number; bits: number }>;
|
|
401
408
|
/** Get a texture (.ktx2 compressed textures also work) */
|
|
402
409
|
texture(nameOrUrl: string, opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] }): Promise<Texture>;
|
|
403
410
|
/**
|
|
@@ -446,6 +453,18 @@ export interface Assets {
|
|
|
446
453
|
draco: any;
|
|
447
454
|
/** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) */
|
|
448
455
|
ktx2: any;
|
|
456
|
+
/** 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 */
|
|
457
|
+
report(nameOrRoot: string | Object3D): AssetReport;
|
|
458
|
+
/** assets.report as text for the console / describe */
|
|
459
|
+
reportText(nameOrRoot: string | Object3D): string;
|
|
460
|
+
}
|
|
461
|
+
/** engine.assets.report(): see recipes/46-blender-art-route.md */
|
|
462
|
+
export interface AssetReport {
|
|
463
|
+
name: string | null; url: string | null; fromFile: boolean;
|
|
464
|
+
counts: Record<string, number>;
|
|
465
|
+
materials: { name: string; type: string; maps: Record<string, any>; flatShading: boolean; vertexColors: boolean; madeByStyle: boolean }[];
|
|
466
|
+
textures: any[]; clips: { name: string; seconds: number }[]; colliders: any[]; templates: any[];
|
|
467
|
+
issues: { severity: 'warn' | 'info'; code: string; msg: string }[];
|
|
449
468
|
}
|
|
450
469
|
|
|
451
470
|
/** Phase of a loading task */
|
|
@@ -622,7 +641,7 @@ export type UIPartValue = boolean | Record<string, any> | UIPartFactory;
|
|
|
622
641
|
export interface UIPartDef {
|
|
623
642
|
on?: boolean;
|
|
624
643
|
multi?: boolean;
|
|
625
|
-
modal?: { freeze?: boolean; cancel?: (engine: Engine) => void; data?: (engine: Engine, options: Record<string, any>) => object } | null;
|
|
644
|
+
modal?: { freeze?: boolean | ((engine: Engine) => boolean); cancel?: (engine: Engine) => void; data?: (engine: Engine, options: Record<string, any>) => object } | null;
|
|
626
645
|
}
|
|
627
646
|
/**
|
|
628
647
|
* What the 'touch' UI part receives in show(view) and update(view) (buttons added later, language changed). Call move / press / release from your controls:
|
|
@@ -811,22 +830,25 @@ export type ModuleInput = ModuleDef | ModuleInput[] | false | null | undefined;
|
|
|
811
830
|
// ======================================================================
|
|
812
831
|
|
|
813
832
|
export interface EngineOptions {
|
|
814
|
-
/** Canvas element (required), e.g. document.getElementById('view') */
|
|
815
|
-
canvas
|
|
816
|
-
/**
|
|
817
|
-
*
|
|
833
|
+
/** Canvas element (required unless renderer is given), e.g. document.getElementById('view') */
|
|
834
|
+
canvas?: HTMLCanvasElement | HTMLElement;
|
|
835
|
+
/** A ready three.js renderer (WebGLRenderer or compatible) to use instead of creating one; canvas then defaults to renderer.domElement. The engine configures
|
|
836
|
+
* (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) */
|
|
837
|
+
renderer?: any;
|
|
838
|
+
/** Style pack (looks only: materials, sky, lighting, post, UI look), a pack you made or installed (import basePack from 'your-pack'), or a list of parts
|
|
839
|
+
* deep-merged left to right: [basePack, { sky: { sunSize: 600 } }]. Without one: neutral gray placeholders */
|
|
818
840
|
style?: StyleInput;
|
|
819
841
|
/** Real-time shadows, default true */
|
|
820
842
|
shadows?: boolean;
|
|
821
|
-
/** Shadow filter: 'basic' (hard edge) | 'pcf' | 'vsm' (softest, costliest), default 'pcf'. Change later with engine.
|
|
843
|
+
/** Shadow filter: 'basic' (hard edge) | 'pcf' | 'vsm' (softest, costliest), default 'pcf'. Change later with engine.look.shadow.set({ type }) */
|
|
822
844
|
shadowType?: 'basic' | 'pcf' | 'vsm';
|
|
823
845
|
/** MSAA anti-aliasing (kept with post effects on), default style.antialias, else on for desktop and off for low-tier devices */
|
|
824
846
|
antialias?: boolean;
|
|
825
847
|
/** 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) */
|
|
826
848
|
post?: Record<string, boolean>;
|
|
827
|
-
/** Render resolution, default min(device pixel ratio, 1.5) */
|
|
849
|
+
/** Render resolution, default min(device pixel ratio, 1.5); the low tier uses at least 0.75 x device pixel ratio (never below 1). describe().render.scale reports it */
|
|
828
850
|
pixelRatio?: number;
|
|
829
|
-
/** Automatically lower resolution when the frame rate is too low, default true */
|
|
851
|
+
/** Automatically lower resolution when the frame rate is too low, default true. Never silent: a dev warning once, and describe().render.scale.autoLowered */
|
|
830
852
|
adaptiveResolution?: boolean;
|
|
831
853
|
/** Target frame rate for automatic resolution lowering, default 55 */
|
|
832
854
|
targetFps?: number;
|
|
@@ -891,6 +913,8 @@ export interface EngineOptions {
|
|
|
891
913
|
threads?: 'auto' | number | false;
|
|
892
914
|
/** Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page) */
|
|
893
915
|
pauseOnBlur?: boolean;
|
|
916
|
+
/** 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 */
|
|
917
|
+
lights?: boolean;
|
|
894
918
|
/** Automatic instancing of repeated static models (engine.batching): false turns it off; default { minCount: 8, cell: engine.stream.cellSize } */
|
|
895
919
|
batching?: false | BatchingOptions;
|
|
896
920
|
}
|
|
@@ -955,6 +979,22 @@ export interface Thing extends HitThing {
|
|
|
955
979
|
id: string; owner: string; at: string | null; phase: 'setup' | 'play'; saved: 'record' | 'code' | 'session' | 'engine'; keeps: string[]; loses: string[];
|
|
956
980
|
/** the live object (the record's current model, null when not built) */
|
|
957
981
|
readonly object: Object3D | null;
|
|
982
|
+
/** everything about this id in one JSON-able object: definition file:line, template, model, materials, state, collision rules, related ops, save status, how to change it. Not engine.explain(): that answers "why can this op / quest not run" (recipes/41 section 6) */
|
|
983
|
+
explain(): ThingExplanation;
|
|
984
|
+
}
|
|
985
|
+
/** What thing.explain() returns (`threedog thing <id>` prints the same JSON); modules add keys to rules / state through their explainers */
|
|
986
|
+
export interface ThingExplanation {
|
|
987
|
+
id: string; kind: string; owner: string;
|
|
988
|
+
/** at: 'content/props.js:14' (null in release builds and for code without a file) */
|
|
989
|
+
definition: { at: string | null; template: string | null; templateAt: string | null; level?: string; node?: string; spawned?: boolean; [k: string]: any };
|
|
990
|
+
model: string | null;
|
|
991
|
+
materials: ({ role: string | null; name: string | null; from: string | null; keys: string[]; type: string; color: string | null; mesh: string | null } | { more: number })[];
|
|
992
|
+
state: { position?: number[]; visible?: boolean; scale?: number[]; [k: string]: any };
|
|
993
|
+
rules: { height?: number; blocksMovement?: any; pickable?: boolean; interact?: any; [k: string]: any };
|
|
994
|
+
ops: { op: string; desc: string | null; args: any }[];
|
|
995
|
+
saved: { tier: 'record' | 'code' | 'session' | 'engine'; keeps: string[]; loses: string[]; overridden?: boolean; removed?: boolean };
|
|
996
|
+
change: { runtime: string; permanent: string; diagnostic: string };
|
|
997
|
+
overrides?: any[];
|
|
958
998
|
}
|
|
959
999
|
/**
|
|
960
1000
|
* What a ray hit is (RayHit.thing, engine.inspect(id).thing; engine.thing gives the same plus owner / saved): the world record it belongs to, else the
|
|
@@ -1117,7 +1157,19 @@ export interface StateParams {
|
|
|
1117
1157
|
cutscene?: 'skip' | 'keep';
|
|
1118
1158
|
}
|
|
1119
1159
|
|
|
1120
|
-
/**
|
|
1160
|
+
/** A claim on something only its owner releases (pause, freeze, takeCamera, views) */
|
|
1161
|
+
export interface OwnerHandle { owner: string; remove(): void }
|
|
1162
|
+
/** What pause / freeze return: the claim handle, plus the old chaining calls forwarded to the engine */
|
|
1163
|
+
export interface ChainedHandle extends OwnerHandle {
|
|
1164
|
+
pause(owner?: string | { owner?: string; kind?: 'test' }, opts?: { kind?: 'test' }): ChainedHandle;
|
|
1165
|
+
resume(owner?: string | { owner?: string }): Engine;
|
|
1166
|
+
freeze(owner?: string | { owner?: string; kind?: 'title' }, opts?: { kind?: 'title' }): ChainedHandle;
|
|
1167
|
+
unfreeze(owner?: string | { owner?: string }): Engine;
|
|
1168
|
+
step(seconds: number, opts?: { render?: boolean; frameEvery?: number; describe?: boolean }): GameState | null;
|
|
1169
|
+
}
|
|
1170
|
+
/** engine.runState: state in one word, by = every pause / freeze owner, blockedBy = opaque input contexts plus 'error' / 'loading' */
|
|
1171
|
+
export interface RunState { state: 'loading' | 'title-frozen' | 'test-paused' | 'paused' | 'running'; by: string[]; blockedBy: string[] }
|
|
1172
|
+
/** Camera takeover: when non-null no camera module moves the camera (for cutscenes); see engine.takeCamera */
|
|
1121
1173
|
export interface CameraOverride {
|
|
1122
1174
|
/** Who took over (any name) */
|
|
1123
1175
|
owner: string;
|
|
@@ -1126,7 +1178,129 @@ export interface CameraOverride {
|
|
|
1126
1178
|
[key: string]: any;
|
|
1127
1179
|
}
|
|
1128
1180
|
/** State of automatic resolution */
|
|
1129
|
-
export interface AdaptiveState { paused: boolean; on: boolean; target: number; min: number; max: number; [key: string]: any }
|
|
1181
|
+
export interface AdaptiveState { paused: boolean; on: boolean; target: number; min: number; max: number; /** true once the render scale was lowered below max (a dev warning was logged) */ lowered?: boolean; [key: string]: any }
|
|
1182
|
+
|
|
1183
|
+
// ======================================================================
|
|
1184
|
+
// Look parts engine.look.<part> (recipes/52-look.md)
|
|
1185
|
+
// ======================================================================
|
|
1186
|
+
|
|
1187
|
+
/** Returned by set / patch / replace: remove() takes that owner's layer back off */
|
|
1188
|
+
export interface LookHandle { remove(): void }
|
|
1189
|
+
/** engine.look.post: a LookPart with add() for one custom pass */
|
|
1190
|
+
export interface LookPost extends LookPart {
|
|
1191
|
+
/** Add ONE custom post pass (name, create | fuse, slot, order, params) without replacing the chain; remove() takes it out again. Slot, order and depth-order errors throw and add nothing. Change its params with set({ '<name>.<param>': v }) */
|
|
1192
|
+
add(effect: PostEffect, opts?: LookOptions): LookHandle;
|
|
1193
|
+
}
|
|
1194
|
+
/** owner: who writes the layer (non-empty name, default 'game'); roles: only materials.patch, the material roles that get the patch */
|
|
1195
|
+
export interface LookOptions { owner?: string; roles?: string[] }
|
|
1196
|
+
/** patch(name, spec): a spec instead of plain GLSL. post: fuse snippet (glsl, slot, order, uniforms, values); sky 'layer:<name>': glsl, blend, order, uniforms */
|
|
1197
|
+
export interface LookPatchSpec {
|
|
1198
|
+
glsl?: string | Record<string, any>;
|
|
1199
|
+
/** post: 'hdr' | 'ldr' */
|
|
1200
|
+
slot?: string;
|
|
1201
|
+
/** post and sky layers: draw order, smaller first */
|
|
1202
|
+
order?: number;
|
|
1203
|
+
uniforms?: Record<string, any>;
|
|
1204
|
+
/** post: live values of the generated effect */
|
|
1205
|
+
values?: Record<string, any>;
|
|
1206
|
+
/** sky layer: 'mix' | 'add' */
|
|
1207
|
+
blend?: string;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* One look part. Layers, upper wins: engine default < style < game (per owner, last write wins) < engine.debug.override.
|
|
1212
|
+
* A part offers only the verbs that make sense for it; the others throw naming the verb to use.
|
|
1213
|
+
*/
|
|
1214
|
+
export interface LookPart<P = Record<string, any>> {
|
|
1215
|
+
/** 'look.<part>': the id engine.catalog() and debug.override use */
|
|
1216
|
+
readonly id: string;
|
|
1217
|
+
/** Shallow-merge into the owner's layer, only the keys given; null drops a key so the layer below shows again. Keys that recompile shaders warn once in dev */
|
|
1218
|
+
set(params: { [K in keyof P]?: P[K] | null } & Record<string, any>, opts?: LookOptions): LookHandle;
|
|
1219
|
+
/** Swap one named GLSL hook the part registered (names: engine.catalog('look.<part>').hooks); the same name again overrides; patch(name, null) restores the default */
|
|
1220
|
+
patch(name: string, glsl: string | LookPatchSpec | null, opts?: LookOptions): LookHandle;
|
|
1221
|
+
/** Take the whole part over (Material, texture, object, effect list ...: see the catalog); replace(null) gives it back. materials.replace takes the role first */
|
|
1222
|
+
replace(impl: any, opts?: LookOptions): LookHandle;
|
|
1223
|
+
replace(role: string, impl: any, opts?: LookOptions): LookHandle;
|
|
1224
|
+
/** Drop every game and debug layer of that owner (the style value shows again); returns how many layers were removed, like engine.debug.clear */
|
|
1225
|
+
clear(owner: string): number;
|
|
1226
|
+
/** The resolved value of a key (what is in use now) */
|
|
1227
|
+
value(key: string): any;
|
|
1228
|
+
/** The value from the highest game / debug layer for the key (undefined when only style or default gives it) */
|
|
1229
|
+
top(key: string): any;
|
|
1230
|
+
/** The three.js object(s) behind the part (renderer, lights, scene.fog ...); changing it directly works but describe tags it 'three'.
|
|
1231
|
+
* look.materials: a function, object('wool') = the last Material made for that role, object() = all of them */
|
|
1232
|
+
readonly object: any;
|
|
1233
|
+
/** Each verb's call shape, e.g. { set: 'set(params, { owner })', replace: 'replace(role, ...)' } (also in engine.catalog('look.<part>')) */
|
|
1234
|
+
readonly signatures: Record<string, string>;
|
|
1235
|
+
// ---- for authors of a part made with defineLookPart (recipes/52-look.md) ----
|
|
1236
|
+
/** Write raw keys (params, 'hook:<name>', '@replace') for an owner, no normalize; null drops a key */
|
|
1237
|
+
write(owner: string, values: Record<string, any>, opts?: { layer?: 'game' | 'debug' }): LookHandle;
|
|
1238
|
+
/** What one owner holds for a key, or undefined */
|
|
1239
|
+
ownerValue(owner: string, key: string, opts?: { layer?: 'game' | 'debug' }): any;
|
|
1240
|
+
/** Add declared keys to a started part (same fields as defineLookPart params) */
|
|
1241
|
+
extend(params: Record<string, any>): void;
|
|
1242
|
+
/** Remove every key starting with prefix, with every layer's value for them */
|
|
1243
|
+
retract(prefix: string): void;
|
|
1244
|
+
/** Is key a declared param */
|
|
1245
|
+
has(key: string): boolean;
|
|
1246
|
+
/** [key, value] pairs in effect whose key starts with prefix */
|
|
1247
|
+
resolved(prefix?: string): Array<[string, any]>;
|
|
1248
|
+
/** Replace the style layer */
|
|
1249
|
+
restyle(values: Record<string, any>): void;
|
|
1250
|
+
/** Declare keys a style-driven system writes every frame (by = the driver's module name); drive(keys, null) hands them back */
|
|
1251
|
+
drive(keys: string[], by: string | null): void;
|
|
1252
|
+
/** Unregister the part (its module went away) */
|
|
1253
|
+
dispose(): void;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
export interface LookTone { mapping: string; exposure: number | Array<[number, number]> | ((t: number) => number) }
|
|
1257
|
+
export interface LookLightSide { color?: ColorLike; intensity?: number }
|
|
1258
|
+
export interface LookLights { sun: LookLightSide | 'manual' | false; hemi: LookLightSide | 'manual' | false }
|
|
1259
|
+
/** The map itself is the replace slot: look.env.replace('sky' | Texture | null) */
|
|
1260
|
+
export interface LookEnv { intensity: number; rotation: number; interval: number }
|
|
1261
|
+
export interface LookFog { kind: string; color: ColorLike | 'horizon'; density: number; near: number; far: number; height: number; falloff: number; enabled: boolean }
|
|
1262
|
+
export interface LookSky { clouds: Record<string, any>; backdrop: ColorLike | null }
|
|
1263
|
+
export interface LookShadow {
|
|
1264
|
+
type: 'basic' | 'pcf' | 'vsm'; radius: number; blurSamples: number; bias: number; normalBias: number; mapSize: number; updateEvery: number;
|
|
1265
|
+
snap: number | 'texel'; ahead: number; cascades: number; maxFar: number; fade: boolean; lightMargin: number; enabled: boolean;
|
|
1266
|
+
split: 'practical' | 'uniform' | 'logarithmic' | ((count: number, near: number, far: number, out: number[]) => void);
|
|
1267
|
+
}
|
|
1268
|
+
export interface LookCloudShadow { shadow: number; scale: number; speed: [number, number] }
|
|
1269
|
+
export interface LookWind { frequency: number; amplitude: number }
|
|
1270
|
+
export interface LookGround {
|
|
1271
|
+
colors: Record<string, ColorLike>; biomeColors: Record<string, string | string[]>; steep: Array<{ maxNormalY: number; colors: any }>;
|
|
1272
|
+
variation: any; detail: any; shading: string;
|
|
1273
|
+
}
|
|
1274
|
+
export interface LookSurface { lighting: Record<string, any>; detail: Record<string, any>; ramp: number[]; soften: number }
|
|
1275
|
+
export interface LookWater {
|
|
1276
|
+
color: ColorLike; opacity: number; depthColor: { shallow?: ColorLike; deep?: ColorLike }; foam: Record<string, any>;
|
|
1277
|
+
waveHeight: number; waveScale: number; waveSpeed: number; fresnel: number;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/** engine.look: the parts by name. A part exists only when the module that provides it is installed (fog / sky / shadow / env: sky(); ground: terrain(); wind: vegetation(); water; weather) */
|
|
1281
|
+
export interface Look {
|
|
1282
|
+
tone: LookPart<LookTone>;
|
|
1283
|
+
lights: LookPart<LookLights>;
|
|
1284
|
+
cloudShadow: LookPart<LookCloudShadow>;
|
|
1285
|
+
/** Old name of cloudShadow (recipes/52-look.md, Old names) */
|
|
1286
|
+
clouds: LookPart<LookCloudShadow>;
|
|
1287
|
+
env: LookPart<LookEnv>;
|
|
1288
|
+
fog: LookPart<LookFog>;
|
|
1289
|
+
sky: LookPart<LookSky>;
|
|
1290
|
+
shadow: LookPart<LookShadow>;
|
|
1291
|
+
/** Roles are the keys: set({ wool: { roughness: 0.4 } }), patch(name, spec, { roles }), replace('wool', Material | fn) */
|
|
1292
|
+
materials: LookPart<Record<string, Record<string, any>>>;
|
|
1293
|
+
surface: LookPart<LookSurface>;
|
|
1294
|
+
ground: LookPart<LookGround>;
|
|
1295
|
+
wind: LookPart<LookWind>;
|
|
1296
|
+
water: LookPart<LookWater>;
|
|
1297
|
+
/** Keys 'rain.speed', 'snow.size', 'lightning.brightness', overcastColor ...; patch('rain.fragment', wholeShaderText) */
|
|
1298
|
+
weather: LookPart;
|
|
1299
|
+
/** Per effect: set({ bloom: { strength: 0.6 }, vignette: false }); patch(name, { glsl, slot, order, uniforms, values }); add(effect, { owner }); replace([effects]) */
|
|
1300
|
+
post: LookPost;
|
|
1301
|
+
/** Parts made with defineLookPart */
|
|
1302
|
+
[custom: string]: LookPart;
|
|
1303
|
+
}
|
|
1130
1304
|
|
|
1131
1305
|
/**
|
|
1132
1306
|
* The engine. Created by createEngine({ canvas, style }); engine.use(module...) installs modules, engine.start() starts it.
|
|
@@ -1160,7 +1334,7 @@ export declare class Engine {
|
|
|
1160
1334
|
focus: Vector3;
|
|
1161
1335
|
/** Whether shadows are on */
|
|
1162
1336
|
shadows: boolean;
|
|
1163
|
-
/** Shadow filter in use; change it with
|
|
1337
|
+
/** Shadow filter in use; change it with look.shadow.set({ type }) */
|
|
1164
1338
|
shadowType: 'basic' | 'pcf' | 'vsm';
|
|
1165
1339
|
/** Current ground */
|
|
1166
1340
|
ground: Ground;
|
|
@@ -1195,6 +1369,12 @@ export declare class Engine {
|
|
|
1195
1369
|
* A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
|
|
1196
1370
|
*/
|
|
1197
1371
|
readonly moduleStates: Record<string, 'registered' | 'initializing' | 'running' | 'failed' | 'disposed'>;
|
|
1372
|
+
/**
|
|
1373
|
+
* What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas).
|
|
1374
|
+
* 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
|
|
1375
|
+
* @example engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']
|
|
1376
|
+
*/
|
|
1377
|
+
catalog(id?: string | { find?: string }): any;
|
|
1198
1378
|
/**
|
|
1199
1379
|
* Gameplay error in development / testing (module hooks, onFixed / onFrame / clock callbacks, event listeners): { where (location of the error),
|
|
1200
1380
|
* message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
|
|
@@ -1235,6 +1415,8 @@ export declare class Engine {
|
|
|
1235
1415
|
readonly loading: Loading;
|
|
1236
1416
|
/** Post-processing: named effects in slots (add / get / enable / list) */
|
|
1237
1417
|
post: PostFX;
|
|
1418
|
+
/** Every look in one place: engine.look.<part>.set / patch / replace (recipes/52-look.md) */
|
|
1419
|
+
look: Look;
|
|
1238
1420
|
/** UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md) */
|
|
1239
1421
|
ui: UIParts;
|
|
1240
1422
|
/** Automatic resolution state */
|
|
@@ -1246,8 +1428,12 @@ export declare class Engine {
|
|
|
1246
1428
|
cpuMs: number;
|
|
1247
1429
|
/** cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks */
|
|
1248
1430
|
cpuPhases: { fixed: number; frame: number; render: number; afterRender: number };
|
|
1249
|
-
/**
|
|
1431
|
+
/** The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Assigning { owner } / null is the old alias of takeCamera */
|
|
1250
1432
|
cameraOverride: CameraOverride | null;
|
|
1433
|
+
/** 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 */
|
|
1434
|
+
takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>): OwnerHandle;
|
|
1435
|
+
/** Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is */
|
|
1436
|
+
readonly runState: RunState;
|
|
1251
1437
|
/** Draco/KTX2 decoder directory */
|
|
1252
1438
|
decoders: string;
|
|
1253
1439
|
/** Game clock: game seconds now, after / every (clock-time / season timers are on engine.sky) */
|
|
@@ -1269,6 +1455,8 @@ export declare class Engine {
|
|
|
1269
1455
|
threads: Threads;
|
|
1270
1456
|
/** One entry point for actions players and NPCs decide to do: define / run / can / list / recent, see Ops and recipes/23-ops.md */
|
|
1271
1457
|
ops: Ops;
|
|
1458
|
+
/** Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md) */
|
|
1459
|
+
views: Views;
|
|
1272
1460
|
/** Fixed-step count (the gameplay timeline: does not advance while frozen; commits due times, event history and the operation log use it) */
|
|
1273
1461
|
readonly tick: number;
|
|
1274
1462
|
/** Seeded random numbers (use for gameplay randomness: reproducible and saved with the game) */
|
|
@@ -1363,8 +1551,8 @@ export declare class Engine {
|
|
|
1363
1551
|
photo?: Photo;
|
|
1364
1552
|
/** Ambience (ambience() module) */
|
|
1365
1553
|
ambience?: Ambience;
|
|
1366
|
-
/**
|
|
1367
|
-
debug
|
|
1554
|
+
/** Diagnostic overrides and view modes with an owner (override / clear / view: core, always there); panel is the F3 panel, null without the debug() module */
|
|
1555
|
+
debug: DebugOverrides & { panel: DebugPanel | null };
|
|
1368
1556
|
/** Navmesh (nav() module) */
|
|
1369
1557
|
nav?: Nav;
|
|
1370
1558
|
/** HLOD, merged distant geometry (hlod() module) @experimental */
|
|
@@ -1460,15 +1648,7 @@ export declare class Engine {
|
|
|
1460
1648
|
setShadows(on: boolean): void;
|
|
1461
1649
|
/** Fog distance (meters), also adjusts the camera far plane */
|
|
1462
1650
|
setFogFar(d: number): void;
|
|
1463
|
-
/**
|
|
1464
|
-
setToneMapping(kind: 'aces' | 'agx' | 'neutral' | 'none'): void;
|
|
1465
|
-
/**
|
|
1466
|
-
* Exposure at run time: a number, [[time 0-1, exposure], ...] over the day or (sky) => number (both evaluated by the sky module each frame);
|
|
1467
|
-
* replaces style.exposure
|
|
1468
|
-
* @example engine.setExposure(1.4); engine.setExposure(sky => sky.isDay ? 1 : 1.5);
|
|
1469
|
-
*/
|
|
1470
|
-
setExposure(v: number | [number, number][] | ((sky: any) => number)): void;
|
|
1471
|
-
/** Exposure per frame from style.exposure / setExposure keyframes or function, null for a plain number; the sky module calls it with engine.sky @readonly */
|
|
1651
|
+
/** Exposure per frame from style.exposure / look.tone keyframes or function, null for a plain number; the sky module calls it with engine.sky @readonly */
|
|
1472
1652
|
exposureDriver: ((sky: any) => number) | null;
|
|
1473
1653
|
|
|
1474
1654
|
// ---------- Rays, scenarios ----------
|
|
@@ -1506,18 +1686,20 @@ export declare class Engine {
|
|
|
1506
1686
|
* 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
|
|
1507
1687
|
* pause
|
|
1508
1688
|
*/
|
|
1509
|
-
pause():
|
|
1510
|
-
/** Resume the real-time loop */
|
|
1511
|
-
resume(): this;
|
|
1689
|
+
pause(owner?: string | { owner?: string; kind?: 'test' }, opts?: { kind?: 'test' }): ChainedHandle;
|
|
1690
|
+
/** Resume the real-time loop (only this owner's pause) */
|
|
1691
|
+
resume(owner?: string | { owner?: string }): this;
|
|
1692
|
+
/** Run fn at the start of the next fixed step (via commits); a Promise of fn's value */
|
|
1693
|
+
nextFixed<T>(fn: () => T): Promise<T>;
|
|
1512
1694
|
/**
|
|
1513
1695
|
* Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, the game clock and engine.elapsed all stop), frame
|
|
1514
1696
|
* hooks and rendering continue and the UI works.
|
|
1515
1697
|
* So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's
|
|
1516
1698
|
* name, default 'game'
|
|
1517
1699
|
*/
|
|
1518
|
-
freeze(owner?: string):
|
|
1700
|
+
freeze(owner?: string | { owner?: string; kind?: 'title' }, opts?: { kind?: 'title' }): ChainedHandle;
|
|
1519
1701
|
/** Release the freeze of owner (gameplay resumes only when all freezers are released) */
|
|
1520
|
-
unfreeze(owner?: string): this;
|
|
1702
|
+
unfreeze(owner?: string | { owner?: string }): this;
|
|
1521
1703
|
/** Is anyone freezing gameplay? */
|
|
1522
1704
|
readonly frozen: boolean;
|
|
1523
1705
|
/**
|
|
@@ -1541,6 +1723,18 @@ export declare class Engine {
|
|
|
1541
1723
|
* @example engine.skip({ seconds: 600 })
|
|
1542
1724
|
*/
|
|
1543
1725
|
skip(opts: SkipOptions): Promise<{ seconds: number; clock: string | null; day: number | null } | null>;
|
|
1726
|
+
/**
|
|
1727
|
+
* 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).
|
|
1728
|
+
* @param ignore state paths (or prefixes) not to compare
|
|
1729
|
+
* @returns a = after skip, b = after stepping
|
|
1730
|
+
* @example const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);
|
|
1731
|
+
*/
|
|
1732
|
+
checkSkip(seconds: number, opts?: { ignore?: string[] }): Promise<{ ok: boolean; diffs: { path: string; a: any; b: any }[] }>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Consistency check: save -> load gives the same saved state back (nothing is written to the browser).
|
|
1735
|
+
* @example const r = await engine.checkSave(); if (!r.ok) console.log(r.diffs);
|
|
1736
|
+
*/
|
|
1737
|
+
checkSave(opts?: { ignore?: string[] }): Promise<{ ok: boolean; diffs: { path: string; a: any; b: any }[] }>;
|
|
1544
1738
|
/**
|
|
1545
1739
|
* Call engine.describe(opts?: { radius?: number }) to get the current game state (a plain object, JSON.stringify-able); radius is how far counts as
|
|
1546
1740
|
* "nearby" (meters, default 30).
|
package/types/gameplay.d.ts
CHANGED
|
@@ -545,18 +545,21 @@ export type { Music };
|
|
|
545
545
|
// Characters characters() -> engine.characters, engine.npcs
|
|
546
546
|
// ======================================================================
|
|
547
547
|
|
|
548
|
-
/**
|
|
548
|
+
/**
|
|
549
|
+
* A ready procedural body ({ rig }): root is the root node, body/head optional, limbs are the swinging limbs. A model asset carries the same shape
|
|
550
|
+
* by object name in root.userData.rig ({ body: 'hips', head: 'head', joints: ['armL'], limbs: [{ joint: 'legL', ... }] }), as an asset pack's humanoid does
|
|
551
|
+
*/
|
|
549
552
|
export interface CharacterRig {
|
|
550
553
|
root: Object3D;
|
|
551
554
|
body?: Object3D;
|
|
552
555
|
head?: Object3D;
|
|
553
|
-
/** Named joints, exposed on the character as properties (
|
|
556
|
+
/** Named joints, exposed on the character as properties (a humanoid rig: armL armR legL legR) */
|
|
554
557
|
joints?: Record<string, Object3D>;
|
|
555
558
|
limbs?: { joint: Object3D; offset: number; amp: number; kind: 'arm' | 'leg'; side?: number }[];
|
|
556
559
|
}
|
|
557
560
|
/** Character parameters (shared by the player and NPCs) */
|
|
558
561
|
export interface CharacterOptions {
|
|
559
|
-
/**
|
|
562
|
+
/** Per-character part colors: recolor the body's meshes marked userData.part (a humanoid rig: body, skin, legs, hair); the style tints by material role */
|
|
560
563
|
colors?: { body?: ColorLike; skin?: ColorLike; legs?: ColorLike; hair?: ColorLike };
|
|
561
564
|
/** Walking speed (m/s), default 4.5 */
|
|
562
565
|
speed?: number;
|
|
@@ -587,12 +590,15 @@ export interface CharacterOptions {
|
|
|
587
590
|
/** Whether it can jump, default true */
|
|
588
591
|
canJump?: boolean;
|
|
589
592
|
/**
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
* event 'character:model')
|
|
593
|
+
* The body, one path for every kind: the name of a registered model asset, or what engine.assets.model() returned. A procedural builder name
|
|
594
|
+
* (from an asset pack) is built at once; a file model name shows a gray capsule and swaps in a copy when it loads (Character.ready / whenReady,
|
|
595
|
+
* event 'character:model'). Without model and rig: a gray capsule placeholder (warned once)
|
|
596
|
+
* @example engine.assets.manifest(yourAssets); engine.characters.createPlayer({ model: 'yourBody' }) // a generator or GLB name from an asset pack
|
|
593
597
|
* @example engine.characters.createPlayer({ model: 'hero' }) // after engine.assets.manifest({ models: { hero: '/models/hero.glb' } })
|
|
594
598
|
*/
|
|
595
599
|
model?: Object3D | string | null;
|
|
600
|
+
/** A ready procedural body (CharacterRig), used instead of model (a hand-built guard / pet) */
|
|
601
|
+
rig?: CharacterRig | null;
|
|
596
602
|
/** Action name mapping { idle, walk, run, swim, jump, fall } (shorthand for animation) */
|
|
597
603
|
clips?: { idle?: string; walk?: string; run?: string; swim?: string; jump?: string; fall?: string; drive?: string } | null;
|
|
598
604
|
/** Skeletal animation state machine config (states, blend trees, one-shot actions), see AnimatorOptions */
|
|
@@ -698,6 +704,11 @@ export declare class Character {
|
|
|
698
704
|
exit(): void;
|
|
699
705
|
/** Play a one-shot action (e.g. 'wave'); skipped if the model has no such clip */
|
|
700
706
|
playAction(name: string): void;
|
|
707
|
+
/**
|
|
708
|
+
* 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.
|
|
709
|
+
* @example const h = player.onPose(() => sword.position.copy(hand.getWorldPosition(v)));
|
|
710
|
+
*/
|
|
711
|
+
onPose(fn: (character: Character, dt: number) => void): { remove(): void };
|
|
701
712
|
/**
|
|
702
713
|
* Fully delete this character: exits the vehicle first, releases animation and movement, removes it from the scene and releases geometry and materials
|
|
703
714
|
* (used by npcs.remove / removePlayer)
|
|
@@ -714,6 +725,11 @@ export declare class Character {
|
|
|
714
725
|
* after has it
|
|
715
726
|
*/
|
|
716
727
|
syncRecord(): this;
|
|
728
|
+
/**
|
|
729
|
+
* 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
|
|
730
|
+
* one with 'cancelled'. Transient: not saved, not fast-forwarded by engine.skip
|
|
731
|
+
*/
|
|
732
|
+
walkTo(target: Vector3 | { x: number; z: number } | [number, number, number], opts?: { speed?: number; arrive?: number; turnRate?: number; stuckSeconds?: number; maxRepaths?: number; run?: boolean }): Promise<{ status: 'arrived' | 'noPath' | 'stuck' | 'cancelled' }> & { remove(): void };
|
|
717
733
|
/** Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1), run to run, dt in seconds */
|
|
718
734
|
move(dirX: number, dirZ: number, run: boolean, dt: number, speedOverride?: number): void;
|
|
719
735
|
/** Ground type underfoot ('water' while swimming) */
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/DebugOverrides.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
export class DebugOverrides {
|
|
3
|
+
/** The F3 debug panel (the debug() module), or null when it is not installed @type {any} */
|
|
4
|
+
panel: any;
|
|
5
|
+
/**
|
|
6
|
+
* Diagnostic view: 'albedo' | 'lighting' | 'shadow' | 'normals' to look at one part of the render, 'off' to restore. Temporary and owner-scoped; never saved
|
|
7
|
+
* (describe().render says which view is active, so it is not mistaken for the real look). While one owner's view is on, another owner can neither switch it
|
|
8
|
+
* nor turn it off without force: true; engine.debug.clear(owner) turns that owner's view off too.
|
|
9
|
+
* @example engine.debug.view('normals'); // look at the screenshot, then engine.debug.view('off')
|
|
10
|
+
* @param {'albedo' | 'lighting' | 'shadow' | 'normals' | 'off'} mode @param {{ owner?: string, force?: boolean }} [opts]
|
|
11
|
+
* @returns {{ mode: string, owner: string | null, what?: string, note?: string }}
|
|
12
|
+
*/
|
|
13
|
+
view(mode: "albedo" | "lighting" | "shadow" | "normals" | "off", opts?: {
|
|
14
|
+
owner?: string;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
}): {
|
|
17
|
+
mode: string;
|
|
18
|
+
owner: string | null;
|
|
19
|
+
what?: string;
|
|
20
|
+
note?: string;
|
|
21
|
+
};
|
|
22
|
+
/** The active view ({ mode: 'off', owner: null } when none) @returns {{ mode: string, owner: string | null, what?: string }} */
|
|
23
|
+
viewState(): {
|
|
24
|
+
mode: string;
|
|
25
|
+
owner: string | null;
|
|
26
|
+
what?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Change how an object looks for diagnosis, owned by `owner`. Returns { remove() }. Never saved, never part of the game state; listed in
|
|
30
|
+
* describe().scene.overrides while active. A thing id is remembered as the id: when that thing is removed, or a load replaces it, the override is dropped.
|
|
31
|
+
* @param {string} owner who sets it (a tool or session name); engine.debug.clear(owner) removes all of that owner's overrides
|
|
32
|
+
* @param {string | import('three').Object3D} target a thing id (engine.thing), an object name or any Object3D, or a look part id ('look.tone'): then patch is that part's set() values, written on its debug layer above every game owner
|
|
33
|
+
* @param {{ visible?: boolean, material?: 'flat' | 'wire', apply?: (obj: any) => (() => void) | void }} patch flat = unlit base colour, wire = wireframe, apply = your own change (return its undo)
|
|
34
|
+
* @example const h = engine.debug.override('ai-session', 'windmill', { material: 'flat' }); h.remove(); // or engine.debug.clear('ai-session')
|
|
35
|
+
*/
|
|
36
|
+
override(owner: string, target: string | import("three").Object3D, patch: {
|
|
37
|
+
visible?: boolean;
|
|
38
|
+
material?: "flat" | "wire";
|
|
39
|
+
apply?: (obj: any) => (() => void) | void;
|
|
40
|
+
}): any;
|
|
41
|
+
/**
|
|
42
|
+
* Remove every override of one owner (nothing else), its look-part debug values and its view; returns how many were removed
|
|
43
|
+
* @param {string} owner
|
|
44
|
+
*/
|
|
45
|
+
clear(owner: string): number;
|
|
46
|
+
/** Active overrides as plain data (describe().scene.overrides) */
|
|
47
|
+
overrides(): any[];
|
|
48
|
+
/** Active overrides on one object, for engine.thing(id).explain() */
|
|
49
|
+
overridesOn(obj: any): any[];
|
|
50
|
+
/** Undo everything, drop / restore what the views put back, re-apply */
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
@@ -3,6 +3,49 @@
|
|
|
3
3
|
export class Events {
|
|
4
4
|
/** How many history entries to keep, default 200; 0 records nothing */
|
|
5
5
|
historySize: number;
|
|
6
|
+
/** Cause trace ring size, default 0 = off (no cost). Set e.g. 200 in dev to record which event or op caused which follow-up event; read with trace() */
|
|
7
|
+
traceSize: number;
|
|
8
|
+
/**
|
|
9
|
+
* Verbose trace for one object (needs traceSize > 0): perception queries and state checks that name `obj` === id are recorded in full (misses too), the rest of the world only
|
|
10
|
+
* records what changed. null clears. For "why did this guard not see me": traceFocus('guard-1'), play, then read trace('sight').
|
|
11
|
+
* @param {string | null} id world record id
|
|
12
|
+
* @example engine.events.traceSize = 300; engine.events.traceFocus('guard-1');
|
|
13
|
+
*/
|
|
14
|
+
traceFocus(id: string | null): void;
|
|
15
|
+
/**
|
|
16
|
+
* Add one entry to the cause trace (no-op while traceSize is 0; check `events.traceSize > 0` first to skip building info). Returns its parent id (`ev:<n>`) to pass as info.parent of follow-ups, or null.
|
|
17
|
+
* info: code (failure code), obj (world record id it is about), data (small plain values), verbose (true = only recorded while traceFocus(obj)), parent (default: the event or op running now).
|
|
18
|
+
* The engine notes failed ops (`op:<name>`), collision.lineClear (`sight`) and NPC state changes (`npc:state`); a game's behaviors can note their own, e.g. 'npc:mode' patrol -> investigate.
|
|
19
|
+
* @param {string} name
|
|
20
|
+
* @param {{ code?: string, obj?: string, data?: object, verbose?: boolean, parent?: string }} [info]
|
|
21
|
+
* @returns {string | null}
|
|
22
|
+
* @example if (e.events.traceSize > 0) e.events.note('npc:mode', { obj: rec.id, data: { from: 'patrol', to: 'investigate' } });
|
|
23
|
+
*/
|
|
24
|
+
note(name: string, info?: {
|
|
25
|
+
code?: string;
|
|
26
|
+
obj?: string;
|
|
27
|
+
data?: object;
|
|
28
|
+
verbose?: boolean;
|
|
29
|
+
parent?: string;
|
|
30
|
+
}): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Cause chains (needs traceSize > 0): each emitted event is recorded with parent = the event (`ev:<id>`) or op (`op:<name>#<seq>`) whose handler emitted it, null when
|
|
33
|
+
* it came from outside any. chain lists the causes from the nearest to the root (as far as the ring still holds). For "why did this fire".
|
|
34
|
+
* @param {string} [name] only events of this name
|
|
35
|
+
* Entries also carry code (failure code), obj and data when noted with events.note.
|
|
36
|
+
* @returns {{ id: number, tick: number, name: string, parent: string | null, chain: string[], code?: string, obj?: string, data?: object }[]}
|
|
37
|
+
* @example engine.events.traceSize = 200; engine.ops.run('shop.buy', { item: 'bread' }); engine.events.trace('item:add').at(-1).chain; // ['op:shop.buy#12']
|
|
38
|
+
*/
|
|
39
|
+
trace(name?: string): {
|
|
40
|
+
id: number;
|
|
41
|
+
tick: number;
|
|
42
|
+
name: string;
|
|
43
|
+
parent: string | null;
|
|
44
|
+
chain: string[];
|
|
45
|
+
code?: string;
|
|
46
|
+
obj?: string;
|
|
47
|
+
data?: object;
|
|
48
|
+
}[];
|
|
6
49
|
/**
|
|
7
50
|
* Recent events (old -> new); with name, only that kind: { tick = which fixed step, name, data = summary (simple values only; objects become '…') }. For "why did it not fire", first check whether it happened at all
|
|
8
51
|
* @param {string} [name]
|