threedog 0.2.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +371 -1
- package/README.md +21 -12
- package/core/Animator.js +15 -12
- package/core/Assets.js +92 -26
- package/core/Audio.js +45 -38
- package/core/Baked.js +30 -15
- package/core/Batching.js +102 -15
- package/core/Budget.js +40 -19
- package/core/Clock.js +40 -80
- package/core/DebugOverrides.js +75 -25
- package/core/Describe.js +105 -45
- package/core/Engine.js +203 -75
- package/core/Events.js +4 -1
- package/core/I18n.js +25 -13
- package/core/Input.js +175 -80
- package/core/Inspect.js +8 -5
- package/core/InspectMaterials.js +84 -0
- package/core/InspectPerf.js +68 -0
- package/core/InspectScene.js +13 -2
- package/core/Loading.js +2 -1
- package/core/MaterialInfo.js +7 -5
- package/core/Ops.js +50 -9
- package/core/Random.js +9 -2
- package/core/Rays.js +12 -7
- package/core/SaveStore.js +41 -9
- package/core/Saves.js +71 -15
- package/core/Stream.js +13 -10
- package/core/Threads.js +26 -7
- package/core/UrlState.js +69 -13
- package/core/Views.js +10 -6
- package/core/actor.js +1 -1
- package/core/adaptive.js +93 -0
- package/core/assetEntry.js +27 -7
- package/core/assetHot.js +176 -0
- package/core/assetLoad.js +44 -19
- package/core/assetManifest.js +53 -11
- package/core/assetReport.js +5 -5
- package/core/audioRules.js +13 -11
- package/core/audioVoice.js +69 -42
- package/core/batchGroups.js +9 -1
- package/core/canvasBox.js +1 -2
- package/core/catalog.js +21 -5
- package/core/cells.js +62 -0
- package/core/checks.js +10 -8
- package/core/chunkStream.js +87 -0
- package/core/control.js +149 -0
- package/core/copies.js +32 -0
- package/core/dayTime.js +12 -6
- package/core/debugView.js +85 -18
- package/core/describeRender.js +117 -21
- package/core/describeText.js +41 -21
- package/core/engineCamera.js +32 -0
- package/core/errorCodes.js +478 -32
- package/core/errorHints.js +41 -142
- package/core/errors.js +31 -8
- package/core/events.generated.js +13 -7
- package/core/gameLights.js +69 -0
- package/core/grayMap.js +20 -0
- package/core/grid.js +14 -13
- package/core/gridLoad.js +2 -1
- package/core/ground.js +6 -4
- package/core/headlessLoad.js +55 -0
- package/core/holds.js +78 -50
- package/core/inputContext.js +11 -7
- package/core/inputDefaults.js +24 -21
- package/core/inputPad.js +1 -1
- package/core/inputPointer.js +1 -1
- package/core/inputTouch.js +2 -2
- package/core/lifecycle.js +46 -12
- package/core/lightWatch.js +9 -5
- package/core/loop.js +109 -43
- package/core/math.js +18 -3
- package/core/moduleSlots.js +100 -0
- package/core/moduleTypes.js +86 -0
- package/core/modules.js +147 -29
- package/core/movement.js +2 -2
- package/core/namedModel.js +74 -0
- package/core/opsCheck.js +3 -3
- package/core/opsFail.js +15 -6
- package/core/opsGuard.js +4 -4
- package/core/opsRun.js +4 -3
- package/core/owned.js +171 -0
- package/core/page.js +44 -10
- package/core/params.js +30 -8
- package/core/pictureSlots.js +33 -0
- package/core/pictureWriters.js +343 -0
- package/core/plugins.js +245 -0
- package/core/saveApply.js +99 -17
- package/core/saveFiles.js +8 -6
- package/core/saveValues.js +46 -0
- package/core/saveVersions.js +20 -3
- package/core/scatter.js +48 -19
- package/core/sceneDelta.js +211 -0
- package/core/sceneMethods.js +31 -33
- package/core/screenToGround.js +1 -1
- package/core/services.js +27 -11
- package/core/session.js +28 -25
- package/core/shaderCost.js +78 -0
- package/core/shadowTypes.js +3 -2
- package/core/shadows.js +405 -0
- package/core/sharedPoint.js +303 -0
- package/core/skip.js +36 -28
- package/core/stackFrames.js +45 -0
- package/core/stacks.js +166 -0
- package/core/startup.js +153 -13
- package/core/streamSources.js +0 -11
- package/core/targeting.js +1 -1
- package/core/textureBytes.js +20 -0
- package/core/thingExplain.js +3 -3
- package/core/thingOps.js +29 -6
- package/core/things.js +22 -12
- package/core/threadPure.js +7 -3
- package/core/threePatches.js +47 -0
- package/core/tier.js +21 -10
- package/core/time.js +236 -0
- package/core/uiClock.js +25 -0
- package/core/util.js +8 -2
- package/core/validate.js +66 -87
- package/core/view.js +43 -0
- package/core/wrap.js +106 -0
- package/docs/AI.md +95 -104
- package/docs/API.md +35 -31
- package/docs/CODEMAP.md +231 -176
- package/docs/COMMANDS.md +63 -39
- package/docs/CONVENTIONS.md +99 -31
- package/docs/MIGRATING-0.3.md +248 -0
- package/docs/MIGRATING-0.4.md +320 -0
- package/docs/MIGRATING-0.5.md +68 -0
- package/docs/MIGRATING-0.6.md +126 -0
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/PERF.md +35 -7
- package/docs/THREE.md +82 -28
- package/docs/api/ambience.md +0 -1
- package/docs/api/assets.md +15 -11
- package/docs/api/audio.md +10 -14
- package/docs/api/budget.md +4 -0
- package/docs/api/calendar.md +41 -0
- package/docs/api/cameraRig.md +16 -5
- package/docs/api/characters.md +41 -24
- package/docs/api/clock.md +6 -5
- package/docs/api/collision.md +10 -7
- package/docs/api/content.md +6 -4
- package/docs/api/dialogue.md +9 -9
- package/docs/api/engine.md +95 -65
- package/docs/api/events.md +20 -14
- package/docs/api/grids.md +10 -3
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +5 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +13 -7
- package/docs/api/interactions.md +10 -6
- package/docs/api/inventory.md +17 -17
- package/docs/api/level.md +0 -2
- package/docs/api/lightPool.md +3 -1
- package/docs/api/music.md +1 -1
- package/docs/api/nav.md +3 -0
- package/docs/api/occlusion.md +5 -0
- package/docs/api/openWorld.md +2 -1
- package/docs/api/particles.md +6 -3
- package/docs/api/photo.md +0 -2
- package/docs/api/pickups.md +21 -0
- package/docs/api/post.md +8 -5
- package/docs/api/quests.md +2 -3
- package/docs/api/rigid.md +16 -14
- package/docs/api/saves.md +6 -4
- package/docs/api/settings.md +2 -3
- package/docs/api/sky.md +18 -49
- package/docs/api/stream.md +1 -1
- package/docs/api/terrain.md +16 -7
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/timeline.md +3 -4
- package/docs/api/tools.md +32 -15
- package/docs/api/triggers.md +7 -10
- package/docs/api/vegetation.md +17 -9
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +9 -21
- package/docs/api/weather.md +10 -15
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +3 -2
- package/docs/recipes/01-new-game.md +52 -42
- package/docs/recipes/02-npc.md +24 -7
- package/docs/recipes/03-items-pickups.md +57 -22
- package/docs/recipes/04-quests.md +12 -5
- package/docs/recipes/05-props-bake.md +174 -22
- package/docs/recipes/06-clock-events.md +100 -52
- package/docs/recipes/07-flow-scenes-pause.md +50 -10
- package/docs/recipes/08-weather-sky.md +134 -37
- package/docs/recipes/09-materials-lights-models.md +185 -0
- package/docs/recipes/10-blender-level.md +16 -4
- package/docs/recipes/11-vehicles.md +67 -10
- package/docs/recipes/13-animation.md +23 -9
- package/docs/recipes/14-custom-module.md +63 -29
- package/docs/recipes/15-perf.md +31 -10
- package/docs/recipes/16-dev-bridge.md +74 -40
- package/docs/recipes/18-world.md +26 -14
- package/docs/recipes/19-shooting-picking.md +12 -10
- package/docs/recipes/20-content-actions-save.md +60 -18
- package/docs/recipes/21-camera.md +55 -17
- package/docs/recipes/22-shop-gold.md +3 -3
- package/docs/recipes/23-ops.md +17 -11
- package/docs/recipes/26-ui-parts.md +86 -13
- package/docs/recipes/27-net.md +11 -5
- package/docs/recipes/28-terrain.md +36 -3
- package/docs/recipes/29-grid.md +46 -19
- package/docs/recipes/30-templates.md +72 -15
- package/docs/recipes/31-audio.md +20 -12
- package/docs/recipes/32-action-game.md +51 -4
- package/docs/recipes/34-environment-lighting.md +108 -21
- package/docs/recipes/35-picture-from-reference.md +147 -0
- package/docs/recipes/36-sky-ground-plants.md +158 -0
- package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -12
- package/docs/recipes/38-environment-hooks.md +67 -0
- package/docs/recipes/40-scene.md +114 -32
- package/docs/recipes/42-terrain-shape.md +2 -2
- package/docs/recipes/43-shader-patches-surfaces.md +206 -0
- package/docs/recipes/44-water-weather-hooks.md +191 -0
- package/docs/recipes/45-cascaded-shadows.md +130 -23
- package/docs/recipes/46-blender-art-route.md +17 -20
- package/docs/recipes/47-island-snow-backdrop.md +13 -15
- package/docs/recipes/49-game-module-contract.md +30 -17
- package/docs/recipes/50-own-renderer.md +4 -4
- package/docs/recipes/51-capability-catalog.md +3 -3
- package/docs/recipes/52-around-the-picture.md +181 -0
- package/docs/recipes/53-ground-up-close.md +12 -12
- package/docs/recipes/54-three-idioms.md +88 -0
- package/docs/recipes/55-mods-time-wrap.md +124 -0
- package/docs/recipes/56-webgpu-tsl.md +303 -0
- package/docs/recipes/57-control.md +104 -0
- package/docs/recipes/58-input.md +60 -0
- package/docs/recipes/59-depth-post-effects.md +83 -0
- package/docs/recipes/60-judge-the-picture.md +70 -0
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +244 -0
- package/docs/recipes/63-third-person-start.md +77 -0
- package/docs/recipes/64-particles.md +35 -0
- package/examples/action/.threedog/content-index.json +1 -0
- package/examples/action/GAMEMAP.md +20 -14
- package/examples/action/assets.js +8 -0
- package/examples/action/content/actions.js +1 -1
- package/examples/action/content/audio.js +5 -5
- package/examples/action/main.js +12 -15
- package/examples/action/models.js +23 -24
- package/examples/action/picture/index.js +13 -0
- package/examples/action/picture/lights.js +35 -0
- package/examples/action/picture/materials.js +8 -0
- package/examples/action/picture/palette.js +33 -0
- package/examples/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/FINDINGS.md +53 -0
- package/examples/plain-picture/GAMEMAP.md +90 -0
- package/examples/plain-picture/main.js +48 -0
- package/examples/plain-picture/picture/index.js +21 -0
- package/examples/plain-picture/picture/lights.js +54 -0
- package/examples/plain-picture/picture/materials.js +24 -0
- package/examples/plain-picture/picture/palette.js +16 -0
- package/examples/plain-picture/picture/sky.js +37 -0
- package/examples/pullable.json +133 -0
- package/examples/rc2d/.threedog/content-index.json +1 -0
- package/examples/rc2d/GAMEMAP.md +88 -0
- package/examples/rc2d/README.md +57 -0
- package/examples/rc2d/main.js +55 -0
- package/examples/rc2d/picture/index.js +18 -0
- package/examples/rc2d/picture/lights.js +11 -0
- package/examples/rc2d/picture/materials.js +18 -0
- package/examples/rc2d/picture/palette.js +15 -0
- package/examples/rc2d/picture/post.js +11 -0
- package/examples/rc2d/rc2d.js +187 -0
- package/examples/rc2d/shaders.js +144 -0
- package/examples/sheepisland/.threedog/content-index.json +1 -0
- package/examples/sheepisland/GAMEMAP.md +22 -17
- package/examples/sheepisland/assets.js +5 -0
- package/examples/sheepisland/content/templates.js +1 -1
- package/examples/sheepisland/content/vegetation.js +3 -1
- package/examples/sheepisland/main.js +29 -18
- package/examples/sheepisland/{style/models.js → models.js} +13 -24
- package/examples/sheepisland/picture/index.js +20 -0
- package/examples/sheepisland/picture/lights.js +34 -0
- package/examples/sheepisland/picture/materials.js +61 -0
- package/examples/sheepisland/picture/palette.js +60 -0
- package/examples/sheepisland/picture/sky.js +20 -0
- package/examples/sheepisland/views.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -0
- package/examples/styletest/GAMEMAP.md +25 -22
- package/examples/styletest/assets.js +6 -0
- package/examples/styletest/content/templates.js +1 -1
- package/examples/styletest/content/vegetation.js +1 -1
- package/examples/styletest/main.js +25 -34
- package/examples/styletest/models.js +30 -30
- package/examples/styletest/params.js +2 -5
- package/examples/styletest/picture/env.js +38 -0
- package/examples/styletest/picture/index.js +16 -0
- package/examples/styletest/picture/lights.js +9 -0
- package/examples/styletest/picture/materials.js +28 -0
- package/examples/styletest/picture/palette.js +22 -0
- package/examples/techniques/contact-shadows/README.md +91 -0
- package/examples/techniques/contact-shadows/contactShadows.js +67 -0
- package/examples/techniques/contact-shadows/main.js +55 -0
- package/examples/techniques/contact-shadows/picture/index.js +14 -0
- package/examples/techniques/contact-shadows/picture/lights.js +34 -0
- package/examples/techniques/contact-shadows/picture/materials.js +12 -0
- package/examples/techniques/contact-shadows/picture/palette.js +17 -0
- package/examples/techniques/day-night-grade/README.md +83 -0
- package/examples/techniques/day-night-grade/main.js +41 -0
- package/examples/techniques/day-night-grade/picture/index.js +20 -0
- package/examples/techniques/day-night-grade/picture/lights.js +45 -0
- package/examples/techniques/day-night-grade/picture/materials.js +15 -0
- package/examples/techniques/day-night-grade/picture/palette.js +59 -0
- package/examples/techniques/day-night-grade/picture/post.js +25 -0
- package/examples/techniques/day-night-grade/picture/sky.js +33 -0
- package/examples/techniques/interior-light/README.md +106 -0
- package/examples/techniques/interior-light/interiorLight.js +47 -0
- package/examples/techniques/interior-light/main.js +87 -0
- package/examples/techniques/interior-light/picture/index.js +24 -0
- package/examples/techniques/interior-light/picture/lights.js +52 -0
- package/examples/techniques/interior-light/picture/materials.js +13 -0
- package/examples/techniques/interior-light/picture/palette.js +32 -0
- package/examples/techniques/interior-light/picture/sky.js +40 -0
- package/examples/techniques/modular-building/README.md +126 -0
- package/examples/techniques/modular-building/kit.js +426 -0
- package/examples/techniques/modular-building/main.js +39 -0
- package/examples/techniques/modular-building/picture/index.js +17 -0
- package/examples/techniques/modular-building/picture/lights.js +26 -0
- package/examples/techniques/modular-building/picture/materials.js +13 -0
- package/examples/techniques/modular-building/picture/palette.js +23 -0
- package/examples/techniques/night-lights/README.md +95 -0
- package/examples/techniques/night-lights/main.js +47 -0
- package/examples/techniques/night-lights/nightLights.js +95 -0
- package/examples/techniques/night-lights/picture/index.js +18 -0
- package/examples/techniques/night-lights/picture/lights.js +44 -0
- package/examples/techniques/night-lights/picture/materials.js +15 -0
- package/examples/techniques/night-lights/picture/palette.js +34 -0
- package/examples/techniques/night-lights/picture/post.js +9 -0
- package/examples/techniques/night-lights/picture/sky.js +36 -0
- package/examples/techniques/outlines-and-rim/README.md +59 -0
- package/examples/techniques/outlines-and-rim/main.js +61 -0
- package/examples/techniques/outlines-and-rim/outlines.js +64 -0
- package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
- package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
- package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
- package/examples/techniques/procedural-animation/README.md +79 -0
- package/examples/techniques/procedural-animation/creature.js +44 -0
- package/examples/techniques/procedural-animation/main.js +47 -0
- package/examples/techniques/procedural-animation/picture/index.js +15 -0
- package/examples/techniques/procedural-animation/picture/lights.js +35 -0
- package/examples/techniques/procedural-animation/picture/materials.js +10 -0
- package/examples/techniques/procedural-animation/picture/palette.js +16 -0
- package/examples/techniques/procedural-animation/picture/sky.js +31 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +118 -0
- package/examples/techniques/procedural-surface/README.md +69 -0
- package/examples/techniques/procedural-surface/main.js +65 -0
- package/examples/techniques/procedural-surface/picture/index.js +14 -0
- package/examples/techniques/procedural-surface/picture/lights.js +18 -0
- package/examples/techniques/procedural-surface/picture/materials.js +34 -0
- package/examples/techniques/procedural-surface/picture/palette.js +15 -0
- package/examples/techniques/procedural-surface/surface.js +120 -0
- package/examples/techniques/stylized-shading/README.md +74 -0
- package/examples/techniques/stylized-shading/main.js +62 -0
- package/examples/techniques/stylized-shading/picture/index.js +14 -0
- package/examples/techniques/stylized-shading/picture/lights.js +23 -0
- package/examples/techniques/stylized-shading/picture/materials.js +18 -0
- package/examples/techniques/stylized-shading/picture/palette.js +19 -0
- package/examples/techniques/stylized-shading/shading.js +131 -0
- package/examples/techniques/sun-and-key-light/README.md +133 -0
- package/examples/techniques/sun-and-key-light/keyLight.js +71 -0
- package/examples/techniques/sun-and-key-light/main.js +51 -0
- package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
- package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
- package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
- package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
- package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
- package/examples/techniques/three-looks/README.md +21 -0
- package/examples/techniques/three-looks/main.js +58 -0
- package/examples/techniques/three-looks/picture/cartoon.js +23 -0
- package/examples/techniques/three-looks/picture/cinematic.js +27 -0
- package/examples/techniques/three-looks/picture/comic.js +27 -0
- package/examples/techniques/three-looks/picture/index.js +14 -0
- package/examples/techniques/three-looks/picture/sun.js +23 -0
- package/examples/techniques/wet-road/README.md +102 -0
- package/examples/techniques/wet-road/main.js +48 -0
- package/examples/techniques/wet-road/picture/index.js +17 -0
- package/examples/techniques/wet-road/picture/lights.js +57 -0
- package/examples/techniques/wet-road/picture/materials.js +16 -0
- package/examples/techniques/wet-road/picture/palette.js +24 -0
- package/examples/techniques/wet-road/picture/sky.js +46 -0
- package/examples/techniques/wet-road/wetRoad.js +209 -0
- package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
- package/examples/webgpu-tsl/GAMEMAP.md +89 -0
- package/examples/webgpu-tsl/README.md +45 -0
- package/examples/webgpu-tsl/main.js +44 -0
- package/examples/webgpu-tsl/picture/index.js +18 -0
- package/examples/webgpu-tsl/picture/lights.js +25 -0
- package/examples/webgpu-tsl/picture/materials.js +36 -0
- package/examples/webgpu-tsl/picture/palette.js +23 -0
- package/examples/webgpu-tsl/picture/post.js +16 -0
- package/examples/webgpu-tsl/picture/sky.js +30 -0
- package/examples/world/.threedog/content-index.json +1 -0
- package/examples/world/GAMEMAP.md +31 -21
- package/examples/world/art/humanoid.js +38 -0
- package/examples/world/art/index.js +11 -0
- package/examples/world/art/models.js +57 -0
- package/examples/world/art/shapes.js +9 -0
- package/examples/world/assets.js +6 -0
- package/examples/world/content/audio.js +5 -5
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/rules.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +22 -18
- package/examples/world/models.js +17 -7
- package/examples/world/picture/index.js +20 -0
- package/examples/world/picture/lights.js +41 -0
- package/examples/world/picture/materials.js +34 -0
- package/examples/world/picture/palette.js +74 -0
- package/examples/world/picture/post.js +9 -0
- package/examples/world/picture/sky.js +39 -0
- package/index.d.ts +44 -54
- package/index.js +29 -25
- package/llms.txt +24 -15
- package/modules/ambience/Ambience.js +34 -23
- package/modules/calendar/Calendar.js +163 -0
- package/modules/calendar/contract.js +21 -0
- package/modules/calendar/index.js +82 -0
- package/modules/{sky → calendar}/schedule.js +17 -16
- package/modules/calendar/seasons.js +55 -0
- package/modules/camera/FirstPersonCamera.js +6 -15
- package/modules/camera/FixedCamera.js +33 -15
- package/modules/camera/FollowCamera.js +90 -16
- package/modules/camera/RtsCamera.js +18 -17
- package/modules/camera/common.js +73 -20
- package/modules/camera/contract.js +17 -0
- package/modules/camera/projection.js +11 -24
- package/modules/characters/Character.js +188 -48
- package/modules/characters/NPC.js +92 -41
- package/modules/characters/assetModel.js +8 -16
- package/modules/characters/behaviors.js +2 -1
- package/modules/characters/contract.js +13 -0
- package/modules/characters/footsteps.js +1 -1
- package/modules/characters/index.js +112 -49
- package/modules/characters/moveHelpers.js +4 -5
- package/modules/characters/movers/common.js +102 -19
- package/modules/characters/movers/manual.js +23 -0
- package/modules/characters/movers/rapier.js +19 -16
- package/modules/characters/movers/simple.js +14 -11
- package/modules/characters/movers/support.js +186 -0
- package/modules/characters/npcAvoid.js +47 -42
- package/modules/characters/npcSim.js +17 -9
- package/modules/characters/npcView.js +44 -16
- package/modules/characters/pathAsync.js +7 -3
- package/modules/characters/playerStrings.js +4 -3
- package/modules/characters/proceduralRig.js +19 -4
- package/modules/characters/useModel.js +2 -2
- package/modules/characters/vehicle.contract.js +21 -0
- package/modules/characters/walkTo.js +21 -7
- package/modules/collision/Collision.js +69 -27
- package/modules/collision/grid.js +8 -6
- package/modules/content/explain.js +2 -2
- package/modules/content/fields.js +102 -0
- package/modules/content/ids.js +8 -6
- package/modules/content/index.js +104 -27
- package/modules/content/loader.js +45 -33
- package/modules/content/models.js +58 -42
- package/modules/content/packs.js +6 -5
- package/modules/content/parts.js +41 -0
- package/modules/content/props.js +20 -11
- package/modules/content/rules.js +66 -0
- package/modules/content/stages.js +80 -0
- package/modules/content/templates.js +123 -30
- package/modules/debug/DebugPanel.js +24 -17
- package/modules/flow/contract.js +16 -0
- package/modules/flow/index.js +21 -15
- package/modules/gameplay/Container.js +41 -32
- package/modules/gameplay/Containers.js +30 -15
- package/modules/gameplay/Dialogue.js +113 -55
- package/modules/gameplay/Interactions.js +273 -72
- package/modules/gameplay/Inventory.js +72 -76
- package/modules/gameplay/Quests.js +75 -39
- package/modules/gameplay/boxOps.js +3 -3
- package/modules/gameplay/dialogue.contract.js +21 -0
- package/modules/gameplay/dialogueBox.js +4 -2
- package/modules/gameplay/dialogueBubbles.js +116 -0
- package/modules/gameplay/interactionPrompt.js +4 -1
- package/modules/gameplay/interactions.contract.js +16 -0
- package/modules/gameplay/inventory.contract.js +23 -0
- package/modules/gameplay/inventoryOps.js +19 -17
- package/modules/gameplay/pickups.js +306 -85
- package/modules/gameplay/questLog.js +6 -6
- package/modules/gameplay/quests.contract.js +17 -0
- package/modules/grid/Grid.js +92 -50
- package/modules/grid/Layer.js +27 -13
- package/modules/grid/index.js +96 -43
- package/modules/grid/ops.js +20 -18
- package/modules/grid/preview.js +37 -29
- package/modules/grid/strings.js +12 -0
- package/modules/grid/tiles.js +19 -22
- package/modules/hlod/index.js +52 -19
- package/modules/hud/index.js +48 -20
- package/modules/hud/parts.js +28 -13
- package/modules/level/heightfield.js +3 -1
- package/modules/level/index.js +49 -23
- package/modules/level/nodes.js +4 -3
- package/modules/lights/index.js +47 -19
- package/modules/music/Music.js +38 -21
- package/modules/music/rules.js +1 -1
- package/modules/nav/index.js +48 -42
- package/modules/net/Client.js +13 -6
- package/modules/net/Host.js +19 -5
- package/modules/net/Net.js +2 -1
- package/modules/net/index.js +13 -8
- package/modules/net/sync.js +9 -8
- package/modules/net/transports.js +77 -27
- package/modules/particles/Particles.js +58 -28
- package/modules/particles/contract.js +17 -0
- package/modules/particles/effect.js +54 -11
- package/modules/photo/Photo.js +56 -38
- package/modules/rigid/RigidBodies.js +194 -32
- package/modules/rigid/Vehicles.js +18 -15
- package/modules/rigid/sync.js +62 -17
- package/modules/settings/Settings.js +60 -55
- package/modules/settings/apply.js +38 -3
- package/modules/settings/sections.js +5 -3
- package/modules/settings/strings.js +3 -2
- package/modules/settings/view.js +5 -3
- package/modules/sky/Sky.js +132 -205
- package/modules/sky/clouds.js +37 -23
- package/modules/sky/dome.js +100 -0
- package/modules/sky/domeLayers.js +30 -15
- package/modules/sky/environment.js +45 -99
- package/modules/sky/fog.js +9 -139
- package/modules/sky/frame.js +60 -56
- package/modules/sky/season.js +21 -0
- package/modules/sky/shader.js +63 -35
- package/modules/sky/skyModule.js +52 -37
- package/modules/sky/tint.js +59 -0
- package/modules/terrain/ChunkManager.js +194 -110
- package/modules/terrain/chunkJob.js +1 -1
- package/modules/terrain/chunkQueries.js +6 -4
- package/modules/terrain/draw.js +154 -0
- package/modules/terrain/index.js +87 -54
- package/modules/terrain/terrainDefaults.js +2 -2
- package/modules/terrain/terrainEdit.js +18 -20
- package/modules/terrain/terrainGen.js +6 -4
- package/modules/terrain/terrainIsland.js +5 -4
- package/modules/terrain/terrainShape.js +12 -12
- package/modules/terrain/terrainShapeMain.js +8 -7
- package/modules/terrain/terrainTexture.js +21 -19
- package/modules/timeline/Timeline.js +95 -43
- package/modules/timeline/Tween.js +18 -10
- package/modules/timeline/letterbox.js +2 -2
- package/modules/timeline/shots.js +5 -1
- package/modules/triggers/index.js +111 -76
- package/modules/vegetation/Vegetation.js +229 -112
- package/modules/vegetation/densityMap.js +62 -0
- package/modules/vegetation/draw.js +191 -0
- package/modules/vegetation/groundChunks.js +52 -58
- package/modules/vegetation/index.js +32 -11
- package/modules/vegetation/modelGeometry.js +3 -2
- package/modules/vegetation/nearFade.js +8 -2
- package/modules/water/Water.js +157 -72
- package/modules/water/surface.js +86 -47
- package/modules/weather/Weather.js +96 -103
- package/modules/weather/particles.js +37 -14
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/strings.js +2 -2
- package/modules/weather/weatherDraw.js +141 -0
- package/modules/world/World.js +26 -9
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -4
- package/modules/world/persist.js +62 -2
- package/modules/world/pos.js +3 -2
- package/modules/world/records.js +8 -6
- package/modules/world/sim.js +60 -20
- package/modules/world/simFar.js +4 -3
- package/modules/world/state.js +3 -2
- package/modules/world/thingSource.js +1 -1
- package/modules/world/views.js +8 -6
- package/package.json +8 -3
- package/presets.js +43 -29
- package/render/PostFX.js +318 -135
- package/render/backend.js +486 -0
- package/render/cascades.js +195 -0
- package/render/cascades.tsl.js +96 -0
- package/render/daylight.js +39 -0
- package/render/detail.js +122 -41
- package/render/effects.js +155 -48
- package/render/engineUniforms.js +10 -1
- package/render/fuse.js +5 -4
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/cloudShadow.tsl.js +16 -0
- package/render/fx/detail.tsl.js +66 -0
- package/render/fx/index.js +28 -0
- package/render/fx/lighting.tsl.js +28 -0
- package/render/fx/nodeErrors.tsl.js +68 -0
- package/render/fx/noise.tsl.js +12 -0
- package/render/fx/objectOrigin.tsl.js +42 -0
- package/render/fx/particles.tsl.js +139 -0
- package/render/fx/patchNodes.tsl.js +403 -0
- package/render/fx/postWebGPU.tsl.js +181 -0
- package/render/fx/season.tsl.js +13 -0
- package/render/fx/sky.tsl.js +187 -0
- package/render/fx/uniforms.tsl.js +67 -0
- package/render/fx/water.tsl.js +53 -0
- package/render/fx/wind.tsl.js +22 -0
- package/render/fxNumbers.js +36 -0
- package/render/hotGlsl.js +24 -0
- package/render/layers.js +14 -0
- package/render/lighting.js +71 -18
- package/render/lightmap.js +142 -0
- package/render/lights.js +47 -6
- package/render/materials.js +55 -152
- package/render/modeling.js +73 -0
- package/render/neutral.js +23 -0
- package/render/occlusion.js +184 -0
- package/render/ownFrame.js +76 -0
- package/render/patches.js +317 -35
- package/render/postWebGL.js +205 -0
- package/render/probes.js +288 -0
- package/render/shaderErrors.js +154 -0
- package/render/slots.js +165 -0
- package/render/terms.js +163 -0
- package/render/uniformDecl.js +4 -3
- package/types/common.d.ts +2 -2
- package/types/core.d.ts +757 -346
- package/types/gameplay.d.ts +539 -330
- package/types/generated/core/Audio.d.ts +26 -42
- package/types/generated/core/Batching.d.ts +6 -2
- package/types/generated/core/Budget.d.ts +2 -8
- package/types/generated/core/DebugOverrides.d.ts +58 -9
- package/types/generated/core/I18n.d.ts +2 -2
- package/types/generated/core/Input.d.ts +110 -32
- package/types/generated/core/Ops.d.ts +31 -0
- package/types/generated/core/Random.d.ts +2 -2
- package/types/generated/core/Saves.d.ts +10 -2
- package/types/generated/core/Stream.d.ts +1 -1
- package/types/generated/core/Threads.d.ts +4 -1
- package/types/generated/core/Views.d.ts +0 -1
- package/types/generated/core/audioVoice.d.ts +17 -9
- package/types/generated/core/control.d.ts +55 -0
- package/types/generated/core/page.d.ts +9 -2
- package/types/generated/core/session.d.ts +2 -1
- package/types/generated/modules/ambience/Ambience.d.ts +0 -9
- package/types/generated/modules/calendar/Calendar.d.ts +84 -0
- package/types/generated/modules/calendar/index.d.ts +10 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Grid.d.ts +61 -25
- package/types/generated/modules/grid/Layer.d.ts +13 -5
- package/types/generated/modules/grid/index.d.ts +56 -20
- package/types/generated/modules/music/Music.d.ts +5 -3
- package/types/generated/modules/net/index.d.ts +3 -3
- package/types/generated/modules/net/transports.d.ts +12 -3
- package/types/generated/modules/particles/Particles.d.ts +13 -6
- package/types/generated/modules/sky/Sky.d.ts +85 -110
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/timeline/Timeline.d.ts +8 -6
- package/types/generated/modules/water/Water.d.ts +50 -3
- package/types/generated/modules/weather/Weather.d.ts +44 -15
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +20 -5
- package/types/generated/render/PostFX.d.ts +109 -29
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +31 -50
- package/types/generated/render/modeling.d.ts +30 -0
- package/types/generated/render/occlusion.d.ts +13 -0
- package/types/generated/render/patches.d.ts +16 -2
- package/types/generated/ui/UI.d.ts +6 -3
- package/types/nav.d.ts +6 -0
- package/types/physics.d.ts +140 -45
- package/types/tsl.d.ts +94 -0
- package/types/world.d.ts +489 -122
- package/ui/Focus.js +35 -14
- package/ui/LoadingScreen.js +3 -3
- package/ui/Parts.js +35 -15
- package/ui/UI.js +27 -17
- package/ui/cursor.js +115 -0
- package/ui/defaults.js +15 -11
- package/ui/theme.js +36 -27
- package/ui/touchPart.js +2 -2
- package/core/claims.js +0 -51
- package/core/look/coreParts.js +0 -112
- package/core/look/layers.js +0 -136
- package/core/look/part.js +0 -173
- package/core/look/report.js +0 -79
- package/core/look/write.js +0 -86
- package/core/renamed.js +0 -22
- package/core/styleParts.js +0 -98
- package/docs/api/entities.md +0 -61
- package/docs/api/style.md +0 -134
- package/docs/recipes/09-style-pack.md +0 -169
- package/docs/recipes/35-style-from-reference.md +0 -84
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/38-environment-look-hooks.md +0 -88
- package/docs/recipes/41-thing-registry.md +0 -93
- package/docs/recipes/43-shader-patches-surface-looks.md +0 -135
- package/docs/recipes/44-water-weather-look-hooks.md +0 -135
- package/docs/recipes/48-make-material.md +0 -70
- package/docs/recipes/52-look.md +0 -146
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/styletest/overrides.js +0 -33
- package/examples/styletest/panel.js +0 -135
- package/modules/entities/Entities.js +0 -243
- package/modules/entities/build.js +0 -25
- package/modules/entities/index.js +0 -4
- package/modules/sky/calendar.js +0 -80
- package/modules/sky/cascades.js +0 -125
- package/modules/sky/layers.js +0 -69
- package/modules/sky/look.js +0 -51
- package/modules/sky/lookFog.js +0 -80
- package/modules/sky/lookShadow.js +0 -50
- package/modules/sky/lookSky.js +0 -108
- package/modules/sky/shadow.js +0 -74
- package/modules/terrain/chunkLevels.js +0 -40
- package/modules/terrain/lookGround.js +0 -61
- package/modules/terrain/mountTerrain.js +0 -32
- package/modules/vegetation/lookWind.js +0 -37
- package/modules/water/look.js +0 -80
- package/modules/weather/look.js +0 -75
- package/modules/world/cells.js +0 -42
- package/render/lookSurface.js +0 -161
- package/render/postLook.js +0 -86
- package/render/surface.js +0 -69
- package/types/style.d.ts +0 -643
package/docs/api/dialogue.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# engine.dialogue — dialogue(opts?: DialogueOptions)
|
|
2
2
|
|
|
3
|
-
Dialogue (dialogue() module)
|
|
3
|
+
Dialogue (dialogue() module). Ops: `dialogue.advance` (finish typing the line, else go on to the next one) and `dialogue.choose { index }` (pick visible choice index, 0-based) are the only ways keys, clicks, tests and the dev bridge move a conversation on: `engine.ops.run('dialogue.choose', { index: 0 })`
|
|
4
4
|
|
|
5
5
|
- Options `DialogueOptions`:
|
|
6
6
|
- `charsPerSecond?: number` Typing speed (characters/second, game time: advanced by engine.step), default 40
|
|
7
|
-
- `advanceActions?: string[]` Actions that advance the dialogue, default ['confirm', 'interact']
|
|
8
|
-
- `
|
|
9
|
-
- `holdSeconds?: number` A non-locking line (lock: false) moves on this many seconds after it is fully typed, default 2
|
|
7
|
+
- `advanceActions?: string[]` Actions that advance the dialogue, default ['confirm'] (a basic key); e.g. ['confirm', 'interact'] to also advance on the game's interact key. Choices: the cursor, clicks, and the actions choice1..choice9 (context 'dialog', no keys of their own: presets.bindings.dialogNumbers binds 1-9)
|
|
8
|
+
- `holdSeconds?: number` A bubble line stays this many seconds plus its reading time (about 15 characters a second) unless say() gives seconds, default 2
|
|
10
9
|
|
|
11
10
|
## Methods and properties
|
|
12
11
|
- `dialogue.define(speaker: string, nodes: DialogueScript)` — Define a dialogue (the name is usually the speaker)
|
|
13
|
-
- `dialogue.start(speaker: string, nodeId?: string, onEnd?: (() => void) | null, opts?: {
|
|
14
|
-
- `dialogue.say(text: string | DialogueScript, opts?: { speaker?, node?,
|
|
15
|
-
- `dialogue.
|
|
12
|
+
- `dialogue.start(speaker: string, nodeId?: string, onEnd?: (() => void) | null, opts?: { channel?, at?, onCancel? })` — Start a dialogue: from node nodeId (default 'start'), onEnd is called when it ends. Main channel (default): locks game input and takes Esc; its choices take the UI choice cursor. onCancel: what the back key (Esc) does while it is on top of the UI focus stack (default: nothing). channel: 'bubble' plays the script as bubble lines over at (no lock, no choices; a running conversation is untouched). Ending the playthrough (engine.session newGame / load / quit) closes it without calling onEnd. Example: `engine.dialogue.start('guard', 'start', null, { channel: 'bubble', at: guard.root })`
|
|
13
|
+
- `dialogue.say(text: string | DialogueScript, opts?: { speaker?, node?, channel?, onCancel? } & BubbleOptions) → SayPromise` — Say a one-off line (no need to define first); the Promise resolves when it is done. channel: 'bubble' = over at while the player keeps playing (barks, shop chatter, radio); several speakers at once, queued per speaker. When the playthrough ends (engine.session) the line is dropped and the Promise never resolves, so code awaiting it does not run in the next playthrough. Example: `await engine.dialogue.say('Reloading!', { speaker: 'Mira', channel: 'bubble', at: mira.root })`
|
|
14
|
+
- `dialogue.bubbles() → { speaker, text, queued }[]` — Lines on the bubble channel now
|
|
15
|
+
- `dialogue.end()` — End the main dialogue
|
|
16
16
|
- Properties:
|
|
17
17
|
- `state: DialogueState` Story state: state.flags is engine.vars.flags (autosaved)
|
|
18
18
|
- `scripts: Map<string, DialogueScript>` All scripts
|
|
19
|
-
- `active: { speaker, nodes, node?, onEnd
|
|
20
|
-
- `speaking: string | null` The script
|
|
19
|
+
- `active: { speaker, nodes, node?, id?, onEnd } | null` The dialogue in progress (null when none). speaker: the script name; node: the current node OBJECT (its fields: text, choices, data...); id: that node's id string ('start', 'ask'); both are set once the first line shows. Read-only: drive it with start / end / the dialogue ops. Example: `const atAsk = engine.dialogue.active?.id === 'ask'; // the node id; active.node.data holds the node's own fields`
|
|
20
|
+
- `speaking: string | null` The script the main dialogue is playing
|
|
21
21
|
- `cps: number` Typing speed (characters/second)
|
|
22
22
|
|
|
23
23
|
## Data structures
|
package/docs/api/engine.md
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
# engine — createEngine and the Engine class (core)
|
|
2
2
|
|
|
3
|
-
- `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required; style is the style
|
|
3
|
+
- `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required; style is the game's style (see recipes/09-materials-lights-models.md)
|
|
4
4
|
- Options `EngineOptions`:
|
|
5
5
|
- `canvas?: HTMLCanvasElement | HTMLElement` Canvas element (required unless renderer is given), e.g. document.getElementById('view')
|
|
6
|
-
- `renderer?:
|
|
7
|
-
- `
|
|
8
|
-
- `
|
|
9
|
-
- `shadowType?: 'basic' | 'pcf' | 'vsm'` Shadow filter: 'basic' (hard edge) / 'pcf' / 'vsm' (softest, costliest), default 'pcf'. Change later with engine.look.shadow.set({ type })
|
|
10
|
-
- `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default style.antialias, else on for desktop and off for low-tier devices
|
|
11
|
-
- `post?: Record<string, boolean>` Turn style post effects on or off by name at startup, e.g. { bloom: false }; default: each effect's own setting (costly ones off on low-tier devices)
|
|
6
|
+
- `renderer?: 'webgl' | 'webgpu' | EngineRenderer` 'webgl' (default): the engine builds a WebGLRenderer. 'webgpu': it builds three's WebGPURenderer (needs import 'threedog/tsl' first) and start() awaits its init(). Or a ready three.js renderer (WebGLRenderer or WebGPURenderer) used as is; canvas then defaults to renderer.domElement.
|
|
7
|
+
- `fallback?: 'webgl2' | 'webgl' | 'error'` WebGPU route only: what start() does when the browser gives no WebGPU. 'webgl2' (default): the same WebGPURenderer on its WebGL2 backend, TSL keeps working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
|
|
8
|
+
- `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. The start value is the canvas's own MSAA (no post chain while no effect is on)
|
|
12
9
|
- `pixelRatio?: number` Render resolution, default min(device pixel ratio, 1.5); the low tier uses at least 0.75 x device pixel ratio (never below 1). describe().render.scale reports it
|
|
13
10
|
- `adaptiveResolution?: boolean` Automatically lower resolution when the frame rate is too low, default true. Never silent: a dev warning once, and describe().render.scale.autoLowered
|
|
14
11
|
- `targetFps?: number` Target frame rate for automatic resolution lowering, default 55
|
|
15
|
-
- `ui?:
|
|
12
|
+
- `ui?: UIOptions` All screen UI: replace or turn off any part (loading, toast, title, hud.marker, hud.counter, hud.bar; the default title screen is off), and the look of the default parts (theme, css, fonts, templates). Example: `createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })`
|
|
16
13
|
- `audio?: AudioConfig` Volume of each channel, 0–1
|
|
17
14
|
- `fov?: number` Camera field of view (degrees), default 55
|
|
18
15
|
- `near?: number` Camera near clipping plane (meters), default 0.3
|
|
19
|
-
- `
|
|
20
|
-
- `locale?: string` UI language: 'auto' (default) follows the browser (a language starting with zh gives 'zh-CN', anything else 'en'); or force 'zh-CN' / 'en' / your own
|
|
16
|
+
- `locale?: string` UI language: 'auto' (default) follows the browser (a language starting with zh gives 'zh-CN', anything else 'en'); or force 'zh-CN' / 'en' / your own. Matched by language: 'zh' / 'zh-Hans' give 'zh-CN', 'en-US' gives 'en'; a language with no strings warns once
|
|
21
17
|
- `strings?: StringTables` Override / add UI strings: { 'zh-CN': { key: text } }
|
|
22
|
-
- `bindings?: Record<string, string[]
|
|
23
|
-
- `padBindings?: Record<string, string>` Default gamepad buttons: { jump: 'PadA' }
|
|
18
|
+
- `bindings?: Readonly<Record<string, string | readonly string[]>>` The game's keys per action (keyboard, 'Mouse0', gamepad 'PadA' in one list), owner 'game': replaces the basics (move / confirm / cancel / UI cursor) and binds every other action, e.g. { interact: ['KeyE', 'PadX'], ...presets.bindings.dialogNumbers }. Same as engine.input.bind(map)
|
|
24
19
|
- `saveKey?: string` Save name prefix; must differ when several games share one site, default 'game'
|
|
25
20
|
- `joystick?: 'auto' | boolean` On-screen joystick: 'auto' (only on touch devices) / true / false
|
|
26
21
|
- `headless?: boolean` Headless mode: no real-time loop and no per-frame rendering, advances only on step() (for tests and screenshots). Adding ?threedog-headless to the URL also turns it on
|
|
@@ -32,17 +27,19 @@
|
|
|
32
27
|
- `movement?: Partial<MovementProfile>` Shared "can walk there" parameters (meters / degrees): collision, the Rapier capsule, navigation and level steps all read them by default. Default { radius: 0.4, height: 1.8, maxSlope: 48, stepHeight: 0.45 }
|
|
33
28
|
- `threads?: 'auto' | number | false` (experimental) Worker pool size for engine.threads: 'auto' (default: cores - 1, at most 4), a worker count, or false (all on the main thread, same results, no workers created)
|
|
34
29
|
- `pauseOnBlur?: boolean` Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page)
|
|
35
|
-
- `lights?: boolean` false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. Default true
|
|
36
|
-
- `batching?: false | BatchingOptions` Automatic instancing of repeated static models (engine.batching): false turns it off; default { minCount: 8, cell: engine.stream.cellSize }
|
|
30
|
+
- `lights?: boolean` false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. No light of the engine's reaches the picture. Default true
|
|
31
|
+
- `batching?: false | BatchingOptions` Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: engine.stream.cellSize }
|
|
37
32
|
|
|
38
33
|
## engine methods
|
|
39
34
|
- `engine.actorPosition(id?: string) → { x, y, z } | null` — Where an actor is now (default engine.actor): the player's position for 'player' (engine.focus without a player), else its model or world record position; null when unknown. Example: `engine.actor = 'boat_1'; engine.actorPosition()`
|
|
40
|
-
- `engine.catalog(id?: string | { find?: string }) → any` — What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas). No argument: short list; a module id / op name: that entry expanded (null if unknown); { find }: the short list filtered. recipes/51-capability-catalog.md. Example: `engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']`
|
|
35
|
+
- `engine.catalog(id?: string | { find?: string }) → any` — What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas). No argument: the short list, an ARRAY of { id, kind, label, ops, saves, ... } (read .id, not Object.keys); a module id / op name: that entry expanded (null if unknown); { find }: the short list filtered. recipes/51-capability-catalog.md. Example: `engine.catalog().map(s => s.id); engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']`
|
|
41
36
|
- `engine.takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>) → OwnerHandle` — Take the camera over (camera modules leave it alone) until remove(); the latest holder is in charge, releasing hands it back to the previous one
|
|
42
|
-
- `engine.
|
|
43
|
-
- `engine.
|
|
37
|
+
- `engine.mod(name: string, opts: import('./gameplay').ModOptions) → import('./gameplay').ModHandle` — The one way several systems change a shared quantity: an entry per owner, combined by layer, ended by its handle; nothing remembers an old value. Example: `engine.time.channel('enemies'); engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on a channel the game made`
|
|
38
|
+
- `engine.wrap(target: T, method: string, fn: (next, args) => any, opts?: { owner?: string }) → Handle` — The one way to change what a module's public method does without copying the module: fn(next, ...args) runs instead of it; call next(...args) for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api. Example: `engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })`
|
|
39
|
+
- `engine.setCamera(kind: CameraKind, opts?: object) → CameraRig` — Switch the camera at runtime between kinds, once a camera module is installed (openWorld installs followCamera; with none it throws camera-none naming the module to install, e.g. engine.use(fixedCamera({ position, lookAt }))): the target and horizontal heading carry over; the first-person camera hides the character body automatically (the shadow stays) and locks / releases the mouse; the camera switched out is kept, with its parameters, for switching back. Passing opts rebuilds this kind of camera with the new parameters. A wrong kind throws and lists the available options. Example: `engine.onFrame(() => { if (engine.input.pressedRaw('toggleView')) engine.setCamera(engine.cameraRig.kind === 'follow' ? 'firstPerson' : 'follow'); });`
|
|
40
|
+
- `engine.use(...mods: (ModuleInput | { replaces })[])` — Install one or more modules (in order; dependencies must be installed first). A last argument { replaces: 'slot' } swaps the module that holds that exclusive slot: it is unloaded first (its handles, changes and dispose) and put back if the new install fails. Example: `engine.use(myInventory(), { replaces: 'inventory' })`
|
|
41
|
+
- `engine.unuse(name: string)` — Unload one installed module: its tracked handles, its slots and ctx.mod entries, its dispose. What it added some other way stays (dev reports a picture module's leftovers). Throws while another module still requires it. To swap a holder use engine.use(mine(), { replaces: 'slot' }). Example: `engine.unuse('rain');`
|
|
44
42
|
- `engine.has(name: string) → boolean` — Whether a module is installed
|
|
45
|
-
- `engine.makeMaterial(purpose?: string, params?: { color?, … }) → Material` — Material by role from this engine's style pack: engine.makeMaterial('prop', { color: 0x8a5a36 })
|
|
46
43
|
- `engine.setGround(g: Partial<Ground>)` — Set the ground (called by the terrain and level modules); missing parts fall back to flat ground
|
|
47
44
|
- `engine.surface(x: number, z: number, refY?: number) → number` / `surface(at: PositionLike, refY?: number) → number` — Ground height (meters) at (x, z); a position or object also works: engine.surface(mesh.position). For multi-layer ground (bridges, caves, interiors) pass a reference height refY: returns the highest layer not above refY + one step (0.45 m), so standing under a bridge gives the ground and standing on it gives the deck; without it the highest layer is used (as before). Procedural terrain and flat ground have one layer and ignore refY. Off the outline of terrain({ shape }) it is -Infinity (no ground there; engine.ground.has(x, z) says so as a boolean)
|
|
48
45
|
- `engine.slope(x: number, z: number) → number` / `slope(at: PositionLike) → number` — Slope at (x, z); a position or object also works
|
|
@@ -55,56 +52,53 @@
|
|
|
55
52
|
- `engine.thing(idOrObj: string | Object3D) → Thing` — What a thing is and what a save keeps: a world record id, an engine.add id or name, or any Object3D (its registered ancestor). object is the live Object3D (not enumerable). Throws with the closest id when nothing matches. Change it with ops.run('thing.set' / 'thing.remove', { id, ... }). Example: `engine.thing('windmill').saved // 'code'`
|
|
56
53
|
- `engine.remove(...objs: Object3D[])` — Fully delete an object (use it when you no longer want the object): removes it from its parent, unregisters rays, and releases the geometry and materials of it and its children (textures and geometry / materials shared by assets are not released)
|
|
57
54
|
- `engine.detach(...objs: Object3D[])` — Only take it off its parent without releasing GPU memory (use when you will add it back later). Use remove for objects you no longer need
|
|
58
|
-
- `engine.onFixed(fn: (dt: number) => void) → Handle` — Fixed-step logic (60 times per second, dt in fixed seconds): movement, physics, cooldowns, and gameplay keys (read pressed() here: a per-step snapshot, independent of frame rate). Returns a handle { remove() }
|
|
55
|
+
- `engine.onFixed(fn: (dt: number) => void, opts?: { channel?, phase? }) → Handle` — Fixed-step logic (60 times per second, dt in fixed seconds): movement, physics, cooldowns, and gameplay keys (read pressed() here: a per-step snapshot, independent of frame rate). dt is real seconds (always 1/60) unless { channel } names a time channel: then the channel's scaled dt. phase 'early' (default) runs before every module fixed hook (the player has not moved yet this step); 'late' after them, before the clock (hit checks, reading this step's result). Returns a handle { remove() }. Example: `engine.onFixed(() => checkHits(engine.player.position), { phase: 'late' })`
|
|
59
56
|
- `engine.onFrame(fn: (dt: number) => void) → Handle` — Once per frame (dt in frame seconds): animation, camera, UI and UI keys (menus read this frame's latest input). Gameplay keys belong in onFixed. Returns a handle { remove() }
|
|
57
|
+
- `engine.onRender(fn: (ctx) => void, opts?: { when?: 'before' | 'after' }) → Handle` — Around the main frame render, after the camera update and batching. when 'before' (default): render into your own render target here (mirror, minimap, portal, picking); the render target is reset to the screen afterwards. 'after': right after the frame (read pixels). The main frame render itself stays the engine's (post chain). Returns a handle { remove() }. Example: `const rt = new THREE.WebGLRenderTarget(256, 256); engine.onRender(({ renderer, scene }) => { renderer.setRenderTarget(rt); renderer.render(scene, mapCam); });`
|
|
58
|
+
- `engine.renderOnce(target?: import('three').RenderTarget | null, camera?: import('three').Camera)` — Draw one picture now, outside the loop, on either renderer. `renderOnce()`: the frame the player sees, onto the canvas through engine.post (read the canvas in the same task, as photo mode does). `renderOnce(target)`: that frame through engine.post into a render target (the canvas's pixels). `renderOnce(target, camera)` with another camera: the scene from that camera, without post. On WebGPURenderer each call is a fresh node frame, so two calls in one task give two pictures (a RenderPipeline draws its scene pass once per frame). Example: `engine.renderOnce(); const url = engine.renderer.domElement.toDataURL('image/png'); engine.renderOnce(rt, mapCamera); // a minimap / thumbnail into your own render target`
|
|
59
|
+
- `engine.bakeProbes(opts: { bounds, spacing, resolution?, include?, owner? }) → Promise<ProbeSet>` — Bake a grid of light probes from the scene as it is now: three's probe grid renders a cube at every grid point and keeps spherical harmonics, and every lit pixel inside the grid then takes its own interpolated light, on WebGL and WebGPU alike. The grid adds to whatever ambient light the scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so). Outside the grid there is no probe light. A load-time cost, not per frame: 6 renders per probe, a few probes per task so the page keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once: bake at start-up, not mid-play. Example: `const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving }); saveFile('probes.json', JSON.stringify(probes.toJSON()));`
|
|
60
|
+
- `engine.loadProbes(json: ProbeData, opts?: { owner?: string }) → ProbeSet` — A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added. Example: `const probes = engine.loadProbes(await (await fetch('probes.json')).json());`
|
|
61
|
+
- `engine.loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }) → Promise<Lightmap>` — Put a baked lightmap on the scene: `threedog bake light` wrote the file from the meshes the game marked `userData.static = true`; this rebuilds each with its second UV set and sets plain `material.lightMap`, on WebGL and WebGPU alike. Call it once the level is built, with its lights as they will be played. Nothing runs per frame. Keep the sun real-time; the ambient light the bake saw (hemisphere, environment) has to go, or it counts twice. A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what was skipped, moved or doubled. Example: `const light = await engine.loadLightmap('light/level.lightmap');`
|
|
60
62
|
- `engine.setPixelRatio(p: number)` — Render resolution
|
|
61
|
-
- `engine.setShadows(on: boolean)` — Shadow toggle
|
|
62
|
-
- `engine.setFogFar(d: number)` — Fog distance (meters), also adjusts the camera far plane
|
|
63
63
|
- `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit)
|
|
64
64
|
- `engine.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY)
|
|
65
|
-
- `engine.spawn(name: string, at: any, fields?: { id?, rot?, scale?, y?, items?, … }) → import('./generated/modules/world…` — New runtime instance of a content template (inside an op or fixed step), saved whole; returns the world record (kind = template name). Needs content(). e.g. engine.spawn('chest', { x: 10, z: 4 }, { opened: true })
|
|
66
65
|
- `engine.applyState(params: StateParams) → Promise<void>` — Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done
|
|
67
|
-
- `engine.defineState(name: string, params: StateParams)` — Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name
|
|
66
|
+
- `engine.defineState(name: string, params: StateParams, opts?: { owner?: string }) → { owner?: string; remove(): void }` — Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name. Returns a handle: remove() forgets the name
|
|
68
67
|
- `engine.start() → Promise<this>` — Start: initialize modules, preload assets, wait for the world to be ready
|
|
69
|
-
- `engine.pause(owner?: string | { owner?, kind? }, opts?: { kind?: 'test' }) →
|
|
70
|
-
- `engine.resume(owner?: string | { owner?: string })` — Resume the real-time loop (only this owner's pause)
|
|
68
|
+
- `engine.pause(owner?: string | { owner?, kind? }, opts?: { kind?: 'test' }) → OwnerHandle` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu pause
|
|
71
69
|
- `engine.nextFixed(fn: () => T) → Promise<T>` — Run fn at the start of the next fixed step (via commits); a Promise of fn's value
|
|
72
|
-
- `engine.freeze(owner?: string | { owner?, kind? }, opts?: { kind
|
|
73
|
-
- `engine.
|
|
74
|
-
- `engine.
|
|
75
|
-
- `engine.
|
|
76
|
-
- `engine.checkSkip(seconds: number, opts?: { ignore?: string[] }) → Promise<{ ok: boolean; diffs: { p…` — Consistency check: engine.skip({ seconds }) vs stepping the same span in fixed steps; compares the saved state. Leaves the world at the stepped state (use a scratch playthrough or a test). Example: `const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);`
|
|
70
|
+
- `engine.freeze(owner?: string | { owner?, kind?, ambient? }, opts?: { kind?, ambient? }) → OwnerHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame hooks and rendering continue and the UI works. So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's name, default 'game'. uniforms.uTime (wind, water, clouds) keeps moving while frozen; { ambient: true } stops it too
|
|
71
|
+
- `engine.step(seconds: number, opts?: { render?, frameEvery?, describe? }) → GameState | null` — Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render), negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; time channels and the calendar clock.now / sky time of day run at their own speeds; frame hooks run once every frameEvery fixed steps, default 2; describe: false returns null instead of building describe()). jobs ignore real time and finish every frame; results of stream's synchronous build are attached to the scene before returning. When render is true (default) one frame is rendered at the end. Returns the describe() result after advancing
|
|
72
|
+
- `engine.skip(opts: SkipOptions) → Promise<{ seconds: number; clock:…` — Skip game time forward (sleep until morning, wait an hour) without stepping every fixed step. clock.after / every, sky.at / daily / between, day:start and season:change fire in time order as if stepped (each crossing once); world records with far catch up the span in one far(rec, dt). onFixed, module fixed hooks, physics and near simulation do not run; every time view (tick, real, ambient, channels, calendar) moves as if stepped. Input is locked and gameplay frozen during the skip; emits time:skip. fade 0 (default): the time has moved when skip returns. fade > 0: fade out, jump, save, fade in; the Promise resolves after the fade in (it needs frames). session.newGame / load / quit cancel a running skip: it resolves null. Example: `await engine.skip({ to: '06:00' })`
|
|
73
|
+
- `engine.checkSkip(seconds: number, opts?: { ignore?: string[] }) → Promise<{ ok: boolean; code?: 'fr…` — Consistency check: engine.skip({ seconds }) vs stepping the same span in fixed steps; compares the saved state. Leaves the world at the stepped state (use a scratch playthrough or a test). Example: `const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);`
|
|
77
74
|
- `engine.checkSave(opts?: { ignore?: string[] }) → Promise<{ ok: boolean; diffs: { p…` — Consistency check: save -> load gives the same saved state back (nothing is written to the browser). Example: `const r = await engine.checkSave(); if (!r.ok) console.log(r.diffs);`
|
|
78
|
-
- `engine.describeText(opts?: { radius?, full?, path? }) → string` — The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, one line per module with its key counts), ending with how to expand. { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data). Example: `engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })`
|
|
79
|
-
- `engine.explain(q: { op, args?, actor? } | Record<string, any>) → { ok,
|
|
75
|
+
- `engine.describeText(opts?: { radius?, full?, path? }) → string` — The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, the game's describe.add sections, one line per module with its key counts, the engine tables such as shared / slots / owned as one count line), ending with how to expand. { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data). Example: `engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })`
|
|
76
|
+
- `engine.explain(q: { op, args?, actor? } | Record<string, any>) → { ok, code?, text, detail?, recent?, events?, … }` — Why something is the way it is. { op, args?, actor? }: text says whether it can run now, and if not the reason and the op's note on fixing it (reason first); detail has the last attempt and the events around it; recent / events are the raw last 5 attempts and event names within a step of the last one. Other keys are answered by modules (definition field explain: { key(e, value, query) { return { ok, text } } }); the quests module answers { quest: id }. Example: `engine.explain({ op: 'shop.buy', args: { shop: 'bakery', item: 'bread' } }).text // 'shop.buy {...} cannot run now: noMoney (Not enough gold)'`
|
|
80
77
|
- `engine.profile(on: boolean)` / `profile() → Record<string, number> | null` — Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns { moduleName: average milliseconds per rendered frame } and resets, or null when not on
|
|
81
|
-
- `engine.dispose()` — Destroy the engine: stop the main loop, call each module's dispose(e) in reverse install order, then reclaim listeners, timers, audio, UI and GPU memory (scene, assets cache, post-processing, renderer). After that no callbacks fire and step() returns null. Safe to call repeatedly. Don't use it for level changes; use level.track(handle)
|
|
78
|
+
- `engine.dispose(opts?: { keepContext?: boolean })` — Destroy the engine: stop the main loop, call each module's dispose(e) in reverse install order, then reclaim listeners, timers, audio, UI and GPU memory (scene, assets cache, post-processing, renderer). After that no callbacks fire and step() returns null. Safe to call repeatedly. Don't use it for level changes; use level.track(handle). The engine's own renderer gives its WebGL context back (browsers keep about 16 live ones), so that canvas cannot host a new engine; keepContext: true keeps it. A renderer passed to createEngine({ renderer }) is never released.
|
|
82
79
|
- `engine.counts() → EngineCounts` — Counts for leak hunting: they should not keep growing after repeatedly entering / leaving levels or opening / closing windows. geometries / textures come from three.js renderer.info.memory (counted only after rendering)
|
|
83
80
|
|
|
84
81
|
## engine properties (module properties are on each module page)
|
|
85
82
|
- `THREE: typeof import('three')` three.js (a game can also import { THREE } from 'threedog' directly)
|
|
86
|
-
- `
|
|
87
|
-
- `
|
|
88
|
-
- `tier: 'low' | 'high'` Device tier: 'low' (phones, integrated graphics) / 'high'
|
|
83
|
+
- `renderer: EngineRenderer` three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer)
|
|
84
|
+
- `tier: 'low' | 'high'` Device tier: 'low' (phones, integrated graphics) / 'high'. A headless page takes it from ?threedog-tier=low/high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier)
|
|
89
85
|
- `scene: import('three').Scene` three.js scene
|
|
90
|
-
- `lights: { sun, hemi }`
|
|
91
|
-
- `camera: import('three').PerspectiveCamera` three.js
|
|
86
|
+
- `lights: { sun, hemi }` Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
|
|
87
|
+
- `camera: import('three').PerspectiveCamera` three.js PerspectiveCamera (class EngineCamera, core/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which)
|
|
92
88
|
- `focus: Vector3` Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the player by default), which does not follow the camera
|
|
93
|
-
- `shadows: boolean` Whether shadows are on
|
|
94
|
-
- `shadowType: 'basic' | 'pcf' | 'vsm'` Shadow filter in use; change it with look.shadow.set({ type })
|
|
95
89
|
- `ground: Ground` Current ground
|
|
96
90
|
- `movement: Readonly<MovementProfile>` Shared parameters for whether a character can walk somewhere (set by createEngine({ movement }), read-only); same-named options of individual modules are only overrides
|
|
97
91
|
- `player: Character | null` The player (exists only after characters.createPlayer()). Its position belongs to the character's mover: other systems request movement (placeAt / move / vehicle enter), don't modify position directly
|
|
98
92
|
- `actor: string` World record id of the one the local user controls (default 'player'): interactions, trigger zones, marker distances, the world simulation center and ops (ctx.actor) use it. Set it to hand control to a vehicle or squad member
|
|
99
|
-
- `
|
|
100
|
-
- `
|
|
93
|
+
- `phase: 'constructed' | 'loading' | 'ready' | 'running' | 'disposed'` Where the engine is in its life: 'constructed' (start() not called) -> 'loading' (start() running: frame hooks only, no fixed step, so no game time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved) -> 'disposed'. engine.step() during loading runs frame hooks only
|
|
94
|
+
- `ready: boolean` phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property)
|
|
95
|
+
- `disposed: boolean` phase is 'disposed'
|
|
101
96
|
- `moduleOrder: string[]` Execution order of module hooks (module names, first -> last), for debugging "who runs before whom"
|
|
102
97
|
- `moduleStates: Record<string, 'registered' | 'initializing' | 'running' | …` Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'. A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
|
|
103
98
|
- `error: EngineError | null` Gameplay error in development / testing (module hooks, onFixed / onFrame / clock callbacks, event listeners): { where (location of the error), message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
|
|
104
|
-
- `disabledModules: Set<string>` Names of
|
|
99
|
+
- `disabledModules: Set<string>` Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft)
|
|
105
100
|
- `signal: AbortSignal` The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on dispose()
|
|
106
101
|
- `uiRoot: HTMLDivElement` UI root node: UI elements of the engine and modules hang under it (don't attach to document.body directly), the whole tree is removed on dispose()
|
|
107
|
-
- `fogFar: number` Base fog distance (meters)
|
|
108
102
|
- `modules: Map<string, ModuleDef>` Installed modules: name -> module definition
|
|
109
103
|
- `waterBodies: WaterBody[]` Standalone water bodies (lakes, ponds)
|
|
110
104
|
- `events: Events` Event bus
|
|
@@ -117,33 +111,38 @@
|
|
|
117
111
|
- `assets: Assets` Assets
|
|
118
112
|
- `loading: Loading` Observable loading: every asset load, module init / isReady and track() step as a task (phase, error, source manifest)
|
|
119
113
|
- `post: PostFX` Post-processing: named effects in slots (add / get / enable / list)
|
|
120
|
-
- `
|
|
114
|
+
- `occlusion: Occlusion` Occlusion culling of the engine's big things (hlod cells, batched groups) on both renderers. Off by default; it pays only when heavy things hide behind others (recipe 34)
|
|
121
115
|
- `ui: UIParts` UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md)
|
|
122
116
|
- `adaptive: AdaptiveState` Automatic resolution state
|
|
123
117
|
- `cpuMs: number` Main-thread CPU milliseconds of the last real-time frame: input, fixed steps, frame hooks, render submission and afterRender hooks (not GPU time, not the wait for the next frame). Only the real-time loop updates it; step() does not.
|
|
124
118
|
- `cpuPhases: { fixed, frame, render, afterRender }` cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks
|
|
125
|
-
- `cameraOverride: CameraOverride | null` The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it.
|
|
119
|
+
- `cameraOverride: CameraOverride | null` The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Read-only
|
|
126
120
|
- `runState: RunState` Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is
|
|
127
121
|
- `decoders: string` Draco/KTX2 decoder directory
|
|
128
|
-
- `clock: Clock`
|
|
122
|
+
- `clock: Clock` Calendar clock: calendar seconds now, after / every, the rate (clock-time / season timers are on engine.calendar)
|
|
123
|
+
- `stacks: import('./gameplay').Stacks` Every shared quantity by name; define your own with engine.stacks.define(name, { base })
|
|
124
|
+
- `control: Control` Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < net; a higher one pauses the lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57. Example: `const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();`
|
|
125
|
+
- `time: import('./gameplay').Time` Time channels: read seconds with time.now('real' / 'ambient' / 'calendar' / a channel such as 'world'), speeds with scale(ch, id?)
|
|
129
126
|
- `vars: Vars` Story flags and counters (autosaved)
|
|
130
127
|
- `budget: Budget` Performance budget (off by default)
|
|
128
|
+
- `plugins: { add, off, on, list }` The plugins folder: files in the game's plugins/ plugged at start by what they export (core/plugins.js); describe().slots lists them (add() off() on() list())
|
|
131
129
|
- `rays: Rays` Ray registry (what engine.raycast hits)
|
|
132
130
|
- `jobs: Jobs` Frame-spread job scheduler
|
|
133
131
|
- `commits: Commits` Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits
|
|
134
132
|
- `threads: Threads` (experimental) Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays. Results that affect gameplay go through commits
|
|
135
133
|
- `ops: Ops` One entry point for actions players and NPCs decide to do: define / run / can / list / recent, see Ops and recipes/23-ops.md
|
|
136
134
|
- `views: Views` Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md)
|
|
137
|
-
- `tick: number` Fixed-step count (the
|
|
138
|
-
- `random: Random` Seeded random numbers (
|
|
135
|
+
- `tick: number` Fixed-step count (= engine.time.tick, the one time counter: does not advance while frozen; commits due times, event history and the operation log use it). Seconds are views of it: engine.time.now('real' / 'ambient' / 'calendar' / channel)
|
|
136
|
+
- `random: Random` Seeded random numbers, an object (not a function): engine.random.next() in [0, 1), .range(a, b), .int(a, b), .pick(list), .chance(p). Use it for gameplay randomness: reproducible and saved with the game
|
|
139
137
|
- `stream: Stream` Spatial stream-in and the stream sources (where the world is loaded: terrain, colliders, models, stream entries; built-in player and camera sources, add one for a teleport destination)
|
|
140
|
-
- `batching: Batching` Automatic batching: the same static model placed many times in a cell is drawn as one InstancedMesh (createEngine({ batching }))
|
|
138
|
+
- `batching: Batching` Automatic batching: the same static model the engine placed (world records, stream builds, level files) many times in a cell is drawn as one InstancedMesh; your own meshes only with userData.batch = true (createEngine({ batching }))
|
|
141
139
|
- `startup: StartupReport | null` Startup timing report (null until start() completes)
|
|
142
|
-
- `
|
|
143
|
-
- `uniforms: EngineUniforms` This engine's shader uniforms, read by the built-in effects (wind, clouds, season, water, sky, rain). Share these objects in your own ShaderMaterial or patch instead of making your own uTime. Weather and sky write them; uTime follows engine.elapsed. Example: `new THREE.ShaderMaterial({ uniforms: { uTime: engine.uniforms.uTime }, vertexShader, fragmentShader });`
|
|
140
|
+
- `uniforms: EngineUniforms` This engine's shader uniforms, read by the built-in effects (wind, clouds, season, water, sky, rain). Share these objects in your own ShaderMaterial or patch instead of making your own uTime. Weather and sky write them; uTime is engine.time.now('ambient'). Example: `new THREE.ShaderMaterial({ uniforms: { uTime: engine.uniforms.uTime }, vertexShader, fragmentShader });`
|
|
144
141
|
- `waterLevel: number` Global water level (meters); -Infinity when there is no water
|
|
145
142
|
- `debug: DebugOverrides & { panel: DebugPanel | null }` Diagnostic overrides and view modes with an owner (override / clear / view: core, always there); panel is the F3 panel, null without the debug() module
|
|
146
|
-
- `
|
|
143
|
+
- `shadows: Shadows` Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there
|
|
144
|
+
- `view: View` The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there
|
|
145
|
+
- `terms: Terms` Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there
|
|
147
146
|
- `stateApplied: boolean` Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it: page.waitForFunction(() => window.engine?.stateApplied)
|
|
148
147
|
- `headless: boolean` Whether in headless mode (createEngine({ headless: true }))
|
|
149
148
|
- `paused: boolean` Whether paused (headless mode is paused by default, only step() advances)
|
|
@@ -151,49 +150,80 @@
|
|
|
151
150
|
- `openWindows: Set<string>` Ids of the open windows
|
|
152
151
|
- `frozen: boolean` Is anyone freezing gameplay?
|
|
153
152
|
- `describe: { add }` Call engine.describe(opts?: { radius?: number }) to get the current game state (a plain object, JSON.stringify-able); radius is how far counts as "nearby" (meters, default 30).
|
|
154
|
-
- `inspect: { scene }` What is around an actor or a spot, and what that actor can do now (each op offer checked with can, possible first, at most 8; failed ones carry
|
|
153
|
+
- `inspect: { scene, materials, perf }` What is around an actor or a spot, and what that actor can do now (each op offer checked with can, possible first, at most 8; failed ones carry code and the op's reasons note). at: a world record id (that actor), [x, z] / { x, z } (a spot, ops as the player), or nothing (the player). radius default 10 m. Example: `engine.inspect(); // { actor: 'player', at: { x, z }, near: [...], ops: [{ op: 'shop.buy', args, ok: false, code: 'noMoney', why: 'Not enough gold' }] }`
|
|
155
154
|
|
|
156
155
|
## Module definition (engine.use(myModule()))
|
|
157
156
|
- **ModuleDef** A module (the argument of engine.use). The name is the property name on the engine once installed. Per-frame hook order follows stage, then before / after within a stage, then install order.
|
|
158
157
|
- `name: string` Module name; after install, access the object returned by install through engine[name]
|
|
158
|
+
- `type: ModuleType` What the module may own (required; core/moduleTypes.js): 'world' state, records, ops (draws nothing) / 'picture' what is seen and heard (changes no game state: no ops, no world record writes) / 'actor' characters / 'rules' game logic / 'ui' panels and menus (binds no keys, no game save part) / 'net' multiplayer / 'tool' a one-shot job.
|
|
159
159
|
- `label?: string` Display name (used by the loading screen)
|
|
160
|
-
- `requires?: string[]`
|
|
160
|
+
- `requires?: string[]` Capabilities this depends on: slot names another module provides ('inventory', 'world', 'sky'), never a particular module. Missing throws with both fixes: install the engine's part of that name first, or your own module with provides: ['inventory']
|
|
161
|
+
- `provides?: (PictureSlot | (string & {}))[]` Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
|
|
161
162
|
- `optional?: string[] | Record<string, string>` Optional dependencies (modules the code uses as e.xxx?. or guards with if (e.xxx); rule R16 requires listing them all). An array only registers them; written as { moduleName: 'what is lost when missing' }, start() prints a one-time development hint when one is missing; use this form when it changes gameplay results
|
|
162
|
-
- `stage?: 'control' | '
|
|
163
|
+
- `stage?: 'control' | 'ground' | 'environment' | 'gameplay' | 'effects' | 'late' | 'audio'` Hook stages, only the run order (first -> last): 'control' timeline, camera -> 'ground' terrain, level -> 'environment' weather, sky, water -> 'gameplay' interactions, dialogue, triggers -> 'effects' particles, settings, objective markers -> 'late' (default) -> 'audio' music. Within a stage use before / after, then install order.
|
|
163
164
|
- `before?: string[]` Hooks run before these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs earlier)
|
|
164
165
|
- `after?: string[]` Hooks run after these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs later)
|
|
165
|
-
- `
|
|
166
|
-
- `critical?: boolean` The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of starting a broken game. Without it a failed init is reported by severity (presentation: disabled and the game carries on; gameplay: error tiers) and start() goes on. Example: `engine.use({ name: 'saveSlots', critical: true, async init(e) { await loadSlots(); } })`
|
|
166
|
+
- `critical?: boolean` The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of starting a broken game. Without it a failed init is reported by severity (type picture / ui: disabled and the game carries on; other types: error tiers) and start() goes on. Example: `engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })`
|
|
167
167
|
- `explain?: Record<string, (e: Engine, value: any, query: Record<string…` Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) }
|
|
168
|
-
- `install(e: Engine) → Api` — Install: create and return the object the game uses (engine.name)
|
|
169
|
-
- `init(e: Engine) → void | Promise<void>` — Called at startup (download things, wait for assets); may be async
|
|
168
|
+
- `install(e: Engine, ctx: ModuleCtx) → Api` — Install: create and return the object the game uses (engine.name). Register listeners / timers through ctx.track so they leave with the module (a use() batch that rolls back, a failed init, engine.dispose). Example: `install(e, ctx) { ctx.track(e.events.on('item:add', onAdd)); return api; }`
|
|
169
|
+
- `init(e: Engine, ctx: ModuleCtx) → void | Promise<void>` — Called at startup (download things, wait for assets); may be async. ctx is the same as install's
|
|
170
170
|
- `isReady(e: Engine) → boolean` — The loading screen waits until this returns true before disappearing (the hook is called isReady; in the engine ready is always a boolean property)
|
|
171
171
|
- `afterLoad(e: Engine) → void | Promise<void>` — After a save loaded: rebuild what the loaded state needs nearby; gameplay waits frozen until the returned Promise resolves
|
|
172
172
|
- `fixed(dt: number, e: Engine)` — Fixed step (60 times per second); dt is in seconds
|
|
173
173
|
- `frame(dt: number, e: Engine)` — Once per frame; dt is in seconds
|
|
174
174
|
- `afterRender(dt: number, e: Engine)` — After rendering
|
|
175
|
-
- `skip(dt: number, e: Engine, done: boolean)` — engine.skip moved time without stepping: advance your own time by dt fixed seconds (
|
|
175
|
+
- `skip(dt: number, e: Engine, done: boolean)` — engine.skip moved time without stepping: advance your own time by dt fixed seconds (calendar seconds = dt x clock.speed), no per-step work. Called once per skip segment (segments end at timers and calendar clock marks); done is true on the last one: do expensive catch-up only then. Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
|
|
176
176
|
- `describe(e: Engine, ctx: DescribeContext) → any` — Optional: add state to engine.describe(). The (JSON-able) return value goes into the result keyed by the module name; nothing is added if it returns nothing. It may also fill in the standard fields of ctx.out, or use ctx.near() to report "nearby things"
|
|
177
177
|
- `counts(e: Engine) → number | Record<string, number>` — Optional: leak-hunting counts for engine.counts(), put there under the module name (a number or an object of numbers that should not keep growing)
|
|
178
|
-
- `applyState(e: Engine, params: StateParams) → void | Promise<void>` — Optional: handle the keys of engine.applyState that this module owns (e.g.
|
|
178
|
+
- `applyState(e: Engine, params: StateParams) → void | PositionLike | Promise<void>` — Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position
|
|
179
179
|
- `dispose(e: Engine)` — Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers, Audio nodes you connected yourself. Events, onFixed / onFrame, clock timers, jobs, stream, ray registrations and GPU memory in the scene are reclaimed by the core; DOM listeners attached to engine.signal and UI attached to engine.uiRoot are cleaned up automatically too
|
|
180
180
|
|
|
181
|
+
## createEngine({ ui })
|
|
182
|
+
- **UIOptions** createEngine({ ui }): the look of the default parts (theme, css, fonts, templates); every other key is a part name
|
|
183
|
+
- `theme?: UITheme` CSS values of every default part
|
|
184
|
+
- `css?: string` Extra CSS, placed after every default (overrides .threedog-* classes)
|
|
185
|
+
- `fonts?: string[]` Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in theme.font: '"pixel", system-ui'
|
|
186
|
+
- `templates?: Record<string, UITemplate>` Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar…
|
|
187
|
+
- **UITheme** The CSS values of every default UI part: each key becomes the variable --threedog-<key> on engine.uiRoot
|
|
188
|
+
- `bg?: string` Background color
|
|
189
|
+
- `fg?: string` Text color
|
|
190
|
+
- `muted?: string` Secondary text color
|
|
191
|
+
- `accent?: string` Accent color
|
|
192
|
+
- `good?: string` Color for good news such as "done"
|
|
193
|
+
- `line?: string` Divider color
|
|
194
|
+
- `font?: string` Font (CSS font-family)
|
|
195
|
+
- `radius?: string` Corner radius of windows and the dialogue box (CSS, e.g. '12px')
|
|
196
|
+
- `radiusSmall?: string` Corner radius of small things: buttons, prompts, toasts, bubbles, HUD counters (CSS, default '8px')
|
|
197
|
+
- `loadingBg?: string` Loading screen background
|
|
198
|
+
- `shadow?: string` Window shadow (CSS)
|
|
199
|
+
- `shadowSmall?: string` Shadow of small things: speech bubbles, objective marker labels (CSS)
|
|
200
|
+
- `fadeBg?: string` Fade color for scene transitions (CSS), default '#000'
|
|
201
|
+
- `hudBg?: string` Background / text / accent of objective markers, counters and progress bars (CSS); default: follow bg, fg and accent
|
|
202
|
+
- `hudFg?: string`
|
|
203
|
+
- `hudAccent?: string`
|
|
204
|
+
|
|
181
205
|
## Data structures
|
|
182
206
|
- **Handle** Handle: returned by every "add / register / listen / attach" API (events.on, onFrame, clock.after, collision.addBox, interactions.add, rays.addStatic…), call remove() to undo that registration (removes the listener, collider, timer…; safe to call repeatedly). Some handles carry extra fields (such as setTarget on hud.marker)
|
|
183
207
|
- `remove()`
|
|
184
208
|
- **StateParams** Scenario parameters (can also go in the URL: ?time=18:30&weather=rain&pos=40,-20&cutscene=skip&state=name)
|
|
185
209
|
- `state?: string` A group of parameters named with defineState
|
|
186
210
|
- `time?: string | number` Time of day: 'HH:MM' or 0–1
|
|
187
|
-
- `season?: string` Season name from
|
|
211
|
+
- `season?: string` Season name from calendar({ seasons }): jumps calendar.day to that season's first day (time of day kept)
|
|
188
212
|
- `weather?: string` Weather name
|
|
189
213
|
- `pos?: string | PositionLike` Player position: 'x,z' or a position (sets the focus when there is no player)
|
|
214
|
+
- `at?: string` Start at a named place (content places, level markers): past the title like play, then the player stands there with the game's camera on it
|
|
190
215
|
- `save?: string` Which save slot to load
|
|
191
|
-
- `wait?: number` How many seconds to advance (fixed-step seconds,
|
|
216
|
+
- `wait?: number` How many seconds to advance (real seconds: fixed-step seconds, no scale)
|
|
192
217
|
- `cutscene?: 'skip' | 'keep'` Opening cutscene: 'skip' skips it / 'keep' plays it as usual
|
|
193
|
-
-
|
|
218
|
+
- `view?: string` A view declared with engine.views to show after engine:ready (?view=name); ignored when the game declared no views
|
|
219
|
+
- `play?: string | boolean` Present (?play, any value): leave the title screen the way its Start does (engine.session.newGame(), the title part closes; flow leaves its start state) before wait; nothing when no title is up
|
|
220
|
+
- `fresh?: string | boolean` Delete every save of this page first (no Continue on the title); on a running page also end the run and go back to the title. ?fresh in the URL
|
|
221
|
+
- **StartupReport** Startup timing (milliseconds): totalMs page open to playable, startMs start() to playable, preloadMs preloading, streamMs the nearby builds required by stream registrations finished, compileMs shader compilation before the first frame, modules is the init / ready time of each module. With a budget on and startupMs (open to playable) / moduleMs (a single module) given, the slowest module is reported in the console when exceeded. firstFrameMs: page open to the end of the first frame drawn after the loading screen (null until that frame, and headless); phases add up to it: script (page open until createEngine), construct (createEngine), setup (game code until start()), init (saves, renderer, module init), preload, world (scenario parameters, nearby builds), compile (shaders + hidden warm-up frame), draw (ready until the first frame's draw calls were submitted)
|
|
194
222
|
- `totalMs: number`
|
|
195
223
|
- `startMs: number`
|
|
196
224
|
- `preloadMs: number`
|
|
197
225
|
- `streamMs: number | null`
|
|
198
226
|
- `compileMs: number`
|
|
199
227
|
- `modules: Record<string, { init?: number; ready?: number }>`
|
|
228
|
+
- `firstFrameMs: number | null`
|
|
229
|
+
- `phases: { script, construct, setup, init, preload, world, … }`
|
package/docs/api/events.md
CHANGED
|
@@ -26,24 +26,29 @@
|
|
|
26
26
|
- `settings:change` [values: Record<string, any>] A value in the settings menu changed (the argument is all setting values)
|
|
27
27
|
- `water:add` [body: WaterBody] A water body was added
|
|
28
28
|
- `water:remove` [body: WaterBody] A water body was removed
|
|
29
|
-
- `day:start` [day: number] A new day (the argument is the day number, starting at 1; needs the
|
|
29
|
+
- `day:start` [day: number] A new day (the argument is the day number, starting at 1; needs the calendar module)
|
|
30
30
|
- `season:change` [season: string] Season changed (the argument is the season name, e.g. 'autumn')
|
|
31
|
+
- `mod:end` [{ target: string; owner: string; id: string | null }] A mod with `for` ran out (engine.mod(target, { owner, for })): target is the quantity's name, id the record for per-record ones
|
|
31
32
|
- `time:skip` [{ seconds: number }] engine.skip jumped game time forward (seconds = game seconds skipped); timers and world catch-up already ran
|
|
32
33
|
- `weather:lightning` [] Lightning strike (weather module)
|
|
33
34
|
- `weather:change` [change: { from: string; to: string }] engine.weather.set switched to another weather name (once, when the blend starts; setting the same name again does not fire)
|
|
34
35
|
- `camera:shot` [CameraShotEvent] The fixed-shot camera switched shots
|
|
35
36
|
- `camera:change` [{ kind: string; previous: string }] engine.setCamera switched the camera kind; settings that belong to the camera (sensitivity, invert Y, field of view) are re-applied on it
|
|
36
|
-
- `character:jump` [{ character: Character }] A character jumped
|
|
37
|
+
- `character:jump` [{ character: Character; air: boolean; index: number }] A character jumped
|
|
38
|
+
- `character:launch` [{ character: Character; speed: number; owner: string }]
|
|
39
|
+
- `character:fall` [{ character: Character; safe: Vector3 | null; preventDefault(): void…
|
|
37
40
|
- `character:model` [{ character: Character; model: Object3D }] A character's model named by asset finished loading and replaced the placeholder body (same root; anim is now set)
|
|
38
41
|
- `character:land` [{ character: Character; impact: number }] A character landed; impact is the landing speed (m/s), the larger the harder the fall
|
|
42
|
+
- `character:water` [{ character: Character; in: boolean; mode: string; depth: number }] A character went into or out of deep water (water option): in true on entering, mode what the water option did there ('swim' / 'block' / 'wade', or what the function returned)
|
|
39
43
|
- `dialogue:start` [speaker: string] Dialogue started; the argument is the dialogue script name
|
|
40
44
|
- `dialogue:line` [{ script: string; node: string; speaker: string; text: string; data:… A dialogue line started (after its do ran): data is the node's own fields (portrait, voice...), {} when none. Use it for voice, portraits, camera shots without replacing the UI part
|
|
45
|
+
- `dialogue:bubble` [{ speaker: string; text: string; at: any }] A bubble line started showing (the bubble channel: lines over their speakers while play goes on); at is what it is attached to, null = a screen line
|
|
41
46
|
- `dialogue:end` [speaker: string] Dialogue ended; the argument is the dialogue script name
|
|
42
|
-
- `item:add` [ItemEvent] An item was added to
|
|
43
|
-
- `item:remove` [ItemEvent] An item was removed from
|
|
44
|
-
- `
|
|
45
|
-
- `
|
|
46
|
-
- `
|
|
47
|
+
- `item:add` [ItemEvent] An item was added to a container (any bag or chest: container names it, actor says who did it)
|
|
48
|
+
- `item:remove` [ItemEvent] An item was removed from a container (container names it, actor says who did it)
|
|
49
|
+
- `pickup:take` [PickupEvent] A pickup was taken off the ground (pickup = world id, item = its item id or null for a give function, actor = who took it)
|
|
50
|
+
- `interaction:hold` [{ id: string; action: string; seconds: number }] A hold interaction started (the key went down on it); seconds is its hold
|
|
51
|
+
- `interaction:interrupt` [{ id: string; action: string; reason: string; progress: number }] A hold interaction stopped before it completed: 'released' / 'tooFar' / 'disabled' / 'removed' / 'inputLocked'
|
|
47
52
|
- `item:use` [ItemUseEvent] An item was used through the inventory.use op (after use ran)
|
|
48
53
|
- `quest:start` [{ id: string }] A quest started
|
|
49
54
|
- `quest:step` [{ id: string; step: number }] A quest moved to the next step; step is the new step index (starting at 0)
|
|
@@ -57,17 +62,17 @@
|
|
|
57
62
|
- `level:loaded` [LevelLoadedEvent] Level finished loading
|
|
58
63
|
- `timeline:start` [{ id: number }] A cutscene started
|
|
59
64
|
- `timeline:end` [{ id: number; skipped: boolean }] A cutscene ended; skipped tells whether it was skipped
|
|
60
|
-
- `
|
|
61
|
-
- `entity:remove` [Entity] An entity was removed
|
|
62
|
-
- `entity:state` [EntityStateEvent] A state value of an entity changed
|
|
63
|
-
- `entity:stage` [EntityStageEvent] An entity entered a new growth stage
|
|
65
|
+
- `template:stage` [TemplateStageEvent] A content template instance entered a new stage by growing (templates with stages)
|
|
64
66
|
- `ground:change` [{ x0: number; z0: number; x1: number; z1: number }] The ground's shape or type changed in this world-space box (engine.terrain.edit): cached ground samples (path rasters) inside it are stale
|
|
67
|
+
- `rigid:rebuilt` [{ world: any; player: any; bodies: Record<string, any> }] rigid: newGame / a load rebuilt the physics world (a fresh page for physics) and the engine's bodies are back (entry.body is the rebuilt Rapier body; bodies maps the ids given to addBox / addBall / addHull / addWheeled). The old world's joints were freed with it: re-create the game's joints here (recipes/11-vehicles.md, Joints). Not emitted while a vehicle exists (the world is kept then, joints included)
|
|
65
68
|
- `terrain:void` [{ who: any; position: { x: number; y: number; z: number } }] terrain({ shape }): the player or a moving rigid body dropped below engine.terrain.voidY (once per fall). The engine does not respawn: the game decides
|
|
69
|
+
- `terrain:chunkFailed` [{ cx: number; cz: number; error: any }] A terrain chunk job failed every try (usually the game's height / groundType / placement rule throws there): the chunk stays empty and the error is reported. engine.terrain.retry() sends failed chunks again
|
|
66
70
|
- `vegetation:remove` [VegetationRemoveEvent] A vegetation instance was chopped / removed
|
|
67
71
|
- `vegetation:restore` [VegetationRemoveEvent] A vegetation instance was restored
|
|
68
72
|
- `music:change` [MusicChangeEvent] Background music changed track (null means silence)
|
|
69
73
|
- `music:stinger` [{ name: string }] A stinger was played
|
|
70
74
|
- `state:applied` [StateParams] Scenario parameters were applied (URL parameters or engine.applyState)
|
|
75
|
+
- `state:placed` [{ x: number; z: number }] A scenario (at, pos) moved the player: a camera or view that eases jumps there
|
|
71
76
|
- `anim:end` [{ root: Object3D; state: string }] A one-shot action of the animation state machine finished
|
|
72
77
|
- `world:add` [{ id: string; kind: string }] A record was added to world
|
|
73
78
|
- `world:change` [{ id: string; kind: string; keys: string[] }] world.set changed fields (keys lists which)
|
|
@@ -80,13 +85,14 @@
|
|
|
80
85
|
- `net:sync` [{ tick: number; full: boolean }] Client (net): host state applied (full: a whole snapshot, else a diff); redraw UI from state here
|
|
81
86
|
- `net:result` [{ seq: number; name: string; ok: boolean; code: string | null; value… Client (net): the host's answer to an op request (seq from ops.run's return value; tick is the host's), sent after the state it caused
|
|
82
87
|
- `engine:error` [EngineError] A gameplay error in development / testing; gameplay is frozen (error severity levels, see engine.error)
|
|
83
|
-
- `module:disabled` [{ name: string; message: string }] A
|
|
84
|
-
- `vehicle:enter` [{ character: Character; vehicle:
|
|
85
|
-
- `vehicle:exit` [{ character: Character; vehicle:
|
|
88
|
+
- `module:disabled` [{ name: string; message: string }] A picture or ui module errored and was disabled (the game continues)
|
|
89
|
+
- `vehicle:enter` [{ character: Character; vehicle: Rideable }] A character boarded a vehicle
|
|
90
|
+
- `vehicle:exit` [{ character: Character; vehicle: Rideable }] A character exited a vehicle
|
|
86
91
|
- `flow:change` [{ from: string; to: string }] Game flow state changed
|
|
87
92
|
- `flow:transition` [{ phase: 'start' | 'end' }] Scene transition: phase 'start' begins fading to black, 'end' finishes fading back in
|
|
88
93
|
- `session:end` [] A playthrough ends (engine.session.newGame / load / quit), before the reset
|
|
89
94
|
- `session:start` [{ kind: 'new' | 'load'; slot?: string }] A playthrough started from a clean slate: kind 'new' (newGame) or 'load' (session.load, with the slot)
|
|
95
|
+
- `session:failed` [{ kind: 'new' | 'load'; slot?: string }] newGame / session.load failed (a save part's load() threw) and the game was rolled back: the old playthrough goes on, no session:start
|
|
90
96
|
- `page:blur` [{ focused: boolean; visible: boolean }] The page went away: the window lost focus or the tab was hidden (engine.page)
|
|
91
97
|
- `page:focus` [{ focused: boolean; visible: boolean }] The page came back: focused and visible again
|
|
92
98
|
- `page:pointerlock` [{ locked: boolean }] The mouse lock on the canvas started or ended (Esc, alt-tab); cameras with pointerLock lock again on the next click
|
package/docs/api/grids.md
CHANGED
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Methods and properties
|
|
7
|
-
- `grids.add(name: string, opts?: { cell?, origin?, size?, zone?, flat?,
|
|
7
|
+
- `grids.add(name: string, opts?: { cell?, origin?, size?, zone?, flat?, y?, … }) → Grid` — Create a grid. cell: edge length (m, default 1); origin: world [x, z] of the min corner of cell [0, 0]; size: [cells wide, cells deep] (omit = unbounded); zone: level name (tiles only show there); flat: max height difference under a footprint (m, default 0.5); y: height of level 0 (m; default the ground under each cell), levelHeight: meters per level (default 3; level n is at y + n * levelHeight); mapping: { toCell(x, z) => [i, j], center([i, j]) => [x, z] } replaces the square cell <-> world math (one place: toCell, toWorld, tiles, flatness); layers: authored cells { zone: [[i, j, { buildable: true }], ...] } (content/grids.js): the baseline a save diffs against, so a save keeps only changed cells. Example: `const room = engine.grids.add('room', { cell: 0.5, origin: [-3, -3], size: [12, 12], zone: 'house' })`
|
|
8
8
|
- `grids.get(name: string) → Grid | null` — A grid by name, or null when there is none
|
|
9
9
|
- `grids.list() → Grid[]` — All grids (a new array)
|
|
10
|
-
- `grids.define(name: string, rule: import("./Grid.js").GridRule)` — Register what can be placed and its rules. size [w, d] in cells (default [1, 1]); kind of the world record (default the item name); ground: allowed engine.groundType values; layer: { layerName: field } that must be truthy on every cell (reason 'not' + Field, e.g.
|
|
11
|
-
- `grids.preview(opts: { grid, item, from?, rotate?,
|
|
10
|
+
- `grids.define(name: string, rule: import("./Grid.js").GridRule)` — Register what can be placed and its rules. size [w, d] in cells (default [1, 1]); kind of the world record (default the item name); occupy: the occupancy layer it takes (default 'main'): things in different layers share a cell ('floor' tile, 'main' table, 'wall' lamp), two in one layer do not; ground: allowed engine.groundType values; layer: { layerName: field } that must be truthy on every cell (reason 'not' + Field, e.g. notBuildable); flat: max height difference (overrides the grid's); fields: copied into the record; can(e, { grid, cell, rotation, cells, level }): your own rule. Example: `engine.grids.define('tower', { size: [2, 2], layer: { zone: 'buildable' }, fields: { range: 6 } }) // tower defense`
|
|
11
|
+
- `grids.preview(opts: { grid, item, from?, rotate?, rotation?, draw? }) → { cell, rotation, ok, code, rotate, place, … }` — Show where an item would go: the target cell under the pointer ('pointer', default), in front of the player ('front') or from your function, turned by the input action rotate (default name 'rotate'; the game binds it, e.g. presets.bindings.gridRotate; the engine binds no key itself), light when can() passes, dark otherwise (neutral tool colors; grids({ ok, bad }) override them). draw: false = no visual; (engine) => ({ update(view), hide(), dispose() }) = your own; pv.material is the default box's three.js material. place() runs grid.place with what is shown. Example: `engine.input.bind({ place: ['Mouse0'], ...presets.bindings.gridRotate }); // the game's own bindings const pv = engine.grids.preview({ grid: 'field', item: 'tower' }); engine.onFrame(() => { if (engine.input.pressed('place')) { const r = pv.place(); if (!r.ok) toast(engine, engine.t('grid.' + r.code)); } });`
|
|
12
|
+
- Properties:
|
|
13
|
+
- `ok: any` Preview color where it can be placed, read when a preview is made
|
|
14
|
+
- `bad: any` Preview color where it cannot be placed, read when a preview is made
|
|
15
|
+
- `previewOpacity: number` Opacity of the preview box, read when a preview is made
|
|
16
|
+
- `previewHeight: number` Height of the preview box (meters), read when a preview is made
|
|
17
|
+
- `tiles: Record<string, Record<string, any>>` Tile colors by layer name, { layer: { field: color } } (first truthy field of a cell wins), read when a layer is made
|
|
18
|
+
- `tileLift: number` Height of tiles above the ground (meters), read when a layer is made
|
package/docs/api/ground.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
- `ground.has(x: number, z: number) → boolean` — Is there ground at (x, z). Always true except off the outline of terrain({ shape }), where height is -Infinity and slope 0. Example: `if (engine.ground.has(x, z)) engine.snapToGround(chest);`
|
|
7
7
|
- `ground.voidY() → number` — Height below which something has fallen out of the world (terrain:void): engine.terrain.voidY with terrain({ shape }), else -Infinity
|
|
8
8
|
- `ground.forEachCollider(x: number, z: number, range: number, fn: (cx, cz, r) => void)` — Optional: iterate the circular colliders (tree trunks etc.) within range meters of (x, z)
|
|
9
|
-
- `ground.viewRange() → number` — Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else
|
|
9
|
+
- `ground.viewRange() → number` — Optional: how far (meters) the ground is shown around a stream source now; stream entries build within it by default (else engine.uniforms.uViewDistance)
|
|
10
10
|
- `ground.chunkCollision(cx: number, cz: number) → any` — Optional: collision data of a chunk (used by the physics module)
|
|
11
11
|
- `ground.staticTrimeshes() → { positions, indices }[]` — Optional: static triangle mesh (the level module provides it for physics)
|
|
12
12
|
- `ground.staticVersion() → number` — Optional: version number of the static mesh; rebuild when it changes
|
package/docs/api/hud.md
CHANGED
|
@@ -7,8 +7,10 @@ Objective markers, counters, progress bars (hud() module)
|
|
|
7
7
|
|
|
8
8
|
## Methods and properties
|
|
9
9
|
- `hud.marker(target: HudTarget, opts?: HudMarkerOptions) → HudMarker` — Add an objective marker: target is an object, position or place name
|
|
10
|
-
- `hud.counter(id: string, opts: { label?, icon?, value?, max? })` — Counter (calling again with the same id = update; calling every frame is fine)
|
|
11
|
-
- `hud.
|
|
10
|
+
- `hud.counter(id: string, opts: { label?, icon?, value?, max?, anchor? })` — Counter or text status (calling again with the same id = update; calling every frame is fine): counter('fish', { label: '鱼', value: 2, max: 5 }), counter('clock', { value: '08:30' }); no value = the label alone
|
|
11
|
+
- `hud.add(id: string, n?: number) → number` — Add n (default 1) to a number counter, return the new value; one not declared yet starts at 0 with its id as the label
|
|
12
|
+
- `hud.value(id: string) → number | string | undefined` — Current value of a counter or bar (number or text), undefined when there is none; reads what interactions.add({ counter }) has added up
|
|
13
|
+
- `hud.bar(id: string, opts: { value, max?, label?, anchor? })` — Progress bar (calling again with the same id = update; calling every frame is fine, the DOM is untouched when the value is unchanged), value/max 0–max
|
|
12
14
|
- `hud.remove(id: string)` — Delete a counter or progress bar
|
|
13
15
|
- Properties:
|
|
14
16
|
- `markers: HudMarker[]` All markers
|
|
@@ -29,3 +31,4 @@ Objective markers, counters, progress bars (hud() module)
|
|
|
29
31
|
- `set(opts: HudMarkerOptions)` — Change parameters
|
|
30
32
|
- `setTarget(target: HudTarget)` — Change the target (the marker itself is not rebuilt)
|
|
31
33
|
- `remove()` — Delete
|
|
34
|
+
- **HudAnchor** = `'top-left' | 'top' | 'top-right' | 'left' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right'` — Screen corner / edge a counter or bar column sits at (default 'top-left'); each anchor stacks its own column
|
package/docs/api/i18n.md
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
- `i18n.has(key: string) → boolean` — Whether the key exists
|
|
6
6
|
- `i18n.t(key: string, params?: Record<string, any>) → string` — Fetch text; params replace {name}, {key:action} shows the key label. Example: `engine.i18n.t('shop.buy', { name: '鱼' });`
|
|
7
7
|
- Properties:
|
|
8
|
-
- `locale: any` Current language, e.g. 'zh-CN'
|
|
9
8
|
- `fallback: string` Language used when a key is missing in the current one (default 'en')
|
|
9
|
+
- `locale: any` Current language, e.g. 'zh-CN' ('zh' and 'zh-Hans' resolve to it, 'en-US' to 'en')
|
|
10
10
|
- `languages: string[]` All available languages
|