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/docs/api/cameraRig.md
CHANGED
|
@@ -6,18 +6,18 @@ Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamer
|
|
|
6
6
|
- `projection?: 'perspective' | 'orthographic'` 'orthographic' draws without perspective (isometric / 2.5D; the wheel then changes size); default 'perspective'
|
|
7
7
|
- `size?: number` With projection 'orthographic': world units of view height, default 20
|
|
8
8
|
- `yaw?: number` Which side of the focus the camera sits on (radians), default 0.8: camera = focus + (sin yaw, cos yaw) × distance, it looks along forward() = -(sin yaw, cos yaw). Behind a character facing f: yaw = f + PI
|
|
9
|
-
- `pitch?: number` Pitch angle (radians), default 0.42
|
|
9
|
+
- `pitch?: number` Pitch angle (radians), default 0.42. Positive = camera above the look point, looking down: the opposite of firstPersonCamera's pitch
|
|
10
10
|
- `distance?: number` Distance (meters), default 13
|
|
11
11
|
- `minDistance?: number` Zoom range (meters)
|
|
12
12
|
- `maxDistance?: number`
|
|
13
13
|
- `height?: number` How high above the character to look at (meters), default 1.4
|
|
14
|
-
- `smoothing?: number` Follow smoothing, default 10
|
|
14
|
+
- `smoothing?: number` (experimental) Follow smoothing, default 10
|
|
15
15
|
- `sensitivity?: number` Drag sensitivity, default 1
|
|
16
16
|
- `minPitch?: number` Pitch range (radians)
|
|
17
|
-
- `maxPitch?: number`
|
|
18
|
-
- `zoomStep?: number` Zoom ratio per wheel notch, default 0.1
|
|
19
|
-
- `groundClearance?: number` Minimum camera height above the ground (meters), default 1.2
|
|
20
|
-
- `invertY?: boolean` Invert vertical
|
|
17
|
+
- `maxPitch?: number` (experimental)
|
|
18
|
+
- `zoomStep?: number` (experimental) Zoom ratio per wheel notch, default 0.1
|
|
19
|
+
- `groundClearance?: number` (experimental) Minimum camera height above the ground (meters), default 1.2
|
|
20
|
+
- `invertY?: boolean` (experimental) Invert vertical
|
|
21
21
|
- `lockPitch?: boolean` Lock the pitch angle (top-down games)
|
|
22
22
|
- `shoulder?: number` Over-the-shoulder offset: meters to the right of the target the camera aims (negative = left shoulder), default 0
|
|
23
23
|
- `pointerLock?: boolean` Click locks the mouse; mouse motion turns the view without dragging (Esc releases), default false
|
|
@@ -31,46 +31,46 @@ Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamer
|
|
|
31
31
|
- `sensitivity?: number` Mouse sensitivity, default 1
|
|
32
32
|
- `fov?: number | null` Field of view (degrees); unchanged if omitted
|
|
33
33
|
- `headBob?: number` Walking bob amplitude (meters), 0 off, default 0.04
|
|
34
|
-
- `bobFrequency?: number` Bobs per meter
|
|
35
|
-
- `hideTarget?: boolean` Hide the character itself (its shadow remains), default true
|
|
34
|
+
- `bobFrequency?: number` (experimental) Bobs per meter
|
|
35
|
+
- `hideTarget?: boolean` (experimental) Hide the character itself (its shadow remains), default true
|
|
36
36
|
- `hideLayer?: number` Layer number used for hiding 0–31
|
|
37
37
|
- `pointerLock?: boolean` Click to lock the mouse, default true
|
|
38
38
|
- `swallowLockClick?: boolean` The press that locks the mouse is not delivered as Mouse0 / a click (default true); false delivers it too
|
|
39
39
|
- `yaw?: number` Initial heading (radians)
|
|
40
|
-
- `pitch?: number`
|
|
41
|
-
- `minPitch?: number` Look down / up limit (radians)
|
|
42
|
-
- `maxPitch?: number`
|
|
43
|
-
- `yawLimits?: number[] | null` Turn range left / right [min, max] (radians), unlimited by default
|
|
44
|
-
- `smoothing?: number` Smoothing of the camera following the body
|
|
45
|
-
- `invertY?: boolean` Invert vertical
|
|
40
|
+
- `pitch?: number` Initial look angle (radians), default 0 = level. Positive looks up, negative down: the opposite of followCamera's pitch
|
|
41
|
+
- `minPitch?: number` Look down / up limit (radians), default -1.45 / 1.45
|
|
42
|
+
- `maxPitch?: number` (experimental)
|
|
43
|
+
- `yawLimits?: number[] | null` (experimental) Turn range left / right [min, max] (radians), unlimited by default
|
|
44
|
+
- `smoothing?: number` (experimental) Smoothing of the camera following the body
|
|
45
|
+
- `invertY?: boolean` (experimental) Invert vertical
|
|
46
46
|
- fixedCamera options `FixedCameraOptions` (also includes the fields of Partial<CameraShot>):
|
|
47
47
|
- `shots?: Record<string, CameraShot>` Shots: name → shot
|
|
48
48
|
- `start?: string | null` Initial shot name
|
|
49
49
|
- `auto?: false | 'nearest'` Automatic switching: false / 'nearest' (pick the one nearest to the player)
|
|
50
|
-
- `autoInterval?: number` Check interval for automatic switching (seconds)
|
|
50
|
+
- `autoInterval?: number` (experimental) Check interval for automatic switching (seconds)
|
|
51
51
|
- `hysteresis?: number` How many meters closer a new shot must be to switch (prevents flipping back and forth)
|
|
52
|
-
- `triggerBlend?: number` Transition seconds for trigger-zone switches (0 = hard cut)
|
|
53
|
-
- `trackHeight?: number` How high above the character a track shot looks (meters)
|
|
54
|
-
- `trackSmoothing?: number` Head-follow smoothing
|
|
55
|
-
- `holdDirection?: boolean` Keep the direction when switching shots until the direction key is released
|
|
52
|
+
- `triggerBlend?: number` (experimental) Transition seconds for trigger-zone switches (0 = hard cut)
|
|
53
|
+
- `trackHeight?: number` (experimental) How high above the character a track shot looks (meters)
|
|
54
|
+
- `trackSmoothing?: number` (experimental) Head-follow smoothing
|
|
55
|
+
- `holdDirection?: boolean` (experimental) Keep the direction when switching shots until the direction key is released
|
|
56
56
|
- `ease?: Ease` Transition easing
|
|
57
57
|
- rtsCamera options `RtsCameraOptions`:
|
|
58
58
|
- `height?: number` Camera height above the focus (meters), default 30
|
|
59
59
|
- `minHeight?: number` Zoom range (meters)
|
|
60
60
|
- `maxHeight?: number`
|
|
61
|
-
- `
|
|
61
|
+
- `pitch?: number` Pitch down angle (radians, π/2 = straight down), default 0.95
|
|
62
62
|
- `yaw?: number` Initial horizontal heading (radians)
|
|
63
|
-
- `panSpeed?: number` Pan speed multiplier
|
|
64
|
-
- `dragPan?: boolean` Drag with the mouse to pan, default true
|
|
65
|
-
- `edgePan?: boolean` Pan at the screen edge, default false
|
|
66
|
-
- `edgeSize?: number` Edge width (fraction of the screen)
|
|
63
|
+
- `panSpeed?: number` (experimental) Pan speed multiplier
|
|
64
|
+
- `dragPan?: boolean` (experimental) Drag with the mouse to pan, default true
|
|
65
|
+
- `edgePan?: boolean` (experimental) Pan at the screen edge, default false
|
|
66
|
+
- `edgeSize?: number` (experimental) Edge width (fraction of the screen)
|
|
67
67
|
- `bounds?: { minX?, maxX?, minZ?, maxZ? } | null` Focus range (meters)
|
|
68
68
|
- `rotate?: boolean` false: no turning. Default true: declares the actions rotateLeft / rotateRight (no keys; presets.bindings.rtsRotate binds Q / R)
|
|
69
|
-
- `rotateSpeed?: number` Rotation speed (radians/second)
|
|
70
|
-
- `zoomStep?: number` Zoom ratio per wheel notch
|
|
71
|
-
- `smoothing?: number` Smoothing
|
|
69
|
+
- `rotateSpeed?: number` (experimental) Rotation speed (radians/second)
|
|
70
|
+
- `zoomStep?: number` (experimental) Zoom ratio per wheel notch
|
|
71
|
+
- `smoothing?: number` (experimental) Smoothing
|
|
72
72
|
- `fov?: number | null` Field of view (degrees); unchanged if omitted
|
|
73
|
-
- `followLock?: boolean` Manual panning is not allowed while following
|
|
73
|
+
- `followLock?: boolean` (experimental) Manual panning is not allowed while following
|
|
74
74
|
- `start?: PositionLike | null` Initial focus (position)
|
|
75
75
|
|
|
76
76
|
## Methods and properties
|
|
@@ -103,7 +103,7 @@ Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamer
|
|
|
103
103
|
- `cam.cut(name: string)` — Cut to a shot immediately
|
|
104
104
|
- `cam.blend(name: string, opts?: { seconds?: number; ease?: Ease }) → Promise<void>` — Transition smoothly to a shot ({ seconds = 1, ease }); the Promise resolves when done
|
|
105
105
|
- `cam.nearest(p: Vector3) → string | null` — Name of the shot nearest to a point
|
|
106
|
-
- `shots: Record<string, any>` All shots
|
|
106
|
+
- `shots: Record<string, any>` All shots. A shot stays where it was placed: for a view that pans at a fixed angle use followCamera({ mouseLook: false }) (recipe 21 section 6)
|
|
107
107
|
- `current: string | null` Current shot name
|
|
108
108
|
- `auto: false | 'nearest'`
|
|
109
109
|
- `autoInterval: number`
|
package/docs/api/characters.md
CHANGED
|
@@ -4,7 +4,7 @@ Characters: createPlayer() (characters() module)
|
|
|
4
4
|
|
|
5
5
|
- Options `CharactersOptions`:
|
|
6
6
|
- `npcs?: boolean` Whether to enable NPCs (engine.npcs), default true
|
|
7
|
-
- `npcTiers?: { fullRadius: number; nearEvery: number }` Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts)
|
|
7
|
+
- `npcTiers?: { fullRadius: number; nearEvery: number }` (experimental) Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts)
|
|
8
8
|
- `animation?: AnimatorOptions` What every character's Animator starts from, e.g. { fade: 0.15 }; a model's manifest mapping and the character's own animation win over it
|
|
9
9
|
|
|
10
10
|
## Methods and properties
|
|
@@ -12,7 +12,7 @@ Characters: createPlayer() (characters() module)
|
|
|
12
12
|
- `characters.createPlayer(opts: PlayerOptions) → Character` — Create the player and set engine.player; control is required (no default feel), e.g. createPlayer({ ...presets.player.thirdPerson, spawn }). An existing player is deleted first
|
|
13
13
|
- `characters.moveInput() → { x, z, run }` — The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it inside your own control function to wrap it
|
|
14
14
|
- `characters.support(object: any, opts?: { id?, safe?, carry?, inherit? }) → { id: string; remove(): void }` — Something characters stand on and ride (moving platform, lift, raft). Move the object any way (onFixed before or after the player, a timeline, physics): riders follow how its matrix changed, so the order does not matter. safe: false = never a respawn spot; carry 'position+yaw' turns riders with it; inherit: false = jumping off keeps none of its speed. With mover 'rapier' give it a collider too. Example: `const lift = engine.characters.support(liftMesh); engine.onFixed(() => { liftMesh.position.y = 2 + Math.sin(engine.time.now('real')); });`
|
|
15
|
-
- `characters.removePlayer()` — Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
|
|
15
|
+
- `characters.removePlayer()` — (experimental) Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
|
|
16
16
|
- `characters.findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }) → XZ[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: FindPathOptions & { detailed: true }) → PathResult` — Pathfinding (the single entry point): uses the navmesh when nav is installed and ready, otherwise the A* fallback. Returns a path [{ x, z }...], or null if unreachable
|
|
17
17
|
- `characters.findPathAsync(from: PositionLike, to: PositionLike, done: (path, status) => void, opts?: { radius?, step?, maxNodes? }) → { remove(): void }` — findPath for many callers (NPC crowds, AI squads): solved in engine.threads workers; done(path, status) runs on a fixed step a few steps later (same paths with threads on or off). Recipe 12 section 4
|
|
18
18
|
- Properties:
|
|
@@ -22,51 +22,56 @@ Characters: createPlayer() (characters() module)
|
|
|
22
22
|
## Character (engine.player / NPC are both Character)
|
|
23
23
|
- `player.push(vx: number, vz: number, seconds: number)` — Move at a fixed velocity (m/s) for seconds, ignoring move()'s direction and without turning (knockback, dodge roll); gravity and collision still apply
|
|
24
24
|
- `player.stat(name: 'speed' | 'runSpeed' | 'gravity' | …) → number` — A movement stat as the mover uses it now: the base field with every engine.mod('move.<name>') entry applied (canJump reads 1 / 0). Example: `engine.mod('move.speed', { owner: 'haste', id: 'player', mul: 1.2, for: 5 }); player.stat('speed') // 1.2 x player.speed`
|
|
25
|
-
- `player.addJumps(n?: number)` — Give back n jumps for this airtime (pickup, wall touch)
|
|
26
|
-
- `player.resetJumps()` — All jumps back, as if it had landed
|
|
25
|
+
- `player.addJumps(n?: number)` — (experimental) Give back n jumps for this airtime (pickup, wall touch)
|
|
26
|
+
- `player.resetJumps()` — (experimental) All jumps back, as if it had landed
|
|
27
27
|
- `player.launch(speed: number, opts?: { owner?: string })` — Throw it upward at speed m/s (jump pad, spring): leaves the ground, ends coyote time, the ground jump counts as used (air jumps stay); emits character:launch. Example: `player.launch(19, { owner: 'pad' })`
|
|
28
|
-
- `player.jumpState() → { grounded, coyoteLeft, bufferLeft, jumpsUsed, jumpsLeft, vy }` — Jump state now, read-only
|
|
28
|
+
- `player.jumpState() → { grounded, coyoteLeft, bufferLeft, jumpsUsed, jumpsLeft, vy }` — (experimental) Jump state now, read-only
|
|
29
29
|
- `player.enter(vehicle: Rideable)` — Board a vehicle (rigid.addWheeled's, or any object with the vehicle contract): the driver seat when free, else a free passenger seat; no-op when full
|
|
30
30
|
- `player.exit()` — Exit the vehicle
|
|
31
31
|
- `player.playAction(name: string)` — Play a one-shot action (e.g. 'wave'); skipped if the model has no such clip
|
|
32
32
|
- `player.onPose(fn: (character, dt) => void) → { remove(): void }` — Run fn(character, dt) every frame right after the animation pose is applied (model clips or procedural rig): attach things to bones or adjust bones. h.remove() stops it. Presentation only. Example: `const h = player.onPose(() => sword.position.copy(hand.getWorldPosition(v)));`
|
|
33
33
|
- `player.dispose()` — Fully delete this character: exits the vehicle first, releases animation and movement, removes it from the scene and releases geometry and materials (used by npcs.remove / removePlayer)
|
|
34
34
|
- `player.jump(opts?: { air?: boolean })` — Request a jump (buffered for jumpBuffer s): the ground jump on the ground or in coyote time, else an air jump while maxJumps allows; air: false = ground only. Example: `createPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump`
|
|
35
|
-
- `player.addTo(scene?: any)` — Add to the scene
|
|
36
35
|
- `player.placeAt(position: PositionLike)` — Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z })
|
|
37
36
|
- `player.syncRecord()` — After moving root yourself (a cutscene path, a scripted pose): write position and motion back to its world record (the player's), so a save right after has it
|
|
38
37
|
- `player.walkTo(target: Vector3 | { x: number; z: number } | [number, number, number] | …, opts?: { speed?, arrive?, turnRate?, stuckSeconds?, maxRepaths?, run? }) → Promise<{ status: 'arri… & { remove(): void }` — Walk to a point along characters.findPath on fixed steps; never rejects. One walk per character: a new walkTo, dispose() or a save load ends the old one with 'cancelled'. Transient: not saved, not fast-forwarded by engine.skip. Holds the character's control on layer 'script' (owner 'walkTo'): the player's keys / an NPC's schedule pause meanwhile, a cutscene pauses the walk, and another script owner on it is control-conflict
|
|
39
38
|
- `player.move(dirX: number, dirZ: number, run: boolean, dt: number)` — Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1 scales the speed), run to run, dt in seconds (used as given). Speed comes from the stats: engine.mod('move.speed', { owner, id: character.id, ... }) (the player: id 'player'), the one way to change speed. A character someone controls (engine.control.of(ch)) moves only through its holder: called from anywhere else it is control-bypass in dev; take control and use handle.move() / step instead
|
|
40
39
|
- `player.groundType() → string` — Ground type underfoot ('water' while swimming)
|
|
41
40
|
- `player.face(target: PositionLike | number)` — Turn at once to a position, or to an angle in radians (0 = +Z)
|
|
42
|
-
- `player.saveMotion(out?: CharacterMotion) → CharacterMotion` — Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
|
|
43
|
-
- `player.loadMotion(m: CharacterMotion | null | undefined)` — Restore the motion state from the plain object of saveMotion
|
|
41
|
+
- `player.saveMotion(out?: CharacterMotion) → CharacterMotion` — (experimental) Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
|
|
42
|
+
- `player.loadMotion(m: CharacterMotion | null | undefined)` — (experimental) Restore the motion state from the plain object of saveMotion
|
|
44
43
|
- Properties:
|
|
45
|
-
- `root: Object3D` Root node
|
|
46
|
-
- `object: Object3D` Same as root: add children, change visible and scale on it
|
|
44
|
+
- `root: Object3D` Root node: add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it
|
|
47
45
|
- `position: Vector3` Position (= root.position)
|
|
48
46
|
- `velocity: Vector2` Horizontal velocity (x, y map to world x, z). Writable: a write is an impulse the mover steers back toward the input (lasting knockback: push(); full control: mover 'manual')
|
|
49
47
|
- `facing: number` Heading (radians): 0 faces +Z, forward = (sin facing, cos facing); increasing turns toward +X (rotation about the Y axis, consistent with root.rotation.y)
|
|
50
|
-
- `vy: number` Vertical velocity (m/s). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly)
|
|
48
|
+
- `vy: number` Vertical velocity (m/s), kept apart from velocity, which is horizontal only (velocity.y is world z, not this). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly)
|
|
51
49
|
- `grounded: boolean` Whether standing on the ground
|
|
52
|
-
- `swimming: boolean` Whether swimming
|
|
50
|
+
- `swimming: boolean` (experimental) Whether swimming
|
|
53
51
|
- `state: CharacterState` Current action state
|
|
54
52
|
- `moveAmount: number` Current movement speed (m/s)
|
|
55
53
|
- `faceMode: FaceMode` Facing mode, change at any time; see CharacterOptions.faceMode
|
|
56
54
|
- `faceTarget: PositionLike | null` What faceMode 'target' faces
|
|
57
|
-
- `cameraFollow?: boolean` Player only: whether the camera module follows it (see PlayerOptions.cameraFollow)
|
|
58
|
-
- `
|
|
59
|
-
- `
|
|
55
|
+
- `cameraFollow?: boolean` (experimental) Player only: whether the camera module follows it (see PlayerOptions.cameraFollow)
|
|
56
|
+
- `swimDepth: number` (experimental)
|
|
57
|
+
- `swimSpeedFactor: number` (experimental)
|
|
58
|
+
- `turnSpeed: number` (experimental)
|
|
59
|
+
- `acceleration: number` (experimental)
|
|
60
|
+
- `stepHeight: number` (experimental)
|
|
61
|
+
- `airControl: number` (experimental)
|
|
62
|
+
- `coyoteTime: number` (experimental)
|
|
63
|
+
- `maxJumps: number` (experimental) Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed'))
|
|
64
|
+
- `airJumpSpeed: number | null` (experimental)
|
|
65
|
+
- `jumpBuffer: number` (experimental)
|
|
66
|
+
- `fall: false | { belowY }` (experimental) Fall check (see CharacterOptions.fall); a plain property
|
|
60
67
|
- `channel: string` Time channel the engine drives it on (see CharacterOptions.channel)
|
|
61
68
|
- `id: string` The character's id, the one form engine.mod / time.local take: its world record id ('player', an NPC's record id), else the id option, else a generated one
|
|
62
69
|
- `support: { kind, object, id, safe, velocity }` What it stands on, read-only (reused object); 'platform' = a registered support (characters.support), which carries it
|
|
63
70
|
- `safeGround: Vector3 | null` Last spot it stood still on safe ground (where a fall returns it); null until it first stands. Saved with the motion
|
|
64
|
-
- `onStep: ((groundType: string) => void) | null` Called when a foot lands (the argument is the ground type underfoot)
|
|
65
|
-
- `onLand: ((impact: number) => void) | null` Called on landing (the argument is the landing speed)
|
|
66
71
|
- `mover: { name, controller?, body?, collider?, move, dispose? }` How it walks now; name is 'simple' / 'rapier' / 'manual', controller is the native Rapier character controller (when rapier). Assign a name to switch: c.mover = 'manual'
|
|
67
72
|
- `anim: Animator | null` Skeletal animation state machine (when there is a glTF model; null while a model named by asset is still loading)
|
|
68
73
|
- `ready: boolean` false while a model named by asset is loading (the placeholder body shows); true otherwise, also after a failed load (placeholder kept)
|
|
69
|
-
- `whenReady: Promise<void>` Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise. Example: `const npc = new Character(engine, { model: 'villager' }).
|
|
74
|
+
- `whenReady: Promise<void>` Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise. Example: `const npc = new Character(engine, { model: 'villager' }); engine.add(npc.root); // import { Character } from 'threedog' await npc.whenReady; npc.playAction('Wave');`
|
|
70
75
|
- `vehicle: Rideable | null` The vehicle it sits in (null on foot)
|
|
71
76
|
- `seat: number | null` Its seat in the vehicle: 0 drives, others ride; null on foot
|
|
72
77
|
|
package/docs/api/clock.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine.clock (Clock) — engine.clock: calendar seconds and "after how long / every how long"
|
|
2
2
|
|
|
3
|
-
- `clock.after(seconds: number, fnOrEvent: (() => void) | string,
|
|
3
|
+
- `clock.after(seconds: number, fnOrEvent: (() => void) | string, opts?: { data?: any; channel?: string }) → Handle` — Call fn after seconds calendar seconds; if an event name is passed, the event is emitted when due (with data, can be saved). { channel } counts that time channel's seconds instead (a poison tick that slows down in bullet time)
|
|
4
4
|
- `clock.every(seconds: number, fn: () => void, opts?: { channel?: string }) → Handle` — Call once every seconds calendar seconds ({ channel }: 'real' or a time channel's seconds instead)
|
|
5
5
|
- Properties:
|
|
6
6
|
- `now: number` Calendar seconds = world-channel seconds x clock.rate, does not advance while paused / frozen, saved with the game; one calendar day = calendar.dayLength calendar seconds
|
package/docs/api/collision.md
CHANGED
|
@@ -5,9 +5,9 @@ Lightweight collision (collision() module): no clipping while walking, the camer
|
|
|
5
5
|
- Options `CollisionOptions`:
|
|
6
6
|
- `maxClimb?: number` Max walkable slope (height difference / horizontal distance), default 1.1
|
|
7
7
|
- `canopyHeight?: number` A camera above this height (meters) is not considered blocked by trees, default 5
|
|
8
|
-
- `cameraPad?: number` Margin between the camera and obstacles (meters), default 0.5
|
|
8
|
+
- `cameraPad?: number` (experimental) Margin between the camera and obstacles (meters), default 0.5
|
|
9
9
|
- `cameraMin?: number` Nearest camera distance (meters), default 1.5
|
|
10
|
-
- `walkableWaterMargin?: number` Height above the water surface (meters) at which it counts as walkable, default 0.2
|
|
10
|
+
- `walkableWaterMargin?: number` (experimental) Height above the water surface (meters) at which it counts as walkable, default 0.2
|
|
11
11
|
- `cameraOcclusion?: 'colliders' | 'meshes' | 'both'` What camera occlusion checks: 'both' (default) / 'colliders' / 'meshes' = static meshes registered with engine.rays.addStatic(mesh, { occluder: true })
|
|
12
12
|
|
|
13
13
|
## Methods and properties
|
|
@@ -15,18 +15,21 @@ Lightweight collision (collision() module): no clipping while walking, the camer
|
|
|
15
15
|
- `collision.addBox(position: PositionLike, opts?: BoxColliderOptions) → Handle` — Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() }
|
|
16
16
|
- `collision.addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?, height?, y?, occluder? }) → Handle` — Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y, occluder (as in addBox). A gap between segments is a gate. Returns a handle { remove() }
|
|
17
17
|
- `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure (no side effects, same answer for the same (x, z)); reading engine.ground in it is fine. findPathAsync caches the answers, so after the ground or your own state changes, remove() and add the field again. bounds { minX, maxX, minZ, maxZ } (world metres, the field's x / z extent) skips fn outside it; give it to keep findPathAsync's ground sampling cheap. Returns a handle { remove() }
|
|
18
|
-
- `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — Is a character of this radius touching addBlocked ground at (x, z)
|
|
18
|
+
- `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — (experimental) Is a character of this radius touching addBlocked ground at (x, z)
|
|
19
19
|
- `collision.addObject(obj: Object3D, opts?: { pad?: number; occluder?: boolean }) → Handle` — Add a collider from an object's bounding box, pad expands outward (meters), occluder as in addBox. Returns a handle { remove() }
|
|
20
|
-
- `collision.forEachStatic(fn: (type, data) => void)` — Iterate all static colliders added by hand
|
|
21
|
-
- `collision.mirror(fns: { add, remove }) → { sync, clear, size }` — Keep an outside copy of the static colliders in step (physics colliders, navmesh obstacles): add builds one piece, remove drops one; sync() diffs only when colliders changed and returns whether it compared; clear() forgets every piece without remove (the outside world was thrown away)
|
|
20
|
+
- `collision.forEachStatic(fn: (type, data) => void)` — (experimental) Iterate all static colliders added by hand
|
|
21
|
+
- `collision.mirror(fns: { add, remove }) → { sync, clear, size }` — (experimental) Keep an outside copy of the static colliders in step (physics colliders, navmesh obstacles): add builds one piece, remove drops one; sync() diffs only when colliders changed and returns whether it compared; clear() forgets every piece without remove (the outside world was thrown away)
|
|
22
22
|
- `collision.walkable(position: PositionLike, opts?: { radius?: number }) → boolean` — Whether someone can stand at this position (for pathfinding): not in water, not too steep, not inside an obstacle. radius is the character radius (meters, default engine.movement.radius)
|
|
23
23
|
- `collision.walkableAt(x: number, z: number, radius?: number) → boolean` — walkable with plain numbers, allocating nothing (A* inner loops); radius defaults to engine.movement.radius
|
|
24
24
|
- `collision.lineClear(a: PositionLike, b: PositionLike, opts?: { radius?, who? }) → boolean` — Line of sight with height: is the 3D segment a -> b free of boxes, circles and terrain trees? radius fattens the line; addBlocked water is ignored. Give eye heights in a / b
|
|
25
25
|
- Properties:
|
|
26
|
-
- `
|
|
27
|
-
- `
|
|
28
|
-
- `
|
|
29
|
-
- `
|
|
26
|
+
- `maxClimb: number` (experimental)
|
|
27
|
+
- `canopyHeight: number` (experimental)
|
|
28
|
+
- `cameraPad: number` (experimental)
|
|
29
|
+
- `cameraMin: number` (experimental)
|
|
30
|
+
- `walkableWaterMargin: number` (experimental)
|
|
31
|
+
- `cameraOcclusion: 'colliders' | 'meshes' | 'both'` (experimental) What camera occlusion checks (see CollisionOptions.cameraOcclusion)
|
|
32
|
+
- `version: number` (experimental) +1 each time a static collider is added or removed
|
|
30
33
|
|
|
31
34
|
## Data structures
|
|
32
35
|
- **CircleColliderOptions** Parameters of addCircle() (meters)
|
package/docs/api/content.md
CHANGED
|
@@ -11,7 +11,7 @@ Content loading (content() module)
|
|
|
11
11
|
- `content.place(name: string) → XZ | null` — Place name -> position (load's places first, then level markers), null if none
|
|
12
12
|
- `content.where(p: { place?, x?, z? }) → XZ` — Position form in content { place?, x?, z? } -> world coordinates
|
|
13
13
|
- `content.template(name: string) → Readonly<ContentTemplate>` — The shared, frozen definition of a content template (content/templates.js); instance state lives on the world record. e.g. template('chest').container.capacity
|
|
14
|
-
- `content.fields(name: string) → Record<string, ContentField>` — The fields one content entry may have (core/params.js spec format): what an editor panel lists and what content-check validates against. name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template', 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw. Example: `engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }`
|
|
14
|
+
- `content.fields(name: string) → Record<string, ContentField>` — The fields one content entry may have (core/base/params.js spec format): what an editor panel lists and what content-check validates against. name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template', 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw. Example: `engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }`
|
|
15
15
|
- `content.spawn(name: string, at: any, fields?: { id?, rot?, scale?, y?, items?, … }) → WorldRecord` — Place a new runtime instance of a content template (inside an op or a fixed step), saved whole; returns the world record (kind = template name, id `<template>#<n>` unless fields.id is given). fields: id, rot, scale, y (height above ground), items (container start goods), state fields (stage too, for a template with stages). Example: `engine.ops.define('chest.build', { run: (e, { x, z }) => e.content.spawn('chest', { x, z }, { items: { stick: 3 } }).id })`
|
|
16
16
|
- Properties:
|
|
17
17
|
- `ready: boolean` All vegetation models are fetched and the models of world data such as nearby props are built (world.ready)
|
|
@@ -48,13 +48,13 @@ Conditions are used in quest step done, dialogue option if and line variant if;
|
|
|
48
48
|
- `items.js` items (id -> name, icon, description); also export startItems for starting items
|
|
49
49
|
- `pickups.js` pickups on the ground (list)
|
|
50
50
|
- `containers.js` chests / shelves (container id -> { capacity, items: starting goods }; starting goods are placed only the first time, then saved)
|
|
51
|
-
- `npcs.js` NPCs (id -> name, schedule,
|
|
51
|
+
- `npcs.js` NPCs (id -> name, schedule, interact)
|
|
52
52
|
- `dialogues.js` dialogues (id -> speaker, nodes)
|
|
53
53
|
- `quests.js` quests (id -> title, steps, reward; a step can have a target position)
|
|
54
54
|
- `actions.js` own key actions of the game (action name -> default key, label)
|
|
55
|
-
- `places.js` place names (coordinates computed at runtime in main.js)
|
|
55
|
+
- `places.js` place names (name -> { x, z, y?, rot? }; rot turns everything placed there about Y; coordinates may be computed at runtime in main.js)
|
|
56
56
|
- `triggers.js` trigger zones (tag -> position / from level, enter/exit effects)
|
|
57
|
-
- `level.js` level markers (spawn point, NPCs, trigger zones)
|
|
57
|
+
- `level.js` level markers (spawn point, NPCs, trigger zones) of a code-built level: for the tools (content checks, GAMEMAP); load() accepts the file and does not read it
|
|
58
58
|
- `vegetation.js` vegetation (name -> model, growth rule)
|
|
59
59
|
- `props.js` props (list: model, position, facing, collision; or { template, x, z } = an instance of a template; or { id, grid, item, cell } = a grid item), streamed in on demand
|
|
60
60
|
- `templates.js` reusable objects (name -> model, collide, interact, container, sound, animate, state defaults, physics body); shared read-only definitions
|
|
@@ -62,5 +62,5 @@ Conditions are used in quest step done, dialogue option if and line variant if;
|
|
|
62
62
|
- `views.js` named fixed camera views (name -> { position: [x, y, z], target?: [x, y, z], fov? }); engine.views.show(name), ?view=name, npm run shot -- -w game --view name
|
|
63
63
|
- `grids.js` placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved
|
|
64
64
|
- `renames.js` renamed or deleted authored ids (old id -> new id, or null = deleted on purpose): the player's saved changes follow the new id
|
|
65
|
-
- `rules.js` condition words added by the game ({ conditions }); actions are ops, not effect words
|
|
66
|
-
- any other `<name>.js` the game registers in content/rules.js as kinds: { name: { desc, load(e, data), check?, map? } } (enemies, recipes, loot tables…)
|
|
65
|
+
- `rules.js` condition words and data kinds added by the game ({ conditions, kinds }); actions are ops, not effect words
|
|
66
|
+
- any other `<name>.js` the game registers in content/rules.js as kinds: { name: { desc, load?(e, data), check?, map? } } (enemies, recipes, loot tables…)
|
package/docs/api/dialogue.md
CHANGED
|
@@ -15,10 +15,10 @@ Dialogue (dialogue() module). Ops: `dialogue.advance` (finish typing the line, e
|
|
|
15
15
|
- `dialogue.end()` — End the main dialogue
|
|
16
16
|
- Properties:
|
|
17
17
|
- `state: DialogueState` Story state: state.flags is engine.vars.flags (autosaved)
|
|
18
|
-
- `scripts: Map<string, DialogueScript>` All scripts
|
|
18
|
+
- `scripts: Map<string, DialogueScript>` (experimental) All scripts
|
|
19
19
|
- `active: { speaker, nodes, node?, id?, onEnd } | null` The dialogue in progress (null when none). speaker: the script name; node: the current node OBJECT (its fields: text, choices, data...); id: that node's id string ('start', 'ask'); both are set once the first line shows. Read-only: drive it with start / end / the dialogue ops. Example: `const atAsk = engine.dialogue.active?.id === 'ask'; // the node id; active.node.data holds the node's own fields`
|
|
20
|
-
- `speaking: string | null` The script the main dialogue is playing
|
|
21
|
-
- `
|
|
20
|
+
- `speaking: string | null` (experimental) The script the main dialogue is playing
|
|
21
|
+
- `charsPerSecond: number` (experimental) Typing speed (characters/second)
|
|
22
22
|
|
|
23
23
|
## Data structures
|
|
24
24
|
- **DialogueScript** = `Record<string, DialogueNode>` — Dialogue script: node name -> node, starting from 'start'
|
package/docs/api/engine.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine — createEngine and the Engine class (core)
|
|
2
2
|
|
|
3
|
-
- `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required
|
|
3
|
+
- `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required
|
|
4
4
|
- Options `EngineOptions`:
|
|
5
5
|
- `canvas?: HTMLCanvasElement | HTMLElement` Canvas element (required unless renderer is given), e.g. document.getElementById('view')
|
|
6
6
|
- `renderer?: 'webgl' | 'webgpu' | EngineRenderer` 'webgl' (default): the engine builds a WebGLRenderer. 'webgpu': it builds three's WebGPURenderer (needs import 'threedog/tsl' first) and start() awaits its init(). Or a ready three.js renderer (WebGLRenderer or WebGPURenderer) used as is; canvas then defaults to renderer.domElement.
|
|
@@ -19,23 +19,23 @@
|
|
|
19
19
|
- `saveKey?: string` Save name prefix; must differ when several games share one site, default 'game'
|
|
20
20
|
- `joystick?: 'auto' | boolean` On-screen joystick: 'auto' (only on touch devices) / true / false
|
|
21
21
|
- `headless?: boolean` Headless mode: no real-time loop and no per-frame rendering, advances only on step() (for tests and screenshots). Adding ?threedog-headless to the URL also turns it on
|
|
22
|
-
- `validate?: boolean` 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 to turn it off
|
|
23
|
-
- `decoders?: string` 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 three are packed by vite automatically
|
|
22
|
+
- `validate?: boolean` (experimental) 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 to turn it off
|
|
23
|
+
- `decoders?: string` (experimental) 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 three are packed by vite automatically
|
|
24
24
|
- `budget?: BudgetLimits` Performance budget limits, e.g. { drawCalls: 250, fps: 55 }; only the given categories are checked; off by default
|
|
25
|
-
- `urlState?: boolean` Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development
|
|
25
|
+
- `urlState?: boolean` (experimental) Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development
|
|
26
26
|
- `seed?: number` Seed for engine.random; default 1 in headless mode (reproducible), the current time for live runs (different every game)
|
|
27
27
|
- `movement?: Partial<MovementProfile>` Shared "can walk there" parameters (meters / degrees): collision, the Rapier capsule, navigation and level steps all read them by default. Default { radius: 0.4, height: 1.8, maxSlope: 48, stepHeight: 0.45 }
|
|
28
28
|
- `threads?: 'auto' | number | false` (experimental) Worker pool size for engine.threads: 'auto' (default: cores - 1, at most 4), a worker count, or false (all on the main thread, same results, no workers created)
|
|
29
29
|
- `pauseOnBlur?: boolean` Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page)
|
|
30
30
|
- `lights?: boolean` 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
|
|
31
|
-
- `batching?: false | BatchingOptions` 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 }
|
|
31
|
+
- `batching?: false | BatchingOptions` 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 }
|
|
32
32
|
|
|
33
33
|
## engine methods
|
|
34
34
|
- `engine.actorPosition(id?: string) → { x, y, z } | null` — Where an actor is now (default engine.actor): the player's position for 'player' (engine.focus without a player), else its model or world record position; null when unknown. Example: `engine.actor = 'boat_1'; engine.actorPosition()`
|
|
35
35
|
- `engine.catalog(id?: string | { find?: string }) → any` — What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas). No argument: the short list, an ARRAY of { id, kind, label, ops, saves, ... } (read .id, not Object.keys); a module id / op name: that entry expanded (null if unknown); { find }: the short list filtered. recipes/51-capability-catalog.md. Example: `engine.catalog().map(s => s.id); engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']`
|
|
36
36
|
- `engine.takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>) → OwnerHandle` — 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
|
|
37
|
-
- `engine.mod(name: string, opts: import('./gameplay').ModOptions) → import('./gameplay').ModHandle` — The one way several systems change a shared quantity: an entry per owner, combined by layer, ended by its handle; nothing remembers an old value. 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`
|
|
38
|
-
- `engine.wrap(target: T, method: string, fn: (next, args) => any, opts?: { owner?: string }) → Handle` — The one way to change what a module's public method does without copying the module: fn(next, ...args) runs instead of it; call next(...args) for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api. Example: `engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })`
|
|
37
|
+
- `engine.mod(name: string, opts: import('./gameplay').ModOptions) → import('./gameplay').ModHandle` — (experimental) The one way several systems change a shared quantity: an entry per owner, combined by layer, ended by its handle; nothing remembers an old value. 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`
|
|
38
|
+
- `engine.wrap(target: T, method: string, fn: (next, args) => any, opts?: { owner?: string }) → Handle` — (experimental) The one way to change what a module's public method does without copying the module: fn(next, ...args) runs instead of it; call next(...args) for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api. Example: `engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })`
|
|
39
39
|
- `engine.setCamera(kind: CameraKind, opts?: object) → CameraRig` — Switch the camera at runtime between kinds, once a camera module is installed (openWorld installs followCamera; with none it throws camera-none naming the module to install, e.g. engine.use(fixedCamera({ position, lookAt }))): the target and horizontal heading carry over; the first-person camera hides the character body automatically (the shadow stays) and locks / releases the mouse; the camera switched out is kept, with its parameters, for switching back. Passing opts rebuilds this kind of camera with the new parameters. A wrong kind throws and lists the available options. Example: `engine.onFrame(() => { if (engine.input.pressedRaw('toggleView')) engine.setCamera(engine.cameraRig.kind === 'follow' ? 'firstPerson' : 'follow'); });`
|
|
40
40
|
- `engine.use(...mods: (ModuleInput | { replaces })[])` — Install one or more modules (in order; dependencies must be installed first). A last argument { replaces: 'slot' } swaps the module that holds that exclusive slot: it is unloaded first (its handles, changes and dispose) and put back if the new install fails. Example: `engine.use(myInventory(), { replaces: 'inventory' })`
|
|
41
41
|
- `engine.unuse(name: string)` — Unload one installed module: its tracked handles, its slots and ctx.mod entries, its dispose. What it added some other way stays (dev reports a picture module's leftovers). Throws while another module still requires it. To swap a holder use engine.use(mine(), { replaces: 'slot' }). Example: `engine.unuse('rain');`
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
- `engine.waterAt(x: number, z: number) → number` / `waterAt(at: PositionLike) → number` — Water surface height at (x, z): standalone water bodies first, otherwise the global water level; -Infinity when there is no water. A position or object also works
|
|
48
48
|
- `engine.snapToGround(obj: T, offset?: number) → T` — Put an object on the ground under it (y = ground height + offset) and return the object. With multi-layer ground the object's current y is the reference height
|
|
49
49
|
- `engine.addWaterBody(opts: WaterBodyOptions) → Handle & { body: WaterBody }` — Add a water body (give radius for a circle, halfWidth / halfDepth for a rectangle) and return a handle { body, remove() }. The water module draws it
|
|
50
|
-
- `engine.t(key: string, params?: Record<string, any>) → string` — Get UI text (i18n)
|
|
50
|
+
- `engine.t(key: string, params?: Record<string, any>) → string` — Get UI text (i18n): {name} in the text takes params.name, {key:action} the label of the key bound to that action; a key with no text comes back as itself. Example: `engine.t('shop.buy', { name: 'Fish' });`
|
|
51
51
|
- `engine.add(obj: T, ...more: (Object3D | { id?, save? })[]) → T` — Add objects to the scene and register them (engine.thing), returns the first one. The last argument may be { id?, save? }: id makes thing.set / thing.remove changes saved (unique, no '#', one object per call); without it a unique obj.name is used, else a session id obj#n. save: true asks dev to warn when it cannot be saved. engine.scene.add adds without registering. Example: `engine.add(windmill, { id: 'windmill' });`
|
|
52
52
|
- `engine.thing(idOrObj: string | Object3D) → Thing` — What a thing is and what a save keeps: a world record id, an engine.add id or name, or any Object3D (its registered ancestor). object is the live Object3D (not enumerable). Throws with the closest id when nothing matches. Change it with ops.run('thing.set' / 'thing.remove', { id, ... }). Example: `engine.thing('windmill').saved // 'code'`
|
|
53
53
|
- `engine.remove(...objs: Object3D[])` — Fully delete an object (use it when you no longer want the object): removes it from its parent, unregisters rays, and releases the geometry and materials of it and its children (textures and geometry / materials shared by assets are not released)
|
|
@@ -56,18 +56,18 @@
|
|
|
56
56
|
- `engine.onFrame(fn: (dt: number) => void) → Handle` — Once per frame (dt in frame seconds): animation, camera, UI and UI keys (menus read this frame's latest input). Gameplay keys belong in onFixed. Returns a handle { remove() }
|
|
57
57
|
- `engine.onRender(fn: (ctx) => void, opts?: { when?: 'before' | 'after' }) → Handle` — Around the main frame render, after the camera update and batching. when 'before' (default): render into your own render target here (mirror, minimap, portal, picking); the render target is reset to the screen afterwards. 'after': right after the frame (read pixels). The main frame render itself stays the engine's (post chain). Returns a handle { remove() }. Example: `const rt = new THREE.WebGLRenderTarget(256, 256); engine.onRender(({ renderer, scene }) => { renderer.setRenderTarget(rt); renderer.render(scene, mapCam); });`
|
|
58
58
|
- `engine.renderOnce(target?: import('three').RenderTarget | null, camera?: import('three').Camera)` — Draw one picture now, outside the loop, on either renderer. `renderOnce()`: the frame the player sees, onto the canvas through engine.post (read the canvas in the same task, as photo mode does). `renderOnce(target)`: that frame through engine.post into a render target (the canvas's pixels). `renderOnce(target, camera)` with another camera: the scene from that camera, without post. On WebGPURenderer each call is a fresh node frame, so two calls in one task give two pictures (a RenderPipeline draws its scene pass once per frame). Example: `engine.renderOnce(); const url = engine.renderer.domElement.toDataURL('image/png'); engine.renderOnce(rt, mapCamera); // a minimap / thumbnail into your own render target`
|
|
59
|
-
- `engine.bakeProbes(opts: { bounds, spacing, resolution?, include?, owner? }) → Promise<ProbeSet>` — Bake a grid of light probes from the scene as it is now: three's probe grid renders a cube at every grid point and keeps spherical harmonics, and every lit pixel inside the grid then takes its own interpolated light, on WebGL and WebGPU alike. The grid adds to whatever ambient light the scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so). Outside the grid there is no probe light. A load-time cost, not per frame: 6 renders per probe, a few probes per task so the page keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once: bake at start-up, not mid-play. Example: `const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving }); saveFile('probes.json', JSON.stringify(probes.toJSON()));`
|
|
60
|
-
- `engine.loadProbes(json: ProbeData, opts?: { owner?: string }) → ProbeSet` — A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added. Example: `const probes = engine.loadProbes(await (await fetch('probes.json')).json());`
|
|
61
|
-
- `engine.loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }) → Promise<Lightmap>` — Put a baked lightmap on the scene: `threedog bake light` wrote the file from the meshes the game marked `userData.static = true`; this rebuilds each with its second UV set and sets plain `material.lightMap`, on WebGL and WebGPU alike. Call it once the level is built, with its lights as they will be played. Nothing runs per frame. Keep the sun real-time; the ambient light the bake saw (hemisphere, environment) has to go, or it counts twice. A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what was skipped, moved or doubled. Example: `const light = await engine.loadLightmap('light/level.lightmap');`
|
|
62
|
-
- `engine.setPixelRatio(p: number)` — Render resolution
|
|
59
|
+
- `engine.bakeProbes(opts: { bounds, spacing, resolution?, include?, owner? }) → Promise<ProbeSet>` — (experimental) Bake a grid of light probes from the scene as it is now: three's probe grid renders a cube at every grid point and keeps spherical harmonics, and every lit pixel inside the grid then takes its own interpolated light, on WebGL and WebGPU alike. The grid adds to whatever ambient light the scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so). Outside the grid there is no probe light. A load-time cost, not per frame: 6 renders per probe, a few probes per task so the page keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once: bake at start-up, not mid-play. Example: `const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving }); saveFile('probes.json', JSON.stringify(probes.toJSON()));`
|
|
60
|
+
- `engine.loadProbes(json: ProbeData, opts?: { owner?: string }) → ProbeSet` — (experimental) A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added. Example: `const probes = engine.loadProbes(await (await fetch('probes.json')).json());`
|
|
61
|
+
- `engine.loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }) → Promise<Lightmap>` — (experimental) Put a baked lightmap on the scene: `threedog bake light` wrote the file from the meshes the game marked `userData.static = true`; this rebuilds each with its second UV set and sets plain `material.lightMap`, on WebGL and WebGPU alike. Call it once the level is built, with its lights as they will be played. Nothing runs per frame. Keep the sun real-time; the ambient light the bake saw (hemisphere, environment) has to go, or it counts twice. A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what was skipped, moved or doubled. Example: `const light = await engine.loadLightmap('light/level.lightmap');`
|
|
62
|
+
- `engine.setPixelRatio(p: number)` — Render resolution, and the top adaptive resolution climbs back to
|
|
63
63
|
- `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit)
|
|
64
|
-
- `engine.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY)
|
|
65
|
-
- `engine.applyState(params: StateParams) → Promise<
|
|
64
|
+
- `engine.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY). The ray comes from the camera as last drawn: a rig.yaw / rig.pitch write reaches it on the next drawn step, so several shots in one step with recoil between them cast from the rig's angles with engine.raycast (recipe 19)
|
|
65
|
+
- `engine.applyState(params: StateParams) → Promise<{ ok: boolean, refused: {…` — Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done
|
|
66
66
|
- `engine.defineState(name: string, params: StateParams, opts?: { owner?: string }) → { owner?: string; remove(): void }` — Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name. Returns a handle: remove() forgets the name
|
|
67
67
|
- `engine.start() → Promise<this>` — Start: initialize modules, preload assets, wait for the world to be ready
|
|
68
|
-
- `engine.
|
|
68
|
+
- `engine.haltLoop(owner?: string | { owner?: string }) → OwnerHandle` — 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 pause
|
|
69
69
|
- `engine.nextFixed(fn: () => T) → Promise<T>` — Run fn at the start of the next fixed step (via commits); a Promise of fn's value
|
|
70
|
-
- `engine.freeze(owner?: string | { owner?, kind?, ambient? }, opts?: { kind?, ambient? }) → OwnerHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame hooks and rendering continue and the UI works. So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's name, default 'game'. uniforms.uTime (wind, water, clouds)
|
|
70
|
+
- `engine.freeze(owner?: string | { owner?, kind?, ambient? }, opts?: { kind?, ambient? }) → OwnerHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame hooks and rendering continue and the UI works. So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; { ambient: true } stops them too (a still)
|
|
71
71
|
- `engine.step(seconds: number, opts?: { render?, frameEvery?, describe? }) → GameState | null` — Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render), negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; time channels and the calendar clock.now / sky time of day run at their own speeds; frame hooks run once every frameEvery fixed steps, default 2; describe: false returns null instead of building describe()). jobs ignore real time and finish every frame; results of stream's synchronous build are attached to the scene before returning. When render is true (default) one frame is rendered at the end. Returns the describe() result after advancing
|
|
72
72
|
- `engine.skip(opts: SkipOptions) → Promise<{ seconds: number; clock:…` — Skip game time forward (sleep until morning, wait an hour) without stepping every fixed step. clock.after / every, sky.at / daily / between, day:start and season:change fire in time order as if stepped (each crossing once); world records with far catch up the span in one far(rec, dt). onFixed, module fixed hooks, physics and near simulation do not run; every time view (tick, real, ambient, channels, calendar) moves as if stepped. Input is locked and gameplay frozen during the skip; emits time:skip. fade 0 (default): the time has moved when skip returns. fade > 0: fade out, jump, save, fade in; the Promise resolves after the fade in (it needs frames). session.newGame / load / quit cancel a running skip: it resolves null. Example: `await engine.skip({ to: '06:00' })`
|
|
73
73
|
- `engine.checkSkip(seconds: number, opts?: { ignore?: string[] }) → Promise<{ ok: boolean; code?: 'fr…` — Consistency check: engine.skip({ seconds }) vs stepping the same span in fixed steps; compares the saved state. Leaves the world at the stepped state (use a scratch playthrough or a test). Example: `const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);`
|
|
@@ -79,24 +79,24 @@
|
|
|
79
79
|
- `engine.counts() → EngineCounts` — Counts for leak hunting: they should not keep growing after repeatedly entering / leaving levels or opening / closing windows. geometries / textures come from three.js renderer.info.memory (counted only after rendering)
|
|
80
80
|
|
|
81
81
|
## engine properties (module properties are on each module page)
|
|
82
|
-
- `
|
|
82
|
+
- `validate: boolean` False when createEngine({ validate: false }) turned the development checks off for this engine
|
|
83
83
|
- `renderer: EngineRenderer` three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer)
|
|
84
84
|
- `tier: 'low' | 'high'` 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)
|
|
85
85
|
- `scene: import('three').Scene` three.js scene
|
|
86
86
|
- `lights: { sun, hemi }` Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
|
|
87
|
-
- `camera: import('three').PerspectiveCamera` 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)
|
|
87
|
+
- `camera: import('three').PerspectiveCamera` 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)
|
|
88
88
|
- `focus: Vector3` Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the player by default), which does not follow the camera
|
|
89
89
|
- `ground: Ground` Current ground
|
|
90
90
|
- `movement: Readonly<MovementProfile>` Shared parameters for whether a character can walk somewhere (set by createEngine({ movement }), read-only); same-named options of individual modules are only overrides
|
|
91
91
|
- `player: Character | null` The player (exists only after characters.createPlayer()). Its position belongs to the character's mover: other systems request movement (placeAt / move / vehicle enter), don't modify position directly
|
|
92
92
|
- `actor: string` World record id of the one the local user controls (default 'player'): interactions, trigger zones, marker distances, the world simulation center and ops (ctx.actor) use it. Set it to hand control to a vehicle or squad member
|
|
93
|
-
- `phase: 'constructed' | 'loading' | 'ready' | 'running' | 'disposed'` Where the engine is in its life: 'constructed' (start() not called) -> '
|
|
93
|
+
- `phase: 'constructed' | 'starting' | 'loading' | 'ready' | 'running' | 'disposed'` 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 time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved) -> 'disposed'.
|
|
94
94
|
- `ready: boolean` phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property)
|
|
95
95
|
- `disposed: boolean` phase is 'disposed'
|
|
96
|
-
- `moduleOrder: string[]` Execution order of module hooks (module names, first -> last), for debugging "who runs before whom"
|
|
97
|
-
- `moduleStates: Record<string, 'registered' | 'initializing' | 'running' | …` Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'. A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
|
|
96
|
+
- `moduleOrder: string[]` (experimental) Execution order of module hooks (module names, first -> last), for debugging "who runs before whom"
|
|
97
|
+
- `moduleStates: Record<string, 'registered' | 'initializing' | 'running' | …` (experimental) Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'. A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
|
|
98
98
|
- `error: EngineError | null` Gameplay error in development / testing (module hooks, onFixed / onFrame / clock callbacks, event listeners): { where (location of the error), message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
|
|
99
|
-
- `disabledModules: Set<string>` Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft)
|
|
99
|
+
- `disabledModules: Set<string>` (experimental) Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft)
|
|
100
100
|
- `signal: AbortSignal` The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on dispose()
|
|
101
101
|
- `uiRoot: HTMLDivElement` UI root node: UI elements of the engine and modules hang under it (don't attach to document.body directly), the whole tree is removed on dispose()
|
|
102
102
|
- `modules: Map<string, ModuleDef>` Installed modules: name -> module definition
|
|
@@ -114,25 +114,22 @@
|
|
|
114
114
|
- `occlusion: Occlusion` Occlusion culling of the engine's big things (hlod cells, batched groups) on both renderers. Off by default; it pays only when heavy things hide behind others (recipe 34)
|
|
115
115
|
- `ui: UIParts` UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md)
|
|
116
116
|
- `adaptive: AdaptiveState` Automatic resolution state
|
|
117
|
-
- `
|
|
118
|
-
- `cpuPhases: { fixed, frame, render, afterRender }` cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks
|
|
117
|
+
- `stepBlend: number` 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
|
|
119
118
|
- `cameraOverride: CameraOverride | null` The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Read-only
|
|
120
119
|
- `runState: RunState` Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is
|
|
121
|
-
- `decoders: string` Draco/KTX2 decoder directory
|
|
122
120
|
- `clock: Clock` Calendar clock: calendar seconds now, after / every, the rate (clock-time / season timers are on engine.calendar)
|
|
123
|
-
- `stacks: import('./gameplay').Stacks` Every shared quantity by name; define your own with engine.stacks.define(name, { base })
|
|
124
|
-
- `control: Control` Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < net; a higher one pauses the lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57. Example: `const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();`
|
|
121
|
+
- `stacks: import('./gameplay').Stacks` (experimental) Every shared quantity by name; define your own with engine.stacks.define(name, { base })
|
|
122
|
+
- `control: Control` Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < physics < net; a higher one pauses the lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57. Example: `const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();`
|
|
125
123
|
- `time: import('./gameplay').Time` Time channels: read seconds with time.now('real' / 'ambient' / 'calendar' / a channel such as 'world'), speeds with scale(ch, id?)
|
|
126
124
|
- `vars: Vars` Story flags and counters (autosaved)
|
|
127
125
|
- `budget: Budget` Performance budget (off by default)
|
|
128
|
-
- `plugins: { add, off, on, list }` The plugins folder: files in the game's plugins/ plugged at start by what they export (core/plugins.js); describe().slots lists them (add() off() on() list())
|
|
126
|
+
- `plugins: { add, off, on, list }` The plugins folder: files in the game's plugins/ plugged at start by what they export (core/engine/plugins.js); describe().slots lists them (add() off() on() list())
|
|
129
127
|
- `rays: Rays` Ray registry (what engine.raycast hits)
|
|
130
128
|
- `jobs: Jobs` Frame-spread job scheduler
|
|
131
|
-
- `commits: Commits` Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits
|
|
129
|
+
- `commits: Commits` (experimental) Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits
|
|
132
130
|
- `threads: Threads` (experimental) Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays. Results that affect gameplay go through commits
|
|
133
131
|
- `ops: Ops` One entry point for actions players and NPCs decide to do: define / run / can / list / recent, see Ops and recipes/23-ops.md
|
|
134
132
|
- `views: Views` Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md)
|
|
135
|
-
- `tick: number` Fixed-step count (= engine.time.tick, the one time counter: does not advance while frozen; commits due times, event history and the operation log use it). Seconds are views of it: engine.time.now('real' / 'ambient' / 'calendar' / channel)
|
|
136
133
|
- `random: Random` 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
|
|
137
134
|
- `stream: Stream` Spatial stream-in and the stream sources (where the world is loaded: terrain, colliders, models, stream entries; built-in player and camera sources, add one for a teleport destination)
|
|
138
135
|
- `batching: Batching` Automatic batching: the same static model the engine placed (world records, stream builds, level files) many times in a cell is drawn as one InstancedMesh; your own meshes only with userData.batch = true (createEngine({ batching }))
|
|
@@ -141,21 +138,22 @@
|
|
|
141
138
|
- `waterLevel: number` Global water level (meters); -Infinity when there is no water
|
|
142
139
|
- `debug: DebugOverrides & { panel: DebugPanel | null }` Diagnostic overrides and view modes with an owner (override / clear / view: core, always there); panel is the F3 panel, null without the debug() module
|
|
143
140
|
- `shadows: Shadows` Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there
|
|
144
|
-
- `
|
|
145
|
-
- `
|
|
146
|
-
- `stateApplied: boolean` Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it: page.waitForFunction(() => window.engine?.stateApplied)
|
|
141
|
+
- `autoView: View` The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there
|
|
142
|
+
- `shaderTerms: Terms` Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there
|
|
143
|
+
- `stateApplied: boolean` (experimental) Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it: page.waitForFunction(() => window.engine?.stateApplied)
|
|
144
|
+
- `stateRefused: { key: string, value: any, reason: string }[]` (experimental) What the URL parameters or the latest applyState could not do, e.g. ?weather=typo. Read it after stateApplied
|
|
147
145
|
- `headless: boolean` Whether in headless mode (createEngine({ headless: true }))
|
|
148
|
-
- `
|
|
146
|
+
- `halted: boolean` Whether the real-time loop is stopped: only step() advances the game (headless mode starts this way)
|
|
149
147
|
- `fps: number` Smoothed frame rate
|
|
150
|
-
- `openWindows: Set<string>` Ids of the open windows
|
|
151
148
|
- `frozen: boolean` Is anyone freezing gameplay?
|
|
149
|
+
- `still: boolean` 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
|
|
152
150
|
- `describe: { add }` Call engine.describe(opts?: { radius?: number }) to get the current game state (a plain object, JSON.stringify-able); radius is how far counts as "nearby" (meters, default 30).
|
|
153
151
|
- `inspect: { scene, materials, perf }` What is around an actor or a spot, and what that actor can do now (each op offer checked with can, possible first, at most 8; failed ones carry code and the op's reasons note). at: a world record id (that actor), [x, z] / { x, z } (a spot, ops as the player), or nothing (the player). radius default 10 m. Example: `engine.inspect(); // { actor: 'player', at: { x, z }, near: [...], ops: [{ op: 'shop.buy', args, ok: false, code: 'noMoney', why: 'Not enough gold' }] }`
|
|
154
152
|
|
|
155
153
|
## Module definition (engine.use(myModule()))
|
|
156
154
|
- **ModuleDef** A module (the argument of engine.use). The name is the property name on the engine once installed. Per-frame hook order follows stage, then before / after within a stage, then install order.
|
|
157
155
|
- `name: string` Module name; after install, access the object returned by install through engine[name]
|
|
158
|
-
- `type
|
|
156
|
+
- `type?: ModuleType` What the module owns (default 'rules'; core/engine/moduleTypes.js): 'world' state, records, ops (draws nothing) / 'picture' what is seen and heard (changes no game state: no ops, no world record writes) / 'actor' characters / 'rules' game logic / 'ui' panels and menus (binds no keys, no game save part) / 'net' multiplayer / 'tool' a one-shot job.
|
|
159
157
|
- `label?: string` Display name (used by the loading screen)
|
|
160
158
|
- `requires?: string[]` Capabilities this depends on: slot names another module provides ('inventory', 'world', 'sky'), never a particular module. Missing throws with both fixes: install the engine's part of that name first, or your own module with provides: ['inventory']
|
|
161
159
|
- `provides?: (PictureSlot | (string & {}))[]` Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
|
|
@@ -164,7 +162,11 @@
|
|
|
164
162
|
- `before?: string[]` Hooks run before these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs earlier)
|
|
165
163
|
- `after?: string[]` Hooks run after these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs later)
|
|
166
164
|
- `critical?: boolean` The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of starting a broken game. Without it a failed init is reported by severity (type picture / ui: disabled and the game carries on; other types: error tiers) and start() goes on. Example: `engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })`
|
|
165
|
+
- `noSkip?: string` Why a module with a fixed hook has no skip hook: engine.catalog shows it instead of a warning
|
|
166
|
+
- `params?: any` The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it
|
|
167
|
+
- `docs?: string` Where its docs live, shown by engine.catalog
|
|
167
168
|
- `explain?: Record<string, (e: Engine, value: any, query: Record<string…` Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) }
|
|
169
|
+
- `stateKeys?: string[]` 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
|
|
168
170
|
- `install(e: Engine, ctx: ModuleCtx) → Api` — Install: create and return the object the game uses (engine.name). Register listeners / timers through ctx.track so they leave with the module (a use() batch that rolls back, a failed init, engine.dispose). Example: `install(e, ctx) { ctx.track(e.events.on('item:add', onAdd)); return api; }`
|
|
169
171
|
- `init(e: Engine, ctx: ModuleCtx) → void | Promise<void>` — Called at startup (download things, wait for assets); may be async. ctx is the same as install's
|
|
170
172
|
- `isReady(e: Engine) → boolean` — The loading screen waits until this returns true before disappearing (the hook is called isReady; in the engine ready is always a boolean property)
|
|
@@ -175,7 +177,7 @@
|
|
|
175
177
|
- `skip(dt: number, e: Engine, done: boolean)` — engine.skip moved time without stepping: advance your own time by dt fixed seconds (calendar seconds = dt x clock.speed), no per-step work. Called once per skip segment (segments end at timers and calendar clock marks); done is true on the last one: do expensive catch-up only then. Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
|
|
176
178
|
- `describe(e: Engine, ctx: DescribeContext) → any` — 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 returns nothing. It may also fill in the standard fields of ctx.out, or use ctx.near() to report "nearby things"
|
|
177
179
|
- `counts(e: Engine) → number | Record<string, number>` — Optional: leak-hunting counts for engine.counts(), put there under the module name (a number or an object of numbers that should not keep growing)
|
|
178
|
-
- `applyState(e: Engine, params: StateParams) → void | PositionLike | Promise<void>` — 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
|
|
180
|
+
- `applyState(e: Engine, params: StateParams) → void | PositionLike | { refused } | Promise<void>` — 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
|
|
179
181
|
- `dispose(e: Engine)` — Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers, Audio nodes you connected yourself. Events, onFixed / onFrame, clock timers, jobs, stream, ray registrations and GPU memory in the scene are reclaimed by the core; DOM listeners attached to engine.signal and UI attached to engine.uiRoot are cleaned up automatically too
|
|
180
182
|
|
|
181
183
|
## createEngine({ ui })
|
|
@@ -219,11 +221,11 @@
|
|
|
219
221
|
- `play?: string | boolean` Present (?play, any value): leave the title screen the way its Start does (engine.session.newGame(), the title part closes; flow leaves its start state) before wait; nothing when no title is up
|
|
220
222
|
- `fresh?: string | boolean` Delete every save of this page first (no Continue on the title); on a running page also end the run and go back to the title. ?fresh in the URL
|
|
221
223
|
- **StartupReport** Startup timing (milliseconds): totalMs page open to playable, startMs start() to playable, preloadMs preloading, streamMs the nearby builds required by stream registrations finished, compileMs shader compilation before the first frame, modules is the init / ready time of each module. With a budget on and startupMs (open to playable) / moduleMs (a single module) given, the slowest module is reported in the console when exceeded. firstFrameMs: page open to the end of the first frame drawn after the loading screen (null until that frame, and headless); phases add up to it: script (page open until createEngine), construct (createEngine), setup (game code until start()), init (saves, renderer, module init), preload, world (scenario parameters, nearby builds), compile (shaders + hidden warm-up frame), draw (ready until the first frame's draw calls were submitted)
|
|
222
|
-
- `totalMs: number`
|
|
223
|
-
- `startMs: number`
|
|
224
|
-
- `preloadMs: number`
|
|
225
|
-
- `streamMs: number | null`
|
|
224
|
+
- `totalMs: number` (experimental)
|
|
225
|
+
- `startMs: number` (experimental)
|
|
226
|
+
- `preloadMs: number` (experimental)
|
|
227
|
+
- `streamMs: number | null` (experimental)
|
|
226
228
|
- `compileMs: number`
|
|
227
229
|
- `modules: Record<string, { init?: number; ready?: number }>`
|
|
228
|
-
- `firstFrameMs: number | null`
|
|
229
|
-
- `phases: { script, construct, setup, init, preload, world, … }`
|
|
230
|
+
- `firstFrameMs: number | null` (experimental)
|
|
231
|
+
- `phases: { script, construct, setup, init, preload, world, … }` (experimental)
|