threedog 1.1.0 → 1.3.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 +893 -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 +187 -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 +17 -7
- 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 +8 -7
- 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 +50 -28
- 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 +36 -15
- package/core/scene/adaptive.js +144 -21
- package/core/scene/drawOnly.js +17 -0
- package/core/scene/gameLights.js +47 -4
- 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 +17 -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 +30 -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 +24 -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 +7 -2
- 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 +75 -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 +10 -9
- package/docs/recipes/61-deploy.md +5 -0
- package/docs/recipes/62-picture-code.md +72 -79
- package/docs/recipes/63-third-person-start.md +48 -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/.threedog/content-index.json +1 -1
- 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/.threedog/content-index.json +1 -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/.threedog/content-index.json +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/.threedog/content-index.json +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 +5 -1
- package/presets.js +5 -5
- package/render/PostFX.js +102 -42
- package/render/backend.js +142 -16
- package/render/bindingLimits.js +59 -0
- 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/compareLevel.tsl.js +23 -0
- package/render/fx/detail.tsl.js +9 -7
- package/render/fx/index.js +9 -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 +104 -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 +44 -7
- 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 +115 -47
- 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/core/scene/Views.d.ts +17 -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/gameplay.d.ts
CHANGED
|
@@ -297,6 +297,8 @@ export interface ParticleOptions {
|
|
|
297
297
|
ratePerMeter?: number;
|
|
298
298
|
/** Meters over which a particle fades where it meets what writes depth; default 0, off. Set at define, not in overrides. On WebGLRenderer it costs one depth-only draw of the scene per render while such an effect is on screen @experimental */
|
|
299
299
|
soft?: number;
|
|
300
|
+
/** The scene's lights tint each particle's color (dust a lamp lights): point, spot, directional, ambient, hemisphere, as a matte card facing each light. No shadows, environment map or probes. Default false (the color is drawn as given). Set at define, not in overrides; costs live particles x lights per frame on the CPU, the same on both renderers @experimental */
|
|
301
|
+
lit?: boolean;
|
|
300
302
|
}
|
|
301
303
|
/** Continuous emitter returned by attach() (a handle) */
|
|
302
304
|
export interface ParticleEmitter extends Handle {
|
|
@@ -434,7 +436,7 @@ export interface Settings {
|
|
|
434
436
|
presets: Record<string, QualityPreset>;
|
|
435
437
|
/** Tabs @experimental */
|
|
436
438
|
sections: Map<string, any>;
|
|
437
|
-
/** Whether the menu is open
|
|
439
|
+
/** Whether the menu is open */
|
|
438
440
|
readonly isOpen: boolean;
|
|
439
441
|
/** Read a setting, e.g. get('vol.music') */
|
|
440
442
|
get(key: string): any;
|
|
@@ -444,8 +446,14 @@ export interface Settings {
|
|
|
444
446
|
preset(name: 'low' | 'medium' | 'high' | (string & {})): void;
|
|
445
447
|
/** Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row
|
|
446
448
|
* restricts on the settings layer, like the built-in shadows row: off holds it off (the scene, weather or a cutscene cannot turn it back on),
|
|
447
|
-
* on allows what the scene chose; a number row from 0 to 1 is a factor on a number value. Define it after the effect exists
|
|
448
|
-
|
|
449
|
+
* on allows what the scene chose; a number row from 0 to 1 is a factor on a number value. Define it after the effect exists.
|
|
450
|
+
* The menu draws the row itself in the tab menu names (default 'options', shown while it has a row): a switch for true/false, a slider for a
|
|
451
|
+
* number (min/max; a limits row has 0..1), buttons for options. label: an i18n key or text, else the key. menu: false when your own tab draws it;
|
|
452
|
+
* a row the menu cannot draw, a missing tab or a row drawn twice warns once */
|
|
453
|
+
define<T = any>(key: string, def: T, apply?: ((value: T, e: Engine) => void) | {
|
|
454
|
+
apply?: (value: T, e: Engine) => void; limits?: string | string[];
|
|
455
|
+
menu?: string | false; label?: string; options?: (T | [T, string])[]; min?: number; max?: number; step?: number;
|
|
456
|
+
}): this;
|
|
449
457
|
/** Add a tab of your own, or a built-in / optional one by name: addSection('camera') */
|
|
450
458
|
addSection(id: string, section?: SettingsSection): this;
|
|
451
459
|
open(): void;
|
|
@@ -535,7 +543,7 @@ export interface CharacterOptions {
|
|
|
535
543
|
/**
|
|
536
544
|
* The game's own states on top of the built-in ones (crouch, climb, glide, dash, roll): run after the mover's state each step, return a state name
|
|
537
545
|
* or null to keep facts.base. The state picks the clip like any other (clips: { crouch: 'Crouch' }); speed changes stay engine.mod('move.speed')
|
|
538
|
-
* @example
|
|
546
|
+
* @example addPlayer({ ..., clips: { crouch: 'Crouch' }, states: (c, f) => f.grounded && engine.input.down('crouch') ? 'crouch' : null })
|
|
539
547
|
*/
|
|
540
548
|
states?: CharacterStates | null;
|
|
541
549
|
/** Water depth (meters) at which water counts as deep, default 1 */
|
|
@@ -568,12 +576,14 @@ export interface CharacterOptions {
|
|
|
568
576
|
fall?: false | { belowY: number | ((character: Character) => boolean) };
|
|
569
577
|
/** Time channel its movement and animation follow when the engine drives it (player default 'player', others 'world') */
|
|
570
578
|
channel?: string;
|
|
579
|
+
/** Collider layers it walks through, e.g. ['gate'] (collision.addBox { layer: 'gate' }): its walking, walkTo and NPC paths, navmesh included, follow it. Default: stopped by every collider */
|
|
580
|
+
passes?: string[];
|
|
571
581
|
/**
|
|
572
582
|
* The body, one path for every kind: the name of a registered model asset, or what engine.assets.model() returned. A procedural builder name
|
|
573
583
|
* (from an asset pack) is built at once; a file model name shows a gray capsule and swaps in a copy when it loads (Character.ready / whenReady,
|
|
574
584
|
* event 'character:model'). Without model and rig: a gray capsule placeholder (warned once)
|
|
575
|
-
* @example engine.assets.manifest(yourAssets); engine.characters.
|
|
576
|
-
* @example engine.characters.
|
|
585
|
+
* @example engine.assets.manifest(yourAssets); engine.characters.addPlayer({ model: 'yourBody' }) // a generator or GLB name from an asset pack
|
|
586
|
+
* @example engine.characters.addPlayer({ model: 'hero' }) // after engine.assets.manifest({ models: { hero: '/models/hero.glb' } })
|
|
577
587
|
*/
|
|
578
588
|
model?: Object3D | string | null;
|
|
579
589
|
/** A ready procedural body (CharacterRig), used instead of model (a hand-built guard / pet) */
|
|
@@ -603,7 +613,7 @@ export type MoveRequest = { x: number; y?: number; z: number; run?: boolean } |
|
|
|
603
613
|
* a function returning the move request. The game moving the player itself takes control: engine.control.take(player, { owner, layer: 'script', step })
|
|
604
614
|
*/
|
|
605
615
|
export type PlayerControl = 'camera' | ((player: Character, input: Input, dt: number) => MoveRequest);
|
|
606
|
-
/** Parameters of
|
|
616
|
+
/** Parameters of addPlayer() */
|
|
607
617
|
export interface PlayerOptions extends CharacterOptions {
|
|
608
618
|
/** A further local player's id and world record; left out, the one player (engine.player) */
|
|
609
619
|
id?: string;
|
|
@@ -625,7 +635,7 @@ export type CharacterState = 'idle' | 'walk' | 'run' | 'swim' | 'jump' | 'fall'
|
|
|
625
635
|
/** Character (player and NPCs) */
|
|
626
636
|
export declare class Character {
|
|
627
637
|
constructor(engine: Engine, opts?: CharacterOptions);
|
|
628
|
-
/** Root node: add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it */
|
|
638
|
+
/** Root node, the character's model (there is no character.model; the loaded glTF is a child of root): add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it */
|
|
629
639
|
root: Object3D;
|
|
630
640
|
/** Position (= root.position) */
|
|
631
641
|
readonly position: Vector3;
|
|
@@ -670,6 +680,8 @@ export declare class Character {
|
|
|
670
680
|
fall: false | { belowY: number | ((character: Character) => boolean) };
|
|
671
681
|
/** Time channel the engine drives it on (see CharacterOptions.channel) */
|
|
672
682
|
channel: string;
|
|
683
|
+
/** Collider layers it goes through (the passes option, sorted); undefined = stopped by every collider. Plain: a write counts from its next step and path */
|
|
684
|
+
passes: readonly string[] | undefined;
|
|
673
685
|
/** The character's id, the one form engine.mod / time.local take: its world record id ('player', an NPC's record id), else the id option, else a generated one */
|
|
674
686
|
readonly id: string;
|
|
675
687
|
/**
|
|
@@ -727,7 +739,7 @@ export declare class Character {
|
|
|
727
739
|
dispose(): void;
|
|
728
740
|
/**
|
|
729
741
|
* Request a jump (buffered for jumpBuffer s): the ground jump on the ground or in coyote time, else an air jump while maxJumps allows; air: false = ground only
|
|
730
|
-
* @example
|
|
742
|
+
* @example addPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump
|
|
731
743
|
*/
|
|
732
744
|
jump(opts?: { air?: boolean }): this;
|
|
733
745
|
/** Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z }) */
|
|
@@ -934,10 +946,10 @@ export interface CharactersApi {
|
|
|
934
946
|
*/
|
|
935
947
|
findSpawn(position?: PositionLike, opts?: FindSpawnOptions): Vector3;
|
|
936
948
|
/**
|
|
937
|
-
* Create the player and set engine.player; control is required (no default feel), e.g.
|
|
949
|
+
* Create the player and set engine.player; control is required (no default feel), e.g. addPlayer({ ...presets.player.thirdPerson, spawn }). An
|
|
938
950
|
* existing player is deleted first
|
|
939
951
|
*/
|
|
940
|
-
|
|
952
|
+
addPlayer(opts: PlayerOptions): Character;
|
|
941
953
|
/**
|
|
942
954
|
* The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it
|
|
943
955
|
* inside your own control function to wrap it
|
|
@@ -976,7 +988,7 @@ export interface CharactersApi {
|
|
|
976
988
|
*/
|
|
977
989
|
findPathAsync(
|
|
978
990
|
from: PositionLike, to: PositionLike, done: (path: NavPathPoint[] | null, status: 'ok' | 'noPath' | 'notReady') => void,
|
|
979
|
-
opts?: { radius?: number; step?: number; maxNodes?: number }
|
|
991
|
+
opts?: { radius?: number; passes?: string[]; step?: number; maxNodes?: number }
|
|
980
992
|
): { remove(): void };
|
|
981
993
|
/** How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps */
|
|
982
994
|
pathsPerStep: number;
|
|
@@ -1005,9 +1017,9 @@ export interface CharactersOptions {
|
|
|
1005
1017
|
}
|
|
1006
1018
|
/**
|
|
1007
1019
|
* Pathfinding options: step is the grid size (meters, A*), maxNodes the maximum cells searched (A*), radius the character radius (meters,
|
|
1008
|
-
* default engine.movement.radius); for detailed see findPath
|
|
1020
|
+
* default engine.movement.radius), passes the collider layers the path goes through (collision.addBox { layer }); for detailed see findPath
|
|
1009
1021
|
*/
|
|
1010
|
-
export interface FindPathOptions { step?: number; maxNodes?: number; radius?: number; detailed?: boolean; id?: string }
|
|
1022
|
+
export interface FindPathOptions { step?: number; maxNodes?: number; radius?: number; passes?: string[]; detailed?: boolean; id?: string }
|
|
1011
1023
|
|
|
1012
1024
|
// ======================================================================
|
|
1013
1025
|
// Interactions interactions()
|
|
@@ -1584,10 +1596,11 @@ export interface Quests {
|
|
|
1584
1596
|
state(id: string): { step: number; steps: number; done: boolean; failed: boolean; active: boolean; visited: string[] } | null;
|
|
1585
1597
|
/** Finish the current step from code (its done() is not asked) and go on; the last step completes the quest. false when not active */
|
|
1586
1598
|
advance(id: string): boolean;
|
|
1587
|
-
/**
|
|
1599
|
+
/** Finished (done, not failed) */
|
|
1600
|
+
isDone(id: string): boolean;
|
|
1588
1601
|
/** Started, not done and not failed */
|
|
1589
1602
|
isActive(id: string): boolean;
|
|
1590
|
-
/** Its fail condition held (start(id) begins it again)
|
|
1603
|
+
/** Its fail condition held (start(id) begins it again) */
|
|
1591
1604
|
isFailed(id: string): boolean;
|
|
1592
1605
|
/** Check completion conditions once immediately */
|
|
1593
1606
|
check(): void;
|
|
@@ -1642,6 +1655,8 @@ export interface PhotoShot {
|
|
|
1642
1655
|
url: string; time: string; position: XZ | null;
|
|
1643
1656
|
/** What was in the middle of the frame: name is the name, kind the kind (npc, entity, vegetation...), distance in meters */
|
|
1644
1657
|
subject?: { name: string; kind: string; distance: number } | null;
|
|
1658
|
+
/** Only on a path-traced shot: samples per pixel reached, milliseconds, picture size, and the one line naming what the tracer did not draw as the game does (plus 'no post effects') @experimental */
|
|
1659
|
+
pathTraced?: { samples: number; ms: number; size: [number, number]; untraced: string };
|
|
1645
1660
|
}
|
|
1646
1661
|
export interface PhotoTakeOptions {
|
|
1647
1662
|
/** Resolution multiplier, default 1.6 */
|
|
@@ -1658,6 +1673,8 @@ export interface PhotoTakeOptions {
|
|
|
1658
1673
|
export interface PhotoOptions extends PhotoTakeOptions {
|
|
1659
1674
|
/** How many photos the album keeps at most, default 50 @experimental */
|
|
1660
1675
|
maxAlbum?: number;
|
|
1676
|
+
/** The game's import of its optional path tracer, called on the first photo.trace(): () => import('three-gpu-pathtracer/webgpu') @experimental */
|
|
1677
|
+
pathTracer?: (() => Promise<any>) | null;
|
|
1661
1678
|
}
|
|
1662
1679
|
/** engine.photo */
|
|
1663
1680
|
export interface Photo {
|
|
@@ -1670,6 +1687,11 @@ export interface Photo {
|
|
|
1670
1687
|
/** @experimental */ maxAlbum: number;
|
|
1671
1688
|
/** Capture a photo now without checks. Gameplay takes photos through the op: engine.ops.run('photo.take') (checks canTake, logged) */
|
|
1672
1689
|
take(opts?: PhotoTakeOptions): PhotoShot;
|
|
1690
|
+
/** A path-traced photo (WebGPU backend or a WebGLRenderer; the game's photo({ pathTracer })): samples (whole, >= 1, default 128) accumulate on a snapshot while the game
|
|
1691
|
+
* runs, until seconds (>= 1, default 60); resolves to the shot, rejects naming why. scale defaults to 1 here. The op photo.trace starts it (r.value is this Promise) @experimental */
|
|
1692
|
+
trace(opts?: PhotoTakeOptions & { samples?: number; seconds?: number }): Promise<PhotoShot>;
|
|
1693
|
+
/** While a path-traced photo accumulates: samples per pixel so far and the target; null otherwise @experimental */
|
|
1694
|
+
tracing: { samples: number; of: number } | null;
|
|
1673
1695
|
/** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() @experimental */
|
|
1674
1696
|
subject(): { name: string; kind: string; distance: number } | null;
|
|
1675
1697
|
}
|
|
@@ -1731,6 +1753,8 @@ export interface FocusHandle extends Handle {
|
|
|
1731
1753
|
index: number | null;
|
|
1732
1754
|
/** The choice cursor used confirm on this entry this frame (the owner's own confirm handling skips this frame) */
|
|
1733
1755
|
readonly consumed: boolean;
|
|
1756
|
+
/** This entry is the top of the focus stack (a window over it makes it false: its owner must not read confirm / choice keys then) */
|
|
1757
|
+
readonly onTop: boolean;
|
|
1734
1758
|
/** Change the cursor's controls while pushed (the index starts over); null = no cursor */
|
|
1735
1759
|
setNav(nav: FocusNav | null): void;
|
|
1736
1760
|
}
|
|
@@ -1836,17 +1860,22 @@ export interface Stack {
|
|
|
1836
1860
|
export interface Stacks {
|
|
1837
1861
|
/**
|
|
1838
1862
|
* Define your own point: kind 'number' (default, base 1), 'value' (any data, set only), 'any' (true while held), 'top' (latest holder wins),
|
|
1839
|
-
* 'one' (exclusive slot); per: true = one value per record id; manual = the takeover call the conflict error offers
|
|
1863
|
+
* 'one' (exclusive slot); per: true = one value per record id; manual = the takeover call the conflict error offers;
|
|
1864
|
+
* important: true = always on the "Values being changed now" line (changed()), even at its base
|
|
1840
1865
|
*/
|
|
1841
|
-
define(name: string, opts?: { kind?: 'number' | 'value' | 'any' | 'top' | 'one'; base?: any; min?: number; max?: number; per?: boolean | 'optional'; save?: boolean; manual?: string }): Stack;
|
|
1866
|
+
define(name: string, opts?: { kind?: 'number' | 'value' | 'any' | 'top' | 'one'; base?: any; min?: number; max?: number; per?: boolean | 'optional'; save?: boolean; manual?: string; important?: boolean }): Stack;
|
|
1842
1867
|
get(name: string): Stack;
|
|
1843
1868
|
has(name: string): boolean;
|
|
1844
1869
|
list(): string[];
|
|
1845
|
-
mod(name: string, opts: ModOptions): ModHandle;
|
|
1846
1870
|
/** describe().shared: one row per point with entries */
|
|
1847
1871
|
describe(): Record<string, SharedRow>;
|
|
1848
1872
|
/** Everything one owner changes now, e.g. ['time.world (mul 0.8, effect)', 'inventory (holds)'] */
|
|
1849
1873
|
of(owner: string): string[];
|
|
1874
|
+
/**
|
|
1875
|
+
* The values being changed now, furthest from base first, at most max (default 5): points off their base, capped by a setting, or defined with
|
|
1876
|
+
* { important: true }. describeText's "Values being changed now" line and the dev panel read this.
|
|
1877
|
+
*/
|
|
1878
|
+
changed(max?: number): { name: string; base: any; now: any; how: string; text: string }[];
|
|
1850
1879
|
}
|
|
1851
1880
|
/** engine.time: time channels (world, player, your own). Speeds change only through engine.mod('time.<channel>', ...) */
|
|
1852
1881
|
export interface Time {
|
|
@@ -1873,7 +1902,7 @@ export interface Vars {
|
|
|
1873
1902
|
counters: Record<string, number>;
|
|
1874
1903
|
/** Read a flag */
|
|
1875
1904
|
flag(key: string): any;
|
|
1876
|
-
/** Set a flag (default true)
|
|
1905
|
+
/** Set a flag (default true) */
|
|
1877
1906
|
setFlag(key: string, value?: any): void;
|
|
1878
1907
|
/** Read a counter (0 if none) */
|
|
1879
1908
|
counter(key: string): number;
|
|
@@ -2142,8 +2171,8 @@ export interface Hud {
|
|
|
2142
2171
|
markers: HudMarker[];
|
|
2143
2172
|
/** Add an objective marker: target is an object, position or place name */
|
|
2144
2173
|
marker(target: HudTarget, opts?: HudMarkerOptions): HudMarker;
|
|
2145
|
-
/** Counter or text status (calling again with the same id = update; calling every frame is fine):
|
|
2146
|
-
|
|
2174
|
+
/** Counter or text status, returns { set(value), remove() } (calling again with the same id = update; calling every frame is fine): addCounter('fish', { label: '鱼', value: 2, max: 5 }), addCounter('clock', { value: '08:30' }); no value = the label alone, no label = the value alone (the id is not shown) */
|
|
2175
|
+
addCounter(id: string, opts: { label?: string; icon?: string; value?: number | string; max?: number; anchor?: HudAnchor }): { id: string; set(value: number | string | { label?: string; icon?: string; value?: number | string; max?: number }): void; remove(): void };
|
|
2147
2176
|
/** Add n (default 1) to a number counter, return the new value; one not declared yet starts at 0 with its id as the label */
|
|
2148
2177
|
bump(id: string, n?: number): number;
|
|
2149
2178
|
/** Current value of a counter or bar (number or text), undefined when there is none; reads what interactions.add({ counter }) has added up */
|
|
@@ -2151,7 +2180,11 @@ export interface Hud {
|
|
|
2151
2180
|
/** Progress bar (calling again with the same id = update; calling every frame is fine, the DOM is untouched when the value is unchanged),
|
|
2152
2181
|
* value/max 0–max */
|
|
2153
2182
|
bar(id: string, opts: { value: number; max?: number; label?: string; anchor?: HudAnchor }): void;
|
|
2154
|
-
/**
|
|
2183
|
+
/** Clickable button (calling again with the same id = update): label is text or an i18n key, run() is called on a click / tap. The press never reaches the game and focus goes back to it; a locked mouse has no cursor, so free it first (Esc) */
|
|
2184
|
+
button(id: string, opts: { label: string; run: () => void; icon?: string; anchor?: HudAnchor; action?: string }): void;
|
|
2185
|
+
/** Key hint "E · Talk" (same id = update): the key text is engine.input.label(action) (the input.noKey text when the action needs a key and has none, as in the prompt), so it follows rebinding and keyboard / pad switching; label is text or an i18n key. A button with `action` shows its key too @experimental */
|
|
2186
|
+
hint(id: string, opts: { action: string; label?: string; anchor?: HudAnchor }): void;
|
|
2187
|
+
/** Delete a counter, progress bar, button or key hint */
|
|
2155
2188
|
remove(id: string): void;
|
|
2156
2189
|
}
|
|
2157
2190
|
/**
|
|
@@ -45,6 +45,23 @@ export class Audio {
|
|
|
45
45
|
* @example engine.audio.setVolume('music', 0.3);
|
|
46
46
|
*/
|
|
47
47
|
setVolume(bus: string, v: number): void;
|
|
48
|
+
/**
|
|
49
|
+
* The one reverb: a send/return any bus can feed (a cave, a hall, a bathroom). Off until called: nothing is built or heard before. Each call
|
|
50
|
+
* changes only the keys given (sends merge per bus; 0 stops one); null turns it off. The echo of a bus follows its slider and its ducks, and
|
|
51
|
+
* comes back through master. The impulse is generated (decaying noise, no file): changing size or decay rebuilds it, wet and sends only fade.
|
|
52
|
+
* Called before the first click it waits for audio to unlock. Places: an ambience rule { reverb: 0.6, when: { zone: 'cave' } } sets wet while it holds (recipes/31 §9)
|
|
53
|
+
* @param {{ wet?: number, decay?: number, size?: number, sends?: Record<string, number>, fade?: number } | null} opts wet 0-1 (0.3), decay seconds to -60 dB (2), size 0-1 (0.5), fade seconds
|
|
54
|
+
* @returns {void}
|
|
55
|
+
* @example engine.audio.reverb({ sends: { sfx: 0.5, ambience: 0.8 }, decay: 3, size: 0.8, wet: 0.4 });
|
|
56
|
+
* @experimental
|
|
57
|
+
*/
|
|
58
|
+
reverb(opts: {
|
|
59
|
+
wet?: number;
|
|
60
|
+
decay?: number;
|
|
61
|
+
size?: number;
|
|
62
|
+
sends?: Record<string, number>;
|
|
63
|
+
fade?: number;
|
|
64
|
+
} | null): void;
|
|
48
65
|
/**
|
|
49
66
|
* Lower buses until the handle is removed (dialogue, pause menu, a cutscene). Several ducks stack (their levels multiply).
|
|
50
67
|
* @param {Record<string, number>} levels bus -> multiplier 0-1
|
|
@@ -128,7 +145,8 @@ export class Audio {
|
|
|
128
145
|
/**
|
|
129
146
|
* What is playing (describe().audio shows it while something is ducked or playing): bus levels, the duck multiplier per bus, live voices per sound name.
|
|
130
147
|
* ducks is the level the active ducks ask for (1 = not lowered), read at once even while a fade is still ramping or the audio clock does not run (headless page).
|
|
131
|
-
*
|
|
148
|
+
* reverb (only once reverb() was called): its targets, `place` while an ambience rule sets wet, `built` once audio unlocked.
|
|
149
|
+
* @returns {{ running: boolean, state: string | null, levels: Record<string, number>, ducks: Record<string, number>, voices: Record<string, number>, reverb?: { wet: number, decay: number, size: number, sends: Record<string, number>, place?: number, built: boolean } }}
|
|
132
150
|
* @example engine.audio.duck({ music: 0.3 }); engine.audio.info.ducks.music // 0.3
|
|
133
151
|
*/
|
|
134
152
|
get info(): {
|
|
@@ -137,6 +155,14 @@ export class Audio {
|
|
|
137
155
|
levels: Record<string, number>;
|
|
138
156
|
ducks: Record<string, number>;
|
|
139
157
|
voices: Record<string, number>;
|
|
158
|
+
reverb?: {
|
|
159
|
+
wet: number;
|
|
160
|
+
decay: number;
|
|
161
|
+
size: number;
|
|
162
|
+
sends: Record<string, number>;
|
|
163
|
+
place?: number;
|
|
164
|
+
built: boolean;
|
|
165
|
+
};
|
|
140
166
|
};
|
|
141
167
|
/**
|
|
142
168
|
* Synth building block: a burst of filtered noise (footsteps, shutter, rain, thunder). dur seconds, freq Hz, vol 0-1; out: the node to
|
|
@@ -17,7 +17,7 @@ export class Random {
|
|
|
17
17
|
next(): number;
|
|
18
18
|
/** A decimal between a and b @param {number} a @param {number} b @returns {number} */
|
|
19
19
|
range(a: number, b: number): number;
|
|
20
|
-
/** An integer between a and b (inclusive) @param {number} a @param {number} b @returns {number} @example const dice = engine.random.int(1, 6);
|
|
20
|
+
/** An integer between a and b (inclusive) @param {number} a @param {number} b @returns {number} @example const dice = engine.random.int(1, 6); */
|
|
21
21
|
int(a: number, b: number): number;
|
|
22
22
|
/**
|
|
23
23
|
* Pick one element of the array at random (undefined for an empty array).
|
|
@@ -29,7 +29,7 @@ export class Input {
|
|
|
29
29
|
/** Is this a touch device? @experimental */
|
|
30
30
|
touch: boolean;
|
|
31
31
|
/**
|
|
32
|
-
* Declare an action: its context and display name, never its keys (the game binds those). Modules call ctx.input.
|
|
32
|
+
* Declare an action: its context and display name, never its keys (the game binds those). Modules call ctx.input.define (owned by the module,
|
|
33
33
|
* removed with it); a game's own action can pass keys to declare and bind in one line.
|
|
34
34
|
* context: the input context it is read in (default 'walk'); readable only while that context is on the stack and not shadowed, see push().
|
|
35
35
|
* optional: true = the module works without it (number keys for dialogue choices), so reading it unbound is silent.
|
|
@@ -37,10 +37,10 @@ export class Input {
|
|
|
37
37
|
* @param {string} name
|
|
38
38
|
* @param {{ context?: string, label?: string, optional?: boolean, keys?: string | string[], owner?: string }} [o]
|
|
39
39
|
* @returns {{ name: string, remove(): void }} remove() takes the declaration (and keys given here) away
|
|
40
|
-
* @example ctx.input.
|
|
41
|
-
* @example engine.input.
|
|
40
|
+
* @example ctx.input.define('choice1', { context: 'dialog', label: 'dialogue.choice', optional: true }); // in a module: no keys
|
|
41
|
+
* @example engine.input.define('brake', { context: 'vehicle', keys: ['KeyB', 'PadLT'] }); // a game's own action, bound at once
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
define(name: string, o?: {
|
|
44
44
|
context?: string;
|
|
45
45
|
label?: string;
|
|
46
46
|
optional?: boolean;
|
|
@@ -84,7 +84,7 @@ export class Input {
|
|
|
84
84
|
*/
|
|
85
85
|
simulate(action: string, down?: boolean): void;
|
|
86
86
|
/**
|
|
87
|
-
* A local player's share of the input on a shared screen: its own keys and gamepad, read like engine.input (axis, down, pressed, released). Pass it to
|
|
87
|
+
* A local player's share of the input on a shared screen: its own keys and gamepad, read like engine.input (axis, down, pressed, released). Pass it to addPlayer({ id, input }).
|
|
88
88
|
* pad: gamepad index; that pad leaves engine.input and answers the game's pad bindings here. keys: { action: keys } for this seat alone. Two seats on one pad or key throw `input-seat`.
|
|
89
89
|
* @example const two = engine.input.seat({ pad: 1, keys: { moveForward: 'KeyI', moveBack: 'KeyK', moveLeft: 'KeyJ', moveRight: 'KeyL', jump: 'KeyU' } });
|
|
90
90
|
* @param {{ pad?: number, keys?: Record<string, string | string[]> }} [opts] @returns {Seat}
|
|
@@ -106,7 +106,6 @@ export class Input {
|
|
|
106
106
|
/**
|
|
107
107
|
* All keys bound to an action: the player's rebinding, else the game's bind, else the default preset (basics only); plus its touch button
|
|
108
108
|
* @param {string} action @returns {readonly string[]}
|
|
109
|
-
* @experimental
|
|
110
109
|
*/
|
|
111
110
|
keysOf(action: string): readonly string[];
|
|
112
111
|
/**
|
|
@@ -131,7 +130,6 @@ export class Input {
|
|
|
131
130
|
/**
|
|
132
131
|
* Just released (which copy is read is the same as pressed; for things like release-to-fire after charging) @param {string} action @returns {boolean}
|
|
133
132
|
* @example if (engine.input.released('fire')) shoot(charge);
|
|
134
|
-
* @experimental
|
|
135
133
|
*/
|
|
136
134
|
released(action: string): boolean;
|
|
137
135
|
/**
|
|
@@ -143,7 +141,7 @@ export class Input {
|
|
|
143
141
|
* Push an input context (an action group, like a Unity Action Map). The top context shadows lower actions bound to the same key.
|
|
144
142
|
* Opaque by default (nothing below is readable: menus, dialogue, cutscenes); { pass: true } lets unrelated lower actions keep working (vehicle, build mode).
|
|
145
143
|
* Applies at the start of the next fixed step; actions it blocks lose their held state (no stuck keys after a menu closes). Join a context with
|
|
146
|
-
* input.
|
|
144
|
+
* input.define(name, { context }); menu keys: pressedRaw.
|
|
147
145
|
* @param {string} name e.g. 'vehicle', 'dialog', 'menu', 'cutscene', 'build' (the base context is 'walk')
|
|
148
146
|
* owner (default the name) is who pushed it, listed in describe().holds.input
|
|
149
147
|
* @param {{ pass?: boolean, owner?: string }} [opts]
|
|
@@ -7,7 +7,7 @@ export class Seat {
|
|
|
7
7
|
keys?: Record<string, string | string[]>;
|
|
8
8
|
});
|
|
9
9
|
/** The gamepad index this seat owns, if any @type {number | undefined} */ pad: number | undefined;
|
|
10
|
-
/** Who this seat acts for, as engine.actor for engine.input:
|
|
10
|
+
/** Who this seat acts for, as engine.actor for engine.input: addPlayer sets the player's id; interactions read it. Set it to hand the seat to a vehicle or a squad member @type {string | null} */ actor: string | null;
|
|
11
11
|
/** Same list as engine.input.actions: actions are the game's, a seat only routes them */
|
|
12
12
|
get actions(): any;
|
|
13
13
|
/** Held, as engine.input.down @param {string} action @returns {boolean} */
|
|
@@ -7,6 +7,10 @@ export class Budget {
|
|
|
7
7
|
limits: BudgetLimits;
|
|
8
8
|
/** Cost of applying background results, split in stages (see ApplyCost) */
|
|
9
9
|
cost: ApplyCost;
|
|
10
|
+
/** The recorded run to compare against: { [where]: { drawCalls, triangles, cpuMs?, modules: { name: ms } } } as record() makes it. threedog shot / verify
|
|
11
|
+
* load the game's .threedog/perf-baseline.json (this machine's) here when the game set none (and write it with --save-baseline). null = no comparison
|
|
12
|
+
* @type {Record<string, any> | null} */
|
|
13
|
+
baseline: Record<string, any> | null;
|
|
10
14
|
/**
|
|
11
15
|
* Turn on and set limits (only categories given are checked)
|
|
12
16
|
* @param {BudgetLimits} [limits]
|
|
@@ -53,6 +57,28 @@ export class Budget {
|
|
|
53
57
|
}[];
|
|
54
58
|
/** Current value per category (fps/low1/cpuMs exist only once there are frame times) @returns {Record<string, number>} */
|
|
55
59
|
values(): Record<string, number>;
|
|
60
|
+
/**
|
|
61
|
+
* This run's numbers in the shape baseline keeps: { where, values: { drawCalls, triangles, cpuMs (live runs), modules: { name: median ms, 0 too } } }.
|
|
62
|
+
* threedog shot / verify --save-baseline write it into the game's .threedog/perf-baseline.json (this machine's, not committed)
|
|
63
|
+
* @returns {{ where: string, values: { drawCalls: number, triangles: number, cpuMs?: number, modules: Record<string, number> } }}
|
|
64
|
+
*/
|
|
65
|
+
record(): {
|
|
66
|
+
where: string;
|
|
67
|
+
values: {
|
|
68
|
+
drawCalls: number;
|
|
69
|
+
triangles: number;
|
|
70
|
+
cpuMs?: number;
|
|
71
|
+
modules: Record<string, number>;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* One line when something is off, null when all is fine: over a limit the game declared (only when the budget is on; the engine's own reference
|
|
76
|
+
* limits never), slower than the baseline recorded at this spot on this machine (medians, past a noise margin), a module with spikes (p95 over 3x
|
|
77
|
+
* its median and over 2 ms), or what adaptive quality lowered (resolution, effects). threedog shot, verify and describeText print it
|
|
78
|
+
* @returns {string | null}
|
|
79
|
+
* @example engine.budget.notice() // 'Perf: over budget drawCalls 312 (limit 250, +25%); slower than baseline: modules.terrain 1.4 ms (was 0.6, +133%) -> threedog inspect perf'
|
|
80
|
+
*/
|
|
81
|
+
notice(): string | null;
|
|
56
82
|
/**
|
|
57
83
|
* Estimate draw calls and triangles by userData.budgetTag (visible meshes inside the frustum; shadow casters count a second shadow draw).
|
|
58
84
|
* Returns [{ tag, drawCalls, triangles }], largest first. Called only on overrun (at most once a second) or when debugging
|
|
@@ -110,6 +110,4 @@ export class DebugOverrides {
|
|
|
110
110
|
overrides(): any[];
|
|
111
111
|
/** Active overrides on one object, for engine.explain({ thing: id }) */
|
|
112
112
|
overridesOn(obj: any): any[];
|
|
113
|
-
/** Undo everything, drop / restore what the views put back, re-apply */
|
|
114
|
-
dispose(): void;
|
|
115
113
|
}
|
|
@@ -24,14 +24,14 @@ export class Saves {
|
|
|
24
24
|
/** Resolves once the save index is in memory; await it only to list / load before start() @type {Promise<void>} */
|
|
25
25
|
whenReady: Promise<void>;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Define "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); first may be a number, lower loads earlier, true counts as 0 (zones that need the level: 1); a load returning a Promise makes later
|
|
28
28
|
* parts wait.
|
|
29
29
|
* version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current
|
|
30
30
|
* shape.
|
|
31
31
|
* A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept).
|
|
32
32
|
* load(data, turn): turn is this replacement's identity. Pass it on, level.load(x, { turn }) or content.load(x, { turn }): those wait for a running load to end, except with its turn.
|
|
33
33
|
* A part registered after a save was loaded (a module installed later) is handed its data from that save: at once when idle, else right after the replacement under way.
|
|
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
|
+
* 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; load synchronous: an async function is refused here).
|
|
35
35
|
* checkNewGame(data): 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
|
|
36
36
|
* (world: records placed by code instead of content). The part knows its own format; core only hands the data over.
|
|
37
37
|
* Returns a handle: remove() takes the part out and keeps its data as unattached data (it rides in later saves and goes back to a part registered under
|
|
@@ -40,11 +40,11 @@ export class Saves {
|
|
|
40
40
|
* @param {SaveProvider} provider
|
|
41
41
|
* @returns {{ remove(o?: { keep?: boolean }): void }}
|
|
42
42
|
* @example
|
|
43
|
-
* engine.saves.
|
|
43
|
+
* engine.saves.define('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
|
|
44
44
|
* // later the format gains beds: version 2, and a step that upgrades version-1 data
|
|
45
|
-
* engine.saves.
|
|
45
|
+
* engine.saves.define('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
define(key: string, provider: SaveProvider): {
|
|
48
48
|
remove(o?: {
|
|
49
49
|
keep?: boolean;
|
|
50
50
|
}): void;
|
|
@@ -56,7 +56,7 @@ export class Saves {
|
|
|
56
56
|
get versions(): Record<string, number>;
|
|
57
57
|
/**
|
|
58
58
|
* Store a binary attachment outside the world save (a photo, a replay). It rides in the queue of save writes, so flush() waits for it, and exportFile() carries it.
|
|
59
|
-
* Pass a function to make the bytes when the write runs: flush() then waits for that too. Without IndexedDB it is not kept.
|
|
59
|
+
* Pass a function to make the bytes when the write runs: flush() then waits for that too. Without IndexedDB it is not kept: it rejects with save-write.
|
|
60
60
|
* Rejects with save-stale, changing nothing, when another tab wrote this id since this tab last saw it; attachments(group) is how a tab looks.
|
|
61
61
|
* @example await engine.saves.putAttachment('replay', 'run-1', blob, { score: 12 });
|
|
62
62
|
* @param {string} group what the attachment is for
|
|
@@ -151,10 +151,13 @@ export class Saves {
|
|
|
151
151
|
* game back.
|
|
152
152
|
* To continue or retry with nothing of the current playthrough left over, use engine.session.load(slot).
|
|
153
153
|
* @param {string} [slot]
|
|
154
|
+
* @param {{ turn?: object }} [o] turn: the running request's own (what a save part's load(), an afterLoad or a module's applyState was given): the call then runs inside that request instead of waiting behind it for itself, as level.load({ turn }) does
|
|
154
155
|
* @returns {Promise<boolean>}
|
|
155
156
|
* @example if (!(await engine.saves.load('quick'))) toast(engine, 'No quick save');
|
|
156
157
|
*/
|
|
157
|
-
load(slot?: string
|
|
158
|
+
load(slot?: string, { turn }?: {
|
|
159
|
+
turn?: object;
|
|
160
|
+
}): Promise<boolean>;
|
|
158
161
|
/** All slots, newest first (synchronous, reads the in-memory index) @returns {{ slot: string, savedAt: number }[]} */
|
|
159
162
|
list(): {
|
|
160
163
|
slot: string;
|
|
@@ -24,12 +24,15 @@ export class Session {
|
|
|
24
24
|
/**
|
|
25
25
|
* Start a new playthrough from the state the game had right after start(). Returns Promise<boolean> (false only if a save part failed to load: the
|
|
26
26
|
* old playthrough then goes on, with its data, listeners and timers, and 'session:failed' fires instead of 'session:start').
|
|
27
|
+
* @param {{ turn?: object }} [o] turn: the running request's own (what a save part's load(), an afterLoad or a module's applyState was given): the call then runs inside that request instead of waiting behind it for itself, as level.load({ turn }) does
|
|
27
28
|
* @returns {Promise<boolean>}
|
|
28
29
|
* @example
|
|
29
30
|
* // a "Restart" button in a game-over screen
|
|
30
31
|
* restartBtn.onclick = () => engine.session.newGame();
|
|
31
32
|
*/
|
|
32
|
-
newGame(
|
|
33
|
+
newGame({ turn }?: {
|
|
34
|
+
turn?: object;
|
|
35
|
+
}): Promise<boolean>;
|
|
33
36
|
/**
|
|
34
37
|
* Continue from a save (or retry from a checkpoint) with nothing of the current playthrough left over: the new-game state with the save on top,
|
|
35
38
|
* so a part the save does not have (a module added in a later version of the game) starts from its new-game state.
|
|
@@ -43,8 +46,11 @@ export class Session {
|
|
|
43
46
|
/**
|
|
44
47
|
* End the playthrough and show the title screen (the title part when the game turned it on; flow returns to its start state).
|
|
45
48
|
* The state behind the title is the new-game state, so nothing from the old playthrough runs while the title is up.
|
|
49
|
+
* @param {{ turn?: object }} [o] turn: the running request's own (what a save part's load(), an afterLoad or a module's applyState was given): the call then runs inside that request instead of waiting behind it for itself, as level.load({ turn }) does
|
|
46
50
|
* @returns {Promise<boolean>}
|
|
47
51
|
* @example settingsBackToTitle.onclick = () => engine.session.quit();
|
|
48
52
|
*/
|
|
49
|
-
quit(
|
|
53
|
+
quit({ turn }?: {
|
|
54
|
+
turn?: object;
|
|
55
|
+
}): Promise<boolean>;
|
|
50
56
|
}
|
|
@@ -9,7 +9,7 @@ export class Rays {
|
|
|
9
9
|
/** The three.js Raycaster (firstHitOnly is on) @type {any} @experimental */
|
|
10
10
|
ray: any;
|
|
11
11
|
/**
|
|
12
|
-
* Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }.
|
|
12
|
+
* Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }. Matrices are read once per tick and frame: a registered mesh moved between two rays of one step needs updateMatrixWorld() first.
|
|
13
13
|
* Only visible objects are hit. Something that is merely not drawn is still hit: batched originals, far hlod originals and the full model of a far assets.lod sit on a reserved layer, with their visible true.
|
|
14
14
|
* Unregisters automatically on geometry dispose or engine.remove.
|
|
15
15
|
* @param {THREE.Object3D | THREE.Object3D[]} obj
|
|
@@ -20,8 +20,6 @@ export class Rays {
|
|
|
20
20
|
addStatic(obj: THREE.Object3D | THREE.Object3D[], opts?: {
|
|
21
21
|
occluder?: boolean;
|
|
22
22
|
}): Handle;
|
|
23
|
-
/** Unregister every mesh under the object (engine.remove calls this automatically) @param {THREE.Object3D} obj @experimental */
|
|
24
|
-
forget(obj: THREE.Object3D): void;
|
|
25
23
|
/** A module merges its own hits (rigid adds rigid bodies; asked only when targets is 'all'). Returns a handle { remove() } @param {RayProvider} fn @returns {Handle} @experimental */
|
|
26
24
|
addProvider(fn: RayProvider): Handle;
|
|
27
25
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/scene/Views.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
export class Views {
|
|
3
|
+
/**
|
|
4
|
+
* A pose written as text, 'x,y,z,targetX,targetY,targetZ[,fov]' (meters, fov in degrees): the form a URL's ?view= and `threedog state view=` carry. null when the text is not one
|
|
5
|
+
* @param {string} text @returns {{ position: number[], target: number[], fov?: number } | null}
|
|
6
|
+
*/
|
|
7
|
+
static pose(text: string): {
|
|
8
|
+
position: number[];
|
|
9
|
+
target: number[];
|
|
10
|
+
fov?: number;
|
|
11
|
+
} | null;
|
|
3
12
|
/** @param {any} engine */
|
|
4
13
|
constructor(engine: any);
|
|
5
14
|
map: Map<any, any>;
|
|
@@ -21,10 +30,15 @@ export class Views {
|
|
|
21
30
|
/** @returns {string[]} the declared view names */
|
|
22
31
|
list(): string[];
|
|
23
32
|
/**
|
|
24
|
-
* 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
|
|
25
|
-
*
|
|
33
|
+
* 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.
|
|
34
|
+
* A pose { position, target?, fov? } in place of a name shows that pose without declaring it (current reads '(pose)')
|
|
35
|
+
* @param {string | { position: number[], target?: number[], fov?: number }} view @returns {{ remove(): void } | null}
|
|
26
36
|
*/
|
|
27
|
-
show(
|
|
37
|
+
show(view: string | {
|
|
38
|
+
position: number[];
|
|
39
|
+
target?: number[];
|
|
40
|
+
fov?: number;
|
|
41
|
+
}): {
|
|
28
42
|
remove(): void;
|
|
29
43
|
} | null;
|
|
30
44
|
/** Give the camera back (to the previous holder, e.g. a running cutscene, or to the rig) */
|
|
@@ -32,7 +32,7 @@ export class Particles {
|
|
|
32
32
|
*/
|
|
33
33
|
has(name: string): boolean;
|
|
34
34
|
/**
|
|
35
|
-
* Burst: emit count particles at once (default 10) at position (Vector3 / Object3D / [x, y, z] / {x, y, z}). overrides affect this batch only (color, speed, direction...; max/texture/blending/soft cannot be changed temporarily)
|
|
35
|
+
* Burst: emit count particles at once (default 10) at position (Vector3 / Object3D / [x, y, z] / {x, y, z}). overrides affect this batch only (color, speed, direction...; max/texture/blending/soft/lit cannot be changed temporarily)
|
|
36
36
|
* @param {string} name
|
|
37
37
|
* @param {PositionLike} position
|
|
38
38
|
* @param {{ count?: number, overrides?: ParticleOptions | null }} [opts]
|
|
@@ -153,7 +153,8 @@ export class World {
|
|
|
153
153
|
* Register how a kind of thing looks: models are built automatically within radius meters of any full-detail stream source (engine.stream: player, camera
|
|
154
154
|
* focus, teleport destination) and torn down when far from all of them (radius × 1.25); tearing down never touches the record. Callbacks:
|
|
155
155
|
* build(rec) → three.js object (may be async). world adds it to the scene and places it at rec.position; if it throws / fails / returns a non-object:
|
|
156
|
-
* reported once, does not block ready, retried when you leave and come back.
|
|
156
|
+
* reported once, does not block ready, retried when you leave and come back. Only the position is world's: rec.rot / rec.scale are the build's to apply
|
|
157
|
+
* (rotate the root or a child, in its own units) and update's to follow.
|
|
157
158
|
* update(rec, obj, dt): called every frame for records that have a model (change the picture from the data, e.g. an opened chest swaps texture).
|
|
158
159
|
* dispose(rec, obj): called on teardown (record first, model second); if omitted, engine.remove(obj).
|
|
159
160
|
* show(rec) → false: this record has no model right now (picked up, waiting to respawn); re-evaluated when world.set changes records of this kind.
|