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
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
# Writing shader patches and surface looks
|
|
2
|
-
|
|
3
|
-
The default surface is flat: `lambert` plus vertex colors. This page is the three exits for changing that, from simplest to most open:
|
|
4
|
-
**1. parameters** in the material spec (nothing changes until you write them), **2. a named patch or GLSL snippet** you write, **3. your own
|
|
5
|
-
material** (a function or instance). Use the first that does the job.
|
|
6
|
-
|
|
7
|
-
## Material roles are open
|
|
8
|
-
`style.materials` maps a role name to a material. The engine asks for `default terrain vegetation character water pickup prop`; **any other
|
|
9
|
-
name is fine** (`cloth`, `metal`, `glass`): code asks for it with `engine.makeMaterial('cloth', { color })`, an unlisted role uses `materials.default`.
|
|
10
|
-
Only a name very close to an existing one (`props`, `charcter`) warns, as a probable typo.
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
materials: {
|
|
14
|
-
default: { type: 'lambert' },
|
|
15
|
-
cloth: { type: 'standard', roughness: 1, detail: { noise: 'grain', projection: 'triplanar', scale: 3, normal: 0.01 } },
|
|
16
|
-
glass: { type: 'physical', transmission: 1, roughness: 0.05, thickness: 0.2 },
|
|
17
|
-
rock: { type: 'standard', map: 'rock.png', normalMap: 'rock_n.png', roughnessMap: 'rock_r.png', repeat: 4 },
|
|
18
|
-
prop: (params, purpose, engine) => new THREE.MeshMatcapMaterial({ matcap: texture, color: params.color }), // any Material
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
A **function** gets `(params, purpose, engine)`: the call's `params` (color, vertexColors...), the role asked for, and the engine; it returns any
|
|
22
|
-
three.js Material. A **spec** is plain data (`type: lambert | phong | standard | physical | toon | basic` plus material properties), layered over
|
|
23
|
-
`materials.default` when that is a spec too; keys the material has are set, spec keys below are handled by the engine.
|
|
24
|
-
|
|
25
|
-
## Exit 1: parameters in the spec
|
|
26
|
-
The accepted spec keys, texture slots, `repeat` / `wrap` and who wins between pack and call: recipe 48. How texture names load: the engine
|
|
27
|
-
fetches the asset with `engine.assets.texture` (`map`, `emissiveMap` sRGB, the other slots linear), sets anisotropy, wrap and repeat, and a neutral
|
|
28
|
-
stand-in (flat normal, white) sits in the slot until the image arrives. `style check` verifies the names against the asset pack. This page
|
|
29
|
-
covers the keys that add shader code: `detail`, `lighting`, toon `ramp`, seasons.
|
|
30
|
-
|
|
31
|
-
**`detail`**: a noise pattern, a texture or your own GLSL laid over the surface in world space (needs no UVs). Off unless written; every number is a uniform, so
|
|
32
|
-
100 materials with different `scale` / `strength` / `direction` compile **one** program (tested: 8 variants, +0 programs).
|
|
33
|
-
|
|
34
|
-
| key | meaning |
|
|
35
|
-
|---|---|
|
|
36
|
-
| `noise` | `'grain'` (default) `'paper'` `'stroke'` `'dabs'` (soft oval dabs, no direction); or `texture: 'name'` (asset name or a Texture), or `glsl` (below) |
|
|
37
|
-
| `projection` | `'world'` top-down (default, fine for ground) or `'triplanar'` (walls, rocks, characters) |
|
|
38
|
-
| `scale` `strength` | repeats per meter (0.25), color effect 0-1 (0.35) |
|
|
39
|
-
| `mode` `tint` | `'multiply'` (default) `'add'` `'mix'`; tint colors the sample |
|
|
40
|
-
| `direction` `stretch` | degrees; stretch along it (strokes default 6): a brush stroke is `{ noise: 'stroke', direction: 20 }` |
|
|
41
|
-
| `octaves` | 1-4 noise layers (2) |
|
|
42
|
-
| `normal` | relief height in meters (bumps the normal; 0 = off) |
|
|
43
|
-
| `roughness` | amount the sample moves roughness (`standard` / `physical`) |
|
|
44
|
-
| `fade` | default `true`: the effect fades out where its pattern is smaller than a pixel (far, grazing), so it does not shimmer; `false` keeps it |
|
|
45
|
-
|
|
46
|
-
Which channels (color, normal, roughness) are on is fixed when the material is made (it is part of the program); the numbers can change any time.
|
|
47
|
-
The ground takes the same object as `style.terrain.detail` / `look.ground.set({ detail })`; which detail suits which ground: recipe 53.
|
|
48
|
-
|
|
49
|
-
**`lighting`** shapes the light after it is summed. three has no "shadow color": a shadow only removes the sun's light. The patch reads the first
|
|
50
|
-
directional light (the sun; three sorts shadow casters first) and its shadow value for the pixel:
|
|
51
|
-
|
|
52
|
-
| key | effect |
|
|
53
|
-
|---|---|
|
|
54
|
-
| `shadowTint: { color, strength, soft }` | shadowed or sun-averted parts shift hue towards `color`, same brightness. `soft` = terminator width |
|
|
55
|
-
| `rim: { color, strength, power, shadowSide }` | fresnel edge light added to the ambient part; `shadowSide: 1` = only away from the sun (a cool back light) |
|
|
56
|
-
| `wrap` | half-lambert: `(n.l + wrap) / (1 + wrap)` from the sun |
|
|
57
|
-
|
|
58
|
-
Limits: one directional light; point and spot lights are untouched; cloud shadows do not count as shadow for `shadowTint`; `wrap` does not follow a toon
|
|
59
|
-
ramp. Put it on every lit material of the pack with `style.lighting` (same keys; a material's own `lighting` wins, `lighting: false` opts out).
|
|
60
|
-
**Toon** takes `ramp: [0.3, 0.65, 1]` (grays = light strength per band) or colors (a cool band in the shade), `soften: 0..1` melts the bands; `steps` still works.
|
|
61
|
-
|
|
62
|
-
**Seasons**: `style.seasons: { mode: 'mix', strength: 0.5, autumn: { foliage: 0xd98a3a } }`. `multiply` (default) multiplies the color on, which turns
|
|
63
|
-
orange-on-green muddy; `mix` moves the surface `strength` of the way to the color.
|
|
64
|
-
|
|
65
|
-
## Exit 2: your own GLSL
|
|
66
|
-
`detail.glsl` replaces the noise: `vec4 threedogDetailSample(vec2 p)` returns `vec4(color, height 0-1)`; `p` is already scaled, turned, stretched;
|
|
67
|
-
`uniforms: { uCells: 6 }` (numbers, colors, arrays, textures) are in scope; `threedogDetailFootprint` is one pixel in pattern units (`fade` uses it; read it to fade your own sample). `lighting.glsl` replaces the three light effects:
|
|
68
|
-
`void threedogLighting(inout ReflectedLight light, vec3 normal, vec3 viewDir, vec3 sunDir, float sunShadow, vec3 albedo)` (view space; `sunShadow` 1 lit,
|
|
69
|
-
0 shadowed; change `light.directDiffuse` / `indirectDiffuse`, the lights are already summed).
|
|
70
|
-
|
|
71
|
-
For anything else write a **named patch** and add it with `applyEffects(material, { patches: [...] })` (or in a `materials` function):
|
|
72
|
-
```js
|
|
73
|
-
{ name: 'fuzz', // one name per effect; the same name again replaces it
|
|
74
|
-
cacheKey: 'v1', // changes whenever the GLSL text changes, never for uniform values
|
|
75
|
-
uniforms: { uFuzz: { value: 0.3 } }, // numbers live here, so materials with different values share a program
|
|
76
|
-
needs: { patches: ['world'], data: ['vertexColors'] }, // 'world' gives `varying vec3 vThreedogWorld`; data = program inputs you read
|
|
77
|
-
conflicts: ['wind'], // patches it cannot share a material with (checked when added)
|
|
78
|
-
shadow: false, // true = the patch MOVES vertices, so its vertex code also runs in the shadow passes (wind does)
|
|
79
|
-
glsl: { fragment: { pars: 'uniform float uFuzz;', // pars = declarations at the top
|
|
80
|
-
color_fragment: 'diffuseColor.rgb *= 1.0 - uFuzz * 0.5;' } } } // chunk name -> code placed after `#include <chunk>`
|
|
81
|
-
```
|
|
82
|
-
Patches on one material must agree. Each patch declares what it relies on, and a bad combination throws when it is added (or logs once at compile):
|
|
83
|
-
|
|
84
|
-
| Field | Meaning | Checked |
|
|
85
|
-
|---|---|---|
|
|
86
|
-
| `needs.data` | Program inputs the code reads: `'instancing'`, `'instancingColor'`, `'vertexColors'`, `'skinning'`, `'batching'` | when the program compiles (console.error once per material) |
|
|
87
|
-
| `needs.patches` | Patches it builds on, e.g. `['world']` for the `vThreedogWorld` varying (world position; `applyEffects` adds `world` itself when a patch needs it) | when added |
|
|
88
|
-
| `conflicts` | Patch names it cannot share a material with | when added, both ways |
|
|
89
|
-
| `uniforms` | A uniform name belongs to one patch; share `engine.uniforms` (`uTime`, `uWind`, `uCloud`...) instead of making your own `uTime` | when added |
|
|
90
|
-
| `shadow` | Render steps: without it the color pass only; `true` also runs its vertex code in the depth (sun / spot shadows) and distance (point-light shadows) passes | - |
|
|
91
|
-
| `cacheKey` | Changes whenever the GLSL text changes (defines, branches), never for uniform values; the program key joins every patch's `name=cacheKey` in order | same name + cacheKey with different code throws |
|
|
92
|
-
```js
|
|
93
|
-
applyEffects(mat, { wind: 0.03, season: 'foliage', patches: [{ name: 'ripple', needs: { patches: ['world'] }, conflicts: ['wind'],
|
|
94
|
-
glsl: { fragment: { color_fragment: 'diffuseColor.rgb *= 0.9 + 0.1 * sin(vThreedogWorld.x);' } } }] }); // throws: 'wind' and 'ripple' cannot be combined
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
A chunk value may be `{ before, after }`. A missing chunk throws when the patch is added (`strict`), not as a silent no-op. Chunk names in three **0.187**
|
|
98
|
-
(read from `three/src/renderers/shaders`), in main-body order:
|
|
99
|
-
|
|
100
|
-
| stage | chunk | what is in scope after it |
|
|
101
|
-
|---|---|---|
|
|
102
|
-
| vertex | `begin_vertex` | `transformed` (object space; wind moves it here) |
|
|
103
|
-
| vertex | `project_vertex` | `mvPosition`, `gl_Position` |
|
|
104
|
-
| vertex | `worldpos_vertex` | `worldPosition` (only when shadows, env maps or transmission need it) |
|
|
105
|
-
| fragment | `map_fragment` `color_fragment` | `diffuseColor` (rgb after the map, then the vertex colors) |
|
|
106
|
-
| fragment | `roughnessmap_fragment` `metalnessmap_fragment` | `roughnessFactor`, `metalnessFactor` (standard / physical) |
|
|
107
|
-
| fragment | `normal_fragment_begin` `normal_fragment_maps` | `normal` (view space), `faceDirection`; `vViewPosition` = minus the view-space position |
|
|
108
|
-
| fragment | `emissivemap_fragment` | `totalEmissiveRadiance` |
|
|
109
|
-
| fragment | `lights_fragment_begin` ... `lights_fragment_end` | `reflectedLight.directDiffuse / indirectDiffuse / directSpecular / indirectSpecular`; after `_end` they are final |
|
|
110
|
-
| fragment | `opaque_fragment` | `outgoingLight` and `gl_FragColor`; (called `output_fragment` before r154) |
|
|
111
|
-
|
|
112
|
-
`MeshBasicMaterial` has no lights, so no `lights_*` chunks; `lambert` has no roughness chunks. `vThreedogWorld` is the world position (instancing and
|
|
113
|
-
batching included). Meshes with several patches stack them in the order added, in one program per distinct combination.
|
|
114
|
-
|
|
115
|
-
## Exit 3: your own material
|
|
116
|
-
A `materials` entry that is a Material instance (cloned per use, its patches kept) or a function returning one; `style.lighting` still shapes plain three.js
|
|
117
|
-
lit materials returned by it. Nothing else is applied: textures, `detail` and `lighting` keys are only read on specs, so call `applyEffects(material,
|
|
118
|
-
{ detail, patches })` yourself.
|
|
119
|
-
|
|
120
|
-
## Three complete looks (different directions, same mechanism)
|
|
121
|
-
```js
|
|
122
|
-
const looks = {
|
|
123
|
-
// metal, realistic PBR: a texture set does the work; a fine world-space grain moves only the roughness (smudges), not the color
|
|
124
|
-
metal: { type: 'standard', metalness: 1, roughness: 0.35, map: 'steel.png', normalMap: 'steel_n.png', roughnessMap: 'steel_r.png', repeat: 2,
|
|
125
|
-
detail: { noise: 'grain', projection: 'triplanar', scale: 6, strength: 0, roughness: 0.25 } },
|
|
126
|
-
// poster, flat and unlit: no light or shadow, the color is exactly the given one; a faint grain keeps large areas from looking empty
|
|
127
|
-
poster: { type: 'basic', detail: { noise: 'paper', scale: 2, strength: 0.12 } },
|
|
128
|
-
// leaf, stylized: toon bands, directional strokes along the wind, cool shade, a rim on the side away from the sun
|
|
129
|
-
leaf: { type: 'toon', ramp: [0.45, 0.8, 1], soften: 0.25, detail: { noise: 'stroke', direction: 35, scale: 1.2, strength: 0.3, mode: 'add' },
|
|
130
|
-
lighting: { shadowTint: { color: 0x5a6fb0, strength: 0.7 }, rim: { color: 0xb8e08a, strength: 0.3, shadowSide: 1 } } },
|
|
131
|
-
};
|
|
132
|
-
```
|
|
133
|
-
Fetch them with `engine.makeMaterial('metal')`. Check a pack with `threedog style check`; the pixel and program-count guarantees are in `tests/specs/surface.mjs`.
|
|
134
|
-
|
|
135
|
-
To change these from code at run time (`materials`, `surface`, `ground`, `wind` look parts), see recipe 52.
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
# Water and rain/snow looks: depth color, foam, reflections, particles, lightning
|
|
2
|
-
|
|
3
|
-
For an AI that wants water or weather particles to look a way the defaults do not. Water basics are the `water()` module and `style.water` (color, opacity, waves,
|
|
4
|
-
fresnel, normal map); lights, fog and the sky are in `38-environment-look-hooks.md`. A style that writes none of the keys below keeps the built-in
|
|
5
|
-
shaders and pays nothing for them (`tests/specs/appearance-water.mjs`). Three exits: a parameter, a GLSL function you replace, or your own material.
|
|
6
|
-
At run time the same keys go through `engine.look.water` / `engine.look.weather` (recipe 52).
|
|
7
|
-
|
|
8
|
-
## Water: depth color and crest foam (parameters)
|
|
9
|
-
```js
|
|
10
|
-
water: {
|
|
11
|
-
depthColor: { shallow: 0x55ddcc, deep: 0x082040 }, // by 'view' (default): shallow looking down, deep toward the horizon
|
|
12
|
-
depthColor: { shallow: 0x7fe0d0, deep: 0x0a3050, by: 'wave', curve: 1.5 }, // shallow on the crests, deep in the troughs
|
|
13
|
-
foam: { color: 0xffffff, start: 0.55, end: 0.85, opacity: 1 }, // white on the wave tops; foam: true = these defaults
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
- `depthColor` replaces `color` (opacity stays). `'view'` is a fresnel-style blend by the view angle, `'wave'` blends by the wave height; neither
|
|
17
|
-
needs a depth texture. `curve` bends the blend (above 1 keeps more of the shallow color).
|
|
18
|
-
- `foam` uses the same wave height as the vertices: `start` / `end` are fractions of the peak height (`glsl.waveMax`, default 0.29) where
|
|
19
|
-
foam begins and is full. Foam is opaque even on transparent water. All numbers are uniforms (`engine.water.material.uniforms.uFoamStart.value`).
|
|
20
|
-
- **Shore foam is not built in.** An accurate foam line where water meets land needs the distance to the ground under each pixel: a depth
|
|
21
|
-
pre-pass (a `DepthTexture` render target of the scene without water) or a terrain height lookup, both cost a full extra pass or a texture
|
|
22
|
-
read per pixel. Do it yourself through `style.water.material`: render the scene's depth to a target before the water draws
|
|
23
|
-
(`material.onBeforeRender`), pass it as a uniform, and in your fragment compare the scene depth with this fragment's depth, both turned into meters with three's
|
|
24
|
-
`perspectiveDepthToViewZ` (`#include <packing>`); foam
|
|
25
|
-
where the difference is under about a meter. A cheap fake: `engine.addWaterBody` lakes have known radii, so a surface function can foam the
|
|
26
|
-
ring `length(worldPos.xz - center) > radius - 1.0` (pass the center and radius as `uniforms`).
|
|
27
|
-
|
|
28
|
-
## Water: replace the wave or the surface function (GLSL)
|
|
29
|
-
```js
|
|
30
|
-
water: {
|
|
31
|
-
uniforms: { uBands: 4, uDeep: [0.05, 0.2, 0.4] }, // numbers, colors, [x, y(, z, w)] arrays, textures; in both stages
|
|
32
|
-
glsl: {
|
|
33
|
-
wave: `float threedogWaterWave(vec3 p, float t) { // p = world position * waveScale, t = time * waveSpeed
|
|
34
|
-
return sin(p.x * 0.5 + t) * 0.2 + sin(p.z * 0.8 - t * 1.3) * 0.1; }`, // height before waveHeight
|
|
35
|
-
waveMax: 0.3, // its peak: foam and depthColor 'wave' divide by it
|
|
36
|
-
surface: `vec4 threedogWaterSurface(vec4 base, float wave, float facing, vec3 worldPos, float time) {
|
|
37
|
-
float b = floor(facing * uBands) / uBands; // toon bands by view angle
|
|
38
|
-
return vec4(mix(uDeep, vec3(0.4, 0.8, 0.9), b), base.a); }`,
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
- `wave` replaces only the vertex motion; the rest of the built-in water stays. Copying the default
|
|
43
|
-
(`modules/water/surface.js`, `WAVE`) draws pixel for pixel the same.
|
|
44
|
-
- `surface` runs before lighting: `base` is the material color and opacity, `wave` the height at this point, `facing` 1 looking straight down and 0
|
|
45
|
-
at grazing angles, `worldPos` the moved surface point. The result is lit, fogged and gets the grazing-angle fresnel like the default water.
|
|
46
|
-
With `surface` written, `depthColor` / `foam` are not added (your function is the whole surface).
|
|
47
|
-
- A wrong signature throws with the right one; misspelled keys warn with the near name; `threedog style check` knows these keys.
|
|
48
|
-
|
|
49
|
-
## Water: your own material (reflections, refraction)
|
|
50
|
-
`style.water.material: (engine, { uniforms, waves, surface, normalMap }) => Material` replaces the whole water material; the engine still builds
|
|
51
|
-
the meshes, snaps the sea to the focus and scrolls the normal map. Reflections and refraction are not built in (each one renders the scene a
|
|
52
|
-
second time). three's `Reflector` addon works through this exit; the engine water is pre-rotated geometry, so the mirror gets the mesh's
|
|
53
|
-
matrix turned into the XY plane it expects:
|
|
54
|
-
|
|
55
|
-
```js
|
|
56
|
-
import * as THREE from 'three';
|
|
57
|
-
import { Reflector } from 'three/addons/objects/Reflector.js';
|
|
58
|
-
|
|
59
|
-
water: { material: () => {
|
|
60
|
-
const mirror = new Reflector(new THREE.PlaneGeometry(1, 1), { textureWidth: 512, textureHeight: 512, color: 0x88aacc }), m = mirror.material;
|
|
61
|
-
const toPlane = new THREE.Matrix4().makeRotationX(-Math.PI / 2), back = new THREE.Matrix4().makeRotationX(Math.PI / 2);
|
|
62
|
-
let busy = false;
|
|
63
|
-
m.onBeforeRender = (renderer, scene, camera, geometry, mesh) => {
|
|
64
|
-
if (busy) return; busy = true; // the mirror's own render must not reflect again
|
|
65
|
-
mirror.matrixWorld.copy(mesh.matrixWorld).multiply(toPlane);
|
|
66
|
-
mesh.visible = false; mirror.onBeforeRender(renderer, scene, camera); mesh.visible = true;
|
|
67
|
-
m.uniforms.textureMatrix.value.multiply(back); // undo the turn for the pre-rotated vertices
|
|
68
|
-
busy = false;
|
|
69
|
-
};
|
|
70
|
-
return m;
|
|
71
|
-
} }
|
|
72
|
-
```
|
|
73
|
-
- Cost: the whole scene drawn once more per frame per water mesh at `textureWidth` x `textureHeight` (shadows are not re-rendered). Use 256-512
|
|
74
|
-
on phones; on `engine.tier === 'low'` return the default-looking material instead.
|
|
75
|
-
- One mirror plane: the material is shared, so water bodies at other levels need `water({ sea: false })` or their own mirror. The Reflector's
|
|
76
|
-
shader has no waves or fog; for both, copy its `fragmentShader` into a `MeshPhongMaterial` patch that samples `tDiffuse` with `textureMatrix`.
|
|
77
|
-
- three's `Refractor` addon (next to `Reflector`) reads `matrixWorld` as an XY plane too, so the same adapter applies (not covered by a test).
|
|
78
|
-
- Tested: `tests/specs/appearance-water.mjs` renders this exact example and finds the reflected box in the mirror texture.
|
|
79
|
-
|
|
80
|
-
## Weather particles: rain and snow parameters
|
|
81
|
-
`style.weather.rain` / `snow` (left-out keys keep the built-in look):
|
|
82
|
-
|
|
83
|
-
```js
|
|
84
|
-
weather: {
|
|
85
|
-
rain: { color: 0xa8b8d0, opacity: 0.6, length: 1.2, speed: 26, slant: 1.5, density: a => a * a }, // streaks; sparse in a drizzle
|
|
86
|
-
// rain: { shape: 'soft', size: 10, maxSize: 6, sway: 0.3 }, // drops as soft sprites instead of streaks
|
|
87
|
-
snow: { shape: 'soft', size: 28, maxSize: 7, speed: 1, sway: 3, count: 4000 },
|
|
88
|
-
// snow: { texture: 'flake' }, // a sprite image replaces the shape
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
- `shape`: `'line'` (rain default; leans with the wind by `slant`, `length` meters) or a sprite: `'round'` (snow default), `'soft'`, `'square'`
|
|
92
|
-
(`size` pixels at 3 m, capped at `maxSize`; drifts `sway` meters). `speed` is the fall in m/s.
|
|
93
|
-
- `density: amount => share`: how many particles show at a weather amount 0..1 (rain `a => min(1, a * 1.2)`, snow `() => 1`); opacity still
|
|
94
|
-
follows the amount. `count` per system (default `weather({ particles })`, halved on low-tier devices). Coverage is `style.weather.area`.
|
|
95
|
-
- The numbers are uniforms: `engine.weather.systems.get('rain').uniforms.uColor.value.set(0xff0000)` works at run time.
|
|
96
|
-
|
|
97
|
-
## Weather particles: replace the shaders (GLSL)
|
|
98
|
-
```js
|
|
99
|
-
snow: { uniforms: { uTint: [1, 0.85, 0.9] }, glsl: { fragment: `uniform float uOpacity;
|
|
100
|
-
void main(){
|
|
101
|
-
vec2 d = gl_PointCoord - 0.5;
|
|
102
|
-
float a = 1.0 - smoothstep(0.1, 0.25, dot(d, d)); // a soft petal
|
|
103
|
-
gl_FragColor = vec4(uTint, uOpacity * a);
|
|
104
|
-
#include <tonemapping_fragment>
|
|
105
|
-
#include <colorspace_fragment>
|
|
106
|
-
}` } }
|
|
107
|
-
```
|
|
108
|
-
`glsl.vertex` / `glsl.fragment` are the whole shader text; copy `modules/weather/shaders.js` (`lineVert lineFrag pointVert pointFrag`) as the
|
|
109
|
-
start. In scope: `uCam uSize uFallOff uOpacity uColor`; lines add `uWindDir uLen` and the attribute `aEnd` (0 head, 1 tail); sprites add
|
|
110
|
-
`uPx uMaxPx uSway uSwayAmp uMap uUseMap`. Your `uniforms` are declared for you; declare the built-in ones you use, as the copies do. Keep
|
|
111
|
-
the two `#include` lines so the color matches three's materials with and without post-processing.
|
|
112
|
-
|
|
113
|
-
## Lightning look
|
|
114
|
-
```js
|
|
115
|
-
weather: { lightning: f => f * f * 0.8 } // flash 1 at the strike -> sky flash amount (default flickers)
|
|
116
|
-
weather: { lightning: () => 0 } // no sky flash: draw your own bolt instead
|
|
117
|
-
engine.events.on('weather:lightning', () => spawnBolt()); // when it strikes stays the weather table's (lightning > 0.5)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Particles of the game's own weather
|
|
121
|
-
A field of the game's own weather table (`ash`, `petals`, `sparks`) gets particles with `engine.look.weather.replace({ [field]: spec })`; the amount is
|
|
122
|
-
`engine.weather.current[field]`, so they fade in and out with the weather. The spec takes the rain / snow keys above (default: drifting
|
|
123
|
-
round sprites), or `create` for a system of your own:
|
|
124
|
-
|
|
125
|
-
```js
|
|
126
|
-
engine.use(sky(), weather({ types: { clear: {}, ashfall: { ash: 1, grey: 0.5, sun: 0.6 } } }));
|
|
127
|
-
engine.look.weather.replace({ ash: { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 } });
|
|
128
|
-
engine.look.weather.replace({ rain: { create: (engine, { area, count }) => { // the same call replaces rain or snow
|
|
129
|
-
const drops = new THREE.InstancedMesh(new THREE.SphereGeometry(0.03), new THREE.MeshBasicMaterial({ color: 0x99bbff }), count);
|
|
130
|
-
return { object: drops, update(amount, { camera, time, wind }) { /* move the instances; shown while amount > 0.02 */ } };
|
|
131
|
-
} } });
|
|
132
|
-
```
|
|
133
|
-
A field no type has throws with the table's fields. Rain and snow are built only when a type rains or snows, so a desert pays nothing.
|
|
134
|
-
|
|
135
|
-
> Water and weather are also look parts (`engine.look.water`, `engine.look.weather`): recipes/52-look.md, "Water, weather, post".
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# 48. `engine.makeMaterial(role, spec)`: which keys work, who wins
|
|
2
|
-
|
|
3
|
-
`engine.makeMaterial('furniture', { color: 0x8a5a36 })` returns a normal three.js material. The **role** picks the look from the style pack
|
|
4
|
-
(`style.materials[role]`, unlisted roles use `materials.default`); the **spec** is this call's own settings.
|
|
5
|
-
|
|
6
|
-
## Which spec keys are accepted
|
|
7
|
-
|
|
8
|
-
- **Any real property of the material**: `color`, `emissive`, `emissiveIntensity`, `roughness`, `metalness` (standard/physical only), `shininess` (phong),
|
|
9
|
-
`transparent`, `opacity`, `side` (`THREE.DoubleSide`), `vertexColors`, `flatShading`, `wireframe`, `alphaTest`, `depthWrite`, `fog`... Colors take
|
|
10
|
-
a hex, a CSS string or a `THREE.Color`; a Vector2 prop takes `[x, y]`.
|
|
11
|
-
- `type`: `'lambert' | 'phong' | 'standard' | 'physical' | 'toon' | 'basic'` (default `lambert`, or whatever the pack says).
|
|
12
|
-
- Texture slots by asset name (or a `THREE.Texture`): `map`, `emissiveMap` (sRGB), `normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `bumpMap`,
|
|
13
|
-
`alphaMap`... The slot must exist on the type (`roughnessMap` needs `standard`). Plus `repeat` (number or `[x, y]`) and `wrap` (`repeat | clamp | mirror`).
|
|
14
|
-
- `detail`: a noise (`grain`, `paper`, `stroke`, `dabs`), a texture or your own GLSL laid over the surface in world space (no UVs); its keys: recipe 43.
|
|
15
|
-
- `lighting`: extra light shaping (shadow tint, rim, wrap, own GLSL), merged over `style.lighting`; `false` opts out (recipe 43).
|
|
16
|
-
- toon only: `steps` (number of bands), or `ramp` (+ `soften`). `ramp` on a non-toon type throws.
|
|
17
|
-
- A key the chosen material does not have (`roughness` on lambert) is skipped on purpose, so one spec works for any type.
|
|
18
|
-
A key that looks like a typo of a real one (`roughnes`) warns once in dev with `did you mean 'roughness'?`. Nothing is ever blocked.
|
|
19
|
-
|
|
20
|
-
## Who wins: pack or call
|
|
21
|
-
|
|
22
|
-
The pack entry is the default, the call wins. For a pack **spec** the two are merged (`default` spec, then the role's spec, then your call);
|
|
23
|
-
the same key in the call overrides the pack's:
|
|
24
|
-
|
|
25
|
-
```js
|
|
26
|
-
// pack: materials: { building: { type: 'standard', roughness: 0.8 } }
|
|
27
|
-
engine.makeMaterial('building', { roughness: 0.2 }); // roughness 0.2, still standard
|
|
28
|
-
engine.makeMaterial('building', { type: 'toon', steps: 4 }); // your type wins too
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
A pack entry that is a **Material instance** is cloned, then your keys are set on the clone (keys it lacks are skipped).
|
|
32
|
-
A pack **function** `(params, role, engine) => Material` receives your spec first and decides itself; keys it did not use are set afterwards.
|
|
33
|
-
The pack's `style.lighting` is added unless your spec says `lighting: false`.
|
|
34
|
-
|
|
35
|
-
## Tweak the returned material directly
|
|
36
|
-
|
|
37
|
-
The result is an ordinary `THREE.Material`; edit it freely. The engine does not wrap or track it, so this is not "bypassing" anything:
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
const glass = engine.makeMaterial('window', { color: 0x9fd4ff, transparent: true, opacity: 0.35, side: THREE.DoubleSide });
|
|
41
|
-
glass.depthWrite = false; // plain property edit, fine
|
|
42
|
-
glass.onBeforeCompile = ...; // allowed, but it replaces the engine's shader patches (wind, clouds, detail, lighting) on this material
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Keep `makeMaterial` as the way to *create* materials (a style swap then restyles the game, `npm run check` flags a bare `new THREE.Mesh*Material`);
|
|
46
|
-
afterwards use three.js normally. Changing `needsUpdate`-type settings (`vertexColors`, `flatShading`, `transparent`) after first render needs `mat.needsUpdate = true`.
|
|
47
|
-
|
|
48
|
-
## Copyable examples
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
// Solid prop with vertex colors (merged model)
|
|
52
|
-
engine.makeMaterial('prop', { vertexColors: true });
|
|
53
|
-
|
|
54
|
-
// Textured PBR stone
|
|
55
|
-
engine.makeMaterial('rock', { type: 'standard', map: 'rock.png', normalMap: 'rock_n.png', roughness: 0.9, repeat: 4 });
|
|
56
|
-
|
|
57
|
-
// See-through, double-sided
|
|
58
|
-
engine.makeMaterial('banner', { color: 0xd04a3a, transparent: true, opacity: 0.8, side: THREE.DoubleSide });
|
|
59
|
-
|
|
60
|
-
// Glowing lamp
|
|
61
|
-
engine.makeMaterial('lamp', { color: 0x6b5a40, emissive: 0xffc070, emissiveIntensity: 1.2 });
|
|
62
|
-
|
|
63
|
-
// Grain over the surface, no extra shading
|
|
64
|
-
engine.makeMaterial('wall', { color: 0xc9b99a, detail: { noise: 'paper' }, lighting: false });
|
|
65
|
-
|
|
66
|
-
// Toon with an explicit light ramp
|
|
67
|
-
engine.makeMaterial('character', { type: 'toon', color: 0xe8a0a0, ramp: [0.25, 0.6, 1] });
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
See also: `09-style-pack.md` (writing the pack side), `43-shader-patches-surface-looks.md` (detail / lighting / patches).
|
package/docs/recipes/52-look.md
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# 52 Change any look: `engine.look`
|
|
2
|
-
|
|
3
|
-
Every look part lives at `engine.look.<part>` and is changed with the same verbs. The style pack gives the starting values; the game changes them on top.
|
|
4
|
-
|
|
5
|
-
Exits, in order: `set` params → `patch` (your own GLSL at a named hook) → textures in the material spec (`map`, `normalMap`) → `replace` (your own material or object) → plain three.js (recipe 40 §8). When two rounds of tuning params do not reach the reference, take the next exit instead of tuning on.
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
const cave = engine.look.tone.set({ exposure: 0.6 }, { owner: 'cave' }); // only the keys you give; null drops a key
|
|
9
|
-
engine.look.lights.set({ sun: { intensity: 0.5 } }, { owner: 'cave' });
|
|
10
|
-
cave.remove(); // or engine.look.tone.clear('cave'): the style value shows again
|
|
11
|
-
engine.look.env.replace('sky'); // take a part over whole; replace(null) gives it back
|
|
12
|
-
engine.describe().look.tone.exposure; // { value: 0.6, by: 'game:cave', at: 'main.js:12', under: ['style'] }
|
|
13
|
-
engine.catalog('look.tone'); // params with default, why, off; hooks; what replace accepts and loses
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
- Layers, upper wins: engine default < style < game (each owner; the last one written wins) < `engine.debug.override(owner, 'look.<part>', values)`.
|
|
17
|
-
- `set` / `patch(name, glsl)` / `replace(impl)`: a part offers only the verbs that make sense for it; the others throw with the verb to use. A part whose verb takes other arguments (`materials.replace(role, impl)`) lists the call shape in `engine.catalog('look.<part>').signatures`, and a wrong call quotes it.
|
|
18
|
-
- `by` in describe is `'engine'`, `'style'`, `'game'` (owner `'game'`), `'<layer>:<owner>'` (for example game:cave or debug:probe: the layer, then the owner you passed) or `'three'`. `describe().render` keeps only renderer facts; its `by` is the path of the record to read here (`'look.tone.exposure'`).
|
|
19
|
-
- Look changes are not saved: after a load, set them again from your own state.
|
|
20
|
-
- Changing the three.js object directly (`engine.renderer.toneMappingExposure = 2`) still works; describe tags it `three` and you lose the owner and the debug layer.
|
|
21
|
-
- Old calls and names throw `renamed-api` and name the new call: see [Renamed in 0.2](#renamed-in-02).
|
|
22
|
-
- Your own module's part: `defineLookPart(engine, { id, params, style, apply })`. Every param declares `default`; a default that changes the picture declares `why` and `off`, or `neutral: true` (checked by `npm run check`; R36 checks that the part's `Look<Part>` type lists the same keys). A part author changes records only through the part's methods `write`, `ownerValue`, `extend`, `retract`, `has`, `resolved`, `restyle` (rule R25 flags `part._...`); `validate(key, value)` in the spec rejects a value before anything is written, and an `apply` that throws leaves no layer behind.
|
|
23
|
-
|
|
24
|
-
## Atmosphere parts (sky module): fog, sky, shadow
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
engine.look.fog.set({ far: 220, color: '#9bb' }, { owner: 'cave' }); // kind, color, density, near, far, height, falloff, enabled
|
|
28
|
-
engine.look.fog.replace('manual'); // or a THREE.Fog: the sky stops writing scene.fog; replace(null) gives it back
|
|
29
|
-
engine.look.sky.set({ clouds: { coverage: 0.7, speed: [0.01, 0] }, backdrop: 0x335577 });
|
|
30
|
-
engine.look.sky.patch('layer:aurora', { glsl: '...threedogSkyLayer...', blend: 'add' }); // a named dome layer; patch('layer:aurora', null) removes it
|
|
31
|
-
engine.look.sky.patch('clouds', glsl); // the cloud function; replace(skyboxName | Texture | Object3D) swaps the dome
|
|
32
|
-
engine.look.shadow.set({ type: 'vsm', radius: 3, cascades: 3, maxFar: 150 }); // set only
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
- `fog` shows `enabled` and `far` (fog reaches full strength at `engine.fogFar`, starting at 0.3 x that) as the visible defaults; turn off with `set({ enabled: false })`. Color, density, near, far, enabled and linear <-> exp2 are live. Kind `'exp'` / `'height'`, `height`, `falloff` and the `'fog'` hook replace three's shared fog shader chunks, so they only work before the first frame (style, `sky({ fog })`, or right after `createEngine`); later they throw and say so.
|
|
36
|
-
- `sky`: `clouds.*` are live uniforms of the dome (they only draw when `clouds.coverage` > 0). A hook change recompiles the dome material once. Style `layers` arrays are named by their `name` key, else `layer0`, `layer1`.
|
|
37
|
-
- `shadow`: no `patch` (the cascade patch is internal) and no `replace` (to own the shadows, light with your own lights: `sky({ sun: false })`).
|
|
38
|
-
- Fog kinds and the fog hook in detail, and taking lights or fog away from the sky entirely (`sky({ sun: 'manual' | false })`, `look.fog.replace('manual')`): [recipe 38](38-environment-look-hooks.md).
|
|
39
|
-
|
|
40
|
-
## Surface parts: `materials`, `surface`, `ground`, `wind`
|
|
41
|
-
|
|
42
|
-
A change to these parts reaches the materials made **after** it, with one exception: `look.materials.set` of the plain properties `color`, `emissive`, `emissiveIntensity`, `roughness`, `metalness`, `opacity`, `envMapIntensity`, `shininess` and `specular` also changes the materials already made for that role (no recompile; clearing the layer goes back to the style's value). Shader-changing keys (`type`, `steps`, `ramp`, `soften`, `repeat`, `wrap`, `detail`, `lighting`, `patch`, `replace`) and all of `look.surface` are for new materials only (a Material already handed out, or cloned by your game, is not touched; catalog and describe say so as `appliesTo`, and a debug override warns). `engine.look.<part>.object` is the three.js object behind a part; for `materials` it is a function: `engine.look.materials.object('cloth')` is the last Material made for that role, `object()` all of them.
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const L = engine.look;
|
|
46
|
-
L.materials.set({ cloth: { roughness: 0.4, color: 0xf2ece0 } }, { owner: 'shop' }); // merged into style.materials.cloth; any role name
|
|
47
|
-
L.materials.patch('dim', { glsl: { fragment: { color_fragment: 'diffuseColor.rgb *= 0.8;' } } }, { roles: ['metal'] }); // a ShaderPatch on those roles
|
|
48
|
-
L.materials.replace('glass', new THREE.MeshPhysicalMaterial({ transmission: 1 })); // the role is this Material (or (params, purpose, engine) => Material)
|
|
49
|
-
L.surface.set({ lighting: { wrap: 0.3, shadowTint: { color: '#4a5a9a', strength: 0.5 } }, detail: { noise: 'grain', strength: 0.15 } });
|
|
50
|
-
L.surface.set({ ramp: [0.35, 0.7, 1], soften: 0.2 }); // every toon material's ramp
|
|
51
|
-
L.surface.patch('lighting', glsl); // your threedogLighting(...), see recipe 43
|
|
52
|
-
L.ground.set({ shading: 'flat', colors: { grass: '#7cc06b' } }); // colors / biomeColors / steep / variation / shading rebuild the chunks
|
|
53
|
-
L.ground.set({ detail: { noise: 'paper', scale: 0.4, strength: 0.25 } }); // detail layer on the ground (style.terrain.detail)
|
|
54
|
-
L.ground.replace((e) => myGroundMaterial(e)); // Material or (engine) => Material; replace(null) gives it back
|
|
55
|
-
L.wind.set({ frequency: 1.5, amplitude: 0.5 }); // live on every plant, planted ones too
|
|
56
|
-
L.wind.patch('sway', glsl); // threedogWind(...); read when vegetation.add runs, so patch first
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
- `materials`: `set` / `patch` / `replace` all name a role. `set` merges into spec entries; a role whose style entry is a Material or a function is changed with `replace`. Role names are free: invent new ones (`makeMaterial('lantern-glass')`); the engine only warns on a likely typo of a known role.
|
|
60
|
-
- `surface`: `set` / `patch('lighting' | 'detail', glsl)`; no `replace` (swap a whole material with `materials.replace`). `style.lighting` is the style layer.
|
|
61
|
-
- `ground` (terrain module): `set` / `patch('detail', glsl)` / `replace`. What `terrain({ colors, shading, material })` was given shows as owner `terrain()`.
|
|
62
|
-
- `wind` (vegetation module): `set` / `patch('sway', glsl)`; no `replace`. `style.wind` is the style layer.
|
|
63
|
-
- `set({ role: { key } })` accepts a key `makeMaterial` reads (type, steps, ramp, soften, repeat, wrap, detail, lighting, or a three.js material property); a typo throws.
|
|
64
|
-
- `look.cloudShadow` (cloud shadows, core) stays its own part: its `shadow` is read by every material and by the weather, not only by surfaces.
|
|
65
|
-
|
|
66
|
-
## Water, weather, post
|
|
67
|
-
|
|
68
|
-
```js
|
|
69
|
-
engine.look.water.set({ opacity: 0.5, waveHeight: 2 }, { owner: 'storm' }); // live, no recompile
|
|
70
|
-
engine.look.water.set({ foam: { color: 0xffffff }, depthColor: { shallow: 0x88ccdd, deep: 0x003355 } }); // rebuilds the water material once
|
|
71
|
-
engine.look.water.patch('wave', 'float threedogWaterWave(vec3 p, float t) { return sin(p.x + t) * 0.2; }'); // hooks: wave, surface
|
|
72
|
-
engine.look.water.replace((engine, { uniforms, waves, surface }) => myMaterial); // the whole surface (style.water.material)
|
|
73
|
-
|
|
74
|
-
engine.look.weather.set({ 'rain.speed': 10, 'snow.size': 8, 'lightning.brightness': 0.5, overcastColor: '#667' }); // rebuilds that field's particles once
|
|
75
|
-
engine.look.weather.patch('rain.fragment', wholeFragmentShaderText); // rain|snow . vertex|fragment: the WHOLE shader text, not a function
|
|
76
|
-
engine.look.weather.replace({ ash: { shape: 'soft', color: 0x555555 }, rain: { create } }); // null gives the fields back
|
|
77
|
-
|
|
78
|
-
engine.look.post.set({ bloom: { strength: 0.6 }, vignette: false }); // keys: '<effect>.<param>', '<effect>.enabled'
|
|
79
|
-
engine.look.post.patch('tint', { glsl: 'color.rgb *= vec3(1.0, 0.9, 0.8);', slot: 'ldr', order: 5 }); // generates a fuse effect named 'tint'; patch('tint', null) removes it
|
|
80
|
-
engine.look.post.add({ name: 'scan', slot: 'hdr', order: 5, create: (ctx) => myPass }, { owner: 'cave' }); // ONE custom pass; returns { remove() }. Same errors as the chain (duplicate name, second 'scene' pass, depth order) and nothing is added. Tune it with set({ 'scan.<param>': v })
|
|
81
|
-
engine.look.post.replace([bloom(), grain()]); // swaps the whole chain; replace(null) gives the style chain back
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
- Water: structural keys (`depthColor`, `foam`, the hooks, `replace`) rebuild the shared material once and hand it to every water mesh; the live keys only write a uniform. `water({ opacity: 0.5 })` options are the game layer.
|
|
85
|
-
- Weather: a field the weather table lacks (`snow` in a desert) has no particles; setting it warns once. `replace({ [field]: spec })` holds one object per owner, so list every field you replace in each call; while a field is replaced, `set` on it is ignored.
|
|
86
|
-
- Post: `look.post.set` writes the `game` layer (keys `<effect>.<param>` and `<effect>.enabled`); style effects (bloom, ao ...) are the style layer; `engine.post.get(name)` only reads an effect. MSAA is `engine.post.setAntialias(on)`. Costly effects start off on low-tier devices: `look.post` lists `<effect>.enabled` with `why` and `off`. `postAdd` / `postRemove` stay style-pack parts (they edit the list before the engine exists).
|
|
87
|
-
- `describe().render.post` reads the same records (`by`: style, game, debug).
|
|
88
|
-
|
|
89
|
-
## Post effect chain
|
|
90
|
-
|
|
91
|
-
Post-processing is an ordered list of named effects (`style.post`, then `look.post`). Each runs in a slot, then by `order` (low first):
|
|
92
|
-
`scene` (replaces the scene render, one at a time, e.g. pixelation) -> `hdr` (linear color: outline, AO, bloom) -> tone mapping -> `ldr` (sRGB: LUT,
|
|
93
|
-
palette, grain, vignette) -> `final` (FXAA / SMAA). An effect is `{ name, slot, order, params, create(ctx) => pass, update?(pass, params) }`; under
|
|
94
|
-
WebGL the pass is any three.js postprocessing Pass, built the first time it is on.
|
|
95
|
-
```js
|
|
96
|
-
import { bloom, outline, vignette, lut } from '@threedog/post-effects'; // never from another style pack: packs do not depend on each other
|
|
97
|
-
import { LUTPass } from 'three/addons/postprocessing/LUTPass.js';
|
|
98
|
-
const myStyle = { post: [outline({ enabled: true, thickness: 1.5 }), bloom({ strength: 0.2 }), vignette(), lut({ saturation: 1.1 }),
|
|
99
|
-
{ name: 'myLut', slot: 'ldr', params: { lut: myLut }, create: ({ params }) => new LUTPass({ lut: params.lut }) }] };
|
|
100
|
-
```
|
|
101
|
-
- The engine ships no effects. `@threedog/post-effects` (import only what you use) has `bloom`, `ao`, `outline`, `dof` (all `hdr`; outline and dof
|
|
102
|
-
read depth) and `lut` (contrast / saturation / warm-cool / optional 3D LUT), `grain`, `vignette`, `chromatic` (`ldr`). `lut`, `grain`, `vignette`,
|
|
103
|
-
`chromatic`, `dof`, `ao` and `outline` are off until `enabled: true`. To add to or trim a pack's list without replacing it: `postAdd(...effects)` /
|
|
104
|
-
`postRemove(...names)` ([recipe 09](09-style-pack.md), 0b).
|
|
105
|
-
- Depth: an effect that reads scene depth (`needsDepth: true`, e.g. `outline`) must run before any pass that swaps buffers (a `ShaderPass`, a
|
|
106
|
-
scene-slot pixelation pass, the tone-mapping output). A chain that breaks this throws when the effect is added or enabled, naming both effects;
|
|
107
|
-
give the depth reader a lower `order`. `dof` keeps the scene depth (`pass.keepsDepth = true`), so `dof` and `outline` can both be on while `dof`
|
|
108
|
-
has the lower `order` (default: dof 5, outline 10). `threedog style check` reports the other order as an error.
|
|
109
|
-
- `createEngine({ post: { bloom: false } })` overrides an effect's startup on/off; `costly: true` effects start off on low-tier devices. MSAA
|
|
110
|
-
(`antialias`) works with every effect on. The settings menu shows `bloom` / `ao` toggles only when the style registers effects with those names.
|
|
111
|
-
- `fuse`: a light color effect can skip its own fullscreen pass by carrying a GLSL snippet instead of `create()`:
|
|
112
|
-
`fuse: { uniforms: { uMyAmount: 'float' }, values: p => ({ uMyAmount: p.amount }), glsl: 'color.rgb *= 1.0 - uMyAmount * length(vUv - 0.5);' }`.
|
|
113
|
-
Fused effects that are on and next to each other in one slot (never `scene`) compile into one shader and draw in one pass, in `order`. The
|
|
114
|
-
snippet edits `vec4 color` and may use `vUv`, `tDiffuse`, `uTime`, `uResolution`, `fxHash(vec2)`; uniform names are shared by the group, so prefix
|
|
115
|
-
them with the effect name. A snippet that samples `tDiffuse` elsewhere (blur, color fringe) sets `reads: true` and starts a new group.
|
|
116
|
-
`look.post.patch(name, { glsl })` builds such an effect for you.
|
|
117
|
-
- Outline: `outline({ mode: 'depth' | 'normal' | 'both' })`: `depth` (default, silhouettes), `normal` (creases; draws the scene once more with
|
|
118
|
-
normals, so it is `costly`), `both`. `fadeWithDistance: false` keeps lines at any distance; `wobble: 1.5` jitters lines by up to 1.5 px at 8 steps a
|
|
119
|
-
second. To exempt objects: `outline({ offLayer: OUTLINE_OFF_LAYER })` and `mesh.layers.enable(OUTLINE_OFF_LAYER)` (one extra render of just
|
|
120
|
-
those objects; nothing when `offLayer` is `null`).
|
|
121
|
-
|
|
122
|
-
## sky.modify vs look.lights
|
|
123
|
-
|
|
124
|
-
Two ways to make the light darker or brighter; pick by what you want to keep.
|
|
125
|
-
- `engine.sky.modify('cave', { sun: 0.3, ambient: 0.4, fog: 0.5, tint, tintAmount })` is a **multiplier layer** on what the sky produces each frame (keyframes, weather, season). The time of day keeps moving underneath, layers from different owners multiply, `modify('cave', null)` removes yours, and `sky.modifiers` shows the combined result (read-only). Use it for "darker in the cave" or "ash over the ground" (`groundCover`, `coverAmount`).
|
|
126
|
-
- `engine.look.lights.set({ sun: { intensity: 0.5 } }, { owner: 'cave' })` is an **override layer** on the part's own values: the key you give replaces what the style or the keyframes said, whatever the hour. Use it for "the sun is exactly this".
|
|
127
|
-
|
|
128
|
-
## Renamed in 0.2 (old call → new call)
|
|
129
|
-
|
|
130
|
-
The old calls below now throw `renamed-api` and the message names the new call (the list is `RENAMED` in `core/renamed.js`; rule R39 keeps the old names out of the repo).
|
|
131
|
-
|
|
132
|
-
| Old call | New call |
|
|
133
|
-
|---|---|
|
|
134
|
-
| `engine.setExposure(v)`, `engine.setToneMapping(m)` | `engine.look.tone.set({ exposure: v })`, `engine.look.tone.set({ mapping: m })` |
|
|
135
|
-
| `engine.sky.setShadow(o)` | `engine.look.shadow.set(o)` |
|
|
136
|
-
| `engine.sky.setEnvironment(o)` | `engine.look.env.replace('sky')` then `engine.look.env.set({ intensity, rotation })`; `replace(false)` turns it off |
|
|
137
|
-
| `engine.weather.define(field, spec)` | `engine.look.weather.replace({ [field]: spec })` |
|
|
138
|
-
| `engine.post.add(effect)` | `engine.look.post.add(effect, { owner })` (one pass, returns `{ remove() }`), `engine.look.post.patch(name, { glsl })` (a color effect) or `engine.look.post.replace([...effects])` (the whole chain) |
|
|
139
|
-
| `engine.post.enable(name, on)`, handle `.set` / `.enable` / `.remove` | `engine.look.post.set({ 'bloom.enabled': on })`, `engine.look.post.set({ 'bloom.strength': 0.6 })`; MSAA: `engine.post.setAntialias(on)` |
|
|
140
|
-
| `engine.look.clouds` | `engine.look.cloudShadow` |
|
|
141
|
-
| `engine.cameraOverride = { owner }` | `const cam = engine.takeCamera('owner', { focus })`; `cam.remove()` releases it |
|
|
142
|
-
| `engine.views.define(name, { pos })` | `engine.views.define(name, { position: [x, y, z] })` |
|
|
143
|
-
| failure `result.reason` (`ops.run` / `can` / `undo`) | `result.code` (reading `reason` throws) |
|
|
144
|
-
| `style.character.create` / `.model` / `.colors` (a body from the style pack) | bodies are assets: `createPlayer({ model: 'humanoid' })` with a pack's `assets` registered, a GLB asset name, or `{ rig }`; part colors are material roles `cloth` / `skin` / `trousers` / `hair`, or `{ colors }` per character ([13-animation](13-animation.md)) |
|
|
145
|
-
|
|
146
|
-
Not renamed (still the way to do it): per-call `makeMaterial(role, params)` keys win for that one material; `applyEffects(mat, { patches })` is the low-level form of `look.materials.patch(name, spec, { roles })`; `style.terrain.*`, `style.wind.*` and `style.lighting` are the style layer of `look.ground` / `look.wind` / `look.surface`.
|
package/examples/action/look.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// This example's look, as a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, look] })). Logic never reads colors; models.js does.
|
|
2
|
-
export default {
|
|
3
|
-
name: 'action', // a part needs at least one Style field (TypeScript rejects an object that shares none), so it names itself
|
|
4
|
-
action: { floor: 0x5b6168, wall: 0x8a8f96, pillar: 0x9a8c78, enemy: 0x6fbf5a, eye: 0x1d2024 },
|
|
5
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// sheepisland: a style pack, LOOKS ONLY (recipes/09-style-pack.md, 35-style-from-reference.md), started from the new-style template
|
|
2
|
-
// (packages/tools/templates/style). A soft painted diorama: few flat colors, round shapes, soft shadows, a pale warm background with no horizon.
|
|
3
|
-
// The world (island outline, river, wheat field) is the game's terrain() in ../main.js, never here.
|
|
4
|
-
import { makeMaterial, applyEffects } from '../../../index.js';
|
|
5
|
-
import { models, PALETTE } from './models.js';
|
|
6
|
-
|
|
7
|
-
export { models };
|
|
8
|
-
/** Asset pack of the procedural models: engine.assets.manifest(assets) registers roundTree, sheep and wheatTuft */
|
|
9
|
-
export const assets = { name: 'sheepisland', models };
|
|
10
|
-
|
|
11
|
-
// Background: zenith = horizon = fog color at every time, so the dome is one flat tone and no horizon line shows.
|
|
12
|
-
// [time 0-1, zenith, horizon (= fog), sun color, sun intensity, ambient intensity]
|
|
13
|
-
// Ground material with snow that survives shading: 'texture'. The engine's season tint runs at color_fragment, before the per-chunk color map is
|
|
14
|
-
// multiplied in, so in 'mix' mode the map paints the green back over the white. This patch repeats the season mix later (emissivemap_fragment,
|
|
15
|
-
// after every color patch, before lighting), reading the engine's own season uniforms under new names (the season patch declares the old ones).
|
|
16
|
-
/** @param {any} engine */
|
|
17
|
-
function snowyGround(engine) {
|
|
18
|
-
const u = engine.uniforms;
|
|
19
|
-
return applyEffects(makeMaterial('terrain', { vertexColors: true }, engine), { clouds: false, patches: [{
|
|
20
|
-
name: 'snowCover', cacheKey: 1, uniforms: { uSnowTint: u.uGroundTint, uSnowMix: u.uGroundMix },
|
|
21
|
-
glsl: { fragment: { pars: 'uniform vec3 uSnowTint; uniform float uSnowMix;',
|
|
22
|
-
emissivemap_fragment: 'diffuseColor.rgb = mix(diffuseColor.rgb, uSnowTint, uSnowMix);' } } }] });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const DAY = 0xefebe4, DUSK = 0xf0d9c4, NIGHT = 0x2c3346;
|
|
26
|
-
export default {
|
|
27
|
-
name: 'sheepisland',
|
|
28
|
-
exposure: 1,
|
|
29
|
-
toneMapping: 'neutral', // neutral keeps the painted colors close to what is written here (aces darkens and shifts them)
|
|
30
|
-
|
|
31
|
-
post: [], // restraint: the reference shows no outline, bloom or grain
|
|
32
|
-
|
|
33
|
-
materials: {
|
|
34
|
-
default: { type: 'lambert' },
|
|
35
|
-
leaf: { type: 'lambert' },
|
|
36
|
-
bark: { type: 'lambert' },
|
|
37
|
-
wool: { type: 'lambert' },
|
|
38
|
-
face: { type: 'lambert' },
|
|
39
|
-
cliff: { type: 'lambert' },
|
|
40
|
-
vegetation: { type: 'lambert', side: 2 }, // the wheat stalks are thin: both sides (THREE.DoubleSide = 2)
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
// Soft light: half-lambert wrap so the shade side of a round blob is not black, and a cool blue shade instead of a gray one
|
|
44
|
-
lighting: { wrap: 0.45, shadowTint: { color: 0x7d88b8, strength: 0.45, soft: 0.3 } },
|
|
45
|
-
|
|
46
|
-
palette: PALETTE,
|
|
47
|
-
|
|
48
|
-
sky: {
|
|
49
|
-
keyframes: [
|
|
50
|
-
[0.00, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
51
|
-
[0.22, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
52
|
-
[0.30, DAY, DAY, 0xfff0dc, 1.8, 1.0],
|
|
53
|
-
[0.50, DAY, DAY, 0xfffaf0, 2.3, 1.15],
|
|
54
|
-
[0.70, DAY, DAY, 0xffe6c8, 1.9, 1.0],
|
|
55
|
-
[0.77, DUSK, DUSK, 0xffb07a, 1.5, 0.85],
|
|
56
|
-
[0.84, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
57
|
-
[1.00, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
58
|
-
],
|
|
59
|
-
groundTint: 0xb8c49a, // ambient bounce from below: the green of the meadow, not gray
|
|
60
|
-
sunBrightness: 0, sunGlow: 0, moonBrightness: 0, starDensity: 0, // a flat painted backdrop: no disc, glow or stars
|
|
61
|
-
clouds: { coverage: 0 },
|
|
62
|
-
shadow: { type: 'pcf', radius: 4, extent: 45, mapSize: 2048 }, // soft edges; the island is small, so a tight box keeps them sharp enough
|
|
63
|
-
fog: { kind: 'exp', density: 0.0015 }, // barely there: the far rim fades a touch into the backdrop
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
terrain: {
|
|
67
|
-
config: { shading: 'texture', colorResolution: 256 }, // crisp river bank and field edge without more triangles (recipe 37); 128 (0.5 m pixels) shows stairs up close
|
|
68
|
-
colors: { grassA: 0x92c062, grassB: 0x86b658, river: 0x6aa6d6, riverDeep: 0x5b97ca, wheatA: 0xdcae48, wheatB: 0xd2a442,
|
|
69
|
-
earth: 0xb98d64, rock: 0x94705a },
|
|
70
|
-
biomeColors: { grass: ['grassA', 'grassB'], river: ['river', 'riverDeep'], wheat: ['wheatA', 'wheatB'], cliff: ['earth'], rock: ['rock'] },
|
|
71
|
-
variation: { blend: { size: 14, strength: 0.6 }, jitter: { size: 0.5, min: 0.97, range: 0.04 } }, // low texture: almost no grain
|
|
72
|
-
material: snowyGround,
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// Snow: winter in the calendar turns foliage and ground most of the way to white ('mix', so green does not go muddy)
|
|
76
|
-
seasons: { mode: /** @type {const} */ ('mix'), strength: 0.82, winter: { foliage: 0xf6f6f8, ground: 0xf4f5f8 } },
|
|
77
|
-
// snow greys the sky towards overcastColor and dims the sun: keep the backdrop pale and the island readable
|
|
78
|
-
weather: { snow: { color: 0xffffff }, overcastColor: 0xe6e3de, types: { snow: { sun: 0.8, grey: 0.25 } } },
|
|
79
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This example's look, a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, look] })): how the test surfaces feel.
|
|
2
|
-
// The exhibits ask for roles wood / stone / metal / glass; a style that does not define them falls back to materials.default.
|
|
3
|
-
export default {
|
|
4
|
-
name: 'styletest',
|
|
5
|
-
materials: {
|
|
6
|
-
wood: { type: 'lambert' },
|
|
7
|
-
stone: { type: 'lambert', flatShading: true },
|
|
8
|
-
metal: { type: 'standard', metalness: 0.9, roughness: 0.3 }, // only looks like metal with environment light: ?env=1
|
|
9
|
-
glass: { type: 'phong', shininess: 100 },
|
|
10
|
-
},
|
|
11
|
-
};
|