threedog 1.1.0 → 1.2.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 +879 -798
- package/README.md +1 -1
- package/core/assets/Animator.js +41 -3
- package/core/assets/Assets.js +100 -24
- package/core/assets/assetEntry.js +73 -20
- package/core/assets/assetHot.js +68 -16
- package/core/assets/assetLoad.js +6 -6
- package/core/assets/assetLod.js +9 -2
- package/core/assets/assetManifest.js +12 -2
- package/core/assets/assetPart.js +54 -0
- package/core/assets/ik.js +271 -0
- package/core/assets/modelNeeds.js +37 -0
- package/core/assets/namedModel.js +102 -29
- package/core/assets/nodeVisibility.js +15 -0
- package/core/audio/Audio.js +36 -4
- package/core/audio/audioReverb.js +99 -0
- package/core/audio/audioRules.js +1 -1
- package/core/audio/audioVoice.js +1 -1
- package/core/base/Events.js +14 -4
- package/core/base/Random.js +1 -1
- package/core/base/Vars.js +1 -1
- package/core/base/docRef.js +51 -0
- package/core/base/errorCodes.js +178 -126
- package/core/base/errorHints.js +9 -7
- package/core/base/errors.js +25 -10
- package/core/base/events.generated.js +2 -0
- package/core/base/freeParts.js +76 -0
- package/core/base/math.js +28 -0
- package/core/base/sections.js +5 -5
- package/core/base/validate.js +31 -3
- package/core/engine/Engine.js +16 -6
- package/core/engine/Loading.js +5 -3
- package/core/engine/copies.js +1 -1
- package/core/engine/headlessLoad.js +4 -1
- package/core/engine/lifecycle.js +32 -16
- package/core/engine/loop.js +71 -27
- package/core/engine/moduleSlots.js +2 -2
- package/core/engine/moduleTypes.js +3 -3
- package/core/engine/modules.js +65 -39
- package/core/engine/page.js +6 -3
- package/core/engine/services.js +6 -5
- package/core/engine/startup.js +5 -5
- package/core/input/Input.js +28 -14
- package/core/input/inputContext.js +28 -16
- package/core/input/inputKeyboard.js +31 -3
- package/core/input/inputPad.js +4 -0
- package/core/input/inputPointer.js +2 -1
- package/core/input/inputSeat.js +1 -1
- package/core/inspect/Budget.js +109 -19
- package/core/inspect/DebugOverrides.js +28 -4
- package/core/inspect/Describe.js +17 -9
- package/core/inspect/Inspect.js +4 -2
- package/core/inspect/InspectMaterials.js +3 -1
- package/core/inspect/InspectPerf.js +19 -9
- package/core/inspect/InspectScene.js +32 -7
- package/core/inspect/MaterialInfo.js +19 -2
- package/core/inspect/UrlState.js +46 -27
- package/core/inspect/catalog.js +28 -9
- package/core/inspect/debugView.js +2 -1
- package/core/inspect/describeRender.js +25 -13
- package/core/inspect/describeText.js +14 -6
- package/core/inspect/lightWatch.js +1 -1
- package/core/inspect/metadata.generated.js +35 -17
- package/core/inspect/pictureChecks.js +148 -0
- package/core/inspect/pictureMenu.js +84 -0
- package/core/inspect/pictureWriters.js +26 -6
- package/core/inspect/textureBytes.js +12 -2
- package/core/inspect/toolDoor.js +2 -4
- package/core/ops/Ops.js +11 -4
- package/core/ops/holds.js +27 -10
- package/core/ops/opsAtomic.js +15 -7
- package/core/ops/opsGuard.js +2 -2
- package/core/ops/opsRun.js +8 -7
- package/core/ops/sharedPoint.js +72 -21
- package/core/ops/stacks.js +56 -16
- package/core/saves/SaveStore.js +9 -3
- package/core/saves/Saves.js +32 -23
- package/core/saves/saveApply.js +96 -44
- package/core/saves/saveIds.js +1 -1
- package/core/saves/saveVersions.js +7 -5
- package/core/saves/session.js +17 -8
- package/core/saves/stateReplace.js +34 -15
- package/core/scene/Rays.js +52 -10
- package/core/scene/Views.js +13 -7
- package/core/scene/adaptive.js +144 -21
- package/core/scene/drawOnly.js +17 -0
- package/core/scene/gameLights.js +44 -3
- package/core/scene/sceneMethods.js +13 -11
- package/core/scene/stepPoses.js +11 -3
- package/core/scene/targeting.js +5 -3
- package/core/scene/thingOps.js +1 -1
- package/core/scene/tier.js +15 -0
- package/core/stream/Batching.js +30 -7
- package/core/stream/Stream.js +26 -7
- package/core/stream/batchGroups.js +2 -2
- package/core/stream/chunkStream.js +7 -5
- package/core/stream/prepare.js +77 -0
- package/core/time/skip.js +3 -1
- package/core/time/time.js +4 -2
- package/docs/AI.md +82 -83
- package/docs/API.md +16 -16
- package/docs/CODEMAP.md +16 -11
- package/docs/COMMANDS.md +139 -142
- package/docs/CONVENTIONS.md +37 -49
- package/docs/MIGRATING-0.8.md +2 -2
- package/docs/MIGRATING-1.0.md +2 -2
- package/docs/THREE.md +28 -35
- package/docs/api/assets.md +3 -1
- package/docs/api/audio.md +4 -2
- package/docs/api/budget.md +5 -0
- package/docs/api/characters.md +10 -8
- package/docs/api/collision.md +6 -4
- package/docs/api/engine.md +16 -16
- package/docs/api/events.md +3 -2
- package/docs/api/ground.md +6 -5
- package/docs/api/hud.md +4 -2
- package/docs/api/input.md +5 -5
- package/docs/api/particles.md +2 -1
- package/docs/api/photo.md +3 -0
- package/docs/api/post.md +7 -4
- package/docs/api/quests.md +2 -2
- package/docs/api/rays.md +1 -2
- package/docs/api/saves.md +7 -7
- package/docs/api/settings.md +2 -2
- package/docs/api/tools.md +3 -1
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -2
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +16 -17
- package/docs/recipes/02-npc.md +22 -18
- package/docs/recipes/03-items-pickups.md +37 -35
- package/docs/recipes/04-quests.md +15 -10
- package/docs/recipes/05-props-bake.md +101 -95
- package/docs/recipes/06-clock-events.md +28 -28
- package/docs/recipes/07-flow-scenes-pause.md +29 -26
- package/docs/recipes/08-weather-sky.md +52 -64
- package/docs/recipes/09-materials-lights-models.md +26 -17
- package/docs/recipes/10-blender-level.md +15 -10
- package/docs/recipes/11-vehicles.md +12 -7
- package/docs/recipes/12-navmesh.md +44 -26
- package/docs/recipes/13-animation.md +56 -45
- package/docs/recipes/14-custom-module.md +21 -18
- package/docs/recipes/15-perf.md +61 -55
- package/docs/recipes/16-dev-bridge.md +23 -33
- package/docs/recipes/18-world.md +36 -42
- package/docs/recipes/19-shooting-picking.md +20 -15
- package/docs/recipes/20-content-actions-save.md +48 -56
- package/docs/recipes/21-camera.md +45 -54
- package/docs/recipes/22-shop-gold.md +12 -7
- package/docs/recipes/23-ops.md +25 -23
- package/docs/recipes/26-ui-parts.md +67 -47
- package/docs/recipes/27-net.md +12 -7
- package/docs/recipes/28-terrain.md +24 -21
- package/docs/recipes/29-grid.md +32 -27
- package/docs/recipes/30-templates.md +21 -20
- package/docs/recipes/31-audio.md +39 -22
- package/docs/recipes/32-action-game.md +19 -14
- package/docs/recipes/33-stream-sources.md +15 -11
- package/docs/recipes/34-environment-lighting.md +126 -70
- package/docs/recipes/35-picture-from-reference.md +8 -8
- package/docs/recipes/36-ground-plants.md +27 -21
- package/docs/recipes/40-scene.md +19 -28
- package/docs/recipes/43-shader-patches-surfaces.md +15 -12
- package/docs/recipes/44-water-weather-hooks.md +34 -31
- package/docs/recipes/45-cascaded-shadows.md +35 -26
- package/docs/recipes/46-blender-art-route.md +6 -1
- package/docs/recipes/49-game-module-contract.md +13 -8
- package/docs/recipes/50-own-renderer.md +6 -2
- package/docs/recipes/51-capability-catalog.md +15 -8
- package/docs/recipes/52-around-the-picture.md +34 -32
- package/docs/recipes/53-ground-up-close.md +6 -1
- package/docs/recipes/55-mods-time-wrap.md +27 -19
- package/docs/recipes/56-webgpu-tsl.md +74 -43
- package/docs/recipes/57-control.md +18 -13
- package/docs/recipes/58-input.md +26 -16
- package/docs/recipes/59-depth-post-effects.md +8 -3
- package/docs/recipes/60-judge-the-picture.md +9 -8
- package/docs/recipes/61-deploy.md +5 -0
- package/docs/recipes/62-picture-code.md +70 -79
- package/docs/recipes/63-third-person-start.md +47 -45
- package/docs/recipes/64-particles.md +22 -10
- package/docs/recipes/65-swarm.md +18 -13
- package/docs/recipes/66-common-tasks.md +38 -35
- package/examples/action/GAMEMAP.md +2 -3
- package/examples/action/main.js +3 -3
- package/examples/action/picture/lights.js +3 -1
- package/examples/perf-island/GAMEMAP.md +3 -3
- package/examples/perf-island/picture/lights.js +2 -1
- package/examples/plain-picture/GAMEMAP.md +1 -1
- package/examples/rc2d/GAMEMAP.md +1 -1
- package/examples/styletest/GAMEMAP.md +2 -2
- package/examples/styletest/main.js +1 -1
- package/examples/techniques/interior-light/README.md +3 -3
- package/examples/techniques/interior-light/interiorLight.js +2 -4
- package/examples/techniques/interior-light/picture/lights.js +2 -1
- package/examples/techniques/modular-building/picture/lights.js +3 -1
- package/examples/techniques/outlines-and-rim/picture/lights.js +3 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/techniques/procedural-animation/main.js +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +1 -1
- package/examples/world/GAMEMAP.md +2 -3
- package/examples/world/art/humanoid.js +1 -1
- package/examples/world/main.js +6 -3
- package/index.d.ts +2 -2
- package/llms.txt +101 -0
- package/modules/ambience/Ambience.js +21 -5
- package/modules/calendar/index.js +9 -5
- package/modules/calendar/schedule.js +23 -8
- package/modules/camera/FirstPersonCamera.js +3 -1
- package/modules/camera/FollowCamera.js +10 -5
- package/modules/camera/RtsCamera.js +4 -3
- package/modules/camera/common.js +70 -8
- package/modules/camera/contract.js +1 -1
- package/modules/characters/Character.js +16 -10
- package/modules/characters/NPC.js +31 -19
- package/modules/characters/assetModel.js +14 -9
- package/modules/characters/astar.js +6 -1
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +34 -22
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +17 -2
- package/modules/characters/movers/simple.js +1 -1
- package/modules/characters/movers/support.js +16 -7
- package/modules/characters/npcAvoid.js +2 -2
- package/modules/characters/npcSim.js +3 -2
- package/modules/characters/pathAsync.js +24 -8
- package/modules/characters/pathJob.js +1 -1
- package/modules/characters/player.js +10 -9
- package/modules/characters/playerStrings.js +5 -5
- package/modules/characters/proceduralRig.js +5 -5
- package/modules/characters/useModel.js +6 -0
- package/modules/characters/walkTo.js +1 -1
- package/modules/collision/Collision.js +29 -18
- package/modules/collision/grid.js +22 -4
- package/modules/content/index.js +3 -1
- package/modules/content/loader.js +1 -1
- package/modules/content/models.js +82 -33
- package/modules/content/props.js +2 -1
- package/modules/content/rules.js +11 -5
- package/modules/content/templates.js +3 -3
- package/modules/content/words.js +2 -2
- package/modules/debug/DebugPanel.js +9 -9
- package/modules/flow/index.js +9 -6
- package/modules/gameplay/Dialogue.js +34 -20
- package/modules/gameplay/Interactions.js +19 -15
- package/modules/gameplay/Inventory.js +9 -4
- package/modules/gameplay/Quests.js +12 -10
- package/modules/gameplay/pickups.js +23 -11
- package/modules/grid/index.js +1 -1
- package/modules/grid/preview.js +2 -2
- package/modules/grid/tiles.js +1 -1
- package/modules/hlod/index.js +4 -1
- package/modules/hud/index.js +47 -10
- package/modules/hud/parts.js +28 -9
- package/modules/level/geometry.js +8 -3
- package/modules/level/index.js +10 -5
- package/modules/level/load.js +4 -2
- package/modules/lights/sources.js +1 -1
- package/modules/music/Music.js +22 -4
- package/modules/nav/index.js +20 -10
- package/modules/particles/Particles.js +31 -14
- package/modules/particles/effect.js +20 -5
- package/modules/particles/lit.js +72 -0
- package/modules/photo/Photo.js +72 -28
- package/modules/photo/pathTrace.js +106 -0
- package/modules/rigid/RigidBodies.js +23 -14
- package/modules/rigid/Vehicles.js +3 -13
- package/modules/rigid/sync.js +2 -1
- package/modules/settings/Settings.js +52 -20
- package/modules/settings/apply.js +23 -9
- package/modules/settings/sections.js +39 -6
- package/modules/settings/strings.js +2 -0
- package/modules/settings/view.js +19 -3
- package/modules/sky/dome.js +15 -3
- package/modules/sky/environment.js +28 -12
- package/modules/sky/fog.js +1 -1
- package/modules/sky/frame.js +6 -1
- package/modules/sky/shader.js +4 -3
- package/modules/sky/skyModule.js +8 -4
- package/modules/swarm/Swarm.js +1 -1
- package/modules/terrain/ChunkManager.js +61 -15
- package/modules/terrain/chunkJob.js +2 -2
- package/modules/terrain/index.js +20 -5
- package/modules/terrain/terrainEdit.js +8 -4
- package/modules/terrain/terrainTexture.js +4 -2
- package/modules/timeline/Timeline.js +4 -3
- package/modules/timeline/Tween.js +3 -0
- package/modules/timeline/letterbox.js +1 -0
- package/modules/triggers/index.js +36 -17
- package/modules/vegetation/Vegetation.js +81 -19
- package/modules/vegetation/densityMap.js +13 -8
- package/modules/vegetation/draw.js +147 -24
- package/modules/vegetation/groundChunks.js +20 -5
- package/modules/vegetation/index.js +3 -3
- package/modules/vegetation/modelGeometry.js +9 -4
- package/modules/water/Water.js +11 -8
- package/modules/weather/Weather.js +7 -2
- package/modules/weather/shaders.js +25 -5
- package/modules/weather/weatherDraw.js +20 -6
- package/modules/world/World.js +2 -1
- package/modules/world/index.js +2 -2
- package/modules/world/persist.js +6 -2
- package/modules/world/views.js +15 -2
- package/package.json +4 -1
- package/presets.js +5 -5
- package/render/PostFX.js +84 -41
- package/render/backend.js +137 -16
- package/render/cascades.js +3 -1
- package/render/cascades.tsl.js +2 -0
- package/render/daylight.js +7 -1
- package/render/detail.js +7 -4
- package/render/effects.js +27 -8
- package/render/fogLook.js +24 -0
- package/render/fuse.js +5 -2
- package/render/fx/detail.tsl.js +9 -7
- package/render/fx/index.js +7 -2
- package/render/fx/library.tsl.js +1 -0
- package/render/fx/lightShaft.tsl.js +114 -0
- package/render/fx/noise.tsl.js +25 -8
- package/render/fx/objectOrigin.tsl.js +39 -10
- package/render/fx/particles.tsl.js +23 -6
- package/render/fx/patchNodes.tsl.js +17 -12
- package/render/fx/pcss.tsl.js +51 -0
- package/render/fx/postWebGPU.tsl.js +89 -29
- package/render/fx/sky.tsl.js +3 -9
- package/render/fxNumbers.js +10 -4
- package/render/impostor.tsl.js +107 -0
- package/render/lighting.js +33 -1
- package/render/lightmap.js +42 -28
- package/render/lights.js +19 -3
- package/render/materials.js +6 -4
- package/render/mergeCommon.js +4 -1
- package/render/occlusion.js +14 -4
- package/render/patches.js +79 -41
- package/render/postRuns.js +32 -0
- package/render/postWebGL.js +97 -10
- package/render/probes.js +10 -14
- package/render/shaderErrors.js +2 -1
- package/render/shadowCache.tsl.js +33 -5
- package/render/shadows.js +42 -16
- package/render/slots.js +8 -5
- package/render/vertexInputs.js +52 -0
- package/types/core.d.ts +114 -46
- package/types/gameplay.d.ts +56 -23
- package/types/generated/core/audio/Audio.d.ts +27 -1
- package/types/generated/core/base/Random.d.ts +1 -1
- package/types/generated/core/input/Input.d.ts +6 -8
- package/types/generated/core/input/inputSeat.d.ts +1 -1
- package/types/generated/core/inspect/Budget.d.ts +26 -0
- package/types/generated/core/inspect/DebugOverrides.d.ts +0 -2
- package/types/generated/core/saves/Saves.d.ts +10 -7
- package/types/generated/core/saves/session.d.ts +8 -2
- package/types/generated/core/scene/Rays.d.ts +1 -3
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/world/World.d.ts +2 -1
- package/types/generated/render/PostFX.d.ts +35 -9
- package/types/physics.d.ts +796 -764
- package/types/pixel.d.ts +1 -1
- package/types/tsl.d.ts +62 -1
- package/types/world.d.ts +12 -3
- package/ui/Focus.js +7 -5
- package/ui/Parts.js +1 -1
- package/ui/touchPart.js +6 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Lights, fog, exposure and environment lighting
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
> **Covers:** lights, fog, exposure, environment maps, probes, lightmaps, light you can see in the air (light beams, shafts).
|
|
4
|
+
> **Use when:** lighting a scene or making its light change.
|
|
5
|
+
> **Shortest:** your own `THREE.DirectionalLight` added in `picture/`.
|
|
6
|
+
> **Sections:** Lights the placeholders, and · A light the player carries · Fog plain three.js, signals · Exposure and the tone · Environment maps · Light probes baked indirect · Lightmaps baked light on · Real-time bounced light WebGPU · Reflections · Light you can see · Soft shadows, area lights · Occlusion culling
|
|
4
7
|
|
|
5
8
|
Lights, fog and exposure are your own three.js code ([recipe 62](62-picture-code.md)): the sky computes signals and draws its dome, it writes none of them. The sky itself is `08-weather-sky.md`.
|
|
6
9
|
|
|
@@ -9,22 +12,36 @@ The engine has one directional light (`engine.lights.sun`) and one hemisphere (`
|
|
|
9
12
|
with no picture code is neutral gray and not black. Nothing moves them, with or without a sky.
|
|
10
13
|
|
|
11
14
|
```js
|
|
12
|
-
const engine = createEngine({ canvas, lights: false });
|
|
13
|
-
const sun = new THREE.DirectionalLight(0xffd0a0, 2); engine.scene.add(sun, sun.target);
|
|
15
|
+
const engine = createEngine({ canvas, lights: false }); // the placeholders stay out of the scene
|
|
16
|
+
const sun = new THREE.DirectionalLight(0xffd0a0, 2); engine.scene.add(sun, sun.target); // add your own lights before engine.start()
|
|
14
17
|
engine.onRender(() => { sun.position.copy(engine.uniforms.uSunDir.value).multiplyScalar(100); sun.intensity = 2 * engine.uniforms.uDaylight.value * engine.uniforms.uWeatherLight.value; });
|
|
15
18
|
const torch = new THREE.PointLight(0xffa040, 6, 12); engine.add(torch);
|
|
16
19
|
```
|
|
17
20
|
|
|
18
|
-
- `createEngine({ lights: false })`: the
|
|
19
|
-
|
|
20
|
-
- Shadows: only the engine sun's box is managed. Your own `castShadow` lights work as in three.js, each costing its
|
|
21
|
-
own shadow pass; `engine.shadows` (recipe 45) takes them when you hand them in, and `engine.shadows.enabled = false` turns every shadow off.
|
|
21
|
+
- `createEngine({ lights: false })`: the placeholders never enter the scene; `engine.lights.sun` / `hemi` stay as detached objects so nothing reads `undefined`.
|
|
22
|
+
- Shadows: only the engine sun's box is managed. Your own `castShadow` lights work as in three.js (one shadow pass each); `engine.shadows` (recipe 45) takes those you hand in, and `engine.shadows.enabled = false` turns every shadow off.
|
|
22
23
|
- Add or remove lights before `engine.start()`; what a change costs mid-play, and many lamps with `lightPool`: recipe 09 "Lights and stalls".
|
|
24
|
+
- A light the player carries (head lamp, torch, flashlight): place it every frame next to `engine.camera` or parent it to the player, as in three.js; nothing to call. While the camera hides the body (first person, a follow close-up), a shadow-casting point or spot light within one body width of the body is not shadowed by it, on both renderers, so the lamp pool has no black wedge; the sun and the other lights still cast the body's shadow. A body that is seen (third person) shadows every light, a torch in the hand too, as in plain three.js. The lamp's own fixture mesh is yours: give it `castShadow = false`, or it shadows its own light.
|
|
25
|
+
|
|
26
|
+
## A light the player carries (headlamp, lantern, flashlight): one spot that follows, with a shadow
|
|
27
|
+
One plain three.js `SpotLight`, moved with the view each frame (also a car's beam). `lightPool` is for many cheap lights sharing a few real ones (recipe 09), not for this.
|
|
28
|
+
```js
|
|
29
|
+
const beam = new THREE.SpotLight(0xffd8a0, 80, 18, 0.6, 0.5, 2); // color, intensity (candela), distance, angle, penumbra, decay
|
|
30
|
+
beam.castShadow = true; beam.shadow.mapSize.set(1024, 1024); beam.shadow.camera.near = 0.2;
|
|
31
|
+
engine.scene.add(beam, beam.target); // add before engine.start(), like any light
|
|
32
|
+
const ahead = new THREE.Vector3();
|
|
33
|
+
engine.onRender(() => { // after the camera moved this frame: the light never lags the view
|
|
34
|
+
const cam = engine.camera; beam.position.copy(cam.position);
|
|
35
|
+
beam.target.position.copy(cam.getWorldDirection(ahead)).multiplyScalar(4).add(cam.position);
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
- **Intensity is candela** (decay 2): a lantern with a short `distance` takes tens to a few hundred. Judge it in a shot of the darkest place.
|
|
39
|
+
- **Shadow cost**: one extra caster render per frame (a point light: six). Keep `distance` short (it bounds the shadow camera), `mapSize` modest; make it a quality setting. For a hand or shoulder, use that object's `getWorldPosition`.
|
|
23
40
|
|
|
24
41
|
## Fog: plain three.js, signals, your own math
|
|
25
42
|
```js
|
|
26
|
-
const fog = engine.scene.fog = new THREE.Fog(0x99bbbb, 60, 220);
|
|
27
|
-
engine.onRender(() => {
|
|
43
|
+
const fog = engine.scene.fog = new THREE.Fog(0x99bbbb, 60, 220); // or new THREE.FogExp2(color, density)
|
|
44
|
+
engine.onRender(() => { // a fog that follows the day and the weather: your picture/ code
|
|
28
45
|
fog.color.copy(engine.uniforms.uSkyHorizon.value);
|
|
29
46
|
fog.far = 220 / engine.uniforms.uWeatherFog.value;
|
|
30
47
|
});
|
|
@@ -33,27 +50,29 @@ There is no fog until your code makes one, and nothing writes it after that.
|
|
|
33
50
|
|
|
34
51
|
- Signals to read (table in recipe 62): fog in the color of `uSkyHorizon` hides the line where the dome meets the ground; `uWeatherFog` and `uViewDistance` feed your own fog distance.
|
|
35
52
|
- A fog color of your own that differs from the horizon: the dome fades its lower band to it, so fogged ground and sky still meet without a line.
|
|
36
|
-
- Color, near, far and density are live. Adding or
|
|
37
|
-
- Your own fog math (height fog, a warm far haze): the `fogPars` and `fog` slots on a material
|
|
53
|
+
- Color, near, far and density are live. Adding, removing or retyping `scene.fog` recompiles materials once: do it at a scene change.
|
|
54
|
+
- Your own fog math (height fog, a warm far haze): on WebGPU `scene.fogNode` (recipe 56); on WebGL the `fogPars` and `fog` slots on a material (recipe 43) or your own `ShaderMaterial`:
|
|
38
55
|
`applyEffects(material, { patches: [{ name: 'haze', slot: 'fog', glsl: 'float f = 1.0 - exp(-fogDensity * vFogDepth); gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(1.0, 0.85, 0.7), f * 0.3);' }] })`.
|
|
39
56
|
- Check the result with `engine.describe('picture').picture.fog`; `threedog shot` says how much of the picture the fog makes up.
|
|
40
57
|
|
|
41
58
|
## Exposure and the tone curve
|
|
42
59
|
```js
|
|
43
60
|
engine.renderer.toneMappingExposure = 1.3;
|
|
44
|
-
engine.onRender(() => { engine.renderer.toneMappingExposure = 1 + 0.5 * (1 - engine.uniforms.uDaylight.value); });
|
|
45
|
-
engine.renderer.toneMapping = THREE.NeutralToneMapping;
|
|
61
|
+
engine.onRender(() => { engine.renderer.toneMappingExposure = 1 + 0.5 * (1 - engine.uniforms.uDaylight.value); }); // over the day: your picture/ code
|
|
62
|
+
engine.renderer.toneMapping = THREE.NeutralToneMapping; // the curve; materials recompile on their next draw
|
|
46
63
|
```
|
|
47
64
|
The engine picks no curve: `renderer.toneMapping` stays three.js's default (`NoToneMapping`) until your code writes it. A curve of your own is a post effect in the `'tone'` slot (recipe 52).
|
|
48
65
|
|
|
66
|
+
Exposure that adapts like an eye (WebGPU): `engine.post.add(autoExposure({ min: 0.25, max: 4 }))` from `@threedog/post-effects/tsl` measures the average brightness on the GPU and eases toward `key`. It multiplies after everything that adds light, before tone mapping (`toneMappingExposure` still applies on top). Bloom runs before it, so in bright daylight large areas glow and are then darkened: raise bloom's `threshold` or give it an `order` above 800. Narrow `min` / `max` for an authored look; `speedUp` / `speedDown` set the speed, on `engine.time`; a chain rebuild keeps the adapted value. It measures a 64x64 sample: a small, very bright thing can nudge it.
|
|
67
|
+
|
|
49
68
|
## Environment maps
|
|
50
69
|
`scene.environment` is plain three.js and stays `null` until your code writes it. The background (the sky dome or a skybox) and the environment lighting are two separate fields.
|
|
51
70
|
|
|
52
71
|
```js fragment
|
|
53
|
-
const env = engine.sky.environment({ into: engine.scene });
|
|
54
|
-
engine.scene.environmentIntensity = 0.8;
|
|
72
|
+
const env = engine.sky.environment({ into: engine.scene }); // the sky as a map: follows the time of day; env.texture is the live map
|
|
73
|
+
engine.scene.environmentIntensity = 0.8; // intensity and rotation are three.js
|
|
55
74
|
engine.scene.environmentRotation.y = Math.PI / 2;
|
|
56
|
-
env.remove();
|
|
75
|
+
env.remove(); // takes the map off, frees it
|
|
57
76
|
// an asset panorama: plain PMREMGenerator
|
|
58
77
|
const pmrem = new THREE.PMREMGenerator(engine.renderer);
|
|
59
78
|
engine.assets.useTexture('hdr/studio.hdr', t => { t.mapping = THREE.EquirectangularReflectionMapping; engine.scene.environment = pmrem.fromEquirectangular(t).texture; });
|
|
@@ -63,19 +82,15 @@ engine.scene.environment = myPmremTarget.texture;
|
|
|
63
82
|
On `renderer: 'webgpu'` take `PMREMGenerator` from `three/webgpu`. A map you made is yours to dispose.
|
|
64
83
|
|
|
65
84
|
### The sky as a map: `engine.sky.environment({ into?, interval? })`
|
|
66
|
-
- Nothing is built before this call. Without `into` nothing is written
|
|
85
|
+
- Nothing is built before this call. Without `into` nothing is written: put `handle.texture` (a live getter) on the materials you choose (`material.envMap`).
|
|
67
86
|
- With `into`, that object's `.environment` gets the map at each rebuild. A map you write there yourself stays: the rebuilds go on, but only `handle.texture` follows them.
|
|
68
|
-
- The dome is rendered into a cube and prefiltered with `PMREMGenerator
|
|
69
|
-
|
|
70
|
-
day builds once. A call before the first frame waits for that frame, so the map uses real colors. One map at a time: a second call replaces the first.
|
|
71
|
-
- The cube is at least 256 px per face (PMREMGenerator's floor in 0.187), so a low tier saves time by rebuilding less often, or by your `picture/` code skipping the call on `engine.tier === 'low'`.
|
|
87
|
+
- The dome is rendered into a cube (at least 256 px a face) and prefiltered with `PMREMGenerator`, rebuilt only when sky colors, sun direction or cloud cover changed
|
|
88
|
+
AND `interval` seconds passed (default 1, 4 on a low tier; yours stands). A fixed time of day builds once; a call before the first frame waits for it. A second call replaces the first.
|
|
72
89
|
- An asset map is a fixed photo: it does not dim at night. Write `scene.environmentIntensity` from your own frame code reading `engine.uniforms.uDaylight`.
|
|
73
90
|
|
|
74
91
|
### What a MeshLambertMaterial does with it (three 0.187)
|
|
75
|
-
The engine's neutral materials are Lambert
|
|
76
|
-
|
|
77
|
-
- The hemisphere light stays and adds on top. When you turn the environment on, lower your hemisphere light so shadows do not wash out.
|
|
78
|
-
- The first frame with an environment recompiles every Lambert program once; do it at start-up, not mid-game.
|
|
92
|
+
The engine's neutral materials are Lambert: they get soft ambient light colored by the environment by direction, and no specular (reflections need Standard / Physical).
|
|
93
|
+
The hemisphere light still adds on top, so lower it when the environment comes on. The first frame with an environment recompiles every Lambert program once: do it at start-up.
|
|
79
94
|
- Toon, Basic and ShaderMaterial surfaces ignore it.
|
|
80
95
|
|
|
81
96
|
## Light probes (baked indirect light)
|
|
@@ -83,88 +98,129 @@ An environment map lights everything as seen from one point. Light probes (`engi
|
|
|
83
98
|
a bright wall, dimmer light under a roof), and every lit pixel takes its own light from the grid, on WebGL and WebGPU, with no shader of your own.
|
|
84
99
|
```js fragment
|
|
85
100
|
const probes = await engine.bakeProbes({ bounds: { min: [-30, 0, -30], max: [30, 8, 30] }, spacing: 4, include: o => !o.userData.moving });
|
|
86
|
-
const file = JSON.stringify(probes.toJSON());
|
|
87
|
-
const shipped = engine.loadProbes(json);
|
|
88
|
-
probes.sample(cart.position);
|
|
101
|
+
const file = JSON.stringify(probes.toJSON()); // ship this (half precision, a few tens of KB)
|
|
102
|
+
const shipped = engine.loadProbes(json); // at start-up, instead of the bake; either renderer reads either renderer's file
|
|
103
|
+
probes.sample(cart.position); // the SH at any point, for a "how dark is it here"
|
|
89
104
|
probes.remove();
|
|
90
105
|
```
|
|
91
|
-
- What it builds: three's probe grid over `bounds` (
|
|
92
|
-
`
|
|
93
|
-
- **Outside the grid there is no probe light
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
|
|
97
|
-
- Dark bake indoors: `scene.background` is a display color, far weaker than the sun, so a room lit by the sky comes out black. Raise the sky just for the bake
|
|
98
|
-
(a brighter `scene.background` or `backgroundIntensity`, put back after), and keep a little fill for walls that face away from every window.
|
|
99
|
-
- Cost: 6 renders per probe at load time, a few probes per task, so the page keeps drawing (`probes.bakeMs` says how long). Bake once and ship the JSON: phones often cannot bake, but
|
|
100
|
-
they all read the file. Meshes `include` rejects are hidden only while the cubes render. Adding a grid recompiles lit materials once, so do it at start-up.
|
|
106
|
+
- What it builds: three's probe grid over `bounds` (step at most `spacing`, at least 2 layers per axis) as `probes.grid`, a plain three.js light that costs almost nothing per frame:
|
|
107
|
+
`priority` and `visible` are yours; `intensity` works on WebGPU only.
|
|
108
|
+
- **Outside the grid there is no probe light** (half a step past `bounds`), and with no other ambient light a mesh goes black there: size `bounds` to where things are.
|
|
109
|
+
- **Light counted twice**: the bake saw the hemisphere light, the environment and any `material.lightMap`, and they still add at run time. Lower them where the probes take over, or bake without them (a warning and describe say so).
|
|
110
|
+
- Dark bake indoors: `scene.background` is a display color, far weaker than the sun. Raise it (or `backgroundIntensity`) for the bake only, and keep a little fill for walls no window sees.
|
|
111
|
+
- Cost: 6 renders per probe, a few per task, so the page keeps drawing (`probes.bakeMs`). Bake once and ship the JSON (phones often cannot bake, all read the file). Adding a grid recompiles lit materials once: at start-up.
|
|
101
112
|
- Check it: `engine.describe().render.probes` (count, step, source, owner, `outside`: lit objects the grid does not hold, `doubled`: what counts twice) and `engine.debug.view('probes')` (a dot per probe in its average color).
|
|
102
113
|
|
|
103
114
|
## Lightmaps (baked light on what never moves)
|
|
104
115
|
The best-looking baked light, and free at run time: it is plain `material.lightMap` on a second UV set, so a file baked on WebGPU draws the same on WebGL. Baking needs a real GPU and Google Chrome on the machine that bakes, not on the player's.
|
|
105
116
|
```js fragment
|
|
106
|
-
floor.userData.static = true; wall.userData.static = true;
|
|
117
|
+
floor.userData.static = true; wall.userData.static = true; // named meshes that never move
|
|
107
118
|
// npx threedog bake light --page "/?bake=1" --out public/light/level.lightmap --size 1024
|
|
108
119
|
const baking = new URLSearchParams(location.search).has('bake'); // the bake must see the lights the map replaces
|
|
109
120
|
if (!baking) {
|
|
110
|
-
const light = await engine.loadLightmap('light/level.lightmap');
|
|
111
|
-
hemi.visible = false;
|
|
121
|
+
const light = await engine.loadLightmap('light/level.lightmap'); // once the level is built
|
|
122
|
+
hemi.visible = false; // the bake saw it: keep the sun, drop the ambient
|
|
112
123
|
}
|
|
113
|
-
floor.material.lightMapIntensity = 1.2;
|
|
124
|
+
floor.material.lightMapIntensity = 1.2; // plain three.js, yours
|
|
114
125
|
```
|
|
115
|
-
-
|
|
116
|
-
- Turning the ambient off:
|
|
126
|
+
- Baked: sky and bounced light, by rays from every texel through the static meshes (walls stop light, a pillar shades what is behind it). The sun stays real-time, so moving things keep their shadows; its bounce is in the map. The game's hemisphere or ambient light is the sky during the bake, at the same strength.
|
|
127
|
+
- Turning the ambient off: picture code that writes `intensity` every frame (the template's `picture/lights.js`) undoes a one-off write, so hide the light (`visible = false`) behind a URL flag as above, never in the palette (the next bake would see no sky; a bake that sees no light writes nothing).
|
|
117
128
|
- Instanced and skinned meshes and anything moving cannot hold a lightmap: give them `engine.bakeProbes`. A grid also lights the baked meshes, so where the two overlap the light doubles; keep the grid's `bounds` to where the moving things go, or turn `lightMapIntensity` down.
|
|
118
|
-
- Files are large
|
|
129
|
+
- Files are large (half precision): 8 MB at 1024, 32 MB at 2048 before compression. Start small.
|
|
119
130
|
- Check it: `engine.describe().render.lightmap` lists `skipped` (instanced), `missing` (not found, or changed since the bake: bake again), `moved`, `doubled` (ambient light or a grid on top) and `shared` (an unbaked mesh on a baked material: give it its own).
|
|
120
131
|
- WebGPU and TSL: nothing changes. `material.lightMap` is read by node materials too, so there is no separate form.
|
|
121
132
|
|
|
122
133
|
## Real-time bounced light (WebGPU games only)
|
|
123
134
|
|
|
124
|
-
Bake first when the scene holds still
|
|
135
|
+
Bake first when the scene holds still (probes and lightmaps cost nearly nothing). Real-time bounce is for light that changes while the world stands (moving sun, carried lamp, opening door). WebGPU only (table below).
|
|
125
136
|
|
|
126
137
|
```js fragment
|
|
127
138
|
import { voxelGI, temporalAA } from '@threedog/post-effects/tsl';
|
|
128
139
|
engine.post.add(voxelGI({ bounds: new THREE.Box3(min, max), intensity: 1 }));
|
|
129
|
-
engine.post.add(temporalAA());
|
|
140
|
+
engine.post.add(temporalAA()); // clears the dots; it replaces MSAA while it is on
|
|
130
141
|
```
|
|
131
142
|
|
|
132
|
-
- `bounds` is the world box to voxelize. Keep it tight: the same voxels
|
|
133
|
-
- Lights can move every frame. Geometry cannot: moving things go outside the volume (`setup: gi => gi.volume.layers...`), and a rare change (a wall falls) calls `gi.needsUpdate = true`, a stall
|
|
134
|
-
- It bounces direct light only
|
|
135
|
-
-
|
|
136
|
-
- `occlusion` (0 to 1) darkens corners
|
|
137
|
-
-
|
|
138
|
-
- Does not work: metal
|
|
143
|
+
- `bounds` is the world box to voxelize. Keep it tight: the same voxels over a town are too coarse for a room. `describe().render.post` gives `voxelSize`; judge it against the smallest thing that should throw color.
|
|
144
|
+
- Lights can move every frame. Geometry cannot: moving things go outside the volume (`setup: gi => gi.volume.layers...`), and a rare change (a wall falls) calls `gi.needsUpdate = true`, a stall.
|
|
145
|
+
- It bounces direct light only; sky light stays yours (a low hemisphere or environment light). Judge: a colored wall tints what stands next to it and a sunlit floor lifts the ceiling, shadows not flat.
|
|
146
|
+
- A chain change at or before it (add, remove, on / off, a rebuilding setting, MSAA, a new scene buffer) voxelizes again, a stall: set the chain at a scene change. Effects after it (vignette, grain) switch freely.
|
|
147
|
+
- `occlusion` (0 to 1) darkens corners, direct light too, so it starts at 0.
|
|
148
|
+
- Where it is held (table below), give those players probes or a lightmap.
|
|
149
|
+
- Does not work: metal bounces as diffuse; moving and transparent things are not in the bounce; one volume cannot cover a big open world.
|
|
139
150
|
|
|
140
|
-
What runs where
|
|
151
|
+
What runs where (held: the game's `enabled` stays, the effect costs nothing, `describe().render.post` says why):
|
|
141
152
|
|
|
142
|
-
| Case | voxelGI | temporalAA, sunShafts, lightVolumes |
|
|
153
|
+
| Case | voxelGI | reflections (held on 'low'), temporalAA, sunShafts, lightVolumes, autoExposure |
|
|
143
154
|
|---|---|---|
|
|
144
155
|
| Real WebGPU | runs (held on `engine.tier` 'low') | run |
|
|
145
|
-
| WebGL2 backend (no WebGPU
|
|
146
|
-
| Fell back to `WebGLRenderer`
|
|
156
|
+
| WebGL2 backend (no WebGPU or `forceWebGL: true`) | held | run |
|
|
157
|
+
| Fell back to `WebGLRenderer` | held | held |
|
|
147
158
|
| Game chose WebGL (`--webgl`, `WebGLRenderer`) | throws by name | throw by name |
|
|
148
159
|
|
|
149
|
-
##
|
|
160
|
+
## Reflections
|
|
161
|
+
|
|
162
|
+
Screen-space (three's `SSRNode`): only what is on screen, elsewhere the environment map.
|
|
163
|
+
|
|
164
|
+
```js fragment
|
|
165
|
+
import { reflections } from '@threedog/post-effects/tsl';
|
|
166
|
+
const shine = engine.post.add(reflections({ maxDistance: 5 }));
|
|
167
|
+
shine.set({ intensity: 0.8 }); // in place
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- It follows metalness (0 and Lambert: none), not base color; roughness blurs it; a wet road wants a little metalness.
|
|
171
|
+
- Known limits: where a ray hits, the environment's specular stays and the reflection adds on top (indoors lower the mirror's `envMapIntensity`, under open sky `intensity`, until a dark thing on it reads dark). Added after fog, a far wet road shows through thick fog: lower `intensity` or `maxDistance`.
|
|
172
|
+
- Cost: a screen-filling mirror at 1080p on an integrated GPU: +2.9 ms at the default `resolutionScale: 0.5`, +12.5 at 1 (sharp). It grows with pixels (pixel ratio too), `maxDistance` and `quality`.
|
|
173
|
+
|
|
174
|
+
## Light you can see in the air: a beam of daylight through a hole or window, sun shafts, lamp cones
|
|
150
175
|
|
|
151
|
-
Pick by the light.
|
|
176
|
+
Pick by cost and by what must cut the light. All three need WebGPURenderer; a game on `WebGLRenderer` keeps the depth haze of recipe 59.
|
|
177
|
+
|
|
178
|
+
| Want | Use | Cost |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| One beam you place: a ceiling hole, window, stage light, lighthouse, torch | `lightShaft(engine, …)` from `threedog/tsl`, a mesh | one transparent draw; any tier |
|
|
181
|
+
| Sun through every gap, cut by what stands in it | `sunShafts` (post effect) | high |
|
|
182
|
+
| Spot cones and point glows with shadows, in a box of air | `lightVolumes` (post effect) | high |
|
|
183
|
+
|
|
184
|
+
```js fragment
|
|
185
|
+
import { lightShaft } from 'threedog/tsl';
|
|
186
|
+
const beam = lightShaft(engine, { radiusTop: 0.6, radiusBottom: 1.1, length: 5, color: 0xfff0d0, intensity: 0.5, dust: 0.6 });
|
|
187
|
+
beam.position.set(2, 5, -3); // the opening (top) at the hole; it points down its -Y axis
|
|
188
|
+
engine.scene.add(beam);
|
|
189
|
+
beam.shaft.intensity.value = 0.3; // numbers live (`beam.shaft.*.value`); size and segments are fixed, make a new one
|
|
190
|
+
// lightShaft(engine, { light: spot }) follows a SpotLight (position, aim, cone width, colour) or a DirectionalLight (aim, colour)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- An additive cone, not a volume (fades: `softness`, `fadeAtGeometry`, `fadeNear`; api/tools.md). **What stands in it does not cut it** (that is `sunShafts`).
|
|
194
|
+
- Start `intensity` low (0.2 to 0.5 over a dark cave) and raise it until the beam reads; with `bloom` it wants less. `dust` is skipped on `engine.tier` 'low'; floating motes are particles (recipe 64).
|
|
152
195
|
|
|
153
196
|
```js fragment
|
|
154
197
|
import { sunShafts, lightVolumes } from '@threedog/post-effects/tsl';
|
|
155
|
-
engine.post.add(sunShafts({ light: engine.lights.sun }));
|
|
156
|
-
engine.post.add(lightVolumes({ bounds: new THREE.Box3(min, max) }));
|
|
198
|
+
engine.post.add(sunShafts({ light: engine.lights.sun })); // sun through gaps
|
|
199
|
+
engine.post.add(lightVolumes({ bounds: new THREE.Box3(min, max) })); // spot cones, point glows
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- `sunShafts` (three's `GodraysNode`) marches the sun's shadow map, so the sun and whatever makes the gaps must cast shadows. Made for air mostly in shadow (a room with a window, a forest); open daylight reads as haze, so lower `density`. Raise it until the beam reads against the dark, before the far wall washes out.
|
|
203
|
+
- `lightVolumes` (three's `VolumeNodeMaterial`) fills a box of air and lights it from point and spot lights, shadows included. **The sun does nothing here**, three skips lights at infinity. It is dithered, so run `temporalAA` after it. `scattering: (tsl, { positionRay, density }) => ...` gives density per point for smoke or ground fog; times `uWeatherFog` (recipe 62) to follow the weather.
|
|
204
|
+
- Does not work: shafts from more than one light at once, cones through transparent glass. For crisp beams in open air, aim a spot light along the sun under `lightVolumes`.
|
|
205
|
+
|
|
206
|
+
## Soft shadows, area lights, translucency, lens flare
|
|
207
|
+
|
|
208
|
+
```js fragment
|
|
209
|
+
import { pcss } from 'threedog/tsl';
|
|
210
|
+
const sun = new THREE.DirectionalLight(0xffffff, 3);
|
|
211
|
+
sun.shadow.filterNode = pcss({ lightSize: 0.04, samples: 16 }); // before the first frame, as any filterNode
|
|
157
212
|
```
|
|
158
213
|
|
|
159
|
-
- `
|
|
160
|
-
- `
|
|
161
|
-
-
|
|
214
|
+
- `pcss` (WebGPU, DirectionalLight, cascades included): the edge widens with the caster-receiver distance, by `lightSize` per world unit (the sun about 0.01) up to `maxDistance`. About ten times PCF's lookups at `samples: 16`. The caster distance is found at four depths, jittered per pixel: a sloped caster's edge widens smoothly, with a fine static grain in wide edges.
|
|
215
|
+
- `RectAreaLight`: just add it, the engine loads three's tables for it on both renderers. No shadow; lights only MeshStandard / MeshPhysical.
|
|
216
|
+
- Light through skin, leaves, wax: three's `MeshSSSNodeMaterial` (`thicknessColorNode` ...), cheap, per light; three's `SSSNode` is screen-space shadows, not this. Glass, jade, liquid: `transmission` + `thickness` + `attenuationColor` on MeshPhysicalMaterial.
|
|
217
|
+
- Lens flare: three's `LensflareNode` (`three/addons/tsl/display/`) fed by `ctx.display.bloom` in a post effect of your own (recipe 52), or `LensflareMesh` on a light.
|
|
162
218
|
|
|
163
219
|
## Occlusion culling
|
|
164
220
|
|
|
165
|
-
`engine.occlusion.enabled = true` skips the engine's big things while something hides them: hlod cells and `engine.batching` groups. Works on both renderers. Ordinary objects are not watched.
|
|
221
|
+
`engine.occlusion.enabled = true` skips the engine's big things while something hides them: hlod cells and `engine.batching` groups. Works on both renderers. Ordinary objects are not watched. Only for heavy things behind others (a walled town, a building of rooms); with many small things it is a loss (each box costs CPU, more on WebGPU). Measure with `describe().render.occlusion` (`hidden`, `trianglesSkipped`) and frame time, on and off.
|
|
166
222
|
|
|
167
|
-
-
|
|
168
|
-
- Culling hides things from `engine.camera` alone. Every other camera (a minimap, a mirror
|
|
169
|
-
- **Step mode hides nothing
|
|
170
|
-
- Answers come a few frames late
|
|
223
|
+
- Not to be confused with `cameraOcclusion` of `collision()` (recipe 21: walls between camera and player) or `voxelGI`'s `occlusion` (darker corners).
|
|
224
|
+
- Culling hides things from `engine.camera` alone. Every other camera (a minimap, a mirror), shadows, `engine.rays`, a `THREE.Raycaster` of your own and `voxelGI`'s volume see them as ever; `visible` and `layers` stay yours.
|
|
225
|
+
- **Step mode hides nothing**: answers arrive over drawn frames, so under `threedog step` / `engine.step()` `hidden` stays 0 and `inspect perf` counts every draw. Judge occlusion with `threedog resume` and real time.
|
|
226
|
+
- Answers come a few frames late: camera moves and cuts are covered, a big occluder that moves fast (a falling wall) can show a gap for a few frames.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Making a new picture from a reference picture
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
3
|
+
> **Covers:** matching a reference picture: the loop, the picture check after every shot, a fixed scene to judge by.
|
|
4
|
+
> **Use when:** the look should come close to a given image.
|
|
5
|
+
> **Shortest:** `threedog picture palette ref.png`, then `threedog shot`.
|
|
6
|
+
> **Sections:** The loop every round · What picture code can · Steps · Picture check after every · Picture questions · Guard rails · A fixed scene to
|
|
5
7
|
|
|
6
8
|
```sh
|
|
7
9
|
threedog picture palette art/reference/ref.png --n 8 --average # the colors: they go in picture/palette.js
|
|
@@ -12,9 +14,8 @@ threedog picture compare art/reference/ref.png .threedog/shots/now.png --out sid
|
|
|
12
14
|
No reference picture? Skip the measuring (step 2, `picture palette`, `picture compare` against a reference); judge each shot against DESIGN.md and
|
|
13
15
|
its "Loved / Not for this game" list, and use the rest: the loop, the picture check after every shot and the picture questions.
|
|
14
16
|
|
|
15
|
-
For
|
|
16
|
-
|
|
17
|
-
yours. How the `picture/` folder is laid out and which signals it reads are in `62-picture-code.md`; this page is the order of work.
|
|
17
|
+
For turning one given picture ("make it look like this") into the game's picture. `threedog picture palette` and `picture compare` measure; the game's `picture/` folder
|
|
18
|
+
holds the result in plain three.js (recipe 62). They never say which colors are right: the taste is yours. This page is the order of work.
|
|
18
19
|
|
|
19
20
|
## The loop (every round, in this order)
|
|
20
21
|
Looping "edit, screenshot, read the image" costs the most tokens and fixes the least. Numbers come first, pictures last.
|
|
@@ -27,14 +28,13 @@ Looping "edit, screenshot, read the image" costs the most tokens and fixes the l
|
|
|
27
28
|
pixel diff and the picture differences. Through MCP the `snap` tool is 480 px wide by default; `picture_compare` gives the numbers.
|
|
28
29
|
4. **Read the numbers first, then at most one image per round.** Name the biggest remaining difference and fix only that. With no reference, read the shot's hints (below). Then look at the image as a player would and judge it
|
|
29
30
|
against the picture DESIGN.md wants and its "Loved / Not for this game" list (never against a technique example): what would a player read as a
|
|
30
|
-
mistake
|
|
31
|
-
glare, areas too dark or busy to read, placeholder-looking shapes; these are prompts, not a list to tick. Fix what you find, or note it in
|
|
31
|
+
mistake (objects floating or cutting into each other, odd flat discs, glare, areas too dark or busy to read, placeholder shapes)? Fix what you find, or note it in
|
|
32
32
|
STATUS.md with why it stays. Before calling a picture done, go through the "Picture questions" below that matter for this game.
|
|
33
33
|
5. **Wrong in a way the numbers do not explain?** Diagnose before guessing: `engine.debug.view('albedo' | 'lighting' | 'shadow' | 'normals')` shows which
|
|
34
34
|
layer is off, and every value has one writer, a line in your `picture/` code. Nothing drawn: `threedog scene --hidden` (reasons per mesh).
|
|
35
35
|
Washed-out or too-dark textures, odd normals: `threedog inspect materials` (wrong color spaces first, sizes, who made each material).
|
|
36
36
|
6. **If the biggest difference stops shrinking over a few rounds, change approach** (in this order) and tell the user which and why:
|
|
37
|
-
painted textures (`map`, `normalMap`) -> `
|
|
37
|
+
painted textures (`map`, `normalMap`) -> node inputs (`colorNode` ...) on your own node material (WebGPU, recipe 56; on WebGL `onBeforeCompile`) -> a whole shader of your own (TSL, or `ShaderMaterial` on WebGL).
|
|
38
38
|
Never call it "close" to stop tuning.
|
|
39
39
|
7. **Every few rounds show the user the shot and the numbers.**
|
|
40
40
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
# Ground color and plants
|
|
2
2
|
|
|
3
|
+
> **Covers:** ground colors by height and slope, plants and their wind.
|
|
4
|
+
> **Use when:** coloring terrain or covering it with plants.
|
|
5
|
+
> **Shortest:** `terrain({ colors: { grass: 0x6a8a3a } })`.
|
|
6
|
+
> **Sections:** Ground color terrain { · Plants and wind
|
|
7
|
+
|
|
3
8
|
```js
|
|
4
9
|
import { terrainPreset } from '@threedog/terrain-noise';
|
|
5
10
|
engine.use(terrain({ ...terrainPreset(), colors: { grass: 0x6a8a3a, rock: 0x777066 }, biomeColors: { meadow: ['grass'], cliff: ['rock'] } }));
|
|
6
|
-
engine.terrain.material.flatShading = true;
|
|
7
|
-
engine.terrain.recolor({ colors: { grass: 0xa8a050, rock: 0x777066 } });
|
|
8
|
-
engine.terrain.material = applyEffects(new THREE.MeshToonMaterial({ vertexColors: true }), { patches: engine.terrain.patches });
|
|
11
|
+
engine.terrain.material.flatShading = true; // the ground's picture is a plain three.js material
|
|
12
|
+
engine.terrain.recolor({ colors: { grass: 0xa8a050, rock: 0x777066 } }); // what the workers baked in, changed at run time
|
|
13
|
+
engine.terrain.material = applyEffects(new THREE.MeshToonMaterial({ vertexColors: true }), { patches: engine.terrain.patches }); // your own, effects kept
|
|
9
14
|
engine.vegetation.material = applyEffects(new THREE.MeshToonMaterial({ vertexColors: true }), { patches: engine.vegetation.patches });
|
|
10
15
|
```
|
|
11
16
|
|
|
@@ -19,9 +24,9 @@ color is neutral gray. The `variation` defaults are shown (plain data, so it tra
|
|
|
19
24
|
```js fragment
|
|
20
25
|
terrain({ colors: { ... }, biomeColors: { ... },
|
|
21
26
|
variation: {
|
|
22
|
-
blend: { size: 33, strength: 1 },
|
|
23
|
-
jitter: { size: 0.33, min: 0.92, range: 0.12 },
|
|
24
|
-
patches: { size: 90, strength: 0.15, levels: 0, tint: 0xb59a5a },
|
|
27
|
+
blend: { size: 33, strength: 1 }, // wavelength in m of the two-color noise; strength > 1 = harder contrast, < 1 = flatter
|
|
28
|
+
jitter: { size: 0.33, min: 0.92, range: 0.12 }, // grain cell in m; darkest multiplier; how much brighter it can get (0 range = no grain)
|
|
29
|
+
patches: { size: 90, strength: 0.15, levels: 0, tint: 0xb59a5a }, // optional (example values): a second, large layer of color blocks
|
|
25
30
|
} })
|
|
26
31
|
```
|
|
27
32
|
`patches` is off unless given. It is a noise much larger than `blend`; `levels: 4` snaps it to 4 flat steps (hard-edged color blocks instead of a
|
|
@@ -31,8 +36,8 @@ interpolate across a chunk cell (4 m at the default resolution), so blocks small
|
|
|
31
36
|
|
|
32
37
|
### Changing it at run time: `engine.terrain.recolor`
|
|
33
38
|
```js fragment
|
|
34
|
-
engine.terrain.recolor({ colors, biomeColors, steep, variation, shading, normals });
|
|
35
|
-
engine.terrain.recolor({ detail: { noise: 'paper', strength: 0.2 } });
|
|
39
|
+
engine.terrain.recolor({ colors, biomeColors, steep, variation, shading, normals }); // every chunk is rebuilt; edits stay, collision does not change
|
|
40
|
+
engine.terrain.recolor({ detail: { noise: 'paper', strength: 0.2 } }); // only the material: no chunk is rebuilt
|
|
36
41
|
```
|
|
37
42
|
Each value is given whole, not merged, and `null` takes it out (`shading: null` goes back to what `terrain({...})` was given). Keys left out stay.
|
|
38
43
|
`recolor` throws under a picture that replaced `'terrain-draw'`, which draws the ground its own way.
|
|
@@ -48,7 +53,7 @@ Chunk geometry has `position`, `normal`, `color` and `uv = world xz / chunk size
|
|
|
48
53
|
UVs (steep sides stretch a top-down map), project from the world position in a patch instead (`needs.patches: ['world']` gives `vThreedogWorld`):
|
|
49
54
|
```js fragment
|
|
50
55
|
engine.terrain.material = applyEffects(new THREE.MeshLambertMaterial({ vertexColors: true }), { clouds: false, patches: [{
|
|
51
|
-
name: 'triplanar', needs: { patches: ['world'] }, uniforms: { uTex: { value: groundTexture }, uTexScale: { value: 0.1 } },
|
|
56
|
+
name: 'triplanar', needs: { patches: ['world'] }, uniforms: { uTex: { value: groundTexture }, uTexScale: { value: 0.1 } }, // groundTexture: repeat wrapping
|
|
52
57
|
glsl: { fragment: { pars: 'uniform sampler2D uTex; uniform float uTexScale;',
|
|
53
58
|
color_fragment: `vec3 n = abs(normalize(cross(dFdx(vThreedogWorld), dFdy(vThreedogWorld)))); n /= n.x + n.y + n.z;
|
|
54
59
|
diffuseColor.rgb *= texture2D(uTex, vThreedogWorld.zy * uTexScale).rgb * n.x + texture2D(uTex, vThreedogWorld.xz * uTexScale).rgb * n.y
|
|
@@ -64,15 +69,14 @@ The lighter alternative, with no material of your own: `terrain({ detail })`, or
|
|
|
64
69
|
`vegetation.define` works at any time after `engine.use`, before or after `content.load` and `engine.start`. A species named by a model (`model: 'oak'`) appears when its promise settles, so `vegetation.list()` right after
|
|
65
70
|
that call does not show it yet. To keep plants off a road or a yard, give the species a `densityMap: (x, z) => 0..1`, or a ground type of its own that the species' `biomes` leave out. Per-species options are in `../api/vegetation.md`; `castShadow` defaults to not `nearOnly`.
|
|
66
71
|
```js fragment
|
|
67
|
-
engine.vegetation.define('oak', { model: await engine.assets.model('oak'), wind: 0.02 });
|
|
72
|
+
engine.vegetation.define('oak', { model: await engine.assets.model('oak'), wind: 0.02 }); // per species: its own material, wind, fade
|
|
68
73
|
engine.vegetation.define('fern', { geometry, material: new THREE.MeshToonMaterial({ vertexColors: true }), wind: 0.08 });
|
|
69
|
-
engine.vegetation.material = applyEffects(new THREE.MeshToonMaterial({ vertexColors: true }), { patches: engine.vegetation.patches });
|
|
70
|
-
engine.uniforms.uWindAmp.value = 0.5; engine.uniforms.uWindFreq.value = 2;
|
|
74
|
+
engine.vegetation.material = applyEffects(new THREE.MeshToonMaterial({ vertexColors: true }), { patches: engine.vegetation.patches }); // the shared default
|
|
75
|
+
engine.uniforms.uWindAmp.value = 0.5; engine.uniforms.uWindFreq.value = 2; // how hard and how fast: plain signals, live (uWindAmp 0 = plants stand still)
|
|
71
76
|
```
|
|
72
|
-
`engine.vegetation.material`
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
shadows, season tint and the fade to it unless `effects: false`. Each species' live material is `engine.vegetationDraw.kind(name).material`.
|
|
77
|
+
`engine.vegetation.material` (species with no material or model of their own) is drawn as given, planted ones too: hand it `engine.vegetation.patches`
|
|
78
|
+
to keep the season tint, sway and `color()` code; `null` restores the default. A species' own amplitude and near fade need `define(name, { material })`,
|
|
79
|
+
which gets wind, cloud shadows, season tint and the fade unless `effects: false`; its live material is `engine.vegetationDraw.kind(name).material`.
|
|
76
80
|
|
|
77
81
|
The placement, rings and instancing are mechanism and stay (the whole picture is replaceable: recipe 28 section 6). The picture has three entries:
|
|
78
82
|
- **Sway shape**: built in, two sines with a phase from each plant's origin, weighted by height, leaning with wind strength. `engine.vegetation.sway(glsl)` replaces it (below).
|
|
@@ -80,7 +84,7 @@ The placement, rings and instancing are mechanism and stay (the whole picture is
|
|
|
80
84
|
- **Season tint**: `engine.sky.seasonTints = { mode: 'multiply' | 'mix', strength, autumn: { foliage: 0xffb070, ground: 0xc8a060 } }`, plain data read every frame, blended to the next season over the last fifth of a season. `'multiply'` (default) multiplies the surface; `'mix'` moves it `strength` (default 0.5) of the way to the color, so orange on green leaves stays orange instead of turning muddy.
|
|
81
85
|
|
|
82
86
|
```js
|
|
83
|
-
engine.vegetation.sway({ uniforms: { uSteps: 3 },
|
|
87
|
+
engine.vegetation.sway({ uniforms: { uSteps: 3 }, // stepped sway: plants snap between 3 poses instead of a smooth sine
|
|
84
88
|
glsl: `void threedogWind(inout vec3 transformed, vec3 ip, vec3 position){
|
|
85
89
|
float s = floor(sin(uTime * uWindFreq + ip.x * 0.3 + ip.z * 0.2) * uSteps) / uSteps;
|
|
86
90
|
transformed.x += s * max(position.y, 0.0) * THREEDOG_WIND_AMP * uWind;
|
|
@@ -92,11 +96,13 @@ engine.vegetation.sway({ uniforms: { uSteps: 3 }, // stepped sway: plants sna
|
|
|
92
96
|
`sway(null)` gives the built-in sway back. A shared material the game set keeps what it was built with: apply the new `engine.vegetation.patches` to it. The same object works in code:
|
|
93
97
|
`applyEffects(mat, { wind: { amplitude: 0.03, glsl, uniforms } })`.
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
`sway()` is the world's default shape; one species' own `define(name, { wind: { amplitude, glsl, tsl, uniforms } })` wins over it, and `sway()` / `sway(null)` leave that one as it is.
|
|
100
|
+
|
|
101
|
+
Grass costs vertex count and fill, not sway: lower `rule.perChunk` or `maxRing`, or use `nearOnly`.
|
|
102
|
+
Grass has no blade-shape setting: give `vegetation.define` your own `geometry` or `model`.
|
|
97
103
|
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
### Far trees as cards: `impostor`
|
|
105
|
+
`define('pine', { model, impostor: true })` (or `{ views, size }`, default 8 x 128 px), instead of `lodGeometry`: beyond `lodRing` each plant is a camera-facing card baked from its own model and materials, lit through baked normals, one draw per species. No shadow or sway there. WebGPU only (WebGL draws the mesh and warns).
|
|
100
106
|
|
|
101
107
|
### Near-only plants fade out by distance
|
|
102
108
|
Any `nearOnly` species (grass, flowers, pebbles, twigs, snow tufts, debris ...) is placed per chunk ring
|
package/docs/recipes/40-scene.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Scene: what is in the world, where, who manages it, and what a save keeps (engine.thing)
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
> **Covers:** the scene: content and code as two doors, ids, what a save keeps, explain.
|
|
4
|
+
> **Use when:** deciding where an object is written and what persists.
|
|
5
|
+
> **Shortest:** `engine.add(mesh, { id: 'mill' })`.
|
|
6
|
+
> **Sections:** 1 Two doors into · 2 What goes in · 3 Which state a · 4 Give it an · 4b Change it thing.set · 4c Saves the scene · 5 Moving from three.js · 6 Verify and dev · 7 Why is this · 8 When to write · 9 One id, everything
|
|
6
7
|
|
|
7
8
|
The engine's three outward concepts are **Scene** (what stands in the world, where it is, how you interact with it), **Assets** (models, textures,
|
|
8
9
|
sounds, fonts: `05-props-bake.md` §3b) and **Picture** (how it looks: `09-materials-lights-models.md`). Content packs belong to Scene: they are the data form of it.
|
|
@@ -21,17 +22,7 @@ A scene object comes in either of two ways, and both end up in the same scene:
|
|
|
21
22
|
- **A template.** Define it in `content/templates.js`, place it in `content/props.js` with an `id`, or create it during play with
|
|
22
23
|
`engine.content.spawn(name, at)`. This is the right way for anything that must be saved, be editable without code, or exist in many copies.
|
|
23
24
|
|
|
24
|
-
The same windmill, both ways:
|
|
25
|
-
|
|
26
|
-
```js fragment
|
|
27
|
-
// A. plain three.js: your code builds it on every start
|
|
28
|
-
const mill = buildWindmill(); // THREE.Group
|
|
29
|
-
mill.position.set(20, 0, -10);
|
|
30
|
-
engine.snapToGround(mill);
|
|
31
|
-
engine.add(mill, { id: 'mill' });
|
|
32
|
-
engine.collision?.addCircle(mill, { radius: 1.3 }); // also pulls the follow camera in; { occluder: false } only stops walkers (forest trunks)
|
|
33
|
-
engine.onFrame(dt => { mill.userData.blades.rotation.z += dt * 1.5; });
|
|
34
|
-
```
|
|
25
|
+
The same windmill, both ways. A, plain three.js built on every start: `THREE.md §"Example: a spinning windmill"` (with `engine.add(mill, { id: 'mill' })` for a stable id). B:
|
|
35
26
|
```js
|
|
36
27
|
// B. template: the definition is data; the model is a name in the asset manifest
|
|
37
28
|
// content/templates.js
|
|
@@ -75,15 +66,15 @@ inside an op with `engine.content.spawn(name, at)`: a record is saved whole.
|
|
|
75
66
|
|
|
76
67
|
## 4. Give it an id
|
|
77
68
|
```js
|
|
78
|
-
const windmill = new THREE.Group();
|
|
79
|
-
engine.add(windmill, { id: 'windmill' });
|
|
80
|
-
engine.add(new THREE.Group());
|
|
69
|
+
const windmill = new THREE.Group(); // any Object3D
|
|
70
|
+
engine.add(windmill, { id: 'windmill' }); // at setup: thing.set / thing.remove changes to it are saved
|
|
71
|
+
engine.add(new THREE.Group()); // effects need no id: obj#7, this session only
|
|
81
72
|
engine.thing('windmill');
|
|
82
73
|
// { id: 'windmill', kind: 'Group', owner: 'game', at: 'main.js:50', phase: 'setup', saved: 'code',
|
|
83
74
|
// keeps: ['position, rotation, scale, visibility and removal made with thing.set / thing.remove (scene save part)'],
|
|
84
75
|
// loses: ['geometry and material changes', 'children added later', 'userData', ...], edit: 'added by code at main.js:50 (id ...)' }
|
|
85
|
-
engine.thing('windmill').object;
|
|
86
|
-
engine.pick(0, 0)?.thing;
|
|
76
|
+
engine.thing('windmill').object; // the live Object3D (not enumerable, so the result stays JSON-able)
|
|
77
|
+
engine.pick(0, 0)?.thing; // any child resolves to its registered root
|
|
87
78
|
```
|
|
88
79
|
- The id is `{ id }`, else a session id `obj#n` (session tier: never saved). `obj.name` is not an id (GLB roots are all called `Scene`): it only helps `engine.thing(name)` find the object. An id is a non-empty string without `#`,
|
|
89
80
|
unique across `engine.add` objects and world records: a clash throws (`thing-id`) from either side (`engine.add` or `world.add`) and says which one holds it.
|
|
@@ -95,10 +86,10 @@ engine.pick(0, 0)?.thing; // any child resolves to its
|
|
|
95
86
|
|
|
96
87
|
## 4b. Change it: thing.set / thing.remove (ops, undoable)
|
|
97
88
|
```js
|
|
98
|
-
const args = { id: 'windmill', position: [5, 0, 2], rotation: 1.2 };
|
|
89
|
+
const args = { id: 'windmill', position: [5, 0, 2], rotation: 1.2 }; // rotation: a number is yaw, or [x, y, z]; scale: a number or [x, y, z]
|
|
99
90
|
const r = engine.ops.run('thing.set', args);
|
|
100
|
-
engine.ops.undo('thing.set', args, r.value);
|
|
101
|
-
const gone = engine.ops.run('thing.remove', { id: 'windmill' });
|
|
91
|
+
engine.ops.undo('thing.set', args, r.value); // back where it was
|
|
92
|
+
const gone = engine.ops.run('thing.remove', { id: 'windmill' }); // detached and kept: undo puts it back
|
|
102
93
|
engine.ops.undo('thing.remove', { id: 'windmill' }, gone.value);
|
|
103
94
|
```
|
|
104
95
|
- A world record id turns into `world.set` / `world.move` (`rot` / `scale` are template instance fields) and `world.remove`; the model follows the
|
|
@@ -150,12 +141,12 @@ Plain three.js is always allowed (`engine.scene`, `engine.renderer`, `engine.cam
|
|
|
150
141
|
| your own `EffectComposer` / render call to the canvas | the engine yields the frame (`[own-frame]`), so `engine.post` effects, adaptive resolution, photo mode, `describe().render.post`; keep them with `engine.post.add(pass)` instead |
|
|
151
142
|
| `renderer.toneMappingExposure = x`, `scene.fog = ...` | the debug layer's restore (`engine.debug.override` gives the old value back) |
|
|
152
143
|
|
|
153
|
-
The engine adds nothing to your materials. The cloud shadow is a signal (`engine.uniforms.uCloudShadow`, `uCloudShadowScale`, `uCloudShadowSpeed`) and a function: `applyEffects(mat)` gives a lit three.js material the engine's term
|
|
144
|
+
The engine adds nothing to your materials. The cloud shadow is a signal (`engine.uniforms.uCloudShadow`, `uCloudShadowScale`, `uCloudShadowSpeed`) and a function: `applyEffects(mat)` gives a lit three.js material the engine's term (darkens under the drifting clouds like the engine's ground, on WebGL and WebGPU); your own shader calls `threedogCloudShadow(worldPos)` (recipe 43). Clouds dim the sun only (directional lights, every cascade): a `PointLight` lamp or torch is never shaded. At 0 a uniform branch skips the cloud noise; one program per material type stays. Snow and season cover work the same way: `applyEffects(mat, { season: 'ground' })` (`'foliage'` for leaves).
|
|
154
145
|
Keep the integrations by going through the engine: `applyEffects(mat, { wind, season, detail, lighting, patches })` on your material, `engine.post.add(pass | { name, fuse: { glsl }, slot })` for a screen effect.
|
|
155
146
|
|
|
156
147
|
## 9. One id, everything: explain and the three kinds of change
|
|
157
148
|
```js
|
|
158
|
-
engine.explain({ thing: 'chest-home' }).detail;
|
|
149
|
+
engine.explain({ thing: 'chest-home' }).detail; // CLI: threedog explain thing chest-home --full (MCP: explain); the same JSON
|
|
159
150
|
// { id, kind, owner, definition: { at: 'content/props.js:14', template, templateAt, level?, node?, spawned? }, model, materials: [{ role, name, from, keys }],
|
|
160
151
|
// state, rules: { blocksMovement, pickable, interact, height }, ops: [{ op, desc, args }], saved: { tier, keeps, loses }, change: {…}, overrides? }
|
|
161
152
|
```
|
|
@@ -170,11 +161,11 @@ engine.explain({ thing: 'chest-home' }).detail; // CLI: threedog explain thin
|
|
|
170
161
|
| Diagnostic override ("show me without it") | `engine.debug.override(owner, id, { visible: false, material: 'flat' \| 'wire', apply })` | until `handle.remove()` / `engine.debug.clear(owner)`; never saved |
|
|
171
162
|
|
|
172
163
|
```js
|
|
173
|
-
const h = engine.debug.override('ai-session', 'windmill', { material: 'flat' });
|
|
164
|
+
const h = engine.debug.override('ai-session', 'windmill', { material: 'flat' }); // unlit base colour: is the colour wrong, or the light?
|
|
174
165
|
engine.debug.override('ai-session', engine.player.root, { visible: false });
|
|
175
|
-
engine.debug.override('ai-session', engine.renderer, 'toneMappingExposure', 3);
|
|
176
|
-
engine.describe().scene.overrides;
|
|
177
|
-
h.remove(); engine.debug.clear('ai-session');
|
|
166
|
+
engine.debug.override('ai-session', engine.renderer, 'toneMappingExposure', 3); // any three.js value: (object, key, value); held above picture code until remove()
|
|
167
|
+
engine.describe().scene.overrides; // [{ owner, target, material: 'flat' }, …]: the screen differs from the real state while this is non-empty
|
|
168
|
+
h.remove(); engine.debug.clear('ai-session'); // clear removes every override of that owner (and its debug.view) and nothing else
|
|
178
169
|
```
|
|
179
170
|
`apply(obj)` may return its undo function: any other picture (a view mode) uses the same owner mechanism. Overrides do not touch game state, ops or saves.
|
|
180
171
|
|