threedog 0.2.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +290 -0
- package/README.md +9 -8
- package/core/Animator.js +15 -12
- package/core/Assets.js +71 -16
- package/core/Audio.js +45 -38
- package/core/Baked.js +32 -8
- package/core/Batching.js +102 -15
- package/core/Budget.js +39 -18
- package/core/Clock.js +40 -80
- package/core/DebugOverrides.js +45 -10
- package/core/Describe.js +104 -43
- package/core/Engine.js +183 -59
- package/core/Events.js +4 -1
- package/core/I18n.js +25 -13
- package/core/Input.js +168 -79
- package/core/Inspect.js +2 -2
- package/core/InspectMaterials.js +85 -0
- package/core/InspectPerf.js +61 -0
- package/core/InspectScene.js +13 -2
- package/core/Loading.js +2 -1
- package/core/Ops.js +50 -9
- package/core/Random.js +9 -2
- package/core/Rays.js +5 -5
- package/core/SaveStore.js +41 -9
- package/core/Saves.js +71 -15
- package/core/Stream.js +14 -10
- package/core/Threads.js +26 -7
- package/core/UrlState.js +25 -9
- package/core/Views.js +9 -6
- package/core/actor.js +1 -1
- package/core/adaptive.js +93 -0
- package/core/assetEntry.js +22 -5
- package/core/assetHot.js +176 -0
- package/core/assetLoad.js +38 -11
- package/core/assetManifest.js +48 -9
- package/core/assetReport.js +1 -1
- package/core/audioRules.js +13 -11
- package/core/audioVoice.js +69 -42
- package/core/canvasBox.js +1 -2
- package/core/catalog.js +5 -2
- package/core/cells.js +62 -0
- package/core/checks.js +10 -8
- package/core/chunkStream.js +87 -0
- package/core/control.js +149 -0
- package/core/copies.js +32 -0
- package/core/dayTime.js +12 -6
- package/core/debugView.js +82 -15
- package/core/describeRender.js +37 -17
- package/core/describeText.js +41 -21
- package/core/engineCamera.js +32 -0
- package/core/errorCodes.js +438 -19
- package/core/errorHints.js +37 -141
- package/core/errors.js +31 -8
- package/core/events.generated.js +12 -7
- package/core/gameLights.js +62 -0
- package/core/grayMap.js +20 -0
- package/core/grid.js +14 -13
- package/core/gridLoad.js +2 -1
- package/core/ground.js +6 -4
- package/core/headlessLoad.js +55 -0
- package/core/holds.js +78 -50
- package/core/inputContext.js +11 -7
- package/core/inputDefaults.js +24 -21
- package/core/inputPad.js +1 -1
- package/core/inputPointer.js +1 -1
- package/core/inputTouch.js +2 -2
- package/core/lifecycle.js +48 -12
- package/core/lightWatch.js +6 -4
- package/core/look/coreParts.js +137 -30
- package/core/look/part.js +175 -95
- package/core/look/points.js +255 -0
- package/core/look/report.js +34 -17
- package/core/look/shadowPart.js +63 -0
- package/core/look/state.js +45 -0
- package/core/look/write.js +12 -28
- package/core/loop.js +100 -41
- package/core/math.js +11 -3
- package/core/moduleSlots.js +75 -0
- package/core/moduleTypes.js +73 -0
- package/core/modules.js +145 -27
- package/core/movement.js +2 -2
- package/core/namedModel.js +70 -0
- package/core/opsCheck.js +3 -3
- package/core/opsFail.js +15 -6
- package/core/opsGuard.js +4 -4
- package/core/opsRun.js +4 -3
- package/core/owned.js +168 -0
- package/core/page.js +2 -1
- package/core/params.js +30 -8
- package/core/plugins.js +277 -0
- package/core/saveApply.js +99 -17
- package/core/saveFiles.js +8 -6
- package/core/saveValues.js +46 -0
- package/core/saveVersions.js +20 -3
- package/core/scatter.js +48 -19
- package/core/sceneDelta.js +203 -0
- package/core/sceneMethods.js +35 -30
- package/core/screenToGround.js +1 -1
- package/core/services.js +27 -11
- package/core/session.js +28 -25
- package/core/shaderCost.js +78 -0
- package/core/shadowTypes.js +2 -1
- package/core/sharedPoint.js +317 -0
- package/core/skip.js +36 -28
- package/core/stackFrames.js +34 -0
- package/core/stacks.js +166 -0
- package/core/startup.js +153 -11
- package/core/streamSources.js +0 -11
- package/core/styleParts.js +63 -47
- package/core/targeting.js +1 -1
- package/core/textureBytes.js +20 -0
- package/core/thingExplain.js +2 -2
- package/core/thingOps.js +29 -6
- package/core/things.js +21 -11
- package/core/threadPure.js +7 -3
- package/core/threePatches.js +47 -0
- package/core/tier.js +21 -10
- package/core/time.js +236 -0
- package/core/uiClock.js +25 -0
- package/core/util.js +7 -1
- package/core/validate.js +65 -86
- package/core/wrap.js +106 -0
- package/docs/AI.md +87 -100
- package/docs/API.md +32 -28
- package/docs/CODEMAP.md +220 -147
- package/docs/COMMANDS.md +56 -35
- package/docs/CONVENTIONS.md +90 -28
- package/docs/MIGRATING-0.3.md +248 -0
- package/docs/MIGRATING-0.4.md +228 -0
- package/docs/MIGRATING-0.5.md +68 -0
- package/docs/PERF.md +35 -7
- package/docs/THREE.md +79 -27
- package/docs/api/ambience.md +0 -1
- package/docs/api/assets.md +11 -9
- package/docs/api/audio.md +10 -14
- package/docs/api/calendar.md +41 -0
- package/docs/api/cameraRig.md +16 -5
- package/docs/api/characters.md +38 -23
- package/docs/api/clock.md +6 -5
- package/docs/api/collision.md +9 -6
- package/docs/api/content.md +6 -4
- package/docs/api/dialogue.md +9 -9
- package/docs/api/engine.md +63 -60
- package/docs/api/events.md +19 -14
- package/docs/api/grids.md +3 -3
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +11 -6
- package/docs/api/interactions.md +7 -5
- package/docs/api/inventory.md +17 -16
- package/docs/api/level.md +0 -1
- package/docs/api/lightPool.md +3 -1
- package/docs/api/music.md +1 -1
- package/docs/api/nav.md +3 -0
- package/docs/api/openWorld.md +2 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +0 -2
- package/docs/api/pickups.md +15 -0
- package/docs/api/post.md +5 -4
- package/docs/api/quests.md +2 -3
- package/docs/api/rigid.md +16 -14
- package/docs/api/saves.md +6 -4
- package/docs/api/settings.md +2 -3
- package/docs/api/sky.md +11 -44
- package/docs/api/stream.md +1 -1
- package/docs/api/style.md +28 -26
- package/docs/api/terrain.md +9 -6
- package/docs/api/terrainLook.md +10 -0
- package/docs/api/timeline.md +3 -4
- package/docs/api/tools.md +29 -13
- package/docs/api/triggers.md +5 -10
- package/docs/api/vegetation.md +11 -8
- package/docs/api/vegetationLook.md +10 -0
- package/docs/api/water.md +4 -20
- package/docs/api/weather.md +5 -15
- package/docs/api/weatherLook.md +10 -0
- package/docs/api/world.md +2 -1
- package/docs/recipes/01-new-game.md +48 -34
- package/docs/recipes/02-npc.md +24 -7
- package/docs/recipes/03-items-pickups.md +35 -21
- package/docs/recipes/04-quests.md +12 -5
- package/docs/recipes/05-props-bake.md +151 -15
- package/docs/recipes/06-clock-events.md +100 -52
- package/docs/recipes/07-flow-scenes-pause.md +40 -9
- package/docs/recipes/08-weather-sky.md +145 -36
- package/docs/recipes/{09-style-pack.md → 09-style.md} +101 -52
- package/docs/recipes/10-blender-level.md +14 -2
- package/docs/recipes/11-vehicles.md +64 -7
- package/docs/recipes/13-animation.md +14 -6
- package/docs/recipes/14-custom-module.md +61 -29
- package/docs/recipes/15-perf.md +30 -9
- package/docs/recipes/16-dev-bridge.md +61 -37
- package/docs/recipes/18-world.md +16 -6
- package/docs/recipes/19-shooting-picking.md +6 -6
- package/docs/recipes/20-content-actions-save.md +55 -17
- package/docs/recipes/21-camera.md +49 -16
- package/docs/recipes/22-shop-gold.md +3 -3
- package/docs/recipes/23-ops.md +16 -10
- package/docs/recipes/26-ui-parts.md +61 -12
- package/docs/recipes/27-net.md +11 -5
- package/docs/recipes/28-terrain.md +34 -1
- package/docs/recipes/29-grid.md +34 -16
- package/docs/recipes/30-templates.md +64 -12
- package/docs/recipes/31-audio.md +20 -12
- package/docs/recipes/32-action-game.md +35 -2
- package/docs/recipes/34-environment-lighting.md +26 -3
- package/docs/recipes/35-style-from-reference.md +88 -19
- package/docs/recipes/36-sky-ground-plant-looks.md +18 -18
- package/docs/recipes/37-terrain-look-hooks.md +3 -2
- package/docs/recipes/38-environment-look-hooks.md +37 -26
- package/docs/recipes/40-scene.md +16 -13
- package/docs/recipes/41-thing-registry.md +11 -7
- package/docs/recipes/42-terrain-shape.md +2 -2
- package/docs/recipes/43-shader-patches-surface-looks.md +158 -76
- package/docs/recipes/44-water-weather-look-hooks.md +26 -17
- package/docs/recipes/45-cascaded-shadows.md +16 -7
- package/docs/recipes/47-island-snow-backdrop.md +7 -7
- package/docs/recipes/48-make-material.md +11 -6
- package/docs/recipes/49-game-module-contract.md +30 -17
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/51-capability-catalog.md +3 -3
- package/docs/recipes/52-look.md +197 -61
- package/docs/recipes/53-ground-up-close.md +1 -1
- package/docs/recipes/54-three-idioms.md +88 -0
- package/docs/recipes/55-mods-time-wrap.md +112 -0
- package/docs/recipes/56-webgpu-tsl.md +260 -0
- package/docs/recipes/57-control.md +65 -0
- package/docs/recipes/58-input.md +57 -0
- package/docs/recipes/59-depth-post-effects.md +83 -0
- package/docs/recipes/60-judge-the-picture.md +55 -0
- package/examples/action/.threedog/content-index.json +1 -0
- package/examples/action/GAMEMAP.md +17 -13
- package/examples/action/assets.js +8 -0
- package/examples/action/content/actions.js +1 -1
- package/examples/action/content/audio.js +5 -5
- package/examples/action/look.js +1 -1
- package/examples/action/main.js +10 -14
- package/examples/action/models.js +24 -23
- package/examples/pullable.json +111 -0
- package/examples/rc2d/.threedog/content-index.json +1 -0
- package/examples/rc2d/GAMEMAP.md +83 -0
- package/examples/rc2d/README.md +52 -0
- package/examples/rc2d/main.js +63 -0
- package/examples/rc2d/rc2d.js +197 -0
- package/examples/rc2d/shaders.js +144 -0
- package/examples/sheepisland/.threedog/content-index.json +1 -0
- package/examples/sheepisland/GAMEMAP.md +13 -11
- package/examples/sheepisland/assets.js +5 -0
- package/examples/sheepisland/main.js +17 -12
- package/examples/sheepisland/style/index.js +6 -6
- package/examples/styletest/.threedog/content-index.json +1 -0
- package/examples/styletest/GAMEMAP.md +15 -16
- package/examples/styletest/assets.js +6 -0
- package/examples/styletest/content/templates.js +1 -1
- package/examples/styletest/content/vegetation.js +1 -1
- package/examples/styletest/look.js +1 -1
- package/examples/styletest/main.js +17 -16
- package/examples/styletest/models.js +1 -1
- package/examples/styletest/params.js +3 -3
- package/examples/techniques/contact-shadows/README.md +92 -0
- package/examples/techniques/contact-shadows/contactShadows.js +51 -0
- package/examples/techniques/contact-shadows/main.js +53 -0
- package/examples/techniques/day-night-grade/README.md +86 -0
- package/examples/techniques/day-night-grade/dayNightGrade.js +76 -0
- package/examples/techniques/day-night-grade/main.js +51 -0
- package/examples/techniques/interior-light/README.md +103 -0
- package/examples/techniques/interior-light/interiorLight.js +45 -0
- package/examples/techniques/interior-light/main.js +124 -0
- package/examples/techniques/modular-building/README.md +125 -0
- package/examples/techniques/modular-building/kit.js +426 -0
- package/examples/techniques/modular-building/main.js +47 -0
- package/examples/techniques/night-lights/README.md +94 -0
- package/examples/techniques/night-lights/main.js +70 -0
- package/examples/techniques/night-lights/nightLights.js +91 -0
- package/examples/techniques/outlines-and-rim/README.md +59 -0
- package/examples/techniques/outlines-and-rim/main.js +84 -0
- package/examples/techniques/outlines-and-rim/outlines.js +64 -0
- package/examples/techniques/procedural-animation/README.md +77 -0
- package/examples/techniques/procedural-animation/creature.js +44 -0
- package/examples/techniques/procedural-animation/main.js +45 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +118 -0
- package/examples/techniques/procedural-surface/README.md +67 -0
- package/examples/techniques/procedural-surface/main.js +103 -0
- package/examples/techniques/procedural-surface/surface.js +120 -0
- package/examples/techniques/stylized-shading/README.md +75 -0
- package/examples/techniques/stylized-shading/main.js +93 -0
- package/examples/techniques/stylized-shading/shading.js +131 -0
- package/examples/techniques/sun-and-key-light/README.md +135 -0
- package/examples/techniques/sun-and-key-light/keyLight.js +53 -0
- package/examples/techniques/sun-and-key-light/main.js +95 -0
- package/examples/techniques/wet-road/README.md +99 -0
- package/examples/techniques/wet-road/main.js +68 -0
- package/examples/techniques/wet-road/wetRoad.js +209 -0
- package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
- package/examples/webgpu-tsl/GAMEMAP.md +84 -0
- package/examples/webgpu-tsl/README.md +42 -0
- package/examples/webgpu-tsl/main.js +21 -0
- package/examples/webgpu-tsl/tslScene.js +75 -0
- package/examples/world/.threedog/content-index.json +1 -0
- package/examples/world/GAMEMAP.md +22 -15
- package/examples/world/art/humanoid.js +42 -0
- package/examples/world/art/index.js +11 -0
- package/examples/world/art/models.js +58 -0
- package/examples/world/art/shapes.js +9 -0
- package/examples/world/assets.js +6 -0
- package/examples/world/content/audio.js +5 -5
- package/examples/world/content/npcs.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/rules.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +17 -13
- package/examples/world/style/index.js +61 -0
- package/examples/world/style/plugins/10-bloom.js +5 -0
- package/index.d.ts +44 -45
- package/index.js +26 -22
- package/llms.txt +11 -4
- package/modules/ambience/Ambience.js +34 -23
- package/modules/calendar/Calendar.js +163 -0
- package/modules/calendar/contract.js +21 -0
- package/modules/calendar/index.js +81 -0
- package/modules/{sky → calendar}/schedule.js +17 -16
- package/modules/calendar/seasons.js +55 -0
- package/modules/camera/FirstPersonCamera.js +6 -15
- package/modules/camera/FixedCamera.js +33 -15
- package/modules/camera/FollowCamera.js +90 -16
- package/modules/camera/RtsCamera.js +18 -17
- package/modules/camera/common.js +70 -19
- package/modules/camera/contract.js +17 -0
- package/modules/camera/projection.js +11 -24
- package/modules/characters/Character.js +177 -42
- package/modules/characters/NPC.js +87 -36
- package/modules/characters/assetModel.js +4 -13
- package/modules/characters/behaviors.js +2 -1
- package/modules/characters/contract.js +13 -0
- package/modules/characters/footsteps.js +1 -1
- package/modules/characters/index.js +87 -49
- package/modules/characters/moveHelpers.js +4 -5
- package/modules/characters/movers/common.js +97 -19
- package/modules/characters/movers/manual.js +20 -0
- package/modules/characters/movers/rapier.js +19 -16
- package/modules/characters/movers/simple.js +14 -11
- package/modules/characters/movers/support.js +172 -0
- package/modules/characters/npcAvoid.js +47 -42
- package/modules/characters/npcSim.js +12 -8
- package/modules/characters/npcView.js +44 -16
- package/modules/characters/pathAsync.js +7 -3
- package/modules/characters/playerStrings.js +4 -3
- package/modules/characters/proceduralRig.js +2 -1
- package/modules/characters/useModel.js +1 -1
- package/modules/characters/vehicle.contract.js +21 -0
- package/modules/characters/walkTo.js +21 -7
- package/modules/collision/Collision.js +65 -25
- package/modules/collision/grid.js +8 -6
- package/modules/content/explain.js +2 -2
- package/modules/content/fields.js +102 -0
- package/modules/content/ids.js +8 -6
- package/modules/content/index.js +96 -27
- package/modules/content/loader.js +45 -33
- package/modules/content/models.js +11 -40
- package/modules/content/packs.js +6 -5
- package/modules/content/parts.js +41 -0
- package/modules/content/props.js +16 -9
- package/modules/content/rules.js +58 -0
- package/modules/content/stages.js +80 -0
- package/modules/content/templates.js +121 -30
- package/modules/debug/DebugPanel.js +24 -17
- package/modules/flow/contract.js +16 -0
- package/modules/flow/index.js +21 -15
- package/modules/gameplay/Container.js +41 -32
- package/modules/gameplay/Containers.js +30 -15
- package/modules/gameplay/Dialogue.js +113 -55
- package/modules/gameplay/Interactions.js +193 -67
- package/modules/gameplay/Inventory.js +69 -73
- package/modules/gameplay/Quests.js +75 -39
- package/modules/gameplay/boxOps.js +3 -3
- package/modules/gameplay/dialogue.contract.js +21 -0
- package/modules/gameplay/dialogueBox.js +4 -2
- package/modules/gameplay/dialogueBubbles.js +116 -0
- package/modules/gameplay/interactionPrompt.js +4 -1
- package/modules/gameplay/interactions.contract.js +16 -0
- package/modules/gameplay/inventory.contract.js +23 -0
- package/modules/gameplay/inventoryOps.js +18 -16
- package/modules/gameplay/pickups.js +268 -85
- package/modules/gameplay/questLog.js +4 -4
- package/modules/gameplay/quests.contract.js +17 -0
- package/modules/grid/Grid.js +92 -50
- package/modules/grid/Layer.js +14 -13
- package/modules/grid/index.js +60 -36
- package/modules/grid/ops.js +20 -18
- package/modules/grid/preview.js +15 -16
- package/modules/grid/strings.js +12 -0
- package/modules/grid/tiles.js +6 -5
- package/modules/hlod/index.js +51 -19
- package/modules/hud/index.js +35 -20
- package/modules/hud/parts.js +20 -7
- package/modules/level/heightfield.js +3 -1
- package/modules/level/index.js +45 -20
- package/modules/level/nodes.js +4 -3
- package/modules/lights/index.js +42 -18
- package/modules/music/Music.js +38 -21
- package/modules/music/rules.js +1 -1
- package/modules/nav/index.js +48 -42
- package/modules/net/Client.js +13 -6
- package/modules/net/Host.js +19 -5
- package/modules/net/Net.js +2 -1
- package/modules/net/index.js +13 -8
- package/modules/net/sync.js +9 -8
- package/modules/net/transports.js +77 -27
- package/modules/particles/Particles.js +23 -14
- package/modules/particles/contract.js +17 -0
- package/modules/particles/effect.js +39 -11
- package/modules/photo/Photo.js +53 -36
- package/modules/rigid/RigidBodies.js +194 -32
- package/modules/rigid/Vehicles.js +18 -15
- package/modules/rigid/sync.js +62 -17
- package/modules/settings/Settings.js +57 -52
- package/modules/settings/apply.js +38 -3
- package/modules/settings/sections.js +5 -3
- package/modules/settings/strings.js +3 -2
- package/modules/settings/view.js +5 -3
- package/modules/sky/Sky.js +88 -176
- package/modules/sky/cascades.js +86 -25
- package/modules/sky/cascades.tsl.js +82 -0
- package/modules/sky/clouds.js +34 -19
- package/modules/sky/domeLayers.js +30 -15
- package/modules/sky/environment.js +83 -13
- package/modules/sky/fog.js +140 -95
- package/modules/sky/frame.js +112 -44
- package/modules/sky/look.js +22 -19
- package/modules/sky/lookFog.js +48 -52
- package/modules/sky/lookShadow.js +53 -41
- package/modules/sky/lookSky.js +82 -21
- package/modules/sky/season.js +21 -0
- package/modules/sky/shader.js +41 -19
- package/modules/sky/shadow.js +44 -20
- package/modules/sky/skyModule.js +45 -33
- package/modules/sky/tint.js +61 -0
- package/modules/terrain/ChunkManager.js +175 -108
- package/modules/terrain/chunkJob.js +1 -1
- package/modules/terrain/chunkQueries.js +6 -4
- package/modules/terrain/index.js +105 -50
- package/modules/terrain/look.js +83 -0
- package/modules/terrain/lookGround.js +21 -16
- package/modules/terrain/terrainDefaults.js +1 -1
- package/modules/terrain/terrainEdit.js +18 -20
- package/modules/terrain/terrainGen.js +5 -3
- package/modules/terrain/terrainIsland.js +5 -4
- package/modules/terrain/terrainShape.js +12 -12
- package/modules/terrain/terrainShapeMain.js +8 -7
- package/modules/terrain/terrainTexture.js +21 -19
- package/modules/timeline/Timeline.js +95 -43
- package/modules/timeline/Tween.js +18 -10
- package/modules/timeline/letterbox.js +2 -2
- package/modules/timeline/shots.js +5 -1
- package/modules/triggers/index.js +107 -76
- package/modules/vegetation/Vegetation.js +186 -110
- package/modules/vegetation/densityMap.js +62 -0
- package/modules/vegetation/groundChunks.js +52 -58
- package/modules/vegetation/index.js +32 -11
- package/modules/vegetation/look.js +119 -0
- package/modules/vegetation/lookWind.js +71 -10
- package/modules/vegetation/modelGeometry.js +3 -2
- package/modules/vegetation/nearFade.js +8 -2
- package/modules/water/Water.js +65 -27
- package/modules/water/look.js +29 -18
- package/modules/water/surface.js +64 -25
- package/modules/water/surfaceDefaults.js +3 -0
- package/modules/weather/Weather.js +62 -104
- package/modules/weather/look.js +1 -2
- package/modules/weather/particles.js +24 -9
- package/modules/weather/strings.js +2 -2
- package/modules/weather/weatherLook.js +135 -0
- package/modules/world/World.js +24 -7
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -4
- package/modules/world/persist.js +62 -2
- package/modules/world/pos.js +3 -2
- package/modules/world/records.js +8 -6
- package/modules/world/sim.js +60 -20
- package/modules/world/simFar.js +4 -3
- package/modules/world/state.js +3 -2
- package/modules/world/thingSource.js +1 -1
- package/modules/world/views.js +7 -5
- package/package.json +7 -3
- package/presets.js +41 -27
- package/render/PostFX.js +145 -120
- package/render/backend.js +440 -0
- package/render/detail.js +120 -39
- package/render/effects.js +130 -38
- package/render/engineUniforms.js +10 -1
- package/render/fuse.js +5 -4
- package/render/fx/cloudShadow.tsl.js +16 -0
- package/render/fx/detail.tsl.js +66 -0
- package/render/fx/index.js +26 -0
- package/render/fx/lighting.tsl.js +28 -0
- package/render/fx/nodeErrors.tsl.js +68 -0
- package/render/fx/noise.tsl.js +12 -0
- package/render/fx/objectOrigin.tsl.js +42 -0
- package/render/fx/particles.tsl.js +139 -0
- package/render/fx/patchNodes.tsl.js +403 -0
- package/render/fx/postWebGPU.tsl.js +158 -0
- package/render/fx/season.tsl.js +13 -0
- package/render/fx/sky.tsl.js +260 -0
- package/render/fx/uniforms.tsl.js +67 -0
- package/render/fx/water.tsl.js +53 -0
- package/render/fx/wind.tsl.js +22 -0
- package/render/fxNumbers.js +36 -0
- package/render/hotGlsl.js +24 -0
- package/render/lighting.js +66 -14
- package/render/lights.js +223 -4
- package/render/lookGlow.js +139 -0
- package/render/lookSurface.js +99 -36
- package/render/materials.js +71 -52
- package/render/modeling.js +73 -0
- package/render/ownFrame.js +76 -0
- package/render/patches.js +311 -34
- package/render/postLook.js +124 -46
- package/render/postWebGL.js +197 -0
- package/render/probes.js +231 -0
- package/render/shaderErrors.js +154 -0
- package/render/slots.js +165 -0
- package/render/surface.js +53 -17
- package/render/terms.js +211 -0
- package/render/uniformDecl.js +3 -2
- package/types/common.d.ts +2 -2
- package/types/core.d.ts +614 -240
- package/types/gameplay.d.ts +482 -312
- package/types/generated/core/Audio.d.ts +26 -42
- package/types/generated/core/Batching.d.ts +6 -2
- package/types/generated/core/Budget.d.ts +2 -8
- package/types/generated/core/DebugOverrides.d.ts +44 -3
- package/types/generated/core/I18n.d.ts +2 -2
- package/types/generated/core/Input.d.ts +102 -31
- package/types/generated/core/Ops.d.ts +31 -0
- package/types/generated/core/Random.d.ts +2 -2
- package/types/generated/core/Saves.d.ts +10 -2
- package/types/generated/core/Stream.d.ts +1 -1
- package/types/generated/core/Threads.d.ts +4 -1
- package/types/generated/core/Views.d.ts +0 -1
- package/types/generated/core/audioVoice.d.ts +17 -9
- package/types/generated/core/control.d.ts +55 -0
- package/types/generated/core/session.d.ts +2 -1
- package/types/generated/modules/ambience/Ambience.d.ts +0 -9
- package/types/generated/modules/calendar/Calendar.d.ts +84 -0
- package/types/generated/modules/calendar/index.d.ts +10 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Grid.d.ts +61 -25
- package/types/generated/modules/grid/Layer.d.ts +5 -5
- package/types/generated/modules/grid/index.d.ts +29 -17
- package/types/generated/modules/music/Music.d.ts +5 -3
- package/types/generated/modules/net/index.d.ts +3 -3
- package/types/generated/modules/net/transports.d.ts +12 -3
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/sky/Sky.d.ts +12 -104
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/timeline/Timeline.d.ts +8 -6
- package/types/generated/modules/weather/Weather.d.ts +17 -18
- package/types/generated/modules/weather/weatherLook.d.ts +12 -0
- package/types/generated/modules/world/World.d.ts +18 -3
- package/types/generated/render/PostFX.d.ts +67 -30
- package/types/generated/render/materials.d.ts +26 -20
- package/types/generated/render/modeling.d.ts +30 -0
- package/types/generated/render/patches.d.ts +16 -2
- package/types/generated/ui/UI.d.ts +6 -3
- package/types/nav.d.ts +6 -0
- package/types/physics.d.ts +137 -44
- package/types/style.d.ts +109 -81
- package/types/tsl.d.ts +86 -0
- package/types/world.d.ts +158 -110
- package/ui/Focus.js +25 -14
- package/ui/LoadingScreen.js +1 -1
- package/ui/Parts.js +27 -11
- package/ui/UI.js +20 -10
- package/ui/cursor.js +115 -0
- package/ui/defaults.js +15 -11
- package/ui/theme.js +9 -6
- package/ui/touchPart.js +1 -1
- package/core/claims.js +0 -51
- package/core/look/layers.js +0 -136
- package/core/renamed.js +0 -22
- package/docs/api/entities.md +0 -61
- package/examples/styletest/overrides.js +0 -33
- package/examples/styletest/panel.js +0 -135
- package/modules/entities/Entities.js +0 -243
- package/modules/entities/build.js +0 -25
- package/modules/entities/index.js +0 -4
- package/modules/sky/calendar.js +0 -80
- package/modules/sky/layers.js +0 -69
- package/modules/terrain/chunkLevels.js +0 -40
- package/modules/terrain/mountTerrain.js +0 -32
- package/modules/world/cells.js +0 -42
package/docs/COMMANDS.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Commands and debugging details
|
|
2
2
|
|
|
3
3
|
The scripts in `package.json` forward to the CLI `threedog` (from `@threedog/tools`; the root `build` runs each workspace's own `build`);
|
|
4
|
-
`
|
|
5
|
-
installed from npm alike.
|
|
4
|
+
**`threedog xxx` on this page means `node node_modules/@threedog/tools/bin/threedog.mjs xxx`** (in this repo: `node packages/tools/bin/threedog.mjs xxx`): plain node starts fastest. `npm run xxx` runs the same command (npx adds about 2.5 s per call, so it is not used here). The tools find every path through their `paths.mjs`, in the engine repository and in a game
|
|
5
|
+
installed from npm alike. Every command checks its options: an unknown or misspelled one fails and lists the valid ones (dev bridge commands read their own options; `dev` / `build` / `preview` pass theirs to vite).
|
|
6
6
|
|
|
7
7
|
## Running one game only
|
|
8
8
|
After `-w` write the directory or the package name (inside a game directory a plain `npm run ...` does the same):
|
|
@@ -12,13 +12,13 @@ After `-w` write the directory or the package name (inside a game directory a pl
|
|
|
12
12
|
- Test: `npm test -w games/my-game`, or `npm 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).
|
|
15
|
-
- Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--keep` timestamped file name, `--look`
|
|
16
|
-
- A game's tests:
|
|
17
|
-
errors). Minimal example:
|
|
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, look numbers and hints after every shot, `--no-look` 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`.
|
|
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
|
+
`tests/specs/` a smoke test runs automatically (page opens, engine ready, no console errors). Minimal example:
|
|
18
18
|
```js
|
|
19
|
-
// games/my-farm/tests/specs.mjs — export a specs array, one entry per page
|
|
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', // npm test -- apple matches by name substring
|
|
21
|
+
name: 'farm: pick up apple', // npm 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,53 +32,74 @@ 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
|
-
- New game: `npm run new-game -- name [--
|
|
36
|
-
- Game in your own folder (outside this repo): after `npm install threedog three@~0.187.0 @threedog/tools`, run `
|
|
35
|
+
- New game: `npm run new-game -- name [--open-world] [--example]` (blank scene with a camera by default; `--open-world` adds generated ground, sky, follow camera and a player; `--example` adds a sample on top; see `recipes/01-new-game.md`).
|
|
36
|
+
- Game in your own folder (outside this repo): after `npm install threedog@0.5 three@~0.187.0 @threedog/tools@0.5`, run `node node_modules/@threedog/tools/bin/threedog.mjs init [folder] [--open-world] [--example]` (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
37
|
|
|
38
|
-
> Git Bash (MSYS) rewrites arguments that start with `/` (
|
|
38
|
+
> 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
|
+
|
|
40
|
+
> Windows PowerShell 5.1: `Get-Content` / `Set-Content` without `-Encoding utf8` read and write UTF-8 files in the system code page (mojibake, lost newlines). Pass `-Encoding utf8`, or edit files with your editor tools.
|
|
39
41
|
|
|
40
42
|
## Command table
|
|
41
43
|
| Command | When to use |
|
|
42
44
|
|---|---|
|
|
43
|
-
| `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 (
|
|
44
|
-
| `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests):
|
|
45
|
-
| R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls timers, `Math.random`, an inventory
|
|
46
|
-
| `npm run types` | Type check only (does game code misuse the engine API) |
|
|
47
|
-
| `npm test` | Full browser tests (slow). Normally `npm test -- name` runs only the related ones (matched by test-name substring, e.g. `--
|
|
48
|
-
| `
|
|
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) |
|
|
47
|
+
| R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls timers, `Math.random`, an inventory or grid/height blending, or hand-colors a material in a file that also takes style materials (`makeMaterial`), is pointed to the engine system that already does it. Hand-made materials elsewhere, and anything in art code (`style/`, `art/`, `assets.js`, `art.js`), are the plain three.js route and not hinted. 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
|
+
| `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 `npm 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. `npm 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 |
|
|
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` |
|
|
49
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 |
|
|
50
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`) |
|
|
51
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 |
|
|
52
|
-
| `threedog
|
|
54
|
+
| `threedog describe [path] [--full\|--all]` · `threedog state time=18:30 weather=rain pos=40,-20` | Read the running game as compact text (one item: `describe player.pos`); change the scenario without a reload. Run 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`). `recipes/16-dev-bridge.md` |
|
|
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` · `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 look check (as `shot`; `--no-look` skips it); reload the page |
|
|
57
|
+
| `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` |
|
|
58
|
+
| `threedog pick 480,270` | What is at a screen pixel (from the canvas top-left): record id, kind, template, content file:line, fields |
|
|
59
|
+
| `threedog js --file steps.js [--verbose]` | 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` |
|
|
53
60
|
| `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 |
|
|
54
|
-
| `threedog catalog [id] [--find word] [--json]` | What this game can do: modules, ops (args, failure codes, last attempt), saves, time. `recipes/51-capability-catalog.md` |
|
|
61
|
+
| `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` |
|
|
62
|
+
| `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-style.md` section 2a |
|
|
63
|
+
| `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--preview url|png] [--force]` · `threedog lib list [words]` · `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 code entry goes to `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; `page` writes `index.html` with all previews. MCP: `lib_list`. recipes/05-props-bake.md §2d |
|
|
64
|
+
| `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 |
|
|
55
65
|
| `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 |
|
|
56
66
|
| `threedog explain op shop.buy shop=bakery` / `explain quest first-light` | Why an op cannot run now, or what a quest waits on (`engine.explain`). `recipes/23-ops.md` |
|
|
57
67
|
| `threedog thing <id>` | Everything about one id: definition file:line, model, materials, state, ops, save tier, how to change it (`thing.explain()`). `recipes/41-thing-registry.md` section 6 |
|
|
58
|
-
| `threedog content set <id>
|
|
68
|
+
| `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/41-thing-registry.md` |
|
|
69
|
+
| `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/41-thing-registry.md` |
|
|
59
70
|
| `threedog loading [task]` | Loading progress and what failed, also while `start()` is stuck. `recipes/05-props-bake.md` |
|
|
60
71
|
| `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
|
|
61
72
|
| `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
|
|
62
73
|
| `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` |
|
|
63
74
|
| `threedog skip to=06:00` / `skip seconds=600` | Jump the clock like sleeping (`engine.skip`: op `time.skip`, sky clock and time-keeping modules catch up; optional `fade=0.6 save=auto`). Needs the sky module for `to` |
|
|
64
|
-
| `threedog errors` / `errors latest [N]` / `errors --since E5` | Page errors with id (E1…), time, tick, source and count
|
|
65
|
-
| 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 |
|
|
75
|
+
| `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 |
|
|
76
|
+
| 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) |
|
|
66
77
|
| `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`) |
|
|
67
|
-
| `npm run shot -- / --time 18:30 --weather rain --pos x,z` | 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`**. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time |
|
|
78
|
+
| `npm run shot -- / --time 18:30 --weather rain --pos x,z` | 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; 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) |
|
|
79
|
+
| `npm run shot -- / [--ref image] [--no-look] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`, on the live page): look 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. **Intent** (only against what the game declared): the listed words on DESIGN.md's optional `Look 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 (look.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; `--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 |
|
|
68
80
|
| `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) |
|
|
69
|
-
| `
|
|
81
|
+
| `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 |
|
|
70
82
|
| `npm run bake` | Before release, or to take code-generated models into Blender: exports public/models/baked/*.glb (`-- -w game`) |
|
|
71
83
|
| `npm run assets` | Compress glTF from art/models/ into public/models/ (names such as col_ and spawn are kept; `-- -w game`). Skips files whose source content, options and tool versions are unchanged. Prints a report per file (sizes, meshes / materials / textures / animations, final texture format, texture transfer size vs GPU memory; also `.threedog/assets-report.json`). `-- --ktx2` makes KTX2 textures; without the ktx tool it falls back to WebP and says so, `-- --ktx2 --strict` fails instead |
|
|
72
84
|
| `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models/): 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 |
|
|
73
|
-
| `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld); compare with `PERF.md
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `threedog
|
|
79
|
-
| `threedog style
|
|
80
|
-
| `threedog
|
|
85
|
+
| `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld); compare with `PERF.md`. Prints the renderer first |
|
|
86
|
+
| `threedog stress [--only a,b] [--frames 30] [--json]` | Load ramps, one axis at a time, on the neutral page `tests/stress/`: per step CPU / GPU / frame ms, then the load that fits 16.7 and 33 ms per axis (`PERF.md` "Load budget"). About 1-2 minutes |
|
|
87
|
+
| `--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 |
|
|
88
|
+
| `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 -->
|
|
89
|
+
| `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 one verdict `{ healthy, items, render }`; exit code 0 only when healthy. 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 |
|
|
90
|
+
| `threedog api-count [--unused] [--json]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, look parts and verbs, 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 |
|
|
91
|
+
| `threedog style check [folder\|file\|game] [--json] [--assets file]` | Check the final merged style (no argument: the `style/` folder of the game in the current folder; a game folder or workspace name means its `style/`): unknown fields (did-you-mean), world-state fields, palette keys read but not defined, color formats, post-effect conflicts, misspelled material roles / types, asset names the style does not register; plus R34 on those files. Exit 1 on errors. Static: it cannot prove a style has no gameplay logic. See `recipes/35-style-from-reference.md` |
|
|
92
|
+
| `threedog style 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 |
|
|
93
|
+
| `threedog style 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 |
|
|
94
|
+
| `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 |
|
|
95
|
+
| `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` |
|
|
96
|
+
| `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` |
|
|
97
|
+
| `?panel=1` with `import('@threedog/tools/panel').then(m => m.openPanel(engine))` | The dev panel in any game: live look / post / UI sliders, materials by name, `engine.uniforms`, export of style overrides, "write back" for `threedog tune`. Needs the optional dev package `tweakpane`; production builds of the vite preset get a stub. `recipes/35-style-from-reference.md` |
|
|
98
|
+
| `threedog tune show` · `threedog tune write [file] [--apply]` | Values dragged in the dev panel (`?panel=1` "tune" folder, then "write back" -> `.threedog/tune.json`) as one `// threedog:tune begin ... end` block of plain calls (`engine.look.<part>.set`, `material.setValues` by name, `engine.uniforms`, a `tunedStyle` literal) in `file`; 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-style-from-reference.md` |
|
|
99
|
+
| `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 style compare <ref> <png> --out diff.png`. `recipes/05-props-bake.md` section 2c |
|
|
81
100
|
| `npm run build` | Bundle each workspace into its own dist/ |
|
|
101
|
+
| `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 |
|
|
102
|
+
| `threedog relay [port]` | The WebSocket relay for the net module (default port 8787, no dependencies). `recipes/27-net.md` |
|
|
82
103
|
|
|
83
104
|
## Reproducing a scenario and debugging
|
|
84
105
|
- Add `?time=18:30&weather=rain&pos=40,-20&save=slot1&cutscene=skip&state=name` to the URL (effective in development).
|
|
@@ -98,12 +119,12 @@ export const specs = [{
|
|
|
98
119
|
- `modules/` modules, one folder each, installed with `engine.use`; list in `CODEMAP.md`.
|
|
99
120
|
- `render/ ui/` material factory, post-processing; UI basics (windows, UI focus stack, toast, fadeScreen, worldToScreen).
|
|
100
121
|
- `index.js index.d.ts types/` entry and API declarations (`types/generated/` is generated from source JSDoc, never edited by hand).
|
|
101
|
-
- `
|
|
102
|
-
|
|
122
|
+
- `examples/world/style/` is the world example's own small look (starting values and material roles), not a recommended one; `examples/world/art/`
|
|
123
|
+
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.
|
|
103
124
|
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`).
|
|
104
|
-
- `examples/world/` is the engine example (open world `/`, content-only placement). The small city (level, no terrain, no style
|
|
125
|
+
- `examples/world/` is the engine example (open world `/`, content-only placement). The small city (level, no terrain, no style, top-down) and
|
|
105
126
|
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`.
|
|
106
|
-
- `tests/` specs
|
|
127
|
+
- `tests/` specs/*.mjs test items (found by the runner), `<name>/index.html` test pages, fixtures/ test assets. `public/` art for the examples.
|
|
107
128
|
- Each game `games/<game>/`: package.json, vite.config.js (one line, gameConfig), index.html, main.js, `content/` (items npcs dialogues quests pickups
|
|
108
129
|
containers props templates triggers actions places level vegetation audio grids renames rules, plus the game's own kinds registered in
|
|
109
130
|
`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.
|
package/docs/CONVENTIONS.md
CHANGED
|
@@ -12,30 +12,79 @@ one line; the detail is here.
|
|
|
12
12
|
- **Level ownership**: world data carrying `zone: engine.world.zone` (= the current level name) gets its model built and is simulated only in that
|
|
13
13
|
level; when you leave, the data stays (content NPCs, pickups and props already work this way);
|
|
14
14
|
things that need not be kept (trigger zones, etc.) use `level.track(handle)` and are deleted automatically on level change.
|
|
15
|
-
- **
|
|
15
|
+
- **Module type**: every module says what it may own with `type` (`'rules'` for game logic; `'world'` state that draws nothing, `'look'` what is
|
|
16
|
+
seen and heard, `'ui'` panels, `'actor'`, `'net'`, `'tool'`; recipes/14). Modules depend on capabilities (`requires: ['inventory']`), never on
|
|
17
|
+
another module's name or private fields; a module doing two kinds of thing is two definitions from one factory (`weather()`: state + look).
|
|
18
|
+
- **Who owns a handle**: every `{ remove() }` handle has one owner that removes it, chosen by how long it should live: the module
|
|
19
|
+
(`ctx.track(h)` in its install / init: until the module goes), the playthrough (`engine.session.track(h)`: until newGame / load / quit), or
|
|
20
|
+
the level (`level.track(h)`: until the level changes). A handle with none lives until `engine.dispose()`.
|
|
21
|
+
- **Two doors, one scene**: plain three.js (`engine.add(mesh, { id })`) and templates (`engine.content.spawn`, props) land in the same registry;
|
|
16
22
|
`engine.thing(id)` says what it is and what a save keeps (`recipes/41-thing-registry.md`). What must be saved with its own state or edited without
|
|
17
23
|
code goes in `content/` (templates + props with ids, pickups, npcs, containers, game kinds) or the level model; a save stores only changes on top.
|
|
18
|
-
Startup code never creates what a save stores whole (rule R33): things that appear during play come from `engine.spawn` inside an op.
|
|
24
|
+
Startup code never creates what a save stores whole (rule R33): things that appear during play come from `engine.content.spawn` inside an op.
|
|
19
25
|
- To find leaks read `engine.counts()` (listeners, timers, geometry count; they should not grow when entering and leaving a level repeatedly).
|
|
20
26
|
|
|
21
27
|
## Textures
|
|
22
28
|
The opts of `assets.texture(name, opts)` are part of the cache key: the same image with different opts gives two separately configured textures.
|
|
23
29
|
|
|
24
|
-
##
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(
|
|
30
|
+
## Values the engine drives (sun, hemi, fog, camera)
|
|
31
|
+
With a sky or camera module installed the engine writes `engine.lights.sun / hemi` (intensity, color, position), `scene.fog` and the `camera` pose
|
|
32
|
+
every frame. Setting them directly is plain three.js and works: the engine yields that value (stops writing it, warns once). Say it on purpose with
|
|
33
|
+
`engine.look.<part>.manual(key)` (no warning; `manual(key, false)` gives it back), or adjust without taking it, keeping the day cycle, with
|
|
34
|
+
`look.<part>.set(...)`: the game's value is the base, weather and the sunset still multiply it and the settings menu can only turn it down
|
|
35
|
+
(the "Customization ladder" below; how they stack: `recipes/52-look.md` "How look values stack"). The camera: `engine.takeCamera(owner)`
|
|
36
|
+
or a timeline camera step.
|
|
37
|
+
|
|
38
|
+
## Customization ladder
|
|
39
|
+
Pick the row for what you want; each row is the one entry for it (take the first that fully works). Plain JS fields and your own `onFixed`
|
|
40
|
+
logic need none of this.
|
|
41
|
+
|
|
42
|
+
| You want to | Use | Detail |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| Tweak a parameter of a system | its options (`createEngine({...})`, `terrain({...})`, `openWorld({...})`; unknown keys throw), or content data | `api/<module>.md` |
|
|
45
|
+
| 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` |
|
|
46
|
+
| 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` |
|
|
47
|
+
| Close one action for a while (stunned: no jump) | `engine.input.gate(action, { owner, for })` | `recipes/55-mods-time-wrap.md` |
|
|
48
|
+
| 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" |
|
|
49
|
+
| Change a look value (light, fog, sky, water, tone, post, materials) | `engine.look.<part>.set(values, { owner })`; take a value the engine drives: `manual(key)`; swap a named shader hook: `patch(hook, code)` (never a `glsl` key in an option); one more named thing: `add(...)` (`look.post.add`, `look.materials.add`); swap the one three.js thing a part draws: `replace(thing)`; read: `value(key)`; a whole module: `engine.use(mine(), { replaces })`; your own fog: `scene.fog = ...` | `recipes/52-look.md#verbs` |
|
|
50
|
+
| Write the look 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`, `recipes/54-three-idioms.md` |
|
|
51
|
+
|
|
52
|
+
The starting look comes from the game's `style/` folder; what a style section builds as a factory can also be passed at the call site, and the
|
|
53
|
+
call site wins (`terrain({ material })` and the like; the water surface has only `look.water.replace`); a new style factory ships with its call-site option. No module option starts a value taken over.
|
|
54
|
+
|
|
55
|
+
**Time channels**: most games use only the default (fixed `dt` in real seconds, `engine.clock` for calendar time). A channel exists so one group
|
|
56
|
+
of things can run slower or faster than the rest (bullet time on enemies, haste on the player): `engine.onFixed(fn, { channel: 'enemies' })` gets
|
|
57
|
+
that channel's scaled `dt`, and `engine.mod('time.enemies', { owner, mul })` scales it; units and which clock to use: `recipes/06-clock-events.md`.
|
|
58
|
+
|
|
59
|
+
### One task, which entry
|
|
60
|
+
Where a task has more than one entry they are layers of the ladder above, not alternatives: take the first, go down only for the reason given.
|
|
61
|
+
Look rows (light, glow, environment, post) follow the order in `THREE.md` (plain three.js first): they name the hook your three.js code plugs
|
|
62
|
+
into, or a convenience for after.
|
|
63
|
+
|
|
64
|
+
| Task | First | Go down a layer when |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| Windows, signs, screens glow at night | `look.materials.glow(match, { night })` | your own emissive logic: plain three.js. `lightPool.add(obj, { glow })` is something else: the stand-in a pooled lamp shows while it holds no real light |
|
|
67
|
+
| 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 |
|
|
68
|
+
| Sun / light strength | `look.lights.set(values, { owner })`: a layer over the day keyframes, `remove()` gives them back | take it over (the day cycle stops writing it): write `engine.lights.sun` directly, or `look.lights.manual('sun')` |
|
|
69
|
+
| 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, `npm 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) |
|
|
70
|
+
| 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 })` |
|
|
71
|
+
| Camera | install one: `openWorld({ camera })`, `engine.use(fixedCamera({ position, lookAt }))` | switch kinds at run time: `setCamera(kind)`; a shot of your own: `takeCamera(owner)` |
|
|
72
|
+
| Sky | the style's sky layers, tuned with `look.sky.set` | a custom sky of your own (shader dome, skybox, painted backdrop): `look.sky.replace(obj)` (recipe 08 "Your own sky object"); on WebGPU three's `SkyMesh` the same way |
|
|
73
|
+
| Environment light | the style, then `look.env.replace('sky' \| asset)` / `look.env.set` | light that changes from place to place: `bakeProbes` |
|
|
74
|
+
| Post effects | your own three.js Pass in the engine's chain: `look.post.add(pass)`, the one way in (the engine renders through its composer) | ready-made effects as an optional convenience: `@threedog/post-effects` through the same call or a plugin file, tuned with `look.post.set`; a whole chain of your own: `look.post.replace([...])` |
|
|
75
|
+
| Ambient occlusion | `look.post.set({ 'ao.enabled': true })` (screen space) | a model made in code: `bakeVertexAO(geometry)`; bounce light between places: `bakeProbes` |
|
|
28
76
|
|
|
29
77
|
## Owners
|
|
30
78
|
Everything that holds the engine is named by an owner, and only that owner releases it. Positional `pause('menu')` and `pause({ owner: 'menu' })` are the same.
|
|
31
79
|
|
|
32
80
|
| What | Take | Release | Returns |
|
|
33
81
|
|---|---|---|---|
|
|
34
|
-
| Real-time loop | `pause(owner, { kind? })` | `
|
|
35
|
-
| Gameplay freeze | `freeze(owner, { kind? })` | `
|
|
82
|
+
| Real-time loop | `pause(owner, { kind? })` | `handle.remove()` | handle `{ remove() }` |
|
|
83
|
+
| Gameplay freeze | `freeze(owner, { kind? })` | `handle.remove()` | handle |
|
|
36
84
|
| Camera | `takeCamera(owner, { focus? })` | `handle.remove()` | handle |
|
|
85
|
+
| Where a character goes | `control.take(character, { owner, layer, step? })` (layers base < script < cutscene < net; higher pauses lower) | `handle.remove()` | handle `{ active, move(), remove() }` |
|
|
37
86
|
| Debug override / view | `debug.override(owner, ...)`, `debug.view(mode, { owner })` | `debug.clear(owner)` | handle / state |
|
|
38
|
-
| Look values | `look.<part>.set(values, { owner })` | `
|
|
87
|
+
| Look values | `look.<part>.set(values, { owner })` | `handle.remove()` | handle |
|
|
39
88
|
|
|
40
89
|
## Worker limits
|
|
41
90
|
`modules/terrain/terrainGen.js` (via `chunkJob.js`) runs in a Worker and must not import three.js; a vegetation `rule` is sent to the Worker and must
|
|
@@ -80,42 +129,53 @@ inside template strings, which then throw on the first call).
|
|
|
80
129
|
## Interface conventions (one style across the engine)
|
|
81
130
|
- **A position is one argument**: any API that takes a position takes it as a single argument: Vector3, Object3D (its position), `[x, y, z]` or
|
|
82
131
|
`{ x, z }` all work. Size, radius and count go in the options object after it: `collision.addBox(house, { halfWidth: 3, halfDepth: 2 })`,
|
|
83
|
-
`particles.emit('dust', p, { count: 20 })`, `
|
|
132
|
+
`particles.emit('dust', p, { count: 20 })`, `world.query({ near: p, radius, kind })`. A position key inside an options object is always `position`
|
|
84
133
|
(`stream.add({ position, build })`). The only exceptions are ground sampling `engine.surface / slope / groundType / waterAt(x, z)` and
|
|
85
134
|
`ground.height(x, z)`; `{ place, x, z }` in content data is a data form.
|
|
86
135
|
- **Registrations return a handle**: anything that registers a listener, timer, continuing effect or registration (`events.on/once`,
|
|
87
|
-
`onFixed/onFrame`, `clock.after/every`, `
|
|
88
|
-
`triggers.add`, `hud.marker`, `hlod.add`, `particles.attach`, `
|
|
136
|
+
`onFixed/onFrame`, `clock.after/every`, `calendar.at/between/daily/onSeason`, `collision.addBox/...`, `interactions.add`, `rays.addStatic`, `stream.add`,
|
|
137
|
+
`triggers.add`, `hud.marker`, `hlod.add`, `particles.attach`, `pickups.spawn`, `rigid.addBox/...`, `audio.addBus`, `defineState`) returns a
|
|
138
|
+
handle `{ owner?, remove() }`; `h.remove()` undoes it, the only give-back form (no `null` / `false` hand-back calls)
|
|
89
139
|
(safe to call repeatedly), never a bare function. `remove()` undoes what that call did: models it created itself are deleted with it (such as a
|
|
90
140
|
pickup); objects you passed in are not. APIs that add an object or change business data return what their own signature says: `engine.add(obj)`
|
|
91
141
|
returns the added object, `inventory.add` returns a result, `world.add` a record; delete those with `engine.remove(obj)` / their own remove call.
|
|
142
|
+
- **Verbs**: defining a kind is `define` (`vegetation.define`, `particles.define`, `grids.define`, `ops.define`); placing one is `add` / `spawn`;
|
|
143
|
+
hooking up a provider the engine calls back is `register` (`saves.register(key, { save, load })`: it defines no kind and places nothing).
|
|
144
|
+
One timer entry: `engine.clock.after(seconds, fn, data, { channel })` (calendar seconds, or `'real'` / a time channel's seconds with `channel`);
|
|
145
|
+
one queue, so `remove()` is immediate: a removed timer never fires, not even later in the same step.
|
|
146
|
+
- **Unknown options throw**: every options bag goes through a `readParams` schema (one schema gives the check, the defaults and the catalog entry); an
|
|
147
|
+
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
|
|
148
|
+
state and material fields, where games add their own keys).
|
|
92
149
|
- **Ready is always the boolean property `ready`** (to wait, `await h.whenReady`); a module's readiness hook is `isReady(e)`.
|
|
93
|
-
- **Event names are `noun:action`**: the noun is the emitter's singular camelCase name (`item`, `
|
|
150
|
+
- **Event names are `noun:action`**: the noun is the emitter's singular camelCase name (`item`, `template`...), the action is a lowercase verb or state
|
|
94
151
|
(`add`, `done`, `change`); a game's own events follow the same rule (`door:open`).
|
|
95
|
-
- **Time**:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`
|
|
152
|
+
- **Time**: one source, `engine.time.tick`; real, ambient, channel and calendar seconds are read-only views (`engine.time.now(name)`), and only
|
|
153
|
+
`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
|
|
154
|
+
the table of which one to use for movement, action timelines, cooldowns, hit-stop, crop growth, calendar and UI, and what pause / freeze /
|
|
155
|
+
`clock.rate` 2 do to each. Speeds change only through `engine.mod` (the "Customization ladder" above).
|
|
99
156
|
- **Input**: gameplay keys (attack, jump, interact...) are read in the fixed step (`onFixed` / module `fixed`), where `pressed / down / released` give
|
|
100
157
|
a snapshot taken at the start of the step, so the result does not depend on frame rate and a press is never lost. UI keys (menus, toggling a view, a
|
|
101
158
|
HUD button) are read in `onFrame` / module `frame`, which gives this frame's latest state. Never read `pointer.clicked` for gameplay; bind a `Mouse0` action.
|
|
159
|
+
Modules declare actions and their context (`ctx.input.action`) and never name a key; the game binds (`createEngine({ bindings })`,
|
|
160
|
+
`input.bind`, `presets.bindings.*`); only the basics (move, confirm, cancel, UI cursor) have default keys (`recipes/58-input.md`).
|
|
102
161
|
- **Module names**: `collision()` installs as `engine.collision` (lightweight collision: walking, camera); `rigid()` installs as `engine.rigid` (real
|
|
103
162
|
physics with Rapier).
|
|
104
|
-
- **Presets**: `openWorld()` installs only world, environment and basic modules; gameplay modules (interactions, dialogue, inventory, quests...) are
|
|
163
|
+
- **Presets**: `openWorld()` installs only world, environment and basic modules; gameplay modules (interactions, dialogue, inventory, pickups, quests...) are
|
|
105
164
|
added by the game with `engine.use`; pass `false` for items you don't want; the camera has no default and must be named, e.g.
|
|
106
165
|
`openWorld({ camera: 'firstPerson' })` (`'follow'` / `'rts'` / `'fixed'`, a camera module, or `false`).
|
|
107
166
|
- **Errors say how to fix it**: passing an old form (a numeric position, etc.) throws and explains the fix.
|
|
108
167
|
|
|
109
168
|
## Core conventions
|
|
110
169
|
- Lighting without `sky`: every engine has `engine.lights = { sun, hemi }` (neutral); to light the scene yourself hide or adjust them and add three.js
|
|
111
|
-
lights. The engine ships no art: the humanoid, pickup shapes and flat shading
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
- Gameplay state (world, containers, vars, quests) changes only in fixed steps or inside ops; dev warns otherwise (
|
|
115
|
-
`
|
|
170
|
+
lights. The engine ships no art: the humanoid, pickup shapes and flat shading come from the game's `style/` folder and `assets.js` (e.g.
|
|
171
|
+
`terrain.config.shading: 'flat'` in its style); without them the engine shows a gray capsule, a gray box and flat gray ground at y = 0, with a
|
|
172
|
+
dev warning naming the fix.
|
|
173
|
+
- Gameplay state (world, containers, vars, quests) changes only in fixed steps or inside ops; dev warns otherwise (`npm test` prints the first place, all in
|
|
174
|
+
`<game>/.threedog/ops-guard.log`). (game side)
|
|
116
175
|
- **One source for "can walk there"**: `createEngine({ movement: { radius, height, maxSlope, stepHeight } })` -> read-only `engine.movement`;
|
|
117
176
|
collision, the Rapier capsule, navigation, A* and level steps all read it; don't write another 0.4 / 0.45 in a module. A character's position
|
|
118
177
|
belongs to the Character mover; other systems only request movement (`placeAt` / `move` / vehicle `enter`) and never set `player.position` directly.
|
|
178
|
+
Who calls `move` is the character's control holder (`engine.control`, `recipes/57-control.md`): one per step; anyone else is `[control-bypass]`.
|
|
119
179
|
- 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).
|
|
120
180
|
- Never call `requestAnimationFrame` or `renderer.render` yourself. **Game logic always uses fixed seconds or game seconds** (the hook's `dt`,
|
|
121
181
|
`engine.clock`; see the time table in `recipes/06-clock-events.md`); no `setTimeout` / `setInterval` / `performance.now()`: they ignore pause,
|
|
@@ -123,9 +183,9 @@ inside template strings, which then throw on the first call).
|
|
|
123
183
|
- To be saved, call `engine.saves.register(key, { save, load })` (`load` may return a Promise); `saves.save / load` always return `Promise<boolean>`,
|
|
124
184
|
so `await` them. Saved data names things by stable ids, never positions; when it changes shape raise `version` and add a `migrate` step
|
|
125
185
|
(`recipes/20-content-actions-save.md` "Save format").
|
|
126
|
-
- Day / night comes
|
|
127
|
-
- A game's own look parameters (colors, materials)
|
|
128
|
-
|
|
186
|
+
- Day / night in gameplay comes from the calendar: read `calendar.isDay`, use `calendar.daylight` (0-1) for fades (they work with no sky); don't judge by clock text yourself.
|
|
187
|
+
- A game's own look parameters (colors, materials) can live anywhere plain three.js code lives; put them in its `style/` folder when you want
|
|
188
|
+
them in one place (mixed, tuned with `look.<part>.set`).
|
|
129
189
|
- Vegetation `rule` must not contain functions (it is sent to a Worker).
|
|
130
190
|
- Terrain is editable: `engine.terrain.edit(pos, { lower|raise|flatten|paint })`, only inside an op or fixed step; custom
|
|
131
191
|
`terrain({ height, groundType })` must be pure functions.
|
|
@@ -135,11 +195,13 @@ inside template strings, which then throw on the first call).
|
|
|
135
195
|
`page:*`. Show "saved" only after `saves.save` returns true.
|
|
136
196
|
- Character bodies are assets, not style: `createPlayer({ ...presets.player.thirdPerson, model: 'humanoid' | 'hero' })` (a procedural builder is built
|
|
137
197
|
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
|
|
138
|
-
asset has throws.
|
|
198
|
+
asset has throws. The style tints bodies through material roles (cloth, skin, trousers, hair).
|
|
139
199
|
- Importing the engine makes `Mesh.prototype.customDepthMaterial` / `customDistanceMaterial` default to a depth material carrying the mesh material's
|
|
140
200
|
vertex patches, so wind-swayed meshes cast swaying shadows with nothing to set up; assigning your own value still wins. Shader time, wind and cloud
|
|
141
201
|
cover are per engine in `engine.uniforms` (share them in your own `ShaderMaterial`); with two engines on a page, pass the engine to
|
|
142
202
|
`makeMaterial(role, params, engine)`.
|
|
143
203
|
|
|
144
204
|
## Failures: which shape
|
|
145
|
-
A runtime "can't" (not enough money, shelf empty) is returned as `{ ok: false, code, facts, nextActions }` (ops.run / can / undo). Misuse (a wrong call, a typo) is a thrown `codedError`. Documented exceptions: `checkSkip` / `checkSave` return `{ ok, diffs }`, `walkTo` returns `{ status }`. Read `code
|
|
205
|
+
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.
|
|
206
|
+
|
|
207
|
+
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.
|