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/saves.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# engine.saves (Saves) — engine.saves handles saving
|
|
2
2
|
|
|
3
|
-
- `saves.register(key: string, provider: SaveProvider)` — Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later parts wait. version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current shape. A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept). A part registered after a save was loaded (a module installed later) is handed its data from that save at once.
|
|
4
|
-
- `saves.
|
|
3
|
+
- `saves.register(key: string, provider: SaveProvider)` — Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later parts wait. version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current shape. A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept). A part registered after a save was loaded (a module installed later) is handed its data from that save at once. atomic: true joins this part to atomic ops: it is copied before an atomic op runs and put back if the op fails (plain data only; afterLoad does not run on rollback). Example: `engine.saves.register('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) }); // later the format gains beds: version 2, and a step that upgrades version-1 data engine.saves.register('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });`
|
|
4
|
+
- `saves.putAttachment(group: string, id: string, blob: Blob | (() => Promise<Blob>), meta?: any) → Promise<void>` — (experimental) Store a binary attachment outside the world save (a photo, a replay). It rides in the queue of save writes, so flush() waits for it, and exportFile() carries it. Pass a function to make the bytes when the write runs: flush() then waits for that too. Without IndexedDB it is not kept. Example: `await engine.saves.putAttachment('replay', 'run-1', blob, { score: 12 });`
|
|
5
|
+
- `saves.removeAttachment(group: string, id: string) → Promise<void>` — (experimental) Delete an attachment; no such id is fine
|
|
6
|
+
- `saves.attachments(group: string) → Promise<{ group: string; id: stri…` — (experimental) The attachments of a group, once storage is ready. Empty without IndexedDB.
|
|
7
|
+
- `saves.storageKey(name: string) → string` — A localStorage key for what belongs to this game but is not a save (settings, a last-used tab): it shares the game's name, so two games on one site stay apart, and stays out of list(). Example: `localStorage.setItem(engine.saves.storageKey('lastTab'), 'map');`
|
|
5
8
|
- `saves.flush() → Promise<void>` — Wait for all queued disk writes to finish (for tests and before the page closes)
|
|
6
9
|
- `saves.collect() → { format, savedAt, versions, parts }` — Collect the data of every part (does not write to the browser): { format, savedAt, versions, parts }. A part whose save() throws is left out and reported (engine.error in dev); save() instead refuses to write such a save.
|
|
7
10
|
- `saves.check(slot?: string) → null | "missing" | "corrupt" | "tooNew" | "migrate"` — Can this slot be loaded? null when it can, else why not (checked without touching the game): 'missing' / 'corrupt' (unreadable) / 'tooNew' (a newer save format or part) / 'migrate' (an upgrade step is missing or throws). Example: `if (engine.saves.check('slot1') === 'tooNew') showUpdateHint();`
|
|
@@ -10,14 +13,13 @@
|
|
|
10
13
|
- `saves.load(slot?: string) → Promise<boolean>` — Load a slot onto the running playthrough (a quick load: what the game added during play stays) and resolve true on success; the 'save:loaded' event fires on success. A missing slot resolves false; a corrupt / too new / unmigratable save resolves false with a toast and changes nothing; a part whose load throws rolls the game back. To continue or retry with nothing of the current playthrough left over, use engine.session.load(slot). Example: `if (!(await engine.saves.load('quick'))) toast(engine, 'No quick save');`
|
|
11
14
|
- `saves.list() → { slot: string; savedAt: number }[]` — All slots, newest first (synchronous, reads the in-memory index)
|
|
12
15
|
- `saves.remove(slot: string) → Promise<void>` — Delete a slot. Returns a Promise (disk write done); awaiting is optional
|
|
13
|
-
- `saves.export(slot?: string) → string` — Export as a piece of text (can be copied as a backup; synchronous, without binary attachments)
|
|
16
|
+
- `saves.export(slot?: string) → string` — (experimental) Export as a piece of text (can be copied as a backup; synchronous, without binary attachments)
|
|
14
17
|
- `saves.import(text: string, slot?: string) → Promise<boolean>` — Import text from export() into a slot (default 'imported'); checked like importFile and written before it resolves. Resolves true once stored (save:imported fires), false when the text is not a save or the write failed. It does not load the slot.
|
|
15
|
-
- `saves.exportFile(slot?: string, opts?: { files?: boolean }) → Promise<boolean>` — Download a save file (.json): the save plus every binary attachment (as data: text, so the file is larger; { files: false } exports the save only). Restores everything when browser data is wiped on a phone. Returns Promise<boolean>. Example: `engine.saves.exportFile('slot1');`
|
|
18
|
+
- `saves.exportFile(slot?: string, opts?: { files?: boolean }) → Promise<boolean>` — (experimental) Download a save file (.json): the save plus every binary attachment (as data: text, so the file is larger; { files: false } exports the save only). Restores everything when browser data is wiped on a phone. Returns Promise<boolean>. Example: `engine.saves.exportFile('slot1');`
|
|
16
19
|
- `saves.importFile(file?: Blob, slot?: string) → Promise<string | null>` — Restore from a save file into slot (default 'imported', so a shared file never overwrites 'auto'). file is a File / Blob; omit it to open a file picker. Everything is checked first (file marker and format, the save inside, attachments must be data: URLs: nothing is fetched). Returns the slot name on success, and null if cancelled, the file is invalid or the write failed (a toast was already shown). It restores the slot only and does not load it.
|
|
17
20
|
- `saves.autosave(minutes?: number) → { remove(): void }` — Autosave into 'auto' every `minutes` minutes of play: counted in fixed seconds, so it waits while paused, frozen or in a menu that freezes the game, and it never saves while no playthrough runs (the title screen, during newGame / load / quit) or after a gameplay error. Returns a handle; remove() stops it. Calling it again replaces the previous autosave. Example: `engine.saves.autosave(3); // once at boot: it waits by itself while no playthrough runs`
|
|
18
21
|
- Properties:
|
|
19
|
-
- `
|
|
20
|
-
- `store: { mode, blobs, putBlob, deleteBlob }` Storage layer: saves in the IndexedDB slots store, attachments (by group, e.g. 'photo') in the blobs store; mode 'localStorage' without IndexedDB.
|
|
22
|
+
- `store: { mode, blobs, putBlob, deleteBlob }` (experimental) Storage layer: saves in the IndexedDB slots store, attachments (by group, e.g. 'photo') in the blobs store; mode 'localStorage' without IndexedDB.
|
|
21
23
|
- `ready: boolean` Has the save index been read into memory? (start() waits for it; game code rarely needs to care)
|
|
22
24
|
- `whenReady: Promise<void>` Resolves once the save index is in memory; await it only to list / load before start()
|
|
23
25
|
- `versions: Record<string, number>` The save versions this build reads, per part: { world: 1, clock: 1, ... }. A save whose part is newer is refused; an older one is migrated.
|
|
@@ -31,4 +33,3 @@
|
|
|
31
33
|
- `checkNewGame?: (data: any) => void` Dev only: called once start() finished with this part's data in the new-game state, to warn about what should not be there yet (world: records placed by code)
|
|
32
34
|
- `version?: number` This part's format version, default 1: raise it by 1 when what save() returns changes shape. A save with a newer version is refused
|
|
33
35
|
- `migrate?: Record<number, (data: any, save: { parts: Record<string, an…` Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }. The second argument is the whole save as read ({ parts, versions }, read only), for a step that depends on another part
|
|
34
|
-
- `movedFrom?: Record<string, (data: any) => any>` This part's data used to be saved under another part's name: { oldPart: data => newData } (newData in this version's shape). An old save without this part but with oldPart loads it here; oldPart is then dropped unless a registered part still owns that name
|
package/docs/api/settings.md
CHANGED
|
@@ -6,25 +6,26 @@ Settings menu (settings() module)
|
|
|
6
6
|
- `action?: string` Action that opens the menu, default the basic 'cancel' (Esc / pad B on an empty UI focus stack); another name is declared and the game binds it
|
|
7
7
|
- `storageKey?: string` Browser storage key
|
|
8
8
|
- `presets?: Record<string, QualityPreset>` Override the graphics presets: { low: {...}, medium: {...}, high: {...} }
|
|
9
|
-
- `sections?: boolean | string[]` Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY / camera.fov). Example: `settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })`
|
|
9
|
+
- `sections?: boolean | (string | { id: 'graphics'; omit: string[] })[]` Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY / camera.fov). Example: `settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })`
|
|
10
10
|
- `freezeWorld?: boolean` Pause gameplay while the menu is open (with flow installed it switches to flow's 'paused' and returns to the previous state on close; without flow it uses engine.freeze); the picture keeps running, default false
|
|
11
11
|
|
|
12
12
|
## Methods and properties
|
|
13
13
|
- `settings.get(key: string) → any` — Read a setting, e.g. get('vol.music')
|
|
14
14
|
- `settings.set(key: string, value: any, opts?: { save?: boolean })` — Change a setting (takes effect immediately + saved)
|
|
15
|
-
- `settings.preset(name: 'low' | 'medium' | 'high' | (string & {}))` — Graphics preset: 'low' / 'medium' / 'high'
|
|
15
|
+
- `settings.preset(name: 'low' | 'medium' | 'high' | (string & {}))` — (experimental) Graphics preset: 'low' / 'medium' / 'high'
|
|
16
16
|
- `settings.define(key: string, def: T, apply?: ((value, e) => void) | { apply?, limits? })` — Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row restricts on the settings layer, like the built-in shadows row: off holds it off (the scene, weather or a cutscene cannot turn it back on), on allows what the scene chose; a number row from 0 to 1 is a factor on a number value. Define it after the effect exists
|
|
17
17
|
- `settings.addSection(id: string, section?: SettingsSection)` — Add a tab of your own, or a built-in / optional one by name: addSection('camera')
|
|
18
|
-
- `settings.
|
|
18
|
+
- `settings.reset(key?: string)` — Put one setting (or all, with no key) back to its default: the engine's start value, or the default the game gave define(). Keys: resetBindings
|
|
19
|
+
- `settings.resetBindings()` — (experimental) Restore all keys to defaults
|
|
19
20
|
- `settings.rebind(action: string, code: string)` — Change the first key of an action to code
|
|
20
|
-
- `settings.actionList() → any[]` — Key list (for the UI)
|
|
21
|
+
- `settings.actionList() → any[]` — (experimental) Key list (for the UI)
|
|
21
22
|
- `settings.save()` — Save to the browser
|
|
22
|
-
- Also: `settings.
|
|
23
|
+
- Also: `settings.open()`, `settings.close()`, `settings.toggle(on?: boolean)`
|
|
23
24
|
- Properties:
|
|
24
|
-
- `values: Record<string, any>` All current setting values
|
|
25
|
+
- `values: Record<string, any>` All current setting values, read only (set() changes one). pixelRatio is the renderer's real ratio
|
|
25
26
|
- `presets: Record<string, QualityPreset>` Graphics presets
|
|
26
|
-
- `sections: Map<string, any>` Tabs
|
|
27
|
-
- `isOpen: boolean` Whether the menu is open
|
|
27
|
+
- `sections: Map<string, any>` (experimental) Tabs
|
|
28
|
+
- `isOpen: boolean` (experimental) Whether the menu is open
|
|
28
29
|
|
|
29
30
|
## Data structures
|
|
30
31
|
- **SettingsSection** One settings tab
|
package/docs/api/sky.md
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
# engine.sky — sky(opts?: SkyOptions)
|
|
2
2
|
|
|
3
|
-
Sky dome
|
|
3
|
+
Sky dome and the sun / daylight / sky-color signals, from the calendar's time; it writes no light or fog (sky() module)
|
|
4
4
|
|
|
5
|
-
- Options `SkyOptions` (also includes the fields of Pick<SkyPictureOptions, 'clouds' | 'backdrop' | 'keyframes' | 'sunSize' | 'sunGlow' | 'sunBrightness' | '
|
|
5
|
+
- Options `SkyOptions` (also includes the fields of Pick<SkyPictureOptions, 'clouds' | 'backdrop' | 'keyframes' | 'sunSize' | 'sunGlow' | 'sunBrightness' | 'moonColor' | 'moonBrightness' | 'starDensity' | 'dim'>):
|
|
6
6
|
- `time?: string | number` The fixed time of day drawn while no calendar() is installed: 'HH:MM' or 0–1 (0.5 noon), default 0.33 (a sunset arena: sky({ time: '18:30' })). With calendar() the sky draws engine.calendar.timeOfDay and this option throws (start the day with calendar({ time }))
|
|
7
7
|
|
|
8
8
|
## Methods and properties
|
|
9
9
|
- `sky.keyframes(rows: any[][])` — The day's colors, live: rows [time, zenith, horizon, sunColor, ambient] sorted from 0 to 1 (the same rows as sky({ keyframes })). Throws, changing nothing, on rows that are not sorted from 0 to 1. Example: `engine.sky.keyframes([[0, 0x101828, 0x202838, 0x8090b0, 0.3], [0.5, 0x4080c0, 0xc0d8e8, 0xffffff, 1.2], [1, 0x101828, 0x202838, 0x8090b0, 0.3]]);`
|
|
10
10
|
- `sky.clouds(spec: string | { glsl?, tsl?, uniforms? } | null)` — Your own cloud function on the dome: glsl defines `vec4 threedogClouds(vec3 dir, float time, vec3 sunDir, float night, vec3 lit, vec3 shade, float cover)`, tsl is its WebGPURenderer form (ctx) => vec4 node; each renderer needs its own form (modules/sky/clouds.js). null gives the built-in kind back. Recompiles the dome once: a scene change, not every frame. Example: `engine.sky.clouds({ glsl: 'vec4 threedogClouds(vec3 d, float t, vec3 s, float night, vec3 lit, vec3 shade, float cover){ return vec4(lit, step(0.5, threedogNoise(d.xz * 4.0)) * cover); }' });`
|
|
11
11
|
- `sky.layer(name: string, spec: string | { glsl?, tsl?, uniforms?, order?, blend? } | null | …)` — Add, change or remove (null) a named dome layer drawn after the clouds and stars: glsl defines `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returning (rgb, amount), tsl is its WebGPURenderer form (modules/sky/domeLayers.js). Recompiles the dome once. Example: `engine.sky.layer('aurora', { glsl: 'vec4 threedogSkyLayer(vec3 d, float t, vec3 s, float n){ return vec4(0.2, 1.0, 0.5, n * smoothstep(0.1, 0.6, d.y) * 0.4); }', blend: 'add' });`
|
|
12
|
-
- `sky.replace(sky: string | import("three").Texture | THREE.Object3D |
|
|
13
|
-
- `sky.environment(options?: { into?, interval? }) → { texture, remove }` — Render the sky into an environment map. Only after this call is anything built: a PMREM target, rebuilt when the sky changed and interval seconds passed (default 1, 4
|
|
12
|
+
- `sky.replace(sky: string | import("three").Texture | THREE.Object3D | …)` — Replace or hide the dome: a skybox asset name (equirectangular panorama), a THREE.Texture / CubeTexture, or your own THREE.Object3D sky; null gives the dome back, false draws no sky (the scene shows its base background, the signals keep running). The engine never writes your object: it hides the dome, adds your object to the scene only when it has no parent, puts a plain texture's panorama mapping on a clone, and keeps feeding engine.uniforms (uSunDir, uWind ...). Example: `engine.sky.replace(new SkyMesh());`
|
|
13
|
+
- `sky.environment(options?: { into?, interval? }) → { texture, remove }` — Render the sky into an environment map. Only after this call is anything built: a PMREM target, rebuilt when the sky changed and interval seconds passed (default 1, 4 on a low-tier device). With into, that object's .environment gets the map at each rebuild (a map you wrote there yourself stays); without it nothing is written anywhere and you read handle.texture. handle.remove() takes the map off and frees it. One at a time. Intensity and rotation are three.js: scene.environmentIntensity. Example: `const env = engine.sky.environment({ into: engine.scene });`
|
|
14
14
|
- Properties:
|
|
15
15
|
- `fixedTime: number` The time of day drawn while no calendar is installed (0-1; sky({ time: '17:30' }) or applyState({ time })); with engine.calendar the sky draws the calendar's time and this is unused
|
|
16
16
|
- `seasonTints: import("../../../world").SeasonTints | null` What each calendar season tints the plants and ground, read every frame, or null for no tint: plain data the game's picture/ code writes
|
|
17
17
|
- `dim: { tint: boolean; stars: boolean }` What the sky dims for every game, plain fields read each frame (a fantasy sky can stay bright at night, keep its stars through clouds): tint false keeps a sky.tint color at full strength at any hour, stars false keeps the stars through the weather's cover
|
|
18
18
|
- `top: any` Zenith color over the keyframes, any THREE.Color input (null = the keyframes); read each frame
|
|
19
19
|
- `horizon: any` Horizon color over the keyframes, any THREE.Color input (null = the keyframes); read each frame. The color drawn: engine.uniforms.uSkyHorizon
|
|
20
|
+
- `uniforms: Record<string, { value: any }>` The dome's { value } objects, live on both renderers: the built-in ones (the same objects as engine.uniforms where the names match) and the uniforms given to engine.sky.clouds() and engine.sky.layer(), which join here once the call has run
|
|
20
21
|
- `dome: THREE.Object3D` Dome mesh
|
|
21
|
-
- `sunDir: THREE.Vector3` Sun direction (unit vector toward the sun)
|
|
22
22
|
- `orbit: { tilt: number; sway: number; distance: number }` Sun orbit: tilt = north-south tilt, sway = east-west swing, distance = light distance (meters)
|
|
23
|
+
- `sunDir: THREE.Vector3` Sun direction (unit vector toward the sun): the same vector as engine.uniforms.uSunDir. Computed each frame from the time and orbit until a game writes either, then the value is the game's (the sun at a compass direction of your choice); engine.autoView.manual('sunDir', false) gives it back.
|
|
23
24
|
- `backdrop: any` One flat color in place of the dome, a THREE.Color while on, else null (sky({ backdrop }) starts with one). Set any THREE.Color input, null gives the dome back.
|
|
24
|
-
- `drawnTime: any` Time of day being drawn, 0-1: engine.calendar.timeOfDay, or fixedTime without a calendar. Read-only: the time itself is the calendar's
|
|
25
|
-
- `sunHeight: number` Sun elevation -1 (midnight) ... 0 (horizon) ... 1 (noon) of the drawn sun (the calendar's daylight is the gameplay value)
|
|
25
|
+
- `drawnTime: any` (experimental) Time of day being drawn, 0-1: engine.calendar.timeOfDay, or fixedTime without a calendar. Read-only: the time itself is the calendar's
|
|
26
|
+
- `sunHeight: number` (experimental) Sun elevation -1 (midnight) ... 0 (horizon) ... 1 (noon) of the drawn sun (the calendar's daylight is the gameplay value)
|
|
26
27
|
- `isDay: boolean` Whether the drawn sun is above the horizon (picture functions: ({ sky }) => sky.isDay ? ...; gameplay reads engine.calendar.isDay)
|
|
27
28
|
- `daylight: number` Daylight of the drawn sun 0-1 (0 at night, 1 at noon)
|
package/docs/api/stream.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# engine.stream (Stream) — engine.stream builds on demand by space: only entries near the focus get built
|
|
2
2
|
|
|
3
3
|
- `stream.add(def: StreamEntryOptions) → StreamHandle` — Register something to stream in (not built at once); an object returned by build with no parent is added to the scene automatically. Example: `engine.stream.add({ position: [40, 0, 12], radius: 6, build: () => makeHouse() });`
|
|
4
|
-
- `stream.setRadius(m: number)` — Set the build radius in meters
|
|
4
|
+
- `stream.setRadius(m: number)` — (experimental) Set the build radius in meters
|
|
5
5
|
- `stream.source(position: any, opts?: StreamSourceOptions) → StreamSource` — (experimental) Add a stream source: the world around position is loaded (terrain chunks, colliders, nearby models, stream entries) until remove() or until. position may be live (an Object3D or Vector3 that moves) or a function. detail 'simple' loads only terrain and hlod proxies (a far view); physics defaults to true for 'full'; pass false for a camera that only needs a picture. radius caps every loader's range (default: each loader's own range). until: a Promise (removed when it settles) or a function checked every frame (removed when it returns true). Example: `const dest = engine.stream.source([800, 0, 300], { radius: 64 }); await dest.whenReady; engine.player.placeAt([800, 0, 300]); dest.remove();`
|
|
6
6
|
- `stream.teleport(position: any, opts?: { radius?, move?, timeout? }) → Promise<void>` — (experimental) Load the destination first, then move: resolves after the player (engine.focus without one) is placed. Until the destination is ready (terrain chunks, collision, nearby models) the player stays where it is. move replaces the default placement (for a vehicle or a custom character). timeout (seconds of frame time, default 60; Infinity waits forever): when the destination is still not ready, the Promise rejects (code stream-timeout, naming the loaders still waiting) and the player is not moved. Example: `await engine.stream.teleport([800, 0, 300]);`
|
|
7
|
-
- `stream.
|
|
7
|
+
- `stream.addReadyCheck(name: string, fn: (source: StreamSource) => boolean) → { remove(): void }` — (experimental) Register a readiness check for loaders: fn(source) returns whether this loader finished what that source asks for. For module authors whose loader reads stream sources; games only read source.ready. Example: `engine.stream.addReadyCheck('props', s => s.detail !== 'full' // props.queued === 0)`
|
|
8
8
|
- `stream.sources(pick?: { detail?, physics? }) → StreamSource[]` — (experimental) Sources with fresh positions, filtered: { detail: 'full' } for models and stream entries, { physics: true } for colliders, no filter for terrain
|
|
9
9
|
- Properties:
|
|
10
|
-
- `radius: number | null` Build radius in meters around each full-detail stream source (a source radius caps it); null = follow the terrain view distance (the fog distance the fog distance without terrain)
|
|
11
10
|
- `cellSize: number` Grid cell edge in meters, shared with hlod, default 64
|
|
12
|
-
- `unloadFactor: number` Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25
|
|
13
|
-
- `player: StreamSource` Built-in source at the
|
|
11
|
+
- `unloadFactor: number` (experimental) Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25
|
|
12
|
+
- `player: StreamSource` Built-in source at the player (engine.focus without one): full detail and physics
|
|
14
13
|
- `camera: StreamSource` Built-in source at the camera focus engine.focus: full detail, no physics
|
|
15
|
-
- `activeRadius: number` The build radius actually in use, in meters
|
|
14
|
+
- `activeRadius: number` (experimental) The build radius actually in use, in meters
|
|
15
|
+
- `radius: number | null` Build radius in meters around each full-detail stream source (a source radius caps it); null = follow the terrain view distance (the uViewDistance signal without terrain). Writing it takes effect like setRadius.
|
|
16
16
|
- `ready: boolean` Everything registered within radius is built (start() waits for it before the loading screen goes away)
|
|
17
17
|
- `stats: { entries: number; built: number; queued: number }` entries is the registered count, built the built count, queued the queued count
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- `position: PositionLike` Position (Vector3 / object / [x, y, z] / { x, z }; only the horizontal coordinates count)
|
|
22
22
|
- `radius?: number` Object size (meters); larger ones are built earlier
|
|
23
23
|
- `build: () => Object3D | Promise<Object3D>` Generate the object (called when entering range, run spread over frames through engine.jobs)
|
|
24
|
-
- `dispose?: (obj: Object3D) => void` Unload (called when leaving range), default engine.remove (
|
|
24
|
+
- `dispose?: (obj: Object3D) => void` Unload (called when leaving range), default engine.remove (frees what nothing else in the scene uses); write your own when the object is reused (e.g. engine.detach)
|
|
25
25
|
- `keep?: boolean` Do not unload even when out of range
|
|
26
26
|
- `priority?: number` Build order: larger first (nearer first within the same priority), default 0
|
|
27
27
|
- **StreamHandle** Handle returned by stream.add(): object is the generated object (null while not generated)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# engine.swarm — swarm()
|
|
2
|
+
|
|
3
|
+
(experimental) Makes a swarm of same-kind gameplay objects (swarm() module): engine.swarm({ name, capacity, geometry, material, fields })
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
|
|
8
|
+
## Data structures
|
|
9
|
+
- **SwarmOptions** Options of engine.swarm(). See recipes/65-swarm.md
|
|
10
|
+
- `name: string` Unique name: shown in describe(), the key in a save
|
|
11
|
+
- `capacity: number` Most objects alive at once; all memory is taken up front
|
|
12
|
+
- `geometry?: import('three').BufferGeometry` Plain three.js geometry, stays the game's to dispose. Leave out with material for a swarm that draws nothing
|
|
13
|
+
- `material?: import('three').Material` Plain three.js material, stays the game's to dispose
|
|
14
|
+
- `fields?: string[]` Number columns beside x, y, z. yaw, pitch, roll (radians, order YXZ) and scale are also drawn by the engine
|
|
15
|
+
- `color?: boolean` Per-object colour: columns r, g, b (linear) and spawn({ color: 0xff8800 })
|
|
16
|
+
- `channel?: string` Time channel of the onStep dt (default 'world')
|
|
17
|
+
- `cell?: number` Grid cell for near, in meters: about the usual query radius (default 2)
|
|
18
|
+
- `save?: boolean` Keep this swarm in saves; otherwise it is empty after a load or new game
|
|
19
|
+
- **Swarm** One swarm: what engine.swarm(options) returns. See the top of modules/swarm/Swarm.js for the handle / row rule
|
|
20
|
+
- `name: string` Name given to engine.swarm
|
|
21
|
+
- `capacity: number` Most objects alive at once
|
|
22
|
+
- `channel: string` Time channel of the onStep dt
|
|
23
|
+
- `saved: boolean` Whether this swarm is kept in saves
|
|
24
|
+
- `dropped: number` Spawns refused because the swarm was full, since it was made
|
|
25
|
+
- `data: SwarmData` The columns: data.x[row], data.y[row], data.z[row] (Float32Array), one Float64Array per field, so a field can hold a handle, and data.id[row], the handle of that row (Float64Array). Rows 0 to count - 1 are live. The same object onStep and near pass as d
|
|
26
|
+
- `mesh: THREE.InstancedMesh | null` The swarm's plain THREE.InstancedMesh (null when made without geometry and material); instance index = row. castShadow, layers and the rest are yours
|
|
27
|
+
- `count: number` Objects alive now
|
|
28
|
+
- `spawn(o?: Record<string, number>) → number` — Add one object. Fields left out start at 0 (scale at 1, colour at white). Returns its handle, or -1 when the swarm is full: the object is not added, dropped goes up, and one [swarm-full] warning is printed. May be called from onStep and near callbacks; an object spawned there first moves in the next step. Example: `const h = bullets.spawn({ x: 0, y: 1, z: 0, vx: 8, life: 2 });`
|
|
29
|
+
- `row(handle: number) → number` — Where a handle's object sits now, or -1 if it is gone. A row is good until the next removal outside a callback: read it, use it, drop it. Example: `const i = enemies.row(target); if (i >= 0) aim(enemies.data.x[i], enemies.data.z[i]);`
|
|
30
|
+
- `free(handle: number) → boolean` — Remove an object by handle: d.id[i] inside a callback. False if it was already gone (safe to call twice; -1 from a full spawn too). A row passed by mistake throws [swarm-handle]. Inside onStep and near the object counts as gone at once (near and row skip it) and rows only move when the walk ends. Example: `enemies.near(x, z, 2, (d, i) => { enemies.free(d.id[i]); });`
|
|
31
|
+
- `onStep(fn: SwarmRowFn) → { remove(): void }` — Set the one function that moves this swarm: fn(d, i, dt) for each live row, every fixed step, dt on the swarm's channel. Return false to remove the object; anything else keeps it. Returns a handle: h.remove() takes it off. Set it once at setup, not every step (a second one while one is set throws [swarm-step]). Example: `bullets.onStep((d, i, dt) => { d.x[i] += d.vx[i] * dt; return (d.life[i] -= dt) > 0; });`
|
|
32
|
+
- `near(x: number, z: number, r: number, cb: (d, i, dist2) => (boolean | void)) → number` — Visit the live objects within r meters of (x, z), height ignored: cb(d, i, dist2) with the row and the squared distance; cb returning false stops early. Returns how many were visited. The grid is built on the first query after things moved, so a swarm nobody queries pays nothing. Order is the same every run. Inside onStep it stays the grid of that step's first query: distances are exact, but a row that crossed a cell line since then can be missed for one step. Example: `const hit = enemies.near(px, pz, 0.5, (d, i) => { enemies.free(d.id[i]); return false; });`
|
|
33
|
+
- `clear()` — Remove every object (their handles die for good). Inside a callback it applies when the walk ends
|
|
34
|
+
- `dispose()` — Remove this swarm: its mesh leaves the scene and its GPU buffers go. Geometry and material stay, they are the game's. The name is free again
|
package/docs/api/terrain.md
CHANGED
|
@@ -13,23 +13,22 @@ Procedural terrain, data part (terrain() module: chunks, heights, edits, collisi
|
|
|
13
13
|
|
|
14
14
|
## Methods and properties
|
|
15
15
|
- `terrain.recolor(o?: TerrainRecolor)` — Change at run time what terrain({...}) baked in. colors, biomeColors, steep, variation, shading, normals rebuild every chunk (edits stay); detail only patches the engine's material. Throws under a draw part that replaced 'terrain-draw'. Example: `engine.terrain.recolor({ colors: { grass: 0x6a8a3a }, biomeColors: { meadow: ['grass'] } });`
|
|
16
|
-
- `terrain.setViewChunks(n: number)` — Change the view distance (in chunks); camera far plane and, with viewFog, uViewDistance adjust too
|
|
17
|
-
- `terrain.setDensity(d: number)` — Change the vegetation density: plants are placed again on the loaded chunks; the ground and its collision stay
|
|
18
|
-
- `terrain.view(hooks: { add?, change?, remove?, show? }) → { remove(): void }` — Draw these chunks: the hooks a draw part that replaces 'terrain-draw' uses. add(c): generated (c.data holds pos / nor / col / uv / tex arrays, c.cx / c.cz the chunk); change(c): an edit rewrote c.data (
|
|
16
|
+
- `terrain.setViewChunks(n: number)` — (experimental) Change the view distance (in chunks); camera far plane and, with viewFog, uViewDistance adjust too
|
|
17
|
+
- `terrain.setDensity(d: number)` — (experimental) Change the vegetation density: plants are placed again on the loaded chunks; the ground and its collision stay
|
|
18
|
+
- `terrain.view(hooks: { add?, change?, remove?, show? }) → { remove(): void }` — Draw these chunks: the hooks a draw part that replaces 'terrain-draw' uses. add(c): generated (c.data holds pos / nor / col / uv / tex arrays, c.cx / c.cz the chunk); change(c): an edit rewrote c.data (the vertex count can differ on the rim of a shape with diagonal 'adaptive'); remove(c): released; show(c, visible): in view or not. Chunks already loaded are added at once. Returns { remove() } (ctx.track it). Example: `ctx.track(engine.terrain.view({ add(c) { draw(c) }, remove(c) { undraw(c) } }))`
|
|
19
19
|
- `terrain.retry() → number` — Send chunks that failed every try (terrain:chunkFailed) again, e.g. after fixing what their rule reads. Returns how many were queued
|
|
20
20
|
- `terrain.rebuild()` — Rebuild all chunks
|
|
21
21
|
- `terrain.edit(position: PositionLike, opts: TerrainEditOptions) → { heights: number; cells: number }` — (experimental) Change the ground: dig, raise, flatten, paint the ground type. Saved gameplay state: call it from an op or a fixed step. engine.surface / slope / groundType, collision, paths and vegetation follow at once; it is saved, and chunks generated later come out edited. Example: `engine.terrain.edit(pos, { radius: 3, lower: 1.5 }); // dig a pit engine.terrain.edit(pos, { shape: 'square', radius: engine.terrain.cellSize / 2, paint: 'tilled' }); // till one cell`
|
|
22
|
-
- `terrain.isReadyAround(position: PositionLike, opts?: { rings?: number }) → boolean` — Whether the chunks within rings rings (default 1) around position are all loaded
|
|
23
22
|
- Properties:
|
|
24
|
-
- `
|
|
23
|
+
- `generator: TerrainGen` Pure-computation terrain (height, landform), what createTerrain() returns
|
|
25
24
|
- `material: Material | null` The plain three.js material every chunk draws with (null under a draw part that replaced 'terrain-draw'). The neutral one takes direct writes; setting one swaps it on every loaded chunk and draws it as given. Nothing is regenerated, collision is untouched. Chunks carry position, normal, color and uv (world xz / chunk size). Example: `engine.terrain.material = applyEffects(new THREE.MeshStandardMaterial({ vertexColors: true }), { patches: engine.terrain.patches });`
|
|
26
25
|
- `patches: ShaderPatch[]` The engine's ground patches (world, clouds, season, detail), so a game material keeps them: applyEffects(mat, { patches: engine.terrain.patches })
|
|
27
26
|
- `uniforms: Record<string, { value: any }>` The detail layer's { value } uniforms, written directly and live: uDetailStrength, uDetailScale, uDetailTint... ({} without a detail layer)
|
|
28
|
-
- `
|
|
27
|
+
- `chunkSize: number` Chunk edge length (meters), the same value as the chunkSize option and ground.chunkSize
|
|
29
28
|
- `voidY: number` terrain({ shape }) only: below this height the player or a moving rigid body has fallen out of the world (one terrain:void per fall). shape.voidY, else 50 m under the lowest island chunk loaded so far; -Infinity without a shape. Example: `engine.events.on('terrain:void', ({ who }) => { if (who === engine.player) engine.player.placeAt(home); });`
|
|
30
29
|
- `chunks: Map<string, TerrainChunk>` Loaded chunks: 'cx,cz' → chunk
|
|
31
|
-
- `viewChunks: number` View distance (in chunks)
|
|
32
|
-
- `density: number` Vegetation density multiplier
|
|
30
|
+
- `viewChunks: number` (experimental) View distance (in chunks); writing it takes effect like setViewChunks
|
|
31
|
+
- `density: number` Vegetation density multiplier; writing it takes effect like setDensity
|
|
33
32
|
- `applyBudgetMs: number` Time budget (milliseconds) for uploading chunks per frame
|
|
34
33
|
- `stats: { builtThisFrame, applyMs, queued, failed, visible?, loaded?, … }` Statistics (for the debug panel); failed = chunks that failed every try (terrain:chunkFailed)
|
|
35
34
|
- `cellSize: number` Grid spacing (meters) = chunkSize / resolution: edits snap to it, paint colors whole cells of this size
|
package/docs/api/terrainDraw.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine.terrainDraw — terrainDraw()
|
|
2
2
|
|
|
3
|
-
Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it)
|
|
3
|
+
(experimental) Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
package/docs/api/timeline.md
CHANGED
|
@@ -9,8 +9,8 @@ Cutscenes, tweens (timeline() module)
|
|
|
9
9
|
- `timeline.play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions) → Promise<{ skipped: boolean }>` — Play a timeline; resolves with { skipped } when it ends
|
|
10
10
|
- `timeline.skip(run?: any)` — Skip all (or one) playing timelines
|
|
11
11
|
- Properties:
|
|
12
|
-
- `skipAll: boolean` Skip every cutscene immediately (set by scenario param cutscene=skip)
|
|
13
|
-
- `playing: boolean` Whether a cutscene is playing
|
|
12
|
+
- `skipAll: boolean` (experimental) Skip every cutscene immediately (set by scenario param cutscene=skip)
|
|
13
|
+
- `playing: boolean` (experimental) Whether a cutscene is playing
|
|
14
14
|
|
|
15
15
|
## Timeline steps (engine.timeline.play([...]))
|
|
16
16
|
- **TimelineStep** Timeline steps (run in order), which can be any of the following:
|
package/docs/api/tools.md
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
# Utility functions (imported from threedog)
|
|
2
2
|
|
|
3
3
|
- `PICTURE_SLOTS: Readonly<Record<PictureSlot, { readonly what: str…` — The picture slots: what each one is and which describe('picture').picture.writers names it covers (a name ending in '.' covers everything under it)
|
|
4
|
-
- `weather(opts?: WeatherOptions) → [ModuleDef<Weather>, ModuleDef<im…` — Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its picture (engine.weatherDraw, type 'picture';
|
|
4
|
+
- `weather(opts?: WeatherOptions) → [ModuleDef<Weather>, ModuleDef<im…` — Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its picture (engine.weatherDraw, type 'picture'; sky optional)
|
|
5
5
|
- `presets: { weather, calendar, player, interactions, bindings, camera }` — Opt-in gameplay presets: named option objects a game picks on purpose (the engine never applies one itself). Each only bundles options the game could write; spread and override: weather({ ...presets.weather.temperate, autoPool: ['clear', 'rain'] })
|
|
6
6
|
- `world(opts?: { cellSize?, radius?, farEvery?, farMaxPerTick?, buildPerFrame? }) → import("../../../core").ModuleDef…` — World data module: installed as engine.world. Put things here that must be saved, survive level changes and keep changing while far away; models are only built while nearby
|
|
7
7
|
- `net(opts?: { role, transport, sync?, syncEvery?, keepAlive?, rate?, … }) → import("../../../core").ModuleDef…` — (experimental) Optional co-op multiplayer: one host owns the state, clients mirror it and ask for changes through ops. Installed as engine.net. Host: peers' requests run as `ops.run(name, args, { source: 'net', actor })` only for ops defined with net: 'peer', with the op's args shape checked, the optional owner check, and a per-peer rate limit; the result comes back after the state diff that contains it. State: world records, containers, vars and the other save parts are sent as a snapshot on join and as diffs every syncEvery steps. Client: ops.run of a peer op returns { ok: true, pending: true, seq } (watch state or the net:result event, not the return value); its own avatar moves locally and is sent to the host (clamped to maxSpeed); other avatars glide between updates.
|
|
8
8
|
- `fakeNetwork(opts?: { latency?, jitter?, loss?, seed?, manual? }) → { host, connect, advance, now, loss, latency, … }` — (experimental) An in-process network for tests and offline demos: one host and any number of clients in the same page, with optional latency, jitter and loss. Messages are deep-copied on send (no shared objects, like a real wire). Order per link is kept, as on a WebSocket. manual: true delivers only when you call advance(ms) (deterministic tests); otherwise messages land after real time. connect({ heartbeat }) turns on the ping / pong check for that client (off by default here so loss and jitter replay the same); a client's cut() kills its link silently in both directions, which only the heartbeat notices (then the client gets 'close' and the host 'leave').
|
|
9
9
|
- `webSocket(url: string, { host, key, heartbeat, reconnect }?: { host?, key?, heartbeat?, reconnect? }) → { send, on, close, key, id }` — (experimental) WebSocket transport: talks to the relay in packages/tools/net-relay.mjs (`node packages/tools/net-relay.mjs 8787`). The host joins a room with host: true; clients join the same room. The relay assigns peer ids and remembers each client's key for reconnects. Messages are JSON. For a dedicated server or Colyseus, write another transport with the same send / on / close shape instead. heartbeat (ms, default 2000, 0 = off): ping the relay that often; 3 intervals with nothing received closes the link and emits 'close'. reconnect (clients only, default false): after a close, open again with the same key, waiting 0.5 s, 1 s, 2 s ... up to 15 s between tries; 'open' fires again on success (net() then asks the host for a full snapshot).
|
|
10
10
|
- `grids(opts?: GridsOptions) → import("../../../core").ModuleDef…` — (experimental) Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers). Options: ok, bad, previewOpacity, previewHeight (the preview box), tiles, tileLift (layer tiles). The materials are pv.material and layer.material.
|
|
11
|
+
- `swarm() → import("../../../core").ModuleDef` — (experimental) Module: many same-kind gameplay objects in typed arrays, drawn as one InstancedMesh each. After engine.use(swarm()), engine.swarm(options) makes one and returns a Swarm. Bullets, enemy crowds, pickups, debris. See recipes/65-swarm.md
|
|
11
12
|
- `screenToGround(engine: Engine, ndcX: number, ndcY: number, opts?: { maxDistance?: number }) → Vector3 | null` — Screen coordinates (-1..1) -> point on the ground; null if the ray misses the ground
|
|
12
|
-
- `EASINGS: Record<EaseName, (t: number) => number>` — All easing functions: name -> function
|
|
13
13
|
- `sampleGrid(data: ArrayLike<number>, opts: { width, height, cellSize?, size?, origin?, interp?, … }) → (x: number, z: number) => number` — A grid of numbers (height, moisture, density, walkable...) as a function (x, z) -> value. data[j * width + i] sits at origin + (i, j) * cell. interp 'nearest' = flat steps, 'linear' (default) = bilinear, 'cubic' = smooth (clamp: true avoids overshoot). Outside: edge value, or `outside`.
|
|
14
14
|
- `ease(e: Ease) → (t: number) => number` — Name or function -> easing function
|
|
15
|
-
- `checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean })` — Warn once about unknown keys in extensible data (your item / record definitions where players or mods add their own fields), with a "did you mean" hint. Options bags go through readParams instead (an unknown key throws in dev). loose only warns on near-misses.
|
|
15
|
+
- `checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean })` — (experimental) Warn once about unknown keys in extensible data (your item / record definitions where players or mods add their own fields), with a "did you mean" hint. Options bags go through readParams instead (an unknown key throws in dev). loose only warns on near-misses.
|
|
16
16
|
- `contentParts(modules: Record<string, { default: any } | a…) → any` — One content kind split over several files (content/props/forest.js, town.js…): joined in file-name order (arrays concatenated, objects merged, a key in two files an error), the same order content check and write-back use, with each entry's dev source line kept.
|
|
17
17
|
- `readParams(where: string, schema: Record<string, ParamSpec>, opts?: object) → T` — Module options read through a params schema: unknown keys and wrong types throw in dev with the fix, defaults are filled in. Also put params / options on the module definition so engine.catalog(name) shows them (recipes/51-capability-catalog.md).
|
|
18
18
|
- `threePatches: { list, off }` — Every change the engine makes to three.js classes, the game's three.js objects or its renderer (also in describe().threePatches). scope: what it reaches; lost: what stops when it is off (or why it cannot be). off(id) undoes an offable one for the whole page; others throw.
|
|
19
19
|
- `createTerrain(cfg?: Partial<TerrainConfig>) → TerrainGen` — Pure terrain computation (no engine needed), for previewing heights before start: createTerrain({ seed, ...terrainPreset() }).surface(x, z)
|
|
20
|
-
- `terrainMaterial(base?: THREE.Material | null, engine?: { assets: any }, { effects, detail }?: { effects?, detail? }) → THREE.Material` — Terrain material: base (default neutral with vertex colors) + cloud shadows + season tint + optional detail layer (detail: see DetailOptions; defaults scale 0.25, strength 0.35, top-down world projection, multiply). Pass the engine so its assets load a detail texture by name. effects: false returns your base as is (no engine patch at all, the vegetation.define({ effects: false }) word).
|
|
20
|
+
- `terrainMaterial(base?: THREE.Material | null, engine?: { assets: any }, { effects, detail }?: { effects?, detail? }) → THREE.Material` — (experimental) Terrain material: base (default neutral with vertex colors) + cloud shadows + season tint + optional detail layer (detail: see DetailOptions; defaults scale 0.25, strength 0.35, top-down world projection, multiply). Pass the engine so its assets load a detail texture by name. effects: false returns your base as is (no engine patch at all, the vegetation.define({ effects: false }) word).
|
|
21
21
|
- `mergeColored(parts: [THREE.BufferGeometry, ColorLike][], { flat }?: { flat?: boolean }) → THREE.BufferGeometry` — Merge several geometries into one vertex-colored geometry (a tree = trunk + canopy in one draw call): [[geometry, color], ...]. flat (default true): one normal per triangle, the faceted low-poly look; false keeps each part's own (smooth) normals. UVs are kept when every part has them, so the merged model can still take a texture.
|
|
22
22
|
- `applyEffects(material: THREE.Material, { wind, clouds, season, detail, lighting, engine, patches }?: { wind?, clouds?, season?, detail?, lighting?, engine?, … }) → THREE.Material` — Add effects to any material (the engine's or your own); returns the same material. The one entry for shader effects: wind (sway amplitude; the shadow sways too, nothing else to set up), clouds (drifting cloud shadows, default on; how dark is engine.uniforms.uCloudShadow), season ('foliage' / 'ground' seasonal tint), and patches: your own named patches (see ShaderPatch in render/patches.js), detail (grain / paper / strokes / a texture over the surface, see DetailOptions in render/detail.js; a texture given by asset name loads from `engine`, default the first live engine), lighting (light shaping: { wrap, shadowTint, rim }, or your own { glsl, uniforms }; see LightingOptions in render/lighting.js; materials with the same options share one program).
|
|
23
23
|
- `rampTexture(ramp: (number | import("../../common").…)[], soften?: number) → THREE.DataTexture` — The gradientMap of a toon material from `ramp` (grays or colors, dark to light) and `soften` (0 = hard bands, 1 = bands melt into each other). A gray number n is the light's strength in that band. three's toon reads only the red channel of this texture on both renderers; color entries tint the band under `celLighting` of threedog/tsl (WebGPU route).
|
|
24
24
|
- `bakeVertexAO(geometry: THREE.BufferGeometry, { samples, radius, strength, bias, occluders, seed }?: { samples?, radius?, strength?, bias?, occluders?, seed? }) → THREE.BufferGeometry` — Bake ambient occlusion into a geometry's vertex colors: each vertex casts `samples` rays over the hemisphere around its normal, and the share that hits the geometry (or an occluder) within `radius` darkens it. Creases, insides and parts tucked under other parts go dark; open sides stay as they were. The result multiplies the existing `color` attribute (white is added when there is none), so it works on `mergeColored` output and on any geometry drawn with `vertexColors: true`. Deterministic for a seed, so cached and baked models stay identical. Cost is vertices x samples ray casts (a 5k-vertex model at 32 samples is ~160k casts); run it inside a model generator, where it is cached. Resolution is per vertex: a large flat face with four corners gets no contact shadow in its middle (subdivide it, or bake a texture in Blender).
|
|
25
|
-
- `materialPatches(material: THREE.Material) → string[]` — Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
|
|
25
|
+
- `materialPatches(material: THREE.Material) → string[]` — (experimental) Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
|
|
26
26
|
- `toast(engine: Engine, text: string, { kind, ms }?: { kind?: string; ms?: number })` — Show a short message through the 'toast' UI part (default: top of the screen, gone after ms). A game restyles it, filters it by kind or turns it off with createEngine({ ui: { toast: false } }). kind says where it came from: 'info' (default), 'quest', 'item', 'save', 'error'.
|
|
27
27
|
- `makeWindow(engine: Engine, opts: WindowOptions) → UIWindow` — A toggleable window
|
|
28
28
|
- `worldToScreen(engine: Engine, pos: PositionLike) → ScreenPoint` — World coordinates (position or object) -> pixels from the canvas's top-left corner { x, y, onScreen, behind } (the UI root covers the canvas, so these place UI elements directly)
|
|
29
29
|
- `fadeScreen(engine: Engine, to: number, opts?: { seconds?: number }) → Promise<void>` — Fade the whole screen to `to` (0 clear ... 1 fully covered) over `seconds` (default 0.5); the Promise resolves when the fade ends. fadeScreen(engine, 1, 0.5) throws in dev: fadeScreen(engine, 1, { seconds: 0.5 })
|
|
30
|
-
- `uiFocus(engine: Engine) → UIFocus` — UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
|
|
31
|
-
- `toggleOnKey(engine: Engine, win: { open, toggle }, action: string)` — Window toggle key: call once per frame in a frame hook; opens on the action when closed, closes on another press when open
|
|
30
|
+
- `uiFocus(engine: Engine) → UIFocus` — (experimental) UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
|
|
31
|
+
- `toggleOnKey(engine: Engine, win: { open, toggle }, action: string)` — (experimental) Window toggle key: call once per frame in a frame hook; opens on the action when closed, closes on another press when open
|
|
32
32
|
- `parseClock(clock: string | number, hoursPerDay?: number) → number` — Clock time -> fraction of the day: parseClock('18:30') = 0.77; a number or numeric string ('0.25') is converted as is. hoursPerDay is hours per day, default 24
|
|
33
33
|
- `formatClock(t: number, hoursPerDay?: number) → string` — Fraction of the day -> 'HH:MM': formatClock(0.75) = '18:00'
|
|
34
|
-
- `inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number) → boolean` — Is time t (0-1, e.g. calendar.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by calendar.between and the audio rule condition { time: [from, to] }
|
|
34
|
+
- `inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number) → boolean` — (experimental) Is time t (0-1, e.g. calendar.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by calendar.between and the audio rule condition { time: [from, to] }
|
|
35
35
|
- `pickTarget(from: PositionLike, view: { x: number; z: number } | number, candidates: Iterable<T>, opts?: TargetOptions<T>) → T | null` — Best target in front: lowest "distance + angle off view × angleWeight" inside radius and cone. view is a direction { x, z } (cameraRig.forward()) or a facing angle. Returns the candidate or null
|
|
36
36
|
- `switchTarget(from: PositionLike, view: { x: number; z: number } | number, current: T | null, candidates: Iterable<T>, side: 1 | -1, opts?: Pick<TargetOptions<T>, 'radius' | '…) → T | null` — Next target to the right (side 1) or left (-1) of current as seen along view, wrapping; current missing → the leftmost. Returns a candidate or null
|
|
37
37
|
- `THREE` — three.js itself (any): `import { THREE } from 'threedog'`
|
|
@@ -58,18 +58,21 @@
|
|
|
58
58
|
- `behind: boolean`
|
|
59
59
|
|
|
60
60
|
## Other exported classes and functions
|
|
61
|
-
- `wind(position: Node, origin: Node, amplitude: Node | number) → Node` — GLSL vec3 threedogWind(vec3 position, vec3 origin, float amplitude): object-space sway offset, higher vertices sway more. position: object space before the instance transform (positionGeometry); origin: the object's world origin (objectOrigin()); amplitude: metres per metre of height. Reads uTime, uWind, uWindFreq.
|
|
62
|
-
- `cloudShadow(worldPos: Node) → Node` — GLSL float threedogCloudShadow(vec3 worldPos): light factor 0-1 under the drifting clouds (1 = no shadow). Reads uTime,
|
|
63
|
-
- `season(color: Node, kind: Node | 0 | 1) → Node` — GLSL vec3 threedogSeason(vec3 color, int kind): kind 0 foliage, 1 ground; tints by uFoliageTint / uGroundTint (mix mode when uFoliageMix / uGroundMix > 0). A vec4 color is read as its rgb.
|
|
64
|
-
- `objectOrigin() → Node` — World position of the drawn object's origin (an InstancedMesh: of each instance), vec3. Works for any Mesh / InstancedMesh sharing the material; BatchedMesh throws [tsl-misuse].
|
|
65
|
-
- `
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
68
|
-
- `
|
|
69
|
-
- `
|
|
70
|
-
- `
|
|
71
|
-
- `
|
|
72
|
-
- `
|
|
73
|
-
- `
|
|
74
|
-
- `
|
|
61
|
+
- `wind(position: Node, origin: Node, amplitude: Node | number) → Node` — (experimental) GLSL vec3 threedogWind(vec3 position, vec3 origin, float amplitude): object-space sway offset, higher vertices sway more. position: object space before the instance transform (positionGeometry); origin: the object's world origin (objectOrigin()); amplitude: metres per metre of height. Reads uTime, uWind, uWindFreq.
|
|
62
|
+
- `cloudShadow(worldPos: Node) → Node` — (experimental) GLSL float threedogCloudShadow(vec3 worldPos): light factor 0-1 under the drifting clouds (1 = no shadow). Reads uTime, uWeatherCloud, uCloudShadow*, uCloudShadowSpeed.
|
|
63
|
+
- `season(color: Node, kind: Node | 0 | 1) → Node` — (experimental) GLSL vec3 threedogSeason(vec3 color, int kind): kind 0 foliage, 1 ground; tints by uFoliageTint / uGroundTint (mix mode when uFoliageMix / uGroundMix > 0). A vec4 color is read as its rgb.
|
|
64
|
+
- `objectOrigin() → Node` — (experimental) World position of the drawn object's origin (an InstancedMesh: of each instance), vec3. Works for any Mesh / InstancedMesh sharing the material; BatchedMesh throws [tsl-misuse].
|
|
65
|
+
- `instanceOffset(offset: Node) → Node` — (experimental) An object-space offset carried through the drawn instance's rotation and scale (a plain Mesh: the offset as it is). A positionNode runs after the instance transform, so an offset meant for before it, like wind()'s, goes through this. BatchedMesh throws [tsl-misuse].
|
|
66
|
+
- `hash(p: Node) → Node` — (experimental) GLSL float threedogHash(vec2 p): a repeatable random number 0-1 from a 2D position.
|
|
67
|
+
- `noise(p: Node) → Node` — (experimental) GLSL float threedogNoise(vec2 p): smooth value noise 0-1, the one behind the engine's clouds and cloud shadows. No uniforms.
|
|
68
|
+
- `uniforms(engine: { uniforms: object }) → Record<string, Node>` — (experimental) engine.uniforms as TSL uniform nodes (uTime, uWind, uWeatherCloud, uFoliageTint, uSunDir, uDaylight ...), cached per engine. They read the same { value } objects, so engine.uniforms.uWind.value = 2 changes GLSL and TSL materials alike.
|
|
69
|
+
- `detailNoise(p: Node, kind: Node | 0 | 1 | 2 | 3, octaves: Node | number) → Node` — (experimental) GLSL vec4 threedogDetailNoise(vec2 p, int kind, float octaves): kind 0 grain, 1 paper, 2 stroke, 3 dabs; returns (gray rgb, height 0-1). No uniforms: p is any 2D pattern position you choose (world xz times a scale, a uv...). octaves: up to 4 (dabs: 3).
|
|
70
|
+
- `detailBump(surfPos: Node, surfNorm: Node, h: Node, k: Node | number, faceDir: Node | number) → Node` — (experimental) GLSL vec3 threedogDetailBump(vec3 surfPos, vec3 surfNorm, float h, float k, float faceDir): screen-space bump from a height h, strength k. View space; the result is a normal for material.normalNode.
|
|
71
|
+
- `wrapDiffuse(nl: Node, wrap: Node | number, lightColor: Node, shadow: Node | number, albedo: Node) → Node` — (experimental) GLSL vec3 threedogWrapDiffuse(float nl, float wrap, vec3 lightColor, float shadow, vec3 albedo): the half-lambert light beyond plain Lambert, to add to directDiffuse. nl = dot(normal, sunDir). Call it from your LightingModel's direct() (lightColor there already carries the shadow: pass shadow 1).
|
|
72
|
+
- `shadowTint(ambient: Node, tint: Node, strength: Node | number, soft: Node | number, nl: Node, shadow: Node | number) → Node` — (experimental) GLSL vec3 threedogShadowTint(vec3 ambient, vec3 tint, float strength, float soft, float nl, float shadow): the ambient with the shaded side's hue moved toward tint (brightness kept). shadow: 1 lit / 0 shadowed (the sun's lightNode.shadowNode); soft: terminator width in n.l.
|
|
73
|
+
- `rim(normal: Node, viewDir: Node, color: Node, strength: Node | number, power: Node | number, shadowSide: Node | number, nl: Node) → Node` — (experimental) GLSL vec3 threedogRim(vec3 normal, vec3 viewDir, vec3 color, float strength, float power, float shadowSide, float nl): edge light to add (viewDir from the surface to the eye, e.g. normalView and positionViewDirection); shadowSide 1 = only on the side facing away from the sun.
|
|
74
|
+
- `celLighting() → import('three/webgpu').LightingMo…` — (experimental) The lighting model for cel bands with colored ramps: assign it to a MeshToonNodeMaterial, whose gradientMap holds the ramp (rampTexture). A shadowed pixel reads the dark end of the ramp, so a cast shadow takes the same flat band and color as the side turned away. Without a gradientMap: two levels, as three's toon.
|
|
75
|
+
- `waterWave(p: Node, t: Node | number) → Node` — (experimental) GLSL float threedogWaterWave(vec3 p, float t): the built-in wave sum (height before waveHeight). p = world position * waveScale, t = time * waveSpeed.
|
|
76
|
+
- `waterSurface(spec?: { depth?, foam?, waveMax? }) → (base, wave, facing, worldPos, time) => Node` — (experimental) The built-in water surface as TSL: returns a function with the GLSL signature threedogWaterSurface(base, wave, facing, worldPos, time) -> vec4 (rgb, opacity). Only the parts given exist (depth: shallow / deep by viewing angle or wave height; foam on crests); values are numbers / colors or nodes. wave is waterWave's height, facing = 1 looking straight down.
|
|
77
|
+
- `waterFresnel(color: Node, normal: Node, viewDir: Node, strength: Node | number, towards: Node) → Node` — (experimental) The water's fresnel blend: color mixed toward `towards` (the engine uses the fog color) by pow(1 - /viewDir . normal/, 3) * strength, view space
|
|
75
78
|
- `serve(handler: (msg: any) => any)` — Start answering lane messages in a worker. handler is the same function the lane's local() returns on the main thread.
|
package/docs/api/vars.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# engine.vars (Vars) — engine.vars: story flags and counters (autosaved)
|
|
2
2
|
|
|
3
3
|
- `vars.flag(key: string) → any` — Read a flag
|
|
4
|
-
- `vars.setFlag(key: string, value?: any)` — Set a flag (default true)
|
|
4
|
+
- `vars.setFlag(key: string, value?: any)` — (experimental) Set a flag (default true)
|
|
5
5
|
- `vars.counter(key: string) → number` — Read a counter (0 if none)
|
|
6
6
|
- `vars.bump(key: string, n?: number) → number` — Counter +n (default 1), returns the new value
|
|
7
7
|
- Properties:
|
package/docs/api/vegetation.md
CHANGED
|
@@ -16,10 +16,11 @@ Vegetation (vegetation() module; grows on terrain or on any ground provider)
|
|
|
16
16
|
- `vegetation.rebuild()` — Place every chunk again: after changing the ground behind the same provider (a ground function reading game state). A new setGround or level is followed automatically
|
|
17
17
|
- `vegetation.setShadowRing(name: string, ring: number)` — Change at runtime how far a vegetation kind casts shadows: within `ring` chunk rings of the player (0 = only the chunk you stand in, 1 = the default, larger = further and dearer). Takes effect at once; the define() option shadowRing is only the starting value. An unknown name warns with the known ones. Example: `engine.vegetation.setShadowRing('tree', 0); // graphics setting "shadows: low": trees shadow only the nearest chunk`
|
|
18
18
|
- `vegetation.define(name: string, opts: VegetationOptions) → Species | Promise<Species>` — Define a kind of vegetation (a model name in model / lodGeometry: resolves first, so the result is a Promise of the species)
|
|
19
|
-
- `vegetation.
|
|
20
|
-
- `vegetation.
|
|
19
|
+
- `vegetation.isRemoved(species: string, cx: number, cz: number, id: number) → boolean` — (experimental)
|
|
20
|
+
- `vegetation.removeInstance(species: string, cx: number, cz: number, id: number, opts?: { regrowSeconds?: number }) → string` — Remove one (chop a tree). regrowSeconds: grows back after this many calendar seconds, 0 = permanent. The record is saved with the save (save key 'vegetation'). Returns the entry name
|
|
21
|
+
- `vegetation.restoreInstance(species: string, cx: number, cz: number, id: number)` — (experimental) Restore one
|
|
21
22
|
- `vegetation.instanceAt(position: PositionLike, opts?: { radius?, species? }) → VegetationHit | null` — The one nearest to position within radius meters (default 2) (species restricts to one kind), null if none
|
|
22
|
-
- Also: `vegetation.get(name: string) → Species | undefined`, `vegetation.list() → Species[]
|
|
23
|
+
- Also: `vegetation.get(name: string) → Species | undefined`, `vegetation.list() → Species[]`
|
|
23
24
|
- Properties:
|
|
24
25
|
- `material: Material | null` The shared default material: species with no material or model of their own draw it, as given, planted ones too; null gives the neutral default back. Until set, reading gives the neutral source of each species' own copy (only .color written there reaches them all). Throws when a game module drew the plants instead (replaces: 'vegetation-draw').
|
|
25
26
|
- `patches: any[]` The engine's plant patches (season tint, sway with one amplitude, vegetation.color() code) for applyEffects(myMaterial, { patches })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# engine.vegetationDraw — vegetationDraw()
|
|
2
2
|
|
|
3
|
-
Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it)
|
|
3
|
+
(experimental) Draws the plants (vegetation()'s drawing module, slot 'vegetation-draw'; undefined when a game replaced it)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
package/docs/api/water.md
CHANGED
|
@@ -17,7 +17,7 @@ Water surface (water() module)
|
|
|
17
17
|
- `patches: import("../../render/patches.js").ShaderPatch[]` The engine's water shader patches (waves, waterSurface when asked for, fresnel), so a game material keeps the behavior: applyEffects(mat, { patches: engine.water.patches })
|
|
18
18
|
- `uniforms: Record<string, { value: any }>` Shader values, written directly and live: uWave, uWaveScale, uWaveSpeed, uFresnel, uTime; with depthColor / foam uWaterShallow, uWaterDeep, uWaterCurve, uFoamColor, uFoamStart, uFoamEnd, uFoamOpacity; and what shader({ uniforms }) declared
|
|
19
19
|
- `bodies: Map<WaterBody, THREE.Mesh>` Water body → mesh
|
|
20
|
-
- `sea: THREE.Mesh | null` Global water mesh (null when absent)
|
|
20
|
+
- `sea: THREE.Mesh | null` (experimental) Global water mesh (null when absent)
|
|
21
21
|
- `material: THREE.Material` Water material, shared by all water. Reading gives the plain three.js material in use (a neutral MeshLambertMaterial until you set one); setting swaps it on every water mesh and draws it as given: no engine patch is added, so a material that should keep the waves goes through applyEffects(m, { patches: engine.water.patches })
|
|
22
22
|
|
|
23
23
|
## Data structures
|
package/docs/api/weather.md
CHANGED
|
@@ -4,7 +4,7 @@ Weather state (weather() module): the table, current values, set / setAuto, save
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
|
7
|
-
- `weather.
|
|
7
|
+
- `weather.defineField(field: string, spec: WeatherParticles | null) → WeatherParticleSystem | null` — Draw a field of the weather table with particles: your own (ash, petals, sparks) or rain / snow in place of the built-in ones. The amount each frame is weather.current[field], so they fade with the weather. spec takes the keys of weather({ rain }), or { create(engine, { area, count }) => { object, update?(amount, { camera, time, wind }) } } for a system of your own; null gives rain / snow back to weather({ rain, snow }) and removes any other field. Defining a field again replaces it. A field no type has throws with the table's fields. Example: `engine.weather.defineField('ash', { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 });`
|
|
8
8
|
- `weather.setAuto(on: boolean)` — Automatic weather on/off
|
|
9
9
|
- `weather.set(name: WeatherName, opts?: { seconds?: number })` — Switch weather. seconds: transition seconds, default 15; 0 switches at once (current is the new weather before the next step, so a screenshot or test right after shows all of it). Options in an object like every other engine call: set('rain', 20) throws [module-params] in dev (the old positional form). Example: `engine.weather.set('rain', { seconds: 20 })`
|
|
10
10
|
- `weather.label(name?: string) → string` — Display name of a weather (string table weather.<name>, falls back to the name itself); defaults to the current weather
|
|
@@ -12,13 +12,13 @@ Weather state (weather() module): the table, current values, set / setAuto, save
|
|
|
12
12
|
- `types: Record<string, WeatherPreset>` The weather types this game has: name -> numbers (the standard fields plus any of the game's own, all blended on change)
|
|
13
13
|
- `current: WeatherPreset` Current (mid-transition) weather parameters
|
|
14
14
|
- `name: string` Current weather name
|
|
15
|
-
- `
|
|
16
|
-
- `
|
|
17
|
-
- `
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
- `
|
|
21
|
-
- `lightning: (flash: number, engine: any) => number` Strike picture: flash (1 at the strike, fading in a third of a second) -> sky flash amount. Write it at any time
|
|
15
|
+
- `autoPool: string[]` (experimental) Candidates for automatic weather (repeat a name to make it likelier)
|
|
16
|
+
- `autoInterval: number[]` (experimental) Automatic weather interval [min, max] seconds
|
|
17
|
+
- `autoTransition: number` (experimental) Transition seconds for automatic weather
|
|
18
|
+
- `lightningFirst: number` (experimental) Seconds to the first bolt (also after a load without a saved timer)
|
|
19
|
+
- `lightningInterval: number[]` (experimental) [min, max] seconds between bolts while a type with lightning > 0.5 holds
|
|
20
|
+
- `lightning: (flash: number, engine: any) => number` (experimental) Strike picture: flash (1 at the strike, fading in a third of a second) -> sky flash amount. Write it at any time
|
|
22
21
|
- `lightningBrightness: number` Multiplies the sky flash of every strike; write it at any time
|
|
23
22
|
- `overcastColor: THREE.Color` Color the sky turns as a weather type raises grey: a THREE.Color, overcastColor.set(0x667788) changes it live
|
|
24
|
-
- `particles: Record<string, WeatherParticleSystem>` The particle systems drawn now, by field: rain and snow when the table has them, plus what
|
|
23
|
+
- `particles: Record<string, WeatherParticleSystem>` The particle systems drawn now, by field: rain and snow when the table has them, plus what defineField() added. Example: `engine.weather.particles.rain.spec.speed = 30;`
|
|
24
|
+
- `auto: boolean` Automatic weather on/off. Writing it takes effect like setAuto.
|
package/docs/api/weatherDraw.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# engine.weatherDraw — weatherDraw()
|
|
2
2
|
|
|
3
|
-
Weather drawing (installed by weather()
|
|
3
|
+
(experimental) Weather drawing (installed by weather(); sky is optional): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
|
7
7
|
- Properties:
|
|
8
8
|
- `flash: number` Sky flash now, 1 at a strike (the weather:lightning event) fading to 0
|
|
9
|
-
- `particles: number` Default particle count per system (
|
|
10
|
-
- `systems: Map<string, any>` Particle systems drawn now: field -> { field, object, material, uniforms, spec } (rain / snow when the table has them, plus fields engine.weather.
|
|
9
|
+
- `particles: number` Default particle count per system: weather({ particles }), else 6000 (3000 on low-tier devices)
|
|
10
|
+
- `systems: Map<string, any>` Particle systems drawn now: field -> { field, object, material, uniforms, spec } (rain / snow when the table has them, plus fields engine.weather.defineField adds)
|
package/docs/api/world.md
CHANGED
|
@@ -4,9 +4,9 @@ World data (world() module): things that must be saved, survive level changes an
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
|
7
|
-
- `world.add(def: { kind, id?, position?, … }, opts?: { initial?, save? }) → WorldRecord | null` — Add a record and return it (a plain object). kind is required; without id one is numbered automatically (kind#1, kind#2…, saved; `#` never appears in an authored id, so the two can never collide). opts.initial: initial record written in content (needs an id); saves only keep its changes and removal; if the id already exists the existing one is returned (content may load twice); returns null if the save removed it (it is not added back). opts.save: false: not saved (temporary things). Example: `engine.world.add({ id: 'shop_owner', kind: 'npc', position: [12, 0, -30], name: '店主', mood: 'calm' }, { initial: true })`
|
|
7
|
+
- `world.add(def: { kind, id?, position?, … }, opts?: { initial?, save? }) → WorldRecord | null` — Add a record and return it (a plain object). kind is required; without id one is numbered automatically (kind#1, kind#2…, saved; `#` never appears in an authored id, so the two can never collide). opts.initial: initial record written in content (needs an id); saves only keep its changes and removal; if the id already exists the existing one is returned (content may load twice), after taking a new position / rot from the content unless play moved it; returns null if the save removed it (it is not added back). opts.save: false: not saved (temporary things). Example: `engine.world.add({ id: 'shop_owner', kind: 'npc', position: [12, 0, -30], name: '店主', mood: 'calm' }, { initial: true })`
|
|
8
8
|
- `world.origin(id: string) → { definedAt?, level?, node?, template?, spawned? } | null | …` — Where a record comes from (filled in dev and test builds; null in release): { definedAt: 'content/props.js:14' } for a content entry, { level, node } for a level-model node, { template } when it is a template instance, { spawned: { op, tick } } for a record created during play. engine.inspect(id) and engine.pick(...).thing show it, so you know which file to edit to change the level for good. Example: `engine.world.origin('chest-home') // { definedAt: 'content/props.js:14', template: 'chest' }`
|
|
9
|
-
- `world.idOf(obj: any) → string | null` — The id of the record whose model contains obj (obj itself or one of its parents is a built model), else null. A ray hit on a model names its record this way. Example: `const h = engine.pick(0, 0); const id = h && engine.world.idOf(h.object);`
|
|
9
|
+
- `world.idOf(obj: any) → string | null` — (experimental) The id of the record whose model contains obj (obj itself or one of its parents is a built model), else null. A ray hit on a model names its record this way. Example: `const h = engine.pick(0, 0); const id = h && engine.world.idOf(h.object);`
|
|
10
10
|
- `world.get(id: string) → WorldRecord | undefined` — Get a record by id (undefined if missing, like a Map)
|
|
11
11
|
- `world.set(id: string, patch: Record<string, any>) → WorldRecord` — Merge fields into a record and emit the world:change event; a position in patch also moves it. Returns the record. For discrete changes (chest opened, growth stage, picked up); if present has show, it is re-evaluated after the change. id / kind cannot be changed. Example: `engine.world.set('crate_1', { opened: true })`
|
|
12
12
|
- `world.move(id: string, position: any)` — Move a record (no event; use it in simulate for things that move every step); still saved (saves diff against content). The model of a positionFrom 'record' (default) record follows this frame; to do something else with the position in presentation, compare in update. Example: `engine.world.move(rec.id, { x: rec.position.x + 1, z: rec.position.z })`
|
|
@@ -17,9 +17,9 @@ World data (world() module): things that must be saved, survive level changes an
|
|
|
17
17
|
- `world.view(id: string) → any` — The current model of this record (only exists nearby; null if not built yet or far away)
|
|
18
18
|
- `world.refresh()` — Build / tear down models for the stream sources right now (normally automatic every frame, with a per-frame limit). Use it right after add when you need the model: sync builds are available via view(id) after the call, for async ones also await world.whenReady. Example: `engine.world.add({ id: 'gate', kind: 'gate', position: p }); engine.world.refresh(); engine.world.view('gate')`
|
|
19
19
|
- `world.simulate(kind: string, opts: { near?, far?, farEvery?, radius?, fullRadius?, nearEvery?, … }) → { remove(): void }` — Register how a kind of thing changes (gameplay logic goes here, runs in the fixed step); near / far is split by distance from world.anchor (default: the player): near(rec, dt, obj): within radius, once per fixed step (obj is the model, may be null if not built yet; gameplay must not depend on it); far(rec, dt): farther away, once every farEvery seconds; dt is the seconds accumulated since the last simulation (can catch up a long time at once); on the far → near step, far runs first to pay back the owed time. With only far (crops), near also advances via far; with only near, far records are not simulated and owed time is not made up. Both dt are accumulated real (fixed-step) seconds (not multiplied by clock.rate). For things measured in game clock (grows over days) store engine.clock.now and compare. Example: `engine.world.simulate('zombie', { near: (rec, dt) => chase(rec, dt), far: (rec, dt) => wander(rec, dt), farEvery: 2 })`
|
|
20
|
-
- `world.pauseSimulation() → { remove(): void }` — Stop running simulate() handlers on this machine until remove(): a multiplayer client lets the host simulate and only receives the records. Public so net() needs no world internals.
|
|
20
|
+
- `world.pauseSimulation() → { remove(): void }` — (experimental) Stop running simulate() handlers on this machine until remove(): a multiplayer client lets the host simulate and only receives the records. Public so net() needs no world internals.
|
|
21
21
|
- Properties:
|
|
22
|
-
- `records: Map<string, WorldRecord>` All records: id → record (read-only; use set to change fields, move to change position)
|
|
22
|
+
- `records: Map<string, WorldRecord>` (experimental) All records: id → record (read-only; use set to change fields, move to change position)
|
|
23
23
|
- `radius: number` Default distance (meters) for building models and counting as near; present / simulate can override it. Changing it at runtime affects those without their own radius
|
|
24
24
|
- `farEvery: number` Default interval (seconds) between far simulations, same unit as dt
|
|
25
25
|
- `farMaxPerTick: number` Max far simulations per fixed step; the rest queue for the next step (dt accumulates, no time is lost). Counted by records, not milliseconds, so results do not depend on machine speed
|
|
@@ -28,4 +28,4 @@ World data (world() module): things that must be saved, survive level changes an
|
|
|
28
28
|
- `zone: string | null` Current zone (e.g. level name, set by the level module on level change): once set, records of another zone get no model and no near simulation; null = no zoning
|
|
29
29
|
- `ready: boolean` All models that should exist near the stream sources are built (async ones too; failed builds do not count as pending). The loading screen waits for it; to wait yourself, await world.whenReady
|
|
30
30
|
- `whenReady: Promise<void>` Promise that resolves when ready becomes true
|
|
31
|
-
- `steps: number` Number of fixed steps simulated
|
|
31
|
+
- `steps: number` (experimental) Number of fixed steps simulated
|