threedog 0.2.1 → 0.7.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 +371 -1
- package/README.md +21 -12
- package/core/Animator.js +15 -12
- package/core/Assets.js +92 -26
- package/core/Audio.js +45 -38
- package/core/Baked.js +30 -15
- package/core/Batching.js +102 -15
- package/core/Budget.js +40 -19
- package/core/Clock.js +40 -80
- package/core/DebugOverrides.js +75 -25
- package/core/Describe.js +105 -45
- package/core/Engine.js +203 -75
- package/core/Events.js +4 -1
- package/core/I18n.js +25 -13
- package/core/Input.js +175 -80
- package/core/Inspect.js +8 -5
- package/core/InspectMaterials.js +84 -0
- package/core/InspectPerf.js +68 -0
- package/core/InspectScene.js +13 -2
- package/core/Loading.js +2 -1
- package/core/MaterialInfo.js +7 -5
- package/core/Ops.js +50 -9
- package/core/Random.js +9 -2
- package/core/Rays.js +12 -7
- package/core/SaveStore.js +41 -9
- package/core/Saves.js +71 -15
- package/core/Stream.js +13 -10
- package/core/Threads.js +26 -7
- package/core/UrlState.js +69 -13
- package/core/Views.js +10 -6
- package/core/actor.js +1 -1
- package/core/adaptive.js +93 -0
- package/core/assetEntry.js +27 -7
- package/core/assetHot.js +176 -0
- package/core/assetLoad.js +44 -19
- package/core/assetManifest.js +53 -11
- package/core/assetReport.js +5 -5
- package/core/audioRules.js +13 -11
- package/core/audioVoice.js +69 -42
- package/core/batchGroups.js +9 -1
- package/core/canvasBox.js +1 -2
- package/core/catalog.js +21 -5
- package/core/cells.js +62 -0
- package/core/checks.js +10 -8
- package/core/chunkStream.js +87 -0
- package/core/control.js +149 -0
- package/core/copies.js +32 -0
- package/core/dayTime.js +12 -6
- package/core/debugView.js +85 -18
- package/core/describeRender.js +117 -21
- package/core/describeText.js +41 -21
- package/core/engineCamera.js +32 -0
- package/core/errorCodes.js +478 -32
- package/core/errorHints.js +41 -142
- package/core/errors.js +31 -8
- package/core/events.generated.js +13 -7
- package/core/gameLights.js +69 -0
- package/core/grayMap.js +20 -0
- package/core/grid.js +14 -13
- package/core/gridLoad.js +2 -1
- package/core/ground.js +6 -4
- package/core/headlessLoad.js +55 -0
- package/core/holds.js +78 -50
- package/core/inputContext.js +11 -7
- package/core/inputDefaults.js +24 -21
- package/core/inputPad.js +1 -1
- package/core/inputPointer.js +1 -1
- package/core/inputTouch.js +2 -2
- package/core/lifecycle.js +46 -12
- package/core/lightWatch.js +9 -5
- package/core/loop.js +109 -43
- package/core/math.js +18 -3
- package/core/moduleSlots.js +100 -0
- package/core/moduleTypes.js +86 -0
- package/core/modules.js +147 -29
- package/core/movement.js +2 -2
- package/core/namedModel.js +74 -0
- package/core/opsCheck.js +3 -3
- package/core/opsFail.js +15 -6
- package/core/opsGuard.js +4 -4
- package/core/opsRun.js +4 -3
- package/core/owned.js +171 -0
- package/core/page.js +44 -10
- package/core/params.js +30 -8
- package/core/pictureSlots.js +33 -0
- package/core/pictureWriters.js +343 -0
- package/core/plugins.js +245 -0
- package/core/saveApply.js +99 -17
- package/core/saveFiles.js +8 -6
- package/core/saveValues.js +46 -0
- package/core/saveVersions.js +20 -3
- package/core/scatter.js +48 -19
- package/core/sceneDelta.js +211 -0
- package/core/sceneMethods.js +31 -33
- package/core/screenToGround.js +1 -1
- package/core/services.js +27 -11
- package/core/session.js +28 -25
- package/core/shaderCost.js +78 -0
- package/core/shadowTypes.js +3 -2
- package/core/shadows.js +405 -0
- package/core/sharedPoint.js +303 -0
- package/core/skip.js +36 -28
- package/core/stackFrames.js +45 -0
- package/core/stacks.js +166 -0
- package/core/startup.js +153 -13
- package/core/streamSources.js +0 -11
- package/core/targeting.js +1 -1
- package/core/textureBytes.js +20 -0
- package/core/thingExplain.js +3 -3
- package/core/thingOps.js +29 -6
- package/core/things.js +22 -12
- package/core/threadPure.js +7 -3
- package/core/threePatches.js +47 -0
- package/core/tier.js +21 -10
- package/core/time.js +236 -0
- package/core/uiClock.js +25 -0
- package/core/util.js +8 -2
- package/core/validate.js +66 -87
- package/core/view.js +43 -0
- package/core/wrap.js +106 -0
- package/docs/AI.md +95 -104
- package/docs/API.md +35 -31
- package/docs/CODEMAP.md +231 -176
- package/docs/COMMANDS.md +63 -39
- package/docs/CONVENTIONS.md +99 -31
- package/docs/MIGRATING-0.3.md +248 -0
- package/docs/MIGRATING-0.4.md +320 -0
- package/docs/MIGRATING-0.5.md +68 -0
- package/docs/MIGRATING-0.6.md +126 -0
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/PERF.md +35 -7
- package/docs/THREE.md +82 -28
- package/docs/api/ambience.md +0 -1
- package/docs/api/assets.md +15 -11
- package/docs/api/audio.md +10 -14
- package/docs/api/budget.md +4 -0
- package/docs/api/calendar.md +41 -0
- package/docs/api/cameraRig.md +16 -5
- package/docs/api/characters.md +41 -24
- package/docs/api/clock.md +6 -5
- package/docs/api/collision.md +10 -7
- package/docs/api/content.md +6 -4
- package/docs/api/dialogue.md +9 -9
- package/docs/api/engine.md +95 -65
- package/docs/api/events.md +20 -14
- package/docs/api/grids.md +10 -3
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +5 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +13 -7
- package/docs/api/interactions.md +10 -6
- package/docs/api/inventory.md +17 -17
- package/docs/api/level.md +0 -2
- package/docs/api/lightPool.md +3 -1
- package/docs/api/music.md +1 -1
- package/docs/api/nav.md +3 -0
- package/docs/api/occlusion.md +5 -0
- package/docs/api/openWorld.md +2 -1
- package/docs/api/particles.md +6 -3
- package/docs/api/photo.md +0 -2
- package/docs/api/pickups.md +21 -0
- package/docs/api/post.md +8 -5
- package/docs/api/quests.md +2 -3
- package/docs/api/rigid.md +16 -14
- package/docs/api/saves.md +6 -4
- package/docs/api/settings.md +2 -3
- package/docs/api/sky.md +18 -49
- package/docs/api/stream.md +1 -1
- package/docs/api/terrain.md +16 -7
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/timeline.md +3 -4
- package/docs/api/tools.md +32 -15
- package/docs/api/triggers.md +7 -10
- package/docs/api/vegetation.md +17 -9
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +9 -21
- package/docs/api/weather.md +10 -15
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +3 -2
- package/docs/recipes/01-new-game.md +52 -42
- package/docs/recipes/02-npc.md +24 -7
- package/docs/recipes/03-items-pickups.md +57 -22
- package/docs/recipes/04-quests.md +12 -5
- package/docs/recipes/05-props-bake.md +174 -22
- package/docs/recipes/06-clock-events.md +100 -52
- package/docs/recipes/07-flow-scenes-pause.md +50 -10
- package/docs/recipes/08-weather-sky.md +134 -37
- package/docs/recipes/09-materials-lights-models.md +185 -0
- package/docs/recipes/10-blender-level.md +16 -4
- package/docs/recipes/11-vehicles.md +67 -10
- package/docs/recipes/13-animation.md +23 -9
- package/docs/recipes/14-custom-module.md +63 -29
- package/docs/recipes/15-perf.md +31 -10
- package/docs/recipes/16-dev-bridge.md +74 -40
- package/docs/recipes/18-world.md +26 -14
- package/docs/recipes/19-shooting-picking.md +12 -10
- package/docs/recipes/20-content-actions-save.md +60 -18
- package/docs/recipes/21-camera.md +55 -17
- package/docs/recipes/22-shop-gold.md +3 -3
- package/docs/recipes/23-ops.md +17 -11
- package/docs/recipes/26-ui-parts.md +86 -13
- package/docs/recipes/27-net.md +11 -5
- package/docs/recipes/28-terrain.md +36 -3
- package/docs/recipes/29-grid.md +46 -19
- package/docs/recipes/30-templates.md +72 -15
- package/docs/recipes/31-audio.md +20 -12
- package/docs/recipes/32-action-game.md +51 -4
- package/docs/recipes/34-environment-lighting.md +108 -21
- package/docs/recipes/35-picture-from-reference.md +147 -0
- package/docs/recipes/36-sky-ground-plants.md +158 -0
- package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -12
- package/docs/recipes/38-environment-hooks.md +67 -0
- package/docs/recipes/40-scene.md +114 -32
- package/docs/recipes/42-terrain-shape.md +2 -2
- package/docs/recipes/43-shader-patches-surfaces.md +206 -0
- package/docs/recipes/44-water-weather-hooks.md +191 -0
- package/docs/recipes/45-cascaded-shadows.md +130 -23
- package/docs/recipes/46-blender-art-route.md +17 -20
- package/docs/recipes/47-island-snow-backdrop.md +13 -15
- package/docs/recipes/49-game-module-contract.md +30 -17
- package/docs/recipes/50-own-renderer.md +4 -4
- package/docs/recipes/51-capability-catalog.md +3 -3
- package/docs/recipes/52-around-the-picture.md +181 -0
- package/docs/recipes/53-ground-up-close.md +12 -12
- package/docs/recipes/54-three-idioms.md +88 -0
- package/docs/recipes/55-mods-time-wrap.md +124 -0
- package/docs/recipes/56-webgpu-tsl.md +303 -0
- package/docs/recipes/57-control.md +104 -0
- package/docs/recipes/58-input.md +60 -0
- package/docs/recipes/59-depth-post-effects.md +83 -0
- package/docs/recipes/60-judge-the-picture.md +70 -0
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +244 -0
- package/docs/recipes/63-third-person-start.md +77 -0
- package/docs/recipes/64-particles.md +35 -0
- package/examples/action/.threedog/content-index.json +1 -0
- package/examples/action/GAMEMAP.md +20 -14
- package/examples/action/assets.js +8 -0
- package/examples/action/content/actions.js +1 -1
- package/examples/action/content/audio.js +5 -5
- package/examples/action/main.js +12 -15
- package/examples/action/models.js +23 -24
- 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/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/FINDINGS.md +53 -0
- package/examples/plain-picture/GAMEMAP.md +90 -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 +133 -0
- package/examples/rc2d/.threedog/content-index.json +1 -0
- package/examples/rc2d/GAMEMAP.md +88 -0
- package/examples/rc2d/README.md +57 -0
- package/examples/rc2d/main.js +55 -0
- 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 +187 -0
- package/examples/rc2d/shaders.js +144 -0
- package/examples/sheepisland/.threedog/content-index.json +1 -0
- package/examples/sheepisland/GAMEMAP.md +22 -17
- package/examples/sheepisland/assets.js +5 -0
- package/examples/sheepisland/content/templates.js +1 -1
- package/examples/sheepisland/content/vegetation.js +3 -1
- package/examples/sheepisland/main.js +29 -18
- package/examples/sheepisland/{style/models.js → models.js} +13 -24
- package/examples/sheepisland/picture/index.js +20 -0
- package/examples/sheepisland/picture/lights.js +34 -0
- package/examples/sheepisland/picture/materials.js +61 -0
- package/examples/sheepisland/picture/palette.js +60 -0
- package/examples/sheepisland/picture/sky.js +20 -0
- package/examples/sheepisland/views.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -0
- package/examples/styletest/GAMEMAP.md +25 -22
- package/examples/styletest/assets.js +6 -0
- package/examples/styletest/content/templates.js +1 -1
- package/examples/styletest/content/vegetation.js +1 -1
- package/examples/styletest/main.js +25 -34
- package/examples/styletest/models.js +30 -30
- package/examples/styletest/params.js +2 -5
- 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 +91 -0
- package/examples/techniques/contact-shadows/contactShadows.js +67 -0
- package/examples/techniques/contact-shadows/main.js +55 -0
- 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 +83 -0
- package/examples/techniques/day-night-grade/main.js +41 -0
- 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 +106 -0
- package/examples/techniques/interior-light/interiorLight.js +47 -0
- package/examples/techniques/interior-light/main.js +87 -0
- 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 +126 -0
- package/examples/techniques/modular-building/kit.js +426 -0
- package/examples/techniques/modular-building/main.js +39 -0
- 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 +95 -0
- package/examples/techniques/night-lights/main.js +47 -0
- package/examples/techniques/night-lights/nightLights.js +95 -0
- 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 +59 -0
- package/examples/techniques/outlines-and-rim/main.js +61 -0
- package/examples/techniques/outlines-and-rim/outlines.js +64 -0
- 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 +79 -0
- package/examples/techniques/procedural-animation/creature.js +44 -0
- package/examples/techniques/procedural-animation/main.js +47 -0
- 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 +118 -0
- package/examples/techniques/procedural-surface/README.md +69 -0
- package/examples/techniques/procedural-surface/main.js +65 -0
- 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/procedural-surface/surface.js +120 -0
- package/examples/techniques/stylized-shading/README.md +74 -0
- package/examples/techniques/stylized-shading/main.js +62 -0
- 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 +131 -0
- package/examples/techniques/sun-and-key-light/README.md +133 -0
- package/examples/techniques/sun-and-key-light/keyLight.js +71 -0
- package/examples/techniques/sun-and-key-light/main.js +51 -0
- 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 +102 -0
- package/examples/techniques/wet-road/main.js +48 -0
- 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/techniques/wet-road/wetRoad.js +209 -0
- package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
- package/examples/webgpu-tsl/GAMEMAP.md +89 -0
- package/examples/webgpu-tsl/README.md +45 -0
- package/examples/webgpu-tsl/main.js +44 -0
- 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 -0
- package/examples/world/GAMEMAP.md +31 -21
- package/examples/world/art/humanoid.js +38 -0
- package/examples/world/art/index.js +11 -0
- package/examples/world/art/models.js +57 -0
- package/examples/world/art/shapes.js +9 -0
- package/examples/world/assets.js +6 -0
- package/examples/world/content/audio.js +5 -5
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/rules.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +22 -18
- 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 +44 -54
- package/index.js +29 -25
- package/llms.txt +24 -15
- package/modules/ambience/Ambience.js +34 -23
- package/modules/calendar/Calendar.js +163 -0
- package/modules/calendar/contract.js +21 -0
- package/modules/calendar/index.js +82 -0
- package/modules/{sky → calendar}/schedule.js +17 -16
- package/modules/calendar/seasons.js +55 -0
- package/modules/camera/FirstPersonCamera.js +6 -15
- package/modules/camera/FixedCamera.js +33 -15
- package/modules/camera/FollowCamera.js +90 -16
- package/modules/camera/RtsCamera.js +18 -17
- package/modules/camera/common.js +73 -20
- package/modules/camera/contract.js +17 -0
- package/modules/camera/projection.js +11 -24
- package/modules/characters/Character.js +188 -48
- package/modules/characters/NPC.js +92 -41
- package/modules/characters/assetModel.js +8 -16
- package/modules/characters/behaviors.js +2 -1
- package/modules/characters/contract.js +13 -0
- package/modules/characters/footsteps.js +1 -1
- package/modules/characters/index.js +112 -49
- package/modules/characters/moveHelpers.js +4 -5
- package/modules/characters/movers/common.js +102 -19
- package/modules/characters/movers/manual.js +23 -0
- package/modules/characters/movers/rapier.js +19 -16
- package/modules/characters/movers/simple.js +14 -11
- package/modules/characters/movers/support.js +186 -0
- package/modules/characters/npcAvoid.js +47 -42
- package/modules/characters/npcSim.js +17 -9
- package/modules/characters/npcView.js +44 -16
- package/modules/characters/pathAsync.js +7 -3
- package/modules/characters/playerStrings.js +4 -3
- package/modules/characters/proceduralRig.js +19 -4
- package/modules/characters/useModel.js +2 -2
- package/modules/characters/vehicle.contract.js +21 -0
- package/modules/characters/walkTo.js +21 -7
- package/modules/collision/Collision.js +69 -27
- package/modules/collision/grid.js +8 -6
- package/modules/content/explain.js +2 -2
- package/modules/content/fields.js +102 -0
- package/modules/content/ids.js +8 -6
- package/modules/content/index.js +104 -27
- package/modules/content/loader.js +45 -33
- package/modules/content/models.js +58 -42
- package/modules/content/packs.js +6 -5
- package/modules/content/parts.js +41 -0
- package/modules/content/props.js +20 -11
- package/modules/content/rules.js +66 -0
- package/modules/content/stages.js +80 -0
- package/modules/content/templates.js +123 -30
- package/modules/debug/DebugPanel.js +24 -17
- package/modules/flow/contract.js +16 -0
- package/modules/flow/index.js +21 -15
- package/modules/gameplay/Container.js +41 -32
- package/modules/gameplay/Containers.js +30 -15
- package/modules/gameplay/Dialogue.js +113 -55
- package/modules/gameplay/Interactions.js +273 -72
- package/modules/gameplay/Inventory.js +72 -76
- package/modules/gameplay/Quests.js +75 -39
- package/modules/gameplay/boxOps.js +3 -3
- package/modules/gameplay/dialogue.contract.js +21 -0
- package/modules/gameplay/dialogueBox.js +4 -2
- package/modules/gameplay/dialogueBubbles.js +116 -0
- package/modules/gameplay/interactionPrompt.js +4 -1
- package/modules/gameplay/interactions.contract.js +16 -0
- package/modules/gameplay/inventory.contract.js +23 -0
- package/modules/gameplay/inventoryOps.js +19 -17
- package/modules/gameplay/pickups.js +306 -85
- package/modules/gameplay/questLog.js +6 -6
- package/modules/gameplay/quests.contract.js +17 -0
- package/modules/grid/Grid.js +92 -50
- package/modules/grid/Layer.js +27 -13
- package/modules/grid/index.js +96 -43
- package/modules/grid/ops.js +20 -18
- package/modules/grid/preview.js +37 -29
- package/modules/grid/strings.js +12 -0
- package/modules/grid/tiles.js +19 -22
- package/modules/hlod/index.js +52 -19
- package/modules/hud/index.js +48 -20
- package/modules/hud/parts.js +28 -13
- package/modules/level/heightfield.js +3 -1
- package/modules/level/index.js +49 -23
- package/modules/level/nodes.js +4 -3
- package/modules/lights/index.js +47 -19
- package/modules/music/Music.js +38 -21
- package/modules/music/rules.js +1 -1
- package/modules/nav/index.js +48 -42
- package/modules/net/Client.js +13 -6
- package/modules/net/Host.js +19 -5
- package/modules/net/Net.js +2 -1
- package/modules/net/index.js +13 -8
- package/modules/net/sync.js +9 -8
- package/modules/net/transports.js +77 -27
- package/modules/particles/Particles.js +58 -28
- package/modules/particles/contract.js +17 -0
- package/modules/particles/effect.js +54 -11
- package/modules/photo/Photo.js +56 -38
- package/modules/rigid/RigidBodies.js +194 -32
- package/modules/rigid/Vehicles.js +18 -15
- package/modules/rigid/sync.js +62 -17
- package/modules/settings/Settings.js +60 -55
- package/modules/settings/apply.js +38 -3
- package/modules/settings/sections.js +5 -3
- package/modules/settings/strings.js +3 -2
- package/modules/settings/view.js +5 -3
- package/modules/sky/Sky.js +132 -205
- package/modules/sky/clouds.js +37 -23
- package/modules/sky/dome.js +100 -0
- package/modules/sky/domeLayers.js +30 -15
- package/modules/sky/environment.js +45 -99
- package/modules/sky/fog.js +9 -139
- package/modules/sky/frame.js +60 -56
- package/modules/sky/season.js +21 -0
- package/modules/sky/shader.js +63 -35
- package/modules/sky/skyModule.js +52 -37
- package/modules/sky/tint.js +59 -0
- package/modules/terrain/ChunkManager.js +194 -110
- package/modules/terrain/chunkJob.js +1 -1
- package/modules/terrain/chunkQueries.js +6 -4
- package/modules/terrain/draw.js +154 -0
- package/modules/terrain/index.js +87 -54
- package/modules/terrain/terrainDefaults.js +2 -2
- package/modules/terrain/terrainEdit.js +18 -20
- package/modules/terrain/terrainGen.js +6 -4
- package/modules/terrain/terrainIsland.js +5 -4
- package/modules/terrain/terrainShape.js +12 -12
- package/modules/terrain/terrainShapeMain.js +8 -7
- package/modules/terrain/terrainTexture.js +21 -19
- package/modules/timeline/Timeline.js +95 -43
- package/modules/timeline/Tween.js +18 -10
- package/modules/timeline/letterbox.js +2 -2
- package/modules/timeline/shots.js +5 -1
- package/modules/triggers/index.js +111 -76
- package/modules/vegetation/Vegetation.js +229 -112
- package/modules/vegetation/densityMap.js +62 -0
- package/modules/vegetation/draw.js +191 -0
- package/modules/vegetation/groundChunks.js +52 -58
- package/modules/vegetation/index.js +32 -11
- package/modules/vegetation/modelGeometry.js +3 -2
- package/modules/vegetation/nearFade.js +8 -2
- package/modules/water/Water.js +157 -72
- package/modules/water/surface.js +86 -47
- package/modules/weather/Weather.js +96 -103
- package/modules/weather/particles.js +37 -14
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/strings.js +2 -2
- package/modules/weather/weatherDraw.js +141 -0
- package/modules/world/World.js +26 -9
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -4
- package/modules/world/persist.js +62 -2
- package/modules/world/pos.js +3 -2
- package/modules/world/records.js +8 -6
- package/modules/world/sim.js +60 -20
- package/modules/world/simFar.js +4 -3
- package/modules/world/state.js +3 -2
- package/modules/world/thingSource.js +1 -1
- package/modules/world/views.js +8 -6
- package/package.json +8 -3
- package/presets.js +43 -29
- package/render/PostFX.js +318 -135
- package/render/backend.js +486 -0
- package/render/cascades.js +195 -0
- package/render/cascades.tsl.js +96 -0
- package/render/daylight.js +39 -0
- package/render/detail.js +122 -41
- package/render/effects.js +155 -48
- package/render/engineUniforms.js +10 -1
- package/render/fuse.js +5 -4
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/cloudShadow.tsl.js +16 -0
- package/render/fx/detail.tsl.js +66 -0
- package/render/fx/index.js +28 -0
- package/render/fx/lighting.tsl.js +28 -0
- package/render/fx/nodeErrors.tsl.js +68 -0
- package/render/fx/noise.tsl.js +12 -0
- package/render/fx/objectOrigin.tsl.js +42 -0
- package/render/fx/particles.tsl.js +139 -0
- package/render/fx/patchNodes.tsl.js +403 -0
- package/render/fx/postWebGPU.tsl.js +181 -0
- package/render/fx/season.tsl.js +13 -0
- package/render/fx/sky.tsl.js +187 -0
- package/render/fx/uniforms.tsl.js +67 -0
- package/render/fx/water.tsl.js +53 -0
- package/render/fx/wind.tsl.js +22 -0
- package/render/fxNumbers.js +36 -0
- package/render/hotGlsl.js +24 -0
- package/render/layers.js +14 -0
- package/render/lighting.js +71 -18
- package/render/lightmap.js +142 -0
- package/render/lights.js +47 -6
- package/render/materials.js +55 -152
- package/render/modeling.js +73 -0
- package/render/neutral.js +23 -0
- package/render/occlusion.js +184 -0
- package/render/ownFrame.js +76 -0
- package/render/patches.js +317 -35
- package/render/postWebGL.js +205 -0
- package/render/probes.js +288 -0
- package/render/shaderErrors.js +154 -0
- package/render/slots.js +165 -0
- package/render/terms.js +163 -0
- package/render/uniformDecl.js +4 -3
- package/types/common.d.ts +2 -2
- package/types/core.d.ts +757 -346
- package/types/gameplay.d.ts +539 -330
- package/types/generated/core/Audio.d.ts +26 -42
- package/types/generated/core/Batching.d.ts +6 -2
- package/types/generated/core/Budget.d.ts +2 -8
- package/types/generated/core/DebugOverrides.d.ts +58 -9
- package/types/generated/core/I18n.d.ts +2 -2
- package/types/generated/core/Input.d.ts +110 -32
- package/types/generated/core/Ops.d.ts +31 -0
- package/types/generated/core/Random.d.ts +2 -2
- package/types/generated/core/Saves.d.ts +10 -2
- package/types/generated/core/Stream.d.ts +1 -1
- package/types/generated/core/Threads.d.ts +4 -1
- package/types/generated/core/Views.d.ts +0 -1
- package/types/generated/core/audioVoice.d.ts +17 -9
- package/types/generated/core/control.d.ts +55 -0
- package/types/generated/core/page.d.ts +9 -2
- package/types/generated/core/session.d.ts +2 -1
- package/types/generated/modules/ambience/Ambience.d.ts +0 -9
- package/types/generated/modules/calendar/Calendar.d.ts +84 -0
- package/types/generated/modules/calendar/index.d.ts +10 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Grid.d.ts +61 -25
- package/types/generated/modules/grid/Layer.d.ts +13 -5
- package/types/generated/modules/grid/index.d.ts +56 -20
- package/types/generated/modules/music/Music.d.ts +5 -3
- package/types/generated/modules/net/index.d.ts +3 -3
- package/types/generated/modules/net/transports.d.ts +12 -3
- package/types/generated/modules/particles/Particles.d.ts +13 -6
- package/types/generated/modules/sky/Sky.d.ts +85 -110
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/timeline/Timeline.d.ts +8 -6
- package/types/generated/modules/water/Water.d.ts +50 -3
- package/types/generated/modules/weather/Weather.d.ts +44 -15
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +20 -5
- package/types/generated/render/PostFX.d.ts +109 -29
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +31 -50
- package/types/generated/render/modeling.d.ts +30 -0
- package/types/generated/render/occlusion.d.ts +13 -0
- package/types/generated/render/patches.d.ts +16 -2
- package/types/generated/ui/UI.d.ts +6 -3
- package/types/nav.d.ts +6 -0
- package/types/physics.d.ts +140 -45
- package/types/tsl.d.ts +94 -0
- package/types/world.d.ts +489 -122
- package/ui/Focus.js +35 -14
- package/ui/LoadingScreen.js +3 -3
- package/ui/Parts.js +35 -15
- package/ui/UI.js +27 -17
- package/ui/cursor.js +115 -0
- package/ui/defaults.js +15 -11
- package/ui/theme.js +36 -27
- package/ui/touchPart.js +2 -2
- package/core/claims.js +0 -51
- package/core/look/coreParts.js +0 -112
- package/core/look/layers.js +0 -136
- package/core/look/part.js +0 -173
- package/core/look/report.js +0 -79
- package/core/look/write.js +0 -86
- package/core/renamed.js +0 -22
- package/core/styleParts.js +0 -98
- package/docs/api/entities.md +0 -61
- package/docs/api/style.md +0 -134
- package/docs/recipes/09-style-pack.md +0 -169
- package/docs/recipes/35-style-from-reference.md +0 -84
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/38-environment-look-hooks.md +0 -88
- package/docs/recipes/41-thing-registry.md +0 -93
- package/docs/recipes/43-shader-patches-surface-looks.md +0 -135
- package/docs/recipes/44-water-weather-look-hooks.md +0 -135
- package/docs/recipes/48-make-material.md +0 -70
- package/docs/recipes/52-look.md +0 -146
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/styletest/overrides.js +0 -33
- package/examples/styletest/panel.js +0 -135
- package/modules/entities/Entities.js +0 -243
- package/modules/entities/build.js +0 -25
- package/modules/entities/index.js +0 -4
- package/modules/sky/calendar.js +0 -80
- package/modules/sky/cascades.js +0 -125
- package/modules/sky/layers.js +0 -69
- package/modules/sky/look.js +0 -51
- package/modules/sky/lookFog.js +0 -80
- package/modules/sky/lookShadow.js +0 -50
- package/modules/sky/lookSky.js +0 -108
- package/modules/sky/shadow.js +0 -74
- package/modules/terrain/chunkLevels.js +0 -40
- package/modules/terrain/lookGround.js +0 -61
- package/modules/terrain/mountTerrain.js +0 -32
- package/modules/vegetation/lookWind.js +0 -37
- package/modules/water/look.js +0 -80
- package/modules/weather/look.js +0 -75
- package/modules/world/cells.js +0 -42
- package/render/lookSurface.js +0 -161
- package/render/postLook.js +0 -86
- package/render/surface.js +0 -69
- package/types/style.d.ts +0 -643
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Plain-picture materials by name. Flat-illustration technique: MeshLambertMaterial with a flat color, plus an emissive copy of that same color whose
|
|
3
|
+
// strength rises at night. Why: in a flat illustration a night facade is still its own color, only darker and warmer; light from the scene alone would turn it black.
|
|
4
|
+
import { THREE } from '../../../index.js';
|
|
5
|
+
import { PALETTE, nightOf } from './palette.js';
|
|
6
|
+
|
|
7
|
+
export function createMaterials() {
|
|
8
|
+
const mat = /** @type {Record<keyof typeof PALETTE, THREE.MeshLambertMaterial>} */ ({});
|
|
9
|
+
for (const [k, hex] of Object.entries(PALETTE)) mat[/** @type {keyof typeof PALETTE} */ (k)] = new THREE.MeshLambertMaterial({ color: hex, emissive: hex, emissiveIntensity: 0 });
|
|
10
|
+
// things that glow by themselves keep a fixed emissive; the rest get the night base below
|
|
11
|
+
const glowing = new Set(['windowLit', 'lamp']);
|
|
12
|
+
mat.windowLit.emissiveIntensity = 1;
|
|
13
|
+
const lampHead = new THREE.MeshBasicMaterial({ color: PALETTE.lamp });
|
|
14
|
+
return {
|
|
15
|
+
mat: { ...mat, lampHead },
|
|
16
|
+
/** @param {any} signals engine.uniforms */
|
|
17
|
+
update(signals) {
|
|
18
|
+
const night = nightOf(signals.uDaylight.value);
|
|
19
|
+
for (const [k, m] of Object.entries(mat)) if (!glowing.has(k)) m.emissiveIntensity = 0.2 * night;
|
|
20
|
+
mat.windowLit.emissiveIntensity = 0.25 + 0.85 * night;
|
|
21
|
+
lampHead.color.set(night > 0.5 ? 0xfff6dc : PALETTE.lamp);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Plain-picture palette: every color and key value of the picture, one copy; the other files here read it.
|
|
3
|
+
import { THREE } from '../../../index.js';
|
|
4
|
+
|
|
5
|
+
const C = (/** @type {number} */ hex) => new THREE.Color(hex);
|
|
6
|
+
export const PALETTE = {
|
|
7
|
+
wallA: 0xd9774f, wallB: 0xe8b65a, wallC: 0x4f9a94, wallD: 0xe9dcc0, roof: 0x3a2c3e, door: 0x5a3b34,
|
|
8
|
+
road: 0x55506a, walk: 0x8f8794, pole: 0x2d2a38, windowDark: 0x2f3150, windowLit: 0xffd27a, lamp: 0xffe2a0,
|
|
9
|
+
};
|
|
10
|
+
// sky and ambient colors at noon and at night (the picture's own palette; the engine's neutral sky colors only nudge the horizon)
|
|
11
|
+
export const DAY = { top: C(0x7cc4e8), horizon: C(0xf3e6c8), hemiSky: C(0xfff4e0), hemiGround: C(0xb0a090) };
|
|
12
|
+
export const NIGHT = { top: C(0x23285a), horizon: C(0x8a5a78), hemiSky: C(0x9a86b0), hemiGround: C(0x7a5444) };
|
|
13
|
+
// Flat colors should come out as written: no filmic curve squashing the darks
|
|
14
|
+
export const TONE_MAPPING = THREE.NoToneMapping;
|
|
15
|
+
/** 1 until the sun is a bit above the horizon, then falling to 0: what lamps and glow follow @param {number} day uDaylight */
|
|
16
|
+
export const nightOf = day => 1 - Math.min(1, day * 4);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Plain-picture sky and fog: a big gradient sphere drawn behind everything (the engine's dome is hidden; this one is the game's), with the fog in the horizon color.
|
|
3
|
+
import { THREE } from '../../../index.js';
|
|
4
|
+
import { DAY, NIGHT, nightOf } from './palette.js';
|
|
5
|
+
|
|
6
|
+
/** @param {any} engine */
|
|
7
|
+
export function createSky(engine) {
|
|
8
|
+
const { scene } = engine;
|
|
9
|
+
scene.fog = new THREE.Fog(0x000000, 20, 140);
|
|
10
|
+
const skyMat = new THREE.ShaderMaterial({
|
|
11
|
+
side: THREE.BackSide, depthWrite: false, fog: false,
|
|
12
|
+
uniforms: { uTop: { value: new THREE.Color() }, uHorizon: { value: new THREE.Color() } },
|
|
13
|
+
vertexShader: 'varying vec3 vDir; void main(){ vDir = normalize(position); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
|
|
14
|
+
// colorspace_fragment: the uniforms hold linear colors; without it the gradient comes out much darker than the hex values in palette.js
|
|
15
|
+
fragmentShader: `uniform vec3 uTop; uniform vec3 uHorizon; varying vec3 vDir;
|
|
16
|
+
void main(){ float h = smoothstep(-0.05, 0.45, vDir.y); gl_FragColor = vec4(mix(uHorizon, uTop, h), 1.0);
|
|
17
|
+
#include <colorspace_fragment>
|
|
18
|
+
}`,
|
|
19
|
+
});
|
|
20
|
+
const skyDome = new THREE.Mesh(new THREE.SphereGeometry(400, 32, 16), skyMat);
|
|
21
|
+
skyDome.renderOrder = -1;
|
|
22
|
+
scene.add(skyDome);
|
|
23
|
+
if (engine.sky) engine.sky.dome.visible = false;
|
|
24
|
+
|
|
25
|
+
const top = new THREE.Color(), horizon = new THREE.Color(), tmp = new THREE.Color();
|
|
26
|
+
return {
|
|
27
|
+
/** @param {any} signals engine.uniforms */
|
|
28
|
+
update(signals) {
|
|
29
|
+
const day = signals.uDaylight.value, night = nightOf(day), rain = signals.uRain.value;
|
|
30
|
+
top.copy(NIGHT.top).lerp(DAY.top, day);
|
|
31
|
+
horizon.copy(NIGHT.horizon).lerp(DAY.horizon, day).lerp(tmp.copy(signals.uSkyHorizon.value), 0.15); // follow the engine's sky a little (dusk tints)
|
|
32
|
+
if (rain) { top.lerp(tmp.set(0x4a4a58), rain * 0.6); horizon.lerp(tmp.set(0x5a5a66), rain * 0.6); }
|
|
33
|
+
skyMat.uniforms.uTop.value.copy(top); skyMat.uniforms.uHorizon.value.copy(horizon);
|
|
34
|
+
if (scene.fog instanceof THREE.Fog) { scene.fog.color.copy(horizon); scene.fog.near = 30 - 14 * night - rain * 10; scene.fog.far = 160 - 60 * night - rain * 60; }
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Examples `threedog examples list|pull` can copy into a game. The single list: a folder under examples/ is pullable only when it is named here. Summary = the first line of its README.md. files = the game-facing files (the demo page and its main.js stay here). use = the line to print after a pull, paths relative to the pulled folder.",
|
|
3
|
+
"examples": {
|
|
4
|
+
"contact-shadows": {
|
|
5
|
+
"dir": "techniques/contact-shadows",
|
|
6
|
+
"files": [
|
|
7
|
+
"README.md",
|
|
8
|
+
"contactShadows.js"
|
|
9
|
+
],
|
|
10
|
+
"use": "import { applyContactShadows, groundStatic } from './contactShadows.js'; applyContactShadows(engine, { sun, hemi }); // your own three.js lights"
|
|
11
|
+
},
|
|
12
|
+
"day-night-grade": {
|
|
13
|
+
"dir": "techniques/day-night-grade",
|
|
14
|
+
"files": [
|
|
15
|
+
"README.md",
|
|
16
|
+
"picture/index.js",
|
|
17
|
+
"picture/palette.js",
|
|
18
|
+
"picture/lights.js",
|
|
19
|
+
"picture/materials.js",
|
|
20
|
+
"picture/sky.js",
|
|
21
|
+
"picture/post.js"
|
|
22
|
+
],
|
|
23
|
+
"use": "import { createPicture } from './picture/index.js'; const picture = createPicture(engine); // createEngine({ lights: false }); shapes take picture.mat.<name>, picture.addLamp(x, y, z)"
|
|
24
|
+
},
|
|
25
|
+
"interior-light": {
|
|
26
|
+
"dir": "techniques/interior-light",
|
|
27
|
+
"files": [
|
|
28
|
+
"README.md",
|
|
29
|
+
"interiorLight.js"
|
|
30
|
+
],
|
|
31
|
+
"use": "import { exposureZones, windowLight } from './interiorLight.js'; const zones = exposureZones(engine, { hemi, isInside, exposure, ambient }); engine.onFrame(dt => zones.update(dt)); windowLight(engine, { position, lookAt, width, height });"
|
|
32
|
+
},
|
|
33
|
+
"modular-building": {
|
|
34
|
+
"dir": "techniques/modular-building",
|
|
35
|
+
"files": [
|
|
36
|
+
"README.md",
|
|
37
|
+
"kit.js"
|
|
38
|
+
],
|
|
39
|
+
"use": "import { createModularKit } from './kit.js'; const kit = createModularKit({ slots: { wall: yourWallMaterial } }); engine.assets.manifest(kit.pack);"
|
|
40
|
+
},
|
|
41
|
+
"night-lights": {
|
|
42
|
+
"dir": "techniques/night-lights",
|
|
43
|
+
"files": [
|
|
44
|
+
"README.md",
|
|
45
|
+
"nightLights.js"
|
|
46
|
+
],
|
|
47
|
+
"use": "import { createNightLights } from './nightLights.js'; engine.use(lightPool({ spot: 8 })); const lights = createNightLights(engine); lights.addLamp(position, { head: headMaterial }); lights.addGlow(windowMaterial);"
|
|
48
|
+
},
|
|
49
|
+
"outlines-and-rim": {
|
|
50
|
+
"dir": "techniques/outlines-and-rim",
|
|
51
|
+
"files": [
|
|
52
|
+
"README.md",
|
|
53
|
+
"outlines.js"
|
|
54
|
+
],
|
|
55
|
+
"use": "import { trackResolution, addHull, rimPatch } from './outlines.js'; // see README for which route fits your DESIGN.md"
|
|
56
|
+
},
|
|
57
|
+
"procedural-animation": {
|
|
58
|
+
"dir": "techniques/procedural-animation",
|
|
59
|
+
"files": [
|
|
60
|
+
"README.md",
|
|
61
|
+
"proceduralAnim.js",
|
|
62
|
+
"creature.js"
|
|
63
|
+
],
|
|
64
|
+
"use": "import { createProceduralAnimator, KNOBS } from './proceduralAnim.js'; const anim = createProceduralAnimator({ body, legs, tail }); // update it in onFrame (README)"
|
|
65
|
+
},
|
|
66
|
+
"procedural-surface": {
|
|
67
|
+
"dir": "techniques/procedural-surface",
|
|
68
|
+
"files": [
|
|
69
|
+
"README.md",
|
|
70
|
+
"surface.js"
|
|
71
|
+
],
|
|
72
|
+
"use": "import { scaleForCamera, worldVariation, brushTexture, cavity } from './surface.js'; // see README for which route fits your DESIGN.md"
|
|
73
|
+
},
|
|
74
|
+
"rc2d": {
|
|
75
|
+
"dir": "rc2d",
|
|
76
|
+
"files": [
|
|
77
|
+
"README.md",
|
|
78
|
+
"rc2d.js",
|
|
79
|
+
"shaders.js"
|
|
80
|
+
],
|
|
81
|
+
"use": "import { createRadianceCascades2D } from './rc2d.js'; const rc = createRadianceCascades2D(engine, { layer: 5, ambient: 0.15 }); // then put rc.pass in your post chain before the tone curve (README)"
|
|
82
|
+
},
|
|
83
|
+
"stylized-shading": {
|
|
84
|
+
"dir": "techniques/stylized-shading",
|
|
85
|
+
"files": [
|
|
86
|
+
"README.md",
|
|
87
|
+
"shading.js"
|
|
88
|
+
],
|
|
89
|
+
"use": "import { rampTexture, toonMaterial, toonPatch, painterlyMaterial } from './shading.js'; // see README for which route fits your DESIGN.md"
|
|
90
|
+
},
|
|
91
|
+
"sun-and-key-light": {
|
|
92
|
+
"dir": "techniques/sun-and-key-light",
|
|
93
|
+
"files": [
|
|
94
|
+
"README.md",
|
|
95
|
+
"keyLight.js"
|
|
96
|
+
],
|
|
97
|
+
"use": "import { applyKeyFill, aimSun, fitSunShadow } from './keyLight.js'; applyKeyFill({ sun, hemi, scene }, route); aimSun(sun, { elevation, azimuth, camera }); fitSunShadow(sun, { extent }); // your own three.js lights"
|
|
98
|
+
},
|
|
99
|
+
"three-looks": {
|
|
100
|
+
"dir": "techniques/three-looks",
|
|
101
|
+
"files": [
|
|
102
|
+
"README.md",
|
|
103
|
+
"picture/index.js",
|
|
104
|
+
"picture/sun.js",
|
|
105
|
+
"picture/cartoon.js",
|
|
106
|
+
"picture/comic.js",
|
|
107
|
+
"picture/cinematic.js"
|
|
108
|
+
],
|
|
109
|
+
"use": "import { createPicture } from './picture/index.js'; const { materials } = createPicture(engine, 'comic'); // materials by part name; lights, fog and post are set up"
|
|
110
|
+
},
|
|
111
|
+
"webgpu-tsl": {
|
|
112
|
+
"dir": "webgpu-tsl",
|
|
113
|
+
"files": [
|
|
114
|
+
"README.md",
|
|
115
|
+
"picture/index.js",
|
|
116
|
+
"picture/palette.js",
|
|
117
|
+
"picture/lights.js",
|
|
118
|
+
"picture/materials.js",
|
|
119
|
+
"picture/sky.js",
|
|
120
|
+
"picture/post.js"
|
|
121
|
+
],
|
|
122
|
+
"use": "import 'threedog/tsl'; import { createPicture } from './picture/index.js'; const picture = createPicture(engine); // createEngine({ renderer: 'webgpu', lights: false }); shapes take picture.mat.ground, picture.mat.grass, picture.mat.lantern"
|
|
123
|
+
},
|
|
124
|
+
"wet-road": {
|
|
125
|
+
"dir": "techniques/wet-road",
|
|
126
|
+
"files": [
|
|
127
|
+
"README.md",
|
|
128
|
+
"wetRoad.js"
|
|
129
|
+
],
|
|
130
|
+
"use": "import { createWetRoad } from './wetRoad.js'; createWetRoad(engine, { materials: [roadMaterial] });"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":1,"files":{},"ids":{}}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Game map: rc2d (generated, do not edit by hand)
|
|
2
|
+
|
|
3
|
+
> Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /rc2d.html, entry `main.js`.
|
|
4
|
+
> Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
|
|
5
|
+
|
|
6
|
+
Content: none (no content/ folder)
|
|
7
|
+
|
|
8
|
+
## Design decisions (hand-written, from DESIGN.md)
|
|
9
|
+
|
|
10
|
+
None yet, write them in `DESIGN.md` (why it is designed this way, what not to change).
|
|
11
|
+
|
|
12
|
+
## Engine modules (engine.use)
|
|
13
|
+
|
|
14
|
+
- createEngine: { lights: false, ui: { loading: false }, saveKey: 'threedog-rc2d' }
|
|
15
|
+
- fixedCamera ({ shots: { top }, start: 'top' })
|
|
16
|
+
|
|
17
|
+
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
18
|
+
|
|
19
|
+
- cameraRig: `node_modules/threedog/docs/recipes/21-camera.md` · `node_modules/threedog/docs/api/cameraRig.md`
|
|
20
|
+
|
|
21
|
+
Not used yet (check these before writing the system yourself):
|
|
22
|
+
|
|
23
|
+
- inventory: items, stacks, containers and pickups: `inventory()` + key map presets.bindings.inventory, content/items.js (node_modules/threedog/docs/recipes/03-items-pickups.md)
|
|
24
|
+
- collision: walls and blocking for characters: `collision()` (in openWorld), template `collide` (node_modules/threedog/docs/recipes/18-world.md)
|
|
25
|
+
- characters: player and NPC movement, spawn, schedules: `characters()` (in openWorld), content/npcs.js (node_modules/threedog/docs/recipes/02-npc.md)
|
|
26
|
+
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
27
|
+
- interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
|
|
28
|
+
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
29
|
+
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
30
|
+
- templates: reusable objects placed from content: content/templates.js + props { template } (node_modules/threedog/docs/recipes/30-templates.md)
|
|
31
|
+
|
|
32
|
+
## Files
|
|
33
|
+
|
|
34
|
+
content/*.js is content data: how to write it in `node_modules/threedog/docs/recipes/` (02-npc, 03-items-pickups, 04-quests, 20-content-actions-save…).
|
|
35
|
+
|
|
36
|
+
| File | Lines | Description |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| main.js | 56 | @ts-check 2D radiance cascades demo (page /rc2d.html): a top-down street at night. Street lamps, li… |
|
|
39
|
+
| picture/index.js | 19 | @ts-check The picture of the rc2d demo: wiring only. |
|
|
40
|
+
| picture/lights.js | 12 | @ts-check The scene's own light is one dim ambient; everything else on the street is lit by the cas… |
|
|
41
|
+
| picture/materials.js | 19 | @ts-check Materials by name. An emitter is a black surface with an emissive: rc2d.js reads emissive… |
|
|
42
|
+
| picture/palette.js | 16 | @ts-check Every value of the rc2d demo's picture. A street at night: one dim ambient, and the emiss… |
|
|
43
|
+
| picture/post.js | 12 | @ts-check The cascades and the one pass that adds their light to the frame. 'hdr' slot: the light i… |
|
|
44
|
+
| rc2d.js | 188 | @ts-check 2D radiance cascades: screen-space global illumination for top-down and side-view games (… |
|
|
45
|
+
| shaders.js | 145 | GLSL for rc2d.js (2D radiance cascades), GLSL ES 3.0 as three.js compiles a ShaderMaterial under We… |
|
|
46
|
+
|
|
47
|
+
## NPCs (content/npcs.js)
|
|
48
|
+
|
|
49
|
+
(none)
|
|
50
|
+
|
|
51
|
+
## Dialogues (content/dialogues.js, node → destination)
|
|
52
|
+
|
|
53
|
+
(none)
|
|
54
|
+
|
|
55
|
+
## Items (content/items.js)
|
|
56
|
+
|
|
57
|
+
(none)
|
|
58
|
+
|
|
59
|
+
## Quests (content/quests.js)
|
|
60
|
+
|
|
61
|
+
(none)
|
|
62
|
+
|
|
63
|
+
## Trigger zones, level markers, places
|
|
64
|
+
|
|
65
|
+
(none)
|
|
66
|
+
|
|
67
|
+
## Placements (the level is content; counts per content file)
|
|
68
|
+
|
|
69
|
+
- none in content yet: place things with a template (content/templates.js) and a placement (content/props.js)
|
|
70
|
+
|
|
71
|
+
Code that breaks saves or manages world models: none (rule R33).
|
|
72
|
+
|
|
73
|
+
## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
|
|
74
|
+
|
|
75
|
+
(none)
|
|
76
|
+
|
|
77
|
+
## Events the game emits / listens to
|
|
78
|
+
|
|
79
|
+
(none)
|
|
80
|
+
|
|
81
|
+
## Saves
|
|
82
|
+
|
|
83
|
+
- Save prefix saveKey: threedog-rc2d
|
|
84
|
+
- Saved parts of the engine modules (vars, inventory, quests, timers, world...): `threedog catalog` (saves per module)
|
|
85
|
+
|
|
86
|
+
## Style keys
|
|
87
|
+
|
|
88
|
+
(none)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 2D radiance cascades (optional example)
|
|
2
|
+
|
|
3
|
+
Screen-space global illumination for top-down and side-view games: lamps, lit windows and neon signs light the floor around them, walls block
|
|
4
|
+
that light and cast soft shadows, coloured lights mix. It is an example you copy, not an engine module: the engine never imports it and
|
|
5
|
+
nothing installs it. Run it with `npm run dev` and open `/rc2d.html` (`?quality=low|medium|high`, `cascades=auto|1..8`, `interval=4`, `apply=0`).
|
|
6
|
+
|
|
7
|
+
## When to use it
|
|
8
|
+
- A fixed top-down or side-on camera (orthographic or nearly so) where light should spread over the floor and stop at walls, with many
|
|
9
|
+
or large light shapes (a whole neon bar is one light, at no extra cost per light).
|
|
10
|
+
- Not for a free 3D camera: it only knows what is on screen, in the screen plane. A light off screen gives no light, and height is ignored.
|
|
11
|
+
For a few point lights in 3D, three.js lights (`engine.lightPool` for many) are cheaper and correct.
|
|
12
|
+
|
|
13
|
+
## How to copy it into a game
|
|
14
|
+
1. Copy `rc2d.js` and `shaders.js` into your game (`threedog examples pull rc2d`, or by hand). They import only `three` and `three/addons`.
|
|
15
|
+
2. Put what light sees on one layer: emitters (any mesh with `material.emissive`, strength `emissiveIntensity`) and occluders (meshes
|
|
16
|
+
without emissive). `mesh.layers.enable(5)` keeps them visible to the normal camera too. The floor stays off the layer: it receives light.
|
|
17
|
+
3. `const rc = createRadianceCascades2D(engine, { layer: 5, ambient: 0.15 })`. Each frame it renders in `engine.onRender`. `rc.pass` is a plain
|
|
18
|
+
three.js `ShaderPass` that adds the light to the frame, `color * (1 + light / ambient)`: put it in your post chain before the tone curve, as
|
|
19
|
+
this example's `picture/post.js` does. Set `ambient` to how bright your scene's own light already is, so the light lands on the surface colour
|
|
20
|
+
(albedo = color / ambient).
|
|
21
|
+
4. Or leave `rc.pass` out and read `rc.texture` (linear light per screen uv) in your own materials. `rc.target` is its render target.
|
|
22
|
+
5. `rc.describe()` (size, cascades, intervals, targets), `rc.resize()` (also checked every frame), `rc.dispose()` (frees every target and the
|
|
23
|
+
pass; take the pass out of the chain first).
|
|
24
|
+
|
|
25
|
+
Colours and strengths are the game's: change a lamp's `emissiveIntensity` and the light follows the same frame (flicker, day / night).
|
|
26
|
+
`threedog examples pull rc2d` copies the two files and this README into the game (`techniques/rc2d/`), or copy them by hand.
|
|
27
|
+
|
|
28
|
+
The demo's own picture (ambient light, emitter colours, tone curve, the flicker) is plain three.js in `picture/`; only `rc2d.js` and `shaders.js` travel.
|
|
29
|
+
|
|
30
|
+
## Parameters (all in `RC2D_DEFAULTS` / `RC2D_QUALITY` at the top of `rc2d.js`)
|
|
31
|
+
| Option | Default | Meaning |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `quality` | `'medium'` | `low` / `medium` / `high`: resolution 1/4, 1/2, 1x of the canvas (CSS pixels) and 16 / 24 / 32 march steps per ray |
|
|
34
|
+
| `cascades` | `'auto'` | how many cascades; auto = enough for the longest ray to cross the screen diagonal |
|
|
35
|
+
| `interval` | `4` | cascade 0's ray length in RC pixels; each cascade above is 4x longer. Larger = smoother, softer contact light |
|
|
36
|
+
| `layer` | `5` | the three.js layer of emitters and occluders |
|
|
37
|
+
| `ambient` | `1` | the scene's own light level, see step 3 |
|
|
38
|
+
|
|
39
|
+
## Cost (1280x720 canvas, measured 2026-11-02, the demo scene)
|
|
40
|
+
- GPU (AMD Radeon 780M integrated, D3D11): frame 3.6 ms without, about 15.8 ms with `medium`, 32.6 ms with `high`; `low` about 14 ms
|
|
41
|
+
(at low the fixed cost of ~20 passes dominates). Use `low` or `medium` on integrated graphics.
|
|
42
|
+
- Software rendering (headless SwiftShader): about 16x a plain frame at `medium`; only for tests.
|
|
43
|
+
- Memory: about 10 half-float targets the size of the RC resolution (two float targets for the jump flood).
|
|
44
|
+
|
|
45
|
+
## Limits
|
|
46
|
+
- Screen space: nothing off screen contributes, and what moves off screen stops lighting.
|
|
47
|
+
- Occluder tops stay as the scene lights them (rays start inside them and see no light); light is 2D, so a lamp on a roof lights the
|
|
48
|
+
floor beside the building as if it stood on the ground.
|
|
49
|
+
- Thin occluders under about one RC pixel (2 screen pixels at `medium`) can leak.
|
|
50
|
+
- The merge uses the paper's "bilinear fix" (4 rays per merge) against leaks and rings; it is the main cost.
|
|
51
|
+
|
|
52
|
+
## Sources
|
|
53
|
+
Written from the public descriptions, no code copied: Alexander Sannikov, "Radiance Cascades: A Novel Approach to Calculating Global
|
|
54
|
+
Illumination" (2023); jason.today, "Building Real-Time Global Illumination" (parts 1 and 2: jump flood, distance field, cascades);
|
|
55
|
+
GM Shaders, "Radiance Cascades".
|
|
56
|
+
|
|
57
|
+
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).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// 2D radiance cascades demo (page /rc2d.html): a top-down street at night. Street lamps, lit windows and a neon bar are emissive meshes; building
|
|
3
|
+
// blocks and a wall are occluders. Both are on the light layer, which is all rc2d.js looks at; the floor is not, so it only receives light.
|
|
4
|
+
// URL: ?quality=low|medium|high &cascades=auto|1..8 &interval=4 &apply=0 (no post pass: the frame stays as the scene's own light draws it).
|
|
5
|
+
// Test page for tests/specs/rc2d.mjs: window.rc2dTest = { rc, picture, THREE, points } (points: world spots the spec reads the light at).
|
|
6
|
+
// Shapes only here; the whole picture is picture/.
|
|
7
|
+
import { createEngine, fixedCamera, THREE } from 'threedog';
|
|
8
|
+
import { createPicture } from './picture/index.js';
|
|
9
|
+
|
|
10
|
+
const url = new URLSearchParams(location.search);
|
|
11
|
+
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, ui: { loading: false }, saveKey: 'threedog-rc2d' });
|
|
12
|
+
// projection / size per shot work at run time (recipes/21-camera.md) but CameraShot does not declare them yet, hence the cast
|
|
13
|
+
const top = /** @type {any} */ ({ position: [0, 40, 0.001], lookAt: [0, 0, 0], projection: 'orthographic', size: 30 });
|
|
14
|
+
engine.use(fixedCamera({ shots: { top }, start: 'top' }));
|
|
15
|
+
|
|
16
|
+
const cascades = url.get('cascades');
|
|
17
|
+
const picture = createPicture(engine, {
|
|
18
|
+
quality: url.get('quality') ?? 'medium',
|
|
19
|
+
cascades: cascades && cascades !== 'auto' ? Number(cascades) : 'auto',
|
|
20
|
+
interval: Number(url.get('interval') ?? 4),
|
|
21
|
+
apply: url.get('apply') !== '0',
|
|
22
|
+
});
|
|
23
|
+
const { mat, layer, rc } = picture;
|
|
24
|
+
|
|
25
|
+
const floor = new THREE.Mesh(new THREE.PlaneGeometry(120, 120), mat.floor);
|
|
26
|
+
floor.rotation.x = -Math.PI / 2;
|
|
27
|
+
engine.scene.add(floor);
|
|
28
|
+
|
|
29
|
+
/** A box seen from above: [x0, z0, x1, z1] in metres; on the light layer, so it blocks (and shines when emissive) */
|
|
30
|
+
function block(/** @type {number[]} */ [x0, z0, x1, z1], /** @type {THREE.Material} */ material, height = 4) {
|
|
31
|
+
const m = new THREE.Mesh(new THREE.BoxGeometry(x1 - x0, height, z1 - z0), material);
|
|
32
|
+
m.position.set((x0 + x1) / 2, height / 2, (z0 + z1) / 2);
|
|
33
|
+
m.layers.enable(layer);
|
|
34
|
+
engine.scene.add(m);
|
|
35
|
+
return m;
|
|
36
|
+
}
|
|
37
|
+
for (const r of [[-14, -11, -4, -3], [3, -13, 13, -5], [-14, 4, -6, 12], [2, 3.7, 10, 4.3], [2, 3.7, 2.6, 11], [14, 2, 17, 9]]) block(r, mat.wall);
|
|
38
|
+
// pillars along the street: small occluders that cast soft shadows from the lamps
|
|
39
|
+
for (let x = -10; x <= 10; x += 5) block([x - 0.3, 0.7, x + 0.3, 1.3], mat.wall, 2);
|
|
40
|
+
|
|
41
|
+
// the third lamp is the one that flickers
|
|
42
|
+
[[7, 2.2], [-8, 2], [-2, -5], [-2, 14]].forEach(([x, z], i) => {
|
|
43
|
+
const m = new THREE.Mesh(new THREE.CylinderGeometry(0.45, 0.45, 0.2, 20), i === 2 ? mat.flicker : mat.lamp);
|
|
44
|
+
m.position.set(x, 4.5, z);
|
|
45
|
+
m.layers.enable(layer);
|
|
46
|
+
engine.scene.add(m);
|
|
47
|
+
});
|
|
48
|
+
// lit windows on the south face of the first block, a neon bar on the west face of the second
|
|
49
|
+
for (let x = -13; x < -5; x += 3) block([x, -3, x + 1.6, -2.75], mat.window, 3);
|
|
50
|
+
block([2.75, -12, 3, -6], mat.neon, 3);
|
|
51
|
+
|
|
52
|
+
// lit: 1 m from lamp 0; open: 4 m from it with nothing between; shadow: 4 m from it behind the wall at z 3.7..4.3
|
|
53
|
+
const points = { lit: [7, 3], open: [7, -1.8], shadow: [7, 6.2] };
|
|
54
|
+
Object.assign(window, { engine, rc2dTest: { rc, picture, THREE, points } });
|
|
55
|
+
engine.start();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The picture of the rc2d demo: wiring only.
|
|
3
|
+
import { EXPOSURE, LIGHT_LAYER, TONE_MAPPING } from './palette.js';
|
|
4
|
+
import { createLights } from './lights.js';
|
|
5
|
+
import { createMaterials } from './materials.js';
|
|
6
|
+
import { createPost } from './post.js';
|
|
7
|
+
|
|
8
|
+
/** Returns { mat, layer, rc, remove() }; remove() takes the pass out of the chain and frees the cascades. @param {any} engine @param {Parameters<typeof createPost>[1]} o */
|
|
9
|
+
export function createPicture(engine, o) {
|
|
10
|
+
engine.renderer.toneMapping = TONE_MAPPING;
|
|
11
|
+
engine.renderer.toneMappingExposure = EXPOSURE;
|
|
12
|
+
createLights(engine);
|
|
13
|
+
const materials = createMaterials();
|
|
14
|
+
// hooked before createPost: the hooks run in order and the cascades' own one must read this frame's flicker
|
|
15
|
+
engine.onRender(() => materials.update(engine.clock.now));
|
|
16
|
+
const post = createPost(engine, o);
|
|
17
|
+
return { mat: materials.mat, layer: LIGHT_LAYER, rc: post.rc, remove: post.remove };
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The scene's own light is one dim ambient; everything else on the street is lit by the cascades.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
import { AMBIENT } from './palette.js';
|
|
5
|
+
|
|
6
|
+
/** @param {any} engine */
|
|
7
|
+
export function createLights(engine) {
|
|
8
|
+
const ambient = new THREE.AmbientLight(0xffffff, AMBIENT);
|
|
9
|
+
engine.scene.add(ambient);
|
|
10
|
+
return { ambient };
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Materials by name. An emitter is a black surface with an emissive: rc2d.js reads emissive * emissiveIntensity every frame, so a write here is
|
|
3
|
+
// all it takes for the light to follow. The flickering lamp has its own material, the other lamps keep theirs steady.
|
|
4
|
+
import { THREE } from 'threedog';
|
|
5
|
+
import { COLORS, FLICKER, GLOW } from './palette.js';
|
|
6
|
+
|
|
7
|
+
export function createMaterials() {
|
|
8
|
+
const flat = (/** @type {number} */ color) => new THREE.MeshLambertMaterial({ color });
|
|
9
|
+
const glow = (/** @type {number} */ emissive, /** @type {number} */ emissiveIntensity) =>
|
|
10
|
+
new THREE.MeshLambertMaterial({ color: COLORS.glowBase, emissive, emissiveIntensity });
|
|
11
|
+
const flicker = glow(COLORS.lamp, GLOW.lamp), [fast, slow] = FLICKER.rates;
|
|
12
|
+
return {
|
|
13
|
+
mat: { floor: flat(COLORS.floor), wall: flat(COLORS.wall), lamp: glow(COLORS.lamp, GLOW.lamp), flicker,
|
|
14
|
+
window: glow(COLORS.window, GLOW.window), neon: glow(COLORS.neon, GLOW.neon) },
|
|
15
|
+
/** @param {number} now seconds */
|
|
16
|
+
update(now) { flicker.emissiveIntensity = GLOW.lamp * (1 - FLICKER.depth + FLICKER.depth * Math.sin(now * fast) * Math.sin(now * slow)); },
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Every value of the rc2d demo's picture. A street at night: one dim ambient, and the emissive shapes rc2d.js turns into light.
|
|
3
|
+
import { THREE } from 'threedog';
|
|
4
|
+
|
|
5
|
+
/** The scene's own light. rc2d divides by it to get albedo back, so the same number feeds the light and the cascades */
|
|
6
|
+
export const AMBIENT = 0.12;
|
|
7
|
+
/** The three.js layer rc2d.js looks at: emitters and occluders are on it, the floor is not, so the floor only receives light */
|
|
8
|
+
export const LIGHT_LAYER = 5;
|
|
9
|
+
export const COLORS = { floor: 0x8a8a90, wall: 0x6d6258, glowBase: 0x000000, lamp: 0xffb060, window: 0x7fb0ff, neon: 0xff40c0 };
|
|
10
|
+
/** emissiveIntensity of each emitter: this is what sets how far its light reaches */
|
|
11
|
+
export const GLOW = { lamp: 6, window: 2, neon: 3 };
|
|
12
|
+
/** The flickering lamp: its intensity swings by depth around 1 - depth, as the product of two sines at these rates */
|
|
13
|
+
export const FLICKER = { depth: 0.2, rates: [9, 2.3] };
|
|
14
|
+
export const TONE_MAPPING = THREE.AgXToneMapping;
|
|
15
|
+
export const EXPOSURE = 1;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The cascades and the one pass that adds their light to the frame. 'hdr' slot: the light is linear, so it goes in before the tone curve.
|
|
3
|
+
import { createRadianceCascades2D } from '../rc2d.js';
|
|
4
|
+
import { AMBIENT, LIGHT_LAYER } from './palette.js';
|
|
5
|
+
|
|
6
|
+
/** @param {any} engine @param {{ quality: any, cascades: number | 'auto', interval: number, apply: boolean }} o apply false: the frame stays as the scene's own light draws it */
|
|
7
|
+
export function createPost(engine, { apply, ...options }) {
|
|
8
|
+
const rc = createRadianceCascades2D(engine, { layer: LIGHT_LAYER, ambient: AMBIENT, ...options });
|
|
9
|
+
const handle = apply ? engine.post.add(rc.pass, { name: 'rc2d', slot: 'hdr' }) : null;
|
|
10
|
+
return { rc, remove() { handle?.remove(); rc.dispose(); } };
|
|
11
|
+
}
|