threedog 0.7.0 → 0.8.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 +196 -1
- package/README.md +6 -9
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +98 -54
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- 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} +6 -12
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +26 -23
- 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} +10 -10
- package/core/{Random.js → base/Random.js} +5 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +98 -110
- package/core/{errorHints.js → base/errorHints.js} +5 -9
- package/core/{errors.js → base/errors.js} +6 -6
- package/core/{events.generated.js → base/events.generated.js} +1 -0
- package/core/{math.js → base/math.js} +15 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +28 -7
- package/core/{Engine.js → engine/Engine.js} +80 -77
- package/core/{Loading.js → engine/Loading.js} +4 -2
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
- package/core/{lifecycle.js → engine/lifecycle.js} +14 -12
- package/core/{loop.js → engine/loop.js} +68 -47
- package/core/{moduleSlots.js → engine/moduleSlots.js} +6 -6
- package/core/{moduleTypes.js → engine/moduleTypes.js} +13 -14
- package/core/{modules.js → engine/modules.js} +14 -11
- package/core/{page.js → engine/page.js} +36 -23
- package/core/{plugins.js → engine/plugins.js} +6 -9
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +26 -24
- package/core/{Input.js → input/Input.js} +30 -22
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/{inputPad.js → input/inputPad.js} +1 -1
- package/core/{inputPointer.js → input/inputPointer.js} +8 -2
- package/core/{inputTouch.js → input/inputTouch.js} +1 -1
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +30 -16
- package/core/{Describe.js → inspect/Describe.js} +26 -22
- package/core/{Inspect.js → inspect/Inspect.js} +9 -7
- 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} +52 -20
- package/core/{catalog.js → inspect/catalog.js} +3 -3
- 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} +21 -20
- package/core/{describeText.js → inspect/describeText.js} +11 -6
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +15 -16
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/{Ops.js → ops/Ops.js} +16 -11
- package/core/{control.js → ops/control.js} +13 -12
- package/core/ops/holds.js +139 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
- package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +7 -4
- package/core/{owned.js → ops/owned.js} +14 -17
- package/core/{sharedPoint.js → ops/sharedPoint.js} +8 -8
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +12 -14
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
- package/core/{Saves.js → saves/Saves.js} +58 -36
- package/core/{saveApply.js → saves/saveApply.js} +13 -9
- package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
- package/core/{saveValues.js → saves/saveValues.js} +20 -3
- package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
- package/core/{session.js → saves/session.js} +31 -17
- package/core/{Rays.js → scene/Rays.js} +23 -25
- package/core/{Views.js → scene/Views.js} +14 -6
- package/core/{adaptive.js → scene/adaptive.js} +15 -8
- package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
- package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
- 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} +4 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/{ground.js → scene/ground.js} +9 -9
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/{sceneDelta.js → scene/sceneDelta.js} +2 -2
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -13
- package/core/scene/stepPoses.js +55 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +6 -5
- package/core/{thingOps.js → scene/thingOps.js} +4 -3
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{view.js → scene/view.js} +17 -16
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +60 -30
- package/core/{batchGroups.js → stream/batchGroups.js} +10 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +2 -2
- package/core/{streamSources.js → stream/streamSources.js} +12 -7
- package/core/{Commits.js → threads/Commits.js} +6 -5
- package/core/{Jobs.js → threads/Jobs.js} +12 -10
- package/core/{Threads.js → threads/Threads.js} +16 -16
- 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} +17 -10
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +18 -17
- package/core/{time.js → time/time.js} +18 -12
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +22 -19
- package/docs/API.md +24 -23
- package/docs/CODEMAP.md +76 -183
- package/docs/COMMANDS.md +66 -58
- package/docs/CONVENTIONS.md +54 -14
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +78 -29
- 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 +29 -29
- package/docs/api/characters.md +23 -18
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +45 -43
- package/docs/api/events.md +3 -2
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +7 -7
- package/docs/api/interactions.md +4 -4
- package/docs/api/inventory.md +9 -9
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -7
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +2 -2
- package/docs/api/post.md +20 -3
- package/docs/api/quests.md +3 -3
- package/docs/api/rays.md +5 -7
- package/docs/api/rigid.md +27 -18
- package/docs/api/saves.md +8 -7
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +7 -8
- package/docs/api/terrainDraw.md +1 -1
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +25 -22
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +1 -1
- package/docs/api/water.md +1 -1
- package/docs/api/weather.md +9 -9
- package/docs/api/weatherDraw.md +3 -3
- package/docs/api/world.md +5 -5
- package/docs/recipes/01-new-game.md +25 -40
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +27 -43
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +29 -39
- package/docs/recipes/06-clock-events.md +27 -18
- package/docs/recipes/07-flow-scenes-pause.md +12 -17
- package/docs/recipes/08-weather-sky.md +88 -34
- package/docs/recipes/09-materials-lights-models.md +22 -36
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +30 -22
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +39 -17
- package/docs/recipes/14-custom-module.md +14 -13
- package/docs/recipes/15-perf.md +49 -26
- package/docs/recipes/16-dev-bridge.md +32 -52
- package/docs/recipes/18-world.md +36 -23
- package/docs/recipes/19-shooting-picking.md +4 -2
- package/docs/recipes/20-content-actions-save.md +30 -35
- package/docs/recipes/21-camera.md +33 -5
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +10 -10
- package/docs/recipes/26-ui-parts.md +22 -12
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +117 -21
- package/docs/recipes/29-grid.md +2 -2
- package/docs/recipes/30-templates.md +55 -19
- package/docs/recipes/31-audio.md +5 -5
- package/docs/recipes/32-action-game.md +15 -6
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +67 -19
- package/docs/recipes/35-picture-from-reference.md +10 -17
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +7 -11
- package/docs/recipes/43-shader-patches-surfaces.md +20 -41
- package/docs/recipes/44-water-weather-hooks.md +48 -43
- package/docs/recipes/45-cascaded-shadows.md +39 -17
- package/docs/recipes/46-blender-art-route.md +7 -8
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/52-around-the-picture.md +54 -98
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +12 -16
- package/docs/recipes/56-webgpu-tsl.md +16 -14
- package/docs/recipes/57-control.md +9 -2
- package/docs/recipes/58-input.md +2 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +29 -24
- package/docs/recipes/62-picture-code.md +49 -17
- package/docs/recipes/63-third-person-start.md +17 -4
- package/docs/recipes/64-particles.md +1 -1
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +2 -2
- package/examples/{sheepisland → perf-island}/.threedog/content-index.json +1 -1
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +12 -11
- 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 +1 -0
- package/examples/rc2d/GAMEMAP.md +3 -2
- package/examples/rc2d/main.js +1 -3
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +3 -2
- 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 +1 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +4 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +8 -7
- package/index.js +31 -31
- package/llms.txt +9 -13
- package/modules/ambience/Ambience.js +11 -8
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +13 -13
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +2 -2
- package/modules/camera/FixedCamera.js +14 -15
- package/modules/camera/FollowCamera.js +4 -4
- package/modules/camera/RtsCamera.js +11 -11
- package/modules/camera/common.js +48 -24
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +33 -30
- package/modules/characters/NPC.js +27 -19
- package/modules/characters/assetModel.js +14 -10
- package/modules/characters/astar.js +7 -5
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +168 -214
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +16 -14
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +8 -8
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +23 -17
- package/modules/characters/npcView.js +6 -5
- package/modules/characters/pathAsync.js +12 -10
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +108 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +26 -20
- package/modules/collision/contract.js +15 -0
- package/modules/content/explain.js +1 -2
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +2 -2
- package/modules/content/index.js +61 -99
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +10 -7
- package/modules/content/packs.js +3 -3
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +35 -0
- package/modules/content/props.js +17 -14
- package/modules/content/rules.js +25 -21
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +20 -20
- package/modules/content/words.js +34 -0
- package/modules/debug/DebugPanel.js +10 -43
- package/modules/flow/contract.js +1 -1
- package/modules/flow/index.js +11 -7
- package/modules/gameplay/Container.js +12 -11
- package/modules/gameplay/Containers.js +14 -5
- package/modules/gameplay/Dialogue.js +13 -11
- package/modules/gameplay/Interactions.js +37 -24
- package/modules/gameplay/Inventory.js +8 -9
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +3 -4
- package/modules/gameplay/inventoryOps.js +0 -1
- package/modules/gameplay/pickups.js +22 -23
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +4 -4
- package/modules/grid/index.js +7 -8
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +37 -55
- package/modules/hud/index.js +17 -11
- package/modules/hud/parts.js +4 -4
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +47 -152
- package/modules/level/load.js +79 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +6 -7
- package/modules/lights/index.js +28 -181
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +30 -26
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +14 -0
- package/modules/nav/index.js +11 -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 +5 -4
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +11 -8
- package/modules/particles/effect.js +7 -5
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +15 -17
- package/modules/rigid/RigidBodies.js +66 -43
- package/modules/rigid/Vehicles.js +2 -3
- package/modules/rigid/ragdoll.js +287 -0
- package/modules/rigid/ragdollBones.js +159 -0
- package/modules/rigid/sync.js +6 -6
- package/modules/settings/Settings.js +108 -39
- package/modules/settings/apply.js +6 -6
- package/modules/settings/sections.js +16 -14
- 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 +14 -27
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +346 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +70 -52
- 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 +28 -34
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +17 -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 +27 -19
- package/modules/timeline/Tween.js +6 -6
- package/modules/timeline/shots.js +5 -7
- package/modules/triggers/index.js +9 -9
- package/modules/vegetation/Vegetation.js +30 -23
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +23 -18
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +8 -6
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +16 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +41 -30
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +22 -18
- package/modules/world/World.js +8 -8
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -12
- package/modules/world/persist.js +73 -25
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +28 -8
- package/modules/world/sim.js +4 -4
- package/modules/world/state.js +12 -5
- package/modules/world/thingSource.js +4 -2
- package/modules/world/views.js +11 -9
- package/package.json +42 -7
- package/presets.js +1 -3
- package/render/PostFX.js +39 -27
- package/render/backend.js +26 -32
- 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/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +27 -23
- 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 +1 -1
- package/render/lighting.js +5 -3
- package/render/lightmap.js +20 -20
- 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 +20 -4
- package/render/ownFrame.js +4 -4
- package/render/patches.js +13 -13
- package/render/postWebGL.js +12 -10
- package/render/probes.js +16 -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 +57 -11
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +200 -153
- package/types/gameplay.d.ts +163 -91
- 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} +7 -15
- 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} +12 -8
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +2 -2
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
- 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/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 +1 -1
- 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 +2 -1
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +16 -12
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +5 -3
- package/types/generated/render/PostFX.d.ts +17 -11
- 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 +11 -11
- package/types/physics.d.ts +99 -70
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +38 -71
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +4 -3
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +5 -3
- package/core/assetEntry.js +0 -109
- package/core/holds.js +0 -134
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- 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/core/{Vars.js → base/Vars.js} +0 -0
- /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/{opsFail.js → ops/opsFail.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/{tier.js → scene/tier.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
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
import type { Engine } from './core';
|
|
5
|
-
import type { Input } from './generated/core/Input';
|
|
5
|
+
import type { Input } from './generated/core/input/Input';
|
|
6
6
|
import type { Animator, AnimatorOptions, Rideable } from './physics';
|
|
7
7
|
import type { WorldRecord } from './generated/modules/world/World';
|
|
8
8
|
|
|
@@ -93,15 +93,15 @@ export interface LevelOptions {
|
|
|
93
93
|
outside?: number;
|
|
94
94
|
/** Water surface height (meters), default no water */
|
|
95
95
|
waterLevel?: number;
|
|
96
|
-
/** Expand the collision box outward by this much (meters) */
|
|
96
|
+
/** Expand the collision box outward by this much (meters) @experimental */
|
|
97
97
|
colliderPad?: number;
|
|
98
|
-
/** Minimum height of the collision box (meters) */
|
|
98
|
+
/** Minimum height of the collision box (meters) @experimental */
|
|
99
99
|
colliderHeight?: number;
|
|
100
|
-
/** Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6 */
|
|
100
|
+
/** Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6 @experimental */
|
|
101
101
|
sharpEdge?: number;
|
|
102
|
-
/** Hide the marker placeholder meshes, default true */
|
|
102
|
+
/** Hide the marker placeholder meshes, default true @experimental */
|
|
103
103
|
hideMarkers?: boolean;
|
|
104
|
-
/** Add the scene to engine.scene, default true */
|
|
104
|
+
/** Add the scene to engine.scene, default true @experimental */
|
|
105
105
|
addToScene?: boolean;
|
|
106
106
|
}
|
|
107
107
|
/** Markers in the level (spawn, npc_*, trigger_*, marker_*), in world coordinates */
|
|
@@ -116,7 +116,7 @@ export interface Level {
|
|
|
116
116
|
markers: Record<string, LevelMarker>;
|
|
117
117
|
/** Spawn point position */
|
|
118
118
|
spawn: Vector3;
|
|
119
|
-
/** Heightfield (for debugging) */
|
|
119
|
+
/** Heightfield (for debugging) @experimental */
|
|
120
120
|
heightfield: any;
|
|
121
121
|
/** Whether loading is finished */
|
|
122
122
|
readonly ready: boolean;
|
|
@@ -124,7 +124,7 @@ export interface Level {
|
|
|
124
124
|
marker(name: string): LevelMarker | null;
|
|
125
125
|
/** Get all markers whose names start with prefix, e.g. markersWith('npc_') */
|
|
126
126
|
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) */
|
|
127
|
+
/** Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together) @experimental */
|
|
128
128
|
unload(): void;
|
|
129
129
|
/**
|
|
130
130
|
* Change level: unload the current one, load the new one (glTF path/asset name, or a THREE object), and emit level:loaded when done. When a load
|
|
@@ -237,7 +237,7 @@ export interface Triggers {
|
|
|
237
237
|
|
|
238
238
|
/** Particle effect parameters (define(), and each entry of particles({ effects, default })). All optional */
|
|
239
239
|
export interface ParticleOptions {
|
|
240
|
-
/** Maximum alive at once, default 120 (
|
|
240
|
+
/** Maximum alive at once, default 120 (60 on low-tier devices; a number the game gives stands) */
|
|
241
241
|
max?: number;
|
|
242
242
|
/** Seconds each particle lives [min, max] */
|
|
243
243
|
lifetime?: Range;
|
|
@@ -307,13 +307,48 @@ export interface ParticlesOptions {
|
|
|
307
307
|
|
|
308
308
|
// Particles (engine.particles) is generated from the JSDoc in modules/particles/Particles.js (npm run map); only the type is re-exported here
|
|
309
309
|
import type { Particles } from './generated/modules/particles/Particles';
|
|
310
|
+
|
|
311
|
+
// Swarm swarm()
|
|
312
|
+
|
|
313
|
+
/** Options of engine.swarm(). See recipes/65-swarm.md */
|
|
314
|
+
export interface SwarmOptions {
|
|
315
|
+
/** Unique name: shown in describe(), the key in a save */
|
|
316
|
+
name: string;
|
|
317
|
+
/** Most objects alive at once; all memory is taken up front */
|
|
318
|
+
capacity: number;
|
|
319
|
+
/** Plain three.js geometry, stays the game's to dispose. Leave out with material for a swarm that draws nothing */
|
|
320
|
+
geometry?: import('three').BufferGeometry;
|
|
321
|
+
/** Plain three.js material, stays the game's to dispose */
|
|
322
|
+
material?: import('three').Material;
|
|
323
|
+
/** Number columns beside x, y, z. yaw, pitch, roll (radians, order YXZ) and scale are also drawn by the engine */
|
|
324
|
+
fields?: string[];
|
|
325
|
+
/** Per-object colour: columns r, g, b (linear) and spawn({ color: 0xff8800 }) */
|
|
326
|
+
color?: boolean;
|
|
327
|
+
/** Time channel of the onStep dt (default 'world') */
|
|
328
|
+
channel?: string;
|
|
329
|
+
/** Grid cell for near, in meters: about the usual query radius (default 2) */
|
|
330
|
+
cell?: number;
|
|
331
|
+
/** Keep this swarm in saves; otherwise it is empty after a load or new game */
|
|
332
|
+
save?: boolean;
|
|
333
|
+
}
|
|
334
|
+
/** The columns of a swarm: d.x[row], d.vx[row]... and d.id[row], the handle of that row */
|
|
335
|
+
export type SwarmData = { x: Float32Array; y: Float32Array; z: Float32Array; id: Float64Array } & Record<string, Float32Array | Float64Array>;
|
|
336
|
+
/** Runs for each live row every fixed step; returning false removes the object, anything else keeps it */
|
|
337
|
+
export type SwarmRowFn = (d: SwarmData, i: number, dt: number) => unknown;
|
|
338
|
+
import type { Swarm } from './generated/modules/swarm/Swarm';
|
|
339
|
+
export type { Swarm };
|
|
340
|
+
/** engine.swarm: call it to make a swarm */
|
|
341
|
+
export interface SwarmMaker {
|
|
342
|
+
/** Make a swarm. Returns a Swarm: spawn, free, row, onStep, near, clear, dispose, count, capacity, data, mesh */
|
|
343
|
+
(opts: SwarmOptions): Swarm;
|
|
344
|
+
}
|
|
310
345
|
export type { Particles };
|
|
311
346
|
|
|
312
347
|
// ======================================================================
|
|
313
348
|
// Settings menu settings()
|
|
314
349
|
// ======================================================================
|
|
315
350
|
|
|
316
|
-
/** Contents of a graphics quality preset */
|
|
351
|
+
/** 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
352
|
export interface QualityPreset { pixelRatio?: number; shadows?: boolean; antialias?: boolean; bloom?: boolean; ao?: boolean; viewChunks?: number; density?: number; [key: string]: any }
|
|
318
353
|
/**
|
|
319
354
|
* The tools a settings tab's render(tools, e, s) receives: escaping, translation and the control helpers (each returns HTML)
|
|
@@ -356,10 +391,12 @@ export interface SettingsOptions {
|
|
|
356
391
|
/**
|
|
357
392
|
* Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional
|
|
358
393
|
* '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)
|
|
394
|
+
* / camera.fov). The entry { id: 'graphics', omit } leaves graphics rows out (quality, pixelRatio, shadows, antialias, bloom, ao, adaptive, viewChunks,
|
|
395
|
+
* density): an omitted row stays the game's value, and no preset or stored value moves it
|
|
360
396
|
* @example settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })
|
|
397
|
+
* @example settings({ sections: [{ id: 'graphics', omit: ['pixelRatio', 'antialias', 'adaptive'] }, 'audio', 'controls', 'language', 'saves'] }) // a fixed pixel look
|
|
361
398
|
*/
|
|
362
|
-
sections?: boolean | string[];
|
|
399
|
+
sections?: boolean | (string | { id: 'graphics'; omit: string[] })[];
|
|
363
400
|
/**
|
|
364
401
|
* 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
402
|
* it uses engine.freeze); the picture keeps running, default false
|
|
@@ -369,19 +406,19 @@ export interface SettingsOptions {
|
|
|
369
406
|
|
|
370
407
|
/** engine.settings */
|
|
371
408
|
export interface Settings {
|
|
372
|
-
/** All current setting values */
|
|
373
|
-
values: Record<string, any>;
|
|
409
|
+
/** All current setting values, read only (set() changes one). pixelRatio is the renderer's real ratio */
|
|
410
|
+
readonly values: Record<string, any>;
|
|
374
411
|
/** Graphics presets */
|
|
375
412
|
presets: Record<string, QualityPreset>;
|
|
376
|
-
/** Tabs */
|
|
413
|
+
/** Tabs @experimental */
|
|
377
414
|
sections: Map<string, any>;
|
|
378
|
-
/** Whether the menu is open */
|
|
415
|
+
/** Whether the menu is open @experimental */
|
|
379
416
|
readonly isOpen: boolean;
|
|
380
417
|
/** Read a setting, e.g. get('vol.music') */
|
|
381
418
|
get(key: string): any;
|
|
382
419
|
/** Change a setting (takes effect immediately + saved) */
|
|
383
420
|
set(key: string, value: any, opts?: { save?: boolean }): void;
|
|
384
|
-
/** Graphics preset: 'low' | 'medium' | 'high' */
|
|
421
|
+
/** Graphics preset: 'low' | 'medium' | 'high' @experimental */
|
|
385
422
|
preset(name: 'low' | 'medium' | 'high' | (string & {})): void;
|
|
386
423
|
/** Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row
|
|
387
424
|
* 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 +426,16 @@ export interface Settings {
|
|
|
389
426
|
define<T = any>(key: string, def: T, apply?: ((value: T, e: Engine) => void) | { apply?: (value: T, e: Engine) => void; limits?: string | string[] }): this;
|
|
390
427
|
/** Add a tab of your own, or a built-in / optional one by name: addSection('camera') */
|
|
391
428
|
addSection(id: string, section?: SettingsSection): this;
|
|
392
|
-
removeSection(id: string): void;
|
|
393
429
|
open(): void;
|
|
394
430
|
close(): void;
|
|
395
431
|
toggle(on?: boolean): void;
|
|
396
|
-
/**
|
|
432
|
+
/** 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 */
|
|
433
|
+
reset(key?: string): void;
|
|
434
|
+
/** Restore all keys to defaults @experimental */
|
|
397
435
|
resetBindings(): void;
|
|
398
436
|
/** Change the first key of an action to code */
|
|
399
437
|
rebind(action: string, code: string): void;
|
|
400
|
-
/** Key list (for the UI) */
|
|
438
|
+
/** Key list (for the UI) @experimental */
|
|
401
439
|
actionList(): any[];
|
|
402
440
|
/** Save to the browser */
|
|
403
441
|
save(): void;
|
|
@@ -425,7 +463,7 @@ export interface MusicOptions {
|
|
|
425
463
|
fade?: number;
|
|
426
464
|
/** Duck the music bus during dialogue to this (0-1, e.g. 0.35); default false = no duck (the game opts in) */
|
|
427
465
|
duckDialogue?: number | false;
|
|
428
|
-
/** Fade seconds for the ducking */
|
|
466
|
+
/** Fade seconds for the ducking @experimental */
|
|
429
467
|
duckFade?: number;
|
|
430
468
|
/** Rule debounce seconds, default 2 */
|
|
431
469
|
hold?: number;
|
|
@@ -561,10 +599,8 @@ export type CharacterState = 'idle' | 'walk' | 'run' | 'swim' | 'jump' | 'fall'
|
|
|
561
599
|
/** Character (player and NPCs) */
|
|
562
600
|
export declare class Character {
|
|
563
601
|
constructor(engine: Engine, opts?: CharacterOptions);
|
|
564
|
-
/** Root node
|
|
602
|
+
/** 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
603
|
root: Object3D;
|
|
566
|
-
/** Same as root: add children, change visible and scale on it */
|
|
567
|
-
readonly object: Object3D;
|
|
568
604
|
/** Position (= root.position) */
|
|
569
605
|
readonly position: Vector3;
|
|
570
606
|
/** 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 +610,11 @@ export declare class Character {
|
|
|
574
610
|
* root.rotation.y)
|
|
575
611
|
*/
|
|
576
612
|
facing: number;
|
|
577
|
-
/** Vertical velocity (m/s). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly) */
|
|
613
|
+
/** 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
614
|
vy: number;
|
|
579
615
|
/** Whether standing on the ground */
|
|
580
616
|
grounded: boolean;
|
|
581
|
-
/** Whether swimming */
|
|
617
|
+
/** Whether swimming @experimental */
|
|
582
618
|
swimming: boolean;
|
|
583
619
|
/** Current action state */
|
|
584
620
|
state: CharacterState;
|
|
@@ -588,15 +624,23 @@ export declare class Character {
|
|
|
588
624
|
faceMode: FaceMode;
|
|
589
625
|
/** What faceMode 'target' faces */
|
|
590
626
|
faceTarget: PositionLike | null;
|
|
591
|
-
/** Player only: whether the camera module follows it (see PlayerOptions.cameraFollow) */
|
|
627
|
+
/** Player only: whether the camera module follows it (see PlayerOptions.cameraFollow) @experimental */
|
|
592
628
|
cameraFollow?: boolean;
|
|
593
629
|
/** 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
630
|
push(vx: number, vz: number, seconds: number): void;
|
|
595
|
-
speed: number; runSpeed: number; radius: number; water: CharacterWater; states: CharacterStates | null;
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
|
|
599
|
-
/**
|
|
631
|
+
speed: number; runSpeed: number; radius: number; water: CharacterWater; states: CharacterStates | null;
|
|
632
|
+
/** @experimental */ swimDepth: number;
|
|
633
|
+
/** @experimental */ swimSpeedFactor: number;
|
|
634
|
+
/** @experimental */ turnSpeed: number;
|
|
635
|
+
/** @experimental */ acceleration: number; gravity: number; jumpSpeed: number;
|
|
636
|
+
/** @experimental */ stepHeight: number;
|
|
637
|
+
/** @experimental */ airControl: number;
|
|
638
|
+
/** @experimental */ coyoteTime: number; canJump: boolean;
|
|
639
|
+
/** Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed')) @experimental */
|
|
640
|
+
maxJumps: number;
|
|
641
|
+
/** @experimental */ airJumpSpeed: number | null;
|
|
642
|
+
/** @experimental */ jumpBuffer: number;
|
|
643
|
+
/** Fall check (see CharacterOptions.fall); a plain property @experimental */
|
|
600
644
|
fall: false | { belowY: number | ((character: Character) => boolean) };
|
|
601
645
|
/** Time channel the engine drives it on (see CharacterOptions.channel) */
|
|
602
646
|
channel: string;
|
|
@@ -607,25 +651,21 @@ export declare class Character {
|
|
|
607
651
|
* @example engine.mod('move.speed', { owner: 'haste', id: 'player', mul: 1.2, for: 5 }); player.stat('speed') // 1.2 x player.speed
|
|
608
652
|
*/
|
|
609
653
|
stat(name: 'speed' | 'runSpeed' | 'gravity' | 'jumpSpeed' | 'canJump'): number;
|
|
610
|
-
/** Give back n jumps for this airtime (pickup, wall touch) */
|
|
654
|
+
/** Give back n jumps for this airtime (pickup, wall touch) @experimental */
|
|
611
655
|
addJumps(n?: number): this;
|
|
612
|
-
/** All jumps back, as if it had landed */
|
|
656
|
+
/** All jumps back, as if it had landed @experimental */
|
|
613
657
|
resetJumps(): this;
|
|
614
658
|
/**
|
|
615
659
|
* 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
660
|
* @example player.launch(19, { owner: 'pad' })
|
|
617
661
|
*/
|
|
618
662
|
launch(speed: number, opts?: { owner?: string }): this;
|
|
619
|
-
/** Jump state now, read-only */
|
|
663
|
+
/** Jump state now, read-only @experimental */
|
|
620
664
|
jumpState(): { grounded: boolean; coyoteLeft: number; bufferLeft: number; jumpsUsed: number; jumpsLeft: number; vy: number };
|
|
621
665
|
/** What it stands on, read-only (reused object); 'platform' = a registered support (characters.support), which carries it */
|
|
622
666
|
readonly support: { kind: 'ground' | 'platform' | 'collider' | 'water' | null; object: any; id: string | null; safe: boolean; velocity: { x: number; y: number; z: number } };
|
|
623
667
|
/** Last spot it stood still on safe ground (where a fall returns it); null until it first stands. Saved with the motion */
|
|
624
668
|
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
669
|
/** 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
670
|
get mover(): { name: 'simple' | 'rapier' | 'manual'; controller?: any; body?: any; collider?: any; move(dirX: number, dirZ: number, run: boolean, dt: number): void; dispose?(): void };
|
|
631
671
|
set mover(name: 'simple' | 'rapier' | 'manual');
|
|
@@ -635,7 +675,7 @@ export declare class Character {
|
|
|
635
675
|
ready: boolean;
|
|
636
676
|
/**
|
|
637
677
|
* 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' }).
|
|
678
|
+
* @example const npc = new Character(engine, { model: 'villager' }); engine.add(npc.root); // import { Character } from 'threedog' await npc.whenReady;
|
|
639
679
|
* npc.playAction('Wave');
|
|
640
680
|
*/
|
|
641
681
|
readonly whenReady: Promise<void>;
|
|
@@ -664,8 +704,6 @@ export declare class Character {
|
|
|
664
704
|
* @example createPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump
|
|
665
705
|
*/
|
|
666
706
|
jump(opts?: { air?: boolean }): this;
|
|
667
|
-
/** Add to the scene */
|
|
668
|
-
addTo(scene?: any): this;
|
|
669
707
|
/** Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z }) */
|
|
670
708
|
placeAt(position: PositionLike): this;
|
|
671
709
|
/**
|
|
@@ -693,9 +731,10 @@ export declare class Character {
|
|
|
693
731
|
/**
|
|
694
732
|
* Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after
|
|
695
733
|
* the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
|
|
734
|
+
* @experimental
|
|
696
735
|
*/
|
|
697
736
|
saveMotion(out?: CharacterMotion): CharacterMotion;
|
|
698
|
-
/** Restore the motion state from the plain object of saveMotion */
|
|
737
|
+
/** Restore the motion state from the plain object of saveMotion @experimental */
|
|
699
738
|
loadMotion(m: CharacterMotion | null | undefined): this;
|
|
700
739
|
}
|
|
701
740
|
/** Result of Character.saveMotion (plain values, can be saved); facing is the same as Character.facing: 0 = +Z, forward (sin f, cos f) */
|
|
@@ -888,6 +927,7 @@ export interface CharactersApi {
|
|
|
888
927
|
/**
|
|
889
928
|
* Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the
|
|
890
929
|
* position and the vehicle; loading an on-foot save exits the vehicle first
|
|
930
|
+
* @experimental
|
|
891
931
|
*/
|
|
892
932
|
removePlayer(): void;
|
|
893
933
|
/**
|
|
@@ -921,7 +961,7 @@ export interface FindSpawnOptions { minH?: number; maxH?: number; maxSlope?: num
|
|
|
921
961
|
export interface CharactersOptions {
|
|
922
962
|
/** Whether to enable NPCs (engine.npcs), default true */
|
|
923
963
|
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) */
|
|
964
|
+
/** Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts) @experimental */
|
|
925
965
|
npcTiers?: { fullRadius: number; nearEvery: number };
|
|
926
966
|
/** 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
967
|
animation?: AnimatorOptions;
|
|
@@ -936,6 +976,34 @@ export interface FindPathOptions { step?: number; maxNodes?: number; radius?: nu
|
|
|
936
976
|
// Interactions interactions()
|
|
937
977
|
// ======================================================================
|
|
938
978
|
|
|
979
|
+
/** One live interaction, as interactions.get(id) and interactions.items give it */
|
|
980
|
+
export interface Interaction {
|
|
981
|
+
id: string;
|
|
982
|
+
/** What it follows; a fixed position is an empty Object3D placed there */
|
|
983
|
+
object: Object3D;
|
|
984
|
+
label: string | ((object: Object3D, ctx: { actor: string }) => string);
|
|
985
|
+
radius: number;
|
|
986
|
+
action: string;
|
|
987
|
+
onUse?: (object: Object3D, ctx: { actor: string }) => any;
|
|
988
|
+
enabled: (object: Object3D, ctx: { actor: string }) => boolean;
|
|
989
|
+
height?: number;
|
|
990
|
+
hold: number;
|
|
991
|
+
approach: boolean;
|
|
992
|
+
once: boolean;
|
|
993
|
+
counter?: string;
|
|
994
|
+
}
|
|
995
|
+
/** inventory.add: what went in, or why nothing did */
|
|
996
|
+
export interface ItemAddResult {
|
|
997
|
+
ok: boolean;
|
|
998
|
+
/** The entry they went into ('arrow', 'sword#3'); set when ok */
|
|
999
|
+
key?: string;
|
|
1000
|
+
/** How many fit (a partial fit places what fits); set when ok */
|
|
1001
|
+
added?: number;
|
|
1002
|
+
/** 'full' when none fit */
|
|
1003
|
+
code?: 'full';
|
|
1004
|
+
facts?: { id: string; n: number };
|
|
1005
|
+
nextActions?: any[];
|
|
1006
|
+
}
|
|
939
1007
|
export interface InteractionOptions {
|
|
940
1008
|
/** Stable id for the op interaction.use { id } (default: the world record id it was built for, else a running number) */
|
|
941
1009
|
id?: string;
|
|
@@ -966,15 +1034,15 @@ export interface InteractionOptions {
|
|
|
966
1034
|
approach?: boolean;
|
|
967
1035
|
/** 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
1036
|
once?: boolean;
|
|
969
|
-
/** Name of a HUD counter each use adds 1 to (hud.
|
|
1037
|
+
/** Name of a HUD counter each use adds 1 to (hud.bump; nothing without hud()). Saved; read the total with hud.value(name) */
|
|
970
1038
|
counter?: string;
|
|
971
1039
|
}
|
|
972
1040
|
/** engine.interactions */
|
|
973
1041
|
export interface Interactions {
|
|
974
|
-
/** How high the prompt floats (meters) */
|
|
1042
|
+
/** How high the prompt floats (meters) @experimental */
|
|
975
1043
|
promptHeight: number;
|
|
976
1044
|
/** All interactions in the order added (a fresh array each read; get(id) finds one without it) */
|
|
977
|
-
readonly items:
|
|
1045
|
+
readonly items: Interaction[];
|
|
978
1046
|
/** Default reach of add() in meters (2.5) */
|
|
979
1047
|
radius: number;
|
|
980
1048
|
/** How the one in front of the actor is chosen; can be changed at runtime */
|
|
@@ -990,8 +1058,8 @@ export interface Interactions {
|
|
|
990
1058
|
* Returns a handle { remove() }
|
|
991
1059
|
*/
|
|
992
1060
|
add(target: Object3D | PositionLike, opts?: InteractionOptions): Handle;
|
|
993
|
-
/** The interaction with this id, or
|
|
994
|
-
get(id: string):
|
|
1061
|
+
/** 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) */
|
|
1062
|
+
get(id: string): Interaction | undefined;
|
|
995
1063
|
}
|
|
996
1064
|
/**
|
|
997
1065
|
* 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 +1165,7 @@ export interface BubbleView { speaker: string; text: string; x: number; y: numbe
|
|
|
1097
1165
|
export interface Dialogue {
|
|
1098
1166
|
/** Story state: state.flags is engine.vars.flags (autosaved) */
|
|
1099
1167
|
readonly state: DialogueState;
|
|
1100
|
-
/** All scripts */
|
|
1168
|
+
/** All scripts @experimental */
|
|
1101
1169
|
scripts: Map<string, DialogueScript>;
|
|
1102
1170
|
/**
|
|
1103
1171
|
* The dialogue in progress (null when none). speaker: the script name; node: the current node OBJECT (its fields: text, choices, data...);
|
|
@@ -1105,10 +1173,10 @@ export interface Dialogue {
|
|
|
1105
1173
|
* @example const atAsk = engine.dialogue.active?.id === 'ask'; // the node id; active.node.data holds the node's own fields
|
|
1106
1174
|
*/
|
|
1107
1175
|
readonly active: { speaker: string; nodes: DialogueScript; node?: DialogueNode; id?: string; onEnd: (() => void) | null } | null;
|
|
1108
|
-
/** The script the main dialogue is playing */
|
|
1176
|
+
/** The script the main dialogue is playing @experimental */
|
|
1109
1177
|
readonly speaking: string | null;
|
|
1110
|
-
/** Typing speed (characters/second) */
|
|
1111
|
-
|
|
1178
|
+
/** Typing speed (characters/second) @experimental */
|
|
1179
|
+
charsPerSecond: number;
|
|
1112
1180
|
/** Define a dialogue (the name is usually the speaker) */
|
|
1113
1181
|
define(speaker: string, nodes: DialogueScript): void;
|
|
1114
1182
|
/**
|
|
@@ -1263,7 +1331,7 @@ export interface PickupOptions {
|
|
|
1263
1331
|
auto?: boolean;
|
|
1264
1332
|
/** The game's own three.js object for this one pickup (only detached when it goes; otherwise the model name decides the shape) */
|
|
1265
1333
|
mesh?: Object3D | null;
|
|
1266
|
-
/**
|
|
1334
|
+
/** Calendar seconds until it reappears, 0 = never reappears */
|
|
1267
1335
|
respawnSeconds?: number;
|
|
1268
1336
|
/** Bob up and down and rotate, default true */
|
|
1269
1337
|
bob?: boolean;
|
|
@@ -1289,7 +1357,7 @@ export interface Pickups {
|
|
|
1289
1357
|
material: Material;
|
|
1290
1358
|
/** Edge of the placeholder box (meters), read when one is built */
|
|
1291
1359
|
size: number;
|
|
1292
|
-
/** Height above the ground new pickups float at (meters) */
|
|
1360
|
+
/** Height above the ground new pickups float at (meters) @experimental */
|
|
1293
1361
|
lift: number;
|
|
1294
1362
|
/**
|
|
1295
1363
|
* 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 +1370,7 @@ export interface Pickups {
|
|
|
1302
1370
|
export interface PickupsOptions {
|
|
1303
1371
|
/** Reach of pickups that do not set their own radius (meters), default 2 */
|
|
1304
1372
|
radius?: number;
|
|
1305
|
-
/** Pickups have a model, float and spin only within this distance (meters) of the stream sources, default 60 */
|
|
1373
|
+
/** Pickups have a model, float and spin only within this distance (meters) of the stream sources, default 60 @experimental */
|
|
1306
1374
|
showDistance?: number;
|
|
1307
1375
|
/** Who walks into auto pickups (actor ids); default engine.actor, plus net peers on a host */
|
|
1308
1376
|
takers?: (e: Engine) => string[];
|
|
@@ -1330,7 +1398,7 @@ export interface Container {
|
|
|
1330
1398
|
/** Whether there are at least n (default 1) */
|
|
1331
1399
|
has(x: string, n?: number): boolean;
|
|
1332
1400
|
/** One entry by key, or null */
|
|
1333
|
-
get(key: string): ItemEntry |
|
|
1401
|
+
get(key: string): ItemEntry | undefined;
|
|
1334
1402
|
/** Slots used */
|
|
1335
1403
|
readonly slotsUsed: number;
|
|
1336
1404
|
/** Total weight */
|
|
@@ -1339,8 +1407,8 @@ export interface Container {
|
|
|
1339
1407
|
list(): ItemEntry[];
|
|
1340
1408
|
/** How many more fit (Infinity = no limit), for an item without data, with this data, or like an existing entry key */
|
|
1341
1409
|
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 }):
|
|
1410
|
+
/** Add n (default 1), optionally with data; returns { ok: true, key, added } (added: how many fit), or { ok: false, code: 'full' } when none fit; silent suppresses the toast (only the bag of engine.actor shows one) */
|
|
1411
|
+
add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): ItemAddResult;
|
|
1344
1412
|
/** Remove n (default 1) of an item or entry key, returns false if there are not enough */
|
|
1345
1413
|
remove(x: string, n?: number): boolean;
|
|
1346
1414
|
/**
|
|
@@ -1360,13 +1428,13 @@ export interface Container {
|
|
|
1360
1428
|
export interface Inventory {
|
|
1361
1429
|
/** true: gameplay freezes while the inventory window is open (set from inventory({ pauseGame }) or at runtime) */
|
|
1362
1430
|
pauseGame: boolean;
|
|
1363
|
-
/** Slot limit of the player inventory */
|
|
1431
|
+
/** Slot limit of the player inventory @experimental */
|
|
1364
1432
|
capacity: number;
|
|
1365
|
-
/** Player inventory: the bag of engine.actor (= of()) */
|
|
1433
|
+
/** Player inventory: the bag of engine.actor (= of()) @experimental */
|
|
1366
1434
|
readonly bag: Container;
|
|
1367
1435
|
/** 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
1436
|
of(actor?: string): Container;
|
|
1369
|
-
defaultStack: number;
|
|
1437
|
+
/** @experimental */ defaultStack: number;
|
|
1370
1438
|
action: string;
|
|
1371
1439
|
/** Define an item (chainable) */
|
|
1372
1440
|
define(id: string, def: ItemDef): this;
|
|
@@ -1376,14 +1444,12 @@ export interface Inventory {
|
|
|
1376
1444
|
count(x: string): number;
|
|
1377
1445
|
/** Whether there are at least n (default 1) */
|
|
1378
1446
|
has(x: string, n?: number): boolean;
|
|
1379
|
-
/** Slots used */
|
|
1380
|
-
readonly slotsUsed: number;
|
|
1381
1447
|
/** Player inventory entries (for custom UI) */
|
|
1382
1448
|
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 }):
|
|
1449
|
+
/** One player inventory entry by key, or undefined */
|
|
1450
|
+
get(key: string): ItemEntry | undefined;
|
|
1451
|
+
/** Add n to the player inventory (default 1), opts { data, silent }; returns { ok: true, key, added }, or { ok: false, code: 'full' } when none fit */
|
|
1452
|
+
add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): ItemAddResult;
|
|
1387
1453
|
/** Remove n (default 1) of an item or entry key, returns false if there are not enough */
|
|
1388
1454
|
remove(x: string, n?: number): boolean;
|
|
1389
1455
|
/**
|
|
@@ -1407,9 +1473,9 @@ export interface Inventory {
|
|
|
1407
1473
|
transfer(from: Container | string, to: Container | string, item: string, n?: number): number;
|
|
1408
1474
|
/** Delete a container together with its contents ('player' cannot be deleted), returns whether one was deleted */
|
|
1409
1475
|
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) */
|
|
1476
|
+
/** Every container's items as plain data, the player bag included: { [containerId]: entries } (what setContents takes; net syncs through these two) @experimental */
|
|
1411
1477
|
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 */
|
|
1478
|
+
/** 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
1479
|
setContents(data: Record<string, any[] | null>, opts?: { only?: boolean }): void;
|
|
1414
1480
|
}
|
|
1415
1481
|
export interface InventoryOptions {
|
|
@@ -1421,7 +1487,7 @@ export interface InventoryOptions {
|
|
|
1421
1487
|
capacity?: number;
|
|
1422
1488
|
/** Weight limit of the player inventory, default Infinity */
|
|
1423
1489
|
maxWeight?: number;
|
|
1424
|
-
/** Default stack limit, default 99 */
|
|
1490
|
+
/** Default stack limit, default 99 @experimental */
|
|
1425
1491
|
defaultStack?: number;
|
|
1426
1492
|
}
|
|
1427
1493
|
|
|
@@ -1475,10 +1541,10 @@ export interface Quests {
|
|
|
1475
1541
|
state(id: string): { step: number; steps: number; done: boolean; failed: boolean; active: boolean } | null;
|
|
1476
1542
|
/** 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
1543
|
advance(id: string): boolean;
|
|
1478
|
-
isDone(id: string): boolean;
|
|
1544
|
+
/** @experimental */ isDone(id: string): boolean;
|
|
1479
1545
|
/** Started, not done and not failed */
|
|
1480
1546
|
isActive(id: string): boolean;
|
|
1481
|
-
/** Its fail condition held (start(id) begins it again) */
|
|
1547
|
+
/** Its fail condition held (start(id) begins it again) @experimental */
|
|
1482
1548
|
isFailed(id: string): boolean;
|
|
1483
1549
|
/** Check completion conditions once immediately */
|
|
1484
1550
|
check(): void;
|
|
@@ -1510,7 +1576,7 @@ export interface QuestLogView {
|
|
|
1510
1576
|
export interface QuestsOptions {
|
|
1511
1577
|
/** Action name that opens the quest log, default 'quests' */
|
|
1512
1578
|
action?: string;
|
|
1513
|
-
/** Check interval (
|
|
1579
|
+
/** Check interval (real seconds, checked in the fixed step; not checked while frozen / paused), default 0.5 @experimental */
|
|
1514
1580
|
checkInterval?: number;
|
|
1515
1581
|
/**
|
|
1516
1582
|
* Messages on quest start / step / done: true a toast with kind 'quest' (default) · false none · a function to show them your way.
|
|
@@ -1547,7 +1613,7 @@ export interface PhotoTakeOptions {
|
|
|
1547
1613
|
format?: string;
|
|
1548
1614
|
}
|
|
1549
1615
|
export interface PhotoOptions extends PhotoTakeOptions {
|
|
1550
|
-
/** How many photos the album keeps at most, default 50 */
|
|
1616
|
+
/** How many photos the album keeps at most, default 50 @experimental */
|
|
1551
1617
|
maxAlbum?: number;
|
|
1552
1618
|
}
|
|
1553
1619
|
/** engine.photo */
|
|
@@ -1556,10 +1622,12 @@ export interface Photo {
|
|
|
1556
1622
|
album: PhotoShot[];
|
|
1557
1623
|
/** The op photo.take's can: return true, or false / a reason string to refuse (e.g. () => engine.inventory.has('film') || 'noFilm') */
|
|
1558
1624
|
canTake: () => boolean | string;
|
|
1559
|
-
scale: number; shadowMapSize: number; bloom: boolean; quality: number;
|
|
1625
|
+
scale: number; shadowMapSize: number; bloom: boolean; quality: number;
|
|
1626
|
+
/** @experimental */ format: string;
|
|
1627
|
+
/** @experimental */ maxAlbum: number;
|
|
1560
1628
|
/** Capture a photo now without checks. Gameplay takes photos through the op: engine.ops.run('photo.take') (checks canTake, logged) */
|
|
1561
1629
|
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() */
|
|
1630
|
+
/** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() @experimental */
|
|
1563
1631
|
subject(): { name: string; kind: string; distance: number } | null;
|
|
1564
1632
|
}
|
|
1565
1633
|
|
|
@@ -1672,7 +1740,7 @@ export interface Clock {
|
|
|
1672
1740
|
* Call fn after seconds calendar seconds; if an event name is passed, the event is emitted when due (with data, can be saved).
|
|
1673
1741
|
* { channel } counts that time channel's seconds instead (a poison tick that slows down in bullet time)
|
|
1674
1742
|
*/
|
|
1675
|
-
after(seconds: number, fnOrEvent: (() => void) | string,
|
|
1743
|
+
after(seconds: number, fnOrEvent: (() => void) | string, opts?: { data?: any; channel?: string }): Handle;
|
|
1676
1744
|
/** Call once every seconds calendar seconds ({ channel }: 'real' or a time channel's seconds instead) */
|
|
1677
1745
|
every(seconds: number, fn: () => void, opts?: { channel?: string }): Handle;
|
|
1678
1746
|
}
|
|
@@ -1721,7 +1789,7 @@ export interface Stack {
|
|
|
1721
1789
|
/** End owner's entry; false when it held none */
|
|
1722
1790
|
release(owner: string, opts?: { id?: string }): boolean;
|
|
1723
1791
|
}
|
|
1724
|
-
/** engine.stacks: every shared point by name ('time.<channel>', 'time.local', 'clock.rate', 'freeze', '
|
|
1792
|
+
/** engine.stacks: every shared point by name ('time.<channel>', 'time.local', 'clock.rate', 'freeze', 'halt', 'camera', 'debug.view', slots, your own) */
|
|
1725
1793
|
export interface Stacks {
|
|
1726
1794
|
/**
|
|
1727
1795
|
* Define your own point: kind 'number' (default, base 1), 'value' (any data, set only), 'any' (true while held), 'top' (latest holder wins),
|
|
@@ -1739,19 +1807,19 @@ export interface Stacks {
|
|
|
1739
1807
|
}
|
|
1740
1808
|
/** engine.time: time channels (world, player, your own). Speeds change only through engine.mod('time.<channel>', ...) */
|
|
1741
1809
|
export interface Time {
|
|
1742
|
-
/** Define a channel; parent (default 'world') multiplies its speed */
|
|
1810
|
+
/** Define a channel; parent (default 'world') multiplies its speed @experimental */
|
|
1743
1811
|
channel(name: string, opts?: { parent?: string | null; stack?: string }): Time;
|
|
1744
|
-
channels(): string[];
|
|
1812
|
+
/** @experimental */ channels(): string[];
|
|
1745
1813
|
/** Effective speed: parent x the channel's stack (x the record's 'time.local' stack when id is given) */
|
|
1746
1814
|
scale(name: string, id?: string): number;
|
|
1747
|
-
/** Fixed steps run this playthrough: the one time counter
|
|
1815
|
+
/** Fixed steps run this playthrough: the one time counter; every other time is a read-only view of it */
|
|
1748
1816
|
readonly tick: number;
|
|
1749
1817
|
/**
|
|
1750
1818
|
* Seconds on a view: 'real' (tick / 60, no scale, stops while frozen), 'ambient' (= uniforms.uTime, keeps moving while frozen),
|
|
1751
1819
|
* 'calendar' (= engine.clock.now) or a channel ('world', 'player', your own)
|
|
1752
1820
|
*/
|
|
1753
1821
|
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 }) */
|
|
1822
|
+
/** 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
1823
|
dt(name: string, id?: string): number;
|
|
1756
1824
|
}
|
|
1757
1825
|
/** engine.vars: story flags and counters (autosaved) */
|
|
@@ -1762,7 +1830,7 @@ export interface Vars {
|
|
|
1762
1830
|
counters: Record<string, number>;
|
|
1763
1831
|
/** Read a flag */
|
|
1764
1832
|
flag(key: string): any;
|
|
1765
|
-
/** Set a flag (default true) */
|
|
1833
|
+
/** Set a flag (default true) @experimental */
|
|
1766
1834
|
setFlag(key: string, value?: any): void;
|
|
1767
1835
|
/** Read a counter (0 if none) */
|
|
1768
1836
|
counter(key: string): number;
|
|
@@ -1814,6 +1882,8 @@ export interface PropDef {
|
|
|
1814
1882
|
static?: boolean;
|
|
1815
1883
|
/** false: never drawn through engine.batching (default: repeated props batch automatically) */
|
|
1816
1884
|
batch?: boolean;
|
|
1885
|
+
/** 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 */
|
|
1886
|
+
lod?: boolean | number[];
|
|
1817
1887
|
}
|
|
1818
1888
|
/** engine.content: loads the plain data of the game's content/*.js into the engine */
|
|
1819
1889
|
export interface Content {
|
|
@@ -1843,7 +1913,7 @@ export interface Content {
|
|
|
1843
1913
|
*/
|
|
1844
1914
|
template(name: string): Readonly<ContentTemplate>;
|
|
1845
1915
|
/**
|
|
1846
|
-
* The fields one content entry may have (core/params.js spec format): what an editor panel lists and what content-check validates against.
|
|
1916
|
+
* 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
1917
|
* name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template',
|
|
1848
1918
|
* 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw.
|
|
1849
1919
|
* @example engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }
|
|
@@ -1857,10 +1927,10 @@ export interface Content {
|
|
|
1857
1927
|
*/
|
|
1858
1928
|
spawn(name: string, at: any, fields?: { id?: string; rot?: number; scale?: number; y?: number; items?: Record<string, number>; [stateField: string]: any }): WorldRecord;
|
|
1859
1929
|
}
|
|
1860
|
-
/** One stage of a template with stages: a named step it stays in for duration
|
|
1930
|
+
/** 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
1931
|
export interface ContentTemplateStage {
|
|
1862
1932
|
name: string;
|
|
1863
|
-
/**
|
|
1933
|
+
/** Calendar seconds spent in this stage; only the last stage may leave it out (it stays there) */
|
|
1864
1934
|
duration?: number;
|
|
1865
1935
|
/** Multiplies the instance's scale while in this stage */
|
|
1866
1936
|
scale?: number;
|
|
@@ -1869,7 +1939,7 @@ export interface ContentTemplateStage {
|
|
|
1869
1939
|
}
|
|
1870
1940
|
/** template:stage event: a template instance entered a new stage by growing (several stages crossed at once give one event) */
|
|
1871
1941
|
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 */
|
|
1942
|
+
/** One field of a content entry (engine.content.fields): the core/base/params.js spec as plain data */
|
|
1873
1943
|
export interface ContentField {
|
|
1874
1944
|
type: 'string' | 'number' | 'int' | 'bool' | 'position' | 'id' | 'any' | 'object' | 'array' | 'function';
|
|
1875
1945
|
optional?: boolean;
|
|
@@ -1888,6 +1958,8 @@ export interface ContentTemplate {
|
|
|
1888
1958
|
collide?: 'box' | 'circle' | false | { circle: number; occluder?: boolean };
|
|
1889
1959
|
/** false = not registered for rays */
|
|
1890
1960
|
static?: boolean;
|
|
1961
|
+
/** true: lower-detail levels far away (`threedog assets optimize --lod`), or rising distances in meters; such copies are never batched @experimental */
|
|
1962
|
+
lod?: boolean | number[];
|
|
1891
1963
|
/** Interaction: using an instance runs op with { id } */
|
|
1892
1964
|
interact?: { op: string; label?: string | ((rec: WorldRecord, e: Engine) => string); radius?: number; height?: number; action?: string; enabled?: (rec: WorldRecord, e: Engine) => boolean };
|
|
1893
1965
|
/** Each instance gets a container with its record id; items = starting goods (placed once) */
|
|
@@ -1951,7 +2023,7 @@ export interface FlowTransitionOptions {
|
|
|
1951
2023
|
export interface Flow {
|
|
1952
2024
|
/** Current state name */
|
|
1953
2025
|
state: string;
|
|
1954
|
-
/** A scene transition is in progress */
|
|
2026
|
+
/** A scene transition is in progress @experimental */
|
|
1955
2027
|
readonly transitioning: boolean;
|
|
1956
2028
|
/** Define a state (built-in 'playing', 'paused') */
|
|
1957
2029
|
define(name: string, def: FlowStateDef): this;
|
|
@@ -2018,10 +2090,10 @@ export interface Hud {
|
|
|
2018
2090
|
markers: HudMarker[];
|
|
2019
2091
|
/** Add an objective marker: target is an object, position or place name */
|
|
2020
2092
|
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 */
|
|
2093
|
+
/** 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
2094
|
counter(id: string, opts: { label?: string; icon?: string; value?: number | string; max?: number; anchor?: HudAnchor }): void;
|
|
2023
2095
|
/** 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
|
-
|
|
2096
|
+
bump(id: string, n?: number): number;
|
|
2025
2097
|
/** Current value of a counter or bar (number or text), undefined when there is none; reads what interactions.add({ counter }) has added up */
|
|
2026
2098
|
value(id: string): number | string | undefined;
|
|
2027
2099
|
/** Progress bar (calling again with the same id = update; calling every frame is fine, the DOM is untouched when the value is unchanged),
|