threedog 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Animator.js +1 -0
- package/core/Assets.js +16 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +14 -3
- package/core/Engine.js +32 -69
- package/core/Events.js +59 -1
- package/core/I18n.js +2 -2
- package/core/Inspect.js +12 -32
- package/core/InspectScene.js +7 -3
- package/core/MaterialInfo.js +32 -0
- package/core/Ops.js +43 -59
- package/core/Saves.js +5 -4
- package/core/UrlState.js +3 -2
- package/core/Vars.js +1 -0
- package/core/Views.js +49 -0
- package/core/actor.js +2 -2
- package/core/assetReport.js +83 -0
- package/core/catalog.js +169 -0
- package/core/checks.js +67 -0
- package/core/claims.js +51 -0
- package/core/debugView.js +76 -0
- package/core/describeRender.js +45 -0
- package/core/describeText.js +11 -4
- package/core/errorCodes.js +33 -0
- package/core/errorHints.js +6 -1
- package/core/holds.js +106 -0
- package/core/lifecycle.js +1 -0
- package/core/lightWatch.js +23 -3
- package/core/look/coreParts.js +112 -0
- package/core/look/layers.js +136 -0
- package/core/look/part.js +173 -0
- package/core/look/report.js +79 -0
- package/core/look/write.js +86 -0
- package/core/loop.js +15 -14
- package/core/modules.js +19 -5
- package/core/opsAtomic.js +31 -0
- package/core/opsCheck.js +25 -14
- package/core/opsFail.js +20 -0
- package/core/opsHistory.js +6 -6
- package/core/opsRun.js +77 -0
- package/core/params.js +132 -0
- package/core/renamed.js +21 -0
- package/core/saveApply.js +2 -2
- package/core/sceneMethods.js +9 -34
- package/core/services.js +73 -0
- package/core/startup.js +3 -1
- package/core/styleParts.js +2 -2
- package/core/thingExplain.js +68 -0
- package/core/thingOps.js +35 -24
- package/core/things.js +15 -1
- package/core/util.js +11 -0
- package/core/validate.js +23 -7
- package/docs/AI.md +83 -109
- package/docs/API.md +7 -8
- package/docs/CODEMAP.md +63 -51
- package/docs/COMMANDS.md +17 -5
- package/docs/CONVENTIONS.md +17 -6
- package/docs/THREE.md +3 -3
- package/docs/api/assets.md +2 -0
- package/docs/api/characters.md +2 -0
- package/docs/api/collision.md +4 -0
- package/docs/api/content.md +1 -0
- package/docs/api/engine.md +20 -11
- package/docs/api/events.md +5 -1
- package/docs/api/post.md +5 -4
- package/docs/api/saves.md +2 -1
- package/docs/api/sky.md +3 -3
- package/docs/api/style.md +3 -3
- package/docs/api/tools.md +2 -0
- package/docs/api/weather.md +1 -1
- package/docs/recipes/02-npc.md +16 -0
- package/docs/recipes/03-items-pickups.md +1 -1
- package/docs/recipes/06-clock-events.md +13 -0
- package/docs/recipes/07-flow-scenes-pause.md +4 -0
- package/docs/recipes/08-weather-sky.md +1 -1
- package/docs/recipes/09-style-pack.md +5 -5
- package/docs/recipes/12-navmesh.md +22 -0
- package/docs/recipes/13-animation.md +3 -0
- package/docs/recipes/15-perf.md +1 -1
- package/docs/recipes/16-dev-bridge.md +51 -17
- package/docs/recipes/21-camera.md +51 -2
- package/docs/recipes/23-ops.md +45 -9
- package/docs/recipes/27-net.md +1 -1
- package/docs/recipes/29-grid.md +1 -1
- package/docs/recipes/34-environment-lighting.md +9 -8
- package/docs/recipes/38-environment-look-hooks.md +8 -6
- package/docs/recipes/40-scene.md +29 -0
- package/docs/recipes/41-thing-registry.md +29 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +2 -0
- package/docs/recipes/44-water-weather-look-hooks.md +6 -4
- package/docs/recipes/45-cascaded-shadows.md +1 -1
- package/docs/recipes/46-blender-art-route.md +22 -0
- package/docs/recipes/48-make-material.md +70 -0
- package/docs/recipes/49-game-module-contract.md +71 -0
- package/docs/recipes/50-own-renderer.md +12 -0
- package/docs/recipes/51-capability-catalog.md +63 -0
- package/docs/recipes/52-look.md +108 -0
- package/examples/action/GAMEMAP.md +5 -5
- package/examples/action/content/index.js +2 -1
- package/examples/action/content/views.js +6 -0
- package/examples/sheepisland/GAMEMAP.md +2 -3
- package/examples/styletest/GAMEMAP.md +3 -3
- package/examples/styletest/main.js +1 -1
- package/examples/styletest/panel.js +3 -3
- package/examples/world/GAMEMAP.md +3 -3
- package/index.d.ts +27 -0
- package/index.js +3 -1
- package/llms.txt +5 -0
- package/modules/ambience/Ambience.js +5 -2
- package/modules/camera/FirstPersonCamera.js +3 -5
- package/modules/camera/FixedCamera.js +19 -12
- package/modules/camera/FollowCamera.js +14 -8
- package/modules/camera/RtsCamera.js +3 -5
- package/modules/camera/common.js +40 -10
- package/modules/camera/index.js +1 -1
- package/modules/camera/projection.js +34 -0
- package/modules/characters/Character.js +29 -17
- package/modules/characters/astar.js +14 -7
- package/modules/characters/index.js +6 -3
- package/modules/characters/movers/simple.js +6 -1
- package/modules/characters/npcSim.js +8 -2
- package/modules/characters/pathAsync.js +12 -6
- package/modules/characters/pathJob.js +2 -1
- package/modules/characters/proceduralRig.js +5 -1
- package/modules/characters/useModel.js +22 -0
- package/modules/characters/walkTo.js +58 -0
- package/modules/collision/Collision.js +102 -4
- package/modules/content/explain.js +13 -0
- package/modules/content/index.js +2 -0
- package/modules/content/loader.js +3 -0
- package/modules/content/rules.js +1 -0
- package/modules/debug/DebugPanel.js +11 -5
- package/modules/entities/Entities.js +6 -2
- package/modules/flow/index.js +5 -2
- package/modules/gameplay/Dialogue.js +5 -2
- package/modules/gameplay/Interactions.js +12 -2
- package/modules/gameplay/Inventory.js +21 -11
- package/modules/gameplay/Quests.js +13 -3
- package/modules/gameplay/pickups.js +5 -3
- package/modules/grid/Layer.js +1 -1
- package/modules/grid/index.js +1 -1
- package/modules/grid/tiles.js +9 -5
- package/modules/hlod/index.js +5 -2
- package/modules/hud/index.js +5 -2
- package/modules/level/index.js +5 -3
- package/modules/lights/index.js +5 -2
- package/modules/music/Music.js +6 -2
- package/modules/nav/index.js +5 -3
- package/modules/net/Client.js +4 -3
- package/modules/net/Host.js +2 -2
- package/modules/net/index.js +5 -3
- package/modules/particles/Particles.js +1 -1
- package/modules/photo/Photo.js +10 -7
- package/modules/rigid/RigidBodies.js +5 -2
- package/modules/settings/Settings.js +6 -3
- package/modules/settings/apply.js +2 -1
- package/modules/sky/Sky.js +21 -19
- package/modules/sky/cascades.js +6 -6
- package/modules/sky/domeLayers.js +1 -1
- package/modules/sky/environment.js +39 -13
- package/modules/sky/fog.js +9 -6
- package/modules/sky/frame.js +4 -3
- package/modules/sky/look.js +3 -2
- package/modules/sky/lookFog.js +80 -0
- package/modules/sky/lookShadow.js +50 -0
- package/modules/sky/lookSky.js +108 -0
- package/modules/sky/shader.js +2 -2
- package/modules/sky/shadow.js +4 -10
- package/modules/sky/skyModule.js +4 -3
- package/modules/terrain/ChunkManager.js +2 -33
- package/modules/terrain/chunkLevels.js +40 -0
- package/modules/terrain/index.js +10 -2
- package/modules/terrain/lookGround.js +61 -0
- package/modules/timeline/Timeline.js +7 -3
- package/modules/timeline/Tween.js +3 -7
- package/modules/timeline/shots.js +6 -4
- package/modules/triggers/index.js +9 -2
- package/modules/vegetation/Vegetation.js +2 -1
- package/modules/vegetation/index.js +6 -3
- package/modules/vegetation/lookWind.js +37 -0
- package/modules/water/Water.js +19 -3
- package/modules/water/look.js +80 -0
- package/modules/weather/Weather.js +22 -31
- package/modules/weather/look.js +75 -0
- package/modules/weather/particles.js +1 -1
- package/modules/weather/strings.js +15 -0
- package/modules/world/explain.js +11 -0
- package/modules/world/index.js +11 -4
- package/modules/world/thingSource.js +44 -0
- package/package.json +1 -1
- package/render/PostFX.js +48 -51
- package/render/effects.js +4 -2
- package/render/fuse.js +12 -0
- package/render/lights.js +4 -2
- package/render/lookSurface.js +161 -0
- package/render/materials.js +27 -10
- package/render/postLook.js +86 -0
- package/render/surface.js +3 -1
- package/types/core.d.ts +216 -24
- package/types/gameplay.d.ts +10 -0
- package/types/generated/core/DebugOverrides.d.ts +52 -0
- package/types/generated/core/Events.d.ts +43 -0
- package/types/generated/core/Ops.d.ts +62 -21
- package/types/generated/core/Saves.d.ts +1 -0
- package/types/generated/core/Views.d.ts +33 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Layer.d.ts +1 -0
- package/types/generated/modules/sky/Sky.d.ts +10 -17
- package/types/generated/modules/weather/Weather.d.ts +5 -15
- package/types/generated/render/PostFX.d.ts +20 -23
- package/types/generated/render/materials.d.ts +10 -0
- package/types/physics.d.ts +8 -0
- package/types/style.d.ts +16 -6
- package/ui/Parts.js +6 -2
- package/ui/UI.js +1 -1
- package/ui/defaults.js +1 -1
- package/docs/api/debug.md +0 -10
|
@@ -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]
|
|
@@ -4,15 +4,21 @@
|
|
|
4
4
|
* Inside an op use ctx.actor (world record id, default engine.actor = 'player'), never engine.player: NPCs and network peers run the same op as themselves.
|
|
5
5
|
*/
|
|
6
6
|
export class Ops {
|
|
7
|
+
/** Counter bumped on each committed op (an op that failed or rolled back does not bump it); every run result carries it, so "did anything change since I looked" is one compare */
|
|
8
|
+
revision: number;
|
|
7
9
|
set historySize(n: number);
|
|
8
10
|
/** History entries kept (ring, default 256); setting it clears the history */
|
|
9
11
|
get historySize(): number;
|
|
10
12
|
/**
|
|
11
13
|
* Register an op. Name it noun.verb. run changes state; can (optional) is read-only and returns true or a reason string; offers (optional) lists the arg sets possible now (for list / describe / the dev bridge `ops` command).
|
|
12
14
|
* args shape types: string number int bool position id any, suffix ? for optional. net: 'peer' lets remote players request it (default: host only);
|
|
15
|
+
* or { type, default, min, max, values, desc } (default is filled in, engine.catalog shows it).
|
|
16
|
+
* atomic: true = world records, inventory containers and vars written by run are rolled back if run fails or throws (events and other state are not; see recipe 23); after(e, args, value, ctx): sound / animation, runs only once the op committed.
|
|
17
|
+
* run (and can) may fail with { ok: false, code, facts, nextActions } (facts: object or list [{ id, field, actual, expected? }]); nextActions are the game's own suggestions.
|
|
13
18
|
* owner (optional, checked by net() for peer requests): args => world record id whose `owner` field must equal the requesting actor.
|
|
14
19
|
* @param {string} name
|
|
15
|
-
*
|
|
20
|
+
* targets (optional): the thing ids, kinds or template names this op is for; engine.thing(id).explain().ops lists it ('*' = any thing).
|
|
21
|
+
* @param {{ run: (e: any, args: any, ctx: OpContext) => any, can?: (e: any, args: any, ctx: OpContext) => true | string | { code: string, facts?: object, nextActions?: { op: string, args?: object }[] }, targets?: string | string[], args?: Record<string, string | { type: string, default?: any, min?: number, max?: number, values?: any[], desc?: string, optional?: boolean }>, offers?: (e: any, ctx: OpContext) => object[], reasons?: Record<string, string>, desc?: string, undo?: (e: any, args: any, value: any) => void, net?: 'peer' | 'local', owner?: (args: any) => string, atomic?: boolean, after?: (e: any, args: any, value: any, ctx: OpContext) => void }} def
|
|
16
22
|
* @returns {{ remove(): void }}
|
|
17
23
|
* @example
|
|
18
24
|
* const PRICE = { bread: 5 };
|
|
@@ -34,28 +40,46 @@ export class Ops {
|
|
|
34
40
|
*/
|
|
35
41
|
define(name: string, def: {
|
|
36
42
|
run: (e: any, args: any, ctx: OpContext) => any;
|
|
37
|
-
can?: (e: any, args: any, ctx: OpContext) => true | string
|
|
38
|
-
|
|
43
|
+
can?: (e: any, args: any, ctx: OpContext) => true | string | {
|
|
44
|
+
code: string;
|
|
45
|
+
facts?: object;
|
|
46
|
+
nextActions?: {
|
|
47
|
+
op: string;
|
|
48
|
+
args?: object;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
targets?: string | string[];
|
|
52
|
+
args?: Record<string, string | {
|
|
53
|
+
type: string;
|
|
54
|
+
default?: any;
|
|
55
|
+
min?: number;
|
|
56
|
+
max?: number;
|
|
57
|
+
values?: any[];
|
|
58
|
+
desc?: string;
|
|
59
|
+
optional?: boolean;
|
|
60
|
+
}>;
|
|
39
61
|
offers?: (e: any, ctx: OpContext) => object[];
|
|
40
62
|
reasons?: Record<string, string>;
|
|
41
63
|
desc?: string;
|
|
42
64
|
undo?: (e: any, args: any, value: any) => void;
|
|
43
65
|
net?: "peer" | "local";
|
|
44
66
|
owner?: (args: any) => string;
|
|
67
|
+
atomic?: boolean;
|
|
68
|
+
after?: (e: any, args: any, value: any, ctx: OpContext) => void;
|
|
45
69
|
}): {
|
|
46
70
|
remove(): void;
|
|
47
71
|
};
|
|
48
72
|
/**
|
|
49
|
-
* Run an op now (synchronously): checks args (dev), calls can, then run, and logs it. Returns { ok: true, value } or { ok: false,
|
|
73
|
+
* Run an op now (synchronously): checks args (dev), calls can, then run, and logs it. Returns { ok: true, value, revision } or { ok: false, code, facts, nextActions, revision } (revision = ops.revision, counts committed ops); can may also return { code, facts?, nextActions? }.
|
|
50
74
|
* Pass a fresh args object each call (it is kept in the history; in dev it is frozen). opts.source: 'player' | 'game' | 'bridge' | 'test' | 'replay' | 'net'
|
|
51
75
|
* (default: 'game' inside a fixed step, 'player' between steps); opts.actor: who does it (world record id, default engine.actor, which is 'player' unless the game hands control elsewhere).
|
|
52
76
|
* @param {string} name
|
|
53
77
|
* @param {object} [args]
|
|
54
78
|
* @param {{ source?: string, actor?: string }} [opts]
|
|
55
|
-
* @returns {{ ok: boolean, value?: any,
|
|
79
|
+
* @returns {{ ok: boolean, value?: any, revision: number, code?: string, facts?: object, nextActions?: { op: string, args?: object }[] }}
|
|
56
80
|
* @example
|
|
57
81
|
* const r = engine.ops.run('shop.buy', { shop: 'bakery', item: 'bread' });
|
|
58
|
-
* if (!r.ok) showHint(engine.t('op.shop.buy.' + r.
|
|
82
|
+
* if (!r.ok) showHint(engine.t('op.shop.buy.' + r.code));
|
|
59
83
|
* // from a fixed step, for an input-driven action: e.ops.run('combat.roll', { dir }, { source: 'player' })
|
|
60
84
|
*/
|
|
61
85
|
run(name: string, args?: object, opts?: {
|
|
@@ -64,31 +88,42 @@ export class Ops {
|
|
|
64
88
|
}): {
|
|
65
89
|
ok: boolean;
|
|
66
90
|
value?: any;
|
|
67
|
-
|
|
91
|
+
revision: number;
|
|
92
|
+
code?: string;
|
|
93
|
+
facts?: object;
|
|
94
|
+
nextActions?: {
|
|
95
|
+
op: string;
|
|
96
|
+
args?: object;
|
|
97
|
+
}[];
|
|
68
98
|
};
|
|
69
99
|
/**
|
|
70
100
|
* Reverse a finished op with the undo(e, args, value) its definition declared: pass the same args and the value run returned.
|
|
71
|
-
* Returns { ok: true }, or { ok: false,
|
|
101
|
+
* Returns { ok: true }, or { ok: false, code: 'noUndo', facts: { op }, nextActions } when the op did not declare undo. The undo runs as an op write (the dev guard stays quiet).
|
|
72
102
|
* @example const r = engine.ops.run('inventory.trade', { take: 'rusty_key', give: 'gold_key' }); engine.ops.undo('inventory.trade', { take: 'rusty_key', give: 'gold_key' }, r.value);
|
|
73
103
|
* @param {string} name
|
|
74
104
|
* @param {object} args
|
|
75
105
|
* @param {any} value
|
|
76
106
|
* @param {{ actor?: string }} [opts]
|
|
77
|
-
* @returns {{ ok: boolean,
|
|
107
|
+
* @returns {{ ok: boolean, code?: string, facts?: object, nextActions?: { op: string, args?: object }[] }}
|
|
78
108
|
*/
|
|
79
109
|
undo(name: string, args: object, value: any, opts?: {
|
|
80
110
|
actor?: string;
|
|
81
111
|
}): {
|
|
82
112
|
ok: boolean;
|
|
83
|
-
|
|
113
|
+
code?: string;
|
|
114
|
+
facts?: object;
|
|
115
|
+
nextActions?: {
|
|
116
|
+
op: string;
|
|
117
|
+
args?: object;
|
|
118
|
+
}[];
|
|
84
119
|
};
|
|
85
120
|
/**
|
|
86
121
|
* Ask without doing: runs only can (no state change, no history). For greying out buttons and input buffers.
|
|
87
122
|
* @param {string} name
|
|
88
123
|
* @param {object} [args]
|
|
89
124
|
* @param {{ actor?: string, source?: string }} [opts]
|
|
90
|
-
* @returns {{ ok: boolean,
|
|
91
|
-
* @example const { ok,
|
|
125
|
+
* @returns {{ ok: boolean, code?: string, facts?: object, nextActions?: { op: string, args?: object }[] }}
|
|
126
|
+
* @example const { ok, code } = engine.ops.can('shop.buy', { shop: 'bakery', item: 'bread' });
|
|
92
127
|
* button.disabled = !ok;
|
|
93
128
|
*/
|
|
94
129
|
can(name: string, args?: object, opts?: {
|
|
@@ -96,14 +131,19 @@ export class Ops {
|
|
|
96
131
|
source?: string;
|
|
97
132
|
}): {
|
|
98
133
|
ok: boolean;
|
|
99
|
-
|
|
134
|
+
code?: string;
|
|
135
|
+
facts?: object;
|
|
136
|
+
nextActions?: {
|
|
137
|
+
op: string;
|
|
138
|
+
args?: object;
|
|
139
|
+
}[];
|
|
100
140
|
};
|
|
101
141
|
/**
|
|
102
142
|
* What exists, or with { available: true } what is possible now: every arg set from each op's offers checked with can
|
|
103
143
|
* (an op with neither offers nor args is checked once with {}; one with args but no offers is skipped, since its args are free-form).
|
|
104
144
|
* @param {{ available?: boolean, actor?: string }} [opts]
|
|
105
|
-
* @returns {{ name: string, desc?: string, args?: any, ok?: boolean,
|
|
106
|
-
* @example engine.ops.list({ available: true }); // [{ name: 'shop.buy', args: { shop: 'bakery', item: 'bread' }, ok: false,
|
|
145
|
+
* @returns {{ name: string, desc?: string, args?: any, atomic: boolean, ok?: boolean, code?: string }[]}
|
|
146
|
+
* @example engine.ops.list({ available: true }); // [{ name: 'shop.buy', args: { shop: 'bakery', item: 'bread' }, ok: false, code: 'noMoney' }, ...]
|
|
107
147
|
*/
|
|
108
148
|
list({ available, actor }?: {
|
|
109
149
|
available?: boolean;
|
|
@@ -112,15 +152,16 @@ export class Ops {
|
|
|
112
152
|
name: string;
|
|
113
153
|
desc?: string;
|
|
114
154
|
args?: any;
|
|
155
|
+
atomic: boolean;
|
|
115
156
|
ok?: boolean;
|
|
116
|
-
|
|
157
|
+
code?: string;
|
|
117
158
|
}[];
|
|
118
159
|
/**
|
|
119
|
-
* Recent history (old -> new), optionally of one op: { seq, tick, phase: 'fixed' | 'between', name, args, source, actor, ok,
|
|
120
|
-
* Consecutive identical failures (same actor, op and
|
|
160
|
+
* Recent history (old -> new), optionally of one op: { seq, tick, phase: 'fixed' | 'between', name, args, source, actor, ok, code, depth, count }.
|
|
161
|
+
* Consecutive identical failures (same actor, op and code) merge into one entry with count.
|
|
121
162
|
* @param {string} [name]
|
|
122
|
-
* @returns {{ seq: number, tick: number, phase: string, name: string, args: any, source: string, actor: string, ok: boolean,
|
|
123
|
-
* @example engine.ops.recent('shop.buy').at(-1); // { tick: 812, phase: 'between', ok: false,
|
|
163
|
+
* @returns {{ seq: number, tick: number, phase: string, name: string, args: any, source: string, actor: string, ok: boolean, code: string | null, depth: number, count: number }[]}
|
|
164
|
+
* @example engine.ops.recent('shop.buy').at(-1); // { tick: 812, phase: 'between', ok: false, code: 'noMoney', ... }
|
|
124
165
|
*/
|
|
125
166
|
recent(name?: string): {
|
|
126
167
|
seq: number;
|
|
@@ -131,7 +172,7 @@ export class Ops {
|
|
|
131
172
|
source: string;
|
|
132
173
|
actor: string;
|
|
133
174
|
ok: boolean;
|
|
134
|
-
|
|
175
|
+
code: string | null;
|
|
135
176
|
depth: number;
|
|
136
177
|
count: number;
|
|
137
178
|
}[];
|
|
@@ -31,6 +31,7 @@ export class Saves {
|
|
|
31
31
|
* shape.
|
|
32
32
|
* A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept).
|
|
33
33
|
* A part registered after a save was loaded (a module installed later) is handed its data from that save at once.
|
|
34
|
+
* atomic: true joins this part to atomic ops: it is copied before an atomic op runs and put back if the op fails (plain data only; afterLoad does not run on rollback).
|
|
34
35
|
* @param {string} key
|
|
35
36
|
* @param {SaveProvider} provider
|
|
36
37
|
* @example
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/Views.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
export class Views {
|
|
3
|
+
/** @param {any} engine */
|
|
4
|
+
constructor(engine: any);
|
|
5
|
+
engine: any;
|
|
6
|
+
map: Map<any, any>;
|
|
7
|
+
current: string;
|
|
8
|
+
/**
|
|
9
|
+
* Declare a view. position and target are [x, y, z]; fov (degrees) is optional (the camera's own when left out). Returns { remove() } (undeclares it).
|
|
10
|
+
* @param {string} name @param {{ position: number[], target?: number[], fov?: number }} v
|
|
11
|
+
* @returns {{ remove(): void }}
|
|
12
|
+
*/
|
|
13
|
+
define(name: string, v: {
|
|
14
|
+
position: number[];
|
|
15
|
+
target?: number[];
|
|
16
|
+
fov?: number;
|
|
17
|
+
}): {
|
|
18
|
+
remove(): void;
|
|
19
|
+
};
|
|
20
|
+
/** @param {string} name */
|
|
21
|
+
has(name: string): boolean;
|
|
22
|
+
/** @returns {string[]} the declared view names */
|
|
23
|
+
list(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Put the camera on a view and keep it there (the camera rigs leave it alone) until release() or the returned handle's remove(); null for an unknown name
|
|
26
|
+
* @param {string} name @returns {{ remove(): void } | null}
|
|
27
|
+
*/
|
|
28
|
+
show(name: string): {
|
|
29
|
+
remove(): void;
|
|
30
|
+
} | null;
|
|
31
|
+
/** Give the camera back (to the previous holder, e.g. a running cutscene, or to the rig) */
|
|
32
|
+
release(): void;
|
|
33
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/debug/DebugPanel.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
/**
|
|
3
|
-
* F3
|
|
3
|
+
* F3 debug panel -> engine.debug.panel: performance panel, settings, stress test. Collapsed by default; F3 shows/hides it; open: true shows it at start. Just do not install it in a release
|
|
4
4
|
* @param {{ open?: boolean }} [opts]
|
|
5
5
|
* @returns {ModuleDef<DebugPanel>}
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ export function debug(opts?: {
|
|
|
8
8
|
open?: boolean;
|
|
9
9
|
}): ModuleDef<DebugPanel>;
|
|
10
10
|
/** @import { ModuleDef } from '../../../core' */
|
|
11
|
-
/** engine.debug (F3 panel) */
|
|
11
|
+
/** engine.debug.panel (F3 panel) */
|
|
12
12
|
export class DebugPanel {
|
|
13
13
|
/** Stress test running (player auto-runs fast) @type {boolean} */
|
|
14
14
|
benchmarking: boolean;
|
|
@@ -53,6 +53,7 @@ export class Layer {
|
|
|
53
53
|
export type LayerOptions = {
|
|
54
54
|
tiles?: boolean | {
|
|
55
55
|
look?: (data: Record<string, any>, cell: [number, number]) => any;
|
|
56
|
+
colors?: Record<string, number | string>;
|
|
56
57
|
lift?: number;
|
|
57
58
|
} | ((engine: any, layer: Layer) => {
|
|
58
59
|
update?: (cells: {
|
|
@@ -33,7 +33,7 @@ export class Sky {
|
|
|
33
33
|
sway: number;
|
|
34
34
|
distance: number;
|
|
35
35
|
};
|
|
36
|
-
/** Current shadow params (change via
|
|
36
|
+
/** Current shadow params (change via look.shadow.set) @readonly @type {SkyShadowParams} */
|
|
37
37
|
readonly shadow: SkyShadowParams;
|
|
38
38
|
/** three's CSM (addons/csm) while shadow.cascades > 1, else null; its lights[0] is sun (recipes/45) @type {any} */
|
|
39
39
|
csm: any;
|
|
@@ -110,14 +110,11 @@ export class Sky {
|
|
|
110
110
|
*/
|
|
111
111
|
onSeason(name: string, fn: (season: string) => void): Handle;
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* radius = edge softness (pcf, vsm; no effect on basic); blurSamples = blur quality (vsm only); cascades 2-4 = cascaded shadows, 1 = off (recipes/45)
|
|
117
|
-
* @param {Partial<SkyShadowParams>} [opts]
|
|
118
|
-
* @returns {this}
|
|
113
|
+
* Renamed in 0.2: throws and names the new call, engine.look.shadow.set(opts) (fields: bias, normalBias, updateEvery, snap, ahead, type, radius, blurSamples, cascades; recipes/45)
|
|
114
|
+
* @param {Partial<SkyShadowParams>} [_opts]
|
|
115
|
+
* @returns {never}
|
|
119
116
|
*/
|
|
120
|
-
setShadow(
|
|
117
|
+
setShadow(_opts?: Partial<SkyShadowParams>): never;
|
|
121
118
|
/**
|
|
122
119
|
* Change shadow resolution (raise temporarily for photo mode)
|
|
123
120
|
* @param {number} n pixels
|
|
@@ -125,20 +122,16 @@ export class Sky {
|
|
|
125
122
|
*/
|
|
126
123
|
setShadowMapSize(n: number): void;
|
|
127
124
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* light from it (no reflections); lower the hemisphere ambient when you turn it on (recipes/09)
|
|
132
|
-
* @example engine.sky.setEnvironment({ source: 'sky', intensity: 0.8 }); engine.sky.setEnvironment(null);
|
|
133
|
-
* @param {{ source?: string | null, intensity?: number, rotation?: number, interval?: number } | null} [opts]
|
|
134
|
-
* @returns {this}
|
|
125
|
+
* Renamed in 0.2: throws and names the new call, engine.look.env.replace(source) then engine.look.env.set({ intensity, rotation, interval })
|
|
126
|
+
* @param {{ source?: string | null, intensity?: number, rotation?: number, interval?: number } | null} [_opts]
|
|
127
|
+
* @returns {never}
|
|
135
128
|
*/
|
|
136
|
-
setEnvironment(
|
|
129
|
+
setEnvironment(_opts?: {
|
|
137
130
|
source?: string | null;
|
|
138
131
|
intensity?: number;
|
|
139
132
|
rotation?: number;
|
|
140
133
|
interval?: number;
|
|
141
|
-
} | null):
|
|
134
|
+
} | null): never;
|
|
142
135
|
/** Environment lighting now: { source, intensity, rotation, interval, builds }, null when off @type {SkyEnvironmentInfo | null} */
|
|
143
136
|
get environment(): SkyEnvironmentInfo | null;
|
|
144
137
|
}
|
|
@@ -29,22 +29,12 @@ export class Weather {
|
|
|
29
29
|
/** Particle systems drawn now: field -> { field, object, uniforms } (rain / snow when the table has them, plus define()) @type {Map<string, any>} */
|
|
30
30
|
systems: Map<string, any>;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
* engine.weather.define('ash', { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 }); // types: { ashfall: { ash: 1, grey: 0.5 } }
|
|
37
|
-
* @param {string} field
|
|
38
|
-
* @param {import('../../../style').StyleWeatherParticles} [spec]
|
|
39
|
-
* @returns {{ field: string, object: THREE.Object3D, uniforms: Record<string, { value: any }> | null }}
|
|
32
|
+
* Renamed in 0.2: throws and names the new call, engine.look.weather.replace({ [field]: spec }) (recipes/44-water-weather-look-hooks.md)
|
|
33
|
+
* @param {string} _field
|
|
34
|
+
* @param {import('../../../style').StyleWeatherParticles} [_spec]
|
|
35
|
+
* @returns {never}
|
|
40
36
|
*/
|
|
41
|
-
define(
|
|
42
|
-
field: string;
|
|
43
|
-
object: THREE.Object3D;
|
|
44
|
-
uniforms: Record<string, {
|
|
45
|
-
value: any;
|
|
46
|
-
}> | null;
|
|
47
|
-
};
|
|
37
|
+
define(_field: string, _spec?: import("../../../style").StyleWeatherParticles): never;
|
|
48
38
|
/**
|
|
49
39
|
* Automatic weather on/off
|
|
50
40
|
* @param {boolean} on
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/render/PostFX.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
export class PostFX {
|
|
3
3
|
/**
|
|
4
|
-
* MSAA on (read-only; switch with post.
|
|
4
|
+
* MSAA on (read-only; switch with post.setAntialias(on))
|
|
5
5
|
* @returns {boolean}
|
|
6
6
|
*/
|
|
7
7
|
get antialias(): boolean;
|
|
@@ -11,40 +11,40 @@ export class PostFX {
|
|
|
11
11
|
*/
|
|
12
12
|
get active(): boolean;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* create: ({ scene, camera, width, height, params }) => new RenderPixelatedPass(params.size, scene, camera),
|
|
19
|
-
* update: (pass, p) => pass.setPixelSize(p.size) });
|
|
20
|
-
* pixels.set({ size: 6 }); pixels.enable(false); pixels.remove();
|
|
21
|
-
* @param {PostEffect} effect
|
|
22
|
-
* @param {{ slot?: PostSlot, order?: number, enabled?: boolean }} [opts]
|
|
23
|
-
* @returns {PostHandle}
|
|
14
|
+
* Renamed in 0.2: throws and names the new call (engine.look.post.patch / engine.look.post.replace, recipes/52-look.md)
|
|
15
|
+
* @param {PostEffect} _effect
|
|
16
|
+
* @param {{ slot?: PostSlot, order?: number, enabled?: boolean }} [_opts]
|
|
17
|
+
* @returns {never}
|
|
24
18
|
* @experimental
|
|
25
19
|
*/
|
|
26
|
-
add(
|
|
20
|
+
add(_effect: PostEffect, _opts?: {
|
|
27
21
|
slot?: PostSlot;
|
|
28
22
|
order?: number;
|
|
29
23
|
enabled?: boolean;
|
|
30
|
-
}):
|
|
24
|
+
}): never;
|
|
31
25
|
/**
|
|
32
|
-
*
|
|
26
|
+
* Read-only record of an added effect (name, slot, order, enabled, params), or undefined. Change one with engine.look.post.set({ 'bloom.strength': 0.6 })
|
|
33
27
|
* @param {string} name
|
|
34
28
|
* @returns {PostHandle | undefined}
|
|
35
29
|
* @experimental
|
|
36
30
|
*/
|
|
37
31
|
get(name: string): PostHandle | undefined;
|
|
38
32
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
33
|
+
* Renamed in 0.2: throws and names the new call (engine.look.post.set({ 'bloom.enabled': on }); MSAA: engine.post.setAntialias(on))
|
|
34
|
+
* @param {string} _name
|
|
35
|
+
* @param {boolean} _on
|
|
36
|
+
* @returns {never}
|
|
37
|
+
* @experimental
|
|
38
|
+
*/
|
|
39
|
+
enable(_name: string, _on: boolean): never;
|
|
40
|
+
/**
|
|
41
|
+
* Turn MSAA (antialiasing of the post chain) on or off. It is a render target setting, not a look part.
|
|
42
|
+
* @example engine.post.setAntialias(false);
|
|
43
43
|
* @param {boolean} on
|
|
44
|
-
* @returns {
|
|
44
|
+
* @returns {void}
|
|
45
45
|
* @experimental
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
setAntialias(on: boolean): void;
|
|
48
48
|
/**
|
|
49
49
|
* Effects in render order: [{ name, slot, order, enabled }]
|
|
50
50
|
* @returns {{ name: string, slot: PostSlot, order: number, enabled: boolean }[]}
|
|
@@ -120,9 +120,6 @@ export type PostHandle = {
|
|
|
120
120
|
readonly order: number;
|
|
121
121
|
readonly enabled: boolean;
|
|
122
122
|
readonly params: Record<string, any>;
|
|
123
|
-
enable(on: boolean): void;
|
|
124
|
-
set(params: Record<string, any>): void;
|
|
125
|
-
remove(): void;
|
|
126
123
|
};
|
|
127
124
|
import type { Engine } from '../../core';
|
|
128
125
|
import * as THREE from 'three';
|
|
@@ -25,6 +25,16 @@ export function makeMaterial(purpose?: string, params?: {
|
|
|
25
25
|
}, engine?: {
|
|
26
26
|
style: any;
|
|
27
27
|
}): THREE.Material;
|
|
28
|
+
export function windCustom({ glsl, uniforms }: {
|
|
29
|
+
glsl: any;
|
|
30
|
+
uniforms: any;
|
|
31
|
+
}): {
|
|
32
|
+
uniforms: Record<string, {
|
|
33
|
+
value: any;
|
|
34
|
+
}>;
|
|
35
|
+
decl: string;
|
|
36
|
+
glsl: any;
|
|
37
|
+
};
|
|
28
38
|
/**
|
|
29
39
|
* Add effects to any material (built-in, from a style pack, or third-party); returns the same material. The one entry for shader effects:
|
|
30
40
|
* wind (sway amplitude; the shadow sways too, nothing else to set up), clouds (drifting cloud shadows, default on; how dark is
|
package/types/physics.d.ts
CHANGED
|
@@ -67,6 +67,12 @@ export interface Collision {
|
|
|
67
67
|
addCircle(position: PositionLike, opts?: CircleColliderOptions): Handle;
|
|
68
68
|
/** Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() } */
|
|
69
69
|
addBox(position: PositionLike, opts?: BoxColliderOptions): Handle;
|
|
70
|
+
/** Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y. A gap between segments is a gate. Returns a handle { remove() } */
|
|
71
|
+
addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?: number; height?: number; y?: number }): Handle;
|
|
72
|
+
/** Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure. bounds skips fn outside it. Returns a handle { remove() } */
|
|
73
|
+
addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds?: { minX: number; maxX: number; minZ: number; maxZ: number } }): Handle;
|
|
74
|
+
/** Is a character of this radius touching addBlocked ground at (x, z) */
|
|
75
|
+
blockedAt(x: number, z: number, radius?: number): boolean;
|
|
70
76
|
/** Add a collider from an object's bounding box, pad expands outward (meters). Returns a handle { remove() } */
|
|
71
77
|
addObject(obj: Object3D, opts?: { pad?: number }): Handle;
|
|
72
78
|
/** Iterate all static colliders added by hand */
|
|
@@ -75,6 +81,8 @@ export interface Collision {
|
|
|
75
81
|
walkable(position: PositionLike, opts?: { radius?: number }): boolean;
|
|
76
82
|
/** walkable with plain numbers, allocating nothing (A* inner loops); radius defaults to engine.movement.radius */
|
|
77
83
|
walkableAt(x: number, z: number, radius?: number): boolean;
|
|
84
|
+
/** Line of sight with height: is the 3D segment a -> b free of boxes, circles and terrain trees? radius fattens the line; addBlocked water is ignored. Give eye heights in a / b */
|
|
85
|
+
lineClear(a: PositionLike, b: PositionLike, opts?: { radius?: number }): boolean;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
// ======================================================================
|
package/types/style.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export interface StyleSky {
|
|
|
145
145
|
skybox?: string;
|
|
146
146
|
/** Shadows: mapSize resolution (pixels), extent coverage (meters), etc., see StyleShadow */
|
|
147
147
|
shadow?: StyleShadow;
|
|
148
|
-
/** Environment lighting (scene.environment), off unless a source is given; see
|
|
148
|
+
/** Environment lighting (scene.environment), off unless a source is given; see engine.look.env. A pack can give defaults, sky({ environment }) overrides */
|
|
149
149
|
environment?: StyleEnvironment;
|
|
150
150
|
/** Fog model and color (default: linear fog in the horizon color); see StyleFog */
|
|
151
151
|
fog?: StyleFog;
|
|
@@ -165,6 +165,12 @@ export interface StyleFog {
|
|
|
165
165
|
color?: 'horizon' | ColorLike | ((sky: any) => ColorLike);
|
|
166
166
|
/** Per meter, exp / exp2 / height (default: derived from engine.fogFar, so fog reaches the same distance as linear); weather fog divides it */
|
|
167
167
|
density?: number;
|
|
168
|
+
/** Linear fog start (meters); default 0.3 x far. Same keys as engine.look.fog.set */
|
|
169
|
+
near?: number;
|
|
170
|
+
/** Linear fog end (meters); default engine.fogFar */
|
|
171
|
+
far?: number;
|
|
172
|
+
/** false: no fog; default true */
|
|
173
|
+
enabled?: boolean;
|
|
168
174
|
/** 'height': world y of the fog floor, default 0 */
|
|
169
175
|
height?: number;
|
|
170
176
|
/** 'height': how fast the fog thins above the floor, per meter, default 0.05 */
|
|
@@ -185,6 +191,8 @@ export interface StyleFog {
|
|
|
185
191
|
* return vec4(uAurora, band * night); }` }]
|
|
186
192
|
*/
|
|
187
193
|
export interface StyleSkyLayer {
|
|
194
|
+
/** The layer's name, the key for engine.look.sky.patch('layer:<name>'); default layer0, layer1 ... by position */
|
|
195
|
+
name?: string;
|
|
188
196
|
/** Defines `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returning (rgb, amount 0..1); renamed per layer, so layers never clash */
|
|
189
197
|
glsl: string;
|
|
190
198
|
/** Custom uniforms (numbers, THREE.Color, [x, y(, z, w)], THREE.Texture), live in engine.sky.dome.material.uniforms */
|
|
@@ -271,10 +279,12 @@ export interface StyleWind {
|
|
|
271
279
|
uniforms?: Record<string, number | number[] | object>;
|
|
272
280
|
}
|
|
273
281
|
|
|
274
|
-
/** engine.sky.shadow: the shadow params in use (
|
|
282
|
+
/** engine.sky.shadow: the shadow params in use (engine.look.shadow.set changes them); field meanings as in StyleShadow */
|
|
275
283
|
export interface SkyShadowParams {
|
|
276
284
|
bias: number; normalBias: number; updateEvery: number; snap: number | 'texel'; ahead: number; type: 'basic' | 'pcf' | 'vsm'; radius: number; blurSamples: number;
|
|
277
285
|
cascades: number; maxFar: number; fade: boolean; lightMargin: number; split: StyleShadow['split'];
|
|
286
|
+
/** Same keys as engine.look.shadow.set */
|
|
287
|
+
mapSize?: number; enabled?: boolean;
|
|
278
288
|
}
|
|
279
289
|
|
|
280
290
|
export interface StyleShadow {
|
|
@@ -343,7 +353,7 @@ export interface StyleWeather {
|
|
|
343
353
|
types?: Record<string, Partial<WeatherPreset>>;
|
|
344
354
|
}
|
|
345
355
|
|
|
346
|
-
/** Falling weather particles: style.weather.rain / snow and engine.weather.
|
|
356
|
+
/** Falling weather particles: style.weather.rain / snow and engine.look.weather.replace({ field: spec }). See recipes/44-water-weather-look-hooks.md */
|
|
347
357
|
/** style.weather.snow: the snow particles' look plus the cover it leaves */
|
|
348
358
|
export interface StyleWeatherSnow extends StyleWeatherParticles {
|
|
349
359
|
/** Snow lying on foliage / ground while it snows (StyleSnowCover); leave out for particles only */
|
|
@@ -395,7 +405,7 @@ export interface StyleWeatherParticles {
|
|
|
395
405
|
glsl?: { vertex?: string; fragment?: string };
|
|
396
406
|
/** Uniforms for your glsl: numbers, colors, [x, y(, z, w)] arrays, textures; live in engine.weather.systems.get(field).uniforms */
|
|
397
407
|
uniforms?: Record<string, any>;
|
|
398
|
-
/** A system of your own instead (engine.weather.
|
|
408
|
+
/** A system of your own instead (engine.look.weather.replace only): the engine adds object, shows it while the amount is above 0.02, calls update */
|
|
399
409
|
create?: (engine: Engine, ctx: { area: number; count: number }) => {
|
|
400
410
|
object: Object3D; update?: (amount: number, ctx: { camera: any; time: number; wind: number }) => void };
|
|
401
411
|
}
|
|
@@ -548,11 +558,11 @@ export interface Style {
|
|
|
548
558
|
name?: string;
|
|
549
559
|
/**
|
|
550
560
|
* Exposure, default 1 (lowpoly: 1.05): a number, or over the day [[time 0-1, exposure], ...] (sorted, wraps across midnight) or (sky) => number,
|
|
551
|
-
* evaluated by the sky module every frame. engine.
|
|
561
|
+
* evaluated by the sky module every frame. engine.look.tone.set changes it at run time
|
|
552
562
|
* @example exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // brighter nights
|
|
553
563
|
*/
|
|
554
564
|
exposure?: number | number[][] | ((sky: any) => number);
|
|
555
|
-
/** Tone mapping
|
|
565
|
+
/** Tone mapping. Engine default 'none' (no style pack, no tone mapping); the style pack picks the look (lowpoly: 'aces') */
|
|
556
566
|
toneMapping?: Loose<'aces' | 'agx' | 'neutral' | 'none'>;
|
|
557
567
|
/** Background color (when there is no sky module) */
|
|
558
568
|
background?: ColorLike;
|