threedog 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +196 -1
- package/README.md +6 -9
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +98 -54
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
- package/core/{assetReport.js → assets/assetReport.js} +6 -12
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +26 -23
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +10 -10
- package/core/{Random.js → base/Random.js} +5 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +98 -110
- package/core/{errorHints.js → base/errorHints.js} +5 -9
- package/core/{errors.js → base/errors.js} +6 -6
- package/core/{events.generated.js → base/events.generated.js} +1 -0
- package/core/{math.js → base/math.js} +15 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +28 -7
- package/core/{Engine.js → engine/Engine.js} +80 -77
- package/core/{Loading.js → engine/Loading.js} +4 -2
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
- package/core/{lifecycle.js → engine/lifecycle.js} +14 -12
- package/core/{loop.js → engine/loop.js} +68 -47
- package/core/{moduleSlots.js → engine/moduleSlots.js} +6 -6
- package/core/{moduleTypes.js → engine/moduleTypes.js} +13 -14
- package/core/{modules.js → engine/modules.js} +14 -11
- package/core/{page.js → engine/page.js} +36 -23
- package/core/{plugins.js → engine/plugins.js} +6 -9
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +26 -24
- package/core/{Input.js → input/Input.js} +30 -22
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/{inputPad.js → input/inputPad.js} +1 -1
- package/core/{inputPointer.js → input/inputPointer.js} +8 -2
- package/core/{inputTouch.js → input/inputTouch.js} +1 -1
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +30 -16
- package/core/{Describe.js → inspect/Describe.js} +26 -22
- package/core/{Inspect.js → inspect/Inspect.js} +9 -7
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
- package/core/{UrlState.js → inspect/UrlState.js} +52 -20
- package/core/{catalog.js → inspect/catalog.js} +3 -3
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +4 -4
- package/core/{describeRender.js → inspect/describeRender.js} +21 -20
- package/core/{describeText.js → inspect/describeText.js} +11 -6
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +15 -16
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/{Ops.js → ops/Ops.js} +16 -11
- package/core/{control.js → ops/control.js} +13 -12
- package/core/ops/holds.js +139 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
- package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +7 -4
- package/core/{owned.js → ops/owned.js} +14 -17
- package/core/{sharedPoint.js → ops/sharedPoint.js} +8 -8
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +12 -14
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
- package/core/{Saves.js → saves/Saves.js} +58 -36
- package/core/{saveApply.js → saves/saveApply.js} +13 -9
- package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
- package/core/{saveValues.js → saves/saveValues.js} +20 -3
- package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
- package/core/{session.js → saves/session.js} +31 -17
- package/core/{Rays.js → scene/Rays.js} +23 -25
- package/core/{Views.js → scene/Views.js} +14 -6
- package/core/{adaptive.js → scene/adaptive.js} +15 -8
- package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
- package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
- package/core/{gameLights.js → scene/gameLights.js} +17 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +4 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/{ground.js → scene/ground.js} +9 -9
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/{sceneDelta.js → scene/sceneDelta.js} +2 -2
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -13
- package/core/scene/stepPoses.js +55 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +6 -5
- package/core/{thingOps.js → scene/thingOps.js} +4 -3
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{view.js → scene/view.js} +17 -16
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +60 -30
- package/core/{batchGroups.js → stream/batchGroups.js} +10 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +2 -2
- package/core/{streamSources.js → stream/streamSources.js} +12 -7
- package/core/{Commits.js → threads/Commits.js} +6 -5
- package/core/{Jobs.js → threads/Jobs.js} +12 -10
- package/core/{Threads.js → threads/Threads.js} +16 -16
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +17 -10
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +18 -17
- package/core/{time.js → time/time.js} +18 -12
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +22 -19
- package/docs/API.md +24 -23
- package/docs/CODEMAP.md +76 -183
- package/docs/COMMANDS.md +66 -58
- package/docs/CONVENTIONS.md +54 -14
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +78 -29
- package/docs/api/assets.md +12 -13
- package/docs/api/audio.md +6 -5
- package/docs/api/budget.md +4 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +29 -29
- package/docs/api/characters.md +23 -18
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +45 -43
- package/docs/api/events.md +3 -2
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +7 -7
- package/docs/api/interactions.md +4 -4
- package/docs/api/inventory.md +9 -9
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -7
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +2 -2
- package/docs/api/post.md +20 -3
- package/docs/api/quests.md +3 -3
- package/docs/api/rays.md +5 -7
- package/docs/api/rigid.md +27 -18
- package/docs/api/saves.md +8 -7
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +7 -8
- package/docs/api/terrainDraw.md +1 -1
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +25 -22
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +1 -1
- package/docs/api/water.md +1 -1
- package/docs/api/weather.md +9 -9
- package/docs/api/weatherDraw.md +3 -3
- package/docs/api/world.md +5 -5
- package/docs/recipes/01-new-game.md +25 -40
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +27 -43
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +29 -39
- package/docs/recipes/06-clock-events.md +27 -18
- package/docs/recipes/07-flow-scenes-pause.md +12 -17
- package/docs/recipes/08-weather-sky.md +88 -34
- package/docs/recipes/09-materials-lights-models.md +22 -36
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +30 -22
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +39 -17
- package/docs/recipes/14-custom-module.md +14 -13
- package/docs/recipes/15-perf.md +49 -26
- package/docs/recipes/16-dev-bridge.md +32 -52
- package/docs/recipes/18-world.md +36 -23
- package/docs/recipes/19-shooting-picking.md +4 -2
- package/docs/recipes/20-content-actions-save.md +30 -35
- package/docs/recipes/21-camera.md +33 -5
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +10 -10
- package/docs/recipes/26-ui-parts.md +22 -12
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +117 -21
- package/docs/recipes/29-grid.md +2 -2
- package/docs/recipes/30-templates.md +55 -19
- package/docs/recipes/31-audio.md +5 -5
- package/docs/recipes/32-action-game.md +15 -6
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +67 -19
- package/docs/recipes/35-picture-from-reference.md +10 -17
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +7 -11
- package/docs/recipes/43-shader-patches-surfaces.md +20 -41
- package/docs/recipes/44-water-weather-hooks.md +48 -43
- package/docs/recipes/45-cascaded-shadows.md +39 -17
- package/docs/recipes/46-blender-art-route.md +7 -8
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/52-around-the-picture.md +54 -98
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +12 -16
- package/docs/recipes/56-webgpu-tsl.md +16 -14
- package/docs/recipes/57-control.md +9 -2
- package/docs/recipes/58-input.md +2 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +29 -24
- package/docs/recipes/62-picture-code.md +49 -17
- package/docs/recipes/63-third-person-start.md +17 -4
- package/docs/recipes/64-particles.md +1 -1
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +2 -2
- package/examples/{sheepisland → perf-island}/.threedog/content-index.json +1 -1
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +12 -11
- package/examples/{sheepisland → perf-island}/assets.js +1 -1
- package/examples/{sheepisland → perf-island}/main.js +8 -8
- package/examples/{sheepisland → perf-island}/models.js +1 -1
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/GAMEMAP.md +1 -0
- package/examples/rc2d/GAMEMAP.md +3 -2
- package/examples/rc2d/main.js +1 -3
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +3 -2
- package/examples/techniques/contact-shadows/contactShadows.js +1 -1
- package/examples/techniques/contact-shadows/main.js +1 -1
- package/examples/techniques/interior-light/main.js +1 -1
- package/examples/techniques/modular-building/README.md +7 -6
- package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +1 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +4 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +8 -7
- package/index.js +31 -31
- package/llms.txt +9 -13
- package/modules/ambience/Ambience.js +11 -8
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +13 -13
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +2 -2
- package/modules/camera/FixedCamera.js +14 -15
- package/modules/camera/FollowCamera.js +4 -4
- package/modules/camera/RtsCamera.js +11 -11
- package/modules/camera/common.js +48 -24
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +33 -30
- package/modules/characters/NPC.js +27 -19
- package/modules/characters/assetModel.js +14 -10
- package/modules/characters/astar.js +7 -5
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +168 -214
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +16 -14
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +8 -8
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +23 -17
- package/modules/characters/npcView.js +6 -5
- package/modules/characters/pathAsync.js +12 -10
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +108 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +26 -20
- package/modules/collision/contract.js +15 -0
- package/modules/content/explain.js +1 -2
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +2 -2
- package/modules/content/index.js +61 -99
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +10 -7
- package/modules/content/packs.js +3 -3
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +35 -0
- package/modules/content/props.js +17 -14
- package/modules/content/rules.js +25 -21
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +20 -20
- package/modules/content/words.js +34 -0
- package/modules/debug/DebugPanel.js +10 -43
- package/modules/flow/contract.js +1 -1
- package/modules/flow/index.js +11 -7
- package/modules/gameplay/Container.js +12 -11
- package/modules/gameplay/Containers.js +14 -5
- package/modules/gameplay/Dialogue.js +13 -11
- package/modules/gameplay/Interactions.js +37 -24
- package/modules/gameplay/Inventory.js +8 -9
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +3 -4
- package/modules/gameplay/inventoryOps.js +0 -1
- package/modules/gameplay/pickups.js +22 -23
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +4 -4
- package/modules/grid/index.js +7 -8
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +37 -55
- package/modules/hud/index.js +17 -11
- package/modules/hud/parts.js +4 -4
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +47 -152
- package/modules/level/load.js +79 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +6 -7
- package/modules/lights/index.js +28 -181
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +30 -26
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +14 -0
- package/modules/nav/index.js +11 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +5 -4
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +11 -8
- package/modules/particles/effect.js +7 -5
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +15 -17
- package/modules/rigid/RigidBodies.js +66 -43
- package/modules/rigid/Vehicles.js +2 -3
- package/modules/rigid/ragdoll.js +287 -0
- package/modules/rigid/ragdollBones.js +159 -0
- package/modules/rigid/sync.js +6 -6
- package/modules/settings/Settings.js +108 -39
- package/modules/settings/apply.js +6 -6
- package/modules/settings/sections.js +16 -14
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +29 -22
- package/modules/sky/clouds.js +7 -7
- package/modules/sky/dome.js +33 -20
- package/modules/sky/domeLayers.js +9 -9
- package/modules/sky/environment.js +6 -6
- package/modules/sky/frame.js +19 -10
- package/modules/sky/season.js +7 -1
- package/modules/sky/shader.js +24 -25
- package/modules/sky/skyModule.js +14 -27
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +346 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +70 -52
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +14 -11
- package/modules/terrain/index.js +28 -34
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +17 -12
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +27 -19
- package/modules/timeline/Tween.js +6 -6
- package/modules/timeline/shots.js +5 -7
- package/modules/triggers/index.js +9 -9
- package/modules/vegetation/Vegetation.js +30 -23
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +23 -18
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +8 -6
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +16 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +41 -30
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +22 -18
- package/modules/world/World.js +8 -8
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -12
- package/modules/world/persist.js +73 -25
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +28 -8
- package/modules/world/sim.js +4 -4
- package/modules/world/state.js +12 -5
- package/modules/world/thingSource.js +4 -2
- package/modules/world/views.js +11 -9
- package/package.json +42 -7
- package/presets.js +1 -3
- package/render/PostFX.js +39 -27
- package/render/backend.js +26 -32
- package/render/cascades.js +17 -12
- package/render/cascades.tsl.js +5 -8
- package/render/daylight.js +20 -3
- package/render/detail.js +8 -7
- package/render/effects.js +28 -25
- package/render/fuse.js +3 -3
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +5 -10
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +27 -23
- package/render/fx/sky.tsl.js +15 -17
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +1 -1
- package/render/lighting.js +5 -3
- package/render/lightmap.js +20 -20
- package/render/lights.js +6 -6
- package/render/lit.js +24 -0
- package/render/materials.js +8 -7
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/occlusion.js +20 -4
- package/render/ownFrame.js +4 -4
- package/render/patches.js +13 -13
- package/render/postWebGL.js +12 -10
- package/render/probes.js +16 -19
- package/render/recordSweep.js +117 -0
- package/render/shaderErrors.js +10 -9
- package/render/shadowCache.tsl.js +107 -0
- package/render/shadowTypes.js +9 -0
- package/{core → render}/shadows.js +57 -11
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +200 -153
- package/types/gameplay.d.ts +163 -91
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +12 -8
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +2 -2
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Layer.d.ts +1 -1
- package/types/generated/modules/grid/index.d.ts +3 -3
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/sky/Sky.d.ts +21 -10
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +2 -1
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +16 -12
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +5 -3
- package/types/generated/render/PostFX.d.ts +17 -11
- package/types/generated/render/materials.d.ts +1 -0
- package/types/generated/render/occlusion.d.ts +9 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +11 -11
- package/types/physics.d.ts +99 -70
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +38 -71
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +4 -3
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +5 -3
- package/core/assetEntry.js +0 -109
- package/core/holds.js +0 -134
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -320
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/MIGRATING-0.6.md +0 -126
- package/docs/PERF.md +0 -245
- package/docs/recipes/36-sky-ground-plants.md +0 -158
- package/docs/recipes/37-terrain-hooks.md +0 -115
- package/docs/recipes/38-environment-hooks.md +0 -67
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/47-island-snow-backdrop.md +0 -43
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/plain-picture/FINDINGS.md +0 -53
- /package/core/{Vars.js → base/Vars.js} +0 -0
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsFail.js → ops/opsFail.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{tier.js → scene/tier.js} +0 -0
- /package/core/{cells.js → stream/cells.js} +0 -0
- /package/core/{streamCells.js → stream/streamCells.js} +0 -0
- /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
- /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
package/docs/COMMANDS.md
CHANGED
|
@@ -9,16 +9,16 @@ After `-w` write the directory or the package name (inside a game directory a pl
|
|
|
9
9
|
- Dev: `npm run dev -w games/my-game`, or from the root `npm run dev -- my-game` (part of the name is enough); no name means the engine example. To
|
|
10
10
|
change the port (default 5173; if taken it moves to the next one): `npm run dev -- my-game --port 5000` (the game name must come first, the
|
|
11
11
|
remaining arguments go to vite untouched; don't add another `--`).
|
|
12
|
-
- Test: `npm test -w games/my-game`, or `
|
|
12
|
+
- Test: `npm test -w games/my-game`, or `threedog test -w my-game`; `npm test` at the root tests every workspace (engine + each game).
|
|
13
13
|
- Build: `npm run build -w games/my-game`; `npm run build` at the root builds all (every *.html in a workspace root is bundled, no change to
|
|
14
14
|
vite.config.js needed); under a sub-path of a site: `threedog build my-game --base /my-game/` (recipes/61-deploy.md).
|
|
15
|
-
- Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--out day.png` your own name, still in `.threedog/shots/` (a path with a directory is written as given), `--tier low|high` render at that device tier (default: the desktop tier, skipped effects are named), `--keep` timestamped file name, picture numbers and hints after every shot, `--no-picture` skips them, `--ref image` also compares with a reference, `--json` one JSON object; an unknown option fails naming the closest one), `npm run bake -- -w my-game`, `npm run assets -- -w my-game`.
|
|
15
|
+
- Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--out day.png` your own name, still in `.threedog/shots/` (a path with a directory is written as given), `--tier low|high` render at that device tier (default: the desktop tier, skipped effects are named), `--keep` timestamped file name, picture numbers and hints after every shot, `--no-picture` skips them, `--ref image` also compares with a reference, `--json` one JSON object; an unknown option fails naming the closest one), `npm run bake -- -w my-game`, `npm run assets -- optimize -w my-game`.
|
|
16
16
|
- A game's tests: every `games/<game>/tests/specs/*.mjs` runs (each exports a `specs` array; the runner finds the files, nothing to register); without
|
|
17
17
|
`tests/specs/` a smoke test runs automatically (page opens, engine ready, no console errors). Minimal example:
|
|
18
18
|
```js
|
|
19
19
|
// games/my-farm/tests/specs/farm.mjs — export a specs array, one entry per page
|
|
20
20
|
export const specs = [{
|
|
21
|
-
name: 'farm: pick up apple', //
|
|
21
|
+
name: 'farm: pick up apple', // threedog test apple matches by name substring, any case
|
|
22
22
|
url: '/?cutscene=skip', // page path + URL parameters
|
|
23
23
|
async run({ page, check, ev, frames, wait }) {
|
|
24
24
|
// ev(fn, arg): runs in the page (engine is available). The function is serialized, so it can't use outer variables; pass them as the argument:
|
|
@@ -32,8 +32,11 @@ export const specs = [{
|
|
|
32
32
|
```
|
|
33
33
|
Tests run against the built bundle (not the dev server): main.js must set `window.engine = engine;` before `await engine.start()`, otherwise the
|
|
34
34
|
test waits for the engine until timeout (the error explains why).
|
|
35
|
+
A spec whose run() reads pixels (`page.screenshot`) moves to software rendering, which is much slower; `software: false` on the spec keeps it on the GPU for a real picture.
|
|
36
|
+
A test that steers: `frames(n)` and `wait(ms)` follow the machine, so under load the same script takes a different path. Hold the loop with
|
|
37
|
+
`engine.haltLoop('my-test')` and advance game time yourself, `await page.keyboard.down('KeyW'); await ev(() => engine.step(0.25));`: the same steps give the same path on any machine.
|
|
35
38
|
- New game: `npm run new-game -- name [--open-world] [--webgl]` (blank scene with a camera by default; `--open-world` adds generated ground, sky, follow camera and a player; the game runs on WebGPU and writes shaders in TSL, `--webgl` on WebGL with GLSL; see `recipes/01-new-game.md`).
|
|
36
|
-
- Game in your own folder (outside this repo): after `npm install threedog@0.
|
|
39
|
+
- Game in your own folder (outside this repo): after `npm install threedog@0.8 three@~0.187.0 @threedog/tools@0.8`, run `node node_modules/@threedog/tools/bin/threedog.mjs init [folder] [--open-world] [--webgl]` (folder: the one to create, default the current folder): it copies the new-game template without overwriting anything, merges package.json and writes `.mcp.json`, so Claude Code opened in that folder starts the threedog MCP server by itself.
|
|
37
40
|
|
|
38
41
|
> Git Bash (MSYS) rewrites arguments that start with `/` into a path under the Git install (`/` turns into `C:/Program Files/Git/`). Page arguments (`shot`, `capture`, `--page`) undo that by themselves, through `npm run` too (npm still echoes `> threedog shot C:/...`; shot then prints the page it really opens); if the Git folder cannot be found the error says so: then write `shot styletest`, set `MSYS_NO_PATHCONV=1`, or use PowerShell.
|
|
39
42
|
|
|
@@ -42,73 +45,94 @@ export const specs = [{
|
|
|
42
45
|
## Command table
|
|
43
46
|
| Command | When to use |
|
|
44
47
|
|---|---|
|
|
45
|
-
| `npm run dev` | Development. Browser errors are sent automatically to the terminal and to the workspace's `.threedog/errors.log` (e.g. `games/my-game/.threedog/errors.log`): read that file first when something breaks, before taking screenshots. Known error classes carry `Possible cause: …` and `Read: recipes/…` lines (tables `core/errorCodes.js` for engine errors, `core/errorHints.js` for browser / JavaScript ones) |
|
|
46
|
-
| `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): rule checks (`packages/tools/rules/`, the engine's hard rules among them; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. Errors print in full, warnings as one count line per rule; `-- --verbose` lists them (the first 15 per rule), `-- --all` every one. `-- --rule R4` runs one rule (`R04` works; an unknown id fails and lists them), `-- -w game` (or `threedog check -w game`, or `check` run inside a game folder, as `new-game` does) reports only that game's rule, type and content problems and sets the exit code from them alone, with other games and the engine as one count line each; plain `check` at the repo root stays repo-wide (run it before committing engine changes) |
|
|
48
|
+
| `npm run dev` | Development. Browser errors are sent automatically to the terminal and to the workspace's `.threedog/errors.log` (e.g. `games/my-game/.threedog/errors.log`): read that file first when something breaks, before taking screenshots. Known error classes carry `Possible cause: …` and `Read: recipes/…` lines (tables `core/base/errorCodes.js` for engine errors, `core/base/errorHints.js` for browser / JavaScript ones) |
|
|
49
|
+
| `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): rule checks (`packages/tools/rules/`, the engine's hard rules among them; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. Errors print in full, warnings as one count line per rule; `-- --verbose` lists them (the first 15 per rule), `-- --all` every one. `-- --rule R4` runs one rule (`R04` works; an unknown id fails and lists them), `-- -w game` (or `threedog check -w game`, or `check` run inside a game folder, as `new-game` does) reports only that game's rule, type and content problems and sets the exit code from them alone, with other games and the engine as one count line each; plain `check` at the repo root stays repo-wide (run it before committing engine changes); `-- --json` prints one JSON result instead (shape below, text to stderr, same exit code) |
|
|
47
50
|
| R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls timers, `Math.random`, an inventory, grid/height blending, a localStorage save or its own pause is pointed to the engine system that already does it. Off per line `// hint-off(kind)`, per file `// hint-off-file(kind)`, per project `package.json "threedog": { "hints": false | { "kind": false } }`, per run `THREEDOG_HINTS=off`. A deliberate choice goes in DESIGN.md Systems |
|
|
48
51
|
| `npm run types` | Type check only (does game code misuse the engine API). Plain JS TypeScript cannot follow (a field added to your own object later, a union from your own ternary, TSL node inference) is a `!` hint, not an error: no `// @ts-nocheck` needed |
|
|
49
|
-
| `npm test` | Full browser tests (slow; test pages run in parallel, `-- --jobs N` sets how many, `--jobs 1` one at a time; without `--jobs`, at most 2 software-rendered pages at once; a spec with `serial: true` runs alone; a failure that happens only beside other pages is retried alone and listed). Normally `
|
|
50
|
-
| `threedog snap-describe save|diff name [--only a,b]` | Describe snapshot instead of a screenshot: baseline of the gameplay part of `describe()` (see recipes/16-dev-bridge.md section 7); in tests one line `expectDescribe({ check, ev }, name, { only, tolerance })` from `@threedog/tools/describe-snapshot` |
|
|
51
|
-
| `threedog play` / `play --stop` | Start the game for the AI: starts the dev server if none runs (detached, output in `.threedog/dev.log`), waits for the dev bridge and the engine, prints the page address and whether a headless or a live browser page is connected. `--stop` stops the server play started |
|
|
52
|
-
| `threedog status` | One call: engine ready, loading done, page errors, running / paused / frozen. When the bridge cannot answer it names one of four causes with one next step: no server (`threedog play`), server still starting (wait, status again), page script error (`threedog errors latest`), no dev bridge installed (use `gameConfig`) |
|
|
52
|
+
| `npm test` | Full browser tests (slow; test pages run in parallel, `-- --jobs N` sets how many, `--jobs 1` one at a time; without `--jobs`, at most 2 software-rendered pages at once; a spec with `serial: true` runs alone; a failure that happens only beside other pages is retried alone and listed). Normally `threedog test name` runs only the related ones (matched by test-name substring, any case, e.g. `-- hlod`; a word that matches nothing fails), `-- -w game` tests one game. Prints only failed items (with their failed checks), a progress line and the summary; `-- --verbose` prints every check. `-- --update-snapshots` makes tests that use `expectDescribe` write their describe baselines (`tests/snapshots/*.describe.json`) instead of comparing. `threedog test pack` (the build test): after a real build of each game, open only dist from a static server and check that the engine is ready, no 4xx resources, no console errors; `-- --json` prints the result as the same JSON shape, one item per failed check |
|
|
53
53
|
| `threedog session [--minutes N]` / `session stop` / `session status` | Optional: keeps one small local process alive (127.0.0.1, token, `.threedog/session.json`) so later bridge commands skip module loading (about 0.1 to 0.15 s less per command); exits by itself after N idle minutes (default 10). Every command works the same without it: no session, a dead one or an unreachable one falls back to a direct call. Restart it after editing the tools |
|
|
54
|
-
| `threedog
|
|
55
|
-
| `threedog step 2` · `threedog press interact [--for 0.02]` · `threedog hold moveForward 1.5` | Advance game time: N game seconds / press a key or action (held 0.1 s) / hold a key or action for N seconds. The page stays paused afterwards (`threedog resume`) |
|
|
56
|
-
| `threedog eval "expr"` (alias `js`) · `threedog snap name [--play]` · `threedog reload` | Evaluate an expression in the page (`engine` available, await works); save a screenshot of the running page to `.threedog/shots/name.png` and print the picture check (as `shot`; `--no-picture` skips it); reload the page |
|
|
57
|
-
| `threedog bake light [-w game] [--out public/light/level.lightmap] [--size 1024] [--spacing m] [--samples 16] [--page /]` | Bake a lightmap of the meshes marked `userData.static` in system Chrome on the real GPU; stops if WebGPU is not real. `recipes/34-environment-lighting.md` |
|
|
58
|
-
| `threedog ops` · `threedog op shop.buy shop=bakery item=bread` | What the player can do now (each op offer checked); run one op as source bridge (no time passes). `recipes/23-ops.md` |
|
|
59
|
-
| `threedog pick 480,270` | What is at a screen pixel (from the canvas top-left): record id, kind, template, content file:line, fields |
|
|
60
|
-
| `threedog js --file steps.js [--verbose] [--wait seconds]` | `--wait` (default 120) is how long a script may wait on a page that looks stopped: driven by manual step, nothing loading, no clock tick. The command then ends and says the script may be waiting on the game clock; the script may still run in the page. A script that calls `assert(cond, msg)` or `expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg)` (or `expect(v, msg)`) runs as checks in ONE call; failed checks are recorded and the script goes on, a throw stops it. Output: `✓ 7 checks passed`, or the failures then `✗ 2 of 7 checks failed`; exit code 1 on failure. `--verbose` adds passes, `log` lines and the return value. A script without those calls is the plain eval (prints its return value); both modes get the same globals `engine`, `step(seconds)`, `log(...)`, `assert`, `expect` |
|
|
61
|
-
| `threedog verify scenario` | Run `tests/scenarios/<scenario>.json` on the running page and print PASS / FAIL, **Tested** (ops with outcomes, describe sections compared, time advanced), **Not tested** (ops never run, sections never compared, steps skipped after a failure, key path, picture), a `Layers:` line (steps by layer: direct = op/describe call, simulated-input = bridge press; real-browser-input is always 0 and printed as not verified, visual 0 because scenario snapshots are describe, not pixels), tests that mention an error code seen, and the `threedog test` command to re-run. A page error during the run fails it. JSON adds `layers` / `layerCounts` / `evidence` (per-check layers, notProven, ops / modules coverage; text: Evidence, NOT proven, Coverage: ops ran/total with refused ones marked, modules tested / indirect / untested, lists capped with "+N more"). `threedog scenario` prints its pass line plus the same Coverage block |
|
|
62
|
-
| `threedog catalog [id] [--find word] [--full] [--json]` | What this game can do: modules, ops (args, failure codes, last attempt), saves, time. No id: a line per module that has ops or problems, the rest named on one line (`--full`: a line each). `recipes/51-capability-catalog.md` |
|
|
54
|
+
| `threedog bake light [-w game] [--out public/light/level.lightmap] [--size 1024] [--samples 128] [--page /]` | Bake a lightmap of the meshes marked `userData.static` in system Chrome on the real GPU; stops if WebGPU is not real. `recipes/34-environment-lighting.md`. `--samples` is rays per texel: raise it if flat walls look blotchy. A map with no light fails and writes nothing |
|
|
63
55
|
| `threedog art list <source>` · `threedog art copy <source> [names…] [--to art/] [--force] [--dry]` | Reuse art code by copying it into this game (no dependency, no link back): the source is a game folder (its `art/`), a local folder or file, or an installed package. `list` shows modules, exported generator functions with their first JSDoc line, asset files; `copy` brings the named modules plus their local imports and the textures / models they name, rewrites relative imports, never overwrites a changed file without `--force` (then nothing is written), prints the `engine.assets.manifest` lines. MCP: `art_list`. `recipes/09-materials-lights-models.md` section 2a |
|
|
64
56
|
| `threedog art board [-w game] [--out file.html] [--json] [--live] [--lib dir]` | Every art resource of one game on one page (default `.threedog/art-board/index.html`): models, textures, sounds, fonts, materials, shaders and library entries, each with a preview where one exists, its file, size and where it is used as file:line. Status: used, unused, missing, or not traced (a name built at run time or plain text that may mean it; never called unused). Each item copies one line for the AI; several items plus a note copy one request. `--json` prints the same data. `--live` also asks the running game (dev server, dev bridge) what it has really loaded; `?panel=1` shows the same list in folder "art". A model gets a picture once `threedog gallery --shots` has made one. |
|
|
65
57
|
| `threedog lib status [-w game] [--lib dir]` | What this game pulled from the library (read from its `.threedog-lib.json`, which every `lib pull` writes): each entry changed or not, and newer in the library or not. It only reports: a pull belongs to the game and nothing updates it |
|
|
66
|
-
| `threedog lib check [-w game]` | Do the things this game pulled fit together? Fails on a need nothing gives
|
|
67
|
-
| `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--style a,b] [--usage s] [--no-proof] [--preview url|png] [--force]` · `threedog lib list [words] [--card] [-w game]` · `threedog lib pull <name> [-w game] [--to art/] [--plug "makeIt({ ... })"] [--force] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games, kept outside the engine (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): one folder per entry with the copied files, `entry.json` (kind model / texture / material / shader / effect / module / other, summary, the use line, backends, params, which game and day it came from) and `preview.png`. `add` copies from a game the way `art copy` does (local imports, textures, models), summary defaults to the first JSDoc line, never replaces a different existing entry without `--force`; a model or texture gets the gallery turntable when the game registers it, a code entry a picture only with `--preview <url of a running scene>` or `--preview file.png`. `list` is one line per entry (words narrow it); `pull` copies an entry into this game (no link back, no update command; the game adapts it) and prints the use line; a
|
|
58
|
+
| `threedog lib check [-w game]` | Do the things this game pulled fit together? Fails on a need nothing gives, on two entries writing one three.js value, and on code the game's renderer cannot run (GLSL in a WebGPU game, a node material in a WebGL game); sizes and styles that do not fit are notes. It reads the game's copies, so an edit or a port clears a clash |
|
|
59
|
+
| `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--style a,b] [--usage s] [--no-proof] [--preview url|png] [--force]` · `threedog lib list [words] [--card] [-w game]` · `threedog lib pull <name> [-w game] [--to art/] [--plug "makeIt({ ... })"] [--force] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games, kept outside the engine (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): one folder per entry with the copied files, `entry.json` (kind model / texture / material / shader / effect / module / other, summary, the use line, backends, params, which game and day it came from) and `preview.png`. `add` copies from a game the way `art copy` does (local imports, textures, models), summary defaults to the first JSDoc line, never replaces a different existing entry without `--force`; a model or texture gets the gallery turntable when the game registers it, a code entry a picture only with `--preview <url of a running scene>` or `--preview file.png`. `list` is one line per entry (words narrow it); `pull` copies an entry into this game (no link back, no update command; the game adapts it) and prints the use line with the path where the file landed. An entry that cannot draw on the game's renderer (`backends` in `entry.json`, `lib list` shows it, `lib list webgpu` narrows to it) is refused with nothing copied; `--force` copies it to port by hand. Where it lands goes by kind: a `picture` or `material` entry in `picture/` (a `.glsl` in `picture/shaders/`) with no wiring file, you import it yourself; a model or texture in `art/`; a `shader`, `effect` or `module` entry in `plugins/<name>/` plus the wiring file `plugins/<name>.js` that calls its factory (the entry's plug line, set by `add --plug`, else its exported function; `pull --plug` overrides), so it plugs at start with nothing hand-written; a `system` in `systems/<name>/` plus that wiring file; `page` writes `index.html` with all previews. MCP: `lib_list`. recipes/05-props-bake.md §2d |
|
|
68
60
|
| `threedog examples list` · `threedog examples pull <name> [--out dir] [--force]` | Technique and optional examples you copy and adapt (the list is `examples/pullable.json` in the engine package; the summary is each README's first line). `pull` copies the game-facing files to `<game>/techniques/<name>/` (or `--out`), never overwrites a changed file without `--force` (then nothing is written), prints the import line and the packages the code imports. An unknown name fails with did-you-mean |
|
|
69
61
|
| `threedog how "<task>"` | Ranks the AI.md task rows and recipe headings for a task in your own words. `recipes/51-capability-catalog.md` section 5 |
|
|
70
|
-
| `threedog explain op shop.buy shop=bakery` / `explain quest first-light` / `explain picture fog.far` | Why an op cannot run now, what a quest waits on, or which line last changed a picture value (`engine.explain`). `recipes/23-ops.md`, `recipes/62-picture-code.md` |
|
|
71
|
-
| `threedog thing <id>` | Everything about one id: definition file:line, model, materials, state, ops, save tier, how to change it (`thing.explain()`). `recipes/40-scene.md` section 6 |
|
|
72
62
|
| `threedog content set <id> x=12 place=home … [--expect x=5] [--in props] [--file content/x.js] [--dry]` | Write a permanent change into the content entry (several fields, one write, all-or-nothing; refused when `--expect` no longer matches). `recipes/40-scene.md` |
|
|
73
63
|
| `threedog content add <kind> id=<id> field=value … [--file content/props/town.js]` · `threedog content remove <id> [--in kind]` | Append one entry at the end of a kind (always with an id) / delete one. Reads and checks only that file (id index `.threedog/content-index.json`). `recipes/40-scene.md` |
|
|
74
|
-
| `threedog
|
|
64
|
+
| `threedog content stamp <arrangement> id=stall-1 x=20 z=5 [rot=1.6] [--dry]` | (experimental) Copy `content/arrangements/<arrangement>.js` (entries around zero, each with a local `part`; read by tools only) into the game: one place in `content/places.js` and one plain props entry per part, id `<id>-<part>`, `source: <arrangement>`. An id clash lists every clash; any failure writes nothing |
|
|
65
|
+
| `threedog content set --source <arrangement> <part> field=value … [--dry]` | Explicit batch edit: the same change in that part of every copy, all or nothing, and it prints how many changed (`--dry` lists them first). Copies do not follow automatically, and the arrangement file is not changed. Without `--source`, `content set` edits only that entry |
|
|
66
|
+
| `threedog content capture <groupName> --as <arrangement> [--page /p.html] [--force] [--dry]` | (experimental) From the running game (dev server): read a named `THREE.Group`'s direct children (position, turn, scale relative to the group, named model or template of each) and write the arrangement. Placement only, never geometry. A child with no named model, a tilt or an uneven scale is listed by name with the fix, and nothing is written. Afterwards delete the code that placed the group, or it appears twice; `check` warns (R52) while its name is still in the code |
|
|
75
67
|
| `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
|
|
76
68
|
| `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
|
|
77
69
|
| `threedog shot --view name [--compare before.png]` | A named camera view (`engine.views.define`) and a pixel diff against an earlier picture. `recipes/46-blender-art-route.md` |
|
|
78
|
-
| `threedog
|
|
79
|
-
| `threedog errors` / `errors latest [N]` / `errors --since E5` | Page errors with id (E1…), time, tick, source and count; the same error repeated is one line with its first and last id / time and `×N`. Plain `errors` = new since the last read; `latest` = the last N (default 3), same answer every time; `--since` = after an id, never moves the read position. Every result prints a cursor |
|
|
80
|
-
| Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game paused, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|paused|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it. MCP `data` over 3 KB keeps its small fields and names `threedog <cmd> --json` for the rest (the text already summarizes it) |
|
|
70
|
+
| Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game loop halted, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|halted|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / busy / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it. MCP `data` over 3 KB keeps its small fields and names `threedog <cmd> --json` for the rest (the text already summarizes it) |
|
|
81
71
|
| `npm run map` | Regenerate CODEMAP, API.md + api/, each game's GAMEMAP and the event-name list (generated from `EventMap` in core.d.ts; add a new event to EventMap first) after changing code, JSDoc or content (run it before `check`) |
|
|
82
72
|
| `npm run shot -- / --time 18:30 --weather rain --pos x,z` (or `--at place`: in play at a named place) | Only when you need to see the picture; by default 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`**. Under a picture it prints only what bears on it (time, weather, camera; the same lines as `threedog snap`); `--describe-only` and `--json` give the whole state. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time. The shot waits until loading is finished (`--load-timeout` seconds, default 120) and fails naming what is still pending, then for the game's own code after `await engine.start()` (no request open and the scene's objects / lights / materials unchanged for 0.3 s, at most 10 s; it prints how long and what was added; if the scene still changes after the picture, it warns that the picture may be incomplete); a page error before `window.engine` fails at once with the error. `--no-build` reuses the last dist/ (code unchanged); a playing cutscene is skipped unless `--keep-cutscene`; `--play` starts straight in play, past the title screen the way its Start does (the engine's `?play` URL key) |
|
|
83
73
|
| `npm run shot -- / [--ref image] [--no-picture] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`, on the live page): picture numbers measured on the 3D canvas (mean luminance, contrast = std of luminance and the p5-p95 range, saturation, share clipped white / near black, shadow area and how much shadows darken) and hints. **Contradictions** (always on): shadows on but none measurable, a light the game added that changes no pixel. **Facts** (each a contradiction only where DESIGN.md declares the opposite): glare, naming each light or glowing material that blows pixels out with its current values and the detail lost under it, and large clipped areas (`no-glare`); large near-black areas (`no-pitch-black`); time of day that barely changes the picture or a night not dark from lighting (renders 12:00 and 00:00 when the game runs calendar + sky or the shot sets `--time`; `dark-nights`); `light:` the share of the lit brightness from the sun / key and from the fill (each turned off once) and how much darker shadowed areas are (`strong-light`); the camera standing inside a closed mesh; a black frame, naming the material whose hiding alone brings the picture back (newest materials first; a ShaderMaterial is told the usual NaN / Inf causes, and shader programs that failed to compile are listed); fog that is most of the color in a large share of the picture, with its near / far and color. **Intent** (only against what the game declared): the listed words on DESIGN.md's optional `Picture intent:` line (the only place the check reads a wish; the table's free text is never read), or `--ref`. Each hint states the fact and the likely cause with the parameter and its current value, never a target; nothing fails and nothing is changed. Printed short: the numbers line (noon / midnight with each exposure when the two differ), then at most four one-sentence hint lines, contradictions first and then by measured size, and `N more: threedog shot --json (picture.hints)`; `--json` has every hint in full. A few extra renders of the current view (about 0.3 s on a GPU), every touched value put back. `--json` prints one object (file, look, probe, hints, describe) for MCP / the dev bridge. A full URL opens that already running page without a build, and a local server of another game's folder is refused (one that cannot say which game it serves gets a printed note); `--image` reads a picture taken any other way and gives the pixel part only (shares, near-white spots, intent), saying what needs the live page. A screenshot of your own skips the check: take pictures with `shot` or `snap`. recipes/35 |
|
|
84
74
|
| `npm run shot -- styletest --view room --time dusk --weather rain` | The fixed style-judging scene (`examples/styletest`, page `/styletest.html`; a bare name is a page of the workspace). `--view` = a named camera (overview, character, water, room, path, ui), `--time` also takes day / dusk / night, `--weather` clear / rain / snow; same arguments every round, so only the style differs. `--panel` is not a shot option: open `/styletest.html?panel=1` in a browser for the workbench (recipes/35) |
|
|
85
|
-
| `threedog capture [page] [--top N] [--no-spector] [--spector-url url] [--full] [--no-build]` | Find out what a frame draws: renders one steady frame headless and prints draw calls, shadow-map draws, render passes (post effects) and the largest draws with world record id, budget tag and material purpose. Also records the WebGL command stream of that frame with Spector.js (fetched on first use into `.threedog/cache/`, not a dependency) to `.threedog/captures/`; `--no-spector` skips it, `--spector-url` fetches it from another source |
|
|
75
|
+
| `threedog capture [page] [--top N] [--no-spector] [--spector-url url] [--full] [--no-build]` | Find out what a frame draws: renders one steady frame headless and prints draw calls, shadow-map draws, render passes (post effects) and the largest draws with world record id, budget tag and material purpose. Also records the WebGL command stream of that frame with Spector.js (fetched on first use into `.threedog/cache/`, not a dependency) to `.threedog/captures/`; `--no-spector` skips it, `--spector-url` fetches it from another source. Works on the game's own renderer, WebGL or WebGPU, and prints which one it measured; Spector only runs on WebGL. A frame with no draws fails |
|
|
86
76
|
| `npm run bake` | Before release, or to take code-generated models into Blender: exports public/models/baked/*.glb (`-- -w game`) |
|
|
87
|
-
| `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models
|
|
88
|
-
| `threedog assets
|
|
89
|
-
| `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld)
|
|
90
|
-
| `threedog stress [--only a,b] [--frames 30] [--json]` |
|
|
91
|
-
| `--gpu` · `--software` · `THREEDOG_RENDER=gpu` or `software` | Renderer of the headless browser. `shot`, `gallery --shots`, `perf` and `stress` prefer the hardware GPU (ANGLE d3d11 / metal / vulkan), check the renderer string after launch and fall back to SwiftShader with one note line; tests that read rendered pixels (`software: true` on the spec; unmarked ones are caught at the end of a GPU run) start on SwiftShader (same pixels everywhere), the others on the GPU when it is reachable |
|
|
77
|
+
| `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models/; a game with no such folder has nothing to check and passes, and only models are read: sprite and texture PNGs are never looked at): the level manifest (spawns, col_ colliders, trigger_ zones, npcs, markers, template / id nodes, missing templates, duplicate ids), material and color-space suspicions (data texture in a color slot, BLEND, texture without UV, oversized texture), statistics. `--json` for tools, exit 1 on errors (`--strict`: on warnings too). `npm run check` also reads the level glbs for content validation |
|
|
78
|
+
| `threedog assets optimize [-w game] [--dry] [--force] [--budget MB] [--strict] [--lod [--lod-shares 0.5,0.2]]` (`npm run assets -- optimize`) | `--lod` also writes lower-detail levels and reports triangles per level, saying which models it skipped and why (recipe 15 §4a). Make game-ready copies of the models in art/models/ without touching them: Meshopt geometry, KTX2 textures encoded by slot (normal / occlusion / roughness maps as linear UASTC, color maps as sRGB ETC1S; each output texture is read back and checked against its slot), into public/optimized/. Writes `assets.optimized.js` and adds its import to assets.js, so the names point at the results. A rerun handles only changed files (content hash, options, tool versions). Per file: size before / after, estimated GPU memory, and problems (over `--budget` MB of texture memory, color space, texture without UV or without the second UV set it asks for). `--dry` writes nothing and reports the estimate. Needs `@gltf-transform/cli`. Textures are encoded by the `ktx` command (KTX-Software 4.3+) when it is on PATH, else by the WebAssembly encoder of the npm package `ktx2-encoder` (MIT; its Basis Universal build is Apache-2.0), which comes with the tools. The output says which encoder ran and how long encoding took. With neither, only this command fails and says what to install. Baked lightmaps are left as baked (banding after compression is not measured). Report: `.threedog/optimize-report.json` |
|
|
79
|
+
| `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld). Prints the renderer first. `threedog perf -w my-game [frames]`: your game's page in play, standing still: frame ms, JS ms, draw calls, memory |
|
|
80
|
+
| `threedog stress [-w game] [--only a,b] [--frames 30] [--json]` | At what load this game drops: from a game folder (or `-w`) the load ramps go on top of the game's own scene on its own renderer in system Chrome, one axis at a time (extra meshes, triangles, instances, point lights), after a line with the game alone; then the load that fits 16.7 and 33 ms per axis. A WebGPU game on a browser without real WebGPU is refused. In the engine repo with no game it runs the neutral page `tests/stress/` for the engine's own measurements, and says so |
|
|
81
|
+
| `--gpu` · `--software` · `THREEDOG_RENDER=gpu` or `software` | Renderer of the headless browser. `shot`, the dev bridge's headless page, `gallery --shots`, `perf` and `stress` prefer the hardware GPU (ANGLE d3d11 / metal / vulkan), check the renderer string after launch and fall back to SwiftShader with one note line; tests that read rendered pixels (`software: true` on the spec; unmarked ones are caught at the end of a GPU run) start on SwiftShader (same pixels everywhere), the others on the GPU when it is reachable |
|
|
92
82
|
| `threedog content ids [-w game \| folder] [--write]` | Stateful content entries (pickups, template instances with state / container / interact / body) that rely on their index id: prints the id each has now as `-`/`+` lines (dry run); `--write` writes them into `content/*.js`. Rename later through `content/renames.js` (recipe 30) | <!-- r18-ignore-line -->
|
|
93
|
-
| `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems; `-- --json` prints
|
|
94
|
-
| `threedog api-count [--unused] [--json]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, module options and APIs, exports of `threedog` / `threedog/tsl` / `@threedog/post-effects`, CLI commands and options, error codes) from the type declarations, one line per group; `--unused` lists the items no engine source, example, template or recipe code block uses (deletion candidates, a name heuristic); unused items kept on purpose (CLI commands, error codes, tuning options with a default) are reported apart as `kept`. For engine maintainers deciding what to delete |
|
|
83
|
+
| `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems; `-- --json` prints the same shape as `check --json`: `{ ok, summary, items }` (items are the problems and info lines); exit code 0 only when `ok`. Checks Node version, node_modules, workspace links, package-lock consistency, `.threedog` writable, the physical copy (real path, version, package.json mtime) of engine / tools / three per context (check, run/build per game; a `MISMATCH` line when contexts use different copies, e.g. vendor/ vs node_modules), port 5173, the dev server recorded in `.threedog/dev.json`, then renders one real engine frame on software rendering (what tests use; failing is a problem) and on the GPU path (whether a hardware GPU is available to headless; info only), and whether `EXT_disjoint_timer_query_webgl2` gives GPU ms. Run it first when the environment acts strange |
|
|
84
|
+
| `threedog api-count [--unused] [--json] [--games dirA,dirB]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, module options and APIs, exports of `threedog` / `threedog/tsl` / `@threedog/post-effects`, CLI commands and options, error codes) from the type declarations, one line per group; `--unused` lists the items no engine source, example, template or recipe code block uses (deletion candidates, a name heuristic); unused items kept on purpose (CLI commands, error codes, tuning options with a default) are reported apart as `kept`. For engine maintainers deciding what to delete |
|
|
95
85
|
| `threedog picture palette <image> [--n 8] [--average] [--region x,y,w,h] [--ignore-ui] [--crop out.png] [--json]` | Dominant colors of a reference picture and a one-line summary (headless Chromium reads the pixels). `--average` adds the mean color (HSL); `--region` measures one rectangle; `--ignore-ui` cuts a flat frame around the picture (edge row / column one flat color, frame 3% to 45% of the picture; a plain sky at the edge looks the same, so check with `--crop out.png`, which saves the measured area). The output says what was measured; `--json` prints the JSON only (summary inside). A path that starts with `-` goes after `--`. A measurement, not a design decision |
|
|
96
86
|
| `threedog picture compare <reference> <screenshot> [--region x,y,w,h] [--ref-region ..] [--shot-region ..] [--json]` | Differences as numbers: brightness, saturation, contrast (std of luma), fine detail (variance of the Laplacian of luma; read as a ratio), average and main color (hue / saturation / lightness), plus one neutral sentence ("18% darker, 2.3x more broken up"). Both pictures are scaled down to one size, never enlarged (detail is measured at the smaller picture's scale), and the notes say so. Regions are matched by position: a shifted feature shows as a large hue difference, so cut the same content with `--ref-region` / `--shot-region`. **An aid to judging, not a replacement for looking; no number is a quality score and there is no "similarity %".** recipes/35 |
|
|
97
|
-
| `threedog scene [--hidden] [--limit N] [--json]` | **The mesh exists but is not drawn: use this first** (needs the running game). Lists every Mesh / Points / Line / Sprite and for each undrawn one every reason, most likely first: `visible = false` on it or a parent, layers vs camera, material flags, scale 0 / NaN, NaN position or vertices, empty geometry, behind the camera, beyond `camera.far`, outside the view. "maybe" reasons (depthWrite off, fully fogged...) do not stop drawing. `--hidden` = only undrawn. Answer first: a `Not drawn because:` line counts every undrawn object by reason, then the first 6 (surprising ones before plain view culling); `--limit N` or `--full` (40) for more. Code: `engine.inspect.scene()`; MCP tool `scene`. Cannot see shader output |
|
|
98
|
-
| `threedog inspect materials` | Every material in the running game: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with `×N`; **wrong color spaces first** (color map not sRGB = washed out; normal / roughness map marked sRGB). Code: `engine.inspect.materials()`; MCP `inspect` target `materials`. Plain three.js: `scene.traverse` + `texture.colorSpace` |
|
|
99
|
-
| `threedog inspect perf` | The last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; `✗` lines name the next call. Budgets: `engine.budget` limits, else a desktop reference. Code: `engine.inspect.perf()`; MCP `inspect` target `perf`. Plain three.js: `renderer.info`. The engine benchmark suite is `npm run perf` |
|
|
100
87
|
| `?panel=1` with `import('@threedog/tools/panel').then(m => m.openPanel(engine))` | The dev panel in any game: live sliders straight on the three.js objects (exposure, `scene.fog`, lights, module materials and uniforms, materials by name, `engine.uniforms`), post effects, UI colors, "write back" for `threedog tune`. Needs the optional dev package `tweakpane`; production builds of the vite preset get a stub. `recipes/35-picture-from-reference.md` |
|
|
101
|
-
| `threedog tune show` · `threedog tune write [file] [--apply]` | Values
|
|
88
|
+
| `threedog tune show [-w game]` · `threedog tune write [file] [--apply] [-w game]` | Values from `.threedog/tune.json` as one `// threedog:tune begin ... end` block of plain three.js writes (`engine.scene.fog.far = 90;`, `material.setValues` by name, UI CSS variables) in `file`. A later write merges into the block, so values the panel no longer holds stay; delete a line to drop it. Model generator params (the panel's models folder) become the `default` in that model's `params` schema where it is registered (no file needed for those). Without `--apply` it only prints the diff. `recipes/35-picture-from-reference.md` |
|
|
89
|
+
| Tuning without a mouse | The panel is for a person. An AI does not need it: try values with `threedog eval` (`engine.scene.fog.far = 90`), look with `threedog snap`, then write what it settled on into `.threedog/tune.json` as `{ "values": { "engine.scene.fog.far": 90, "engine.scene.background": "#336699" }, "css": { "accent": "#7fd3ff" }, "materials": { "rock": { "roughness": 0.8 } }, "models": { "tree": { "height": 4 } } }` and run `threedog tune write main.js --apply`. Or write the value straight into the code; the file only saves reviewing the change first |
|
|
102
90
|
| `threedog gallery [-w game] [--port 5181]` · `threedog gallery --shots [--size 256] [--only a,b] [--mode silhouette,value]` | Every registered model and texture on a turntable under three neutral light setups (midday, low sun, overcast; tone mapping copied from the game). Without `--shots` it serves the game in dev and prints the `?gallery=1` URL (any dev page opens it with `?gallery=1`); `--shots` writes `.threedog/gallery/<name>-<light>.png`, `index.html` and `index.json` headless. `--mode` adds review pictures beside them: `silhouette` (each model pure black on white: `fill`, `boxFill`, `aspect`) and `value` (the midday shot as grayscale luminance: `p5` / `p50` / `p95` inside the outline); the facts are printed per asset and stored in `index.json`, with no thresholds. Compare one with a reference: `threedog picture compare <ref> <png> --out diff.png`. `recipes/05-props-bake.md` section 2c |
|
|
103
91
|
| `npm run build` | Bundle each workspace into its own dist/ |
|
|
104
|
-
| `threedog preview [game]` (or `-w game`, as for dev and build) | Serve a workspace's built dist/ (vite preview) to open the production build in a browser |
|
|
92
|
+
| `threedog preview [game]` (or `-w game`, as for dev and build) | Serve a workspace's built dist/ (vite preview) to open the production build in a browser. It is the shipped game, so URL keys (`?play`, `?time`…) are not read; `shot`, `test` and `dev` read them, or set `createEngine({ urlState: true })` (`?fresh` stays dev-only) |
|
|
105
93
|
| `threedog relay [port]` | The WebSocket relay for the net module (default port 8787, no dependencies). `recipes/27-net.md` |
|
|
106
94
|
|
|
95
|
+
**`--json` result** (`check`, `test`): one line on stdout, `{ ok, summary, items: [{ code, level, file, line, message, fix }] }`. `level` is `error` or `warn`; a field is present only when known. `code` is the rule id (`R4`), a TypeScript code (`TS2345`), `content` or `test`. A test item's message is `<item name>: <check> → <reason>`; the totals are in `summary`. `ok` and the exit code agree.
|
|
96
|
+
|
|
97
|
+
## Dev bridge commands
|
|
98
|
+
They drive the running game. Run them inside the game folder or with `-w game`; at the repo root the one running dev server is used (several: the error lists them for `-w`). `threedog <command> --help` prints the same line. `recipes/16-dev-bridge.md`
|
|
99
|
+
|
|
100
|
+
<!-- rows written by npm run map from packages/tools/threedog/command-table.mjs: edit them there -->
|
|
101
|
+
| Command | What it does |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `threedog describe` | compact scenario description (--full for the describeText summary, --all for everything, describe player.x for one item, --max characters); recipes/16-dev-bridge.md |
|
|
104
|
+
| `threedog step` | advance N real seconds: step 2. The loop stays halted afterwards (threedog resume) |
|
|
105
|
+
| `threedog skip` | jump the clock like sleeping: skip to=06:00 / skip seconds=600 (engine.skip: op time.skip, sky clock and time-keeping modules catch up; optional fade=0.6 save=auto). to works with calendar() alone; the sky only follows the clock when installed |
|
|
106
|
+
| `threedog press` | press a key or action: press interact / press KeyE / press e (held 0.1 s, then renders 1/60 s; --for 0.02 shortens the hold) |
|
|
107
|
+
| `threedog hold` | hold for N seconds: hold moveForward 1.5. moveForward walks along the camera's heading, so with a follow camera at its start angle it goes diagonally, not along an axis: place things by reading player after a short hold |
|
|
108
|
+
| `threedog state` | change the scenario without a reload: state time=18:30 weather=rain pos=40,-20 (pos=x,z has no height: the hero stands on the highest support over that spot, a ledge included; to stand under it, js "engine.player.placeAt([x, y, z])") |
|
|
109
|
+
| `threedog eval` | evaluate an expression in the page (engine is available, await works; one expression prints its value, several statements print what they return): eval "engine.calendar.timeOfDay"; long scripts: eval --file path. A script that calls assert(cond, msg) or expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg) (or expect(v, msg)) runs as checks in ONE call: failed checks are recorded and the script goes on, a throw stops it; output ✓ 7 checks passed, or the failures then ✗ 2 of 7 checks failed; exit 1 on failure; --verbose adds passes, log lines and the return value. A script without those calls is the plain eval. Both modes get the globals engine, step(seconds), log(...), assert, expect. --wait <seconds>, default 120: how long a script may wait on a page that looks stopped (driven by manual step, nothing loading, no clock tick); the command then ends and says the script may be waiting on the game clock, and the script may still run in the page |
|
|
110
|
+
| `threedog js` | alias of eval (the command has no eval in it, so the Bash sandbox does not block it): js "engine.calendar.timeOfDay" / js --file path |
|
|
111
|
+
| `threedog snap-describe` | describe snapshot instead of a screenshot, a baseline of the gameplay part of describe(): snap-describe save\|diff name [--only a,b] [--ignore x.y] [--tolerance 0.5] (recipes/16-dev-bridge.md section 7); in tests one line expectDescribe({ check, ev }, name, { only, tolerance }) from @threedog/tools/describe-snapshot |
|
|
112
|
+
| `threedog snap` | save a screenshot to .threedog/shots/name.png and run the picture check on the page, as threedog shot does (snap name, or snap path/to/file.png used as given; --play first leaves the title as shot --play; --width N scales the returned image down, the saved file stays full size; --no-picture skips the check) |
|
|
113
|
+
| `threedog errors` | page errors with id (E1…), time, tick, source and count; the same error repeated is one line with its first and last id / time and ×N. errors = new since the last read; errors latest [N] = the last N (default 3), same answer every time; errors --since E5 = after id 5, never moves the read position. Every result prints a cursor (known classes come with the cause and the doc page) |
|
|
114
|
+
| `threedog reload` | reload the page |
|
|
115
|
+
| `threedog resume` | resume real-time running (the page is halted after step / press) |
|
|
116
|
+
| `threedog ops` | what the player can do now (each op offer checked with can): ✓ shop.buy shop=bakery item=bread · ✗ … (reason); recipes/23-ops.md |
|
|
117
|
+
| `threedog op` | run an op as source bridge (no time passes): op shop.buy shop=bakery item=bread n=2 (values converted by the op args shape) |
|
|
118
|
+
| `threedog inspect` | what is around the player (or inspect npc_3 / inspect 10,-4) and which ops it can do now, with reasons. inspect materials (engine.inspect.materials(), plain three.js: scene.traverse + texture.colorSpace) = every material: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with ×N; wrong color spaces first (color map not sRGB = washed out; normal / roughness map marked sRGB). inspect perf (engine.inspect.perf(), plain three.js: renderer.info) = the last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; ✗ lines name the next call. Budgets: engine.budget limits, else a desktop reference. The engine benchmark suite is npm run perf |
|
|
119
|
+
| `threedog scene` | the mesh exists but is not drawn: use this first. Counts, one Not drawn because: line over every Mesh / Points / Line / Sprite, then the first 6 undrawn ones (surprising before plain view culling) with every reason, most likely first: visible=false on it or a parent, layers vs camera, material flags, scale 0 / NaN, NaN position or vertices, empty geometry, behind the camera, beyond camera.far, outside the view. "maybe" reasons (depthWrite off, fully fogged...) do not stop drawing. scene [--hidden (only undrawn)] [--limit N \| --full (40)] [--json]. Code: engine.inspect.scene(). Cannot see shader output |
|
|
120
|
+
| `threedog pick` | what is at screen pixel x,y (from the canvas top-left): pick 480,270 -> record id, kind, template, where it is defined (content file:line), fields |
|
|
121
|
+
| `threedog thing` | everything about one id as JSON: thing player-chest (definition file:line, template, model, materials, state, collision rules, related ops, save status, how to change it; thing.explain(), recipes/40-scene.md section 9) |
|
|
122
|
+
| `threedog explain` | why: explain op shop.buy shop=bakery item=bread (can it run; --full adds its last attempt) / explain quest first-light (where it is stuck) / explain picture fog.far (which line last changed it). engine.explain; recipes/23-ops.md, recipes/62-picture-code.md |
|
|
123
|
+
| `threedog scenario` | run one scenario test (tests/scenarios/<name>.json) on this page: scenario barter (prints failed checks and the Coverage block of verify; the scenario leaves the page halted) |
|
|
124
|
+
| `threedog catalog` | what the game can do, from its registrations: catalog = a line per module with ops or problems, the rest named on one line (--full: a line each); catalog shop = one module (dependencies, params + defaults, ops with args and failure codes, saved parts, time hooks, problems, doc / recipe / source files); catalog shop.buy = one op; catalog --find throw; --json for the raw data; recipes/51-capability-catalog.md |
|
|
125
|
+
| `threedog loading` | what loading waits for / what failed / does it block the start (answers while start() is stuck); loading hero: one task with its manifest and path; recipes/05-props-bake.md |
|
|
126
|
+
| `threedog play` | start the game for the AI: starts the dev server if none runs (detached, output in .threedog/dev.log), waits for the bridge and the engine, prints the page address and whether a headless or a live browser page is connected (play --stop stops the server play started) |
|
|
127
|
+
| `threedog status` | is it ready: engine ready / loading / page errors / running, halted or frozen. When the bridge cannot answer it names one of five causes with one next step: no server (threedog play), server still starting (wait, status again), server busy and not answering in time (wait, status again), page script error (threedog errors latest), no dev bridge installed (use gameConfig) |
|
|
128
|
+
| `threedog verify` | run a scenario (tests/scenarios/<name>.json) and report PASS / FAIL, what it tested (ops with outcomes, describe sections compared, time advanced) and what it never touched (ops never run, sections never compared, steps skipped after a failure, key path, picture): verify barter. Also a Layers: line (steps by layer: direct = op/describe call, simulated-input = bridge press; real-browser-input is always 0 and printed as not verified, visual 0 because scenario snapshots are describe, not pixels), tests that mention an error code seen, and the threedog test command to re-run. A page error during the run fails it. JSON adds layers / layerCounts / evidence (per-check layers, notProven, ops / modules coverage; text: Evidence, NOT proven, Coverage: ops ran/total with refused ones marked, modules tested / indirect / untested, lists capped with "+N more") |
|
|
129
|
+
<!-- end of generated rows -->
|
|
130
|
+
|
|
107
131
|
## Reproducing a scenario and debugging
|
|
108
132
|
- Add `?time=18:30&weather=rain&pos=40,-20&save=slot1&cutscene=skip&state=name` to the URL (effective in development).
|
|
109
133
|
- In the console / tests: `engine.describeText()` reads the state as English text; `engine.step(seconds)` fast-forwards synchronously (no rendering);
|
|
110
|
-
`engine.
|
|
111
|
-
- To wait for the page: `page.waitForFunction(() => window.engine?.stateApplied)` (start has finished and all URL parameters are applied); never read
|
|
134
|
+
`engine.haltLoop()` stops the real-time loop.
|
|
135
|
+
- To wait for the page: `page.waitForFunction(() => window.engine?.stateApplied)` (start has finished and all URL parameters are applied), then read `engine.stateRefused` for what the URL could not do (`shot` and `capture` fail on it); never read
|
|
112
136
|
`_`-prefixed private fields. When the dev bridge / `npm test` / `npm run shot` cannot reach the engine (no `window.engine` after 40 seconds, or it
|
|
113
137
|
exists but never becomes ready), the error states the page status, the latest page errors and the fix.
|
|
114
138
|
- Advancing dialogue headlessly: `engine.step(1)` lets the typing finish, then press a number key or run
|
|
@@ -116,19 +140,3 @@ export const specs = [{
|
|
|
116
140
|
- Debug objects on window: `window.engine = engine` is already declared; for a game's own, write `/** @type {any} */ (window).game = {...}`
|
|
117
141
|
(`npm run types` reports properties on window as web hints, not errors).
|
|
118
142
|
- To operate a running game use the dev bridge, see `recipes/16-dev-bridge.md`.
|
|
119
|
-
|
|
120
|
-
## Folder guide (inside packages/engine)
|
|
121
|
-
- `core/` core: Engine (main loop, ground, step/describe), Events Input Saves Assets Audio I18n Clock Vars Jobs Stream Rays Budget UrlState Animator.
|
|
122
|
-
- `modules/` modules, one folder each, installed with `engine.use`; list in `CODEMAP.md`.
|
|
123
|
-
- `render/ ui/` material factory, post-processing; UI basics (windows, UI focus stack, toast, fadeScreen, worldToScreen).
|
|
124
|
-
- `index.js index.d.ts types/` entry and API declarations (`types/generated/` is generated from source JSDoc, never edited by hand).
|
|
125
|
-
- `examples/world/picture/` is the world example's own small picture (plain three.js), not a recommended one; `examples/world/art/`
|
|
126
|
-
is its art: `index.js` exports the asset pack `assets`, `models.js` the procedural trees / rocks, `humanoid.js` the humanoid body asset, `shapes.js` the pickup shape.
|
|
127
|
-
The bloom / outline / ao effects are in `packages/post-effects/` (`@threedog/post-effects`). The terrain preset `terrainPreset()` is a separate package, `packages/terrain-noise/` (`@threedog/terrain-noise`).
|
|
128
|
-
- `examples/world/` is the engine example (open world `/`, content-only placement). The small city (level, no terrain, top-down) and
|
|
129
|
-
the co-op page are test pages in the engine repository (`tests/city/`, `tests/coop/`), opened at `/tests/city/index.html` and `/tests/coop/index.html`.
|
|
130
|
-
- `tests/` specs/*.mjs test items (found by the runner), `<name>/index.html` test pages, fixtures/ test assets. `public/` art for the examples.
|
|
131
|
-
- Each game `games/<game>/`: package.json, vite.config.js (one line, gameConfig), index.html, main.js, `content/` (items npcs dialogues quests pickups
|
|
132
|
-
containers props templates triggers actions places level vegetation audio grids renames rules, plus the game's own kinds registered in
|
|
133
|
-
`content/rules.js`; only these file names are read), `public/` (art; Blender source files go in `art/models/`), DESIGN.md, GAMEMAP.md (generated), CLAUDE.md.
|
|
134
|
-
- Each workspace has its own `.threedog/` (browser error log errors.log, screenshots shots/, generated cache) and `dist/`; neither is committed.
|
package/docs/CONVENTIONS.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
For API details see `api/<module>.md`; this file holds conventions that don't belong to one API but cause problems when broken. `AI.md` lists each in
|
|
4
4
|
one line; the detail is here.
|
|
5
5
|
|
|
6
|
+
## Where a thing goes in the world
|
|
7
|
+
|
|
8
|
+
| The thing | Use |
|
|
9
|
+
|---|---|
|
|
10
|
+
| Built by code on every start | `scene.add` (plain three.js) or `engine.add` |
|
|
11
|
+
| Must be saved, or live on while far away | `engine.world` (`world.add`, `world.present` for its model) |
|
|
12
|
+
| Written as data | `content`, the data front of `engine.world` |
|
|
13
|
+
| Drawn in a level file | a level, through `level()` |
|
|
14
|
+
| Placed on cells | `engine.grids`, on top of the above |
|
|
15
|
+
|
|
16
|
+
`engine.stream` is the low-level loader under these; reach for it only for your own distance-based loading.
|
|
17
|
+
|
|
6
18
|
## World data and level ownership
|
|
7
19
|
- **World data**: game objects that must be saved, survive level changes, or change while far away go in `engine.world` (the model is built with
|
|
8
20
|
`present` only when near, the simulation runs with `simulate`).
|
|
@@ -12,7 +24,7 @@ one line; the detail is here.
|
|
|
12
24
|
- **Level ownership**: world data carrying `zone: engine.world.zone` (= the current level name) gets its model built and is simulated only in that
|
|
13
25
|
level; when you leave, the data stays (content NPCs, pickups and props already work this way);
|
|
14
26
|
things that need not be kept (trigger zones, etc.) use `level.track(handle)` and are deleted automatically on level change.
|
|
15
|
-
- **Module type**:
|
|
27
|
+
- **Module type**: a module says what it owns with `type` (`'rules'` for game logic, the default; `'world'` state that draws nothing, `'picture'` what is
|
|
16
28
|
seen and heard, `'ui'` panels, `'actor'`, `'net'`, `'tool'`; recipes/14). Modules depend on capabilities (`requires: ['inventory']`), never on
|
|
17
29
|
another module's name or private fields; a module doing two kinds of thing is two definitions from one factory (`weather()`: state + drawing).
|
|
18
30
|
- **Who owns a handle**: every `{ remove() }` handle has one owner that removes it, chosen by how long it should live: the module
|
|
@@ -53,9 +65,22 @@ logic need none of this.
|
|
|
53
65
|
| Let several systems change one shared value (speed, time scale, gravity, damage taken): the game sets, effects multiply, settings cap | `engine.mod(point, { owner, set \| add \| mul \| clamp, for })`, in a module `ctx.mod`; `mul` / `add` cooperate, two owners' `set` on one layer is an error with the fix; your own point: `engine.stacks.define` | `recipes/55-mods-time-wrap.md` |
|
|
54
66
|
| Run code before / after / around a module method (a weight limit on `inventory.add`) | `engine.wrap(engine.inventory, 'add', (next, ...a) => next(...a), { owner })` | `recipes/55-mods-time-wrap.md` |
|
|
55
67
|
| Close one action for a while (stunned: no jump) | `engine.input.gate(action, { owner, for })` | `recipes/55-mods-time-wrap.md` |
|
|
56
|
-
| Replace a whole system (your own inventory, interactions, dialogue, quests, flow, characters, camera; your own vehicle for `character.enter`) | `engine.use(mine(), { replaces: '<slot>' })` for a part that `provides` that slot; a module (or object) that meets that contract (`<module>.contract.js`; vehicle: `modules/characters/vehicle.contract.js`), checked with `runContract` | `recipes/55-mods-time-wrap.md` "Replacing a module" |
|
|
57
|
-
| Change a picture value (light, fog, sky, water, tone, post) | write it in your `picture/` code on the three.js object or the module's `material` (recipe 62); a value the engine drives (camera far, fov, pixel ratio): `engine.
|
|
58
|
-
| Write the picture yourself | plain three.js on `engine.scene / camera / renderer` (own material, `ShaderMaterial`, pass); a direct write takes that value over and the engine yields | `THREE.md
|
|
68
|
+
| Replace a whole system (your own inventory, interactions, dialogue, quests, flow, characters, camera, collision, level, navmesh; your own vehicle for `character.enter`) | `engine.use(mine(), { replaces: '<slot>' })` for a part that `provides` that slot; a module (or object) that meets that contract (`<module>.contract.js`; vehicle: `modules/characters/vehicle.contract.js`), checked with `runContract` | `recipes/55-mods-time-wrap.md` "Replacing a module" |
|
|
69
|
+
| Change a picture value (light, fog, sky, water, tone, post) | write it in your `picture/` code on the three.js object or the module's `material` (recipe 62); a value the engine drives (camera far, fov, pixel ratio): `engine.autoView.manual(key)` first; a screen effect: `engine.post.add(x)` |
|
|
70
|
+
| Write the picture yourself | plain three.js on `engine.scene / camera / renderer` (own material, `ShaderMaterial`, pass); a direct write takes that value over and the engine yields | `THREE.md` |
|
|
71
|
+
|
|
72
|
+
**What can be replaced**: a slot with a contract file (inventory, interactions, dialogue, quests, flow, characters, calendar, cameraRig, particles, collision, level, nav) lists what a replacement must supply, and `runContract` checks it. The slots below have no contract; a replacement must supply what the engine's own callers read:
|
|
73
|
+
|
|
74
|
+
| Slot | A replacement must supply |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `sky` | the `engine.uniforms` signals your `picture/` code reads; `dome` (the object a photo leaves out) if it has one |
|
|
77
|
+
| `terrain` | the ground through `engine.setGround`; `chunkSize`, `stats`, `edit` (nav), `view` and `setPlanter` (vegetation). Replace `terrain-draw` with it: the drawing half reads the engine terrain's chunks |
|
|
78
|
+
| `weather` | `types`, `name`, `current`, `label(name)`, `set(name, { seconds })`, `setAuto(on)`. Replace `weatherDraw` with it |
|
|
79
|
+
| `vegetation` | `define(name, rule)` (content), `instanceAt(point, { radius })` (photo), `host` (settings). Replace `vegetation-draw` with it |
|
|
80
|
+
| `rigid` | `vehicles`, a list of objects that meet `modules/characters/vehicle.contract.js` |
|
|
81
|
+
| `swarm` | nothing: no other module calls it |
|
|
82
|
+
|
|
83
|
+
**Not replaceable**: `world` (saves, the shared id space, streaming and content stand on its records; it provides the slot so that `requires: ['world']` names a capability), and the player inside `characters` (a replacement of `characters` leaves a live player's `world` record behind, and `engine.player` is the engine's own character; steer it with `control.take`).
|
|
59
84
|
|
|
60
85
|
The starting picture comes from the game's `picture/` folder; what it builds as a factory can also be passed at the call site, and the
|
|
61
86
|
call site wins (`terrain({ material })` and the like; the water surface is `engine.water.material`); a new style factory ships with its call-site option. No module option starts a value taken over.
|
|
@@ -74,7 +99,7 @@ into, or a convenience for after.
|
|
|
74
99
|
| Windows, signs, screens glow at night | a material whose `emissiveIntensity` reads `engine.uniforms.uNight` (recipe 09 §1b) | `lightPool.add(obj, { glow })` is something else: the stand-in a pooled lamp shows while it holds no real light |
|
|
75
100
|
| Time of day | `engine.calendar` (`calendar({ time })`) | no calendar at all (one fixed scene): `sky({ time })`; timers: `engine.clock`; one group faster / slower: a time channel |
|
|
76
101
|
| Sun / light strength | your own three.js light in `picture/`, reading `engine.uniforms` (recipe 62) | the placeholders: write `engine.lights.sun` directly |
|
|
77
|
-
| A game test (write one for your game) | a spec file `tests/specs/<name>.mjs` exporting `specs` (COMMANDS.md "A game's tests": minimal example, `
|
|
102
|
+
| A game test (write one for your game) | a spec file `tests/specs/<name>.mjs` exporting `specs` (COMMANDS.md "A game's tests": minimal example, `threedog test <name>`) | the test is steps and checks only: a scenario JSON `tests/scenarios/<name>.json` (recipes/23 §7); compare whole state: describe snapshots (recipes/16 §7) |
|
|
78
103
|
| Teleport the player | `player.placeAt(p)` in an op | not streamed in yet: `await engine.stream.teleport(p)` (waits, then places); a test or scenario: `applyState({ pos })` |
|
|
79
104
|
| Camera | install one: `openWorld({ camera })`, `engine.use(fixedCamera({ position, lookAt }))` | switch kinds at runtime: `setCamera(kind)`; a shot of your own: `takeCamera(owner)` |
|
|
80
105
|
| Sky | `sky({ ... })` start values, tuned through `engine.uniforms` and `engine.sky` | a custom sky of your own (shader dome, skybox, painted backdrop): `engine.sky.replace(obj)` (recipe 08 "Your own sky object"); on WebGPU three's `SkyMesh` the same way |
|
|
@@ -83,11 +108,11 @@ into, or a convenience for after.
|
|
|
83
108
|
| Ambient occlusion | `engine.post.add(ao())` (screen space) | a model made in code: `bakeVertexAO(geometry)`; bounce light between places: `bakeProbes` |
|
|
84
109
|
|
|
85
110
|
## Owners
|
|
86
|
-
Everything that holds the engine is named by an owner, and only that owner releases it. Positional `
|
|
111
|
+
Everything that holds the engine is named by an owner, and only that owner releases it. Positional `freeze('menu')` and `freeze({ owner: 'menu' })` are the same.
|
|
87
112
|
|
|
88
113
|
| What | Take | Release | Returns |
|
|
89
114
|
|---|---|---|---|
|
|
90
|
-
| Real-time loop | `
|
|
115
|
+
| Real-time loop | `haltLoop(owner)` (tests and tools; a game freezes) | `handle.remove()` | handle `{ remove() }` |
|
|
91
116
|
| Gameplay freeze | `freeze(owner, { kind? })` | `handle.remove()` | handle |
|
|
92
117
|
| Camera | `takeCamera(owner, { focus? })` | `handle.remove()` | handle |
|
|
93
118
|
| Where a character goes | `control.take(character, { owner, layer, step? })` (layers base < script < cutscene < net; higher pauses lower) | `handle.remove()` | handle `{ active, move(), remove() }` |
|
|
@@ -98,10 +123,10 @@ Everything that holds the engine is named by an owner, and only that owner relea
|
|
|
98
123
|
not contain functions.
|
|
99
124
|
Workers are created only through `engine.threads.lane({ create, local })` (the same handler runs on the main thread when there are no workers); no
|
|
100
125
|
`new Worker` / `postMessage` elsewhere (`npm run check` rule R19). Worker files import only worker-safe code (a game:
|
|
101
|
-
`import { serve } from 'threedog/worker'`; inside the engine `core/threadServe.js`, `core/threadPure.js`), never `core/Threads.js` or three.js.
|
|
126
|
+
`import { serve } from 'threedog/worker'`; inside the engine `core/threads/threadServe.js`, `core/threads/threadPure.js`), never `core/threads/Threads.js` or three.js.
|
|
102
127
|
|
|
103
128
|
### Worker results that change gameplay: `engine.commits`
|
|
104
|
-
A result that changes gameplay never takes effect "when it arrives"; it takes effect on a fixed tick decided when you ask (`engine.tick + lag`,
|
|
129
|
+
A result that changes gameplay never takes effect "when it arrives"; it takes effect on a fixed tick decided when you ask (`engine.time.tick + lag`,
|
|
105
130
|
default 30 steps), so threads on or off, fast or slow machine, give the same state.
|
|
106
131
|
```js
|
|
107
132
|
const t = engine.commits.request({
|
|
@@ -148,7 +173,7 @@ inside template strings, which then throw on the first call).
|
|
|
148
173
|
returns the added object, `inventory.add` returns a result, `world.add` a record; delete those with `engine.remove(obj)` / their own remove call.
|
|
149
174
|
- **Verbs**: defining a kind is `define` (`vegetation.define`, `particles.define`, `grids.define`, `ops.define`); placing one is `add` / `spawn`;
|
|
150
175
|
hooking up a provider the engine calls back is `register` (`saves.register(key, { save, load })`: it defines no kind and places nothing).
|
|
151
|
-
One timer entry: `engine.clock.after(seconds, fn, data,
|
|
176
|
+
One timer entry: `engine.clock.after(seconds, fn, { data, channel })` (calendar seconds, or `'real'` / a time channel's seconds with `channel`);
|
|
152
177
|
one queue, so `remove()` is immediate: a removed timer never fires, not even later in the same step.
|
|
153
178
|
- **Unknown options throw**: every options bag goes through a `readParams` schema (one schema gives the check, the defaults and the catalog entry); an
|
|
154
179
|
unknown key throws in dev with a did-you-mean and warns once in a release build; `checkOptions` is only for extensible data (item, template
|
|
@@ -157,7 +182,7 @@ inside template strings, which then throw on the first call).
|
|
|
157
182
|
- **Event names are `noun:action`**: the noun is the emitter's singular camelCase name (`item`, `template`...), the action is a lowercase verb or state
|
|
158
183
|
(`add`, `done`, `change`); a game's own events follow the same rule (`door:open`).
|
|
159
184
|
- **Time**: one source, `engine.time.tick`; real, ambient, channel and calendar seconds are read-only views (`engine.time.now(name)`), and only
|
|
160
|
-
`core/time.js` adds to them (a spec checks). Always name the unit, real, channel or calendar seconds; `recipes/06-clock-events.md` defines them (and the calendar's time of day) and has
|
|
185
|
+
`core/time/time.js` adds to them (a spec checks). Always name the unit, real, channel or calendar seconds; `recipes/06-clock-events.md` defines them (and the calendar's time of day) and has
|
|
161
186
|
the table of which one to use for movement, action timelines, cooldowns, hit-stop, crop growth, calendar and UI, and what pause / freeze /
|
|
162
187
|
`clock.rate` 2 do to each. Speeds change only through `engine.mod` (the "Customization ladder" above).
|
|
163
188
|
- **Input**: gameplay keys (attack, jump, interact...) are read in the fixed step (`onFixed` / module `fixed`), where `pressed / down / released` give
|
|
@@ -184,7 +209,7 @@ inside template strings, which then throw on the first call).
|
|
|
184
209
|
belongs to the Character mover; other systems only request movement (`placeAt` / `move` / vehicle `enter`) and never set `player.position` directly.
|
|
185
210
|
Who calls `move` is the character's control holder (`engine.control`, `recipes/57-control.md`): one per step; anyone else is `[control-bypass]`.
|
|
186
211
|
- Units are meters, Y is up, north is -Z. Characters and vehicles face the model's +Z; `facing` 0 = +Z, forward = (sin f, cos f).
|
|
187
|
-
- Never call `requestAnimationFrame` or `renderer.render` yourself. **Game logic always uses
|
|
212
|
+
- Never call `requestAnimationFrame` or `renderer.render` yourself. **Game logic always uses real seconds or calendar seconds** (the hook's `dt`,
|
|
188
213
|
`engine.clock`; see the time table in `recipes/06-clock-events.md`); no `setTimeout` / `setInterval` / `performance.now()`: they ignore pause,
|
|
189
214
|
freeze and `engine.step` fast-forward, so they can't be tested or saved.
|
|
190
215
|
- To be saved, call `engine.saves.register(key, { save, load })` (`load` may return a Promise); `saves.save / load` always return `Promise<boolean>`,
|
|
@@ -197,7 +222,7 @@ inside template strings, which then throw on the first call).
|
|
|
197
222
|
`terrain({ height, groundType })` must be pure functions.
|
|
198
223
|
- Loading follows the `engine.stream` sources (player + camera focus by default); display, physics and world data are separate: unloading a model
|
|
199
224
|
never removes its world record.
|
|
200
|
-
- Window blur, tab hidden, pointer lock and WebGL context loss are listened to only in `core/page.js`; modules read `engine.page` or listen to
|
|
225
|
+
- Window blur, tab hidden, pointer lock and WebGL context loss are listened to only in `core/engine/page.js`; modules read `engine.page` or listen to
|
|
201
226
|
`page:*`. Show "saved" only after `saves.save` returns true.
|
|
202
227
|
- Character bodies are assets: `createPlayer({ ...presets.player.thirdPerson, model: 'humanoid' | 'hero' })` (a procedural builder is built
|
|
203
228
|
now; a file shows a gray capsule and is swapped in when it loads: `await player.whenReady`, event `character:model`), or `{ rig }`; a name no model
|
|
@@ -210,4 +235,19 @@ inside template strings, which then throw on the first call).
|
|
|
210
235
|
## Failures: which shape
|
|
211
236
|
A runtime "can't" (not enough money, shelf empty) is returned as `{ ok: false, code, facts, nextActions }` (ops.run / can / undo, and direct calls such as `container.trade`, which a module builds by returning that shape, or a code string from an op's `can`). Misuse (a wrong call, a typo) is a thrown `codedError`. Documented exceptions: `checkSkip` / `checkSave` return `{ ok, diffs }`, `walkTo` returns `{ status }`. Read `code` (there is no `reason` field). Predicates (op `can`, `grid.can()`) may return a plain code string.
|
|
212
237
|
|
|
213
|
-
Inside the engine a failure takes one of three forms, so every one reaches the reader with a code, a fix and a page: misuse throws `codedError(code, message)` with an `ERROR_CODES` entry (`core/errorCodes.js`: what to change, which page to read); a recoverable problem warns once with `warnOnce(coded(code, message))`; a game or module callback that threw goes to `reportError`. Check rule R45 rejects a plain `throw new Error` and a bare `console.warn` / `console.error` in engine code.
|
|
238
|
+
Inside the engine a failure takes one of three forms, so every one reaches the reader with a code, a fix and a page: misuse throws `codedError(code, message)` with an `ERROR_CODES` entry (`core/base/errorCodes.js`: what to change, which page to read); a recoverable problem warns once with `warnOnce(coded(code, message))`; a game or module callback that threw goes to `reportError`. Check rule R45 rejects a plain `throw new Error` and a bare `console.warn` / `console.error` in engine code.
|
|
239
|
+
|
|
240
|
+
## Stability
|
|
241
|
+
|
|
242
|
+
`@experimental` means one thing: the name may change or go in any version, with no migration note. Everything unmarked is frozen at 1.0.
|
|
243
|
+
|
|
244
|
+
- **How to see it.** The tag sits on the declaration, so an editor shows it; `api/*.md` prints `(experimental)`; the name's line in `docs/api-surface.txt` ends with it. A tag on a module or an engine member covers what hangs off it. A value or a sub-command has no line of its own, so its docs say so.
|
|
245
|
+
- **How it is kept.** The API lock (rule R55) lets a marked name change. Marking a stable name needs a line in the changelog: the mark takes a promise back.
|
|
246
|
+
- **Objects from other libraries**, which follow that library's version: `rigid.rapier / world / playerBody / playerCollider`, `nav.navMesh / query / tileCache / crowd / helper`, `assets.gltf / draco / ktx2`, `post.object / targets`, `shadows.csm`.
|
|
247
|
+
- **Effects still moving with three.js**: all of `threedog/tsl` and `@threedog/post-effects/tsl`.
|
|
248
|
+
- **Names nothing uses yet**: a public name no game, recipe, example or template used at 0.8 stays marked until one does; `docs/api-surface.txt` lists them.
|
|
249
|
+
- **Coordination no test game has used**: `engine.stacks`, `engine.wrap`, `engine.mod`, `time.channel / channels`.
|
|
250
|
+
- **Systems still settling**: `net()`, `engine.threads`, `engine.commits`, `grids()`, `hlod()`, `swarm()`, `stream.source / teleport / addReadyCheck / sources`, `post.get / own / setAntialias / list`, `world.simulate({ worker })`, `terrain.edit`, `ops.guard / allow`, `terrainDraw`, `vegetationDraw`, `weatherDraw`, `engine.bakeProbes / loadProbes / loadLightmap`.
|
|
251
|
+
- **Flat content**: an entry's `source`, `content stamp`, `content capture`.
|
|
252
|
+
- **Tuning and readings**: `engine.moduleOrder / moduleStates / disabledModules`, `player.saveMotion / loadMotion`, `jobs.loadingMs / maxSteps / slowStepMs`, `stream.unloadFactor`, `batching.held`, `world.steps`, `level.heightfield`.
|
|
253
|
+
- **Commands.** Only the `--json` and MCP shapes are an interface; printed text keeps changing for AI readers. An error's `code` string is frozen, its message is not.
|