threedog 0.8.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +223 -4
- package/README.md +6 -6
- package/core/assets/Animator.js +2 -0
- package/core/assets/Assets.js +44 -13
- package/core/assets/assetEntry.js +87 -22
- package/core/assets/assetHot.js +2 -1
- package/core/assets/assetReport.js +1 -2
- package/core/audio/Audio.js +24 -5
- package/core/base/I18n.js +6 -3
- package/core/base/Random.js +3 -1
- package/core/base/Vars.js +14 -4
- package/core/base/errorCodes.js +54 -16
- package/core/base/errorHints.js +12 -1
- package/core/base/errors.js +6 -4
- package/core/base/events.generated.js +10 -0
- package/core/base/follows.js +26 -0
- package/core/base/math.js +15 -8
- package/core/base/params.js +2 -2
- package/core/{saves → base}/saveValues.js +24 -6
- package/core/base/sections.js +97 -0
- package/core/base/spelling.js +32 -0
- package/core/base/validate.js +8 -29
- package/core/engine/Engine.js +61 -18
- package/core/engine/Loading.js +30 -3
- package/core/engine/copies.js +1 -1
- package/core/engine/headlessLoad.js +30 -13
- package/core/engine/lifecycle.js +30 -25
- package/core/engine/loop.js +22 -4
- package/core/engine/moduleSlots.js +91 -15
- package/core/engine/moduleTypes.js +13 -0
- package/core/engine/modules.js +248 -62
- package/core/engine/page.js +25 -8
- package/core/engine/plugins.js +15 -3
- package/core/engine/services.js +3 -0
- package/core/engine/startup.js +46 -36
- package/core/input/Input.js +39 -19
- package/core/input/inputKeyboard.js +39 -0
- package/core/input/inputPad.js +23 -2
- package/core/input/inputPointer.js +3 -1
- package/core/input/inputSeat.js +66 -0
- package/core/input/inputTouch.js +23 -6
- package/core/inspect/DebugOverrides.js +13 -2
- package/core/inspect/Describe.js +10 -6
- package/core/inspect/Inspect.js +31 -4
- package/core/inspect/UrlState.js +14 -10
- package/core/inspect/catalog.js +12 -5
- package/core/inspect/describeRender.js +3 -2
- package/core/inspect/describeText.js +6 -2
- package/core/inspect/metadata.generated.js +4140 -0
- package/core/inspect/pictureWriters.js +117 -33
- package/core/inspect/toolDoor.js +21 -0
- package/core/inspect/valueHistory.js +35 -0
- package/core/ops/Ops.js +32 -7
- package/core/ops/control.js +48 -23
- package/core/ops/holds.js +4 -3
- package/core/ops/opsAtomic.js +18 -6
- package/core/ops/opsCheck.js +7 -5
- package/core/ops/opsFail.js +5 -7
- package/core/ops/opsRun.js +2 -2
- package/core/ops/owned.js +20 -3
- package/core/ops/sharedPoint.js +7 -10
- package/core/ops/stacks.js +22 -1
- package/core/saves/SaveStore.js +52 -26
- package/core/saves/Saves.js +122 -27
- package/core/saves/saveApply.js +159 -61
- package/core/saves/saveFiles.js +30 -25
- package/core/saves/saveVersions.js +20 -6
- package/core/saves/session.js +76 -33
- package/core/saves/stateReplace.js +184 -0
- package/core/scene/Rays.js +21 -5
- package/core/scene/Views.js +6 -6
- package/core/scene/adaptive.js +13 -10
- package/core/scene/canvasBox.js +2 -0
- package/core/scene/compositeGround.js +72 -0
- package/core/scene/floor.js +17 -0
- package/core/scene/grid.js +2 -0
- package/core/scene/ground.contract.js +14 -0
- package/core/scene/ground.js +52 -17
- package/core/scene/pixel.js +154 -0
- package/core/scene/pixelRatio.js +167 -0
- package/core/scene/sceneDelta.js +3 -3
- package/core/scene/sceneMethods.js +11 -6
- package/core/scene/stepPoses.js +6 -1
- package/core/scene/thingExplain.js +1 -1
- package/core/scene/thingOps.js +22 -14
- package/core/scene/things.js +1 -1
- package/core/scene/tier.js +10 -0
- package/core/scene/view.js +126 -9
- package/core/stream/Batching.js +0 -1
- package/core/stream/Stream.js +24 -12
- package/core/stream/batchGroups.js +1 -0
- package/core/stream/scatter.js +5 -2
- package/core/stream/streamSources.js +2 -1
- package/core/threads/Commits.js +12 -7
- package/core/threads/Jobs.js +15 -5
- package/core/threads/Threads.js +5 -2
- package/core/time/Clock.js +3 -1
- package/core/time/skip.js +10 -4
- package/core/time/time.js +16 -10
- package/docs/AI.md +89 -72
- package/docs/API.md +18 -14
- package/docs/CODEMAP.md +68 -40
- package/docs/COMMANDS.md +22 -23
- package/docs/CONVENTIONS.md +120 -17
- package/docs/MIGRATING-0.8.md +2 -0
- package/docs/MIGRATING-1.0.md +101 -0
- package/docs/THREE.md +65 -12
- package/docs/api/cameraRig.md +3 -0
- package/docs/api/characters.md +13 -7
- package/docs/api/collider3d.md +9 -0
- package/docs/api/content.md +16 -15
- package/docs/api/dialogue.md +2 -1
- package/docs/api/engine.md +18 -16
- package/docs/api/events.md +14 -4
- package/docs/api/ground.md +2 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +2 -1
- package/docs/api/interactions.md +1 -1
- package/docs/api/inventory.md +1 -1
- package/docs/api/level.md +3 -2
- package/docs/api/nav.md +4 -2
- package/docs/api/particles.md +8 -5
- package/docs/api/pickups.md +1 -1
- package/docs/api/post.md +3 -4
- package/docs/api/quests.md +4 -2
- package/docs/api/rays.md +2 -0
- package/docs/api/rigid.md +3 -2
- package/docs/api/saves.md +8 -7
- package/docs/api/stream.md +4 -5
- package/docs/api/terrain.md +3 -4
- package/docs/api/terrainDraw.md +1 -1
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +3 -1
- package/docs/api/triggers.md +2 -0
- package/docs/api/vegetationDraw.md +1 -1
- package/docs/api/water.md +6 -2
- package/docs/api/weather.md +19 -4
- package/docs/api/weatherDraw.md +1 -1
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +3 -3
- package/docs/recipes/02-npc.md +3 -4
- package/docs/recipes/03-items-pickups.md +11 -11
- package/docs/recipes/04-quests.md +2 -0
- package/docs/recipes/05-props-bake.md +9 -9
- package/docs/recipes/06-clock-events.md +6 -6
- package/docs/recipes/07-flow-scenes-pause.md +18 -15
- package/docs/recipes/08-weather-sky.md +5 -5
- package/docs/recipes/09-materials-lights-models.md +3 -3
- package/docs/recipes/10-blender-level.md +16 -4
- package/docs/recipes/11-vehicles.md +18 -6
- package/docs/recipes/12-navmesh.md +52 -8
- package/docs/recipes/13-animation.md +34 -8
- package/docs/recipes/14-custom-module.md +20 -8
- package/docs/recipes/15-perf.md +4 -4
- package/docs/recipes/16-dev-bridge.md +9 -8
- package/docs/recipes/18-world.md +13 -5
- package/docs/recipes/19-shooting-picking.md +3 -2
- package/docs/recipes/20-content-actions-save.md +26 -6
- package/docs/recipes/21-camera.md +17 -23
- package/docs/recipes/22-shop-gold.md +21 -12
- package/docs/recipes/23-ops.md +19 -15
- package/docs/recipes/26-ui-parts.md +3 -2
- package/docs/recipes/27-net.md +3 -3
- package/docs/recipes/28-terrain.md +3 -3
- package/docs/recipes/29-grid.md +1 -1
- package/docs/recipes/30-templates.md +10 -13
- package/docs/recipes/31-audio.md +2 -2
- package/docs/recipes/32-action-game.md +6 -5
- package/docs/recipes/33-stream-sources.md +4 -1
- package/docs/recipes/34-environment-lighting.md +7 -8
- package/docs/recipes/35-picture-from-reference.md +13 -9
- package/docs/recipes/36-ground-plants.md +3 -2
- package/docs/recipes/40-scene.md +11 -10
- package/docs/recipes/43-shader-patches-surfaces.md +7 -7
- package/docs/recipes/44-water-weather-hooks.md +9 -8
- package/docs/recipes/45-cascaded-shadows.md +3 -4
- package/docs/recipes/46-blender-art-route.md +3 -3
- package/docs/recipes/49-game-module-contract.md +2 -1
- package/docs/recipes/50-own-renderer.md +1 -0
- package/docs/recipes/51-capability-catalog.md +14 -8
- package/docs/recipes/52-around-the-picture.md +4 -4
- package/docs/recipes/55-mods-time-wrap.md +5 -4
- package/docs/recipes/56-webgpu-tsl.md +12 -1
- package/docs/recipes/57-control.md +30 -10
- package/docs/recipes/58-input.md +13 -0
- package/docs/recipes/60-judge-the-picture.md +1 -1
- package/docs/recipes/62-picture-code.md +106 -48
- package/docs/recipes/63-third-person-start.md +2 -1
- package/docs/recipes/64-particles.md +53 -4
- package/docs/recipes/65-swarm.md +2 -2
- package/docs/recipes/66-common-tasks.md +313 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +3 -3
- package/examples/perf-island/.threedog/content-index.json +1 -1
- package/examples/perf-island/GAMEMAP.md +3 -3
- package/examples/perf-island/main.js +2 -2
- package/examples/plain-picture/GAMEMAP.md +3 -1
- package/examples/rc2d/GAMEMAP.md +1 -1
- package/examples/rc2d/rc2d.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +3 -3
- package/examples/webgpu-tsl/GAMEMAP.md +1 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +5 -4
- package/examples/world/main.js +3 -3
- package/index.d.ts +8 -5
- package/index.js +22 -1
- package/llms.txt +2 -1
- package/modules/ambience/Ambience.js +5 -3
- package/modules/calendar/index.js +7 -5
- package/modules/camera/FirstPersonCamera.js +3 -3
- package/modules/camera/FixedCamera.js +34 -20
- package/modules/camera/FollowCamera.js +20 -11
- package/modules/camera/RtsCamera.js +1 -0
- package/modules/camera/common.js +33 -22
- package/modules/camera/pixelSnap.js +62 -0
- package/modules/characters/Character.js +136 -43
- package/modules/characters/NPC.js +60 -28
- package/modules/characters/assetModel.js +2 -2
- package/modules/characters/astar.js +47 -28
- package/modules/characters/character.contract.js +21 -0
- package/modules/characters/contract.js +17 -3
- package/modules/characters/index.js +94 -34
- package/modules/characters/moveHelpers.js +80 -15
- package/modules/characters/mover.contract.js +14 -0
- package/modules/characters/movers/common.js +6 -4
- package/modules/characters/movers/rapier.js +12 -5
- package/modules/characters/movers/simple.js +25 -12
- package/modules/characters/movers/support.js +18 -7
- package/modules/characters/npcAvoid.js +15 -12
- package/modules/characters/npcSim.js +75 -25
- package/modules/characters/npcView.js +13 -6
- package/modules/characters/pathAsync.js +74 -24
- package/modules/characters/pathJob.js +38 -21
- package/modules/characters/player.js +59 -47
- package/modules/characters/seat.js +56 -0
- package/modules/characters/vehicle.contract.js +8 -5
- package/modules/characters/walkTo.js +31 -18
- package/modules/collision/Collision.js +44 -26
- package/modules/collision/contract.js +2 -2
- package/modules/collision/grid.js +6 -1
- package/modules/content/explain.js +1 -1
- package/modules/content/fields.js +3 -3
- package/modules/content/ids.js +3 -1
- package/modules/content/index.js +83 -27
- package/modules/content/loader.js +110 -130
- package/modules/content/markers.js +1 -1
- package/modules/content/models.js +48 -14
- package/modules/content/packs.js +2 -1
- package/modules/content/places.js +5 -4
- package/modules/content/props.js +8 -6
- package/modules/content/rules.js +29 -47
- package/modules/content/templates.js +66 -35
- package/modules/content/words.js +19 -6
- package/modules/debug/DebugPanel.js +4 -2
- package/modules/flow/contract.js +1 -0
- package/modules/flow/index.js +24 -14
- package/modules/gameplay/Container.js +5 -2
- package/modules/gameplay/Containers.js +9 -1
- package/modules/gameplay/Dialogue.js +82 -25
- package/modules/gameplay/Interactions.js +61 -32
- package/modules/gameplay/Inventory.js +56 -13
- package/modules/gameplay/Quests.js +133 -24
- package/modules/gameplay/boxOps.js +7 -0
- package/modules/gameplay/dialogueBubbles.js +14 -9
- package/modules/gameplay/inventoryOps.js +11 -7
- package/modules/gameplay/pickups.js +43 -16
- package/modules/gameplay/questLog.js +4 -2
- package/modules/gameplay/questSave.js +6 -1
- package/modules/gameplay/quests.contract.js +1 -1
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +8 -4
- package/modules/grid/index.js +21 -15
- package/modules/grid/ops.js +43 -46
- package/modules/grid/tiles.js +1 -1
- package/modules/hlod/index.js +6 -3
- package/modules/hud/index.js +6 -4
- package/modules/hud/parts.js +4 -4
- package/modules/level/contract.js +2 -2
- package/modules/level/heightfield.js +17 -21
- package/modules/level/index.js +83 -26
- package/modules/level/load.js +165 -48
- package/modules/level/nodes.js +34 -16
- package/modules/lights/index.js +6 -3
- package/modules/lights/sources.js +3 -1
- package/modules/music/Music.js +4 -2
- package/modules/nav/contract.js +7 -5
- package/modules/nav/index.js +174 -44
- package/modules/nav/navPath.js +45 -10
- package/modules/net/index.js +1 -1
- package/modules/particles/Particles.js +85 -22
- package/modules/particles/effect.js +80 -28
- package/modules/particles/shaders.js +17 -0
- package/modules/photo/Photo.js +12 -10
- package/modules/rigid/RigidBodies.js +200 -57
- package/modules/rigid/Vehicles.js +15 -5
- package/modules/rigid/collider3d.contract.js +26 -0
- package/modules/rigid/ragdoll.js +55 -44
- package/modules/rigid/ragdollBones.js +83 -33
- package/modules/rigid/refresh.js +10 -0
- package/modules/rigid/sync.js +46 -15
- package/modules/settings/Settings.js +84 -37
- package/modules/settings/apply.js +15 -8
- package/modules/settings/sections.js +7 -4
- package/modules/settings/strings.js +2 -2
- package/modules/sky/skyModule.js +3 -1
- package/modules/swarm/Swarm.js +16 -6
- package/modules/terrain/ChunkManager.js +10 -16
- package/modules/terrain/index.js +17 -11
- package/modules/terrain/terrainEdit.js +13 -2
- package/modules/terrain/terrainGen.js +5 -3
- package/modules/terrain/terrainShape.js +1 -1
- package/modules/timeline/Timeline.js +58 -26
- package/modules/timeline/Tween.js +19 -13
- package/modules/timeline/shots.js +19 -10
- package/modules/triggers/index.js +87 -20
- package/modules/vegetation/Vegetation.js +4 -3
- package/modules/vegetation/draw.js +16 -0
- package/modules/vegetation/groundChunks.js +10 -7
- package/modules/vegetation/index.js +30 -7
- package/modules/water/Water.js +6 -2
- package/modules/weather/Weather.js +16 -15
- package/modules/weather/weatherDraw.js +7 -6
- package/modules/world/World.js +20 -7
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +13 -6
- package/modules/world/persist.js +23 -8
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +13 -7
- package/modules/world/sim.js +74 -23
- package/modules/world/simFar.js +2 -2
- package/modules/world/state.js +31 -6
- package/modules/world/thingSource.js +16 -3
- package/modules/world/views.js +19 -8
- package/package.json +7 -1
- package/render/PostFX.js +47 -29
- package/render/backend.js +5 -1
- package/render/fx/particles.tsl.js +8 -6
- package/render/fx/postWebGPU.tsl.js +3 -3
- package/render/layers.js +1 -1
- package/render/lightmap.js +23 -3
- package/render/occlusion.js +43 -12
- package/render/patches.js +2 -2
- package/render/postWebGL.js +4 -3
- package/render/probes.js +25 -0
- package/render/shadows.js +2 -2
- package/types/core.d.ts +142 -55
- package/types/gameplay.d.ts +92 -40
- package/types/generated/core/base/I18n.d.ts +2 -2
- package/types/generated/core/input/Input.d.ts +16 -2
- package/types/generated/core/input/inputSeat.d.ts +26 -0
- package/types/generated/core/inspect/DebugOverrides.d.ts +15 -1
- package/types/generated/core/ops/Ops.d.ts +2 -1
- package/types/generated/core/ops/control.d.ts +12 -2
- package/types/generated/core/saves/Saves.d.ts +26 -6
- package/types/generated/core/saves/session.d.ts +1 -1
- package/types/generated/core/scene/Views.d.ts +1 -1
- package/types/generated/core/stream/Stream.d.ts +6 -4
- package/types/generated/modules/grid/Grid.d.ts +1 -0
- package/types/generated/modules/particles/Particles.d.ts +4 -3
- package/types/generated/modules/timeline/Timeline.d.ts +5 -4
- package/types/generated/modules/weather/Weather.d.ts +1 -7
- package/types/generated/modules/world/World.d.ts +6 -4
- package/types/generated/render/PostFX.d.ts +6 -14
- package/types/nav.d.ts +36 -4
- package/types/physics.d.ts +55 -7
- package/types/pixel.d.ts +75 -0
- package/types/world.d.ts +14 -8
- package/ui/Parts.js +9 -2
- package/ui/theme.js +2 -2
- package/core/scene/engineCamera.js +0 -32
- package/modules/camera/projection.js +0 -21
package/docs/api/characters.md
CHANGED
|
@@ -5,19 +5,23 @@ Characters: createPlayer() (characters() module)
|
|
|
5
5
|
- Options `CharactersOptions`:
|
|
6
6
|
- `npcs?: boolean` Whether to enable NPCs (engine.npcs), default true
|
|
7
7
|
- `npcTiers?: { fullRadius: number; nearEvery: number }` (experimental) Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts)
|
|
8
|
+
- `fall?: 'rescue' | false | ((facts, engine) => 'rescue' | false)` The rule 'fall' for everyone: 'rescue' brings what falls out of the world back; left out, the engine rescues nothing. engine.mod('fall', ...) from the game sits above it
|
|
8
9
|
- `animation?: AnimatorOptions` What every character's Animator starts from, e.g. { fade: 0.15 }; a model's manifest mapping and the character's own animation win over it
|
|
9
10
|
|
|
10
11
|
## Methods and properties
|
|
11
12
|
- `characters.findSpawn(position?: PositionLike, opts?: FindSpawnOptions) → Vector3` — Find a spawn point: searches outward from position (default origin) for walkable (not steep, no obstacle), non-water ground, without assuming terrain height; e.g. findSpawn(v, { minH: 3, maxH: 20 }). Returns a Vector3 (y is the ground height)
|
|
12
13
|
- `characters.createPlayer(opts: PlayerOptions) → Character` — Create the player and set engine.player; control is required (no default feel), e.g. createPlayer({ ...presets.player.thirdPerson, spawn }). An existing player is deleted first
|
|
13
|
-
- `characters.moveInput() → { x, z, run }` — The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it inside your own control function to wrap it
|
|
14
|
+
- `characters.moveInput(seat?: Seat) → { x, z, run }` — The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it inside your own control function to wrap it
|
|
15
|
+
- `characters.addVehicle(vehicle: any) → { remove(): void }` — Join the vehicles a saved rider can be seated in again, before or after the load
|
|
14
16
|
- `characters.support(object: any, opts?: { id?, safe?, carry?, inherit? }) → { id: string; remove(): void }` — Something characters stand on and ride (moving platform, lift, raft). Move the object any way (onFixed before or after the player, a timeline, physics): riders follow how its matrix changed, so the order does not matter. safe: false = never a respawn spot; carry 'position+yaw' turns riders with it; inherit: false = jumping off keeps none of its speed. With mover 'rapier' give it a collider too. Example: `const lift = engine.characters.support(liftMesh); engine.onFixed(() => { liftMesh.position.y = 2 + Math.sin(engine.time.now('real')); });`
|
|
15
|
-
- `characters.removePlayer()` — (experimental) Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
|
|
16
|
-
- `characters.findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }) →
|
|
17
|
+
- `characters.removePlayer(id?: string)` — (experimental) Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
|
|
18
|
+
- `characters.findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }) → NavPathPoint[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: FindPathOptions & { detailed: true }) → PathResult` — Pathfinding (the single entry point): uses the navmesh when nav is installed and ready, otherwise the A* fallback. Returns a path [{ x, y, z }...], or null if unreachable
|
|
17
19
|
- `characters.findPathAsync(from: PositionLike, to: PositionLike, done: (path, status) => void, opts?: { radius?, step?, maxNodes? }) → { remove(): void }` — findPath for many callers (NPC crowds, AI squads): solved in engine.threads workers; done(path, status) runs on a fixed step a few steps later (same paths with threads on or off). Recipe 12 section 4
|
|
18
20
|
- Properties:
|
|
19
21
|
- `material: Material` The three.js material of every placeholder capsule. Set it to swap the look of all of them at once; used as given, with no patches added. A character with colors.body draws with a copy of it in that color. A model's own materials are the model's. Example: `engine.characters.material = new THREE.MeshToonMaterial({ color: 0xd9a066 });`
|
|
22
|
+
- `kit: { beginMove, groundAt, endMove, ownState }` What a game's mover calls to take part in contact, each optional (recipe 57): a mover calling none owns contact itself (beginMove() groundAt() endMove() ownState())
|
|
20
23
|
- `pathsPerStep: number` How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps
|
|
24
|
+
- `linkPose: ((t, position, crossing, character) => void) | null` (experimental) Bends a link crossing away from its straight line: t 0-1, called each step after position is set on the line, write to position. Depends only on its arguments, so a crossing saved halfway resumes on the same curve. null = the straight line
|
|
21
25
|
|
|
22
26
|
## Character (engine.player / NPC are both Character)
|
|
23
27
|
- `player.push(vx: number, vz: number, seconds: number)` — Move at a fixed velocity (m/s) for seconds, ignoring move()'s direction and without turning (knockback, dodge roll); gravity and collision still apply
|
|
@@ -35,7 +39,7 @@ Characters: createPlayer() (characters() module)
|
|
|
35
39
|
- `player.placeAt(position: PositionLike)` — Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z })
|
|
36
40
|
- `player.syncRecord()` — After moving root yourself (a cutscene path, a scripted pose): write position and motion back to its world record (the player's), so a save right after has it
|
|
37
41
|
- `player.walkTo(target: Vector3 | { x: number; z: number } | [number, number, number] | …, opts?: { speed?, arrive?, turnRate?, stuckSeconds?, maxRepaths?, run? }) → Promise<{ status: 'arri… & { remove(): void }` — Walk to a point along characters.findPath on fixed steps; never rejects. One walk per character: a new walkTo, dispose() or a save load ends the old one with 'cancelled'. Transient: not saved, not fast-forwarded by engine.skip. Holds the character's control on layer 'script' (owner 'walkTo'): the player's keys / an NPC's schedule pause meanwhile, a cutscene pauses the walk, and another script owner on it is control-conflict
|
|
38
|
-
- `player.move(dirX: number, dirZ: number, run: boolean, dt: number)` — Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1 scales the speed), run to run, dt in seconds (used as given). Speed comes from the stats: engine.mod('move.speed', { owner, id: character.id, ... }) (the player: id 'player'), the one way to change speed. A character someone controls (engine.control.of(ch)) moves only through its holder: called from anywhere else it is control-bypass in dev; take control and use handle.move() / step instead
|
|
42
|
+
- `player.move(dirX: number, dirZ: number, run: boolean, dt: number, dirY?: number)` — Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1 scales the speed), run to run, dt in seconds (used as given). Speed comes from the stats: engine.mod('move.speed', { owner, id: character.id, ... }) (the player: id 'player'), the one way to change speed. A character someone controls (engine.control.of(ch)) moves only through its holder: called from anywhere else it is control-bypass in dev; take control and use handle.move() / step instead
|
|
39
43
|
- `player.groundType() → string` — Ground type underfoot ('water' while swimming)
|
|
40
44
|
- `player.face(target: PositionLike | number)` — Turn at once to a position, or to an angle in radians (0 = +Z)
|
|
41
45
|
- `player.saveMotion(out?: CharacterMotion) → CharacterMotion` — (experimental) Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
|
|
@@ -68,7 +72,7 @@ Characters: createPlayer() (characters() module)
|
|
|
68
72
|
- `id: string` 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
|
|
69
73
|
- `support: { kind, object, id, safe, velocity }` What it stands on, read-only (reused object); 'platform' = a registered support (characters.support), which carries it
|
|
70
74
|
- `safeGround: Vector3 | null` Last spot it stood still on safe ground (where a fall returns it); null until it first stands. Saved with the motion
|
|
71
|
-
- `mover: { name, controller?, body?, collider?, move, dispose
|
|
75
|
+
- `mover: { name, controller?, body?, collider?, move, dispose?, … }` How it walks now; name is 'simple' / 'rapier' / 'manual', controller is the native Rapier character controller (when rapier). Assign a name to switch: c.mover = 'manual'
|
|
72
76
|
- `anim: Animator | null` Skeletal animation state machine (when there is a glTF model; null while a model named by asset is still loading)
|
|
73
77
|
- `ready: boolean` false while a model named by asset is loading (the placeholder body shows); true otherwise, also after a failed load (placeholder kept)
|
|
74
78
|
- `whenReady: Promise<void>` Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise. Example: `const npc = new Character(engine, { model: 'villager' }); engine.add(npc.root); // import { Character } from 'threedog' await npc.whenReady; npc.playAction('Wave');`
|
|
@@ -116,6 +120,8 @@ Characters: createPlayer() (characters() module)
|
|
|
116
120
|
- `x: number`
|
|
117
121
|
- `z: number`
|
|
118
122
|
- **PlayerOptions** (extends CharacterOptions) Parameters of createPlayer()
|
|
123
|
+
- `id?: string` A further local player's id and world record; left out, the one player (engine.player)
|
|
124
|
+
- `input?: Seat` The seat that drives this player (engine.input.seat); default engine.input
|
|
119
125
|
- `spawn?: PositionLike` Spawn point (meters, { x, z } / Vector3 / object); flat ground is found automatically if omitted
|
|
120
126
|
- `control: PlayerControl` Required, no default: 'camera' (keys relative to the camera) / (player, input, dt) => ({ x, z, run? }) (null stands still). presets.player.* fill it. Given once: a game that steers the player for a while takes control (engine.control.take(player, { owner, layer: 'script', step }))
|
|
121
127
|
- `cameraFollow?: boolean` true: the camera module follows the player (and back after a vehicle, and on a new session). Omitted with a camera installed warns in dev
|
|
@@ -139,14 +145,14 @@ Characters: createPlayer() (characters() module)
|
|
|
139
145
|
- `maxJumps?: number` Jumps before landing again, default 1; 2 = double jump (jump() again in the air)
|
|
140
146
|
- `airJumpSpeed?: number` Takeoff speed of an air jump (m/s), default jumpSpeed
|
|
141
147
|
- `jumpBuffer?: number` How long a jump() pressed early waits for the ground (seconds), default 0.12
|
|
142
|
-
- `fall?: false | { belowY }` Falling out of the level: below belowY (or when belowY(character) is true) character:fall fires and
|
|
148
|
+
- `fall?: false | { belowY }` Falling out of the level: below belowY (or when belowY(character) is true) character:fall fires and the rule 'fall' decides: back to safeGround by default, engine.mod('fall', { owner, id, set: false }) leaves it to the game. false (default) = off
|
|
143
149
|
- `channel?: string` Time channel its movement and animation follow when the engine drives it (player default 'player', others 'world')
|
|
144
150
|
- `model?: Object3D | string | null` The body, one path for every kind: the name of a registered model asset, or what engine.assets.model() returned. A procedural builder name (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, event 'character:model'). Example: `engine.assets.manifest(yourAssets); engine.characters.createPlayer({ model: 'yourBody' }) // a generator or GLB name from an asset pack`
|
|
145
151
|
- `rig?: CharacterRig | null` A ready procedural body (CharacterRig), used instead of model (a hand-built guard / pet)
|
|
146
152
|
- `id?: string` Id for engine.mod / time.local entries of a character without a world record (read it back as character.id); the player is 'player', an NPC its record id
|
|
147
153
|
- `clips?: { idle?, walk?, run?, swim?, jump?, fall?, … } | null` Action name mapping { idle, walk, run, swim, jump, fall } (shorthand for animation)
|
|
148
154
|
- `animation?: AnimatorOptions | null` Skeletal animation state machine config (states, blend trees, one-shot actions), see AnimatorOptions
|
|
149
|
-
- `mover?: 'simple' | 'rapier' | 'manual'
|
|
155
|
+
- `mover?: 'simple' | 'rapier' | 'manual' | …` Movement method: 'simple' built into the engine (default) / 'rapier' Rapier character controller (needs the rigid module) / 'manual' the game writes the position, move() only updates grounded / support / safeGround / fall
|
|
150
156
|
- `faceMode?: FaceMode` Which way it turns each move: 'move' (default, toward its velocity) / 'camera' (along cameraRig.forward()) / 'target' (toward faceTarget) / 'manual' (only face() turns it)
|
|
151
157
|
- `faceTarget?: PositionLike | null` What faceMode 'target' faces (lock-on)
|
|
152
158
|
- **FindSpawnOptions** Parameters of findSpawn(): minH/maxH height range (meters, default unlimited), maxSlope maximum slope (default 0.3), waterMargin minimum meters above the water (default 0.5)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# engine.collider3d — collider3d()
|
|
2
|
+
|
|
3
|
+
(experimental) Collision on all three axes (the collider3d slot, held by rigid() unless replaced)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `collider3d.addSolid(opts: { position, size?, radius?, rotation?, friction? }) → Handle` — A fixed solid turned any way. size [x, y, z] for a box or radius for a ball; rotation [x, y, z] radians or a quaternion. Callable before start(); newGame and a load keep it. engine.collision does not know it
|
|
8
|
+
- `collider3d.overlap(position: PositionLike, radius?: number) → boolean` — Is a ball here inside something solid. Skips the player's capsule
|
|
9
|
+
- `collider3d.sweep(from: PositionLike, to: PositionLike, radius?: number) → SweepHit | null` — Move a ball from there to there: null when clear, else the first hit. Skips the player's capsule
|
package/docs/api/content.md
CHANGED
|
@@ -4,10 +4,10 @@ Content loading (content() module)
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
|
7
|
-
- `content.load(data: ContentPack | ContentPack[], opts?: ContentLoadOptions)
|
|
7
|
+
- `content.load(data: ContentPack | ContentPack[], opts?: ContentLoadOptions) → Promise<void>` — Load content (items, pickups, vegetation, NPCs, dialogue, quests, keys, trigger zones, props, the game vocabulary rules): one pack, or a list of packs loaded together in order; an id defined by two packs of one call is an error naming both (a later separate load overrides by name instead). Bad data throws on the line. The Promise answers for this load: it resolves when the pack committed, and rejects when it failed, after the old level and registrations are back (err.notRestored lists what could not be). A load nobody awaits is reported all the same. Example: `await engine.content.load([baseContent, forestDlc], { places: { home } })`
|
|
8
8
|
- `content.condition(name: string, def: ContentConditionDef)` — Register a custom condition, e.g. condition('timeAfter', { ref: 'clock', test: (e, t) => e.calendar.timeOfDay >= t })
|
|
9
9
|
- `content.test(cond: any, opts?: { actor?: string }) → boolean` — Whether a condition holds (object, array or function (e, { actor })); actor = whose bag has / lacks look in (default the running op's actor, else engine.actor)
|
|
10
|
-
- `content.run(effect: any, opts?: { actor?: string }) →
|
|
10
|
+
- `content.run(effect: any, opts?: { actor?: string }) → { ok: true } | { ok, code, facts, nextActions }` — Run an effect (object, array or function (e, { actor })); actor = whose bag give / take change (default the running op's actor, else engine.actor)
|
|
11
11
|
- `content.place(name: string) → XZ | null` — Place name -> position (load's places first, then level markers), null if none
|
|
12
12
|
- `content.where(p: { place?, x?, z? }) → XZ` — Position form in content { place?, x?, z? } -> world coordinates
|
|
13
13
|
- `content.template(name: string) → Readonly<ContentTemplate>` — The shared, frozen definition of a content template (content/templates.js); instance state lives on the world record. e.g. template('chest').container.capacity
|
|
@@ -38,29 +38,30 @@ Conditions are used in quest step done, dialogue option if and line variant if;
|
|
|
38
38
|
- `give` value is { itemId: count }, e.g. { berry: 3 }: give items
|
|
39
39
|
- `take` value is { itemId: count }, e.g. { berry: 3 }: take items
|
|
40
40
|
- `bump` value is a counter name, e.g. 'sunsetPhotos': counter +1
|
|
41
|
-
- `startQuest` value is a quest id: start a quest
|
|
42
41
|
- `toast` value is text: show a toast
|
|
43
42
|
- `particles` value is { name, at: [x, y, z], count }: play particles
|
|
44
43
|
- `marker` value is a place name, or { place, x, z } / { x, z }: add an objective marker (hud module)
|
|
45
44
|
- `clearMarker` value is a place name, or { place, x, z } / { x, z }: remove an objective marker
|
|
46
45
|
- `op` value is ['noun.verb', { args }], e.g. ['shop.buy', { shop: 'bakery', item: 'bread' }]: run a game op (engine.ops.run); the game's own actions are ops
|
|
46
|
+
- `startQuest` value is a quest id: start a quest
|
|
47
47
|
- Files content/ recognizes:
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
48
|
+
- `actions.js` own key actions of the game (action name -> default key, label)
|
|
49
|
+
- `audio.js` sounds by asset name, ambience and music rules as data, footsteps (sounds, ambience, music: { tracks, rules }, footsteps)
|
|
50
50
|
- `containers.js` chests / shelves (container id -> { capacity, items: starting goods }; starting goods are placed only the first time, then saved)
|
|
51
|
-
- `npcs.js` NPCs (id -> name, schedule, interact)
|
|
52
51
|
- `dialogues.js` dialogues (id -> speaker, nodes)
|
|
53
|
-
- `
|
|
54
|
-
- `
|
|
52
|
+
- `grids.js` placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved
|
|
53
|
+
- `items.js` items (id -> name, icon, description); also export startItems for starting items
|
|
54
|
+
- `level.js` level markers (spawn point, NPCs, trigger zones) of a code-built level: for the tools (content checks, GAMEMAP); load() reads no markers from it. A file or asset name here switches level, as engine.level.load does
|
|
55
|
+
- `npcs.js` NPCs (id -> name, schedule, interact)
|
|
56
|
+
- `pickups.js` pickups on the ground (list)
|
|
55
57
|
- `places.js` place names (name -> { x, z, y?, rot? }; rot turns everything placed there about Y; coordinates may be computed at runtime in main.js)
|
|
56
|
-
- `triggers.js` trigger zones (tag -> position / from level, enter/exit effects)
|
|
57
|
-
- `level.js` level markers (spawn point, NPCs, trigger zones) of a code-built level: for the tools (content checks, GAMEMAP); load() accepts the file and does not read it
|
|
58
|
-
- `vegetation.js` vegetation (name -> model, growth rule)
|
|
59
58
|
- `props.js` props (list: model, position, facing, collision; or { template, x, z } = an instance of a template; or { id, grid, item, cell } = a grid item), streamed in on demand
|
|
60
|
-
- `
|
|
61
|
-
- `audio.js` sounds by asset name, ambience and music rules as data, footsteps (sounds, ambience, music: { tracks, rules }, footsteps)
|
|
62
|
-
- `views.js` named fixed camera views (name -> { position: [x, y, z], target?: [x, y, z], fov? }); engine.views.show(name), ?view=name, npm run shot -- -w game --view name
|
|
63
|
-
- `grids.js` placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved
|
|
59
|
+
- `quests.js` quests (id -> title, steps, reward; a step can have a target position)
|
|
64
60
|
- `renames.js` renamed or deleted authored ids (old id -> new id, or null = deleted on purpose): the player's saved changes follow the new id
|
|
65
61
|
- `rules.js` condition words and data kinds added by the game ({ conditions, kinds }); actions are ops, not effect words
|
|
62
|
+
- `startItems.js` starting items (exported from items.js)
|
|
63
|
+
- `templates.js` reusable objects (name -> model, collide, interact, container, sound, animate, state defaults, physics body); shared read-only definitions
|
|
64
|
+
- `triggers.js` trigger zones (tag -> position / from level, enter/exit effects)
|
|
65
|
+
- `vegetation.js` vegetation (name -> model, growth rule)
|
|
66
|
+
- `views.js` named fixed camera views (name -> { position: [x, y, z], target?: [x, y, z], fov? }); engine.views.show(name), ?view=name, npm run shot -- -w game --view name
|
|
66
67
|
- any other `<name>.js` the game registers in content/rules.js as kinds: { name: { desc, load?(e, data), check?, map? } } (enemies, recipes, loot tables…)
|
package/docs/api/dialogue.md
CHANGED
|
@@ -6,12 +6,13 @@ Dialogue (dialogue() module). Ops: `dialogue.advance` (finish typing the line, e
|
|
|
6
6
|
- `charsPerSecond?: number` Typing speed (characters/second, game time: advanced by engine.step), default 40
|
|
7
7
|
- `advanceActions?: string[]` Actions that advance the dialogue, default ['confirm'] (a basic key); e.g. ['confirm', 'interact'] to also advance on the game's interact key. Choices: the cursor, clicks, and the actions choice1..choice9 (context 'dialog', no keys of their own: presets.bindings.dialogNumbers binds 1-9)
|
|
8
8
|
- `holdSeconds?: number` A bubble line stays this many seconds plus its reading time (about 15 characters a second) unless say() gives seconds, default 2
|
|
9
|
+
- `bubbleChoice?: 'end' | 'ask'` A bubble script reaching a node with choices: 'end' (default: warn, the script ends there) or 'ask' (the line stays with its choices until engine.ops.run('dialogue.choose', { index, run }); run is in dialogue.bubbles())
|
|
9
10
|
|
|
10
11
|
## Methods and properties
|
|
11
12
|
- `dialogue.define(speaker: string, nodes: DialogueScript)` — Define a dialogue (the name is usually the speaker)
|
|
12
13
|
- `dialogue.start(speaker: string, nodeId?: string, onEnd?: (() => void) | null, opts?: { channel?, at?, onCancel? })` — Start a dialogue: from node nodeId (default 'start'), onEnd is called when it ends. Main channel (default): locks game input and takes Esc; its choices take the UI choice cursor. onCancel: what the back key (Esc) does while it is on top of the UI focus stack (default: nothing). channel: 'bubble' plays the script as bubble lines over at (no lock, no choices; a running conversation is untouched). Ending the playthrough (engine.session newGame / load / quit) closes it without calling onEnd. Example: `engine.dialogue.start('guard', 'start', null, { channel: 'bubble', at: guard.root })`
|
|
13
14
|
- `dialogue.say(text: string | DialogueScript, opts?: { speaker?, node?, channel?, onCancel? } & BubbleOptions) → SayPromise` — Say a one-off line (no need to define first); the Promise resolves when it is done. channel: 'bubble' = over at while the player keeps playing (barks, shop chatter, radio); several speakers at once, queued per speaker. When the playthrough ends (engine.session) the line is dropped and the Promise never resolves, so code awaiting it does not run in the next playthrough. Example: `await engine.dialogue.say('Reloading!', { speaker: 'Mira', channel: 'bubble', at: mira.root })`
|
|
14
|
-
- `dialogue.bubbles() → { speaker, text, queued }[]` — Lines on the bubble channel now
|
|
15
|
+
- `dialogue.bubbles() → { speaker, text, queued, run?, choices? }[]` — Lines on the bubble channel now
|
|
15
16
|
- `dialogue.end()` — End the main dialogue
|
|
16
17
|
- Properties:
|
|
17
18
|
- `state: DialogueState` Story state: state.flags is engine.vars.flags (autosaved)
|
package/docs/api/engine.md
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
- `canvas?: HTMLCanvasElement | HTMLElement` Canvas element (required unless renderer is given), e.g. document.getElementById('view')
|
|
6
6
|
- `renderer?: 'webgl' | 'webgpu' | EngineRenderer` 'webgl' (default): the engine builds a WebGLRenderer. 'webgpu': it builds three's WebGPURenderer (needs import 'threedog/tsl' first) and start() awaits its init(). Or a ready three.js renderer (WebGLRenderer or WebGPURenderer) used as is; canvas then defaults to renderer.domElement.
|
|
7
7
|
- `fallback?: 'webgl2' | 'webgl' | 'error'` WebGPU route only: what start() does when the browser gives no WebGPU. 'webgl2' (default): the same WebGPURenderer on its WebGL2 backend, TSL keeps working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
|
|
8
|
-
- `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias.
|
|
8
|
+
- `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. It is fixed with the canvas: a player's settings row changes it at the next launch
|
|
9
9
|
- `pixelRatio?: number` Render resolution, default min(device pixel ratio, 1.5); the low tier uses at least 0.75 x device pixel ratio (never below 1). describe().render.scale reports it
|
|
10
|
+
- `pixelSize?: number` Real screen pixels per art pixel, a whole number from 1 up: art pixels of exactly one size at any display scale, through page zoom and moves to another display. Sets image-rendering: pixelated, antialias defaults to off, adaptive resolution stops, and the last few real pixels (fewer than k) at the right and bottom stay empty. Example: `createEngine({ canvas, pixelSize: 3 })`
|
|
10
11
|
- `adaptiveResolution?: boolean` Automatically lower resolution when the frame rate is too low, default true. Never silent: a dev warning once, and describe().render.scale.autoLowered
|
|
11
12
|
- `targetFps?: number` Target frame rate for automatic resolution lowering, default 55
|
|
12
13
|
- `ui?: UIOptions` 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 default parts (theme, css, fonts, templates). Example: `createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })`
|
|
@@ -39,19 +40,18 @@
|
|
|
39
40
|
- `engine.setCamera(kind: CameraKind, opts?: object) → CameraRig` — Switch the camera at runtime between kinds, once a camera module is installed (openWorld installs followCamera; with none it throws camera-none naming the module to install, e.g. engine.use(fixedCamera({ position, lookAt }))): the target and horizontal heading carry over; the first-person camera hides the character body automatically (the shadow stays) and locks / releases the mouse; the camera switched out is kept, with its parameters, for switching back. Passing opts rebuilds this kind of camera with the new parameters. A wrong kind throws and lists the available options. Example: `engine.onFrame(() => { if (engine.input.pressedRaw('toggleView')) engine.setCamera(engine.cameraRig.kind === 'follow' ? 'firstPerson' : 'follow'); });`
|
|
40
41
|
- `engine.use(...mods: (ModuleInput | { replaces })[])` — Install one or more modules (in order; dependencies must be installed first). A last argument { replaces: 'slot' } swaps the module that holds that exclusive slot: it is unloaded first (its handles, changes and dispose) and put back if the new install fails. Example: `engine.use(myInventory(), { replaces: 'inventory' })`
|
|
41
42
|
- `engine.unuse(name: string)` — Unload one installed module: its tracked handles, its slots and ctx.mod entries, its dispose. What it added some other way stays (dev reports a picture module's leftovers). Throws while another module still requires it. To swap a holder use engine.use(mine(), { replaces: 'slot' }). Example: `engine.unuse('rain');`
|
|
42
|
-
- `engine.has(name: string) → boolean` — Whether a module is installed
|
|
43
|
+
- `engine.has(name: string) → boolean` — Whether a module of this name, or a provider of this capability, is installed. Installed only: engine.explain({ module: name }) says whether it is running
|
|
43
44
|
- `engine.setGround(g: Partial<Ground>)` — Set the ground (called by the terrain and level modules); missing parts fall back to flat ground
|
|
44
45
|
- `engine.surface(x: number, z: number, refY?: number) → number` / `surface(at: PositionLike, refY?: number) → number` — Ground height (meters) at (x, z); a position or object also works: engine.surface(mesh.position). 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 standing under a bridge gives the ground and standing on it gives the deck; without it the highest layer is used (as before). Procedural terrain and flat ground have one layer and ignore refY. Off the outline of terrain({ shape }) it is -Infinity (no ground there; engine.ground.has(x, z) says so as a boolean)
|
|
45
|
-
- `engine.slope(x: number, z: number) → number` / `slope(at: PositionLike) → number` — Slope at (x, z); a position or object also works
|
|
46
|
-
- `engine.groundType(x: number, z: number) → string` / `groundType(at: PositionLike) → string` — Ground type at (x, z) (for footsteps, particles); a position or object also works. 'void' off the outline of terrain({ shape })
|
|
47
|
-
- `engine.waterAt(x: number, z: number) → number` / `waterAt(at: PositionLike) → number` — Water surface height at (x, z): standalone water bodies first, otherwise the global water level; -Infinity when there is no water. A position or object also works
|
|
46
|
+
- `engine.slope(x: number, z: number, refY?: number) → number` / `slope(at: PositionLike, refY?: number) → number` — Slope at (x, z); a position or object also works
|
|
47
|
+
- `engine.groundType(x: number, z: number, refY?: number) → string` / `groundType(at: PositionLike, refY?: number) → string` — Ground type at (x, z) (for footsteps, particles); a position or object also works. 'void' off the outline of terrain({ shape })
|
|
48
|
+
- `engine.waterAt(x: number, z: number, refY?: number) → number` / `waterAt(at: PositionLike, refY?: number) → number` — Water surface height at (x, z): standalone water bodies first, otherwise the global water level; -Infinity when there is no water. A position or object also works
|
|
48
49
|
- `engine.snapToGround(obj: T, offset?: number) → T` — Put an object on the ground under it (y = ground height + offset) and return the object. With multi-layer ground the object's current y is the reference height
|
|
49
50
|
- `engine.addWaterBody(opts: WaterBodyOptions) → Handle & { body: WaterBody }` — Add a water body (give radius for a circle, halfWidth / halfDepth for a rectangle) and return a handle { body, remove() }. The water module draws it
|
|
50
51
|
- `engine.t(key: string, params?: Record<string, any>) → string` — Get UI text (i18n): {name} in the text takes params.name, {key:action} the label of the key bound to that action; a key with no text comes back as itself. Example: `engine.t('shop.buy', { name: 'Fish' });`
|
|
51
52
|
- `engine.add(obj: T, ...more: (Object3D | { id?, save? })[]) → T` — Add objects to the scene and register them (engine.thing), returns the first one. The last argument may be { id?, save? }: id makes thing.set / thing.remove changes saved (unique, no '#', one object per call); without it a unique obj.name is used, else a session id obj#n. save: true asks dev to warn when it cannot be saved. engine.scene.add adds without registering. Example: `engine.add(windmill, { id: 'windmill' });`
|
|
52
53
|
- `engine.thing(idOrObj: string | Object3D) → Thing` — What a thing is and what a save keeps: a world record id, an engine.add id or name, or any Object3D (its registered ancestor). object is the live Object3D (not enumerable). Throws with the closest id when nothing matches. Change it with ops.run('thing.set' / 'thing.remove', { id, ... }). Example: `engine.thing('windmill').saved // 'code'`
|
|
53
54
|
- `engine.remove(...objs: Object3D[])` — Fully delete an object (use it when you no longer want the object): removes it from its parent, unregisters rays, and releases the geometry and materials of it and its children (textures and geometry / materials shared by assets are not released)
|
|
54
|
-
- `engine.detach(...objs: Object3D[])` — Only take it off its parent without releasing GPU memory (use when you will add it back later). Use remove for objects you no longer need
|
|
55
55
|
- `engine.onFixed(fn: (dt: number) => void, opts?: { channel?, phase? }) → Handle` — Fixed-step logic (60 times per second, dt in fixed seconds): movement, physics, cooldowns, and gameplay keys (read pressed() here: a per-step snapshot, independent of frame rate). dt is real seconds (always 1/60) unless { channel } names a time channel: then the channel's scaled dt. phase 'early' (default) runs before every module fixed hook (the player has not moved yet this step); 'late' after them, before the clock (hit checks, reading this step's result). Returns a handle { remove() }. Example: `engine.onFixed(() => checkHits(engine.player.position), { phase: 'late' })`
|
|
56
56
|
- `engine.onFrame(fn: (dt: number) => void) → Handle` — 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. Returns a handle { remove() }
|
|
57
57
|
- `engine.onRender(fn: (ctx) => void, opts?: { when?: 'before' | 'after' }) → Handle` — Around the main frame render, after the camera update and batching. when 'before' (default): render into your own render target here (mirror, minimap, portal, picking); the render target is reset to the screen afterwards. 'after': right after the frame (read pixels). The main frame render itself stays the engine's (post chain). Returns a handle { remove() }. Example: `const rt = new THREE.WebGLRenderTarget(256, 256); engine.onRender(({ renderer, scene }) => { renderer.setRenderTarget(rt); renderer.render(scene, mapCam); });`
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
- `engine.bakeProbes(opts: { bounds, spacing, resolution?, include?, owner? }) → Promise<ProbeSet>` — (experimental) Bake a grid of light probes from the scene as it is now: three's probe grid renders a cube at every grid point and keeps spherical harmonics, and every lit pixel inside the grid then takes its own interpolated light, on WebGL and WebGPU alike. The grid adds to whatever ambient light the scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so). Outside the grid there is no probe light. A load-time cost, not per frame: 6 renders per probe, a few probes per task so the page keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once: bake at start-up, not mid-play. Example: `const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving }); saveFile('probes.json', JSON.stringify(probes.toJSON()));`
|
|
60
60
|
- `engine.loadProbes(json: ProbeData, opts?: { owner?: string }) → ProbeSet` — (experimental) A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added. Example: `const probes = engine.loadProbes(await (await fetch('probes.json')).json());`
|
|
61
61
|
- `engine.loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }) → Promise<Lightmap>` — (experimental) Put a baked lightmap on the scene: `threedog bake light` wrote the file from the meshes the game marked `userData.static = true`; this rebuilds each with its second UV set and sets plain `material.lightMap`, on WebGL and WebGPU alike. Call it once the level is built, with its lights as they will be played. Nothing runs per frame. Keep the sun real-time; the ambient light the bake saw (hemisphere, environment) has to go, or it counts twice. A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what was skipped, moved or doubled. Example: `const light = await engine.loadLightmap('light/level.lightmap');`
|
|
62
|
-
- `engine.setPixelRatio(p: number)` — Render resolution, and the top adaptive resolution climbs back to
|
|
62
|
+
- `engine.setPixelRatio(p: number)` — Render resolution, and the top adaptive resolution climbs back to. Throws while pixelSize is on
|
|
63
|
+
- `engine.setPixelSize(k: number | null)` — One art pixel becomes k real screen pixels (createEngine({ pixelSize }) at runtime). While on, adaptive resolution stops, engine.setPixelRatio throws and a photo keeps the art pixels. null turns it off and brings the ratio from before back. Example: `engine.setPixelSize(3);`
|
|
63
64
|
- `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit)
|
|
64
65
|
- `engine.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY). The ray comes from the camera as last drawn: a rig.yaw / rig.pitch write reaches it on the next drawn step, so several shots in one step with recoil between them cast from the rig's angles with engine.raycast (recipe 19)
|
|
65
66
|
- `engine.applyState(params: StateParams) → Promise<{ ok: boolean, refused: {…` — Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
- `engine.checkSkip(seconds: number, opts?: { ignore?: string[] }) → Promise<{ ok: boolean; code?: 'fr…` — Consistency check: engine.skip({ seconds }) vs stepping the same span in fixed steps; compares the saved state. Leaves the world at the stepped state (use a scratch playthrough or a test). Example: `const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);`
|
|
74
75
|
- `engine.checkSave(opts?: { ignore?: string[] }) → Promise<{ ok: boolean; diffs: { p…` — Consistency check: save -> load gives the same saved state back (nothing is written to the browser). Example: `const r = await engine.checkSave(); if (!r.ok) console.log(r.diffs);`
|
|
75
76
|
- `engine.describeText(opts?: { radius?, full?, path? }) → string` — The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, the game's describe.add sections, one line per module with its key counts, the engine tables such as shared / slots / owned as one count line), ending with how to expand. { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data). Example: `engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })`
|
|
76
|
-
- `engine.explain(q: { op, args?, actor? } |
|
|
77
|
+
- `engine.explain(q: { op, args?, actor? } | { value: string } | { thing } | …) → { ok, code?, text, detail?, recent?, events?, … }` — Why something is the way it is. { op, args?, actor? }: text says whether it can run now, and if not the reason and the op's note on fixing it (reason first); detail has the last attempt and the events around it; recent / events are the raw last 5 attempts and event names within a step of the last one. { value }: who last wrote a watched value, with its history. { thing: id }: where the id comes from; detail is the whole ThingExplanation. { module } / { capability }: whether it runs and what blocks it. Other keys are answered by modules (definition field explain: { key(e, value, query) { return { ok, text } } }); the quests module answers { quest: id }. Example: `engine.explain({ op: 'shop.buy', args: { shop: 'bakery', item: 'bread' } }).text // 'shop.buy {...} cannot run now: noMoney (Not enough gold)'`
|
|
77
78
|
- `engine.profile(on: boolean)` / `profile() → Record<string, number> | null` — Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns { moduleName: average milliseconds per rendered frame } and resets, or null when not on
|
|
78
79
|
- `engine.dispose(opts?: { keepContext?: boolean })` — 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 memory (scene, assets cache, post-processing, renderer). After that no callbacks fire and step() returns null. Safe to call repeatedly. Don't use it for level changes; use level.track(handle). The engine's own renderer gives its WebGL context back (browsers keep about 16 live ones), so that canvas cannot host a new engine; keepContext: true keeps it. A renderer passed to createEngine({ renderer }) is never released.
|
|
79
80
|
- `engine.counts() → EngineCounts` — Counts for leak hunting: they should not keep growing after repeatedly entering / leaving levels or opening / closing windows. geometries / textures come from three.js renderer.info.memory (counted only after rendering)
|
|
@@ -81,10 +82,10 @@
|
|
|
81
82
|
## engine properties (module properties are on each module page)
|
|
82
83
|
- `validate: boolean` False when createEngine({ validate: false }) turned the development checks off for this engine
|
|
83
84
|
- `renderer: EngineRenderer` three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer)
|
|
84
|
-
- `tier: 'low' | 'high'`
|
|
85
|
+
- `tier: 'low' | 'high'` The one quality value, what everything that scales by quality reads: the device's tier, 'low' (phones, integrated graphics) / 'high', unless the player's preset says otherwise (shared point 'tier'). A headless page takes the device's from ?threedog-tier=low/high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier)
|
|
85
86
|
- `scene: import('three').Scene` three.js scene
|
|
86
87
|
- `lights: { sun, hemi }` Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
|
|
87
|
-
- `camera: import('three').
|
|
88
|
+
- `camera: import('three').Perspec… | import('three').Orthogr…` The camera the engine draws with, a plain THREE.PerspectiveCamera to begin with. Assign a real THREE.PerspectiveCamera or THREE.OrthographicCamera to draw through it; any other class is refused [camera-option].
|
|
88
89
|
- `focus: Vector3` Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the player by default), which does not follow the camera
|
|
89
90
|
- `ground: Ground` Current ground
|
|
90
91
|
- `movement: Readonly<MovementProfile>` Shared parameters for whether a character can walk somewhere (set by createEngine({ movement }), read-only); same-named options of individual modules are only overrides
|
|
@@ -94,9 +95,7 @@
|
|
|
94
95
|
- `ready: boolean` phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property)
|
|
95
96
|
- `disposed: boolean` phase is 'disposed'
|
|
96
97
|
- `moduleOrder: string[]` (experimental) Execution order of module hooks (module names, first -> last), for debugging "who runs before whom"
|
|
97
|
-
- `moduleStates: Record<string, 'registered' | 'initializing' | 'running' | …` (experimental) Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'. A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
|
|
98
98
|
- `error: EngineError | null` Gameplay error in development / testing (module hooks, onFixed / onFrame / clock callbacks, event listeners): { where (location of the error), message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
|
|
99
|
-
- `disabledModules: Set<string>` (experimental) Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft)
|
|
100
99
|
- `signal: AbortSignal` The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on dispose()
|
|
101
100
|
- `uiRoot: HTMLDivElement` UI root node: UI elements of the engine and modules hang under it (don't attach to document.body directly), the whole tree is removed on dispose()
|
|
102
101
|
- `modules: Map<string, ModuleDef>` Installed modules: name -> module definition
|
|
@@ -109,6 +108,7 @@
|
|
|
109
108
|
- `input: Input` Input
|
|
110
109
|
- `audio: Audio` Audio
|
|
111
110
|
- `assets: Assets` Assets
|
|
111
|
+
- `picture: any` The API of the module holding the 'picture' slot (recipe 62), undefined when no look is installed: engine.use(next(), { replaces: 'picture' }) changes it, so read it again after a switch
|
|
112
112
|
- `loading: Loading` Observable loading: every asset load, module init / isReady and track() step as a task (phase, error, source manifest)
|
|
113
113
|
- `post: PostFX` Post-processing: named effects in slots (add / get / enable / list)
|
|
114
114
|
- `occlusion: Occlusion` Occlusion culling of the engine's big things (hlod cells, batched groups) on both renderers. Off by default; it pays only when heavy things hide behind others (recipe 34)
|
|
@@ -159,10 +159,12 @@
|
|
|
159
159
|
- `provides?: (PictureSlot | (string & {}))[]` Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
|
|
160
160
|
- `optional?: string[] | Record<string, string>` Optional dependencies (modules the code uses as e.xxx?. or guards with if (e.xxx); rule R16 requires listing them all). An array only registers them; written as { moduleName: 'what is lost when missing' }, start() prints a one-time development hint when one is missing; use this form when it changes gameplay results
|
|
161
161
|
- `stage?: 'control' | 'ground' | 'environment' | 'gameplay' | 'effects' | 'late' | 'audio'` Hook stages, only the run order (first -> last): 'control' timeline, camera -> 'ground' terrain, level -> 'environment' weather, sky, water -> 'gameplay' interactions, dialogue, triggers -> 'effects' particles, settings, objective markers -> 'late' (default) -> 'audio' music. Within a stage use before / after, then install order.
|
|
162
|
-
- `before?: string[]` Hooks run before these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs earlier)
|
|
163
|
-
- `after?: string[]` Hooks run after these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs later)
|
|
162
|
+
- `before?: string[]` Hooks run before these modules or capabilities, inside one stage (ignored if not installed; a capability means whichever module provides it now; use() throws on a cycle, or when the other module's stage already runs earlier; reached through a capability that is a dev warning and the stage order stays)
|
|
163
|
+
- `after?: string[]` Hooks run after these modules or capabilities, inside one stage (ignored if not installed; a capability means whichever module provides it now; use() throws on a cycle, or when the other module's stage already runs later; reached through a capability that is a dev warning and the stage order stays)
|
|
164
164
|
- `critical?: boolean` The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of starting a broken game. Without it a failed init is reported by severity (type picture / ui: disabled and the game carries on; other types: error tiers) and start() goes on. Example: `engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })`
|
|
165
|
-
- `
|
|
165
|
+
- `content?: Record<string, ContentSection>` Content sections this module owns: their format, checks and how the data becomes live state (validate, prepare, commit). See core/base/sections.js
|
|
166
|
+
- `noSkip?: string` Why a module with a fixed hook has no skip hook
|
|
167
|
+
- `skipKind?: 'exact' | 'approx' | 'step' | 'none'` How engine.skip advances it. exact: the same state as stepping, from the clock or a hook. approx: a hook catches up with an estimate. step: a hook replays the steps. none: a jump moves nothing here. A module with a fixed or skip hook declares it (engine.catalog reports one that does not); engine modules always do
|
|
166
168
|
- `params?: any` The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it
|
|
167
169
|
- `docs?: string` Where its docs live, shown by engine.catalog
|
|
168
170
|
- `explain?: Record<string, (e: Engine, value: any, query: Record<string…` Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) }
|
|
@@ -170,7 +172,7 @@
|
|
|
170
172
|
- `install(e: Engine, ctx: ModuleCtx) → Api` — Install: create and return the object the game uses (engine.name). Register listeners / timers through ctx.track so they leave with the module (a use() batch that rolls back, a failed init, engine.dispose). Example: `install(e, ctx) { ctx.track(e.events.on('item:add', onAdd)); return api; }`
|
|
171
173
|
- `init(e: Engine, ctx: ModuleCtx) → void | Promise<void>` — Called at startup (download things, wait for assets); may be async. ctx is the same as install's
|
|
172
174
|
- `isReady(e: Engine) → boolean` — The loading screen waits until this returns true before disappearing (the hook is called isReady; in the engine ready is always a boolean property)
|
|
173
|
-
- `afterLoad(e: Engine) → void | Promise<void>` — After a save loaded: rebuild what the loaded state needs nearby; gameplay waits frozen until the returned Promise resolves
|
|
175
|
+
- `afterLoad(e: Engine, turn: SaveTurn) → void | Promise<void>` — After a save loaded: rebuild what the loaded state needs nearby; gameplay waits frozen until the returned Promise resolves. turn: as SaveProvider.load
|
|
174
176
|
- `fixed(dt: number, e: Engine)` — Fixed step (60 times per second); dt is in seconds
|
|
175
177
|
- `frame(dt: number, e: Engine)` — Once per frame; dt is in seconds
|
|
176
178
|
- `afterRender(dt: number, e: Engine)` — After rendering
|
package/docs/api/events.md
CHANGED
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
- `camera:change` [{ kind: string; previous: string }] engine.setCamera switched the camera kind; settings that belong to the camera (sensitivity, invert Y, field of view) are re-applied on it
|
|
37
37
|
- `character:jump` [{ character: Character; air: boolean; index: number }] A character jumped
|
|
38
38
|
- `character:launch` [{ character: Character; speed: number; owner: string }]
|
|
39
|
-
- `
|
|
39
|
+
- `link:enter` [{ id: string; character: Character; crossing: LinkCrossing }] (experimental) A walker reached a nav link. Set crossing.seconds here to say how long it takes
|
|
40
|
+
- `link:exit` [{ id: string; character: Character | null; crossing: LinkCrossing }] (experimental) A crossing ended: landed, or cut short (npc.placeAt, walk.remove()). character is null for an NPC that went out of range mid-crossing
|
|
41
|
+
- `character:fall` [{ character: Character; safe: Vector3 | null }]
|
|
40
42
|
- `character:model` [{ character: Character; model: Object3D }] A character's model named by asset finished loading and replaced the placeholder body (same root; anim is now set)
|
|
41
43
|
- `character:step` [{ character: Character }] A foot of a walking character came down; character.groundType() is what it stepped on
|
|
42
44
|
- `character:land` [{ character: Character; impact: number }] A character landed; impact is the landing speed (m/s), the larger the harder the fall
|
|
@@ -56,13 +58,19 @@
|
|
|
56
58
|
- `quest:done` [{ id: string }] A quest completed
|
|
57
59
|
- `quest:part` [{ id: string; step: number; part: number }] A part of a parallel quest step was met; step and part are indexes (starting at 0)
|
|
58
60
|
- `quest:fail` [{ id: string }] A quest failed (its fail condition held); quests.start(id) may begin it again
|
|
61
|
+
- `quest:unpaid` [{ id: string; code: string; failed: { word: string; code: string; fa… A finished quest's reward was not given. failed: each word that failed; owed: the items the quest still owes, null when none or when onUnpaid took it
|
|
62
|
+
- `content:failed` [{ code: string; failed: { word: string; code: string; facts: any }[]… A content effect word failed ({ give } in a full bag, { op } refused), wherever it ran: a dialogue do, a trigger, a reward, content.run. actor: whose effect it was
|
|
59
63
|
- `photo:taken` [PhotoShot] A photo was taken
|
|
60
64
|
- `photo:denied` [{ reason: string }] The photo key was pressed but the op photo.take was refused (reason from photo.canTake(), 'denied' when it returned false)
|
|
61
65
|
- `trigger:enter` [TriggerEvent] Entered a trigger zone
|
|
62
66
|
- `trigger:exit` [TriggerEvent] Left a trigger zone
|
|
63
|
-
- `level:
|
|
67
|
+
- `level:loading` [LevelLoadingEvent] Level finished loading
|
|
68
|
+
- `level:loaded` [LevelLoadedEvent]
|
|
69
|
+
- `level:unloaded` [LevelUnloadedEvent]
|
|
70
|
+
- `level:playable` [LevelPlayableEvent]
|
|
71
|
+
- `level:failed` [LevelFailedEvent]
|
|
64
72
|
- `timeline:start` [{ id: number }] A cutscene started
|
|
65
|
-
- `timeline:end` [{ id: number;
|
|
73
|
+
- `timeline:end` [{ id: number; ending: 'finished' | 'skipped' | 'dropped' | 'failed';… A cutscene ended; ending says how, error why it failed
|
|
66
74
|
- `template:stage` [TemplateStageEvent] A content template instance entered a new stage by growing (templates with stages)
|
|
67
75
|
- `ground:change` [{ x0: number; z0: number; x1: number; z1: number }] The ground's shape or type changed in this world-space box (engine.terrain.edit): cached ground samples (path rasters) inside it are stale
|
|
68
76
|
- `rigid:rebuilt` [{ world: any; player: any; bodies: Record<string, any> }] rigid: newGame / a load rebuilt the physics world (a fresh page for physics) and the engine's bodies are back (entry.body is the rebuilt Rapier body; bodies maps the ids given to addBox / addBall / addHull / addWheeled). The old world's joints were freed with it: re-create the game's joints here (recipes/11-vehicles.md, Joints). Not emitted while a vehicle exists (the world is kept then, joints included)
|
|
@@ -87,13 +95,15 @@
|
|
|
87
95
|
- `net:result` [{ seq: number; name: string; ok: boolean; code: string | null; value… 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
|
|
88
96
|
- `engine:error` [EngineError] A gameplay error in development / testing; gameplay is frozen (error severity levels, see engine.error)
|
|
89
97
|
- `module:disabled` [{ name: string; message: string }] A picture or ui module errored and was disabled (the game continues)
|
|
98
|
+
- `module:restored` [{ modules: any[] }]
|
|
99
|
+
- `state:replaced` [{ undone: boolean }]
|
|
90
100
|
- `vehicle:enter` [{ character: Character; vehicle: Rideable }] A character boarded a vehicle
|
|
91
101
|
- `vehicle:exit` [{ character: Character; vehicle: Rideable }] A character exited a vehicle
|
|
92
102
|
- `flow:change` [{ from: string; to: string }] Game flow state changed
|
|
93
103
|
- `flow:transition` [{ phase: 'start' | 'end' }] Scene transition: phase 'start' begins fading to black, 'end' finishes fading back in
|
|
94
104
|
- `session:end` [] A playthrough ends (engine.session.newGame / load / quit), before the reset
|
|
95
105
|
- `session:start` [{ kind: 'new' | 'load'; slot?: string }] A playthrough started from a clean slate: kind 'new' (newGame) or 'load' (session.load, with the slot)
|
|
96
|
-
- `session:failed` [{ kind: 'new' | 'load'; slot?: string }] newGame / session.load failed (a save part's load() threw) and the game was rolled back: the old playthrough goes on, no session:start
|
|
106
|
+
- `session:failed` [{ kind: 'new' | 'load' | 'quit'; slot?: string }] newGame / session.load failed (a save part's load() threw) and the game was rolled back: the old playthrough goes on, no session:start
|
|
97
107
|
- `page:blur` [{ focused: boolean; visible: boolean }] The page went away: the window lost focus or the tab was hidden (engine.page)
|
|
98
108
|
- `page:focus` [{ focused: boolean; visible: boolean }] The page came back: focused and visible again
|
|
99
109
|
- `page:pointerlock` [{ locked: boolean }] The mouse lock on the canvas started or ended (Esc, alt-tab); cameras with pointerLock lock again on the next click
|
package/docs/api/ground.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# engine.ground (Ground) — Ground: whoever provides the ground height is the "terrain" (terrain module, level module, or the default flat y=0)
|
|
2
2
|
|
|
3
3
|
- `ground.height(x: number, z: number, refY?: number) → number` — 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); without it the highest layer is used. Single-layer ground ignores refY
|
|
4
|
-
- `ground.slope(x: number, z: number) → number` — Slope at (x, z) (height difference / horizontal distance)
|
|
5
|
-
- `ground.type(x: number, z: number) → string` — Ground type at (x, z) (landform name, e.g. 'meadow')
|
|
4
|
+
- `ground.slope(x: number, z: number, refY?: number) → number` — Slope at (x, z) (height difference / horizontal distance)
|
|
5
|
+
- `ground.type(x: number, z: number, refY?: number) → string` — Ground type at (x, z) (landform name, e.g. 'meadow')
|
|
6
6
|
- `ground.has(x: number, z: number) → boolean` — Is there ground at (x, z). Always true except off the outline of terrain({ shape }), where height is -Infinity and slope 0. Example: `if (engine.ground.has(x, z)) engine.snapToGround(chest);`
|
|
7
7
|
- `ground.voidY() → number` — Height below which something has fallen out of the world (terrain:void): engine.terrain.voidY with terrain({ shape }), else -Infinity
|
|
8
8
|
- `ground.forEachCollider(x: number, z: number, range: number, fn: (cx, cz, r) => void)` — Optional: iterate the circular colliders (tree trunks etc.) within range meters of (x, z)
|
package/docs/api/i18n.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
- `i18n.has(key: string) → boolean` — Whether the key exists
|
|
7
7
|
- Properties:
|
|
8
8
|
- `fallback: string` (experimental) Language used when a key is missing in the current one (default 'en')
|
|
9
|
-
- `locale:
|
|
9
|
+
- `locale: string` (experimental) Current language, e.g. 'zh-CN' ('zh' and 'zh-Hans' resolve to it, 'en-US' to 'en'). Read-only: setLocale changes it, and tells i18n:change
|
|
10
10
|
- `languages: string[]` (experimental) All available languages
|
package/docs/api/input.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
- `input.action(name: string, o?: { context?, label?, optional?, keys?, owner? }) → { name: string; remove(): void }` — Declare an action: its context and display name, never its keys (the game binds those). Modules call ctx.input.action (owned by the module, removed with it); a game's own action can pass keys to declare and bind in one line. context: the input context it is read in (default 'walk'); readable only while that context is on the stack and not shadowed, see push(). optional: true = the module works without it (number keys for dialogue choices), so reading it unbound is silent. A second owner declaring the same action with another context throws input-action-context. Example: `ctx.input.action('choice1', { context: 'dialog', label: 'dialogue.choice', optional: true }); // in a module: no keys`
|
|
4
4
|
- `input.bind(name: string | Readonly<Record<string,…, keys?: string | readonly string[], { owner }?: { owner?: string }) → { owner: string; remove(): void }` — Bind keys to an action (the game's choice; owner 'game'). Takes one action or a whole map, e.g. a preset: bind(presets.bindings.rtsRotate). Binding again as the same owner replaces; a DIFFERENT owner binding the same action throws input-bound-twice in dev (release: the later wins). An action nobody declared yet is created in context 'walk' (a module declaring it later sets its context; order does not matter). Example: `engine.input.bind('jump', ['Space', 'PadA']);`
|
|
5
|
-
- `input.touchButton(action: string, labelKey: string)` — Touch button (appears only on touch devices); pressing it triggers the action. labelKey is the string-table key of the button text (updates when the language changes)
|
|
5
|
+
- `input.touchButton(action: string, labelKey: string) → { remove(): void }` — Touch button (appears only on touch devices); pressing it triggers the action. labelKey is the string-table key of the button text (updates when the language changes). Returns { remove() }: a module tracks it, so the button leaves with the module
|
|
6
6
|
- `input.simulate(action: string, down?: boolean)` — Press (down true) or release an action from code, through the same path as a real key: tests, AI drivers, replays. Presses the action's first bound key and holds it until simulate(action, false), so the player walks like with a held key. Takes action names (moveForward, moveLeft, run, interact, ...; engine.input.actions lists them), not keys; an unknown name throws unknown-name with the closest one. Example: `engine.input.simulate('moveForward'); engine.step(1); engine.input.simulate('moveForward', false)`
|
|
7
|
+
- `input.seat(opts?: { pad?, keys? }) → Seat` — 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 createPlayer({ id, input }). 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`. Example: `const two = engine.input.seat({ pad: 1, keys: { moveForward: 'KeyI', moveBack: 'KeyK', moveLeft: 'KeyJ', moveRight: 'KeyL', jump: 'KeyU' } });`
|
|
7
8
|
- `input.rebind(action: string, keys: string | string[] | null)` — The player's rebinding (the settings menu calls this and saves it): replaces the game's keys on the settings layer of 'input.keys'. keys null takes the player's choice away (the game's or the default keys show again). Works before the action is declared (a saved binding is restored at start, the module declaring the action comes later). Example: `engine.input.rebind('jump', ['KeyJ']); engine.input.rebind('jump', null); // back to the game's keys`
|
|
8
9
|
- `input.rebound() → Record<string, string[]>` — The player's rebindings now in effect: { action: keys } (what the settings menu saves)
|
|
9
10
|
- `input.keysOf(action: string) → readonly string[]` — (experimental) 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
|
package/docs/api/interactions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine.interactions — interactions(opts?: InteractionsOptions)
|
|
2
2
|
|
|
3
|
-
Interaction prompts (interactions() module)
|
|
3
|
+
Interaction prompts (interactions() module). Press a key near a thing. Install: engine.use(interactions()); undefined until installed. onUse returning { ok: false, code } fails the use and spends nothing
|
|
4
4
|
|
|
5
5
|
- Options `InteractionsOptions`:
|
|
6
6
|
- `action?: string` Default action name, default 'interact'
|
package/docs/api/inventory.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine.inventory — inventory(opts?: InventoryOptions)
|
|
2
2
|
|
|
3
|
-
Inventory (inventory() module)
|
|
3
|
+
Inventory (inventory() module). Items, counts and containers, saved with the game. Install: engine.use(inventory()); undefined until installed. add() answers { ok }, read .ok
|
|
4
4
|
|
|
5
5
|
- Options `InventoryOptions`:
|
|
6
6
|
- `action?: string` Action name that opens the inventory, default 'inventory'
|
package/docs/api/level.md
CHANGED
|
@@ -14,20 +14,21 @@ Hand-built level (level() module)
|
|
|
14
14
|
- `colliderHeight?: number` (experimental) Minimum height of the collision box (meters)
|
|
15
15
|
- `sharpEdge?: number` (experimental) Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6
|
|
16
16
|
- `hideMarkers?: boolean` (experimental) Hide the marker placeholder meshes, default true
|
|
17
|
+
- `part?: boolean` true: do not take the ground slot; compositeGround({ parts: [{ of: 'level' }] }) does and reads level.ground
|
|
17
18
|
- `addToScene?: boolean` (experimental) Add the scene to engine.scene, default true
|
|
18
19
|
|
|
19
20
|
## Methods and properties
|
|
20
21
|
- `level.marker(name: string) → LevelMarker | null` — Get a marker, null if none
|
|
21
22
|
- `level.markersWith(prefix: string) → LevelMarker[]` — Get all markers whose names start with prefix, e.g. markersWith('npc_')
|
|
22
23
|
- `level.unload()` — (experimental) Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together)
|
|
23
|
-
- `level.load(urlOrScene: string | Object3D) → Promise<void>` — Change level
|
|
24
|
+
- `level.load(urlOrScene: string | Object3D, opts?: { turn?: SaveTurn }) → Promise<void>` — Change level (glTF path/asset name, or a THREE object). The new level is built first and replaces the old one only when that worked: level:loaded fires then. On failure the old level stays, level:failed fires and the Promise rejects. When a load changes level, the save system waits for it, and a level that fails rolls the save back. A load overtaken by a newer one or an unload resolves without a level. During a save load it waits for that load to end; a part's load() or an afterLoad passes the turn it got, and it goes at once
|
|
24
25
|
- `level.track(handle: T) → T` — Register things that belong to the current level and need not be kept (the { remove() } handles of triggers...); they are deleted automatically on level change / unload; returns the same handle. world data that keeps state (NPCs, pickups, props) needs no registration: with a zone, a level change only tears down the model
|
|
25
26
|
- Properties:
|
|
26
27
|
- `root: Object3D | null` Scene root node
|
|
27
28
|
- `markers: Record<string, LevelMarker>` All markers: name -> marker
|
|
28
29
|
- `spawn: Vector3` Spawn point position
|
|
29
30
|
- `heightfield: any` (experimental) Heightfield (for debugging)
|
|
30
|
-
- `ready: boolean`
|
|
31
|
+
- `ready: boolean` The level's state is committed and nothing is loading; level:loaded fires at this moment, level:playable once every module and required nearby build settled too. After unload() it is true with no level, since nothing is loading: root says whether a level stands
|
|
31
32
|
|
|
32
33
|
## Data structures
|
|
33
34
|
- **LevelMarker** Markers in the level (spawn, npc_*, trigger_*, marker_*), in world coordinates
|
package/docs/api/nav.md
CHANGED
|
@@ -4,7 +4,7 @@ Navmesh (nav() module)
|
|
|
4
4
|
|
|
5
5
|
- Options `NavOptions`:
|
|
6
6
|
- `cellSize?: number` Voxel cell size (meters), default 0.3; smaller is more accurate but slower to build
|
|
7
|
-
- `agentRadius?: number` Character radius (meters), default reads engine.movement.radius (this is an override)
|
|
7
|
+
- `agentRadius?: number` Character radius (meters), default reads engine.movement.radius (this is an override). The mesh built at load; a path with another radius gets a mesh of its own, on first ask
|
|
8
8
|
- `agentHeight?: number` Character height (meters), default reads engine.movement.height
|
|
9
9
|
- `maxClimb?: number` Step height that can be climbed (meters), default reads engine.movement.stepHeight
|
|
10
10
|
- `maxSlope?: number` Max walkable slope (degrees), default reads engine.movement.maxSlope
|
|
@@ -14,12 +14,14 @@ Navmesh (nav() module)
|
|
|
14
14
|
- `maxObstacles?: number` (experimental) Most TileCache obstacles (collision boxes are cut into several), default 1024
|
|
15
15
|
- `maxAgents?: number` (experimental) Most crowd agents (with crowd: true), default 128
|
|
16
16
|
- `arrive?: number` Meters past the character's radius a path may end short of its goal and still count as arrived, default 0.6
|
|
17
|
+
- `links?: NavLink[]` (experimental) Places joined by a jump or a climb instead of walking (Recast off-mesh connections); walkers cross them straight unless the game says otherwise
|
|
17
18
|
|
|
18
19
|
## Methods and properties
|
|
19
|
-
- `nav.findPath(from: PositionLike, to: PositionLike, opts?: { radius?, detailed? }) →
|
|
20
|
+
- `nav.findPath(from: PositionLike, to: PositionLike, opts?: { radius?, detailed? }) → NavPathPoint[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: { radius?: number; detailed: true }) → { status, path }` — Path from from to to [{ x, y, z }…] (meters); null if not ready or unreachable; radius: the body it must fit, default agentRadius. Usually use engine.characters.findPath
|
|
20
21
|
- `nav.dispose()` — Unload the navmesh (frees native objects); characters.findPath then falls back to A*
|
|
21
22
|
- Properties:
|
|
22
23
|
- `ready: boolean` The navmesh has been generated
|
|
24
|
+
- `links: readonly { id: string | number; from: { x: number; y: numbe…` (experimental) The links in effect, ends in 3D, in the order given to nav({ links }); empty until the mesh is built
|
|
23
25
|
- `navMesh: any` (experimental) Native Recast NavMesh (null until ready)
|
|
24
26
|
- `query: any` (experimental) Native Recast NavMeshQuery
|
|
25
27
|
- `tileCache: any` (experimental) Native Recast TileCache (for dynamic obstacles)
|
package/docs/api/particles.md
CHANGED
|
@@ -9,8 +9,8 @@ Particles (particles() module)
|
|
|
9
9
|
## Methods and properties
|
|
10
10
|
- `particles.define(name: string, opts?: ParticleOptions) → ParticleEffect` — Define an effect (same name replaces it, and emitters attached to it move to the new definition); params sit on top of particles({ effects, default }). Returns the effect object: .points is its THREE.Points (a Sprite on WebGPURenderer); .material is its plain three.js material (set your own and it is drawn as given, null gives the engine's back); .uniforms are the engine material's { value } objects (uMap, uHasMap, uScale, uMaxPx), which a ShaderMaterial of yours can share. A material of yours lasts until the effect is defined again. Example: `engine.particles.define('sparks', { blending: 'additive' }).material = myMaterial;`
|
|
11
11
|
- `particles.has(name: string) → boolean` — Whether this effect has been defined
|
|
12
|
-
- `particles.emit(name: string, position: PositionLike, opts?: { count?, overrides? })` — 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 cannot be changed temporarily)
|
|
13
|
-
- `particles.attach(name: string, object3d: THREE.Object3D, opts?: { rate?, offset?, overrides? }) → ParticleEmitter` — Keep emitting while following an object: rate per second, offset in the object's local coordinates [x, y, z] (meters). Returns a handle { remove(), rate, active } (active = false pauses)
|
|
12
|
+
- `particles.emit(name: string, position: PositionLike, opts?: { count?, overrides? })` — 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)
|
|
13
|
+
- `particles.attach(name: string, object3d: THREE.Object3D, opts?: { rate?, ratePerMeter?, offset?, overrides? }) → ParticleEmitter` — Keep emitting while following an object: rate per second, ratePerMeter per meter it moves (spread along the path, on top of rate), offset in the object's local coordinates [x, y, z] (meters). Returns a handle { remove(), rate, ratePerMeter, active } (active = false pauses)
|
|
14
14
|
- `particles.count(name?: string) → number` — Live particle count (no name = all)
|
|
15
15
|
- `particles.clear(name?: string)` — Clear one effect's (or all) particles
|
|
16
16
|
- Properties:
|
|
@@ -29,16 +29,19 @@ Particles (particles() module)
|
|
|
29
29
|
- `drag?: number` Air drag (fraction of speed lost per second)
|
|
30
30
|
- `wind?: number` How much wind affects it
|
|
31
31
|
- `windDir?: number[]` Wind direction [x, y, z]
|
|
32
|
-
- `size?: Range` Size at birth / at death (meters)
|
|
33
|
-
- `color?: ColorLike | ColorLike[]` Color at birth / at death (one color, or [birth, death]; an array, not a tuple, so a plain JS literal [0xffffff, 0xdddddd] type-checks)
|
|
34
|
-
- `opacity?: Range` Opacity at birth / at death, 0–1
|
|
32
|
+
- `size?: Range | number[][]` Size at birth / at death (meters), or stops over life: evenly spaced [a, b, c] or timed [[0, a], [0.2, b], [1, c]] (0 birth, 1 death)
|
|
33
|
+
- `color?: ColorLike | ColorLike[] | ColorLike[][]` Color at birth / at death (one color, or [birth, death]; an array, not a tuple, so a plain JS literal [0xffffff, 0xdddddd] type-checks), or stops over life as for size
|
|
34
|
+
- `opacity?: Range | number[][]` Opacity at birth / at death, 0–1, or stops over life as for size: [[0, 0], [0.1, 0.8], [1, 0]] fades in, then out
|
|
35
35
|
- `texture?: string | Texture | null` Texture (asset name, path or THREE.Texture); a soft round dot if omitted
|
|
36
36
|
- `blending?: Loose<'normal' | 'additive'>` 'normal' / 'additive' (glowing blend, for sparks)
|
|
37
37
|
- `spin?: number` Texture rotation speed (radians/second)
|
|
38
38
|
- `worldSpace?: boolean` With attach, whether particles stay in the world (true) or the emission direction rotates with the object (false)
|
|
39
39
|
- `fog?: boolean` Affected by fog, default true
|
|
40
40
|
- `maxPixels?: number` Largest on-screen size of one particle in pixels (smoke drifting past the camera stays bounded), default 512
|
|
41
|
+
- `ratePerMeter?: number` (experimental) Default particles per meter the emitter moves for attach, on top of rate, spread along the path it moved; default 0
|
|
42
|
+
- `soft?: number` (experimental) 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
|
|
41
43
|
- **ParticleEmitter** (extends Handle) Continuous emitter returned by attach() (a handle)
|
|
42
44
|
- `rate: number` Particles per second (can be changed at any time)
|
|
45
|
+
- `ratePerMeter: number` (experimental) Particles per meter the object moves, on top of rate (can be changed at any time)
|
|
43
46
|
- `active: boolean` false pauses
|
|
44
47
|
- `remove()` — Stop and remove (also removed automatically when the object leaves the scene)
|
package/docs/api/pickups.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine.pickups — pickups(opts?: PickupsOptions)
|
|
2
2
|
|
|
3
|
-
pickups()
|
|
3
|
+
pickups(). Things on the ground that go in the bag. Install: engine.use(pickups()) with inventory() and interactions(); undefined until installed. A full bag leaves the item on the ground
|
|
4
4
|
|
|
5
5
|
- Options `PickupsOptions`:
|
|
6
6
|
- `radius?: number` Reach of pickups that do not set their own radius (meters), default 2
|
package/docs/api/post.md
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# engine.post (PostFX)
|
|
2
2
|
|
|
3
|
-
- `post.object() → any` — (experimental) What the chain runs in, for reading, or null while no post work has run yet (built the first time an effect
|
|
3
|
+
- `post.object() → any` — (experimental) What the chain runs in, for reading, or null while no post work has run yet (built the first time an effect is on; it is not built here, so asking never costs a render target). WebGLRenderer: the three.js EffectComposer (pass list, sizes, its targets). WebGPURenderer: { pipeline, scenePass }, three's RenderPipeline and the scene's pass() node. Read-only by rule, not by lock: the engine owns it, rebuilds the chain whenever the list changes and disposes it with the engine. To add a pass use post.add, to own the whole chain post.own() (recipe 52). Why public: a game reading the chain had to dig into an internal field (review 2026-11-03)
|
|
4
4
|
- `post.targets() → { renderTarget1, renderTarget2, readBuffer, writeBuffer } | null | …` — (experimental) The composer's render targets, for reading (sample the last frame's color or depth in a game pass, check formats / samples), or null while there is no composer, and always on WebGPURenderer (its pass nodes own their targets: post.object().scenePass). renderTarget1 / renderTarget2 are the ping-pong pair. During the chain readBuffer is a pass's input and writeBuffer its output; EffectComposer swaps them after every pass with needsSwap (most passes; the scene RenderPass does not). The last pass draws to the canvas and still swaps, so after the frame (engine.onRender(fn, { when: 'after' })) neither target holds the final picture: writeBuffer holds the input of that last pass (readBuffer when the last pass does not swap) and readBuffer is stale. For the final image, render into a target of your own.
|
|
5
5
|
- `post.add(x: any, o?: { name?, slot?, order? }) → PostHandle` — The one way to add a post effect. x is a three.js Pass (WebGL), a TSL node function (input, ctx) => node (WebGPU), or an effect { name, create / node / fuse, slot, order, params, needsDepth, needsBuffers, backend, skipOnLowTier, facts } (both renderers when it gives create and node, or a fuse). A wrong shape throws with nothing added. needsDepth, needsBuffers ('normal' / 'diffuse' / 'velocity', WebGPU), backend ('webgpu': not on the WebGL2 backend), skipOnLowTier (held when engine.tier is 'low') and facts (shown by describe().render.post) are explained on PostEffect. A Pass that draws engine.scene takes the 'scene' slot, FXAA / SMAA / TAA 'final', any other 'hdr' after the effects already there, or 'ldr' once an OutputPass was added. A RenderPass of engine.scene and an OutputPass are the engine's own stages: skipped and said once (an OutputPass still marks where display color starts). Example: `const glow = engine.post.add(new UnrealBloomPass(size, 0.6, 0.4, 0.85), { name: 'glow' }); glow.enabled = false;`
|
|
6
6
|
- `post.get(name: string) → PostHandle | undefined` — (experimental) An added effect's handle (as add() returns it), or undefined. Example: `engine.post.get('bloom').set({ strength: 0.6 });`
|
|
7
7
|
- `post.own(on?: boolean)` — (experimental) Hand the built chain to the game: the engine stops rebuilding it, so the composer's passes (post.object().passes) or the WebGPU pipeline's outputNode are the game's to edit. own(false) gives it back and rebuilds from the list. describe().owned shows who has it. Example: `engine.post.own(); engine.post.object().passes.reverse();`
|
|
8
|
-
- `post.setAntialias(on: boolean)` — (experimental) Turn MSAA on or off. It is a render setting, not a drawing part. With no effect on, the start value is the canvas's own MSAA (free: no post chain); the other value, and any effect, draws through the chain, whose render targets carry the MSAA. Example: `engine.post.setAntialias(false);`
|
|
9
8
|
- `post.list() → { name, slot, order, enabled }[]` — (experimental) Effects in render order: [{ name, slot, order, enabled }]
|
|
10
9
|
- `post.render(dt: number, target?: any)` — Draw the frame through the chain. target: a render target to draw the finished picture into instead of the canvas (engine.renderOnce(target)); it gets the canvas's pixels (tone mapped, output color space). Why a target argument and not "set the render target first": the WebGL chain's last pass always writes to the canvas (EffectComposer renderToScreen); the WebGPU pipeline draws into whatever target is set.
|
|
11
10
|
- Properties:
|
|
12
|
-
- `antialias: boolean` (experimental) MSAA on.
|
|
13
|
-
- `active: boolean` Whether the post chain runs: an effect is on
|
|
11
|
+
- `antialias: boolean` (experimental) MSAA on or off in the post chain's render targets, for what runs through the chain. It is a render setting, not a drawing part. With no effect on nothing runs through the chain: the canvas's own MSAA shows, fixed when the context was made (createEngine({ antialias })). Example: `engine.post.antialias = false;`
|
|
12
|
+
- `active: boolean` Whether the post chain runs: an effect is on
|
|
14
13
|
|
|
15
14
|
## Data structures
|
|
16
15
|
- **PostEffect** An effect as data, the form post.add() takes. node (WebGPURenderer): returns the effect's output color node built on input (the color node so far); called again only when a param that is not a number, boolean, color or vector changes (those are live in ctx.p). An effect with only create cannot run on WebGPURenderer (it throws by name). create: builds the implementation the first time the effect is on (WebGL: a three.js postprocessing Pass); optional when fuse is given. fuse: see PostFuse; effects with a fuse in the same slot next to each other are merged (never in slot 'scene'), their params update in place (no update() needed). slot: a PostSlot; typed as any string too because a slot in a plain JS object (an effect returned from a function) is a string to TypeScript, and the chain throws on an unknown slot naming the valid ones.
|