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
|
@@ -2,24 +2,17 @@
|
|
|
2
2
|
// Technique example: interior light (page /interior-light.html, README.md next to this file). A neutral gray room (8 x 6 m, 3 m high) with a
|
|
3
3
|
// window in the west wall and a door in the south wall. One skill: lighting a room from outside (sun through the opening, sky light through the
|
|
4
4
|
// window), filling the shadowed side with bounce, the exposure change between outside and inside, and lamps at night.
|
|
5
|
-
// (time and view are the engine's own URL scenario keys, see core/UrlState.js: page params use other names)
|
|
5
|
+
// (time and view are the engine's own URL scenario keys, see core/inspect/UrlState.js: page params use other names)
|
|
6
6
|
// URL: ?night=1 ?cam=inside|doorway|outside ?fill=probes|light|none ?area=0 (no window area light) ?leak=1 (keep outdoor ambient indoors)
|
|
7
|
-
// Test page for tests/specs/techniques-light.mjs: window.interiorTest = { THREE, ready, points,
|
|
7
|
+
// Test page for tests/specs/techniques-light.mjs: window.interiorTest = { THREE, ready, points, picture }. Shapes only here; the whole picture is picture/.
|
|
8
8
|
import { createEngine, sky, fixedCamera, THREE } from 'threedog';
|
|
9
|
-
import {
|
|
9
|
+
import { createPicture } from './picture/index.js';
|
|
10
10
|
|
|
11
11
|
// ---- parameters: change these ----------------------------------------------------------------------------------------------------------
|
|
12
12
|
const ROOM = { min: [-4, 0, -3], max: [4, 3, 3], wall: 0.2 };
|
|
13
13
|
const WINDOW = { z: [-1.1, 1.1], y: [0.8, 2.4] }; // opening in the west wall (x = -4)
|
|
14
14
|
const DOOR = { x: [1.4, 2.5], y: [0, 2.2] }; // opening in the south wall (z = +3)
|
|
15
|
-
const
|
|
16
|
-
// outdoor ambient (hemisphere + room environment) is not blocked by walls: indoors it is turned down and the fill comes from bounce instead
|
|
17
|
-
const AMBIENT = { outside: { hemi: 1.0, env: 0.3 }, inside: { hemi: 0.06, env: 0.04 } };
|
|
18
|
-
const WINDOW_LIGHT = { color: '#cfe0ff', intensity: 2.2 }; // RectAreaLight: the sky seen through the window (nits-like units, Standard / Physical only)
|
|
19
|
-
const BOUNCE_LIGHT = { color: '#ffe2c0', intensity: 1.2, distance: 7 }; // ?fill=light: one unshadowed point light standing in for the sun patch's bounce
|
|
20
|
-
// exposure per zone, eased over EASE seconds when the camera crosses the doorway (an eye adapting)
|
|
21
|
-
const EXPOSURE = { day: { outside: 1, inside: 1.9 }, night: { outside: 1.6, inside: 1 }, ease: 1.2 };
|
|
22
|
-
const LAMPS = [{ at: [2.6, 1.55, -2.2], intensity: 5, color: '#ffc58a', shadow: true }, { at: [-2.8, 1.0, 2.2], intensity: 2.5, color: '#ffb874', shadow: false }];
|
|
15
|
+
const LAMPS = /** @type {{ at: number[], kind: 'main' | 'side' }[]} */ ([{ at: [2.6, 1.55, -2.2], kind: 'main' }, { at: [-2.8, 1.0, 2.2], kind: 'side' }]);
|
|
23
16
|
const VIEWS = {
|
|
24
17
|
inside: { position: [3.4, 1.65, 2.4], lookAt: [-3, 0.8, -0.6] },
|
|
25
18
|
doorway: { position: [1.95, 1.65, 5.2], lookAt: [0.6, 1.1, -3] },
|
|
@@ -31,40 +24,32 @@ const url = new URLSearchParams(location.search);
|
|
|
31
24
|
const night = url.get('night') === '1', fill = url.get('fill') ?? 'probes', view = /** @type {keyof typeof VIEWS} */ (url.get('cam') ?? 'inside');
|
|
32
25
|
if (!VIEWS[view]) throw new Error(`?cam=${view}: use one of ${Object.keys(VIEWS).join(', ')}`);
|
|
33
26
|
|
|
34
|
-
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), ui: { loading: false }, saveKey: 'threedog-interior' });
|
|
27
|
+
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, ui: { loading: false }, saveKey: 'threedog-interior' });
|
|
35
28
|
engine.use(sky({ time: night ? '22:30' : '15:00' }));
|
|
36
29
|
engine.use(fixedCamera({ shots: VIEWS, start: view }));
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
sun.position.copy(dir).multiplyScalar(160);
|
|
46
|
-
engine.look.lights.set({ sun: { intensity: SUN.intensity, color: SUN.color } }, { owner: 'technique' });
|
|
47
|
-
}
|
|
48
|
-
// thin walls need a small normal bias, or light leaks along the wall's inner edge; the bias is ~1 cm (shadow depth 0-1 x the camera's depth range)
|
|
49
|
-
engine.look.shadow.set({ follow: false, extent: 9, normalBias: 0.01, bias: -0.01 / (sun.shadow.camera.far - sun.shadow.camera.near), type: 'pcf', radius: 2 }, { owner: 'technique' });
|
|
31
|
+
const [x0, , z0] = ROOM.min, [x1, h, z1] = ROOM.max, t = ROOM.wall, windowY = (WINDOW.y[0] + WINDOW.y[1]) / 2;
|
|
32
|
+
// the camera inside this box gets indoor ambient and indoor exposure, eased
|
|
33
|
+
const inside = (/** @type {THREE.Vector3} */ p) => p.x > x0 && p.x < x1 && p.z > z0 && p.z < z1 + 0.5 && p.y < h;
|
|
34
|
+
const picture = createPicture(engine, { night, fill, isInside: inside, leak: url.get('leak') === '1',
|
|
35
|
+
// the window as a light: a RectAreaLight in the opening, facing in
|
|
36
|
+
windowOpening: url.get('area') === '0' ? null : { position: [x0 - 0.02, windowY, 0], lookAt: [0, windowY, 0], width: WINDOW.z[1] - WINDOW.z[0], height: WINDOW.y[1] - WINDOW.y[0] } });
|
|
37
|
+
const { mat } = picture;
|
|
50
38
|
|
|
51
|
-
// ---- the neutral gray room
|
|
52
|
-
const
|
|
53
|
-
const wallMat = mat(0xb5b5b5), floorMat = mat(0x8f8f8f);
|
|
54
|
-
const box = (/** @type {number[]} */ min, /** @type {number[]} */ max, m = wallMat) => {
|
|
39
|
+
// ---- the neutral gray room ----
|
|
40
|
+
const box = (/** @type {number[]} */ min, /** @type {number[]} */ max, m = mat.wall) => {
|
|
55
41
|
const mesh = new THREE.Mesh(new THREE.BoxGeometry(max[0] - min[0], max[1] - min[1], max[2] - min[2]), m);
|
|
56
42
|
mesh.position.set((min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2);
|
|
57
43
|
mesh.castShadow = mesh.receiveShadow = true;
|
|
58
44
|
engine.scene.add(mesh);
|
|
59
45
|
return mesh;
|
|
60
46
|
};
|
|
61
|
-
const
|
|
62
|
-
const ground = new THREE.Mesh(new THREE.PlaneGeometry(120, 120), mat(0x8a8a8a, 0.95));
|
|
47
|
+
const ground = new THREE.Mesh(new THREE.PlaneGeometry(120, 120), mat.ground);
|
|
63
48
|
ground.rotation.x = -Math.PI / 2;
|
|
64
49
|
ground.position.y = -0.01;
|
|
65
50
|
ground.receiveShadow = true;
|
|
66
51
|
engine.scene.add(ground);
|
|
67
|
-
box([x0, -0.01, z0], [x1, 0.02, z1],
|
|
52
|
+
box([x0, -0.01, z0], [x1, 0.02, z1], mat.floor); // the floor
|
|
68
53
|
box([x0 - t, h, z0 - t], [x1 + t, h + t, z1 + t]); // the ceiling
|
|
69
54
|
box([x0 - t, 0, z0 - t], [x1 + t, h, z0]); // north wall
|
|
70
55
|
box([x1, 0, z0], [x1 + t, h, z1]); // east wall
|
|
@@ -74,51 +59,29 @@ box([x0 - t, 0, WINDOW.z[0]], [x0, WINDOW.y[0], WINDOW.z[1]]); box([x0 - t, WIND
|
|
|
74
59
|
// south wall with the door
|
|
75
60
|
box([x0 - t, 0, z1], [DOOR.x[0], h, z1 + t]); box([DOOR.x[1], 0, z1], [x1 + t, h, z1 + t]); box([DOOR.x[0], DOOR.y[1], z1], [DOOR.x[1], h, z1 + t]);
|
|
76
61
|
// furniture-sized blocks: a table, a cabinet against the east wall, a sofa-sized block in the corner
|
|
77
|
-
box([-1.2, 0, -0.5], [0.4, 0.75, 0.5], mat
|
|
78
|
-
|
|
79
|
-
// ---- the window as a light: a RectAreaLight in the opening, facing in. Soft and shaped like the window, but it casts no shadow ----
|
|
80
|
-
if (url.get('area') !== '0' && !night) {
|
|
81
|
-
windowLight(engine, { position: [x0 - 0.02, (WINDOW.y[0] + WINDOW.y[1]) / 2, 0], lookAt: [0, (WINDOW.y[0] + WINDOW.y[1]) / 2, 0],
|
|
82
|
-
width: WINDOW.z[1] - WINDOW.z[0], height: WINDOW.y[1] - WINDOW.y[0], ...WINDOW_LIGHT });
|
|
83
|
-
}
|
|
62
|
+
box([-1.2, 0, -0.5], [0.4, 0.75, 0.5], mat.table); box([3.2, 0, -1.4], [3.95, 1.9, 0.6], mat.cabinet); box([-3.9, 0, 1.4], [-2.2, 0.8, 2.9], mat.sofa);
|
|
84
63
|
|
|
85
|
-
// ---- night: lamps. The bulb hides inside a shade; the light lands on surfaces, the visible emitter stays dim
|
|
64
|
+
// ---- night: lamps. The bulb hides inside a shade; the light lands on surfaces, the visible emitter stays dim ----
|
|
86
65
|
if (night) {
|
|
87
|
-
for (const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
shade.position.copy(p.position);
|
|
95
|
-
const stand = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, l.at[1] - 0.14, 8), mat(0x777777));
|
|
96
|
-
stand.position.set(l.at[0], (l.at[1] - 0.14) / 2, l.at[2]);
|
|
97
|
-
engine.scene.add(p, shade, stand);
|
|
66
|
+
for (const { at, kind } of LAMPS) {
|
|
67
|
+
picture.addLamp(kind, at);
|
|
68
|
+
const shade = new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.26, 0.28, 24, 1, true), mat.shade[kind]);
|
|
69
|
+
shade.position.set(at[0], at[1], at[2]);
|
|
70
|
+
const stand = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, at[1] - 0.14, 8), mat.stand);
|
|
71
|
+
stand.position.set(at[0], (at[1] - 0.14) / 2, at[2]);
|
|
72
|
+
engine.scene.add(shade, stand);
|
|
98
73
|
}
|
|
99
74
|
}
|
|
100
75
|
|
|
101
|
-
// ----
|
|
102
|
-
const inside = (/** @type {THREE.Vector3} */ p) => p.x > x0 && p.x < x1 && p.z > z0 && p.z < z1 + 0.5 && p.y < h;
|
|
103
|
-
const leak = url.get('leak') === '1';
|
|
104
|
-
const { zone, apply: applyZone } = exposureZones(engine, { isInside: inside, exposure: EXPOSURE[night ? 'night' : 'day'], ease: EXPOSURE.ease,
|
|
105
|
-
ambient: leak ? { inside: AMBIENT.outside, outside: AMBIENT.outside } : AMBIENT });
|
|
106
|
-
|
|
107
|
-
// ---- fill: bounce baked into light probes, one cheap point light, or nothing ----
|
|
76
|
+
// ---- fill: bounce baked into light probes; ?fill=light is one cheap point light in picture/lights.js ----
|
|
108
77
|
async function setupFill() {
|
|
109
|
-
|
|
110
|
-
if (fill
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
await engine.bakeProbes({ bounds: { min: [x0 + 0.5, 0.4, z0 + 0.5], max: [x1 - 0.5, h - 0.4, z1 - 0.5] }, spacing: 2.5, follow: () => center });
|
|
114
|
-
} else if (fill === 'light' && !night) {
|
|
115
|
-
const bounce = new THREE.PointLight(BOUNCE_LIGHT.color, BOUNCE_LIGHT.intensity, BOUNCE_LIGHT.distance, 1);
|
|
116
|
-
bounce.position.set(-1.6, 0.4, 0.2); // just above where the sun patch lands
|
|
117
|
-
engine.scene.add(bounce);
|
|
118
|
-
}
|
|
78
|
+
picture.snapZone(); // bake with indoor ambient, as the room is meant to be seen
|
|
79
|
+
if (fill !== 'probes') return;
|
|
80
|
+
// bounds = the room's air
|
|
81
|
+
await engine.bakeProbes({ bounds: { min: [x0 + 0.5, 0.4, z0 + 0.5], max: [x1 - 0.5, h - 0.4, z1 - 0.5] }, spacing: 2.5 });
|
|
119
82
|
}
|
|
120
83
|
// spots the spec reads: the floor along the north wall and the north wall's lower part, both out of the sun patch
|
|
121
84
|
const points = { corner: [-0.5, 0.03, -2.5], northWall: [1.5, 0.6, -2.98] };
|
|
122
85
|
// the bake renders cubes between frames, so it runs after start; tracked in engine.loading so screenshots and tests wait for it
|
|
123
86
|
const ready = engine.start().then(() => engine.loading.track('fill', setupFill));
|
|
124
|
-
Object.assign(window, { engine, interiorTest: { THREE, ready, points,
|
|
87
|
+
Object.assign(window, { engine, interiorTest: { THREE, ready, points, picture, fill, night } });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The picture of the interior-light demo: wiring only. Each part writes plain three.js.
|
|
3
|
+
import { exposureZones } from '../interiorLight.js';
|
|
4
|
+
import { AMBIENT, EXPOSURE, TONE_MAPPING } from './palette.js';
|
|
5
|
+
import { createLights } from './lights.js';
|
|
6
|
+
import { createMaterials } from './materials.js';
|
|
7
|
+
import { createSky } from './sky.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns { mat, sun, hemi, addLamp, zone, snapZone() }. snapZone(): the zone's values at once, without easing, for the bake.
|
|
11
|
+
* @param {any} engine
|
|
12
|
+
* @param {Parameters<typeof createLights>[1] & { isInside: (p: any) => boolean, leak: boolean }} o
|
|
13
|
+
*/
|
|
14
|
+
export function createPicture(engine, { isInside, leak, ...o }) {
|
|
15
|
+
engine.renderer.toneMapping = TONE_MAPPING;
|
|
16
|
+
const sky = createSky(engine), lights = createLights(engine, o), { mat } = createMaterials();
|
|
17
|
+
const zones = exposureZones(engine, { hemi: lights.hemi, isInside, exposure: EXPOSURE[o.night ? 'night' : 'day'], ease: EXPOSURE.ease,
|
|
18
|
+
ambient: leak ? { inside: AMBIENT.outside, outside: AMBIENT.outside } : AMBIENT });
|
|
19
|
+
// onRender, not onFrame: onFrame runs before the sky module, so it would read last frame's signals
|
|
20
|
+
engine.onRender(() => { sky.update(engine.uniforms); lights.update(engine.uniforms); });
|
|
21
|
+
// the zones read no signals but must count every second, and a frame that is not drawn still passes time: onFrame sees those, onRender does not
|
|
22
|
+
engine.onFrame((/** @type {number} */ dt) => zones.update(dt));
|
|
23
|
+
return { mat, sun: lights.sun, hemi: lights.hemi, addLamp: lights.addLamp, zone: zones.zone, snapZone: () => zones.update() };
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The room's lights: sun or moon aimed by hand with its shadow box fitted to the room, the hemisphere, the window as an area light, the bounce
|
|
3
|
+
// stand-in and the lamps. The sun stays fixed all day: this page is about the room, not the clock; only the hemisphere's colors read the signals.
|
|
4
|
+
import { THREE } from 'threedog';
|
|
5
|
+
import { windowLight } from '../interiorLight.js';
|
|
6
|
+
import { BOUNCE_LIGHT, HEMI, LAMPS, LAMP_SHADOW, MOON, SHADOW, SUN, WINDOW_LIGHT } from './palette.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {any} engine
|
|
10
|
+
* @param {{ night: boolean, fill: string, windowOpening: { position: number[], lookAt: number[], width: number, height: number } | null }} o
|
|
11
|
+
*/
|
|
12
|
+
export function createLights(engine, { night, fill, windowOpening }) {
|
|
13
|
+
const { scene, renderer } = engine, key = night ? MOON : SUN;
|
|
14
|
+
const hemi = new THREE.HemisphereLight(), sun = new THREE.DirectionalLight(key.color, key.intensity);
|
|
15
|
+
const az = THREE.MathUtils.degToRad(key.azimuth), el = THREE.MathUtils.degToRad(key.elevation);
|
|
16
|
+
sun.position.set(Math.sin(az) * Math.cos(el), Math.sin(el), -Math.cos(az) * Math.cos(el)).multiplyScalar(SHADOW.distance);
|
|
17
|
+
sun.castShadow = true;
|
|
18
|
+
renderer.shadowMap.type = SHADOW.type;
|
|
19
|
+
sun.shadow.mapSize.setScalar(SHADOW.mapSize[engine.tier === 'low' ? 'low' : 'high']);
|
|
20
|
+
const { extent: e, distance } = SHADOW;
|
|
21
|
+
Object.assign(sun.shadow.camera, { left: -e, right: e, top: e, bottom: -e, near: 1, far: distance * 2 });
|
|
22
|
+
// three adds bias in the shadow camera's 0-1 depth, i.e. a world offset of bias x (far - near)
|
|
23
|
+
Object.assign(sun.shadow, { normalBias: SHADOW.normalBias, bias: -SHADOW.biasCm / 100 / (distance * 2 - 1), radius: SHADOW.radius });
|
|
24
|
+
scene.add(hemi, sun, sun.target);
|
|
25
|
+
|
|
26
|
+
if (windowOpening && !night) windowLight(engine, { ...windowOpening, ...WINDOW_LIGHT });
|
|
27
|
+
if (fill === 'light' && !night) {
|
|
28
|
+
const { color, intensity, distance: reach, decay, at } = BOUNCE_LIGHT, bounce = new THREE.PointLight(color, intensity, reach, decay);
|
|
29
|
+
bounce.position.set(at[0], at[1], at[2]);
|
|
30
|
+
scene.add(bounce);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The light of one lamp; the bulb hides inside the shade main.js puts around it @param {keyof typeof LAMPS} kind @param {number[]} at */
|
|
34
|
+
function addLamp(kind, at) {
|
|
35
|
+
const l = LAMPS[kind], p = new THREE.PointLight(l.color, l.intensity, 0, 2);
|
|
36
|
+
p.position.set(at[0], at[1], at[2]);
|
|
37
|
+
p.castShadow = l.shadow;
|
|
38
|
+
if (l.shadow) { p.shadow.mapSize.setScalar(LAMP_SHADOW.mapSize); p.shadow.bias = LAMP_SHADOW.bias; p.shadow.radius = LAMP_SHADOW.radius; }
|
|
39
|
+
scene.add(p);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const day = { sky: new THREE.Color(HEMI.day.sky), ground: new THREE.Color(HEMI.day.ground) }, dark = { sky: new THREE.Color(HEMI.night.sky), ground: new THREE.Color(HEMI.night.ground) };
|
|
43
|
+
return {
|
|
44
|
+
sun, hemi, addLamp,
|
|
45
|
+
/** @param {any} s engine.uniforms */
|
|
46
|
+
update(s) {
|
|
47
|
+
const light = s.uDaylight.value;
|
|
48
|
+
hemi.color.copy(dark.sky).lerp(day.sky, light);
|
|
49
|
+
hemi.groundColor.copy(dark.ground).lerp(day.ground, light);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Materials by name. Standard everywhere, since a RectAreaLight lights nothing else. Each lamp's shade glows in its own light's color.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
import { COLORS, LAMPS, ROUGHNESS } from './palette.js';
|
|
5
|
+
|
|
6
|
+
export function createMaterials() {
|
|
7
|
+
const flat = (/** @type {number} */ color, roughness = ROUGHNESS.surface) => new THREE.MeshStandardMaterial({ color, roughness });
|
|
8
|
+
const shade = (/** @type {{ color: string, glow: number }} */ l) => new THREE.MeshStandardMaterial({ color: COLORS.shade, emissive: l.color, emissiveIntensity: l.glow, side: THREE.DoubleSide, roughness: ROUGHNESS.shade });
|
|
9
|
+
return {
|
|
10
|
+
mat: { wall: flat(COLORS.wall), floor: flat(COLORS.floor), ground: flat(COLORS.ground, ROUGHNESS.ground), table: flat(COLORS.table), cabinet: flat(COLORS.cabinet),
|
|
11
|
+
sofa: flat(COLORS.sofa), stand: flat(COLORS.stand), shade: { main: shade(LAMPS.main), side: shade(LAMPS.side) } },
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Interior light palette: every value of the picture. Neutral numbers on a gray room; the colors of your game come from its own picture.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
|
|
5
|
+
/** Surfaces of the room, by name */
|
|
6
|
+
export const COLORS = { wall: 0xb5b5b5, floor: 0x8f8f8f, ground: 0x8a8a8a, table: 0xa0a0a0, cabinet: 0x9c9c9c, sofa: 0xa6a6a6, stand: 0x777777, shade: 0xe8dccb };
|
|
7
|
+
export const ROUGHNESS = { surface: 0.9, ground: 0.95, shade: 1 };
|
|
8
|
+
/** azimuth: compass degrees from north (-Z), -90 = from the west. By night the same light is a weak moon */
|
|
9
|
+
export const SUN = { elevation: 32, azimuth: -90 + 12, intensity: 3.2, color: '#fff0dc' };
|
|
10
|
+
export const MOON = { elevation: 40, azimuth: -90 + 40, intensity: 0.12, color: '#8fa4d4' };
|
|
11
|
+
// the walls stop the sun but not these two, so indoors the ambient is turned down and the fill comes from bounce
|
|
12
|
+
export const AMBIENT = { outside: { hemi: 1.0, env: 0.3 }, inside: { hemi: 0.06, env: 0.04 } };
|
|
13
|
+
/** Hemisphere colors, blended by daylight */
|
|
14
|
+
export const HEMI = { day: { sky: '#b9b9b9', ground: '#4a4a4a' }, night: { sky: '#212121', ground: '#3a3a3a' } };
|
|
15
|
+
/** RectAreaLight: the sky seen through the window (nits-like units, Standard / Physical only) */
|
|
16
|
+
export const WINDOW_LIGHT = { color: '#cfe0ff', intensity: 2.2 };
|
|
17
|
+
/** ?fill=light: one unshadowed point light just above the sun patch, standing in for its bounce */
|
|
18
|
+
export const BOUNCE_LIGHT = { color: '#ffe2c0', intensity: 1.2, distance: 7, decay: 1, at: [-1.6, 0.4, 0.2] };
|
|
19
|
+
/** Exposure per zone, eased over `ease` seconds when the camera crosses the doorway (an eye adapting) */
|
|
20
|
+
export const EXPOSURE = { day: { outside: 1, inside: 1.9 }, night: { outside: 1.6, inside: 1 }, ease: 1.2 };
|
|
21
|
+
/** intensity in candela, physical falloff; a point light shadow is six renders, so only the light that needs it gets one. glow: the shade stays dim (no glare without bloom) */
|
|
22
|
+
export const LAMPS = {
|
|
23
|
+
main: { intensity: 5, color: '#ffc58a', shadow: true, glow: 0.35 },
|
|
24
|
+
side: { intensity: 2.5, color: '#ffb874', shadow: false, glow: 0.35 },
|
|
25
|
+
};
|
|
26
|
+
export const LAMP_SHADOW = { mapSize: 512, bias: -0.002, radius: 4 };
|
|
27
|
+
/** Fitted to the room: 8 m wide at 2048 px is 0.6 cm texels. Thin walls need a small normalBias, or light leaks along their inner edge; biasCm is the depth bias in centimeters */
|
|
28
|
+
export const SHADOW = { extent: 9, distance: 160, mapSize: { high: 2048, low: 1024 }, normalBias: 0.01, biasCm: 1, radius: 2, type: THREE.PCFShadowMap };
|
|
29
|
+
/** Sky colors by daylight; horizon is also the fog color */
|
|
30
|
+
export const SKY = { day: { top: '#d4d4d4', horizon: '#d4d4d4' }, night: { top: '#20242c', horizon: '#2a2a2a' } };
|
|
31
|
+
export const FOG = { near: 180, far: 600 };
|
|
32
|
+
export const TONE_MAPPING = THREE.AgXToneMapping;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The sky is the game's: a gradient sphere and fog in its horizon color, blended by daylight. The engine's dome is hidden. The environment is
|
|
3
|
+
// three's RoomEnvironment: soft fill with some direction, no asset; the zones write its strength.
|
|
4
|
+
import { THREE } from 'threedog';
|
|
5
|
+
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
|
|
6
|
+
import { FOG, SKY } from './palette.js';
|
|
7
|
+
|
|
8
|
+
/** @param {any} engine */
|
|
9
|
+
export function createSky(engine) {
|
|
10
|
+
const { scene, renderer } = engine;
|
|
11
|
+
scene.fog = new THREE.Fog(SKY.day.horizon, FOG.near, FOG.far);
|
|
12
|
+
const pmrem = new THREE.PMREMGenerator(renderer);
|
|
13
|
+
scene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
|
|
14
|
+
pmrem.dispose();
|
|
15
|
+
const skyMat = new THREE.ShaderMaterial({
|
|
16
|
+
side: THREE.BackSide, depthWrite: false, fog: false,
|
|
17
|
+
uniforms: { uTop: { value: new THREE.Color() }, uHorizon: { value: new THREE.Color() } },
|
|
18
|
+
vertexShader: 'varying vec3 vDir; void main(){ vDir = normalize(position); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
|
|
19
|
+
// tonemapping_fragment: the sky takes the room's curve and exposure, so the window runs bright indoors and calms down outside, as the zones intend
|
|
20
|
+
fragmentShader: `uniform vec3 uTop; uniform vec3 uHorizon; varying vec3 vDir;
|
|
21
|
+
void main(){ gl_FragColor = vec4(mix(uHorizon, uTop, smoothstep(-0.05, 0.45, vDir.y)), 1.0);
|
|
22
|
+
#include <tonemapping_fragment>
|
|
23
|
+
#include <colorspace_fragment>
|
|
24
|
+
}`,
|
|
25
|
+
});
|
|
26
|
+
const dome = new THREE.Mesh(new THREE.SphereGeometry(400, 32, 16), skyMat);
|
|
27
|
+
dome.renderOrder = -1;
|
|
28
|
+
scene.add(dome);
|
|
29
|
+
if (engine.sky) engine.sky.dome.visible = false;
|
|
30
|
+
const day = { top: new THREE.Color(SKY.day.top), horizon: new THREE.Color(SKY.day.horizon) }, night = { top: new THREE.Color(SKY.night.top), horizon: new THREE.Color(SKY.night.horizon) };
|
|
31
|
+
return {
|
|
32
|
+
/** @param {any} s engine.uniforms */
|
|
33
|
+
update(s) {
|
|
34
|
+
const light = s.uDaylight.value, u = skyMat.uniforms;
|
|
35
|
+
u.uTop.value.copy(night.top).lerp(day.top, light);
|
|
36
|
+
u.uHorizon.value.copy(night.horizon).lerp(day.horizon, light);
|
|
37
|
+
/** @type {THREE.Fog} */ (scene.fog).color.copy(u.uHorizon.value);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -4,8 +4,10 @@ Modular buildings on a grid: parameterized wall / window / door / roof / trim mo
|
|
|
4
4
|
|
|
5
5
|
A kit of building pieces made in code, snapped to a grid and assembled into buildings and whole streets, with the colours and materials left to
|
|
6
6
|
the game. The pieces are plain on purpose: the same kit draws a cozy town, a gray block-out or a cold sci-fi row by swapping one set of
|
|
7
|
-
materials and one set of trim profiles.
|
|
8
|
-
|
|
7
|
+
materials and one set of trim profiles. `threedog examples pull modular-building` copies this README and `kit.js`, the whole technique: import `kit.js` from your game
|
|
8
|
+
and give it your materials (the code below shows how). The engine never imports this folder; change anything. The engine repository also has a demo page next to them,
|
|
9
|
+
which a pull does not copy: `main.js` and `picture/`, opened at `/modular-building.html` with `npm run dev` (`?set=gray|warm|cool`, `seed=1`, `count=10`,
|
|
10
|
+
`view=street|close`, `batch=0|merge`). Nothing in a game depends on it.
|
|
9
11
|
|
|
10
12
|
## The principle
|
|
11
13
|
A town reads from far to near: skyline first, then the rhythm of openings, then trim, then small detail. A grid makes every piece fit every
|
|
@@ -53,8 +55,8 @@ vanish at that distance? Does anything flicker at seams when the camera moves?
|
|
|
53
55
|
- **Merged hero block**: a fixed set piece merged once for the fewest draws, when it never changes.
|
|
54
56
|
|
|
55
57
|
## The engine helper (optional convenience)
|
|
56
|
-
`kit.js` is the kit: modules, assembler, manifest entries; it imports only `three` and `three/addons`.
|
|
57
|
-
same seed three
|
|
58
|
+
`kit.js` is the kit: modules, assembler, manifest entries; it imports only `three` and `three/addons`. The demo page in the engine repository (not in a pull)
|
|
59
|
+
has its picture in plain three.js (lights, tone curve, one Lambert material per slot) and builds the same seed three ways (gray block-out, warm with soft cove trims, cool with hard stepped trims and faintly emissive frames; the two coloured
|
|
58
60
|
sets are demo values, not advice). In the kit, the block-out stage is `facade` strings of `.` (blank walls) and `roof`. A style is the slot
|
|
59
61
|
materials (`wall`, `trim`, `roof`, `frame`, `glass`, `accent`, `awning`, `sign`) plus `profiles` plus `windows`. The only textures are gray
|
|
60
62
|
masks (awning stripes, sign text) tinted by the slot material's colour, so a material swap recolours them too. `street` mirrors upper floors
|
|
@@ -111,14 +113,14 @@ Rules (correctness):
|
|
|
111
113
|
notice". Where pieces meet, either one covers the seam (corner pilasters cover the wall ends; front / back trims run past the corners,
|
|
112
114
|
side trims stop at the walls) or they are offset by a few millimetres (the sill top sits above the reveal floor).
|
|
113
115
|
- **Generators get every input from `params`.** The slot materials are live objects, so the kit's manifest entries are `cache: false`
|
|
114
|
-
(the dev cache would otherwise keep a model built with old materials). To bake a street,
|
|
116
|
+
(the dev cache would otherwise keep a model built with old materials). To bake a street, build the slot materials inside the
|
|
115
117
|
generator instead (recipe 05, section 2a) and drop `cache: false`.
|
|
116
118
|
|
|
117
119
|
Limits:
|
|
118
120
|
- Footprints are rectangles of cells (`width` x `depth`); an L-shaped building needs `building` extended to take a cell list (two buildings
|
|
119
121
|
with `gap: 0` meet wall to wall, and their corner pilasters then overlap).
|
|
120
122
|
- Gable ridges run along the building's width; hip roofs, dormers and balconies are not in the kit (each is one more module).
|
|
121
|
-
- The test is `
|
|
123
|
+
- The test is `threedog test "modular building"` (tests/specs/modular-building.mjs): determinism per seed, grid snapping without gaps,
|
|
122
124
|
shared geometry, batching under 400 draw calls, params changing shape, the optional AO pass.
|
|
123
125
|
|
|
124
126
|
Sources: written for this example; no code copied. Background: the grid-snapped kit of reusable pieces is common modular level design practice
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Modular building kit (optional technique example, see README.md). Shapes only: every module is built from parameters and drawn with the
|
|
3
3
|
// game's own materials, one per slot (wall, trim, roof, frame, glass, accent, awning, sign). Imports only three and three/addons, so a game can
|
|
4
4
|
// copy the folder and change anything.
|
|
5
|
-
// The pieces are deliberately plain: they teach the method (grid, modules, variation, shared geometry), not a
|
|
5
|
+
// The pieces are deliberately plain: they teach the method (grid, modules, variation, shared geometry), not a picture.
|
|
6
6
|
import * as THREE from 'three';
|
|
7
7
|
import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
|
|
8
8
|
import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';
|
|
@@ -18,7 +18,7 @@ export const PROFILES = {
|
|
|
18
18
|
cove: [[0, 0], [0.35, 0], [0.5, 0.25], [0.75, 0.45], [1, 0.75], [1, 1], [0, 1]],
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
/** Window variants a street picks from: a few shared variants (not a random size per window) keep the
|
|
21
|
+
/** Window variants a street picks from: a few shared variants (not a random size per window) keep the picture designed and the geometry shared */
|
|
22
22
|
export const WINDOWS = [
|
|
23
23
|
{ width: 0.9, height: 1.4, sill: 0.9, mullions: 1, planter: false },
|
|
24
24
|
{ width: 1.1, height: 1.5, sill: 0.8, mullions: 2, planter: true },
|
|
@@ -2,32 +2,24 @@
|
|
|
2
2
|
// Modular building demo (page /modular-building.html): one seeded street from kit.js, drawn with one of three material sets.
|
|
3
3
|
// URL: ?set=gray|warm|cool (gray = the block-out, the default) &seed=1 &count=10 &view=street|close &batch=0 (draw every piece on its own) | merge (kit.merge: one mesh per material).
|
|
4
4
|
// The two coloured sets exist to show the kit is style-free: same seed, same shapes, other slots and trim profiles. They are demo values,
|
|
5
|
-
// not a recommended
|
|
6
|
-
|
|
5
|
+
// not a recommended picture. Test page for tests/specs/modular-building.mjs: window.mbTest = { kit, street, createModularKit, bakeVertexAO, THREE }.
|
|
6
|
+
// Shapes only here; the whole picture is picture/.
|
|
7
|
+
import { createEngine, fixedCamera, bakeVertexAO, THREE } from 'threedog';
|
|
7
8
|
import { createModularKit, PROFILES } from './kit.js';
|
|
9
|
+
import { createPicture } from './picture/index.js';
|
|
8
10
|
|
|
9
11
|
const url = new URLSearchParams(location.search);
|
|
10
12
|
const set = url.get('set') ?? 'gray', seed = Number(url.get('seed') ?? 1), count = Number(url.get('count') ?? 10);
|
|
11
|
-
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), ui: { loading: false }, saveKey: 'threedog-modular-building',
|
|
13
|
+
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, ui: { loading: false }, saveKey: 'threedog-modular-building',
|
|
12
14
|
batching: url.get('batch') === '0' || url.get('batch') === 'merge' ? false : undefined });
|
|
15
|
+
const { mat: { ground: groundMat, ...slots } } = createPicture(engine, { set });
|
|
13
16
|
|
|
14
|
-
/** Slot materials for one set. A game makes these from its own style (makeMaterial roles, or plain three.js materials) */
|
|
15
|
-
function makeSlots(name = 'gray') {
|
|
16
|
-
const m = (/** @type {number} */ color, extra = {}) => makeMaterial('prop', { color, ...extra });
|
|
17
|
-
if (name === 'gray') return { wall: m(0x9c9c9c), trim: m(0xbdbdbd), roof: m(0x6c6c6c), frame: m(0x5c5c5c), glass: m(0x3c4046, { roughness: 0.3 }),
|
|
18
|
-
accent: m(0x7c7c7c), awning: m(0xc4c4c4), sign: m(0xd2d2d2) };
|
|
19
|
-
if (name === 'warm') return { wall: m(0xd9c7a3), trim: m(0xf0e9da), roof: m(0xa4553a), frame: m(0x3f5b45), glass: m(0x2e3d4f, { roughness: 0.2 }),
|
|
20
|
-
accent: m(0x7a4e33), awning: m(0xb8433a), sign: m(0xe0b54a) };
|
|
21
|
-
if (name === 'cool') return { wall: m(0x4a5260), trim: m(0x9aa3ad), roof: m(0x2c3038), frame: m(0x30c0d0, { emissive: 0x1a6a74, emissiveIntensity: 0.6 }),
|
|
22
|
-
glass: m(0x1b2a33, { roughness: 0.15, emissive: 0x0e2a33, emissiveIntensity: 0.5 }), accent: m(0xd07a30), awning: m(0x2f8f9a), sign: m(0xe6edf2) };
|
|
23
|
-
throw new Error(`modular-building: unknown set "${name}" (gray, warm, cool)`);
|
|
24
|
-
}
|
|
25
17
|
// a style swaps trim profiles too: same names (so a seed picks the same trim slot), other cross-sections. Hard-edged for the cool set
|
|
26
18
|
const cutProfiles = { flat: PROFILES.flat, step: [[0, 0], [1, 0], [1, 0.35], [0.4, 0.35], [0.4, 1], [0, 1]], cove: [[0, 0], [0.6, 0], [1, 0.4], [1, 1], [0, 1]] };
|
|
27
|
-
const kit = createModularKit({ slots
|
|
19
|
+
const kit = createModularKit({ slots, profiles: set === 'cool' ? cutProfiles : PROFILES });
|
|
28
20
|
engine.assets.manifest(kit.pack); // every module, a building and the street, by name: threedog gallery, hot swap, ?panel=1 tuning
|
|
29
21
|
|
|
30
|
-
const ground = new THREE.Mesh(new THREE.PlaneGeometry(400, 400),
|
|
22
|
+
const ground = new THREE.Mesh(new THREE.PlaneGeometry(400, 400), groundMat);
|
|
31
23
|
ground.rotation.x = -Math.PI / 2; ground.receiveShadow = true;
|
|
32
24
|
engine.scene.add(ground);
|
|
33
25
|
|
|
@@ -43,5 +35,5 @@ built.userData.batch = true; // opt in to engine.batching before adding: ident
|
|
|
43
35
|
const street = url.get('batch') === 'merge' ? kit.merge(built) : built;
|
|
44
36
|
engine.scene.add(street);
|
|
45
37
|
|
|
46
|
-
Object.assign(window, { engine, mbTest: { kit, street, createModularKit,
|
|
38
|
+
Object.assign(window, { engine, mbTest: { kit, street, createModularKit, bakeVertexAO, THREE } });
|
|
47
39
|
engine.start();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The picture of the modular-building demo: wiring only.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
import { BACKGROUND, EXPOSURE, TONE_MAPPING } from './palette.js';
|
|
5
|
+
import { createLights } from './lights.js';
|
|
6
|
+
import { createMaterials } from './materials.js';
|
|
7
|
+
|
|
8
|
+
/** Returns { mat, sun, hemi }. @param {any} engine @param {{ set: string }} o */
|
|
9
|
+
export function createPicture(engine, o) {
|
|
10
|
+
engine.renderer.toneMapping = TONE_MAPPING;
|
|
11
|
+
engine.renderer.toneMappingExposure = EXPOSURE;
|
|
12
|
+
engine.scene.background = new THREE.Color(BACKGROUND);
|
|
13
|
+
const lights = createLights(engine), { mat } = createMaterials(o.set);
|
|
14
|
+
// onRender, not onFrame: engine.focus is this frame's only after the camera module ran
|
|
15
|
+
engine.onRender(() => lights.update());
|
|
16
|
+
return { mat, sun: lights.sun, hemi: lights.hemi };
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// One fixed sun and a hemisphere fill: the street has no time of day, the page judges shapes.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
import { LIGHT, SHADOW } from './palette.js';
|
|
5
|
+
|
|
6
|
+
/** @param {any} engine */
|
|
7
|
+
export function createLights(engine) {
|
|
8
|
+
const { sun: key, ambient } = LIGHT, { extent, far, mapSize, lowMapSize, bias, normalBias, radius } = SHADOW;
|
|
9
|
+
const hemi = new THREE.HemisphereLight(ambient.sky, ambient.ground, ambient.intensity);
|
|
10
|
+
const sun = new THREE.DirectionalLight(key.color, key.intensity);
|
|
11
|
+
sun.castShadow = true;
|
|
12
|
+
sun.shadow.mapSize.setScalar(engine.tier === 'low' ? lowMapSize : mapSize);
|
|
13
|
+
Object.assign(sun.shadow.camera, { left: -extent, right: extent, top: extent, bottom: -extent, near: 1, far });
|
|
14
|
+
Object.assign(sun.shadow, { bias, normalBias, radius });
|
|
15
|
+
engine.scene.add(hemi, sun, sun.target);
|
|
16
|
+
|
|
17
|
+
const [ox, oy, oz] = key.offset;
|
|
18
|
+
return {
|
|
19
|
+
sun, hemi,
|
|
20
|
+
update() {
|
|
21
|
+
// the shadow box sits on what the camera looks at, so ?view=close keeps the same shadows as the street shot
|
|
22
|
+
sun.target.position.set(engine.focus.x, 0, engine.focus.z);
|
|
23
|
+
sun.position.set(engine.focus.x + ox, oy, engine.focus.z + oz);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Materials by name, plain Lambert: the ground plus one material per kit slot, from one set of the palette.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
import { GROUND, SETS } from './palette.js';
|
|
5
|
+
|
|
6
|
+
/** @param {string} set a name in SETS */
|
|
7
|
+
export function createMaterials(set) {
|
|
8
|
+
const slots = SETS[/** @type {keyof typeof SETS} */ (set)];
|
|
9
|
+
if (!slots) throw new Error(`modular-building: unknown set "${set}" (${Object.keys(SETS).join(', ')})`);
|
|
10
|
+
const mat = /** @type {Record<string, THREE.MeshLambertMaterial>} */ ({ ground: new THREE.MeshLambertMaterial({ color: GROUND }) });
|
|
11
|
+
for (const [name, v] of Object.entries(slots)) mat[name] = new THREE.MeshLambertMaterial(typeof v === 'number' ? { color: v } : v);
|
|
12
|
+
return { mat };
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Palette of the modular street: every value of the picture. The sets are demo values that prove the kit is style-free, not a recommended picture.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
|
|
5
|
+
/** Slot colors per set. A plain number is the color; an object is the material's own properties */
|
|
6
|
+
export const SETS = {
|
|
7
|
+
// the block-out: gray, so only silhouette and rhythm are left to judge
|
|
8
|
+
gray: { wall: 0x9c9c9c, trim: 0xbdbdbd, roof: 0x6c6c6c, frame: 0x5c5c5c, glass: 0x3c4046, accent: 0x7c7c7c, awning: 0xc4c4c4, sign: 0xd2d2d2 },
|
|
9
|
+
warm: { wall: 0xd9c7a3, trim: 0xf0e9da, roof: 0xa4553a, frame: 0x3f5b45, glass: 0x2e3d4f, accent: 0x7a4e33, awning: 0xb8433a, sign: 0xe0b54a },
|
|
10
|
+
cool: { wall: 0x4a5260, trim: 0x9aa3ad, roof: 0x2c3038, frame: { color: 0x30c0d0, emissive: 0x1a6a74, emissiveIntensity: 0.6 },
|
|
11
|
+
glass: { color: 0x1b2a33, emissive: 0x0e2a33, emissiveIntensity: 0.5 }, accent: 0xd07a30, awning: 0x2f8f9a, sign: 0xe6edf2 },
|
|
12
|
+
};
|
|
13
|
+
export const GROUND = 0x8c8c86;
|
|
14
|
+
export const BACKGROUND = 0x8c8c8c;
|
|
15
|
+
/** A strong, nearly even fill over a modest sun, on purpose: a block-out has to show every facade, so the sides facing away stay as readable as the lit ones */
|
|
16
|
+
export const LIGHT = {
|
|
17
|
+
sun: { color: 0xffffff, intensity: 2, offset: [40, 80, 30] },
|
|
18
|
+
ambient: { sky: 0xffffff, ground: 0x909090, intensity: 3.1 },
|
|
19
|
+
};
|
|
20
|
+
/** A 60 m box around what the camera looks at: most of a ten-building street, at about 3 cm a texel */
|
|
21
|
+
export const SHADOW = { extent: 30, far: 250, mapSize: 2048, lowMapSize: 1024, bias: -0.0001, normalBias: 0.03, radius: 3 };
|
|
22
|
+
export const TONE_MAPPING = THREE.AgXToneMapping;
|
|
23
|
+
export const EXPOSURE = 1;
|
|
@@ -14,12 +14,12 @@ colored windows, and a night that is darker than all of them.
|
|
|
14
14
|
the facades above dark, like a real cut-off fixture. `distance` only cuts the tail; keep it a few times the lamp height so the edge comes
|
|
15
15
|
from decay.
|
|
16
16
|
|
|
17
|
-
**Which pixels bloom is the threshold's choice.** The tone curve (AgX
|
|
17
|
+
**Which pixels bloom is the threshold's choice.** The tone curve (AgX on this page) compresses everything above ~1 toward white. Bloom adds light
|
|
18
18
|
around pixels above its `threshold` (linear, before the curve). Usually it sits between the windows and the lamp heads, so only the small heads
|
|
19
19
|
glow and windows and signs read as colored light; if your game wants a hazy, everything-glows night, set it lower on purpose.
|
|
20
20
|
|
|
21
21
|
**Emissive is a color, not a brightness knob.** Saturated emissive colors survive the tone curve; near-white ones have no headroom and clip
|
|
22
|
-
to flat white rectangles
|
|
22
|
+
to flat white rectangles. Get the warmth from the color and let bloom carry the halo; the
|
|
23
23
|
intensities in this example are its values, not targets.
|
|
24
24
|
|
|
25
25
|
**Lights read when the night is darker than they are.** If the ambient at night is close to the pool brightness, the lamps look painted on.
|
|
@@ -31,7 +31,7 @@ bright, readable night, keep the ambient up and let the lamps be accents instead
|
|
|
31
31
|
**Lights fade in.** A hard switch at 18:00 pops; fade by daylight.
|
|
32
32
|
|
|
33
33
|
How to judge it in a shot at the game's camera: the ground under a lamp is clearly brighter than half way to the next one, and the pool fades
|
|
34
|
-
without a ring; around a lamp only its core is white (the
|
|
34
|
+
without a ring; around a lamp only its core is white (the picture check of `threedog shot` / `threedog snap` names each light or glowing material that blows pixels out, and the detail lost under it); the "near black" share stays low enough
|
|
35
35
|
that shapes hold.
|
|
36
36
|
|
|
37
37
|
| Symptom | Cause | Fix |
|
|
@@ -39,7 +39,7 @@ that shapes hold.
|
|
|
39
39
|
| Lamp heads and windows are flat white blocks | emissive far above the tone curve's shoulder: everything clips to the same white | lower emissiveIntensity, use a saturated color; usually only the small lamp core clips (more if your game wants blinding light) |
|
|
40
40
|
| A wall next to a lamp is a bright blown-out sheet | `decay: 0` (or 1) and the light close to the wall: no falloff, the whole wall gets the full intensity | `decay: 2`, aim a spot down, move the light off the wall |
|
|
41
41
|
| The whole night scene glows and looks foggy | bloom threshold below 1: every lit surface blooms | threshold between window and lamp-head brightness |
|
|
42
|
-
| Everything is too bright or too gray at night | exposure or ambient set for the day | lower the night ambient (
|
|
42
|
+
| Everything is too bright or too gray at night | exposure or ambient set for the day | lower the night ambient (`NIGHT.hemi` in `picture/palette.js`) rather than the lights |
|
|
43
43
|
| Halo plus bloom look like a smear | both at full strength | pick one as the main glow, keep the other faint |
|
|
44
44
|
| Lights pop on at nightfall | a hard switch at 18:00 | fade by daylight (`dusk`) |
|
|
45
45
|
|
|
@@ -63,32 +63,33 @@ that shapes hold.
|
|
|
63
63
|
- **Pixel art**: hard-edged pools in two or three palette steps, no bloom. A texture lookup.
|
|
64
64
|
|
|
65
65
|
## The engine helper (optional convenience)
|
|
66
|
-
`threedog examples pull night-lights` copies it. Only `nightLights.js` is the technique (defaults in `NIGHT_LIGHTS_DEFAULTS`); `main.js` is the
|
|
67
|
-
demo scene,
|
|
66
|
+
`threedog examples pull night-lights` copies it. Only `nightLights.js` is the technique (defaults in `NIGHT_LIGHTS_DEFAULTS`) and it stands alone; `main.js` is the
|
|
67
|
+
demo scene and `picture/` its picture (sun, ambient, sky, fog, bloom, tone curve). In a game:
|
|
68
68
|
```js
|
|
69
69
|
engine.use(lightPool({ point: 4, spot: 8 })); // real lights for the nearest lamps; the rest wait their turn
|
|
70
70
|
const lights = createNightLights(engine);
|
|
71
71
|
lights.addLamp(headPosition, { head: headMaterial }); // pooled spot aimed down + emissive head + halo
|
|
72
|
-
lights.addGlow(windowMaterial); //
|
|
72
|
+
lights.addGlow(windowMaterial); // emissive fades in at dusk
|
|
73
73
|
```
|
|
74
74
|
This example's current values: 80 cd at 5.5 m, so the pool center is a little under the brightness a sunlit mid-gray gets (recipe 52 "How
|
|
75
75
|
bright a lit color comes out"); raise it for brighter streets, lower it for moody ones. Lamp heads at 2.5, windows at 0.6, bloom threshold 1.4.
|
|
76
|
-
The demo
|
|
76
|
+
The demo keeps its night ambient far under the pools (`NIGHT.hemi` in `picture/palette.js`). With bloom on, keep the halo's
|
|
77
77
|
opacity low; they stack.
|
|
78
78
|
|
|
79
79
|
Cost (the demo street): 8 pooled spot lights (no shadows) for any number of lamps; one emissive material per kind of glow; one sprite per lamp
|
|
80
|
-
sharing one material and a 64 px texture; bloom is one `UnrealBloomPass` (several half-resolution blur passes; costly on integrated GPUs,
|
|
81
|
-
|
|
80
|
+
sharing one material and a 64 px texture; bloom is one `UnrealBloomPass` (several half-resolution blur passes; costly on integrated GPUs, so
|
|
81
|
+
`picture/post.js` starts it off on low-tier devices). Spot shadows add one shadow map each (another pass over the casters): this example gives none; a game that wants lamp shadows picks its hero lamps and measures the frame time as it adds them.
|
|
82
82
|
|
|
83
83
|
Rules (correctness):
|
|
84
84
|
- Lamps take their real lights from `engine.lightPool` (`lightPool({ spot })`): a fixed number of three.js lights, so many lamps never
|
|
85
85
|
recompile shaders or add per-light cost. Without the pool it throws.
|
|
86
86
|
- The night factor comes from the time of day (`engine.calendar.daylight`, the sky's when there is no calendar). Nothing here is saved: it
|
|
87
87
|
is recomputed from the time each frame, so loads and time skips are right by construction.
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
the
|
|
91
|
-
from `daylight` (`dusk` is set to the glow's range) and sets the pooled lights; `lights.force(v)` holds it.
|
|
88
|
+
- `addGlow` drives every mesh using that material: give dark windows their own material (the demo uses two lit ones and plain wall gray).
|
|
89
|
+
- The lamps' real lights fade through the pool (`lightPool.add(at, { dusk })`). Windows, signs, lamp heads and halos are not pool sources, so
|
|
90
|
+
the technique applies the same curve at the same `dusk` to their `emissiveIntensity` and the halo opacity, in one `engine.onRender`.
|
|
92
91
|
|
|
93
92
|
Sources: written for this example; no code copied. Light units and falloff as documented for three.js physically based lights; the bloom pass
|
|
94
93
|
is three's `UnrealBloomPass` through `@threedog/post-effects`.
|
|
94
|
+
|
|
95
|
+
This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). A game on the default WebGPU route writes the same ideas in TSL (recipe 56).
|