threedog 0.2.1 → 0.5.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 +290 -0
- package/README.md +9 -8
- package/core/Animator.js +15 -12
- package/core/Assets.js +71 -16
- package/core/Audio.js +45 -38
- package/core/Baked.js +32 -8
- package/core/Batching.js +102 -15
- package/core/Budget.js +39 -18
- package/core/Clock.js +40 -80
- package/core/DebugOverrides.js +45 -10
- package/core/Describe.js +104 -43
- package/core/Engine.js +183 -59
- package/core/Events.js +4 -1
- package/core/I18n.js +25 -13
- package/core/Input.js +168 -79
- package/core/Inspect.js +2 -2
- package/core/InspectMaterials.js +85 -0
- package/core/InspectPerf.js +61 -0
- package/core/InspectScene.js +13 -2
- package/core/Loading.js +2 -1
- package/core/Ops.js +50 -9
- package/core/Random.js +9 -2
- package/core/Rays.js +5 -5
- package/core/SaveStore.js +41 -9
- package/core/Saves.js +71 -15
- package/core/Stream.js +14 -10
- package/core/Threads.js +26 -7
- package/core/UrlState.js +25 -9
- package/core/Views.js +9 -6
- package/core/actor.js +1 -1
- package/core/adaptive.js +93 -0
- package/core/assetEntry.js +22 -5
- package/core/assetHot.js +176 -0
- package/core/assetLoad.js +38 -11
- package/core/assetManifest.js +48 -9
- package/core/assetReport.js +1 -1
- package/core/audioRules.js +13 -11
- package/core/audioVoice.js +69 -42
- package/core/canvasBox.js +1 -2
- package/core/catalog.js +5 -2
- package/core/cells.js +62 -0
- package/core/checks.js +10 -8
- package/core/chunkStream.js +87 -0
- package/core/control.js +149 -0
- package/core/copies.js +32 -0
- package/core/dayTime.js +12 -6
- package/core/debugView.js +82 -15
- package/core/describeRender.js +37 -17
- package/core/describeText.js +41 -21
- package/core/engineCamera.js +32 -0
- package/core/errorCodes.js +438 -19
- package/core/errorHints.js +37 -141
- package/core/errors.js +31 -8
- package/core/events.generated.js +12 -7
- package/core/gameLights.js +62 -0
- package/core/grayMap.js +20 -0
- package/core/grid.js +14 -13
- package/core/gridLoad.js +2 -1
- package/core/ground.js +6 -4
- package/core/headlessLoad.js +55 -0
- package/core/holds.js +78 -50
- package/core/inputContext.js +11 -7
- package/core/inputDefaults.js +24 -21
- package/core/inputPad.js +1 -1
- package/core/inputPointer.js +1 -1
- package/core/inputTouch.js +2 -2
- package/core/lifecycle.js +48 -12
- package/core/lightWatch.js +6 -4
- package/core/look/coreParts.js +137 -30
- package/core/look/part.js +175 -95
- package/core/look/points.js +255 -0
- package/core/look/report.js +34 -17
- package/core/look/shadowPart.js +63 -0
- package/core/look/state.js +45 -0
- package/core/look/write.js +12 -28
- package/core/loop.js +100 -41
- package/core/math.js +11 -3
- package/core/moduleSlots.js +75 -0
- package/core/moduleTypes.js +73 -0
- package/core/modules.js +145 -27
- package/core/movement.js +2 -2
- package/core/namedModel.js +70 -0
- package/core/opsCheck.js +3 -3
- package/core/opsFail.js +15 -6
- package/core/opsGuard.js +4 -4
- package/core/opsRun.js +4 -3
- package/core/owned.js +168 -0
- package/core/page.js +2 -1
- package/core/params.js +30 -8
- package/core/plugins.js +277 -0
- package/core/saveApply.js +99 -17
- package/core/saveFiles.js +8 -6
- package/core/saveValues.js +46 -0
- package/core/saveVersions.js +20 -3
- package/core/scatter.js +48 -19
- package/core/sceneDelta.js +203 -0
- package/core/sceneMethods.js +35 -30
- package/core/screenToGround.js +1 -1
- package/core/services.js +27 -11
- package/core/session.js +28 -25
- package/core/shaderCost.js +78 -0
- package/core/shadowTypes.js +2 -1
- package/core/sharedPoint.js +317 -0
- package/core/skip.js +36 -28
- package/core/stackFrames.js +34 -0
- package/core/stacks.js +166 -0
- package/core/startup.js +153 -11
- package/core/streamSources.js +0 -11
- package/core/styleParts.js +63 -47
- package/core/targeting.js +1 -1
- package/core/textureBytes.js +20 -0
- package/core/thingExplain.js +2 -2
- package/core/thingOps.js +29 -6
- package/core/things.js +21 -11
- package/core/threadPure.js +7 -3
- package/core/threePatches.js +47 -0
- package/core/tier.js +21 -10
- package/core/time.js +236 -0
- package/core/uiClock.js +25 -0
- package/core/util.js +7 -1
- package/core/validate.js +65 -86
- package/core/wrap.js +106 -0
- package/docs/AI.md +87 -100
- package/docs/API.md +32 -28
- package/docs/CODEMAP.md +220 -147
- package/docs/COMMANDS.md +56 -35
- package/docs/CONVENTIONS.md +90 -28
- package/docs/MIGRATING-0.3.md +248 -0
- package/docs/MIGRATING-0.4.md +228 -0
- package/docs/MIGRATING-0.5.md +68 -0
- package/docs/PERF.md +35 -7
- package/docs/THREE.md +79 -27
- package/docs/api/ambience.md +0 -1
- package/docs/api/assets.md +11 -9
- package/docs/api/audio.md +10 -14
- package/docs/api/calendar.md +41 -0
- package/docs/api/cameraRig.md +16 -5
- package/docs/api/characters.md +38 -23
- package/docs/api/clock.md +6 -5
- package/docs/api/collision.md +9 -6
- package/docs/api/content.md +6 -4
- package/docs/api/dialogue.md +9 -9
- package/docs/api/engine.md +63 -60
- package/docs/api/events.md +19 -14
- package/docs/api/grids.md +3 -3
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +11 -6
- package/docs/api/interactions.md +7 -5
- package/docs/api/inventory.md +17 -16
- package/docs/api/level.md +0 -1
- package/docs/api/lightPool.md +3 -1
- package/docs/api/music.md +1 -1
- package/docs/api/nav.md +3 -0
- package/docs/api/openWorld.md +2 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +0 -2
- package/docs/api/pickups.md +15 -0
- package/docs/api/post.md +5 -4
- package/docs/api/quests.md +2 -3
- package/docs/api/rigid.md +16 -14
- package/docs/api/saves.md +6 -4
- package/docs/api/settings.md +2 -3
- package/docs/api/sky.md +11 -44
- package/docs/api/stream.md +1 -1
- package/docs/api/style.md +28 -26
- package/docs/api/terrain.md +9 -6
- package/docs/api/terrainLook.md +10 -0
- package/docs/api/timeline.md +3 -4
- package/docs/api/tools.md +29 -13
- package/docs/api/triggers.md +5 -10
- package/docs/api/vegetation.md +11 -8
- package/docs/api/vegetationLook.md +10 -0
- package/docs/api/water.md +4 -20
- package/docs/api/weather.md +5 -15
- package/docs/api/weatherLook.md +10 -0
- package/docs/api/world.md +2 -1
- package/docs/recipes/01-new-game.md +48 -34
- package/docs/recipes/02-npc.md +24 -7
- package/docs/recipes/03-items-pickups.md +35 -21
- package/docs/recipes/04-quests.md +12 -5
- package/docs/recipes/05-props-bake.md +151 -15
- package/docs/recipes/06-clock-events.md +100 -52
- package/docs/recipes/07-flow-scenes-pause.md +40 -9
- package/docs/recipes/08-weather-sky.md +145 -36
- package/docs/recipes/{09-style-pack.md → 09-style.md} +101 -52
- package/docs/recipes/10-blender-level.md +14 -2
- package/docs/recipes/11-vehicles.md +64 -7
- package/docs/recipes/13-animation.md +14 -6
- package/docs/recipes/14-custom-module.md +61 -29
- package/docs/recipes/15-perf.md +30 -9
- package/docs/recipes/16-dev-bridge.md +61 -37
- package/docs/recipes/18-world.md +16 -6
- package/docs/recipes/19-shooting-picking.md +6 -6
- package/docs/recipes/20-content-actions-save.md +55 -17
- package/docs/recipes/21-camera.md +49 -16
- package/docs/recipes/22-shop-gold.md +3 -3
- package/docs/recipes/23-ops.md +16 -10
- package/docs/recipes/26-ui-parts.md +61 -12
- package/docs/recipes/27-net.md +11 -5
- package/docs/recipes/28-terrain.md +34 -1
- package/docs/recipes/29-grid.md +34 -16
- package/docs/recipes/30-templates.md +64 -12
- package/docs/recipes/31-audio.md +20 -12
- package/docs/recipes/32-action-game.md +35 -2
- package/docs/recipes/34-environment-lighting.md +26 -3
- package/docs/recipes/35-style-from-reference.md +88 -19
- package/docs/recipes/36-sky-ground-plant-looks.md +18 -18
- package/docs/recipes/37-terrain-look-hooks.md +3 -2
- package/docs/recipes/38-environment-look-hooks.md +37 -26
- package/docs/recipes/40-scene.md +16 -13
- package/docs/recipes/41-thing-registry.md +11 -7
- package/docs/recipes/42-terrain-shape.md +2 -2
- package/docs/recipes/43-shader-patches-surface-looks.md +158 -76
- package/docs/recipes/44-water-weather-look-hooks.md +26 -17
- package/docs/recipes/45-cascaded-shadows.md +16 -7
- package/docs/recipes/47-island-snow-backdrop.md +7 -7
- package/docs/recipes/48-make-material.md +11 -6
- package/docs/recipes/49-game-module-contract.md +30 -17
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/51-capability-catalog.md +3 -3
- package/docs/recipes/52-look.md +197 -61
- package/docs/recipes/53-ground-up-close.md +1 -1
- package/docs/recipes/54-three-idioms.md +88 -0
- package/docs/recipes/55-mods-time-wrap.md +112 -0
- package/docs/recipes/56-webgpu-tsl.md +260 -0
- package/docs/recipes/57-control.md +65 -0
- package/docs/recipes/58-input.md +57 -0
- package/docs/recipes/59-depth-post-effects.md +83 -0
- package/docs/recipes/60-judge-the-picture.md +55 -0
- package/examples/action/.threedog/content-index.json +1 -0
- package/examples/action/GAMEMAP.md +17 -13
- package/examples/action/assets.js +8 -0
- package/examples/action/content/actions.js +1 -1
- package/examples/action/content/audio.js +5 -5
- package/examples/action/look.js +1 -1
- package/examples/action/main.js +10 -14
- package/examples/action/models.js +24 -23
- package/examples/pullable.json +111 -0
- package/examples/rc2d/.threedog/content-index.json +1 -0
- package/examples/rc2d/GAMEMAP.md +83 -0
- package/examples/rc2d/README.md +52 -0
- package/examples/rc2d/main.js +63 -0
- package/examples/rc2d/rc2d.js +197 -0
- package/examples/rc2d/shaders.js +144 -0
- package/examples/sheepisland/.threedog/content-index.json +1 -0
- package/examples/sheepisland/GAMEMAP.md +13 -11
- package/examples/sheepisland/assets.js +5 -0
- package/examples/sheepisland/main.js +17 -12
- package/examples/sheepisland/style/index.js +6 -6
- package/examples/styletest/.threedog/content-index.json +1 -0
- package/examples/styletest/GAMEMAP.md +15 -16
- package/examples/styletest/assets.js +6 -0
- package/examples/styletest/content/templates.js +1 -1
- package/examples/styletest/content/vegetation.js +1 -1
- package/examples/styletest/look.js +1 -1
- package/examples/styletest/main.js +17 -16
- package/examples/styletest/models.js +1 -1
- package/examples/styletest/params.js +3 -3
- package/examples/techniques/contact-shadows/README.md +92 -0
- package/examples/techniques/contact-shadows/contactShadows.js +51 -0
- package/examples/techniques/contact-shadows/main.js +53 -0
- package/examples/techniques/day-night-grade/README.md +86 -0
- package/examples/techniques/day-night-grade/dayNightGrade.js +76 -0
- package/examples/techniques/day-night-grade/main.js +51 -0
- package/examples/techniques/interior-light/README.md +103 -0
- package/examples/techniques/interior-light/interiorLight.js +45 -0
- package/examples/techniques/interior-light/main.js +124 -0
- package/examples/techniques/modular-building/README.md +125 -0
- package/examples/techniques/modular-building/kit.js +426 -0
- package/examples/techniques/modular-building/main.js +47 -0
- package/examples/techniques/night-lights/README.md +94 -0
- package/examples/techniques/night-lights/main.js +70 -0
- package/examples/techniques/night-lights/nightLights.js +91 -0
- package/examples/techniques/outlines-and-rim/README.md +59 -0
- package/examples/techniques/outlines-and-rim/main.js +84 -0
- package/examples/techniques/outlines-and-rim/outlines.js +64 -0
- package/examples/techniques/procedural-animation/README.md +77 -0
- package/examples/techniques/procedural-animation/creature.js +44 -0
- package/examples/techniques/procedural-animation/main.js +45 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +118 -0
- package/examples/techniques/procedural-surface/README.md +67 -0
- package/examples/techniques/procedural-surface/main.js +103 -0
- package/examples/techniques/procedural-surface/surface.js +120 -0
- package/examples/techniques/stylized-shading/README.md +75 -0
- package/examples/techniques/stylized-shading/main.js +93 -0
- package/examples/techniques/stylized-shading/shading.js +131 -0
- package/examples/techniques/sun-and-key-light/README.md +135 -0
- package/examples/techniques/sun-and-key-light/keyLight.js +53 -0
- package/examples/techniques/sun-and-key-light/main.js +95 -0
- package/examples/techniques/wet-road/README.md +99 -0
- package/examples/techniques/wet-road/main.js +68 -0
- package/examples/techniques/wet-road/wetRoad.js +209 -0
- package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
- package/examples/webgpu-tsl/GAMEMAP.md +84 -0
- package/examples/webgpu-tsl/README.md +42 -0
- package/examples/webgpu-tsl/main.js +21 -0
- package/examples/webgpu-tsl/tslScene.js +75 -0
- package/examples/world/.threedog/content-index.json +1 -0
- package/examples/world/GAMEMAP.md +22 -15
- package/examples/world/art/humanoid.js +42 -0
- package/examples/world/art/index.js +11 -0
- package/examples/world/art/models.js +58 -0
- package/examples/world/art/shapes.js +9 -0
- package/examples/world/assets.js +6 -0
- package/examples/world/content/audio.js +5 -5
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/rules.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +17 -13
- package/examples/world/style/index.js +61 -0
- package/examples/world/style/plugins/10-bloom.js +5 -0
- package/index.d.ts +44 -45
- package/index.js +26 -22
- package/llms.txt +11 -4
- package/modules/ambience/Ambience.js +34 -23
- package/modules/calendar/Calendar.js +163 -0
- package/modules/calendar/contract.js +21 -0
- package/modules/calendar/index.js +81 -0
- package/modules/{sky → calendar}/schedule.js +17 -16
- package/modules/calendar/seasons.js +55 -0
- package/modules/camera/FirstPersonCamera.js +6 -15
- package/modules/camera/FixedCamera.js +33 -15
- package/modules/camera/FollowCamera.js +90 -16
- package/modules/camera/RtsCamera.js +18 -17
- package/modules/camera/common.js +70 -19
- package/modules/camera/contract.js +17 -0
- package/modules/camera/projection.js +11 -24
- package/modules/characters/Character.js +177 -42
- package/modules/characters/NPC.js +87 -36
- package/modules/characters/assetModel.js +4 -13
- package/modules/characters/behaviors.js +2 -1
- package/modules/characters/contract.js +13 -0
- package/modules/characters/footsteps.js +1 -1
- package/modules/characters/index.js +87 -49
- package/modules/characters/moveHelpers.js +4 -5
- package/modules/characters/movers/common.js +97 -19
- package/modules/characters/movers/manual.js +20 -0
- package/modules/characters/movers/rapier.js +19 -16
- package/modules/characters/movers/simple.js +14 -11
- package/modules/characters/movers/support.js +172 -0
- package/modules/characters/npcAvoid.js +47 -42
- package/modules/characters/npcSim.js +12 -8
- package/modules/characters/npcView.js +44 -16
- package/modules/characters/pathAsync.js +7 -3
- package/modules/characters/playerStrings.js +4 -3
- package/modules/characters/proceduralRig.js +2 -1
- package/modules/characters/useModel.js +1 -1
- package/modules/characters/vehicle.contract.js +21 -0
- package/modules/characters/walkTo.js +21 -7
- package/modules/collision/Collision.js +65 -25
- package/modules/collision/grid.js +8 -6
- package/modules/content/explain.js +2 -2
- package/modules/content/fields.js +102 -0
- package/modules/content/ids.js +8 -6
- package/modules/content/index.js +96 -27
- package/modules/content/loader.js +45 -33
- package/modules/content/models.js +11 -40
- package/modules/content/packs.js +6 -5
- package/modules/content/parts.js +41 -0
- package/modules/content/props.js +16 -9
- package/modules/content/rules.js +58 -0
- package/modules/content/stages.js +80 -0
- package/modules/content/templates.js +121 -30
- package/modules/debug/DebugPanel.js +24 -17
- package/modules/flow/contract.js +16 -0
- package/modules/flow/index.js +21 -15
- package/modules/gameplay/Container.js +41 -32
- package/modules/gameplay/Containers.js +30 -15
- package/modules/gameplay/Dialogue.js +113 -55
- package/modules/gameplay/Interactions.js +193 -67
- package/modules/gameplay/Inventory.js +69 -73
- package/modules/gameplay/Quests.js +75 -39
- package/modules/gameplay/boxOps.js +3 -3
- package/modules/gameplay/dialogue.contract.js +21 -0
- package/modules/gameplay/dialogueBox.js +4 -2
- package/modules/gameplay/dialogueBubbles.js +116 -0
- package/modules/gameplay/interactionPrompt.js +4 -1
- package/modules/gameplay/interactions.contract.js +16 -0
- package/modules/gameplay/inventory.contract.js +23 -0
- package/modules/gameplay/inventoryOps.js +18 -16
- package/modules/gameplay/pickups.js +268 -85
- package/modules/gameplay/questLog.js +4 -4
- package/modules/gameplay/quests.contract.js +17 -0
- package/modules/grid/Grid.js +92 -50
- package/modules/grid/Layer.js +14 -13
- package/modules/grid/index.js +60 -36
- package/modules/grid/ops.js +20 -18
- package/modules/grid/preview.js +15 -16
- package/modules/grid/strings.js +12 -0
- package/modules/grid/tiles.js +6 -5
- package/modules/hlod/index.js +51 -19
- package/modules/hud/index.js +35 -20
- package/modules/hud/parts.js +20 -7
- package/modules/level/heightfield.js +3 -1
- package/modules/level/index.js +45 -20
- package/modules/level/nodes.js +4 -3
- package/modules/lights/index.js +42 -18
- package/modules/music/Music.js +38 -21
- package/modules/music/rules.js +1 -1
- package/modules/nav/index.js +48 -42
- package/modules/net/Client.js +13 -6
- package/modules/net/Host.js +19 -5
- package/modules/net/Net.js +2 -1
- package/modules/net/index.js +13 -8
- package/modules/net/sync.js +9 -8
- package/modules/net/transports.js +77 -27
- package/modules/particles/Particles.js +23 -14
- package/modules/particles/contract.js +17 -0
- package/modules/particles/effect.js +39 -11
- package/modules/photo/Photo.js +53 -36
- package/modules/rigid/RigidBodies.js +194 -32
- package/modules/rigid/Vehicles.js +18 -15
- package/modules/rigid/sync.js +62 -17
- package/modules/settings/Settings.js +57 -52
- package/modules/settings/apply.js +38 -3
- package/modules/settings/sections.js +5 -3
- package/modules/settings/strings.js +3 -2
- package/modules/settings/view.js +5 -3
- package/modules/sky/Sky.js +88 -176
- package/modules/sky/cascades.js +86 -25
- package/modules/sky/cascades.tsl.js +82 -0
- package/modules/sky/clouds.js +34 -19
- package/modules/sky/domeLayers.js +30 -15
- package/modules/sky/environment.js +83 -13
- package/modules/sky/fog.js +140 -95
- package/modules/sky/frame.js +112 -44
- package/modules/sky/look.js +22 -19
- package/modules/sky/lookFog.js +48 -52
- package/modules/sky/lookShadow.js +53 -41
- package/modules/sky/lookSky.js +82 -21
- package/modules/sky/season.js +21 -0
- package/modules/sky/shader.js +41 -19
- package/modules/sky/shadow.js +44 -20
- package/modules/sky/skyModule.js +45 -33
- package/modules/sky/tint.js +61 -0
- package/modules/terrain/ChunkManager.js +175 -108
- package/modules/terrain/chunkJob.js +1 -1
- package/modules/terrain/chunkQueries.js +6 -4
- package/modules/terrain/index.js +105 -50
- package/modules/terrain/look.js +83 -0
- package/modules/terrain/lookGround.js +21 -16
- package/modules/terrain/terrainDefaults.js +1 -1
- package/modules/terrain/terrainEdit.js +18 -20
- package/modules/terrain/terrainGen.js +5 -3
- package/modules/terrain/terrainIsland.js +5 -4
- package/modules/terrain/terrainShape.js +12 -12
- package/modules/terrain/terrainShapeMain.js +8 -7
- package/modules/terrain/terrainTexture.js +21 -19
- package/modules/timeline/Timeline.js +95 -43
- package/modules/timeline/Tween.js +18 -10
- package/modules/timeline/letterbox.js +2 -2
- package/modules/timeline/shots.js +5 -1
- package/modules/triggers/index.js +107 -76
- package/modules/vegetation/Vegetation.js +186 -110
- package/modules/vegetation/densityMap.js +62 -0
- package/modules/vegetation/groundChunks.js +52 -58
- package/modules/vegetation/index.js +32 -11
- package/modules/vegetation/look.js +119 -0
- package/modules/vegetation/lookWind.js +71 -10
- package/modules/vegetation/modelGeometry.js +3 -2
- package/modules/vegetation/nearFade.js +8 -2
- package/modules/water/Water.js +65 -27
- package/modules/water/look.js +29 -18
- package/modules/water/surface.js +64 -25
- package/modules/water/surfaceDefaults.js +3 -0
- package/modules/weather/Weather.js +62 -104
- package/modules/weather/look.js +1 -2
- package/modules/weather/particles.js +24 -9
- package/modules/weather/strings.js +2 -2
- package/modules/weather/weatherLook.js +135 -0
- package/modules/world/World.js +24 -7
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -4
- package/modules/world/persist.js +62 -2
- package/modules/world/pos.js +3 -2
- package/modules/world/records.js +8 -6
- package/modules/world/sim.js +60 -20
- package/modules/world/simFar.js +4 -3
- package/modules/world/state.js +3 -2
- package/modules/world/thingSource.js +1 -1
- package/modules/world/views.js +7 -5
- package/package.json +7 -3
- package/presets.js +41 -27
- package/render/PostFX.js +145 -120
- package/render/backend.js +440 -0
- package/render/detail.js +120 -39
- package/render/effects.js +130 -38
- package/render/engineUniforms.js +10 -1
- package/render/fuse.js +5 -4
- package/render/fx/cloudShadow.tsl.js +16 -0
- package/render/fx/detail.tsl.js +66 -0
- package/render/fx/index.js +26 -0
- package/render/fx/lighting.tsl.js +28 -0
- package/render/fx/nodeErrors.tsl.js +68 -0
- package/render/fx/noise.tsl.js +12 -0
- package/render/fx/objectOrigin.tsl.js +42 -0
- package/render/fx/particles.tsl.js +139 -0
- package/render/fx/patchNodes.tsl.js +403 -0
- package/render/fx/postWebGPU.tsl.js +158 -0
- package/render/fx/season.tsl.js +13 -0
- package/render/fx/sky.tsl.js +260 -0
- package/render/fx/uniforms.tsl.js +67 -0
- package/render/fx/water.tsl.js +53 -0
- package/render/fx/wind.tsl.js +22 -0
- package/render/fxNumbers.js +36 -0
- package/render/hotGlsl.js +24 -0
- package/render/lighting.js +66 -14
- package/render/lights.js +223 -4
- package/render/lookGlow.js +139 -0
- package/render/lookSurface.js +99 -36
- package/render/materials.js +71 -52
- package/render/modeling.js +73 -0
- package/render/ownFrame.js +76 -0
- package/render/patches.js +311 -34
- package/render/postLook.js +124 -46
- package/render/postWebGL.js +197 -0
- package/render/probes.js +231 -0
- package/render/shaderErrors.js +154 -0
- package/render/slots.js +165 -0
- package/render/surface.js +53 -17
- package/render/terms.js +211 -0
- package/render/uniformDecl.js +3 -2
- package/types/common.d.ts +2 -2
- package/types/core.d.ts +614 -240
- package/types/gameplay.d.ts +482 -312
- package/types/generated/core/Audio.d.ts +26 -42
- package/types/generated/core/Batching.d.ts +6 -2
- package/types/generated/core/Budget.d.ts +2 -8
- package/types/generated/core/DebugOverrides.d.ts +44 -3
- package/types/generated/core/I18n.d.ts +2 -2
- package/types/generated/core/Input.d.ts +102 -31
- package/types/generated/core/Ops.d.ts +31 -0
- package/types/generated/core/Random.d.ts +2 -2
- package/types/generated/core/Saves.d.ts +10 -2
- package/types/generated/core/Stream.d.ts +1 -1
- package/types/generated/core/Threads.d.ts +4 -1
- package/types/generated/core/Views.d.ts +0 -1
- package/types/generated/core/audioVoice.d.ts +17 -9
- package/types/generated/core/control.d.ts +55 -0
- package/types/generated/core/session.d.ts +2 -1
- package/types/generated/modules/ambience/Ambience.d.ts +0 -9
- package/types/generated/modules/calendar/Calendar.d.ts +84 -0
- package/types/generated/modules/calendar/index.d.ts +10 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Grid.d.ts +61 -25
- package/types/generated/modules/grid/Layer.d.ts +5 -5
- package/types/generated/modules/grid/index.d.ts +29 -17
- package/types/generated/modules/music/Music.d.ts +5 -3
- package/types/generated/modules/net/index.d.ts +3 -3
- package/types/generated/modules/net/transports.d.ts +12 -3
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/sky/Sky.d.ts +12 -104
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/timeline/Timeline.d.ts +8 -6
- package/types/generated/modules/weather/Weather.d.ts +17 -18
- package/types/generated/modules/weather/weatherLook.d.ts +12 -0
- package/types/generated/modules/world/World.d.ts +18 -3
- package/types/generated/render/PostFX.d.ts +67 -30
- package/types/generated/render/materials.d.ts +26 -20
- package/types/generated/render/modeling.d.ts +30 -0
- package/types/generated/render/patches.d.ts +16 -2
- package/types/generated/ui/UI.d.ts +6 -3
- package/types/nav.d.ts +6 -0
- package/types/physics.d.ts +137 -44
- package/types/style.d.ts +109 -81
- package/types/tsl.d.ts +86 -0
- package/types/world.d.ts +158 -110
- package/ui/Focus.js +25 -14
- package/ui/LoadingScreen.js +1 -1
- package/ui/Parts.js +27 -11
- package/ui/UI.js +20 -10
- package/ui/cursor.js +115 -0
- package/ui/defaults.js +15 -11
- package/ui/theme.js +9 -6
- package/ui/touchPart.js +1 -1
- package/core/claims.js +0 -51
- package/core/look/layers.js +0 -136
- package/core/renamed.js +0 -22
- package/docs/api/entities.md +0 -61
- package/examples/styletest/overrides.js +0 -33
- package/examples/styletest/panel.js +0 -135
- package/modules/entities/Entities.js +0 -243
- package/modules/entities/build.js +0 -25
- package/modules/entities/index.js +0 -4
- package/modules/sky/calendar.js +0 -80
- package/modules/sky/layers.js +0 -69
- package/modules/terrain/chunkLevels.js +0 -40
- package/modules/terrain/mountTerrain.js +0 -32
- package/modules/world/cells.js +0 -42
package/docs/api/style.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Style
|
|
1
|
+
# Style — createEngine({ style }), all the look (any style: a folder with index.js; recipes/09-style.md)
|
|
2
2
|
|
|
3
3
|
- **Style** fields (all optional):
|
|
4
|
-
- `name?: string` Style
|
|
5
|
-
- `exposure?: number | number[][] | ((
|
|
6
|
-
- `toneMapping?: Loose<'aces' | 'agx' | 'neutral' | 'none'>` Tone mapping
|
|
4
|
+
- `name?: string` Style name
|
|
5
|
+
- `exposure?: number | number[][] | ((ctx: LookContext) => number)` Exposure, default 1: a number, or over the day [[time 0-1, exposure], ...] (sorted, wraps across midnight) or ({ time, state, sky }) => number, evaluated by the sky module every frame. engine.look.tone.set changes it at run time. Example: `exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // brighter nights`
|
|
6
|
+
- `toneMapping?: Loose<'aces' | 'agx' | 'neutral' | 'none'>` Tone mapping curve, written once when the engine creates its renderer (default 'agx', the render baseline). Later changes are plain three.js: engine.renderer.toneMapping = THREE.ACESFilmicToneMapping; the engine never writes it again
|
|
7
7
|
- `background?: ColorLike` Background color (when there is no sky module)
|
|
8
|
-
- `
|
|
9
|
-
- `
|
|
8
|
+
- `materials?: Record<string, MaterialSpec | import('three').Material | ((…` Material per role (default, terrain, vegetation, character, water, building, pickup…): a spec, a three.js Material instance (cloned per use), or a function (params, purpose) => Material. This table is the style layer of engine.look.materials (the one entry makeMaterial reads): the game's look.materials.set / replace go on top
|
|
9
|
+
- `plugins?: Record<string, any>` The style's own look plugins: what engine.plugins.add takes (import.meta.glob('./plugins/*.js', { eager: true }) from the style folder, or { name: { default: value } }), each file exporting the same shapes as the game's plugins/ folder. Example: `plugins: import.meta.glob('./plugins/*.js', { eager: true })`
|
|
10
10
|
- `antialias?: boolean` Anti-aliasing: true = MSAA (also inside post-processing), false = off (pixel art, sharp edges). Default: on for desktop, off for low tier; createEngine({ antialias }) wins
|
|
11
11
|
- `lighting?: MaterialLighting` Light shaping for every lit material of the pack (shadow tint, rim, wrap, glsl); a material's `lighting` wins, `lighting: false` opts out
|
|
12
12
|
- `seasons?: StyleSeasons` Seasonal tint: { spring: { foliage, ground }, ... }. mode 'multiply' (default) multiplies the color onto the surface (pick tints near white: orange times green is muddy); 'mix' moves the surface `strength` (0-1, default 0.5) of the way to the color. Season names are the other keys, so none can be called mode or strength
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
- `sky?: StyleSky` Sky
|
|
18
18
|
- `weather?: StyleWeather` Weather look
|
|
19
19
|
- `water?: StyleWater` Water look
|
|
20
|
-
- `pickup?: { color
|
|
21
|
-
- `character?: { animation?: { fade?: number } }` How character motion looks: animation.fade skeletal animation transition seconds. Bodies are assets, not style ({ model: 'yourBody' } from an asset pack); a style tints body parts through materials roles (cloth, skin, trousers, hair).
|
|
20
|
+
- `pickup?: { color?: ColorLike; size?: number; lift?: number }` Default look of pickups on the ground: color (the item's own color wins), size (meters, of the gray placeholder box), lift height above ground (meters). The shape is not style: it is a model name from an asset pack (item model, else 'pickup:<item>', else 'pickup'); a generator that returns bare geometry is shaded by materials.pickup in the item's color
|
|
21
|
+
- `character?: { animation?: { fade?: number } }` How character motion looks: animation.fade skeletal animation transition seconds. Bodies are assets, not style ({ model: 'yourBody' } from an asset pack); a style tints body parts through materials roles (cloth, skin, trousers, hair).
|
|
22
22
|
- `ui?: StyleUI` UI colors, fonts, templates
|
|
23
23
|
- `particles?: Record<string, ParticleOptions>` Particle presets: name → parameters; default is the fallback for all effects
|
|
24
24
|
- `triggers?: { debugColor?: ColorLike; debugOpacity?: number }` Trigger zone debug wireframe
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
|
|
27
27
|
## Sub-structures
|
|
28
28
|
- **StyleSky**
|
|
29
|
-
- `keyframes?: SkyKeyframe[]`
|
|
30
|
-
- `backdrop?: ColorLike | ((
|
|
31
|
-
- `sunSize?: number`
|
|
29
|
+
- `keyframes?: SkyKeyframe[]` Rows [time, zenith, horizon, lightColor, lightIntensity, ambient]. time: share of the day (0 = 00:00, 0.5 = noon), sorted, first row 0, last 1 (midnight again: same values as 0). horizon is also the fog color. light*: engine.lights.sun (the moon at night). ambient: the hemisphere fill, also dims the room environment (recipe 08). Example: `[[0, 0x0b1030, 0x1c2440, 0x8090c0, 0.3, 0.25], [0.5, 0x5a8fd0, 0xbcd4ea, 0xfff4e0, 3, 1.1], [1, 0x0b1030, 0x1c2440, 0x8090c0, 0.3, 0.25]]`
|
|
30
|
+
- `backdrop?: ColorLike | ((ctx: LookContext) => ColorLike)` A flat background color in place of the dome (no gradient, horizon line, sun / moon disk, stars or clouds), or ({ time, weather, season, state, sky }) => color per frame. Drawn as written (no tone mapping); the keyframes still light the world; fog in its default horizon color follows it (a fog.color of your own still wins). Leave out for the dome. Example: `backdrop: ({ sky }) => sky.isDay ? 0xefebe4 : 0x2c3346`
|
|
31
|
+
- `sunSize?: number` Sharpness exponent of the sun disk, default 900 (about 2 deg); larger = smaller. Not a size in degrees: 10 is ~20 deg, under ~3 the "disk" washes most of the sky toward the sun color
|
|
32
32
|
- `sunGlow?: number` Sun glow, default 0.18
|
|
33
33
|
- `sunBrightness?: number` Sun brightness, default 6
|
|
34
34
|
- `moonSize?: number` Larger means a smaller moon
|
|
@@ -36,26 +36,27 @@
|
|
|
36
36
|
- `moonBrightness?: number`
|
|
37
37
|
- `orbitTilt?: number` North-south tilt of the sun path
|
|
38
38
|
- `orbitSway?: number` East-west swing of the sun path
|
|
39
|
-
- `starDensity?: number`
|
|
40
|
-
- `starScale?: number`
|
|
41
|
-
- `
|
|
39
|
+
- `starDensity?: number` Share of the sky grid cells (0-1) that hold a star at night, default 0.0025 (0 = no stars). A probability, not a brightness: near 1 every cell is lit and the upper sky turns into a white sheet. The cell size is starScale
|
|
40
|
+
- `starScale?: number` Star grid resolution (cells per unit of view direction), default 260: larger means smaller and more numerous stars
|
|
41
|
+
- `dim?: { tint?: boolean; stars?: boolean }` What the sky dims for every game unless the style says no (each default true; false turns that one off, the rest stay). The one place these look decisions are switched: - tint: a sky.tint color (weather grey, a cave tint) dims with the sky's own light, so a grey rain tint stays dark at night. Example: `style.sky.dim = { stars: false } // or engine.look.sky.set({ dim: { tint: false } })`
|
|
42
|
+
- `gradientCurve?: number` Gradient curve from horizon to zenith, default 0.55 (color = mix(horizon, zenith, elevation^curve), mixed in linear light, then tone mapped and exposed like the scene).
|
|
42
43
|
- `groundTint?: ColorLike` Ground bounce color of the ambient light
|
|
43
44
|
- `clouds?: StyleSkyClouds` Clouds in the sky (cloud cover follows the weather); see StyleSkyClouds
|
|
44
|
-
- `skybox?: string` Panorama (equirectangular) replacing the gradient sky, asset name or path
|
|
45
|
+
- `skybox?: string` Panorama (equirectangular) replacing the gradient sky, asset name or path (at run time engine.look.sky.replace(name))
|
|
45
46
|
- `shadow?: StyleShadow` Shadows: mapSize resolution (pixels), extent coverage (meters), etc., see StyleShadow
|
|
46
47
|
- `environment?: StyleEnvironment` Environment lighting (scene.environment), off unless a source is given; see engine.look.env. A pack can give defaults, sky({ environment }) overrides
|
|
47
48
|
- `fog?: StyleFog` Fog model and color (default: linear fog in the horizon color); see StyleFog
|
|
48
49
|
- `layers?: StyleSkyLayer[]` Extra dome layers drawn after the clouds and stars (rainbow, aurora), default none; see StyleSkyLayer
|
|
49
|
-
- **StyleShadow**
|
|
50
|
+
- **StyleShadow** Sun shadow parameters (defaults are the current look)
|
|
50
51
|
- `mapSize?: number` Shadow resolution (pixels), default 2048
|
|
51
52
|
- `extent?: number` Coverage radius (meters), default 70
|
|
52
53
|
- `distance?: number` Distance of the light from the shadow center (meters), default 160
|
|
53
|
-
- `bias?: number` Anti shadow-acne bias, default -0.
|
|
54
|
+
- `bias?: number` Anti shadow-acne depth bias (0-1 shadow depth over the 419 m light range: -0.00005 = 2 cm), default -0.00005
|
|
54
55
|
- `normalBias?: number` Normal-offset anti-acne, default 0.04
|
|
55
56
|
- `updateEvery?: number` Update shadows every N frames, default 1 (every frame); larger saves more, still updates promptly when the focus moves
|
|
56
57
|
- `snap?: number | 'texel'` Shadow center snapping grid (meters), default 0.5; 'texel' snaps to shadow pixels (shadow edges do not shimmer while moving)
|
|
57
58
|
- `ahead?: number` How far ahead of the view direction the shadow center is shifted (meters), default 0
|
|
58
|
-
- `type?: Loose<'basic' | 'pcf' | 'vsm'>` Shadow filter: 'basic' (hard edge, cheapest) / 'pcf' (default, soft edge) / 'vsm' (softest, costliest). Default
|
|
59
|
+
- `type?: Loose<'basic' | 'pcf' | 'vsm'>` Shadow filter: 'basic' (hard edge, cheapest) / 'pcf' (default, soft edge) / 'vsm' (softest, costliest). Default 'pcf' (look.shadow type)
|
|
59
60
|
- `radius?: number` Edge softness for 'pcf' and 'vsm' (no effect on 'basic'), default 1
|
|
60
61
|
- `blurSamples?: number` Blur sample count, 'vsm' only, default 8
|
|
61
62
|
- `cascades?: number` Cascaded shadows (recipes/45): 1 (default) = one shadow map around the focus, the plain path; 2-4 split the sun's shadow along the view, sharp near the camera and wide far away. Each cascade draws the casters once more. Low-tier devices stay at 1 unless low.cascades says so. Example: `shadow: { cascades: 3, maxFar: 150, low: { cascades: 2, fade: false } } // low-tier devices: 2 cascades instead of one map`
|
|
@@ -73,11 +74,10 @@
|
|
|
73
74
|
- `snow?: StyleWeatherSnow` Snow particles (default round sprites: color 0xffffff, opacity 0.9, size 20, maxSize 5 px, speed 1.6 m/s, sway 1.5 m)
|
|
74
75
|
- `types?: Record<string, Partial<WeatherPreset>>` Retune the look of weather types the game has (e.g. a darker storm); never adds a type: the list is the game's weather({ types })
|
|
75
76
|
- **StyleWater**
|
|
76
|
-
- `material?: (engine, ctx) => Material` Replace the whole water surface material (the built-in role 'water', waves and fresnel are skipped). Receives the shared uniforms (uTime, uWave, uWaveScale, uWaveSpeed), the built-in wave patch, the surface patch (depthColor / foam /
|
|
77
|
+
- `material?: (engine, ctx) => Material` Replace the whole water surface material (the built-in role 'water', waves and fresnel are skipped). Receives the shared uniforms (uTime, uWave, uWaveScale, uWaveSpeed), the built-in wave patch, the surface patch (depthColor / foam / the 'surface' hook; null without them; put it after waves) and the scrolling normal map (null without one). Example: `material: (engine, { waves }) => applyEffects(new THREE.MeshToonMaterial({ color: 0x3a8acf }), { clouds: false, patches: [waves] })`
|
|
77
78
|
- `depthColor?: StyleWaterDepth` Water color from the view angle (by 'view', default: shallow looking down, deep at grazing angles) or the wave height (by 'wave': shallow on crests); replaces color. curve shapes the blend (default 1)
|
|
78
|
-
- `foam?: StyleWaterFoam | true` Crest foam from the wave height (start / end: fraction of
|
|
79
|
-
- `
|
|
80
|
-
- `uniforms?: Record<string, any>` Uniforms for your glsl, in both stages: numbers, colors, [x, y(, z, w)] arrays or textures; live in engine.water.material.uniforms
|
|
79
|
+
- `foam?: StyleWaterFoam | true` Crest foam from the wave height (start / end: fraction of waveMax (the 'wave' hook's, default 0.29) where foam begins / is full, default 0.55 / 0.85); true = defaults. Shore foam needs depth: recipes/44
|
|
80
|
+
- `uniforms?: Record<string, any>` Uniforms for your look.water hooks' GLSL, in both stages: numbers, colors, [x, y(, z, w)] arrays or textures; live in engine.water.material.uniforms
|
|
81
81
|
- `color?: ColorLike`
|
|
82
82
|
- `opacity?: number` Opacity 0–1
|
|
83
83
|
- `flat?: boolean` Flat shading (low poly)
|
|
@@ -125,10 +125,12 @@
|
|
|
125
125
|
- `ramp?: (number | ColorLike)[]` toon only: the light ramp, dark to light: grays 0-1 (light strength in the band) or colors (tint the band). Replaces steps
|
|
126
126
|
- `soften?: number` toon only, with ramp: 0 = hard bands, up to 1 = the bands melt into each other
|
|
127
127
|
- `color?: ColorLike`
|
|
128
|
-
- `map?:
|
|
129
|
-
- `normalMap?:
|
|
130
|
-
- `roughnessMap?:
|
|
128
|
+
- `map?: TextureSlot` Texture slots take an asset name: map, emissiveMap (sRGB), normalMap, roughnessMap, metalnessMap, aoMap, bumpMap, alphaMap, displacementMap... (linear). Loaded through engine.assets.texture, a neutral stand-in until the image arrives; the key must be a slot the type has (roughnessMap needs 'standard').
|
|
129
|
+
- `normalMap?: TextureSlot`
|
|
130
|
+
- `roughnessMap?: TextureSlot`
|
|
131
|
+
- `aoMap?: TextureSlot`
|
|
132
|
+
- `lightMap?: TextureSlot`
|
|
131
133
|
- `repeat?: number | [number, number]` How many times the textures of this material repeat (a number, or [x, y]); default 1
|
|
132
|
-
- `wrap?: Loose<'repeat' | 'clamp' | 'mirror'>` Texture wrapping: 'repeat' (default) / 'clamp' / 'mirror'
|
|
134
|
+
- `wrap?: Loose<'repeat' | 'clamp' | 'mirror'>` Texture wrapping: 'repeat' (default for files loaded by name; your own textures keep theirs) / 'clamp' / 'mirror'
|
|
133
135
|
- `detail?: MaterialDetail` Grain, paper, strokes or a texture laid over the surface in world space (no UVs needed); off unless given
|
|
134
136
|
- `lighting?: MaterialLighting | false` Extra light shaping (shadow tint, rim, wrap, your own GLSL); merged over style.lighting, false opts out
|
package/docs/api/terrain.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# engine.terrain — terrain(opts?: TerrainOptions)
|
|
2
2
|
|
|
3
|
-
Procedural terrain (terrain() module)
|
|
3
|
+
Procedural terrain, data part (terrain() module: chunks, heights, edits, collision)
|
|
4
4
|
|
|
5
|
-
- Options `TerrainOptions` (also includes the fields of Partial<TerrainConfig
|
|
5
|
+
- Options `TerrainOptions` (also includes the fields of Partial<Omit<TerrainConfig, 'normals'>>):
|
|
6
6
|
- `viewChunks?: number` View distance (in chunks), default 4
|
|
7
7
|
- `density?: number` Vegetation density multiplier, default 1
|
|
8
|
-
- `viewFog?: boolean` true: the fog distance (engine
|
|
8
|
+
- `viewFog?: boolean` true: the fog distance (look.fog far, engine layer, owner 'terrainLook') follows the view distance so the far chunk edge fades out; default false keeps the game's fog (openWorld() sets true)
|
|
9
9
|
- `material?: Material | ((engine: Engine) => Material)` Ground material (default style.terrain.material, else the 'terrain' role with vertex colors); chunks have uv = world xz / chunk size. Cloud shadows and season tint are added
|
|
10
|
+
- `effects?: boolean` With material: false = draw it exactly as given, no cloud shadow / season / detail patch (same as look.ground.replace(m, { effects: false }))
|
|
10
11
|
|
|
11
12
|
## Methods and properties
|
|
12
13
|
- `terrain.setViewChunks(n: number)` — Change the view distance (in chunks); fog and camera far plane adjust too
|
|
13
|
-
- `terrain.setDensity(d: number)` — Change the vegetation density
|
|
14
|
+
- `terrain.setDensity(d: number)` — Change the vegetation density: plants are placed again on the loaded chunks; the ground and its collision stay
|
|
15
|
+
- `terrain.view(hooks: { add?, change?, remove?, show? }) → { remove(): void }` — Draw these chunks: the hooks a look that replaces 'terrain-look' 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 (same vertex count); 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
|
+
- `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
|
|
14
17
|
- `terrain.rebuild()` — Rebuild all chunks
|
|
15
18
|
- `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`
|
|
16
19
|
- `terrain.isReadyAround(position: PositionLike, opts?: { rings?: number }) → boolean` — Whether the chunks within rings rings (default 1) around position are all loaded
|
|
@@ -18,11 +21,11 @@ Procedural terrain (terrain() module)
|
|
|
18
21
|
- `T: TerrainGen` Pure-computation terrain (height, landform)
|
|
19
22
|
- `CHUNK: number` Chunk edge length (meters)
|
|
20
23
|
- `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); });`
|
|
21
|
-
- `chunks: Map<string,
|
|
24
|
+
- `chunks: Map<string, TerrainChunk>` Loaded chunks: 'cx,cz' → chunk
|
|
22
25
|
- `viewChunks: number` View distance (in chunks)
|
|
23
26
|
- `density: number` Vegetation density multiplier
|
|
24
27
|
- `applyBudgetMs: number` Time budget (milliseconds) for uploading chunks per frame
|
|
25
|
-
- `stats: { builtThisFrame, applyMs, queued, visible?, loaded?,
|
|
28
|
+
- `stats: { builtThisFrame, applyMs, queued, failed, visible?, loaded?, … }` Statistics (for the debug panel); failed = chunks that failed every try (terrain:chunkFailed)
|
|
26
29
|
- `cellSize: number` Grid spacing (meters) = chunkSize / resolution: edits snap to it, paint colors whole cells of this size
|
|
27
30
|
|
|
28
31
|
## Data structures
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# engine.terrainLook — terrainLook()
|
|
2
|
+
|
|
3
|
+
Draws the terrain chunks (terrain()'s look module, slot 'terrain-look'; undefined when a game replaced it)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `terrainLook.setMaterial(m: Material)` — Swap the ground material on every loaded chunk at once (look.ground.replace uses it): nothing is regenerated, collision is untouched
|
|
8
|
+
- Properties:
|
|
9
|
+
- `material: Material` The ground material every chunk draws with
|
|
10
|
+
- `meshes: Map<TerrainChunk, { group: Object3D; mesh: Mesh; colorTex: …` chunk record -> { group, mesh, colorTex, colorMat }
|
package/docs/api/timeline.md
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Cutscenes, tweens (timeline() module)
|
|
4
4
|
|
|
5
|
-
- Options `TimelineOptions
|
|
6
|
-
- `skipKeys?: string[]` Keys that skip a cutscene, default ['Escape', 'Backspace'] (Esc is the back key, which the UI focus stack hands to the topmost cutscene; cutscenes do not advance while frozen)
|
|
5
|
+
- Options `TimelineOptions`
|
|
7
6
|
|
|
8
7
|
## Methods and properties
|
|
9
|
-
- `timeline.tween(target: any, to: TweenTo, duration?: number
|
|
8
|
+
- `timeline.tween(target: any, to: TweenTo, opts?: { duration?: number; ease?: Ease }) → TweenPromise` — General tween (the only entry point for tweens in the engine): await engine.timeline.tween(mesh, { 'position.y': 2 }, { duration: 1, ease: 'outCubic' }); duration in seconds (default 1), ease default 'inOutCubic'; tween(mesh, to, 1) throws in dev. Returns a Promise (with finish() / remove())
|
|
10
9
|
- `timeline.play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions) → Promise<{ skipped: boolean }>` — Play a timeline; resolves with { skipped } when it ends
|
|
11
10
|
- `timeline.skip(run?: any)` — Skip all (or one) playing timelines
|
|
12
11
|
- Properties:
|
|
@@ -32,7 +31,7 @@ Cutscenes, tweens (timeline() module)
|
|
|
32
31
|
- **TimelinePlayOptions**
|
|
33
32
|
- `skippable?: boolean` Can be skipped, default true
|
|
34
33
|
- `letterbox?: boolean` Letterbox bars, default false
|
|
35
|
-
- `
|
|
34
|
+
- `actors?: any[]` The characters the cutscene drives (their control slot on layer 'cutscene'; keys / walks / NPC behaviours pause and come back after). Default: [engine.player] when there is a player; [] drives nobody (a bubble scene the player walks through). A path step adds its character
|
|
36
35
|
- **CameraPose** One end point of a camera move
|
|
37
36
|
- `position?: Vec3Like` Camera position
|
|
38
37
|
- `lookAt?: Vec3Like | Object3D` The point to look at, or a moving object
|
package/docs/api/tools.md
CHANGED
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
# Utility functions (imported from threedog)
|
|
2
2
|
|
|
3
|
-
- `
|
|
4
|
-
- `
|
|
5
|
-
- `presets: { weather, calendar, player, interactions, keys, 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'] })
|
|
3
|
+
- `weather(opts?: WeatherOptions) → [ModuleDef<Weather>, ModuleDef<im…` — Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its look (engine.weatherLook, type 'look'; needs sky)
|
|
4
|
+
- `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'] })
|
|
6
5
|
- `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
|
|
7
6
|
- `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.
|
|
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.
|
|
9
|
-
- `webSocket(url: string, { host, key }?: { host
|
|
7
|
+
- `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
|
+
- `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).
|
|
10
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).
|
|
11
10
|
- `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
|
|
12
11
|
- `EASINGS: Record<EaseName, (t: number) => number>` — All easing functions: name -> function
|
|
13
12
|
- `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`.
|
|
14
13
|
- `ease(e: Ease) → (t: number) => number` — Name or function -> easing function
|
|
15
|
-
- `checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean })` — Warn
|
|
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
|
+
- `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
16
|
- `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
|
-
- `
|
|
17
|
+
- `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).
|
|
18
19
|
- `createTerrain(cfg?: Partial<TerrainConfig>) → TerrainGen` — Pure terrain computation (no engine needed), for previewing heights before start: createTerrain({ seed, ...terrainPreset() }).surface(x, z)
|
|
19
|
-
- `terrainMaterial(base?: THREE.Material | null, engine?: { style: any; assets: any }) → THREE.Material` — Terrain material: base (default the style's 'terrain' role with vertex colors) + cloud shadows + season tint + optional detail texture (style.terrain.detail). Pass the engine so its style
|
|
20
|
+
- `terrainMaterial(base?: THREE.Material | null, engine?: { style: any; assets: any }, { effects }?: { effects?: boolean }) → THREE.Material` — Terrain material: base (default the style's 'terrain' role with vertex colors) + cloud shadows + season tint + optional detail texture (style.terrain.detail). Pass the engine so its style and assets are used. effects: false returns your base as is (no engine patch at all, the vegetation.define({ effects: false }) word): look.ground.replace(myMaterial, { effects: false }).
|
|
20
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.
|
|
21
|
-
- `applyEffects(material: THREE.Material, { wind, clouds, season, detail, engine, patches }?: { wind?, clouds?, season?, detail?, engine?, patches? }) → THREE.Material` — Add effects to any material (built-in, from a style
|
|
22
|
+
- `applyEffects(material: THREE.Material, { wind, clouds, season, detail, engine, patches }?: { wind?, clouds?, season?, detail?, engine?, patches? }) → THREE.Material` — Add effects to any material (built-in, from a style, or third-party); 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 style.clouds.shadow), 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 MaterialDetail in types/style.d.ts; a texture given by asset name loads from `engine`, default the first live engine). The 'world' patch (varying vThreedogWorld, world position) comes with clouds, and is added for any of your patches that lists it in needs.patches or reads vThreedogWorld (a one-time dev note asks for the needs line).
|
|
22
23
|
- `MATERIAL_PURPOSES: string[]` — Material roles the engine itself uses
|
|
23
|
-
- `makeMaterial(purpose?: string, params?:
|
|
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):
|
|
25
|
+
- `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).
|
|
24
26
|
- `materialPatches(material: THREE.Material) → string[]` — Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
|
|
25
27
|
- `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'.
|
|
26
28
|
- `makeWindow(engine: Engine, opts: WindowOptions) → UIWindow` — A toggleable window
|
|
27
29
|
- `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)
|
|
28
|
-
- `fadeScreen(engine: Engine, to: number, 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
|
|
30
|
+
- `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 })
|
|
29
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
|
|
30
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
|
|
31
33
|
- `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
|
|
32
34
|
- `formatClock(t: number, hoursPerDay?: number) → string` — Fraction of the day -> 'HH:MM': formatClock(0.75) = '18:00'
|
|
33
|
-
- `inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number) → boolean` — Is time t (0-1, e.g.
|
|
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
36
|
- `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
|
|
35
37
|
- `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
|
|
36
38
|
- `THREE` — three.js itself (any): `import { THREE } from 'threedog'`
|
|
37
39
|
|
|
38
40
|
## Data structures
|
|
39
41
|
- **WindowOptions** Parameters of makeWindow()
|
|
40
|
-
- `id: string` Window name (also the style
|
|
42
|
+
- `id: string` Window name (also the style's template name)
|
|
41
43
|
- `title: () => string` Title
|
|
42
44
|
- `hintAction?: string` Action name that toggles it (shows the key hint)
|
|
43
45
|
- `render: (data, tools) => string` Default content: (data, tools) => HTML
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
- `open: boolean` Whether it is open
|
|
49
51
|
- `refresh()` — Redraw the content
|
|
50
52
|
- `toggle(on?: boolean)` — Open / close (toggle if no argument is passed)
|
|
53
|
+
- `remove()` — Remove the window: closed, its listeners and its element gone (a module passes the window to ctx.track instead)
|
|
51
54
|
- **ScreenPoint** Result of worldToScreen(): x/y are pixels from the canvas's top-left corner (the UI root covers the canvas), onScreen is inside the view, behind is behind the camera
|
|
52
55
|
- `x: number`
|
|
53
56
|
- `y: number`
|
|
@@ -55,4 +58,17 @@
|
|
|
55
58
|
- `behind: boolean`
|
|
56
59
|
|
|
57
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, uCloud*, uCloudSpeed.
|
|
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
|
+
- `uniforms(engine: { uniforms: object }) → Record<string, Node>` — engine.uniforms as TSL uniform nodes (uTime, uWind, uCloud, uFoliageTint, uSunDir, uDaylight ...), cached per engine. They read the same { value } objects, so engine.uniforms.uWind.value = 2 changes GLSL and TSL materials alike.
|
|
66
|
+
- `detailNoise(p: Node, kind: Node | 0 | 1 | 2 | 3, octaves: Node | number) → Node` — 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).
|
|
67
|
+
- `detailBump(surfPos: Node, surfNorm: Node, h: Node, k: Node | number, faceDir: Node | number) → Node` — 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.
|
|
68
|
+
- `wrapDiffuse(nl: Node, wrap: Node | number, lightColor: Node, shadow: Node | number, albedo: Node) → Node` — 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).
|
|
69
|
+
- `shadowTint(ambient: Node, tint: Node, strength: Node | number, soft: Node | number, nl: Node, shadow: Node | number) → Node` — 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.
|
|
70
|
+
- `rim(normal: Node, viewDir: Node, color: Node, strength: Node | number, power: Node | number, shadowSide: Node | number, nl: Node) → Node` — 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.
|
|
71
|
+
- `waterWave(p: Node, t: Node | number) → Node` — GLSL float threedogWaterWave(vec3 p, float t): the built-in wave sum (height before waveHeight). p = world position * waveScale, t = time * waveSpeed.
|
|
72
|
+
- `waterSurface(spec?: { depth?, foam?, waveMax? }) → (base, wave, facing, worldPos, time) => Node` — 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.
|
|
73
|
+
- `waterFresnel(color: Node, normal: Node, viewDir: Node, strength: Node | number, towards: Node) → Node` — The water's fresnel blend: color mixed toward `towards` (the engine uses the fog color) by pow(1 - /viewDir . normal/, 3) * strength, view space
|
|
58
74
|
- `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
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Trigger zones (triggers() module)
|
|
4
4
|
|
|
5
5
|
- Options `TriggersOptions`:
|
|
6
|
-
- `
|
|
7
|
-
- `action?: string` Action name that toggles the wireframes, default 'triggersDebug'
|
|
8
|
-
- `keys?: string[]` Key that toggles the wireframes: default ['F4'] in dev builds, none in release builds
|
|
6
|
+
- `action?: string` Action name that toggles the debug view 'triggers' (engine.debug.view), default 'triggersDebug'
|
|
9
7
|
|
|
10
8
|
## Methods and properties
|
|
11
9
|
- `triggers.list() → Trigger[]` — All trigger zones (a new array)
|
|
@@ -13,9 +11,6 @@ Trigger zones (triggers() module)
|
|
|
13
11
|
- `triggers.clear()` — Delete all (delete a single one with trigger.remove())
|
|
14
12
|
- `triggers.byTag(tag: string) → Trigger[]` — Find by tag
|
|
15
13
|
- `triggers.fromMarkers(opts?: TriggerOptions) → Trigger[]` — Every trigger_xxx marker in the level becomes a trigger zone with tag xxx; opts is shared by all of them
|
|
16
|
-
- `triggers.setDebug(on: boolean)` — Show / hide the wireframes
|
|
17
|
-
- Properties:
|
|
18
|
-
- `debug: boolean` Whether wireframes are shown
|
|
19
14
|
|
|
20
15
|
## Data structures
|
|
21
16
|
- **TriggerOptions** Trigger zone parameters
|
|
@@ -25,13 +20,13 @@ Trigger zones (triggers() module)
|
|
|
25
20
|
- `size?: number[]` Box size [width, height, depth] (meters), default [2, 2, 2]
|
|
26
21
|
- `height?: number` Cylinder height (meters), default 3
|
|
27
22
|
- `rotation?: number` Box rotation around the Y axis (radians)
|
|
28
|
-
- `onEnter?: ((t
|
|
29
|
-
- `onExit?: ((t
|
|
30
|
-
- `onStay?: ((dt
|
|
23
|
+
- `onEnter?: ((t, who, id) => void) | null` Called on entering; who is the position that entered, id the world record id of who it is (engine.actor for the default who, an id given in who, object.userData.id, null for a bare position)
|
|
24
|
+
- `onExit?: ((t, who, id) => void) | null` Called on leaving; id = who was inside
|
|
25
|
+
- `onStay?: ((dt, t, who, id) => void) | null` Called every fixed step while inside (dt in seconds)
|
|
31
26
|
- `once?: boolean` Fire on the first enter only (exit follows at once); the zone stays with used = true, and a new playthrough (engine.session) re-arms it
|
|
32
27
|
- `enabled?: boolean` false pauses detection
|
|
33
28
|
- `tag?: string` Name (carried in events)
|
|
34
|
-
- `who?: Vector3 | Object3D | { x, y, z } | (() => Array<
|
|
29
|
+
- `who?: string | Vector3 | Object3D | { x, y, z } | (() => Array<string | Obje…) | null` Who can trigger it: engine.actor by default; or an actor id, a position, an object (its position is used), or a function returning an array of those (several actors: () => [e.actor, ...e.net.peers.map(p => p.actor)])
|
|
35
30
|
- `cooldown?: number` Seconds after leaving during which entering does not fire again, default 0
|
|
36
31
|
- `userData?: Record<string, any>` Custom data
|
|
37
32
|
- **Trigger** A trigger zone (the return value of add())
|
package/docs/api/vegetation.md
CHANGED
|
@@ -10,20 +10,23 @@ Vegetation (vegetation() module; grows on terrain or on any ground provider)
|
|
|
10
10
|
- `seed?: number` Placement seed, default 1
|
|
11
11
|
|
|
12
12
|
## Methods and properties
|
|
13
|
+
- `vegetation.view(hooks: { species?, change?, ring?, show?, drop? }) → { remove(): void }` — Draw the plants: the hooks a look that replaces 'vegetation-look' uses. species(sp): defined or defined again (sp.source = the define() options); change(c, name): c.plants[name] placed, replaced or gone, or c.hidden[name] (felled slots) changed; ring(c, ring): LOD ring; show(c, visible); drop(c): released. What is already there is replayed at once. Returns { remove() } (ctx.track it). Example: `ctx.track(engine.vegetation.view({ change(c, name) { draw(c, c.plants[name]) }, drop(c) { undraw(c) } }))`
|
|
13
14
|
- `vegetation.rebuild()` — Place every chunk again: after changing the ground behind the same provider (a ground function reading game state). A new setGround or level is followed automatically
|
|
14
|
-
- `vegetation.setShadowRing(name: string, ring: number)` — Change at runtime how far a vegetation kind casts shadows: within `ring` chunk rings of the player (0 = only the chunk you stand in, 1 = the default, larger = further and dearer). Takes effect at once; the
|
|
15
|
-
- `vegetation.
|
|
15
|
+
- `vegetation.setShadowRing(name: string, ring: number)` — Change at runtime how far a vegetation kind casts shadows: within `ring` chunk rings of the player (0 = only the chunk you stand in, 1 = the default, larger = further and dearer). Takes effect at once; the define() option shadowRing is only the starting value. An unknown name warns with the known ones. Example: `engine.vegetation.setShadowRing('tree', 0); // graphics setting "shadows: low": trees shadow only the nearest chunk`
|
|
16
|
+
- `vegetation.define(name: string, opts: VegetationOptions) → Species | Promise<Species>` — Define a kind of vegetation (a model name in model / lodGeometry: resolves first, so the result is a Promise of the species)
|
|
16
17
|
- `vegetation.removeInstance(species: string, cx: number, cz: number, id: number, opts?: { regrowSeconds?: number }) → string` — Remove one (chop a tree). regrowSeconds: grows back after this many game seconds, 0 = permanent. The record is saved with the save (save key 'vegetation'). Returns the entry name
|
|
17
18
|
- `vegetation.restoreInstance(species: string, cx: number, cz: number, id: number)` — Restore one
|
|
18
19
|
- `vegetation.instanceAt(position: PositionLike, opts?: { radius?, species? }) → VegetationHit | null` — The one nearest to position within radius meters (default 2) (species restricts to one kind), null if none
|
|
19
20
|
- Also: `vegetation.get(name: string) → Species | undefined`, `vegetation.list() → Species[]`, `vegetation.isRemoved(species: string, cx: number, cz: number, id: number) → boolean`
|
|
20
21
|
|
|
21
22
|
## Data structures
|
|
22
|
-
- **VegetationOptions** Parameters of engine.vegetation.
|
|
23
|
+
- **VegetationOptions** Parameters of engine.vegetation.define(name, {...})
|
|
23
24
|
- `geometry?: BufferGeometry` High-detail model (this or model is required)
|
|
24
|
-
- `model?: Object3D`
|
|
25
|
-
- `lodGeometry?: BufferGeometry | Object3D` Low-detail model, switched to beyond lodRing rings
|
|
26
|
-
- `rule?: VegetationRule` Placement rule
|
|
25
|
+
- `model?: Object3D | string | [string, ...any[]]` A model name from an asset pack ('pine', or ['flower', color] for a generator with params), resolved as content resolves it (file or generator, cache, bake; add then returns a Promise of the species), or a multi-material Object3D (one material per mesh, e.g. bark trunk + leaf cards); still one InstancedMesh per species. Its materials are cloned
|
|
26
|
+
- `lodGeometry?: BufferGeometry | Object3D | string | [string, ...any[]]` Low-detail model, switched to beyond lodRing rings: a model name, or with model an Object3D with the same mesh order, or a geometry drawn with the first material
|
|
27
|
+
- `rule?: VegetationRule` Placement rule (random scatter per chunk)
|
|
28
|
+
- `positions?: number[][]` The game's own spots instead of the random scatter: [x, z], [x, z, scale] or [x, z, scale, yaw] in world metres / size multiplier / radians.
|
|
29
|
+
- `densityMap?: ((x, z) => number) | { url?, data?, width?, height?, size, center?, … }` How much of this species survives at each spot, 0 (none) ..
|
|
27
30
|
- `wind?: number` Wind sway amplitude, 0 = still
|
|
28
31
|
- `nearOnly?: boolean` Only generated near the player (grass, flowers)
|
|
29
32
|
- `maxRing?: number` No longer drawn beyond this many rings
|
|
@@ -32,10 +35,10 @@ Vegetation (vegetation() module; grows on terrain or on any ground provider)
|
|
|
32
35
|
- `castShadow?: boolean` Cast shadows
|
|
33
36
|
- `shadowRing?: number` Cast shadows within this many rings
|
|
34
37
|
- `receiveShadow?: boolean` Receive shadows, default true
|
|
35
|
-
- `material?: Material` Custom material, any three.js material (default: the style
|
|
38
|
+
- `material?: Material` Custom material, any three.js material (default: the style's 'vegetation' role); wind, cloud shadows and season tint are added to it
|
|
36
39
|
- `effects?: boolean` false: leave a custom material untouched (no wind / clouds / season added)
|
|
37
40
|
- `doubleSided?: boolean` Double-sided rendering
|
|
38
|
-
- **VegetationRule** Vegetation placement rule (must be JSON-able, no functions)
|
|
41
|
+
- **VegetationRule** Vegetation placement rule (must be JSON-able, no functions: it is sent to the terrain workers)
|
|
39
42
|
- `perChunk?: number` Placement attempts per chunk, default 100
|
|
40
43
|
- `chance?: number` Success probability of each attempt 0–1 (when cluster is 'none'), default 1
|
|
41
44
|
- `minHeight?: number` Altitude range (meters); default unlimited both ways (a terrain game names its band above the water, e.g. minHeight: 1.5)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# engine.vegetationLook — vegetationLook()
|
|
2
|
+
|
|
3
|
+
Draws the plants (vegetation()'s look module, slot 'vegetation-look'; undefined when a game replaced it)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `vegetationLook.mesh(c: TerrainChunk, name: string) → InstancedMesh | null` — The InstancedMesh drawing one species in one chunk, null when none
|
|
8
|
+
- `vegetationLook.kind(name: string) → { geometry, lodGeometry, material, fadeUniforms } | null | …` — How one species is drawn: its geometry, low-poly geometry, patched material(s), near-fade uniforms; null for an unknown name
|
|
9
|
+
- Properties:
|
|
10
|
+
- `meshes: Map<TerrainChunk, { group: Object3D; ims: Record<string, In…` chunk record -> { group, ims: { species name: InstancedMesh } }
|
package/docs/api/water.md
CHANGED
|
@@ -5,26 +5,10 @@ Water surface (water() module)
|
|
|
5
5
|
- Options `WaterOptions`:
|
|
6
6
|
- `sea?: boolean` false: do not draw the global water surface (sea)
|
|
7
7
|
- `level?: number` Global water level (meters); if omitted, the terrain's water level is used
|
|
8
|
-
- `
|
|
9
|
-
- `
|
|
10
|
-
- `
|
|
11
|
-
- `
|
|
12
|
-
- `waveScale?: number`
|
|
13
|
-
- `waveSpeed?: number`
|
|
14
|
-
- `fresnel?: number`
|
|
15
|
-
- `size?: number`
|
|
16
|
-
- `segments?: number`
|
|
17
|
-
- `normalMap?: string`
|
|
18
|
-
- `normalScale?: number`
|
|
19
|
-
- `normalRepeat?: number`
|
|
20
|
-
- `normalSpeed?: number[]`
|
|
21
|
-
- `shininess?: number`
|
|
22
|
-
- `specular?: ColorLike`
|
|
23
|
-
- `material?: import('./style').StyleWater['material']` Replace the whole surface material, same as style.water.material
|
|
24
|
-
- `depthColor?: import('./style').StyleWater['depthColor']`
|
|
25
|
-
- `foam?: import('./style').StyleWater['foam']`
|
|
26
|
-
- `glsl?: import('./style').StyleWater['glsl']`
|
|
27
|
-
- `uniforms?: import('./style').StyleWater['uniforms']`
|
|
8
|
+
- `flat?: boolean` Flat shading (low poly), default true
|
|
9
|
+
- `size?: number` Edge length of the global water plane (meters), default 900
|
|
10
|
+
- `segments?: number` Mesh subdivision of the global water, default 150
|
|
11
|
+
- `uniforms?: import('./style').StyleWater['uniforms']` Uniforms for your look.water hooks' GLSL (same as style.water.uniforms)
|
|
28
12
|
|
|
29
13
|
## Methods and properties
|
|
30
14
|
- Properties:
|
package/docs/api/weather.md
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
# engine.weather — weather(
|
|
1
|
+
# engine.weather — weather()
|
|
2
2
|
|
|
3
|
-
Weather (weather() module,
|
|
3
|
+
Weather state (weather() module): the table, current values, set / setAuto, save, events
|
|
4
4
|
|
|
5
|
-
- Options `WeatherOptions`:
|
|
6
|
-
- `start?: WeatherName` Starting weather, default 'clear' (or the first of the game's types when it has no 'clear')
|
|
7
|
-
- `auto?: boolean` Automatic weather changes
|
|
8
|
-
- `particles?: number` Rain / snow particle count, default 6000
|
|
9
|
-
- `types?: Record<string, Partial<WeatherPreset> & Record<string, numb…` The game's weather table, the whole list (default only a calm 'clear'; seven temperate ones in presets.weather.temperate.types, extend them with { ...presets.weather.temperate.types, dust: {...} }). Left-out fields are calm; extra numeric fields of the game's own blend too and show in weather.current
|
|
10
|
-
- `autoPool?: string[]` Candidates for automatic changes (repeat an entry for higher probability)
|
|
11
|
-
- `autoInterval?: number[]` Interval between automatic changes [shortest, longest] seconds
|
|
12
|
-
- `transition?: number` Transition seconds of automatic changes, default 25
|
|
13
|
-
- `area?: number` Rain / snow coverage (meters)
|
|
14
5
|
|
|
15
6
|
## Methods and properties
|
|
16
|
-
- `weather.define(_field: string, _spec?: import("../../../style").StyleWeath…) → never` — Renamed in 0.2: throws and names the new call, engine.look.weather.replace({ [field]: spec }) (recipes/44-water-weather-look-hooks.md)
|
|
17
7
|
- `weather.setAuto(on: boolean)` — Automatic weather on/off
|
|
18
|
-
- `weather.set(name: WeatherName, seconds?: number)` — Switch weather. seconds: transition seconds, default 15
|
|
8
|
+
- `weather.set(name: WeatherName, opts?: { seconds?: number })` — Switch weather. seconds: transition seconds, default 15; 0 switches at once (current is the new weather before the next step, so a screenshot or test right after shows all of it). Options in an object like every other engine call: set('rain', 20) throws [module-params] in dev (the old positional form). Example: `engine.weather.set('rain', { seconds: 20 })`
|
|
19
9
|
- `weather.label(name?: string) → string` — Display name of a weather (string table weather.<name>, falls back to the name itself); defaults to the current weather
|
|
20
10
|
- Properties:
|
|
21
11
|
- `types: Record<string, WeatherPreset>` The weather types this game has: name -> numbers (the standard fields plus any of the game's own, all blended on change)
|
|
@@ -25,5 +15,5 @@ Weather (weather() module, needs sky)
|
|
|
25
15
|
- `autoPool: string[]` Candidates for automatic weather (repeat a name to make it likelier)
|
|
26
16
|
- `autoInterval: number[]` Automatic weather interval [min, max] seconds
|
|
27
17
|
- `autoTransition: number` Transition seconds for automatic weather
|
|
28
|
-
- `
|
|
29
|
-
- `
|
|
18
|
+
- `lightningFirst: number` Seconds to the first bolt (also after a load without a saved timer)
|
|
19
|
+
- `lightningInterval: number[]` [min, max] seconds between bolts while a type with lightning > 0.5 holds
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# engine.weatherLook — weatherLook()
|
|
2
|
+
|
|
3
|
+
Weather look (installed by weather(), needs sky): rain / snow particle systems, lightning flash, the weather's effect on sun, fog and sky
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- Properties:
|
|
8
|
+
- `flash: number` Sky flash now, 1 at a strike (the weather:lightning event) fading to 0
|
|
9
|
+
- `particles: number` Default particle count per system (halved on low-tier devices)
|
|
10
|
+
- `systems: Map<string, any>` Particle systems drawn now: field -> { field, object, uniforms } (rain / snow when the table has them, plus fields look.weather.replace adds)
|
package/docs/api/world.md
CHANGED
|
@@ -16,7 +16,8 @@ World data (world() module): things that must be saved, survive level changes an
|
|
|
16
16
|
- `world.present(kind: string, opts: { build, update?, dispose?, show?, radius?, positionFrom? }) → { remove(): void }` — Register how a kind of thing looks: models are built automatically within radius meters of any full-detail stream source (engine.stream: player, camera focus, teleport destination) and torn down when far from all of them (radius × 1.25); tearing down never touches the record. Callbacks: build(rec) → three.js object (may be async). world adds it to the scene and places it at rec.position; if it throws / fails / returns a non-object: reported once, does not block ready, retried when you leave and come back. update(rec, obj, dt): called every frame for records that have a model (change the look from the data, e.g. an opened chest swaps texture). dispose(rec, obj): called on teardown (record first, model second); if omitted, engine.remove(obj). show(rec) → false: this record has no model right now (picked up, waiting to respawn); re-evaluated when world.set changes records of this kind. Example: `engine.world.present('chest', { build: rec => new THREE.Mesh(boxGeo, makeMaterial('prop')), dispose: (rec, obj) => engine.remove(obj), show: rec => !rec.looted })`
|
|
17
17
|
- `world.view(id: string) → any` — The current model of this record (only exists nearby; null if not built yet or far away)
|
|
18
18
|
- `world.refresh()` — Build / tear down models for the stream sources right now (normally automatic every frame, with a per-frame limit). Use it right after add when you need the model: sync builds are available via view(id) after the call, for async ones also await world.whenReady. Example: `engine.world.add({ id: 'gate', kind: 'gate', position: p }); engine.world.refresh(); engine.world.view('gate')`
|
|
19
|
-
- `world.simulate(kind: string, opts: { near?, far?, farEvery?, radius?,
|
|
19
|
+
- `world.simulate(kind: string, opts: { near?, far?, farEvery?, radius?, fullRadius?, nearEvery?, … }) → { remove(): void }` — Register how a kind of thing changes (gameplay logic goes here, runs in the fixed step); near / far is split by distance from world.anchor (default: the player): near(rec, dt, obj): within radius, once per fixed step (obj is the model, may be null if not built yet; gameplay must not depend on it); far(rec, dt): farther away, once every farEvery seconds; dt is the seconds accumulated since the last simulation (can catch up a long time at once); on the far → near step, far runs first to pay back the owed time. With only far (crops), near also advances via far; with only near, far records are not simulated and owed time is not made up. Both dt are accumulated real (fixed-step) seconds (not multiplied by clock.rate). For things measured in game clock (grows over days) store engine.clock.now and compare. Example: `engine.world.simulate('zombie', { near: (rec, dt) => chase(rec, dt), far: (rec, dt) => wander(rec, dt), farEvery: 2 })`
|
|
20
|
+
- `world.pauseSimulation() → { remove(): void }` — Stop running simulate() handlers on this machine until remove(): a multiplayer client lets the host simulate and only receives the records. Public so net() needs no world internals.
|
|
20
21
|
- Properties:
|
|
21
22
|
- `records: Map<string, WorldRecord>` All records: id → record (read-only; use set to change fields, move to change position)
|
|
22
23
|
- `radius: number` Default distance (meters) for building models and counting as near; present / simulate can override it. Changing it at runtime affects those without their own radius
|