threedog 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +276 -1
- package/README.md +18 -13
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +116 -61
- package/core/{Baked.js → assets/Baked.js} +16 -25
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- package/core/{assetLoad.js → assets/assetLoad.js} +66 -29
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +23 -12
- package/core/{assetReport.js → assets/assetReport.js} +9 -15
- package/core/{namedModel.js → assets/namedModel.js} +24 -16
- package/core/{Audio.js → audio/Audio.js} +27 -24
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +10 -10
- package/core/{Random.js → base/Random.js} +5 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +154 -139
- package/core/{errorHints.js → base/errorHints.js} +9 -10
- package/core/{errors.js → base/errors.js} +9 -9
- package/core/{events.generated.js → base/events.generated.js} +2 -0
- package/core/{math.js → base/math.js} +22 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +29 -8
- package/core/{Engine.js → engine/Engine.js} +112 -105
- package/core/{Loading.js → engine/Loading.js} +4 -2
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
- package/core/{lifecycle.js → engine/lifecycle.js} +16 -16
- package/core/{loop.js → engine/loop.js} +80 -52
- package/core/{moduleSlots.js → engine/moduleSlots.js} +35 -10
- package/core/{moduleTypes.js → engine/moduleTypes.js} +30 -18
- package/core/{modules.js → engine/modules.js} +20 -17
- package/core/engine/page.js +125 -0
- package/core/{plugins.js → engine/plugins.js} +68 -103
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +35 -35
- package/core/{Input.js → input/Input.js} +41 -27
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/{inputPad.js → input/inputPad.js} +1 -1
- package/core/{inputPointer.js → input/inputPointer.js} +8 -2
- package/core/{inputTouch.js → input/inputTouch.js} +1 -1
- package/core/{Budget.js → inspect/Budget.js} +23 -22
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +60 -31
- package/core/{Describe.js → inspect/Describe.js} +33 -30
- package/core/{Inspect.js → inspect/Inspect.js} +14 -9
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +8 -10
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +29 -16
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +9 -6
- package/core/inspect/UrlState.js +182 -0
- package/core/{catalog.js → inspect/catalog.js} +18 -5
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +8 -8
- package/core/inspect/describeRender.js +148 -0
- package/core/{describeText.js → inspect/describeText.js} +17 -12
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +11 -9
- package/core/inspect/pictureWriters.js +342 -0
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/{Ops.js → ops/Ops.js} +16 -11
- package/core/{control.js → ops/control.js} +13 -12
- package/core/ops/holds.js +139 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
- package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +7 -4
- package/core/{owned.js → ops/owned.js} +37 -37
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -27
- package/core/{stackFrames.js → ops/stackFrames.js} +17 -6
- package/core/{stacks.js → ops/stacks.js} +18 -20
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
- package/core/{Saves.js → saves/Saves.js} +58 -36
- package/core/{saveApply.js → saves/saveApply.js} +13 -9
- package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
- package/core/{saveValues.js → saves/saveValues.js} +20 -3
- package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
- package/core/{session.js → saves/session.js} +31 -17
- package/core/{Rays.js → scene/Rays.js} +27 -24
- package/core/{Views.js → scene/Views.js} +15 -6
- package/core/{adaptive.js → scene/adaptive.js} +15 -8
- package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
- package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
- package/core/{gameLights.js → scene/gameLights.js} +24 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +4 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/{ground.js → scene/ground.js} +9 -9
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/scene/pictureSlots.js +33 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +14 -6
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -20
- package/core/scene/stepPoses.js +55 -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} +4 -3
- package/core/{things.js → scene/things.js} +19 -6
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +1 -1
- package/core/scene/view.js +44 -0
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +62 -33
- package/core/{batchGroups.js → stream/batchGroups.js} +18 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +41 -1
- package/core/{scatter.js → stream/scatter.js} +2 -2
- package/core/{streamSources.js → stream/streamSources.js} +12 -7
- package/core/{Commits.js → threads/Commits.js} +6 -5
- package/core/{Jobs.js → threads/Jobs.js} +12 -10
- package/core/{Threads.js → threads/Threads.js} +16 -16
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +17 -10
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +18 -17
- package/core/{time.js → time/time.js} +18 -12
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +70 -63
- package/docs/API.md +30 -29
- package/docs/CODEMAP.md +98 -223
- package/docs/COMMANDS.md +80 -69
- package/docs/CONVENTIONS.md +87 -41
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +100 -49
- package/docs/api/assets.md +17 -16
- package/docs/api/audio.md +8 -7
- package/docs/api/budget.md +8 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +29 -29
- package/docs/api/characters.md +26 -19
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +14 -11
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +82 -53
- package/docs/api/events.md +5 -3
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +9 -2
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +4 -1
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +10 -9
- package/docs/api/interactions.md +6 -4
- package/docs/api/inventory.md +10 -11
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -8
- package/docs/api/lightPool.md +2 -7
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/occlusion.md +5 -0
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +8 -5
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +7 -1
- package/docs/api/post.md +24 -5
- package/docs/api/quests.md +3 -3
- package/docs/api/rays.md +5 -7
- package/docs/api/rigid.md +27 -18
- package/docs/api/saves.md +8 -7
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +17 -14
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +17 -12
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +30 -26
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +11 -5
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +11 -6
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +38 -57
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +47 -42
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +72 -66
- package/docs/recipes/06-clock-events.md +30 -21
- package/docs/recipes/07-flow-scenes-pause.md +21 -17
- package/docs/recipes/08-weather-sky.md +117 -75
- package/docs/recipes/09-materials-lights-models.md +171 -0
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +33 -25
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +50 -22
- package/docs/recipes/14-custom-module.md +20 -17
- package/docs/recipes/15-perf.md +52 -29
- package/docs/recipes/16-dev-bridge.md +47 -57
- package/docs/recipes/18-world.md +45 -30
- package/docs/recipes/19-shooting-picking.md +11 -7
- package/docs/recipes/20-content-actions-save.md +36 -37
- package/docs/recipes/21-camera.md +41 -8
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +11 -11
- package/docs/recipes/26-ui-parts.md +56 -22
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +126 -30
- package/docs/recipes/29-grid.md +16 -7
- package/docs/recipes/30-templates.md +62 -21
- package/docs/recipes/31-audio.md +9 -9
- package/docs/recipes/32-action-game.md +32 -9
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +164 -52
- package/docs/recipes/35-picture-from-reference.md +140 -0
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +105 -30
- package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +74 -106
- package/docs/recipes/44-water-weather-hooks.md +196 -0
- package/docs/recipes/45-cascaded-shadows.md +145 -25
- package/docs/recipes/46-blender-art-route.md +21 -25
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +3 -3
- package/docs/recipes/52-around-the-picture.md +137 -0
- package/docs/recipes/53-ground-up-close.md +65 -28
- package/docs/recipes/55-mods-time-wrap.md +25 -17
- package/docs/recipes/56-webgpu-tsl.md +73 -28
- package/docs/recipes/57-control.md +47 -1
- package/docs/recipes/58-input.md +3 -0
- package/docs/recipes/59-depth-post-effects.md +5 -5
- package/docs/recipes/60-judge-the-picture.md +47 -27
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +276 -0
- package/docs/recipes/63-third-person-start.md +90 -0
- package/docs/recipes/64-particles.md +35 -0
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +9 -7
- package/examples/action/main.js +5 -4
- package/examples/action/models.js +12 -14
- package/examples/action/picture/index.js +13 -0
- package/examples/action/picture/lights.js +35 -0
- package/examples/action/picture/materials.js +8 -0
- package/examples/action/picture/palette.js +33 -0
- package/examples/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +18 -14
- package/examples/{sheepisland → perf-island}/assets.js +2 -2
- package/examples/{sheepisland → perf-island}/content/templates.js +1 -1
- package/examples/{sheepisland → perf-island}/content/vegetation.js +3 -1
- package/examples/{sheepisland → perf-island}/main.js +22 -16
- package/examples/{sheepisland/style → perf-island}/models.js +13 -24
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/perf-island/picture/index.js +20 -0
- package/examples/perf-island/picture/lights.js +34 -0
- package/examples/perf-island/picture/materials.js +61 -0
- package/examples/perf-island/picture/palette.js +60 -0
- package/examples/perf-island/picture/sky.js +20 -0
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/GAMEMAP.md +91 -0
- package/examples/plain-picture/main.js +48 -0
- package/examples/plain-picture/picture/index.js +21 -0
- package/examples/plain-picture/picture/lights.js +54 -0
- package/examples/plain-picture/picture/materials.js +24 -0
- package/examples/plain-picture/picture/palette.js +16 -0
- package/examples/plain-picture/picture/sky.js +37 -0
- package/examples/pullable.json +31 -9
- package/examples/rc2d/GAMEMAP.md +10 -4
- package/examples/rc2d/README.md +11 -6
- package/examples/rc2d/main.js +26 -36
- package/examples/rc2d/picture/index.js +18 -0
- package/examples/rc2d/picture/lights.js +11 -0
- package/examples/rc2d/picture/materials.js +18 -0
- package/examples/rc2d/picture/palette.js +15 -0
- package/examples/rc2d/picture/post.js +11 -0
- package/examples/rc2d/rc2d.js +18 -28
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +15 -10
- package/examples/styletest/main.js +20 -30
- package/examples/styletest/models.js +29 -29
- package/examples/styletest/params.js +1 -4
- package/examples/styletest/picture/env.js +38 -0
- package/examples/styletest/picture/index.js +16 -0
- package/examples/styletest/picture/lights.js +9 -0
- package/examples/styletest/picture/materials.js +28 -0
- package/examples/styletest/picture/palette.js +22 -0
- package/examples/techniques/contact-shadows/README.md +22 -23
- package/examples/techniques/contact-shadows/contactShadows.js +32 -16
- package/examples/techniques/contact-shadows/main.js +20 -18
- package/examples/techniques/contact-shadows/picture/index.js +14 -0
- package/examples/techniques/contact-shadows/picture/lights.js +34 -0
- package/examples/techniques/contact-shadows/picture/materials.js +12 -0
- package/examples/techniques/contact-shadows/picture/palette.js +17 -0
- package/examples/techniques/day-night-grade/README.md +13 -16
- package/examples/techniques/day-night-grade/main.js +15 -25
- package/examples/techniques/day-night-grade/picture/index.js +20 -0
- package/examples/techniques/day-night-grade/picture/lights.js +45 -0
- package/examples/techniques/day-night-grade/picture/materials.js +15 -0
- package/examples/techniques/day-night-grade/picture/palette.js +59 -0
- package/examples/techniques/day-night-grade/picture/post.js +25 -0
- package/examples/techniques/day-night-grade/picture/sky.js +33 -0
- package/examples/techniques/interior-light/README.md +16 -13
- package/examples/techniques/interior-light/interiorLight.js +19 -17
- package/examples/techniques/interior-light/main.js +31 -68
- package/examples/techniques/interior-light/picture/index.js +24 -0
- package/examples/techniques/interior-light/picture/lights.js +52 -0
- package/examples/techniques/interior-light/picture/materials.js +13 -0
- package/examples/techniques/interior-light/picture/palette.js +32 -0
- package/examples/techniques/interior-light/picture/sky.js +40 -0
- package/examples/techniques/modular-building/README.md +8 -6
- package/examples/techniques/modular-building/kit.js +2 -2
- package/examples/techniques/modular-building/main.js +9 -17
- package/examples/techniques/modular-building/picture/index.js +17 -0
- package/examples/techniques/modular-building/picture/lights.js +26 -0
- package/examples/techniques/modular-building/picture/materials.js +13 -0
- package/examples/techniques/modular-building/picture/palette.js +23 -0
- package/examples/techniques/night-lights/README.md +15 -14
- package/examples/techniques/night-lights/main.js +20 -43
- package/examples/techniques/night-lights/nightLights.js +25 -21
- package/examples/techniques/night-lights/picture/index.js +18 -0
- package/examples/techniques/night-lights/picture/lights.js +44 -0
- package/examples/techniques/night-lights/picture/materials.js +15 -0
- package/examples/techniques/night-lights/picture/palette.js +34 -0
- package/examples/techniques/night-lights/picture/post.js +9 -0
- package/examples/techniques/night-lights/picture/sky.js +36 -0
- package/examples/techniques/outlines-and-rim/README.md +2 -2
- package/examples/techniques/outlines-and-rim/main.js +15 -38
- package/examples/techniques/outlines-and-rim/outlines.js +3 -3
- package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
- package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
- package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
- package/examples/techniques/procedural-animation/README.md +6 -4
- package/examples/techniques/procedural-animation/main.js +9 -7
- package/examples/techniques/procedural-animation/picture/index.js +15 -0
- package/examples/techniques/procedural-animation/picture/lights.js +35 -0
- package/examples/techniques/procedural-animation/picture/materials.js +10 -0
- package/examples/techniques/procedural-animation/picture/palette.js +16 -0
- package/examples/techniques/procedural-animation/picture/sky.js +31 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
- package/examples/techniques/procedural-surface/README.md +2 -0
- package/examples/techniques/procedural-surface/main.js +17 -55
- package/examples/techniques/procedural-surface/picture/index.js +14 -0
- package/examples/techniques/procedural-surface/picture/lights.js +18 -0
- package/examples/techniques/procedural-surface/picture/materials.js +34 -0
- package/examples/techniques/procedural-surface/picture/palette.js +15 -0
- package/examples/techniques/stylized-shading/README.md +13 -14
- package/examples/techniques/stylized-shading/main.js +11 -42
- package/examples/techniques/stylized-shading/picture/index.js +14 -0
- package/examples/techniques/stylized-shading/picture/lights.js +23 -0
- package/examples/techniques/stylized-shading/picture/materials.js +18 -0
- package/examples/techniques/stylized-shading/picture/palette.js +19 -0
- package/examples/techniques/stylized-shading/shading.js +2 -2
- package/examples/techniques/sun-and-key-light/README.md +20 -22
- package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
- package/examples/techniques/sun-and-key-light/main.js +19 -63
- package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
- package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
- package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
- package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
- package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
- package/examples/techniques/three-looks/README.md +21 -0
- package/examples/techniques/three-looks/main.js +58 -0
- package/examples/techniques/three-looks/picture/cartoon.js +23 -0
- package/examples/techniques/three-looks/picture/cinematic.js +27 -0
- package/examples/techniques/three-looks/picture/comic.js +27 -0
- package/examples/techniques/three-looks/picture/index.js +14 -0
- package/examples/techniques/three-looks/picture/sun.js +23 -0
- package/examples/techniques/wet-road/README.md +7 -4
- package/examples/techniques/wet-road/main.js +18 -38
- package/examples/techniques/wet-road/picture/index.js +17 -0
- package/examples/techniques/wet-road/picture/lights.js +57 -0
- package/examples/techniques/wet-road/picture/materials.js +16 -0
- package/examples/techniques/wet-road/picture/palette.js +24 -0
- package/examples/techniques/wet-road/picture/sky.js +46 -0
- package/examples/webgpu-tsl/GAMEMAP.md +10 -4
- package/examples/webgpu-tsl/README.md +13 -10
- package/examples/webgpu-tsl/main.js +30 -7
- package/examples/webgpu-tsl/picture/index.js +18 -0
- package/examples/webgpu-tsl/picture/lights.js +25 -0
- package/examples/webgpu-tsl/picture/materials.js +36 -0
- package/examples/webgpu-tsl/picture/palette.js +23 -0
- package/examples/webgpu-tsl/picture/post.js +16 -0
- package/examples/webgpu-tsl/picture/sky.js +30 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +16 -12
- package/examples/world/art/humanoid.js +9 -13
- package/examples/world/art/index.js +2 -2
- package/examples/world/art/models.js +3 -4
- package/examples/world/art/shapes.js +2 -2
- package/examples/world/assets.js +2 -2
- package/examples/world/content/audio.js +1 -1
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +10 -10
- package/examples/world/models.js +17 -7
- package/examples/world/picture/index.js +20 -0
- package/examples/world/picture/lights.js +41 -0
- package/examples/world/picture/materials.js +34 -0
- package/examples/world/picture/palette.js +74 -0
- package/examples/world/picture/post.js +9 -0
- package/examples/world/picture/sky.js +39 -0
- package/index.d.ts +14 -22
- package/index.js +36 -36
- package/llms.txt +19 -21
- package/modules/ambience/Ambience.js +12 -9
- package/modules/calendar/Calendar.js +20 -20
- package/modules/calendar/index.js +14 -13
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +2 -2
- package/modules/camera/FixedCamera.js +14 -15
- package/modules/camera/FollowCamera.js +4 -4
- package/modules/camera/RtsCamera.js +11 -11
- package/modules/camera/common.js +51 -25
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +47 -39
- package/modules/characters/NPC.js +30 -22
- package/modules/characters/assetModel.js +18 -13
- package/modules/characters/astar.js +7 -5
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +172 -193
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +22 -15
- package/modules/characters/movers/manual.js +4 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +32 -18
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +28 -18
- package/modules/characters/npcView.js +6 -5
- package/modules/characters/pathAsync.js +12 -10
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +108 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +19 -5
- package/modules/characters/useModel.js +5 -5
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +30 -22
- package/modules/collision/contract.js +15 -0
- package/modules/content/explain.js +1 -2
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +2 -2
- package/modules/content/index.js +68 -98
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +66 -18
- package/modules/content/packs.js +3 -3
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +35 -0
- package/modules/content/props.js +19 -14
- package/modules/content/rules.js +34 -22
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +24 -22
- package/modules/content/words.js +34 -0
- package/modules/debug/DebugPanel.js +10 -43
- package/modules/flow/contract.js +1 -1
- package/modules/flow/index.js +11 -7
- package/modules/gameplay/Container.js +12 -11
- package/modules/gameplay/Containers.js +14 -5
- package/modules/gameplay/Dialogue.js +13 -11
- package/modules/gameplay/Interactions.js +115 -27
- package/modules/gameplay/Inventory.js +11 -12
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBox.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +4 -5
- package/modules/gameplay/interactionPrompt.js +1 -1
- package/modules/gameplay/interactions.contract.js +1 -1
- package/modules/gameplay/inventoryOps.js +2 -3
- package/modules/gameplay/pickups.js +81 -44
- package/modules/gameplay/questLog.js +2 -2
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +16 -3
- package/modules/grid/index.js +47 -19
- package/modules/grid/preview.js +29 -20
- package/modules/grid/tiles.js +19 -23
- package/modules/hlod/index.js +38 -55
- package/modules/hud/index.js +27 -8
- package/modules/hud/parts.js +13 -11
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +48 -152
- package/modules/level/load.js +79 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +6 -7
- package/modules/lights/index.js +34 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +31 -27
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +14 -0
- package/modules/nav/index.js +11 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +5 -4
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +49 -25
- package/modules/particles/effect.js +27 -10
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +26 -27
- package/modules/rigid/RigidBodies.js +66 -43
- package/modules/rigid/Vehicles.js +2 -3
- package/modules/rigid/ragdoll.js +287 -0
- package/modules/rigid/ragdollBones.js +159 -0
- package/modules/rigid/sync.js +6 -6
- package/modules/settings/Settings.js +114 -45
- package/modules/settings/apply.js +10 -10
- package/modules/settings/sections.js +16 -14
- package/modules/settings/strings.js +1 -1
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +125 -103
- package/modules/sky/clouds.js +22 -23
- package/modules/sky/dome.js +113 -0
- package/modules/sky/domeLayers.js +13 -13
- package/modules/sky/environment.js +47 -171
- package/modules/sky/fog.js +5 -180
- package/modules/sky/frame.js +42 -97
- package/modules/sky/season.js +9 -3
- package/modules/sky/shader.js +49 -44
- package/modules/sky/skyModule.js +25 -35
- package/modules/sky/tint.js +9 -11
- package/modules/swarm/Swarm.js +346 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +97 -62
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +157 -0
- package/modules/terrain/index.js +60 -88
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +4 -3
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +19 -14
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +27 -19
- package/modules/timeline/Tween.js +6 -6
- package/modules/timeline/shots.js +5 -7
- package/modules/triggers/index.js +19 -15
- package/modules/vegetation/Vegetation.js +87 -39
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +196 -0
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +18 -16
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +140 -93
- package/modules/water/surface.js +56 -56
- package/modules/weather/Weather.js +84 -38
- package/modules/weather/particles.js +18 -10
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/weatherDraw.js +145 -0
- package/modules/world/World.js +10 -10
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -12
- package/modules/world/persist.js +73 -25
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +28 -8
- package/modules/world/sim.js +4 -4
- package/modules/world/state.js +12 -5
- package/modules/world/thingSource.js +4 -2
- package/modules/world/views.js +12 -10
- package/package.json +44 -8
- package/presets.js +3 -5
- package/render/PostFX.js +233 -63
- package/render/backend.js +72 -32
- package/render/cascades.js +200 -0
- package/render/cascades.tsl.js +93 -0
- package/render/daylight.js +56 -0
- package/render/detail.js +13 -12
- package/render/effects.js +60 -42
- package/render/fuse.js +3 -3
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +10 -13
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/patchNodes.tsl.js +6 -16
- package/render/fx/postWebGPU.tsl.js +55 -28
- package/render/fx/sky.tsl.js +34 -109
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/water.tsl.js +1 -1
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +14 -0
- package/render/lighting.js +11 -8
- package/render/lightmap.js +142 -0
- package/render/lights.js +26 -204
- package/render/lit.js +24 -0
- package/render/materials.js +47 -162
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/neutral.js +23 -0
- package/render/occlusion.js +200 -0
- package/render/ownFrame.js +5 -5
- package/render/patches.js +46 -41
- package/render/postWebGL.js +19 -9
- package/render/probes.js +182 -128
- 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/render/shadows.js +451 -0
- package/render/slots.js +11 -11
- package/render/terms.js +63 -113
- package/render/uniformDecl.js +2 -2
- package/types/core.d.ts +489 -405
- package/types/gameplay.d.ts +225 -114
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +23 -8
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/engine/page.d.ts +24 -0
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +21 -10
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +16 -8
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Layer.d.ts +9 -1
- package/types/generated/modules/grid/index.d.ts +32 -8
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +14 -7
- package/types/generated/modules/sky/Sky.d.ts +101 -23
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +2 -1
- package/types/generated/modules/water/Water.d.ts +51 -3
- package/types/generated/modules/weather/Weather.d.ts +44 -10
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +7 -5
- package/types/generated/render/PostFX.d.ts +69 -20
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +20 -44
- package/types/generated/render/occlusion.d.ts +22 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +11 -11
- package/types/physics.d.ts +104 -73
- package/types/tsl.d.ts +45 -4
- package/types/world.d.ts +372 -86
- package/ui/Focus.js +21 -10
- package/ui/LoadingScreen.js +2 -2
- package/ui/Parts.js +12 -7
- package/ui/UI.js +17 -17
- package/ui/cursor.js +1 -1
- package/ui/defaults.js +3 -2
- package/ui/theme.js +36 -28
- package/ui/touchPart.js +1 -1
- package/core/UrlState.js +0 -110
- package/core/assetEntry.js +0 -106
- package/core/describeRender.js +0 -71
- package/core/holds.js +0 -134
- package/core/look/coreParts.js +0 -219
- package/core/look/part.js +0 -253
- package/core/look/points.js +0 -255
- package/core/look/report.js +0 -96
- package/core/look/shadowPart.js +0 -63
- package/core/look/state.js +0 -45
- package/core/look/write.js +0 -70
- package/core/page.js +0 -79
- package/core/shadowTypes.js +0 -16
- package/core/styleParts.js +0 -114
- package/core/util.js +0 -17
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -228
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/PERF.md +0 -245
- package/docs/api/style.md +0 -136
- package/docs/api/terrainLook.md +0 -10
- package/docs/api/vegetationLook.md +0 -10
- package/docs/api/weatherLook.md +0 -10
- package/docs/recipes/09-style.md +0 -218
- package/docs/recipes/35-style-from-reference.md +0 -153
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/37-terrain-look-hooks.md +0 -119
- package/docs/recipes/38-environment-look-hooks.md +0 -99
- package/docs/recipes/41-thing-registry.md +0 -97
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/44-water-weather-look-hooks.md +0 -144
- package/docs/recipes/47-island-snow-backdrop.md +0 -45
- package/docs/recipes/48-make-material.md +0 -75
- package/docs/recipes/52-look.md +0 -282
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/.threedog/content-index.json +0 -1
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
- package/examples/webgpu-tsl/tslScene.js +0 -75
- package/examples/world/style/index.js +0 -61
- package/examples/world/style/plugins/10-bloom.js +0 -5
- package/modules/sky/cascades.js +0 -186
- package/modules/sky/cascades.tsl.js +0 -82
- package/modules/sky/look.js +0 -54
- package/modules/sky/lookFog.js +0 -76
- package/modules/sky/lookShadow.js +0 -62
- package/modules/sky/lookSky.js +0 -169
- package/modules/sky/shadow.js +0 -98
- package/modules/terrain/look.js +0 -83
- package/modules/terrain/lookGround.js +0 -66
- package/modules/vegetation/look.js +0 -119
- package/modules/vegetation/lookWind.js +0 -98
- package/modules/water/look.js +0 -91
- package/modules/water/surfaceDefaults.js +0 -3
- package/modules/weather/look.js +0 -74
- package/modules/weather/weatherLook.js +0 -135
- package/render/lookGlow.js +0 -139
- package/render/lookSurface.js +0 -224
- package/render/postLook.js +0 -164
- package/render/surface.js +0 -105
- package/types/generated/core/page.d.ts +0 -18
- package/types/generated/modules/weather/weatherLook.d.ts +0 -12
- package/types/style.d.ts +0 -671
- /package/core/{Vars.js → base/Vars.js} +0 -0
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsFail.js → ops/opsFail.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{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
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# Crisp ground color borders, terrain normals, height from a grid
|
|
2
|
-
|
|
3
|
-
For an AI that wants the ground to look a way the defaults do not: crisp color borders (a river bank, a path edge), a coarse low-poly mesh with
|
|
4
|
-
fine color, a different triangle cut, custom lighting normals, height read from a grid or image. Terrain basics are in `28-terrain.md`, ground
|
|
5
|
-
color noise in `36-sky-ground-plant-looks.md`, the ground up close (detail, variation, symptoms) in `53-ground-up-close.md`. Each knob names its
|
|
6
|
-
default (`tests/specs/terrain-look.mjs` pins them). Each knob has three exits: a parameter, a small pure function, or replacing the whole ground material.
|
|
7
|
-
|
|
8
|
-
## Why the bank is jagged: color lived on the mesh
|
|
9
|
-
With `shading: 'smooth'` or `'flat'` a color is computed at a grid point (or triangle center) and blended across the triangle. At the default
|
|
10
|
-
`resolution: 16` on a 64 m chunk that is one color sample per 4 m, so any border between two ground types can only run along triangle edges.
|
|
11
|
-
Raising `resolution` fixes it at the price of triangles (and collision, and edit granularity). `shading: 'texture'` cuts the link: color is
|
|
12
|
-
computed per pixel into a per-chunk image, the mesh stays as coarse as you like.
|
|
13
|
-
|
|
14
|
-
## 1. `shading: 'texture'` (and `colorResolution`)
|
|
15
|
-
```js
|
|
16
|
-
engine.use(terrain({ ...terrainPreset(), shading: 'texture', colorResolution: 128 }));
|
|
17
|
-
// or as a look of a style: terrain: { config: { shading: 'texture', colorResolution: 128 }, colors, biomeColors, ... }
|
|
18
|
-
```
|
|
19
|
-
- A worker computes a `(colorResolution + 2)^2` RGBA image per chunk with the same rules as the vertex colors (`faceColor`: ground type from your
|
|
20
|
-
`groundType`, `biomeColors` two-color noise blend, `steep` slope colors, `style.terrain.variation` blend / jitter / patches, painted cells).
|
|
21
|
-
The main thread uploads it as a `DataTexture` (sRGB, mipmaps, anisotropy 4). The `+ 2` is a 1 pixel border computed from world coordinates, so
|
|
22
|
-
neighboring chunks hold identical values at the seam and no seam shows (checked byte for byte).
|
|
23
|
-
- Vertex colors are plain white in this mode (they carry no color). The material samples the image by world xz (the `world` patch), so `uv`
|
|
24
|
-
stays free (`world xz / chunk size`, for your own textures). Each chunk gets its own clone of the terrain material (same patches, one compiled
|
|
25
|
-
program), so a change you make to the terrain material object after chunks exist does not reach loaded chunks; pass it through `terrain({ material })`.
|
|
26
|
-
- Painted cells (`terrain.edit(..., { paint })`) keep their whole-cell color; the image of every chunk touched by an edit is re-uploaded in place.
|
|
27
|
-
- Steep-slope colors test a normal interpolated between grid points, so they no longer follow single triangles either.
|
|
28
|
-
- Independent of `resolution`: `resolution` still sets mesh, collision and edit granularity, `colorResolution` only the color detail
|
|
29
|
-
(64 m chunk: 128 = 0.5 m per pixel, 256 = 0.25 m).
|
|
30
|
-
|
|
31
|
-
Numbers (resolution 16, 64 m chunk, a curved ground-type border, rendered top-down in the real engine, error against the true curve):
|
|
32
|
-
|
|
33
|
-
| shading | border RMS error | border jaggedness (RMS 2nd difference) |
|
|
34
|
-
| --- | --- | --- |
|
|
35
|
-
| smooth | 1.12 m | 0.48 |
|
|
36
|
-
| texture, colorResolution 128 | 0.14 m | 0.10 |
|
|
37
|
-
|
|
38
|
-
Cost (software-rendered machine, relative values only):
|
|
39
|
-
- worker time per chunk: about 9 ms for `texture` at 128 (calculation is mostly your `groundType` called once per pixel) against 1.1 ms for smooth
|
|
40
|
-
(measured in Node, the worker runs the same code); 64 costs a quarter, 256 four times that.
|
|
41
|
-
- memory: 130 x 130 x 4 = 68 KB per chunk plus mipmaps (about 90 KB; 23 KB at 64). 69 loaded chunks = about 6 MB at 128.
|
|
42
|
-
- `threedog perf --only=stream --shading=texture` against the default: frame CPU average 5.5 ms both; worst frame 64 ms -> 88 ms (one-time shader
|
|
43
|
-
program compile plus first uploads, it lands once, not per chunk); upload stage total 41 ms -> 112 ms over 69 chunks.
|
|
44
|
-
- Low-tier devices (`engine.tier === 'low'`, see `core/tier.js`): if you did not set `colorResolution`, the terrain module uses 64 there. To skip the
|
|
45
|
-
color map completely on low tier, choose the shading yourself: `shading: engine.tier === 'low' ? 'smooth' : 'texture'` in your terrain() call.
|
|
46
|
-
- With `terrain({ shape })` (an outline, `42-terrain-shape.md`) the map covers the top only: void pixels keep the color of the ground under them
|
|
47
|
-
(no seam at the rim) with alpha 0, and island sides and bottom draw with vertex colors (or `shape.side.material`).
|
|
48
|
-
|
|
49
|
-
## 2. Lighting normals: `normals` and `normalFn`
|
|
50
|
-
- `shading: 'smooth'` lights with one normal per grid point, `'flat'` one per triangle. In texture mode choose: `normals: 'smooth'` (default) or
|
|
51
|
-
`'flat'` (faceted light, fine color: a low-poly shape with crisp borders).
|
|
52
|
-
- `normalFn(i, j, h, cell) => [nx, ny, nz]` replaces the smooth normal at grid point `(i, j)`; `h(i, j)` reads a grid-point height, `cell` is the
|
|
53
|
-
spacing in meters. Pure like `height` / `groundType` (only its parameters, `Math`; a function you pass travels to workers as source text and an
|
|
54
|
-
outside variable throws naming it). The engine normalizes the result. Default: central difference of the four neighbors.
|
|
55
|
-
```js
|
|
56
|
-
terrain({ normalFn: (i, j, h, cell) => [(h(i - 1, j) - h(i + 1, j)) / cell, 4, (h(i, j - 1) - h(i, j + 1)) / cell] }) // gentler lighting on slopes
|
|
57
|
-
```
|
|
58
|
-
`normals` and `normalFn` are looks (a style may set them); they change light only, never height or collision. `normals` is a `look.ground` param
|
|
59
|
-
(`engine.look.ground.set({ normals: 'flat' })`, rebuilds the chunks), not a `terrain()` option.
|
|
60
|
-
|
|
61
|
-
## 3. `diagonal`: how a cell is cut into triangles
|
|
62
|
-
```js
|
|
63
|
-
terrain({ diagonal: 'adaptive' }) // 'fixed' (default) | 'adaptive' | 'alternate'
|
|
64
|
-
```
|
|
65
|
-
`fixed` cuts every cell the same way. `adaptive` cuts along the diagonal with the smaller height difference, which removes
|
|
66
|
-
the zigzag ridges a fixed cut leaves on a slope; `alternate` flips every other cell (no directional bias on flat low-poly facets). `engine.surface`,
|
|
67
|
-
collision and vegetation heights follow the chosen cut, so nothing floats. Because it changes the walkable shape, it belongs to the game's
|
|
68
|
-
`terrain({...})`, not to a style (rule R34 and `style check` accept `shading`, `colorResolution`, `normals`, `normalFn` in `style.terrain.config`
|
|
69
|
-
and flag `diagonal`).
|
|
70
|
-
|
|
71
|
-
## 4. `boundsPad`: the chunk bounding sphere margin
|
|
72
|
-
`boundsPad: { up: 3, radius: 8 }` (meters, the defaults) is the margin of the culling sphere: the center is raised by `up`, the radius grows
|
|
73
|
-
by `radius`. Raise it if a shader moves vertices far (wind on tall ground cover, a vertex-displacement patch) and chunks pop out at the screen edge.
|
|
74
|
-
|
|
75
|
-
## 5. Relation to `style.terrain.variation`
|
|
76
|
-
`variation` shapes *what* color a point gets; `shading` decides *where* it is evaluated. In vertex modes every variation is limited to cell size; in
|
|
77
|
-
texture mode it is sampled per pixel, so `patches: { size: 20, levels: 4 }` gives hard-edged color blocks, and a `jitter.size` below the pixel size
|
|
78
|
-
(0.5 m at `colorResolution: 128`) comes out as one grain per pixel, coarser than asked. Choosing a combination, and ground that looks wrong up close: recipe 53.
|
|
79
|
-
|
|
80
|
-
## 6. Example: a river bank
|
|
81
|
-
```js
|
|
82
|
-
engine.use(terrain({
|
|
83
|
-
shading: 'texture', colorResolution: 192, resolution: 16,
|
|
84
|
-
height: (x, z) => 0,
|
|
85
|
-
// the border is a curve; the ground type is evaluated per pixel
|
|
86
|
-
groundType: (x, z) => z > 32 + 14 * Math.sin(x * 0.09) ? 'grass' : 'sand',
|
|
87
|
-
colors: { grass: 0x5a8a3a, sand: 0xd8c690 }, biomeColors: { grass: ['grass'], sand: ['sand'] },
|
|
88
|
-
}));
|
|
89
|
-
```
|
|
90
|
-
Using a preset (`riverAt` of `@threedog/terrain-noise`) the same switch gives crisp banks without more triangles: `terrain({ ...terrainPreset(), shading: 'texture' })`.
|
|
91
|
-
|
|
92
|
-
## 7. Height from a grid or image
|
|
93
|
-
`sampleGrid(data, { width, height, size | cellSize, origin, interp })` turns numbers laid out on a regular grid into a function `(x, z) => value`;
|
|
94
|
-
`await engine.assets.gridFromImage(nameOrUrl, { channel, range, bits })` reads such a grid from an image (PNG at full 8 or 16 bits, jpg/webp at 8;
|
|
95
|
-
`channel` is `'r'`/`'g'`/`'b'`/`'a'`; `range: [min, max]` maps the pixel values to world units, default `[0, 1]`). Samples sit on the grid nodes, so
|
|
96
|
-
`width` samples span `width - 1` cells; outside the grid the edge value is used, or `outside: v`. The grid is just a field: height, moisture, a
|
|
97
|
-
ground-type weight, spawn density, a walkable mask, danger, travel cost.
|
|
98
|
-
|
|
99
|
-
`interp` is the look between nodes; none of them is the right one:
|
|
100
|
-
- `'nearest'`: flat steps, one value per cell. Terraces, blocky or voxel-like ground, tile masks, numbers that are ids.
|
|
101
|
-
- `'linear'` (default): plain bilinear blend; smooth enough for most fields, never leaves the range of its four corners.
|
|
102
|
-
- `'cubic'`: smooth slopes without cell creases (rolling hills, soft gradients). It can overshoot beside a sharp step; `clamp: true` keeps the
|
|
103
|
-
result inside the four corner values.
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
const g = await engine.assets.gridFromImage('/maps/height16.png', { range: [-5, 60] }); // meters, 16-bit file
|
|
107
|
-
const heightAt = sampleGrid(g.data, { ...g, size: [512, 512], origin: [-256, -256], interp: 'cubic', clamp: true });
|
|
108
|
-
heightAt(10, 20); // gameplay side: where to put a camp, a mine, a lighthouse
|
|
109
|
-
const wet = sampleGrid(moisture, { width: 32, height: 32, cellSize: 8 }); // a hand-made field: wetter ground grows reeds, rice, moss
|
|
110
|
-
const walk = sampleGrid(mask, { width: 64, height: 64, cellSize: 1, interp: 'nearest', outside: 0 }); // 0 / 1 per tile; off the map: not walkable
|
|
111
|
-
```
|
|
112
|
-
A terrain `height` function is recompiled in a worker and cannot capture `heightAt`, so the terrain reads the same image through its own
|
|
113
|
-
`heightmap` (bilinear, centered on `center`): `terrain({ heightmap: { ...g, size: [512, 512], min: -5, max: 60 } })` with `g` from `gridFromImage`
|
|
114
|
-
using the default `range` (it expects 0-1 values; `min`/`max` scale them). Use `sampleGrid` for everything outside the terrain module; when you need
|
|
115
|
-
a look the terrain's bilinear read does not give (terraces: `nearest`), bake it into the data first or write the step in a `height` function.
|
|
116
|
-
|
|
117
|
-
## Whole replacement
|
|
118
|
-
Anything beyond this: `terrain({ material })` (or `style.terrain.material`) swaps the ground material and `engine.terrain.T.buildChunk(cx, cz)` returns the
|
|
119
|
-
raw arrays (`pos`, `nor`, `col`, `uv`, and `tex: { data, size }` in texture mode) if you build chunk meshes yourself.
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# Owning lights, fog and exposure yourself
|
|
2
|
-
|
|
3
|
-
The normal way to change lights, fog, exposure and the sky is `engine.look.<part>.set` / `patch` ([recipe 52](52-look.md)): the sky keeps
|
|
4
|
-
driving them over the day, and your values sit on top. This page is the next step, for when that is not enough: your own fog math, exposure over
|
|
5
|
-
the day, extra sky layers, and taking a light or the fog away from the sky entirely. Sky basics are in `08-weather-sky.md`, clouds and ground color in
|
|
6
|
-
`36-sky-ground-plant-looks.md`, environment lighting in `34-environment-lighting.md`. Each section starts with the `look` call and ends with the exit.
|
|
7
|
-
|
|
8
|
-
```js
|
|
9
|
-
// 1. keyframes (default): style.sky.keyframes / style.exposure lists drive the day; nothing to write
|
|
10
|
-
// 2. a function of the frame context, fed by one call: any key marked fn (fog color / near / far / density, sky top / horizon / backdrop, lights, exposure)
|
|
11
|
-
engine.look.fog.set({ color: ({ state }) => state.boss ? '#400' : 'horizon' }); engine.look.state({ boss: true });
|
|
12
|
-
// 3. your own three.js sky (three/addons Sky, a ShaderMaterial dome, a skybox): never written; time / weather keep flowing through engine.uniforms
|
|
13
|
-
engine.look.sky.replace(mySky); mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir; // the same Vector3, refreshed every frame
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Lights: override, take over, or switch off
|
|
17
|
-
The engine has one directional light (`engine.lights.sun`; moonlight at night, the shadows live on it) and one hemisphere
|
|
18
|
-
ambient (`engine.lights.hemi`). The sky module rewrites their color and intensity every frame from `style.sky.keyframes`,
|
|
19
|
-
so editing the three.js objects directly is overwritten (a dev warning says so). **Without the sky module** both lights are a bright placeholder
|
|
20
|
-
(hemi 1.2, white sun 2 at (40, 80, 30), no shadows).
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
engine.look.lights.set({ sun: { color: '#ffd0a0', intensity: 1.4 }, hemi: { intensity: 0.5 } }, { owner: 'dusk' }); // 1. override, any hour
|
|
24
|
-
engine.mod('look.lights.sun.intensity', { owner: 'cave', mul: 0.3 }); // or a multiplier on top of the day cycle (recipe 52)
|
|
25
|
-
|
|
26
|
-
engine.look.lights.manual(['sun.intensity', 'sun.color']); // 2. take over: the sky still aims the sun along the time of day and moves the shadow box
|
|
27
|
-
engine.lights.sun.color.set(0xffd0a0); engine.lights.sun.intensity = 1.4; // yours now, never overwritten
|
|
28
|
-
|
|
29
|
-
engine.use(sky({ sun: false, hemisphere: false })); // 3. switch off (a dungeon): both hidden, never touched; the dome still shows sun and moon
|
|
30
|
-
const torch = new THREE.PointLight(0xffa040, 6, 12); engine.add(torch); // add your own lights before engine.start()
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
- `sky({ sun, hemisphere })`: `true` (default) the sky drives everything; `false` `visible = false`, no shadows, never touched (lightning no
|
|
34
|
-
longer flashes the ambient either). Taking a value over is one call for every look value, `engine.look.<part>.manual(key)` (here
|
|
35
|
-
`look.lights.manual('sun' | 'hemi' | 'sun.intensity' ...)`), not a sky() option; `manual(key, false)` hands it back.
|
|
36
|
-
- `createEngine({ lights: false })` goes one step further: the default sun and hemisphere are never put in the scene, `engine.lights.sun` / `hemi`
|
|
37
|
-
stay as detached objects so nothing reads `undefined`. Use it for a scene lit entirely by your own lights.
|
|
38
|
-
- Shadows: only the engine sun's shadow is managed (`engine.look.shadow.set`). Your own `castShadow` lights work as in three.js, each costing its
|
|
39
|
-
own shadow pass; `look.shadow.set({ enabled: false })` turns theirs off too and restores them after.
|
|
40
|
-
- Add or remove lights before `engine.start()`: a light count that changes mid-play recompiles every material (one long frame). Many lamps or
|
|
41
|
-
torches: `lightPool({ point: 6 })` keeps a fixed number of real lights and moves them to the nearest sources (recipe 09, "Lights and stalls").
|
|
42
|
-
|
|
43
|
-
## Fog: kind, color, density, your own math, or your own fog
|
|
44
|
-
```js
|
|
45
|
-
engine.look.fog.set({ far: 220, color: '#9bb' }); // live: color, density, near, far, enabled, linear <-> exp2
|
|
46
|
-
engine.look.fog.set({ kind: 'height', height: 2, falloff: 0.08, density: 0.03 }); // valley mist; materials recompile once (below)
|
|
47
|
-
engine.look.fog.patch('fog', `vec4 threedogFog(vec3 c, float depth, vec3 p){
|
|
48
|
-
float f = 1.0 - exp(-fogDensity * depth);
|
|
49
|
-
return vec4(mix(c, vec3(1.0, 0.85, 0.7), f * 0.3), f); }`); // warm far haze
|
|
50
|
-
engine.look.fog.manual(); // the exit: the sky stops writing scene.fog (or assign your own: scene.fog = new THREE.Fog(...))
|
|
51
|
-
```
|
|
52
|
-
The same keys are the style layer `style.sky.fog` (or `sky({ fog })`), e.g. `fog: { kind: 'exp', color: 0xb8c4d0 }` or
|
|
53
|
-
`fog: { color: ({ sky }) => sky.isDay ? 0xc8d0d8 : 0x10141c }` (a function, evaluated each frame).
|
|
54
|
-
|
|
55
|
-
- `kind`: `'linear'` (default, near = 0.3 x far) | `'exp'` | `'exp2'` | `'height'`. `color`: `'horizon'` (default; the dome's lower band fades to
|
|
56
|
-
the fog color, so the horizon line never shows) | color | `({ time, weather, season, state, sky }) => color` (near / far / density take a function too). `density` per meter (default derived from the fog distance);
|
|
57
|
-
an explicit density is kept as given (weather multiplies `far`, which moves only the derived one).
|
|
58
|
-
- The `fog` hook replaces the fog math in every material, built-in or yours: `vec4 threedogFog(vec3 color, float depth, vec3 worldPos)` returns
|
|
59
|
-
(fog rgb, amount 0..1). In scope: `fogColor`, `cameraPosition`, `fogNear` / `fogFar` (linear) or `fogDensity` (other kinds),
|
|
60
|
-
`THREEDOG_FOG_HEIGHT`, `THREEDOG_FOG_FALLOFF`.
|
|
61
|
-
- How: `'exp'`, `'height'` and the hook are one named shader patch, `fog`, on the semantic slots `fogPars` / `fog` (recipe 43), put on
|
|
62
|
-
every built-in material in this engine's scene (yours too: three's own fog would draw another curve; `describe().owned['fog.patch']` lists
|
|
63
|
-
them). Changing them later works and recompiles those materials once, so do it at a scene change, not every frame. Color and density stay live
|
|
64
|
-
uniforms. No custom uniforms (three copies fog uniforms into each material when it compiles); write constants. Materials with `fog: false`
|
|
65
|
-
(the dome) are not fogged. Your own ShaderMaterial and sprites keep three's plain fog.
|
|
66
|
-
- Your own fog is plain three.js: `scene.fog = new THREE.Fog(...)` (or `FogExp2`), and the engine stops writing it (there is no
|
|
67
|
-
`look.fog.replace`); `look.fog.manual()` keeps the engine's `scene.fog` and the sky never writes it again (set its color / near / far); `sky({ fog: false })` sets `scene.fog = null` (leave fog out of your materials with `fog: false` and fog in a
|
|
68
|
-
post pass).
|
|
69
|
-
- Two engines on one page each patch their own scene's materials, so they may use different fog kinds and hooks. Nothing rewrites
|
|
70
|
-
`THREE.ShaderChunk`; plain `linear` / `exp2` add no patch at all.
|
|
71
|
-
|
|
72
|
-
## Exposure over time, and the tone curve
|
|
73
|
-
```js
|
|
74
|
-
exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // style: per time of day (0-1), wraps across midnight
|
|
75
|
-
exposure: ({ sky }) => sky.isDay ? 1 : 1.5 // or a function, evaluated by the sky module every frame
|
|
76
|
-
engine.look.tone.set({ exposure: 1.3 }); // at run time: number, keyframes or function (replaces the style's)
|
|
77
|
-
engine.renderer.toneMapping = THREE.NeutralToneMapping; // the curve: plain three.js; materials recompile on their next draw
|
|
78
|
-
```
|
|
79
|
-
A plain number is set once (no per-frame work). Keyframes and functions need the sky module (it knows the time of day). The curve is written
|
|
80
|
-
once when the engine creates its renderer (`style.toneMapping`, else AgX) and never again, so a direct write stays.
|
|
81
|
-
|
|
82
|
-
## Extra sky layers: rainbow, aurora, color bands
|
|
83
|
-
`style.sky.layers` (at run time `engine.look.sky.patch('layer:aurora', { glsl, blend })`, recipe 52), drawn on the dome
|
|
84
|
-
after clouds and stars; none by default:
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
layers: [{ blend: 'add', uniforms: { uAurora: [0.2, 1, 0.6] }, glsl: `vec4 threedogSkyLayer(vec3 d, float time, vec3 sunDir, float night){
|
|
88
|
-
float band = smoothstep(0.25, 0.45, d.y) * (1.0 - smoothstep(0.55, 0.8, d.y));
|
|
89
|
-
float n = threedogNoise(vec2(d.x * 4.0 + time * 0.05, d.z * 2.0));
|
|
90
|
-
return vec4(uAurora, band * n * night); }` }]
|
|
91
|
-
```
|
|
92
|
-
Signature `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returns (rgb, amount). `blend: 'mix'` (default) or `'add'`;
|
|
93
|
-
`order` sorts layers (smaller first); `uniforms` like `clouds.uniforms`, live in `engine.sky.dome.material.uniforms.uAurora.value`. Each layer's function is
|
|
94
|
-
renamed (`threedogSkyLayer0`, `1`, ...), so layers from different style parts never clash. Whole replacement: `style.sky.skybox` (a panorama) or
|
|
95
|
-
hide `engine.sky.dome` and add your own background.
|
|
96
|
-
|
|
97
|
-
## Water and weather particles
|
|
98
|
-
Water depth color, crest foam, wave / surface GLSL, reflections; rain and snow shape, size, density and shaders, the lightning look, and
|
|
99
|
-
particles for the game's own weather (`engine.look.weather.replace`): `44-water-weather-look-hooks.md`.
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Things: what is in the scene, who manages it, what a save keeps (engine.thing)
|
|
2
|
-
|
|
3
|
-
Every root you pass to `engine.add` is registered: an id, where it was added (`main.js:50`, dev builds only), who manages it and how much a save
|
|
4
|
-
keeps. World records (template instances, props, pickups, NPCs, level nodes) share the same id space and the same query, so one question works for a
|
|
5
|
-
plain three.js mesh and for a template instance alike. `engine.scene.add` adds without registering: the plain three.js way in, still legal.
|
|
6
|
-
|
|
7
|
-
## 1. Give it an id
|
|
8
|
-
```js
|
|
9
|
-
const windmill = buildWindmill(); // any Object3D
|
|
10
|
-
engine.add(windmill, { id: 'windmill' }); // at setup: thing.set / thing.remove changes to it are saved
|
|
11
|
-
engine.add(spark); // effects need no id: obj#7, this session only
|
|
12
|
-
engine.thing('windmill');
|
|
13
|
-
// { id: 'windmill', kind: 'Group', owner: 'game', at: 'main.js:50', phase: 'setup', saved: 'code',
|
|
14
|
-
// keeps: ['position, rotation, scale, visibility and removal made with thing.set / thing.remove (scene save part)'],
|
|
15
|
-
// loses: ['geometry and material changes', 'children added later', 'userData', ...], edit: 'added by code at main.js:50 (id ...)' }
|
|
16
|
-
engine.thing('windmill').object; // the live Object3D (not enumerable, so the result stays JSON-able)
|
|
17
|
-
engine.thing(engine.pick(0, 0).object).id; // any child resolves to its registered root; hit.thing says the same
|
|
18
|
-
```
|
|
19
|
-
- The id is `{ id }`, else a session id `obj#n` (session tier: never saved). `obj.name` is not an id (GLB roots are all called `Scene`): it only helps `engine.thing(name)` find the object. An id is a non-empty string without `#`,
|
|
20
|
-
unique across `engine.add` objects and world records: a clash throws (`thing-id`) from either side (`engine.add` or `world.add`) and says which one holds it.
|
|
21
|
-
- With several objects in one call (`engine.add(a, b)`) pass no id; add the one that needs an id on its own.
|
|
22
|
-
- `engine.thing(id | name | obj)` throws with the closest id when nothing matches. `engine.inspect(id)` takes the same ids.
|
|
23
|
-
- `describe().scene` gives counts only: `{ game, code, session, world, engine, unsaved, conflicts, orphans }`. Objects of engine modules (particles,
|
|
24
|
-
physics bodies, nav helpers, hlod, grid tiles, the level root, streamed objects) are counted under `engine` and never listed as the game's.
|
|
25
|
-
|
|
26
|
-
## 2. Four save tiers
|
|
27
|
-
Judged in this order (`thing.saved`):
|
|
28
|
-
|
|
29
|
-
| Tier | When | A save keeps | A save loses |
|
|
30
|
-
|---|---|---|---|
|
|
31
|
-
| `record` | a world record's model (templates, props, pickups, NPCs, level nodes) | the record's fields and position (world part); the model is rebuilt from its template / present | the model object itself; change it through the record |
|
|
32
|
-
| `code` | added by game code with a stable id at setup (before `engine.ready`, or in a `session:start` listener) | position, rotation, scale, visibility and removal made with `thing.set` / `thing.remove` (`scene` part) | geometry and material changes, children added later, `userData`, closure state, writes like `mesh.position.x = 3` |
|
|
33
|
-
| `session` | no stable id, or added during play | nothing: it exists only in this session | everything; it does not come back after a load |
|
|
34
|
-
| `engine` | managed by an engine module | its module's business | direct changes (the module rewrites them) |
|
|
35
|
-
|
|
36
|
-
Only transform, visibility and removal are saved for `code` objects; colours and materials belong to Style and are not saved. To keep something made
|
|
37
|
-
during play, make it a template and create it inside an op with `engine.content.spawn(name, at)`: a record is saved whole.
|
|
38
|
-
|
|
39
|
-
## 3. Change it: thing.set / thing.remove (ops, undoable)
|
|
40
|
-
```js
|
|
41
|
-
const args = { id: 'windmill', position: [5, 0, 2], rotation: 1.2 }; // rotation: a number is yaw, or [x, y, z]; scale: a number or [x, y, z]
|
|
42
|
-
const r = engine.ops.run('thing.set', args);
|
|
43
|
-
engine.ops.undo('thing.set', args, r.value); // back where it was
|
|
44
|
-
engine.ops.run('thing.remove', { id: 'windmill' }); // detached and kept: undo puts it back
|
|
45
|
-
```
|
|
46
|
-
- A world record id turns into `world.set` / `world.move` (`rot` / `scale` are template instance fields) and `world.remove`; the model follows the
|
|
47
|
-
record. `visible` is refused for a record (`recordVisible`): hide its model with `present({ show })` and a field.
|
|
48
|
-
- A `code` object gets its new values written and recorded as an override; a `session` object only changes in this session.
|
|
49
|
-
- Objects of engine modules are refused (`engineOwned`).
|
|
50
|
-
|
|
51
|
-
## 4. Saves: the `scene` part (version 1)
|
|
52
|
-
`{ set: { windmill: { position: [5, 0, 2] } }, removed: ['old-fence'] }`, only for `code` objects. A load first undoes the current overrides (a new
|
|
53
|
-
game applies an empty part, so everything goes back to what the code built), then applies the save. An id the save names but no object has yet waits:
|
|
54
|
-
the override applies the moment `engine.add(obj, { id })` runs. One that never comes is an orphan: kept in the save, listed in
|
|
55
|
-
`describe().scene.orphans` and warned once (`thing-orphan`).
|
|
56
|
-
|
|
57
|
-
## 5. Dev checks
|
|
58
|
-
- `engine.add(obj, { save: true })` for an object that cannot be saved (no id, or during play) warns at once (`thing-unsaved`); objects added inside an
|
|
59
|
-
op are listed by `saves.save()` and in `describe().scene.unsaved`.
|
|
60
|
-
- `engine.add` of a world model throws (`thing-owned`): world adds, places and tears down its models.
|
|
61
|
-
- Code that moves a `positionFrom: 'record'` world model outside its present `update` is warned once and listed in `describe().scene.conflicts`.
|
|
62
|
-
- Rule R33 (`npm run check`) flags the static half: startup calls that create things saved whole, and code writing `world.view()` models.
|
|
63
|
-
- Cost: a release build pays two table writes per `engine.add` (about 2 µs per add in `tests/specs/things.mjs`); dev builds also take a short stack
|
|
64
|
-
for `at`, at most 2000 per session (`describe().scene.atCapped` after that).
|
|
65
|
-
|
|
66
|
-
## 6. One id, everything: explain() and the three kinds of change
|
|
67
|
-
```js
|
|
68
|
-
engine.thing('chest-home').explain(); // CLI: threedog thing chest-home (MCP: thing); the same JSON
|
|
69
|
-
// { id, kind, owner, definition: { at: 'content/props.js:14', template, templateAt, level?, node?, spawned? }, model, materials: [{ role, name, from, keys }],
|
|
70
|
-
// state, rules: { blocksMovement, pickable, interact, height }, ops: [{ op, desc, args }], saved: { tier, keeps, loses }, change: {…}, overrides? }
|
|
71
|
-
```
|
|
72
|
-
`ops` lists the ops whose definition names this id, kind or template in the optional `targets` field (`engine.ops.define('chest.toggle', { targets: 'chest', … })`;
|
|
73
|
-
`'*'` = any thing, which `thing.set` / `thing.remove` use). `definition.at` is null in release builds and for code run without a file (page `eval`).
|
|
74
|
-
`thing.explain()` (type `ThingExplanation`) is not `engine.explain({ op | quest | … })`: that one takes a question and answers `{ ok, text }` about why an op or quest cannot run now (recipe 23); this one takes no question and returns the facts about one id. `rules.blocksMovement` is the template's / prop's `collide` shape; the engine does not model blocking sight. Pick the kind of change first:
|
|
75
|
-
|
|
76
|
-
| Kind | How | Lasts |
|
|
77
|
-
|---|---|---|
|
|
78
|
-
| Game state (a chest opens, a door moves) | an op: `ops.run('chest.toggle', { id })`, `thing.set`, `thing.remove` (section 3) | by the thing's save tier |
|
|
79
|
-
| Permanent edit (another model, place, material role) | content entry: `threedog content set <id> <field> <json>` (below); template or `engine.add` line: edit the file:line `explain().change.permanent` prints; then reload | forever |
|
|
80
|
-
| Diagnostic override ("show me without it") | `engine.debug.override(owner, id, { visible: false, material: 'flat' \| 'wire', apply })` | until `handle.remove()` / `engine.debug.clear(owner)`; never saved |
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
const h = engine.debug.override('ai-session', 'windmill', { material: 'flat' }); // unlit base colour: is the colour wrong, or the light?
|
|
84
|
-
engine.debug.override('ai-session', 'fence', { visible: false });
|
|
85
|
-
engine.describe().scene.overrides; // [{ owner, target, material: 'flat' }, …]: the screen differs from the real state while this is non-empty
|
|
86
|
-
h.remove(); engine.debug.clear('ai-session'); // clear removes every override of that owner (and its debug.view) and nothing else
|
|
87
|
-
```
|
|
88
|
-
`apply(obj)` may return its undo function: any other look (a view mode) uses the same owner mechanism. Overrides do not touch game state, ops or saves.
|
|
89
|
-
|
|
90
|
-
`threedog content set cabin x=12 z=3 place=home --in props` writes a permanent change into the content entry: several fields in one call (one write, one check, all or nothing;
|
|
91
|
-
values are JSON, a bare word is a string; `-w game` or `--dir folder` picks the game; `--dry` only shows it). It edits just that value in place (comments and spacing stay), adds the
|
|
92
|
-
field when missing, checks the one file it wrote (reverting if that fails; the full check stays `npm run check`) and tells you to reload. `--expect x=5` refuses the write when the
|
|
93
|
-
file no longer has the value you saw (someone else changed it). `content add props id=crate-7 template=crate x=1 z=2` appends one entry at the end (always with an id;
|
|
94
|
-
`--file content/props/town.js` picks the part of a folder kind) and `content remove <id>` deletes one. Fields are the content file's names
|
|
95
|
-
(`x`, `z`, `y`, `rot`, `scale`, `template`, `place`, `model`), not the record's `position`. It refuses, and says why with the line, for an entry built
|
|
96
|
-
by code (loop, spread, computed value), an id matching several entries (`--in props`), or an add / remove that would shift entries whose id is their position. A placed entry wins over a template or npc of the same name.
|
|
97
|
-
It finds the file through `.threedog/content-index.json` (written by the content check; rebuilt when an id is not where it says), so a write reads only that one file however many there are.
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Terrain outline: islands, floating rocks, a world that ends
|
|
2
|
-
|
|
3
|
-
`terrain({ shape })` decides where there is ground at all. Without it (the default) the ground goes on forever. With it, ground exists only
|
|
4
|
-
where `mask > 0`; the rim is cut through the cells in straight lines, walls hang down from it, and an optional underside closes it.
|
|
5
|
-
|
|
6
|
-
## 1. A floating island with a ragged rim (copy this)
|
|
7
|
-
|
|
8
|
-
```js
|
|
9
|
-
import { createEngine, openWorld } from 'threedog';
|
|
10
|
-
|
|
11
|
-
const engine = createEngine({ canvas: document.querySelector('canvas') });
|
|
12
|
-
engine.use(openWorld({ camera: 'follow', water: false, terrain: { // water: false -- a floating island has no sea under it
|
|
13
|
-
height: (x, z, n) => 4 + 6 * n.fbm(x * 0.02, z * 0.02),
|
|
14
|
-
shape: {
|
|
15
|
-
mask: (x, z) => 60 - Math.hypot(x, z), // > 0 ground: a 60 m disc (meters read best)
|
|
16
|
-
edge: { noise: 8, size: 20, jitter: 0.6, round: 1.5 }, // ragged outline, jagged rim, top bends down 1.5 m at the edge
|
|
17
|
-
side: { depth: 3, ground: 'cliff' }, // 3 m of cliff band, colored by biomeColors.cliff
|
|
18
|
-
bottom: { depth: (x, z, n, m) => 2 + m * 0.5 + 4 * n.fbm(x * 0.1, z * 0.1), ground: 'rock' }, // hangs lower inland (m grows inward)
|
|
19
|
-
},
|
|
20
|
-
} }));
|
|
21
|
-
await engine.start();
|
|
22
|
-
|
|
23
|
-
const home = { x: 0, z: 0 };
|
|
24
|
-
engine.events.on('terrain:void', ({ who }) => { // fell off: the game decides (the engine never respawns)
|
|
25
|
-
if (who === engine.player) engine.player.placeAt(home);
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Colors come from the style as usual: add `cliff` and `rock` to `style.terrain.biomeColors` (a name without a color is neutral gray).
|
|
30
|
-
|
|
31
|
-
## 2. The keys
|
|
32
|
-
|
|
33
|
-
| key | what | default |
|
|
34
|
-
|---|---|---|
|
|
35
|
-
| `mask` | `(x, z, n) => number`, > 0 is ground; pure like `height` (runs in workers, settings through `n.params`). Or a gray image `{ url, size: [w, l], center, threshold }`: whiter is ground, value = gray − threshold, outside the image is void | required |
|
|
36
|
-
| `edge.noise` / `edge.size` | meters of fbm added to the mask, and its wavelength in meters | 0 / 16 |
|
|
37
|
-
| `edge.jitter` | meters of random offset per grid point: a jagged, chipped rim | 0 |
|
|
38
|
-
| `edge.round` | meters the top bends down towards the rim; 0 is a hard cliff edge | 0 |
|
|
39
|
-
| `side.depth` | wall height below the rim: meters or `(x, z, n) => meters` | 2 |
|
|
40
|
-
| `side.ground` / `side.material` | wall color (`biomeColors[ground]`), or a Material / `(engine) => Material` for sides and bottom | `'cliff'` / none |
|
|
41
|
-
| `bottom.depth` | underside below the side band: meters or `(x, z, n, m) => meters` (`m` = mask there) | 4 (only with `bottom`) |
|
|
42
|
-
| `bottom.ground` | underside color | `'rock'` |
|
|
43
|
-
| `voidY` | fall height for `terrain:void` | 50 m under the lowest island chunk loaded |
|
|
44
|
-
|
|
45
|
-
Without `bottom` the island is open underneath (the cheapest choice when the camera never looks up at it).
|
|
46
|
-
|
|
47
|
-
## 3. What the rest of the engine does off the outline
|
|
48
|
-
|
|
49
|
-
- `engine.surface(x, z)` is `-Infinity`, `engine.ground.has(x, z)` is `false`, `engine.slope` is 0, `engine.groundType` is `'void'`.
|
|
50
|
-
Check `has` before placing things: `engine.snapToGround` over the void throws in development instead of writing an infinite y.
|
|
51
|
-
The same holds for every place-it-here entry (`engine.content.spawn`, content props, pickups, npcs, `character.placeAt`): in development they throw with this advice, in a release build they keep the caller's y (or 0), never `-Infinity` (a save would turn it into NaN). Camera starts, HUD anchors, grid tiles and shot paths fall back to y 0 / the last height and do not throw.
|
|
52
|
-
- Characters walk off the rim and fall; pathfinding and spawn search treat the void as not walkable.
|
|
53
|
-
- Physics: the top and the walls collide (a rolling barrel stops at a wall, a ball falls off the edge); the underside does not.
|
|
54
|
-
- Vegetation never grows off the outline. `engine.terrain.edit` off it does nothing (returns `{ heights: 0, cells: 0 }`); near the rim it
|
|
55
|
-
still digs, and painting works. The outline itself cannot be edited.
|
|
56
|
-
- The player and every moving rigid body that drops below `engine.terrain.voidY` get one `terrain:void { who, position }` per fall.
|
|
57
|
-
- Global water still draws at its level: a floating island usually turns water off (`water: false` above).
|
|
58
|
-
|
|
59
|
-
## 4. Limits
|
|
60
|
-
|
|
61
|
-
- The cut follows cell edges, so detail finer than a cell (`chunkSize / resolution`, 4 m by default) is lost. Keep `edge.size` above a cell,
|
|
62
|
-
or raise `resolution`.
|
|
63
|
-
- `shading: 'texture'`: the color map covers the top only (void pixels have alpha 0); sides and bottom use vertex colors or `side.material`.
|
|
64
|
-
- The mask is fixed at start; a game that wants the outline to change while playing builds that itself.
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
# Water and rain/snow looks: depth color, foam, reflections, particles, lightning
|
|
2
|
-
|
|
3
|
-
For an AI that wants water or weather particles to look a way the defaults do not. Water basics are the `water()` module (structure only: `sea`, `level`,
|
|
4
|
-
`flat`, `size`, `segments`, `uniforms` for the hooks) and its look `style.water` / `engine.look.water.set` (color, opacity, waves, fresnel, normal map,
|
|
5
|
-
shininess, specular; `water({ color })` throws naming `look.water.set`); lights, fog and the sky are in `38-environment-look-hooks.md`. A style that writes none of the keys below keeps the built-in
|
|
6
|
-
shaders and pays nothing for them (`tests/specs/appearance-water.mjs`). Three exits: a parameter, a GLSL function you replace, or your own material.
|
|
7
|
-
At run time the same keys go through `engine.look.water` / `engine.look.weather` (recipe 52).
|
|
8
|
-
|
|
9
|
-
## Water: depth color and crest foam (parameters)
|
|
10
|
-
```js fragment
|
|
11
|
-
water: {
|
|
12
|
-
depthColor: { shallow: 0x55ddcc, deep: 0x082040 }, // by 'view' (default): shallow looking down, deep toward the horizon
|
|
13
|
-
depthColor: { shallow: 0x7fe0d0, deep: 0x0a3050, by: 'wave', curve: 1.5 }, // shallow on the crests, deep in the troughs
|
|
14
|
-
foam: { color: 0xffffff, start: 0.55, end: 0.85, opacity: 1 }, // white on the wave tops; foam: true = these defaults
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
- `depthColor` replaces `color` (opacity stays). `'view'` is a fresnel-style blend by the view angle, `'wave'` blends by the wave height; neither
|
|
18
|
-
needs a depth texture. `curve` bends the blend (above 1 keeps more of the shallow color). A color left out is a neutral gray (light for
|
|
19
|
-
`shallow`, dark for `deep`): the engine picks no water color, so set both.
|
|
20
|
-
- `foam` uses the same wave height as the vertices: `start` / `end` are fractions of the peak height (the `wave` hook's `waveMax`, default 0.29) where
|
|
21
|
-
foam begins and is full. Foam is opaque even on transparent water. All numbers are uniforms (`engine.water.material.uniforms.uFoamStart.value`).
|
|
22
|
-
- **Shore foam is not built in.** An accurate foam line where water meets land needs the distance to the ground under each pixel: a depth
|
|
23
|
-
pre-pass (a `DepthTexture` render target of the scene without water) or a terrain height lookup, both cost a full extra pass or a texture
|
|
24
|
-
read per pixel. Do it yourself through `style.water.material`: render the scene's depth to a target before the water draws
|
|
25
|
-
(`material.onBeforeRender`), pass it as a uniform, and in your fragment compare the scene depth with this fragment's depth, both turned into meters with three's
|
|
26
|
-
`perspectiveDepthToViewZ` (`#include <packing>`); foam
|
|
27
|
-
where the difference is under about a meter. A cheap fake: `engine.addWaterBody` lakes have known radii, so a surface function can foam the
|
|
28
|
-
ring `length(worldPos.xz - center) > radius - 1.0` (pass the center and radius as `uniforms`).
|
|
29
|
-
|
|
30
|
-
## Water: replace the wave or the surface function (GLSL)
|
|
31
|
-
```js
|
|
32
|
-
// style.water: { uniforms: { uBands: 4, uDeep: [0.05, 0.2, 0.4] } } numbers, colors, [x, y(, z, w)] arrays, textures; in both stages
|
|
33
|
-
// the GLSL goes through the look hooks only (style.water.glsl / water({ glsl }) throw and name them):
|
|
34
|
-
engine.look.water.patch('wave', {
|
|
35
|
-
glsl: `float threedogWaterWave(vec3 p, float t) { // p = world position * waveScale, t = time * waveSpeed
|
|
36
|
-
return sin(p.x * 0.5 + t) * 0.2 + sin(p.z * 0.8 - t * 1.3) * 0.1; }`, // height before waveHeight
|
|
37
|
-
waveMax: 0.3, // its peak: foam and depthColor 'wave' divide by it
|
|
38
|
-
});
|
|
39
|
-
engine.look.water.patch('surface', `vec4 threedogWaterSurface(vec4 base, float wave, float facing, vec3 worldPos, float time) {
|
|
40
|
-
float b = floor(facing * uBands) / uBands; // toon bands by view angle
|
|
41
|
-
return vec4(mix(uDeep, vec3(0.4, 0.8, 0.9), b), base.a); }`);
|
|
42
|
-
```
|
|
43
|
-
- `wave` replaces only the vertex motion; the rest of the built-in water stays. Copying the default
|
|
44
|
-
(`modules/water/surface.js`, `WAVE`) draws pixel for pixel the same.
|
|
45
|
-
- `surface` runs before lighting: `base` is the material color and opacity, `wave` the height at this point, `facing` 1 looking straight down and 0
|
|
46
|
-
at grazing angles, `worldPos` the moved surface point. The result is lit, fogged and gets the grazing-angle fresnel like the default water.
|
|
47
|
-
With `surface` written, `depthColor` / `foam` are not added (your function is the whole surface).
|
|
48
|
-
- A wrong signature throws with the right one; misspelled keys warn with the near name; `threedog style check` knows these keys.
|
|
49
|
-
|
|
50
|
-
## Water: your own material (reflections, refraction)
|
|
51
|
-
`style.water.material: (engine, { uniforms, waves, surface, normalMap }) => Material` replaces the whole water material; at run time the same
|
|
52
|
-
slot is `engine.look.water.replace(fn)` (one entry: `water({ material })` throws naming it). `uniforms` already holds `style.water.uniforms`
|
|
53
|
-
/ `water({ uniforms })`, so your material reads them like the hooks do. The engine still builds
|
|
54
|
-
the meshes, snaps the sea to the focus and scrolls the normal map. Reflections and refraction are not built in (each one renders the scene a
|
|
55
|
-
second time). three's `Reflector` addon works through this exit; the engine water is pre-rotated geometry, so the mirror gets the mesh's
|
|
56
|
-
matrix turned into the XY plane it expects:
|
|
57
|
-
|
|
58
|
-
```js
|
|
59
|
-
import * as THREE from 'three';
|
|
60
|
-
import { Reflector } from 'three/addons/objects/Reflector.js';
|
|
61
|
-
|
|
62
|
-
water: { material: () => {
|
|
63
|
-
const mirror = new Reflector(new THREE.PlaneGeometry(1, 1), { textureWidth: 512, textureHeight: 512, color: 0x88aacc }), m = mirror.material;
|
|
64
|
-
const toPlane = new THREE.Matrix4().makeRotationX(-Math.PI / 2), back = new THREE.Matrix4().makeRotationX(Math.PI / 2);
|
|
65
|
-
let busy = false;
|
|
66
|
-
m.onBeforeRender = (renderer, scene, camera, geometry, mesh) => {
|
|
67
|
-
if (busy) return; busy = true; // the mirror's own render must not reflect again
|
|
68
|
-
mirror.matrixWorld.copy(mesh.matrixWorld).multiply(toPlane);
|
|
69
|
-
mesh.visible = false; mirror.onBeforeRender(renderer, scene, camera); mesh.visible = true;
|
|
70
|
-
m.uniforms.textureMatrix.value.multiply(back); // undo the turn for the pre-rotated vertices
|
|
71
|
-
busy = false;
|
|
72
|
-
};
|
|
73
|
-
return m;
|
|
74
|
-
} }
|
|
75
|
-
```
|
|
76
|
-
- Cost: the whole scene drawn once more per frame per water mesh at `textureWidth` x `textureHeight` (shadows are not re-rendered). Use 256-512
|
|
77
|
-
on phones; on `engine.tier === 'low'` return the default-looking material instead.
|
|
78
|
-
- One mirror plane: the material is shared, so water bodies at other levels need `water({ sea: false })` or their own mirror. The Reflector's
|
|
79
|
-
shader has no waves or fog; for both, copy its `fragmentShader` into a `MeshPhongMaterial` patch that samples `tDiffuse` with `textureMatrix`.
|
|
80
|
-
- three's `Refractor` addon (next to `Reflector`) reads `matrixWorld` as an XY plane too, so the same adapter applies (not covered by a test).
|
|
81
|
-
- Tested: `tests/specs/appearance-water.mjs` renders this exact example and finds the reflected box in the mirror texture.
|
|
82
|
-
|
|
83
|
-
## Water: your own meshes (three's `Water` addon, your own geometry)
|
|
84
|
-
The water module's material is replaceable, its meshes are not. For water drawn entirely your way, leave `water()` out and draw it in plain
|
|
85
|
-
three.js: the water data stays in the engine without the module. `engine.waterAt(x, z)` gives the surface height (water bodies first, then
|
|
86
|
-
`engine.waterLevel`), `engine.waterBodies` lists the lakes and ponds (`{ x, z, radius | hw, hd, level }`), and `water:add` / `water:remove` tell
|
|
87
|
-
you when one comes or goes, so swimming, buoyancy and anything else reading the water keep working.
|
|
88
|
-
|
|
89
|
-
## Weather particles: rain and snow parameters
|
|
90
|
-
`style.weather.rain` / `snow` (left-out keys keep the built-in look):
|
|
91
|
-
|
|
92
|
-
```js fragment
|
|
93
|
-
weather: {
|
|
94
|
-
rain: { color: 0xa8b8d0, opacity: 0.6, length: 1.2, speed: 26, slant: 1.5, density: a => a * a }, // streaks; sparse in a drizzle
|
|
95
|
-
// rain: { shape: 'soft', size: 10, maxSize: 6, sway: 0.3 }, // drops as soft sprites instead of streaks
|
|
96
|
-
snow: { shape: 'soft', size: 28, maxSize: 7, speed: 1, sway: 3, count: 4000 },
|
|
97
|
-
// snow: { texture: 'flake' }, // a sprite image replaces the shape
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
- `shape`: `'line'` (rain default; leans with the wind by `slant`, `length` meters) or a sprite: `'round'` (snow default), `'soft'`, `'square'`
|
|
101
|
-
(`size` pixels at 3 m, capped at `maxSize`; drifts `sway` meters). `speed` is the fall in m/s.
|
|
102
|
-
- `density: amount => share`: how many particles show at a weather amount 0..1 (rain `a => min(1, a * 1.2)`, snow `() => 1`); opacity still
|
|
103
|
-
follows the amount. `count` per system (default `weather({ particles })`, halved on low-tier devices). Coverage is `style.weather.area`.
|
|
104
|
-
- The numbers are uniforms: `engine.weatherLook.systems.get('rain').uniforms.uColor.value.set(0xff0000)` works at run time.
|
|
105
|
-
|
|
106
|
-
## Weather particles: replace the shaders (GLSL)
|
|
107
|
-
```js fragment
|
|
108
|
-
snow: { uniforms: { uTint: [1, 0.85, 0.9] }, glsl: { fragment: `uniform float uOpacity;
|
|
109
|
-
void main(){
|
|
110
|
-
vec2 d = gl_PointCoord - 0.5;
|
|
111
|
-
float a = 1.0 - smoothstep(0.1, 0.25, dot(d, d)); // a soft petal
|
|
112
|
-
gl_FragColor = vec4(uTint, uOpacity * a);
|
|
113
|
-
#include <tonemapping_fragment>
|
|
114
|
-
#include <colorspace_fragment>
|
|
115
|
-
}` } }
|
|
116
|
-
```
|
|
117
|
-
`glsl.vertex` / `glsl.fragment` are the whole shader text; copy `modules/weather/shaders.js` (`lineVert lineFrag pointVert pointFrag`) as the
|
|
118
|
-
start. In scope: `uCam uSize uFallOff uOpacity uColor`; lines add `uWindDir uLen` and the attribute `aEnd` (0 head, 1 tail); sprites add
|
|
119
|
-
`uPx uMaxPx uSway uSwayAmp uMap uUseMap`. Your `uniforms` are declared for you; declare the built-in ones you use, as the copies do. Keep
|
|
120
|
-
the two `#include` lines so the color matches three's materials with and without post-processing.
|
|
121
|
-
|
|
122
|
-
## Lightning look
|
|
123
|
-
```js
|
|
124
|
-
weather: { lightning: f => f * f * 0.8 } // flash 1 at the strike -> sky flash amount (default flickers)
|
|
125
|
-
weather: { lightning: () => 0 } // no sky flash: draw your own bolt instead
|
|
126
|
-
engine.events.on('weather:lightning', () => spawnBolt()); // when it strikes stays the weather table's (lightning > 0.5)
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Particles of the game's own weather
|
|
130
|
-
A field of the game's own weather table (`ash`, `petals`, `sparks`) gets particles with `engine.look.weather.replace({ [field]: spec })`; the amount is
|
|
131
|
-
`engine.weather.current[field]`, so they fade in and out with the weather. The spec takes the rain / snow keys above (default: drifting
|
|
132
|
-
round sprites), or `create` for a system of your own:
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
engine.use(sky(), weather({ types: { clear: {}, ashfall: { ash: 1, grey: 0.5, sun: 0.6 } } }));
|
|
136
|
-
engine.look.weather.replace({ ash: { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 } });
|
|
137
|
-
engine.look.weather.replace({ rain: { create: (engine, { area, count }) => { // the same call replaces rain or snow
|
|
138
|
-
const drops = new THREE.InstancedMesh(new THREE.SphereGeometry(0.03), new THREE.MeshBasicMaterial({ color: 0x99bbff }), count);
|
|
139
|
-
return { object: drops, update(amount, { camera, time, wind }) { /* move the instances; shown while amount > 0.02 */ } };
|
|
140
|
-
} } });
|
|
141
|
-
```
|
|
142
|
-
A field no type has throws with the table's fields. Rain and snow are built only when a type rains or snows, so a desert pays nothing.
|
|
143
|
-
|
|
144
|
-
> Water and weather are also look parts (`engine.look.water`, `engine.look.weather`): recipes/52-look.md, "Water, weather, post".
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Snow cover, flat backdrop, rounded terrain rim
|
|
2
|
-
|
|
3
|
-
Three independent settings, each for its own situation: a **rounded rim** for terrain with a visible edge (an island, a diorama board, a floating
|
|
4
|
-
level; recipe 42 for the outline), **snow cover** for any outdoor scene where it snows, and a **flat backdrop** for a scene that should have no
|
|
5
|
-
horizon (a menu stage, a board game, a diorama). All are style or scenario settings; none needs a shader of your own.
|
|
6
|
-
|
|
7
|
-
## Round rim
|
|
8
|
-
`terrain({ shape: { edge: { round: 1.2 } } })` bends the top down by up to 1.2 m toward the rim. The side wall follows every bend of the
|
|
9
|
-
top (it is split where the rim crosses a cell diagonal), so there is no slit between top and wall at any `round`.
|
|
10
|
-
|
|
11
|
-
## Season tint on a textured top
|
|
12
|
-
With `shading: 'texture'` the color map is applied before the vertex colors, so every patch after `color_fragment` sees the mapped color.
|
|
13
|
-
`style.seasons: { mode: 'mix', winter: { ground: 0xeef0f2 } }` therefore whitens the textured top like the side walls (recipe 43).
|
|
14
|
-
|
|
15
|
-
## Snow that settles: `style.weather.snow.cover`
|
|
16
|
-
```js fragment
|
|
17
|
-
weather: {
|
|
18
|
-
snow: { size: 18, cover: { foliage: 0xf2f4f6, ground: 0xeef0f2, strength: 0.8 } },
|
|
19
|
-
},
|
|
20
|
-
```
|
|
21
|
-
- While the weather's `snow` amount rises (any type with `snow > 0`), the foliage / ground season tint moves `strength` of the way toward
|
|
22
|
-
these colors, and melts back as it falls. It reuses the season patch uniforms (`uFoliageTint/Mix`, `uGroundTint/Mix`): vegetation, terrain
|
|
23
|
-
and any material with `applyEffects(m, { season: 'ground' })` follow; no extra shader pass.
|
|
24
|
-
- Over a `mode: 'mix'` season the two blend into one mix; a `'multiply'` season gives way while snow lies (use `'mix'` for smooth fades).
|
|
25
|
-
- Leave a part out to keep its season color (`cover: { foliage: 0xffffff }` whitens trees only). Leave `cover` out and snow is particles only.
|
|
26
|
-
- Ash, frost or anything else: `engine.mod('look.ground.cover', { owner: 'ash', value: { ground: 0x555555, amount: 0.6 } })` (one entry per owner, the handle's `remove()` ends it).
|
|
27
|
-
|
|
28
|
-
## Weather changes and seasons in scenarios
|
|
29
|
-
- `engine.events.on('weather:change', ({ from, to }) => ...)`: once per change of name, when the blend starts (`weather.set` with the same name
|
|
30
|
-
again does not fire).
|
|
31
|
-
- `engine.applyState({ season: 'winter' })` (or `?season=winter`): jumps `calendar.day` to that season's first day, time of day kept. Needs
|
|
32
|
-
`calendar({ seasons })`; a wrong name throws with the calendar's list.
|
|
33
|
-
|
|
34
|
-
## Flat backdrop: `style.sky.backdrop`
|
|
35
|
-
```js fragment
|
|
36
|
-
sky: { backdrop: 0xefebe4 }, // one color
|
|
37
|
-
sky: { backdrop: ({ sky }) => (sky.isDay ? 0xefebe4 : 0x2c3346) }, // per frame (time of day, weather, your own state)
|
|
38
|
-
```
|
|
39
|
-
- Hides the dome (no gradient, horizon line, sun / moon disk, stars or clouds) and sets `scene.background` to the color. A plain background
|
|
40
|
-
color is not tone mapped, so what you write is what shows. `style.background` stays the color when there is no sky module.
|
|
41
|
-
- The keyframes still light the world (sun, ambient, their colors).
|
|
42
|
-
- Fog: in its default `'horizon'` color the fog follows the backdrop, so far things fade into it; `style.sky.fog.color` of your own wins.
|
|
43
|
-
- Not together with `skybox` (both replace the dome).
|
|
44
|
-
- To fade the backdrop toward gray in snow, read the weather in the function: `() => new THREE.Color(0xefebe4).lerp(gray, engine.weather.current.snow * 0.3)`
|
|
45
|
-
(reuse the Color objects; it runs every frame).
|