threedog 0.2.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +371 -1
- package/README.md +21 -12
- package/core/Animator.js +15 -12
- package/core/Assets.js +92 -26
- package/core/Audio.js +45 -38
- package/core/Baked.js +30 -15
- package/core/Batching.js +102 -15
- package/core/Budget.js +40 -19
- package/core/Clock.js +40 -80
- package/core/DebugOverrides.js +75 -25
- package/core/Describe.js +105 -45
- package/core/Engine.js +203 -75
- package/core/Events.js +4 -1
- package/core/I18n.js +25 -13
- package/core/Input.js +175 -80
- package/core/Inspect.js +8 -5
- package/core/InspectMaterials.js +84 -0
- package/core/InspectPerf.js +68 -0
- package/core/InspectScene.js +13 -2
- package/core/Loading.js +2 -1
- package/core/MaterialInfo.js +7 -5
- package/core/Ops.js +50 -9
- package/core/Random.js +9 -2
- package/core/Rays.js +12 -7
- package/core/SaveStore.js +41 -9
- package/core/Saves.js +71 -15
- package/core/Stream.js +13 -10
- package/core/Threads.js +26 -7
- package/core/UrlState.js +69 -13
- package/core/Views.js +10 -6
- package/core/actor.js +1 -1
- package/core/adaptive.js +93 -0
- package/core/assetEntry.js +27 -7
- package/core/assetHot.js +176 -0
- package/core/assetLoad.js +44 -19
- package/core/assetManifest.js +53 -11
- package/core/assetReport.js +5 -5
- package/core/audioRules.js +13 -11
- package/core/audioVoice.js +69 -42
- package/core/batchGroups.js +9 -1
- package/core/canvasBox.js +1 -2
- package/core/catalog.js +21 -5
- package/core/cells.js +62 -0
- package/core/checks.js +10 -8
- package/core/chunkStream.js +87 -0
- package/core/control.js +149 -0
- package/core/copies.js +32 -0
- package/core/dayTime.js +12 -6
- package/core/debugView.js +85 -18
- package/core/describeRender.js +117 -21
- package/core/describeText.js +41 -21
- package/core/engineCamera.js +32 -0
- package/core/errorCodes.js +478 -32
- package/core/errorHints.js +41 -142
- package/core/errors.js +31 -8
- package/core/events.generated.js +13 -7
- package/core/gameLights.js +69 -0
- package/core/grayMap.js +20 -0
- package/core/grid.js +14 -13
- package/core/gridLoad.js +2 -1
- package/core/ground.js +6 -4
- package/core/headlessLoad.js +55 -0
- package/core/holds.js +78 -50
- package/core/inputContext.js +11 -7
- package/core/inputDefaults.js +24 -21
- package/core/inputPad.js +1 -1
- package/core/inputPointer.js +1 -1
- package/core/inputTouch.js +2 -2
- package/core/lifecycle.js +46 -12
- package/core/lightWatch.js +9 -5
- package/core/loop.js +109 -43
- package/core/math.js +18 -3
- package/core/moduleSlots.js +100 -0
- package/core/moduleTypes.js +86 -0
- package/core/modules.js +147 -29
- package/core/movement.js +2 -2
- package/core/namedModel.js +74 -0
- package/core/opsCheck.js +3 -3
- package/core/opsFail.js +15 -6
- package/core/opsGuard.js +4 -4
- package/core/opsRun.js +4 -3
- package/core/owned.js +171 -0
- package/core/page.js +44 -10
- package/core/params.js +30 -8
- package/core/pictureSlots.js +33 -0
- package/core/pictureWriters.js +343 -0
- package/core/plugins.js +245 -0
- package/core/saveApply.js +99 -17
- package/core/saveFiles.js +8 -6
- package/core/saveValues.js +46 -0
- package/core/saveVersions.js +20 -3
- package/core/scatter.js +48 -19
- package/core/sceneDelta.js +211 -0
- package/core/sceneMethods.js +31 -33
- package/core/screenToGround.js +1 -1
- package/core/services.js +27 -11
- package/core/session.js +28 -25
- package/core/shaderCost.js +78 -0
- package/core/shadowTypes.js +3 -2
- package/core/shadows.js +405 -0
- package/core/sharedPoint.js +303 -0
- package/core/skip.js +36 -28
- package/core/stackFrames.js +45 -0
- package/core/stacks.js +166 -0
- package/core/startup.js +153 -13
- package/core/streamSources.js +0 -11
- package/core/targeting.js +1 -1
- package/core/textureBytes.js +20 -0
- package/core/thingExplain.js +3 -3
- package/core/thingOps.js +29 -6
- package/core/things.js +22 -12
- package/core/threadPure.js +7 -3
- package/core/threePatches.js +47 -0
- package/core/tier.js +21 -10
- package/core/time.js +236 -0
- package/core/uiClock.js +25 -0
- package/core/util.js +8 -2
- package/core/validate.js +66 -87
- package/core/view.js +43 -0
- package/core/wrap.js +106 -0
- package/docs/AI.md +95 -104
- package/docs/API.md +35 -31
- package/docs/CODEMAP.md +231 -176
- package/docs/COMMANDS.md +63 -39
- package/docs/CONVENTIONS.md +99 -31
- package/docs/MIGRATING-0.3.md +248 -0
- package/docs/MIGRATING-0.4.md +320 -0
- package/docs/MIGRATING-0.5.md +68 -0
- package/docs/MIGRATING-0.6.md +126 -0
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/PERF.md +35 -7
- package/docs/THREE.md +82 -28
- package/docs/api/ambience.md +0 -1
- package/docs/api/assets.md +15 -11
- package/docs/api/audio.md +10 -14
- package/docs/api/budget.md +4 -0
- package/docs/api/calendar.md +41 -0
- package/docs/api/cameraRig.md +16 -5
- package/docs/api/characters.md +41 -24
- package/docs/api/clock.md +6 -5
- package/docs/api/collision.md +10 -7
- package/docs/api/content.md +6 -4
- package/docs/api/dialogue.md +9 -9
- package/docs/api/engine.md +95 -65
- package/docs/api/events.md +20 -14
- package/docs/api/grids.md +10 -3
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +5 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +13 -7
- package/docs/api/interactions.md +10 -6
- package/docs/api/inventory.md +17 -17
- package/docs/api/level.md +0 -2
- package/docs/api/lightPool.md +3 -1
- package/docs/api/music.md +1 -1
- package/docs/api/nav.md +3 -0
- package/docs/api/occlusion.md +5 -0
- package/docs/api/openWorld.md +2 -1
- package/docs/api/particles.md +6 -3
- package/docs/api/photo.md +0 -2
- package/docs/api/pickups.md +21 -0
- package/docs/api/post.md +8 -5
- package/docs/api/quests.md +2 -3
- package/docs/api/rigid.md +16 -14
- package/docs/api/saves.md +6 -4
- package/docs/api/settings.md +2 -3
- package/docs/api/sky.md +18 -49
- package/docs/api/stream.md +1 -1
- package/docs/api/terrain.md +16 -7
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/timeline.md +3 -4
- package/docs/api/tools.md +32 -15
- package/docs/api/triggers.md +7 -10
- package/docs/api/vegetation.md +17 -9
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +9 -21
- package/docs/api/weather.md +10 -15
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +3 -2
- package/docs/recipes/01-new-game.md +52 -42
- package/docs/recipes/02-npc.md +24 -7
- package/docs/recipes/03-items-pickups.md +57 -22
- package/docs/recipes/04-quests.md +12 -5
- package/docs/recipes/05-props-bake.md +174 -22
- package/docs/recipes/06-clock-events.md +100 -52
- package/docs/recipes/07-flow-scenes-pause.md +50 -10
- package/docs/recipes/08-weather-sky.md +134 -37
- package/docs/recipes/09-materials-lights-models.md +185 -0
- package/docs/recipes/10-blender-level.md +16 -4
- package/docs/recipes/11-vehicles.md +67 -10
- package/docs/recipes/13-animation.md +23 -9
- package/docs/recipes/14-custom-module.md +63 -29
- package/docs/recipes/15-perf.md +31 -10
- package/docs/recipes/16-dev-bridge.md +74 -40
- package/docs/recipes/18-world.md +26 -14
- package/docs/recipes/19-shooting-picking.md +12 -10
- package/docs/recipes/20-content-actions-save.md +60 -18
- package/docs/recipes/21-camera.md +55 -17
- package/docs/recipes/22-shop-gold.md +3 -3
- package/docs/recipes/23-ops.md +17 -11
- package/docs/recipes/26-ui-parts.md +86 -13
- package/docs/recipes/27-net.md +11 -5
- package/docs/recipes/28-terrain.md +36 -3
- package/docs/recipes/29-grid.md +46 -19
- package/docs/recipes/30-templates.md +72 -15
- package/docs/recipes/31-audio.md +20 -12
- package/docs/recipes/32-action-game.md +51 -4
- package/docs/recipes/34-environment-lighting.md +108 -21
- package/docs/recipes/35-picture-from-reference.md +147 -0
- package/docs/recipes/36-sky-ground-plants.md +158 -0
- package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -12
- package/docs/recipes/38-environment-hooks.md +67 -0
- package/docs/recipes/40-scene.md +114 -32
- package/docs/recipes/42-terrain-shape.md +2 -2
- package/docs/recipes/43-shader-patches-surfaces.md +206 -0
- package/docs/recipes/44-water-weather-hooks.md +191 -0
- package/docs/recipes/45-cascaded-shadows.md +130 -23
- package/docs/recipes/46-blender-art-route.md +17 -20
- package/docs/recipes/47-island-snow-backdrop.md +13 -15
- package/docs/recipes/49-game-module-contract.md +30 -17
- package/docs/recipes/50-own-renderer.md +4 -4
- package/docs/recipes/51-capability-catalog.md +3 -3
- package/docs/recipes/52-around-the-picture.md +181 -0
- package/docs/recipes/53-ground-up-close.md +12 -12
- package/docs/recipes/54-three-idioms.md +88 -0
- package/docs/recipes/55-mods-time-wrap.md +124 -0
- package/docs/recipes/56-webgpu-tsl.md +303 -0
- package/docs/recipes/57-control.md +104 -0
- package/docs/recipes/58-input.md +60 -0
- package/docs/recipes/59-depth-post-effects.md +83 -0
- package/docs/recipes/60-judge-the-picture.md +70 -0
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +244 -0
- package/docs/recipes/63-third-person-start.md +77 -0
- package/docs/recipes/64-particles.md +35 -0
- package/examples/action/.threedog/content-index.json +1 -0
- package/examples/action/GAMEMAP.md +20 -14
- package/examples/action/assets.js +8 -0
- package/examples/action/content/actions.js +1 -1
- package/examples/action/content/audio.js +5 -5
- package/examples/action/main.js +12 -15
- package/examples/action/models.js +23 -24
- package/examples/action/picture/index.js +13 -0
- package/examples/action/picture/lights.js +35 -0
- package/examples/action/picture/materials.js +8 -0
- package/examples/action/picture/palette.js +33 -0
- package/examples/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/FINDINGS.md +53 -0
- package/examples/plain-picture/GAMEMAP.md +90 -0
- package/examples/plain-picture/main.js +48 -0
- package/examples/plain-picture/picture/index.js +21 -0
- package/examples/plain-picture/picture/lights.js +54 -0
- package/examples/plain-picture/picture/materials.js +24 -0
- package/examples/plain-picture/picture/palette.js +16 -0
- package/examples/plain-picture/picture/sky.js +37 -0
- package/examples/pullable.json +133 -0
- package/examples/rc2d/.threedog/content-index.json +1 -0
- package/examples/rc2d/GAMEMAP.md +88 -0
- package/examples/rc2d/README.md +57 -0
- package/examples/rc2d/main.js +55 -0
- package/examples/rc2d/picture/index.js +18 -0
- package/examples/rc2d/picture/lights.js +11 -0
- package/examples/rc2d/picture/materials.js +18 -0
- package/examples/rc2d/picture/palette.js +15 -0
- package/examples/rc2d/picture/post.js +11 -0
- package/examples/rc2d/rc2d.js +187 -0
- package/examples/rc2d/shaders.js +144 -0
- package/examples/sheepisland/.threedog/content-index.json +1 -0
- package/examples/sheepisland/GAMEMAP.md +22 -17
- package/examples/sheepisland/assets.js +5 -0
- package/examples/sheepisland/content/templates.js +1 -1
- package/examples/sheepisland/content/vegetation.js +3 -1
- package/examples/sheepisland/main.js +29 -18
- package/examples/sheepisland/{style/models.js → models.js} +13 -24
- package/examples/sheepisland/picture/index.js +20 -0
- package/examples/sheepisland/picture/lights.js +34 -0
- package/examples/sheepisland/picture/materials.js +61 -0
- package/examples/sheepisland/picture/palette.js +60 -0
- package/examples/sheepisland/picture/sky.js +20 -0
- package/examples/sheepisland/views.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -0
- package/examples/styletest/GAMEMAP.md +25 -22
- package/examples/styletest/assets.js +6 -0
- package/examples/styletest/content/templates.js +1 -1
- package/examples/styletest/content/vegetation.js +1 -1
- package/examples/styletest/main.js +25 -34
- package/examples/styletest/models.js +30 -30
- package/examples/styletest/params.js +2 -5
- package/examples/styletest/picture/env.js +38 -0
- package/examples/styletest/picture/index.js +16 -0
- package/examples/styletest/picture/lights.js +9 -0
- package/examples/styletest/picture/materials.js +28 -0
- package/examples/styletest/picture/palette.js +22 -0
- package/examples/techniques/contact-shadows/README.md +91 -0
- package/examples/techniques/contact-shadows/contactShadows.js +67 -0
- package/examples/techniques/contact-shadows/main.js +55 -0
- package/examples/techniques/contact-shadows/picture/index.js +14 -0
- package/examples/techniques/contact-shadows/picture/lights.js +34 -0
- package/examples/techniques/contact-shadows/picture/materials.js +12 -0
- package/examples/techniques/contact-shadows/picture/palette.js +17 -0
- package/examples/techniques/day-night-grade/README.md +83 -0
- package/examples/techniques/day-night-grade/main.js +41 -0
- package/examples/techniques/day-night-grade/picture/index.js +20 -0
- package/examples/techniques/day-night-grade/picture/lights.js +45 -0
- package/examples/techniques/day-night-grade/picture/materials.js +15 -0
- package/examples/techniques/day-night-grade/picture/palette.js +59 -0
- package/examples/techniques/day-night-grade/picture/post.js +25 -0
- package/examples/techniques/day-night-grade/picture/sky.js +33 -0
- package/examples/techniques/interior-light/README.md +106 -0
- package/examples/techniques/interior-light/interiorLight.js +47 -0
- package/examples/techniques/interior-light/main.js +87 -0
- package/examples/techniques/interior-light/picture/index.js +24 -0
- package/examples/techniques/interior-light/picture/lights.js +52 -0
- package/examples/techniques/interior-light/picture/materials.js +13 -0
- package/examples/techniques/interior-light/picture/palette.js +32 -0
- package/examples/techniques/interior-light/picture/sky.js +40 -0
- package/examples/techniques/modular-building/README.md +126 -0
- package/examples/techniques/modular-building/kit.js +426 -0
- package/examples/techniques/modular-building/main.js +39 -0
- package/examples/techniques/modular-building/picture/index.js +17 -0
- package/examples/techniques/modular-building/picture/lights.js +26 -0
- package/examples/techniques/modular-building/picture/materials.js +13 -0
- package/examples/techniques/modular-building/picture/palette.js +23 -0
- package/examples/techniques/night-lights/README.md +95 -0
- package/examples/techniques/night-lights/main.js +47 -0
- package/examples/techniques/night-lights/nightLights.js +95 -0
- package/examples/techniques/night-lights/picture/index.js +18 -0
- package/examples/techniques/night-lights/picture/lights.js +44 -0
- package/examples/techniques/night-lights/picture/materials.js +15 -0
- package/examples/techniques/night-lights/picture/palette.js +34 -0
- package/examples/techniques/night-lights/picture/post.js +9 -0
- package/examples/techniques/night-lights/picture/sky.js +36 -0
- package/examples/techniques/outlines-and-rim/README.md +59 -0
- package/examples/techniques/outlines-and-rim/main.js +61 -0
- package/examples/techniques/outlines-and-rim/outlines.js +64 -0
- package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
- package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
- package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
- package/examples/techniques/procedural-animation/README.md +79 -0
- package/examples/techniques/procedural-animation/creature.js +44 -0
- package/examples/techniques/procedural-animation/main.js +47 -0
- package/examples/techniques/procedural-animation/picture/index.js +15 -0
- package/examples/techniques/procedural-animation/picture/lights.js +35 -0
- package/examples/techniques/procedural-animation/picture/materials.js +10 -0
- package/examples/techniques/procedural-animation/picture/palette.js +16 -0
- package/examples/techniques/procedural-animation/picture/sky.js +31 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +118 -0
- package/examples/techniques/procedural-surface/README.md +69 -0
- package/examples/techniques/procedural-surface/main.js +65 -0
- package/examples/techniques/procedural-surface/picture/index.js +14 -0
- package/examples/techniques/procedural-surface/picture/lights.js +18 -0
- package/examples/techniques/procedural-surface/picture/materials.js +34 -0
- package/examples/techniques/procedural-surface/picture/palette.js +15 -0
- package/examples/techniques/procedural-surface/surface.js +120 -0
- package/examples/techniques/stylized-shading/README.md +74 -0
- package/examples/techniques/stylized-shading/main.js +62 -0
- package/examples/techniques/stylized-shading/picture/index.js +14 -0
- package/examples/techniques/stylized-shading/picture/lights.js +23 -0
- package/examples/techniques/stylized-shading/picture/materials.js +18 -0
- package/examples/techniques/stylized-shading/picture/palette.js +19 -0
- package/examples/techniques/stylized-shading/shading.js +131 -0
- package/examples/techniques/sun-and-key-light/README.md +133 -0
- package/examples/techniques/sun-and-key-light/keyLight.js +71 -0
- package/examples/techniques/sun-and-key-light/main.js +51 -0
- package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
- package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
- package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
- package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
- package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
- package/examples/techniques/three-looks/README.md +21 -0
- package/examples/techniques/three-looks/main.js +58 -0
- package/examples/techniques/three-looks/picture/cartoon.js +23 -0
- package/examples/techniques/three-looks/picture/cinematic.js +27 -0
- package/examples/techniques/three-looks/picture/comic.js +27 -0
- package/examples/techniques/three-looks/picture/index.js +14 -0
- package/examples/techniques/three-looks/picture/sun.js +23 -0
- package/examples/techniques/wet-road/README.md +102 -0
- package/examples/techniques/wet-road/main.js +48 -0
- package/examples/techniques/wet-road/picture/index.js +17 -0
- package/examples/techniques/wet-road/picture/lights.js +57 -0
- package/examples/techniques/wet-road/picture/materials.js +16 -0
- package/examples/techniques/wet-road/picture/palette.js +24 -0
- package/examples/techniques/wet-road/picture/sky.js +46 -0
- package/examples/techniques/wet-road/wetRoad.js +209 -0
- package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
- package/examples/webgpu-tsl/GAMEMAP.md +89 -0
- package/examples/webgpu-tsl/README.md +45 -0
- package/examples/webgpu-tsl/main.js +44 -0
- package/examples/webgpu-tsl/picture/index.js +18 -0
- package/examples/webgpu-tsl/picture/lights.js +25 -0
- package/examples/webgpu-tsl/picture/materials.js +36 -0
- package/examples/webgpu-tsl/picture/palette.js +23 -0
- package/examples/webgpu-tsl/picture/post.js +16 -0
- package/examples/webgpu-tsl/picture/sky.js +30 -0
- package/examples/world/.threedog/content-index.json +1 -0
- package/examples/world/GAMEMAP.md +31 -21
- package/examples/world/art/humanoid.js +38 -0
- package/examples/world/art/index.js +11 -0
- package/examples/world/art/models.js +57 -0
- package/examples/world/art/shapes.js +9 -0
- package/examples/world/assets.js +6 -0
- package/examples/world/content/audio.js +5 -5
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/rules.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +22 -18
- package/examples/world/models.js +17 -7
- package/examples/world/picture/index.js +20 -0
- package/examples/world/picture/lights.js +41 -0
- package/examples/world/picture/materials.js +34 -0
- package/examples/world/picture/palette.js +74 -0
- package/examples/world/picture/post.js +9 -0
- package/examples/world/picture/sky.js +39 -0
- package/index.d.ts +44 -54
- package/index.js +29 -25
- package/llms.txt +24 -15
- package/modules/ambience/Ambience.js +34 -23
- package/modules/calendar/Calendar.js +163 -0
- package/modules/calendar/contract.js +21 -0
- package/modules/calendar/index.js +82 -0
- package/modules/{sky → calendar}/schedule.js +17 -16
- package/modules/calendar/seasons.js +55 -0
- package/modules/camera/FirstPersonCamera.js +6 -15
- package/modules/camera/FixedCamera.js +33 -15
- package/modules/camera/FollowCamera.js +90 -16
- package/modules/camera/RtsCamera.js +18 -17
- package/modules/camera/common.js +73 -20
- package/modules/camera/contract.js +17 -0
- package/modules/camera/projection.js +11 -24
- package/modules/characters/Character.js +188 -48
- package/modules/characters/NPC.js +92 -41
- package/modules/characters/assetModel.js +8 -16
- package/modules/characters/behaviors.js +2 -1
- package/modules/characters/contract.js +13 -0
- package/modules/characters/footsteps.js +1 -1
- package/modules/characters/index.js +112 -49
- package/modules/characters/moveHelpers.js +4 -5
- package/modules/characters/movers/common.js +102 -19
- package/modules/characters/movers/manual.js +23 -0
- package/modules/characters/movers/rapier.js +19 -16
- package/modules/characters/movers/simple.js +14 -11
- package/modules/characters/movers/support.js +186 -0
- package/modules/characters/npcAvoid.js +47 -42
- package/modules/characters/npcSim.js +17 -9
- package/modules/characters/npcView.js +44 -16
- package/modules/characters/pathAsync.js +7 -3
- package/modules/characters/playerStrings.js +4 -3
- package/modules/characters/proceduralRig.js +19 -4
- package/modules/characters/useModel.js +2 -2
- package/modules/characters/vehicle.contract.js +21 -0
- package/modules/characters/walkTo.js +21 -7
- package/modules/collision/Collision.js +69 -27
- package/modules/collision/grid.js +8 -6
- package/modules/content/explain.js +2 -2
- package/modules/content/fields.js +102 -0
- package/modules/content/ids.js +8 -6
- package/modules/content/index.js +104 -27
- package/modules/content/loader.js +45 -33
- package/modules/content/models.js +58 -42
- package/modules/content/packs.js +6 -5
- package/modules/content/parts.js +41 -0
- package/modules/content/props.js +20 -11
- package/modules/content/rules.js +66 -0
- package/modules/content/stages.js +80 -0
- package/modules/content/templates.js +123 -30
- package/modules/debug/DebugPanel.js +24 -17
- package/modules/flow/contract.js +16 -0
- package/modules/flow/index.js +21 -15
- package/modules/gameplay/Container.js +41 -32
- package/modules/gameplay/Containers.js +30 -15
- package/modules/gameplay/Dialogue.js +113 -55
- package/modules/gameplay/Interactions.js +273 -72
- package/modules/gameplay/Inventory.js +72 -76
- package/modules/gameplay/Quests.js +75 -39
- package/modules/gameplay/boxOps.js +3 -3
- package/modules/gameplay/dialogue.contract.js +21 -0
- package/modules/gameplay/dialogueBox.js +4 -2
- package/modules/gameplay/dialogueBubbles.js +116 -0
- package/modules/gameplay/interactionPrompt.js +4 -1
- package/modules/gameplay/interactions.contract.js +16 -0
- package/modules/gameplay/inventory.contract.js +23 -0
- package/modules/gameplay/inventoryOps.js +19 -17
- package/modules/gameplay/pickups.js +306 -85
- package/modules/gameplay/questLog.js +6 -6
- package/modules/gameplay/quests.contract.js +17 -0
- package/modules/grid/Grid.js +92 -50
- package/modules/grid/Layer.js +27 -13
- package/modules/grid/index.js +96 -43
- package/modules/grid/ops.js +20 -18
- package/modules/grid/preview.js +37 -29
- package/modules/grid/strings.js +12 -0
- package/modules/grid/tiles.js +19 -22
- package/modules/hlod/index.js +52 -19
- package/modules/hud/index.js +48 -20
- package/modules/hud/parts.js +28 -13
- package/modules/level/heightfield.js +3 -1
- package/modules/level/index.js +49 -23
- package/modules/level/nodes.js +4 -3
- package/modules/lights/index.js +47 -19
- package/modules/music/Music.js +38 -21
- package/modules/music/rules.js +1 -1
- package/modules/nav/index.js +48 -42
- package/modules/net/Client.js +13 -6
- package/modules/net/Host.js +19 -5
- package/modules/net/Net.js +2 -1
- package/modules/net/index.js +13 -8
- package/modules/net/sync.js +9 -8
- package/modules/net/transports.js +77 -27
- package/modules/particles/Particles.js +58 -28
- package/modules/particles/contract.js +17 -0
- package/modules/particles/effect.js +54 -11
- package/modules/photo/Photo.js +56 -38
- package/modules/rigid/RigidBodies.js +194 -32
- package/modules/rigid/Vehicles.js +18 -15
- package/modules/rigid/sync.js +62 -17
- package/modules/settings/Settings.js +60 -55
- package/modules/settings/apply.js +38 -3
- package/modules/settings/sections.js +5 -3
- package/modules/settings/strings.js +3 -2
- package/modules/settings/view.js +5 -3
- package/modules/sky/Sky.js +132 -205
- package/modules/sky/clouds.js +37 -23
- package/modules/sky/dome.js +100 -0
- package/modules/sky/domeLayers.js +30 -15
- package/modules/sky/environment.js +45 -99
- package/modules/sky/fog.js +9 -139
- package/modules/sky/frame.js +60 -56
- package/modules/sky/season.js +21 -0
- package/modules/sky/shader.js +63 -35
- package/modules/sky/skyModule.js +52 -37
- package/modules/sky/tint.js +59 -0
- package/modules/terrain/ChunkManager.js +194 -110
- package/modules/terrain/chunkJob.js +1 -1
- package/modules/terrain/chunkQueries.js +6 -4
- package/modules/terrain/draw.js +154 -0
- package/modules/terrain/index.js +87 -54
- package/modules/terrain/terrainDefaults.js +2 -2
- package/modules/terrain/terrainEdit.js +18 -20
- package/modules/terrain/terrainGen.js +6 -4
- package/modules/terrain/terrainIsland.js +5 -4
- package/modules/terrain/terrainShape.js +12 -12
- package/modules/terrain/terrainShapeMain.js +8 -7
- package/modules/terrain/terrainTexture.js +21 -19
- package/modules/timeline/Timeline.js +95 -43
- package/modules/timeline/Tween.js +18 -10
- package/modules/timeline/letterbox.js +2 -2
- package/modules/timeline/shots.js +5 -1
- package/modules/triggers/index.js +111 -76
- package/modules/vegetation/Vegetation.js +229 -112
- package/modules/vegetation/densityMap.js +62 -0
- package/modules/vegetation/draw.js +191 -0
- package/modules/vegetation/groundChunks.js +52 -58
- package/modules/vegetation/index.js +32 -11
- package/modules/vegetation/modelGeometry.js +3 -2
- package/modules/vegetation/nearFade.js +8 -2
- package/modules/water/Water.js +157 -72
- package/modules/water/surface.js +86 -47
- package/modules/weather/Weather.js +96 -103
- package/modules/weather/particles.js +37 -14
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/strings.js +2 -2
- package/modules/weather/weatherDraw.js +141 -0
- package/modules/world/World.js +26 -9
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -4
- package/modules/world/persist.js +62 -2
- package/modules/world/pos.js +3 -2
- package/modules/world/records.js +8 -6
- package/modules/world/sim.js +60 -20
- package/modules/world/simFar.js +4 -3
- package/modules/world/state.js +3 -2
- package/modules/world/thingSource.js +1 -1
- package/modules/world/views.js +8 -6
- package/package.json +8 -3
- package/presets.js +43 -29
- package/render/PostFX.js +318 -135
- package/render/backend.js +486 -0
- package/render/cascades.js +195 -0
- package/render/cascades.tsl.js +96 -0
- package/render/daylight.js +39 -0
- package/render/detail.js +122 -41
- package/render/effects.js +155 -48
- package/render/engineUniforms.js +10 -1
- package/render/fuse.js +5 -4
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/cloudShadow.tsl.js +16 -0
- package/render/fx/detail.tsl.js +66 -0
- package/render/fx/index.js +28 -0
- package/render/fx/lighting.tsl.js +28 -0
- package/render/fx/nodeErrors.tsl.js +68 -0
- package/render/fx/noise.tsl.js +12 -0
- package/render/fx/objectOrigin.tsl.js +42 -0
- package/render/fx/particles.tsl.js +139 -0
- package/render/fx/patchNodes.tsl.js +403 -0
- package/render/fx/postWebGPU.tsl.js +181 -0
- package/render/fx/season.tsl.js +13 -0
- package/render/fx/sky.tsl.js +187 -0
- package/render/fx/uniforms.tsl.js +67 -0
- package/render/fx/water.tsl.js +53 -0
- package/render/fx/wind.tsl.js +22 -0
- package/render/fxNumbers.js +36 -0
- package/render/hotGlsl.js +24 -0
- package/render/layers.js +14 -0
- package/render/lighting.js +71 -18
- package/render/lightmap.js +142 -0
- package/render/lights.js +47 -6
- package/render/materials.js +55 -152
- package/render/modeling.js +73 -0
- package/render/neutral.js +23 -0
- package/render/occlusion.js +184 -0
- package/render/ownFrame.js +76 -0
- package/render/patches.js +317 -35
- package/render/postWebGL.js +205 -0
- package/render/probes.js +288 -0
- package/render/shaderErrors.js +154 -0
- package/render/slots.js +165 -0
- package/render/terms.js +163 -0
- package/render/uniformDecl.js +4 -3
- package/types/common.d.ts +2 -2
- package/types/core.d.ts +757 -346
- package/types/gameplay.d.ts +539 -330
- package/types/generated/core/Audio.d.ts +26 -42
- package/types/generated/core/Batching.d.ts +6 -2
- package/types/generated/core/Budget.d.ts +2 -8
- package/types/generated/core/DebugOverrides.d.ts +58 -9
- package/types/generated/core/I18n.d.ts +2 -2
- package/types/generated/core/Input.d.ts +110 -32
- package/types/generated/core/Ops.d.ts +31 -0
- package/types/generated/core/Random.d.ts +2 -2
- package/types/generated/core/Saves.d.ts +10 -2
- package/types/generated/core/Stream.d.ts +1 -1
- package/types/generated/core/Threads.d.ts +4 -1
- package/types/generated/core/Views.d.ts +0 -1
- package/types/generated/core/audioVoice.d.ts +17 -9
- package/types/generated/core/control.d.ts +55 -0
- package/types/generated/core/page.d.ts +9 -2
- package/types/generated/core/session.d.ts +2 -1
- package/types/generated/modules/ambience/Ambience.d.ts +0 -9
- package/types/generated/modules/calendar/Calendar.d.ts +84 -0
- package/types/generated/modules/calendar/index.d.ts +10 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Grid.d.ts +61 -25
- package/types/generated/modules/grid/Layer.d.ts +13 -5
- package/types/generated/modules/grid/index.d.ts +56 -20
- package/types/generated/modules/music/Music.d.ts +5 -3
- package/types/generated/modules/net/index.d.ts +3 -3
- package/types/generated/modules/net/transports.d.ts +12 -3
- package/types/generated/modules/particles/Particles.d.ts +13 -6
- package/types/generated/modules/sky/Sky.d.ts +85 -110
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/timeline/Timeline.d.ts +8 -6
- package/types/generated/modules/water/Water.d.ts +50 -3
- package/types/generated/modules/weather/Weather.d.ts +44 -15
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +20 -5
- package/types/generated/render/PostFX.d.ts +109 -29
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +31 -50
- package/types/generated/render/modeling.d.ts +30 -0
- package/types/generated/render/occlusion.d.ts +13 -0
- package/types/generated/render/patches.d.ts +16 -2
- package/types/generated/ui/UI.d.ts +6 -3
- package/types/nav.d.ts +6 -0
- package/types/physics.d.ts +140 -45
- package/types/tsl.d.ts +94 -0
- package/types/world.d.ts +489 -122
- package/ui/Focus.js +35 -14
- package/ui/LoadingScreen.js +3 -3
- package/ui/Parts.js +35 -15
- package/ui/UI.js +27 -17
- package/ui/cursor.js +115 -0
- package/ui/defaults.js +15 -11
- package/ui/theme.js +36 -27
- package/ui/touchPart.js +2 -2
- package/core/claims.js +0 -51
- package/core/look/coreParts.js +0 -112
- package/core/look/layers.js +0 -136
- package/core/look/part.js +0 -173
- package/core/look/report.js +0 -79
- package/core/look/write.js +0 -86
- package/core/renamed.js +0 -22
- package/core/styleParts.js +0 -98
- package/docs/api/entities.md +0 -61
- package/docs/api/style.md +0 -134
- package/docs/recipes/09-style-pack.md +0 -169
- package/docs/recipes/35-style-from-reference.md +0 -84
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/38-environment-look-hooks.md +0 -88
- package/docs/recipes/41-thing-registry.md +0 -93
- package/docs/recipes/43-shader-patches-surface-looks.md +0 -135
- package/docs/recipes/44-water-weather-look-hooks.md +0 -135
- package/docs/recipes/48-make-material.md +0 -70
- package/docs/recipes/52-look.md +0 -146
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/styletest/overrides.js +0 -33
- package/examples/styletest/panel.js +0 -135
- package/modules/entities/Entities.js +0 -243
- package/modules/entities/build.js +0 -25
- package/modules/entities/index.js +0 -4
- package/modules/sky/calendar.js +0 -80
- package/modules/sky/cascades.js +0 -125
- package/modules/sky/layers.js +0 -69
- package/modules/sky/look.js +0 -51
- package/modules/sky/lookFog.js +0 -80
- package/modules/sky/lookShadow.js +0 -50
- package/modules/sky/lookSky.js +0 -108
- package/modules/sky/shadow.js +0 -74
- package/modules/terrain/chunkLevels.js +0 -40
- package/modules/terrain/lookGround.js +0 -61
- package/modules/terrain/mountTerrain.js +0 -32
- package/modules/vegetation/lookWind.js +0 -37
- package/modules/water/look.js +0 -80
- package/modules/weather/look.js +0 -75
- package/modules/world/cells.js +0 -42
- package/render/lookSurface.js +0 -161
- package/render/postLook.js +0 -86
- package/render/surface.js +0 -69
- package/types/style.d.ts +0 -643
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Moving a game from 0.4 to 0.5
|
|
2
|
+
|
|
3
|
+
Upgrade steps for what an existing 0.4 game runs into; [CHANGELOG.md](../CHANGELOG.md) lists every change. Each item is:
|
|
4
|
+
what you see (the error code in square brackets, or the silent symptom) → what to write instead.
|
|
5
|
+
|
|
6
|
+
## Plugins: one owner per file, material plugins rebuild what is out
|
|
7
|
+
|
|
8
|
+
- `[shared-conflict]` at start naming two plugins of one style pack (`style:ink/10-a` and `style:ink/20-b`): both write the same key (two
|
|
9
|
+
Materials for one role). Before, the pack shared one owner and the later file silently won (and switching it off dropped both). Keep one
|
|
10
|
+
file, or say which wins in it: `export const replaces = '10-a';`.
|
|
11
|
+
- *silent*: `engine.plugins.off / on` of a material or patch plugin now also changes the materials already made (they are made again and
|
|
12
|
+
swapped in place: `engine.look.materials.rebuild()`). A game that kept a reference to such a material holds the old, disposed one: read
|
|
13
|
+
the mesh's `material` (or `look.materials.object(role)`) after the switch, or pass `{ rebuild: false }`.
|
|
14
|
+
- *silent*: `plugins.off` / `on` return a result object instead of `undefined`, and two post effects with equal `order` keep their first
|
|
15
|
+
place after off / on (before, the one switched on again moved to the end of its slot).
|
|
16
|
+
|
|
17
|
+
## Shadows off no longer touches your lights
|
|
18
|
+
|
|
19
|
+
- *silent*: with shadows off (`look.shadow.set({ enabled: false })` or the settings menu) a light's `castShadow` now stays what the game set;
|
|
20
|
+
only `renderer.shadowMap.enabled` goes off (both renderers then draw and sample no shadow maps). Code that read `castShadow === false` to
|
|
21
|
+
learn whether shadows are off → read `engine.renderer.shadowMap.enabled` (or `engine.look.shadow.value('enabled')`).
|
|
22
|
+
`describe().owned['shadows.off']` is gone (nothing is held any more); budget `shadowLights` reads 0 while shadows are off.
|
|
23
|
+
|
|
24
|
+
## Save parts must return copyable data
|
|
25
|
+
|
|
26
|
+
- `[save-part-threw]` "returned data that cannot be copied" on `saves.load` / `apply` / `session.newGame`: the engine now copies every part's
|
|
27
|
+
`save()` before a load (structuredClone) so a failed load can be undone even when `save()` returns the live object. A `save()` whose result
|
|
28
|
+
holds a function, a DOM node or a three object (written to disk it lost those silently) → return plain data: `save: () => ({ hp: s.hp, items: [...s.items] })`.
|
|
29
|
+
- *silent*: a listener that throws after an `await` in an async part `load()` now fails the load (resolves false, rolled back), as one before
|
|
30
|
+
the `await` always did. A test that expected such a load to resolve true had the bug.
|
|
31
|
+
## Look values left the module options
|
|
32
|
+
|
|
33
|
+
One entry per value: a look value is a `look.*` param (style layer: the style file), and a module option is only a structural choice.
|
|
34
|
+
A removed option throws in dev at the call, naming the new one (`[water-option]`, `[sky-option]`, `[terrain-option]`):
|
|
35
|
+
|
|
36
|
+
- `water({ color | opacity | waveHeight | waveScale | waveSpeed | fresnel | depthColor | foam | normalMap | normalScale | normalRepeat |
|
|
37
|
+
normalSpeed | shininess | specular })` → the same key in `style.water`, or `engine.look.water.set({ ... })` after `engine.use(water())`.
|
|
38
|
+
`water({ material })` → `engine.look.water.replace(material)` (or `style.water.material`): the same slot, one entry. `water()` keeps
|
|
39
|
+
`sea`, `level`, `flat`, `size`, `segments`, `uniforms` (they declare the uniforms the `look.water.patch` hooks read, and your replaced
|
|
40
|
+
material gets them in its `{ uniforms }`).
|
|
41
|
+
- `sky({ keyframes | sunSize | sunGlow | sunBrightness | moonSize | moonColor | moonBrightness | starDensity | starScale | gradientCurve |
|
|
42
|
+
groundTint | orbitTilt | orbitSway | dim | clouds | backdrop })` → `style.sky.<key>`, or `engine.look.sky.set({ ... })` (`dim: { stars: false }`
|
|
43
|
+
and `clouds: { coverage }` nest as before). `sky({ skybox })` → `engine.look.sky.replace(skybox)`; `sky({ layers })` →
|
|
44
|
+
`engine.look.sky.patch('layer:<name>', layer)` per layer (or `style.sky.layers`). `sky()` keeps `time`, `fog`, `sun`, `hemisphere`, `shadow`,
|
|
45
|
+
`environment`.
|
|
46
|
+
- `terrain({ normals })` → `style.terrain.config.normals`, or `engine.look.ground.set({ normals })`.
|
|
47
|
+
- *silent*: these values used to sit on the game layer of the look (`describe().look.water.opacity.writer` was `game`); from the style they
|
|
48
|
+
read `style`, from `set` `game` (or your owner).
|
|
49
|
+
|
|
50
|
+
## Library code pulled into plugins/
|
|
51
|
+
|
|
52
|
+
- *silent*: `threedog lib pull <code entry>` now copies the entry's files into `plugins/<name>/` and writes `plugins/<name>.js`, the wiring
|
|
53
|
+
file that calls its factory (`export default makeIt();`). A game that pulled with 0.4 and hand-wrote the line keeps working; pulling again
|
|
54
|
+
lands beside it, so delete the old copy first. Set the call when adding (`threedog lib add ... --plug "makeIt({ size: 4 })"`) or when
|
|
55
|
+
pulling (`--plug`).
|
|
56
|
+
- `[plugin-shape]` messages changed: each names the file, what it exports, and the fix for that case (a factory function, a module with no
|
|
57
|
+
`type`, a module with no hook, an effect with no name). A test matching the old text ("exports a function") needs the new wording.
|
|
58
|
+
|
|
59
|
+
## Names taken out of the type declarations
|
|
60
|
+
|
|
61
|
+
These never did anything a game needed; `npm run types` now reports them. Nothing changes at runtime.
|
|
62
|
+
|
|
63
|
+
- `engine.look.clouds` (an old name; at runtime it has been `undefined` since 0.3) → `engine.look.cloudShadow`.
|
|
64
|
+
- `import type { Light } from 'threedog'` (three.js's class, leaked by the declarations; the runtime never exported it) → `import type { Light } from 'three'`.
|
|
65
|
+
- `.engine` on `engine.terrain`, a character (`engine.player`, an NPC), `engine.cameraRig`, `engine.control`, `engine.views` → use the
|
|
66
|
+
`engine` your code already holds (the factory's `install(engine)`, `createEngine`'s result).
|
|
67
|
+
- `engine.audio.info`, `engine.ambience.info`, `engine.level.buildMs`: debug readouts the engine's own tests read. They still answer at
|
|
68
|
+
runtime; a game that reads them for its own logic should keep its own state instead (the rules it set, the sounds it played).
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Moving a game from 0.5 to 0.6
|
|
2
|
+
|
|
3
|
+
`engine.look.*` is removed: the capabilities stay, as plain three.js or as one entry on the module that owns them. Each row is old -> new.
|
|
4
|
+
|
|
5
|
+
## Sky: `engine.look.sky` is gone
|
|
6
|
+
|
|
7
|
+
| Old | New |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `engine.look.sky.replace(x)` | `engine.sky.replace(x)` (null gives the dome back) |
|
|
10
|
+
| `engine.look.sky.set({ sunSize, moonColor, starDensity, ... })` | `sky({ ... })` at install; after it `engine.uniforms.uSunSize.value` and friends (recipe 08) |
|
|
11
|
+
| `engine.look.sky.set({ clouds: { coverage, scale, speed } })` | `engine.uniforms.uCloudCover`, `uSkyCloudScale`, `uSkyCloudSpeed` |
|
|
12
|
+
| `engine.look.sky.set({ keyframes })` | `engine.sky.keyframes(rows)` |
|
|
13
|
+
| `engine.look.sky.set({ top, horizon, backdrop, orbitTilt, dim })` | plain fields `engine.sky.top`, `.horizon`, `.backdrop`, `.orbit.tilt`, `.dim`; a color function: write the field in your frame code |
|
|
14
|
+
| `engine.look.sky.patch('clouds', x)`, `patch('layer:<name>', x)` | `engine.sky.clouds(x)`, `engine.sky.layer(name, x)` |
|
|
15
|
+
| `engine.look.env.replace('sky')`, `sky({ environment })`, `style.sky.environment` | `engine.sky.environment({ into: engine.scene })` |
|
|
16
|
+
| `engine.look.env.replace(asset \| Texture \| target)`, `look.env.set({ intensity, rotation })` | `scene.environment`, `scene.environmentIntensity`, `scene.environmentRotation`, `THREE.PMREMGenerator` (recipe 34) |
|
|
17
|
+
| `engine.mod('look.sky.tint' \| 'look.sky.flash' \| 'look.ground.cover', ...)` | `engine.mod('sky.tint' \| 'sky.flash' \| 'ground.cover', ...)` |
|
|
18
|
+
| keyframe rows `[time, zenith, horizon, lightColor, lightIntensity, ambient]` | `[time, zenith, horizon, sunColor, ambient]`: the intensity column drove nothing and six columns now throw; the color is the signal `engine.uniforms.uSunColor` |
|
|
19
|
+
| `engine.sky.setShadowMapSize(n)`, `engine.sky.shadowMapSize` | `engine.shadows.mapSize(light, n)`, `light.shadow.mapSize` |
|
|
20
|
+
|
|
21
|
+
## Post effects: `engine.look.post` is gone
|
|
22
|
+
|
|
23
|
+
| 0.5 | 0.6 |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `engine.look.post.add(x, { name, slot, order })` | `engine.post.add(x, { name, slot, order })`, returns `{ name, enabled, set(params), remove() }` |
|
|
26
|
+
| `look.post.set({ bloom: false })` | `engine.post.get('bloom').enabled = false` |
|
|
27
|
+
| `look.post.set({ 'bloom.strength': 0.6 })` | `engine.post.get('bloom').set({ strength: 0.6 })` |
|
|
28
|
+
| `look.post.replace([...])` | remove the handles and add the new effects |
|
|
29
|
+
| `look.post.manual('chain')` | `engine.post.own()`, back with `engine.post.own(false)` |
|
|
30
|
+
| settings `{ limits: 'look.post.<name>.enabled' }` | `{ limits: 'post.<name>.enabled' }` |
|
|
31
|
+
| a heavy effect a style brought started off on low-tier devices (`costly`) | the engine no longer decides: read `engine.tier` before adding it |
|
|
32
|
+
|
|
33
|
+
## Tone: `engine.look.tone` is gone
|
|
34
|
+
|
|
35
|
+
| 0.5 | 0.6 |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `engine.look.tone.set({ exposure })` | `engine.renderer.toneMappingExposure = x` |
|
|
38
|
+
| `engine.look.tone.manual('toneMapping')` | nothing to take: `engine.renderer.toneMapping = THREE.AgXToneMapping` |
|
|
39
|
+
|
|
40
|
+
## Lights: `engine.look.lights` is gone
|
|
41
|
+
|
|
42
|
+
| 0.5 | 0.6 |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `engine.look.lights.set({ sun: { intensity, color } })`, `hemi` likewise | `engine.lights.sun.intensity = x`, `engine.lights.hemi.color.set(c)`, or `createEngine({ lights: false })` and your own lights |
|
|
45
|
+
| `engine.mod('look.lights.sun.intensity', { mul })`, `settings { limits: 'look.lights.*' }` | keep your own factor in your `picture/` code and multiply when you write the light; weather's is `engine.uniforms.uWeatherLight` |
|
|
46
|
+
| `engine.look.lights.set({ env: { intensity } })` (the neutral room map) | `scene.environment = new THREE.PMREMGenerator(engine.renderer).fromScene(new RoomEnvironment()).texture`, `scene.environmentIntensity = x` (`RoomEnvironment` from `three/addons/environments/RoomEnvironment.js`) |
|
|
47
|
+
| `engine.look.lights.manual('probes')` | `probes.own()`, back with `probes.own(false)` |
|
|
48
|
+
|
|
49
|
+
## Fog: `engine.look.fog` is gone
|
|
50
|
+
|
|
51
|
+
| 0.5 | 0.6 |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `engine.look.fog.set({ far, near, color })` | `engine.scene.fog = new THREE.Fog(color, near, far)`, or write `.color`, `.near`, `.far` on it; read `engine.uniforms.uViewDistance`, `uSkyHorizon`, `uWeatherFog` |
|
|
54
|
+
| `engine.look.fog.set({ kind: 'exp2', density })` | `engine.scene.fog = new THREE.FogExp2(color, density)` |
|
|
55
|
+
| `engine.look.fog.set({ enabled: false })` | `engine.scene.fog = null` |
|
|
56
|
+
| `engine.look.fog.set({ kind: 'height' })`, `look.fog.patch('fog', x)` | three.js: `onBeforeCompile` on your materials, `scene.fogNode` on `renderer: 'webgpu'` |
|
|
57
|
+
| `engine.mod('look.fog.far', { mul })` | your own factor in your `picture/` code, multiplied in when you write the fog |
|
|
58
|
+
|
|
59
|
+
## Cloud shadow: `engine.look.cloudShadow` is gone
|
|
60
|
+
|
|
61
|
+
| 0.5 | 0.6 |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `look.cloudShadow.set({ shadow, scale, speed })` | `engine.uniforms.uCloudShadow.value`, `uCloudScale.value`, `uCloudSpeed.value.set(x, z)` |
|
|
64
|
+
| `look.cloudShadow.replace(spec \| false)` | `engine.terms.cloudShadow(spec \| false)`, returns `{ remove() }` |
|
|
65
|
+
| a plain lit material took the cloud shadow on its own; `userData.cloudShadow = false` kept one out | nothing is added unasked: call `applyEffects(mat)` on the materials that should darken |
|
|
66
|
+
|
|
67
|
+
## Season tint: `engine.look.season` is gone
|
|
68
|
+
|
|
69
|
+
| 0.5 | 0.6 |
|
|
70
|
+
|---|---|
|
|
71
|
+
| `look.season.replace(spec \| kind => spec \| false)` | `engine.terms.season(spec \| kind => spec \| false)`, returns `{ remove() }` |
|
|
72
|
+
|
|
73
|
+
## Wind: `engine.look.wind` is gone
|
|
74
|
+
|
|
75
|
+
| 0.5 | 0.6 |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `look.wind.set({ frequency, amplitude })` | `engine.uniforms.uWindFreq.value`, `uWindAmp.value` |
|
|
78
|
+
| `look.wind.patch('sway', { glsl, tsl, uniforms })` | the species' `wind: { amplitude, glsl, tsl, uniforms }` in `vegetation.define`, or `applyEffects(mat, { wind: { ... } })` |
|
|
79
|
+
|
|
80
|
+
## Shadows: one map now follows the camera
|
|
81
|
+
|
|
82
|
+
`engine.shadows.cascades(light)` with one map (`count: 1`, or a low-tier device) used to leave your light where it was, on three's default 10 m shadow box. It now places the light like cascades do: the map follows the camera and covers `maxFar` each way, `remove()` puts everything back, and `engine.shadows.box` on that light is refused while it is on. Nothing to change unless you sized that light's shadow camera yourself for the low tier: leave it to `maxFar`, or call `engine.shadows.box(light, { ... })` instead of `cascades` there.
|
|
83
|
+
|
|
84
|
+
## The rest of the look and style layer is gone
|
|
85
|
+
|
|
86
|
+
Older parts and every `style.*` key, row by row: [MIGRATING-0.4.md](MIGRATING-0.4.md).
|
|
87
|
+
|
|
88
|
+
| 0.5 | 0.6 |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `createEngine({ style })` | throws `[engine-misuse]`: the picture is plain three.js in the game's `picture/` folder, `createPicture(engine)` (recipes 62, 63); UI colors go in `createEngine({ ui })` |
|
|
91
|
+
| `engine.mod(point, { layer: 'style' })` | throws `[shared-layer]`: use the default `game` layer (recipe 55) |
|
|
92
|
+
| `look.<part>.manual(key)` | `engine.view.manual('far' \| 'fov' \| 'pixelRatio')`; the other values have the entries in the tables above |
|
|
93
|
+
| `engine.look.water` | `engine.water.material`, `.uniforms`, `.patches`, `.shader()`, `.normalMap()` (recipe 44) |
|
|
94
|
+
| `makeMaterial(role)`, `engine.makeMaterial`, `engine.look.materials` | any `new THREE.*Material` in `picture/materials.js`; a module's material is `engine.<module>.material` (recipe 09) |
|
|
95
|
+
| `engine.look.surface` | per material: `applyEffects(mat, { lighting, detail })`, `rampTexture(ramp, soften)` on a toon material (recipe 43) |
|
|
96
|
+
| `look.shadow.set({ enabled })` | `engine.shadows.enabled = false` |
|
|
97
|
+
| `look.shadow.set({ type })` | `engine.renderer.shadowMap.type` |
|
|
98
|
+
| `look.shadow.set({ cascades })`, `look.shadow.include(mat)` | `engine.shadows.cascades(light, { count })`, `engine.shadows.include(mat)` (recipe 45) |
|
|
99
|
+
| `defineLookPart(...)` in a module | module options and a plain `engine.<module>.material` |
|
|
100
|
+
| `threedog style check` | `npm run check` type-checks `picture/` |
|
|
101
|
+
| `threedog style palette \| compare` | `threedog picture palette \| compare` |
|
|
102
|
+
| `engine.styleWorkbench` | `engine.devPanel`, after `openPanel(engine)` from `@threedog/tools/panel` (recipe 35) |
|
|
103
|
+
|
|
104
|
+
## Names: "look" becomes "picture"
|
|
105
|
+
|
|
106
|
+
The look layer is gone, so the word no longer names picture things. Mouse and camera look (`input.look`, `lookAt`, `mouseLook`) keep their names. No aliases: the old names just stop existing.
|
|
107
|
+
|
|
108
|
+
| Old | New |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| game folder `look/` | `picture/` (also the `include` line of a game's `tsconfig.json`) |
|
|
111
|
+
| `createLook(engine)`, `const look = ...`, `look.lamp(id)`, `look.materials` | `createPicture(engine)`, `const picture = ...`, `picture.lamp(id)`, `picture.materials` |
|
|
112
|
+
| module type `type: 'look'` | `type: 'picture'` |
|
|
113
|
+
| `engine.terrainLook`, `engine.vegetationLook`, `engine.weatherLook` | `engine.terrainDraw`, `engine.vegetationDraw`, `engine.weatherDraw` |
|
|
114
|
+
| `replaces: 'terrainLook'`, `'vegetationLook'`, `'weatherLook'` | `replaces: 'terrainDraw'`, `'vegetationDraw'`, `'weatherDraw'` |
|
|
115
|
+
| slots `terrain-look`, `vegetation-look`, provides `weatherLook` | `terrain-draw`, `vegetation-draw`, `weatherDraw` |
|
|
116
|
+
| `SkyLookOptions` (types) | `SkyPictureOptions` |
|
|
117
|
+
| `threedog shot --no-look`, `threedog snap --no-look` | `--no-picture` |
|
|
118
|
+
| `look` and `lookMs` in `threedog shot --json`; the printed `Look:` line | `picture` and `pictureMs`; `Picture:` |
|
|
119
|
+
| DESIGN.md line `Look intent:` | `Picture intent:` |
|
|
120
|
+
| `threedog lib add --kind look` | `--kind picture` (an entry of the old kind in a library is re-added under the new one) |
|
|
121
|
+
| `@threedog/tools/look` (`lookHints`, `lookNumbers`, `probeLook`, `pageLook`, `imageLook`, `formatLook`) | `@threedog/tools/picture-check` (`pictureHints`, `pictureNumbers`, `probePicture`, `pagePicture`, `imagePicture`, `formatPicture`) |
|
|
122
|
+
| recipes 35-look-from-reference, 36-sky-ground-plant-looks, 37-terrain-look-hooks, 38-environment-look-hooks, 43-shader-patches-surface-looks, 44-water-weather-look-hooks, 52-look | 35-picture-from-reference, 36-sky-ground-plants, 37-terrain-hooks, 38-environment-hooks, 43-shader-patches-surfaces, 44-water-weather-hooks, 52-around-the-picture |
|
|
123
|
+
| recipe 41-thing-registry | merged into 40-scene (one recipe on what is in the scene and what a save keeps) |
|
|
124
|
+
| example `plain-look` | `plain-picture` |
|
|
125
|
+
| `grids.preview({ look })` | `grids.preview({ draw })` (`false`, or `(engine) => part`) |
|
|
126
|
+
| `layer(name, { tiles: { look } })` | `tiles: { color }`, the same `(data, cell) => color \| null`; an unknown `tiles` key now throws |
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Moving a game from 0.6 to 0.7
|
|
2
|
+
|
|
3
|
+
## Light probes: every pixel takes its own light
|
|
4
|
+
|
|
5
|
+
`engine.bakeProbes` now builds three's probe grid, so the one scene light that followed a point is gone. Bake or load the same way; lit materials pick the grid up by themselves.
|
|
6
|
+
|
|
7
|
+
| 0.6 | 0.7 |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `bakeProbes({ follow })`, `loadProbes(json, { follow })` | delete it: every pixel inside the grid has its own light |
|
|
10
|
+
| `bakeProbes({ height: 1.5 })` (one layer over the ground) | `bounds` around the ground and the air above it; a grid is a box, and needs 2 layers an axis |
|
|
11
|
+
| `probes.probe`, `probes.own()` | `probes.grid`, a plain three.js light; a light of your own from `probes.sample(pos, myProbe)` as before |
|
|
12
|
+
| `probes.probe.intensity` | `probes.grid.intensity` on WebGPU; on WebGL three ignores it, so change the light you bake, or the exposure |
|
|
13
|
+
| a probe file from 0.6 (version 1) | refused with `probes-data`: bake again (the file is now half precision, about a third of the size) |
|
|
14
|
+
| objects anywhere got the light of the follow point | outside the grid there is no probe light: size `bounds` to the scene (`describe().render.probes.outside`) |
|
|
15
|
+
|
|
16
|
+
## Removed from the public surface
|
|
17
|
+
|
|
18
|
+
| 0.6 | 0.7 |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `engine.level.object` | `engine.level.root` (the same object) |
|
|
21
|
+
| `engine.inventory.defs` | `engine.inventory.item(id)` for one definition; not in the types any more |
|
|
22
|
+
| `engine.quests.defs` | `engine.quests.list()`; not in the types any more |
|
|
23
|
+
| `engine.triggers.action`, `engine.settings.action`, `engine.interactions.action` | the option you passed to `triggers()`, `settings()`, `interactions()` |
|
|
24
|
+
|
|
25
|
+
## Follow camera and characters
|
|
26
|
+
|
|
27
|
+
| 0.6 | 0.7 |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `collision({ cameraOcclusion })` defaulted to colliders only | the default is `'both'`: meshes added with `engine.rays.addStatic(mesh, { occluder: true })` and level buildings stop the camera arm too; `cameraOcclusion: 'colliders'` keeps the old test |
|
|
30
|
+
| `character.placeAt` over a prop or platform ignored it | it stands on a registered support (recipe 32 says what a support needs) |
|
|
31
|
+
| `mover: 'manual'` skipped the `states` hook | it runs the `states` hook (recipe 57, "Moved by script") |
|
|
32
|
+
|
|
33
|
+
## Layers 26 to 29 and 31 are reserved
|
|
34
|
+
|
|
35
|
+
The engine keeps these three.js layers for itself (`RESERVED_LAYERS` from `threedog/layers`). A game's own layers are 1 to 25; move anything of yours on layers 26 to 28 down. Layer 30 stays the default camera `hideLayer`.
|
|
36
|
+
|
|
37
|
+
## Starting a game
|
|
38
|
+
|
|
39
|
+
`threedog new-game --example` and `templates/example` are gone: start from `new-game` itself, and read the engine's `examples/` for finished techniques.
|
package/docs/PERF.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Performance comparison (PERF)
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Sections 1-5 come from a cloud environment without a GPU (Chromium + SwiftShader software rendering, 1280x720, pixel ratio 1; section 6 is a real GPU). Use them only for
|
|
4
4
|
**relative comparison**; they do not represent real-device frame rates.
|
|
5
5
|
> Reproduce: `node packages/tools/perf.mjs [frames]` (default 60 frames; it builds first, then opens
|
|
6
6
|
> `packages/engine/tests/perf/index.html` in a headless browser; both are in the engine repository, not the npm package).
|
|
@@ -28,7 +28,7 @@ The average is capped by the display refresh rate, so this shows headroom exists
|
|
|
28
28
|
a hemisphere light, `renderer.render` every frame.
|
|
29
29
|
- `engine`: the same scene inside `createEngine()` (**no modules installed**), running the same sequence as the real-time loop each frame: fixed
|
|
30
30
|
step -> frame hooks (including stream/jobs) -> render -> budget sampling -> afterRender.
|
|
31
|
-
- `world`: `openWorld()` plus the gameplay modules
|
|
31
|
+
- `world`: `openWorld()` plus the gameplay modules (interactions, dialogue, inventory, quests, timeline, triggers,
|
|
32
32
|
particles, hud; debug panel, music and ambience off), with the same seed, the same flat ground and the same vegetation as the open-world example,
|
|
33
33
|
without NPCs/quests or other content; `engine.profile()` times `fixed/frame/afterRender` for each module.
|
|
34
34
|
- `props`: `n` repeated props over 4 models placed through `world.present`, with a directional shadow; `batch=0` turns `engine.batching` off (section 3c).
|
|
@@ -67,9 +67,8 @@ Whole frame 3.99 ms, of which rendering (submitting draw commands) 2.97 ms; 74 d
|
|
|
67
67
|
| terrain (chunk streaming, LOD, frustum) | 0.04 | 0.06 |
|
|
68
68
|
| weather | 0.02 | < 0.01 |
|
|
69
69
|
| characters / interactions / particles | 0.01 each | < 0.01-0.01 |
|
|
70
|
-
| triggers,
|
|
70
|
+
| triggers, quests, timeline, water, dialogue, settings, hud, inventory | 0 | < 0.01 |
|
|
71
71
|
|
|
72
|
-
(photo is no longer installed by openWorld by default, so it is not in the table.)
|
|
73
72
|
Conclusion: module logic totals about 0.9 ms/frame (a quarter of the frame), and the biggest part is still Rapier; every item rose together with the
|
|
74
73
|
slower whole frame (slower machine), and no single module became slower.
|
|
75
74
|
particles: group X once measured 0.21 ms/frame, and this run alone it is 0.01. The world scene has no particle effects (no emit/attach); particles per
|
|
@@ -104,8 +103,8 @@ back restores 93.
|
|
|
104
103
|
`npm run perf -- --only=props`: 3000 repeated props over 4 models (a lamp of 2 meshes, a fence, a crate, an AC unit; 3750 meshes), each a world record
|
|
105
104
|
presented as a clone of its model, spread over about 143 x 143 m (16 cells of 64 m), one directional light with shadows, 60 frames, headless Chromium
|
|
106
105
|
with ANGLE SwiftShader
|
|
107
|
-
on the user's Windows machine (
|
|
108
|
-
|
|
106
|
+
on the user's Windows machine (plain `--use-gl=swiftshader` does not start WebGL there, which is why section 5 shows 0 draw calls; perf.mjs has since
|
|
107
|
+
moved to the hardware GPU when headless reaches one, so later runs of this table are GPU numbers: the first output line names the renderer).
|
|
109
108
|
|
|
110
109
|
| | CPU ms/frame | Render ms/frame | Draw calls (incl. shadow) | Shadow draw calls | Batches | Instances |
|
|
111
110
|
|---|---|---|---|---|---|---|
|
|
@@ -120,6 +119,10 @@ The batching bookkeeping itself costs about 0.46 ms/frame with 3000 batched obje
|
|
|
120
119
|
|
|
121
120
|
## 4. Open to playable (engine.startup)
|
|
122
121
|
|
|
122
|
+
> Dated: the tables below predate the 2026-11-02 cold-start change (no scene render before ready, `compileAsync` for the real render target, the
|
|
123
|
+
> room environment built only when a material reads it, Rapier / Recast loading from install). After it a test game measured 2.9 s cold start with
|
|
124
|
+
> 2.46 s of long tasks before ready (Radeon 780M, headless); the open-world rows have not been remeasured.
|
|
125
|
+
|
|
123
126
|
| Example | Open to playable ms | start() to playable ms | Asset preload ms | First-screen chunks (terrain ready) ms | Slowest module |
|
|
124
127
|
|---|---|---|---|---|---|
|
|
125
128
|
| Open world (`/`), before optimization | 7036 | 6778 | 0 | 4319 | terrain 4319 |
|
|
@@ -200,11 +203,36 @@ sampling the ground raster (water / slope, cached 5 s) and the batches that came
|
|
|
200
203
|
fewer are late.
|
|
201
204
|
threads 0 costs a little more than the sync loop (batch building plus the raster), so `findPath` stays the call for one-off paths.
|
|
202
205
|
|
|
206
|
+
## 6. Load budget (`threedog stress`), 2026-11-02
|
|
207
|
+
|
|
208
|
+
**Machine: `ANGLE (AMD, AMD Radeon 780M Graphics (0x00001900) Direct3D11 vs_5_0 ps_5_0, D3D11)`** (AMD Ryzen 7 integrated GPU, headless Chromium on
|
|
209
|
+
the hardware GPU), 1280x720, pixel ratio 1, 30 frames per step, medians. Other headless browsers were running on the machine at the same time: expect
|
|
210
|
+
10-20% noise. The same machine's discrete GPU (RTX 5060) is measured separately by the user (key B on the WebGPU compare page); add its row here.
|
|
211
|
+
|
|
212
|
+
Each axis alone on the neutral page `tests/stress/` (gray ground, the engine's default lights, 400 boxes under the light / shadow / post axes). frame =
|
|
213
|
+
CPU + waiting for the GPU to finish, no overlap: an upper bound of the real frame. "≈" is log-interpolated between the two steps around the crossing.
|
|
214
|
+
|
|
215
|
+
| Axis (unit) | Fits 16.7 ms | Fits 33 ms | CPU / GPU / frame ms at the 16.7 ms load | Stopped by |
|
|
216
|
+
|---|---|---|---|---|
|
|
217
|
+
| triangles (1M-triangle tiles, few draws) | ≈ 45M | ≈ 100M | 0.6 / 10.1 / 11.9 | 33 ms |
|
|
218
|
+
| draw calls (separate meshes, one material) | ≈ 2400 | ≈ 4800 | 8.6 / 4.5 / 13.1 | 33 ms |
|
|
219
|
+
| instances (one InstancedMesh of boxes) | ≈ 3.2M | ≈ 7.3M | 0.3 / 15.0 / 16.6 | 33 ms |
|
|
220
|
+
| point + spot lights (no shadow) | ≥ 128 | ≥ 128 | 2.3 / 10.3 / 13.6 | shader compile fails at 256 (uniform limit) |
|
|
221
|
+
| shadow-casting spot lights (1024²) | ≥ 8 | ≥ 8 | 2.7 / 2.8 / 6.6 | shader compile fails at 16 (texture units) |
|
|
222
|
+
| sun shadow map size | ≈ 9700² (8192² fits) | ≈ 13000² | 2.7 / 2.8 / 6.3 at 8192² | 33 ms (16384²: 45 ms GPU) |
|
|
223
|
+
| overlapping full-view transparent quads | ≈ 58 | ≈ 113 | 0.4 / 8.2 / 9.3 | 33 ms |
|
|
224
|
+
| point particles (4 px, additive) | ≈ 1.7M | ≈ 3.8M | 0.3 / 14.6 / 15.8 | 33 ms |
|
|
225
|
+
| post effects, cumulative: bloom, vignette, grain, lut, chromatic, outline, ao, dof | 7 (all but dof) | all 8 (17.1 ms) | 4.1 / 9.7 / 15.0 | ladder end |
|
|
226
|
+
| skinned characters (24 bones, 2352 triangles, own mixer) | ≈ 230 | ≈ 440 | 4.9 / 2.7 / 9.2 | 33 ms |
|
|
227
|
+
|
|
228
|
+
Reading it: on this iGPU draw calls and skinned characters are CPU-bound (main thread), everything else is GPU-bound; ao (GTAO) is the costliest
|
|
229
|
+
single post effect (+5 ms GPU, it redraws the scene for normals). Real scenes combine axes, so take a game's limit well below one axis' crossing.
|
|
230
|
+
|
|
203
231
|
## Limitations
|
|
204
232
|
|
|
205
233
|
- SwiftShader does the GPU's work on the CPU, but WebGL commands are submitted asynchronously: "render ms" in the tables is mostly the time three.js
|
|
206
234
|
spends traversing the scene + submitting commands, and **does not include** the time to actually draw pixels. Fragment-heavy things (shadow map
|
|
207
|
-
resolution, bloom, ambient occlusion, transparent overdraw) show no difference here;
|
|
235
|
+
resolution, bloom, ambient occlusion, transparent overdraw) show no difference here; measure them with `threedog stress` on the GPU (section 6).
|
|
208
236
|
- Noise: the same configuration run repeatedly can differ by 10-30%; draw no conclusion from smaller differences.
|
|
209
237
|
- The `world` mode has no NPCs, pickups or other content, so it has fewer draw calls than the open-world example; to see the example itself, open
|
|
210
238
|
`npm run dev` and run the stress test with F3.
|
package/docs/THREE.md
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Write three.js; the engine adopts it
|
|
2
|
+
|
|
3
|
+
The scene, camera, lights, characters and models in the engine are **plain three.js objects** (three 0.187). Write the three.js you already
|
|
4
|
+
know: what the engine can see, it plugs in with no extra call. Only where it cannot know your intent do you write one line.
|
|
5
|
+
Picture work (materials, shaders, textures, lights, post passes) always take this route first; engine picture features are optional conveniences on top.
|
|
6
|
+
This is the one place that order is stated: a material is `new THREE.*Material` / `ShaderMaterial` before a slot patch, a post
|
|
7
|
+
pass is a three.js Pass (`engine.post.add(pass)`) before a ready-made effect.
|
|
8
|
+
|
|
9
|
+
| You write (plain three.js) | The engine does | The one line, only when you mean it |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `engine.scene.add(obj)` / `group.add(obj)` | registers each root under the scene like `engine.add`: `engine.thing`, `describe().scene`, `thing.set` / `thing.remove` | a stable id so a save finds it: `engine.add(obj, { id: 'mill' })` |
|
|
12
|
+
| `new THREE.PointLight(...)` / `SpotLight` added to the scene | a real light, adopted as a thing; counted by `engine.budget` `lights` / `shadowLights`, listed in `describe().render.lights`; a casting light at intensity 0 stops redrawing its shadow map; weather and day-night leave its values alone | many sources, few real lights: `lightPool` (recipe 52) |
|
|
13
|
+
| `new THREE.MeshStandardMaterial(...)` | scene fog (height fog too), cascaded shadows | wind sway: `applyEffects(mat, { wind: 0.03 })` |
|
|
14
|
+
| `engine.post.add(pass)`, the one way into the chain (the other renderer's form: recipe 56) | slots it after the scene render and before tone mapping (FXAA / SMAA last), or after tone mapping when you added it after an OutputPass; a pass that renders `engine.scene` itself (RenderPixelatedPass, SSAA, TAA) replaces the scene render, so the scene is drawn once; skips a RenderPass / OutputPass it already has; listed in `post.list()`; `remove()` leaves it undisposed | a settings name and position: `add(pass, { name: 'glow', order })`, then `engine.post.get({ glow: false })` |
|
|
15
|
+
| your own `EffectComposer` / `renderer.render` of the whole canvas, every frame | yields the frame (stops drawing its own, warns once `[own-frame]`); delete your render call to hand it back. A minimap / HUD layer on top (scissor, smaller viewport, or `autoClear = false` with another scene) is not a takeover | - |
|
|
16
|
+
| `renderer.setSize` / `setPixelRatio` yourself | the post chain follows on its next draw | - |
|
|
17
|
+
| `scene.fog.far = 80`, `sun.intensity = 3`, `renderer.toneMappingExposure = 1.4` | stays: the engine never writes these on its own | - |
|
|
18
|
+
| one file per piece in `plugins/` next to index.html (`export default mesh`, a Pass, a post effect such as `grain()`, a module; never a bare function; a Material goes on its mesh in `picture/`) | plugs each at `engine.start()` by what it exports, through the same calls as above (`scene.add`, `engine.post.add`, `engine.use`); order by file name or a `plugins.json` beside them; anything else is a `[plugin-shape]` error naming the file, what it found and the fix (a factory: `export default makeIt({ ... })`; a module with no `type`: add one) | switch one off: `plugins.json` `"off": ["20-bloom"]` or `engine.plugins.off('20-bloom')` |
|
|
19
|
+
| a static mesh you want `engine.pick` to hit | - | `engine.rays.addStatic(obj)` (a BVH only pays off for things that do not move) |
|
|
20
|
+
|
|
21
|
+
`describe().slots` is the one table of what is plugged in where: each row is `{ slot, plugged, file, on, affects }`, for the plugins folder,
|
|
22
|
+
`scene.add` roots (with the file:line that added them), `engine.post.add` effects, modules and plain lights. Without the vite preset, hand the folder over
|
|
23
|
+
yourself: `engine.plugins.add(import.meta.glob('./plugins/*.js', { eager: true }))` before `engine.start()`.
|
|
24
|
+
|
|
25
|
+
## What the engine changes in three.js (Global changes)
|
|
26
|
+
Everything else in three is untouched. Every change below is listed in `describe().threePatches` (`{ id, what, scope, on, offable, lost }`);
|
|
27
|
+
an offable one is undone page-wide with `threePatches.off(id)` (`import { threePatches } from 'threedog'`), call it before creating the objects
|
|
28
|
+
that should not see it. It is page-wide: every engine on the page loses the change, and `engine.dispose()` does not undo it (disposing one engine never touches a change another engine or library relies on). A wrapper another library put on `Object3D.prototype.add` stays when `scene-add-hook` is turned off. `lost` says what stops working; a change that cannot be undone says why and `off` throws.
|
|
29
|
+
|
|
30
|
+
| id | Change | Effect on your code | Off |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| `shadow-accessors` | `Mesh.prototype.customDepthMaterial / customDistanceMaterial` become accessors | Unassigned, they return a shadow material only for a mesh whose material carries a vertex-moving engine patch (wind), so its shadow sways too; otherwise `undefined` as in three. An assignment always wins | yes |
|
|
33
|
+
| `node-setup-position` | `NodeMaterial.prototype.setupPosition` wrapped | WebGPU only: runs the engine's vertex-moving patches (wind) first; other node materials unchanged | yes |
|
|
34
|
+
| `scene-add-hook` | `Object3D.prototype.add / remove` wrapped (page-wide) | None to the call itself; the engine sees what enters and leaves its scene at any depth (adopting `scene.add`, fog, cascades, cloud shadow, light counts). Another library wrapping the same methods stacks with it | yes (`scene.add` no longer adopted) |
|
|
35
|
+
| `mesh-material-accessor` | `material` on each object entering the engine's scene: an own get / set on that object (a class accessor, e.g. troika text, still runs) | In devtools `mesh.material` shows as an accessor; `mesh.material = other` works as in three and is seen | yes (new objects) |
|
|
36
|
+
| `material-compile-accessor` | `onBeforeCompile` / `customProgramCacheKey` on each material the engine patches (what applyEffects was asked for, wind, fog) | Your own hook, assigned before or after, runs first, then the engine's | yes (new materials) |
|
|
37
|
+
| `renderer-render` | `engine.renderer.render` (that instance only) wrapped | Counts your full-canvas draws so the engine yields the frame; a scissored / smaller-viewport / `autoClear = false` layer (minimap, HUD) does not count | yes |
|
|
38
|
+
| `shader-chunks` | `THREE.ShaderChunk.threedog_*` added (new names, nothing replaced) | None until you `#include` one | no (the engine's patches include them) |
|
|
39
|
+
| `light-idle-shadow` | `shadow.autoUpdate` of your shadow-casting point / spot lights: off while intensity is 0, back on when lit | Only lights whose autoUpdate was on; writing autoUpdate yourself hands the light back; `light.userData.idleShadow = false` opts one out; `describe().render.lights` shows `shadowIdled` | yes |
|
|
40
|
+
| `picture-writers` | Dev server only (absent from bundles and release builds): an own get / set on the picture values of objects in the engine's scene (light intensity / color / position, `scene.fog` and its values, tone and exposure, environment, background, material color / emissive / opacity), and on the `r g b` / `x y z` of those colors and positions | Every read and write goes through unchanged; in devtools these show as accessors. A write records who made it for `describe('picture').writers` and `engine.explain({ picture })` | yes: `threePatches.off('picture-writers')`, accessors stay and only pass values through |
|
|
41
|
+
| `post-shadow-hold` | `render` of the first pass of the WebGL post chain wrapped (it may be your own Pass) | None to what the pass draws; shadow maps redraw once a frame | yes |
|
|
42
|
+
| `post-background-tone` | `onBeforeRender` of three's own background mesh, while the engine draws straight to the canvas | A texture background is tone-mapped as it is through the post chain; your own `renderer.render` keeps three's rule | yes |
|
|
43
|
+
| `node-twin-dress` | `renderer.library.fromMaterial` of a WebGPURenderer wrapped | WebGPU only: the node twin of a classic material gets its patches | no (patched materials would lose their picture on WebGPU) |
|
|
44
|
+
| `node-builder-hook` | `renderer.debug.onNodeBuilderCreated` of a WebGPURenderer wrapped | WebGPU only: your own hook still runs; a later write of yours replaces the engine's | yes |
|
|
45
|
+
| `device-lost-hook` | `renderer.onDeviceLost` of a WebGPURenderer wrapped | WebGPU only: three's hook still runs; a later write of yours replaces the engine's | yes |
|
|
46
|
+
| `hlod-visible` | `visible` on meshes registered with `engine.hlod.add` (and their `xxx_LOD1` nodes): an own get / set | Reads "your value and not hidden far"; your writes keep your value | per handle: `remove()` |
|
|
2
47
|
|
|
3
|
-
The scene, camera, lights, characters and models in the engine are **plain three.js objects** (three 0.187). For anything the engine does not provide,
|
|
4
|
-
write it the three.js way you already know, as long as you follow the conventions below.
|
|
5
48
|
|
|
6
49
|
## Getting three.js objects from the engine
|
|
7
50
|
|
|
@@ -10,39 +53,44 @@ write it the three.js way you already know, as long as you follow the convention
|
|
|
10
53
|
| THREE itself | `import { THREE } from 'threedog'` or `engine.THREE` (the same copy the engine uses) |
|
|
11
54
|
| Scene / camera / renderer | `engine.scene`, `engine.camera` (PerspectiveCamera), `engine.renderer` (WebGLRenderer) |
|
|
12
55
|
| Player, NPCs | `engine.player.object`, `engine.npcs.get('name').object` (Group); position `.position` (Vector3) |
|
|
13
|
-
| Pickups,
|
|
56
|
+
| Pickups, template instances | `pickups.spawn(...)` returns a handle with `.object` (Mesh); a template instance's model is `engine.world.view(id)` (exists only near) |
|
|
14
57
|
| Level | `engine.level.root`; markers `engine.level.marker('spawn').object / .position` |
|
|
15
|
-
| Sun, ambient light, sky dome, fog | `engine.
|
|
16
|
-
| Water | `engine.water.sea` (Mesh; null when the game sets no water level), `water.material`, `water.bodies.get(body)` |
|
|
17
|
-
| Particles,
|
|
58
|
+
| Sun, ambient light, sky dome, fog | `engine.lights.sun` (DirectionalLight), `engine.lights.hemi` (HemisphereLight), `engine.sky.dome`, `engine.scene.fog` |
|
|
59
|
+
| Water | `engine.water.sea` (Mesh; null when the game sets no water level), `water.material` (get / set), `water.uniforms`, `water.bodies.get(body)` |
|
|
60
|
+
| Particles, weather particles | `.points` and `.material` of the value returned by `particles.define(...)`; `engine.weather.particles[field].material` (the plain material of a weather field) |
|
|
18
61
|
| Rigid bodies | `engine.rigid.addBox(mesh)` returns a handle `{ object, body, remove() }`, or null before Rapier is ready (object is your mesh; `castShadow` / `receiveShadow` keep the values you set, the engine does not change them) |
|
|
19
|
-
| Terrain chunks | `engine.terrain.chunks` (Map;
|
|
62
|
+
| Terrain chunks | `engine.terrain.chunks` (Map of chunk data); a chunk's three.js objects: `engine.terrainDraw.meshes.get(chunk)` (`{ group, mesh }`) |
|
|
20
63
|
| Models, textures, animation | `await engine.assets.model('name or path')` (an Object3D copy), `assets.texture(...)`, `assets.animate(model).mixer` |
|
|
21
|
-
| Vehicles, navigation, character controller | `engine.rigid.
|
|
64
|
+
| Vehicles, navigation, character controller | `engine.rigid.addWheeled(mesh, ...)` returns `{ body, controller }`; `engine.nav.navMesh / query / tileCache / crowd` (they are destroyed and replaced on rebuild; code that caches them compares `engine.nav.version`); `engine.player.mover.controller` (mover: 'rapier') |
|
|
22
65
|
| glTF / compression decoders | `engine.assets.gltf` (GLTFLoader, Meshopt installed), `assets.draco` (DRACOLoader), `assets.ktx2` (KTX2Loader); the last two are created the first time compressed data is met and are null before that |
|
|
23
66
|
| Rays | `engine.raycast(origin, direction)` / `engine.pick(ndcX, ndcY)` return three hits (`object` is the mesh, `face` and `point` unchanged); `{ targets: 'all' }` hits rigid bodies too (the hit carries `entry` and `kind: 'rigid'`); the underlying `engine.rays.ray` (THREE.Raycaster, `firstHitOnly` on) |
|
|
24
|
-
| Ray acceleration (BVH) | three-mesh-bvh:
|
|
67
|
+
| Ray acceleration (BVH) | three-mesh-bvh, without touching three's prototypes: a static mesh the engine registers (from 256 triangles up) gets `mesh.geometry.boundsTree` and its own `mesh.raycast`, so `engine.raycast / pick` are fast and your own `new THREE.Raycaster()` is plain three. Page-wide BVH for your rays: three-mesh-bvh's documented setup (`Mesh.prototype.raycast = acceleratedRaycast`, ...) |
|
|
25
68
|
| Streamed-in objects | `.object` of the handle returned by `engine.stream.add({ position, build })` (the Object3D that build returned; null before it is built) |
|
|
26
|
-
| Post-processing | `engine.
|
|
69
|
+
| Post-processing | `engine.post.add(pass)`, the one way in (a Pass, or an effect `{ name, slot, create: ctx => pass }` plus its twin for the other renderer, recipe 56; slots `scene` / `hdr` / `tone` / `ldr` / `final`; on / off and params with its handle); `engine.post.own()` hands over the whole chain |
|
|
27
70
|
| Where the mouse points | Ground: `screenToGround(engine, input.pointer.ndcX, ndcY)` -> Vector3; objects: `engine.pick(input.pointer.ndcX, ndcY)` (registered static objects; for any object pass `{ targets: [object] }`) |
|
|
28
71
|
|
|
29
72
|
Returned positions are all `THREE.Vector3` (the camera's `forward()/right()` are planar directions `{x, z}`; positions in photo records are saveable `{x, z}`).
|
|
30
73
|
Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x, y, z]` / `{ x, z }` all work, and sizes go in an options object (see
|
|
31
74
|
"Interface conventions" in `CONVENTIONS.md`):
|
|
32
75
|
`collision.addCircle(mesh, { radius: 1 })`, `collision.addBox(mesh.position, { halfWidth: 2, halfDepth: 1 })`, `particles.emit('dust', mesh, { count: 20 })`,
|
|
33
|
-
`triggers.add({ position: mesh })`, `
|
|
76
|
+
`triggers.add({ position: mesh })`, `content.spawn(name, v)`, `npcs.add({ position: v })`, `pickups.spawn(v, { give })`, `interactions.add(v or mesh, ...)`,
|
|
34
77
|
`rigid.impulse(entry, [0, 3, 5])`, `player.placeAt(v)`. Ground sampling `engine.surface(x, z)` also accepts `engine.surface(mesh.position)`.
|
|
35
78
|
|
|
36
79
|
## Engine conventions when using three.js
|
|
37
80
|
|
|
38
|
-
1. **Materials
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
1. **Materials**: `new THREE.MeshStandardMaterial(...)` is the way; afterwards change `.map`, `.transparent` as usual.
|
|
82
|
+
Your own shader code works as in three.js: `ShaderMaterial`, `onBeforeCompile` (also on an engine material: yours runs first, the engine's
|
|
83
|
+
wind / clouds / season patches after it). The engine adds effects only to materials it made; yours opt in with `applyEffects(mat, { wind: 0.03 })`.
|
|
84
|
+
One exception, named: with cascaded shadows on (`engine.shadows.cascades(light)`) every built-in lit material gets the `csm` patch, or it would
|
|
85
|
+
be lit N times; a lit `ShaderMaterial` of yours joins with `engine.shadows.include(mat)` (recipe 45).
|
|
86
|
+
2. **Adding to the scene**: `engine.scene.add(obj)` is all it takes: every root under the scene is registered (`engine.thing(obj)` says what it
|
|
87
|
+
is and what a save keeps). `engine.add(obj, { id })` is only for a stable id, so `thing.set` changes to it are saved. Plain three.js and
|
|
88
|
+
templates (`engine.content.spawn`, content props) are two doors into one scene (`recipes/40-scene.md`). To attach to a character use `player.object.add(hat)`.
|
|
44
89
|
3. **Per-frame logic goes in `engine.onFrame(dt => ...)`** (movement and timing use `engine.onFixed`); it returns a handle, cancel with `h.remove()`.
|
|
45
|
-
|
|
90
|
+
Don't start your own `requestAnimationFrame` loop: the engine owns pausing, fast-forward in tests and ordering. Rendering the canvas
|
|
91
|
+
yourself (own `EffectComposer`) takes the frame over: the engine stops drawing it and its post chain, adaptive resolution and photo mode stop applying. Rendering into your own render target is fine (mirror, minimap, portal, picking): do it in
|
|
92
|
+
`engine.onRender(({ renderer, scene, camera, dt }) => ...)`, which runs after the camera update and batching, just before the frame
|
|
93
|
+
(`{ when: 'after' }` runs right after it). Plain three.js idioms and where each goes: `recipes/54-three-idioms.md`.
|
|
46
94
|
4. **Snap to ground**: get ground height with `engine.surface(x, z)`, or `engine.snapToGround(obj, heightAboveGround)`. Don't raycast the terrain.
|
|
47
95
|
**Rays** always go through `engine.raycast / pick`: level meshes are registered automatically; register your own static objects with
|
|
48
96
|
`engine.rays.addStatic(obj)` or `assets.model(name, { static: true })`.
|
|
@@ -51,10 +99,9 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
|
|
|
51
99
|
and materials (`obj.removeFromParent()` / `scene.remove` leak GPU memory). To take it off only temporarily and `add` it back later use
|
|
52
100
|
`engine.detach(obj)`. A copy from `assets.model()` shares resources with other copies (`remove` skips them); they are freed together by
|
|
53
101
|
`assets.release(name)`.
|
|
54
|
-
6. **
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
7. **Camera**: only change properties of `engine.camera`, never replace it with a new camera (post-processing is bound to this one). When a camera
|
|
102
|
+
6. **The sky lights nothing**: it computes signals and draws the dome, and your `picture/` code writes the lights, the fog and the exposure (recipe 62); weather gives `uWeatherLight` / `uWeatherFog` to multiply in. Every engine-written value: recipe 52
|
|
103
|
+
"Who writes it". Adding your own point lights (street lamps, campfires) is fine.
|
|
104
|
+
7. **Camera**: only change properties of `engine.camera`, never replace the object (post-processing is bound to it; `engine.setCamera('follow')` swaps the camera *module*, not the object). When a camera
|
|
58
105
|
module is installed it places the camera every frame; to control the view yourself take it with `const cam = engine.takeCamera('me')` and `cam.remove()` it
|
|
59
106
|
(`engine.cameraOverride` is read-only: it shows the holder in charge, or `null`).
|
|
60
107
|
8. Collision: the player only respects `engine.collision` (`addCircle / addBox / addObject(mesh)`); a mesh alone does not block anyone.
|
|
@@ -63,24 +110,31 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
|
|
|
63
110
|
`npm run bake` it reads the file.
|
|
64
111
|
Things needed only nearby use `engine.stream.add({ position, build })`; put long loops in `engine.jobs.add(function* () { ...; yield; })` so they
|
|
65
112
|
are spread over frames and the start does not stall.
|
|
113
|
+
Smooth normals on built shapes: a non-indexed geometry (`geometry.toNonIndexed()`, a `mergeGeometries` result where one part has no index) gives
|
|
114
|
+
every triangle its own vertices, so `geometry.computeVertexNormals()` shades each face flat (a low-poly look). Weld first with `mergeVertices` from
|
|
115
|
+
`three/addons/utils/BufferGeometryUtils.js` (per part, so hard edges between parts stay), then compute the normals.
|
|
116
|
+
10. **One copy of the engine and of three per page**: `resolve: { dedupe: ['threedog', 'three'] }` in vite.config.js. A second engine copy
|
|
117
|
+
(a pack that lists threedog under `dependencies` instead of `peerDependencies`, a linked plus an installed copy) breaks shadows of wind and
|
|
118
|
+
cascaded-shadow materials; the engine warns once at load, naming both paths [engine-two-copies].
|
|
66
119
|
|
|
67
120
|
## Example: a spinning windmill (plain three.js + engine conventions)
|
|
68
|
-
This is the plain three.js door. The same windmill as a template with an id, saved and editable without code, is in `recipes/40-scene.md` §1.
|
|
121
|
+
This is the plain three.js door: three's own materials. The same windmill as a template with an id, saved and editable without code, is in `recipes/40-scene.md` §1.
|
|
69
122
|
|
|
70
123
|
```js
|
|
71
|
-
import { THREE
|
|
72
|
-
const mill = new THREE.Group(), wood =
|
|
124
|
+
import { THREE } from 'threedog';
|
|
125
|
+
const mill = new THREE.Group(), wood = new THREE.MeshStandardMaterial({ color: 0x8a6a4a, roughness: 0.9, flatShading: true });
|
|
126
|
+
const cloth = new THREE.MeshStandardMaterial({ color: 0xe8e0d0, roughness: 1 });
|
|
73
127
|
const tower = new THREE.Mesh(new THREE.CylinderGeometry(0.8, 1.2, 6, 6), wood);
|
|
74
128
|
tower.position.y = 3; tower.castShadow = true;
|
|
75
129
|
const blades = new THREE.Group(); blades.position.set(0, 5.5, 1.3);
|
|
76
130
|
for (let i = 0; i < 4; i++) {
|
|
77
|
-
const arm = new THREE.Group(), sail = new THREE.Mesh(new THREE.BoxGeometry(0.5, 4, 0.08),
|
|
131
|
+
const arm = new THREE.Group(), sail = new THREE.Mesh(new THREE.BoxGeometry(0.5, 4, 0.08), cloth);
|
|
78
132
|
sail.position.y = 2; sail.castShadow = true; arm.rotation.z = i * Math.PI / 2; arm.add(sail); blades.add(arm);
|
|
79
133
|
}
|
|
80
134
|
mill.add(tower, blades);
|
|
81
135
|
mill.position.set(20, 0, -10);
|
|
82
136
|
engine.snapToGround(mill); // snap to ground
|
|
83
|
-
engine.add(mill);
|
|
137
|
+
engine.scene.add(mill); // registered like engine.add; engine.add(mill, { id: 'mill' }) also keeps thing.set changes in saves
|
|
84
138
|
engine.collision?.addCircle(mill, { radius: 1.3 }); // block the player (when the collision module is installed)
|
|
85
139
|
engine.onFrame(dt => { blades.rotation.z += dt * 1.5; });
|
|
86
140
|
```
|
package/docs/api/ambience.md
CHANGED
|
@@ -12,4 +12,3 @@ Ambience (ambience() module)
|
|
|
12
12
|
- `ambience.nearWater(radius?: number) → number` — How much of the ground within `radius` meters of the listener is water (0-1), sampled at 6 points: for a water rule's volume. Example: `{ sound: 'river', volume: (e, a) => a.nearWater(20) * 0.12 } // in data: volume: { add: { nearWater: 0.12 } } (12 m)`
|
|
13
13
|
- Properties:
|
|
14
14
|
- `position: THREE.Vector3` Where the sounds are heard from: whoever the player controls (engine.actor), else the camera focus
|
|
15
|
-
- `info: { sound: string; on: boolean; volume: number }[]` What each rule is doing (debug, tests): sound name, whether its condition holds, its current target volume
|