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/core.d.ts
CHANGED
|
@@ -9,29 +9,29 @@ import type { PostEffect } from './generated/render/PostFX';
|
|
|
9
9
|
import type { Grids } from './generated/modules/grid/index';
|
|
10
10
|
import type { Collision, RigidBodies, CameraRig, CameraKind, CameraShotEvent, Animator, AnimatorOptions, Vehicle, Rideable } from './physics';
|
|
11
11
|
import type { Nav } from './nav';
|
|
12
|
-
import type { Stream } from './generated/core/Stream';
|
|
13
|
-
import type { Batching } from './generated/core/Batching';
|
|
14
|
-
import type { Rays } from './generated/core/Rays';
|
|
15
|
-
import type { Control } from './generated/core/control';
|
|
16
|
-
import type { I18n } from './generated/core/I18n';
|
|
17
|
-
import type { Audio } from './generated/core/Audio';
|
|
18
|
-
import type { Input } from './generated/core/Input';
|
|
19
|
-
import type { Saves } from './generated/core/Saves';
|
|
20
|
-
import type { Session } from './generated/core/session';
|
|
21
|
-
import type { Page } from './generated/core/page';
|
|
22
|
-
import type { Events } from './generated/core/Events';
|
|
23
|
-
import type { Commits } from './generated/core/Commits';
|
|
24
|
-
import type { Threads } from './generated/core/Threads';
|
|
25
|
-
import type { Ops } from './generated/core/Ops';
|
|
26
|
-
import type { Views } from './generated/core/Views';
|
|
27
|
-
import type { DebugOverrides } from './generated/core/DebugOverrides';
|
|
28
|
-
import type { Jobs } from './generated/core/Jobs';
|
|
29
|
-
import type { Random } from './generated/core/Random';
|
|
12
|
+
import type { Stream } from './generated/core/stream/Stream';
|
|
13
|
+
import type { Batching } from './generated/core/stream/Batching';
|
|
14
|
+
import type { Rays } from './generated/core/scene/Rays';
|
|
15
|
+
import type { Control } from './generated/core/ops/control';
|
|
16
|
+
import type { I18n } from './generated/core/base/I18n';
|
|
17
|
+
import type { Audio } from './generated/core/audio/Audio';
|
|
18
|
+
import type { Input } from './generated/core/input/Input';
|
|
19
|
+
import type { Saves } from './generated/core/saves/Saves';
|
|
20
|
+
import type { Session } from './generated/core/saves/session';
|
|
21
|
+
import type { Page } from './generated/core/engine/page';
|
|
22
|
+
import type { Events } from './generated/core/base/Events';
|
|
23
|
+
import type { Commits } from './generated/core/threads/Commits';
|
|
24
|
+
import type { Threads } from './generated/core/threads/Threads';
|
|
25
|
+
import type { Ops } from './generated/core/ops/Ops';
|
|
26
|
+
import type { Views } from './generated/core/scene/Views';
|
|
27
|
+
import type { DebugOverrides } from './generated/core/inspect/DebugOverrides';
|
|
28
|
+
import type { Jobs } from './generated/core/threads/Jobs';
|
|
29
|
+
import type { Random } from './generated/core/base/Random';
|
|
30
30
|
import type { PostFX } from './generated/render/PostFX';
|
|
31
31
|
import type { Occlusion } from './generated/render/occlusion';
|
|
32
32
|
import type {
|
|
33
33
|
Timeline, Level, LevelLoadedEvent, Triggers, TriggerEvent, TemplateStageEvent,
|
|
34
|
-
Particles, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
|
|
34
|
+
Particles, SwarmMaker, Settings, Music, MusicChangeEvent, CharactersApi, NPCManager, Character,
|
|
35
35
|
Interactions, Dialogue, Inventory, ItemEvent, ItemUseEvent, PickupEvent, Pickups, PickupsOptions, Quests, Photo, PhotoShot, Ambience, DebugPanel,
|
|
36
36
|
Clock, Vars, Content, Flow, Hud,
|
|
37
37
|
} from './gameplay';
|
|
@@ -96,7 +96,7 @@ export interface EventMap extends GameEvents {
|
|
|
96
96
|
'season:change': [season: string];
|
|
97
97
|
/** A mod with `for` ran out (engine.mod(target, { owner, for })): target is the quantity's name, id the record for per-record ones */
|
|
98
98
|
'mod:end': [{ target: string; owner: string; id: string | null }];
|
|
99
|
-
/** engine.skip jumped game time forward (seconds =
|
|
99
|
+
/** engine.skip jumped game time forward (seconds = calendar seconds skipped); timers and world catch-up already ran */
|
|
100
100
|
'time:skip': [{ seconds: number }];
|
|
101
101
|
/** Lightning strike (weather module) */
|
|
102
102
|
'weather:lightning': [];
|
|
@@ -112,6 +112,8 @@ export interface EventMap extends GameEvents {
|
|
|
112
112
|
'character:fall': [{ character: Character; safe: Vector3 | null; preventDefault(): void }];
|
|
113
113
|
/** A character's model named by asset finished loading and replaced the placeholder body (same root; anim is now set) */
|
|
114
114
|
'character:model': [{ character: Character; model: Object3D }];
|
|
115
|
+
/** A foot of a walking character came down; character.groundType() is what it stepped on */
|
|
116
|
+
'character:step': [{ character: Character }];
|
|
115
117
|
/** A character landed; impact is the landing speed (m/s), the larger the harder the fall */
|
|
116
118
|
'character:land': [{ character: Character; impact: number }];
|
|
117
119
|
/**
|
|
@@ -187,7 +189,7 @@ export interface EventMap extends GameEvents {
|
|
|
187
189
|
/** Background music changed track (null means silence) */
|
|
188
190
|
'music:change': [MusicChangeEvent];
|
|
189
191
|
/** A stinger was played */
|
|
190
|
-
'music:stinger': [{ name: string }];
|
|
192
|
+
'music:stinger': [{ name: string; played: boolean }];
|
|
191
193
|
/** Scenario parameters were applied (URL parameters or engine.applyState) */
|
|
192
194
|
'state:applied': [StateParams];
|
|
193
195
|
/** A scenario (at, pos) moved the player: a camera or view that eases jumps there */
|
|
@@ -267,11 +269,11 @@ export interface EngineUniforms {
|
|
|
267
269
|
uWindFreq: { value: number };
|
|
268
270
|
/** Sway amplitude multiplier: every wind patch's amplitude is scaled by it */
|
|
269
271
|
uWindAmp: { value: number };
|
|
270
|
-
/** Cloud cover 0-1 (weather) */
|
|
271
|
-
|
|
272
|
+
/** Cloud cover 0-1 (weather) @experimental */
|
|
273
|
+
uWeatherCloud: { value: number };
|
|
272
274
|
/** Rain amount 0-1 (weather state, every frame): a signal for the game's own wet surfaces */
|
|
273
275
|
uRain: { value: number };
|
|
274
|
-
/** Snow amount 0-1 (weather state, every frame) */
|
|
276
|
+
/** Snow amount 0-1 (weather state, every frame) @experimental */
|
|
275
277
|
uSnow: { value: number };
|
|
276
278
|
/** Weather's light multiplier (weather state, every frame; 1 = clear): your picture/ code multiplies its own lights by it */
|
|
277
279
|
uWeatherLight: { value: number };
|
|
@@ -281,10 +283,10 @@ export interface EngineUniforms {
|
|
|
281
283
|
uViewDistance: { value: number };
|
|
282
284
|
/** Darkest cloud shadow 0-1 (0 = none) */
|
|
283
285
|
uCloudShadow: { value: number };
|
|
284
|
-
/** Cloud size: smaller = bigger clouds */
|
|
285
|
-
|
|
286
|
-
/** Cloud drift per second */
|
|
287
|
-
|
|
286
|
+
/** Cloud size: smaller = bigger clouds @experimental */
|
|
287
|
+
uCloudShadowScale: { value: number };
|
|
288
|
+
/** Cloud drift per second @experimental */
|
|
289
|
+
uCloudShadowSpeed: { value: Vector2 };
|
|
288
290
|
/** Unit vector toward the sun (sky, every frame); share the object in your own sky: mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir */
|
|
289
291
|
uSunDir: { value: Vector3 };
|
|
290
292
|
/** Sun color now, from the sky's keyframes (white with no sky): what a game's own sun takes. Linear, like every THREE.Color */
|
|
@@ -299,43 +301,43 @@ export interface EngineUniforms {
|
|
|
299
301
|
uSkyTop: { value: Color };
|
|
300
302
|
/** Horizon color the sky draws this frame (or the backdrop color). Read it for a shader that should meet the sky */
|
|
301
303
|
uSkyHorizon: { value: Color };
|
|
302
|
-
/** Sun disk sharpness (larger = smaller), shared with the dome: write .value; sky({ sunSize }) sets the start. The same for every value below */
|
|
304
|
+
/** Sun disk sharpness (larger = smaller), shared with the dome: write .value; sky({ sunSize }) sets the start. The same for every value below @experimental */
|
|
303
305
|
uSunSize: { value: number };
|
|
304
|
-
uSunGlow: { value: number };
|
|
306
|
+
/** @experimental */ uSunGlow: { value: number };
|
|
305
307
|
/** Sun disk brightness (sky({ sunBrightness })) */
|
|
306
|
-
|
|
307
|
-
/** Moon disk sharpness (larger = smaller) */
|
|
308
|
+
uSunBrightness: { value: number };
|
|
309
|
+
/** Moon disk sharpness (larger = smaller) @experimental */
|
|
308
310
|
uMoonSize: { value: number };
|
|
309
|
-
/** Moon disk brightness (sky({ moonBrightness })) */
|
|
310
|
-
|
|
311
|
-
uMoonColor: { value: Color };
|
|
312
|
-
/** Share of sky grid cells holding a star at night, 0-1 (sky({ starDensity })) */
|
|
311
|
+
/** Moon disk brightness (sky({ moonBrightness })) @experimental */
|
|
312
|
+
uMoonBrightness: { value: number };
|
|
313
|
+
/** @experimental */ uMoonColor: { value: Color };
|
|
314
|
+
/** Share of sky grid cells holding a star at night, 0-1 (sky({ starDensity })) @experimental */
|
|
313
315
|
uStars: { value: number };
|
|
314
|
-
/** Star grid resolution: larger = smaller, more numerous stars */
|
|
316
|
+
/** Star grid resolution: larger = smaller, more numerous stars @experimental */
|
|
315
317
|
uStarScale: { value: number };
|
|
316
|
-
/** Horizon-to-zenith gradient exponent (
|
|
317
|
-
|
|
318
|
-
/** Dome cloud amount 0..1+ (sky({ clouds: { coverage } })), multiplied by the weather's
|
|
318
|
+
/** Horizon-to-zenith gradient exponent (engine.uniforms.uSkyCurve) @experimental */
|
|
319
|
+
uSkyCurve: { value: number };
|
|
320
|
+
/** Dome cloud amount 0..1+ (sky({ clouds: { coverage } })), multiplied by the weather's uWeatherCloud */
|
|
319
321
|
uCloudCover: { value: number };
|
|
320
|
-
/** Dome cloud size, smaller = bigger clouds (sky({ clouds: { scale } }));
|
|
322
|
+
/** Dome cloud size, smaller = bigger clouds (sky({ clouds: { scale } })); uCloudShadowScale is the cloud shadows' */
|
|
321
323
|
uSkyCloudScale: { value: number };
|
|
322
|
-
/** Dome cloud drift [x, z] per second;
|
|
324
|
+
/** Dome cloud drift [x, z] per second; uCloudShadowSpeed is the cloud shadows' */
|
|
323
325
|
uSkyCloudSpeed: { value: Vector2 };
|
|
324
|
-
uCloudOpacity: { value: number };
|
|
325
|
-
/** Dome cloud edge softness */
|
|
326
|
+
/** @experimental */ uCloudOpacity: { value: number };
|
|
327
|
+
/** Dome cloud edge softness @experimental */
|
|
326
328
|
uCloudSoft: { value: number };
|
|
327
329
|
/** Lit side of the dome's clouds */
|
|
328
330
|
uCloudColor: { value: Color };
|
|
329
331
|
/** Shaded side of the dome's clouds */
|
|
330
332
|
uCloudShade: { value: Color };
|
|
331
|
-
/** Season tint of foliage (sky, by the calendar's season) */
|
|
333
|
+
/** Season tint of foliage (sky, by the calendar's season) @experimental */
|
|
332
334
|
uFoliageTint: { value: Color };
|
|
333
|
-
/** Season tint of the ground (sky, by the calendar's season) */
|
|
335
|
+
/** Season tint of the ground (sky, by the calendar's season) @experimental */
|
|
334
336
|
uGroundTint: { value: Color };
|
|
335
|
-
uFoliageMix: { value: number };
|
|
336
|
-
uGroundMix: { value: number };
|
|
337
|
-
/** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'ground.cover' point); the tints above already hold it blended in */
|
|
338
|
-
|
|
337
|
+
/** @experimental */ uFoliageMix: { value: number };
|
|
338
|
+
/** @experimental */ uGroundMix: { value: number };
|
|
339
|
+
/** Snow / ash cover amount alone, x foliage, y ground, 0-1 (the 'ground.cover' point); the tints above already hold it blended in @experimental */
|
|
340
|
+
uGroundCover: { value: Vector2 };
|
|
339
341
|
}
|
|
340
342
|
|
|
341
343
|
/** Mouse / touch pointer. ndcX/ndcY are screen coordinates in -1..1 */
|
|
@@ -391,9 +393,6 @@ export interface SaveProvider {
|
|
|
391
393
|
/** Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }.
|
|
392
394
|
* The second argument is the whole save as read ({ parts, versions }, read only), for a step that depends on another part */
|
|
393
395
|
migrate?: Record<number, (data: any, save: { parts: Record<string, any>, versions: Record<string, number> }) => any>;
|
|
394
|
-
/** This part's data used to be saved under another part's name: { oldPart: data => newData } (newData in this version's shape). An old save without
|
|
395
|
-
* this part but with oldPart loads it here; oldPart is then dropped unless a registered part still owns that name */
|
|
396
|
-
movedFrom?: Record<string, (data: any) => any>;
|
|
397
396
|
}
|
|
398
397
|
|
|
399
398
|
|
|
@@ -413,7 +412,7 @@ export type AssetEntry = string | ModelBuilder | {
|
|
|
413
412
|
/** Model: generator function (instead of url) */
|
|
414
413
|
build?: ModelBuilder;
|
|
415
414
|
/**
|
|
416
|
-
* Model: a params schema (core/params.js format plus 'color'), e.g. { height: { type: 'number', min: 1, max: 8, default: 3 } }: build gets one
|
|
415
|
+
* Model: a params schema (core/base/params.js format plus 'color'), e.g. { height: { type: 'number', min: 1, max: 8, default: 3 } }: build gets one
|
|
417
416
|
* object (defaults < dev panel values < a call's own ['name', { ... }]) and the dev panel shows the fields
|
|
418
417
|
*/
|
|
419
418
|
params?: Record<string, string | { type: string; default?: any; min?: number; max?: number; values?: any[]; desc?: string; optional?: boolean }>;
|
|
@@ -495,15 +494,16 @@ export interface Assets {
|
|
|
495
494
|
* it in engine.loading, base resolves its relative paths
|
|
496
495
|
*/
|
|
497
496
|
manifest(m: AssetManifest | AssetManifest[]): this;
|
|
498
|
-
/** The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it) */
|
|
497
|
+
/** The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it) @experimental */
|
|
499
498
|
builder(name: string): ((...args: any[]) => any) | null;
|
|
500
|
-
/** The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null */
|
|
499
|
+
/** The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null @experimental */
|
|
501
500
|
paramsOf(name: string): { schema: Record<string, any>; values: Record<string, any>; tuned: Record<string, any> } | null;
|
|
502
501
|
/** Dev tuning: build a generator with these params (replacing its defaults) and swap every live copy in place; the dev panel's models folder calls it */
|
|
503
502
|
setParams(name: string, values: Record<string, any>): Promise<{ why: string; names: string[]; copies: Record<string, number>; ms: number; partsChanged?: string[] }>;
|
|
504
503
|
/**
|
|
505
504
|
* Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now
|
|
506
505
|
* showing their fallback
|
|
506
|
+
* @experimental
|
|
507
507
|
*/
|
|
508
508
|
preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }): Promise<{ loaded: number; failed: string[]; ok: boolean }>;
|
|
509
509
|
/**
|
|
@@ -516,10 +516,19 @@ export interface Assets {
|
|
|
516
516
|
* acceleration)
|
|
517
517
|
*/
|
|
518
518
|
model(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Promise<Object3D>;
|
|
519
|
+
/**
|
|
520
|
+
* A model copy as a plain THREE.LOD: the full model near, the levels of `threedog assets optimize --lod` far away. Default distances follow the model's size;
|
|
521
|
+
* distances (rising meters) replace them, hysteresis is the share of a distance that stops flicker at the line (default 0.1). Rays, collision and saves keep
|
|
522
|
+
* using the full model. A LOD object is never batched. Without levels it warns in dev and draws in full.
|
|
523
|
+
* @example const tower = await engine.assets.lod('tower', { distances: [40, 120] }); engine.add(tower); tower.levels[1].object;
|
|
524
|
+
* @experimental
|
|
525
|
+
*/
|
|
526
|
+
lod(nameOrUrl: string, opts?: { distances?: number[]; hysteresis?: number; castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Promise<import('three').LOD>;
|
|
519
527
|
/**
|
|
520
528
|
* A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs.
|
|
521
529
|
* Code-built models (a build function in the manifest) count too: they are null until one await model(name) or an entry with preload: true ran (dev warns [asset-not-loaded])
|
|
522
530
|
* @example const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');
|
|
531
|
+
* @experimental
|
|
523
532
|
*/
|
|
524
533
|
modelNow(nameOrUrl: string, opts?: { castShadow?: boolean; receiveShadow?: boolean; static?: boolean }): Object3D | null;
|
|
525
534
|
/** Get the geometry of the first mesh in a model */
|
|
@@ -528,23 +537,24 @@ export interface Assets {
|
|
|
528
537
|
gridFromImage(nameOrUrl: string, opts?: { channel?: 'r' | 'g' | 'b' | 'a' | number; range?: [number, number]; bits?: 8 | 16 }): Promise<{ data: Float32Array; width: number; height: number; bits: number }>;
|
|
529
538
|
/** Get a texture (.ktx2 compressed textures also work) */
|
|
530
539
|
texture(nameOrUrl: string, opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] }): Promise<Texture>;
|
|
531
|
-
/** Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one load
|
|
540
|
+
/** Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one asset-load dev warning naming `where` and what shows `instead`, and resolves false (an error inside use() is not swallowed). opts are texture()'s options */
|
|
532
541
|
useTexture(nameOrUrl: string, use: (texture: Texture) => void, o?: { where?: string; instead?: string; opts?: { color?: boolean; pixelated?: boolean; repeat?: number[] } }): Promise<boolean>;
|
|
533
542
|
/**
|
|
534
|
-
* Release a resource and return
|
|
535
|
-
* removed with engine.remove
|
|
543
|
+
* Release a resource and return its memory. Not released while copies of the model are still in the scene; it is released when the last copy is
|
|
544
|
+
* removed with engine.remove. A sound (name or path) plays on where it is playing and loads again on next use. A load still running ends and its result is thrown away; code awaiting it gets a fresh load, never freed data. A name that
|
|
545
|
+
* fell back holds no data of its own: release the name it fell back to
|
|
536
546
|
*/
|
|
537
547
|
release(name: string): void;
|
|
538
548
|
/**
|
|
539
|
-
* Release every model that has no copy in use (
|
|
540
|
-
* code-generated models are not released
|
|
549
|
+
* Release every model that has no copy in use and every long decoded sound (music, long loops; short effects stay; a sound still playing plays on), unless
|
|
550
|
+
* marked preload (called automatically after level changes). Models whose shared geometry was taken by geometry() and code-generated models are not released
|
|
551
|
+
* automatically. Returns the released names
|
|
541
552
|
*/
|
|
542
553
|
trim(): string[];
|
|
543
|
-
/** How many copies of this model are in use now (taken with model() and not yet removed with engine.remove) */
|
|
544
|
-
users(name: string): number;
|
|
545
554
|
/**
|
|
546
555
|
* Called when an object is fully removed (engine.remove already calls it, normally you don't need to): decrements the use count of the model copies
|
|
547
556
|
* under it
|
|
557
|
+
* @experimental
|
|
548
558
|
*/
|
|
549
559
|
forget(obj: Object3D): void;
|
|
550
560
|
/** Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20 */
|
|
@@ -566,19 +576,18 @@ export interface Assets {
|
|
|
566
576
|
animate(root: Object3D, config?: AnimatorOptions): Animator;
|
|
567
577
|
/** The manifest entry's animation mapping for a model copy, or null (not a manifest copy, or no mapping) */
|
|
568
578
|
mapping(root: Object3D): AnimatorOptions | null;
|
|
569
|
-
/** three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed) */
|
|
579
|
+
/** three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed) @experimental */
|
|
570
580
|
gltf: any;
|
|
571
581
|
/**
|
|
572
582
|
* three.js DRACOLoader (created only the first time Draco compression is met, null before; the decoder defaults to the one bundled with three, vite
|
|
573
583
|
* packs it automatically)
|
|
584
|
+
* @experimental
|
|
574
585
|
*/
|
|
575
586
|
draco: any;
|
|
576
|
-
/** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) */
|
|
587
|
+
/** three.js KTX2Loader (created only the first time a KTX2 texture is met, null before) @experimental */
|
|
577
588
|
ktx2: any;
|
|
578
589
|
/** Import report of a loaded model (by name, or a copy from model()): materials, textures with colorSpace, clips, colliders, templates, and issues for what the file has but the scene lost */
|
|
579
590
|
report(nameOrRoot: string | Object3D): AssetReport;
|
|
580
|
-
/** assets.report as text for the console / describe */
|
|
581
|
-
reportText(nameOrRoot: string | Object3D): string;
|
|
582
591
|
}
|
|
583
592
|
/** engine.assets.report(): see recipes/46-blender-art-route.md */
|
|
584
593
|
export interface AssetReport {
|
|
@@ -649,7 +658,7 @@ export interface Loading {
|
|
|
649
658
|
/** Built-in bus names; a game adds its own with createEngine({ audio: { levels: { voice: 1 } } }) or audio.addBus */
|
|
650
659
|
export type AudioBus = 'master' | 'music' | 'sfx' | 'ambience' | 'ui' | (string & {});
|
|
651
660
|
/** A playing sound (returned by audio.sfx / audio.play): stop(fade), fade(to, seconds), setPosition(at) */
|
|
652
|
-
import type { SoundHandle } from './generated/core/audioVoice';
|
|
661
|
+
import type { SoundHandle } from './generated/core/audio/audioVoice';
|
|
653
662
|
export type { SoundHandle };
|
|
654
663
|
/**
|
|
655
664
|
* One sounds rule in full form: how a sound plays, never what it is made of (that is the asset manifest's: a file or a synth function).
|
|
@@ -861,14 +870,14 @@ export interface UIParts {
|
|
|
861
870
|
set(name: string, value: UIPartValue): void;
|
|
862
871
|
/** The live single part (null when off) */
|
|
863
872
|
get(name: string): UIPart | null;
|
|
864
|
-
/** A new part for one item of a multi part (null when off) */
|
|
873
|
+
/** A new part for one item of a multi part (null when off) @experimental */
|
|
865
874
|
create(name: string): UIPart | null;
|
|
866
875
|
/** Open a full-screen part (title): shows it, takes Esc, locks input, freezes gameplay, emits ui:open; false when off */
|
|
867
876
|
open(name: string, data?: object): boolean;
|
|
868
877
|
/** Close a full-screen part, emits ui:close */
|
|
869
878
|
close(name: string): void;
|
|
870
|
-
isOpen(name: string): boolean;
|
|
871
|
-
/** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle */
|
|
879
|
+
/** @experimental */ isOpen(name: string): boolean;
|
|
880
|
+
/** Add a title screen button from a module (settings adds 'settings'): shown after continue / start, and nameable by id in the title's items. ctx.track the handle @experimental */
|
|
872
881
|
titleItem(id: string, item: { label: string | ((engine: Engine) => string); run(engine: Engine): any }): { remove(): void };
|
|
873
882
|
/** name -> 'default' | 'custom' | 'off' */
|
|
874
883
|
describe(): Record<string, string>;
|
|
@@ -883,7 +892,7 @@ export interface UIParts {
|
|
|
883
892
|
// Ground interface
|
|
884
893
|
// ======================================================================
|
|
885
894
|
|
|
886
|
-
/** Conventional names for the picture values only one writer may hold (core/pictureSlots.js), taken with provides like any other slot */
|
|
895
|
+
/** Conventional names for the picture values only one writer may hold (core/scene/pictureSlots.js), taken with provides like any other slot */
|
|
887
896
|
export type PictureSlot = 'sky' | 'fog' | 'tone' | 'environment' | 'background' | 'sun';
|
|
888
897
|
|
|
889
898
|
/** Ground: whoever provides the ground height is the "terrain" (terrain module, level module, or the default flat y=0) */
|
|
@@ -910,16 +919,14 @@ export interface Ground {
|
|
|
910
919
|
forEachCollider?(x: number, z: number, range: number, fn: (cx: number, cz: number, r: number) => void): void;
|
|
911
920
|
/** Optional: chunk edge length (meters) */
|
|
912
921
|
chunkSize?: number;
|
|
913
|
-
/** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance) */
|
|
922
|
+
/** Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance) @experimental */
|
|
914
923
|
viewRange?(): number;
|
|
915
|
-
/** Optional: collision data of a chunk (used by the physics module) */
|
|
924
|
+
/** Optional: collision data of a chunk (used by the physics module) @experimental */
|
|
916
925
|
chunkCollision?(cx: number, cz: number): any;
|
|
917
|
-
/** Optional: static triangle mesh (the level module provides it for physics) */
|
|
926
|
+
/** Optional: static triangle mesh (the level module provides it for physics) @experimental */
|
|
918
927
|
staticTrimeshes?(): { positions: Float32Array; indices: Uint32Array }[];
|
|
919
|
-
/** Optional: version number of the static mesh; rebuild when it changes */
|
|
928
|
+
/** Optional: version number of the static mesh; rebuild when it changes @experimental */
|
|
920
929
|
staticVersion?(): number;
|
|
921
|
-
/** Optional: triangle mesh for building the navmesh (walkable surfaces + obstacle volumes), used by the nav module */
|
|
922
|
-
navGeometry?(): { positions: Float32Array; indices: Uint32Array };
|
|
923
930
|
}
|
|
924
931
|
|
|
925
932
|
// ======================================================================
|
|
@@ -954,7 +961,7 @@ export interface ModuleCtx {
|
|
|
954
961
|
whileCompiling(fn: () => void): void;
|
|
955
962
|
}
|
|
956
963
|
|
|
957
|
-
/** What a module may own (ModuleDef.type; core/moduleTypes.js) */
|
|
964
|
+
/** What a module may own (ModuleDef.type; core/engine/moduleTypes.js) */
|
|
958
965
|
export type ModuleType = 'world' | 'picture' | 'actor' | 'rules' | 'ui' | 'net' | 'tool';
|
|
959
966
|
|
|
960
967
|
/**
|
|
@@ -965,11 +972,11 @@ export interface ModuleDef<Api = any> {
|
|
|
965
972
|
/** Module name; after install, access the object returned by install through engine[name] */
|
|
966
973
|
name: string;
|
|
967
974
|
/**
|
|
968
|
-
* What the module
|
|
975
|
+
* What the module owns (default 'rules'; core/engine/moduleTypes.js): 'world' state, records, ops (draws nothing) | 'picture' what is seen and heard (changes no
|
|
969
976
|
* game state: no ops, no world record writes) | 'actor' characters | 'rules' game logic | 'ui' panels and menus (binds no keys, no game save part)
|
|
970
|
-
* | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'.
|
|
977
|
+
* | 'net' multiplayer | 'tool' a one-shot job. A game module is usually 'rules'. Going against one warns once in dev with the fix; the call still goes through.
|
|
971
978
|
*/
|
|
972
|
-
type
|
|
979
|
+
type?: ModuleType;
|
|
973
980
|
/** Display name (used by the loading screen) */
|
|
974
981
|
label?: string;
|
|
975
982
|
/**
|
|
@@ -1032,6 +1039,12 @@ export interface ModuleDef<Api = any> {
|
|
|
1032
1039
|
* Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
|
|
1033
1040
|
*/
|
|
1034
1041
|
skip?(dt: number, e: Engine, done: boolean): void;
|
|
1042
|
+
/** Why a module with a fixed hook has no skip hook: engine.catalog shows it instead of a warning */
|
|
1043
|
+
noSkip?: string;
|
|
1044
|
+
/** The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it */
|
|
1045
|
+
params?: any;
|
|
1046
|
+
/** Where its docs live, shown by engine.catalog */
|
|
1047
|
+
docs?: string;
|
|
1035
1048
|
/**
|
|
1036
1049
|
* Optional: add state to engine.describe(). The (JSON-able) return value goes into the result keyed by the module name; nothing is added if it
|
|
1037
1050
|
* returns nothing.
|
|
@@ -1042,8 +1055,10 @@ export interface ModuleDef<Api = any> {
|
|
|
1042
1055
|
counts?(e: Engine): number | Record<string, number>;
|
|
1043
1056
|
/** Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) } */
|
|
1044
1057
|
explain?: Record<string, (e: Engine, value: any, query: Record<string, any>) => { ok: boolean; text: string; [k: string]: any }>;
|
|
1045
|
-
/** Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position */
|
|
1046
|
-
applyState?(e: Engine, params: StateParams): void | PositionLike | Promise<void>;
|
|
1058
|
+
/** Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position; return { refused: { key: reason } } for a value it cannot apply */
|
|
1059
|
+
applyState?(e: Engine, params: StateParams): void | PositionLike | { refused: Record<string, string> } | Promise<void>;
|
|
1060
|
+
/** Optional: the applyState keys this module handles; a key no module handles is reported in applyState's refused list. Leave out to count for every key */
|
|
1061
|
+
stateKeys?: string[];
|
|
1047
1062
|
/**
|
|
1048
1063
|
* Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers,
|
|
1049
1064
|
* Audio nodes you connected yourself.
|
|
@@ -1112,16 +1127,18 @@ export interface EngineOptions {
|
|
|
1112
1127
|
/**
|
|
1113
1128
|
* Check parameter names at runtime and warn on misspelled names (the console prints "did you mean xxx"), default true; a release build can write false
|
|
1114
1129
|
* to turn it off
|
|
1130
|
+
* @experimental
|
|
1115
1131
|
*/
|
|
1116
1132
|
validate?: boolean;
|
|
1117
1133
|
/**
|
|
1118
1134
|
* Directory of Draco/KTX2 decoders (a URL containing draco/ and basis/), for when they live on a CDN. Normally not needed: the decoders bundled with
|
|
1119
1135
|
* three are packed by vite automatically
|
|
1136
|
+
* @experimental
|
|
1120
1137
|
*/
|
|
1121
1138
|
decoders?: string;
|
|
1122
1139
|
/** Performance budget limits, e.g. { drawCalls: 250, fps: 55 }; only the given categories are checked; off by default */
|
|
1123
1140
|
budget?: BudgetLimits;
|
|
1124
|
-
/** Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development */
|
|
1141
|
+
/** Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development @experimental */
|
|
1125
1142
|
urlState?: boolean;
|
|
1126
1143
|
/** Seed for engine.random; default 1 in headless mode (reproducible), the current time for live runs (different every game) */
|
|
1127
1144
|
seed?: number;
|
|
@@ -1139,7 +1156,7 @@ export interface EngineOptions {
|
|
|
1139
1156
|
pauseOnBlur?: boolean;
|
|
1140
1157
|
/** false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. No light of the engine's reaches the picture. Default true */
|
|
1141
1158
|
lights?: boolean;
|
|
1142
|
-
/** Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: engine.stream.cellSize } */
|
|
1159
|
+
/** Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: 4 * engine.stream.cellSize } */
|
|
1143
1160
|
batching?: false | BatchingOptions;
|
|
1144
1161
|
}
|
|
1145
1162
|
|
|
@@ -1309,7 +1326,7 @@ export interface StreamEntryOptions {
|
|
|
1309
1326
|
radius?: number;
|
|
1310
1327
|
/** Generate the object (called when entering range, run spread over frames through engine.jobs) */
|
|
1311
1328
|
build: () => Object3D | Promise<Object3D>;
|
|
1312
|
-
/** Unload (called when leaving range), default engine.remove (
|
|
1329
|
+
/** Unload (called when leaving range), default engine.remove (frees what nothing else in the scene uses); write your own when the object is reused (e.g. engine.detach) */
|
|
1313
1330
|
dispose?: (obj: Object3D) => void;
|
|
1314
1331
|
/** Do not unload even when out of range */
|
|
1315
1332
|
keep?: boolean;
|
|
@@ -1361,9 +1378,12 @@ export interface StreamHandle { def: StreamEntryOptions; object: Object3D | null
|
|
|
1361
1378
|
* world (scenario parameters, nearby builds), compile (shaders + hidden warm-up frame), draw (ready until the first frame's draw calls were submitted)
|
|
1362
1379
|
*/
|
|
1363
1380
|
export interface StartupReport {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1381
|
+
/** @experimental */ totalMs: number;
|
|
1382
|
+
/** @experimental */ startMs: number;
|
|
1383
|
+
/** @experimental */ preloadMs: number;
|
|
1384
|
+
/** @experimental */ streamMs: number | null; compileMs: number; modules: Record<string, { init?: number; ready?: number }>;
|
|
1385
|
+
/** @experimental */ firstFrameMs: number | null;
|
|
1386
|
+
/** @experimental */ phases: { script: number; construct: number; setup: number; init: number; preload: number; world: number; compile: number; draw: number | null };
|
|
1367
1387
|
}
|
|
1368
1388
|
|
|
1369
1389
|
// ======================================================================
|
|
@@ -1400,8 +1420,9 @@ export interface StateParams {
|
|
|
1400
1420
|
|
|
1401
1421
|
/** A claim on something only its owner releases (pause, freeze, takeCamera, views) */
|
|
1402
1422
|
export interface OwnerHandle { owner: string; remove(): void }
|
|
1403
|
-
/** engine.runState: state in one word, owners = every
|
|
1404
|
-
export interface RunState { state: 'loading' | 'title-frozen' | '
|
|
1423
|
+
/** engine.runState: state in one word, owners = every halt / freeze owner, blockedBy = opaque input contexts plus 'error' / 'loading' */
|
|
1424
|
+
export interface RunState { state: 'loading' | 'title-frozen' | 'halted' | 'frozen' | 'running'; owners: string[];
|
|
1425
|
+
/** @experimental */ blockedBy: string[] }
|
|
1405
1426
|
/** Camera takeover: when non-null no camera module moves the camera (for cutscenes); see engine.takeCamera */
|
|
1406
1427
|
export interface CameraOverride {
|
|
1407
1428
|
/** Who took over (any name) */
|
|
@@ -1411,7 +1432,8 @@ export interface CameraOverride {
|
|
|
1411
1432
|
[key: string]: any;
|
|
1412
1433
|
}
|
|
1413
1434
|
/** State of automatic resolution */
|
|
1414
|
-
export interface AdaptiveState {
|
|
1435
|
+
export interface AdaptiveState { on: boolean; target: number; min: number; max: number; /** The ratio this device or game starts at: the base of the settings presets */ base: number;
|
|
1436
|
+
/** true once the render scale was lowered below max (a dev warning was logged) @experimental */ lowered?: boolean; [key: string]: any }
|
|
1415
1437
|
|
|
1416
1438
|
// ======================================================================
|
|
1417
1439
|
// Shadows: engine.shadows (recipes/45-cascaded-shadows.md)
|
|
@@ -1436,7 +1458,7 @@ export interface ShadowCascadeOptions {
|
|
|
1436
1458
|
export interface ShadowCascades {
|
|
1437
1459
|
/** The game's light it was given */
|
|
1438
1460
|
readonly light: import('three').DirectionalLight;
|
|
1439
|
-
/** three's CSM object (the shadow node on WebGPURenderer); null while there is one map */
|
|
1461
|
+
/** three's CSM object (the shadow node on WebGPURenderer); null while there is one map @experimental */
|
|
1440
1462
|
readonly csm: any;
|
|
1441
1463
|
/** Change options (a rebuild recompiles lit materials: a settings screen, not per frame) */
|
|
1442
1464
|
set(options: ShadowCascadeOptions): void;
|
|
@@ -1480,30 +1502,41 @@ export interface TermSpec {
|
|
|
1480
1502
|
/** Default 'lighting' for the cloud shadow, 'color' for the season tint */
|
|
1481
1503
|
slot?: string;
|
|
1482
1504
|
}
|
|
1483
|
-
/** engine.
|
|
1505
|
+
/** engine.shaderTerms */
|
|
1484
1506
|
export interface Terms {
|
|
1485
1507
|
/**
|
|
1486
1508
|
* Your own cloud shadow in place of the engine's on engine materials and on what you passed to applyEffects, built before the call too; false takes it off them
|
|
1487
|
-
* all.
|
|
1488
|
-
* @example const mine = engine.
|
|
1509
|
+
* all. uWeatherCloud, uCloudShadow*, uTime and threedogCloudShadow(worldPos) stay in scope. remove() gives the engine's back.
|
|
1510
|
+
* @example const mine = engine.shaderTerms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= 0.5;', tsl: c => ({ directDiffuse: c.directDiffuse.mul(0.5) }) }); mine.remove();
|
|
1489
1511
|
*/
|
|
1490
1512
|
cloudShadow(spec: TermSpec | false): { remove(): void };
|
|
1491
1513
|
/**
|
|
1492
1514
|
* Your own season and snow tint in place of the engine's on engine materials and on what you passed to applyEffects with a season, built before the call too; false
|
|
1493
|
-
* takes it off them all. uFoliageTint, uGroundTint, uFoliageMix, uGroundMix,
|
|
1494
|
-
* @example const mine = engine.
|
|
1515
|
+
* takes it off them all. uFoliageTint, uGroundTint, uFoliageMix, uGroundMix, uGroundCover and threedogSeason(color, kind) stay in scope. remove() gives the engine's back.
|
|
1516
|
+
* @example const mine = engine.shaderTerms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uGroundCover.y);', tsl: c => c.color })); mine.remove();
|
|
1495
1517
|
*/
|
|
1496
1518
|
season(spec: TermSpec | ((kind: 'foliage' | 'ground') => TermSpec) | false): { remove(): void };
|
|
1497
1519
|
}
|
|
1498
|
-
/** engine.
|
|
1520
|
+
/** engine.autoView */
|
|
1499
1521
|
export interface View {
|
|
1500
1522
|
/**
|
|
1501
1523
|
* Stop the engine changing a camera or drawing-buffer value: it is yours until you hand it back (a direct write takes it too; this says so on purpose, with no
|
|
1502
1524
|
* warning). 'camera' hands the pose back after a direct write (take it with engine.takeCamera(owner)). Pass false to hand back; remove() does the same.
|
|
1503
|
-
* @example const mine = engine.
|
|
1525
|
+
* @example const mine = engine.autoView.manual('far'); engine.camera.far = 5000; mine.remove();
|
|
1504
1526
|
*/
|
|
1505
1527
|
manual(key: 'far' | 'fov' | 'pixelRatio' | 'camera', on?: boolean): { remove(): void };
|
|
1506
1528
|
}
|
|
1529
|
+
/** engine.shadows.cache options: an Object3D (its whole subtree), a list of them, or a test on each mesh (recipes/45) */
|
|
1530
|
+
export interface ShadowCacheOptions { static: import('three').Object3D | import('three').Object3D[] | ((mesh: import('three').Object3D) => boolean); }
|
|
1531
|
+
/** What engine.shadows.cache returns */
|
|
1532
|
+
export interface ShadowCache {
|
|
1533
|
+
/** Say again what is static; the kept map redraws */
|
|
1534
|
+
set(options: ShadowCacheOptions): void;
|
|
1535
|
+
/** Draw the static casters again on the next shadow frame: after one moved, hid or left */
|
|
1536
|
+
redraw(): void;
|
|
1537
|
+
/** The light's plain shadow again */
|
|
1538
|
+
remove(): void;
|
|
1539
|
+
}
|
|
1507
1540
|
/** engine.shadows */
|
|
1508
1541
|
export interface Shadows {
|
|
1509
1542
|
/**
|
|
@@ -1517,6 +1550,13 @@ export interface Shadows {
|
|
|
1517
1550
|
box(light: import('three').DirectionalLight, options?: ShadowBoxOptions): ShadowBox;
|
|
1518
1551
|
/** Redraw one light's shadow map every N frames; other lights are not touched */
|
|
1519
1552
|
budget(light: import('three').Light, options?: { every?: number }): ShadowBudget;
|
|
1553
|
+
/**
|
|
1554
|
+
* Keep the shadows of what does not move: static casters are drawn once, each shadow frame copies them and draws only the rest. One plain map on WebGPURenderer;
|
|
1555
|
+
* elsewhere the light draws everything, with a warning. A static object that moves, hides or leaves needs redraw(); a moving light redraws everything. recipes/45
|
|
1556
|
+
* @example const kept = engine.shadows.cache(sun, { static: mesh => mesh !== cars.mesh }); kept.redraw(); kept.remove();
|
|
1557
|
+
* @experimental
|
|
1558
|
+
*/
|
|
1559
|
+
cache(light: import('three').DirectionalLight, options: ShadowCacheOptions): ShadowCache;
|
|
1520
1560
|
/** Change a light's shadow resolution at any time, with cascades every cascade's map (light.shadow.mapSize alone does nothing once a map exists) */
|
|
1521
1561
|
mapSize(light: import('three').Light, width: number, height?: number): void;
|
|
1522
1562
|
/**
|
|
@@ -1524,7 +1564,7 @@ export interface Shadows {
|
|
|
1524
1564
|
* @example engine.shadows.include(myShaderMaterial);
|
|
1525
1565
|
*/
|
|
1526
1566
|
include<M extends import('three').Material>(material: M): M;
|
|
1527
|
-
/** The cascades on now (three's CSM, or the shadow node on WebGPURenderer); null when off */
|
|
1567
|
+
/** The cascades on now (three's CSM, or the shadow node on WebGPURenderer); null when off @experimental */
|
|
1528
1568
|
readonly csm: any;
|
|
1529
1569
|
}
|
|
1530
1570
|
/**
|
|
@@ -1535,8 +1575,8 @@ export declare class Engine {
|
|
|
1535
1575
|
constructor(opts: EngineOptions);
|
|
1536
1576
|
|
|
1537
1577
|
// ---------- Core objects ----------
|
|
1538
|
-
/**
|
|
1539
|
-
|
|
1578
|
+
/** False when createEngine({ validate: false }) turned the development checks off for this engine */
|
|
1579
|
+
validate: boolean;
|
|
1540
1580
|
/** three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer) */
|
|
1541
1581
|
renderer: EngineRenderer;
|
|
1542
1582
|
/** Device tier: 'low' (phones, integrated graphics) | 'high'. A headless page takes it from ?threedog-tier=low|high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier) */
|
|
@@ -1547,7 +1587,7 @@ export declare class Engine {
|
|
|
1547
1587
|
* Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
|
|
1548
1588
|
*/
|
|
1549
1589
|
lights: { sun: import('three').DirectionalLight; hemi: import('three').HemisphereLight };
|
|
1550
|
-
/** three.js PerspectiveCamera (class EngineCamera, core/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which) */
|
|
1590
|
+
/** three.js PerspectiveCamera (class EngineCamera, core/scene/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which) */
|
|
1551
1591
|
camera: import('three').PerspectiveCamera;
|
|
1552
1592
|
/**
|
|
1553
1593
|
* Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the
|
|
@@ -1577,20 +1617,21 @@ export declare class Engine {
|
|
|
1577
1617
|
*/
|
|
1578
1618
|
actorPosition(id?: string): { x: number; y: number; z: number } | null;
|
|
1579
1619
|
/**
|
|
1580
|
-
* Where the engine is in its life: 'constructed' (start() not called) -> '
|
|
1620
|
+
* Where the engine is in its life: 'constructed' (start() not called) -> 'starting' (modules init) -> 'loading' (assets and the world; in both frame hooks only, no fixed step, so no game
|
|
1581
1621
|
* time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved)
|
|
1582
1622
|
* -> 'disposed'. engine.step() during loading runs frame hooks only
|
|
1583
1623
|
*/
|
|
1584
|
-
readonly phase: 'constructed' | 'loading' | 'ready' | 'running' | 'disposed';
|
|
1624
|
+
readonly phase: 'constructed' | 'starting' | 'loading' | 'ready' | 'running' | 'disposed';
|
|
1585
1625
|
/** phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property) */
|
|
1586
1626
|
readonly ready: boolean;
|
|
1587
1627
|
/** phase is 'disposed' */
|
|
1588
1628
|
readonly disposed: boolean;
|
|
1589
|
-
/** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" */
|
|
1629
|
+
/** Execution order of module hooks (module names, first -> last), for debugging "who runs before whom" @experimental */
|
|
1590
1630
|
readonly moduleOrder: string[];
|
|
1591
1631
|
/**
|
|
1592
1632
|
* Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'.
|
|
1593
1633
|
* A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
|
|
1634
|
+
* @experimental
|
|
1594
1635
|
*/
|
|
1595
1636
|
readonly moduleStates: Record<string, 'registered' | 'initializing' | 'running' | 'failed' | 'disposed'>;
|
|
1596
1637
|
/**
|
|
@@ -1605,7 +1646,7 @@ export declare class Engine {
|
|
|
1605
1646
|
* message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
|
|
1606
1647
|
*/
|
|
1607
1648
|
readonly error: EngineError | null;
|
|
1608
|
-
/** Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft) */
|
|
1649
|
+
/** Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft) @experimental */
|
|
1609
1650
|
readonly disabledModules: Set<string>;
|
|
1610
1651
|
/**
|
|
1611
1652
|
* The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on
|
|
@@ -1644,21 +1685,14 @@ export declare class Engine {
|
|
|
1644
1685
|
ui: UIParts;
|
|
1645
1686
|
/** Automatic resolution state */
|
|
1646
1687
|
adaptive: AdaptiveState;
|
|
1647
|
-
/**
|
|
1648
|
-
|
|
1649
|
-
* (not GPU time, not the wait for the next frame). Only the real-time loop updates it; step() does not.
|
|
1650
|
-
*/
|
|
1651
|
-
cpuMs: number;
|
|
1652
|
-
/** cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks */
|
|
1653
|
-
cpuPhases: { fixed: number; frame: number; render: number; afterRender: number };
|
|
1688
|
+
/** How far the drawn frame is from the last fixed step to the next, 0-1 (real loop); 1 after step(). Holds still while frozen. For drawing fixed-step state smoothly */
|
|
1689
|
+
stepBlend: number;
|
|
1654
1690
|
/** The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Read-only */
|
|
1655
|
-
cameraOverride: CameraOverride | null;
|
|
1691
|
+
readonly cameraOverride: CameraOverride | null;
|
|
1656
1692
|
/** Take the camera over (camera modules leave it alone) until remove(); the latest holder is in charge, releasing hands it back to the previous one */
|
|
1657
1693
|
takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>): OwnerHandle;
|
|
1658
1694
|
/** Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is */
|
|
1659
1695
|
readonly runState: RunState;
|
|
1660
|
-
/** Draco/KTX2 decoder directory */
|
|
1661
|
-
decoders: string;
|
|
1662
1696
|
/** Calendar clock: calendar seconds now, after / every, the rate (clock-time / season timers are on engine.calendar) */
|
|
1663
1697
|
clock: Clock;
|
|
1664
1698
|
/**
|
|
@@ -1666,12 +1700,13 @@ export declare class Engine {
|
|
|
1666
1700
|
* @example engine.time.channel('enemies'); engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on a channel the game made
|
|
1667
1701
|
* @example engine.mod('time.player', { owner: 'haste', mul: 1.2, for: 5 }) // haste on the player
|
|
1668
1702
|
* @example engine.mod('freeze', { owner: 'pause-menu' }) // pause menu (same as engine.freeze('pause-menu'))
|
|
1703
|
+
* @experimental
|
|
1669
1704
|
*/
|
|
1670
1705
|
mod(name: string, opts: import('./gameplay').ModOptions): import('./gameplay').ModHandle;
|
|
1671
|
-
/** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) */
|
|
1706
|
+
/** Every shared quantity by name; define your own with engine.stacks.define(name, { base }) @experimental */
|
|
1672
1707
|
stacks: import('./gameplay').Stacks;
|
|
1673
1708
|
/**
|
|
1674
|
-
* Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < net; a higher one pauses the
|
|
1709
|
+
* Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < physics < net; a higher one pauses the
|
|
1675
1710
|
* lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57
|
|
1676
1711
|
* @example const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();
|
|
1677
1712
|
*/
|
|
@@ -1681,6 +1716,7 @@ export declare class Engine {
|
|
|
1681
1716
|
* for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in
|
|
1682
1717
|
* describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api.
|
|
1683
1718
|
* @example engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })
|
|
1719
|
+
* @experimental
|
|
1684
1720
|
*/
|
|
1685
1721
|
wrap<T extends object>(target: T, method: string, fn: (next: (...args: any[]) => any, ...args: any[]) => any, opts?: { owner?: string }): Handle;
|
|
1686
1722
|
/** Time channels: read seconds with time.now('real' | 'ambient' | 'calendar' | a channel such as 'world'), speeds with scale(ch, id?) */
|
|
@@ -1689,7 +1725,7 @@ export declare class Engine {
|
|
|
1689
1725
|
vars: Vars;
|
|
1690
1726
|
/** Performance budget (off by default) */
|
|
1691
1727
|
budget: Budget;
|
|
1692
|
-
/** The plugins folder: files in the game's plugins/ plugged at start by what they export (core/plugins.js); describe().slots lists them */
|
|
1728
|
+
/** The plugins folder: files in the game's plugins/ plugged at start by what they export (core/engine/plugins.js); describe().slots lists them */
|
|
1693
1729
|
plugins: {
|
|
1694
1730
|
/** Plug a folder's modules yourself (the vite preset does it): import.meta.glob('./plugins/*.js', { eager: true }) */
|
|
1695
1731
|
add(files: Record<string, any>, o?: { order?: string[]; off?: string[] }): any;
|
|
@@ -1707,7 +1743,7 @@ export declare class Engine {
|
|
|
1707
1743
|
rays: Rays;
|
|
1708
1744
|
/** Frame-spread job scheduler */
|
|
1709
1745
|
jobs: Jobs;
|
|
1710
|
-
/** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits */
|
|
1746
|
+
/** Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits @experimental */
|
|
1711
1747
|
commits: Commits;
|
|
1712
1748
|
/**
|
|
1713
1749
|
* Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays.
|
|
@@ -1718,11 +1754,6 @@ export declare class Engine {
|
|
|
1718
1754
|
ops: Ops;
|
|
1719
1755
|
/** Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md) */
|
|
1720
1756
|
views: Views;
|
|
1721
|
-
/**
|
|
1722
|
-
* Fixed-step count (= engine.time.tick, the one time counter: does not advance while frozen; commits due times, event history and the operation
|
|
1723
|
-
* log use it). Seconds are views of it: engine.time.now('real' | 'ambient' | 'calendar' | channel)
|
|
1724
|
-
*/
|
|
1725
|
-
readonly tick: number;
|
|
1726
1757
|
/** Seeded random numbers, an object (not a function): engine.random.next() in [0, 1), .range(a, b), .int(a, b), .pick(list), .chance(p). Use it for gameplay randomness: reproducible and saved with the game */
|
|
1727
1758
|
random: Random;
|
|
1728
1759
|
/**
|
|
@@ -1747,19 +1778,19 @@ export declare class Engine {
|
|
|
1747
1778
|
// ---------- Modules (undefined when not installed) ----------
|
|
1748
1779
|
/** Procedural terrain, data part (terrain() module: chunks, heights, edits, collision) */
|
|
1749
1780
|
terrain?: Terrain;
|
|
1750
|
-
/** Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it) */
|
|
1781
|
+
/** Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it) @experimental */
|
|
1751
1782
|
terrainDraw?: TerrainDraw;
|
|
1752
1783
|
/** Vegetation (vegetation() module; grows on terrain or on any ground provider) */
|
|
1753
1784
|
vegetation?: Vegetation;
|
|
1754
|
-
/** Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it) */
|
|
1785
|
+
/** Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it) @experimental */
|
|
1755
1786
|
vegetationDraw?: VegetationDraw;
|
|
1756
|
-
/** Sky dome
|
|
1787
|
+
/** Sky dome and the sun / daylight / sky-color signals, from the calendar's time; it writes no light or fog (sky() module) */
|
|
1757
1788
|
sky?: Sky;
|
|
1758
1789
|
/** Time of day, day, seasons and clock-time timers (calendar() module); NPC schedules, content clock conditions and audio time rules read it */
|
|
1759
1790
|
calendar?: Calendar;
|
|
1760
1791
|
/** Weather state (weather() module): the table, current values, set / setAuto, save, events */
|
|
1761
1792
|
weather?: Weather;
|
|
1762
|
-
/** Weather drawing (installed by weather()
|
|
1793
|
+
/** Weather drawing (installed by weather(); sky is optional): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky @experimental */
|
|
1763
1794
|
weatherDraw?: WeatherDraw;
|
|
1764
1795
|
/** Water surface (water() module) */
|
|
1765
1796
|
water?: Water;
|
|
@@ -1793,6 +1824,8 @@ export declare class Engine {
|
|
|
1793
1824
|
triggers?: Triggers;
|
|
1794
1825
|
/** Particles (particles() module) */
|
|
1795
1826
|
particles?: Particles;
|
|
1827
|
+
/** Makes a swarm of same-kind gameplay objects (swarm() module): engine.swarm({ name, capacity, geometry, material, fields }) @experimental */
|
|
1828
|
+
swarm?: SwarmMaker;
|
|
1796
1829
|
/** Settings menu (settings() module) */
|
|
1797
1830
|
settings?: Settings;
|
|
1798
1831
|
/** Background music (music() module) */
|
|
@@ -1828,9 +1861,9 @@ export declare class Engine {
|
|
|
1828
1861
|
/** Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there */
|
|
1829
1862
|
shadows: Shadows;
|
|
1830
1863
|
/** The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there */
|
|
1831
|
-
|
|
1864
|
+
autoView: View;
|
|
1832
1865
|
/** Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there */
|
|
1833
|
-
|
|
1866
|
+
shaderTerms: Terms;
|
|
1834
1867
|
/** Light pool: many light sources, a fixed number of real lights (lightPool() module) */
|
|
1835
1868
|
lightPool?: LightPool;
|
|
1836
1869
|
/** Content loading (content() module) */
|
|
@@ -1890,7 +1923,10 @@ export declare class Engine {
|
|
|
1890
1923
|
addWaterBody(opts: WaterBodyOptions): Handle & { body: WaterBody };
|
|
1891
1924
|
|
|
1892
1925
|
// ---------- Common ----------
|
|
1893
|
-
/**
|
|
1926
|
+
/**
|
|
1927
|
+
* Get UI text (i18n): {name} in the text takes params.name, {key:action} the label of the key bound to that action; a key with no text comes back as itself
|
|
1928
|
+
* @example engine.t('shop.buy', { name: 'Fish' });
|
|
1929
|
+
*/
|
|
1894
1930
|
t(key: string, params?: Record<string, any>): string;
|
|
1895
1931
|
/**
|
|
1896
1932
|
* Add objects to the scene and register them (engine.thing), returns the first one. The last argument may be { id?, save? }: id makes thing.set /
|
|
@@ -1953,12 +1989,14 @@ export declare class Engine {
|
|
|
1953
1989
|
* bake at start-up, not mid-play.
|
|
1954
1990
|
* @example const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving });
|
|
1955
1991
|
* saveFile('probes.json', JSON.stringify(probes.toJSON()));
|
|
1992
|
+
* @experimental
|
|
1956
1993
|
*/
|
|
1957
1994
|
bakeProbes(opts: { bounds: import('three').Box3 | { min: PositionLike; max: PositionLike }; spacing: number; resolution?: number;
|
|
1958
1995
|
include?: (o: Object3D) => boolean; owner?: string }): Promise<ProbeSet>;
|
|
1959
1996
|
/**
|
|
1960
1997
|
* A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added.
|
|
1961
1998
|
* @example const probes = engine.loadProbes(await (await fetch('probes.json')).json());
|
|
1999
|
+
* @experimental
|
|
1962
2000
|
*/
|
|
1963
2001
|
loadProbes(json: ProbeData, opts?: { owner?: string }): ProbeSet;
|
|
1964
2002
|
/**
|
|
@@ -1968,55 +2006,62 @@ export declare class Engine {
|
|
|
1968
2006
|
* A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what
|
|
1969
2007
|
* was skipped, moved or doubled.
|
|
1970
2008
|
* @example const light = await engine.loadLightmap('light/level.lightmap');
|
|
2009
|
+
* @experimental
|
|
1971
2010
|
*/
|
|
1972
2011
|
loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }): Promise<Lightmap>;
|
|
1973
2012
|
|
|
1974
2013
|
// ---------- Settings ----------
|
|
1975
|
-
/** Render resolution */
|
|
2014
|
+
/** Render resolution, and the top adaptive resolution climbs back to */
|
|
1976
2015
|
setPixelRatio(p: number): void;
|
|
1977
2016
|
|
|
1978
2017
|
// ---------- Rays, scenarios ----------
|
|
1979
2018
|
/** Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit) */
|
|
1980
2019
|
raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions): RayHit | null;
|
|
1981
|
-
/**
|
|
2020
|
+
/**
|
|
2021
|
+
* Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY). The ray comes from the camera as last drawn: a rig.yaw / rig.pitch
|
|
2022
|
+
* write reaches it on the next drawn step, so several shots in one step with recoil between them cast from the rig's angles with engine.raycast (recipe 19)
|
|
2023
|
+
*/
|
|
1982
2024
|
pick(ndcX: number, ndcY: number, opts?: RaycastOptions): RayHit | null;
|
|
1983
2025
|
/** Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done */
|
|
1984
|
-
applyState(params: StateParams): Promise<
|
|
2026
|
+
applyState(params: StateParams): Promise<{ ok: boolean, refused: { key: string, value: unknown, reason: string }[] }>;
|
|
1985
2027
|
/** Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name. Returns a handle: remove() forgets the name */
|
|
1986
2028
|
defineState(name: string, params: StateParams, opts?: { owner?: string }): { owner?: string; remove(): void };
|
|
1987
2029
|
/**
|
|
1988
2030
|
* Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it:
|
|
1989
2031
|
* page.waitForFunction(() => window.engine?.stateApplied)
|
|
2032
|
+
* @experimental
|
|
1990
2033
|
*/
|
|
1991
2034
|
readonly stateApplied: boolean;
|
|
2035
|
+
/** What the URL parameters or the latest applyState could not do, e.g. ?weather=typo. Read it after stateApplied @experimental */
|
|
2036
|
+
readonly stateRefused: { key: string, value: any, reason: string }[];
|
|
1992
2037
|
|
|
1993
2038
|
// ---------- Start, pause, state ----------
|
|
1994
2039
|
/** Start: initialize modules, preload assets, wait for the world to be ready */
|
|
1995
2040
|
start(): Promise<this>;
|
|
1996
2041
|
/** Whether in headless mode (createEngine({ headless: true })) */
|
|
1997
2042
|
headless: boolean;
|
|
1998
|
-
/** Whether
|
|
1999
|
-
|
|
2043
|
+
/** Whether the real-time loop is stopped: only step() advances the game (headless mode starts this way) */
|
|
2044
|
+
halted: boolean;
|
|
2000
2045
|
/** Smoothed frame rate */
|
|
2001
2046
|
fps: number;
|
|
2002
|
-
/** Ids of the open windows */
|
|
2003
|
-
openWindows: Set<string>;
|
|
2004
2047
|
/**
|
|
2005
2048
|
* Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu
|
|
2006
2049
|
* pause
|
|
2007
2050
|
*/
|
|
2008
|
-
|
|
2051
|
+
haltLoop(owner?: string | { owner?: string }): OwnerHandle; // end it with the handle's remove()
|
|
2009
2052
|
/** Run fn at the start of the next fixed step (via commits); a Promise of fn's value */
|
|
2010
2053
|
nextFixed<T>(fn: () => T): Promise<T>;
|
|
2011
2054
|
/**
|
|
2012
2055
|
* Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame
|
|
2013
2056
|
* hooks and rendering continue and the UI works.
|
|
2014
2057
|
* So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's
|
|
2015
|
-
* name, default 'game'. uniforms.uTime (wind, water, clouds)
|
|
2058
|
+
* name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; { ambient: true } stops them too (a still)
|
|
2016
2059
|
*/
|
|
2017
2060
|
freeze(owner?: string | { owner?: string; kind?: 'title'; ambient?: boolean }, opts?: { kind?: 'title'; ambient?: boolean }): OwnerHandle;
|
|
2018
2061
|
/** Is anyone freezing gameplay? */
|
|
2019
2062
|
readonly frozen: boolean;
|
|
2063
|
+
/** True while a freeze asked for a full still (freeze(owner, { ambient: true })): frame code that moves things reads this, as animation and particles do */
|
|
2064
|
+
readonly still: boolean;
|
|
2020
2065
|
/**
|
|
2021
2066
|
* Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render),
|
|
2022
2067
|
* negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; time channels and
|
|
@@ -2112,7 +2157,7 @@ export declare class Engine {
|
|
|
2112
2157
|
* Budgets are the game's engine.budget limits, else a reference (desktop 60 fps; not enforced). Plain three.js: renderer.info.
|
|
2113
2158
|
* @example engine.inspect.perf().text
|
|
2114
2159
|
*/
|
|
2115
|
-
perf(opts?: { top?: number }): { drawCalls: number; triangles: number; programs: number; textureMB: number; cpuMs: number; compileMs: number; ok: boolean; text: string;
|
|
2160
|
+
perf(opts?: { top?: number }): { drawCalls: number; triangles: number; programs: number; textureMB: number; cpuMs: number | null; compileMs: number; ok: boolean; text: string;
|
|
2116
2161
|
budgets: { name: string; value: number; budget: number; from: 'engine.budget' | 'reference'; ok: boolean; next?: string }[];
|
|
2117
2162
|
compiles: { at: number; programs: number; ms: number }[]; [k: string]: any };
|
|
2118
2163
|
};
|
|
@@ -2154,7 +2199,7 @@ export declare class Engine {
|
|
|
2154
2199
|
export interface EngineError {
|
|
2155
2200
|
/** Where it happened, e.g. "fixed hook of module quests" or "load() of save part 'inventory'" */
|
|
2156
2201
|
where: string;
|
|
2157
|
-
/** The error message (English) */
|
|
2202
|
+
/** The error message (English) @experimental */
|
|
2158
2203
|
message: string;
|
|
2159
2204
|
/** Stable code (e.g. 'save-load-threw', 'world-plain'); null for an unknown error */
|
|
2160
2205
|
code: string | null;
|
|
@@ -2194,6 +2239,8 @@ export interface EngineCounts {
|
|
|
2194
2239
|
rigid?: number;
|
|
2195
2240
|
/** Only with particles() installed: alive is the number of live particles, emitters the number of attached emitters */
|
|
2196
2241
|
particles?: { alive: number; emitters: number };
|
|
2242
|
+
/** Only with swarm() installed: alive is the live objects of all swarms, swarms how many exist */
|
|
2243
|
+
swarm?: { alive: number; swarms: number };
|
|
2197
2244
|
/** Only with sky() installed: timers is the number of at / between / daily / onSeason timers */
|
|
2198
2245
|
calendar?: { timers: number };
|
|
2199
2246
|
/** Any other module's counts(e) hook result, under the module name */
|
|
@@ -2230,14 +2277,14 @@ export interface GameState {
|
|
|
2230
2277
|
loading: LoadingView;
|
|
2231
2278
|
/** tick / real / ambient / calendar are the time views (engine.time); with the calendar module there are also clock, day, season, isDay, timeOfDay */
|
|
2232
2279
|
time: {
|
|
2233
|
-
tick: number; real: number; ambient: number; calendar: number;
|
|
2280
|
+
tick: number; real: number; ambient: number; calendar: number; halted: boolean; frozen: boolean; headless: boolean; clock?: string; day?: number; season?: string; isDay?: boolean;
|
|
2234
2281
|
[key: string]: any;
|
|
2235
2282
|
};
|
|
2236
2283
|
/**
|
|
2237
|
-
* Everyone who holds the engine still (empty parts left out):
|
|
2284
|
+
* Everyone who holds the engine still (empty parts left out): halt / freeze / camera / debugView [{ owner, at? }], input [{ context, owner, pass }]
|
|
2238
2285
|
* (input.push), gates { action: owners } (input.gate). Every other shared value is in `shared`
|
|
2239
2286
|
*/
|
|
2240
|
-
holds: {
|
|
2287
|
+
holds: { halt?: any[]; freeze?: any[]; camera?: any[]; debugView?: any[]; input?: { context: string; owner: string; pass: boolean }[];
|
|
2241
2288
|
gates?: Record<string, string[]>; };
|
|
2242
2289
|
/**
|
|
2243
2290
|
* Every shared value and exclusive slot with entries, one row each ('move.speed[player]' for one record): the value, who decides it, how it
|
|
@@ -2272,7 +2319,7 @@ export interface GameState {
|
|
|
2272
2319
|
cutscene: { count: number; skippable: boolean; [key: string]: any } | null;
|
|
2273
2320
|
/** Installed modules in install order: name, type, and the capabilities it provides / requires when it has any */
|
|
2274
2321
|
modules: { name: string; type: ModuleType; provides?: string[]; requires?: string[] }[];
|
|
2275
|
-
/** What is plugged in where: plugins/ files, scene.add roots, addPass passes, modules, plain lights (core/plugins.js) */
|
|
2322
|
+
/** What is plugged in where: plugins/ files, scene.add roots, addPass passes, modules, plain lights (core/engine/plugins.js) */
|
|
2276
2323
|
slots: { slot: 'scene' | 'post' | 'module' | 'light'; plugged: string; file: string; on: boolean; affects: string[] }[];
|
|
2277
2324
|
/**
|
|
2278
2325
|
* engine.add / world things by save tier (counts only) and what will not survive a load: unsaved ('obj#3 (main.js:88, made during play by op x)'),
|
|
@@ -2286,7 +2333,7 @@ export interface GameState {
|
|
|
2286
2333
|
perf: {
|
|
2287
2334
|
fps: number | null; cpuMs: number | null; drawCalls: number; triangles: number; pixelRatio: number;
|
|
2288
2335
|
chunks?: { loaded: number; visible: number; queued: number }; budget?: BudgetReport | null; startup?: StartupReport | null;
|
|
2289
|
-
/** cpuMs by phase (null while paused), see
|
|
2336
|
+
/** cpuMs by phase (null while paused), see engine.inspect.perf() */
|
|
2290
2337
|
cpu?: { fixed: number; frame: number; render: number; afterRender: number } | null;
|
|
2291
2338
|
/** Cost of applying background results by stage: transit, build, collider, upload, stream (see engine.budget.cost; upload and transit are approximations) */
|
|
2292
2339
|
apply?: Record<string, { n: number; totalMs: number; maxMs: number; frameMs: number; bytes: number }>;
|
|
@@ -2304,7 +2351,7 @@ export interface GameState {
|
|
|
2304
2351
|
weatherDraw?: { rainVisible: boolean; snowVisible: boolean; flash: number };
|
|
2305
2352
|
/**
|
|
2306
2353
|
* Every value the engine writes on its own (shadow box center, background, camera.far, pixel ratio, camera ...) and who writes it now (writer): 'engine',
|
|
2307
|
-
* 'manual:<who>' (engine.
|
|
2354
|
+
* 'manual:<who>' (engine.autoView.manual(key), or the entry that hands the value to the game) or 'three (engine yielded)' (the game wrote it directly). manual = the takeover call
|
|
2308
2355
|
*/
|
|
2309
2356
|
owned?: Record<string, { part: string; key: string; writer: string; manual?: string }>;
|
|
2310
2357
|
/** Content added by other modules */
|
|
@@ -2326,7 +2373,7 @@ export interface DescribeContext {
|
|
|
2326
2373
|
export interface SkipOptions {
|
|
2327
2374
|
/** Until the calendar clock next reads this time ('HH:MM' or 0-1; needs calendar). The current time itself means a full day */
|
|
2328
2375
|
to?: string | number;
|
|
2329
|
-
/**
|
|
2376
|
+
/** Calendar seconds to skip (> 0) */
|
|
2330
2377
|
seconds?: number;
|
|
2331
2378
|
/** Fade out / in seconds (default 0: no fade, the jump happens before skip returns) */
|
|
2332
2379
|
fade?: number;
|