threedog 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +411 -1
- package/README.md +8 -11
- package/core/{Animator.js → assets/Animator.js} +30 -18
- package/core/{Assets.js → assets/Assets.js} +131 -56
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +302 -0
- package/core/{assetHot.js → assets/assetHot.js} +9 -7
- package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
- package/core/{assetReport.js → assets/assetReport.js} +7 -14
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +47 -25
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +15 -12
- package/core/{Random.js → base/Random.js} +7 -4
- package/core/{Vars.js → base/Vars.js} +14 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +151 -125
- package/core/{errorHints.js → base/errorHints.js} +17 -10
- package/core/{errors.js → base/errors.js} +12 -10
- package/core/{events.generated.js → base/events.generated.js} +11 -0
- package/core/base/follows.js +26 -0
- package/core/base/math.js +66 -0
- package/core/{params.js → base/params.js} +5 -6
- package/core/base/saveValues.js +81 -0
- package/core/base/sections.js +97 -0
- package/core/base/spelling.js +32 -0
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +34 -34
- package/core/{Engine.js → engine/Engine.js} +137 -91
- package/core/{Loading.js → engine/Loading.js} +34 -5
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +32 -15
- package/core/{lifecycle.js → engine/lifecycle.js} +41 -34
- package/core/{loop.js → engine/loop.js} +88 -49
- package/core/engine/moduleSlots.js +176 -0
- package/core/{moduleTypes.js → engine/moduleTypes.js} +26 -14
- package/core/engine/modules.js +503 -0
- package/core/{page.js → engine/page.js} +59 -29
- package/core/{plugins.js → engine/plugins.js} +21 -12
- package/core/{services.js → engine/services.js} +50 -40
- package/core/{startup.js → engine/startup.js} +66 -54
- package/core/{Input.js → input/Input.js} +67 -39
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/input/inputKeyboard.js +39 -0
- package/core/{inputPad.js → input/inputPad.js} +24 -3
- package/core/{inputPointer.js → input/inputPointer.js} +11 -3
- package/core/input/inputSeat.js +66 -0
- package/core/{inputTouch.js → input/inputTouch.js} +24 -7
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +43 -18
- package/core/{Describe.js → inspect/Describe.js} +34 -26
- package/core/{Inspect.js → inspect/Inspect.js} +39 -10
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
- package/core/{UrlState.js → inspect/UrlState.js} +60 -24
- package/core/{catalog.js → inspect/catalog.js} +15 -8
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +4 -4
- package/core/{describeRender.js → inspect/describeRender.js} +24 -22
- package/core/{describeText.js → inspect/describeText.js} +17 -8
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/inspect/metadata.generated.js +4140 -0
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +130 -47
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/inspect/toolDoor.js +21 -0
- package/core/inspect/valueHistory.js +35 -0
- package/core/{Ops.js → ops/Ops.js} +44 -14
- package/core/{control.js → ops/control.js} +57 -31
- package/core/ops/holds.js +140 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +18 -5
- package/core/{opsCheck.js → ops/opsCheck.js} +11 -10
- package/core/{opsFail.js → ops/opsFail.js} +5 -7
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +9 -6
- package/core/{owned.js → ops/owned.js} +33 -19
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -16
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +34 -15
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +53 -27
- package/core/{Saves.js → saves/Saves.js} +171 -54
- package/core/saves/saveApply.js +312 -0
- package/core/{saveFiles.js → saves/saveFiles.js} +45 -38
- package/core/{saveVersions.js → saves/saveVersions.js} +24 -23
- package/core/saves/session.js +231 -0
- package/core/saves/stateReplace.js +184 -0
- package/core/{Rays.js → scene/Rays.js} +44 -30
- package/core/{Views.js → scene/Views.js} +16 -8
- package/core/{adaptive.js → scene/adaptive.js} +19 -9
- package/core/{canvasBox.js → scene/canvasBox.js} +4 -3
- package/core/scene/compositeGround.js +72 -0
- package/core/scene/floor.js +17 -0
- package/core/{gameLights.js → scene/gameLights.js} +17 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +6 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/scene/ground.contract.js +14 -0
- package/core/scene/ground.js +139 -0
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/scene/pixel.js +154 -0
- package/core/scene/pixelRatio.js +167 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +5 -5
- package/core/{sceneMethods.js → scene/sceneMethods.js} +43 -15
- package/core/scene/stepPoses.js +60 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
- package/core/{thingOps.js → scene/thingOps.js} +25 -16
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +10 -0
- package/core/scene/view.js +161 -0
- package/core/{Batching.js → stream/Batching.js} +85 -28
- package/core/{Stream.js → stream/Stream.js} +80 -38
- package/core/{batchGroups.js → stream/batchGroups.js} +11 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +7 -4
- package/core/{streamSources.js → stream/streamSources.js} +14 -8
- package/core/{Commits.js → threads/Commits.js} +17 -11
- package/core/{Jobs.js → threads/Jobs.js} +25 -13
- package/core/{Threads.js → threads/Threads.js} +21 -18
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +20 -11
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +28 -21
- package/core/{time.js → time/time.js} +32 -20
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +92 -72
- package/docs/API.md +33 -28
- package/docs/CODEMAP.md +121 -200
- package/docs/COMMANDS.md +77 -70
- package/docs/CONVENTIONS.md +167 -24
- package/docs/MIGRATING-0.8.md +171 -0
- package/docs/MIGRATING-1.0.md +101 -0
- package/docs/THREE.md +140 -38
- package/docs/api/assets.md +12 -13
- package/docs/api/audio.md +6 -5
- package/docs/api/budget.md +4 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +32 -29
- package/docs/api/characters.md +35 -24
- package/docs/api/clock.md +1 -1
- package/docs/api/collider3d.md +9 -0
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +18 -17
- package/docs/api/dialogue.md +5 -4
- package/docs/api/engine.md +58 -54
- package/docs/api/events.md +17 -6
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +6 -7
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +9 -8
- package/docs/api/interactions.md +5 -5
- package/docs/api/inventory.md +10 -10
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +10 -9
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +14 -12
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +10 -7
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +3 -3
- package/docs/api/post.md +21 -5
- package/docs/api/quests.md +7 -5
- package/docs/api/rays.md +7 -7
- package/docs/api/rigid.md +29 -19
- package/docs/api/saves.md +13 -11
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +8 -9
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +6 -8
- package/docs/api/terrainDraw.md +2 -2
- package/docs/api/timeline.md +4 -4
- package/docs/api/tools.md +27 -22
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +2 -2
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +27 -12
- package/docs/api/weatherDraw.md +4 -4
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +28 -43
- package/docs/recipes/02-npc.md +21 -23
- package/docs/recipes/03-items-pickups.md +37 -53
- package/docs/recipes/04-quests.md +5 -4
- package/docs/recipes/05-props-bake.md +34 -44
- package/docs/recipes/06-clock-events.md +31 -22
- package/docs/recipes/07-flow-scenes-pause.md +30 -32
- package/docs/recipes/08-weather-sky.md +91 -37
- package/docs/recipes/09-materials-lights-models.md +25 -39
- package/docs/recipes/10-blender-level.md +22 -11
- package/docs/recipes/11-vehicles.md +44 -24
- package/docs/recipes/12-navmesh.md +60 -15
- package/docs/recipes/13-animation.md +70 -22
- package/docs/recipes/14-custom-module.md +33 -20
- package/docs/recipes/15-perf.md +51 -28
- package/docs/recipes/16-dev-bridge.md +39 -58
- package/docs/recipes/18-world.md +49 -28
- package/docs/recipes/19-shooting-picking.md +7 -4
- package/docs/recipes/20-content-actions-save.md +55 -40
- package/docs/recipes/21-camera.md +47 -25
- package/docs/recipes/22-shop-gold.md +21 -16
- package/docs/recipes/23-ops.md +28 -24
- package/docs/recipes/26-ui-parts.md +25 -14
- package/docs/recipes/27-net.md +3 -5
- package/docs/recipes/28-terrain.md +119 -23
- package/docs/recipes/29-grid.md +3 -3
- package/docs/recipes/30-templates.md +63 -30
- package/docs/recipes/31-audio.md +7 -7
- package/docs/recipes/32-action-game.md +21 -11
- package/docs/recipes/33-stream-sources.md +6 -3
- package/docs/recipes/34-environment-lighting.md +72 -25
- package/docs/recipes/35-picture-from-reference.md +20 -23
- package/docs/recipes/36-ground-plants.md +106 -0
- package/docs/recipes/40-scene.md +18 -21
- package/docs/recipes/43-shader-patches-surfaces.md +27 -48
- package/docs/recipes/44-water-weather-hooks.md +56 -50
- package/docs/recipes/45-cascaded-shadows.md +41 -20
- package/docs/recipes/46-blender-art-route.md +9 -10
- package/docs/recipes/49-game-module-contract.md +7 -6
- package/docs/recipes/50-own-renderer.md +3 -2
- package/docs/recipes/51-capability-catalog.md +14 -8
- package/docs/recipes/52-around-the-picture.md +56 -100
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +17 -20
- package/docs/recipes/56-webgpu-tsl.md +28 -15
- package/docs/recipes/57-control.md +39 -12
- package/docs/recipes/58-input.md +15 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +30 -25
- package/docs/recipes/62-picture-code.md +129 -39
- package/docs/recipes/63-third-person-start.md +19 -5
- package/docs/recipes/64-particles.md +54 -5
- package/docs/recipes/65-swarm.md +140 -0
- package/docs/recipes/66-common-tasks.md +313 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +5 -5
- package/examples/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +15 -14
- package/examples/{sheepisland → perf-island}/assets.js +1 -1
- package/examples/{sheepisland → perf-island}/main.js +8 -8
- package/examples/{sheepisland → perf-island}/models.js +1 -1
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/GAMEMAP.md +4 -1
- package/examples/rc2d/GAMEMAP.md +4 -3
- package/examples/rc2d/main.js +1 -3
- package/examples/rc2d/rc2d.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +6 -5
- package/examples/techniques/contact-shadows/contactShadows.js +1 -1
- package/examples/techniques/contact-shadows/main.js +1 -1
- package/examples/techniques/interior-light/main.js +1 -1
- package/examples/techniques/modular-building/README.md +7 -6
- package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +2 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +9 -7
- package/examples/world/main.js +3 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +16 -12
- package/index.js +53 -32
- package/llms.txt +11 -14
- package/modules/ambience/Ambience.js +16 -11
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +18 -16
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +5 -5
- package/modules/camera/FixedCamera.js +43 -30
- package/modules/camera/FollowCamera.js +24 -15
- package/modules/camera/RtsCamera.js +12 -11
- package/modules/camera/common.js +72 -37
- package/modules/camera/contract.js +1 -0
- package/modules/camera/pixelSnap.js +62 -0
- package/modules/characters/Character.js +166 -70
- package/modules/characters/NPC.js +84 -44
- package/modules/characters/assetModel.js +16 -12
- package/modules/characters/astar.js +48 -27
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/character.contract.js +21 -0
- package/modules/characters/contract.js +17 -3
- package/modules/characters/index.js +240 -226
- package/modules/characters/moveHelpers.js +88 -12
- package/modules/characters/mover.contract.js +14 -0
- package/modules/characters/movers/common.js +22 -18
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +18 -10
- package/modules/characters/movers/simple.js +26 -13
- package/modules/characters/movers/support.js +24 -13
- package/modules/characters/npcAvoid.js +19 -16
- package/modules/characters/npcSim.js +88 -32
- package/modules/characters/npcView.js +19 -11
- package/modules/characters/pathAsync.js +81 -29
- package/modules/characters/pathJob.js +38 -21
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +120 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/seat.js +56 -0
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/vehicle.contract.js +8 -5
- package/modules/characters/walkTo.js +40 -33
- package/modules/collision/Collision.js +69 -45
- package/modules/collision/contract.js +15 -0
- package/modules/collision/grid.js +6 -1
- package/modules/content/explain.js +2 -3
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +5 -3
- package/modules/content/index.js +132 -114
- package/modules/content/loader.js +117 -140
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +54 -17
- package/modules/content/packs.js +5 -4
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +36 -0
- package/modules/content/props.js +22 -17
- package/modules/content/rules.js +47 -61
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +80 -49
- package/modules/content/words.js +47 -0
- package/modules/debug/DebugPanel.js +14 -45
- package/modules/flow/contract.js +2 -1
- package/modules/flow/index.js +30 -16
- package/modules/gameplay/Container.js +17 -13
- package/modules/gameplay/Containers.js +23 -6
- package/modules/gameplay/Dialogue.js +93 -34
- package/modules/gameplay/Interactions.js +93 -51
- package/modules/gameplay/Inventory.js +64 -22
- package/modules/gameplay/Quests.js +146 -30
- package/modules/gameplay/boxOps.js +8 -1
- package/modules/gameplay/dialogueBubbles.js +16 -12
- package/modules/gameplay/inventoryOps.js +11 -8
- package/modules/gameplay/pickups.js +63 -37
- package/modules/gameplay/questLog.js +4 -2
- package/modules/gameplay/questSave.js +9 -4
- package/modules/gameplay/quests.contract.js +1 -1
- package/modules/grid/Grid.js +2 -2
- package/modules/grid/Layer.js +12 -8
- package/modules/grid/index.js +28 -23
- package/modules/grid/ops.js +43 -46
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +42 -57
- package/modules/hud/index.js +22 -14
- package/modules/hud/parts.js +8 -8
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +29 -31
- package/modules/level/index.js +113 -161
- package/modules/level/load.js +196 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +40 -23
- package/modules/lights/index.js +33 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +90 -0
- package/modules/music/Music.js +34 -28
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +16 -0
- package/modules/nav/index.js +180 -49
- package/modules/nav/navPath.js +45 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +6 -5
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +95 -29
- package/modules/particles/effect.js +86 -32
- package/modules/particles/shaders.js +19 -1
- package/modules/photo/Photo.js +23 -23
- package/modules/rigid/RigidBodies.js +255 -89
- package/modules/rigid/Vehicles.js +17 -8
- package/modules/rigid/collider3d.contract.js +26 -0
- package/modules/rigid/ragdoll.js +298 -0
- package/modules/rigid/ragdollBones.js +209 -0
- package/modules/rigid/refresh.js +10 -0
- package/modules/rigid/sync.js +51 -20
- package/modules/settings/Settings.js +177 -61
- package/modules/settings/apply.js +20 -13
- package/modules/settings/sections.js +19 -14
- package/modules/settings/strings.js +2 -2
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +29 -22
- package/modules/sky/clouds.js +7 -7
- package/modules/sky/dome.js +33 -20
- package/modules/sky/domeLayers.js +9 -9
- package/modules/sky/environment.js +6 -6
- package/modules/sky/frame.js +19 -10
- package/modules/sky/season.js +7 -1
- package/modules/sky/shader.js +24 -25
- package/modules/sky/skyModule.js +17 -28
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +356 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +71 -59
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +14 -11
- package/modules/terrain/index.js +42 -42
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +45 -29
- package/modules/terrain/terrainGen.js +19 -12
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +83 -43
- package/modules/timeline/Tween.js +25 -19
- package/modules/timeline/shots.js +24 -17
- package/modules/triggers/index.js +95 -28
- package/modules/vegetation/Vegetation.js +34 -26
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +39 -18
- package/modules/vegetation/groundChunks.js +21 -38
- package/modules/vegetation/index.js +37 -12
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +20 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +52 -40
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +28 -23
- package/modules/world/World.js +28 -15
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +30 -17
- package/modules/world/persist.js +90 -27
- package/modules/world/pos.js +5 -5
- package/modules/world/records.js +37 -11
- package/modules/world/sim.js +78 -27
- package/modules/world/simFar.js +2 -2
- package/modules/world/state.js +43 -11
- package/modules/world/thingSource.js +20 -5
- package/modules/world/views.js +27 -14
- package/package.json +48 -7
- package/presets.js +1 -3
- package/render/PostFX.js +83 -53
- package/render/backend.js +31 -33
- package/render/cascades.js +17 -12
- package/render/cascades.tsl.js +5 -8
- package/render/daylight.js +20 -3
- package/render/detail.js +8 -7
- package/render/effects.js +28 -25
- package/render/fuse.js +3 -3
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +5 -10
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/particles.tsl.js +8 -6
- package/render/fx/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +30 -26
- package/render/fx/sky.tsl.js +15 -17
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +2 -2
- package/render/lighting.js +5 -3
- package/render/lightmap.js +41 -21
- package/render/lights.js +6 -6
- package/render/lit.js +24 -0
- package/render/materials.js +8 -7
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/occlusion.js +62 -15
- package/render/ownFrame.js +4 -4
- package/render/patches.js +15 -15
- package/render/postWebGL.js +15 -12
- package/render/probes.js +41 -19
- package/render/recordSweep.js +117 -0
- package/render/shaderErrors.js +10 -9
- package/render/shadowCache.tsl.js +107 -0
- package/render/shadowTypes.js +9 -0
- package/{core → render}/shadows.js +59 -13
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +336 -202
- package/types/gameplay.d.ts +254 -130
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +8 -16
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +28 -10
- package/types/generated/core/input/inputSeat.d.ts +26 -0
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +17 -3
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +6 -4
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +14 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +62 -18
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +3 -2
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +2 -2
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +22 -18
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Grid.d.ts +1 -0
- package/types/generated/modules/grid/Layer.d.ts +1 -1
- package/types/generated/modules/grid/index.d.ts +3 -3
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +5 -4
- package/types/generated/modules/sky/Sky.d.ts +21 -10
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +7 -5
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +14 -16
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +11 -7
- package/types/generated/render/PostFX.d.ts +21 -23
- package/types/generated/render/materials.d.ts +1 -0
- package/types/generated/render/occlusion.d.ts +9 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +47 -15
- package/types/physics.d.ts +150 -73
- package/types/pixel.d.ts +75 -0
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +48 -75
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +13 -5
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +7 -5
- package/core/assetEntry.js +0 -109
- package/core/engineCamera.js +0 -32
- package/core/ground.js +0 -104
- package/core/holds.js +0 -134
- package/core/math.js +0 -48
- package/core/moduleSlots.js +0 -100
- package/core/modules.js +0 -314
- package/core/saveApply.js +0 -210
- package/core/saveValues.js +0 -46
- package/core/session.js +0 -174
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- package/core/view.js +0 -43
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -320
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/MIGRATING-0.6.md +0 -126
- package/docs/PERF.md +0 -245
- package/docs/recipes/36-sky-ground-plants.md +0 -158
- package/docs/recipes/37-terrain-hooks.md +0 -115
- package/docs/recipes/38-environment-hooks.md +0 -67
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/47-island-snow-backdrop.md +0 -43
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/plain-picture/FINDINGS.md +0 -53
- package/examples/sheepisland/.threedog/content-index.json +0 -1
- package/modules/camera/projection.js +0 -21
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{cells.js → stream/cells.js} +0 -0
- /package/core/{streamCells.js → stream/streamCells.js} +0 -0
- /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
- /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
package/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,19 +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
|
|
5
4
|
- `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
|
-
- `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.
|
|
5
|
+
- `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. Ready means nothing is pending, not that everything built: a stream entry or world model whose build failed is reported and left out, and the trip still lands. A terrain chunk that failed stays not ready, as there is no ground to stand on, so that trip ends in stream-timeout. A game that needs a thing built checks it itself (handle.built, engine.world.view(id)). Example: `await engine.stream.teleport([800, 0, 300]);`
|
|
6
|
+
- `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
7
|
- `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
8
|
- 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
9
|
- `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
|
|
10
|
+
- `unloadFactor: number` (experimental) Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25
|
|
11
|
+
- `player: StreamSource` Built-in source at the player (engine.focus without one): full detail and physics
|
|
14
12
|
- `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
|
|
16
|
-
- `
|
|
13
|
+
- `activeRadius: number` (experimental) The build radius actually in use, in meters
|
|
14
|
+
- `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).
|
|
15
|
+
- `ready: boolean` No build within radius is still waiting (start() waits for it before the loading screen goes away). Nothing pending, not everything built: a build that failed is reported and left out; a game that needs a thing built checks it itself (handle.built)
|
|
17
16
|
- `stats: { entries: number; built: number; queued: number }` entries is the registered count, built the built count, queued the queued count
|
|
18
17
|
|
|
19
18
|
## Data structures
|
|
@@ -21,7 +20,7 @@
|
|
|
21
20
|
- `position: PositionLike` Position (Vector3 / object / [x, y, z] / { x, z }; only the horizontal coordinates count)
|
|
22
21
|
- `radius?: number` Object size (meters); larger ones are built earlier
|
|
23
22
|
- `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 (
|
|
23
|
+
- `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. obj.removeFromParent())
|
|
25
24
|
- `keep?: boolean` Do not unload even when out of range
|
|
26
25
|
- `priority?: number` Build order: larger first (nearer first within the same priority), default 0
|
|
27
26
|
- **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
|
@@ -6,6 +6,7 @@ Procedural terrain, data part (terrain() module: chunks, heights, edits, collisi
|
|
|
6
6
|
- `viewChunks?: number` View distance (in chunks), default 4
|
|
7
7
|
- `density?: number` Vegetation density multiplier, default 1
|
|
8
8
|
- `viewFog?: boolean` true: the signal engine.uniforms.uViewDistance follows the view distance, so a game's fog can read it and fade the far chunk edge out (openWorld() sets true)
|
|
9
|
+
- `part?: boolean` true: do not take the ground slot; compositeGround({ parts: [{ of: 'terrain' }] }) does and reads terrain.ground (so a terrain and a level can both run)
|
|
9
10
|
- `material?: Material | ((engine: Engine) => Material)` Ground material (default neutral gray with vertex colors); chunks have position, normal, color and uv = world xz / chunk size. Cloud shadows, season tint and detail are added
|
|
10
11
|
- `effects?: boolean` With material: false = draw it exactly as given, no cloud shadow / season / detail patch
|
|
11
12
|
- `detail?: MaterialDetail | null` Detail layer over the ground: a noise, a texture asset name or your own glsl; defaults scale 0.25, strength 0.35, top-down world projection, multiply. Change it with engine.terrain.recolor({ detail })
|
|
@@ -13,23 +14,20 @@ Procedural terrain, data part (terrain() module: chunks, heights, edits, collisi
|
|
|
13
14
|
|
|
14
15
|
## Methods and properties
|
|
15
16
|
- `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.
|
|
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 (same vertex count); 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) } }))`
|
|
17
|
+
- `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
18
|
- `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
19
|
- `terrain.rebuild()` — Rebuild all chunks
|
|
21
20
|
- `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
21
|
- Properties:
|
|
24
|
-
- `
|
|
22
|
+
- `generator: TerrainGen` Pure-computation terrain (height, landform), what createTerrain() returns
|
|
25
23
|
- `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
24
|
- `patches: ShaderPatch[]` The engine's ground patches (world, clouds, season, detail), so a game material keeps them: applyEffects(mat, { patches: engine.terrain.patches })
|
|
27
25
|
- `uniforms: Record<string, { value: any }>` The detail layer's { value } uniforms, written directly and live: uDetailStrength, uDetailScale, uDetailTint... ({} without a detail layer)
|
|
28
|
-
- `
|
|
26
|
+
- `chunkSize: number` Chunk edge length (meters), the same value as the chunkSize option and ground.chunkSize
|
|
29
27
|
- `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
28
|
- `chunks: Map<string, TerrainChunk>` Loaded chunks: 'cx,cz' → chunk
|
|
31
|
-
- `viewChunks: number` View distance (in chunks)
|
|
32
|
-
- `density: number` Vegetation density multiplier
|
|
29
|
+
- `viewChunks: number` (experimental) View distance (in chunks). Writing it moves the camera far plane out too, and with viewFog uViewDistance
|
|
30
|
+
- `density: number` Vegetation density multiplier. Writing it places plants again on the loaded chunks: it thins plants without a collider, blocking plants stand at every density, so collision does not change
|
|
33
31
|
- `applyBudgetMs: number` Time budget (milliseconds) for uploading chunks per frame
|
|
34
32
|
- `stats: { builtThisFrame, applyMs, queued, failed, visible?, loaded?, … }` Statistics (for the debug panel); failed = chunks that failed every try (terrain:chunkFailed)
|
|
35
33
|
- `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
|
-
# engine.terrainDraw —
|
|
1
|
+
# engine.terrainDraw — terrain(opts?: TerrainOptions)
|
|
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
|
@@ -5,12 +5,12 @@ Cutscenes, tweens (timeline() module)
|
|
|
5
5
|
- Options `TimelineOptions`
|
|
6
6
|
|
|
7
7
|
## Methods and properties
|
|
8
|
-
- `timeline.tween(target: any, to: TweenTo, opts?: { duration?: number; ease?: Ease }) → TweenPromise` — General tween (the only entry point for tweens in the engine): await engine.timeline.tween(mesh, { 'position.y': 2 }, { duration: 1, ease: 'outCubic' }); duration in seconds (default 1), ease default 'inOutCubic'; tween(mesh, to, 1) throws in dev. Returns a Promise (with finish() / remove())
|
|
9
|
-
- `timeline.play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions) → Promise<{
|
|
8
|
+
- `timeline.tween(target: any, to: TweenTo, opts?: { duration?: number; ease?: Ease }) → TweenPromise` — General tween (the only entry point for tweens in the engine): await engine.timeline.tween(mesh, { 'position.y': 2 }, { duration: 1, ease: 'outCubic' }); duration in seconds (default 1), ease default 'inOutCubic'; tween(mesh, to, 1) throws in dev. Returns a Promise (with finish() / remove()); a write that throws ends the tween and rejects it
|
|
9
|
+
- `timeline.play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions) → Promise<{ ending: "finished" | "s…` — Play a timeline; resolves with { ending, error? } when it ends: 'finished', 'skipped', 'dropped' (a load, a new game or dispose took its state) or 'failed' (a step threw; error says what)
|
|
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,36 @@
|
|
|
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'; needs sky)
|
|
5
4
|
- `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
5
|
- `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
6
|
- `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
7
|
- `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
8
|
- `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
9
|
- `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.
|
|
10
|
+
- `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
11
|
- `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
12
|
- `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
13
|
- `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.
|
|
14
|
+
- `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
15
|
- `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
16
|
- `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
17
|
- `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
18
|
- `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).
|
|
19
|
+
- `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
20
|
- `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
21
|
- `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
22
|
- `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
23
|
- `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']
|
|
24
|
+
- `materialPatches(material: THREE.Material) → string[]` — (experimental) Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
|
|
26
25
|
- `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
26
|
- `makeWindow(engine: Engine, opts: WindowOptions) → UIWindow` — A toggleable window
|
|
28
27
|
- `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
28
|
- `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
|
|
29
|
+
- `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
|
|
30
|
+
- `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
31
|
- `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
32
|
- `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] }
|
|
33
|
+
- `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
34
|
- `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
35
|
- `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
36
|
- `THREE` — three.js itself (any): `import { THREE } from 'threedog'`
|
|
@@ -58,18 +57,24 @@
|
|
|
58
57
|
- `behind: boolean`
|
|
59
58
|
|
|
60
59
|
## Other exported classes and functions
|
|
61
|
-
- `
|
|
62
|
-
- `
|
|
63
|
-
- `
|
|
64
|
-
- `
|
|
65
|
-
- `
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
68
|
-
- `
|
|
69
|
-
- `
|
|
70
|
-
- `
|
|
71
|
-
- `
|
|
72
|
-
- `
|
|
73
|
-
- `
|
|
74
|
-
- `
|
|
60
|
+
- `pixelGrid(options: { camera, pixelsPerMeter }) → PixelGrid` — The art pixel grid of an orthographic camera. Pure math.
|
|
61
|
+
- `pixelSprite(options: PixelSpriteOptions) → Mesh` — A plain THREE.Mesh: a vertical plane that turns around Y with the camera's forward direction, stretched so one texel is one art pixel. Works as a character's `model`. mesh.position stays exact; only what is drawn is rounded.
|
|
62
|
+
- `spriteFrame(mesh: Mesh, frame: number, flip?: boolean) → Mesh` — Show a sheet frame (left to right, top to bottom); flip mirrors it, left out it stays as it was
|
|
63
|
+
- `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.
|
|
64
|
+
- `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.
|
|
65
|
+
- `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.
|
|
66
|
+
- `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].
|
|
67
|
+
- `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].
|
|
68
|
+
- `hash(p: Node) → Node` — (experimental) GLSL float threedogHash(vec2 p): a repeatable random number 0-1 from a 2D position.
|
|
69
|
+
- `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.
|
|
70
|
+
- `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.
|
|
71
|
+
- `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).
|
|
72
|
+
- `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.
|
|
73
|
+
- `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).
|
|
74
|
+
- `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.
|
|
75
|
+
- `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.
|
|
76
|
+
- `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.
|
|
77
|
+
- `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.
|
|
78
|
+
- `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.
|
|
79
|
+
- `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
80
|
- `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/triggers.md
CHANGED
|
@@ -31,6 +31,8 @@ Trigger zones (triggers() module)
|
|
|
31
31
|
- `who?: string | Vector3 | Object3D | { x, y, z } | (() => Array<string | Obje…) | null` Who can trigger it: engine.actor by default; or an actor id, a position, an object (its position is used), or a function returning an array of those (several actors: () => [e.actor, ...e.net.peers.map(p => p.actor)])
|
|
32
32
|
- `cooldown?: number` Seconds after leaving during which entering does not fire again, default 0
|
|
33
33
|
- `userData?: Record<string, any>` Custom data
|
|
34
|
+
- `occupancy?: 'zone' | 'each'` 'zone' (default): one enter when the first actor arrives, one exit when the last leaves. 'each': an enter, stay and exit per actor (a door counting entrants); inside is true while anyone is in
|
|
35
|
+
- `volume?: { contains, bounds? }` Your own region instead of a shape: the plain volume addWaterBody takes. bounds ({ min, max }) lets the zone be indexed and drawn in the debug view; without it the zone is checked every step
|
|
34
36
|
- **Trigger** A trigger zone (the return value of add())
|
|
35
37
|
- `shape: 'cylinder' | 'sphere' | 'box'`
|
|
36
38
|
- `x: number` Position (meters)
|
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
|
-
# engine.vegetationDraw —
|
|
1
|
+
# engine.vegetationDraw — vegetation(opts?: VegetationModuleOptions)
|
|
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,13 +17,17 @@ 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
|
|
24
24
|
- **WaterBodyOptions** Parameters of engine.addWaterBody(): position center, level water surface height (meters); give radius for a circle, halfWidth / halfDepth for a rectangle
|
|
25
|
-
- `position
|
|
26
|
-
- `level
|
|
25
|
+
- `position?: PositionLike`
|
|
26
|
+
- `level?: number`
|
|
27
|
+
- `query?: (x: number, z: number, y?: number) => number | null` Your own water (the engine draws nothing): level at (x, z) for a body at height y, or null where this body has none
|
|
28
|
+
- `bounds?: { min, max }` Box3-like { min, max } that lets waterAt skip the query outside it
|
|
29
|
+
- `mesh?: Object3D` The mesh you draw for it (kept for reference; add it to the scene yourself)
|
|
30
|
+
- `volume?: { contains, bounds? }` A plain volume with contains({ x, y, z }); with level it is water inside the volume
|
|
27
31
|
- `radius?: number`
|
|
28
32
|
- `halfWidth?: number`
|
|
29
33
|
- `halfDepth?: number`
|
package/docs/api/weather.md
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
# engine.weather — weather()
|
|
1
|
+
# engine.weather — weather(opts?: WeatherOptions)
|
|
2
2
|
|
|
3
|
-
Weather state (weather() module): the table, current values, set /
|
|
3
|
+
Weather state (weather() module): the table, current values, set / auto, save, events
|
|
4
4
|
|
|
5
|
+
- Options `WeatherOptions`:
|
|
6
|
+
- `start?: WeatherName` Starting weather, default 'clear' (or the first of the game's types when it has no 'clear')
|
|
7
|
+
- `auto?: boolean` Automatic weather changes
|
|
8
|
+
- `particles?: number` Rain / snow particle count, default 6000
|
|
9
|
+
- `rain?: WeatherParticles` Rain particles (default streaks: color 0xc8c8c8, opacity 0.55, length 0.7 m, speed 22 m/s, slant 1); a texture or a sprite shape draws drops
|
|
10
|
+
- `snow?: WeatherParticles & { cover?: SnowCover }` Snow particles (default round sprites: color 0xffffff, opacity 0.9, size 20, maxSize 5 px, speed 1.6 m/s, sway 1.5 m), plus the cover it leaves
|
|
11
|
+
- `lightning?: (flash: number, engine: Engine) => number` Strike picture: flash (1 at the strike, fading in a third of a second) -> sky flash amount; default flickers. Return 0 and draw your own bolt on the weather:lightning event for a whole replacement. Example: `lightning: f => f * f * 0.8`
|
|
12
|
+
- `lightningBrightness?: number` Multiplies the sky flash of every strike, default 1
|
|
13
|
+
- `overcastColor?: ColorLike` Color the sky turns as a weather type raises grey, default 0x8c8c8c
|
|
14
|
+
- `types?: Record<string, Partial<WeatherPreset> & Record<string, numb…` The game's weather table, the whole list (default only a calm 'clear'; seven temperate ones in presets.weather.temperate.types, extend them with { ...presets.weather.temperate.types, dust: {...} }). Left-out fields are calm; extra numeric fields of the game's own blend too and show in weather.current
|
|
15
|
+
- `autoPool?: string[]` Candidates for automatic changes (repeat an entry for higher probability)
|
|
16
|
+
- `autoInterval?: number[]` Interval between automatic changes [shortest, longest] seconds
|
|
17
|
+
- `transition?: number` Transition seconds of automatic changes, default 25
|
|
18
|
+
- `area?: number` Rain / snow coverage (meters)
|
|
19
|
+
- `lightningFirst?: number` Seconds to the first bolt once a type with lightning > 0.5 holds, default 5
|
|
20
|
+
- `lightningInterval?: number[]` Seconds between later bolts [shortest, longest], default [6, 20]
|
|
5
21
|
|
|
6
22
|
## Methods and properties
|
|
7
|
-
- `weather.
|
|
8
|
-
- `weather.setAuto(on: boolean)` — Automatic weather on/off
|
|
23
|
+
- `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 });`
|
|
9
24
|
- `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
25
|
- `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
|
|
11
26
|
- Properties:
|
|
12
27
|
- `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
28
|
- `current: WeatherPreset` Current (mid-transition) weather parameters
|
|
14
29
|
- `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
|
|
30
|
+
- `autoPool: string[]` (experimental) Candidates for automatic weather (repeat a name to make it likelier)
|
|
31
|
+
- `autoInterval: number[]` (experimental) Automatic weather interval [min, max] seconds
|
|
32
|
+
- `autoTransition: number` (experimental) Transition seconds for automatic weather
|
|
33
|
+
- `lightningFirst: number` (experimental) Seconds to the first bolt (also after a load without a saved timer)
|
|
34
|
+
- `lightningInterval: number[]` (experimental) [min, max] seconds between bolts while a type with lightning > 0.5 holds
|
|
35
|
+
- `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
36
|
- `lightningBrightness: number` Multiplies the sky flash of every strike; write it at any time
|
|
23
37
|
- `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
|
|
38
|
+
- `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;`
|
|
39
|
+
- `auto: boolean` Automatic weather on/off.
|
package/docs/api/weatherDraw.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# engine.weatherDraw —
|
|
1
|
+
# engine.weatherDraw — weather(opts?: WeatherOptions)
|
|
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)
|