threedog 0.5.0 → 0.8.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 +276 -1
- package/README.md +18 -13
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +116 -61
- package/core/{Baked.js → assets/Baked.js} +16 -25
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- package/core/{assetLoad.js → assets/assetLoad.js} +66 -29
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +23 -12
- package/core/{assetReport.js → assets/assetReport.js} +9 -15
- package/core/{namedModel.js → assets/namedModel.js} +24 -16
- package/core/{Audio.js → audio/Audio.js} +27 -24
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +10 -10
- package/core/{Random.js → base/Random.js} +5 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +154 -139
- package/core/{errorHints.js → base/errorHints.js} +9 -10
- package/core/{errors.js → base/errors.js} +9 -9
- package/core/{events.generated.js → base/events.generated.js} +2 -0
- package/core/{math.js → base/math.js} +22 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +29 -8
- package/core/{Engine.js → engine/Engine.js} +112 -105
- package/core/{Loading.js → engine/Loading.js} +4 -2
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
- package/core/{lifecycle.js → engine/lifecycle.js} +16 -16
- package/core/{loop.js → engine/loop.js} +80 -52
- package/core/{moduleSlots.js → engine/moduleSlots.js} +35 -10
- package/core/{moduleTypes.js → engine/moduleTypes.js} +30 -18
- package/core/{modules.js → engine/modules.js} +20 -17
- package/core/engine/page.js +125 -0
- package/core/{plugins.js → engine/plugins.js} +68 -103
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +35 -35
- package/core/{Input.js → input/Input.js} +41 -27
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/{inputPad.js → input/inputPad.js} +1 -1
- package/core/{inputPointer.js → input/inputPointer.js} +8 -2
- package/core/{inputTouch.js → input/inputTouch.js} +1 -1
- package/core/{Budget.js → inspect/Budget.js} +23 -22
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +60 -31
- package/core/{Describe.js → inspect/Describe.js} +33 -30
- package/core/{Inspect.js → inspect/Inspect.js} +14 -9
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +8 -10
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +29 -16
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +9 -6
- package/core/inspect/UrlState.js +182 -0
- package/core/{catalog.js → inspect/catalog.js} +18 -5
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +8 -8
- package/core/inspect/describeRender.js +148 -0
- package/core/{describeText.js → inspect/describeText.js} +17 -12
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +11 -9
- package/core/inspect/pictureWriters.js +342 -0
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/{Ops.js → ops/Ops.js} +16 -11
- package/core/{control.js → ops/control.js} +13 -12
- package/core/ops/holds.js +139 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
- package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +7 -4
- package/core/{owned.js → ops/owned.js} +37 -37
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -27
- package/core/{stackFrames.js → ops/stackFrames.js} +17 -6
- package/core/{stacks.js → ops/stacks.js} +18 -20
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
- package/core/{Saves.js → saves/Saves.js} +58 -36
- package/core/{saveApply.js → saves/saveApply.js} +13 -9
- package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
- package/core/{saveValues.js → saves/saveValues.js} +20 -3
- package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
- package/core/{session.js → saves/session.js} +31 -17
- package/core/{Rays.js → scene/Rays.js} +27 -24
- package/core/{Views.js → scene/Views.js} +15 -6
- package/core/{adaptive.js → scene/adaptive.js} +15 -8
- package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
- package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
- package/core/{gameLights.js → scene/gameLights.js} +24 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +4 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/{ground.js → scene/ground.js} +9 -9
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/scene/pictureSlots.js +33 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +14 -6
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -20
- package/core/scene/stepPoses.js +55 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
- package/core/{thingOps.js → scene/thingOps.js} +4 -3
- package/core/{things.js → scene/things.js} +19 -6
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +1 -1
- package/core/scene/view.js +44 -0
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +62 -33
- package/core/{batchGroups.js → stream/batchGroups.js} +18 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +41 -1
- package/core/{scatter.js → stream/scatter.js} +2 -2
- package/core/{streamSources.js → stream/streamSources.js} +12 -7
- package/core/{Commits.js → threads/Commits.js} +6 -5
- package/core/{Jobs.js → threads/Jobs.js} +12 -10
- package/core/{Threads.js → threads/Threads.js} +16 -16
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +17 -10
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +18 -17
- package/core/{time.js → time/time.js} +18 -12
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +70 -63
- package/docs/API.md +30 -29
- package/docs/CODEMAP.md +98 -223
- package/docs/COMMANDS.md +80 -69
- package/docs/CONVENTIONS.md +87 -41
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +100 -49
- package/docs/api/assets.md +17 -16
- package/docs/api/audio.md +8 -7
- package/docs/api/budget.md +8 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +29 -29
- package/docs/api/characters.md +26 -19
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +14 -11
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +82 -53
- package/docs/api/events.md +5 -3
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +9 -2
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +4 -1
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +10 -9
- package/docs/api/interactions.md +6 -4
- package/docs/api/inventory.md +10 -11
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -8
- package/docs/api/lightPool.md +2 -7
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/occlusion.md +5 -0
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +8 -5
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +7 -1
- package/docs/api/post.md +24 -5
- package/docs/api/quests.md +3 -3
- package/docs/api/rays.md +5 -7
- package/docs/api/rigid.md +27 -18
- package/docs/api/saves.md +8 -7
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +17 -14
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +17 -12
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +30 -26
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +11 -5
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +11 -6
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +38 -57
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +47 -42
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +72 -66
- package/docs/recipes/06-clock-events.md +30 -21
- package/docs/recipes/07-flow-scenes-pause.md +21 -17
- package/docs/recipes/08-weather-sky.md +117 -75
- package/docs/recipes/09-materials-lights-models.md +171 -0
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +33 -25
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +50 -22
- package/docs/recipes/14-custom-module.md +20 -17
- package/docs/recipes/15-perf.md +52 -29
- package/docs/recipes/16-dev-bridge.md +47 -57
- package/docs/recipes/18-world.md +45 -30
- package/docs/recipes/19-shooting-picking.md +11 -7
- package/docs/recipes/20-content-actions-save.md +36 -37
- package/docs/recipes/21-camera.md +41 -8
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +11 -11
- package/docs/recipes/26-ui-parts.md +56 -22
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +126 -30
- package/docs/recipes/29-grid.md +16 -7
- package/docs/recipes/30-templates.md +62 -21
- package/docs/recipes/31-audio.md +9 -9
- package/docs/recipes/32-action-game.md +32 -9
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +164 -52
- package/docs/recipes/35-picture-from-reference.md +140 -0
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +105 -30
- package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +74 -106
- package/docs/recipes/44-water-weather-hooks.md +196 -0
- package/docs/recipes/45-cascaded-shadows.md +145 -25
- package/docs/recipes/46-blender-art-route.md +21 -25
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +3 -3
- package/docs/recipes/52-around-the-picture.md +137 -0
- package/docs/recipes/53-ground-up-close.md +65 -28
- package/docs/recipes/55-mods-time-wrap.md +25 -17
- package/docs/recipes/56-webgpu-tsl.md +73 -28
- package/docs/recipes/57-control.md +47 -1
- 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 +47 -27
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +276 -0
- package/docs/recipes/63-third-person-start.md +90 -0
- package/docs/recipes/64-particles.md +35 -0
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +9 -7
- 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/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +18 -14
- package/examples/{sheepisland → perf-island}/assets.js +2 -2
- package/examples/{sheepisland → perf-island}/content/templates.js +1 -1
- package/examples/{sheepisland → perf-island}/content/vegetation.js +3 -1
- package/examples/{sheepisland → perf-island}/main.js +22 -16
- package/examples/{sheepisland/style → perf-island}/models.js +13 -24
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/perf-island/picture/index.js +20 -0
- package/examples/perf-island/picture/lights.js +34 -0
- package/examples/perf-island/picture/materials.js +61 -0
- package/examples/perf-island/picture/palette.js +60 -0
- package/examples/perf-island/picture/sky.js +20 -0
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/GAMEMAP.md +91 -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 +10 -4
- package/examples/rc2d/README.md +11 -6
- package/examples/rc2d/main.js +26 -36
- 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/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +15 -10
- 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 +31 -68
- 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 +8 -6
- 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 +6 -4
- 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 +10 -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 +16 -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 +14 -22
- package/index.js +36 -36
- package/llms.txt +19 -21
- package/modules/ambience/Ambience.js +12 -9
- package/modules/calendar/Calendar.js +20 -20
- package/modules/calendar/index.js +14 -13
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +2 -2
- package/modules/camera/FixedCamera.js +14 -15
- package/modules/camera/FollowCamera.js +4 -4
- package/modules/camera/RtsCamera.js +11 -11
- package/modules/camera/common.js +51 -25
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +47 -39
- package/modules/characters/NPC.js +30 -22
- package/modules/characters/assetModel.js +18 -13
- package/modules/characters/astar.js +7 -5
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +172 -193
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +22 -15
- package/modules/characters/movers/manual.js +4 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +32 -18
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +28 -18
- package/modules/characters/npcView.js +6 -5
- package/modules/characters/pathAsync.js +12 -10
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +108 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +19 -5
- package/modules/characters/useModel.js +5 -5
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +30 -22
- package/modules/collision/contract.js +15 -0
- package/modules/content/explain.js +1 -2
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +2 -2
- package/modules/content/index.js +68 -98
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +66 -18
- package/modules/content/packs.js +3 -3
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +35 -0
- package/modules/content/props.js +19 -14
- package/modules/content/rules.js +34 -22
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +24 -22
- package/modules/content/words.js +34 -0
- package/modules/debug/DebugPanel.js +10 -43
- package/modules/flow/contract.js +1 -1
- package/modules/flow/index.js +11 -7
- package/modules/gameplay/Container.js +12 -11
- package/modules/gameplay/Containers.js +14 -5
- package/modules/gameplay/Dialogue.js +13 -11
- package/modules/gameplay/Interactions.js +115 -27
- package/modules/gameplay/Inventory.js +11 -12
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBox.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +4 -5
- package/modules/gameplay/interactionPrompt.js +1 -1
- package/modules/gameplay/interactions.contract.js +1 -1
- package/modules/gameplay/inventoryOps.js +2 -3
- package/modules/gameplay/pickups.js +81 -44
- package/modules/gameplay/questLog.js +2 -2
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +16 -3
- package/modules/grid/index.js +47 -19
- package/modules/grid/preview.js +29 -20
- package/modules/grid/tiles.js +19 -23
- package/modules/hlod/index.js +38 -55
- package/modules/hud/index.js +27 -8
- package/modules/hud/parts.js +13 -11
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +48 -152
- package/modules/level/load.js +79 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +6 -7
- package/modules/lights/index.js +34 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +31 -27
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +14 -0
- package/modules/nav/index.js +11 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +5 -4
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +49 -25
- package/modules/particles/effect.js +27 -10
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +26 -27
- package/modules/rigid/RigidBodies.js +66 -43
- package/modules/rigid/Vehicles.js +2 -3
- package/modules/rigid/ragdoll.js +287 -0
- package/modules/rigid/ragdollBones.js +159 -0
- package/modules/rigid/sync.js +6 -6
- package/modules/settings/Settings.js +114 -45
- package/modules/settings/apply.js +10 -10
- package/modules/settings/sections.js +16 -14
- package/modules/settings/strings.js +1 -1
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +125 -103
- package/modules/sky/clouds.js +22 -23
- package/modules/sky/dome.js +113 -0
- package/modules/sky/domeLayers.js +13 -13
- package/modules/sky/environment.js +47 -171
- package/modules/sky/fog.js +5 -180
- package/modules/sky/frame.js +42 -97
- package/modules/sky/season.js +9 -3
- package/modules/sky/shader.js +49 -44
- package/modules/sky/skyModule.js +25 -35
- package/modules/sky/tint.js +9 -11
- package/modules/swarm/Swarm.js +346 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +97 -62
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +157 -0
- package/modules/terrain/index.js +60 -88
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +4 -3
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +19 -14
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +27 -19
- package/modules/timeline/Tween.js +6 -6
- package/modules/timeline/shots.js +5 -7
- package/modules/triggers/index.js +19 -15
- package/modules/vegetation/Vegetation.js +87 -39
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +196 -0
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +18 -16
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +140 -93
- package/modules/water/surface.js +56 -56
- package/modules/weather/Weather.js +84 -38
- package/modules/weather/particles.js +18 -10
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/weatherDraw.js +145 -0
- package/modules/world/World.js +10 -10
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -12
- package/modules/world/persist.js +73 -25
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +28 -8
- package/modules/world/sim.js +4 -4
- package/modules/world/state.js +12 -5
- package/modules/world/thingSource.js +4 -2
- package/modules/world/views.js +12 -10
- package/package.json +44 -8
- package/presets.js +3 -5
- package/render/PostFX.js +233 -63
- package/render/backend.js +72 -32
- package/render/cascades.js +200 -0
- package/render/cascades.tsl.js +93 -0
- package/render/daylight.js +56 -0
- package/render/detail.js +13 -12
- package/render/effects.js +60 -42
- package/render/fuse.js +3 -3
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +10 -13
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/patchNodes.tsl.js +6 -16
- package/render/fx/postWebGPU.tsl.js +55 -28
- package/render/fx/sky.tsl.js +34 -109
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/water.tsl.js +1 -1
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +14 -0
- package/render/lighting.js +11 -8
- package/render/lightmap.js +142 -0
- package/render/lights.js +26 -204
- package/render/lit.js +24 -0
- package/render/materials.js +47 -162
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/neutral.js +23 -0
- package/render/occlusion.js +200 -0
- package/render/ownFrame.js +5 -5
- package/render/patches.js +46 -41
- package/render/postWebGL.js +19 -9
- package/render/probes.js +182 -128
- package/render/recordSweep.js +117 -0
- package/render/shaderErrors.js +10 -9
- package/render/shadowCache.tsl.js +107 -0
- package/render/shadowTypes.js +9 -0
- package/render/shadows.js +451 -0
- package/render/slots.js +11 -11
- package/render/terms.js +63 -113
- package/render/uniformDecl.js +2 -2
- package/types/core.d.ts +489 -405
- package/types/gameplay.d.ts +225 -114
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +23 -8
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/engine/page.d.ts +24 -0
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +21 -10
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +16 -8
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Layer.d.ts +9 -1
- package/types/generated/modules/grid/index.d.ts +32 -8
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +14 -7
- package/types/generated/modules/sky/Sky.d.ts +101 -23
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +2 -1
- package/types/generated/modules/water/Water.d.ts +51 -3
- package/types/generated/modules/weather/Weather.d.ts +44 -10
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +7 -5
- package/types/generated/render/PostFX.d.ts +69 -20
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +20 -44
- package/types/generated/render/occlusion.d.ts +22 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +11 -11
- package/types/physics.d.ts +104 -73
- package/types/tsl.d.ts +45 -4
- package/types/world.d.ts +372 -86
- package/ui/Focus.js +21 -10
- package/ui/LoadingScreen.js +2 -2
- package/ui/Parts.js +12 -7
- package/ui/UI.js +17 -17
- package/ui/cursor.js +1 -1
- package/ui/defaults.js +3 -2
- package/ui/theme.js +36 -28
- package/ui/touchPart.js +1 -1
- package/core/UrlState.js +0 -110
- package/core/assetEntry.js +0 -106
- package/core/describeRender.js +0 -71
- package/core/holds.js +0 -134
- 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/page.js +0 -79
- package/core/shadowTypes.js +0 -16
- package/core/styleParts.js +0 -114
- package/core/util.js +0 -17
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -228
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/PERF.md +0 -245
- 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/37-terrain-look-hooks.md +0 -119
- package/docs/recipes/38-environment-look-hooks.md +0 -99
- package/docs/recipes/41-thing-registry.md +0 -97
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/44-water-weather-look-hooks.md +0 -144
- package/docs/recipes/47-island-snow-backdrop.md +0 -45
- package/docs/recipes/48-make-material.md +0 -75
- package/docs/recipes/52-look.md +0 -282
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/.threedog/content-index.json +0 -1
- 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/core/page.d.ts +0 -18
- package/types/generated/modules/weather/weatherLook.d.ts +0 -12
- package/types/style.d.ts +0 -671
- /package/core/{Vars.js → base/Vars.js} +0 -0
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsFail.js → ops/opsFail.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{cells.js → stream/cells.js} +0 -0
- /package/core/{streamCells.js → stream/streamCells.js} +0 -0
- /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
- /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
package/docs/api/rays.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
# engine.rays (Rays) — engine.rays is the ray registry (engine.raycast hits whatever is registered here)
|
|
2
2
|
|
|
3
|
-
- `rays.addStatic(obj: THREE.Object3D | THREE.Object3D[], opts?: { occluder?: boolean }) → Handle` — Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }. Only visible objects are hit
|
|
4
|
-
- `rays.forget(obj: THREE.Object3D)` — Unregister every mesh under the object (engine.remove calls this automatically)
|
|
5
|
-
- `rays.addProvider(fn: RayProvider) → Handle` — A module merges its own hits (rigid adds rigid bodies; asked only when targets is 'all'). Returns a handle { remove() }
|
|
6
|
-
- `rays.cast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Cast a ray from origin along dir and return the nearest hit or null (same as engine.raycast).
|
|
7
|
-
- `rays.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Cast from screen coordinates (-1..1) through the camera (same as engine.pick).
|
|
3
|
+
- `rays.addStatic(obj: THREE.Object3D | THREE.Object3D[], opts?: { occluder?: boolean }) → Handle` — Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }. Only visible objects are hit. Something that is merely not drawn is still hit: batched originals, far hlod originals and the full model of a far assets.lod sit on a reserved layer, with their visible true. Unregisters automatically on geometry dispose or engine.remove. Example: `engine.rays.addStatic(house, { occluder: true });`
|
|
4
|
+
- `rays.forget(obj: THREE.Object3D)` — (experimental) Unregister every mesh under the object (engine.remove calls this automatically)
|
|
5
|
+
- `rays.addProvider(fn: RayProvider) → Handle` — (experimental) A module merges its own hits (rigid adds rigid bodies; asked only when targets is 'all'). Returns a handle { remove() }
|
|
8
6
|
- Properties:
|
|
9
|
-
- `statics: Map<THREE.Object3D, { refs: number; occ: number }>` Registered mesh -> { refs: registration count, occ: camera-blocker registration count }
|
|
10
|
-
- `ray: any` The three.js Raycaster (firstHitOnly is on)
|
|
7
|
+
- `statics: Map<THREE.Object3D, { refs: number; occ: number }>` (experimental) Registered mesh -> { refs: registration count, occ: camera-blocker registration count }
|
|
8
|
+
- `ray: any` (experimental) The three.js Raycaster (firstHitOnly is on)
|
|
11
9
|
|
|
12
10
|
## Data structures
|
|
13
11
|
- **RaycastOptions** Parameters of engine.raycast()
|
package/docs/api/rigid.md
CHANGED
|
@@ -4,32 +4,41 @@ Real physics, Rapier (rigid() module, needs collision)
|
|
|
4
4
|
|
|
5
5
|
- Options `RigidOptions`:
|
|
6
6
|
- `gravity?: number` Gravity (m/s², negative points down), default -9.81
|
|
7
|
-
- `terrainRing?: number` How many rings of chunks around the player get terrain colliders, default 1
|
|
7
|
+
- `terrainRing?: number` How many rings of chunks around the player get terrain colliders, default 1. A body outside them freezes until the player comes near (entry.enabled false, describe().rigid.frozen), because it would fall through the ground: raise this for a car or ball that must keep moving far away
|
|
8
8
|
- `buoyancy?: boolean` Whether there is buoyancy, default true
|
|
9
|
-
- `buoyancyForce?: number` Buoyancy strength (1 = just floats), default 1.6
|
|
10
|
-
- `waterDrag?: number` Drag in water, default 2.5
|
|
11
|
-
- `floatLine?: number` Buoyancy "waterline": an object starts floating when its center is this many meters below the water surface, default 0.3
|
|
12
|
-
- `floatDepth?: number` Buoyancy reaches its maximum this many meters further down, default 0.8
|
|
13
|
-
- `treeColliderHeight?: number` Height (meters) of vegetation collision pillars (tree trunks), default 6
|
|
14
|
-
- `treeRadius?: number` Trunks get collision cylinders only in chunks within this many meters of the player or a moving rigid body (the rest are covered by engine.collision for characters), default 16
|
|
15
|
-
- `playerCapsule?: { halfHeight: number; radius: number }` Player capsule size (meters), default computed from engine.movement radius / height
|
|
9
|
+
- `buoyancyForce?: number` (experimental) Buoyancy strength (1 = just floats), default 1.6
|
|
10
|
+
- `waterDrag?: number` (experimental) Drag in water, default 2.5
|
|
11
|
+
- `floatLine?: number` (experimental) Buoyancy "waterline": an object starts floating when its center is this many meters below the water surface, default 0.3
|
|
12
|
+
- `floatDepth?: number` (experimental) Buoyancy reaches its maximum this many meters further down, default 0.8
|
|
13
|
+
- `treeColliderHeight?: number` (experimental) Height (meters) of vegetation collision pillars (tree trunks), default 6
|
|
14
|
+
- `treeRadius?: number` (experimental) Trunks get collision cylinders only in chunks within this many meters of the player or a moving rigid body (the rest are covered by engine.collision for characters), default 16
|
|
15
|
+
- `playerCapsule?: { halfHeight: number; radius: number }` (experimental) Player capsule size (meters), default computed from engine.movement radius / height
|
|
16
16
|
|
|
17
17
|
## Methods and properties
|
|
18
18
|
- `rigid.addBox(mesh: Object3D, opts?: RigidBoxOptions) → RigidEntry | null` — Add a box (crate). Physics is ready after engine.start() (or on engine:ready): called before, it throws in development, a release build warns once and returns null
|
|
19
|
-
- `rigid.addBall(mesh: Object3D, opts?: RigidBallOptions) → RigidEntry | null` — Add a ball
|
|
20
|
-
- `rigid.addHull(mesh: Object3D, opts?: RigidBodyOptions) → RigidEntry | null` — Add a convex hull (irregular objects such as rocks and barrels)
|
|
19
|
+
- `rigid.addBall(mesh: Object3D, opts?: RigidBallOptions) → RigidEntry | null` — (experimental) Add a ball; null only as in addBox: a release build, called before physics is ready
|
|
20
|
+
- `rigid.addHull(mesh: Object3D, opts?: RigidBodyOptions) → RigidEntry | null` — (experimental) Add a convex hull (irregular objects such as rocks and barrels); null only as in addBox: a release build, called before physics is ready
|
|
21
|
+
- `rigid.ragdoll(who: any, opts?: RagdollOptions) → Ragdoll | null` — (experimental) Turn a skinned character limp in one call; rd.remove() returns it to animation. who: a Character, an NPC handle, a character id or a skinned Object3D. Its mover, animator, capsule and camera yield until then; calling again on the same one pushes it again and returns the same ragdoll. Not saved: any load ends it. A skeleton it cannot read throws, naming the missing parts.
|
|
21
22
|
- `rigid.impulse(entry: RigidEntry, impulse: Vec3Like)` — Give it a push: impulse vector impulse (Vector3 / [x, y, z] / { x, y, z }), e.g. impulse(ball, [0, 3, 5])
|
|
22
23
|
- `rigid.setPosition(entry: RigidEntry, position: PositionLike)` — Teleport to position (velocity is zeroed)
|
|
23
|
-
- `rigid.groundReady(position: PositionLike) → boolean` — Is the physics ground under position built (always true without chunked terrain; with mover: 'rapier' and not yet built, 'simple' is used temporarily)
|
|
24
24
|
- `rigid.addWheeled(mesh: Object3D, opts: VehicleOptions) → Vehicle | null` — Turn a model into a wheeled vehicle (Rapier ray-cast vehicle controller: cars, karts, carts); remove it with vehicle.remove() (anyone inside gets out first). Before physics is ready it throws in development (release: warns, null), like addBox. Boats, mounts and mechs are the game's own objects with the same seat interface
|
|
25
25
|
- Properties:
|
|
26
26
|
- `ready: boolean` Is the physics engine ready (downloaded and initialized at start())
|
|
27
27
|
- `bodies: RigidEntry[]` All physics bodies
|
|
28
|
-
- `
|
|
29
|
-
- `
|
|
30
|
-
- `
|
|
31
|
-
- `
|
|
32
|
-
- `
|
|
28
|
+
- `terrainRing: number` (experimental)
|
|
29
|
+
- `buoyancy: boolean` (experimental)
|
|
30
|
+
- `buoyancyForce: number` (experimental)
|
|
31
|
+
- `waterDrag: number` (experimental)
|
|
32
|
+
- `floatLine: number` (experimental)
|
|
33
|
+
- `floatDepth: number` (experimental)
|
|
34
|
+
- `treeColliderHeight: number` (experimental)
|
|
35
|
+
- `treeRadius: number` (experimental)
|
|
36
|
+
- `rapier: any` (experimental) The Rapier library itself: its shape follows the Rapier version
|
|
37
|
+
- `world: any` (experimental) The Rapier world: its shape follows the Rapier version
|
|
38
|
+
- `playerBody: any` (experimental) The player's Rapier kinematic body and capsule collider (follow the player position every step; used for collision when mover: 'rapier'; the capsule is off while driving)
|
|
39
|
+
- `playerCollider: any` (experimental) The capsule collider on playerBody
|
|
40
|
+
- `playerCapsule: { halfHeight: number; radius: number }` (experimental) Player capsule size (meters)
|
|
41
|
+
- `vehicles: Vehicle[]` (experimental) All vehicles
|
|
33
42
|
- `stats: { bodies: number; active: number; colliders: number }` Statistics
|
|
34
43
|
|
|
35
44
|
## Data structures
|
|
@@ -46,8 +55,8 @@ Real physics, Rapier (rigid() module, needs collision)
|
|
|
46
55
|
- `body: any` Rapier rigid body (translation(), mass(), setLinvel()…); newGame / a load rebuild the world, so read entry.body again instead of keeping it
|
|
47
56
|
- `collider: any` Rapier collider
|
|
48
57
|
- `mesh: Object3D` The matching three.js model (position is written by physics every step)
|
|
49
|
-
- `object: Object3D` Same as mesh
|
|
50
|
-
- `enabled: boolean` Whether it is being simulated (
|
|
58
|
+
- `object: Object3D` Same as mesh
|
|
59
|
+
- `enabled: boolean` Whether it is being simulated: false while it is outside the terrain colliders (rigid({ terrainRing })), where it would fall through the ground
|
|
51
60
|
- `volume: number` Volume (cubic meters, used for buoyancy)
|
|
52
61
|
- `damping: number`
|
|
53
62
|
- `angularDamping: number`
|
package/docs/api/saves.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# engine.saves (Saves) — engine.saves handles saving
|
|
2
2
|
|
|
3
|
-
- `saves.register(key: string, provider: SaveProvider)` — Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later parts wait. version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current shape. A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept). A part registered after a save was loaded (a module installed later) is handed its data from that save at once.
|
|
4
|
-
- `saves.
|
|
3
|
+
- `saves.register(key: string, provider: SaveProvider)` — Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later parts wait. version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current shape. A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept). A part registered after a save was loaded (a module installed later) is handed its data from that save at once. atomic: true joins this part to atomic ops: it is copied before an atomic op runs and put back if the op fails (plain data only; afterLoad does not run on rollback). Example: `engine.saves.register('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) }); // later the format gains beds: version 2, and a step that upgrades version-1 data engine.saves.register('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });`
|
|
4
|
+
- `saves.putAttachment(group: string, id: string, blob: Blob | (() => Promise<Blob>), meta?: any) → Promise<void>` — (experimental) Store a binary attachment outside the world save (a photo, a replay). It rides in the queue of save writes, so flush() waits for it, and exportFile() carries it. Pass a function to make the bytes when the write runs: flush() then waits for that too. Without IndexedDB it is not kept. Example: `await engine.saves.putAttachment('replay', 'run-1', blob, { score: 12 });`
|
|
5
|
+
- `saves.removeAttachment(group: string, id: string) → Promise<void>` — (experimental) Delete an attachment; no such id is fine
|
|
6
|
+
- `saves.attachments(group: string) → Promise<{ group: string; id: stri…` — (experimental) The attachments of a group, once storage is ready. Empty without IndexedDB.
|
|
7
|
+
- `saves.storageKey(name: string) → string` — A localStorage key for what belongs to this game but is not a save (settings, a last-used tab): it shares the game's name, so two games on one site stay apart, and stays out of list(). Example: `localStorage.setItem(engine.saves.storageKey('lastTab'), 'map');`
|
|
5
8
|
- `saves.flush() → Promise<void>` — Wait for all queued disk writes to finish (for tests and before the page closes)
|
|
6
9
|
- `saves.collect() → { format, savedAt, versions, parts }` — Collect the data of every part (does not write to the browser): { format, savedAt, versions, parts }. A part whose save() throws is left out and reported (engine.error in dev); save() instead refuses to write such a save.
|
|
7
10
|
- `saves.check(slot?: string) → null | "missing" | "corrupt" | "tooNew" | "migrate"` — Can this slot be loaded? null when it can, else why not (checked without touching the game): 'missing' / 'corrupt' (unreadable) / 'tooNew' (a newer save format or part) / 'migrate' (an upgrade step is missing or throws). Example: `if (engine.saves.check('slot1') === 'tooNew') showUpdateHint();`
|
|
@@ -10,14 +13,13 @@
|
|
|
10
13
|
- `saves.load(slot?: string) → Promise<boolean>` — Load a slot onto the running playthrough (a quick load: what the game added during play stays) and resolve true on success; the 'save:loaded' event fires on success. A missing slot resolves false; a corrupt / too new / unmigratable save resolves false with a toast and changes nothing; a part whose load throws rolls the game back. To continue or retry with nothing of the current playthrough left over, use engine.session.load(slot). Example: `if (!(await engine.saves.load('quick'))) toast(engine, 'No quick save');`
|
|
11
14
|
- `saves.list() → { slot: string; savedAt: number }[]` — All slots, newest first (synchronous, reads the in-memory index)
|
|
12
15
|
- `saves.remove(slot: string) → Promise<void>` — Delete a slot. Returns a Promise (disk write done); awaiting is optional
|
|
13
|
-
- `saves.export(slot?: string) → string` — Export as a piece of text (can be copied as a backup; synchronous, without binary attachments)
|
|
16
|
+
- `saves.export(slot?: string) → string` — (experimental) Export as a piece of text (can be copied as a backup; synchronous, without binary attachments)
|
|
14
17
|
- `saves.import(text: string, slot?: string) → Promise<boolean>` — Import text from export() into a slot (default 'imported'); checked like importFile and written before it resolves. Resolves true once stored (save:imported fires), false when the text is not a save or the write failed. It does not load the slot.
|
|
15
|
-
- `saves.exportFile(slot?: string, opts?: { files?: boolean }) → Promise<boolean>` — Download a save file (.json): the save plus every binary attachment (as data: text, so the file is larger; { files: false } exports the save only). Restores everything when browser data is wiped on a phone. Returns Promise<boolean>. Example: `engine.saves.exportFile('slot1');`
|
|
18
|
+
- `saves.exportFile(slot?: string, opts?: { files?: boolean }) → Promise<boolean>` — (experimental) Download a save file (.json): the save plus every binary attachment (as data: text, so the file is larger; { files: false } exports the save only). Restores everything when browser data is wiped on a phone. Returns Promise<boolean>. Example: `engine.saves.exportFile('slot1');`
|
|
16
19
|
- `saves.importFile(file?: Blob, slot?: string) → Promise<string | null>` — Restore from a save file into slot (default 'imported', so a shared file never overwrites 'auto'). file is a File / Blob; omit it to open a file picker. Everything is checked first (file marker and format, the save inside, attachments must be data: URLs: nothing is fetched). Returns the slot name on success, and null if cancelled, the file is invalid or the write failed (a toast was already shown). It restores the slot only and does not load it.
|
|
17
20
|
- `saves.autosave(minutes?: number) → { remove(): void }` — Autosave into 'auto' every `minutes` minutes of play: counted in fixed seconds, so it waits while paused, frozen or in a menu that freezes the game, and it never saves while no playthrough runs (the title screen, during newGame / load / quit) or after a gameplay error. Returns a handle; remove() stops it. Calling it again replaces the previous autosave. Example: `engine.saves.autosave(3); // once at boot: it waits by itself while no playthrough runs`
|
|
18
21
|
- Properties:
|
|
19
|
-
- `
|
|
20
|
-
- `store: { mode, blobs, putBlob, deleteBlob }` Storage layer: saves in the IndexedDB slots store, attachments (by group, e.g. 'photo') in the blobs store; mode 'localStorage' without IndexedDB.
|
|
22
|
+
- `store: { mode, blobs, putBlob, deleteBlob }` (experimental) Storage layer: saves in the IndexedDB slots store, attachments (by group, e.g. 'photo') in the blobs store; mode 'localStorage' without IndexedDB.
|
|
21
23
|
- `ready: boolean` Has the save index been read into memory? (start() waits for it; game code rarely needs to care)
|
|
22
24
|
- `whenReady: Promise<void>` Resolves once the save index is in memory; await it only to list / load before start()
|
|
23
25
|
- `versions: Record<string, number>` The save versions this build reads, per part: { world: 1, clock: 1, ... }. A save whose part is newer is refused; an older one is migrated.
|
|
@@ -31,4 +33,3 @@
|
|
|
31
33
|
- `checkNewGame?: (data: any) => void` Dev only: called once start() finished with this part's data in the new-game state, to warn about what should not be there yet (world: records placed by code)
|
|
32
34
|
- `version?: number` This part's format version, default 1: raise it by 1 when what save() returns changes shape. A save with a newer version is refused
|
|
33
35
|
- `migrate?: Record<number, (data: any, save: { parts: Record<string, an…` Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }. The second argument is the whole save as read ({ parts, versions }, read only), for a step that depends on another part
|
|
34
|
-
- `movedFrom?: Record<string, (data: any) => any>` This part's data used to be saved under another part's name: { oldPart: data => newData } (newData in this version's shape). An old save without this part but with oldPart loads it here; oldPart is then dropped unless a registered part still owns that name
|
package/docs/api/settings.md
CHANGED
|
@@ -6,25 +6,26 @@ Settings menu (settings() module)
|
|
|
6
6
|
- `action?: string` Action that opens the menu, default the basic 'cancel' (Esc / pad B on an empty UI focus stack); another name is declared and the game binds it
|
|
7
7
|
- `storageKey?: string` Browser storage key
|
|
8
8
|
- `presets?: Record<string, QualityPreset>` Override the graphics presets: { low: {...}, medium: {...}, high: {...} }
|
|
9
|
-
- `sections?: boolean | string[]` Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY / camera.fov). Example: `settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })`
|
|
9
|
+
- `sections?: boolean | (string | { id: 'graphics'; omit: string[] })[]` Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY / camera.fov). Example: `settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })`
|
|
10
10
|
- `freezeWorld?: boolean` Pause gameplay while the menu is open (with flow installed it switches to flow's 'paused' and returns to the previous state on close; without flow it uses engine.freeze); the picture keeps running, default false
|
|
11
11
|
|
|
12
12
|
## Methods and properties
|
|
13
13
|
- `settings.get(key: string) → any` — Read a setting, e.g. get('vol.music')
|
|
14
14
|
- `settings.set(key: string, value: any, opts?: { save?: boolean })` — Change a setting (takes effect immediately + saved)
|
|
15
|
-
- `settings.preset(name: 'low' | 'medium' | 'high' | (string & {}))` — Graphics preset: 'low' / 'medium' / 'high'
|
|
15
|
+
- `settings.preset(name: 'low' | 'medium' | 'high' | (string & {}))` — (experimental) Graphics preset: 'low' / 'medium' / 'high'
|
|
16
16
|
- `settings.define(key: string, def: T, apply?: ((value, e) => void) | { apply?, limits? })` — Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row restricts on the settings layer, like the built-in shadows row: off holds it off (the scene, weather or a cutscene cannot turn it back on), on allows what the scene chose; a number row from 0 to 1 is a factor on a number value. Define it after the effect exists
|
|
17
17
|
- `settings.addSection(id: string, section?: SettingsSection)` — Add a tab of your own, or a built-in / optional one by name: addSection('camera')
|
|
18
|
-
- `settings.
|
|
18
|
+
- `settings.reset(key?: string)` — Put one setting (or all, with no key) back to its default: the engine's start value, or the default the game gave define(). Keys: resetBindings
|
|
19
|
+
- `settings.resetBindings()` — (experimental) Restore all keys to defaults
|
|
19
20
|
- `settings.rebind(action: string, code: string)` — Change the first key of an action to code
|
|
20
|
-
- `settings.actionList() → any[]` — Key list (for the UI)
|
|
21
|
+
- `settings.actionList() → any[]` — (experimental) Key list (for the UI)
|
|
21
22
|
- `settings.save()` — Save to the browser
|
|
22
|
-
- Also: `settings.
|
|
23
|
+
- Also: `settings.open()`, `settings.close()`, `settings.toggle(on?: boolean)`
|
|
23
24
|
- Properties:
|
|
24
|
-
- `values: Record<string, any>` All current setting values
|
|
25
|
+
- `values: Record<string, any>` All current setting values, read only (set() changes one). pixelRatio is the renderer's real ratio
|
|
25
26
|
- `presets: Record<string, QualityPreset>` Graphics presets
|
|
26
|
-
- `sections: Map<string, any>` Tabs
|
|
27
|
-
- `isOpen: boolean` Whether the menu is open
|
|
27
|
+
- `sections: Map<string, any>` (experimental) Tabs
|
|
28
|
+
- `isOpen: boolean` (experimental) Whether the menu is open
|
|
28
29
|
|
|
29
30
|
## Data structures
|
|
30
31
|
- **SettingsSection** One settings tab
|
package/docs/api/sky.md
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
# engine.sky — sky(opts?: SkyOptions)
|
|
2
2
|
|
|
3
|
-
Sky dome
|
|
3
|
+
Sky dome and the sun / daylight / sky-color signals, from the calendar's time; it writes no light or fog (sky() module)
|
|
4
4
|
|
|
5
|
-
- Options `SkyOptions` (also includes the fields of Pick<
|
|
6
|
-
- `fog?: boolean | StyleFog` Whether the sky makes scene.fog: true (default; the sky creates it and writes color and distance every frame) / false (scene.fog = null, never touched). An object is style.sky.fog settings (kind, color, density...) and means true. To keep the fog and write it yourself: engine.look.fog.manual() (or scene.fog = your own THREE.Fog), not an option here. Example: `sky({ fog: false }) // no fog at all`
|
|
5
|
+
- Options `SkyOptions` (also includes the fields of Pick<SkyPictureOptions, 'clouds' | 'backdrop' | 'keyframes' | 'sunSize' | 'sunGlow' | 'sunBrightness' | 'moonColor' | 'moonBrightness' | 'starDensity' | 'dim'>):
|
|
7
6
|
- `time?: string | number` The fixed time of day drawn while no calendar() is installed: 'HH:MM' or 0–1 (0.5 noon), default 0.33 (a sunset arena: sky({ time: '18:30' })). With calendar() the sky draws engine.calendar.timeOfDay and this option throws (start the day with calendar({ time }))
|
|
8
|
-
- `sun?: boolean` Whether the sky drives engine.lights.sun: true (default; color, intensity, direction and shadow box from the keyframes) / false (hidden, never touched: light the world with your own three.js lights). How the game lights its world, so a sky() option, not a style key. Example: `sky({ sun: false, hemisphere: false }) // a dungeon lit by the game's own lights`
|
|
9
|
-
- `hemisphere?: boolean` Same for engine.lights.hemi (ambient): true (default) / false (hidden); to write it yourself: engine.look.lights.manual('hemi')
|
|
10
7
|
|
|
11
8
|
## Methods and properties
|
|
12
|
-
- `sky.
|
|
9
|
+
- `sky.keyframes(rows: any[][])` — The day's colors, live: rows [time, zenith, horizon, sunColor, ambient] sorted from 0 to 1 (the same rows as sky({ keyframes })). Throws, changing nothing, on rows that are not sorted from 0 to 1. Example: `engine.sky.keyframes([[0, 0x101828, 0x202838, 0x8090b0, 0.3], [0.5, 0x4080c0, 0xc0d8e8, 0xffffff, 1.2], [1, 0x101828, 0x202838, 0x8090b0, 0.3]]);`
|
|
10
|
+
- `sky.clouds(spec: string | { glsl?, tsl?, uniforms? } | null)` — Your own cloud function on the dome: glsl defines `vec4 threedogClouds(vec3 dir, float time, vec3 sunDir, float night, vec3 lit, vec3 shade, float cover)`, tsl is its WebGPURenderer form (ctx) => vec4 node; each renderer needs its own form (modules/sky/clouds.js). null gives the built-in kind back. Recompiles the dome once: a scene change, not every frame. Example: `engine.sky.clouds({ glsl: 'vec4 threedogClouds(vec3 d, float t, vec3 s, float night, vec3 lit, vec3 shade, float cover){ return vec4(lit, step(0.5, threedogNoise(d.xz * 4.0)) * cover); }' });`
|
|
11
|
+
- `sky.layer(name: string, spec: string | { glsl?, tsl?, uniforms?, order?, blend? } | null | …)` — Add, change or remove (null) a named dome layer drawn after the clouds and stars: glsl defines `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returning (rgb, amount), tsl is its WebGPURenderer form (modules/sky/domeLayers.js). Recompiles the dome once. Example: `engine.sky.layer('aurora', { glsl: 'vec4 threedogSkyLayer(vec3 d, float t, vec3 s, float n){ return vec4(0.2, 1.0, 0.5, n * smoothstep(0.1, 0.6, d.y) * 0.4); }', blend: 'add' });`
|
|
12
|
+
- `sky.replace(sky: string | import("three").Texture | THREE.Object3D | …)` — Replace or hide the dome: a skybox asset name (equirectangular panorama), a THREE.Texture / CubeTexture, or your own THREE.Object3D sky; null gives the dome back, false draws no sky (the scene shows its base background, the signals keep running). The engine never writes your object: it hides the dome, adds your object to the scene only when it has no parent, puts a plain texture's panorama mapping on a clone, and keeps feeding engine.uniforms (uSunDir, uWind ...). Example: `engine.sky.replace(new SkyMesh());`
|
|
13
|
+
- `sky.environment(options?: { into?, interval? }) → { texture, remove }` — Render the sky into an environment map. Only after this call is anything built: a PMREM target, rebuilt when the sky changed and interval seconds passed (default 1, 4 on a low-tier device). With into, that object's .environment gets the map at each rebuild (a map you wrote there yourself stays); without it nothing is written anywhere and you read handle.texture. handle.remove() takes the map off and frees it. One at a time. Intensity and rotation are three.js: scene.environmentIntensity. Example: `const env = engine.sky.environment({ into: engine.scene });`
|
|
13
14
|
- Properties:
|
|
14
15
|
- `fixedTime: number` The time of day drawn while no calendar is installed (0-1; sky({ time: '17:30' }) or applyState({ time })); with engine.calendar the sky draws the calendar's time and this is unused
|
|
16
|
+
- `seasonTints: import("../../../world").SeasonTints | null` What each calendar season tints the plants and ground, read every frame, or null for no tint: plain data the game's picture/ code writes
|
|
17
|
+
- `dim: { tint: boolean; stars: boolean }` What the sky dims for every game, plain fields read each frame (a fantasy sky can stay bright at night, keep its stars through clouds): tint false keeps a sky.tint color at full strength at any hour, stars false keeps the stars through the weather's cover
|
|
18
|
+
- `top: any` Zenith color over the keyframes, any THREE.Color input (null = the keyframes); read each frame
|
|
19
|
+
- `horizon: any` Horizon color over the keyframes, any THREE.Color input (null = the keyframes); read each frame. The color drawn: engine.uniforms.uSkyHorizon
|
|
20
|
+
- `uniforms: Record<string, { value: any }>` The dome's { value } objects, live on both renderers: the built-in ones (the same objects as engine.uniforms where the names match) and the uniforms given to engine.sky.clouds() and engine.sky.layer(), which join here once the call has run
|
|
15
21
|
- `dome: THREE.Object3D` Dome mesh
|
|
16
|
-
- `sunDir: THREE.Vector3` Sun direction (unit vector toward the sun)
|
|
17
22
|
- `orbit: { tilt: number; sway: number; distance: number }` Sun orbit: tilt = north-south tilt, sway = east-west swing, distance = light distance (meters)
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
-
- `isDay: boolean` Whether the drawn sun is above the horizon (look functions: ({ sky }) => sky.isDay ? ...; gameplay reads engine.calendar.isDay)
|
|
23
|
+
- `sunDir: THREE.Vector3` Sun direction (unit vector toward the sun): the same vector as engine.uniforms.uSunDir. Computed each frame from the time and orbit until a game writes either, then the value is the game's (the sun at a compass direction of your choice); engine.autoView.manual('sunDir', false) gives it back.
|
|
24
|
+
- `backdrop: any` One flat color in place of the dome, a THREE.Color while on, else null (sky({ backdrop }) starts with one). Set any THREE.Color input, null gives the dome back.
|
|
25
|
+
- `drawnTime: any` (experimental) Time of day being drawn, 0-1: engine.calendar.timeOfDay, or fixedTime without a calendar. Read-only: the time itself is the calendar's
|
|
26
|
+
- `sunHeight: number` (experimental) Sun elevation -1 (midnight) ... 0 (horizon) ... 1 (noon) of the drawn sun (the calendar's daylight is the gameplay value)
|
|
27
|
+
- `isDay: boolean` Whether the drawn sun is above the horizon (picture functions: ({ sky }) => sky.isDay ? ...; gameplay reads engine.calendar.isDay)
|
|
24
28
|
- `daylight: number` Daylight of the drawn sun 0-1 (0 at night, 1 at noon)
|
|
25
|
-
- `environment: SkyEnvironmentInfo | null` Environment lighting now: { source, intensity, rotation, interval, builds }, null when off
|
package/docs/api/stream.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# engine.stream (Stream) — engine.stream builds on demand by space: only entries near the focus get built
|
|
2
2
|
|
|
3
3
|
- `stream.add(def: StreamEntryOptions) → StreamHandle` — Register something to stream in (not built at once); an object returned by build with no parent is added to the scene automatically. Example: `engine.stream.add({ position: [40, 0, 12], radius: 6, build: () => makeHouse() });`
|
|
4
|
-
- `stream.setRadius(m: number)` — Set the build radius in meters
|
|
4
|
+
- `stream.setRadius(m: number)` — (experimental) Set the build radius in meters
|
|
5
5
|
- `stream.source(position: any, opts?: StreamSourceOptions) → StreamSource` — (experimental) Add a stream source: the world around position is loaded (terrain chunks, colliders, nearby models, stream entries) until remove() or until. position may be live (an Object3D or Vector3 that moves) or a function. detail 'simple' loads only terrain and hlod proxies (a far view); physics defaults to true for 'full'; pass false for a camera that only needs a picture. radius caps every loader's range (default: each loader's own range). until: a Promise (removed when it settles) or a function checked every frame (removed when it returns true). Example: `const dest = engine.stream.source([800, 0, 300], { radius: 64 }); await dest.whenReady; engine.player.placeAt([800, 0, 300]); dest.remove();`
|
|
6
6
|
- `stream.teleport(position: any, opts?: { radius?, move?, timeout? }) → Promise<void>` — (experimental) Load the destination first, then move: resolves after the player (engine.focus without one) is placed. Until the destination is ready (terrain chunks, collision, nearby models) the player stays where it is. move replaces the default placement (for a vehicle or a custom character). timeout (seconds of frame time, default 60; Infinity waits forever): when the destination is still not ready, the Promise rejects (code stream-timeout, naming the loaders still waiting) and the player is not moved. Example: `await engine.stream.teleport([800, 0, 300]);`
|
|
7
|
-
- `stream.
|
|
7
|
+
- `stream.addReadyCheck(name: string, fn: (source: StreamSource) => boolean) → { remove(): void }` — (experimental) Register a readiness check for loaders: fn(source) returns whether this loader finished what that source asks for. For module authors whose loader reads stream sources; games only read source.ready. Example: `engine.stream.addReadyCheck('props', s => s.detail !== 'full' // props.queued === 0)`
|
|
8
8
|
- `stream.sources(pick?: { detail?, physics? }) → StreamSource[]` — (experimental) Sources with fresh positions, filtered: { detail: 'full' } for models and stream entries, { physics: true } for colliders, no filter for terrain
|
|
9
9
|
- Properties:
|
|
10
|
-
- `radius: number | null` Build radius in meters around each full-detail stream source (a source radius caps it); null = follow the terrain view distance (the fog distance the fog distance without terrain)
|
|
11
10
|
- `cellSize: number` Grid cell edge in meters, shared with hlod, default 64
|
|
12
|
-
- `unloadFactor: number` Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25
|
|
13
|
-
- `player: StreamSource` Built-in source at the
|
|
11
|
+
- `unloadFactor: number` (experimental) Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25
|
|
12
|
+
- `player: StreamSource` Built-in source at the player (engine.focus without one): full detail and physics
|
|
14
13
|
- `camera: StreamSource` Built-in source at the camera focus engine.focus: full detail, no physics
|
|
15
|
-
- `activeRadius: number` The build radius actually in use, in meters
|
|
14
|
+
- `activeRadius: number` (experimental) The build radius actually in use, in meters
|
|
15
|
+
- `radius: number | null` Build radius in meters around each full-detail stream source (a source radius caps it); null = follow the terrain view distance (the uViewDistance signal without terrain). Writing it takes effect like setRadius.
|
|
16
16
|
- `ready: boolean` Everything registered within radius is built (start() waits for it before the loading screen goes away)
|
|
17
17
|
- `stats: { entries: number; built: number; queued: number }` entries is the registered count, built the built count, queued the queued count
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- `position: PositionLike` Position (Vector3 / object / [x, y, z] / { x, z }; only the horizontal coordinates count)
|
|
22
22
|
- `radius?: number` Object size (meters); larger ones are built earlier
|
|
23
23
|
- `build: () => Object3D | Promise<Object3D>` Generate the object (called when entering range, run spread over frames through engine.jobs)
|
|
24
|
-
- `dispose?: (obj: Object3D) => void` Unload (called when leaving range), default engine.remove (
|
|
24
|
+
- `dispose?: (obj: Object3D) => void` Unload (called when leaving range), default engine.remove (frees what nothing else in the scene uses); write your own when the object is reused (e.g. engine.detach)
|
|
25
25
|
- `keep?: boolean` Do not unload even when out of range
|
|
26
26
|
- `priority?: number` Build order: larger first (nearer first within the same priority), default 0
|
|
27
27
|
- **StreamHandle** Handle returned by stream.add(): object is the generated object (null while not generated)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# engine.swarm — swarm()
|
|
2
|
+
|
|
3
|
+
(experimental) Makes a swarm of same-kind gameplay objects (swarm() module): engine.swarm({ name, capacity, geometry, material, fields })
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
|
|
8
|
+
## Data structures
|
|
9
|
+
- **SwarmOptions** Options of engine.swarm(). See recipes/65-swarm.md
|
|
10
|
+
- `name: string` Unique name: shown in describe(), the key in a save
|
|
11
|
+
- `capacity: number` Most objects alive at once; all memory is taken up front
|
|
12
|
+
- `geometry?: import('three').BufferGeometry` Plain three.js geometry, stays the game's to dispose. Leave out with material for a swarm that draws nothing
|
|
13
|
+
- `material?: import('three').Material` Plain three.js material, stays the game's to dispose
|
|
14
|
+
- `fields?: string[]` Number columns beside x, y, z. yaw, pitch, roll (radians, order YXZ) and scale are also drawn by the engine
|
|
15
|
+
- `color?: boolean` Per-object colour: columns r, g, b (linear) and spawn({ color: 0xff8800 })
|
|
16
|
+
- `channel?: string` Time channel of the onStep dt (default 'world')
|
|
17
|
+
- `cell?: number` Grid cell for near, in meters: about the usual query radius (default 2)
|
|
18
|
+
- `save?: boolean` Keep this swarm in saves; otherwise it is empty after a load or new game
|
|
19
|
+
- **Swarm** One swarm: what engine.swarm(options) returns. See the top of modules/swarm/Swarm.js for the handle / row rule
|
|
20
|
+
- `name: string` Name given to engine.swarm
|
|
21
|
+
- `capacity: number` Most objects alive at once
|
|
22
|
+
- `channel: string` Time channel of the onStep dt
|
|
23
|
+
- `saved: boolean` Whether this swarm is kept in saves
|
|
24
|
+
- `dropped: number` Spawns refused because the swarm was full, since it was made
|
|
25
|
+
- `data: SwarmData` The columns: data.x[row], data.y[row], data.z[row] (Float32Array), one Float64Array per field, so a field can hold a handle, and data.id[row], the handle of that row (Float64Array). Rows 0 to count - 1 are live. The same object onStep and near pass as d
|
|
26
|
+
- `mesh: THREE.InstancedMesh | null` The swarm's plain THREE.InstancedMesh (null when made without geometry and material); instance index = row. castShadow, layers and the rest are yours
|
|
27
|
+
- `count: number` Objects alive now
|
|
28
|
+
- `spawn(o?: Record<string, number>) → number` — Add one object. Fields left out start at 0 (scale at 1, colour at white). Returns its handle, or -1 when the swarm is full: the object is not added, dropped goes up, and one [swarm-full] warning is printed. May be called from onStep and near callbacks; an object spawned there first moves in the next step. Example: `const h = bullets.spawn({ x: 0, y: 1, z: 0, vx: 8, life: 2 });`
|
|
29
|
+
- `row(handle: number) → number` — Where a handle's object sits now, or -1 if it is gone. A row is good until the next removal outside a callback: read it, use it, drop it. Example: `const i = enemies.row(target); if (i >= 0) aim(enemies.data.x[i], enemies.data.z[i]);`
|
|
30
|
+
- `free(handle: number) → boolean` — Remove an object by handle: d.id[i] inside a callback. False if it was already gone (safe to call twice; -1 from a full spawn too). A row passed by mistake throws [swarm-handle]. Inside onStep and near the object counts as gone at once (near and row skip it) and rows only move when the walk ends. Example: `enemies.near(x, z, 2, (d, i) => { enemies.free(d.id[i]); });`
|
|
31
|
+
- `onStep(fn: SwarmRowFn) → { remove(): void }` — Set the one function that moves this swarm: fn(d, i, dt) for each live row, every fixed step, dt on the swarm's channel. Return false to remove the object; anything else keeps it. Returns a handle: h.remove() takes it off. Set it once at setup, not every step (a second one while one is set throws [swarm-step]). Example: `bullets.onStep((d, i, dt) => { d.x[i] += d.vx[i] * dt; return (d.life[i] -= dt) > 0; });`
|
|
32
|
+
- `near(x: number, z: number, r: number, cb: (d, i, dist2) => (boolean | void)) → number` — Visit the live objects within r meters of (x, z), height ignored: cb(d, i, dist2) with the row and the squared distance; cb returning false stops early. Returns how many were visited. The grid is built on the first query after things moved, so a swarm nobody queries pays nothing. Order is the same every run. Inside onStep it stays the grid of that step's first query: distances are exact, but a row that crossed a cell line since then can be missed for one step. Example: `const hit = enemies.near(px, pz, 0.5, (d, i) => { enemies.free(d.id[i]); return false; });`
|
|
33
|
+
- `clear()` — Remove every object (their handles die for good). Inside a callback it applies when the walk ends
|
|
34
|
+
- `dispose()` — Remove this swarm: its mesh leaves the scene and its GPU buffers go. Geometry and material stay, they are the game's. The name is free again
|
package/docs/api/terrain.md
CHANGED
|
@@ -2,28 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Procedural terrain, data part (terrain() module: chunks, heights, edits, collision)
|
|
4
4
|
|
|
5
|
-
- Options `TerrainOptions` (also includes the fields of Partial<
|
|
5
|
+
- Options `TerrainOptions` (also includes the fields of Partial<TerrainConfig>):
|
|
6
6
|
- `viewChunks?: number` View distance (in chunks), default 4
|
|
7
7
|
- `density?: number` Vegetation density multiplier, default 1
|
|
8
|
-
- `viewFog?: boolean` true: the
|
|
9
|
-
- `material?: Material | ((engine: Engine) => Material)` Ground material (default
|
|
10
|
-
- `effects?: boolean` With material: false = draw it exactly as given, no cloud shadow / season / detail patch
|
|
8
|
+
- `viewFog?: boolean` true: the signal engine.uniforms.uViewDistance follows the view distance, so a game's fog can read it and fade the far chunk edge out (openWorld() sets true)
|
|
9
|
+
- `material?: Material | ((engine: Engine) => Material)` Ground material (default neutral gray with vertex colors); chunks have position, normal, color and uv = world xz / chunk size. Cloud shadows, season tint and detail are added
|
|
10
|
+
- `effects?: boolean` With material: false = draw it exactly as given, no cloud shadow / season / detail patch
|
|
11
|
+
- `detail?: MaterialDetail | null` Detail layer over the ground: a noise, a texture asset name or your own glsl; defaults scale 0.25, strength 0.35, top-down world projection, multiply. Change it with engine.terrain.recolor({ detail })
|
|
12
|
+
- `variation?: TerrainVariation` Ground color noise, baked into the chunks
|
|
11
13
|
|
|
12
14
|
## Methods and properties
|
|
13
|
-
- `terrain.
|
|
14
|
-
- `terrain.
|
|
15
|
-
- `terrain.
|
|
15
|
+
- `terrain.recolor(o?: TerrainRecolor)` — Change at run time what terrain({...}) baked in. colors, biomeColors, steep, variation, shading, normals rebuild every chunk (edits stay); detail only patches the engine's material. Throws under a draw part that replaced 'terrain-draw'. Example: `engine.terrain.recolor({ colors: { grass: 0x6a8a3a }, biomeColors: { meadow: ['grass'] } });`
|
|
16
|
+
- `terrain.setViewChunks(n: number)` — (experimental) Change the view distance (in chunks); camera far plane and, with viewFog, uViewDistance adjust too
|
|
17
|
+
- `terrain.setDensity(d: number)` — (experimental) Change the vegetation density: plants are placed again on the loaded chunks; the ground and its collision stay
|
|
18
|
+
- `terrain.view(hooks: { add?, change?, remove?, show? }) → { remove(): void }` — Draw these chunks: the hooks a draw part that replaces 'terrain-draw' uses. add(c): generated (c.data holds pos / nor / col / uv / tex arrays, c.cx / c.cz the chunk); change(c): an edit rewrote c.data (the vertex count can differ on the rim of a shape with diagonal 'adaptive'); remove(c): released; show(c, visible): in view or not. Chunks already loaded are added at once. Returns { remove() } (ctx.track it). Example: `ctx.track(engine.terrain.view({ add(c) { draw(c) }, remove(c) { undraw(c) } }))`
|
|
16
19
|
- `terrain.retry() → number` — Send chunks that failed every try (terrain:chunkFailed) again, e.g. after fixing what their rule reads. Returns how many were queued
|
|
17
20
|
- `terrain.rebuild()` — Rebuild all chunks
|
|
18
21
|
- `terrain.edit(position: PositionLike, opts: TerrainEditOptions) → { heights: number; cells: number }` — (experimental) Change the ground: dig, raise, flatten, paint the ground type. Saved gameplay state: call it from an op or a fixed step. engine.surface / slope / groundType, collision, paths and vegetation follow at once; it is saved, and chunks generated later come out edited. Example: `engine.terrain.edit(pos, { radius: 3, lower: 1.5 }); // dig a pit engine.terrain.edit(pos, { shape: 'square', radius: engine.terrain.cellSize / 2, paint: 'tilled' }); // till one cell`
|
|
19
|
-
- `terrain.isReadyAround(position: PositionLike, opts?: { rings?: number }) → boolean` — Whether the chunks within rings rings (default 1) around position are all loaded
|
|
20
22
|
- Properties:
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
+
- `generator: TerrainGen` Pure-computation terrain (height, landform), what createTerrain() returns
|
|
24
|
+
- `material: Material | null` The plain three.js material every chunk draws with (null under a draw part that replaced 'terrain-draw'). The neutral one takes direct writes; setting one swaps it on every loaded chunk and draws it as given. Nothing is regenerated, collision is untouched. Chunks carry position, normal, color and uv (world xz / chunk size). Example: `engine.terrain.material = applyEffects(new THREE.MeshStandardMaterial({ vertexColors: true }), { patches: engine.terrain.patches });`
|
|
25
|
+
- `patches: ShaderPatch[]` The engine's ground patches (world, clouds, season, detail), so a game material keeps them: applyEffects(mat, { patches: engine.terrain.patches })
|
|
26
|
+
- `uniforms: Record<string, { value: any }>` The detail layer's { value } uniforms, written directly and live: uDetailStrength, uDetailScale, uDetailTint... ({} without a detail layer)
|
|
27
|
+
- `chunkSize: number` Chunk edge length (meters), the same value as the chunkSize option and ground.chunkSize
|
|
23
28
|
- `voidY: number` terrain({ shape }) only: below this height the player or a moving rigid body has fallen out of the world (one terrain:void per fall). shape.voidY, else 50 m under the lowest island chunk loaded so far; -Infinity without a shape. Example: `engine.events.on('terrain:void', ({ who }) => { if (who === engine.player) engine.player.placeAt(home); });`
|
|
24
29
|
- `chunks: Map<string, TerrainChunk>` Loaded chunks: 'cx,cz' → chunk
|
|
25
|
-
- `viewChunks: number` View distance (in chunks)
|
|
26
|
-
- `density: number` Vegetation density multiplier
|
|
30
|
+
- `viewChunks: number` (experimental) View distance (in chunks); writing it takes effect like setViewChunks
|
|
31
|
+
- `density: number` Vegetation density multiplier; writing it takes effect like setDensity
|
|
27
32
|
- `applyBudgetMs: number` Time budget (milliseconds) for uploading chunks per frame
|
|
28
33
|
- `stats: { builtThisFrame, applyMs, queued, failed, visible?, loaded?, … }` Statistics (for the debug panel); failed = chunks that failed every try (terrain:chunkFailed)
|
|
29
34
|
- `cellSize: number` Grid spacing (meters) = chunkSize / resolution: edits snap to it, paint colors whole cells of this size
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# engine.terrainDraw — terrainDraw()
|
|
2
|
+
|
|
3
|
+
(experimental) Draws the terrain chunks (terrain()'s drawing module, slot 'terrain-draw'; undefined when a game replaced it)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `terrainDraw.recolor(o?: TerrainRecolor)` — Same as engine.terrain.recolor
|
|
8
|
+
- Properties:
|
|
9
|
+
- `material: Material` The ground material every chunk draws with; setting swaps it on every loaded chunk as given (same as engine.terrain.material). Nothing is regenerated, collision is untouched
|
|
10
|
+
- `patches: ShaderPatch[]` Same as engine.terrain.patches
|
|
11
|
+
- `uniforms: Record<string, { value: any }>` Same as engine.terrain.uniforms
|
|
12
|
+
- `meshes: Map<TerrainChunk, { group: Object3D; mesh: Mesh; colorTex: …` chunk record -> { group, mesh, colorTex, colorMat }
|
package/docs/api/timeline.md
CHANGED
|
@@ -9,8 +9,8 @@ Cutscenes, tweens (timeline() module)
|
|
|
9
9
|
- `timeline.play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions) → Promise<{ skipped: boolean }>` — Play a timeline; resolves with { skipped } when it ends
|
|
10
10
|
- `timeline.skip(run?: any)` — Skip all (or one) playing timelines
|
|
11
11
|
- Properties:
|
|
12
|
-
- `skipAll: boolean` Skip every cutscene immediately (set by scenario param cutscene=skip)
|
|
13
|
-
- `playing: boolean` Whether a cutscene is playing
|
|
12
|
+
- `skipAll: boolean` (experimental) Skip every cutscene immediately (set by scenario param cutscene=skip)
|
|
13
|
+
- `playing: boolean` (experimental) Whether a cutscene is playing
|
|
14
14
|
|
|
15
15
|
## Timeline steps (engine.timeline.play([...]))
|
|
16
16
|
- **TimelineStep** Timeline steps (run in order), which can be any of the following:
|
package/docs/api/tools.md
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
# Utility functions (imported from threedog)
|
|
2
2
|
|
|
3
|
-
- `
|
|
3
|
+
- `PICTURE_SLOTS: Readonly<Record<PictureSlot, { readonly what: str…` — The picture slots: what each one is and which describe('picture').picture.writers names it covers (a name ending in '.' covers everything under it)
|
|
4
|
+
- `weather(opts?: WeatherOptions) → [ModuleDef<Weather>, ModuleDef<im…` — Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its picture (engine.weatherDraw, type 'picture'; sky optional)
|
|
4
5
|
- `presets: { weather, calendar, player, interactions, bindings, camera }` — Opt-in gameplay presets: named option objects a game picks on purpose (the engine never applies one itself). Each only bundles options the game could write; spread and override: weather({ ...presets.weather.temperate, autoPool: ['clear', 'rain'] })
|
|
5
6
|
- `world(opts?: { cellSize?, radius?, farEvery?, farMaxPerTick?, buildPerFrame? }) → import("../../../core").ModuleDef…` — World data module: installed as engine.world. Put things here that must be saved, survive level changes and keep changing while far away; models are only built while nearby
|
|
6
7
|
- `net(opts?: { role, transport, sync?, syncEvery?, keepAlive?, rate?, … }) → import("../../../core").ModuleDef…` — (experimental) Optional co-op multiplayer: one host owns the state, clients mirror it and ask for changes through ops. Installed as engine.net. Host: peers' requests run as `ops.run(name, args, { source: 'net', actor })` only for ops defined with net: 'peer', with the op's args shape checked, the optional owner check, and a per-peer rate limit; the result comes back after the state diff that contains it. State: world records, containers, vars and the other save parts are sent as a snapshot on join and as diffs every syncEvery steps. Client: ops.run of a peer op returns { ok: true, pending: true, seq } (watch state or the net:result event, not the return value); its own avatar moves locally and is sent to the host (clamped to maxSpeed); other avatars glide between updates.
|
|
7
8
|
- `fakeNetwork(opts?: { latency?, jitter?, loss?, seed?, manual? }) → { host, connect, advance, now, loss, latency, … }` — (experimental) An in-process network for tests and offline demos: one host and any number of clients in the same page, with optional latency, jitter and loss. Messages are deep-copied on send (no shared objects, like a real wire). Order per link is kept, as on a WebSocket. manual: true delivers only when you call advance(ms) (deterministic tests); otherwise messages land after real time. connect({ heartbeat }) turns on the ping / pong check for that client (off by default here so loss and jitter replay the same); a client's cut() kills its link silently in both directions, which only the heartbeat notices (then the client gets 'close' and the host 'leave').
|
|
8
9
|
- `webSocket(url: string, { host, key, heartbeat, reconnect }?: { host?, key?, heartbeat?, reconnect? }) → { send, on, close, key, id }` — (experimental) WebSocket transport: talks to the relay in packages/tools/net-relay.mjs (`node packages/tools/net-relay.mjs 8787`). The host joins a room with host: true; clients join the same room. The relay assigns peer ids and remembers each client's key for reconnects. Messages are JSON. For a dedicated server or Colyseus, write another transport with the same send / on / close shape instead. heartbeat (ms, default 2000, 0 = off): ping the relay that often; 3 intervals with nothing received closes the link and emits 'close'. reconnect (clients only, default false): after a close, open again with the same key, waiting 0.5 s, 1 s, 2 s ... up to 15 s between tries; 'open' fires again on success (net() then asks the host for a full snapshot).
|
|
9
|
-
- `grids() → import("../../../core").ModuleDef…` — (experimental) Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers).
|
|
10
|
+
- `grids(opts?: GridsOptions) → import("../../../core").ModuleDef…` — (experimental) Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers). Options: ok, bad, previewOpacity, previewHeight (the preview box), tiles, tileLift (layer tiles). The materials are pv.material and layer.material.
|
|
11
|
+
- `swarm() → import("../../../core").ModuleDef` — (experimental) Module: many same-kind gameplay objects in typed arrays, drawn as one InstancedMesh each. After engine.use(swarm()), engine.swarm(options) makes one and returns a Swarm. Bullets, enemy crowds, pickups, debris. See recipes/65-swarm.md
|
|
10
12
|
- `screenToGround(engine: Engine, ndcX: number, ndcY: number, opts?: { maxDistance?: number }) → Vector3 | null` — Screen coordinates (-1..1) -> point on the ground; null if the ray misses the ground
|
|
11
|
-
- `EASINGS: Record<EaseName, (t: number) => number>` — All easing functions: name -> function
|
|
12
13
|
- `sampleGrid(data: ArrayLike<number>, opts: { width, height, cellSize?, size?, origin?, interp?, … }) → (x: number, z: number) => number` — A grid of numbers (height, moisture, density, walkable...) as a function (x, z) -> value. data[j * width + i] sits at origin + (i, j) * cell. interp 'nearest' = flat steps, 'linear' (default) = bilinear, 'cubic' = smooth (clamp: true avoids overshoot). Outside: edge value, or `outside`.
|
|
13
14
|
- `ease(e: Ease) → (t: number) => number` — Name or function -> easing function
|
|
14
|
-
- `checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean })` — Warn once about unknown keys in extensible data (your item / record definitions where players or mods add their own fields), with a "did you mean" hint. Options bags go through readParams instead (an unknown key throws in dev). loose only warns on near-misses.
|
|
15
|
+
- `checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean })` — (experimental) Warn once about unknown keys in extensible data (your item / record definitions where players or mods add their own fields), with a "did you mean" hint. Options bags go through readParams instead (an unknown key throws in dev). loose only warns on near-misses.
|
|
15
16
|
- `contentParts(modules: Record<string, { default: any } | a…) → any` — One content kind split over several files (content/props/forest.js, town.js…): joined in file-name order (arrays concatenated, objects merged, a key in two files an error), the same order content check and write-back use, with each entry's dev source line kept.
|
|
16
17
|
- `readParams(where: string, schema: Record<string, ParamSpec>, opts?: object) → T` — Module options read through a params schema: unknown keys and wrong types throw in dev with the fix, defaults are filled in. Also put params / options on the module definition so engine.catalog(name) shows them (recipes/51-capability-catalog.md).
|
|
17
18
|
- `threePatches: { list, off }` — Every change the engine makes to three.js classes, the game's three.js objects or its renderer (also in describe().threePatches). scope: what it reaches; lost: what stops when it is off (or why it cannot be). off(id) undoes an offable one for the whole page; others throw.
|
|
18
|
-
- `defineLookPart(engine: any, spec: { id, group?, module?, object?, params?, style?, … }) → import('./types/core').LookPart` — Register a module's own look part: engine.look.<id> with set / patch / add / replace / manual / value (module code: part.author), engine.catalog('look.<id>') and describe().look (recipes/52-look.md). Every param needs a default; a default that changes the picture also needs why and off (or neutral: true).
|
|
19
19
|
- `createTerrain(cfg?: Partial<TerrainConfig>) → TerrainGen` — Pure terrain computation (no engine needed), for previewing heights before start: createTerrain({ seed, ...terrainPreset() }).surface(x, z)
|
|
20
|
-
- `terrainMaterial(base?: THREE.Material | null, engine?: {
|
|
20
|
+
- `terrainMaterial(base?: THREE.Material | null, engine?: { assets: any }, { effects, detail }?: { effects?, detail? }) → THREE.Material` — (experimental) Terrain material: base (default neutral with vertex colors) + cloud shadows + season tint + optional detail layer (detail: see DetailOptions; defaults scale 0.25, strength 0.35, top-down world projection, multiply). Pass the engine so its assets load a detail texture by name. effects: false returns your base as is (no engine patch at all, the vegetation.define({ effects: false }) word).
|
|
21
21
|
- `mergeColored(parts: [THREE.BufferGeometry, ColorLike][], { flat }?: { flat?: boolean }) → THREE.BufferGeometry` — Merge several geometries into one vertex-colored geometry (a tree = trunk + canopy in one draw call): [[geometry, color], ...]. flat (default true): one normal per triangle, the faceted low-poly look; false keeps each part's own (smooth) normals. UVs are kept when every part has them, so the merged model can still take a texture.
|
|
22
|
-
- `applyEffects(material: THREE.Material, { wind, clouds, season, detail, engine, patches }?: { wind?, clouds?, season?, detail?, engine?,
|
|
23
|
-
- `
|
|
24
|
-
- `makeMaterial(purpose?: string, params?: import("../../style").MaterialSpec, engine?: { style: any }) → THREE.Material` — Create a material by role: makeMaterial('furniture', { color: 0x8a5a36 }); the look comes from look.materials for that role, whose style layer is the style's materials table and whose game layer is look.materials.set / replace (unlisted roles use the 'default' role). Roles the engine uses: default terrain vegetation character water pickup prop (MATERIAL_PURPOSES); a game may pick new names (e.g. 'building'), and a name close to an existing role ('props', 'charcter') warns in dev. A style entry has one of three forms; params are then applied to the result (keys the material lacks are skipped):
|
|
22
|
+
- `applyEffects(material: THREE.Material, { wind, clouds, season, detail, lighting, engine, patches }?: { wind?, clouds?, season?, detail?, lighting?, engine?, … }) → THREE.Material` — Add effects to any material (the engine's or your own); returns the same material. The one entry for shader effects: wind (sway amplitude; the shadow sways too, nothing else to set up), clouds (drifting cloud shadows, default on; how dark is engine.uniforms.uCloudShadow), season ('foliage' / 'ground' seasonal tint), and patches: your own named patches (see ShaderPatch in render/patches.js), detail (grain / paper / strokes / a texture over the surface, see DetailOptions in render/detail.js; a texture given by asset name loads from `engine`, default the first live engine), lighting (light shaping: { wrap, shadowTint, rim }, or your own { glsl, uniforms }; see LightingOptions in render/lighting.js; materials with the same options share one program).
|
|
23
|
+
- `rampTexture(ramp: (number | import("../../common").…)[], soften?: number) → THREE.DataTexture` — The gradientMap of a toon material from `ramp` (grays or colors, dark to light) and `soften` (0 = hard bands, 1 = bands melt into each other). A gray number n is the light's strength in that band. three's toon reads only the red channel of this texture on both renderers; color entries tint the band under `celLighting` of threedog/tsl (WebGPU route).
|
|
25
24
|
- `bakeVertexAO(geometry: THREE.BufferGeometry, { samples, radius, strength, bias, occluders, seed }?: { samples?, radius?, strength?, bias?, occluders?, seed? }) → THREE.BufferGeometry` — Bake ambient occlusion into a geometry's vertex colors: each vertex casts `samples` rays over the hemisphere around its normal, and the share that hits the geometry (or an occluder) within `radius` darkens it. Creases, insides and parts tucked under other parts go dark; open sides stay as they were. The result multiplies the existing `color` attribute (white is added when there is none), so it works on `mergeColored` output and on any geometry drawn with `vertexColors: true`. Deterministic for a seed, so cached and baked models stay identical. Cost is vertices x samples ray casts (a 5k-vertex model at 32 samples is ~160k casts); run it inside a model generator, where it is cached. Resolution is per vertex: a large flat face with four corners gets no contact shadow in its middle (subdivide it, or bake a texture in Blender).
|
|
26
|
-
- `materialPatches(material: THREE.Material) → string[]` — Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
|
|
25
|
+
- `materialPatches(material: THREE.Material) → string[]` — (experimental) Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
|
|
27
26
|
- `toast(engine: Engine, text: string, { kind, ms }?: { kind?: string; ms?: number })` — Show a short message through the 'toast' UI part (default: top of the screen, gone after ms). A game restyles it, filters it by kind or turns it off with createEngine({ ui: { toast: false } }). kind says where it came from: 'info' (default), 'quest', 'item', 'save', 'error'.
|
|
28
27
|
- `makeWindow(engine: Engine, opts: WindowOptions) → UIWindow` — A toggleable window
|
|
29
28
|
- `worldToScreen(engine: Engine, pos: PositionLike) → ScreenPoint` — World coordinates (position or object) -> pixels from the canvas's top-left corner { x, y, onScreen, behind } (the UI root covers the canvas, so these place UI elements directly)
|
|
30
29
|
- `fadeScreen(engine: Engine, to: number, opts?: { seconds?: number }) → Promise<void>` — Fade the whole screen to `to` (0 clear ... 1 fully covered) over `seconds` (default 0.5); the Promise resolves when the fade ends. fadeScreen(engine, 1, 0.5) throws in dev: fadeScreen(engine, 1, { seconds: 0.5 })
|
|
31
|
-
- `uiFocus(engine: Engine) → UIFocus` — UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
|
|
32
|
-
- `toggleOnKey(engine: Engine, win: { open, toggle }, action: string)` — Window toggle key: call once per frame in a frame hook; opens on the action when closed, closes on another press when open
|
|
30
|
+
- `uiFocus(engine: Engine) → UIFocus` — (experimental) UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
|
|
31
|
+
- `toggleOnKey(engine: Engine, win: { open, toggle }, action: string)` — (experimental) Window toggle key: call once per frame in a frame hook; opens on the action when closed, closes on another press when open
|
|
33
32
|
- `parseClock(clock: string | number, hoursPerDay?: number) → number` — Clock time -> fraction of the day: parseClock('18:30') = 0.77; a number or numeric string ('0.25') is converted as is. hoursPerDay is hours per day, default 24
|
|
34
33
|
- `formatClock(t: number, hoursPerDay?: number) → string` — Fraction of the day -> 'HH:MM': formatClock(0.75) = '18:00'
|
|
35
|
-
- `inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number) → boolean` — Is time t (0-1, e.g. calendar.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by calendar.between and the audio rule condition { time: [from, to] }
|
|
34
|
+
- `inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number) → boolean` — (experimental) Is time t (0-1, e.g. calendar.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by calendar.between and the audio rule condition { time: [from, to] }
|
|
36
35
|
- `pickTarget(from: PositionLike, view: { x: number; z: number } | number, candidates: Iterable<T>, opts?: TargetOptions<T>) → T | null` — Best target in front: lowest "distance + angle off view × angleWeight" inside radius and cone. view is a direction { x, z } (cameraRig.forward()) or a facing angle. Returns the candidate or null
|
|
37
36
|
- `switchTarget(from: PositionLike, view: { x: number; z: number } | number, current: T | null, candidates: Iterable<T>, side: 1 | -1, opts?: Pick<TargetOptions<T>, 'radius' | '…) → T | null` — Next target to the right (side 1) or left (-1) of current as seen along view, wrapping; current missing → the leftmost. Returns a candidate or null
|
|
38
37
|
- `THREE` — three.js itself (any): `import { THREE } from 'threedog'`
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
- `render: (data, tools) => string` Default content: (data, tools) => HTML
|
|
46
45
|
- `data?: () => any` Template data
|
|
47
46
|
- `onCancel?: () => void` What to do on the back key (Esc), default closes the window (an open window is on the UI focus stack, and Esc goes only to the topmost)
|
|
47
|
+
- `closable?: boolean` false: no close button and Esc does nothing, so only the game's own buttons end it (a win or lose window must not drop the player back into the game). Default true
|
|
48
48
|
- **UIWindow** Window returned by makeWindow()
|
|
49
49
|
- `el: HTMLElement`
|
|
50
50
|
- `open: boolean` Whether it is open
|
|
@@ -58,17 +58,21 @@
|
|
|
58
58
|
- `behind: boolean`
|
|
59
59
|
|
|
60
60
|
## Other exported classes and functions
|
|
61
|
-
- `wind(position: Node, origin: Node, amplitude: Node | number) → Node` — GLSL vec3 threedogWind(vec3 position, vec3 origin, float amplitude): object-space sway offset, higher vertices sway more. position: object space before the instance transform (positionGeometry); origin: the object's world origin (objectOrigin()); amplitude: metres per metre of height. Reads uTime, uWind, uWindFreq.
|
|
62
|
-
- `cloudShadow(worldPos: Node) → Node` — GLSL float threedogCloudShadow(vec3 worldPos): light factor 0-1 under the drifting clouds (1 = no shadow). Reads uTime,
|
|
63
|
-
- `season(color: Node, kind: Node | 0 | 1) → Node` — GLSL vec3 threedogSeason(vec3 color, int kind): kind 0 foliage, 1 ground; tints by uFoliageTint / uGroundTint (mix mode when uFoliageMix / uGroundMix > 0). A vec4 color is read as its rgb.
|
|
64
|
-
- `objectOrigin() → Node` — World position of the drawn object's origin (an InstancedMesh: of each instance), vec3. Works for any Mesh / InstancedMesh sharing the material; BatchedMesh throws [tsl-misuse].
|
|
65
|
-
- `
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
68
|
-
- `
|
|
69
|
-
- `
|
|
70
|
-
- `
|
|
71
|
-
- `
|
|
72
|
-
- `
|
|
73
|
-
- `
|
|
61
|
+
- `wind(position: Node, origin: Node, amplitude: Node | number) → Node` — (experimental) GLSL vec3 threedogWind(vec3 position, vec3 origin, float amplitude): object-space sway offset, higher vertices sway more. position: object space before the instance transform (positionGeometry); origin: the object's world origin (objectOrigin()); amplitude: metres per metre of height. Reads uTime, uWind, uWindFreq.
|
|
62
|
+
- `cloudShadow(worldPos: Node) → Node` — (experimental) GLSL float threedogCloudShadow(vec3 worldPos): light factor 0-1 under the drifting clouds (1 = no shadow). Reads uTime, uWeatherCloud, uCloudShadow*, uCloudShadowSpeed.
|
|
63
|
+
- `season(color: Node, kind: Node | 0 | 1) → Node` — (experimental) GLSL vec3 threedogSeason(vec3 color, int kind): kind 0 foliage, 1 ground; tints by uFoliageTint / uGroundTint (mix mode when uFoliageMix / uGroundMix > 0). A vec4 color is read as its rgb.
|
|
64
|
+
- `objectOrigin() → Node` — (experimental) World position of the drawn object's origin (an InstancedMesh: of each instance), vec3. Works for any Mesh / InstancedMesh sharing the material; BatchedMesh throws [tsl-misuse].
|
|
65
|
+
- `instanceOffset(offset: Node) → Node` — (experimental) An object-space offset carried through the drawn instance's rotation and scale (a plain Mesh: the offset as it is). A positionNode runs after the instance transform, so an offset meant for before it, like wind()'s, goes through this. BatchedMesh throws [tsl-misuse].
|
|
66
|
+
- `hash(p: Node) → Node` — (experimental) GLSL float threedogHash(vec2 p): a repeatable random number 0-1 from a 2D position.
|
|
67
|
+
- `noise(p: Node) → Node` — (experimental) GLSL float threedogNoise(vec2 p): smooth value noise 0-1, the one behind the engine's clouds and cloud shadows. No uniforms.
|
|
68
|
+
- `uniforms(engine: { uniforms: object }) → Record<string, Node>` — (experimental) engine.uniforms as TSL uniform nodes (uTime, uWind, uWeatherCloud, uFoliageTint, uSunDir, uDaylight ...), cached per engine. They read the same { value } objects, so engine.uniforms.uWind.value = 2 changes GLSL and TSL materials alike.
|
|
69
|
+
- `detailNoise(p: Node, kind: Node | 0 | 1 | 2 | 3, octaves: Node | number) → Node` — (experimental) GLSL vec4 threedogDetailNoise(vec2 p, int kind, float octaves): kind 0 grain, 1 paper, 2 stroke, 3 dabs; returns (gray rgb, height 0-1). No uniforms: p is any 2D pattern position you choose (world xz times a scale, a uv...). octaves: up to 4 (dabs: 3).
|
|
70
|
+
- `detailBump(surfPos: Node, surfNorm: Node, h: Node, k: Node | number, faceDir: Node | number) → Node` — (experimental) GLSL vec3 threedogDetailBump(vec3 surfPos, vec3 surfNorm, float h, float k, float faceDir): screen-space bump from a height h, strength k. View space; the result is a normal for material.normalNode.
|
|
71
|
+
- `wrapDiffuse(nl: Node, wrap: Node | number, lightColor: Node, shadow: Node | number, albedo: Node) → Node` — (experimental) GLSL vec3 threedogWrapDiffuse(float nl, float wrap, vec3 lightColor, float shadow, vec3 albedo): the half-lambert light beyond plain Lambert, to add to directDiffuse. nl = dot(normal, sunDir). Call it from your LightingModel's direct() (lightColor there already carries the shadow: pass shadow 1).
|
|
72
|
+
- `shadowTint(ambient: Node, tint: Node, strength: Node | number, soft: Node | number, nl: Node, shadow: Node | number) → Node` — (experimental) GLSL vec3 threedogShadowTint(vec3 ambient, vec3 tint, float strength, float soft, float nl, float shadow): the ambient with the shaded side's hue moved toward tint (brightness kept). shadow: 1 lit / 0 shadowed (the sun's lightNode.shadowNode); soft: terminator width in n.l.
|
|
73
|
+
- `rim(normal: Node, viewDir: Node, color: Node, strength: Node | number, power: Node | number, shadowSide: Node | number, nl: Node) → Node` — (experimental) GLSL vec3 threedogRim(vec3 normal, vec3 viewDir, vec3 color, float strength, float power, float shadowSide, float nl): edge light to add (viewDir from the surface to the eye, e.g. normalView and positionViewDirection); shadowSide 1 = only on the side facing away from the sun.
|
|
74
|
+
- `celLighting() → import('three/webgpu').LightingMo…` — (experimental) The lighting model for cel bands with colored ramps: assign it to a MeshToonNodeMaterial, whose gradientMap holds the ramp (rampTexture). A shadowed pixel reads the dark end of the ramp, so a cast shadow takes the same flat band and color as the side turned away. Without a gradientMap: two levels, as three's toon.
|
|
75
|
+
- `waterWave(p: Node, t: Node | number) → Node` — (experimental) GLSL float threedogWaterWave(vec3 p, float t): the built-in wave sum (height before waveHeight). p = world position * waveScale, t = time * waveSpeed.
|
|
76
|
+
- `waterSurface(spec?: { depth?, foam?, waveMax? }) → (base, wave, facing, worldPos, time) => Node` — (experimental) The built-in water surface as TSL: returns a function with the GLSL signature threedogWaterSurface(base, wave, facing, worldPos, time) -> vec4 (rgb, opacity). Only the parts given exist (depth: shallow / deep by viewing angle or wave height; foam on crests); values are numbers / colors or nodes. wave is waterWave's height, facing = 1 looking straight down.
|
|
77
|
+
- `waterFresnel(color: Node, normal: Node, viewDir: Node, strength: Node | number, towards: Node) → Node` — (experimental) The water's fresnel blend: color mixed toward `towards` (the engine uses the fog color) by pow(1 - /viewDir . normal/, 3) * strength, view space
|
|
74
78
|
- `serve(handler: (msg: any) => any)` — Start answering lane messages in a worker. handler is the same function the lane's local() returns on the main thread.
|
package/docs/api/triggers.md
CHANGED
|
@@ -4,6 +4,8 @@ Trigger zones (triggers() module)
|
|
|
4
4
|
|
|
5
5
|
- Options `TriggersOptions`:
|
|
6
6
|
- `action?: string` Action name that toggles the debug view 'triggers' (engine.debug.view), default 'triggersDebug'
|
|
7
|
+
- `debugColor?: ColorLike` Line color of the debug view 'triggers', default neutral gray
|
|
8
|
+
- `debugOpacity?: number` Line opacity of the debug view 'triggers', default 0.8
|
|
7
9
|
|
|
8
10
|
## Methods and properties
|
|
9
11
|
- `triggers.list() → Trigger[]` — All trigger zones (a new array)
|