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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Moving a game from 0.7 to 0.8
|
|
2
|
+
|
|
3
|
+
npm never had 0.7.1, so this page goes from 0.7.0 straight to 0.8.0.
|
|
4
|
+
|
|
5
|
+
Names were settled before 1.0: a few were removed, a few renamed. Nothing below keeps working under its old name. A stale uniform name in shader text reads 0 with no error and no warning, so search for the old names below.
|
|
6
|
+
|
|
7
|
+
## Uniforms
|
|
8
|
+
|
|
9
|
+
Search your shader strings as well as your JavaScript.
|
|
10
|
+
|
|
11
|
+
| 0.7 | 0.8 |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `engine.uniforms.uCloudScale` | `uCloudShadowScale` (the cloud shadows on the ground) |
|
|
14
|
+
| `engine.uniforms.uCloudSpeed` | `uCloudShadowSpeed` |
|
|
15
|
+
| `uCloud` | `uWeatherCloud` |
|
|
16
|
+
| `uCurve` | `uSkyCurve` |
|
|
17
|
+
| `uCover` | `uGroundCover` |
|
|
18
|
+
| `uSunPower` | `uSunBrightness` |
|
|
19
|
+
| `uMoonPower` | `uMoonBrightness` |
|
|
20
|
+
| `uCloudScale`, `uCloudSpeed` on `engine.sky.uniforms`, or in `engine.sky.clouds()` and dome layer GLSL | `uSkyCloudScale`, `uSkyCloudSpeed` (the dome's clouds, the same names as on `engine.uniforms`) |
|
|
21
|
+
|
|
22
|
+
The same names apply to `uniforms(engine)` from `threedog/tsl`, `c.fx.uniform('...')`, and `#include <threedog_uniforms>`. A patch that brings its own uniform called `uCover` is yours and is left alone.
|
|
23
|
+
|
|
24
|
+
## Changed shapes
|
|
25
|
+
|
|
26
|
+
These do not fail loudly, so search for them.
|
|
27
|
+
|
|
28
|
+
| 0.7 | 0.8 |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `const key = bag.add(id)`; `false` when full | `const r = bag.add(id)`: `{ ok: true, key, added }`, or `{ ok: false, code: 'full', facts }`. The result is always an object, so `if (bag.add(id))` is now `if (bag.add(id).ok)` |
|
|
31
|
+
| `clock.after(s, 'ev', data, { channel })` | `clock.after(s, 'ev', { data, channel })`, the same third argument as `clock.every`. The old form throws |
|
|
32
|
+
| `player.onStep = type => ...` | `engine.events.on('character:step', ({ character }) => ...)`, ground from `character.groundType()`. Assigning the old property does nothing and says nothing, so search for it |
|
|
33
|
+
| `player.onLand = impact => ...` | `engine.events.on('character:land', ({ character, impact }) => ...)`. Assigning the old property does nothing and says nothing, so search for it |
|
|
34
|
+
| `grids.get(name)`, `inventory.get(key)`, `container.get(key)`, `interactions.get(id)` return `null` when there is none | `undefined`, like every other `get`; a test `=== null` no longer matches, use `!x` |
|
|
35
|
+
| `settings({ presets: { high: { pixelRatio: 1.5 } } })`: a fixed ratio | A share from 0 to 1 of the ratio the engine picked for this device (`high: { pixelRatio: 1 }`); above 1 throws `module-params`. For a fixed ratio call `engine.setPixelRatio` |
|
|
36
|
+
| `settings.values` was the stored object; `settings.get('pixelRatio')` kept the last number set | `settings.values` is a read-only copy, change a value with `settings.set`; `pixelRatio` is the renderer's real ratio, the same as `describe().render.scale.current` |
|
|
37
|
+
| `mesh.visible` on a registered hlod mesh read `false` while far | It is your own value near and far. To ask whether the camera draws it: `mesh.layers.test(engine.camera.layers)` |
|
|
38
|
+
| `await engine.applyState(...)` resolved to nothing, and rejected for `season` with no calendar or an `at` nothing knows | It resolves to `{ ok, refused: [{ key, value, reason }] }`: read `refused`. A `fresh`, `wait` or `pos` it cannot read throws `state-value` |
|
|
39
|
+
|
|
40
|
+
## Removed names
|
|
41
|
+
|
|
42
|
+
| 0.7 | 0.8 |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `engine.rays.cast(...)`, `engine.rays.pick(...)` | `engine.raycast(...)`, `engine.pick(...)` |
|
|
45
|
+
| `engine.THREE` | `import { THREE } from 'threedog'`, the same copy of three.js. |
|
|
46
|
+
| `model.userData.animations` | `model.animations`, three's own place: `model.clone()` keeps it, where `userData` broke the clips. Clips you add by hand go there too. |
|
|
47
|
+
| `engine.i18n.t(key)` | `engine.t(key)` |
|
|
48
|
+
| `inventory.slotsUsed` | `inventory.of().slotsUsed` |
|
|
49
|
+
| `engine.openWindows` | `engine.ui.isOpen(id)` |
|
|
50
|
+
| `engine.decoders` | set it with `createEngine({ decoders })`; it can no longer be read back |
|
|
51
|
+
| `EASINGS` | `ease(name)` |
|
|
52
|
+
| `assets.reportText(name)` | `assets.report(name)` |
|
|
53
|
+
| `assets.users(name)` | no replacement: it was internal |
|
|
54
|
+
| `player.object`, `character.object` | `.root`, the same object (`npc.object` stays) |
|
|
55
|
+
| `character.addTo()` | `engine.add(character.root)` for a `new Character` of your own; `createPlayer` still adds the player |
|
|
56
|
+
| `engine.rigid.R` | `engine.rigid.rapier` |
|
|
57
|
+
| `collision.circles`, `collision.boxes` | `collision.forEachStatic((type, data) => ...)` |
|
|
58
|
+
| `engine.stream.readyCheck(name, fn)` | `engine.stream.addReadyCheck(name, fn)` |
|
|
59
|
+
| `engine.music.addTracks({ a: url, b: url })` | `engine.music.define('a', url)`, one call per track; it no longer returns the music object |
|
|
60
|
+
| `debug.startBench()`, `debug.benchmarking`, the debug panel's stress button, `describe().debugPanel.benchmarking` | `threedog stress` |
|
|
61
|
+
| The types `Object3D`, `Vector3`, `Vector2`, `Color`, `Quaternion`, `Material`, `BufferGeometry`, `Texture` from `threedog` | import them from `three` |
|
|
62
|
+
| `threedog assets` with no verb | `threedog assets optimize` (it writes files) or `threedog assets check`. `npm run assets` becomes `npm run assets -- optimize` |
|
|
63
|
+
| `threedog doctor --json`: `{ healthy, items: [{ status, msg, fix }], render }` | `{ ok, summary, items: [{ level, message, fix }] }`, the shape of `check --json`. Items are the problems (`error`) and info lines (`warn`); passed lines are left out; `summary` says whether a hardware GPU is reachable |
|
|
64
|
+
| `engine.tick` | `engine.time.tick` |
|
|
65
|
+
| `engine.cpuMs`, `engine.cpuPhases` | `engine.inspect.perf()` (`cpuMs`, `cpuPhases`), `engine.budget.values().cpuMs` |
|
|
66
|
+
| `saves.queue(fn)` | `saves.putAttachment(group, id, blob, meta)`, `saves.removeAttachment(group, id)`; read with `saves.attachments(group)` |
|
|
67
|
+
| `saves.prefix` | `saves.storageKey(name)` for a key of your own |
|
|
68
|
+
| `userData.rayVisible = true` on a hidden object | Leave `visible` alone and put the mesh on `RESERVED_LAYERS.batched` (`threedog/layers`): not drawn, no shadows, still hit by `engine.raycast` |
|
|
69
|
+
| `engine.adaptive.paused` | `engine.adaptive.on = false` |
|
|
70
|
+
| `settings.removeSection(id)` | List the tabs you want: `settings({ sections: [...] })` |
|
|
71
|
+
| `sky({ moonSize })`, `sky({ starScale })`, `sky({ gradientCurve })`, `sky({ orbitTilt })`, `sky({ orbitSway })` | Write `engine.uniforms.uMoonSize.value`, `uStarScale.value`, `uSkyCurve.value`, `engine.sky.orbit.tilt`, `engine.sky.orbit.sway` (plain values after `engine.use(sky())`; defaults unchanged) |
|
|
72
|
+
| `saves.register(key, { movedFrom })` | No replacement. Only the calendar used it: the time and day of a 0.2 save, kept under the old `sky` part, are no longer read, and such a save starts from `calendar({ time })` |
|
|
73
|
+
| The old keys of `sky()` and `water()` (`sky({ fog })`, `sky({ sun })`, `sky({ layers })`, `sky({ dayLength })`, `water({ color })`, `water({ glsl })` and the like) | They are ordinary unknown options now: an error with a did-you-mean in development, one warning in a build. Recipes 08, 44 and 62 say where each value lives |
|
|
74
|
+
| `calendar.daysPerSeason` (the field) | Nothing read it and writing it did nothing. The option `calendar({ daysPerSeason })` stays |
|
|
75
|
+
| `ground.navGeometry` on a ground API of your own | Nothing read it: the navmesh comes from `staticTrimeshes()` |
|
|
76
|
+
| `settings.saved` | No replacement: nothing read it |
|
|
77
|
+
| `withHint` from `threedog/error-hints` | `hintText` |
|
|
78
|
+
| `threePatches.off('hlod-visible')` | The patch is gone: `hlod` hides a far original on the batch layer |
|
|
79
|
+
| `threedog bake light --spacing` | The bake traces rays now, so the option is gone, and `--samples` means rays per texel (default 128). Bake again and compare |
|
|
80
|
+
|
|
81
|
+
## Renamed
|
|
82
|
+
|
|
83
|
+
The table below keeps every rename; `engine.page.held` and `describe().page.held` are removed: ask `engine.frozen`, or `engine.stacks.get('freeze').has('page')` for this one holder. A page hold is now a plain freeze by owner `'page'`, so cutscene tweens and `runState` obey it, and `engine.step()` on a page in the background needs the loop stopped first, as the dev bridge already does.
|
|
84
|
+
|
|
85
|
+
| 0.7 | 0.8 |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `hud.add(id, n)` | `hud.bump(id, n)` |
|
|
88
|
+
| `dialogue.cps` | `dialogue.charsPerSecond` (the option already had this name) |
|
|
89
|
+
| `rtsCamera({ angle })`, `cameraRig.angle` under that camera | `pitch`, as on the other cameras; `angle` is now refused as an unknown option |
|
|
90
|
+
| `weather.define(field, spec)` | `weather.defineField(field, spec)` |
|
|
91
|
+
| `terrain.T` | `terrain.generator` |
|
|
92
|
+
| `terrain.CHUNK` | `terrain.chunkSize` (`createTerrain()` keeps its own `CHUNK`) |
|
|
93
|
+
| `engine.pause(owner)` | `engine.haltLoop(owner)`, for tests and tools. It stops rendering too, so a game that wants to pause uses `engine.freeze` or flow `'paused'`. The `{ kind: 'test' }` option is gone |
|
|
94
|
+
| `engine.paused`, `describe().time.paused` | `engine.halted`, `describe().time.halted` |
|
|
95
|
+
| `engine.mod('pause', ...)`, `describe().holds.pause` | `engine.mod('halt', ...)`, `describe().holds.halt` |
|
|
96
|
+
| `runState.state` `'test-paused'`, `'paused'` | `'halted'` (the loop is stopped), `'frozen'` (a game, page or error freeze) |
|
|
97
|
+
| `engine.terms`, `terms.cloudShadow`, `terms.season` | `engine.shaderTerms`, with the same two members |
|
|
98
|
+
| `engine.view`, `view.manual` | `engine.autoView`, `autoView.manual` |
|
|
99
|
+
| `lightPool.usage()` | `engine.describe().lightPool` |
|
|
100
|
+
| `terrain.isReadyAround(p)`, `rigid.groundReady(p)` | `engine.stream.addReadyCheck` and `stateApplied` already wait on them |
|
|
101
|
+
|
|
102
|
+
## Error codes
|
|
103
|
+
|
|
104
|
+
Search any `e.code === '...'` or `catch` in your game, and any test that names a code.
|
|
105
|
+
|
|
106
|
+
| 0.7 | 0.8 |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `options-object` | `bad-position` |
|
|
109
|
+
| `npc-option` | `character-option` |
|
|
110
|
+
| `pickup-prop-id` | `world-id` |
|
|
111
|
+
| `session-handle` | `module-handle` |
|
|
112
|
+
| `world-missing` | `module-needs` |
|
|
113
|
+
| `load-failed` | `asset-load` |
|
|
114
|
+
| `pause-owner` | `halt-owner` |
|
|
115
|
+
| `bad-arg` | Gone: `input.bind` raises `input-keys`, `characters.support` raises `character-option`, `settings({ presets })` raises `module-params` |
|
|
116
|
+
| `state-at` | Gone: `applyState` lists the value in `refused` |
|
|
117
|
+
| `renamed-field`, `shadow-type` | Gone, nothing raises them: the old names they caught are plain unknown options now |
|
|
118
|
+
| `engine.stacks.define` of a known name raised `mod-owner` | `engine-misuse` |
|
|
119
|
+
| `weather.set` with bad seconds raised `module-params` | `weather-option` |
|
|
120
|
+
| `interaction.use` answered `noKey` | With no key it runs when code asks, `ops.list({ available: true })` leaves it out, and `interaction-no-key` is a dev warning. Code that read `noKey` reads `engine.input.isUnbound(action)` |
|
|
121
|
+
| `ground-missing` threw (a prop, spawn or `snapToGround` beyond `terrain({ shape })`) | A warning, and the safe fallback runs: a `catch` for it no longer fires |
|
|
122
|
+
|
|
123
|
+
These used to throw and now warn once in dev and go on: `engine.wrap` on a `_private` method, `createEngine({ fallback })` without WebGPU, a vegetation `rule` beside `positions`, `ui.theme.promptHeight`, a module going against its `type`, `engine.sky.environment()` called twice (the second replaces the first), and `sky({ time })` with a calendar.
|
|
124
|
+
|
|
125
|
+
## Behaves differently
|
|
126
|
+
|
|
127
|
+
No error tells you about these.
|
|
128
|
+
|
|
129
|
+
| 0.7 | 0.8 |
|
|
130
|
+
|---|---|
|
|
131
|
+
| Physics ran at full speed under `engine.mod('time.world', ...)` | Rigid bodies and vehicles follow the `world` channel, and a hit-stop at speed 0 holds them. To keep them at full speed, slow a channel of your own |
|
|
132
|
+
| `engine.freeze(owner, { ambient: true })` left skeletal animation and particles moving | A real still: they stop with `uTime`. A plain freeze keeps them moving as before |
|
|
133
|
+
| `engine.batching` cell 64 m | 256 m, about 13-25% more triangles drawn. A game with heavy props sets `createEngine({ batching: { cell: 64 } })` |
|
|
134
|
+
| `engine.remove` disposed a shared geometry or material at once | It disposes with the last user. Code that relied on the old timing disposes it itself |
|
|
135
|
+
| `engine.stream` unloaded in the same frame | Through `engine.jobs`, so an entry out of range can stay a few frames longer in the real-time loop; `engine.step` still finishes in the frame |
|
|
136
|
+
| A low-tier device lowered `particles.define` `max`, `weather({ particles })`, a weather `count` and `sky.environment({ interval })` | It changes defaults only: these stand as the game gave them |
|
|
137
|
+
| A skybox reached full brightness at ambient 1.2 | At the brightest row of the game's keyframes |
|
|
138
|
+
| `engine.setPixelRatio(p)` was undone by adaptive resolution within two minutes | It is the top adaptive climbs back to; adaptive may still lower it under load |
|
|
139
|
+
| Settings stored every value | Only what the player changed, with a preset stored by name. Stored files of version 1 are read: a value equal to the default lets go |
|
|
140
|
+
| `music.play`, `music.stinger`, `hud.counter`, `hud.bar`, `calendar.at`, `calendar.daily`, `calendar.between`, `vegetation.removeInstance` ignored an unknown option | They throw on it |
|
|
141
|
+
| A class instance in a saved `world` record (`Vector3`, `Color`, `Map`) failed after a load | It throws `world-plain` in dev at `world.add` / `world.set`. Write `{ x, y, z }`, or add the record with `{ save: false }`. `position` stays free |
|
|
142
|
+
| A direct write to `engine.sky.sunDir` was undone on the next frame | It is the same vector as `engine.uniforms.uSunDir` and the write stays; `engine.autoView.manual('sunDir', false)` gives it back |
|
|
143
|
+
| An `approach` interaction on a held character walked or hung | Refused with `cannotWalk` |
|
|
144
|
+
| `characters.findPath` with no navmesh routed to a target inside a wall or water | `null` (`noPath` when detailed) |
|
|
145
|
+
| `hud.counter` with no label showed the id | The value alone |
|
|
146
|
+
| A quest reward that threw stopped the rest of the list | `content.run` runs every effect, rethrows the first error, and the quest still finishes |
|
|
147
|
+
| `inspect.perf()` on a halted page read `cpuMs` and `fps` as 0 | `null`, and `measured` says whether anything was counted |
|
|
148
|
+
| Two manifest entries naming each other as `fallback` waited for good | The load fails once with `asset-fallback-cycle`, naming the chain |
|
|
149
|
+
| An awaited `model()`, `texture()` or `font()` could reject or resume while the engine was disposed | The promise stays pending for good, and so does any later call: put teardown work in your dispose path, not after the `await` |
|
|
150
|
+
| A load ended by `release`, `trim`, a palette write or registering the name again could write its result back | Its result is freed when it arrives; code awaiting it gets a fresh load |
|
|
151
|
+
| `release('shrub')` on a name that fell back to `rock` touched `rock`'s data | A name that fell back holds no data: release `rock` |
|
|
152
|
+
| A mesh dropped while its material stayed in use held memory on WebGPU | The engine sweeps these every few seconds, so calls you added to work around it can go; `threePatches.off('webgpu-record-sweep')` turns it off |
|
|
153
|
+
|
|
154
|
+
## Tools
|
|
155
|
+
|
|
156
|
+
| 0.7 | 0.8 |
|
|
157
|
+
|---|---|
|
|
158
|
+
| `assets optimize` put the optimized pack anywhere in `assets.js` | It comes last, so `/optimized/x.glb` wins over an original of the same name; the next run moves an older game over |
|
|
159
|
+
| `assets optimize --strict` or a lower `--budget` skipped cached models | Cached models count, so a run that passed may now fail |
|
|
160
|
+
| `check` passed a kind in `content/index.js` listed without `rules` | An error |
|
|
161
|
+
| `check` in a game failed on file size, its own docs, a stale GAMEMAP, a module with no key, or startup creation | Warnings: a CI step that relied on one reads the warnings. New rules: R52 (captured twice), R53 (merge conflict markers in a tracked file) |
|
|
162
|
+
| `state`, `step`, `hold`, `press` and scenarios reported success when they did less | They fail with the reason and exit 1: a refused state, seconds that did not pass, a stopped engine |
|
|
163
|
+
| `shot` and `capture` ignored a value the page refused (`--weather rian`) | They fail |
|
|
164
|
+
| `threedog state` and `threedog snap` added a tick or two | They move no game time, so a script that counted on it steps itself |
|
|
165
|
+
| `lib pull` copied an entry the game's renderer cannot draw | Refused, nothing copied; `--force` copies it to port by hand, and `lib check` fails until it is ported |
|
|
166
|
+
|
|
167
|
+
## Stability
|
|
168
|
+
|
|
169
|
+
`@experimental` now means one thing everywhere: the name may change or go in any version with no migration note. See "Stability" in `CONVENTIONS.md` for the list. Nothing stops working, but do not build a save format on a marked name. The printed text of commands was never an interface: read `--json`.
|
package/docs/THREE.md
CHANGED
|
@@ -9,9 +9,9 @@ pass is a three.js Pass (`engine.post.add(pass)`) before a ready-made effect.
|
|
|
9
9
|
| You write (plain three.js) | The engine does | The one line, only when you mean it |
|
|
10
10
|
|---|---|---|
|
|
11
11
|
| `engine.scene.add(obj)` / `group.add(obj)` | registers each root under the scene like `engine.add`: `engine.thing`, `describe().scene`, `thing.set` / `thing.remove` | a stable id so a save finds it: `engine.add(obj, { id: 'mill' })` |
|
|
12
|
-
| `new THREE.PointLight(...)` / `SpotLight` added to the scene | a real light, adopted as a thing; counted by `engine.budget` `lights` / `shadowLights`, listed in `describe().render.lights`; a casting light at intensity 0 stops redrawing its shadow map; weather and day-night leave its values alone | many sources, few real lights: `lightPool` (recipe
|
|
12
|
+
| `new THREE.PointLight(...)` / `SpotLight` added to the scene | a real light, adopted as a thing; counted by `engine.budget` `lights` / `shadowLights`, listed in `describe().render.lights`; a casting light at intensity 0 stops redrawing its shadow map; weather and day-night leave its values alone | many sources, few real lights: `lightPool` (recipe 09) |
|
|
13
13
|
| `new THREE.MeshStandardMaterial(...)` | scene fog (height fog too), cascaded shadows | wind sway: `applyEffects(mat, { wind: 0.03 })` |
|
|
14
|
-
| `engine.post.add(pass)`, the one way into the chain (the other renderer's form: recipe 56) | slots it after the scene render and before tone mapping (FXAA / SMAA last), or after tone mapping when you added it after an OutputPass; a pass that renders `engine.scene` itself (RenderPixelatedPass, SSAA, TAA) replaces the scene render, so the scene is drawn once; skips a RenderPass / OutputPass it already has; listed in `post.list()`; `remove()` leaves it undisposed | a settings name and position: `add(pass, { name: 'glow', order })`, then `engine.post.get(
|
|
14
|
+
| `engine.post.add(pass)`, the one way into the chain (the other renderer's form: recipe 56) | slots it after the scene render and before tone mapping (FXAA / SMAA last), or after tone mapping when you added it after an OutputPass; a pass that renders `engine.scene` itself (RenderPixelatedPass, SSAA, TAA) replaces the scene render, so the scene is drawn once; skips a RenderPass / OutputPass it already has; listed in `post.list()`; `remove()` leaves it undisposed | a settings name and position: `add(pass, { name: 'glow', order })`, then `engine.post.get('glow').enabled = false` |
|
|
15
15
|
| your own `EffectComposer` / `renderer.render` of the whole canvas, every frame | yields the frame (stops drawing its own, warns once `[own-frame]`); delete your render call to hand it back. A minimap / HUD layer on top (scissor, smaller viewport, or `autoClear = false` with another scene) is not a takeover | - |
|
|
16
16
|
| `renderer.setSize` / `setPixelRatio` yourself | the post chain follows on its next draw | - |
|
|
17
17
|
| `scene.fog.far = 80`, `sun.intensity = 3`, `renderer.toneMappingExposure = 1.4` | stays: the engine never writes these on its own | - |
|
|
@@ -22,6 +22,34 @@ pass is a three.js Pass (`engine.post.add(pass)`) before a ready-made effect.
|
|
|
22
22
|
`scene.add` roots (with the file:line that added them), `engine.post.add` effects, modules and plain lights. Without the vite preset, hand the folder over
|
|
23
23
|
yourself: `engine.plugins.add(import.meta.glob('./plugins/*.js', { eager: true }))` before `engine.start()`.
|
|
24
24
|
|
|
25
|
+
## three.js idioms and who writes the value
|
|
26
|
+
|
|
27
|
+
Write the three.js first; it works. `renderer.toneMapping = THREE.ACESFilmicToneMapping` is a complete answer. What you need to know is which values the
|
|
28
|
+
engine **writes on its own** (every frame or on a timer): a direct write to one of those hands it to you (the engine stops writing it and warns once with the
|
|
29
|
+
explicit call); the full list is recipe 52 "Who writes it". The engine route is optional on top: `engine.mod(point, ...)` adds owners and layers where several
|
|
30
|
+
systems share a value (recipe 55); `engine.autoView.manual(key)` takes a value without the warning (`manual(key, false)` gives it back);
|
|
31
|
+
`engine.describe('picture').picture` says what three.js holds now; `describe().owned` who writes each engine-driven value now.
|
|
32
|
+
|
|
33
|
+
| three.js idiom | Where it goes in the engine | Engine writes it? | How to take it over |
|
|
34
|
+
|---|---|---|---|
|
|
35
|
+
| `renderer.toneMapping` | Just set it: `engine.renderer.toneMapping = THREE.ACESFilmicToneMapping` (any three mapping). A curve of your own: a post stage in the `'tone'` slot, `engine.post.add({ name, slot: 'tone', create, node })`, which runs on both renderers (a `ShaderChunk` edit is page-wide and reaches only WebGLRenderer) | Never: three's default (none) stands until you write it | Nothing to take: `describe().render.toneMapping.writer` then says `game` |
|
|
36
|
+
| `renderer.outputColorSpace` | Leave it at `SRGBColorSpace` (three's default) | No | Changing it makes every color wrong; `assets.report` flags it |
|
|
37
|
+
| `renderer.shadowMap` | On at start on a renderer the engine built; the switch is `engine.shadows.enabled`; `type` is yours | `enabled` when the switch changes | `createEngine({ renderer })` and run your own |
|
|
38
|
+
| `scene.environment` | None by default. The sky as a map: `engine.sky.environment({ into: engine.scene })` | Only after that call; a map you write stays | Write it; recipe 34 |
|
|
39
|
+
| `scene.background` | Starts neutral gray; assign yours, or `engine.sky.replace(name \| Texture \| Object3D)` with a sky | The sky dome draws over it; a backdrop / skybox writes it every frame | Assign it: the dome hides and the sky stops writing it |
|
|
40
|
+
| Your own sky (three/addons `Sky`, a ShaderMaterial dome, a skybox) | `engine.sky.replace(mySky)`; feed it from `engine.uniforms` (`uSunDir`, `uDaylight`, `uTimeOfDay`, `uWind`, `uWeatherCloud`) | Never: the engine only hides its dome and adds `mySky` to the scene when it has no parent; time, lights, fog and weather keep running | `engine.sky.replace(null)` gives the dome back. Per key instead of whole: write `engine.sky.top` and friends in your frame code |
|
|
41
|
+
| Lights (`DirectionalLight`, `PointLight`, ...) | `engine.scene.add(light)` before `engine.start()` (a light count change mid-play recompiles shaders; `lightPool()` for many) | Never; `engine.lights.sun` / `.hemi` are placeholders that nothing writes but you | `createEngine({ lights: false })` leaves the placeholders out |
|
|
42
|
+
| Shadow camera (`light.shadow.camera`, `mapSize`, `bias`) | Your own lights: just do it. Engine sun: the same, plus `engine.shadows.box(engine.lights.sun, ...)` | The engine sun's shadow box follows `engine.focus` every frame | `engine.shadows.box(sun, { follow: 'focus' \| 'camera' \| object3D \| fn \| false, extent })`, or place `sun.target` yourself (the box stops following); recipe 45 |
|
|
43
|
+
| `onBeforeCompile`, `customProgramCacheKey` | On the WebGL route just assign them, on any material: `m.onBeforeCompile = s => { ... }`. On WebGPU neither works and it stops with an error: write a node material (recipe 56). A named, checked patch: `applyEffects(m, { patches: [...] })` | Nothing: on a material the engine patched (wind, clouds, season), your function runs first and the patches after it; your cache key is joined in front of theirs | - |
|
|
44
|
+
| Textures, `CanvasTexture`, `DataTexture` | Just do it; set `colorSpace = SRGBColorSpace` on color textures. File textures by name: `engine.assets.manifest({ textures })` then `assets.texture(name)` | No | A texture made in code gets a name too: `assets.manifest({ textures: { brick: () => makeBrick(), sign: mySignTexture } })`, then `map: 'brick'`; it keeps its own repeat / wrap / colorSpace. Baking: recipe 05 |
|
|
45
|
+
| `EffectComposer` passes | `const h = engine.post.add(pass)` (`composer.addPass`; `{ order }` for `insertPass`; `h.remove()` for `removePass`) | The engine renders the main frame through its own composer | `engine.post.own()` for the whole chain. To read them: `engine.post.object()` (the EffectComposer, null until post first runs) and `engine.post.targets()` (`renderTarget1 / 2`, `readBuffer`, `writeBuffer`; read in `onRender(fn, { when: 'after' })`). Read-only: the engine rebuilds `passes`, resizes and disposes them |
|
|
46
|
+
| Render targets (mirror, minimap, portal, picking) | `engine.onRender(({ renderer, scene, camera, dt }) => { renderer.setRenderTarget(rt); renderer.render(scene, cam); })`; runs after the camera and batching, before the frame (`{ when: 'after' }` after it) | No; the render target is reset to the screen after each `before` callback | The main frame render itself stays the engine's |
|
|
47
|
+
| Loaders (`GLTFLoader`, `TextureLoader`, `EXRLoader`, `FBXLoader`, `FontLoader`, exporters) | glTF and png / jpg / ktx2 / hdr textures: `engine.assets.manifest(...)` gives them names, the loading screen and `describe` | No | A hand-made `GLTFLoader` / `TextureLoader` works (rule R21 warns: the asset gets no name). Formats the manifest cannot load (EXR, FBX, OBJ, typeface fonts) and exporters: just use the three.js addon |
|
|
48
|
+
| Camera (`fov`, `position`, `far`) | Camera modules (`followCamera()`, ...) or `engine.camera` with none installed | An installed camera module writes position / fov every frame; terrain view distance rewrites `camera.far` | `engine.takeCamera('me')` (gives it back on `remove()`), or just write `camera.position` (the rig stops; `engine.autoView.manual('camera', false)` resumes). `camera.far` / `fov`: `engine.autoView.manual('far' \| 'fov')` |
|
|
49
|
+
| Meshes (`scene.add(mesh)`) | `engine.add(mesh, { id })` (tracked, saveable) or plain `engine.scene.add(mesh)` | No: auto-batching only merges what the engine places (world records, stream builds, level files); your own meshes stay as you made them | Many static copies of your own mesh: `mesh.userData.batch = true` before adding (recipe 05, 2b) |
|
|
50
|
+
|
|
51
|
+
Contact shadows are no engine feature: `threedog examples pull contact-shadows` copies one way in. WebGPU and TSL: recipe 56.
|
|
52
|
+
|
|
25
53
|
## What the engine changes in three.js (Global changes)
|
|
26
54
|
Everything else in three is untouched. Every change below is listed in `describe().threePatches` (`{ id, what, scope, on, offable, lost }`);
|
|
27
55
|
an offable one is undone page-wide with `threePatches.off(id)` (`import { threePatches } from 'threedog'`), call it before creating the objects
|
|
@@ -37,22 +65,25 @@ that should not see it. It is page-wide: every engine on the page loses the chan
|
|
|
37
65
|
| `renderer-render` | `engine.renderer.render` (that instance only) wrapped | Counts your full-canvas draws so the engine yields the frame; a scissored / smaller-viewport / `autoClear = false` layer (minimap, HUD) does not count | yes |
|
|
38
66
|
| `shader-chunks` | `THREE.ShaderChunk.threedog_*` added (new names, nothing replaced) | None until you `#include` one | no (the engine's patches include them) |
|
|
39
67
|
| `light-idle-shadow` | `shadow.autoUpdate` of your shadow-casting point / spot lights: off while intensity is 0, back on when lit | Only lights whose autoUpdate was on; writing autoUpdate yourself hands the light back; `light.userData.idleShadow = false` opts one out; `describe().render.lights` shows `shadowIdled` | yes |
|
|
68
|
+
| `shadow-cache` | `light.shadow.shadowNode` of a light handed to `engine.shadows.cache`: a `ShadowNode` subclass with float depth, a second depth map and a draw filter | Only that light, only after the call; the handle's `remove()` puts three's node back |
|
|
69
|
+
| `batching-draw-walk` | `children` of a parent holding batched meshes: those meshes leave the array during the engine's own draw and come back right after | None outside the draw: your code, raycasts and `scene.traverse` see the scene as built. A scene change made inside a render (`onBeforeRender`) on such a parent is lost | yes (three walks every batched original twice a frame again) |
|
|
40
70
|
| `picture-writers` | Dev server only (absent from bundles and release builds): an own get / set on the picture values of objects in the engine's scene (light intensity / color / position, `scene.fog` and its values, tone and exposure, environment, background, material color / emissive / opacity), and on the `r g b` / `x y z` of those colors and positions | Every read and write goes through unchanged; in devtools these show as accessors. A write records who made it for `describe('picture').writers` and `engine.explain({ picture })` | yes: `threePatches.off('picture-writers')`, accessors stay and only pass values through |
|
|
41
71
|
| `post-shadow-hold` | `render` of the first pass of the WebGL post chain wrapped (it may be your own Pass) | None to what the pass draws; shadow maps redraw once a frame | yes |
|
|
42
72
|
| `post-background-tone` | `onBeforeRender` of three's own background mesh, while the engine draws straight to the canvas | A texture background is tone-mapped as it is through the post chain; your own `renderer.render` keeps three's rule | yes |
|
|
43
73
|
| `node-twin-dress` | `renderer.library.fromMaterial` of a WebGPURenderer wrapped | WebGPU only: the node twin of a classic material gets its patches | no (patched materials would lose their picture on WebGPU) |
|
|
44
74
|
| `node-builder-hook` | `renderer.debug.onNodeBuilderCreated` of a WebGPURenderer wrapped | WebGPU only: your own hook still runs; a later write of yours replaces the engine's | yes |
|
|
45
75
|
| `device-lost-hook` | `renderer.onDeviceLost` of a WebGPURenderer wrapped | WebGPU only: three's hook still runs; a later write of yours replaces the engine's | yes |
|
|
46
|
-
| `
|
|
76
|
+
| `lod-view-camera` | `update` and `clone` of the `THREE.LOD` objects `assets.lod` and a prop's `lod` make | Only the engine camera moves the level, and far off the full model waits on the batch layer with `visible` still true, so rays reach it | yes |
|
|
77
|
+
| `webgpu-record-sweep` | A `'dispose'` event sent to objects drawn earlier that have left every Scene for a few seconds, found through WebGPURenderer's private record list | WebGPU only: your `'dispose'` listener on such an object runs; drawing it again rebuilds its record | yes |
|
|
47
78
|
|
|
48
79
|
|
|
49
80
|
## Getting three.js objects from the engine
|
|
50
81
|
|
|
51
82
|
| You want | Use |
|
|
52
83
|
|---|---|
|
|
53
|
-
| THREE itself | `import { THREE } from 'threedog'`
|
|
54
|
-
| Scene / camera / renderer | `engine.scene`, `engine.camera` (PerspectiveCamera), `engine.renderer` (WebGLRenderer) |
|
|
55
|
-
| Player, NPCs | `engine.player.
|
|
84
|
+
| THREE itself | `import { THREE } from 'threedog'` (the same copy the engine uses) |
|
|
85
|
+
| Scene / camera / renderer | `engine.scene`, `engine.camera` (PerspectiveCamera), `engine.renderer` (WebGPURenderer on the default route of a new game, WebGLRenderer on `--webgl`) |
|
|
86
|
+
| Player, NPCs | `engine.player.root`, `engine.npcs.get('name').root` (Group); position `.position` (Vector3) |
|
|
56
87
|
| Pickups, template instances | `pickups.spawn(...)` returns a handle with `.object` (Mesh); a template instance's model is `engine.world.view(id)` (exists only near) |
|
|
57
88
|
| Level | `engine.level.root`; markers `engine.level.marker('spawn').object / .position` |
|
|
58
89
|
| Sun, ambient light, sky dome, fog | `engine.lights.sun` (DirectionalLight), `engine.lights.hemi` (HemisphereLight), `engine.sky.dome`, `engine.scene.fog` |
|
|
@@ -64,17 +95,13 @@ that should not see it. It is page-wide: every engine on the page loses the chan
|
|
|
64
95
|
| Vehicles, navigation, character controller | `engine.rigid.addWheeled(mesh, ...)` returns `{ body, controller }`; `engine.nav.navMesh / query / tileCache / crowd` (they are destroyed and replaced on rebuild; code that caches them compares `engine.nav.version`); `engine.player.mover.controller` (mover: 'rapier') |
|
|
65
96
|
| glTF / compression decoders | `engine.assets.gltf` (GLTFLoader, Meshopt installed), `assets.draco` (DRACOLoader), `assets.ktx2` (KTX2Loader); the last two are created the first time compressed data is met and are null before that |
|
|
66
97
|
| Rays | `engine.raycast(origin, direction)` / `engine.pick(ndcX, ndcY)` return three hits (`object` is the mesh, `face` and `point` unchanged); `{ targets: 'all' }` hits rigid bodies too (the hit carries `entry` and `kind: 'rigid'`); the underlying `engine.rays.ray` (THREE.Raycaster, `firstHitOnly` on) |
|
|
67
|
-
| Ray acceleration (BVH) | three-mesh-bvh, without touching three's prototypes: a static mesh the engine registers (from 256 triangles up) gets `mesh.geometry.boundsTree` and its own `mesh.raycast`, so
|
|
98
|
+
| Ray acceleration (BVH) | three-mesh-bvh, without touching three's prototypes: a static mesh the engine registers (from 256 triangles up) gets `mesh.geometry.boundsTree` and its own `mesh.raycast`, so any ray on that mesh is fast, your own `new THREE.Raycaster()` too; every other mesh is plain three. Page-wide BVH for your rays: three-mesh-bvh's documented setup (`Mesh.prototype.raycast = acceleratedRaycast`, ...) |
|
|
68
99
|
| Streamed-in objects | `.object` of the handle returned by `engine.stream.add({ position, build })` (the Object3D that build returned; null before it is built) |
|
|
69
100
|
| Post-processing | `engine.post.add(pass)`, the one way in (a Pass, or an effect `{ name, slot, create: ctx => pass }` plus its twin for the other renderer, recipe 56; slots `scene` / `hdr` / `tone` / `ldr` / `final`; on / off and params with its handle); `engine.post.own()` hands over the whole chain |
|
|
70
101
|
| Where the mouse points | Ground: `screenToGround(engine, input.pointer.ndcX, ndcY)` -> Vector3; objects: `engine.pick(input.pointer.ndcX, ndcY)` (registered static objects; for any object pass `{ targets: [object] }`) |
|
|
71
102
|
|
|
72
103
|
Returned positions are all `THREE.Vector3` (the camera's `forward()/right()` are planar directions `{x, z}`; positions in photo records are saveable `{x, z}`).
|
|
73
|
-
Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x, y, z]` / `{ x, z }` all work, and sizes go in an options object (
|
|
74
|
-
"Interface conventions" in `CONVENTIONS.md`):
|
|
75
|
-
`collision.addCircle(mesh, { radius: 1 })`, `collision.addBox(mesh.position, { halfWidth: 2, halfDepth: 1 })`, `particles.emit('dust', mesh, { count: 20 })`,
|
|
76
|
-
`triggers.add({ position: mesh })`, `content.spawn(name, v)`, `npcs.add({ position: v })`, `pickups.spawn(v, { give })`, `interactions.add(v or mesh, ...)`,
|
|
77
|
-
`rigid.impulse(entry, [0, 3, 5])`, `player.placeAt(v)`. Ground sampling `engine.surface(x, z)` also accepts `engine.surface(mesh.position)`.
|
|
104
|
+
Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x, y, z]` / `{ x, z }` all work, and sizes go in an options object ("Interface conventions" in `CONVENTIONS.md`).
|
|
78
105
|
|
|
79
106
|
## Engine conventions when using three.js
|
|
80
107
|
|
|
@@ -85,16 +112,15 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
|
|
|
85
112
|
be lit N times; a lit `ShaderMaterial` of yours joins with `engine.shadows.include(mat)` (recipe 45).
|
|
86
113
|
2. **Adding to the scene**: `engine.scene.add(obj)` is all it takes: every root under the scene is registered (`engine.thing(obj)` says what it
|
|
87
114
|
is and what a save keeps). `engine.add(obj, { id })` is only for a stable id, so `thing.set` changes to it are saved. Plain three.js and
|
|
88
|
-
templates (`engine.content.spawn`, content props) are two doors into one scene (`recipes/40-scene.md`). To attach to a character use `player.
|
|
115
|
+
templates (`engine.content.spawn`, content props) are two doors into one scene (`recipes/40-scene.md`). To attach to a character use `player.root.add(hat)`.
|
|
89
116
|
3. **Per-frame logic goes in `engine.onFrame(dt => ...)`** (movement and timing use `engine.onFixed`); it returns a handle, cancel with `h.remove()`.
|
|
90
117
|
Don't start your own `requestAnimationFrame` loop: the engine owns pausing, fast-forward in tests and ordering. Rendering the canvas
|
|
91
118
|
yourself (own `EffectComposer`) takes the frame over: the engine stops drawing it and its post chain, adaptive resolution and photo mode stop applying. Rendering into your own render target is fine (mirror, minimap, portal, picking): do it in
|
|
92
119
|
`engine.onRender(({ renderer, scene, camera, dt }) => ...)`, which runs after the camera update and batching, just before the frame
|
|
93
|
-
(`{ when: 'after' }` runs right after it).
|
|
120
|
+
(`{ when: 'after' }` runs right after it).
|
|
94
121
|
4. **Snap to ground**: get ground height with `engine.surface(x, z)`, or `engine.snapToGround(obj, heightAboveGround)`. Don't raycast the terrain.
|
|
95
122
|
**Rays** always go through `engine.raycast / pick`: level meshes are registered automatically; register your own static objects with
|
|
96
123
|
`engine.rays.addStatic(obj)` or `assets.model(name, { static: true })`.
|
|
97
|
-
When you need a plain `THREE.Raycaster`, it also uses the BVH automatically (as long as the geometry has a boundsTree).
|
|
98
124
|
5. **Deleting**: when you no longer need an object use `engine.remove(obj)`: it removes it, unregisters it from `engine.rays` and frees the geometry
|
|
99
125
|
and materials (`obj.removeFromParent()` / `scene.remove` leak GPU memory). To take it off only temporarily and `add` it back later use
|
|
100
126
|
`engine.detach(obj)`. A copy from `assets.model()` shares resources with other copies (`remove` skips them); they are freed together by
|
|
@@ -110,31 +136,54 @@ Anywhere a position is accepted it is **one argument**: Vector3 / Object3D / `[x
|
|
|
110
136
|
`npm run bake` it reads the file.
|
|
111
137
|
Things needed only nearby use `engine.stream.add({ position, build })`; put long loops in `engine.jobs.add(function* () { ...; yield; })` so they
|
|
112
138
|
are spread over frames and the start does not stall.
|
|
113
|
-
Smooth normals on built shapes: a non-indexed geometry (`geometry.toNonIndexed()`, a `mergeGeometries` result where one part has no index) gives
|
|
114
|
-
every triangle its own vertices, so `geometry.computeVertexNormals()` shades each face flat (a low-poly look). Weld first with `mergeVertices` from
|
|
115
|
-
`three/addons/utils/BufferGeometryUtils.js` (per part, so hard edges between parts stay), then compute the normals.
|
|
116
139
|
10. **One copy of the engine and of three per page**: `resolve: { dedupe: ['threedog', 'three'] }` in vite.config.js. A second engine copy
|
|
117
140
|
(a pack that lists threedog under `dependencies` instead of `peerDependencies`, a linked plus an installed copy) breaks shadows of wind and
|
|
118
141
|
cascaded-shadow materials; the engine warns once at load, naming both paths [engine-two-copies].
|
|
119
142
|
|
|
120
143
|
## Example: a spinning windmill (plain three.js + engine conventions)
|
|
121
|
-
|
|
144
|
+
The same windmill as a template with an id, saved and editable without code, is in `recipes/40-scene.md` §1.
|
|
122
145
|
|
|
123
146
|
```js
|
|
124
147
|
import { THREE } from 'threedog';
|
|
125
|
-
const mill = new THREE.Group(),
|
|
126
|
-
|
|
127
|
-
const tower = new THREE.Mesh(new THREE.CylinderGeometry(0.8, 1.2, 6, 6), wood);
|
|
128
|
-
tower.position.y = 3; tower.castShadow = true;
|
|
129
|
-
const blades = new THREE.Group(); blades.position.set(0, 5.5, 1.3);
|
|
130
|
-
for (let i = 0; i < 4; i++) {
|
|
131
|
-
const arm = new THREE.Group(), sail = new THREE.Mesh(new THREE.BoxGeometry(0.5, 4, 0.08), cloth);
|
|
132
|
-
sail.position.y = 2; sail.castShadow = true; arm.rotation.z = i * Math.PI / 2; arm.add(sail); blades.add(arm);
|
|
133
|
-
}
|
|
134
|
-
mill.add(tower, blades);
|
|
148
|
+
const mill = new THREE.Group(), blades = new THREE.Group(); // plain three.js: meshes and materials as usual
|
|
149
|
+
mill.add(blades);
|
|
135
150
|
mill.position.set(20, 0, -10);
|
|
136
151
|
engine.snapToGround(mill); // snap to ground
|
|
137
152
|
engine.scene.add(mill); // registered like engine.add; engine.add(mill, { id: 'mill' }) also keeps thing.set changes in saves
|
|
138
153
|
engine.collision?.addCircle(mill, { radius: 1.3 }); // block the player (when the collision module is installed)
|
|
139
154
|
engine.onFrame(dt => { blades.rotation.z += dt * 1.5; });
|
|
140
155
|
```
|
|
156
|
+
|
|
157
|
+
## Code-built models: what three.js already has
|
|
158
|
+
Models written in code (recipe 05, 2a) mostly need helpers three.js ships; import them inside the model generator, so the result is cached and baked with the model.
|
|
159
|
+
`three`: `LatheGeometry`, `TubeGeometry`, `ExtrudeGeometry` (`extrudePath`), `ShapeGeometry`, `InstancedMesh`, `BatchedMesh`, `CanvasTexture`. `three/addons`: `BufferGeometryUtils` (`mergeGeometries`, `mergeVertices`, `toCreasedNormals`),
|
|
160
|
+
`LoftGeometry`, `RoundedBoxGeometry`, `ParametricGeometry`, `TextGeometry`, `DecalGeometry`, `ConvexGeometry`, `Flow` (CurveModifier), `MeshSurfaceSampler`, `SimplifyModifier`, `TessellateModifier`, `EdgeSplitModifier`, `SimplexNoise`, `ImprovedNoise`.
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
import * as THREE from 'three';
|
|
164
|
+
import { mergeGeometries, mergeVertices } from 'three/addons/utils/BufferGeometryUtils.js';
|
|
165
|
+
import { SimplexNoise } from 'three/addons/math/SimplexNoise.js';
|
|
166
|
+
import { bakeVertexAO } from 'threedog';
|
|
167
|
+
|
|
168
|
+
const rng = engine.random.seeded(7), simplex = new SimplexNoise({ random: () => rng.next() }); // seeded noise: the same shape every load
|
|
169
|
+
// weld first, or the noise opens cracks; mergeVertices compares every attribute, so drop normal and uv (their seams would stay unwelded)
|
|
170
|
+
const rock = mergeVertices(new THREE.IcosahedronGeometry(1, 3).deleteAttribute('normal').deleteAttribute('uv'));
|
|
171
|
+
const p = rock.attributes.position, v = new THREE.Vector3();
|
|
172
|
+
for (let i = 0; i < p.count; i++) { v.fromBufferAttribute(p, i); v.multiplyScalar(1 + 0.25 * simplex.noise3d(v.x, v.y, v.z)); p.setXYZ(i, v.x, v.y, v.z); }
|
|
173
|
+
rock.computeVertexNormals();
|
|
174
|
+
const slab = new THREE.CylinderGeometry(1.2, 1.4, 0.3).translate(0, -0.9, 0).deleteAttribute('uv');
|
|
175
|
+
const model = mergeGeometries([rock, slab]); // same attributes (position, normal), both indexed
|
|
176
|
+
bakeVertexAO(model, { samples: 32, strength: 0.7, occluders: [new THREE.PlaneGeometry(6, 6).rotateX(-Math.PI / 2).translate(0, -1.05, 0)] });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Traps: `mergeGeometries` needs the same attributes on every part, all indexed or none. A non-indexed geometry (`geometry.toNonIndexed()`, a merge where one part has no index) gives every triangle its own
|
|
180
|
+
vertices, so `geometry.computeVertexNormals()` shades each face flat: weld first with `mergeVertices` (per part, so hard edges between parts stay). `SimplifyModifier.modify` is async in this three version.
|
|
181
|
+
|
|
182
|
+
| Need | Engine, only what three lacks |
|
|
183
|
+
|---|---|
|
|
184
|
+
| Parts of one flat color each, into one geometry | `mergeColored([[g, color], ...])` (vertex colors) |
|
|
185
|
+
| Ambient occlusion in a code-built model (three's `aoMap` needs a baked texture) | `bakeVertexAO(geometry, { samples, radius, strength, occluders })`: hemisphere rays per vertex (three-mesh-bvh), multiplied into the vertex colors; detail is per vertex, so tessellate big faces first |
|
|
186
|
+
| Points over the ground by height, slope and biome | `engine.vegetation.define(name, { rule })` (recipe 36) |
|
|
187
|
+
| Far copies of whole areas | `hlod` (recipe 15) |
|
|
188
|
+
| Terrain heights | `@threedog/terrain-noise` (recipe 28) |
|
|
189
|
+
| Many copies | Auto-batching for copies the engine places, `userData.batch` for yours (recipe 05, 2b) |
|
package/docs/api/assets.md
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
# engine.assets (Assets)
|
|
2
2
|
|
|
3
3
|
- `assets.manifest(m: AssetManifest | AssetManifest[])` — Register an asset manifest or asset pack (can be called several times; a later entry with the same name replaces the earlier one). Its name labels it in engine.loading, base resolves its relative paths
|
|
4
|
-
- `assets.builder(name: string) → ((...args: any[]) => any) | null` — The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it)
|
|
5
|
-
- `assets.paramsOf(name: string) → { schema, values, tuned } | null` — The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null
|
|
4
|
+
- `assets.builder(name: string) → ((...args: any[]) => any) | null` — (experimental) The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it)
|
|
5
|
+
- `assets.paramsOf(name: string) → { schema, values, tuned } | null` — (experimental) The params of a generator registered with a params schema: { schema, values (built with now), tuned (from setParams) }, or null
|
|
6
6
|
- `assets.setParams(name: string, values: Record<string, any>) → Promise<{ why: string; names: str…` — Dev tuning: build a generator with these params (replacing its defaults) and swap every live copy in place; the dev panel's models folder calls it
|
|
7
|
-
- `assets.preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }) → Promise<{ loaded: number; failed:…` — Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now showing their fallback
|
|
7
|
+
- `assets.preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }) → Promise<{ loaded: number; failed:…` — (experimental) Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now showing their fallback
|
|
8
8
|
- `assets.font(name: string) → Promise<FontFace | null>` — A font from an asset pack by name: downloaded once, added to document.fonts; null when the file failed and it is not critical. ui.fonts calls it at start()
|
|
9
9
|
- `assets.model(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Promise<Object3D>` — Get a model copy (name or path; geometry and materials are shared with other copies). static: true registers it in engine.rays (builds ray acceleration)
|
|
10
|
-
- `assets.
|
|
10
|
+
- `assets.lod(nameOrUrl: string, opts?: { distances?, hysteresis?, castShadow?, receiveShadow?, static? }) → Promise<import('three').LOD>` — (experimental) A model copy as a plain THREE.LOD: the full model near, the levels of `threedog assets optimize --lod` far away. Default distances follow the model's size; distances (rising meters) replace them, hysteresis is the share of a distance that stops flicker at the line (default 0.1). Rays, collision and saves keep using the full model. A LOD object is never batched. Without levels it warns in dev and draws in full. Example: `const tower = await engine.assets.lod('tower', { distances: [40, 120] }); engine.add(tower); tower.levels[1].object;`
|
|
11
|
+
- `assets.modelNow(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Object3D | null` — (experimental) A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs. Code-built models (a build function in the manifest) count too: they are null until one await model(name) or an entry with preload: true ran (dev warns [asset-not-loaded]). Example: `const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');`
|
|
11
12
|
- `assets.geometry(nameOrUrl: string) → Promise<BufferGeometry>` — Get the geometry of the first mesh in a model
|
|
12
13
|
- `assets.gridFromImage(nameOrUrl: string, opts?: { channel?, range?, bits? }) → Promise<{ data: Float32Array; wid…` — An image as grid data for sampleGrid: PNG at 8 or 16 bits (jpg / webp 8). channel 'r' (default) 'g' 'b' 'a' or 0-3; range maps pixels to [min, max] (default [0, 1])
|
|
13
14
|
- `assets.texture(nameOrUrl: string, opts?: { color?, pixelated?, repeat? }) → Promise<Texture>` — Get a texture (.ktx2 compressed textures also work)
|
|
14
|
-
- `assets.useTexture(nameOrUrl: string, use: (texture: Texture) => void, o?: { where?, instead?, opts? }) → Promise<boolean>` — Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one load
|
|
15
|
-
- `assets.release(name: string)` — Release a resource and return
|
|
16
|
-
- `assets.trim() → string[]` — Release every model that has no copy in use (called automatically after level changes). Models whose shared geometry was taken by geometry() and code-generated models are not released automatically. Returns the released names
|
|
17
|
-
- `assets.
|
|
18
|
-
- `assets.forget(obj: Object3D)` — Called when an object is fully removed (engine.remove already calls it, normally you don't need to): decrements the use count of the model copies under it
|
|
15
|
+
- `assets.useTexture(nameOrUrl: string, use: (texture: Texture) => void, o?: { where?, instead?, opts? }) → Promise<boolean>` — Fetch a texture for something that already shows a stand-in: use(texture) runs when it arrives; a failed load is one asset-load dev warning naming `where` and what shows `instead`, and resolves false (an error inside use() is not swallowed). opts are texture()'s options
|
|
16
|
+
- `assets.release(name: string)` — Release a resource and return its memory. Not released while copies of the model are still in the scene; it is released when the last copy is removed with engine.remove. A sound (name or path) plays on where it is playing and loads again on next use. A load still running ends and its result is thrown away; code awaiting it gets a fresh load, never freed data. A name that fell back holds no data of its own: release the name it fell back to
|
|
17
|
+
- `assets.trim() → string[]` — Release every model that has no copy in use and every long decoded sound (music, long loops; short effects stay; a sound still playing plays on), unless marked preload (called automatically after level changes). Models whose shared geometry was taken by geometry() and code-generated models are not released automatically. Returns the released names
|
|
18
|
+
- `assets.forget(obj: Object3D)` — (experimental) Called when an object is fully removed (engine.remove already calls it, normally you don't need to): decrements the use count of the model copies under it
|
|
19
19
|
- `assets.animate(root: Object3D, config?: AnimatorOptions) → Animator` — Create an animation state machine for a skinned model (without config it is simple play-by-name). A copy of a manifest model whose entry has `animation` starts from that mapping; config wins per state
|
|
20
20
|
- `assets.mapping(root: Object3D) → AnimatorOptions | null` — The manifest entry's animation mapping for a model copy, or null (not a manifest copy, or no mapping)
|
|
21
21
|
- `assets.report(nameOrRoot: string | Object3D) → AssetReport` — Import report of a loaded model (by name, or a copy from model()): materials, textures with colorSpace, clips, colliders, templates, and issues for what the file has but the scene lost
|
|
22
|
-
- `assets.reportText(nameOrRoot: string | Object3D) → string` — assets.report as text for the console / describe
|
|
23
22
|
- Properties:
|
|
24
23
|
- `cacheMinMs: number` Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20
|
|
25
24
|
- `palette: Record<string, any>` Named colors for what is made in code: a generator written with `function` reads this.palette. Plain data, read, write or replace it freely: it is part of the cache key, so a model or texture asked for after a write is built from the new colors. Copies already placed keep theirs. Example: `engine.assets.palette = { leaf: 0xd98a3a, bark: 0x6b4a30 };`
|
|
26
25
|
- `shared: WeakSet<object>` Geometry and materials shared by model copies (engine.remove does not release them, use release)
|
|
27
26
|
- `memory: { geometries: number; textures: number }` Current GPU memory usage (number of geometries and textures)
|
|
28
|
-
- `gltf: any` three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed)
|
|
29
|
-
- `draco: any` three.js DRACOLoader (created only the first time Draco compression is met, null before; the decoder defaults to the one bundled with three, vite packs it automatically)
|
|
30
|
-
- `ktx2: any` three.js KTX2Loader (created only the first time a KTX2 texture is met, null before)
|
|
27
|
+
- `gltf: any` (experimental) three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed)
|
|
28
|
+
- `draco: any` (experimental) three.js DRACOLoader (created only the first time Draco compression is met, null before; the decoder defaults to the one bundled with three, vite packs it automatically)
|
|
29
|
+
- `ktx2: any` (experimental) three.js KTX2Loader (created only the first time a KTX2 texture is met, null before)
|
|
31
30
|
|
|
32
31
|
## Data structures
|
|
33
32
|
- **AssetManifest** An asset manifest, also the shape of an asset pack (a folder or npm package exporting one): names -> files or generators; content and code use the names only
|
package/docs/api/audio.md
CHANGED
|
@@ -6,21 +6,22 @@
|
|
|
6
6
|
- `audio.condition(name: string, test: (value: any, e: any) => boolean) → { remove(): void }` — Add a condition key for music / ambience rule lists: `when: { [name]: value }` calls test(value, engine). Modules add theirs (calendar: time, weather: weather, triggers: zone); the engine has `state` (engine.audio.state). Example: `engine.audio.condition('inside', v => engine.vars.flag('indoors') === v);`
|
|
7
7
|
- `audio.measure(name: string, fn: (e: any) => number) → { remove(): void }` — Add a measure: a number rule data compares (`when: { daylight: { gt: 0.15 } }`; gt / gte / lt / lte) and adds up (`volume: { add: { wind: 0.08 } }`). calendar adds daylight, weather rain / snow / wind, ambience nearWater / altitude. A name is a condition or a measure, not both. Example: `engine.audio.measure('danger', e => e.vars.counter('alarm') / 10); // data: when: { danger: { gt: 0.5 } } Measures are not only for sound: render/daylight.js reads 'daylight' for night glow, so the calendar (or the sky without one) registers it once and nothing else has to know which module tells day from night. remove() drops only this registration (a later one under the name stays).`
|
|
8
8
|
- `audio.value(name: string) → number | undefined` — The current value of a measure (debug, tests); undefined when none is registered under that name
|
|
9
|
-
- `audio.matches(when: AudioCondition | undefined, ...extra: any[]) → boolean` — Does a rule's `when` hold now? An object needs every key to hold (condition keys, or measure comparisons); a function gets (engine, ...extra); missing = always. Example: `engine.audio.matches({ time: 'night', zone: 'forest', rain: { lt: 0.2 } });`
|
|
10
|
-
- `audio.volumeOf(volume: AudioVolume | undefined, ...extra: any[]) → number` — A rule's volume now: a number, a function (engine, ...extra), or data { base, add: { measure: factor }, min, max }; missing = 1. Example: `engine.audio.volumeOf({ base: 0, add: { rain: 0.22 } }); // 0.22 in full rain`
|
|
9
|
+
- `audio.matches(when: AudioCondition | undefined, ...extra: any[]) → boolean` — (experimental) Does a rule's `when` hold now? An object needs every key to hold (condition keys, or measure comparisons); a function gets (engine, ...extra); missing = always. Example: `engine.audio.matches({ time: 'night', zone: 'forest', rain: { lt: 0.2 } });`
|
|
10
|
+
- `audio.volumeOf(volume: AudioVolume | undefined, ...extra: any[]) → number` — (experimental) A rule's volume now: a number, a function (engine, ...extra), or data { base, add: { measure: factor }, min, max }; missing = 1. Example: `engine.audio.volumeOf({ base: 0, add: { rain: 0.22 } }); // 0.22 in full rain`
|
|
11
11
|
- `audio.sfx(name: string, opts?: { volume?, pitch?, at?, bus?, loop?, params?, … }) → SoundHandle | null` — Play a sound by name: its audio.sounds rule (src / variants, volume, bus...), or with no rule the asset pack sound of that name (file or synth function from assets.manifest({ sounds })). Returns a SoundHandle (stop, fade, setPosition), or null when it is silent: not configured, a built-in synth the game did not name, audio still locked, or held back by the sound's cooldown. Over its `voices` limit the oldest voice stops. Example: `engine.audio.sfx('hit', { at: enemy.root, volume: 0.8 });`
|
|
12
12
|
- `audio.noiseBurst(opts?: { dur?, type?, freq?, vol?, bus?, out?, … })` — Synth building block: a burst of filtered noise (footsteps, shutter, rain, thunder). dur seconds, freq Hz, vol 0-1; out: the node to connect to (a synth's `out`), else the named bus
|
|
13
13
|
- `audio.tone(opts?: { freq?, to?, dur?, vol?, type?, bus?, … })` — Synth building block: a short tone (bird call, notification). freq/to Hz, dur seconds, pan -1..1; out as in noiseBurst. Example: `engine.audio.tone({ freq: 660, to: 880, dur: 0.15, bus: 'ui' });`
|
|
14
|
-
- `audio.load(url: string) → Promise<any>` — Download and decode an audio file
|
|
14
|
+
- `audio.load(url: string) → Promise<any>` — Download and decode an audio file, as an engine.loading task: a path or a sound name from an asset pack (manifest sounds), so sounds entries and music tracks may name assets instead of paths. engine.assets caches it: short effects stay; long sounds go with assets.release / trim or over a memory budget, and load again on next use
|
|
15
15
|
- `audio.play(url: string, opts?: { bus?, volume?, loop?, fadeIn?, pitch?, at? }) → Promise<SoundHandle | null>` — Play an audio file by path (no sounds entry needed); resolves to a SoundHandle once the file is decoded. Example: `const h = await engine.audio.play('/sfx/door.ogg', { bus: 'ui' }); h.stop({ fade: 0.5 });`
|
|
16
16
|
- Properties:
|
|
17
17
|
- `ctx: any` The browser AudioContext (exists only after the first click)
|
|
18
18
|
- `levels: Record<string, number>` Volume per bus 0-1 ('master' is the total). Every key is a bus: levels: { voice: 1 } adds a 'voice' bus
|
|
19
|
-
- `buses: Record<string, any>` Bus input GainNodes by name (connect your own nodes here); empty until audio unlocks
|
|
19
|
+
- `buses: Record<string, any>` Bus input GainNodes by name, 'master' included (connect your own nodes here); empty until audio unlocks. A name that is no bus warns and gives master: node.connect(undefined) would throw, and in dev a throw freezes gameplay
|
|
20
20
|
- `state: string | null` The game's current mode for rule lists, e.g. 'combat' / 'explore' (condition `state` in music and ambience rules)
|
|
21
21
|
- `master: any` The master GainNode (every bus ends here)
|
|
22
22
|
- `noise: any` 2 s of white noise, reused by synthesized sounds
|
|
23
|
-
- `running: boolean` Is audio usable (the player has clicked/pressed a key)?
|
|
23
|
+
- `running: boolean` (experimental) Is audio usable (the player has clicked/pressed a key)?
|
|
24
|
+
- `info: { running, state, levels, ducks, voices }` What is playing (describe().audio shows it while something is ducked or playing): bus levels, the duck multiplier per bus, live voices per sound name. ducks is the level the active ducks ask for (1 = not lowered), read at once even while a fade is still ramping or the audio clock does not run (headless page). Example: `engine.audio.duck({ music: 0.3 }); engine.audio.info.ducks.music // 0.3`
|
|
24
25
|
|
|
25
26
|
## Data structures
|
|
26
27
|
- **AudioConfig** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio).
|
package/docs/api/budget.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# engine.budget (Budget) — engine.budget: performance budget (turned on by createEngine({ budget }) or enable(); off by default, costs nothing)
|
|
2
2
|
|
|
3
3
|
- `budget.enable(limits?: BudgetLimits)` — Turn on and set limits (only categories given are checked). Example: `engine.budget.enable({ drawCalls: 250, fps: 55 });`
|
|
4
|
-
- `budget.disable()` — Turn off
|
|
4
|
+
- `budget.disable()` — (experimental) Turn off
|
|
5
5
|
- `budget.metric(name: string, read: () => number, opts?: { limit?: number }) → Handle` — Module-defined category: read() returns the current value, opts.limit is the limit (the game's enable() takes precedence). Returns a handle { remove() }
|
|
6
|
-
- `budget.limitOf(name: string) → number | undefined` — Limit of a category; undefined if none was given (not checked)
|
|
6
|
+
- `budget.limitOf(name: string) → number | undefined` — (experimental) Limit of a category; undefined if none was given (not checked)
|
|
7
7
|
- `budget.report() → BudgetReport | null` — Budget report; null when off. In the real-time loop it returns the last second's result; in step() mode it is computed on demand
|
|
8
|
-
- `budget.checkStartup(s: { totalMs, modules }) → { category, value, limit, top }[]` — Called by the engine when startup finishes: warns if startupMs / moduleMs is exceeded and returns the offenders (empty array if none)
|
|
8
|
+
- `budget.checkStartup(s: { totalMs, modules }) → { category, value, limit, top }[]` — (experimental) Called by the engine when startup finishes: warns if startupMs / moduleMs is exceeded and returns the offenders (empty array if none)
|
|
9
9
|
- `budget.values() → Record<string, number>` — Current value per category (fps/low1/cpuMs exist only once there are frame times)
|
|
10
10
|
- `budget.byTag() → BudgetTagStat[]` — Estimate draw calls and triangles by userData.budgetTag (visible meshes inside the frustum; shadow casters count a second shadow draw). Returns [{ tag, drawCalls, triangles }], largest first. Called only on overrun (at most once a second) or when debugging
|
|
11
11
|
- Properties:
|
|
12
12
|
- `enabled: boolean` Is it on?
|
|
13
|
-
- `limits: BudgetLimits` Current limits
|
|
13
|
+
- `limits: BudgetLimits` (experimental) Current limits
|
|
14
14
|
- `cost: ApplyCost` Cost of applying background results, split in stages (see ApplyCost)
|
|
15
15
|
|
|
16
16
|
## Data structures
|
package/docs/api/calendar.md
CHANGED
|
@@ -4,7 +4,7 @@ Time of day, day, seasons and clock-time timers (calendar() module); NPC schedul
|
|
|
4
4
|
|
|
5
5
|
- Options `CalendarOptions`:
|
|
6
6
|
- `time?: string | number` Time of day at start: 'HH:MM' or fraction of a day 0–1 (0.5 noon), default 0.33 (afterwards read / write engine.calendar.timeOfDay)
|
|
7
|
-
- `dayLength?: number`
|
|
7
|
+
- `dayLength?: number` Calendar seconds per day, default Infinity: the time of day never moves until the game sets a length (presets.calendar.cycle has 360) (one hour = dayLength / hoursPerDay calendar seconds; with clock.rate 1 calendar seconds are real seconds)
|
|
8
8
|
- `hoursPerDay?: number` Hours per day of the displayed clock and of clock notation ('18:30'), default 24
|
|
9
9
|
- `day?: number` Which day to start from, default 1
|
|
10
10
|
- `daysPerSeason?: number` Days of each season given by name only, default 7
|
|
@@ -15,22 +15,21 @@ Time of day, day, seasons and clock-time timers (calendar() module); NPC schedul
|
|
|
15
15
|
- `calendar.between(from: string | number, to: string | number, opts: CalendarBetweenOptions) → Handle` — Time-range switch: on() while clock time is in [from, to), otherwise off() (from > to wraps midnight). Aligns once immediately on registration, new game, load, applying a scenario and time rewind; afterwards it calls on/off when crossing a boundary. Example: `engine.calendar.between('09:00', '17:00', { on: () => shop.open(), off: () => shop.close() })`
|
|
16
16
|
- `calendar.daily(fn: (day: number) => void, opts?: CalendarAtOptions) → Handle` — Call fn(day) at the start of each day (00:00)
|
|
17
17
|
- `calendar.onSeason(name: string, fn: (season: string) => void) → Handle` — Call fn(seasonName) on entering season name
|
|
18
|
-
- `calendar.untilMark() → number` —
|
|
18
|
+
- `calendar.untilMark() → number` — (experimental) Calendar seconds until the next clock mark (midnight, at times, between edges); engine.skip ends a segment there; Infinity when the time of day never moves
|
|
19
19
|
- Properties:
|
|
20
|
-
- `hoursPerDay: number` Hours per day (clock notation 'HH:MM', schedules, at / between)
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
-
- `timeOfDay: number` Time of day: 0-1 (0 midnight, 0.25 6am, 0.5 noon, 0.75 6pm); one day = dayLength game seconds (the unit of engine.clock.now). Writing it later in the day counts as time passing (at timers crossed fire); writing it earlier only resets the timers' baseline
|
|
20
|
+
- `hoursPerDay: number` (experimental) Hours per day (clock notation 'HH:MM', schedules, at / between)
|
|
21
|
+
- `seasons: string[]` (experimental) Season names, [] when the game has no seasons (the default)
|
|
22
|
+
- `timeOfDay: number` Time of day: 0-1 (0 midnight, 0.25 6am, 0.5 noon, 0.75 6pm); one day = dayLength calendar seconds (the unit of engine.clock.now). Writing it later in the day counts as time passing (at timers crossed fire); writing it earlier only resets the timers' baseline
|
|
24
23
|
- `day: number` Day number (1-based); writing it fires no day:start
|
|
25
|
-
- `dayLength: number`
|
|
24
|
+
- `dayLength: number` Calendar seconds per day (1 hour = dayLength / hoursPerDay calendar seconds; at clock.rate 1 calendar seconds equal real seconds); Infinity = the time of day never moves. Changing it keeps the current time of day
|
|
26
25
|
- `clock: string` Clock text, e.g. "18:00"
|
|
27
26
|
- `daylight: number` Daylight from the clock 0-1 (0 from 18:00 to 06:00, 1 at noon; a sine over the day). Audio rules { daylight }, ambience and the sky's default sun read it
|
|
28
27
|
- `isDay: boolean` Whether it is daytime by the clock (06:00-18:00 of the day's hours)
|
|
29
|
-
- `seasonIndex: number` Current season index, -1 without seasons
|
|
28
|
+
- `seasonIndex: number` (experimental) Current season index, -1 without seasons
|
|
30
29
|
- `season: string | null` Current season name, e.g. 'spring'; null without seasons
|
|
31
|
-
- `dayOfSeason: number` Day within the season (1-based); 0 without seasons
|
|
32
|
-
- `seasonProgress: number` Fraction of the season elapsed, 0-1 (includes time of day); 0 without seasons
|
|
33
|
-
- `totalDays: number` Total game time in days (fractional), for growth, cooldowns and the like
|
|
30
|
+
- `dayOfSeason: number` (experimental) Day within the season (1-based); 0 without seasons
|
|
31
|
+
- `seasonProgress: number` (experimental) Fraction of the season elapsed, 0-1 (includes time of day); 0 without seasons
|
|
32
|
+
- `totalDays: number` (experimental) Total game time in days (fractional), for growth, cooldowns and the like
|
|
34
33
|
|
|
35
34
|
## Data structures
|
|
36
35
|
- **CalendarAtOptions** Parameters of calendar.at() / daily()
|