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
package/core/plugins.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// engine.plugins: the plugins folder (docs/plans/2026-11-03-slot-map.md section 6). Each file in the game's plugins/ folder is imported at
|
|
2
2
|
// start and plugged in by WHAT it exports, through the one call a game would have written by hand:
|
|
3
3
|
// Object3D -> engine.add(obj, { id: <file name> }) (same as scene.add, plus a stable save id)
|
|
4
|
-
// three.js Pass (has render()) -> engine.
|
|
5
|
-
// post effect { name, create | node | fuse } -> engine.
|
|
6
|
-
// Material -> engine.look.materials.replace(role, mat) role = mat.name, else the file name
|
|
7
|
-
// ShaderPatch { slot, glsl|tsl } -> engine.look.materials.add(<file>, spec, { roles })
|
|
4
|
+
// three.js Pass (has render()) -> engine.post.add(pass, { name: <file name> })
|
|
5
|
+
// post effect { name, create | node | fuse } -> engine.post.add(effect) (create for WebGL, node for WebGPU: one file runs on both)
|
|
8
6
|
// module { name, type, install / init } -> engine.use(mod)
|
|
9
7
|
// an array of those -> each one, in array order
|
|
10
8
|
// anything else is a dev error naming the file and the shapes above. A function is never a plugin, on either renderer: a plugin says what it
|
|
@@ -15,42 +13,28 @@
|
|
|
15
13
|
// Order: by file name (10-fog.js before 20-bloom.js), or plugins/plugins.json { "order": [...], "off": [...] }. Nothing is sorted behind
|
|
16
14
|
// the game's back: describe().slots lists the order used.
|
|
17
15
|
// Off: plugins.json "off" (no code change), or engine.plugins.off(name) at run time; on(name) plugs it again.
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// Owners: every plugin is its own owner ('plugin:<file>', 'style:<pack>/<file>'); the pack only groups them. Why: with one owner per pack, B's
|
|
22
|
-
// remove dropped the key A had written too (A said on, the base came back). Two plugins writing one key on one layer is a shared-conflict naming
|
|
23
|
-
// both, unless one file says `export const replaces = '<other file>'` (then the other is unplugged while this one is on).
|
|
24
|
-
// Reach: a post effect, an object, a module change the picture at once ('live'); a material / material patch changes what makeMaterial makes
|
|
25
|
-
// NEXT ('new materials only'), so off / on rebuilds the materials already made (engine.look.materials.rebuild(); { rebuild: false } skips it).
|
|
16
|
+
// Owners: every plugin is its own owner ('plugin:<file>'). Why: with one owner for all, B's remove dropped the key A had written too (A said on,
|
|
17
|
+
// the base came back). Two plugins writing one key on one layer is a shared-conflict naming both, unless one file says `export const replaces = '<other file>'` (then the other is unplugged while this one is on).
|
|
18
|
+
// A Material or a ShaderPatch is no plugin: it says nothing about which mesh it belongs to, so it goes on that mesh or module in plain code.
|
|
26
19
|
// Places: a post effect keeps the place it first got (its name is reserved in plugin order), so off / on never reorders the chain.
|
|
27
|
-
// Why not a second loader for styles: one path means a plugin file works alone in plugins/ or inside any number of style packs, unchanged.
|
|
28
20
|
import { codedError } from './errorHints.js';
|
|
29
|
-
import { stylePlugins } from './styleParts.js';
|
|
30
21
|
import { MODULE_TYPES } from './moduleTypes.js';
|
|
31
22
|
|
|
32
23
|
const SHAPES = 'an Object3D (goes in the scene), a three.js Pass with render() (post chain), a post effect { name, create: ctx => pass, node: (input, ctx) => node } or { name, fuse } (post chain, both renderers), ' +
|
|
33
|
-
'a Material (look.materials role = material.name or the file name), a ShaderPatch { slot, glsl | tsl, roles? } (look.materials.add), ' +
|
|
34
24
|
"a module { name, type, install / init } (engine.use), or an array of these. Export it as default (export default new THREE.Mesh(...))";
|
|
35
25
|
|
|
36
26
|
/** Which slot a value plugs into, or null when it is none of the accepted shapes */
|
|
37
27
|
function shapeOf(v) {
|
|
38
28
|
if (v?.isObject3D) return 'scene';
|
|
39
|
-
if (v?.isMaterial) return
|
|
29
|
+
if (v?.isMaterial) return null; // it has name, type and dispose(), so the module test below would take it for a module
|
|
40
30
|
if (v && typeof v === 'object') {
|
|
41
31
|
if (typeof v.render === 'function' && 'needsSwap' in v) return 'post'; // three's Pass base class sets needsSwap: a Pass, not a module with render()
|
|
42
32
|
if (typeof v.name === 'string' && v.type && (v.install || v.init || v.fixed || v.frame || v.dispose)) return 'module';
|
|
43
33
|
if (typeof v.name === 'string' && (typeof v.create === 'function' || typeof v.node === 'function' || (v.fuse && typeof v.fuse === 'object'))) return 'post';
|
|
44
|
-
if (typeof v.glsl === 'string' || typeof v.glsl === 'object' || v.tsl) return 'patch';
|
|
45
34
|
}
|
|
46
35
|
return null;
|
|
47
36
|
}
|
|
48
37
|
|
|
49
|
-
const NEW = 'new materials only';
|
|
50
|
-
/** How far a slot reaches: a material or patch changes what makeMaterial makes next; everything else changes the picture at once */
|
|
51
|
-
const slotReach = slot => (slot === 'material' || slot === 'patch' ? NEW : 'live');
|
|
52
|
-
/** A plugin's reach: NEW when any of its values is a material / patch */
|
|
53
|
-
const reachOf = p => (p.values.some(v => slotReach(shapeOf(v)) === NEW) ? NEW : 'live');
|
|
54
38
|
/** The post chain name of a plugin's post value: an effect keeps its own name, a bare Pass is named by its file ('<file>/<i>' with several) */
|
|
55
39
|
const postName = (p, v, i) => (v.isPass || 'needsSwap' in v ? (p.values.length > 1 ? `${p.name}/${i}` : p.name) : v.name);
|
|
56
40
|
|
|
@@ -75,29 +59,25 @@ export class Plugins {
|
|
|
75
59
|
* @returns {this}
|
|
76
60
|
* @example engine.plugins.add(import.meta.glob('./plugins/*.js', { eager: true }), { off: ['20-bloom'] });
|
|
77
61
|
*/
|
|
78
|
-
add(files, { order = [], off = [] } = {}) {
|
|
79
|
-
|
|
80
|
-
/** @internal the one loader: the game's folder (group null) and each style pack's plugins (group = the pack's name, style layer) */
|
|
81
|
-
_add(files, { order = [], off = [], group = null }) {
|
|
62
|
+
add(files, { order = [], off = [] } = {}) {
|
|
82
63
|
const paths = Object.keys(files).sort((a, b) => baseOf(a) < baseOf(b) ? -1 : baseOf(a) > baseOf(b) ? 1 : 0);
|
|
83
64
|
const rank = n => { const i = order.indexOf(n); return i < 0 ? order.length : i; };
|
|
84
65
|
paths.sort((a, b) => rank(baseOf(a)) - rank(baseOf(b))); // stable sort: listed names first, the rest keep file-name order
|
|
85
66
|
for (const n of [...order, ...off]) if (!paths.some(p => baseOf(p) === n))
|
|
86
67
|
throw codedError('plugin-shape', `plugins.json names '${n}', but there is no plugins/${n}.js; files: ${paths.map(baseOf).join(', ') || 'none'}`);
|
|
87
|
-
const where = group ? `style ${group}: plugins/` : 'plugins/';
|
|
88
68
|
for (const path of paths) {
|
|
89
|
-
const ns = files[path], name =
|
|
69
|
+
const ns = files[path], name = baseOf(path);
|
|
90
70
|
// replaces: a word about the file, never plugged (a string is no plugin shape)
|
|
91
71
|
const named = ns && 'default' in ns ? [['default', ns.default]] : Object.entries(ns ?? {}).filter(([k]) => k !== 'replaces'), values = named.flatMap(([, v]) => [].concat(v));
|
|
92
|
-
if (!values.length) throw codedError('plugin-shape',
|
|
93
|
-
for (const [key, x] of named) for (const v of [].concat(x)) if (!shapeOf(v)) throw codedError('plugin-shape', notAPlugin(
|
|
94
|
-
const file =
|
|
95
|
-
const replaces = [].concat(ns?.replaces ?? []).map(
|
|
96
|
-
this._list.set(name, { name,
|
|
72
|
+
if (!values.length) throw codedError('plugin-shape', `plugins/${baseOf(path)}.js exports nothing. Fix: export default one of: ${SHAPES}`);
|
|
73
|
+
for (const [key, x] of named) for (const v of [].concat(x)) if (!shapeOf(v)) throw codedError('plugin-shape', notAPlugin(`plugins/${baseOf(path)}.js`, key, v));
|
|
74
|
+
const file = path.replace(/^.*?(plugins\/)/, '$1');
|
|
75
|
+
const replaces = [].concat(ns?.replaces ?? []).map(String);
|
|
76
|
+
this._list.set(name, { name, file, values, replaces, replacedBy: null, on: !off.includes(name), plugged: [] });
|
|
97
77
|
}
|
|
98
78
|
for (const p of this._list.values()) for (const r of p.replaces) if (!this._list.has(r))
|
|
99
79
|
throw codedError('plugin-shape', `${p.file}: export const replaces = '${r}', but there is no plugin '${r}'; plugins: ${[...this._list.keys()].join(', ')}`);
|
|
100
|
-
|
|
80
|
+
this._added = true;
|
|
101
81
|
if (this._e._started) this._plugAll();
|
|
102
82
|
return this;
|
|
103
83
|
}
|
|
@@ -109,22 +89,21 @@ export class Plugins {
|
|
|
109
89
|
for (const p of all) p.values.forEach((v, i) => { if (shapeOf(v) === 'post') e.post?._place(postName(p, v, i), true); });
|
|
110
90
|
const todo = all.filter(p => p.on && !p.plugged.length && !p.replacedBy);
|
|
111
91
|
for (const p of todo) if (p.on && !p.plugged.length && !p.replacedBy) this._plug(p); // re-checked: a plug can unplug a later one it replaces
|
|
112
|
-
if (e._started && todo.some(p => reachOf(p) === NEW)) e.look?.materials?.rebuild?.();
|
|
113
92
|
}
|
|
114
93
|
|
|
115
94
|
/** @internal */
|
|
116
95
|
_plug(p) {
|
|
117
|
-
const e = this._e, owner =
|
|
96
|
+
const e = this._e, owner = 'plugin:' + p.name, layer = 'game';
|
|
97
|
+
let at = null; // the value being plugged, so a clash can name the other plugin
|
|
118
98
|
for (const r of p.replaces) { const q = this._list.get(r); q.replacedBy = p.name; this._unplug(q); }
|
|
119
99
|
try {
|
|
120
100
|
for (const v of p.values) {
|
|
101
|
+
at = v;
|
|
121
102
|
const slot = shapeOf(v);
|
|
122
103
|
let remove;
|
|
123
104
|
if (slot === 'scene') { e.add(v, { id: p.values.length > 1 ? `${p.name}/${p.plugged.length}` : p.name }); remove = () => { v.removeFromParent(); e._things.forget(v); e.rays.forget(v); }; } // not engine.remove: that disposes, and on() puts it back
|
|
124
|
-
// an effect keeps its own name (
|
|
125
|
-
else if (slot === 'post') { const h = e.
|
|
126
|
-
else if (slot === 'material') { const h = e.look.materials.replace(v.name || baseOf(p.name), v, { owner, layer }); remove = () => h.remove(); }
|
|
127
|
-
else if (slot === 'patch') { const { roles, ...spec } = v, h = e.look.materials.add(p.name, spec, { roles, owner, layer }); remove = () => h.remove(); }
|
|
105
|
+
// an effect keeps its own name (engine.post.get('bloom') reads the same from any source); a bare Pass is named by its file
|
|
106
|
+
else if (slot === 'post') { const h = e.post.add(v, v.isPass || 'needsSwap' in v ? { name: postName(p, v, p.plugged.length) } : {}); remove = () => h.remove(); }
|
|
128
107
|
else { e.use(v); remove = () => { if (e.modules.get(v.name) === v) e._unuse(v.name); }; }
|
|
129
108
|
p.plugged.push({ slot, value: v, remove });
|
|
130
109
|
}
|
|
@@ -132,7 +111,10 @@ export class Plugins {
|
|
|
132
111
|
this._unplug(p); // all or nothing per file: half a plugin is harder to read than none
|
|
133
112
|
this._giveBack(p);
|
|
134
113
|
err.message = `${p.file}: ${err.message}`;
|
|
135
|
-
|
|
114
|
+
// two plugins naming one post effect: the error comes from the post chain, which knows names and not files, so the file of the first is added here
|
|
115
|
+
const first = [...this._list.values()].find(q => q !== p && q.plugged.some(x => x.slot === 'post' && at?.name && x.value.name === at.name));
|
|
116
|
+
if (first) err.message += ` ${first.file} added it first.`;
|
|
117
|
+
if (first || /shared-conflict/.test(err.message)) err.message += ` Two plugins write the same key: keep one, or say which wins in the file that should: export const replaces = '<the other file>';`;
|
|
136
118
|
throw err;
|
|
137
119
|
}
|
|
138
120
|
}
|
|
@@ -144,57 +126,47 @@ export class Plugins {
|
|
|
144
126
|
}
|
|
145
127
|
|
|
146
128
|
/**
|
|
147
|
-
* Switch a plugin off: everything it plugged is taken out again (the object leaves the scene, the pass the chain,
|
|
148
|
-
* the module is unloaded). No code change: plugins.json "off" does the same at start.
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* @param {string} name file name without .js, or a style pack's name @param {{ rebuild?: boolean }} [o]
|
|
153
|
-
* @returns {{ off: string[], reach: string[], rebuilt: number | null, note: string }}
|
|
129
|
+
* Switch a plugin off: everything it plugged is taken out again (the object leaves the scene, the pass the chain,
|
|
130
|
+
* the module is unloaded). No code change: plugins.json "off" does the same at start.
|
|
131
|
+
* To pause a post effect and keep everything else, engine.post.get('<effect>').enabled = false is lighter: off unloads.
|
|
132
|
+
* @param {string} name file name without .js
|
|
133
|
+
* @returns {{ off: string[], note: string }}
|
|
154
134
|
*/
|
|
155
|
-
off(name
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return this._result('off',
|
|
135
|
+
off(name) {
|
|
136
|
+
const p = this._get(name);
|
|
137
|
+
p.on = false; this._unplug(p);
|
|
138
|
+
this._giveBack(p);
|
|
139
|
+
return this._result('off', p);
|
|
160
140
|
}
|
|
161
141
|
/**
|
|
162
|
-
* Switch a plugin
|
|
163
|
-
*
|
|
164
|
-
* @returns {{ on: string[], reach: string[], rebuilt: number | null, note: string }}
|
|
142
|
+
* Switch a plugin back on (plugged at once after start). @param {string} name
|
|
143
|
+
* @returns {{ on: string[], note: string }}
|
|
165
144
|
*/
|
|
166
|
-
on(name
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
return this._result('on',
|
|
145
|
+
on(name) {
|
|
146
|
+
const p = this._get(name);
|
|
147
|
+
p.on = true; if (this._e._started && !p.plugged.length && !p.replacedBy) this._plug(p);
|
|
148
|
+
return this._result('on', p);
|
|
170
149
|
}
|
|
171
150
|
/** @internal what off / on did, in words a reader can act on */
|
|
172
|
-
_result(verb,
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
const fx = ps.flatMap(p => p.values.map((v, i) => (shapeOf(v) === 'post' ? postName(p, v, i) : null))).filter(Boolean);
|
|
180
|
-
if (verb === 'off' && fx.length) notes.push(`plugins.off unloads; to pause an effect in its place use engine.look.post.set({ ${fx.map(n => `${/^[\w$]+$/.test(n) ? n : `'${n}'`}: false`).join(', ')} })`);
|
|
181
|
-
if (verb === 'off' && ps.some(p => p.group === name)) notes.push(`style '${name}': its plugins are off; the pack's starting values (exposure, fog, its materials table ...) stay, they are the style itself`);
|
|
182
|
-
const replaced = ps.filter(p => p.replacedBy).map(p => `${p.name} stays out while ${p.replacedBy} (replaces it) is on`);
|
|
183
|
-
return { [verb]: ps.map(p => p.name), reach, rebuilt, note: [...notes, ...replaced].join('; ') };
|
|
151
|
+
_result(verb, p) {
|
|
152
|
+
const notes = [];
|
|
153
|
+
const fx = p.values.map((v, i) => (shapeOf(v) === 'post' ? postName(p, v, i) : null)).filter(Boolean);
|
|
154
|
+
if (verb === 'off' && fx.length) notes.push(`plugins.off unloads; to pause an effect in its place use ${fx.map(n => `engine.post.get('${n}').enabled = false`).join('; ')}`);
|
|
155
|
+
if (p.replacedBy) notes.push(`${p.name} stays out while ${p.replacedBy} (replaces it) is on`);
|
|
156
|
+
return { [verb]: [p.name], note: notes.join('; ') };
|
|
184
157
|
}
|
|
185
|
-
/** @internal
|
|
158
|
+
/** @internal */
|
|
186
159
|
_get(name) {
|
|
187
|
-
const p = this._list.get(name)
|
|
188
|
-
if (!
|
|
189
|
-
return
|
|
160
|
+
const p = this._list.get(name);
|
|
161
|
+
if (!p) throw codedError('plugin-shape', `engine.plugins: no plugin '${name}'; plugins: ${[...this._list.keys()].join(', ') || 'none (no plugins folder)'}`);
|
|
162
|
+
return p;
|
|
190
163
|
}
|
|
191
164
|
|
|
192
165
|
/**
|
|
193
|
-
* The plugins in plug order
|
|
194
|
-
*
|
|
195
|
-
* @returns {{ name: string, file: string, on: boolean, slots: string[], reach: string[], style: string | null, replacedBy: string | null }[]}
|
|
166
|
+
* The plugins in plug order: { name, file, on, slots, replacedBy } (replacedBy: the plugin that holds it out)
|
|
167
|
+
* @returns {{ name: string, file: string, on: boolean, slots: string[], replacedBy: string | null }[]}
|
|
196
168
|
*/
|
|
197
|
-
list() { return [...this._list.values()].map(p => ({ name: p.name, file: p.file, on: p.on, slots: p.values.map(v => shapeOf(v)),
|
|
169
|
+
list() { return [...this._list.values()].map(p => ({ name: p.name, file: p.file, on: p.on, slots: p.values.map(v => shapeOf(v)), replacedBy: p.replacedBy })); }
|
|
198
170
|
}
|
|
199
171
|
|
|
200
172
|
/**
|
|
@@ -203,6 +175,9 @@ export class Plugins {
|
|
|
203
175
|
*/
|
|
204
176
|
function notAPlugin(file, key, v) {
|
|
205
177
|
const what = key === 'default' ? 'the default export' : `the export '${key}'`;
|
|
178
|
+
if (v?.isMaterial) return `${file}: ${what} is a Material, which says nothing about what it goes on. Fix: put it on its mesh in your picture/ code, or on a module (engine.water.material = mat)`;
|
|
179
|
+
if (v && typeof v === 'object' && !v.isObject3D && (v.slot || typeof v.glsl === 'string' || typeof v.glsl === 'object' || v.tsl))
|
|
180
|
+
return `${file}: ${what} is a ShaderPatch, which says nothing about which material it changes. Fix: applyEffects(material, { patches: [patch] }) in your picture/ code`;
|
|
206
181
|
if (typeof v === 'function') {
|
|
207
182
|
const fn = v.name && v.name !== 'default' ? v.name : 'make';
|
|
208
183
|
return `${file}: ${what} is a function (${v.name || 'anonymous'}). A function is never a plugin: it does not say where it plugs in. ` +
|
|
@@ -225,15 +200,10 @@ function notAPlugin(file, key, v) {
|
|
|
225
200
|
}
|
|
226
201
|
|
|
227
202
|
/**
|
|
228
|
-
* Plug
|
|
229
|
-
*
|
|
203
|
+
* Plug what the page's plugins folder gave (the vite preset puts it on globalThis.__threedogPlugins before main.js runs) and the files
|
|
204
|
+
* engine.plugins.add received. Called once by start(). @param {any} e
|
|
230
205
|
*/
|
|
231
206
|
export function plugAtStart(e) {
|
|
232
|
-
// the style's first, so their list order (and describe().slots) reads base look, then the game's additions
|
|
233
|
-
const before = [...e.plugins._list.entries()];
|
|
234
|
-
e.plugins._list.clear();
|
|
235
|
-
for (const { group, files } of stylePlugins(e.style)) e.plugins._add(files, { group });
|
|
236
|
-
for (const [k, v] of before) e.plugins._list.set(k, v);
|
|
237
207
|
const page = typeof globalThis !== 'undefined' ? globalThis.__threedogPlugins : null;
|
|
238
208
|
if (page && !e.plugins._added) e.plugins.add(page.files, page.config ?? {});
|
|
239
209
|
e.plugins._plugAll();
|
|
@@ -241,18 +211,16 @@ export function plugAtStart(e) {
|
|
|
241
211
|
|
|
242
212
|
/**
|
|
243
213
|
* describe().slots: one table of what is plugged in where. Each row: { slot, plugged, file, on, affects }; file is the plugin file, the
|
|
244
|
-
* file:line that called scene.add / engine.add (dev), or the call that plugged it ('engine.use', '
|
|
245
|
-
* a reader asking "what did this game add to the engine" had to put describe().scene, render.post
|
|
214
|
+
* file:line that called scene.add / engine.add (dev), or the call that plugged it ('engine.use', 'engine.post.add'). Why one table:
|
|
215
|
+
* a reader asking "what did this game add to the engine" had to put describe().scene, render.post and modules side by side.
|
|
246
216
|
* @param {any} e
|
|
247
217
|
*/
|
|
248
218
|
export function describeSlots(e) {
|
|
249
219
|
const rows = [], fromPlugin = new Set();
|
|
250
220
|
const passOf = v => e.post?._list.find(h => h._def === v || h._def._pass === v || h._def.node === v);
|
|
251
|
-
const affects = (slot, v
|
|
221
|
+
const affects = (slot, v) => {
|
|
252
222
|
if (slot === 'scene') { const t = e._things.byObj.get(v); return t ? [`engine.thing('${t.id}')`, `save tier ${e._things.tier(t)}`] : ['scene']; }
|
|
253
223
|
if (slot === 'post') { const h = passOf(v); return [h ? `picture: post chain ${h.slot} slot, ${h.name}` : 'picture: post chain']; }
|
|
254
|
-
if (slot === 'material') { const r = v.name || baseOf(name); return [`look.materials replace:${r}`, `makeMaterial('${r}')`]; }
|
|
255
|
-
if (slot === 'patch') return [`look.materials hook:${name}`, v.roles ? `materials of roles ${v.roles.join(', ')}` : 'every makeMaterial material', `shader slot ${v.slot ?? '?'}`];
|
|
256
224
|
if (slot === 'light') return ["budget 'lights'", ...(v.castShadow ? ["budget 'shadowLights'", 'idle shadow redraw rule'] : [])];
|
|
257
225
|
return [`engine.${v.name}`, `type ${v.type}`, ...(v.provides ?? []).map(s => `provides ${s}`)];
|
|
258
226
|
};
|
|
@@ -260,15 +228,15 @@ export function describeSlots(e) {
|
|
|
260
228
|
const slot = shapeOf(v);
|
|
261
229
|
fromPlugin.add(v);
|
|
262
230
|
const live = p.on && !p.replacedBy;
|
|
263
|
-
rows.push({ slot, plugged: (slot === 'module' ? v.name : v.name || v.type) || p.name, file: p.file, on: live,
|
|
264
|
-
affects: live ? affects(slot, v
|
|
231
|
+
rows.push({ slot, plugged: (slot === 'module' ? v.name : v.name || v.type) || p.name, file: p.file, on: live,
|
|
232
|
+
affects: live ? affects(slot, v) : p.replacedBy ? [`replaced by ${p.replacedBy}`] : [] });
|
|
265
233
|
}
|
|
266
234
|
for (const o of e.scene.children) { const en = e._things.byObj.get(o); if (en?.owner === 'game' && !fromPlugin.has(o) && !o.isLight)
|
|
267
235
|
rows.push({ slot: 'scene', plugged: o.name || o.type, file: en.at ?? 'scene.add / engine.add', on: true, affects: affects('scene', o) }); }
|
|
268
236
|
for (const h of e.post?._list ?? []) if (![h._def, h._def._pass, h._def.node].some(v => v && fromPlugin.has(v)))
|
|
269
|
-
rows.push({ slot: 'post', plugged: h.name, file: '
|
|
237
|
+
rows.push({ slot: 'post', plugged: h.name, file: 'engine.post.add', on: h.enabled, affects: [`picture: post chain ${h.slot} slot, ${h.name}`] });
|
|
270
238
|
for (const m of e.post?._plain ?? []) if (m.output)
|
|
271
|
-
rows.push({ slot: 'post', plugged: 'OutputPass (skipped: the engine tone maps; passes after it run in ldr)', file: '
|
|
239
|
+
rows.push({ slot: 'post', plugged: 'OutputPass (skipped: the engine tone maps; passes after it run in ldr)', file: 'engine.post.add', on: true, affects: ['picture: where display color starts'] });
|
|
272
240
|
for (const m of e.modules.values()) if (!fromPlugin.has(m))
|
|
273
241
|
rows.push({ slot: 'module', plugged: m.name, file: 'engine.use', on: true, affects: affects('module', m) });
|
|
274
242
|
for (const l of e._gameLights?.list() ?? [])
|
package/core/sceneDelta.js
CHANGED
|
@@ -35,6 +35,7 @@ if (!P[KEY]) {
|
|
|
35
35
|
Object.defineProperty(P, KEY, { value: true, configurable: true });
|
|
36
36
|
Object.defineProperty(P, ORIG, { value: { add, remove }, configurable: true });
|
|
37
37
|
P.add = function (...a) {
|
|
38
|
+
if (!patchOn('scene-add-hook')) return add.apply(this, a); // switched off while another library's wrapper sits on top of ours: pass through
|
|
38
39
|
const out = add.apply(this, a); // three detaches each child from its old parent first (through remove below), then attaches
|
|
39
40
|
const t = trackerOf(this);
|
|
40
41
|
if (t) for (const c of a) if (c?.parent === this) t.pending.add(c);
|
|
@@ -44,7 +45,7 @@ if (!P[KEY]) {
|
|
|
44
45
|
return out;
|
|
45
46
|
};
|
|
46
47
|
P.remove = function (...a) {
|
|
47
|
-
const t = trackerOf(this);
|
|
48
|
+
const t = patchOn('scene-add-hook') ? trackerOf(this) : null;
|
|
48
49
|
if (!t) return remove.apply(this, a);
|
|
49
50
|
let gone = null, roots = null;
|
|
50
51
|
for (const c of a) if (c?.parent === this && t.seen.has(c)) (gone ??= []).push(c);
|
|
@@ -54,13 +55,20 @@ if (!P[KEY]) {
|
|
|
54
55
|
if (roots) for (const c of roots) if (c.parent !== this) for (const f of t.rootLeaves) f(c);
|
|
55
56
|
return out;
|
|
56
57
|
};
|
|
58
|
+
P[ORIG].ours = { add: P.add, remove: P.remove }; // to tell at off() whether they are still the outermost
|
|
57
59
|
}
|
|
58
60
|
notePatch('scene-add-hook', 'Object3D.prototype.add / remove: wrapped once per page to see what enters and leaves a watched scene at any depth (three\'s childadded fires on the direct parent only)',
|
|
59
|
-
() => {
|
|
60
|
-
|
|
61
|
+
() => {
|
|
62
|
+
// a wrapper another library put on top of ours stays: taking it off would undo that library too. Ours then only passes calls through (patchOn above).
|
|
63
|
+
const o = P[ORIG]; if (!o?.ours) return;
|
|
64
|
+
if (P.add === o.ours.add) P.add = o.add;
|
|
65
|
+
if (P.remove === o.ours.remove) P.remove = o.remove;
|
|
66
|
+
if (P.add === o.add && P.remove === o.remove) { delete P[KEY]; delete P[ORIG]; }
|
|
67
|
+
},
|
|
68
|
+
{ lost: 'plain scene.add is no longer adopted like engine.add, and fog, cascades, night glow and light counts miss objects added later' });
|
|
61
69
|
notePatch('mesh-material-accessor', 'mesh.material on each object with a material that enters a watched scene: an own get / set on that object (the class accessor still runs) so a material swap is seen',
|
|
62
70
|
() => {}, // off: objects entering from now on keep a plain material (_walk asks patchOn)
|
|
63
|
-
{ scope: 'objects in the scene', lost: 'mesh.material = other on objects entering from now on is not seen: the new material misses fog
|
|
71
|
+
{ scope: 'objects in the scene', lost: 'mesh.material = other on objects entering from now on is not seen: the new material misses fog and cascades until the object re-enters' });
|
|
64
72
|
|
|
65
73
|
/** The accessor (get / set) `material` resolves to on this object or up its prototype chain, or null when it is a plain value */
|
|
66
74
|
function materialAccessor(o) {
|
package/core/sceneMethods.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
// Scene and render settings on the engine (split out of Engine.js): add / detach / remove objects, pixel ratio,
|
|
2
|
-
// tone mapping and exposure, one-off renders (renderOnce).
|
|
1
|
+
// Scene and render settings on the engine (split out of Engine.js): add / detach / remove objects, pixel ratio, one-off renders (renderOnce).
|
|
3
2
|
// add registers each root in the thing registry (things.js) so engine.thing / hit.thing can say what it is and what a save keeps. A plain
|
|
4
3
|
// engine.scene.add(obj) is registered the same way (things.js adopts roots added under the scene), so both ways in give the same answer.
|
|
5
4
|
import { DEV } from './validate.js';
|
|
6
5
|
import { codedError } from './errorHints.js';
|
|
7
6
|
import { thing } from './thingOps.js';
|
|
8
|
-
import { TONE, exposureDriver } from './look/coreParts.js';
|
|
9
7
|
import { freshFrame, renderOnce as drawOnce } from '../render/backend.js';
|
|
10
8
|
|
|
11
|
-
/** The engine's fog distance when nobody set one (look.fog far's default; also the stream radius without terrain or fog) */
|
|
12
|
-
export const FOG_FAR = 600;
|
|
13
|
-
/** The fog distance in effect: look.fog far (with every layer: terrain view, style, game, weather), else FOG_FAR @param {any} e */
|
|
14
|
-
export const fogFarOf = e => e.look?.fog?.value('far') ?? FOG_FAR;
|
|
15
|
-
|
|
16
9
|
/** A short stack for "added at main.js:50" (dev): 4 frames are enough (this, add, its caller) and keep the cost low; it is formatted only when read */
|
|
17
10
|
function captureStack() {
|
|
18
11
|
const lim = Error.stackTraceLimit; Error.stackTraceLimit = 4;
|
|
@@ -97,7 +90,7 @@ export const sceneMethods = {
|
|
|
97
90
|
},
|
|
98
91
|
// an engine.setPixelRatio call is the game's (or settings') request: written even when the game took the ratio, and re-read so it is not an outside write
|
|
99
92
|
setPixelRatio(p) { this.renderer.setPixelRatio(p); this._oPixelRatio?.mark(); },
|
|
100
|
-
/** Raise camera.far to at least far (terrain view range
|
|
93
|
+
/** Raise camera.far to at least far (terrain view range). Goes through ownership: a game that owns camera.far (engine.view.manual('far')) keeps its value. @param {number} far */
|
|
101
94
|
viewFar(far) {
|
|
102
95
|
if (this.camera.far >= far) return;
|
|
103
96
|
if (this._oFar) this._oFar.drive(far); else { this.camera.far = far; this.camera.updateProjectionMatrix(); }
|
package/core/services.js
CHANGED
|
@@ -48,7 +48,7 @@ export function createServices(engine, { canvas, validate, locale, strings, save
|
|
|
48
48
|
engine.session = new Session(engine); // new game / continue / back to title from a clean slate (session.js)
|
|
49
49
|
// before Input: key bindings are the shared point 'input.keys'.
|
|
50
50
|
// shared quantities (stacks.js): engine.mod(name, { owner, mul | add | set | clamp, for }) is the one way several systems change one
|
|
51
|
-
(engine.stacks ??= new Stacks(engine))._hook(); // one registry, made early by Engine.js (
|
|
51
|
+
(engine.stacks ??= new Stacks(engine))._hook(); // one registry, made early by Engine.js (drawing parts register points); saves and events hook in now
|
|
52
52
|
engine.mod = (name, o) => engine.stacks.mod(name, o);
|
|
53
53
|
engine.stacks.define('input.gate', { kind: 'any', per: true }); // input.gate(action, owner): one entry per owner and action (Input.js)
|
|
54
54
|
engine.input = new Input(engine, canvas, { joystick, bindings });
|
package/core/shadowTypes.js
CHANGED
|
@@ -9,7 +9,7 @@ export const SHADOW_TYPES = {
|
|
|
9
9
|
vsm: { three: THREE.VSMShadowMap, cost: 1.6 },
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
/** Validate a shadow type name; throws with the allowed values (a wrong name would otherwise silently fall back to the default
|
|
12
|
+
/** Validate a shadow type name; throws with the allowed values (a wrong name would otherwise silently fall back to the default picture). */
|
|
13
13
|
export function shadowTypeOf(name, where) {
|
|
14
14
|
if (Object.hasOwn(SHADOW_TYPES, name)) return SHADOW_TYPES[name].three;
|
|
15
15
|
throw codedError('shadow-type', `${where}: unknown shadow type ${JSON.stringify(name)}. Use one of: ${Object.keys(SHADOW_TYPES).map(k => `'${k}'`).join(', ')}.`);
|