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,60 +1,180 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Shadows: cascades, box, budget, cache, the switch
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
world is bigger than one map covers well.
|
|
3
|
+
**In this recipe**: `engine.shadows` works on a light you hand it and leaves every other light alone: cascades, a box that follows, an update budget, the master
|
|
4
|
+
switch. Filter, bias, softness and map size are plain three.js (last section).
|
|
6
5
|
|
|
7
6
|
```js
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const sun = new THREE.DirectionalLight('#fff4e0', 3);
|
|
8
|
+
sun.position.set(40, 80, 30);
|
|
9
|
+
sun.castShadow = true;
|
|
10
|
+
sun.shadow.mapSize.setScalar(engine.tier === 'low' ? 1024 : 2048);
|
|
11
|
+
engine.scene.add(sun);
|
|
12
|
+
|
|
13
|
+
const shadows = engine.shadows.cascades(sun, { count: 3, maxFar: 150 });
|
|
14
|
+
engine.onRender(() => sun.position.copy(engine.uniforms.uSunDir.value).multiplyScalar(100)); // aim it as usual
|
|
15
|
+
shadows.set({ count: 2 }); // on a settings screen: it recompiles
|
|
16
|
+
shadows.remove(); // one plain shadow map again
|
|
10
17
|
```
|
|
11
18
|
|
|
19
|
+
Cascades split one light's shadow along the view into 2-4 maps (three's CSM addon): sharp near the camera, coarse far away. Use them when near
|
|
20
|
+
shadows look blocky and the world is bigger than one map covers well. Off by default: a light casts one shadow map (the engine sun around the
|
|
21
|
+
focus, `extent` 30 m).
|
|
22
|
+
|
|
23
|
+
The engine sun takes the same entry: `engine.shadows.cascades(engine.lights.sun, { count: 3 })`.
|
|
24
|
+
|
|
12
25
|
| field | default | meaning |
|
|
13
26
|
|---|---|---|
|
|
14
|
-
| `
|
|
27
|
+
| `count` | 3 | 1 = one map (see the rules below); 2-4 = cascades |
|
|
15
28
|
| `maxFar` | 120 | meters from the camera they cover; no sun shadow beyond |
|
|
16
29
|
| `split` | `'practical'` | where borders fall: `'practical'` / `'uniform'` / `'logarithmic'` / `(count, near, far, out) => void` |
|
|
17
30
|
| `lightMargin` | 100 | meters behind each cascade box toward the light still caught as casters |
|
|
18
31
|
| `fade` | true | cross-fade at borders so no seam shows (two shadow lookups there); false is a little cheaper |
|
|
19
32
|
|
|
20
|
-
`mapSize`, `bias`, `normalBias`, `
|
|
33
|
+
`light.shadow.mapSize`, `bias`, `normalBias`, `radius`, `blurSamples`, the filter and a budget reach every cascade. A box does not go with cascades: they
|
|
21
34
|
follow the camera frustum and snap to whole shadow pixels themselves, so edges do not shimmer while the camera moves.
|
|
22
35
|
|
|
23
36
|
## How it works (what you can rely on)
|
|
24
|
-
-
|
|
25
|
-
cascades are extra DirectionalLights that copy its color and intensity every frame. `engine.
|
|
37
|
+
- The light you hand in stays the light you write (color, intensity, direction) and is cascade 0; the other
|
|
38
|
+
cascades are extra DirectionalLights that copy its color and intensity every frame. `engine.shadows.csm` is three's CSM object (lights,
|
|
26
39
|
breaks, updateFrustums()), null when off.
|
|
27
40
|
- Built-in lit materials (Lambert, Phong, Standard, Physical, Toon), **your own `new` ones too**, get a named patch `csm`, added after the
|
|
28
41
|
material's other patches; wind, cloud shadows, season, detail and lighting patches stay, and wind shadows still sway. This is the one place
|
|
29
42
|
the engine changes a material it did not make: unpatched, a lit material is lit once by every cascade light (N times as bright, doubled
|
|
30
43
|
shadows). `engine.describe().owned['shadow.csm'].materials` lists your materials that got it. Materials added later are picked up the next
|
|
31
44
|
frame (the scene is walked once per frame while cascades are on).
|
|
32
|
-
- Your own `ShaderMaterial` with `lights: true` is never patched unasked: one warning names it, and `engine.
|
|
45
|
+
- Your own `ShaderMaterial` with `lights: true` is never patched unasked: one warning names it, and `engine.shadows.include(mat)` opts it
|
|
33
46
|
in (it needs `#include <lights_fragment_begin>`, i.e. a shader built from `THREE.ShaderLib`).
|
|
34
47
|
Never call `CSM.setupMaterial` yourself: it overwrites `onBeforeCompile` and drops every patch. A game patch must not replace
|
|
35
48
|
`lights_fragment_begin` (it would clash with `csm`, reported when added).
|
|
36
49
|
- three's `ShaderChunk` is never changed (the addon's constructor does that globally; the engine swaps the chunk per material instead).
|
|
37
|
-
-
|
|
38
|
-
- Photo mode's `setShadowMapSize` (and `look.shadow.set({ mapSize })`) resizes every cascade's map, on both renderers.
|
|
50
|
+
- Under `engine.shadows.budget` cascades move only on frames whose maps re-render (or when the camera jumps), so lights and maps agree.
|
|
39
51
|
|
|
40
|
-
On WebGPURenderer (recipe 56) the same
|
|
41
|
-
`CSMShadowNode` on `
|
|
42
|
-
and `
|
|
52
|
+
On WebGPURenderer (recipe 56) the same call is three's
|
|
53
|
+
`CSMShadowNode` on `light.shadow.shadowNode`: one light, so no material is patched, nothing is listed in `describe().owned`,
|
|
54
|
+
and `engine.shadows.include(mat)` does nothing (it says so once). `engine.shadows.csm` is that node (its `lights` are placeholder objects, not
|
|
43
55
|
lights). The cascade shadow cameras reach `lightMargin + 2 * maxFar` meters, as on WebGL.
|
|
44
56
|
|
|
45
57
|
## Costs and stalls
|
|
46
58
|
- Each cascade draws the shadow casters once more (each culls to its own box; near ones see little). `engine.budget.byTag()` counts a
|
|
47
|
-
caster once per shadow map (each cascade, on both renderers), an upper bound.
|
|
48
|
-
went from 1 to 3 shadow passes and roughly doubled frame time; do not expect frame rate to improve.
|
|
59
|
+
caster once per shadow map (each cascade, on both renderers), an upper bound. Do not expect frame rate to improve.
|
|
49
60
|
- Switching cascades on, off or changing any cascade field recompiles every lit material once (a stall), and each material keeps the
|
|
50
61
|
old program until it is disposed (three would otherwise reuse a stale program whose uniforms no longer update). Do it on a settings
|
|
51
62
|
screen, not during play.
|
|
52
|
-
- Ladder for weaker devices: `
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
- Ladder for weaker devices: `count: 3` -> `2` -> `1` (one map); before dropping a cascade try a smaller `maxFar` or `mapSize`.
|
|
64
|
+
|
|
65
|
+
## Rules of the entry
|
|
66
|
+
It works with and without a sky, on both renderers (WebGPU needs `import 'threedog/tsl'`, or the call says so).
|
|
67
|
+
- The light must be a DirectionalLight, a direct child of `engine.scene`, with `castShadow = true`; anything else throws at the call.
|
|
68
|
+
- Color, intensity, `visible`, `castShadow` and `light.shadow` values stay yours and are read every frame. The cascades only place the light. On WebGL, while they are on,
|
|
69
|
+
`light.position` and `light.target` hold that placement: writes to `light.position` or a new `light.target` still set the direction, and
|
|
70
|
+
`remove()` puts both back as you left them, with the shadow camera box. A `light.target` you assigned (your player, say) is never moved.
|
|
71
|
+
- `engine.tier === 'low'` gets one map unless you pass `low: { count: 2 }`. On a game's light that map follows the camera and covers `maxFar` each way, so it is blurrier than cascades but never stops at the
|
|
72
|
+
origin; like cascades it places the light, so `engine.shadows.box` on that light is refused. On `engine.lights.sun` the one map stays the engine's own box around the focus, with its size. `handle.csm` is null while there is one map.
|
|
73
|
+
- An engine draws one set of cascades: a second handle throws. A box on the same light throws too, except the engine's own box on `engine.lights.sun`, which waits
|
|
74
|
+
until `remove()`.
|
|
75
|
+
- Another shadow-casting DirectionalLight next to cascades breaks the cascade order on WebGL (three sorts shadow casters first): one warning
|
|
76
|
+
names it; keep extra lights shadowless.
|
|
77
|
+
|
|
78
|
+
## A box that follows
|
|
79
|
+
One shadow map stays sharp when it covers little: one texel covers `2 x extent / mapSize` meters (the engine sun's 30 m on a 2048 map is about 3 cm, twice that on the 1024 map of low tier). A box much bigger than
|
|
80
|
+
what the camera sees blurs the shadows of small things; a box smaller than it cuts shadows off. A depth bias scales with the texel, so re-check `bias` / `normalBias` after changing either. `box` keeps that little around the action:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const sun = new THREE.DirectionalLight('#fff', 3);
|
|
84
|
+
sun.position.set(40, 80, 30); sun.castShadow = true;
|
|
85
|
+
engine.scene.add(sun);
|
|
86
|
+
|
|
87
|
+
const box = engine.shadows.box(sun, { follow: player, extent: 40, snap: 'texel' });
|
|
88
|
+
box.set({ extent: 60 }); // a wider view
|
|
89
|
+
box.remove(); // position, target and the shadow camera come back
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| field | default | meaning |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `follow` | `'focus'` | `'focus'` (`engine.focus`), `'camera'`, an Object3D, `() => Vector3`, or `false` (it stays on the light's target) |
|
|
95
|
+
| `extent` | left out | half size in meters, written on `light.shadow.camera`; left out, the camera stays as you set it |
|
|
96
|
+
| `snap` | 0.5 | center snap grid in meters, or `'texel'`: one shadow pixel, no shimmer on a moving camera |
|
|
97
|
+
| `ahead` | 0 | meters the center is shifted in front of the view |
|
|
98
|
+
|
|
99
|
+
- A game light gets no box unless you call this. The light keeps its direction, which is its position minus its target, so aim it as usual; a `light.target` you assigned
|
|
100
|
+
(your player, say) is never moved. It works like cascades here: `position` and `target` hold the placement while the box is on, and writes to `light.position` or a new `light.target` set the direction.
|
|
101
|
+
- The engine's placeholder sun under `sky()` has a box already, following `engine.focus`, 30 m each way. `engine.shadows.box(engine.lights.sun, { follow: false, extent: 9 })` changes that one
|
|
102
|
+
box and `remove()` restores it. Writing `engine.lights.sun.target.position` yourself takes the box's center over, with one warning; `{ follow: 'focus' }` gives it back.
|
|
103
|
+
|
|
104
|
+
## Keep what does not move
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
const kept = engine.shadows.cache(sun, { static: mesh => mesh !== cars.mesh }); // a test on each mesh; or an Object3D, or a list of them
|
|
108
|
+
kept.redraw(); // a static object moved, hid or left
|
|
109
|
+
kept.set({ static: town }); // say again what is static
|
|
110
|
+
kept.remove(); // three's own shadow node again
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Off until you call it, and only on the light you hand in. Static casters are drawn once into a second depth map. Each shadow frame copies that map into the light's own
|
|
114
|
+
shadow map and draws the rest on top, so no material or shadow filter changes. Whatever you did not name static keeps redrawing: forgetting one costs time, never a
|
|
115
|
+
wrong shadow. A static object added later (a streamed block) casts at once, drawn with the moving things until the next redraw. A batch counts as static when all its originals do, by a subtree or by a test; one moving original keeps the whole batch
|
|
116
|
+
redrawing.
|
|
117
|
+
|
|
118
|
+
**You must call `redraw()`** when a static object moves, hides or is removed: its old shadow stays until then. The engine does not watch for this, with one exception: an
|
|
119
|
+
`InstancedMesh` whose instances changed, or that left the scene (a batch too), redraws the kept map by itself.
|
|
120
|
+
|
|
121
|
+
It does not help when:
|
|
122
|
+
- **The sun moves.** Any change to the light or its box redraws everything, on top of the copy, so a day cycle costs more than plain shadows. Under a box the map holds
|
|
123
|
+
still until the center has left a quarter of the box; the shadows reach that much less far on the side the camera moves toward, and each step is one full redraw.
|
|
124
|
+
- **Wind or vertex animation moves a "static" object.** Its kept shadow does not sway. Leave those objects out of `static`.
|
|
125
|
+
- **Terrain detail changes.** A chunk that swaps its detail leaves the old shape in the kept map until `redraw()`. Leave it out, or call `redraw()` on the swap.
|
|
126
|
+
- **Few things cast.** The copy and the second map (mapSize x mapSize x 4 bytes, and float depth on the light's own map) are a fixed price. Frame time has not been measured yet.
|
|
127
|
+
|
|
128
|
+
WebGPU backend only, one plain map only: with cascades it is refused, and three's `CSMShadowNode` gives no way in. On WebGLRenderer and on WebGPURenderer's WebGL2 backend
|
|
129
|
+
the light draws everything, with one warning: the same picture, no saving. A budget on the same light still sets how often the moving things redraw.
|
|
130
|
+
Listed in `describe().threePatches` as `shadow-cache`.
|
|
131
|
+
|
|
132
|
+
## An update budget
|
|
133
|
+
A shadow map of a still scene need not redraw every frame:
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
const sun = new THREE.DirectionalLight(0xffffff, 2); // your main light
|
|
137
|
+
const budget = engine.shadows.budget(sun, { every: 3 }); // a third of the shadow fill cost
|
|
138
|
+
budget.redraw(); // something big moved: draw on the next frame
|
|
139
|
+
budget.set({ every: 1 }); // every frame again
|
|
140
|
+
budget.remove(); // light.shadow.autoUpdate as it was
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
It works on any light with a shadow, through that light's own `shadow.autoUpdate` and `shadow.needsUpdate`, so other lights are not touched. Skipped frames make swaying shadows stutter.
|
|
144
|
+
A box or cascades on the same light redraw early when they jump (teleport, fast travel).
|
|
145
|
+
|
|
146
|
+
## Resolution after the first draw
|
|
147
|
+
Before the first frame `light.shadow.mapSize.set(2048, 2048)` is all it takes. Once a map exists, three.js keeps it, so a settings menu or a one-shot change goes through the engine:
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const sun = new THREE.DirectionalLight(0xffffff, 2);
|
|
151
|
+
engine.shadows.mapSize(sun, 1024); // the map is rebuilt and redrawn; with cascades, every cascade's map
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Photo mode does this itself for every casting DirectionalLight in the scene (`photo({ shadowMapSize })`) and puts the sizes back after the shot.
|
|
155
|
+
|
|
156
|
+
## The master switch
|
|
157
|
+
```js
|
|
158
|
+
engine.shadows.enabled = false; // a game's own setting
|
|
159
|
+
const hold = engine.mod('shadows.enabled', { owner: 'cutscene', layer: 'system', set: false });
|
|
160
|
+
hold.remove(); // back to what was before
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
It writes `renderer.shadowMap.enabled` only, so no light's `castShadow` changes, and recompiles materials once: use it on a menu, not per frame. The settings menu holds the same
|
|
164
|
+
point (`'shadows.enabled'`, layer `settings`, restrict only), so a player who turned shadows off keeps them off through a cutscene; a game's `true` does not undo that.
|
|
165
|
+
|
|
166
|
+
## Filter, bias, softness, map size: three.js
|
|
167
|
+
```js
|
|
168
|
+
engine.renderer.shadowMap.type = THREE.VSMShadowMap; // BasicShadowMap | PCFShadowMap (default) | VSMShadowMap
|
|
169
|
+
const sun = new THREE.DirectionalLight(0xffffff, 2);
|
|
170
|
+
sun.shadow.radius = 3; sun.shadow.blurSamples = 8; // softness (pcf, vsm); blur quality (vsm)
|
|
171
|
+
sun.shadow.bias = -0.0001; sun.shadow.normalBias = 0.03;
|
|
172
|
+
sun.shadow.mapSize.setScalar(2048); // before the first frame; later also sun.shadow.map?.dispose(); sun.shadow.map = null;
|
|
173
|
+
```
|
|
55
174
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
175
|
+
Changing the type later:
|
|
176
|
+
- WebGLRenderer does the work itself on the next frame that draws a shadow, only for lights that draw on that frame. A light under `engine.shadows.budget` is redrawn
|
|
177
|
+
by the budget at once. A light of your own with `shadow.autoUpdate = false` needs `light.shadow.needsUpdate = true` in the same frame, or it keeps its old map.
|
|
178
|
+
- WebGPURenderer reads the type when it builds a light's shadow node. Set it before the first frame; there is no switch at run time.
|
|
60
179
|
|
|
180
|
+
Each switch costs one recompile of every lit material: a settings screen, not during play.
|
|
@@ -7,7 +7,7 @@ textures, baked shadows, sculpted edges. That finish comes from Blender. This pa
|
|
|
7
7
|
## 1. In Blender
|
|
8
8
|
1. **Model** at real scale (1 unit = 1 meter), origin at the object's base. Apply scale and rotation (Ctrl+A).
|
|
9
9
|
2. **UV unwrap** every textured mesh. A mesh with a texture but no UV set shows one flat pixel (`assets check` warns `texture-without-uv`).
|
|
10
|
-
3. **Bake** the
|
|
10
|
+
3. **Bake** the picture into textures: base color (the paint), optional AO, optional baked light. One image per material keeps draw calls low;
|
|
11
11
|
one shared atlas for many small props is cheaper still. Keep textures at 2048 or less (`assets check` warns above that).
|
|
12
12
|
4. **Name things**: objects, materials and (for animated models) actions. Names survive export and compression, and the engine reads them
|
|
13
13
|
(`spawn`, `col_xxx`, `trigger_xxx`, `template`, `id`; ground type from the material name, see recipe 10).
|
|
@@ -21,7 +21,7 @@ File > Export > glTF 2.0, into `art/models/` of the game:
|
|
|
21
21
|
| Transform > +Y Up | on | three.js is Y-up; the exporter converts from Blender's Z-up |
|
|
22
22
|
| Mesh > Apply Modifiers | on | the game gets the shape you see |
|
|
23
23
|
| Mesh > UVs, Normals, Vertex Colors | on if used | missing data cannot be added later |
|
|
24
|
-
| Material > Images | Automatic (embedded in the .glb) | `threedog assets` recompresses them anyway |
|
|
24
|
+
| Material > Images | Automatic (embedded in the .glb) | `threedog assets optimize` recompresses them anyway |
|
|
25
25
|
| Animation > Actions / NLA tracks | on for animated models | each action becomes one clip; name it as the game will (`Idle`, `Walk`, `Slash`) |
|
|
26
26
|
| Limit to > Visible Objects | off for levels | hidden `col_` boxes must be exported |
|
|
27
27
|
|
|
@@ -30,11 +30,11 @@ Do not join meshes or decimate a level: node names are its interface.
|
|
|
30
30
|
## 3. Check, then compress
|
|
31
31
|
```
|
|
32
32
|
threedog assets check art/models/town.glb # inspect only: spawns, col_ colliders, trigger_ zones, template / id nodes, material suspicions
|
|
33
|
-
threedog assets # compress art/models/*.glb into public/
|
|
33
|
+
threedog assets optimize # compress art/models/*.glb into public/optimized/ (add -w my-game for a game)
|
|
34
34
|
```
|
|
35
35
|
`assets check` also lists materials, textures with the color space three gives them (by slot), normal maps, clips, `col_` colliders and template / id nodes.
|
|
36
|
-
After loading, `engine.assets.report('hero')` (
|
|
37
|
-
flags what the file has but the scene lost: `normal-map-lost`, `material-replaced` (
|
|
36
|
+
After loading, `engine.assets.report('hero')` (pass a copy from `model()` to check what the game shows) lists the same from the scene and
|
|
37
|
+
flags what the file has but the scene lost: `normal-map-lost`, `material-replaced` (your code took over), `clip-lost`, `clip-unmapped` (an animation
|
|
38
38
|
state names a clip the file lacks), `node-lost`, and wrong color spaces. The engine never recomputes normals or drops a normal map on a GLB; only code
|
|
39
39
|
that swaps materials as in section 5 does.
|
|
40
40
|
Swapping an export for a new one: `threedog assets check new.glb --against old.glb` lists what the old file had and the new one lacks (errors: `col_`
|
|
@@ -44,15 +44,14 @@ colliders, template / id nodes, spawn / trigger_ / npc_ / marker_ points; warnin
|
|
|
44
44
|
| Step | What it does | When it matters |
|
|
45
45
|
|---|---|---|
|
|
46
46
|
| Meshopt | compresses geometry; the decoder ships with the engine | always on; smaller download, no visual change |
|
|
47
|
-
|
|
|
48
|
-
| KTX2 (`threedog assets --ktx2`) | textures stay compressed on the GPU too | many or large textures; needs the `ktx` tool (KTX-Software), else falls back to WebP and says so (`--ktx2 --strict` fails instead) |
|
|
47
|
+
| KTX2 | textures stay compressed on the GPU too, and the download shrinks | always on for a model with textures; encoded by the `ktx` tool when it is on PATH, else by the WebAssembly encoder of `ktx2-encoder`, which comes with the tools; if neither runs, that model fails, the command says why, and the game's `assets.js` stays as it was |
|
|
49
48
|
|
|
50
49
|
It needs `@gltf-transform/cli` (`npm i -D @gltf-transform/cli`). Unchanged files are skipped; `--force` redoes everything.
|
|
51
50
|
|
|
52
51
|
### The same shot again, before and after
|
|
53
52
|
Declare fixed views once: `engine.views.define('gate', { position: [10, 4, 12], target: [0, 1, 0], fov: 50 })` (`views.show(name)` also works in code). Then
|
|
54
53
|
`npm run shot -- -w my-game --view gate --keep` takes the picture from there in any game (the page's own `?view=` still wins where a page handles it, as
|
|
55
|
-
in the
|
|
54
|
+
in the picture test). After a change, `npm run shot -- -w my-game --view gate --compare .threedog/shots/<before>.png` prints both file names, one pixel-diff
|
|
56
55
|
number (0 = identical) and the brightness / saturation / contrast / detail differences. A view holds the camera (`engine.takeCamera`) until `views.release()` or the handle `show()` returns is removed; a cutscene that held it before gets it back.
|
|
57
56
|
Views can also be content: `content/views.js` = `{ gate: { position: [10, 4, 12], target: [0, 1, 0], fov: 50 } }` is defined by `engine.content.load` (checked by `npm run check`; example: `examples/action/content/views.js`, `npm run shot -- action --view corner`).
|
|
58
57
|
`describe render` also shows the renderer output color space and warns when it is not srgb; `assets.report` flags color maps that are not srgb and data maps that are.
|
|
@@ -61,8 +60,7 @@ Views can also be content: `content/views.js` = `{ gate: { position: [10, 4, 12]
|
|
|
61
60
|
`engine.debug.view('albedo')` shows only the base color and texture (unlit), `'lighting'` plain white clay under the scene lights, `'shadow'` the same with
|
|
62
61
|
ambient and hemisphere light hidden so shadows read black, `'normals'` the normals as color (a normal map shows here); `'off'` restores everything.
|
|
63
62
|
A view is temporary and owner-scoped (`{ owner }`; another owner needs `force: true` to clear it), never saved, and `describe().render` / `describe render`
|
|
64
|
-
start with a DEBUG VIEW line while one is on, so a screenshot of clay is not taken for the real
|
|
65
|
-
It needs the debug module (`engine.use(debug())`).
|
|
63
|
+
start with a DEBUG VIEW line while one is on, so a screenshot of clay is not taken for the real picture. Meshes added after the call are not covered: call it again.
|
|
66
64
|
|
|
67
65
|
## 4. Use it
|
|
68
66
|
Register the compressed file in the asset pack and refer to it by name everywhere else:
|
|
@@ -77,23 +75,21 @@ engine.assets.manifest({ name: 'town-art', models: {
|
|
|
77
75
|
```
|
|
78
76
|
A whole level is `level({ url: '/models/town.glb' })` (recipe 10). Animation clips and their mapping to game actions: `13-animation.md`.
|
|
79
77
|
|
|
80
|
-
## 5. The GLB's own materials
|
|
81
|
-
**The GLB keeps its own materials.** The engine loads them as they are (textures, colors, roughness) and does not swap them
|
|
82
|
-
that is what lets a painted or baked texture show.
|
|
83
|
-
(terrain, vegetation, procedural models, pickups). One scene can mix GLB props and styled code-built things.
|
|
78
|
+
## 5. The GLB's own materials
|
|
79
|
+
**The GLB keeps its own materials.** The engine loads them as they are (textures, colors, roughness) and does not swap them;
|
|
80
|
+
that is what lets a painted or baked texture show. One scene can mix GLB props and code-built things.
|
|
84
81
|
|
|
85
|
-
There is no automatic mapping from a GLB material name to
|
|
86
|
-
|
|
82
|
+
There is no automatic mapping from a GLB material name to anything. To give a GLB your game's materials, do it in your game code, per model: name the
|
|
83
|
+
material in Blender (`cloth`, `metal`, `glass`) and look it up in your `picture/materials.js`:
|
|
87
84
|
```js
|
|
88
85
|
const m = await engine.assets.model('hat');
|
|
89
|
-
m.traverse(o => { if (o.isMesh
|
|
86
|
+
m.traverse(o => { if (o.isMesh && materials[o.material.name]) o.material = materials[o.material.name]; });
|
|
90
87
|
```
|
|
91
|
-
This replaces the painted material, so the texture is gone unless
|
|
92
|
-
not list falls back to `materials.default`.
|
|
88
|
+
This replaces the painted material, so the texture is gone unless yours sets `map`.
|
|
93
89
|
|
|
94
90
|
## 6. Smallest copyable flow
|
|
95
91
|
1. Blender: a cube named `well`, UV unwrapped, base color baked to a texture, export `art/models/well.glb` with the settings above.
|
|
96
|
-
2. `threedog assets check art/models/well.glb` (no errors), then `threedog assets`.
|
|
92
|
+
2. `threedog assets check art/models/well.glb` (no errors), then `threedog assets optimize`.
|
|
97
93
|
3. Add `well: '/models/well.glb'` to `engine.assets.manifest({ models })`.
|
|
98
94
|
4. `engine.add(await engine.assets.model('well'))`, then `threedog shot /your-page.html --describe-only` or open the page.
|
|
99
95
|
|
|
@@ -103,12 +99,12 @@ not list falls back to `materials.default`.
|
|
|
103
99
|
| Model too dark, or textures washed out/white | color space: a color map used as data or a data map as color (`assets check` reports `looks like data` / `looks like color`) | color maps (base color, emissive) are sRGB; normal, AO, roughness are Non-Color in Blender; one image per use |
|
|
104
100
|
| Texture shows one flat color | no UV set on that mesh (`texture-without-uv`) | unwrap in Blender, export again |
|
|
105
101
|
| Emissive never glows | emissive texture with black emissive color (`emissive-hidden`) | set the emissive color to white |
|
|
106
|
-
| Node names lost (`spawn`, `col_` not found) | meshes joined before export | keep objects separate; `threedog assets` never flattens or joins; run `assets check` to see what the level finds |
|
|
102
|
+
| Node names lost (`spawn`, `col_` not found) | meshes joined before export | keep objects separate; `threedog assets optimize` never flattens or joins; run `assets check` to see what the level finds |
|
|
107
103
|
| Custom properties missing (`template`, `id`) | "Custom Properties" off at export | tick it and export again |
|
|
108
104
|
| Collision does nothing | `col_` object not exported, or no `collision()` module | export hidden objects; `engine.use(level(...), collision())`; test `engine.collision.walkable({ x, z })` |
|
|
109
|
-
| Painted material replaced by
|
|
110
|
-
| File too big | large textures or many materials | textures at 2048 or less, share atlases, `threedog assets
|
|
105
|
+
| Painted material replaced by a flat look | game code swapped it (section 5) | remove the swap, or give your material a `map` |
|
|
106
|
+
| File too big | large textures or many materials | textures at 2048 or less, share atlases, `threedog assets optimize`; sizes are in the `assets` output and `.threedog/optimize-report.json` |
|
|
111
107
|
| Clip not found | action name differs from the manifest `animation` mapping | rename the action in Blender or change `clip:` |
|
|
112
108
|
|
|
113
|
-
See also: `10-blender-level.md` (level names and markers), `43-shader-patches-
|
|
114
|
-
`35-
|
|
109
|
+
See also: `10-blender-level.md` (level names and markers), `43-shader-patches-surfaces.md` (your own material, shader patches),
|
|
110
|
+
`35-picture-from-reference.md` (a whole picture from a reference image).
|
|
@@ -7,7 +7,7 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
|
|
|
7
7
|
1. **State.** Prefer world records (`engine.world.add({ kind, ... })`, recipe 18): saved, streamed and far-simulated for you. State that is not a
|
|
8
8
|
record (a counter, a machine's queue) goes in `engine.saves.register(key, { save, load, version?, migrate? })`. Raise `version` by 1 whenever the
|
|
9
9
|
saved shape changes and add `migrate: { oldVersion: d => newData }`. Never keep game state only in a closure or module variable.
|
|
10
|
-
2. **Time, normal play.** Store *when* something happened in
|
|
10
|
+
2. **Time, normal play.** Store *when* something happened in calendar seconds (`engine.clock.now`), and derive the state from `now - startedAt`. Never use
|
|
11
11
|
`Date.now`, `performance.now` or `setTimeout` for game time: they ignore pause, time channels, `step` and saves. If you must accumulate, do it in
|
|
12
12
|
the module `fixed(dt, e)` hook (dt is real seconds; a speed several systems change goes through `engine.mod`, recipe 06).
|
|
13
13
|
3. **Time, skipped** (`engine.skip`, the op `time.skip`, recipe 06 section 2). `fixed` hooks, physics and near simulation do **not** run during a skip.
|
|
@@ -15,7 +15,7 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
|
|
|
15
15
|
segment, `done` on the last; do heavy work once when `done`), or put the logic in a world record `far(rec, dt)`, which gets one catch-up call.
|
|
16
16
|
4. **Observable.** Module hook `describe(e, ctx)` puts its return value in `describe().<module name>` (plain JSON; the bridge `describe <name>` and
|
|
17
17
|
`describeText()` show it). A game without a module uses `engine.describe.add(name, fn)`. The name must be new (it throws on a clash).
|
|
18
|
-
|
|
18
|
+
Keep it compact: the state an AI checks to verify the module worked.
|
|
19
19
|
5. **Actions are ops.** `engine.ops.define('noun.verb', { args, can, run, offers, reasons, desc })`. `can` is read-only and returns `true` or a reason
|
|
20
20
|
string (a key of `reasons`); `run` changes state; `offers(e, ctx)` lists the arg sets possible right now (shown by the bridge `ops` command and
|
|
21
21
|
`describe`). Call with `engine.ops.run(name, args)` -> `{ ok, value }` or `{ ok: false, code, facts, nextActions }` (read `r.code`). Never mutate state from UI code directly.
|
|
@@ -23,14 +23,14 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
|
|
|
23
23
|
## Declaring stage and dependencies
|
|
24
24
|
`stage` only picks where the hooks run (first to last): `control, ground, environment, gameplay, effects, late (default), audio`; `before / after`
|
|
25
25
|
(module names) only order modules inside one stage; a contradiction with the stage order throws. `requires: ['world']` names a capability that must already be provided (throws
|
|
26
|
-
otherwise, naming both fixes: the engine's `world()` first, or your own module with `provides: ['world']`). `type` says what the module
|
|
27
|
-
(recipe 14: `'rules'
|
|
26
|
+
otherwise, naming both fixes: the engine's `world()` first, or your own module with `provides: ['world']`). `type` says what the module owns
|
|
27
|
+
(recipe 14): none means `'rules'`, game logic like this one, and a module doing what its type does not usually own (a `'picture'` module defining an op) gets a dev warning, never a refusal. `optional: { sky: 'what is lost without it' }` is a soft dependency (use `engine.sky?.`). Core never imports
|
|
28
28
|
modules. The module `name` must not clash with an existing engine property.
|
|
29
29
|
|
|
30
30
|
## One copyable module: something that finishes after a delay (a smelter, a turret recharge, a crop)
|
|
31
31
|
```js
|
|
32
32
|
export const machines = () => {
|
|
33
|
-
const started = new Map(); // id -> startedAt (
|
|
33
|
+
const started = new Map(); // id -> startedAt (calendar seconds)
|
|
34
34
|
return {
|
|
35
35
|
name: 'machines', type: 'rules', stage: 'gameplay', requires: ['inventory'],
|
|
36
36
|
install(e) {
|
|
@@ -4,9 +4,9 @@ Pass a ready three.js renderer when the game must own it (shared canvas, an edit
|
|
|
4
4
|
|
|
5
5
|
```js
|
|
6
6
|
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
|
|
7
|
-
const engine = createEngine({ renderer
|
|
7
|
+
const engine = createEngine({ renderer }); // canvas defaults to renderer.domElement
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
- The engine configures only a renderer it created itself. With yours it sets nothing: pixel ratio (unless `pixelRatio` is given), size, tone mapping, exposure and shadow map stay as you left them, so
|
|
10
|
+
- The engine configures only a renderer it created itself. With yours it sets nothing: pixel ratio (unless `pixelRatio` is given), size, tone mapping, exposure and shadow map stay as you left them, so set them yourself on the renderer. MSAA follows your renderer's `antialias` too (unless `createEngine({ antialias })` says otherwise; a value that differs from the renderer's runs the post chain's MSAA targets every frame).
|
|
11
11
|
- **WebGLRenderer or three's WebGPURenderer.** On WebGPURenderer, materials, patches and post effects take their node / TSL forms (recipe 56). Everything else (scene, modules, input, saves, ops) does not depend on the renderer.
|
|
12
|
-
- Changing the renderer, lights or post effects is yours to do at any time; the engine never warns. `engine.describe().render` (CLI: `describe render`) lists the current values
|
|
12
|
+
- Changing the renderer, lights or post effects is yours to do at any time; the engine never warns. `engine.describe().render` (CLI: `describe render`) lists the current values; `describe().picture.writers` says which line wrote each on the dev server.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# 52 Around the picture: reading it back, the post chain, who writes what
|
|
2
|
+
|
|
3
|
+
**In this recipe**: Atmosphere · Surfaces · Post effect chain · Who writes it
|
|
4
|
+
|
|
5
|
+
The picture is plain three.js in a `picture/` folder that reads `engine.uniforms` ([recipe 62](62-picture-code.md)). This page covers what sits around that code: reading the picture back,
|
|
6
|
+
trying a value out, and the engine pieces it talks to.
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
engine.describe('picture').picture; // tone, exposure, fog, environment, background, every light, shadows: what three.js holds now
|
|
10
|
+
const h = engine.debug.override('me', engine.renderer, 'toneMappingExposure', 3); // try a value on any three.js object; held above your picture/ code
|
|
11
|
+
h.remove(); // back to what your code writes (engine.debug.clear('me') takes every override of that owner)
|
|
12
|
+
engine.catalog('post'); // a capability's entries and what it holds now; also 'shadows'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Which knob changes what on screen, and how to judge it for your picture: [recipe 60](60-judge-the-picture.md). Where picture code sits among the other ways to customize: `../CONVENTIONS.md` "Customization ladder".
|
|
16
|
+
|
|
17
|
+
- The picture is not saved: after a load, your `picture/` code draws it again from your own state.
|
|
18
|
+
- How bright a lit color comes out (three.js light units, exposure 1): a diffuse surface facing up receives `sun.intensity × sin(sun elevation) + hemi.intensity` (the hemisphere's sky color,
|
|
19
|
+
since it faces up), and three divides by π, so a total near π shows mid-tone albedos at roughly their own value under `AgXToneMapping`. AgX darkens light colors and pales saturated ones,
|
|
20
|
+
so a pale or vivid palette needs more, or exposure. Walls and faces away from the sun get only their `N·L` share, and the environment (`scene.environment`) adds on top for Standard / Physical materials.
|
|
21
|
+
|
|
22
|
+
## Atmosphere: fog, sky
|
|
23
|
+
|
|
24
|
+
Fog and the placeholder lights: [recipe 34](34-environment-lighting.md). The sky: plain values and calls on `engine.sky`, [recipe 08](08-weather-sky.md). Shadows: `engine.shadows` and three.js, recipe 45. Water and weather: recipe 44.
|
|
25
|
+
|
|
26
|
+
<a id="tsl-forms"></a>**tsl forms** (`renderer: 'webgpu'`): the GLSL hooks `engine.sky.clouds` and `engine.sky.layer` take `{ glsl, tsl }`; each renderer draws its own form and a missing one throws by name (`[webgpu-needs-tsl]` on WebGPU). `tsl: (ctx) => vec4 node`, ctx = the GLSL function's arguments as nodes plus the value so far (`ctx.clouds` the built-in kind, `ctx.color` the sky under a layer, `ctx.fog` what the fog kind alone draws), `ctx.uniforms` (the dome's, yours included), `ctx.fx` (the `threedog/tsl` functions, `ctx.fx.noise` and `hash` among them) and `ctx.tsl` (three/tsl):
|
|
27
|
+
`engine.sky.layer('glow', { glsl, tsl: ({ dir, tsl }) => tsl.vec4(1, 0.6, 0.3, tsl.smoothstep(0.3, 0.8, dir.y).mul(0.4)), blend: 'add' })`.
|
|
28
|
+
|
|
29
|
+
## Surfaces: ground, plants, cloud shadow, season
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
engine.terrain.material = myGroundMaterial; // plain three.js on the module; terrain({ colors, shading, detail }) are its start values (recipe 28)
|
|
33
|
+
engine.uniforms.uWindFreq.value = 1.5; engine.uniforms.uWindAmp.value = 0.5; // signals: live on every plant, planted ones too
|
|
34
|
+
engine.vegetation.define('grass', { geometry, wind: { amplitude: 0.05, glsl, tsl } }); // your own sway: threedogWind(...) / tsl: (ctx) => moved position (recipe 36)
|
|
35
|
+
engine.vegetation.color({ glsl: 'diffuseColor.rgb *= 0.8;', tsl: c => c.color.mul(0.8) }); // code in the color slot, live on planted species
|
|
36
|
+
engine.shaderTerms.cloudShadow({ glsl: 'reflectedLight.directDiffuse *= myShade(vThreedogWorld);', tsl: c => ({ directDiffuse: c.directDiffuse.mul(myShadeNode) }) });
|
|
37
|
+
engine.shaderTerms.cloudShadow(false); // no engine cloud shadow anywhere: draw your own
|
|
38
|
+
engine.shaderTerms.season(kind => ({ glsl: 'diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), uGroundCover.y);', tsl: c => myTint(c, kind) })); // your own season / snow tint
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- Wind is signals: `engine.uniforms.uWind` (weather), `uWindFreq`, `uWindAmp`. A three.js material of yours sways with `applyEffects(mat, { wind: 0.03 })`; your own shader calls `threedogWind(position, origin, amplitude)` (`#include <threedog_wind>`) or `wind(position, origin, amplitude)` (`threedog/tsl`).
|
|
42
|
+
- The whole plant picture is replaced as a module: `engine.use(myPlants, { replaces: 'vegetation-draw' })`.
|
|
43
|
+
- `engine.shaderTerms.cloudShadow(spec)` and `engine.shaderTerms.season(spec)` put your own patch (`{ glsl, tsl, uniforms?, pars?, slot? }`, slot `lighting` / `color` by default) in place of the engine's on every material that carries the term, including ones built before the call; `false` removes the term; the handle's `remove()` gives the engine's back. The signals stay bound: `uWeatherCloud, uCloudShadow*` and `threedogCloudShadow(worldPos)`; `uFoliageTint` / `uGroundTint` / `uFoliageMix` / `uGroundMix`, `uGroundCover` (cover amount alone, x foliage, y ground) and `threedogSeason(color, kind)` (TSL: `season(color, kind)`). `season` also takes `kind => spec` (kind `'foliage'` | `'ground'`). Each renderer draws its own form, and a missing one throws by name.
|
|
44
|
+
- Cloud shadow values are signals: `engine.uniforms.uCloudShadow` (darkest, 0 = none), `uCloudShadowScale`, `uCloudShadowSpeed`. The term sits on engine materials and on what you pass to `applyEffects(mat)`; your own shader calls `threedogCloudShadow(worldPos)` (GLSL) or `cloudShadow(positionWorld)` (`threedog/tsl`). The engine adds it to no other material.
|
|
45
|
+
|
|
46
|
+
## Post effect chain
|
|
47
|
+
|
|
48
|
+
Post-processing is an ordered list of named effects, and **`engine.post.add(x, { name, slot, order })` is the one way an effect gets
|
|
49
|
+
in**: game code and the game's `plugins/` folder (a file that exports the Pass or effect) go through it, so every
|
|
50
|
+
effect has a name, a handle and a row in `describe().slots` and `describe().render.post`. It returns `{ name, enabled, set(params), remove() }`, and
|
|
51
|
+
`engine.post.get(name)` returns the same handle. A wrong shape throws with nothing added.
|
|
52
|
+
|
|
53
|
+
`x` is a plain three.js Pass (WebGL), a TSL node function `(input, ctx) => node` (WebGPU), or an effect `{ name, create, node, fuse, slot, order, params, update, needsDepth, needsBuffers, backend, skipOnLowTier, facts }`: both renderers when it gives `create` and `node`, or a `fuse`. `create(ctx) => pass` returns any three.js postprocessing Pass, built the first time the effect is on, and `update?(pass, params)` applies new params (on WebGPU `node`: recipe 56). The optional ones: `needsBuffers` lists extra scene outputs on WebGPU, `backend: 'webgpu'` marks an effect the WebGL2 backend cannot run, `skipOnLowTier` holds it when `engine.tier` is 'low', `facts` adds a line to `describe().render.post`.
|
|
54
|
+
|
|
55
|
+
Each runs in a slot, then by `order` (low first): `scene` (replaces the scene render, one at a time, e.g. pixelation) -> `hdr` (linear color: outline, AO, bloom) -> `tone` (replaces the tone-mapping output, one at a time; it must output display color) -> `ldr` (sRGB: LUT, palette, grain, vignette) -> `final` (FXAA / SMAA).
|
|
56
|
+
|
|
57
|
+
A plain Pass is placed by its kind: one that renders `engine.scene` itself (`RenderPixelatedPass`, `SSAARenderPass`, `TAARenderPass`) goes in `scene` and replaces the engine's scene render (the scene is drawn once; a second one throws), FXAA / SMAA / TAA in `final`, any other in `hdr` after the effects already there (`ldr` when you added it after an OutputPass); a RenderPass of `engine.scene` and an OutputPass are skipped (the engine has them). Without `{ name }` it is listed by class or shader name (`CopyShader#1`); its `remove()` does not dispose it.
|
|
58
|
+
|
|
59
|
+
To read the chain: `engine.post.object()` and `engine.post.targets()`; both stay the engine's (it rebuilds passes, resizes, disposes), so change the chain through `engine.post`; to take the built chain over, `engine.post.own()` (`own(false)` gives it back). A game that renders the canvas itself (its own composer) takes the frame: the engine stops drawing and warns once `[own-frame]`.
|
|
60
|
+
```js
|
|
61
|
+
import { bloom, outline, vignette, lut } from '@threedog/post-effects'; // shared effects come from the add-on
|
|
62
|
+
import { LUTPass } from 'three/addons/postprocessing/LUTPass.js';
|
|
63
|
+
const line = engine.post.add(outline({ thickness: 1.5 })); engine.post.add(vignette());
|
|
64
|
+
line.enabled = false; // pauses it in place; a settings restriction above this still holds it off
|
|
65
|
+
engine.post.get('vignette').set({ strength: 0.6 }); // params by name; an unknown name throws
|
|
66
|
+
if (engine.tier !== 'low') engine.post.add(bloom()); // the heavy ones are the game's call on weak devices
|
|
67
|
+
engine.post.add({ name: 'myLut', slot: 'ldr', params: { lut: myLut }, create: ({ params }) => new LUTPass({ lut: params.lut }) });
|
|
68
|
+
// a plugin file brings the same effect with no main.js line: plugins/10-bloom.js
|
|
69
|
+
export default bloom({ strength: 0.2 });
|
|
70
|
+
```
|
|
71
|
+
- `bloom({ strength, radius, threshold })`, defaults 0.35, 0.5, 0.85: `strength` is how much glow is added, `radius` how far it spreads (0 to 1), `threshold` the brightness a pixel needs before it
|
|
72
|
+
glows at all. It reads linear color before the tone curve, so a surface brighter than 1 glows hard however small it is: if the frame washes out, raise `threshold` or lower that surface's brightness
|
|
73
|
+
before lowering `strength`. On the WebGPU route three's own `BloomNode` is also open to you through `engine.post.add({ node })`.
|
|
74
|
+
- The engine ships no effects. `@threedog/post-effects` (import only what you use) has `bloom`, `ao`, `outline`, `dof` (all `hdr`; outline and dof read depth) and `lut` (contrast / saturation / warm-cool / optional 3D LUT, or
|
|
75
|
+
`paletteLut(colors)` for a fixed palette), `grain`, `vignette`, `chromatic` (`ldr`), each on both routes. `voxelGI`, `temporalAA`, `sunShafts`, `lightVolumes` exist only on WebGPU: `@threedog/post-effects/tsl`. Materials and lighting as TSL: `threedog/tsl`; the three.js layers the engine keeps (`RESERVED_LAYERS`): `threedog/layers`.
|
|
76
|
+
An added effect is on (`enabled: false` adds it off, for `handle.enabled = true` later). The heavy ones (`bloom`, `ao`, `dof`, outline `normal`/`both`) are the game's call on weak devices (`threedog shot` renders the desktop tier, `--tier low` checks the low one).
|
|
77
|
+
- Depth: an effect that reads scene depth (`needsDepth: true`, e.g. `outline`) must run before any pass that swaps buffers (a `ShaderPass`, a
|
|
78
|
+
scene-slot pixelation pass, the tone-mapping output). A chain that breaks this throws when the effect is added or enabled, naming both effects;
|
|
79
|
+
give the depth reader a lower `order`. `dof` keeps the scene depth (`pass.keepsDepth = true`), so `dof` and `outline` can both be on while `dof`
|
|
80
|
+
has the lower `order` (default: dof 5, outline 10). The other order throws.
|
|
81
|
+
- Order of glow and a step-style grade (posterize, palette snap, a few-level LUT). Glow is a smooth falloff; a grade that snaps every pixel to a few levels, run **after** it, cuts that falloff into flat
|
|
82
|
+
plateaus, and the middle ones read as a grey stain around a light, not as light. It shows in any style that mixes glow with banded color and gets worse the fewer levels the grade has, and the default
|
|
83
|
+
order is the bad one (`bloom` is `hdr`, a grade `ldr`). Ways out, by the picture you want: (1) grade first, glow after: give the grade `slot: 'hdr'` and an `order` lower than bloom's (the halo may then
|
|
84
|
+
use colors outside the palette: fine for soft light, wrong for a strict palette); (2) keep the grade last and make the glow stepped on purpose, one or two clean rings; (3) drop the glow and paint the light
|
|
85
|
+
(emissive sprites, a lighter ring in the art). Judge it with a `threedog shot` close on one bright light against a dark ground: a gradient (1) or deliberate rings (2) are fine; a grey flat disc is the trap.
|
|
86
|
+
This was reasoned on a one-dimensional model of the two orders, not yet checked with the real passes.
|
|
87
|
+
- On / off: `engine.post.get('bloom').enabled = false` for every effect, whoever added it, pauses it where it is (place and params stay); `engine.plugins.off('<file>')` unloads a plugin (the effect leaves the chain; `on` plugs it again; a pack's file: `'<pack>/<file>'`). Either way
|
|
88
|
+
it comes back in the same place: inside a slot `order` decides, and equal orders keep the order the names were first added in. There is no `createEngine({ post })`. The switch is the shared point `post.<name>.enabled`: `enabled` writes its game layer, a hold of your own goes through `engine.mod('post.bloom.enabled', { owner, set, layer })`, and reading `enabled` gives what runs now.
|
|
89
|
+
The settings menu shows `bloom` / `ao` toggles only when effects with those names exist; a toggle the player turns off sits on the settings layer of that point, above the game and any hold (`describe().render.post` reads `writer: 'settings'`). MSAA is `engine.post.setAntialias(on)` and works with every effect on.
|
|
90
|
+
- `fuse`: a light color effect can skip its own fullscreen pass by carrying a GLSL snippet instead of `create()`:
|
|
91
|
+
`fuse: { uniforms: { uMyAmount: 'float' }, values: p => ({ uMyAmount: p.amount }), glsl: 'color.rgb *= 1.0 - uMyAmount * length(vUv - 0.5);' }`.
|
|
92
|
+
Fused effects that are on and next to each other in one slot (never `scene`) compile into one shader and draw in one pass, in `order`. The
|
|
93
|
+
snippet edits `vec4 color` and may use `vUv`, `tDiffuse`, `uTime`, `uResolution`, `fxHash(vec2)`; uniform names are shared by the group, so prefix
|
|
94
|
+
them with the effect name. A snippet that samples `tDiffuse` elsewhere (blur, color fringe) sets `reads: true` and starts a new group.
|
|
95
|
+
`engine.post.add({ name, fuse: { glsl }, slot: 'ldr' })` adds just a snippet.
|
|
96
|
+
- Outline: `outline({ mode: 'depth' | 'normal' | 'both' })`: `depth` (default, silhouettes), `normal` (creases; draws the scene once more with
|
|
97
|
+
normals, so it costs more), `both`. `fadeWithDistance: false` keeps lines at any distance; `wobble: 1.5` jitters lines by up to 1.5 px at 8 steps a
|
|
98
|
+
second. To exempt objects: `outline({ offLayer: OUTLINE_OFF_LAYER })` and `mesh.layers.enable(OUTLINE_OFF_LAYER)` (one extra render of just those objects; nothing when `offLayer` is `null`).
|
|
99
|
+
- Ambient occlusion (darker creases and contact corners): `ao({ radius, intensity })` wraps three's `GTAOPass`; `radius` is in world units, `intensity` 0..1, both change in place: `engine.post.get('ao').set({ radius: 0.6 })`.
|
|
100
|
+
Order 20 runs it before bloom and the tone mapping. It draws the scene once more with normals: points and lines are skipped, and a vertex-moving shader patch (wind) is not applied there, so swaying leaves get the AO of their rest pose.
|
|
101
|
+
Other GTAOPass settings (`samples`, `thickness`, `output`): `engine.post.object().passes.find(p => p.gtaoMaterial)`.
|
|
102
|
+
|
|
103
|
+
### dof: blur the background (focus blur, bokeh, miniature, tilt shift, cinematic)
|
|
104
|
+
`dof` from `@threedog/post-effects` blurs what is away from the focus distance: `engine.post.add(dof({ focus: 8, range: 3, maxBlur: 5 }))`, then `engine.post.get('dof').set({ focus: distanceToTarget })` each frame for a follow focus. A small `range` and a large `maxBlur` read as a miniature; a long `range` as a soft cinematic backdrop. It is not a shadow setting (`engine.shadows` blur is edge softness).
|
|
105
|
+
|
|
106
|
+
## Who writes it: the ownership table
|
|
107
|
+
|
|
108
|
+
Some three.js values the engine writes **on its own**, every frame or on a timer: the camera module places the camera, a sky keeps the shadow box around the focus. Lights, fog, exposure and the environment are not among them: the game's `picture/` code is their one writer (recipe 62).
|
|
109
|
+
Each of them is registered once (`core/ops/owned.js`), and every one behaves the same way:
|
|
110
|
+
|
|
111
|
+
- **Engine** (default): the engine writes it. Adjust it while the engine keeps driving: the `set` call in the table.
|
|
112
|
+
- **Taken** (`manual`): `engine.autoView.manual('far' | 'fov' | 'pixelRatio')` stops the engine writing it; the three.js value is yours.
|
|
113
|
+
`manual(key, false)` (or the handle's `remove()`) gives it back. No module option starts a value taken over.
|
|
114
|
+
- **Written directly** without `manual`: the engine notices, **stops writing it and keeps your value**, and warns once with the `manual` call and the
|
|
115
|
+
hand-back call. This happens in release builds too (only the warning is dev-only), so a game behaves the same with and without checks.
|
|
116
|
+
- A `timeline.tween` on an object is a temporary takeover of that object only: no warning, no hand-over (other objects stay checked).
|
|
117
|
+
|
|
118
|
+
`engine.describe().owned` lists every registered value and who writes it now, as `writer` (`engine`, `manual:game`, `three (engine yielded)`).
|
|
119
|
+
|
|
120
|
+
| id | part | written when | take it | adjust while the engine drives |
|
|
121
|
+
|---|---|---|---|---|
|
|
122
|
+
| `shadow.follow` | shadow | the box on the engine sun: under a sky every frame (center = `sun.target`); without one the placeholder sun follows `engine.focus` | `engine.shadows.box(engine.lights.sun, { follow: false })` | `engine.shadows.box(engine.lights.sun, { extent })` |
|
|
123
|
+
| `toneMapping` | tone | never: `renderer.toneMapping` stays three.js's default until your code writes it | `engine.renderer.toneMapping = THREE.ACESFilmicToneMapping`; an own curve as a post stage: `engine.post.add({ name, slot: 'tone', create })` (or `node` on WebGPU; replaces OutputPass / renderOutput; outputs display color) | - |
|
|
124
|
+
| `background` | sky | sky: a backdrop color or skybox every frame; with the dome the dome hides when you take it | `scene.background = x` (the dome hides); whole sky: `engine.sky.replace(texture \| object3D)` | `engine.sky.backdrop = '#335577'` |
|
|
125
|
+
| `view.aspect` | view | every resize | `engine.autoView.manual('aspect')` | - |
|
|
126
|
+
| `sky.sunDir` | view | `sky()` each frame, from the time and `engine.sky.orbit` (the same vector as `uSunDir`) | `engine.autoView.manual('sunDir')` | - |
|
|
127
|
+
| `view.far` | view | terrain view range (`setViewChunks`) | `engine.autoView.manual('far')` | - |
|
|
128
|
+
| `view.fov` | view | the settings menu fov slider, camera modules (first person / rts fov, fixed shots, back to the install fov on a switch) | `engine.autoView.manual('fov')` | - |
|
|
129
|
+
| `view.pixelRatio` | view | adaptive resolution, about once a second while slow | `engine.autoView.manual('pixelRatio')` | `engine.setPixelRatio(1.5)` |
|
|
130
|
+
| `camera` (position, rotation) | view | the camera module, every frame | `const cam = engine.takeCamera('me')` (`cam.remove()` gives it back) | - |
|
|
131
|
+
| `post.chain` | post | whenever the effect list changes (add / remove / on / off, MSAA): the engine rebuilds the composer passes (WebGL) or `pipeline.outputNode` (WebGPU) | `engine.post.own()`: the built chain stays as you left it in `engine.post.object()`; `own(false)` rebuilds it from the list. A write to `object()` without `own()` does not yield: the next chain change replaces it | `engine.post.get('bloom').set({ strength: 0.6 })` |
|
|
132
|
+
| `shadow.csm` (not a property: a list) | shadow | while cascades are on: the `csm` patch goes on every built-in lit material, yours too (else N times as bright) | - (`handle.remove()`); your ShaderMaterial is left alone until `engine.shadows.include(mat)` | - |
|
|
133
|
+
|
|
134
|
+
Not in this table, because the engine writes them once rather than keeps writing them: automatic batching (it moves engine-placed meshes to layer 31
|
|
135
|
+
and says so once in the dev console and in `describe().perf.batching`; turn it off per object with `userData.batch = false`, see
|
|
136
|
+
[05-props-bake.md](05-props-bake.md) §2b) and `castShadow` on generator props (set when the model is made: a generator's own flags are kept, the
|
|
137
|
+
manifest entry can set them; change it on the object afterwards).
|