threedog 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +411 -1
- package/README.md +8 -11
- package/core/{Animator.js → assets/Animator.js} +30 -18
- package/core/{Assets.js → assets/Assets.js} +131 -56
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +302 -0
- package/core/{assetHot.js → assets/assetHot.js} +9 -7
- package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
- package/core/{assetReport.js → assets/assetReport.js} +7 -14
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +47 -25
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +15 -12
- package/core/{Random.js → base/Random.js} +7 -4
- package/core/{Vars.js → base/Vars.js} +14 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +151 -125
- package/core/{errorHints.js → base/errorHints.js} +17 -10
- package/core/{errors.js → base/errors.js} +12 -10
- package/core/{events.generated.js → base/events.generated.js} +11 -0
- package/core/base/follows.js +26 -0
- package/core/base/math.js +66 -0
- package/core/{params.js → base/params.js} +5 -6
- package/core/base/saveValues.js +81 -0
- package/core/base/sections.js +97 -0
- package/core/base/spelling.js +32 -0
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +34 -34
- package/core/{Engine.js → engine/Engine.js} +137 -91
- package/core/{Loading.js → engine/Loading.js} +34 -5
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +32 -15
- package/core/{lifecycle.js → engine/lifecycle.js} +41 -34
- package/core/{loop.js → engine/loop.js} +88 -49
- package/core/engine/moduleSlots.js +176 -0
- package/core/{moduleTypes.js → engine/moduleTypes.js} +26 -14
- package/core/engine/modules.js +503 -0
- package/core/{page.js → engine/page.js} +59 -29
- package/core/{plugins.js → engine/plugins.js} +21 -12
- package/core/{services.js → engine/services.js} +50 -40
- package/core/{startup.js → engine/startup.js} +66 -54
- package/core/{Input.js → input/Input.js} +67 -39
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/input/inputKeyboard.js +39 -0
- package/core/{inputPad.js → input/inputPad.js} +24 -3
- package/core/{inputPointer.js → input/inputPointer.js} +11 -3
- package/core/input/inputSeat.js +66 -0
- package/core/{inputTouch.js → input/inputTouch.js} +24 -7
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +43 -18
- package/core/{Describe.js → inspect/Describe.js} +34 -26
- package/core/{Inspect.js → inspect/Inspect.js} +39 -10
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
- package/core/{UrlState.js → inspect/UrlState.js} +60 -24
- package/core/{catalog.js → inspect/catalog.js} +15 -8
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +4 -4
- package/core/{describeRender.js → inspect/describeRender.js} +24 -22
- package/core/{describeText.js → inspect/describeText.js} +17 -8
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/inspect/metadata.generated.js +4140 -0
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +130 -47
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/inspect/toolDoor.js +21 -0
- package/core/inspect/valueHistory.js +35 -0
- package/core/{Ops.js → ops/Ops.js} +44 -14
- package/core/{control.js → ops/control.js} +57 -31
- package/core/ops/holds.js +140 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +18 -5
- package/core/{opsCheck.js → ops/opsCheck.js} +11 -10
- package/core/{opsFail.js → ops/opsFail.js} +5 -7
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +9 -6
- package/core/{owned.js → ops/owned.js} +33 -19
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -16
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +34 -15
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +53 -27
- package/core/{Saves.js → saves/Saves.js} +171 -54
- package/core/saves/saveApply.js +312 -0
- package/core/{saveFiles.js → saves/saveFiles.js} +45 -38
- package/core/{saveVersions.js → saves/saveVersions.js} +24 -23
- package/core/saves/session.js +231 -0
- package/core/saves/stateReplace.js +184 -0
- package/core/{Rays.js → scene/Rays.js} +44 -30
- package/core/{Views.js → scene/Views.js} +16 -8
- package/core/{adaptive.js → scene/adaptive.js} +19 -9
- package/core/{canvasBox.js → scene/canvasBox.js} +4 -3
- package/core/scene/compositeGround.js +72 -0
- package/core/scene/floor.js +17 -0
- package/core/{gameLights.js → scene/gameLights.js} +17 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +6 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/scene/ground.contract.js +14 -0
- package/core/scene/ground.js +139 -0
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/scene/pixel.js +154 -0
- package/core/scene/pixelRatio.js +167 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +5 -5
- package/core/{sceneMethods.js → scene/sceneMethods.js} +43 -15
- package/core/scene/stepPoses.js +60 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
- package/core/{thingOps.js → scene/thingOps.js} +25 -16
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +10 -0
- package/core/scene/view.js +161 -0
- package/core/{Batching.js → stream/Batching.js} +85 -28
- package/core/{Stream.js → stream/Stream.js} +80 -38
- package/core/{batchGroups.js → stream/batchGroups.js} +11 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +7 -4
- package/core/{streamSources.js → stream/streamSources.js} +14 -8
- package/core/{Commits.js → threads/Commits.js} +17 -11
- package/core/{Jobs.js → threads/Jobs.js} +25 -13
- package/core/{Threads.js → threads/Threads.js} +21 -18
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +20 -11
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +28 -21
- package/core/{time.js → time/time.js} +32 -20
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +92 -72
- package/docs/API.md +33 -28
- package/docs/CODEMAP.md +121 -200
- package/docs/COMMANDS.md +77 -70
- package/docs/CONVENTIONS.md +167 -24
- package/docs/MIGRATING-0.8.md +171 -0
- package/docs/MIGRATING-1.0.md +101 -0
- package/docs/THREE.md +140 -38
- package/docs/api/assets.md +12 -13
- package/docs/api/audio.md +6 -5
- package/docs/api/budget.md +4 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +32 -29
- package/docs/api/characters.md +35 -24
- package/docs/api/clock.md +1 -1
- package/docs/api/collider3d.md +9 -0
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +18 -17
- package/docs/api/dialogue.md +5 -4
- package/docs/api/engine.md +58 -54
- package/docs/api/events.md +17 -6
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +6 -7
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +9 -8
- package/docs/api/interactions.md +5 -5
- package/docs/api/inventory.md +10 -10
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +10 -9
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +14 -12
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +10 -7
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +3 -3
- package/docs/api/post.md +21 -5
- package/docs/api/quests.md +7 -5
- package/docs/api/rays.md +7 -7
- package/docs/api/rigid.md +29 -19
- package/docs/api/saves.md +13 -11
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +8 -9
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +6 -8
- package/docs/api/terrainDraw.md +2 -2
- package/docs/api/timeline.md +4 -4
- package/docs/api/tools.md +27 -22
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +2 -2
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +27 -12
- package/docs/api/weatherDraw.md +4 -4
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +28 -43
- package/docs/recipes/02-npc.md +21 -23
- package/docs/recipes/03-items-pickups.md +37 -53
- package/docs/recipes/04-quests.md +5 -4
- package/docs/recipes/05-props-bake.md +34 -44
- package/docs/recipes/06-clock-events.md +31 -22
- package/docs/recipes/07-flow-scenes-pause.md +30 -32
- package/docs/recipes/08-weather-sky.md +91 -37
- package/docs/recipes/09-materials-lights-models.md +25 -39
- package/docs/recipes/10-blender-level.md +22 -11
- package/docs/recipes/11-vehicles.md +44 -24
- package/docs/recipes/12-navmesh.md +60 -15
- package/docs/recipes/13-animation.md +70 -22
- package/docs/recipes/14-custom-module.md +33 -20
- package/docs/recipes/15-perf.md +51 -28
- package/docs/recipes/16-dev-bridge.md +39 -58
- package/docs/recipes/18-world.md +49 -28
- package/docs/recipes/19-shooting-picking.md +7 -4
- package/docs/recipes/20-content-actions-save.md +55 -40
- package/docs/recipes/21-camera.md +47 -25
- package/docs/recipes/22-shop-gold.md +21 -16
- package/docs/recipes/23-ops.md +28 -24
- package/docs/recipes/26-ui-parts.md +25 -14
- package/docs/recipes/27-net.md +3 -5
- package/docs/recipes/28-terrain.md +119 -23
- package/docs/recipes/29-grid.md +3 -3
- package/docs/recipes/30-templates.md +63 -30
- package/docs/recipes/31-audio.md +7 -7
- package/docs/recipes/32-action-game.md +21 -11
- package/docs/recipes/33-stream-sources.md +6 -3
- package/docs/recipes/34-environment-lighting.md +72 -25
- package/docs/recipes/35-picture-from-reference.md +20 -23
- package/docs/recipes/36-ground-plants.md +106 -0
- package/docs/recipes/40-scene.md +18 -21
- package/docs/recipes/43-shader-patches-surfaces.md +27 -48
- package/docs/recipes/44-water-weather-hooks.md +56 -50
- package/docs/recipes/45-cascaded-shadows.md +41 -20
- package/docs/recipes/46-blender-art-route.md +9 -10
- package/docs/recipes/49-game-module-contract.md +7 -6
- package/docs/recipes/50-own-renderer.md +3 -2
- package/docs/recipes/51-capability-catalog.md +14 -8
- package/docs/recipes/52-around-the-picture.md +56 -100
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +17 -20
- package/docs/recipes/56-webgpu-tsl.md +28 -15
- package/docs/recipes/57-control.md +39 -12
- package/docs/recipes/58-input.md +15 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +30 -25
- package/docs/recipes/62-picture-code.md +129 -39
- package/docs/recipes/63-third-person-start.md +19 -5
- package/docs/recipes/64-particles.md +54 -5
- package/docs/recipes/65-swarm.md +140 -0
- package/docs/recipes/66-common-tasks.md +313 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +5 -5
- package/examples/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +15 -14
- package/examples/{sheepisland → perf-island}/assets.js +1 -1
- package/examples/{sheepisland → perf-island}/main.js +8 -8
- package/examples/{sheepisland → perf-island}/models.js +1 -1
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/GAMEMAP.md +4 -1
- package/examples/rc2d/GAMEMAP.md +4 -3
- package/examples/rc2d/main.js +1 -3
- package/examples/rc2d/rc2d.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +6 -5
- package/examples/techniques/contact-shadows/contactShadows.js +1 -1
- package/examples/techniques/contact-shadows/main.js +1 -1
- package/examples/techniques/interior-light/main.js +1 -1
- package/examples/techniques/modular-building/README.md +7 -6
- package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +2 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +9 -7
- package/examples/world/main.js +3 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +16 -12
- package/index.js +53 -32
- package/llms.txt +11 -14
- package/modules/ambience/Ambience.js +16 -11
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +18 -16
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +5 -5
- package/modules/camera/FixedCamera.js +43 -30
- package/modules/camera/FollowCamera.js +24 -15
- package/modules/camera/RtsCamera.js +12 -11
- package/modules/camera/common.js +72 -37
- package/modules/camera/contract.js +1 -0
- package/modules/camera/pixelSnap.js +62 -0
- package/modules/characters/Character.js +166 -70
- package/modules/characters/NPC.js +84 -44
- package/modules/characters/assetModel.js +16 -12
- package/modules/characters/astar.js +48 -27
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/character.contract.js +21 -0
- package/modules/characters/contract.js +17 -3
- package/modules/characters/index.js +240 -226
- package/modules/characters/moveHelpers.js +88 -12
- package/modules/characters/mover.contract.js +14 -0
- package/modules/characters/movers/common.js +22 -18
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +18 -10
- package/modules/characters/movers/simple.js +26 -13
- package/modules/characters/movers/support.js +24 -13
- package/modules/characters/npcAvoid.js +19 -16
- package/modules/characters/npcSim.js +88 -32
- package/modules/characters/npcView.js +19 -11
- package/modules/characters/pathAsync.js +81 -29
- package/modules/characters/pathJob.js +38 -21
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +120 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/seat.js +56 -0
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/vehicle.contract.js +8 -5
- package/modules/characters/walkTo.js +40 -33
- package/modules/collision/Collision.js +69 -45
- package/modules/collision/contract.js +15 -0
- package/modules/collision/grid.js +6 -1
- package/modules/content/explain.js +2 -3
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +5 -3
- package/modules/content/index.js +132 -114
- package/modules/content/loader.js +117 -140
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +54 -17
- package/modules/content/packs.js +5 -4
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +36 -0
- package/modules/content/props.js +22 -17
- package/modules/content/rules.js +47 -61
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +80 -49
- package/modules/content/words.js +47 -0
- package/modules/debug/DebugPanel.js +14 -45
- package/modules/flow/contract.js +2 -1
- package/modules/flow/index.js +30 -16
- package/modules/gameplay/Container.js +17 -13
- package/modules/gameplay/Containers.js +23 -6
- package/modules/gameplay/Dialogue.js +93 -34
- package/modules/gameplay/Interactions.js +93 -51
- package/modules/gameplay/Inventory.js +64 -22
- package/modules/gameplay/Quests.js +146 -30
- package/modules/gameplay/boxOps.js +8 -1
- package/modules/gameplay/dialogueBubbles.js +16 -12
- package/modules/gameplay/inventoryOps.js +11 -8
- package/modules/gameplay/pickups.js +63 -37
- package/modules/gameplay/questLog.js +4 -2
- package/modules/gameplay/questSave.js +9 -4
- package/modules/gameplay/quests.contract.js +1 -1
- package/modules/grid/Grid.js +2 -2
- package/modules/grid/Layer.js +12 -8
- package/modules/grid/index.js +28 -23
- package/modules/grid/ops.js +43 -46
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +42 -57
- package/modules/hud/index.js +22 -14
- package/modules/hud/parts.js +8 -8
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +29 -31
- package/modules/level/index.js +113 -161
- package/modules/level/load.js +196 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +40 -23
- package/modules/lights/index.js +33 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +90 -0
- package/modules/music/Music.js +34 -28
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +16 -0
- package/modules/nav/index.js +180 -49
- package/modules/nav/navPath.js +45 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +6 -5
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +95 -29
- package/modules/particles/effect.js +86 -32
- package/modules/particles/shaders.js +19 -1
- package/modules/photo/Photo.js +23 -23
- package/modules/rigid/RigidBodies.js +255 -89
- package/modules/rigid/Vehicles.js +17 -8
- package/modules/rigid/collider3d.contract.js +26 -0
- package/modules/rigid/ragdoll.js +298 -0
- package/modules/rigid/ragdollBones.js +209 -0
- package/modules/rigid/refresh.js +10 -0
- package/modules/rigid/sync.js +51 -20
- package/modules/settings/Settings.js +177 -61
- package/modules/settings/apply.js +20 -13
- package/modules/settings/sections.js +19 -14
- package/modules/settings/strings.js +2 -2
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +29 -22
- package/modules/sky/clouds.js +7 -7
- package/modules/sky/dome.js +33 -20
- package/modules/sky/domeLayers.js +9 -9
- package/modules/sky/environment.js +6 -6
- package/modules/sky/frame.js +19 -10
- package/modules/sky/season.js +7 -1
- package/modules/sky/shader.js +24 -25
- package/modules/sky/skyModule.js +17 -28
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +356 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +71 -59
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +14 -11
- package/modules/terrain/index.js +42 -42
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +45 -29
- package/modules/terrain/terrainGen.js +19 -12
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +83 -43
- package/modules/timeline/Tween.js +25 -19
- package/modules/timeline/shots.js +24 -17
- package/modules/triggers/index.js +95 -28
- package/modules/vegetation/Vegetation.js +34 -26
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +39 -18
- package/modules/vegetation/groundChunks.js +21 -38
- package/modules/vegetation/index.js +37 -12
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +20 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +52 -40
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +28 -23
- package/modules/world/World.js +28 -15
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +30 -17
- package/modules/world/persist.js +90 -27
- package/modules/world/pos.js +5 -5
- package/modules/world/records.js +37 -11
- package/modules/world/sim.js +78 -27
- package/modules/world/simFar.js +2 -2
- package/modules/world/state.js +43 -11
- package/modules/world/thingSource.js +20 -5
- package/modules/world/views.js +27 -14
- package/package.json +48 -7
- package/presets.js +1 -3
- package/render/PostFX.js +83 -53
- package/render/backend.js +31 -33
- package/render/cascades.js +17 -12
- package/render/cascades.tsl.js +5 -8
- package/render/daylight.js +20 -3
- package/render/detail.js +8 -7
- package/render/effects.js +28 -25
- package/render/fuse.js +3 -3
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +5 -10
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/particles.tsl.js +8 -6
- package/render/fx/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +30 -26
- package/render/fx/sky.tsl.js +15 -17
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +2 -2
- package/render/lighting.js +5 -3
- package/render/lightmap.js +41 -21
- package/render/lights.js +6 -6
- package/render/lit.js +24 -0
- package/render/materials.js +8 -7
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/occlusion.js +62 -15
- package/render/ownFrame.js +4 -4
- package/render/patches.js +15 -15
- package/render/postWebGL.js +15 -12
- package/render/probes.js +41 -19
- package/render/recordSweep.js +117 -0
- package/render/shaderErrors.js +10 -9
- package/render/shadowCache.tsl.js +107 -0
- package/render/shadowTypes.js +9 -0
- package/{core → render}/shadows.js +59 -13
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +336 -202
- package/types/gameplay.d.ts +254 -130
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +8 -16
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +28 -10
- package/types/generated/core/input/inputSeat.d.ts +26 -0
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +17 -3
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +6 -4
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +14 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +62 -18
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +3 -2
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +2 -2
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +22 -18
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Grid.d.ts +1 -0
- package/types/generated/modules/grid/Layer.d.ts +1 -1
- package/types/generated/modules/grid/index.d.ts +3 -3
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +5 -4
- package/types/generated/modules/sky/Sky.d.ts +21 -10
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +7 -5
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +14 -16
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +11 -7
- package/types/generated/render/PostFX.d.ts +21 -23
- package/types/generated/render/materials.d.ts +1 -0
- package/types/generated/render/occlusion.d.ts +9 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +47 -15
- package/types/physics.d.ts +150 -73
- package/types/pixel.d.ts +75 -0
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +48 -75
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +13 -5
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +7 -5
- package/core/assetEntry.js +0 -109
- package/core/engineCamera.js +0 -32
- package/core/ground.js +0 -104
- package/core/holds.js +0 -134
- package/core/math.js +0 -48
- package/core/moduleSlots.js +0 -100
- package/core/modules.js +0 -314
- package/core/saveApply.js +0 -210
- package/core/saveValues.js +0 -46
- package/core/session.js +0 -174
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- package/core/view.js +0 -43
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -320
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/MIGRATING-0.6.md +0 -126
- package/docs/PERF.md +0 -245
- package/docs/recipes/36-sky-ground-plants.md +0 -158
- package/docs/recipes/37-terrain-hooks.md +0 -115
- package/docs/recipes/38-environment-hooks.md +0 -67
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/47-island-snow-backdrop.md +0 -43
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/plain-picture/FINDINGS.md +0 -53
- package/examples/sheepisland/.threedog/content-index.json +0 -1
- package/modules/camera/projection.js +0 -21
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{cells.js → stream/cells.js} +0 -0
- /package/core/{streamCells.js → stream/streamCells.js} +0 -0
- /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
- /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
package/types/gameplay.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Gameplay modules: timeline, level, triggers, world changes, particles, settings, music, characters/NPCs, interactions, dialogue, inventory,
|
|
2
2
|
// quests, photo mode, ambience, debug.
|
|
3
3
|
import type { Object3D, Vector3, Vector2, Quaternion, Texture, ColorLike, Vec3Like, Ease, Handle, Range, XZ, Loose, PositionLike, Material } from './common';
|
|
4
|
-
import type { Engine } from './core';
|
|
5
|
-
import type {
|
|
4
|
+
import type { Engine, SaveTurn } from './core';
|
|
5
|
+
import type { LinkCrossing, NavPathPoint } from './nav';
|
|
6
|
+
import type { Input } from './generated/core/input/Input';
|
|
7
|
+
import type { Seat } from './generated/core/input/inputSeat';
|
|
6
8
|
import type { Animator, AnimatorOptions, Rideable } from './physics';
|
|
7
9
|
import type { WorldRecord } from './generated/modules/world/World';
|
|
8
10
|
|
|
@@ -10,7 +12,7 @@ import type { WorldRecord } from './generated/modules/world/World';
|
|
|
10
12
|
// Timeline timeline()
|
|
11
13
|
// ======================================================================
|
|
12
14
|
|
|
13
|
-
/** Promise of a tween: await it to wait for the end; finish() jumps to the end now, remove() stops at the current position */
|
|
15
|
+
/** Promise of a tween: await it to wait for the end, it rejects if a write throws; finish() jumps to the end now, remove() stops at the current position */
|
|
14
16
|
export interface TweenPromise extends Promise<boolean> {
|
|
15
17
|
finish(): void;
|
|
16
18
|
remove(): void;
|
|
@@ -93,20 +95,28 @@ export interface LevelOptions {
|
|
|
93
95
|
outside?: number;
|
|
94
96
|
/** Water surface height (meters), default no water */
|
|
95
97
|
waterLevel?: number;
|
|
96
|
-
/** Expand the collision box outward by this much (meters) */
|
|
98
|
+
/** Expand the collision box outward by this much (meters) @experimental */
|
|
97
99
|
colliderPad?: number;
|
|
98
|
-
/** Minimum height of the collision box (meters) */
|
|
100
|
+
/** Minimum height of the collision box (meters) @experimental */
|
|
99
101
|
colliderHeight?: number;
|
|
100
|
-
/** Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6 */
|
|
102
|
+
/** Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6 @experimental */
|
|
101
103
|
sharpEdge?: number;
|
|
102
|
-
/** Hide the marker placeholder meshes, default true */
|
|
104
|
+
/** Hide the marker placeholder meshes, default true @experimental */
|
|
103
105
|
hideMarkers?: boolean;
|
|
104
|
-
/**
|
|
106
|
+
/** true: do not take the ground slot; compositeGround({ parts: [{ of: 'level' }] }) does and reads level.ground */
|
|
107
|
+
part?: boolean;
|
|
108
|
+
/** Add the scene to engine.scene, default true @experimental */
|
|
105
109
|
addToScene?: boolean;
|
|
106
110
|
}
|
|
107
111
|
/** Markers in the level (spawn, npc_*, trigger_*, marker_*), in world coordinates */
|
|
108
112
|
export interface LevelMarker { name: string; position: Vector3; quaternion: Quaternion; scale: Vector3; userData: Record<string, any>; object: Object3D }
|
|
109
113
|
export interface LevelLoadedEvent { root: Object3D; markers: Record<string, LevelMarker>; spawn: Vector3 }
|
|
114
|
+
/** source: the file or asset name; null for a code-built scene */
|
|
115
|
+
export interface LevelLoadingEvent { source: string | null }
|
|
116
|
+
export interface LevelFailedEvent { source: string | null; error: unknown }
|
|
117
|
+
export interface LevelPlayableEvent { root: Object3D }
|
|
118
|
+
/** A level left: unload(), or a switch just before the new one commits. source: its file or asset name, null for a code-built one */
|
|
119
|
+
export interface LevelUnloadedEvent { source: string | null }
|
|
110
120
|
|
|
111
121
|
/** engine.level */
|
|
112
122
|
export interface Level {
|
|
@@ -116,21 +126,23 @@ export interface Level {
|
|
|
116
126
|
markers: Record<string, LevelMarker>;
|
|
117
127
|
/** Spawn point position */
|
|
118
128
|
spawn: Vector3;
|
|
119
|
-
/** Heightfield (for debugging) */
|
|
129
|
+
/** Heightfield (for debugging) @experimental */
|
|
120
130
|
heightfield: any;
|
|
121
|
-
/**
|
|
131
|
+
/** 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 */
|
|
122
132
|
readonly ready: boolean;
|
|
123
133
|
/** Get a marker, null if none */
|
|
124
134
|
marker(name: string): LevelMarker | null;
|
|
125
135
|
/** Get all markers whose names start with prefix, e.g. markersWith('npc_') */
|
|
126
136
|
markersWith(prefix: string): LevelMarker[];
|
|
127
|
-
/** Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together) */
|
|
137
|
+
/** Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together) @experimental */
|
|
128
138
|
unload(): void;
|
|
129
139
|
/**
|
|
130
|
-
* Change level
|
|
131
|
-
* changes level, the save system waits for it
|
|
140
|
+
* 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
|
|
141
|
+
* 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
|
|
142
|
+
* level that fails rolls the save back. A load overtaken by a newer one or an unload resolves without a level.
|
|
143
|
+
* 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
|
|
132
144
|
*/
|
|
133
|
-
load(urlOrScene: string | Object3D): Promise<void>;
|
|
145
|
+
load(urlOrScene: string | Object3D, opts?: { turn?: SaveTurn }): Promise<void>;
|
|
134
146
|
/**
|
|
135
147
|
* Register things that belong to the current level and need not be kept (the { remove() } handles of triggers...); they are deleted automatically on
|
|
136
148
|
* level change / unload; returns the same handle. world data that keeps state (NPCs, pickups, props) needs no registration: with a zone, a level
|
|
@@ -181,6 +193,10 @@ export interface TriggerOptions {
|
|
|
181
193
|
cooldown?: number;
|
|
182
194
|
/** Custom data */
|
|
183
195
|
userData?: Record<string, any>;
|
|
196
|
+
/** 'zone' (default): one enter when the first actor arrives, one exit when the last leaves. 'each': an enter, stay and exit per actor (a door counting entrants); inside is true while anyone is in */
|
|
197
|
+
occupancy?: 'zone' | 'each';
|
|
198
|
+
/** Your own region instead of a shape: the plain volume addWaterBody takes. bounds ({ min, max }) lets the zone be indexed and drawn in the debug view; without it the zone is checked every step */
|
|
199
|
+
volume?: { contains(p: { x: number; y: number; z: number }): boolean; bounds?: { min: { x: number; y: number; z: number }; max: { x: number; y: number; z: number } } };
|
|
184
200
|
}
|
|
185
201
|
/** A trigger zone (the return value of add()) */
|
|
186
202
|
export interface Trigger {
|
|
@@ -237,7 +253,7 @@ export interface Triggers {
|
|
|
237
253
|
|
|
238
254
|
/** Particle effect parameters (define(), and each entry of particles({ effects, default })). All optional */
|
|
239
255
|
export interface ParticleOptions {
|
|
240
|
-
/** Maximum alive at once, default 120 (
|
|
256
|
+
/** Maximum alive at once, default 120 (60 on low-tier devices; a number the game gives stands) */
|
|
241
257
|
max?: number;
|
|
242
258
|
/** Seconds each particle lives [min, max] */
|
|
243
259
|
lifetime?: Range;
|
|
@@ -259,12 +275,12 @@ export interface ParticleOptions {
|
|
|
259
275
|
wind?: number;
|
|
260
276
|
/** Wind direction [x, y, z] */
|
|
261
277
|
windDir?: number[];
|
|
262
|
-
/** Size at birth / at death (meters) */
|
|
263
|
-
size?: Range;
|
|
264
|
-
/** Color at birth / at death (one color, or [birth, death]; an array, not a tuple, so a plain JS literal [0xffffff, 0xdddddd] type-checks) */
|
|
265
|
-
color?: ColorLike | ColorLike[];
|
|
266
|
-
/** Opacity at birth / at death, 0–1 */
|
|
267
|
-
opacity?: Range;
|
|
278
|
+
/** 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) */
|
|
279
|
+
size?: Range | number[][];
|
|
280
|
+
/** 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 */
|
|
281
|
+
color?: ColorLike | ColorLike[] | ColorLike[][];
|
|
282
|
+
/** 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 */
|
|
283
|
+
opacity?: Range | number[][];
|
|
268
284
|
/** Texture (asset name, path or THREE.Texture); a soft round dot if omitted */
|
|
269
285
|
texture?: string | Texture | null;
|
|
270
286
|
/** 'normal' | 'additive' (glowing blend, for sparks) */
|
|
@@ -277,11 +293,17 @@ export interface ParticleOptions {
|
|
|
277
293
|
fog?: boolean;
|
|
278
294
|
/** Largest on-screen size of one particle in pixels (smoke drifting past the camera stays bounded), default 512 */
|
|
279
295
|
maxPixels?: number;
|
|
296
|
+
/** Default particles per meter the emitter moves for attach, on top of rate, spread along the path it moved; default 0 @experimental */
|
|
297
|
+
ratePerMeter?: number;
|
|
298
|
+
/** Meters over which a particle fades where it meets what writes depth; default 0, off. Set at define, not in overrides. On WebGLRenderer it costs one depth-only draw of the scene per render while such an effect is on screen @experimental */
|
|
299
|
+
soft?: number;
|
|
280
300
|
}
|
|
281
301
|
/** Continuous emitter returned by attach() (a handle) */
|
|
282
302
|
export interface ParticleEmitter extends Handle {
|
|
283
303
|
/** Particles per second (can be changed at any time) */
|
|
284
304
|
rate: number;
|
|
305
|
+
/** Particles per meter the object moves, on top of rate (can be changed at any time) @experimental */
|
|
306
|
+
ratePerMeter: number;
|
|
285
307
|
/** false pauses */
|
|
286
308
|
active: boolean;
|
|
287
309
|
/** Stop and remove (also removed automatically when the object leaves the scene) */
|
|
@@ -307,13 +329,48 @@ export interface ParticlesOptions {
|
|
|
307
329
|
|
|
308
330
|
// Particles (engine.particles) is generated from the JSDoc in modules/particles/Particles.js (npm run map); only the type is re-exported here
|
|
309
331
|
import type { Particles } from './generated/modules/particles/Particles';
|
|
332
|
+
|
|
333
|
+
// Swarm swarm()
|
|
334
|
+
|
|
335
|
+
/** Options of engine.swarm(). See recipes/65-swarm.md */
|
|
336
|
+
export interface SwarmOptions {
|
|
337
|
+
/** Unique name: shown in describe(), the key in a save */
|
|
338
|
+
name: string;
|
|
339
|
+
/** Most objects alive at once; all memory is taken up front */
|
|
340
|
+
capacity: number;
|
|
341
|
+
/** Plain three.js geometry, stays the game's to dispose. Leave out with material for a swarm that draws nothing */
|
|
342
|
+
geometry?: import('three').BufferGeometry;
|
|
343
|
+
/** Plain three.js material, stays the game's to dispose */
|
|
344
|
+
material?: import('three').Material;
|
|
345
|
+
/** Number columns beside x, y, z. yaw, pitch, roll (radians, order YXZ) and scale are also drawn by the engine */
|
|
346
|
+
fields?: string[];
|
|
347
|
+
/** Per-object colour: columns r, g, b (linear) and spawn({ color: 0xff8800 }) */
|
|
348
|
+
color?: boolean;
|
|
349
|
+
/** Time channel of the onStep dt (default 'world') */
|
|
350
|
+
channel?: string;
|
|
351
|
+
/** Grid cell for near, in meters: about the usual query radius (default 2) */
|
|
352
|
+
cell?: number;
|
|
353
|
+
/** Keep this swarm in saves; otherwise it is empty after a load or new game */
|
|
354
|
+
save?: boolean;
|
|
355
|
+
}
|
|
356
|
+
/** The columns of a swarm: d.x[row], d.vx[row]... and d.id[row], the handle of that row */
|
|
357
|
+
export type SwarmData = { x: Float32Array; y: Float32Array; z: Float32Array; id: Float64Array } & Record<string, Float32Array | Float64Array>;
|
|
358
|
+
/** Runs for each live row every fixed step; returning false removes the object, anything else keeps it */
|
|
359
|
+
export type SwarmRowFn = (d: SwarmData, i: number, dt: number) => unknown;
|
|
360
|
+
import type { Swarm } from './generated/modules/swarm/Swarm';
|
|
361
|
+
export type { Swarm };
|
|
362
|
+
/** engine.swarm: call it to make a swarm */
|
|
363
|
+
export interface SwarmMaker {
|
|
364
|
+
/** Make a swarm. Returns a Swarm: spawn, free, row, onStep, near, clear, dispose, count, capacity, data, mesh */
|
|
365
|
+
(opts: SwarmOptions): Swarm;
|
|
366
|
+
}
|
|
310
367
|
export type { Particles };
|
|
311
368
|
|
|
312
369
|
// ======================================================================
|
|
313
370
|
// Settings menu settings()
|
|
314
371
|
// ======================================================================
|
|
315
372
|
|
|
316
|
-
/** Contents of a graphics quality preset */
|
|
373
|
+
/** Contents of a graphics quality preset. pixelRatio is a share from 0 to 1 of the ratio the engine picked for this device, so one preset fits every screen */
|
|
317
374
|
export interface QualityPreset { pixelRatio?: number; shadows?: boolean; antialias?: boolean; bloom?: boolean; ao?: boolean; viewChunks?: number; density?: number; [key: string]: any }
|
|
318
375
|
/**
|
|
319
376
|
* The tools a settings tab's render(tools, e, s) receives: escaping, translation and the control helpers (each returns HTML)
|
|
@@ -356,10 +413,12 @@ export interface SettingsOptions {
|
|
|
356
413
|
/**
|
|
357
414
|
* Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional
|
|
358
415
|
* 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY
|
|
359
|
-
* / camera.fov)
|
|
416
|
+
* / camera.fov). The entry { id: 'graphics', omit } leaves graphics rows out (quality, pixelRatio, shadows, antialias, bloom, ao, adaptive, viewChunks,
|
|
417
|
+
* density): an omitted row stays the game's value, and no preset or stored value moves it
|
|
360
418
|
* @example settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })
|
|
419
|
+
* @example settings({ sections: [{ id: 'graphics', omit: ['pixelRatio', 'antialias', 'adaptive'] }, 'audio', 'controls', 'language', 'saves'] }) // a fixed pixel look
|
|
361
420
|
*/
|
|
362
|
-
sections?: boolean | string[];
|
|
421
|
+
sections?: boolean | (string | { id: 'graphics'; omit: string[] })[];
|
|
363
422
|
/**
|
|
364
423
|
* Pause gameplay while the menu is open (with flow installed it switches to flow's 'paused' and returns to the previous state on close; without flow
|
|
365
424
|
* it uses engine.freeze); the picture keeps running, default false
|
|
@@ -369,19 +428,19 @@ export interface SettingsOptions {
|
|
|
369
428
|
|
|
370
429
|
/** engine.settings */
|
|
371
430
|
export interface Settings {
|
|
372
|
-
/** All current setting values */
|
|
373
|
-
values: Record<string, any>;
|
|
431
|
+
/** All current setting values, read only (set() changes one). pixelRatio is the renderer's real ratio */
|
|
432
|
+
readonly values: Record<string, any>;
|
|
374
433
|
/** Graphics presets */
|
|
375
434
|
presets: Record<string, QualityPreset>;
|
|
376
|
-
/** Tabs */
|
|
435
|
+
/** Tabs @experimental */
|
|
377
436
|
sections: Map<string, any>;
|
|
378
|
-
/** Whether the menu is open */
|
|
437
|
+
/** Whether the menu is open @experimental */
|
|
379
438
|
readonly isOpen: boolean;
|
|
380
439
|
/** Read a setting, e.g. get('vol.music') */
|
|
381
440
|
get(key: string): any;
|
|
382
441
|
/** Change a setting (takes effect immediately + saved) */
|
|
383
442
|
set(key: string, value: any, opts?: { save?: boolean }): void;
|
|
384
|
-
/** Graphics preset: 'low' | 'medium' | 'high' */
|
|
443
|
+
/** Graphics preset: 'low' | 'medium' | 'high' @experimental */
|
|
385
444
|
preset(name: 'low' | 'medium' | 'high' | (string & {})): void;
|
|
386
445
|
/** Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row
|
|
387
446
|
* restricts on the settings layer, like the built-in shadows row: off holds it off (the scene, weather or a cutscene cannot turn it back on),
|
|
@@ -389,15 +448,16 @@ export interface Settings {
|
|
|
389
448
|
define<T = any>(key: string, def: T, apply?: ((value: T, e: Engine) => void) | { apply?: (value: T, e: Engine) => void; limits?: string | string[] }): this;
|
|
390
449
|
/** Add a tab of your own, or a built-in / optional one by name: addSection('camera') */
|
|
391
450
|
addSection(id: string, section?: SettingsSection): this;
|
|
392
|
-
removeSection(id: string): void;
|
|
393
451
|
open(): void;
|
|
394
452
|
close(): void;
|
|
395
453
|
toggle(on?: boolean): void;
|
|
396
|
-
/**
|
|
454
|
+
/** Put one setting (or all, with no key) back to its default: the engine's start value, or the default the game gave define(). Keys: resetBindings */
|
|
455
|
+
reset(key?: string): void;
|
|
456
|
+
/** Restore all keys to defaults @experimental */
|
|
397
457
|
resetBindings(): void;
|
|
398
458
|
/** Change the first key of an action to code */
|
|
399
459
|
rebind(action: string, code: string): void;
|
|
400
|
-
/** Key list (for the UI) */
|
|
460
|
+
/** Key list (for the UI) @experimental */
|
|
401
461
|
actionList(): any[];
|
|
402
462
|
/** Save to the browser */
|
|
403
463
|
save(): void;
|
|
@@ -425,7 +485,7 @@ export interface MusicOptions {
|
|
|
425
485
|
fade?: number;
|
|
426
486
|
/** Duck the music bus during dialogue to this (0-1, e.g. 0.35); default false = no duck (the game opts in) */
|
|
427
487
|
duckDialogue?: number | false;
|
|
428
|
-
/** Fade seconds for the ducking */
|
|
488
|
+
/** Fade seconds for the ducking @experimental */
|
|
429
489
|
duckFade?: number;
|
|
430
490
|
/** Rule debounce seconds, default 2 */
|
|
431
491
|
hold?: number;
|
|
@@ -504,7 +564,7 @@ export interface CharacterOptions {
|
|
|
504
564
|
airJumpSpeed?: number;
|
|
505
565
|
/** How long a jump() pressed early waits for the ground (seconds), default 0.12 */
|
|
506
566
|
jumpBuffer?: number;
|
|
507
|
-
/** Falling out of the level: below belowY (or when belowY(character) is true) character:fall fires and
|
|
567
|
+
/** 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 */
|
|
508
568
|
fall?: false | { belowY: number | ((character: Character) => boolean) };
|
|
509
569
|
/** Time channel its movement and animation follow when the engine drives it (player default 'player', others 'world') */
|
|
510
570
|
channel?: string;
|
|
@@ -525,7 +585,7 @@ export interface CharacterOptions {
|
|
|
525
585
|
/** Skeletal animation state machine config (states, blend trees, one-shot actions), see AnimatorOptions */
|
|
526
586
|
animation?: AnimatorOptions | null;
|
|
527
587
|
/** 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 */
|
|
528
|
-
mover?: 'simple' | 'rapier' | 'manual';
|
|
588
|
+
mover?: 'simple' | 'rapier' | 'manual' | ((character: any, engine: any) => { name: string; move(x: number, z: number, run: boolean, dt: number, y: number): void; dispose?(): void; leave?(): void });
|
|
529
589
|
/**
|
|
530
590
|
* Which way it turns each move: 'move' (default, toward its velocity) | 'camera' (along cameraRig.forward()) | 'target' (toward faceTarget) | 'manual'
|
|
531
591
|
* (only face() turns it)
|
|
@@ -537,7 +597,7 @@ export interface CharacterOptions {
|
|
|
537
597
|
/** Character facing mode, see CharacterOptions.faceMode */
|
|
538
598
|
export type FaceMode = 'move' | 'camera' | 'target' | 'manual';
|
|
539
599
|
/** What a player control function returns: world direction (length 0–1 scales the speed), run; null = stand still. Speed changes: engine.mod('move.speed', { owner, id: 'player', ... }) */
|
|
540
|
-
export type MoveRequest = { x: number; z: number; run?: boolean } | null | undefined;
|
|
600
|
+
export type MoveRequest = { x: number; y?: number; z: number; run?: boolean } | null | undefined;
|
|
541
601
|
/**
|
|
542
602
|
* How the player's input steers it (the base holder of its control slot, owner 'player-input'): 'camera' movement keys relative to the camera |
|
|
543
603
|
* a function returning the move request. The game moving the player itself takes control: engine.control.take(player, { owner, layer: 'script', step })
|
|
@@ -545,6 +605,10 @@ export type MoveRequest = { x: number; z: number; run?: boolean } | null | undef
|
|
|
545
605
|
export type PlayerControl = 'camera' | ((player: Character, input: Input, dt: number) => MoveRequest);
|
|
546
606
|
/** Parameters of createPlayer() */
|
|
547
607
|
export interface PlayerOptions extends CharacterOptions {
|
|
608
|
+
/** A further local player's id and world record; left out, the one player (engine.player) */
|
|
609
|
+
id?: string;
|
|
610
|
+
/** The seat that drives this player (engine.input.seat); default engine.input */
|
|
611
|
+
input?: Seat;
|
|
548
612
|
/** Spawn point (meters, { x, z } / Vector3 / object); flat ground is found automatically if omitted */
|
|
549
613
|
spawn?: PositionLike;
|
|
550
614
|
/**
|
|
@@ -561,10 +625,8 @@ export type CharacterState = 'idle' | 'walk' | 'run' | 'swim' | 'jump' | 'fall'
|
|
|
561
625
|
/** Character (player and NPCs) */
|
|
562
626
|
export declare class Character {
|
|
563
627
|
constructor(engine: Engine, opts?: CharacterOptions);
|
|
564
|
-
/** Root node
|
|
628
|
+
/** Root node: add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it */
|
|
565
629
|
root: Object3D;
|
|
566
|
-
/** Same as root: add children, change visible and scale on it */
|
|
567
|
-
readonly object: Object3D;
|
|
568
630
|
/** Position (= root.position) */
|
|
569
631
|
readonly position: Vector3;
|
|
570
632
|
/** Horizontal velocity (x, y map to world x, z). Writable: a write is an impulse the mover steers back toward the input (lasting knockback: push(); full control: mover 'manual') */
|
|
@@ -574,11 +636,11 @@ export declare class Character {
|
|
|
574
636
|
* root.rotation.y)
|
|
575
637
|
*/
|
|
576
638
|
facing: number;
|
|
577
|
-
/** Vertical velocity (m/s). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly) */
|
|
639
|
+
/** Vertical velocity (m/s), kept apart from velocity, which is horizontal only (velocity.y is world z, not this). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly) */
|
|
578
640
|
vy: number;
|
|
579
641
|
/** Whether standing on the ground */
|
|
580
642
|
grounded: boolean;
|
|
581
|
-
/** Whether swimming */
|
|
643
|
+
/** Whether swimming @experimental */
|
|
582
644
|
swimming: boolean;
|
|
583
645
|
/** Current action state */
|
|
584
646
|
state: CharacterState;
|
|
@@ -588,15 +650,23 @@ export declare class Character {
|
|
|
588
650
|
faceMode: FaceMode;
|
|
589
651
|
/** What faceMode 'target' faces */
|
|
590
652
|
faceTarget: PositionLike | null;
|
|
591
|
-
/** Player only: whether the camera module follows it (see PlayerOptions.cameraFollow) */
|
|
653
|
+
/** Player only: whether the camera module follows it (see PlayerOptions.cameraFollow) @experimental */
|
|
592
654
|
cameraFollow?: boolean;
|
|
593
655
|
/** Move at a fixed velocity (m/s) for seconds, ignoring move()'s direction and without turning (knockback, dodge roll); gravity and collision still apply */
|
|
594
656
|
push(vx: number, vz: number, seconds: number): void;
|
|
595
|
-
speed: number; runSpeed: number; radius: number; water: CharacterWater; states: CharacterStates | null;
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
|
|
599
|
-
/**
|
|
657
|
+
speed: number; runSpeed: number; radius: number; water: CharacterWater; states: CharacterStates | null;
|
|
658
|
+
/** @experimental */ swimDepth: number;
|
|
659
|
+
/** @experimental */ swimSpeedFactor: number;
|
|
660
|
+
/** @experimental */ turnSpeed: number;
|
|
661
|
+
/** @experimental */ acceleration: number; gravity: number; jumpSpeed: number;
|
|
662
|
+
/** @experimental */ stepHeight: number;
|
|
663
|
+
/** @experimental */ airControl: number;
|
|
664
|
+
/** @experimental */ coyoteTime: number; canJump: boolean;
|
|
665
|
+
/** Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed')) @experimental */
|
|
666
|
+
maxJumps: number;
|
|
667
|
+
/** @experimental */ airJumpSpeed: number | null;
|
|
668
|
+
/** @experimental */ jumpBuffer: number;
|
|
669
|
+
/** Fall check (see CharacterOptions.fall); a plain property @experimental */
|
|
600
670
|
fall: false | { belowY: number | ((character: Character) => boolean) };
|
|
601
671
|
/** Time channel the engine drives it on (see CharacterOptions.channel) */
|
|
602
672
|
channel: string;
|
|
@@ -607,35 +677,31 @@ export declare class Character {
|
|
|
607
677
|
* @example engine.mod('move.speed', { owner: 'haste', id: 'player', mul: 1.2, for: 5 }); player.stat('speed') // 1.2 x player.speed
|
|
608
678
|
*/
|
|
609
679
|
stat(name: 'speed' | 'runSpeed' | 'gravity' | 'jumpSpeed' | 'canJump'): number;
|
|
610
|
-
/** Give back n jumps for this airtime (pickup, wall touch) */
|
|
680
|
+
/** Give back n jumps for this airtime (pickup, wall touch) @experimental */
|
|
611
681
|
addJumps(n?: number): this;
|
|
612
|
-
/** All jumps back, as if it had landed */
|
|
682
|
+
/** All jumps back, as if it had landed @experimental */
|
|
613
683
|
resetJumps(): this;
|
|
614
684
|
/**
|
|
615
685
|
* Throw it upward at speed m/s (jump pad, spring): leaves the ground, ends coyote time, the ground jump counts as used (air jumps stay); emits character:launch
|
|
616
686
|
* @example player.launch(19, { owner: 'pad' })
|
|
617
687
|
*/
|
|
618
688
|
launch(speed: number, opts?: { owner?: string }): this;
|
|
619
|
-
/** Jump state now, read-only */
|
|
689
|
+
/** Jump state now, read-only @experimental */
|
|
620
690
|
jumpState(): { grounded: boolean; coyoteLeft: number; bufferLeft: number; jumpsUsed: number; jumpsLeft: number; vy: number };
|
|
621
691
|
/** What it stands on, read-only (reused object); 'platform' = a registered support (characters.support), which carries it */
|
|
622
692
|
readonly support: { kind: 'ground' | 'platform' | 'collider' | 'water' | null; object: any; id: string | null; safe: boolean; velocity: { x: number; y: number; z: number } };
|
|
623
693
|
/** Last spot it stood still on safe ground (where a fall returns it); null until it first stands. Saved with the motion */
|
|
624
694
|
safeGround: Vector3 | null;
|
|
625
|
-
/** Called when a foot lands (the argument is the ground type underfoot) */
|
|
626
|
-
onStep: ((groundType: string) => void) | null;
|
|
627
|
-
/** Called on landing (the argument is the landing speed) */
|
|
628
|
-
onLand: ((impact: number) => void) | null;
|
|
629
695
|
/** 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' */
|
|
630
|
-
get mover(): { name:
|
|
631
|
-
set mover(
|
|
696
|
+
get mover(): { name: string; controller?: any; body?: any; collider?: any; move(dirX: number, dirZ: number, run: boolean, dt: number, y?: number): void; dispose?(): void; leave?(): void };
|
|
697
|
+
set mover(v: CharacterOptions['mover']);
|
|
632
698
|
/** Skeletal animation state machine (when there is a glTF model; null while a model named by asset is still loading) */
|
|
633
699
|
anim: Animator | null;
|
|
634
700
|
/** false while a model named by asset is loading (the placeholder body shows); true otherwise, also after a failed load (placeholder kept) */
|
|
635
701
|
ready: boolean;
|
|
636
702
|
/**
|
|
637
703
|
* Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise
|
|
638
|
-
* @example const npc = new Character(engine, { model: 'villager' }).
|
|
704
|
+
* @example const npc = new Character(engine, { model: 'villager' }); engine.add(npc.root); // import { Character } from 'threedog' await npc.whenReady;
|
|
639
705
|
* npc.playAction('Wave');
|
|
640
706
|
*/
|
|
641
707
|
readonly whenReady: Promise<void>;
|
|
@@ -664,8 +730,6 @@ export declare class Character {
|
|
|
664
730
|
* @example createPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump
|
|
665
731
|
*/
|
|
666
732
|
jump(opts?: { air?: boolean }): this;
|
|
667
|
-
/** Add to the scene */
|
|
668
|
-
addTo(scene?: any): this;
|
|
669
733
|
/** Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z }) */
|
|
670
734
|
placeAt(position: PositionLike): this;
|
|
671
735
|
/**
|
|
@@ -685,7 +749,7 @@ export declare class Character {
|
|
|
685
749
|
* A character someone controls (engine.control.of(ch)) moves only through its holder: called from anywhere else it is control-bypass in dev;
|
|
686
750
|
* take control and use handle.move() / step instead
|
|
687
751
|
*/
|
|
688
|
-
move(dirX: number, dirZ: number, run: boolean, dt: number): void;
|
|
752
|
+
move(dirX: number, dirZ: number, run: boolean, dt: number, dirY?: number): void;
|
|
689
753
|
/** Ground type underfoot ('water' while swimming) */
|
|
690
754
|
groundType(): string;
|
|
691
755
|
/** Turn at once to a position, or to an angle in radians (0 = +Z) */
|
|
@@ -693,9 +757,10 @@ export declare class Character {
|
|
|
693
757
|
/**
|
|
694
758
|
* Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after
|
|
695
759
|
* the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
|
|
760
|
+
* @experimental
|
|
696
761
|
*/
|
|
697
762
|
saveMotion(out?: CharacterMotion): CharacterMotion;
|
|
698
|
-
/** Restore the motion state from the plain object of saveMotion */
|
|
763
|
+
/** Restore the motion state from the plain object of saveMotion @experimental */
|
|
699
764
|
loadMotion(m: CharacterMotion | null | undefined): this;
|
|
700
765
|
}
|
|
701
766
|
/** Result of Character.saveMotion (plain values, can be saved); facing is the same as Character.facing: 0 = +Z, forward (sin f, cos f) */
|
|
@@ -877,7 +942,9 @@ export interface CharactersApi {
|
|
|
877
942
|
* The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it
|
|
878
943
|
* inside your own control function to wrap it
|
|
879
944
|
*/
|
|
880
|
-
moveInput(): { x: number; z: number; run: boolean };
|
|
945
|
+
moveInput(seat?: Seat): { x: number; z: number; run: boolean };
|
|
946
|
+
/** Join the vehicles a saved rider can be seated in again, before or after the load */
|
|
947
|
+
addVehicle(vehicle: any): { remove(): void };
|
|
881
948
|
/**
|
|
882
949
|
* Something characters stand on and ride (moving platform, lift, raft). Move the object any way (onFixed before or after the player, a timeline,
|
|
883
950
|
* physics): riders follow how its matrix changed, so the order does not matter. safe: false = never a respawn spot; carry 'position+yaw' turns riders
|
|
@@ -888,31 +955,39 @@ export interface CharactersApi {
|
|
|
888
955
|
/**
|
|
889
956
|
* Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the
|
|
890
957
|
* position and the vehicle; loading an on-foot save exits the vehicle first
|
|
958
|
+
* @experimental
|
|
891
959
|
*/
|
|
892
|
-
removePlayer(): void;
|
|
960
|
+
removePlayer(id?: string): void;
|
|
893
961
|
/**
|
|
894
|
-
* Pathfinding (the single entry point): uses the navmesh when nav is installed and ready, otherwise the A* fallback. Returns a path [{ x, z }...], or
|
|
962
|
+
* 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
|
|
895
963
|
* null if unreachable
|
|
896
964
|
*/
|
|
897
|
-
findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }):
|
|
965
|
+
findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }): NavPathPoint[] | null;
|
|
898
966
|
/**
|
|
899
967
|
* Pass detailed: true: returns { status, path }, distinguishing 'ok' found | 'noPath' unreachable | 'notReady' nav is installed but the mesh is not
|
|
900
968
|
* built yet (path is the A* fallback result and may be inaccurate)
|
|
901
969
|
*/
|
|
902
970
|
findPath(from: PositionLike, to: PositionLike, opts: FindPathOptions & { detailed: true }): PathResult;
|
|
971
|
+
/** What a game's mover calls to take part in contact, each optional (recipe 57): a mover calling none owns contact itself */
|
|
972
|
+
kit: { beginMove(c: any): boolean; groundAt(c: any, x: number, z: number, y?: number): number; endMove(c: any, dt: number, hit: any, ground?: string): void; ownState(c: any, base: string, speed: number): void };
|
|
903
973
|
/**
|
|
904
974
|
* 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
|
|
905
975
|
* paths with threads on or off). Recipe 12 section 4
|
|
906
976
|
*/
|
|
907
977
|
findPathAsync(
|
|
908
|
-
from: PositionLike, to: PositionLike, done: (path:
|
|
978
|
+
from: PositionLike, to: PositionLike, done: (path: NavPathPoint[] | null, status: 'ok' | 'noPath' | 'notReady') => void,
|
|
909
979
|
opts?: { radius?: number; step?: number; maxNodes?: number }
|
|
910
980
|
): { remove(): void };
|
|
911
981
|
/** How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps */
|
|
912
982
|
pathsPerStep: number;
|
|
983
|
+
/**
|
|
984
|
+
* 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
|
|
985
|
+
* crossing saved halfway resumes on the same curve. null = the straight line @experimental
|
|
986
|
+
*/
|
|
987
|
+
linkPose: ((t: number, position: Vector3, crossing: LinkCrossing, character: Character) => void) | null;
|
|
913
988
|
}
|
|
914
989
|
/** Return value of findPath(..., { detailed: true }) */
|
|
915
|
-
export interface PathResult { status: 'ok' | 'noPath' | 'notReady'; path:
|
|
990
|
+
export interface PathResult { status: 'ok' | 'noPath' | 'notReady'; path: NavPathPoint[] | null }
|
|
916
991
|
/**
|
|
917
992
|
* Parameters of findSpawn(): minH/maxH height range (meters, default unlimited), maxSlope maximum slope (default 0.3), waterMargin minimum meters above
|
|
918
993
|
* the water (default 0.5)
|
|
@@ -921,8 +996,10 @@ export interface FindSpawnOptions { minH?: number; maxH?: number; maxSlope?: num
|
|
|
921
996
|
export interface CharactersOptions {
|
|
922
997
|
/** Whether to enable NPCs (engine.npcs), default true */
|
|
923
998
|
npcs?: boolean;
|
|
924
|
-
/** Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts) */
|
|
999
|
+
/** Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts) @experimental */
|
|
925
1000
|
npcTiers?: { fullRadius: number; nearEvery: number };
|
|
1001
|
+
/** 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 */
|
|
1002
|
+
fall?: 'rescue' | false | ((facts: any, engine: any) => 'rescue' | false);
|
|
926
1003
|
/** 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 */
|
|
927
1004
|
animation?: AnimatorOptions;
|
|
928
1005
|
}
|
|
@@ -930,12 +1007,40 @@ export interface CharactersOptions {
|
|
|
930
1007
|
* Pathfinding options: step is the grid size (meters, A*), maxNodes the maximum cells searched (A*), radius the character radius (meters,
|
|
931
1008
|
* default engine.movement.radius); for detailed see findPath
|
|
932
1009
|
*/
|
|
933
|
-
export interface FindPathOptions { step?: number; maxNodes?: number; radius?: number; detailed?: boolean }
|
|
1010
|
+
export interface FindPathOptions { step?: number; maxNodes?: number; radius?: number; detailed?: boolean; id?: string }
|
|
934
1011
|
|
|
935
1012
|
// ======================================================================
|
|
936
1013
|
// Interactions interactions()
|
|
937
1014
|
// ======================================================================
|
|
938
1015
|
|
|
1016
|
+
/** One live interaction, as interactions.get(id) and interactions.items give it */
|
|
1017
|
+
export interface Interaction {
|
|
1018
|
+
id: string;
|
|
1019
|
+
/** What it follows; a fixed position is an empty Object3D placed there */
|
|
1020
|
+
object: Object3D;
|
|
1021
|
+
label: string | ((object: Object3D, ctx: { actor: string }) => string);
|
|
1022
|
+
radius: number;
|
|
1023
|
+
action: string;
|
|
1024
|
+
onUse?: (object: Object3D, ctx: { actor: string }) => any;
|
|
1025
|
+
enabled: (object: Object3D, ctx: { actor: string }) => boolean;
|
|
1026
|
+
height?: number;
|
|
1027
|
+
hold: number;
|
|
1028
|
+
approach: boolean;
|
|
1029
|
+
once: boolean;
|
|
1030
|
+
counter?: string;
|
|
1031
|
+
}
|
|
1032
|
+
/** inventory.add: what went in, or why nothing did */
|
|
1033
|
+
export interface ItemAddResult {
|
|
1034
|
+
ok: boolean;
|
|
1035
|
+
/** The entry they went into ('arrow', 'sword#3'); set when ok */
|
|
1036
|
+
key?: string;
|
|
1037
|
+
/** How many fit (a partial fit places what fits); set when ok */
|
|
1038
|
+
added?: number;
|
|
1039
|
+
/** 'full' when none fit */
|
|
1040
|
+
code?: 'full';
|
|
1041
|
+
facts?: { id: string; n: number };
|
|
1042
|
+
nextActions?: any[];
|
|
1043
|
+
}
|
|
939
1044
|
export interface InteractionOptions {
|
|
940
1045
|
/** Stable id for the op interaction.use { id } (default: the world record id it was built for, else a running number) */
|
|
941
1046
|
id?: string;
|
|
@@ -966,15 +1071,15 @@ export interface InteractionOptions {
|
|
|
966
1071
|
approach?: boolean;
|
|
967
1072
|
/** Hide the object after a use and allow no second one (onUse returning { ok: false } leaves it). Saved under id, else the object's name; development throws when it has neither */
|
|
968
1073
|
once?: boolean;
|
|
969
|
-
/** Name of a HUD counter each use adds 1 to (hud.
|
|
1074
|
+
/** Name of a HUD counter each use adds 1 to (hud.bump; nothing without hud()). Saved; read the total with hud.value(name) */
|
|
970
1075
|
counter?: string;
|
|
971
1076
|
}
|
|
972
1077
|
/** engine.interactions */
|
|
973
1078
|
export interface Interactions {
|
|
974
|
-
/** How high the prompt floats (meters) */
|
|
1079
|
+
/** How high the prompt floats (meters) @experimental */
|
|
975
1080
|
promptHeight: number;
|
|
976
1081
|
/** All interactions in the order added (a fresh array each read; get(id) finds one without it) */
|
|
977
|
-
readonly items:
|
|
1082
|
+
readonly items: Interaction[];
|
|
978
1083
|
/** Default reach of add() in meters (2.5) */
|
|
979
1084
|
radius: number;
|
|
980
1085
|
/** How the one in front of the actor is chosen; can be changed at runtime */
|
|
@@ -990,8 +1095,8 @@ export interface Interactions {
|
|
|
990
1095
|
* Returns a handle { remove() }
|
|
991
1096
|
*/
|
|
992
1097
|
add(target: Object3D | PositionLike, opts?: InteractionOptions): Handle;
|
|
993
|
-
/** The interaction with this id, or
|
|
994
|
-
get(id: string):
|
|
1098
|
+
/** The interaction with this id, or undefined. Using one is the op: engine.ops.run('interaction.use', { id }) (no id = the one the actor would pick) */
|
|
1099
|
+
get(id: string): Interaction | undefined;
|
|
995
1100
|
}
|
|
996
1101
|
/**
|
|
997
1102
|
* What the 'prompt' UI part receives in update(view) every frame while an interaction is in reach (hide() when none). Call use() on click: it runs the
|
|
@@ -1097,7 +1202,7 @@ export interface BubbleView { speaker: string; text: string; x: number; y: numbe
|
|
|
1097
1202
|
export interface Dialogue {
|
|
1098
1203
|
/** Story state: state.flags is engine.vars.flags (autosaved) */
|
|
1099
1204
|
readonly state: DialogueState;
|
|
1100
|
-
/** All scripts */
|
|
1205
|
+
/** All scripts @experimental */
|
|
1101
1206
|
scripts: Map<string, DialogueScript>;
|
|
1102
1207
|
/**
|
|
1103
1208
|
* The dialogue in progress (null when none). speaker: the script name; node: the current node OBJECT (its fields: text, choices, data...);
|
|
@@ -1105,10 +1210,10 @@ export interface Dialogue {
|
|
|
1105
1210
|
* @example const atAsk = engine.dialogue.active?.id === 'ask'; // the node id; active.node.data holds the node's own fields
|
|
1106
1211
|
*/
|
|
1107
1212
|
readonly active: { speaker: string; nodes: DialogueScript; node?: DialogueNode; id?: string; onEnd: (() => void) | null } | null;
|
|
1108
|
-
/** The script the main dialogue is playing */
|
|
1213
|
+
/** The script the main dialogue is playing @experimental */
|
|
1109
1214
|
readonly speaking: string | null;
|
|
1110
|
-
/** Typing speed (characters/second) */
|
|
1111
|
-
|
|
1215
|
+
/** Typing speed (characters/second) @experimental */
|
|
1216
|
+
charsPerSecond: number;
|
|
1112
1217
|
/** Define a dialogue (the name is usually the speaker) */
|
|
1113
1218
|
define(speaker: string, nodes: DialogueScript): void;
|
|
1114
1219
|
/**
|
|
@@ -1127,7 +1232,7 @@ export interface Dialogue {
|
|
|
1127
1232
|
*/
|
|
1128
1233
|
say(text: string | DialogueScript, opts?: { speaker?: string; node?: string; channel?: DialogueChannel; onCancel?: (() => void) | null } & BubbleOptions): SayPromise;
|
|
1129
1234
|
/** Lines on the bubble channel now */
|
|
1130
|
-
bubbles(): { speaker: string; text: string; queued: number }[];
|
|
1235
|
+
bubbles(): { speaker: string; text: string; queued: number; run?: number; choices?: string[] }[];
|
|
1131
1236
|
/** End the main dialogue */
|
|
1132
1237
|
end(): void;
|
|
1133
1238
|
// Advancing and choosing are ops: engine.ops.run('dialogue.advance') / engine.ops.run('dialogue.choose', { index })
|
|
@@ -1141,6 +1246,8 @@ export interface DialogueOptions {
|
|
|
1141
1246
|
advanceActions?: string[];
|
|
1142
1247
|
/** A bubble line stays this many seconds plus its reading time (about 15 characters a second) unless say() gives seconds, default 2 */
|
|
1143
1248
|
holdSeconds?: number;
|
|
1249
|
+
/** 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()) */
|
|
1250
|
+
bubbleChoice?: 'end' | 'ask';
|
|
1144
1251
|
}
|
|
1145
1252
|
/**
|
|
1146
1253
|
* What the 'dialogue' UI part receives in update(view) (show() comes first, hide() when the dialogue ends). Call advance() / choose(i) from your UI:
|
|
@@ -1263,7 +1370,7 @@ export interface PickupOptions {
|
|
|
1263
1370
|
auto?: boolean;
|
|
1264
1371
|
/** The game's own three.js object for this one pickup (only detached when it goes; otherwise the model name decides the shape) */
|
|
1265
1372
|
mesh?: Object3D | null;
|
|
1266
|
-
/**
|
|
1373
|
+
/** Calendar seconds until it reappears, 0 = never reappears */
|
|
1267
1374
|
respawnSeconds?: number;
|
|
1268
1375
|
/** Bob up and down and rotate, default true */
|
|
1269
1376
|
bob?: boolean;
|
|
@@ -1289,7 +1396,7 @@ export interface Pickups {
|
|
|
1289
1396
|
material: Material;
|
|
1290
1397
|
/** Edge of the placeholder box (meters), read when one is built */
|
|
1291
1398
|
size: number;
|
|
1292
|
-
/** Height above the ground new pickups float at (meters) */
|
|
1399
|
+
/** Height above the ground new pickups float at (meters) @experimental */
|
|
1293
1400
|
lift: number;
|
|
1294
1401
|
/**
|
|
1295
1402
|
* Place a pickup on the ground at position; its y, if any, is the reference height on multi-layer ground (needs the interactions module unless auto):
|
|
@@ -1302,7 +1409,7 @@ export interface Pickups {
|
|
|
1302
1409
|
export interface PickupsOptions {
|
|
1303
1410
|
/** Reach of pickups that do not set their own radius (meters), default 2 */
|
|
1304
1411
|
radius?: number;
|
|
1305
|
-
/** Pickups have a model, float and spin only within this distance (meters) of the stream sources, default 60 */
|
|
1412
|
+
/** Pickups have a model, float and spin only within this distance (meters) of the stream sources, default 60 @experimental */
|
|
1306
1413
|
showDistance?: number;
|
|
1307
1414
|
/** Who walks into auto pickups (actor ids); default engine.actor, plus net peers on a host */
|
|
1308
1415
|
takers?: (e: Engine) => string[];
|
|
@@ -1330,7 +1437,7 @@ export interface Container {
|
|
|
1330
1437
|
/** Whether there are at least n (default 1) */
|
|
1331
1438
|
has(x: string, n?: number): boolean;
|
|
1332
1439
|
/** One entry by key, or null */
|
|
1333
|
-
get(key: string): ItemEntry |
|
|
1440
|
+
get(key: string): ItemEntry | undefined;
|
|
1334
1441
|
/** Slots used */
|
|
1335
1442
|
readonly slotsUsed: number;
|
|
1336
1443
|
/** Total weight */
|
|
@@ -1339,8 +1446,8 @@ export interface Container {
|
|
|
1339
1446
|
list(): ItemEntry[];
|
|
1340
1447
|
/** How many more fit (Infinity = no limit), for an item without data, with this data, or like an existing entry key */
|
|
1341
1448
|
room(x: string, data?: Record<string, any>): number;
|
|
1342
|
-
/** Add n (default 1), optionally with data; returns
|
|
1343
|
-
add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }):
|
|
1449
|
+
/** Add n (default 1), optionally with data; returns { ok: true, key, added } (added: how many fit), or { ok: false, code: 'full' } when none fit; the answer is an object, so read .ok: if (add(...)) is true even when the bag is full; silent suppresses the toast (only the bag of engine.actor shows one) */
|
|
1450
|
+
add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): ItemAddResult;
|
|
1344
1451
|
/** Remove n (default 1) of an item or entry key, returns false if there are not enough */
|
|
1345
1452
|
remove(x: string, n?: number): boolean;
|
|
1346
1453
|
/**
|
|
@@ -1360,13 +1467,13 @@ export interface Container {
|
|
|
1360
1467
|
export interface Inventory {
|
|
1361
1468
|
/** true: gameplay freezes while the inventory window is open (set from inventory({ pauseGame }) or at runtime) */
|
|
1362
1469
|
pauseGame: boolean;
|
|
1363
|
-
/** Slot limit of the player inventory */
|
|
1470
|
+
/** Slot limit of the player inventory @experimental */
|
|
1364
1471
|
capacity: number;
|
|
1365
|
-
/** Player inventory: the bag of engine.actor (= of()) */
|
|
1472
|
+
/** Player inventory: the bag of engine.actor (= of()) @experimental */
|
|
1366
1473
|
readonly bag: Container;
|
|
1367
1474
|
/** The bag of an actor (default engine.actor): the container with the actor's id, created empty on first use; inside an op pass ctx.actor */
|
|
1368
1475
|
of(actor?: string): Container;
|
|
1369
|
-
defaultStack: number;
|
|
1476
|
+
/** @experimental */ defaultStack: number;
|
|
1370
1477
|
action: string;
|
|
1371
1478
|
/** Define an item (chainable) */
|
|
1372
1479
|
define(id: string, def: ItemDef): this;
|
|
@@ -1376,14 +1483,12 @@ export interface Inventory {
|
|
|
1376
1483
|
count(x: string): number;
|
|
1377
1484
|
/** Whether there are at least n (default 1) */
|
|
1378
1485
|
has(x: string, n?: number): boolean;
|
|
1379
|
-
/** Slots used */
|
|
1380
|
-
readonly slotsUsed: number;
|
|
1381
1486
|
/** Player inventory entries (for custom UI) */
|
|
1382
1487
|
list(): ItemEntry[];
|
|
1383
|
-
/** One player inventory entry by key, or
|
|
1384
|
-
get(key: string): ItemEntry |
|
|
1385
|
-
/** Add n to the player inventory (default 1), opts { data, silent }; returns
|
|
1386
|
-
add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }):
|
|
1488
|
+
/** One player inventory entry by key, or undefined */
|
|
1489
|
+
get(key: string): ItemEntry | undefined;
|
|
1490
|
+
/** Add n to the player inventory (default 1), opts { data, silent }; returns { ok: true, key, added }, or { ok: false, code: 'full' } when none fit */
|
|
1491
|
+
add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): ItemAddResult;
|
|
1387
1492
|
/** Remove n (default 1) of an item or entry key, returns false if there are not enough */
|
|
1388
1493
|
remove(x: string, n?: number): boolean;
|
|
1389
1494
|
/**
|
|
@@ -1407,9 +1512,9 @@ export interface Inventory {
|
|
|
1407
1512
|
transfer(from: Container | string, to: Container | string, item: string, n?: number): number;
|
|
1408
1513
|
/** Delete a container together with its contents ('player' cannot be deleted), returns whether one was deleted */
|
|
1409
1514
|
removeContainer(id: string): boolean;
|
|
1410
|
-
/** Every container's items as plain data, the player bag included: { [containerId]: entries } (what setContents takes; net syncs through these two) */
|
|
1515
|
+
/** Every container's items as plain data, the player bag included: { [containerId]: entries } (what setContents takes; net syncs through these two) @experimental */
|
|
1411
1516
|
contents(): Record<string, any[]>;
|
|
1412
|
-
/** Replace containers' items from contents() data, silently like a save load; a null entry empties that container, only: true empties the rest too */
|
|
1517
|
+
/** Replace containers' items from contents() data, silently like a save load; a null entry empties that container, only: true empties the rest too @experimental */
|
|
1413
1518
|
setContents(data: Record<string, any[] | null>, opts?: { only?: boolean }): void;
|
|
1414
1519
|
}
|
|
1415
1520
|
export interface InventoryOptions {
|
|
@@ -1421,7 +1526,7 @@ export interface InventoryOptions {
|
|
|
1421
1526
|
capacity?: number;
|
|
1422
1527
|
/** Weight limit of the player inventory, default Infinity */
|
|
1423
1528
|
maxWeight?: number;
|
|
1424
|
-
/** Default stack limit, default 99 */
|
|
1529
|
+
/** Default stack limit, default 99 @experimental */
|
|
1425
1530
|
defaultStack?: number;
|
|
1426
1531
|
}
|
|
1427
1532
|
|
|
@@ -1438,6 +1543,8 @@ export interface QuestStep {
|
|
|
1438
1543
|
id?: string;
|
|
1439
1544
|
text: string;
|
|
1440
1545
|
done: (e: Engine) => boolean;
|
|
1546
|
+
/** The step after this one: a step id, or e => id asked when this step is done (a branch); false finishes the quest here. Default: the next step in the list. steps already passed are in quests.state(id).visited */
|
|
1547
|
+
next?: string | false | ((e: Engine) => string | false | undefined);
|
|
1441
1548
|
/**
|
|
1442
1549
|
* Objective: a place name (content.place), object, character, { x, z }, { nearest: itemId } or a function returning an objective; with the hud module
|
|
1443
1550
|
* the current step shows a marker automatically
|
|
@@ -1447,7 +1554,7 @@ export interface QuestStep {
|
|
|
1447
1554
|
/** One goal of a parallel step; optional goals do not hold the step back */
|
|
1448
1555
|
export interface QuestPart { /** Stable id within the step (default: its position) */ id?: string; text: string; done: (e: Engine) => boolean; target?: HudTarget; optional?: boolean }
|
|
1449
1556
|
/** Parallel goals: done when every non-optional part is done, in any order; text defaults to the required parts joined */
|
|
1450
|
-
export interface QuestParallelStep { /** Stable id (default: the step's position) */ id?: string; text?: string; all: QuestPart[] }
|
|
1557
|
+
export interface QuestParallelStep { /** Stable id (default: the step's position) */ id?: string; text?: string; all: QuestPart[]; /** As QuestStep.next */ next?: string | false | ((e: Engine) => string | false | undefined) }
|
|
1451
1558
|
/** Quest definition */
|
|
1452
1559
|
export interface QuestDef {
|
|
1453
1560
|
/** Title */
|
|
@@ -1456,8 +1563,10 @@ export interface QuestDef {
|
|
|
1456
1563
|
desc?: string;
|
|
1457
1564
|
/** Steps (completed in order); a step may be parallel goals { all: [...] } */
|
|
1458
1565
|
steps: (QuestStep | QuestParallelStep)[];
|
|
1459
|
-
/** Called on completion (give rewards) */
|
|
1460
|
-
reward?: (e: Engine) =>
|
|
1566
|
+
/** Called on completion (give rewards). Returning a failure ({ ok: false, code }, e.g. what e.content.run or e.inventory.add answer) means it was not paid: see onUnpaid */
|
|
1567
|
+
reward?: (e: Engine) => any;
|
|
1568
|
+
/** The game's decision for a reward not given, with the failure as answer. Without it the items that did not fit stay owed (list().owed, saved) and go into the bag when there is room */
|
|
1569
|
+
onUnpaid?: (e: Engine, answer: { ok: false; code: string; facts: any }) => void;
|
|
1461
1570
|
/** Checked while active; true fails the quest (quest:fail; start(id) can begin it again). @example fail: e => e.vars.flag('caravanLost') */
|
|
1462
1571
|
fail?: (e: Engine) => boolean;
|
|
1463
1572
|
/** Called when the quest fails */
|
|
@@ -1472,13 +1581,13 @@ export interface Quests {
|
|
|
1472
1581
|
/** Start a quest */
|
|
1473
1582
|
start(id: string): void;
|
|
1474
1583
|
/** One quest's progress (a copy): step index, step count, done, failed, active; null before it starts */
|
|
1475
|
-
state(id: string): { step: number; steps: number; done: boolean; failed: boolean; active: boolean } | null;
|
|
1584
|
+
state(id: string): { step: number; steps: number; done: boolean; failed: boolean; active: boolean; visited: string[] } | null;
|
|
1476
1585
|
/** Finish the current step from code (its done() is not asked) and go on; the last step completes the quest. false when not active */
|
|
1477
1586
|
advance(id: string): boolean;
|
|
1478
|
-
isDone(id: string): boolean;
|
|
1587
|
+
/** @experimental */ isDone(id: string): boolean;
|
|
1479
1588
|
/** Started, not done and not failed */
|
|
1480
1589
|
isActive(id: string): boolean;
|
|
1481
|
-
/** Its fail condition held (start(id) begins it again) */
|
|
1590
|
+
/** Its fail condition held (start(id) begins it again) @experimental */
|
|
1482
1591
|
isFailed(id: string): boolean;
|
|
1483
1592
|
/** Check completion conditions once immediately */
|
|
1484
1593
|
check(): void;
|
|
@@ -1510,13 +1619,13 @@ export interface QuestLogView {
|
|
|
1510
1619
|
export interface QuestsOptions {
|
|
1511
1620
|
/** Action name that opens the quest log, default 'quests' */
|
|
1512
1621
|
action?: string;
|
|
1513
|
-
/** Check interval (
|
|
1622
|
+
/** Check interval (real seconds, checked in the fixed step; not checked while frozen / paused), default 0.5 @experimental */
|
|
1514
1623
|
checkInterval?: number;
|
|
1515
1624
|
/**
|
|
1516
1625
|
* Messages on quest start / step / done: true a toast with kind 'quest' (default) · false none · a function to show them your way.
|
|
1517
1626
|
* @example quests({ notify: false }) quests({ notify: ({ type, text }) => type === 'done' && myBanner(text) })
|
|
1518
1627
|
*/
|
|
1519
|
-
notify?: boolean | ((msg: { type: 'start' | 'step' | 'done'; id: string; text: string }) => void);
|
|
1628
|
+
notify?: boolean | ((msg: { type: 'start' | 'step' | 'done' | 'unpaid'; id: string; text: string }) => void);
|
|
1520
1629
|
}
|
|
1521
1630
|
|
|
1522
1631
|
// ======================================================================
|
|
@@ -1547,7 +1656,7 @@ export interface PhotoTakeOptions {
|
|
|
1547
1656
|
format?: string;
|
|
1548
1657
|
}
|
|
1549
1658
|
export interface PhotoOptions extends PhotoTakeOptions {
|
|
1550
|
-
/** How many photos the album keeps at most, default 50 */
|
|
1659
|
+
/** How many photos the album keeps at most, default 50 @experimental */
|
|
1551
1660
|
maxAlbum?: number;
|
|
1552
1661
|
}
|
|
1553
1662
|
/** engine.photo */
|
|
@@ -1556,10 +1665,12 @@ export interface Photo {
|
|
|
1556
1665
|
album: PhotoShot[];
|
|
1557
1666
|
/** The op photo.take's can: return true, or false / a reason string to refuse (e.g. () => engine.inventory.has('film') || 'noFilm') */
|
|
1558
1667
|
canTake: () => boolean | string;
|
|
1559
|
-
scale: number; shadowMapSize: number; bloom: boolean; quality: number;
|
|
1668
|
+
scale: number; shadowMapSize: number; bloom: boolean; quality: number;
|
|
1669
|
+
/** @experimental */ format: string;
|
|
1670
|
+
/** @experimental */ maxAlbum: number;
|
|
1560
1671
|
/** Capture a photo now without checks. Gameplay takes photos through the op: engine.ops.run('photo.take') (checks canTake, logged) */
|
|
1561
1672
|
take(opts?: PhotoTakeOptions): PhotoShot;
|
|
1562
|
-
/** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() */
|
|
1673
|
+
/** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() @experimental */
|
|
1563
1674
|
subject(): { name: string; kind: string; distance: number } | null;
|
|
1564
1675
|
}
|
|
1565
1676
|
|
|
@@ -1672,7 +1783,7 @@ export interface Clock {
|
|
|
1672
1783
|
* Call fn after seconds calendar seconds; if an event name is passed, the event is emitted when due (with data, can be saved).
|
|
1673
1784
|
* { channel } counts that time channel's seconds instead (a poison tick that slows down in bullet time)
|
|
1674
1785
|
*/
|
|
1675
|
-
after(seconds: number, fnOrEvent: (() => void) | string,
|
|
1786
|
+
after(seconds: number, fnOrEvent: (() => void) | string, opts?: { data?: any; channel?: string }): Handle;
|
|
1676
1787
|
/** Call once every seconds calendar seconds ({ channel }: 'real' or a time channel's seconds instead) */
|
|
1677
1788
|
every(seconds: number, fn: () => void, opts?: { channel?: string }): Handle;
|
|
1678
1789
|
}
|
|
@@ -1721,7 +1832,7 @@ export interface Stack {
|
|
|
1721
1832
|
/** End owner's entry; false when it held none */
|
|
1722
1833
|
release(owner: string, opts?: { id?: string }): boolean;
|
|
1723
1834
|
}
|
|
1724
|
-
/** engine.stacks: every shared point by name ('time.<channel>', 'time.local', 'clock.rate', 'freeze', '
|
|
1835
|
+
/** engine.stacks: every shared point by name ('time.<channel>', 'time.local', 'clock.rate', 'freeze', 'halt', 'camera', 'debug.view', slots, your own) */
|
|
1725
1836
|
export interface Stacks {
|
|
1726
1837
|
/**
|
|
1727
1838
|
* Define your own point: kind 'number' (default, base 1), 'value' (any data, set only), 'any' (true while held), 'top' (latest holder wins),
|
|
@@ -1739,19 +1850,19 @@ export interface Stacks {
|
|
|
1739
1850
|
}
|
|
1740
1851
|
/** engine.time: time channels (world, player, your own). Speeds change only through engine.mod('time.<channel>', ...) */
|
|
1741
1852
|
export interface Time {
|
|
1742
|
-
/** Define a channel; parent (default 'world') multiplies its speed */
|
|
1853
|
+
/** Define a channel; parent (default 'world') multiplies its speed @experimental */
|
|
1743
1854
|
channel(name: string, opts?: { parent?: string | null; stack?: string }): Time;
|
|
1744
|
-
channels(): string[];
|
|
1855
|
+
/** @experimental */ channels(): string[];
|
|
1745
1856
|
/** Effective speed: parent x the channel's stack (x the record's 'time.local' stack when id is given) */
|
|
1746
1857
|
scale(name: string, id?: string): number;
|
|
1747
|
-
/** Fixed steps run this playthrough: the one time counter
|
|
1858
|
+
/** Fixed steps run this playthrough: the one time counter; every other time is a read-only view of it */
|
|
1748
1859
|
readonly tick: number;
|
|
1749
1860
|
/**
|
|
1750
1861
|
* Seconds on a view: 'real' (tick / 60, no scale, stops while frozen), 'ambient' (= uniforms.uTime, keeps moving while frozen),
|
|
1751
1862
|
* 'calendar' (= engine.clock.now) or a channel ('world', 'player', your own)
|
|
1752
1863
|
*/
|
|
1753
1864
|
now(name: 'real' | 'ambient' | 'calendar' | 'world' | 'player' | (string & {})): number;
|
|
1754
|
-
/** This fixed step's dt on a channel (1/60 x scale). Change a speed with engine.mod('time.<channel>', { owner, set | mul }); timers: engine.clock.after(s, fn, data, { channel }) */
|
|
1865
|
+
/** This fixed step's dt on a channel (1/60 x scale). Change a speed with engine.mod('time.<channel>', { owner, set | mul }); timers: engine.clock.after(s, fn, data, { channel }) @experimental */
|
|
1755
1866
|
dt(name: string, id?: string): number;
|
|
1756
1867
|
}
|
|
1757
1868
|
/** engine.vars: story flags and counters (autosaved) */
|
|
@@ -1762,7 +1873,7 @@ export interface Vars {
|
|
|
1762
1873
|
counters: Record<string, number>;
|
|
1763
1874
|
/** Read a flag */
|
|
1764
1875
|
flag(key: string): any;
|
|
1765
|
-
/** Set a flag (default true) */
|
|
1876
|
+
/** Set a flag (default true) @experimental */
|
|
1766
1877
|
setFlag(key: string, value?: any): void;
|
|
1767
1878
|
/** Read a counter (0 if none) */
|
|
1768
1879
|
counter(key: string): number;
|
|
@@ -1788,7 +1899,11 @@ export interface ContentConditionDef {
|
|
|
1788
1899
|
describe?(value: any): string;
|
|
1789
1900
|
}
|
|
1790
1901
|
/** Parameters of content.load(): places is place name -> position. Models are asset names (engine.assets.manifest / an asset pack), not an option */
|
|
1791
|
-
export interface ContentLoadOptions {
|
|
1902
|
+
export interface ContentLoadOptions {
|
|
1903
|
+
places?: Record<string, PositionLike>;
|
|
1904
|
+
/** Inside a save part's load() or a module's afterLoad: the turn it got. Without it this load waits for that replacement to end */
|
|
1905
|
+
turn?: SaveTurn;
|
|
1906
|
+
}
|
|
1792
1907
|
/** A content pack: the object of content/index.js, or a folder / npm package exporting the same tables. Data only: it names assets, never paths or code */
|
|
1793
1908
|
export type ContentPack = Record<string, any> & { name?: string; audio?: import('./core').ContentAudio };
|
|
1794
1909
|
/**
|
|
@@ -1805,15 +1920,20 @@ export interface PropDef {
|
|
|
1805
1920
|
place?: string; x?: number; z?: number;
|
|
1806
1921
|
/** Height above the ground (meters) */
|
|
1807
1922
|
y?: number;
|
|
1808
|
-
/** Rotation about the Y axis (radians) */
|
|
1809
|
-
rot?: number;
|
|
1810
|
-
scale
|
|
1923
|
+
/** Rotation about the Y axis (radians), or [x, y, z] radians to tilt it (a tilted collide needs a collider3d provider) */
|
|
1924
|
+
rot?: number | [number, number, number];
|
|
1925
|
+
/** Uniform scale, or [x, y, z] per axis */
|
|
1926
|
+
scale?: number | [number, number, number];
|
|
1927
|
+
/** false = do not snap to the ground: y is then the height in the world */
|
|
1928
|
+
ground?: boolean;
|
|
1811
1929
|
/** Collision: 'box' cuboid of the bounds, 'circle' cylinder on the model's base, { circle, occluder } the same with its radius in model meters (scales with the prop) and occluder: false so the follow camera passes it; false none (default) */
|
|
1812
1930
|
collide?: 'box' | 'circle' | false | { circle: number; occluder?: boolean };
|
|
1813
1931
|
/** Register for ray acceleration (engine.raycast can hit it), default true */
|
|
1814
1932
|
static?: boolean;
|
|
1815
1933
|
/** false: never drawn through engine.batching (default: repeated props batch automatically) */
|
|
1816
1934
|
batch?: boolean;
|
|
1935
|
+
/** true: lower-detail levels far away (`threedog assets optimize --lod`), or rising distances in meters. Collision, rays and saves keep the full model; such a copy is never batched @experimental */
|
|
1936
|
+
lod?: boolean | number[];
|
|
1817
1937
|
}
|
|
1818
1938
|
/** engine.content: loads the plain data of the game's content/*.js into the engine */
|
|
1819
1939
|
export interface Content {
|
|
@@ -1823,16 +1943,18 @@ export interface Content {
|
|
|
1823
1943
|
markers: Map<string, HudMarker | undefined>;
|
|
1824
1944
|
/**
|
|
1825
1945
|
* Load content (items, pickups, vegetation, NPCs, dialogue, quests, keys, trigger zones, props, the game vocabulary rules): one pack, or a list of packs
|
|
1826
|
-
* 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)
|
|
1827
|
-
*
|
|
1946
|
+
* 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).
|
|
1947
|
+
* 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
|
|
1948
|
+
* back (err.notRestored lists what could not be). A load nobody awaits is reported all the same
|
|
1949
|
+
* @example await engine.content.load([baseContent, forestDlc], { places: { home } })
|
|
1828
1950
|
*/
|
|
1829
|
-
load(data: ContentPack | ContentPack[], opts?: ContentLoadOptions):
|
|
1951
|
+
load(data: ContentPack | ContentPack[], opts?: ContentLoadOptions): Promise<void>;
|
|
1830
1952
|
/** Register a custom condition, e.g. condition('timeAfter', { ref: 'clock', test: (e, t) => e.calendar.timeOfDay >= t }) */
|
|
1831
1953
|
condition(name: string, def: ContentConditionDef): this;
|
|
1832
1954
|
/** 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) */
|
|
1833
1955
|
test(cond: any, opts?: { actor?: string }): boolean;
|
|
1834
1956
|
/** Run an effect (object, array or function (e, { actor })); actor = whose bag give / take change (default the running op's actor, else engine.actor) */
|
|
1835
|
-
run(effect: any, opts?: { actor?: string }): any;
|
|
1957
|
+
run(effect: any, opts?: { actor?: string }): { ok: true } | { ok: false; code: string; facts: { failed: { word: string; code: string; facts: any }[] }; nextActions: any[] };
|
|
1836
1958
|
/** Place name -> position (load's places first, then level markers), null if none */
|
|
1837
1959
|
place(name: string): XZ | null;
|
|
1838
1960
|
/** Position form in content { place?, x?, z? } -> world coordinates */
|
|
@@ -1843,7 +1965,7 @@ export interface Content {
|
|
|
1843
1965
|
*/
|
|
1844
1966
|
template(name: string): Readonly<ContentTemplate>;
|
|
1845
1967
|
/**
|
|
1846
|
-
* The fields one content entry may have (core/params.js spec format): what an editor panel lists and what content-check validates against.
|
|
1968
|
+
* The fields one content entry may have (core/base/params.js spec format): what an editor panel lists and what content-check validates against.
|
|
1847
1969
|
* name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template',
|
|
1848
1970
|
* 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw.
|
|
1849
1971
|
* @example engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }
|
|
@@ -1857,10 +1979,10 @@ export interface Content {
|
|
|
1857
1979
|
*/
|
|
1858
1980
|
spawn(name: string, at: any, fields?: { id?: string; rot?: number; scale?: number; y?: number; items?: Record<string, number>; [stateField: string]: any }): WorldRecord;
|
|
1859
1981
|
}
|
|
1860
|
-
/** One stage of a template with stages: a named step it stays in for duration
|
|
1982
|
+
/** One stage of a template with stages: a named step it stays in for duration calendar seconds (clock.now), e.g. seed -> sprout -> ripe, cold -> armed */
|
|
1861
1983
|
export interface ContentTemplateStage {
|
|
1862
1984
|
name: string;
|
|
1863
|
-
/**
|
|
1985
|
+
/** Calendar seconds spent in this stage; only the last stage may leave it out (it stays there) */
|
|
1864
1986
|
duration?: number;
|
|
1865
1987
|
/** Multiplies the instance's scale while in this stage */
|
|
1866
1988
|
scale?: number;
|
|
@@ -1869,7 +1991,7 @@ export interface ContentTemplateStage {
|
|
|
1869
1991
|
}
|
|
1870
1992
|
/** template:stage event: a template instance entered a new stage by growing (several stages crossed at once give one event) */
|
|
1871
1993
|
export interface TemplateStageEvent { id: string; template: string; stage: number; name: string }
|
|
1872
|
-
/** One field of a content entry (engine.content.fields): the core/params.js spec as plain data */
|
|
1994
|
+
/** One field of a content entry (engine.content.fields): the core/base/params.js spec as plain data */
|
|
1873
1995
|
export interface ContentField {
|
|
1874
1996
|
type: 'string' | 'number' | 'int' | 'bool' | 'position' | 'id' | 'any' | 'object' | 'array' | 'function';
|
|
1875
1997
|
optional?: boolean;
|
|
@@ -1888,6 +2010,8 @@ export interface ContentTemplate {
|
|
|
1888
2010
|
collide?: 'box' | 'circle' | false | { circle: number; occluder?: boolean };
|
|
1889
2011
|
/** false = not registered for rays */
|
|
1890
2012
|
static?: boolean;
|
|
2013
|
+
/** true: lower-detail levels far away (`threedog assets optimize --lod`), or rising distances in meters; such copies are never batched @experimental */
|
|
2014
|
+
lod?: boolean | number[];
|
|
1891
2015
|
/** Interaction: using an instance runs op with { id } */
|
|
1892
2016
|
interact?: { op: string; label?: string | ((rec: WorldRecord, e: Engine) => string); radius?: number; height?: number; action?: string; enabled?: (rec: WorldRecord, e: Engine) => boolean };
|
|
1893
2017
|
/** Each instance gets a container with its record id; items = starting goods (placed once) */
|
|
@@ -1951,7 +2075,7 @@ export interface FlowTransitionOptions {
|
|
|
1951
2075
|
export interface Flow {
|
|
1952
2076
|
/** Current state name */
|
|
1953
2077
|
state: string;
|
|
1954
|
-
/** A scene transition is in progress */
|
|
2078
|
+
/** A scene transition is in progress @experimental */
|
|
1955
2079
|
readonly transitioning: boolean;
|
|
1956
2080
|
/** Define a state (built-in 'playing', 'paused') */
|
|
1957
2081
|
define(name: string, def: FlowStateDef): this;
|
|
@@ -2018,10 +2142,10 @@ export interface Hud {
|
|
|
2018
2142
|
markers: HudMarker[];
|
|
2019
2143
|
/** Add an objective marker: target is an object, position or place name */
|
|
2020
2144
|
marker(target: HudTarget, opts?: HudMarkerOptions): HudMarker;
|
|
2021
|
-
/** Counter or text status (calling again with the same id = update; calling every frame is fine): counter('fish', { label: '鱼', value: 2, max: 5 }), counter('clock', { value: '08:30' }); no value = the label alone */
|
|
2145
|
+
/** Counter or text status (calling again with the same id = update; calling every frame is fine): counter('fish', { label: '鱼', value: 2, max: 5 }), counter('clock', { value: '08:30' }); no value = the label alone, no label = the value alone (the id is not shown) */
|
|
2022
2146
|
counter(id: string, opts: { label?: string; icon?: string; value?: number | string; max?: number; anchor?: HudAnchor }): void;
|
|
2023
2147
|
/** Add n (default 1) to a number counter, return the new value; one not declared yet starts at 0 with its id as the label */
|
|
2024
|
-
|
|
2148
|
+
bump(id: string, n?: number): number;
|
|
2025
2149
|
/** Current value of a counter or bar (number or text), undefined when there is none; reads what interactions.add({ counter }) has added up */
|
|
2026
2150
|
value(id: string): number | string | undefined;
|
|
2027
2151
|
/** Progress bar (calling again with the same id = update; calling every frame is fine, the DOM is untouched when the value is unchanged),
|