threedog 0.5.0 → 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 +81 -1
- package/README.md +21 -13
- package/core/Assets.js +23 -12
- package/core/Audio.js +1 -1
- package/core/Baked.js +14 -23
- package/core/Budget.js +2 -2
- package/core/DebugOverrides.js +33 -18
- package/core/Describe.js +10 -11
- package/core/Engine.js +50 -46
- package/core/I18n.js +2 -2
- package/core/Input.js +11 -5
- package/core/Inspect.js +6 -3
- package/core/InspectMaterials.js +2 -3
- package/core/InspectPerf.js +11 -4
- package/core/MaterialInfo.js +7 -5
- package/core/Rays.js +7 -2
- package/core/Stream.js +2 -3
- package/core/UrlState.js +49 -9
- package/core/Views.js +1 -0
- package/core/adaptive.js +2 -2
- package/core/assetEntry.js +5 -2
- package/core/assetLoad.js +13 -15
- package/core/assetManifest.js +6 -3
- package/core/assetReport.js +4 -4
- package/core/batchGroups.js +9 -1
- package/core/catalog.js +16 -3
- package/core/chunkStream.js +1 -1
- package/core/copies.js +1 -1
- package/core/debugView.js +4 -4
- package/core/describeRender.js +104 -28
- package/core/describeText.js +6 -6
- package/core/errorCodes.js +72 -45
- package/core/errorHints.js +4 -1
- package/core/errors.js +4 -4
- package/core/events.generated.js +1 -0
- package/core/gameLights.js +9 -2
- package/core/lifecycle.js +2 -4
- package/core/lightWatch.js +5 -3
- package/core/loop.js +18 -11
- package/core/math.js +7 -0
- package/core/moduleSlots.js +32 -7
- package/core/moduleTypes.js +20 -7
- package/core/modules.js +7 -7
- package/core/namedModel.js +8 -4
- package/core/owned.js +33 -30
- package/core/page.js +43 -10
- package/core/pictureSlots.js +33 -0
- package/core/pictureWriters.js +343 -0
- package/core/plugins.js +64 -96
- package/core/sceneDelta.js +12 -4
- package/core/sceneMethods.js +2 -9
- package/core/services.js +1 -1
- package/core/shadowTypes.js +1 -1
- package/core/shadows.js +405 -0
- package/core/sharedPoint.js +5 -19
- package/core/stackFrames.js +16 -5
- package/core/stacks.js +6 -6
- package/core/startup.js +9 -11
- package/core/thingExplain.js +1 -1
- package/core/things.js +1 -1
- package/core/tier.js +1 -1
- package/core/util.js +1 -1
- package/core/validate.js +1 -1
- package/core/view.js +43 -0
- package/docs/AI.md +62 -58
- package/docs/API.md +15 -15
- package/docs/CODEMAP.md +36 -54
- package/docs/COMMANDS.md +28 -25
- package/docs/CONVENTIONS.md +36 -30
- package/docs/MIGRATING-0.4.md +93 -1
- package/docs/MIGRATING-0.6.md +126 -0
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/THREE.md +24 -22
- package/docs/api/assets.md +5 -3
- package/docs/api/audio.md +2 -2
- package/docs/api/budget.md +4 -0
- package/docs/api/characters.md +3 -1
- package/docs/api/collision.md +2 -2
- package/docs/api/engine.md +47 -20
- package/docs/api/events.md +2 -1
- package/docs/api/grids.md +8 -1
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +3 -0
- package/docs/api/input.md +3 -2
- package/docs/api/interactions.md +3 -1
- package/docs/api/inventory.md +1 -2
- package/docs/api/level.md +0 -1
- package/docs/api/lightPool.md +1 -1
- package/docs/api/occlusion.md +5 -0
- package/docs/api/particles.md +6 -3
- package/docs/api/pickups.md +6 -0
- package/docs/api/post.md +5 -3
- package/docs/api/sky.md +12 -10
- package/docs/api/terrain.md +12 -6
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/tools.md +8 -7
- package/docs/api/triggers.md +2 -0
- package/docs/api/vegetation.md +7 -2
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +6 -2
- package/docs/api/weather.md +5 -0
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +19 -23
- package/docs/recipes/03-items-pickups.md +25 -4
- package/docs/recipes/05-props-bake.md +53 -37
- package/docs/recipes/06-clock-events.md +3 -3
- package/docs/recipes/07-flow-scenes-pause.md +12 -3
- package/docs/recipes/08-weather-sky.md +45 -57
- package/docs/recipes/09-materials-lights-models.md +185 -0
- package/docs/recipes/10-blender-level.md +2 -2
- package/docs/recipes/11-vehicles.md +3 -3
- package/docs/recipes/13-animation.md +13 -7
- package/docs/recipes/14-custom-module.md +7 -5
- package/docs/recipes/15-perf.md +3 -3
- package/docs/recipes/16-dev-bridge.md +22 -12
- package/docs/recipes/18-world.md +10 -8
- package/docs/recipes/19-shooting-picking.md +7 -5
- package/docs/recipes/20-content-actions-save.md +6 -2
- package/docs/recipes/21-camera.md +8 -3
- package/docs/recipes/23-ops.md +1 -1
- package/docs/recipes/26-ui-parts.md +35 -11
- package/docs/recipes/28-terrain.md +12 -12
- package/docs/recipes/29-grid.md +14 -5
- package/docs/recipes/30-templates.md +8 -3
- package/docs/recipes/31-audio.md +4 -4
- package/docs/recipes/32-action-game.md +18 -4
- package/docs/recipes/34-environment-lighting.md +102 -38
- 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 -13
- package/docs/recipes/38-environment-hooks.md +67 -0
- package/docs/recipes/40-scene.md +106 -27
- package/docs/recipes/42-terrain-shape.md +1 -1
- package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
- package/docs/recipes/44-water-weather-hooks.md +191 -0
- package/docs/recipes/45-cascaded-shadows.md +121 -23
- package/docs/recipes/46-blender-art-route.md +17 -20
- package/docs/recipes/47-island-snow-backdrop.md +10 -12
- package/docs/recipes/49-game-module-contract.md +1 -1
- package/docs/recipes/50-own-renderer.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 +18 -18
- package/docs/recipes/55-mods-time-wrap.md +17 -5
- package/docs/recipes/56-webgpu-tsl.md +66 -23
- package/docs/recipes/57-control.md +39 -0
- package/docs/recipes/58-input.md +3 -0
- package/docs/recipes/59-depth-post-effects.md +5 -5
- package/docs/recipes/60-judge-the-picture.md +39 -24
- 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 -1
- package/examples/action/GAMEMAP.md +7 -5
- package/examples/action/main.js +5 -4
- package/examples/action/models.js +12 -14
- package/examples/action/picture/index.js +13 -0
- package/examples/action/picture/lights.js +35 -0
- package/examples/action/picture/materials.js +8 -0
- package/examples/action/picture/palette.js +33 -0
- package/examples/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 +31 -9
- package/examples/rc2d/GAMEMAP.md +8 -3
- package/examples/rc2d/README.md +11 -6
- package/examples/rc2d/main.js +25 -33
- package/examples/rc2d/picture/index.js +18 -0
- package/examples/rc2d/picture/lights.js +11 -0
- package/examples/rc2d/picture/materials.js +18 -0
- package/examples/rc2d/picture/palette.js +15 -0
- package/examples/rc2d/picture/post.js +11 -0
- package/examples/rc2d/rc2d.js +18 -28
- package/examples/sheepisland/.threedog/content-index.json +1 -1
- package/examples/sheepisland/GAMEMAP.md +13 -10
- package/examples/sheepisland/assets.js +2 -2
- package/examples/sheepisland/content/templates.js +1 -1
- package/examples/sheepisland/content/vegetation.js +3 -1
- package/examples/sheepisland/main.js +15 -9
- 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 -1
- package/examples/styletest/GAMEMAP.md +15 -11
- package/examples/styletest/main.js +20 -30
- package/examples/styletest/models.js +29 -29
- package/examples/styletest/params.js +1 -4
- package/examples/styletest/picture/env.js +38 -0
- package/examples/styletest/picture/index.js +16 -0
- package/examples/styletest/picture/lights.js +9 -0
- package/examples/styletest/picture/materials.js +28 -0
- package/examples/styletest/picture/palette.js +22 -0
- package/examples/techniques/contact-shadows/README.md +22 -23
- package/examples/techniques/contact-shadows/contactShadows.js +32 -16
- package/examples/techniques/contact-shadows/main.js +20 -18
- package/examples/techniques/contact-shadows/picture/index.js +14 -0
- package/examples/techniques/contact-shadows/picture/lights.js +34 -0
- package/examples/techniques/contact-shadows/picture/materials.js +12 -0
- package/examples/techniques/contact-shadows/picture/palette.js +17 -0
- package/examples/techniques/day-night-grade/README.md +13 -16
- package/examples/techniques/day-night-grade/main.js +15 -25
- package/examples/techniques/day-night-grade/picture/index.js +20 -0
- package/examples/techniques/day-night-grade/picture/lights.js +45 -0
- package/examples/techniques/day-night-grade/picture/materials.js +15 -0
- package/examples/techniques/day-night-grade/picture/palette.js +59 -0
- package/examples/techniques/day-night-grade/picture/post.js +25 -0
- package/examples/techniques/day-night-grade/picture/sky.js +33 -0
- package/examples/techniques/interior-light/README.md +16 -13
- package/examples/techniques/interior-light/interiorLight.js +19 -17
- package/examples/techniques/interior-light/main.js +30 -67
- 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 +4 -3
- package/examples/techniques/modular-building/kit.js +2 -2
- package/examples/techniques/modular-building/main.js +9 -17
- package/examples/techniques/modular-building/picture/index.js +17 -0
- package/examples/techniques/modular-building/picture/lights.js +26 -0
- package/examples/techniques/modular-building/picture/materials.js +13 -0
- package/examples/techniques/modular-building/picture/palette.js +23 -0
- package/examples/techniques/night-lights/README.md +15 -14
- package/examples/techniques/night-lights/main.js +20 -43
- package/examples/techniques/night-lights/nightLights.js +25 -21
- package/examples/techniques/night-lights/picture/index.js +18 -0
- package/examples/techniques/night-lights/picture/lights.js +44 -0
- package/examples/techniques/night-lights/picture/materials.js +15 -0
- package/examples/techniques/night-lights/picture/palette.js +34 -0
- package/examples/techniques/night-lights/picture/post.js +9 -0
- package/examples/techniques/night-lights/picture/sky.js +36 -0
- package/examples/techniques/outlines-and-rim/README.md +2 -2
- package/examples/techniques/outlines-and-rim/main.js +15 -38
- package/examples/techniques/outlines-and-rim/outlines.js +3 -3
- package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
- package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
- package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
- package/examples/techniques/procedural-animation/README.md +5 -3
- package/examples/techniques/procedural-animation/main.js +9 -7
- package/examples/techniques/procedural-animation/picture/index.js +15 -0
- package/examples/techniques/procedural-animation/picture/lights.js +35 -0
- package/examples/techniques/procedural-animation/picture/materials.js +10 -0
- package/examples/techniques/procedural-animation/picture/palette.js +16 -0
- package/examples/techniques/procedural-animation/picture/sky.js +31 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
- package/examples/techniques/procedural-surface/README.md +2 -0
- package/examples/techniques/procedural-surface/main.js +17 -55
- package/examples/techniques/procedural-surface/picture/index.js +14 -0
- package/examples/techniques/procedural-surface/picture/lights.js +18 -0
- package/examples/techniques/procedural-surface/picture/materials.js +34 -0
- package/examples/techniques/procedural-surface/picture/palette.js +15 -0
- package/examples/techniques/stylized-shading/README.md +13 -14
- package/examples/techniques/stylized-shading/main.js +11 -42
- package/examples/techniques/stylized-shading/picture/index.js +14 -0
- package/examples/techniques/stylized-shading/picture/lights.js +23 -0
- package/examples/techniques/stylized-shading/picture/materials.js +18 -0
- package/examples/techniques/stylized-shading/picture/palette.js +19 -0
- package/examples/techniques/stylized-shading/shading.js +2 -2
- package/examples/techniques/sun-and-key-light/README.md +20 -22
- package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
- package/examples/techniques/sun-and-key-light/main.js +19 -63
- package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
- package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
- package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
- package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
- package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
- package/examples/techniques/three-looks/README.md +21 -0
- package/examples/techniques/three-looks/main.js +58 -0
- package/examples/techniques/three-looks/picture/cartoon.js +23 -0
- package/examples/techniques/three-looks/picture/cinematic.js +27 -0
- package/examples/techniques/three-looks/picture/comic.js +27 -0
- package/examples/techniques/three-looks/picture/index.js +14 -0
- package/examples/techniques/three-looks/picture/sun.js +23 -0
- package/examples/techniques/wet-road/README.md +7 -4
- package/examples/techniques/wet-road/main.js +18 -38
- package/examples/techniques/wet-road/picture/index.js +17 -0
- package/examples/techniques/wet-road/picture/lights.js +57 -0
- package/examples/techniques/wet-road/picture/materials.js +16 -0
- package/examples/techniques/wet-road/picture/palette.js +24 -0
- package/examples/techniques/wet-road/picture/sky.js +46 -0
- package/examples/webgpu-tsl/GAMEMAP.md +9 -4
- package/examples/webgpu-tsl/README.md +13 -10
- package/examples/webgpu-tsl/main.js +30 -7
- package/examples/webgpu-tsl/picture/index.js +18 -0
- package/examples/webgpu-tsl/picture/lights.js +25 -0
- package/examples/webgpu-tsl/picture/materials.js +36 -0
- package/examples/webgpu-tsl/picture/palette.js +23 -0
- package/examples/webgpu-tsl/picture/post.js +16 -0
- package/examples/webgpu-tsl/picture/sky.js +30 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +15 -12
- package/examples/world/art/humanoid.js +9 -13
- package/examples/world/art/index.js +2 -2
- package/examples/world/art/models.js +3 -4
- package/examples/world/art/shapes.js +2 -2
- package/examples/world/assets.js +2 -2
- package/examples/world/content/audio.js +1 -1
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +10 -10
- package/examples/world/models.js +17 -7
- package/examples/world/picture/index.js +20 -0
- package/examples/world/picture/lights.js +41 -0
- package/examples/world/picture/materials.js +34 -0
- package/examples/world/picture/palette.js +74 -0
- package/examples/world/picture/post.js +9 -0
- package/examples/world/picture/sky.js +39 -0
- package/index.d.ts +7 -16
- package/index.js +7 -7
- package/llms.txt +15 -13
- package/modules/ambience/Ambience.js +1 -1
- package/modules/calendar/Calendar.js +1 -1
- package/modules/calendar/index.js +1 -0
- package/modules/camera/FirstPersonCamera.js +1 -1
- package/modules/camera/FixedCamera.js +2 -2
- package/modules/camera/RtsCamera.js +1 -1
- package/modules/camera/common.js +7 -5
- package/modules/characters/Character.js +15 -10
- package/modules/characters/NPC.js +5 -5
- package/modules/characters/assetModel.js +5 -4
- package/modules/characters/index.js +28 -3
- package/modules/characters/movers/common.js +6 -1
- package/modules/characters/movers/manual.js +3 -0
- package/modules/characters/movers/support.js +25 -11
- package/modules/characters/npcSim.js +5 -1
- package/modules/characters/proceduralRig.js +18 -4
- package/modules/characters/useModel.js +2 -2
- package/modules/collision/Collision.js +4 -2
- package/modules/content/index.js +8 -0
- package/modules/content/models.js +56 -11
- package/modules/content/props.js +5 -3
- package/modules/content/rules.js +12 -4
- package/modules/content/templates.js +5 -3
- package/modules/gameplay/Interactions.js +91 -16
- package/modules/gameplay/Inventory.js +3 -3
- package/modules/gameplay/dialogueBox.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +1 -1
- package/modules/gameplay/interactionPrompt.js +1 -1
- package/modules/gameplay/interactions.contract.js +1 -1
- package/modules/gameplay/inventoryOps.js +2 -2
- package/modules/gameplay/pickups.js +62 -24
- package/modules/gameplay/questLog.js +2 -2
- package/modules/grid/Layer.js +13 -0
- package/modules/grid/index.js +40 -11
- package/modules/grid/preview.js +24 -15
- package/modules/grid/tiles.js +15 -19
- package/modules/hlod/index.js +3 -2
- package/modules/hud/index.js +13 -0
- package/modules/hud/parts.js +9 -7
- package/modules/level/index.js +5 -4
- package/modules/lights/index.js +12 -8
- package/modules/music/Music.js +1 -1
- package/modules/particles/Particles.js +41 -20
- package/modules/particles/effect.js +21 -6
- package/modules/photo/Photo.js +11 -10
- package/modules/settings/Settings.js +7 -7
- package/modules/settings/apply.js +5 -5
- package/modules/settings/sections.js +2 -2
- package/modules/settings/strings.js +1 -1
- package/modules/sky/Sky.js +104 -89
- package/modules/sky/clouds.js +16 -17
- package/modules/sky/dome.js +100 -0
- package/modules/sky/domeLayers.js +5 -5
- package/modules/sky/environment.js +45 -169
- package/modules/sky/fog.js +5 -180
- package/modules/sky/frame.js +26 -90
- package/modules/sky/season.js +3 -3
- package/modules/sky/shader.js +35 -29
- package/modules/sky/skyModule.js +25 -22
- package/modules/sky/tint.js +9 -11
- package/modules/terrain/ChunkManager.js +29 -12
- package/modules/terrain/draw.js +154 -0
- package/modules/terrain/index.js +44 -66
- package/modules/terrain/terrainDefaults.js +2 -2
- package/modules/terrain/terrainEdit.js +1 -1
- package/modules/terrain/terrainGen.js +2 -2
- package/modules/triggers/index.js +10 -6
- package/modules/vegetation/Vegetation.js +58 -17
- package/modules/vegetation/draw.js +191 -0
- package/modules/vegetation/groundChunks.js +1 -1
- package/modules/vegetation/index.js +10 -10
- package/modules/water/Water.js +135 -88
- package/modules/water/surface.js +53 -53
- package/modules/weather/Weather.js +52 -17
- package/modules/weather/particles.js +13 -5
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/weatherDraw.js +141 -0
- package/modules/world/World.js +2 -2
- package/modules/world/views.js +1 -1
- package/package.json +3 -2
- package/presets.js +2 -2
- package/render/PostFX.js +199 -41
- package/render/backend.js +52 -6
- package/render/cascades.js +195 -0
- package/render/cascades.tsl.js +96 -0
- package/render/daylight.js +39 -0
- package/render/detail.js +5 -5
- package/render/effects.js +41 -26
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/index.js +7 -5
- package/render/fx/patchNodes.tsl.js +1 -1
- package/render/fx/postWebGPU.tsl.js +30 -7
- package/render/fx/sky.tsl.js +19 -92
- package/render/fx/water.tsl.js +1 -1
- package/render/layers.js +14 -0
- package/render/lighting.js +6 -5
- package/render/lightmap.js +142 -0
- package/render/lights.js +23 -201
- package/render/materials.js +44 -160
- package/render/neutral.js +23 -0
- package/render/occlusion.js +184 -0
- package/render/ownFrame.js +1 -1
- package/render/patches.js +34 -29
- package/render/postWebGL.js +11 -3
- package/render/probes.js +179 -122
- package/render/slots.js +4 -4
- package/render/terms.js +53 -101
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +333 -296
- package/types/gameplay.d.ts +65 -26
- package/types/generated/core/Audio.d.ts +1 -1
- package/types/generated/core/DebugOverrides.d.ts +14 -6
- package/types/generated/core/Input.d.ts +9 -2
- package/types/generated/core/page.d.ts +9 -2
- package/types/generated/modules/grid/Layer.d.ts +8 -0
- package/types/generated/modules/grid/index.d.ts +29 -5
- package/types/generated/modules/particles/Particles.d.ts +13 -6
- package/types/generated/modules/sky/Sky.d.ts +85 -18
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/water/Water.d.ts +50 -3
- package/types/generated/modules/weather/Weather.d.ts +33 -3
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +2 -2
- package/types/generated/render/PostFX.d.ts +53 -10
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +19 -44
- package/types/generated/render/occlusion.d.ts +13 -0
- package/types/physics.d.ts +5 -3
- package/types/tsl.d.ts +8 -0
- package/types/world.d.ts +376 -57
- package/ui/Focus.js +12 -2
- package/ui/LoadingScreen.js +2 -2
- package/ui/Parts.js +8 -4
- package/ui/UI.js +10 -10
- package/ui/cursor.js +1 -1
- package/ui/theme.js +33 -27
- package/ui/touchPart.js +1 -1
- package/core/look/coreParts.js +0 -219
- package/core/look/part.js +0 -253
- package/core/look/points.js +0 -255
- package/core/look/report.js +0 -96
- package/core/look/shadowPart.js +0 -63
- package/core/look/state.js +0 -45
- package/core/look/write.js +0 -70
- package/core/styleParts.js +0 -114
- package/docs/api/style.md +0 -136
- package/docs/api/terrainLook.md +0 -10
- package/docs/api/vegetationLook.md +0 -10
- package/docs/api/weatherLook.md +0 -10
- package/docs/recipes/09-style.md +0 -218
- package/docs/recipes/35-style-from-reference.md +0 -153
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/38-environment-look-hooks.md +0 -99
- package/docs/recipes/41-thing-registry.md +0 -97
- package/docs/recipes/44-water-weather-look-hooks.md +0 -144
- package/docs/recipes/48-make-material.md +0 -75
- package/docs/recipes/52-look.md +0 -282
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
- package/examples/webgpu-tsl/tslScene.js +0 -75
- package/examples/world/style/index.js +0 -61
- package/examples/world/style/plugins/10-bloom.js +0 -5
- package/modules/sky/cascades.js +0 -186
- package/modules/sky/cascades.tsl.js +0 -82
- package/modules/sky/look.js +0 -54
- package/modules/sky/lookFog.js +0 -76
- package/modules/sky/lookShadow.js +0 -62
- package/modules/sky/lookSky.js +0 -169
- package/modules/sky/shadow.js +0 -98
- package/modules/terrain/look.js +0 -83
- package/modules/terrain/lookGround.js +0 -66
- package/modules/vegetation/look.js +0 -119
- package/modules/vegetation/lookWind.js +0 -98
- package/modules/water/look.js +0 -91
- package/modules/water/surfaceDefaults.js +0 -3
- package/modules/weather/look.js +0 -74
- package/modules/weather/weatherLook.js +0 -135
- package/render/lookGlow.js +0 -139
- package/render/lookSurface.js +0 -224
- package/render/postLook.js +0 -164
- package/render/surface.js +0 -105
- package/types/generated/modules/weather/weatherLook.d.ts +0 -12
- package/types/style.d.ts +0 -671
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Props and baking
|
|
2
2
|
|
|
3
3
|
**In this recipe**: 1. Prop data · 2. Large code-generated models and baking · 2a. Models in plain three.js · 2b. Many copies of one model ·
|
|
4
|
-
2c. Art iteration loop · 2d. Where art comes from · 3. Loading: what is it waiting for, what failed, does it… · 3b. Asset packs · 4. Verify ·
|
|
4
|
+
2c. Art iteration loop · 2d. Where art comes from · 2e. Plants on your own geometry and spots · 3. Loading: what is it waiting for, what failed, does it… · 3b. Asset packs · 4. Verify ·
|
|
5
5
|
5. Deleting objects
|
|
6
6
|
|
|
7
7
|
**Props** are a small number of hand-placed objects (a tree next to a cabin, rocks, street lamps). Write them as data; each entry becomes an ordinary
|
|
8
8
|
`kind: 'prop'` record in `engine.world` (needs `world()`, which `openWorld()` already includes). The model is created only when the player gets close
|
|
9
9
|
(within terrain view distance), and **the collision body and ray registration are built with the model and removed when the player leaves** (only
|
|
10
10
|
things near the player need to block the way).
|
|
11
|
-
Large repeated areas (forests, grass) don't use this; use `content/vegetation.js` (instanced vegetation).
|
|
11
|
+
Large repeated areas (forests, grass) don't use this; use `content/vegetation.js` (instanced vegetation), or section 2e for plants on your own geometry.
|
|
12
12
|
|
|
13
13
|
## 1. Prop data
|
|
14
14
|
`games/<game>/content/props.js` (a list; remember to add it to `content/index.js`):
|
|
@@ -23,7 +23,7 @@ export default [
|
|
|
23
23
|
```
|
|
24
24
|
Fields: `id` (stable id, see below), `model`, `place` + `x/z` (relative to the place), `floor` (on multi-layer ground — a second storey, a bridge
|
|
25
25
|
deck, a lower dungeon level — the reference height of the layer it stands on; a level-marker place lends its own height), `y` (height above that
|
|
26
|
-
ground), `rot`, `scale`, `collide` (`'box'` / `'circle'` / omitted = does not block), `static: false` (do not register for rays), `batch: false` (see 2b).
|
|
26
|
+
ground), `rot`, `scale`, `collide` (`'box'` / `'circle'` / `{ circle: 0.25, occluder: false }` / omitted = does not block; a circle stands on the model's base, see recipes/30-templates.md), `static: false` (do not register for rays), `batch: false` (see 2b).
|
|
27
27
|
An entry with `template` instead of `model` (`{ template: 'chest', x: 3, z: 1 }`) places an instance of a content template: a reusable object with
|
|
28
28
|
interaction, container and saved state (recipe 30).
|
|
29
29
|
A model is always an **asset name**, never a path or a function (`npm run check` reports both): register it in a manifest or asset pack first.
|
|
@@ -61,7 +61,7 @@ there when you come back.
|
|
|
61
61
|
Procedural models of an asset pack (props, templates, vegetation, pickups) are built through that one path: if baked, the file in
|
|
62
62
|
`public/models/baked/` is read; during development the result is cached automatically.
|
|
63
63
|
Other things made in code have one home each: a texture made in code goes in the manifest's `textures` (a Texture or a function returning one), a
|
|
64
|
-
sound made in code (a synth function) in its `sounds`, and a material made in code is
|
|
64
|
+
sound made in code (a synth function) in its `sounds`, and a material made in code is plain three.js in the game's `picture/` (recipe 09), not an asset.
|
|
65
65
|
Models are obtained asynchronously and the loading screen waits for them (`engine.world.ready`: every model that should exist nearby at the start is
|
|
66
66
|
built); `world.view(id)` works after `start()`; a model built later when the player walks up appears one or two frames late (to wait,
|
|
67
67
|
`await engine.world.whenReady`).
|
|
@@ -77,7 +77,7 @@ const block = await engine.assets.model('city-block');
|
|
|
77
77
|
engine.use(level({ url: 'city-block' })); // a level reads it by name (the city example does this): baked file and cache both apply, and loading a save can switch back to this map
|
|
78
78
|
```
|
|
79
79
|
To package a release or edit it in Blender, create `bake.js` in the game folder (`npm run bake -- -w <game>` reads the `bake` export of `bake.js`
|
|
80
|
-
in that game's folder). A game's
|
|
80
|
+
in that game's folder). A game's picture lives in its own `picture/` folder; a model built there is baked the same way, by importing its
|
|
81
81
|
builder into `bake.js`:
|
|
82
82
|
```js
|
|
83
83
|
// games/<game>/bake.js
|
|
@@ -95,27 +95,25 @@ No model file yet? Don't add loose `THREE.Mesh(new THREE.BoxGeometry())` calls t
|
|
|
95
95
|
it by name, and use the name everywhere. Later a `.glb` registered under the same name replaces it with no other change.
|
|
96
96
|
|
|
97
97
|
**The generator contract**
|
|
98
|
-
- Return a `BufferGeometry` (drawn with
|
|
98
|
+
- Return a `BufferGeometry` (drawn with a neutral gray material, or white under its vertex colors) or an `Object3D`
|
|
99
99
|
(a Mesh or a Group, with any number of meshes and materials, used as it is). It may be `async`.
|
|
100
100
|
- Arguments: `model: ['name', ...args]` in content passes them as written (each argument list is its own cached model). Or declare a schema,
|
|
101
101
|
`{ build, params: { height: { type: 'number', min: 1, max: 8, default: 3 }, leaf: { type: 'color', default: 0x4a7a3a } } }` (the
|
|
102
102
|
`core/params.js` format, plus `'color'`): the generator then gets one object, defaults < dev panel values < a call's own `['pine', { height: 5 }]`,
|
|
103
103
|
and a typo or wrong type throws naming the field.
|
|
104
|
-
- Written as `function` (not an arrow), `this` is `{ palette, engine }`: `this.palette` = `
|
|
104
|
+
- Written as `function` (not an arrow), `this` is `{ palette, engine }`: `this.palette` = `engine.assets.palette`, `this.engine` = the engine.
|
|
105
105
|
- Shadows: `{ build, castShadow: false }` in the manifest turns them off for every mesh. Without it, a generator that set `castShadow` or
|
|
106
106
|
`receiveShadow` on any of its meshes keeps its own flags (a rug that receives but does not cast); one that set none casts and receives
|
|
107
107
|
everywhere. The same rule holds for `assets.model(name)` and content props.
|
|
108
108
|
- It runs once per name + params; every placement is a clone sharing geometry and materials (`engine.assets.model(name)` and content props alike).
|
|
109
|
-
- Cache key = name + the generator's source (its file and imports) + params + `
|
|
109
|
+
- Cache key = name + the generator's source (its file and imports) + params + `engine.assets.palette`. Values it reads from outer variables must go in
|
|
110
110
|
`params`, or a change keeps the stale model. In dev a build slower than `assets.cacheMinMs` (20 ms) is stored as GLB in `.threedog/cache` and
|
|
111
111
|
read back next time; `npm run bake` writes the same GLB to `public/models/baked/` (section 2). Neither is needed: unbaked generators run in the
|
|
112
112
|
built game (`npm run build`) too.
|
|
113
113
|
- What the GLB round trip keeps: the hierarchy, names, `userData`, shadow flags, visibility, every material's type and settings, and textures in
|
|
114
|
-
standard slots (`map`, `normalMap`, ...; also ones made in code like `CanvasTexture`). A material
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`onBeforeCompile`, `lightMap` / `specularMap` / `envMap` and a hand-made toon `gradientMap` (glTF has no slot: the bake warns once naming the
|
|
118
|
-
model and slots), `ShaderMaterial` texture uniforms, and the identity of uniform objects (code holding `mat.uniforms.time` stops driving the
|
|
114
|
+
standard slots (`map`, `normalMap`, ...; also ones made in code like `CanvasTexture`). A mesh with a material array comes back as one mesh per
|
|
115
|
+
material. **Lost**: a material's own `onBeforeCompile` and `applyEffects` patches, `lightMap` / `specularMap` / `envMap` and a toon `gradientMap`
|
|
116
|
+
(glTF has no slot: the bake warns once naming the model and slots), `ShaderMaterial` texture uniforms, and the identity of uniform objects (code holding `mat.uniforms.time` stops driving the
|
|
119
117
|
copy). For such a model write `{ build, cache: false }` (never stored in the dev cache, and don't bake it), or set that material after loading.
|
|
120
118
|
|
|
121
119
|
```js
|
|
@@ -123,8 +121,8 @@ import * as THREE from 'three';
|
|
|
123
121
|
import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
|
|
124
122
|
|
|
125
123
|
function lampPost() {
|
|
126
|
-
const pole =
|
|
127
|
-
const glass =
|
|
124
|
+
const pole = new THREE.MeshStandardMaterial({ color: this.palette.metal ?? 0x3a3d42, roughness: 0.5, metalness: 0.8 });
|
|
125
|
+
const glass = new THREE.MeshStandardMaterial({ color: 0xfff2c0, emissive: 0xffd27a, emissiveIntensity: 1.5 });
|
|
128
126
|
const root = new THREE.Group();
|
|
129
127
|
const base = new THREE.Mesh(new RoundedBoxGeometry(0.5, 0.3, 0.5, 2, 0.05), pole); base.position.y = 0.15;
|
|
130
128
|
const post = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.07, 3, 12), pole); post.position.y = 1.8;
|
|
@@ -137,15 +135,15 @@ engine.assets.manifest({ name: 'props', models: { lampPost } });
|
|
|
137
135
|
// content/props.js: { model: 'lampPost', x: 4, z: 2, collide: 'circle' } code: engine.add(await engine.assets.model('lampPost'), { id: 'lamp-1' })
|
|
138
136
|
```
|
|
139
137
|
|
|
140
|
-
**Where the colors come from
|
|
141
|
-
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
**Where the colors come from**
|
|
139
|
+
- **The model's own three.js materials** (`new THREE.MeshStandardMaterial({ map: canvasTexture })`, a `ShaderMaterial`), any type a game's picture calls for.
|
|
140
|
+
- **Colors shared between models** live in the palette: read `this.palette.metal` in the generator, as the lamp post does.
|
|
141
|
+
- Vertex colors for a merged model: `mergeColored([[geometry, this.palette.wood], ...])` returns one geometry.
|
|
142
|
+
|
|
143
|
+
**The palette.** `engine.assets.palette` is a plain object of named colors: `engine.assets.palette = { wood: 0x8a5a36, leaf: 0xd98a3a }`, or write one key.
|
|
144
|
+
Generators and code-made textures read it as `this.palette`. Set it before the models load; after a write, whatever is asked for next is built from the
|
|
145
|
+
new colors, while copies already placed keep theirs. `.glb` files never follow it, and a baked file (built with no palette) is skipped while the palette
|
|
146
|
+
has keys, unless its bake entry says `source: 'file'`.
|
|
149
147
|
|
|
150
148
|
Very detailed models (faces, sculpted shapes, hand-painted textures) are faster in Blender: export a GLB and register it (recipe 46).
|
|
151
149
|
|
|
@@ -182,7 +180,7 @@ engine.batching.enabled = false; // global switch; createEngine({
|
|
|
182
180
|
geometry `hlod` registered (hlod owns far, batching owns near).
|
|
183
181
|
|
|
184
182
|
## 2c. Art iteration loop: edit -> hot swap -> gallery -> compare
|
|
185
|
-
Works for any model made in code (a hut, a weapon, a coral, a character body), in any art style; the tools only build and show, they add no
|
|
183
|
+
Works for any model made in code (a hut, a weapon, a coral, a character body), in any art style; the tools only build and show, they add no picture.
|
|
186
184
|
For the models that matter (characters, main buildings, props repeated across the level), think through the parts and their proportions before
|
|
187
185
|
writing code, and afterwards look at the model on its own, not only inside the level: `threedog gallery --shots` draws each one from a single
|
|
188
186
|
three-quarter view under three lights. When something seems off, turn it on the live turntable (`threedog gallery`) to see it from another side.
|
|
@@ -195,15 +193,15 @@ three-quarter view under three lights. When something seems off, turn it on the
|
|
|
195
193
|
schema's `default` where the model is registered.
|
|
196
194
|
- **Review all at once**: `?gallery=1` on the dev page, or `threedog gallery`, puts every registered model and texture on a turntable under
|
|
197
195
|
three neutral light setups (midday, low sun, overcast). `threedog gallery --shots` writes `.threedog/gallery/<name>-<light>.png` and an
|
|
198
|
-
`index.html` of all of them, so one
|
|
196
|
+
`index.html` of all of them, so one picture covers the whole set.
|
|
199
197
|
- **Outline and light/dark on their own**: `--shots --mode silhouette,value` adds `<name>-silhouette.png` (the model pure black on white) and
|
|
200
198
|
`<name>-value.png` (the midday shot in grayscale) per asset, with facts printed and stored in `index.json`: `fill` (share of the frame),
|
|
201
199
|
`boxFill` (share of its own bounding box), `aspect`, and luminance `p5` / `p50` / `p95` inside the outline. They are measurements, not
|
|
202
200
|
grades. Principle for reading them: a shape the player must recognize at play distance usually still reads as a silhouette, and a
|
|
203
|
-
narrow p5-p95 spread means hue carries the form; whether that is right depends on the game's
|
|
201
|
+
narrow p5-p95 spread means hue carries the form; whether that is right depends on the game's picture and camera, so compare assets that must
|
|
204
202
|
be told apart with each other rather than with a fixed number.
|
|
205
|
-
- **Compare with the reference**: `threedog
|
|
206
|
-
for one asset against its reference crop, the same way as for a whole screenshot (`recipes/35-
|
|
203
|
+
- **Compare with the reference**: `threedog picture compare <reference.png> .threedog/gallery/<name>-midday.png --out diff.png` gives numbers
|
|
204
|
+
for one asset against its reference crop, the same way as for a whole screenshot (`recipes/35-picture-from-reference.md`).
|
|
207
205
|
|
|
208
206
|
## 2d. Where art comes from
|
|
209
207
|
The engine ships no art and picks no source: the game records its choice per kind (ground, vegetation, characters, props, effects, sounds) in
|
|
@@ -211,12 +209,14 @@ the DESIGN.md "Asset sources" row, and every source ends up the same way, as a n
|
|
|
211
209
|
|
|
212
210
|
| Source | Good for | How it enters |
|
|
213
211
|
|---|---|---|
|
|
214
|
-
| Code (sections 2 and 2a: three.js geometry, `mergeColored`,
|
|
212
|
+
| Code (sections 2 and 2a: three.js geometry, `mergeColored`, three.js materials) | blockout, props, variations, anything tuned by `params` | a generator function in the manifest |
|
|
215
213
|
| Blender -> glTF | sculpted or painted finish, rigs and clips | a `.glb` path; export settings, scale (1 unit = 1 m, Y-up, applied transforms), naming and which materials survive are in `recipes/46-blender-art-route.md` |
|
|
216
214
|
| Free libraries (for example Kenney and Quaternius models, Poly Haven textures and HDRIs) | a lot of consistent content fast | the files in `public/` or an asset pack (section 3b), then `threedog assets` |
|
|
217
215
|
| Your own earlier games | an effect, material, model or texture you already made and liked | `threedog lib list` / `lib pull` (below), or `threedog art copy ../earlier-game name` |
|
|
218
216
|
| AI-generated 3D / textures | one-off props, texture variations | export glTF / PNG, then the same checks as any file: `threedog assets check`, scale, origin, triangle count, UVs |
|
|
219
217
|
|
|
218
|
+
**Does it fit?** Every entry has one card, measured at `lib add`: what it needs, what it provides, which shared three.js values it writes, its size (1 unit = 1 meter, up axis, origin, texture color space), its style and a short usage; `threedog lib list <word> --card` prints it. Tag a style with `--style` in your own words (a pixel-art dungeon and a watercolor village both work): only tags can say that, and two entries with no tag in common are reported. After pulling several pieces, `threedog lib check` says what is missing and what clashes, and `threedog lib status` says which copies this game changed. Nothing is forced: fix a clash in your copy, or leave a note you meant.
|
|
219
|
+
|
|
220
220
|
**Your own library.** `threedog lib add <file|folder|exportName> -w earlier-game` keeps a piece of a finished game in `~/.threedog/library` (outside the engine; `THREEDOG_LIBRARY` or `--lib` moves it) with a summary, the use line and the backends it works on; `threedog lib list [words]` searches it, `threedog lib pull <name>` copies it into this game and prints the use line (a code entry: its files go to `plugins/<name>/` and pull writes `plugins/<name>.js`, the one wiring line that calls its factory, from the entry's plug line: `lib add --plug "makeWater({ size: 4 })"` sets it, otherwise it calls the exported function; change the arguments in that file), `threedog lib page` writes a page with all previews. Look here before writing an effect from scratch. A pulled entry is a copy with no link back and no update: change it to fit this game rather than keeping it as it was, or every game ends up looking alike.
|
|
221
221
|
|
|
222
222
|
**Rules (correctness and licensing):**
|
|
@@ -229,12 +229,28 @@ the DESIGN.md "Asset sources" row, and every source ends up the same way, as a n
|
|
|
229
229
|
|
|
230
230
|
**Principles (style, flexible):**
|
|
231
231
|
- Mixed sources read as one game when they share one texture language (flat color, painted, or photo-based; one texel density; one
|
|
232
|
-
roughness range) and one palette. When a source does not match, re-material it: keep its shape and swap its materials for the game's
|
|
233
|
-
(`recipes/46-blender-art-route.md` section 5) or tint it from the palette, rather than adding a second
|
|
232
|
+
roughness range) and one palette. When a source does not match, re-material it: keep its shape and swap its materials for the game's own
|
|
233
|
+
(`recipes/46-blender-art-route.md` section 5) or tint it from the palette, rather than adding a second style.
|
|
234
234
|
- AI-generated meshes usually need cleanup: merge stray parts, set the origin at the base, reduce triangles, and replace baked-in lighting in
|
|
235
235
|
the texture so the game's lights decide the shading.
|
|
236
236
|
- Put a new asset next to the existing ones in `threedog gallery --shots` (and `--mode silhouette,value`) to see whether it stands apart.
|
|
237
237
|
|
|
238
|
+
## 2e. Plants on your own geometry and spots
|
|
239
|
+
Grass, flowers, bushes and trees need no model files and no random scatter: give `vegetation.define` a three.js geometry and the places you want. One instanced
|
|
240
|
+
mesh per species, wind, shadows, LOD and felling come with it; the geometry (and material) stay yours.
|
|
241
|
+
```js
|
|
242
|
+
import { THREE, vegetation } from 'threedog'; // collision() must be installed for the collider below
|
|
243
|
+
engine.use(vegetation({ area: { min: [-30, -30], max: [30, 30] } })); // on any ground: setGround, a level, or the flat default
|
|
244
|
+
const crown = new THREE.IcosahedronGeometry(1.2, 1).translate(0, 3, 0); // geometry baked at its final shape; origin at the foot
|
|
245
|
+
engine.vegetation.define('tree', {
|
|
246
|
+
geometry: crown, material: new THREE.MeshStandardMaterial({ color: 0x3f7a3a, flatShading: true }), // omitted: engine.vegetation.material
|
|
247
|
+
positions: [[-8, 4], [6, -3, 1.3], [10, 9, 0.8, 1.2]], // [x, z] | [x, z, scale] | [x, z, scale, yaw], planted at the ground height
|
|
248
|
+
wind: 0.2, castShadow: true, rule: { collider: 0.5 } }); // collider: a trunk radius players and NPCs cannot walk through
|
|
249
|
+
const hit = engine.vegetation.instanceAt(engine.actorPosition(), { radius: 2, species: 'tree' }); // the nearest one, or null
|
|
250
|
+
```
|
|
251
|
+
`define` with a model name returns a Promise; with a `geometry` it is immediate. Many small spots (grass) use `rule: { perChunk }` and `nearOnly: true` instead
|
|
252
|
+
of `positions`; recipe 10 section 4 has both, `densityMap` and felling (`removeInstance`).
|
|
253
|
+
|
|
238
254
|
## 3. Loading: what is it waiting for, what failed, does it block the start
|
|
239
255
|
Every asset load is a task in `engine.loading` (so are module init / `isReady`, the stream's nearby builds and the game's own steps). Each task has a
|
|
240
256
|
phase (`queued` → `download` → `decode` → `upload` / `build` → `done` | `failed`), progress, the error (file, HTTP status, a texture or `.bin` the
|
|
@@ -272,14 +288,14 @@ engine.assets.manifest({ name: 'mine', models: { oak: '/models/my-oak.glb' } });
|
|
|
272
288
|
```
|
|
273
289
|
A generator function is also an entry (`models: { pine: () => geometry }`): an asset pack exports its procedural models this way.
|
|
274
290
|
|
|
275
|
-
Fonts are entries too, and
|
|
291
|
+
Fonts are entries too, and the UI names them instead of holding the file:
|
|
276
292
|
```js
|
|
277
|
-
const engine = createEngine({ canvas,
|
|
293
|
+
const engine = createEngine({ canvas, ui: { fonts: ['pixel', 'pixelBold'], theme: { font: '"pixel", system-ui' } } });
|
|
278
294
|
engine.assets.manifest({ name: 'ui-fonts', base: '/fonts/', fonts: { pixel: 'pixel.woff2', pixelBold: { url: 'pixel-bold.woff2', family: 'pixel', weight: 700 } } });
|
|
279
295
|
```
|
|
280
296
|
`family` defaults to the asset name; the other keys are FontFace descriptors (`weight`, `style`, `unicodeRange`, ...). `start()` loads the fonts
|
|
281
|
-
`
|
|
282
|
-
`preload: true`. A file that fails falls back to the next family of `
|
|
297
|
+
`createEngine({ ui: { fonts } })` lists (an unknown name stops it with the line to add); other font entries load only on `engine.assets.font(name)` or with
|
|
298
|
+
`preload: true`. A file that fails falls back to the next family of `ui.theme.font` unless it is `critical`.
|
|
283
299
|
|
|
284
300
|
## 4. Verify
|
|
285
301
|
- `npm run check`: prop model names and place names are validated. After `npm run map`, GAMEMAP.md has a props table.
|
|
@@ -292,4 +308,4 @@ engine.assets.manifest({ name: 'ui-fonts', base: '/fonts/', fonts: { pixel: 'pix
|
|
|
292
308
|
## 5. Deleting objects
|
|
293
309
|
`engine.remove(obj)` deletes an object and frees its GPU memory; `engine.detach(obj)` only takes it off for a while (add it back with `engine.add`).
|
|
294
310
|
Don't call `obj.removeFromParent()` or `scene.remove()` on meshes you built: their geometry and materials would leak.
|
|
295
|
-
(`thing.remove` (`
|
|
311
|
+
(`thing.remove` (`40-scene.md`) deletes a registered object so that an undo can bring it back; `engine.remove` is final.)
|
|
@@ -66,13 +66,13 @@ The engine itself runs on the fixed step except the wall-clock items in the tabl
|
|
|
66
66
|
"After how long / every how long" uses `engine.clock` (part of the core; one timer queue for every view: `{ channel: 'real' | '<channel>' }`, default calendar seconds; a removed timer never fires, not even later in the same step); "at what time every day / within a time window / when the season changes"
|
|
67
67
|
uses `engine.calendar` (the `calendar()` module with a `dayLength`; at a fixed time of day these never fire).
|
|
68
68
|
|
|
69
|
-
**The calendar is gameplay, the sky is a
|
|
69
|
+
**The calendar is gameplay, the sky is a picture.** `calendar()` owns the time of day, the day, seasons, the timers below and their save; NPC schedules,
|
|
70
70
|
content `clock` conditions, audio rules `{ time }` / `{ daylight }`, `engine.skip({ to })` and the debug panel read it. `sky()` only reads it to draw
|
|
71
71
|
the sun, moon, colors and season tint. So each kind of game installs what it needs:
|
|
72
72
|
- an outdoor day-night game: `calendar(presets.calendar.cycle), sky()` (`openWorld()` installs both; its `calendar` / `time` / `dayLength` go to the calendar);
|
|
73
73
|
- an indoor shop, office or dungeon with opening hours and NPC shifts: `calendar({ dayLength: 600, hoursPerDay: 24 })` and no sky at all;
|
|
74
74
|
- a management sim on a painted backdrop or a game with its own sky dome: `calendar()` and the game's own drawing reading `engine.calendar.timeOfDay`
|
|
75
|
-
(or `engine.uniforms.uTimeOfDay
|
|
75
|
+
(or `engine.uniforms.uTimeOfDay`, which the calendar writes even with no sky);
|
|
76
76
|
- a survival game with a short brutal day and long seasons: `calendar({ dayLength: 240, seasons: [{ name: 'thaw', days: 3 }, { name: 'frost', days: 9 }] })`;
|
|
77
77
|
- an arena or a level at one frozen hour: `sky({ time: '18:30' })` alone (no calendar: the sky draws that fixed time; nothing has a schedule).
|
|
78
78
|
A game's own calendar (turns, a lunar calendar) replaces the module by meeting `modules/calendar/contract.js` (recipe 55 "Replacing a module").
|
|
@@ -96,7 +96,7 @@ engine.events.on('bread:ready', ({ oven }) => engine.inventory?.add('bread', 1))
|
|
|
96
96
|
|
|
97
97
|
engine.clock.every(30, () => spawnBird()); // every 30 calendar seconds (not 30 clock seconds)
|
|
98
98
|
engine.calendar.daily(day => console.log('day', day)); // every day at 00:00
|
|
99
|
-
engine.calendar.onSeason('winter', () => engine.weather?.set('snow', 20)); // needs seasons (presets.calendar.fourSeasons) and a 'snow' weather (presets.weather.temperate)
|
|
99
|
+
engine.calendar.onSeason('winter', () => engine.weather?.set('snow', { seconds: 20 })); // needs seasons (presets.calendar.fourSeasons) and a 'snow' weather (presets.weather.temperate)
|
|
100
100
|
|
|
101
101
|
// Clock conversion: 'HH:MM' <-> fraction of a day 0-1
|
|
102
102
|
engine.calendar.timeOfDay = parseClock('17:30'); // jump straight to 17:30 (see the catch-up rules below)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Scene transitions and pause (flow)
|
|
2
2
|
|
|
3
|
+
**In this recipe**: 1. Pause, title, ending · 1b. Start and continue · 2. Changing scene · 2b. Input contexts · 3. Verify · 4. Sessions · 5. Window and device
|
|
4
|
+
|
|
3
5
|
Needs the module `flow()` (not in openWorld; add it yourself: `engine.use(openWorld({ camera: 'follow', ...}), flow())`).
|
|
4
6
|
- **Flow states**: title, playing (built-in `playing`), paused (built-in `paused`: freezes gameplay + locks input), ending, ... Only one is active at a time.
|
|
5
7
|
- **Scene transition** `transition(fn)`: lock input -> fade to black -> fade music out -> (with `{ autosave: 'auto' }` save slot 'auto'; off by
|
|
@@ -46,6 +48,8 @@ A game's own windows made with `makeWindow` are pushed automatically (`onCancel`
|
|
|
46
48
|
import { uiFocus } from 'threedog';
|
|
47
49
|
const h = uiFocus(engine).push('myMap', { cancel: () => closeMap() }); // call h.remove() when closing; h.fresh = opened this very frame
|
|
48
50
|
```
|
|
51
|
+
An entry with a `nav` (every window, the settings menu, dialogue choices) lets go of a locked mouse when it opens. For anything else, `engine.page.releaseLock()` frees the mouse
|
|
52
|
+
(recipe 21); neither counts as the player's Esc, so the pause menu stays shut.
|
|
49
53
|
|
|
50
54
|
## 1b. Title -> start -> continue, and opening straight into a moment (screenshots, tests)
|
|
51
55
|
`flow({ start: 'title' })` enters the title during `engine.start()` (on `engine:ready`), so when `await engine.start()` returns the title is
|
|
@@ -66,10 +70,15 @@ if (moment) setUpMoment(moment); // the game's own data only; in code, time /
|
|
|
66
70
|
The engine's ready-made title (`createEngine({ ui: { title } })`, recipe 26 §5) opens in `start()` the same way: leave `title` out for a moment
|
|
67
71
|
(`ui: { ...(moment ? {} : { title: { title: 'My Game', items: ['continue', 'start'] } }) }`).
|
|
68
72
|
Shoot it with `npm run shot -- "/?moment=night" --time 22:20 --weather storm`; a game test opens the same URL.
|
|
73
|
+
To start at a named place, write no code: `?at=pier` (dev and tools, like the other URL keys; `npm run shot -- --at pier`, `applyState({ at: 'pier' })`) leaves the
|
|
74
|
+
start screen as `?play` does, stands the player at that place of `content/places.js` (or a level marker) after the game's `session:start` code ran, and puts the
|
|
75
|
+
game's camera there at once. An unknown name stops with the list of places. A camera of your own: listen to `state:placed` ({ x, z }).
|
|
76
|
+
|
|
69
77
|
To get past the title without a key of your own, use the engine's `?play` URL key (`npm run shot -- --play`, `applyState({ play: true })`): after
|
|
70
78
|
`engine:ready` it does what the title's Start does (`engine.session.newGame()`, then the title part closes), so `flow({ start: 'title' })` moves to
|
|
71
|
-
`'playing'` and the game's `session:start` setup runs; with no title up it does nothing.
|
|
72
|
-
|
|
79
|
+
`'playing'` and the game's `session:start` setup runs; with no title up it does nothing. `?fresh` (`applyState({ fresh: true })`) first deletes this
|
|
80
|
+
page's saves, so the title offers no Continue; on a running page it also ends the run. Two things that make a moment
|
|
81
|
+
drawing half-done in a picture: a headless page advances only on `engine.step` (the shot steps one frame after the game's code, so a
|
|
73
82
|
`weather.set(name, { seconds: 0.1 })` made after `start()` shows a third of the change: use `seconds: 0`), and an `onFrame` copy of a sky
|
|
74
83
|
color is one frame old (share `engine.uniforms.uSkyHorizon` instead, recipe 08).
|
|
75
84
|
|
|
@@ -157,7 +166,7 @@ One place listens to window focus, tab visibility, mouse lock and the WebGL cont
|
|
|
157
166
|
`engine.page.pauseOnBlur = false` keeps playing. Coming back resumes with no catch-up burst; a long frame turns into at most 0.1 s of fixed steps,
|
|
158
167
|
and fewer when the steps are heavy (at most about 33 ms of catch-up work per frame; the rest is dropped as a brief slow-down). `engine.step()` never drops time.
|
|
159
168
|
- `engine.events.on('page:blur', () => engine.flow?.go('paused'))` also opens the pause menu. Other events: `page:focus`,
|
|
160
|
-
`page:pointerlock { locked }` (cameras lock again on the next click), `page:contextlost` / `page:contextrestored` (gameplay waits and the player
|
|
169
|
+
`page:pointerlock { locked, byEngine }` (cameras lock again on the next click; a lock the player ended counts as Esc, because the browser keeps that key), `page:contextlost` / `page:contextrestored` (gameplay waits and the player
|
|
161
170
|
sees a message; three.js restores the context).
|
|
162
171
|
- `engine.step()` still advances while away (tests, dev bridge). Held keys are released by Input.
|
|
163
172
|
- Tests: `npm test -- "Session:" "Window:"`.
|
|
@@ -2,34 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
**In this recipe**: 1. Switching weather · 2. The game's own weather table · 3. Sky colors, sun, stars (and the sky color for your own shader) · 4. Time and brightness (how a game's value and the weather multiply) · 5. Verify · 6. Day and night in game logic · 7. Wet roads
|
|
4
4
|
|
|
5
|
-
Modules: `sky()` (draws
|
|
6
|
-
lightning
|
|
5
|
+
Modules: `sky()` (draws the dome from `engine.calendar`, sun and moon, and computes the signals; it writes no light, fog or exposure, those are your `picture/` code, recipe 62; the time itself is `calendar()`, recipe 06), `weather()` (needs sky; the game's weather types, smooth transitions, rain and snow,
|
|
6
|
+
lightning; their picture is `weather({ rain, snow, lightning })`, recipe 44). The engine has only a neutral fallback.
|
|
7
7
|
|
|
8
8
|
```js
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
engine.
|
|
12
|
-
|
|
13
|
-
engine.
|
|
9
|
+
engine.use(sky({ keyframes: ROWS, sunSize: 600, clouds: { coverage: 0.6 }, dim: { stars: false } })); // start values
|
|
10
|
+
engine.uniforms.uSunPower.value = 4; // sun, moon, star and dome cloud numbers: engine.uniforms, the dome's own objects, on both renderers
|
|
11
|
+
engine.uniforms.uCloudCover.value = 0.8; // also uSunSize uSunGlow uMoonSize uMoonPower uMoonColor uStars uStarScale uCurve uSkyCloudScale uSkyCloudSpeed uCloudOpacity uCloudSoft uCloudColor uCloudShade
|
|
12
|
+
engine.sky.top = boss ? '#400' : null; // plain fields, read each frame: top, horizon (color over the keyframes, null = keyframes), orbit.tilt / sway, dim.tint / stars
|
|
13
|
+
engine.sky.backdrop = 0x335577; // one flat color in place of the dome; null gives the dome back
|
|
14
|
+
engine.sky.keyframes(NIGHT_ROWS); // the day's rows, live
|
|
15
|
+
engine.sky.clouds({ glsl, tsl }); // your cloud function; null = the built-in kind
|
|
16
|
+
engine.sky.layer('aurora', { glsl, tsl, blend: 'add' }); // a named dome layer; null removes it
|
|
17
|
+
const mySky = new THREE.Mesh(skyGeometry, skyMaterial); // or a skybox name, a Texture
|
|
18
|
+
engine.sky.replace(mySky); // skybox name | Texture | CubeTexture | Object3D, never written; null gives the dome back
|
|
19
|
+
mySky.material.uniforms.sunPosition = engine.uniforms.uSunDir; // the same Vector3, refreshed every frame
|
|
14
20
|
```
|
|
15
21
|
|
|
16
|
-
WebGPU (recipe 56): same dome
|
|
22
|
+
WebGPU (recipe 56): same dome as a node material. Hooks take `{ glsl, tsl: (ctx) => vec4 }` ([52](52-around-the-picture.md#tsl-forms)); GLSL alone throws `[webgpu-needs-tsl]`. Own sky: three's `SkyMesh` via `engine.sky.replace`.
|
|
17
23
|
|
|
18
|
-
The sky follows one contract: **inputs**
|
|
19
|
-
**outputs**
|
|
20
|
-
(`uSunDir`, `uDaylight`, `uTimeOfDay`, `uWind`, `uCloud`, season tints) and events (`day:start`, `season:change`, `weather:change`) that wind,
|
|
21
|
-
rain and vegetation read. The keyframes are only the default implementation:
|
|
22
|
-
|
|
23
|
-
`engine.use(mySky(), { replaces: 'sky' })`, recipe 52 [verbs](52-look.md#verbs)). The function gets `{ time, weather, season, day, state, sky }`: write `({ sky }) => sky.isDay ? ...`.
|
|
24
|
+
The sky follows one contract: **inputs** time, weather, season,
|
|
25
|
+
**outputs** the dome and the background, plus the shared `engine.uniforms`
|
|
26
|
+
(`uSunDir`, `uSunColor`, `uDaylight`, `uTimeOfDay`, `uSkyTop`, `uSkyHorizon`, `uWind`, `uCloud`, `uRain`, `uSnow`, `uWeatherLight`, `uWeatherFog` (the weather state writes the last six every frame), season tints) and events (`day:start`, `season:change`, `weather:change`) that wind,
|
|
27
|
+
rain and vegetation read. The keyframes are only the default implementation: `engine.sky.replace` swaps the whole dome and everything else keeps running (the whole sky module is
|
|
28
|
+
`engine.use(mySky(), { replaces: 'sky' })`).
|
|
24
29
|
|
|
25
|
-
### Your own sky object: what `
|
|
30
|
+
### Your own sky object: what `engine.sky.replace(obj)` does with it
|
|
26
31
|
The engine hides its dome, adds `obj` to the scene root when it has no parent yet (and removes it again on `replace(null)` only then), and from
|
|
27
32
|
then on **never moves, scales or writes it**: it does not follow the camera, is not scaled to the far plane and is not exempted from culling.
|
|
28
33
|
(The built-in dome does all three itself: an `onBeforeRender` copies the camera position and scales it to `0.9 × camera.far`.) So a dome of
|
|
29
34
|
your own must, on its own:
|
|
30
35
|
|
|
31
36
|
- **contain the camera and stay inside the far plane**: either a fixed sphere big enough for everywhere the camera goes (radius < `camera.far`,
|
|
32
|
-
which the engine pulls in to the view range unless you take it: `engine.
|
|
37
|
+
which the engine pulls in to the view range unless you take it: `engine.view.manual('far')`), or one that follows the camera; or skip
|
|
33
38
|
depth altogether as below, so the radius no longer matters;
|
|
34
39
|
- **compute the view direction per pixel from world space**: pass `worldPosition - cameraPosition` (linear, safe to interpolate) as the
|
|
35
40
|
varying and do every non-linear step (normalize, `atan`, projecting onto a cloud plane, noise) in the fragment shader. A direction taken from
|
|
@@ -59,7 +64,7 @@ const sky = new THREE.Mesh(new THREE.SphereGeometry(1, 32, 16), new THREE.Shader
|
|
|
59
64
|
}));
|
|
60
65
|
sky.frustumCulled = false; sky.renderOrder = -1000;
|
|
61
66
|
sky.onBeforeRender = (r, s, cam) => { sky.position.copy(cam.position); sky.updateMatrixWorld(); }; // centred on the camera: any radius works
|
|
62
|
-
engine.
|
|
67
|
+
engine.sky.replace(sky);
|
|
63
68
|
```
|
|
64
69
|
Time of day still reaches it through `engine.uniforms` (`uSunDir`, `uDaylight`, `uTimeOfDay` ...): put them in its `uniforms` to follow the day.
|
|
65
70
|
|
|
@@ -77,8 +82,7 @@ ones (clear cloudy overcast rain storm snow fog) are an opt-in preset: `weather(
|
|
|
77
82
|
`types: { ...presets.weather.temperate.types, dust: {...} }`.
|
|
78
83
|
The preset supplies types and an `autoPool`; the weather changes by itself only with `auto: true` (or `engine.weather.setAuto(true)`). To pin one
|
|
79
84
|
for a picture: `engine.weather.set('clear')`, or a shot's `--weather clear` (it also turns `auto` off); a shot prints the weather under the picture.
|
|
80
|
-
Left-out fields are calm (no cloud, rain, snow, grey, lightning; sun, fog, wind 1).
|
|
81
|
-
table leaves out, for types the game has (the table's own numbers win, a preset counts as the game's). There is no patch option for one field
|
|
85
|
+
Left-out fields are calm (no cloud, rain, snow, grey, lightning; sun, fog, wind 1). There is no patch option for one field
|
|
82
86
|
of a preset type: spread that one type, `const T = presets.weather.temperate.types; weather({ types: { ...T, rain: { ...T.rain, fog: 0.5 } } })`.
|
|
83
87
|
```js
|
|
84
88
|
import { createEngine, presets, sky, weather } from 'threedog';
|
|
@@ -92,45 +96,37 @@ Fields: `cloud` cloud cover 0-1, `sun` sunlight multiplier, `fog` fog distance m
|
|
|
92
96
|
0-1, `grey` how gray the sky turns, `lightning` lightning. A table where nothing rains or snows builds no particles.
|
|
93
97
|
With openWorld the weather module is already installed; pass its options through the preset: `openWorld({ camera: 'follow', weather: { types, autoPool } })`.
|
|
94
98
|
|
|
95
|
-
## 3. Changing sky colors, sun, stars
|
|
96
|
-
`sky
|
|
97
|
-
`[time 0-1, zenith color, horizon color
|
|
99
|
+
## 3. Changing sky colors, sun, stars
|
|
100
|
+
`sky({ keyframes })`:
|
|
101
|
+
`[time 0-1, zenith color, horizon color, sun color, ambient intensity]`, interpolated by time; the rows
|
|
98
102
|
run from time 0 to time 1 (both midnight: the first row at 0, the last at 1 with the same values), else the sky throws. What each column drives
|
|
99
|
-
(and which light carries the moonlight) is
|
|
100
|
-
also `sunSize sunGlow moonSize starDensity clouds
|
|
101
|
-
`calendar()` option, not a
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
environment (the light Standard / Lambert / Phong materials get from `scene.environment`) takes the share `look.lights` `env.share` (0..1) of
|
|
108
|
-
it and the hemisphere light the rest, so a dark-night pack is dark on PBR surfaces too and the sun keeps its contrast by day. `env.intensity` keeps
|
|
109
|
-
one meaning, the absolute `scene.environmentIntensity`: a game or pack that writes it under a sky gets that value as written (fixed, not following
|
|
110
|
-
the day; the hemisphere light then keeps the whole budget, `describe().look.env.source.mode` `'absolute'`). `describe().look.env.source` says which map lights
|
|
111
|
-
them (`room` / `sky` / `asset:<name>` / `game`) and `followsTime`; `look.env.replace('sky')` builds it from the dome instead (outdoor reflections
|
|
112
|
-
show the sky, not a studio; it darkens by itself), an asset map is a fixed photo and does not follow. Check with `shot --time 12:00` and `--time 22:00`.
|
|
113
|
-
The look of rain and snow is in `style.weather.rain / snow` (shape, density, shaders, the game's own particles: recipe 44).
|
|
103
|
+
(and which light carries the moonlight) is on `keyframes` in `SkyPictureOptions`, `types/world.d.ts`;
|
|
104
|
+
also `sunSize sunGlow moonSize starDensity clouds` (defaults and ranges there too; `hoursPerDay` is timing, so it is a
|
|
105
|
+
`calendar()` option, not a sky key). `sky()` takes `time` and the dome's start values: all of these are `sky({ ... })` start values; at run time use the entries at the top of this page. `sky({ sun | hemisphere | fog })`
|
|
106
|
+
throw naming what to write in your `picture/` code.
|
|
107
|
+
**Day and night brightness** is your `picture/` code: the sky lights nothing. Read `uDaylight` and write your own lights (recipe 62), and check with `shot --time 12:00` and
|
|
108
|
+
`--time 22:00`. The keyframes only color the dome; the ambient column also dims a skybox and the weather's sky tint. `engine.sky.environment({ into: engine.scene })` builds an environment map
|
|
109
|
+
from the dome (outdoor reflections show the sky, not a studio; it darkens by itself), recipe 34.
|
|
110
|
+
The look of rain and snow is `weather({ rain, snow })` (shape, density, shaders; the game's own particles with `engine.weather.define`: recipe 44).
|
|
114
111
|
|
|
115
112
|
### Sky color for my shader (horizon color, zenith color)
|
|
116
113
|
A shader of your own that should meet the sky (a sea fading to the horizon, distant cards, a reflection) reads the colors the sky draws this frame:
|
|
117
|
-
`engine.uniforms.uSkyHorizon` and `engine.uniforms.uSkyTop` (`THREE.Color`, linear). They hold the keyframes,
|
|
118
|
-
the weather's grey tint and lightning; with
|
|
119
|
-
|
|
120
|
-
(`look.fog.manual()`, `scene.fog = ...`). Share the object, do not copy it in `onFrame`: `onFrame` runs before the sky updates, so a copy is one
|
|
114
|
+
`engine.uniforms.uSkyHorizon` and `engine.uniforms.uSkyTop` (`THREE.Color`, linear). They hold the keyframes, `engine.sky.top` / `horizon`,
|
|
115
|
+
the weather's grey tint and lightning; with a backdrop the horizon is the backdrop color. A fog of yours that should melt into the sky copies
|
|
116
|
+
it in `engine.onRender`: `scene.fog.color.copy(engine.uniforms.uSkyHorizon.value)`. Share the object, do not copy it in `onFrame`: `onFrame` runs before the sky updates, so a copy is one
|
|
121
117
|
frame old (after a time jump, the first picture shows the old hour's color).
|
|
122
118
|
```js
|
|
123
119
|
const sea = new THREE.ShaderMaterial({ uniforms: { uHorizon: engine.uniforms.uSkyHorizon, uTop: engine.uniforms.uSkyTop, uSunDir: engine.uniforms.uSunDir },
|
|
124
120
|
fragmentShader: '... gl_FragColor = vec4(mix(base, uHorizon, fresnel), 1.0); #include <tonemapping_fragment> #include <colorspace_fragment>' /* ... */ });
|
|
125
121
|
engine.uniforms.uSkyHorizon.value.getHexString(); // read it in JS too (game logic, a HUD swatch)
|
|
126
122
|
```
|
|
127
|
-
`
|
|
123
|
+
`engine.sky.horizon` is the override a game set (`null` = the keyframes), not the drawn color.
|
|
128
124
|
|
|
129
125
|
## 4. Time and brightness (game code)
|
|
130
126
|
```js
|
|
131
127
|
await engine.skip({ to: '19:30' }); // jump forward to a time: timers, calendar.at / daily, day:start fire on the way (needs a calendar dayLength; recipe 06)
|
|
132
128
|
engine.mod('clock.rate', { owner: 'game', set: 0 }); // the calendar and calendar seconds stop together, so the sky stops moving (set: 2 = double speed; remove() undoes it); game seconds per day: calendar({ dayLength: 600 }); the three kinds of time are in recipe 06
|
|
133
|
-
engine.
|
|
129
|
+
engine.scene.fog = new THREE.Fog(0x99aabb, 90, 300); // fog is plain three.js; engine.uniforms.uViewDistance (terrain({ viewFog: true }) writes it) and uWeatherFog are signals your picture/ code reads
|
|
134
130
|
```
|
|
135
131
|
**The sky draws the calendar's time; it does not own it.** Day, time of day and seasons are the `calendar()` module (recipe 06 "The time table");
|
|
136
132
|
the sky reads `engine.calendar.timeOfDay` each frame to place the sun and blend the keyframes, and `engine.calendar.season` for the season tint.
|
|
@@ -148,26 +144,18 @@ Seasons are off by default (`engine.calendar.season` is `null`, no `season:chang
|
|
|
148
144
|
calendar({ seasons: ['spring', 'summer', 'autumn', 'winter'], daysPerSeason: 28, dayLength: 360 }); // days advance only with a dayLength; or the preset: openWorld({ camera: 'follow', calendar: presets.calendar.fourSeasons })
|
|
149
145
|
calendar({ seasons: [{ name: 'wet', days: 10 }, { name: 'dry', days: 20 }], dayLength: 360 }); // seasons of their own length
|
|
150
146
|
```
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
modifier layer below; to take it on purpose: `engine.look.lights.manual('sun')` (recipe 52 "Who writes it").
|
|
154
|
-
To darken or tint everything (a cave, a horror segment), add multipliers of your own on the look values; they stack with the weather's without
|
|
155
|
-
overwriting it ([recipe 52](52-look.md#how-look-values-stack)):
|
|
147
|
+
The lights and the fog are your own three.js objects, so nothing overwrites them. To darken or tint everything (a cave, a horror segment), your `picture/` code reads one signal of yours and multiplies
|
|
148
|
+
it in with the weather's (`uWeatherLight`, `uWeatherFog`); the sky color has its own shared points, which stack with the weather's without overwriting it ([recipe 55](55-mods-time-wrap.md#picture-points-follow-the-same-rule)):
|
|
156
149
|
```js
|
|
157
|
-
const cave =
|
|
158
|
-
|
|
159
|
-
engine.mod('look.sky.tint', { owner: 'cave', value: { color: 0x402030, amount: 0.5 } })]; // amount = zenith, horizon: = horizon
|
|
160
|
-
cave.forEach(h => h.remove()); // leave the cave
|
|
150
|
+
const cave = engine.mod('sky.tint', { owner: 'cave', value: { color: 0x402030, amount: 0.5 } }); // amount = zenith, horizon: = horizon
|
|
151
|
+
cave.remove(); // leave the cave
|
|
161
152
|
```
|
|
162
|
-
These are ordinary shared points (recipe 55):
|
|
163
|
-
entries blend weighted by their amount, `{ for: 3 }` ends one by itself. A game's own `look.lights.set({ sun: { intensity: 3 } })` is the base they
|
|
164
|
-
multiply: rain still dims it and the sunset still fades it (`engine.describe().shared['look.lights.sun.intensity'].how` says `arena 3 × weather 0.6`).
|
|
165
|
-
Write once and it stays in effect; no need to write every frame. For a gradual change, write a new value every frame.
|
|
153
|
+
These are ordinary shared points (recipe 55): `sky.flash` adds, `sky.tint` / `ground.cover` entries blend weighted by their amount, `{ for: 3 }` ends one by itself.
|
|
166
154
|
|
|
167
155
|
## 5. Verify
|
|
168
156
|
- Text: `npm run shot -- / --time 19:30 --weather dust --wait 2 --describe-only`, then look for "Time: 19:30..." and "Weather: dust (rain 0, snow 0, fog 0.35)".
|
|
169
157
|
`describe().weather` has `name progress rain snow fog wind cloud`; `describe().time` has `clock day season isDay dayLength rate`.
|
|
170
|
-
- Take a screenshot only after the
|
|
158
|
+
- Take a screenshot only after the picture changed: `npm run shot -- / --time 19:30 --weather dust`.
|
|
171
159
|
|
|
172
160
|
## 6. Day and night in game logic
|
|
173
161
|
Gameplay reads day and night from the calendar: test `engine.calendar.isDay`, and fade with `engine.calendar.daylight` (0-1); they work with or
|