threedog 1.1.0 → 1.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/CHANGELOG.md +879 -798
- package/README.md +1 -1
- package/core/assets/Animator.js +41 -3
- package/core/assets/Assets.js +100 -24
- package/core/assets/assetEntry.js +73 -20
- package/core/assets/assetHot.js +68 -16
- package/core/assets/assetLoad.js +6 -6
- package/core/assets/assetLod.js +9 -2
- package/core/assets/assetManifest.js +12 -2
- package/core/assets/assetPart.js +54 -0
- package/core/assets/ik.js +271 -0
- package/core/assets/modelNeeds.js +37 -0
- package/core/assets/namedModel.js +102 -29
- package/core/assets/nodeVisibility.js +15 -0
- package/core/audio/Audio.js +36 -4
- package/core/audio/audioReverb.js +99 -0
- package/core/audio/audioRules.js +1 -1
- package/core/audio/audioVoice.js +1 -1
- package/core/base/Events.js +14 -4
- package/core/base/Random.js +1 -1
- package/core/base/Vars.js +1 -1
- package/core/base/docRef.js +51 -0
- package/core/base/errorCodes.js +178 -126
- package/core/base/errorHints.js +9 -7
- package/core/base/errors.js +25 -10
- package/core/base/events.generated.js +2 -0
- package/core/base/freeParts.js +76 -0
- package/core/base/math.js +28 -0
- package/core/base/sections.js +5 -5
- package/core/base/validate.js +31 -3
- package/core/engine/Engine.js +16 -6
- package/core/engine/Loading.js +5 -3
- package/core/engine/copies.js +1 -1
- package/core/engine/headlessLoad.js +4 -1
- package/core/engine/lifecycle.js +32 -16
- package/core/engine/loop.js +71 -27
- package/core/engine/moduleSlots.js +2 -2
- package/core/engine/moduleTypes.js +3 -3
- package/core/engine/modules.js +65 -39
- package/core/engine/page.js +6 -3
- package/core/engine/services.js +6 -5
- package/core/engine/startup.js +5 -5
- package/core/input/Input.js +28 -14
- package/core/input/inputContext.js +28 -16
- package/core/input/inputKeyboard.js +31 -3
- package/core/input/inputPad.js +4 -0
- package/core/input/inputPointer.js +2 -1
- package/core/input/inputSeat.js +1 -1
- package/core/inspect/Budget.js +109 -19
- package/core/inspect/DebugOverrides.js +28 -4
- package/core/inspect/Describe.js +17 -9
- package/core/inspect/Inspect.js +4 -2
- package/core/inspect/InspectMaterials.js +3 -1
- package/core/inspect/InspectPerf.js +19 -9
- package/core/inspect/InspectScene.js +32 -7
- package/core/inspect/MaterialInfo.js +19 -2
- package/core/inspect/UrlState.js +46 -27
- package/core/inspect/catalog.js +28 -9
- package/core/inspect/debugView.js +2 -1
- package/core/inspect/describeRender.js +25 -13
- package/core/inspect/describeText.js +14 -6
- package/core/inspect/lightWatch.js +1 -1
- package/core/inspect/metadata.generated.js +35 -17
- package/core/inspect/pictureChecks.js +148 -0
- package/core/inspect/pictureMenu.js +84 -0
- package/core/inspect/pictureWriters.js +26 -6
- package/core/inspect/textureBytes.js +12 -2
- package/core/inspect/toolDoor.js +2 -4
- package/core/ops/Ops.js +11 -4
- package/core/ops/holds.js +27 -10
- package/core/ops/opsAtomic.js +15 -7
- package/core/ops/opsGuard.js +2 -2
- package/core/ops/opsRun.js +8 -7
- package/core/ops/sharedPoint.js +72 -21
- package/core/ops/stacks.js +56 -16
- package/core/saves/SaveStore.js +9 -3
- package/core/saves/Saves.js +32 -23
- package/core/saves/saveApply.js +96 -44
- package/core/saves/saveIds.js +1 -1
- package/core/saves/saveVersions.js +7 -5
- package/core/saves/session.js +17 -8
- package/core/saves/stateReplace.js +34 -15
- package/core/scene/Rays.js +52 -10
- package/core/scene/Views.js +13 -7
- package/core/scene/adaptive.js +144 -21
- package/core/scene/drawOnly.js +17 -0
- package/core/scene/gameLights.js +44 -3
- package/core/scene/sceneMethods.js +13 -11
- package/core/scene/stepPoses.js +11 -3
- package/core/scene/targeting.js +5 -3
- package/core/scene/thingOps.js +1 -1
- package/core/scene/tier.js +15 -0
- package/core/stream/Batching.js +30 -7
- package/core/stream/Stream.js +26 -7
- package/core/stream/batchGroups.js +2 -2
- package/core/stream/chunkStream.js +7 -5
- package/core/stream/prepare.js +77 -0
- package/core/time/skip.js +3 -1
- package/core/time/time.js +4 -2
- package/docs/AI.md +82 -83
- package/docs/API.md +16 -16
- package/docs/CODEMAP.md +16 -11
- package/docs/COMMANDS.md +139 -142
- package/docs/CONVENTIONS.md +37 -49
- package/docs/MIGRATING-0.8.md +2 -2
- package/docs/MIGRATING-1.0.md +2 -2
- package/docs/THREE.md +28 -35
- package/docs/api/assets.md +3 -1
- package/docs/api/audio.md +4 -2
- package/docs/api/budget.md +5 -0
- package/docs/api/characters.md +10 -8
- package/docs/api/collision.md +6 -4
- package/docs/api/engine.md +16 -16
- package/docs/api/events.md +3 -2
- package/docs/api/ground.md +6 -5
- package/docs/api/hud.md +4 -2
- package/docs/api/input.md +5 -5
- package/docs/api/particles.md +2 -1
- package/docs/api/photo.md +3 -0
- package/docs/api/post.md +7 -4
- package/docs/api/quests.md +2 -2
- package/docs/api/rays.md +1 -2
- package/docs/api/saves.md +7 -7
- package/docs/api/settings.md +2 -2
- package/docs/api/tools.md +3 -1
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -2
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +16 -17
- package/docs/recipes/02-npc.md +22 -18
- package/docs/recipes/03-items-pickups.md +37 -35
- package/docs/recipes/04-quests.md +15 -10
- package/docs/recipes/05-props-bake.md +101 -95
- package/docs/recipes/06-clock-events.md +28 -28
- package/docs/recipes/07-flow-scenes-pause.md +29 -26
- package/docs/recipes/08-weather-sky.md +52 -64
- package/docs/recipes/09-materials-lights-models.md +26 -17
- package/docs/recipes/10-blender-level.md +15 -10
- package/docs/recipes/11-vehicles.md +12 -7
- package/docs/recipes/12-navmesh.md +44 -26
- package/docs/recipes/13-animation.md +56 -45
- package/docs/recipes/14-custom-module.md +21 -18
- package/docs/recipes/15-perf.md +61 -55
- package/docs/recipes/16-dev-bridge.md +23 -33
- package/docs/recipes/18-world.md +36 -42
- package/docs/recipes/19-shooting-picking.md +20 -15
- package/docs/recipes/20-content-actions-save.md +48 -56
- package/docs/recipes/21-camera.md +45 -54
- package/docs/recipes/22-shop-gold.md +12 -7
- package/docs/recipes/23-ops.md +25 -23
- package/docs/recipes/26-ui-parts.md +67 -47
- package/docs/recipes/27-net.md +12 -7
- package/docs/recipes/28-terrain.md +24 -21
- package/docs/recipes/29-grid.md +32 -27
- package/docs/recipes/30-templates.md +21 -20
- package/docs/recipes/31-audio.md +39 -22
- package/docs/recipes/32-action-game.md +19 -14
- package/docs/recipes/33-stream-sources.md +15 -11
- package/docs/recipes/34-environment-lighting.md +126 -70
- package/docs/recipes/35-picture-from-reference.md +8 -8
- package/docs/recipes/36-ground-plants.md +27 -21
- package/docs/recipes/40-scene.md +19 -28
- package/docs/recipes/43-shader-patches-surfaces.md +15 -12
- package/docs/recipes/44-water-weather-hooks.md +34 -31
- package/docs/recipes/45-cascaded-shadows.md +35 -26
- package/docs/recipes/46-blender-art-route.md +6 -1
- package/docs/recipes/49-game-module-contract.md +13 -8
- package/docs/recipes/50-own-renderer.md +6 -2
- package/docs/recipes/51-capability-catalog.md +15 -8
- package/docs/recipes/52-around-the-picture.md +34 -32
- package/docs/recipes/53-ground-up-close.md +6 -1
- package/docs/recipes/55-mods-time-wrap.md +27 -19
- package/docs/recipes/56-webgpu-tsl.md +74 -43
- package/docs/recipes/57-control.md +18 -13
- package/docs/recipes/58-input.md +26 -16
- package/docs/recipes/59-depth-post-effects.md +8 -3
- package/docs/recipes/60-judge-the-picture.md +9 -8
- package/docs/recipes/61-deploy.md +5 -0
- package/docs/recipes/62-picture-code.md +70 -79
- package/docs/recipes/63-third-person-start.md +47 -45
- package/docs/recipes/64-particles.md +22 -10
- package/docs/recipes/65-swarm.md +18 -13
- package/docs/recipes/66-common-tasks.md +38 -35
- package/examples/action/GAMEMAP.md +2 -3
- package/examples/action/main.js +3 -3
- package/examples/action/picture/lights.js +3 -1
- package/examples/perf-island/GAMEMAP.md +3 -3
- package/examples/perf-island/picture/lights.js +2 -1
- package/examples/plain-picture/GAMEMAP.md +1 -1
- package/examples/rc2d/GAMEMAP.md +1 -1
- package/examples/styletest/GAMEMAP.md +2 -2
- package/examples/styletest/main.js +1 -1
- package/examples/techniques/interior-light/README.md +3 -3
- package/examples/techniques/interior-light/interiorLight.js +2 -4
- package/examples/techniques/interior-light/picture/lights.js +2 -1
- package/examples/techniques/modular-building/picture/lights.js +3 -1
- package/examples/techniques/outlines-and-rim/picture/lights.js +3 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/techniques/procedural-animation/main.js +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +1 -1
- package/examples/world/GAMEMAP.md +2 -3
- package/examples/world/art/humanoid.js +1 -1
- package/examples/world/main.js +6 -3
- package/index.d.ts +2 -2
- package/llms.txt +101 -0
- package/modules/ambience/Ambience.js +21 -5
- package/modules/calendar/index.js +9 -5
- package/modules/calendar/schedule.js +23 -8
- package/modules/camera/FirstPersonCamera.js +3 -1
- package/modules/camera/FollowCamera.js +10 -5
- package/modules/camera/RtsCamera.js +4 -3
- package/modules/camera/common.js +70 -8
- package/modules/camera/contract.js +1 -1
- package/modules/characters/Character.js +16 -10
- package/modules/characters/NPC.js +31 -19
- package/modules/characters/assetModel.js +14 -9
- package/modules/characters/astar.js +6 -1
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +34 -22
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +17 -2
- package/modules/characters/movers/simple.js +1 -1
- package/modules/characters/movers/support.js +16 -7
- package/modules/characters/npcAvoid.js +2 -2
- package/modules/characters/npcSim.js +3 -2
- package/modules/characters/pathAsync.js +24 -8
- package/modules/characters/pathJob.js +1 -1
- package/modules/characters/player.js +10 -9
- package/modules/characters/playerStrings.js +5 -5
- package/modules/characters/proceduralRig.js +5 -5
- package/modules/characters/useModel.js +6 -0
- package/modules/characters/walkTo.js +1 -1
- package/modules/collision/Collision.js +29 -18
- package/modules/collision/grid.js +22 -4
- package/modules/content/index.js +3 -1
- package/modules/content/loader.js +1 -1
- package/modules/content/models.js +82 -33
- package/modules/content/props.js +2 -1
- package/modules/content/rules.js +11 -5
- package/modules/content/templates.js +3 -3
- package/modules/content/words.js +2 -2
- package/modules/debug/DebugPanel.js +9 -9
- package/modules/flow/index.js +9 -6
- package/modules/gameplay/Dialogue.js +34 -20
- package/modules/gameplay/Interactions.js +19 -15
- package/modules/gameplay/Inventory.js +9 -4
- package/modules/gameplay/Quests.js +12 -10
- package/modules/gameplay/pickups.js +23 -11
- package/modules/grid/index.js +1 -1
- package/modules/grid/preview.js +2 -2
- package/modules/grid/tiles.js +1 -1
- package/modules/hlod/index.js +4 -1
- package/modules/hud/index.js +47 -10
- package/modules/hud/parts.js +28 -9
- package/modules/level/geometry.js +8 -3
- package/modules/level/index.js +10 -5
- package/modules/level/load.js +4 -2
- package/modules/lights/sources.js +1 -1
- package/modules/music/Music.js +22 -4
- package/modules/nav/index.js +20 -10
- package/modules/particles/Particles.js +31 -14
- package/modules/particles/effect.js +20 -5
- package/modules/particles/lit.js +72 -0
- package/modules/photo/Photo.js +72 -28
- package/modules/photo/pathTrace.js +106 -0
- package/modules/rigid/RigidBodies.js +23 -14
- package/modules/rigid/Vehicles.js +3 -13
- package/modules/rigid/sync.js +2 -1
- package/modules/settings/Settings.js +52 -20
- package/modules/settings/apply.js +23 -9
- package/modules/settings/sections.js +39 -6
- package/modules/settings/strings.js +2 -0
- package/modules/settings/view.js +19 -3
- package/modules/sky/dome.js +15 -3
- package/modules/sky/environment.js +28 -12
- package/modules/sky/fog.js +1 -1
- package/modules/sky/frame.js +6 -1
- package/modules/sky/shader.js +4 -3
- package/modules/sky/skyModule.js +8 -4
- package/modules/swarm/Swarm.js +1 -1
- package/modules/terrain/ChunkManager.js +61 -15
- package/modules/terrain/chunkJob.js +2 -2
- package/modules/terrain/index.js +20 -5
- package/modules/terrain/terrainEdit.js +8 -4
- package/modules/terrain/terrainTexture.js +4 -2
- package/modules/timeline/Timeline.js +4 -3
- package/modules/timeline/Tween.js +3 -0
- package/modules/timeline/letterbox.js +1 -0
- package/modules/triggers/index.js +36 -17
- package/modules/vegetation/Vegetation.js +81 -19
- package/modules/vegetation/densityMap.js +13 -8
- package/modules/vegetation/draw.js +147 -24
- package/modules/vegetation/groundChunks.js +20 -5
- package/modules/vegetation/index.js +3 -3
- package/modules/vegetation/modelGeometry.js +9 -4
- package/modules/water/Water.js +11 -8
- package/modules/weather/Weather.js +7 -2
- package/modules/weather/shaders.js +25 -5
- package/modules/weather/weatherDraw.js +20 -6
- package/modules/world/World.js +2 -1
- package/modules/world/index.js +2 -2
- package/modules/world/persist.js +6 -2
- package/modules/world/views.js +15 -2
- package/package.json +4 -1
- package/presets.js +5 -5
- package/render/PostFX.js +84 -41
- package/render/backend.js +137 -16
- package/render/cascades.js +3 -1
- package/render/cascades.tsl.js +2 -0
- package/render/daylight.js +7 -1
- package/render/detail.js +7 -4
- package/render/effects.js +27 -8
- package/render/fogLook.js +24 -0
- package/render/fuse.js +5 -2
- package/render/fx/detail.tsl.js +9 -7
- package/render/fx/index.js +7 -2
- package/render/fx/library.tsl.js +1 -0
- package/render/fx/lightShaft.tsl.js +114 -0
- package/render/fx/noise.tsl.js +25 -8
- package/render/fx/objectOrigin.tsl.js +39 -10
- package/render/fx/particles.tsl.js +23 -6
- package/render/fx/patchNodes.tsl.js +17 -12
- package/render/fx/pcss.tsl.js +51 -0
- package/render/fx/postWebGPU.tsl.js +89 -29
- package/render/fx/sky.tsl.js +3 -9
- package/render/fxNumbers.js +10 -4
- package/render/impostor.tsl.js +107 -0
- package/render/lighting.js +33 -1
- package/render/lightmap.js +42 -28
- package/render/lights.js +19 -3
- package/render/materials.js +6 -4
- package/render/mergeCommon.js +4 -1
- package/render/occlusion.js +14 -4
- package/render/patches.js +79 -41
- package/render/postRuns.js +32 -0
- package/render/postWebGL.js +97 -10
- package/render/probes.js +10 -14
- package/render/shaderErrors.js +2 -1
- package/render/shadowCache.tsl.js +33 -5
- package/render/shadows.js +42 -16
- package/render/slots.js +8 -5
- package/render/vertexInputs.js +52 -0
- package/types/core.d.ts +114 -46
- package/types/gameplay.d.ts +56 -23
- package/types/generated/core/audio/Audio.d.ts +27 -1
- package/types/generated/core/base/Random.d.ts +1 -1
- package/types/generated/core/input/Input.d.ts +6 -8
- package/types/generated/core/input/inputSeat.d.ts +1 -1
- package/types/generated/core/inspect/Budget.d.ts +26 -0
- package/types/generated/core/inspect/DebugOverrides.d.ts +0 -2
- package/types/generated/core/saves/Saves.d.ts +10 -7
- package/types/generated/core/saves/session.d.ts +8 -2
- package/types/generated/core/scene/Rays.d.ts +1 -3
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/world/World.d.ts +2 -1
- package/types/generated/render/PostFX.d.ts +35 -9
- package/types/physics.d.ts +796 -764
- package/types/pixel.d.ts +1 -1
- package/types/tsl.d.ts +62 -1
- package/types/world.d.ts +12 -3
- package/ui/Focus.js +7 -5
- package/ui/Parts.js +1 -1
- package/ui/touchPart.js +6 -3
package/types/core.d.ts
CHANGED
|
@@ -86,6 +86,8 @@ export interface EventMap extends GameEvents {
|
|
|
86
86
|
'settings:shadows': [on: boolean];
|
|
87
87
|
/** A value in the settings menu changed (the argument is all setting values) */
|
|
88
88
|
'settings:change': [values: Record<string, any>];
|
|
89
|
+
/** A post effect was added (its name) */
|
|
90
|
+
'post:add': [name: string];
|
|
89
91
|
/** A water body was added */
|
|
90
92
|
'water:add': [body: WaterBody];
|
|
91
93
|
/** A water body was removed */
|
|
@@ -228,11 +230,13 @@ export interface EventMap extends GameEvents {
|
|
|
228
230
|
'net:sync': [{ tick: number; full: boolean }];
|
|
229
231
|
/** 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 */
|
|
230
232
|
'net:result': [{ seq: number; name: string; ok: boolean; code: string | null; value?: any; tick: number }];
|
|
231
|
-
/** A gameplay error in development / testing
|
|
233
|
+
/** A gameplay error: in development / testing gameplay is frozen; a release build keeps running and sends it once per site (engine.error holds the first; error severity levels, see engine.error) */
|
|
232
234
|
'engine:error': [EngineError];
|
|
233
235
|
/** A picture or ui module errored and was disabled (the game continues) */
|
|
234
236
|
'module:disabled': [{ name: string; message: string }];
|
|
235
237
|
'module:restored': [{ modules: any[] }];
|
|
238
|
+
/** An atomic op failed and its parts were put back (its own events already went out and stay): read derived state again. Not sent for a load's rollback (that ends in state:replaced) */
|
|
239
|
+
'op:rolledBack': [{ op: string; parts: number }];
|
|
236
240
|
/** @internal The state was replaced by something other than a step, from any door (core/saves/stateReplace.js); undone: a failed load put the old state back */
|
|
237
241
|
'state:replaced': [{ undone: boolean }];
|
|
238
242
|
/** A character boarded a vehicle */
|
|
@@ -392,7 +396,7 @@ export type SaveTurn = Readonly<object>;
|
|
|
392
396
|
|
|
393
397
|
/** Save provider: save() returns JSON-able data, load(data) reads it back (may return a Promise, e.g. for changing level;
|
|
394
398
|
* later parts wait for it to finish before loading).
|
|
395
|
-
* first: true providers load first (parts such as the level, where the rest only makes sense after it is loaded) */
|
|
399
|
+
* first: true providers load first (parts such as the level, where the rest only makes sense after it is loaded); first may be a number, lower loads earlier, true counts as 0 */
|
|
396
400
|
export interface SaveProvider {
|
|
397
401
|
/** This part's data now: plain data (structuredClone can copy it; no functions, DOM nodes or three objects). It may be the live object the
|
|
398
402
|
* part keeps: the engine copies it for its rollback point before a load, so a load() that writes into that same object can still be undone.
|
|
@@ -402,10 +406,10 @@ export interface SaveProvider {
|
|
|
402
406
|
* turn: this replacement's identity. Pass it on as level.load(x, { turn }) / content.load(x, { turn }): awaited without it, those wait for this load, so for ever (dev warns after 3 s, save-nested) */
|
|
403
407
|
load: (data: any, turn: SaveTurn) => void | Promise<void>;
|
|
404
408
|
/** Load before the other parts (such as the level) */
|
|
405
|
-
first?: boolean;
|
|
406
|
-
/** Join atomic ops: copied before an atomic op runs, put back if it fails (plain data; afterLoad does not run on rollback) */
|
|
409
|
+
first?: boolean | number;
|
|
410
|
+
/** Join atomic ops: copied before an atomic op runs, put back if it fails (plain data; afterLoad does not run on rollback; load() must be synchronous: an async function is refused at define, a returned Promise at rollback as engine-misuse) */
|
|
407
411
|
atomic?: boolean;
|
|
408
|
-
/** Why an atomic op leaves this part alone. Every engine part gives atomic: true or this (rule
|
|
412
|
+
/** Why an atomic op leaves this part alone. Every engine part gives atomic: true or this (rule R67); a game's part may */
|
|
409
413
|
notAtomic?: string;
|
|
410
414
|
/** Dev only: called once start() finished with this part's data in the new-game state, to warn about what should not be there yet (world: records placed by code) */
|
|
411
415
|
checkNewGame?: (data: any) => void;
|
|
@@ -449,6 +453,13 @@ export type AssetEntry = string | ModelBuilder | {
|
|
|
449
453
|
castShadow?: boolean;
|
|
450
454
|
/** Model: see castShadow */
|
|
451
455
|
receiveShadow?: boolean;
|
|
456
|
+
/**
|
|
457
|
+
* Model: one node of the file at url as its own model ('Wall.001', or three's spelling Wall001; a second node of the same name is Fence_1).
|
|
458
|
+
* Placed at the origin, keeping its turn and size; the file loads once for every part. A name the file lacks fails naming the close ones
|
|
459
|
+
*/
|
|
460
|
+
node?: string;
|
|
461
|
+
/** Model: nodes and animation clips the game relies on; `threedog assets check` errors and the load warns (asset-needs) when the file lost one. Optional */
|
|
462
|
+
needs?: { nodes?: string[]; clips?: string[] };
|
|
452
463
|
/** Bake manifest (bake.js) only: 'file' = the baked file is the source of truth (edited in Blender), npm run bake no longer overwrites it */
|
|
453
464
|
source?: 'file';
|
|
454
465
|
/** Preload at startup */
|
|
@@ -552,6 +563,12 @@ export interface Assets {
|
|
|
552
563
|
* @experimental
|
|
553
564
|
*/
|
|
554
565
|
modelNow(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Object3D | null;
|
|
566
|
+
/**
|
|
567
|
+
* The game's setup for every model the engine hands out (assets.model / modelNow / lod, content props and templates, pickups, character bodies, a code-built vegetation model named in define, a level
|
|
568
|
+
* file): runs once per copy, before it is added or drawn. Synchronous; one per engine (a second throws); leaves the root's transform to its placer (dev throws). Copies share materials: map each original to one of yours
|
|
569
|
+
* @example const mine = new Map(); engine.assets.onModel(m => m.traverse(o => { if (o.isMesh) o.material = mine.get(o.material) ?? mine.set(o.material, myLook(o.material)).get(o.material); }));
|
|
570
|
+
*/
|
|
571
|
+
onModel(fn: (model: Object3D, name: string) => void): { remove(): void };
|
|
555
572
|
/** Get the geometry of the first mesh in a model */
|
|
556
573
|
geometry(nameOrUrl: string): Promise<BufferGeometry>;
|
|
557
574
|
/** 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]) */
|
|
@@ -573,9 +590,8 @@ export interface Assets {
|
|
|
573
590
|
*/
|
|
574
591
|
trim(): string[];
|
|
575
592
|
/**
|
|
576
|
-
* Called when an object is fully removed
|
|
577
|
-
*
|
|
578
|
-
* @experimental
|
|
593
|
+
* Called by engine.remove when an object is fully removed: decrements the use count of the model copies under it
|
|
594
|
+
* @internal
|
|
579
595
|
*/
|
|
580
596
|
forget(obj: Object3D): void;
|
|
581
597
|
/** Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20 */
|
|
@@ -719,8 +735,11 @@ export interface AudioVolumeData { base?: number; add?: Record<string, number>;
|
|
|
719
735
|
export type AudioVolume = number | AudioVolumeData | ((e: Engine, ...extra: any[]) => number);
|
|
720
736
|
/** One ambience rule: while `when` holds, `sound` plays at `volume`. With `every` it is a one-shot repeated at random gaps, else a loop */
|
|
721
737
|
export interface AmbienceRule {
|
|
722
|
-
|
|
738
|
+
/** A name from audio.sounds; required unless the rule is a reverb rule */
|
|
739
|
+
sound?: string;
|
|
723
740
|
when?: AudioCondition;
|
|
741
|
+
/** Instead of a sound: the reverb's wet (0-1, or the volume forms) while `when` holds; the highest holding one wins, none gives engine.audio.reverb's own wet back. Not with sound / volume / every / bus @experimental */
|
|
742
|
+
reverb?: number | AudioVolumeData | ((e: Engine, ambience: import('./gameplay').Ambience) => number);
|
|
724
743
|
/** 0-1, data { base, add: { measure: factor }, min, max }, or a function of the moment (e, ambience) => 0-1 (code only) */
|
|
725
744
|
volume?: number | AudioVolumeData | ((e: Engine, ambience: import('./gameplay').Ambience) => number);
|
|
726
745
|
/** Fade seconds when the rule turns on / off (1) */
|
|
@@ -777,6 +796,8 @@ export interface AudioConfig {
|
|
|
777
796
|
* hud.marker show() · update({ x, y, onScreen, arrow, angle, label, icon, distance }) · hide() · dispose() (one per marker)
|
|
778
797
|
* hud.counter update({ id, label, icon, value, max }) · dispose() (one per counter)
|
|
779
798
|
* hud.bar update({ id, label, value, max }) · dispose() (one per bar)
|
|
799
|
+
* hud.button update({ id, label, icon, run, key? }) · dispose() (one per button; call run() on click; key = shown key text)
|
|
800
|
+
* hud.hint update({ id, label, key }) · dispose() (one per key hint; show "key · label", like the interaction prompt)
|
|
780
801
|
* touch show(view) · update(view) TouchView: on-screen stick and action buttons (touch devices / joystick: true)
|
|
781
802
|
* dialogue show() · update(view) · hide() DialogueView (dialogue module)
|
|
782
803
|
* prompt update(view) every frame · hide() PromptView (interactions module)
|
|
@@ -897,7 +918,8 @@ export interface UIParts {
|
|
|
897
918
|
open(name: string, data?: object): boolean;
|
|
898
919
|
/** Close a full-screen part, emits ui:close */
|
|
899
920
|
close(name: string): void;
|
|
900
|
-
/**
|
|
921
|
+
/** Is the part open now */
|
|
922
|
+
isOpen(name: string): boolean;
|
|
901
923
|
/** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle @experimental */
|
|
902
924
|
titleItem(id: string, item: { label: string | ((engine: Engine) => string); run(engine: Engine): any }): { remove(): void };
|
|
903
925
|
/** name -> 'default' | 'custom' | 'off' */
|
|
@@ -916,19 +938,29 @@ export interface UIParts {
|
|
|
916
938
|
/** Conventional names for the picture values only one writer may hold (core/scene/pictureSlots.js), taken with provides like any other slot */
|
|
917
939
|
export type PictureSlot = 'sky' | 'fog' | 'tone' | 'environment' | 'background' | 'sun';
|
|
918
940
|
|
|
919
|
-
/**
|
|
920
|
-
export interface
|
|
941
|
+
/** engine.debug: the core diagnostics (override / clear / view / defineView) plus the F3 panel, null without the debug() module */
|
|
942
|
+
export interface DebugApi extends DebugOverrides { panel: DebugPanel | null }
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Ground provider: whoever provides the ground height is the "terrain" (terrain module, level module, or the default flat y=0).
|
|
946
|
+
* What a ground provider supplies (engine.setGround, ctx.ground.provide, the terrain and level modules): height, slope, type and waterLevel, plus the optional hooks.
|
|
947
|
+
* A game does not call the four samplers on engine.ground: it uses engine.surface / slope / groundType / waterAt / waterLevel, which pick the layer and the water bodies
|
|
948
|
+
*/
|
|
949
|
+
export interface GroundProvider {
|
|
921
950
|
/**
|
|
922
951
|
* Ground height (meters) at (x, z). For multi-layer ground (bridges, caves) pass refY: takes the highest layer not above refY + one step (0.45 m);
|
|
923
|
-
* without it the highest layer is used. Single-layer ground ignores refY
|
|
952
|
+
* without it the highest layer is used. Single-layer ground ignores refY.
|
|
953
|
+
* A game reads it with engine.surface(x, z)
|
|
924
954
|
*/
|
|
925
955
|
height(x: number, z: number, refY?: number): number;
|
|
926
|
-
/** Slope at (x, z) (height difference / horizontal distance) */
|
|
956
|
+
/** Slope at (x, z) (height difference / horizontal distance). A game reads it with engine.slope */
|
|
927
957
|
slope(x: number, z: number, refY?: number): number;
|
|
928
|
-
/** Ground type at (x, z) (landform name, e.g. 'meadow') */
|
|
958
|
+
/** Ground type at (x, z) (landform name, e.g. 'meadow'). A game reads it with engine.groundType */
|
|
929
959
|
type(x: number, z: number, refY?: number): string;
|
|
930
|
-
/** Global water level (meters); -Infinity when there is no water */
|
|
960
|
+
/** Global water level (meters); -Infinity when there is no water. A game reads engine.waterLevel */
|
|
931
961
|
waterLevel: number;
|
|
962
|
+
/** Optional: water surface height at (x, z) when it differs per point (-Infinity = none); replaces waterLevel there. A game reads engine.waterAt */
|
|
963
|
+
water?(x: number, z: number, refY?: number): number;
|
|
932
964
|
/**
|
|
933
965
|
* Is there ground at (x, z). Always true except off the outline of terrain({ shape }), where height is -Infinity and slope 0.
|
|
934
966
|
* @example if (engine.ground.has(x, z)) engine.snapToGround(chest);
|
|
@@ -950,6 +982,18 @@ export interface Ground {
|
|
|
950
982
|
staticVersion?(): number;
|
|
951
983
|
}
|
|
952
984
|
|
|
985
|
+
/** engine.ground: the provider in force. A game samples through engine.surface / slope / groundType / waterLevel; here it uses has() and voidY() */
|
|
986
|
+
export interface Ground extends GroundProvider {
|
|
987
|
+
/** @internal */
|
|
988
|
+
height(x: number, z: number, refY?: number): number;
|
|
989
|
+
/** @internal */
|
|
990
|
+
slope(x: number, z: number, refY?: number): number;
|
|
991
|
+
/** @internal */
|
|
992
|
+
type(x: number, z: number, refY?: number): string;
|
|
993
|
+
/** @internal */
|
|
994
|
+
waterLevel: number;
|
|
995
|
+
}
|
|
996
|
+
|
|
953
997
|
// ======================================================================
|
|
954
998
|
// Module definition
|
|
955
999
|
// ======================================================================
|
|
@@ -986,6 +1030,8 @@ export interface ModuleCtx {
|
|
|
986
1030
|
* @example ctx.whileCompiling(() => { const w = new R.World(g); w.step(); w.free(); })
|
|
987
1031
|
*/
|
|
988
1032
|
whileCompiling(fn: () => void): void;
|
|
1033
|
+
/** Background results that change gameplay take effect on a fixed tick: ctx.commits.request({ apply, fallback, valid }), Commits and CONVENTIONS "Worker results that change gameplay" */
|
|
1034
|
+
readonly commits: Commits;
|
|
989
1035
|
/**
|
|
990
1036
|
* This module puts data into whoever holds that capability: fn runs before the use() of a new holder returns, so the next line can read it whole. Leaves with the module.
|
|
991
1037
|
* A throw fails that use() and the old holder comes back.
|
|
@@ -994,8 +1040,10 @@ export interface ModuleCtx {
|
|
|
994
1040
|
feeds(capability: string, fn: () => void): void;
|
|
995
1041
|
/** engine.ops.define, owned: the op goes when the module goes */
|
|
996
1042
|
ops: { define: Ops['define'] };
|
|
997
|
-
/** engine.saves.
|
|
998
|
-
saves: {
|
|
1043
|
+
/** engine.saves.define, owned: the part goes when the module goes and its data stays in the save as unattached data, handed back to a later install */
|
|
1044
|
+
saves: {
|
|
1045
|
+
define(key: string, provider: SaveProvider): Handle;
|
|
1046
|
+
};
|
|
999
1047
|
/** engine.ui.define, owned: the part is closed and its definition goes when the module goes */
|
|
1000
1048
|
ui: { define(name: string, factory: UIPartFactory, def?: UIPartDef): Handle };
|
|
1001
1049
|
/** engine.stream.addReadyCheck, owned */
|
|
@@ -1009,7 +1057,7 @@ export interface ModuleCtx {
|
|
|
1009
1057
|
* addColliders: more static colliders in engine.ground.forEachCollider, whoever gives the ground.
|
|
1010
1058
|
* @example provides: ['ground'], install(e, ctx) { ctx.ground.provide({ height: (x, z) => 0 }); }
|
|
1011
1059
|
*/
|
|
1012
|
-
ground: { provide(g: Partial<
|
|
1060
|
+
ground: { provide(g: Partial<GroundProvider>): Handle; addColliders(forEach: (x: number, z: number, range: number, fn: (x: number, z: number, r: number) => void) => void): Handle };
|
|
1013
1061
|
}
|
|
1014
1062
|
|
|
1015
1063
|
/** What a module may own (ModuleDef.type; core/engine/moduleTypes.js) */
|
|
@@ -1135,7 +1183,8 @@ export interface ModuleDef<Api = any> {
|
|
|
1135
1183
|
/**
|
|
1136
1184
|
* Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers,
|
|
1137
1185
|
* Audio nodes you connected yourself.
|
|
1138
|
-
* Events, onFixed / onFrame, clock timers, jobs, stream
|
|
1186
|
+
* Events, onFixed / onFrame, clock timers, jobs, stream and ray registrations are reclaimed by the core. GPU memory is its creator's: free what you put in the scene with
|
|
1187
|
+
* ctx.track({ remove: () => engine.remove(mesh) }) (design.md 6.2); DOM listeners
|
|
1139
1188
|
* attached to engine.signal and UI attached to engine.uiRoot are cleaned up automatically too
|
|
1140
1189
|
*/
|
|
1141
1190
|
dispose?(e: Engine): void;
|
|
@@ -1169,12 +1218,12 @@ export interface EngineOptions {
|
|
|
1169
1218
|
* @example createEngine({ canvas, pixelSize: 3 })
|
|
1170
1219
|
*/
|
|
1171
1220
|
pixelSize?: number;
|
|
1172
|
-
/** Automatically lower
|
|
1221
|
+
/** Automatically lower quality when frames cost too much (resolution, and post effects that declare a cheaper or skippable form; engine.adaptive.steps), default true. Never silent: a dev warning once, and engine.budget.notice() */
|
|
1173
1222
|
adaptiveResolution?: boolean;
|
|
1174
1223
|
/** Target frame rate for automatic resolution lowering, default 55 */
|
|
1175
1224
|
targetFps?: number;
|
|
1176
1225
|
/**
|
|
1177
|
-
* All screen UI: replace or turn off any part (loading, toast, title, hud.marker, hud.counter, hud.bar; the default title screen is off), and the look of the
|
|
1226
|
+
* All screen UI: replace or turn off any part (loading, toast, title, hud.marker, hud.counter, hud.bar, hud.button; the default title screen is off), and the look of the
|
|
1178
1227
|
* default parts (theme, css, fonts, templates).
|
|
1179
1228
|
* @example createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })
|
|
1180
1229
|
* @example createEngine({ canvas, ui: { theme: { bg: '#1c140e', accent: '#e8a13a' }, css: '.threedog-prompt{font-size:16px}' } })
|
|
@@ -1199,6 +1248,8 @@ export interface EngineOptions {
|
|
|
1199
1248
|
saveKey?: string;
|
|
1200
1249
|
/** On-screen joystick: 'auto' (only on touch devices) | true | false */
|
|
1201
1250
|
joystick?: 'auto' | boolean;
|
|
1251
|
+
/** While playing (no menu, not paused), keys the game binds do not reach the browser, e.g. Ctrl+S; true by default. In dev builds F5, Ctrl+R, F12 stay the browser's (recipe 58) */
|
|
1252
|
+
blockBrowserKeys?: boolean;
|
|
1202
1253
|
/**
|
|
1203
1254
|
* Headless mode: no real-time loop and no per-frame rendering, advances only on step() (for tests and screenshots). Adding ?threedog-headless to the
|
|
1204
1255
|
* URL also turns it on
|
|
@@ -1513,9 +1564,19 @@ export interface CameraOverride {
|
|
|
1513
1564
|
focus?: Vector3;
|
|
1514
1565
|
[key: string]: any;
|
|
1515
1566
|
}
|
|
1516
|
-
/**
|
|
1567
|
+
/** One step of adaptive quality: 'resolution', 'post.<name>' (that effect's declared cheaper params, no recompile), 'post.<name>.off' (the effect held off: a chain rebuild),
|
|
1568
|
+
* or the game's own knob: down() lowers one notch and returns false at its floor, up() undoes one notch */
|
|
1569
|
+
export type AdaptiveStep = 'resolution' | `post.${string}` | { name: string; down(): boolean | void; up(): void };
|
|
1570
|
+
/** State of automatic quality (resolution first-class, recipe 15 section 4b) */
|
|
1517
1571
|
export interface AdaptiveState { on: boolean; target: number; min: number; max: number; /** The ratio this device or game starts at: the base of the settings presets */ base: number;
|
|
1518
|
-
/** true once the render scale was lowered below max (a dev warning was logged) @experimental */ lowered?: boolean;
|
|
1572
|
+
/** true once the render scale was lowered below max (a dev warning was logged) @experimental */ lowered?: boolean;
|
|
1573
|
+
/**
|
|
1574
|
+
* What may be lowered under load, first lowered first; raised back in reverse. null (default) = every added effect's cheaper params, then 'resolution', then the effects
|
|
1575
|
+
* that declare skipOnLowTier held off. [] or ['resolution'] opts the rest out. engine.budget.notice() says what is lowered now.
|
|
1576
|
+
* @example engine.adaptive.steps = ['resolution', { name: 'grass', down: () => { if (grass.density <= 0.3) return false; grass.density -= 0.2; }, up: () => { grass.density += 0.2; } }];
|
|
1577
|
+
*/
|
|
1578
|
+
steps: AdaptiveStep[] | null;
|
|
1579
|
+
[key: string]: any }
|
|
1519
1580
|
|
|
1520
1581
|
// ======================================================================
|
|
1521
1582
|
// Shadows: engine.shadows (recipes/45-cascaded-shadows.md)
|
|
@@ -1688,7 +1749,7 @@ export declare class Engine {
|
|
|
1688
1749
|
*/
|
|
1689
1750
|
readonly movement: Readonly<MovementProfile>;
|
|
1690
1751
|
/**
|
|
1691
|
-
* The player (exists only after characters.
|
|
1752
|
+
* The player (exists only after characters.addPlayer()). Its position belongs to the character's mover: other systems request movement (placeAt /
|
|
1692
1753
|
* move / vehicle enter), don't modify position directly
|
|
1693
1754
|
*/
|
|
1694
1755
|
player: Character | null;
|
|
@@ -1717,10 +1778,12 @@ export declare class Engine {
|
|
|
1717
1778
|
/**
|
|
1718
1779
|
* What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas).
|
|
1719
1780
|
* No argument: the short list, an ARRAY of { id, kind, label, ops, saves, ... } (read .id, not Object.keys); a module id / op name: that entry
|
|
1720
|
-
* expanded (null if unknown); { find }: the short list filtered.
|
|
1781
|
+
* expanded (null if unknown); { find }: the short list filtered. 'picture': the picture menu, one row per capability (on now, runs here, cost class,
|
|
1782
|
+
* one way on, recipe, main limit) and the combination checks; o.offered adds effects not in the chain yet (factories with .about).
|
|
1783
|
+
* 'module:<id>' / 'op:<name>' / 'capability:<id>' pick the kind (a bare name tries picture, post, shadows first). recipes/51-capability-catalog.md
|
|
1721
1784
|
* @example engine.catalog().map(s => s.id); engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']
|
|
1722
1785
|
*/
|
|
1723
|
-
catalog(id?: string | { find?: string }): any;
|
|
1786
|
+
catalog(id?: string | { find?: string }, o?: { offered?: any[] }): any;
|
|
1724
1787
|
/**
|
|
1725
1788
|
* Gameplay error in development / testing (module hooks, onFixed / onFrame / clock callbacks, event listeners): { where (location of the error),
|
|
1726
1789
|
* message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
|
|
@@ -1780,7 +1843,6 @@ export declare class Engine {
|
|
|
1780
1843
|
* @example engine.time.channel('enemies'); engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on a channel the game made
|
|
1781
1844
|
* @example engine.mod('time.player', { owner: 'haste', mul: 1.2, for: 5 }) // haste on the player
|
|
1782
1845
|
* @example engine.mod('freeze', { owner: 'pause-menu' }) // pause menu (same as engine.freeze('pause-menu'))
|
|
1783
|
-
* @experimental
|
|
1784
1846
|
*/
|
|
1785
1847
|
mod(name: string, opts: import('./gameplay').ModOptions): import('./gameplay').ModHandle;
|
|
1786
1848
|
/** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) @experimental */
|
|
@@ -1823,7 +1885,7 @@ export declare class Engine {
|
|
|
1823
1885
|
rays: Rays;
|
|
1824
1886
|
/** Frame-spread job scheduler */
|
|
1825
1887
|
jobs: Jobs;
|
|
1826
|
-
/** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...),
|
|
1888
|
+
/** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...). Internal: a module reaches it as ctx.commits, a game as engine.nextFixed @internal */
|
|
1827
1889
|
commits: Commits;
|
|
1828
1890
|
/**
|
|
1829
1891
|
* Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays.
|
|
@@ -1912,7 +1974,7 @@ export declare class Engine {
|
|
|
1912
1974
|
settings?: Settings;
|
|
1913
1975
|
/** Background music (music() module) */
|
|
1914
1976
|
music?: Music;
|
|
1915
|
-
/** Characters:
|
|
1977
|
+
/** Characters: addPlayer() (characters() module) */
|
|
1916
1978
|
characters?: CharactersApi;
|
|
1917
1979
|
/** NPC management (characters() module, npcs on by default) */
|
|
1918
1980
|
npcs?: NPCManager;
|
|
@@ -1935,7 +1997,7 @@ export declare class Engine {
|
|
|
1935
1997
|
/** Ambience (ambience() module) */
|
|
1936
1998
|
ambience?: Ambience;
|
|
1937
1999
|
/** Diagnostic overrides and view modes with an owner (override / clear / view: core, always there); panel is the F3 panel, null without the debug() module */
|
|
1938
|
-
debug:
|
|
2000
|
+
debug: DebugApi;
|
|
1939
2001
|
/** Navmesh (nav() module) */
|
|
1940
2002
|
nav?: Nav;
|
|
1941
2003
|
/** HLOD, merged distant geometry (hlod() module) @experimental */
|
|
@@ -1974,7 +2036,7 @@ export declare class Engine {
|
|
|
1974
2036
|
|
|
1975
2037
|
// ---------- Ground ----------
|
|
1976
2038
|
/** Set the ground (called by the terrain and level modules); missing parts fall back to flat ground */
|
|
1977
|
-
setGround(g: Partial<
|
|
2039
|
+
setGround(g: Partial<GroundProvider>): void;
|
|
1978
2040
|
/**
|
|
1979
2041
|
* Ground height (meters) at (x, z); a position or object also works: engine.surface(mesh.position).
|
|
1980
2042
|
* For multi-layer ground (bridges, caves, interiors) pass a reference height refY: returns the highest layer not above refY + one step (0.45 m), so
|
|
@@ -2037,14 +2099,15 @@ export declare class Engine {
|
|
|
2037
2099
|
*/
|
|
2038
2100
|
onFixed(fn: (dt: number) => void, opts?: { channel?: string, phase?: 'early' | 'late' }): Handle;
|
|
2039
2101
|
/**
|
|
2040
|
-
* Once per frame (dt in frame seconds): animation, camera, UI and UI keys (menus read this frame's latest input). Gameplay keys belong in onFixed.
|
|
2102
|
+
* Once per frame (dt in frame seconds, capped at the fixed step's 0.1 s; 0 on the frame back from a hidden tab): animation, camera, UI and UI keys (menus read this frame's latest input). Gameplay keys belong in onFixed.
|
|
2041
2103
|
* Returns a handle { remove() }
|
|
2042
2104
|
*/
|
|
2043
2105
|
onFrame(fn: (dt: number) => void): Handle;
|
|
2044
2106
|
/**
|
|
2045
2107
|
* Around the main frame render, after the camera update and batching. when 'before' (default): render into your own render target here
|
|
2046
2108
|
* (mirror, minimap, portal, picking); the render target is reset to the screen afterwards. 'after': right after the frame (read pixels).
|
|
2047
|
-
* The main frame render itself stays the engine's (post chain).
|
|
2109
|
+
* The main frame render itself stays the engine's (post chain). fn gets { renderer, scene, camera, dt }: dt is this frame's seconds, the same
|
|
2110
|
+
* value onFrame gets (no performance.now() bookkeeping needed). Returns a handle { remove() }
|
|
2048
2111
|
* @example const rt = new THREE.WebGLRenderTarget(256, 256);
|
|
2049
2112
|
* engine.onRender(({ renderer, scene }) => { renderer.setRenderTarget(rt); renderer.render(scene, mapCam); });
|
|
2050
2113
|
*/
|
|
@@ -2053,7 +2116,8 @@ export declare class Engine {
|
|
|
2053
2116
|
/**
|
|
2054
2117
|
* Draw one picture now, outside the loop, on either renderer. `renderOnce()`: the frame the player sees, onto the canvas through engine.post
|
|
2055
2118
|
* (read the canvas in the same task, as photo mode does). `renderOnce(target)`: that frame through engine.post into a render target (the
|
|
2056
|
-
* canvas's pixels). `renderOnce(target, camera)` with another camera: the scene from that camera, without post
|
|
2119
|
+
* canvas's pixels: tone mapped, in the output color space, display values). `renderOnce(target, camera)` with another camera: the scene from that camera, without post, as three
|
|
2120
|
+
* draws into a target: linear and not tone mapped (right as a texture on a material, which three then tone maps and encodes; read back as image pixels it looks dark). On WebGPURenderer each call is a fresh node frame, so two calls in one task give two pictures (a RenderPipeline draws its scene pass once per frame).
|
|
2057
2121
|
* @example engine.renderOnce(); const url = engine.renderer.domElement.toDataURL('image/png');
|
|
2058
2122
|
* engine.renderOnce(rt, mapCamera); // a minimap / thumbnail into your own render target
|
|
2059
2123
|
*/
|
|
@@ -2115,7 +2179,6 @@ export declare class Engine {
|
|
|
2115
2179
|
/**
|
|
2116
2180
|
* Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it:
|
|
2117
2181
|
* page.waitForFunction(() => window.engine?.stateApplied)
|
|
2118
|
-
* @experimental
|
|
2119
2182
|
*/
|
|
2120
2183
|
readonly stateApplied: boolean;
|
|
2121
2184
|
/** What the URL parameters or the latest applyState could not do, e.g. ?weather=typo. Read it after stateApplied @experimental */
|
|
@@ -2141,12 +2204,12 @@ export declare class Engine {
|
|
|
2141
2204
|
* Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame
|
|
2142
2205
|
* hooks and rendering continue and the UI works.
|
|
2143
2206
|
* So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's
|
|
2144
|
-
* name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; {
|
|
2207
|
+
* name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; { still: true } stops them too (a still)
|
|
2145
2208
|
*/
|
|
2146
|
-
freeze(owner?: string | { owner?: string; kind?: 'title';
|
|
2209
|
+
freeze(owner?: string | { owner?: string; kind?: 'title'; still?: boolean }, opts?: { kind?: 'title'; still?: boolean }): OwnerHandle;
|
|
2147
2210
|
/** Is anyone freezing gameplay? */
|
|
2148
2211
|
readonly frozen: boolean;
|
|
2149
|
-
/** True while a freeze asked for a full still (freeze(owner, {
|
|
2212
|
+
/** True while a freeze asked for a full still (freeze(owner, { still: true })): frame code that moves things reads this, as animation and particles do */
|
|
2150
2213
|
readonly still: boolean;
|
|
2151
2214
|
/**
|
|
2152
2215
|
* Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render),
|
|
@@ -2258,15 +2321,16 @@ export declare class Engine {
|
|
|
2258
2321
|
* An op whose args.id names a world record also says where that record was authored (text ends with "defined in content/props.js:14: edit it there…";
|
|
2259
2322
|
* thing has the rest).
|
|
2260
2323
|
*/
|
|
2261
|
-
explain(q: { op: string; args?: any; actor?: string } | { value: string } | { thing: string | Object3D } | { module: string } | { capability: string } | Record<string, any>): {
|
|
2324
|
+
explain(q: { op: string; args?: any; actor?: string } | { value: string } | { thing: string | Object3D } | { module: string } | { capability: string } | { asset: string } | Record<string, any>): {
|
|
2262
2325
|
ok: boolean; code?: string | null; text: string; detail?: any; recent?: any[]; events?: string[]; thing?: HitThing;
|
|
2263
2326
|
};
|
|
2264
2327
|
/**
|
|
2265
|
-
* Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns
|
|
2266
|
-
*
|
|
2328
|
+
* Module hook timing, on by default in dev builds: pass true to turn on afresh, false to turn off (returns the engine); with no argument returns
|
|
2329
|
+
* { moduleName: { ms (median), mean, p95 } } per frame over the last 300 frame-hook cycles, or null when off. Only the module's own hooks count;
|
|
2330
|
+
* fixed hooks count one fixed step per frame, its dearest (a slow frame's catch-up steps are not the module's cost)
|
|
2267
2331
|
*/
|
|
2268
2332
|
profile(on: boolean): this;
|
|
2269
|
-
profile(): Record<string, number> | null;
|
|
2333
|
+
profile(): Record<string, { ms: number; mean: number; p95: number }> | null;
|
|
2270
2334
|
/**
|
|
2271
2335
|
* Destroy the engine: stop the main loop, call each module's dispose(e) in reverse install order, then reclaim listeners, timers, audio, UI and GPU
|
|
2272
2336
|
* memory (scene, assets cache, post-processing, renderer).
|
|
@@ -2372,7 +2436,9 @@ export interface GameState {
|
|
|
2372
2436
|
* (input.push), gates { action: owners } (input.gate). Every other shared value is in `shared`
|
|
2373
2437
|
*/
|
|
2374
2438
|
holds: { halt?: any[]; freeze?: any[]; camera?: any[]; debugView?: any[]; input?: { context: string; owner: string; pass: boolean }[];
|
|
2375
|
-
gates?: Record<string, string[]>;
|
|
2439
|
+
gates?: Record<string, string[]>;
|
|
2440
|
+
/** Actions of a context on the stack that a pass-through context above shadows (binds the same key), so they do not read: every cause, as input.blockedBy gives it ('shadowed-by:vehicle', ...) */
|
|
2441
|
+
shadowed?: Record<string, string[]>; };
|
|
2376
2442
|
/**
|
|
2377
2443
|
* Every shared value and exclusive slot with entries, one row each ('move.speed[player]' for one record): the value, who decides it, how it
|
|
2378
2444
|
* combined, and everyone else who wants it (hidden: a set above hides theirs).
|
|
@@ -2420,8 +2486,10 @@ export interface GameState {
|
|
|
2420
2486
|
perf: {
|
|
2421
2487
|
fps: number | null; cpuMs: number | null; drawCalls: number; triangles: number; pixelRatio: number;
|
|
2422
2488
|
chunks?: { loaded: number; visible: number; queued: number }; budget?: BudgetReport | null; startup?: StartupReport | null;
|
|
2423
|
-
/** cpuMs
|
|
2424
|
-
cpu?: { fixed: number; frame: number; render: number; afterRender: number } | null;
|
|
2489
|
+
/** cpuMs is the median of the last cpuFrames real-time frames (null while paused, 0 before the first); cpu splits the last frame by phase (null while paused) */
|
|
2490
|
+
cpuFrames?: number; cpu?: { fixed: number; frame: number; render: number; afterRender: number } | null;
|
|
2491
|
+
/** One line when over the game's own budget, slower than its baseline, spiky or at a lowered resolution; null when all is fine (engine.budget.notice()) */
|
|
2492
|
+
notice?: string | null;
|
|
2425
2493
|
/** Cost of applying background results by stage: transit, build, collider, upload, stream (see engine.budget.cost; upload and transit are approximations) */
|
|
2426
2494
|
apply?: Record<string, { n: number; totalMs: number; maxMs: number; frameMs: number; bytes: number }>;
|
|
2427
2495
|
/** Stream registry: registered, built, queued */
|