threedog 0.5.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 +276 -1
- package/README.md +18 -13
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +116 -61
- package/core/{Baked.js → assets/Baked.js} +16 -25
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- package/core/{assetLoad.js → assets/assetLoad.js} +66 -29
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +23 -12
- package/core/{assetReport.js → assets/assetReport.js} +9 -15
- package/core/{namedModel.js → assets/namedModel.js} +24 -16
- package/core/{Audio.js → audio/Audio.js} +27 -24
- 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} +154 -139
- package/core/{errorHints.js → base/errorHints.js} +9 -10
- package/core/{errors.js → base/errors.js} +9 -9
- package/core/{events.generated.js → base/events.generated.js} +2 -0
- package/core/{math.js → base/math.js} +22 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +29 -8
- package/core/{Engine.js → engine/Engine.js} +112 -105
- 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} +16 -16
- package/core/{loop.js → engine/loop.js} +80 -52
- package/core/{moduleSlots.js → engine/moduleSlots.js} +35 -10
- package/core/{moduleTypes.js → engine/moduleTypes.js} +30 -18
- package/core/{modules.js → engine/modules.js} +20 -17
- package/core/engine/page.js +125 -0
- package/core/{plugins.js → engine/plugins.js} +68 -103
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +35 -35
- package/core/{Input.js → input/Input.js} +41 -27
- 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} +23 -22
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +60 -31
- package/core/{Describe.js → inspect/Describe.js} +33 -30
- package/core/{Inspect.js → inspect/Inspect.js} +14 -9
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +8 -10
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +29 -16
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +9 -6
- package/core/inspect/UrlState.js +182 -0
- package/core/{catalog.js → inspect/catalog.js} +18 -5
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +8 -8
- package/core/inspect/describeRender.js +148 -0
- package/core/{describeText.js → inspect/describeText.js} +17 -12
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +11 -9
- package/core/inspect/pictureWriters.js +342 -0
- 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} +37 -37
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -27
- package/core/{stackFrames.js → ops/stackFrames.js} +17 -6
- package/core/{stacks.js → ops/stacks.js} +18 -20
- 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} +27 -24
- package/core/{Views.js → scene/Views.js} +15 -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} +24 -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/scene/pictureSlots.js +33 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +14 -6
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -20
- package/core/scene/stepPoses.js +55 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
- package/core/{thingOps.js → scene/thingOps.js} +4 -3
- package/core/{things.js → scene/things.js} +19 -6
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +1 -1
- package/core/scene/view.js +44 -0
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +62 -33
- package/core/{batchGroups.js → stream/batchGroups.js} +18 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +41 -1
- 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 +70 -63
- package/docs/API.md +30 -29
- package/docs/CODEMAP.md +98 -223
- package/docs/COMMANDS.md +80 -69
- package/docs/CONVENTIONS.md +87 -41
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +100 -49
- package/docs/api/assets.md +17 -16
- package/docs/api/audio.md +8 -7
- package/docs/api/budget.md +8 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +29 -29
- package/docs/api/characters.md +26 -19
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +14 -11
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +82 -53
- package/docs/api/events.md +5 -3
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +9 -2
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +4 -1
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +10 -9
- package/docs/api/interactions.md +6 -4
- package/docs/api/inventory.md +10 -11
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -8
- package/docs/api/lightPool.md +2 -7
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/occlusion.md +5 -0
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +8 -5
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +7 -1
- package/docs/api/post.md +24 -5
- 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 +17 -14
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +17 -12
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +30 -26
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +11 -5
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +11 -6
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +38 -57
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +47 -42
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +72 -66
- package/docs/recipes/06-clock-events.md +30 -21
- package/docs/recipes/07-flow-scenes-pause.md +21 -17
- package/docs/recipes/08-weather-sky.md +117 -75
- package/docs/recipes/09-materials-lights-models.md +171 -0
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +33 -25
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +50 -22
- package/docs/recipes/14-custom-module.md +20 -17
- package/docs/recipes/15-perf.md +52 -29
- package/docs/recipes/16-dev-bridge.md +47 -57
- package/docs/recipes/18-world.md +45 -30
- package/docs/recipes/19-shooting-picking.md +11 -7
- package/docs/recipes/20-content-actions-save.md +36 -37
- package/docs/recipes/21-camera.md +41 -8
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +11 -11
- package/docs/recipes/26-ui-parts.md +56 -22
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +126 -30
- package/docs/recipes/29-grid.md +16 -7
- package/docs/recipes/30-templates.md +62 -21
- package/docs/recipes/31-audio.md +9 -9
- package/docs/recipes/32-action-game.md +32 -9
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +164 -52
- package/docs/recipes/35-picture-from-reference.md +140 -0
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +105 -30
- package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +74 -106
- package/docs/recipes/44-water-weather-hooks.md +196 -0
- package/docs/recipes/45-cascaded-shadows.md +145 -25
- package/docs/recipes/46-blender-art-route.md +21 -25
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +3 -3
- package/docs/recipes/52-around-the-picture.md +137 -0
- package/docs/recipes/53-ground-up-close.md +65 -28
- package/docs/recipes/55-mods-time-wrap.md +25 -17
- package/docs/recipes/56-webgpu-tsl.md +73 -28
- package/docs/recipes/57-control.md +47 -1
- package/docs/recipes/58-input.md +3 -0
- package/docs/recipes/59-depth-post-effects.md +5 -5
- package/docs/recipes/60-judge-the-picture.md +47 -27
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +276 -0
- package/docs/recipes/63-third-person-start.md +90 -0
- package/docs/recipes/64-particles.md +35 -0
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +9 -7
- package/examples/action/main.js +5 -4
- package/examples/action/models.js +12 -14
- package/examples/action/picture/index.js +13 -0
- package/examples/action/picture/lights.js +35 -0
- package/examples/action/picture/materials.js +8 -0
- package/examples/action/picture/palette.js +33 -0
- package/examples/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +18 -14
- package/examples/{sheepisland → perf-island}/assets.js +2 -2
- package/examples/{sheepisland → perf-island}/content/templates.js +1 -1
- package/examples/{sheepisland → perf-island}/content/vegetation.js +3 -1
- package/examples/{sheepisland → perf-island}/main.js +22 -16
- package/examples/{sheepisland/style → perf-island}/models.js +13 -24
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/perf-island/picture/index.js +20 -0
- package/examples/perf-island/picture/lights.js +34 -0
- package/examples/perf-island/picture/materials.js +61 -0
- package/examples/perf-island/picture/palette.js +60 -0
- package/examples/perf-island/picture/sky.js +20 -0
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/GAMEMAP.md +91 -0
- package/examples/plain-picture/main.js +48 -0
- package/examples/plain-picture/picture/index.js +21 -0
- package/examples/plain-picture/picture/lights.js +54 -0
- package/examples/plain-picture/picture/materials.js +24 -0
- package/examples/plain-picture/picture/palette.js +16 -0
- package/examples/plain-picture/picture/sky.js +37 -0
- package/examples/pullable.json +31 -9
- package/examples/rc2d/GAMEMAP.md +10 -4
- package/examples/rc2d/README.md +11 -6
- package/examples/rc2d/main.js +26 -36
- package/examples/rc2d/picture/index.js +18 -0
- package/examples/rc2d/picture/lights.js +11 -0
- package/examples/rc2d/picture/materials.js +18 -0
- package/examples/rc2d/picture/palette.js +15 -0
- package/examples/rc2d/picture/post.js +11 -0
- package/examples/rc2d/rc2d.js +18 -28
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +15 -10
- package/examples/styletest/main.js +20 -30
- package/examples/styletest/models.js +29 -29
- package/examples/styletest/params.js +1 -4
- package/examples/styletest/picture/env.js +38 -0
- package/examples/styletest/picture/index.js +16 -0
- package/examples/styletest/picture/lights.js +9 -0
- package/examples/styletest/picture/materials.js +28 -0
- package/examples/styletest/picture/palette.js +22 -0
- package/examples/techniques/contact-shadows/README.md +22 -23
- package/examples/techniques/contact-shadows/contactShadows.js +32 -16
- package/examples/techniques/contact-shadows/main.js +20 -18
- package/examples/techniques/contact-shadows/picture/index.js +14 -0
- package/examples/techniques/contact-shadows/picture/lights.js +34 -0
- package/examples/techniques/contact-shadows/picture/materials.js +12 -0
- package/examples/techniques/contact-shadows/picture/palette.js +17 -0
- package/examples/techniques/day-night-grade/README.md +13 -16
- package/examples/techniques/day-night-grade/main.js +15 -25
- package/examples/techniques/day-night-grade/picture/index.js +20 -0
- package/examples/techniques/day-night-grade/picture/lights.js +45 -0
- package/examples/techniques/day-night-grade/picture/materials.js +15 -0
- package/examples/techniques/day-night-grade/picture/palette.js +59 -0
- package/examples/techniques/day-night-grade/picture/post.js +25 -0
- package/examples/techniques/day-night-grade/picture/sky.js +33 -0
- package/examples/techniques/interior-light/README.md +16 -13
- package/examples/techniques/interior-light/interiorLight.js +19 -17
- package/examples/techniques/interior-light/main.js +31 -68
- package/examples/techniques/interior-light/picture/index.js +24 -0
- package/examples/techniques/interior-light/picture/lights.js +52 -0
- package/examples/techniques/interior-light/picture/materials.js +13 -0
- package/examples/techniques/interior-light/picture/palette.js +32 -0
- package/examples/techniques/interior-light/picture/sky.js +40 -0
- package/examples/techniques/modular-building/README.md +8 -6
- package/examples/techniques/modular-building/kit.js +2 -2
- package/examples/techniques/modular-building/main.js +9 -17
- package/examples/techniques/modular-building/picture/index.js +17 -0
- package/examples/techniques/modular-building/picture/lights.js +26 -0
- package/examples/techniques/modular-building/picture/materials.js +13 -0
- package/examples/techniques/modular-building/picture/palette.js +23 -0
- package/examples/techniques/night-lights/README.md +15 -14
- package/examples/techniques/night-lights/main.js +20 -43
- package/examples/techniques/night-lights/nightLights.js +25 -21
- package/examples/techniques/night-lights/picture/index.js +18 -0
- package/examples/techniques/night-lights/picture/lights.js +44 -0
- package/examples/techniques/night-lights/picture/materials.js +15 -0
- package/examples/techniques/night-lights/picture/palette.js +34 -0
- package/examples/techniques/night-lights/picture/post.js +9 -0
- package/examples/techniques/night-lights/picture/sky.js +36 -0
- package/examples/techniques/outlines-and-rim/README.md +2 -2
- package/examples/techniques/outlines-and-rim/main.js +15 -38
- package/examples/techniques/outlines-and-rim/outlines.js +3 -3
- package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
- package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
- package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
- package/examples/techniques/procedural-animation/README.md +6 -4
- package/examples/techniques/procedural-animation/main.js +9 -7
- package/examples/techniques/procedural-animation/picture/index.js +15 -0
- package/examples/techniques/procedural-animation/picture/lights.js +35 -0
- package/examples/techniques/procedural-animation/picture/materials.js +10 -0
- package/examples/techniques/procedural-animation/picture/palette.js +16 -0
- package/examples/techniques/procedural-animation/picture/sky.js +31 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
- package/examples/techniques/procedural-surface/README.md +2 -0
- package/examples/techniques/procedural-surface/main.js +17 -55
- package/examples/techniques/procedural-surface/picture/index.js +14 -0
- package/examples/techniques/procedural-surface/picture/lights.js +18 -0
- package/examples/techniques/procedural-surface/picture/materials.js +34 -0
- package/examples/techniques/procedural-surface/picture/palette.js +15 -0
- package/examples/techniques/stylized-shading/README.md +13 -14
- package/examples/techniques/stylized-shading/main.js +11 -42
- package/examples/techniques/stylized-shading/picture/index.js +14 -0
- package/examples/techniques/stylized-shading/picture/lights.js +23 -0
- package/examples/techniques/stylized-shading/picture/materials.js +18 -0
- package/examples/techniques/stylized-shading/picture/palette.js +19 -0
- package/examples/techniques/stylized-shading/shading.js +2 -2
- package/examples/techniques/sun-and-key-light/README.md +20 -22
- package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
- package/examples/techniques/sun-and-key-light/main.js +19 -63
- package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
- package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
- package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
- package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
- package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
- package/examples/techniques/three-looks/README.md +21 -0
- package/examples/techniques/three-looks/main.js +58 -0
- package/examples/techniques/three-looks/picture/cartoon.js +23 -0
- package/examples/techniques/three-looks/picture/cinematic.js +27 -0
- package/examples/techniques/three-looks/picture/comic.js +27 -0
- package/examples/techniques/three-looks/picture/index.js +14 -0
- package/examples/techniques/three-looks/picture/sun.js +23 -0
- package/examples/techniques/wet-road/README.md +7 -4
- package/examples/techniques/wet-road/main.js +18 -38
- package/examples/techniques/wet-road/picture/index.js +17 -0
- package/examples/techniques/wet-road/picture/lights.js +57 -0
- package/examples/techniques/wet-road/picture/materials.js +16 -0
- package/examples/techniques/wet-road/picture/palette.js +24 -0
- package/examples/techniques/wet-road/picture/sky.js +46 -0
- package/examples/webgpu-tsl/GAMEMAP.md +10 -4
- package/examples/webgpu-tsl/README.md +13 -10
- package/examples/webgpu-tsl/main.js +30 -7
- package/examples/webgpu-tsl/picture/index.js +18 -0
- package/examples/webgpu-tsl/picture/lights.js +25 -0
- package/examples/webgpu-tsl/picture/materials.js +36 -0
- package/examples/webgpu-tsl/picture/palette.js +23 -0
- package/examples/webgpu-tsl/picture/post.js +16 -0
- package/examples/webgpu-tsl/picture/sky.js +30 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +16 -12
- package/examples/world/art/humanoid.js +9 -13
- package/examples/world/art/index.js +2 -2
- package/examples/world/art/models.js +3 -4
- package/examples/world/art/shapes.js +2 -2
- package/examples/world/assets.js +2 -2
- package/examples/world/content/audio.js +1 -1
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +10 -10
- package/examples/world/models.js +17 -7
- package/examples/world/picture/index.js +20 -0
- package/examples/world/picture/lights.js +41 -0
- package/examples/world/picture/materials.js +34 -0
- package/examples/world/picture/palette.js +74 -0
- package/examples/world/picture/post.js +9 -0
- package/examples/world/picture/sky.js +39 -0
- package/index.d.ts +14 -22
- package/index.js +36 -36
- package/llms.txt +19 -21
- package/modules/ambience/Ambience.js +12 -9
- package/modules/calendar/Calendar.js +20 -20
- package/modules/calendar/index.js +14 -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 +51 -25
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +47 -39
- package/modules/characters/NPC.js +30 -22
- package/modules/characters/assetModel.js +18 -13
- 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 +172 -193
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +22 -15
- package/modules/characters/movers/manual.js +4 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +32 -18
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +28 -18
- 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 +19 -5
- package/modules/characters/useModel.js +5 -5
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +30 -22
- 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 +68 -98
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +66 -18
- 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 +19 -14
- package/modules/content/rules.js +34 -22
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +24 -22
- 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 +115 -27
- package/modules/gameplay/Inventory.js +11 -12
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBox.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +4 -5
- package/modules/gameplay/interactionPrompt.js +1 -1
- package/modules/gameplay/interactions.contract.js +1 -1
- package/modules/gameplay/inventoryOps.js +2 -3
- package/modules/gameplay/pickups.js +81 -44
- package/modules/gameplay/questLog.js +2 -2
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +16 -3
- package/modules/grid/index.js +47 -19
- package/modules/grid/preview.js +29 -20
- package/modules/grid/tiles.js +19 -23
- package/modules/hlod/index.js +38 -55
- package/modules/hud/index.js +27 -8
- package/modules/hud/parts.js +13 -11
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +48 -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 +34 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +31 -27
- 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 +49 -25
- package/modules/particles/effect.js +27 -10
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +26 -27
- 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 +114 -45
- package/modules/settings/apply.js +10 -10
- package/modules/settings/sections.js +16 -14
- package/modules/settings/strings.js +1 -1
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +125 -103
- package/modules/sky/clouds.js +22 -23
- package/modules/sky/dome.js +113 -0
- package/modules/sky/domeLayers.js +13 -13
- package/modules/sky/environment.js +47 -171
- package/modules/sky/fog.js +5 -180
- package/modules/sky/frame.js +42 -97
- package/modules/sky/season.js +9 -3
- package/modules/sky/shader.js +49 -44
- package/modules/sky/skyModule.js +25 -35
- package/modules/sky/tint.js +9 -11
- 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 +97 -62
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +157 -0
- package/modules/terrain/index.js +60 -88
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +4 -3
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +19 -14
- 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 +19 -15
- package/modules/vegetation/Vegetation.js +87 -39
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +196 -0
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +18 -16
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +140 -93
- package/modules/water/surface.js +56 -56
- package/modules/weather/Weather.js +84 -38
- package/modules/weather/particles.js +18 -10
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/weatherDraw.js +145 -0
- package/modules/world/World.js +10 -10
- 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 +12 -10
- package/package.json +44 -8
- package/presets.js +3 -5
- package/render/PostFX.js +233 -63
- package/render/backend.js +72 -32
- package/render/cascades.js +200 -0
- package/render/cascades.tsl.js +93 -0
- package/render/daylight.js +56 -0
- package/render/detail.js +13 -12
- package/render/effects.js +60 -42
- package/render/fuse.js +3 -3
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +10 -13
- 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 +6 -16
- package/render/fx/postWebGPU.tsl.js +55 -28
- package/render/fx/sky.tsl.js +34 -109
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/water.tsl.js +1 -1
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +14 -0
- package/render/lighting.js +11 -8
- package/render/lightmap.js +142 -0
- package/render/lights.js +26 -204
- package/render/lit.js +24 -0
- package/render/materials.js +47 -162
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/neutral.js +23 -0
- package/render/occlusion.js +200 -0
- package/render/ownFrame.js +5 -5
- package/render/patches.js +46 -41
- package/render/postWebGL.js +19 -9
- package/render/probes.js +182 -128
- 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/render/shadows.js +451 -0
- package/render/slots.js +11 -11
- package/render/terms.js +63 -113
- package/render/uniformDecl.js +2 -2
- package/types/core.d.ts +489 -405
- package/types/gameplay.d.ts +225 -114
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +23 -8
- 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/engine/page.d.ts +24 -0
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +21 -10
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +16 -8
- 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 +9 -1
- package/types/generated/modules/grid/index.d.ts +32 -8
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +14 -7
- package/types/generated/modules/sky/Sky.d.ts +101 -23
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- 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 +51 -3
- package/types/generated/modules/weather/Weather.d.ts +44 -10
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +7 -5
- package/types/generated/render/PostFX.d.ts +69 -20
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +20 -44
- package/types/generated/render/occlusion.d.ts +22 -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 +104 -73
- package/types/tsl.d.ts +45 -4
- package/types/world.d.ts +372 -86
- package/ui/Focus.js +21 -10
- package/ui/LoadingScreen.js +2 -2
- package/ui/Parts.js +12 -7
- package/ui/UI.js +17 -17
- package/ui/cursor.js +1 -1
- package/ui/defaults.js +3 -2
- package/ui/theme.js +36 -28
- package/ui/touchPart.js +1 -1
- package/core/UrlState.js +0 -110
- package/core/assetEntry.js +0 -106
- package/core/describeRender.js +0 -71
- package/core/holds.js +0 -134
- package/core/look/coreParts.js +0 -219
- package/core/look/part.js +0 -253
- package/core/look/points.js +0 -255
- package/core/look/report.js +0 -96
- package/core/look/shadowPart.js +0 -63
- package/core/look/state.js +0 -45
- package/core/look/write.js +0 -70
- package/core/page.js +0 -79
- package/core/shadowTypes.js +0 -16
- package/core/styleParts.js +0 -114
- package/core/util.js +0 -17
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -228
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/PERF.md +0 -245
- package/docs/api/style.md +0 -136
- package/docs/api/terrainLook.md +0 -10
- package/docs/api/vegetationLook.md +0 -10
- package/docs/api/weatherLook.md +0 -10
- package/docs/recipes/09-style.md +0 -218
- package/docs/recipes/35-style-from-reference.md +0 -153
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/37-terrain-look-hooks.md +0 -119
- package/docs/recipes/38-environment-look-hooks.md +0 -99
- package/docs/recipes/41-thing-registry.md +0 -97
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/44-water-weather-look-hooks.md +0 -144
- package/docs/recipes/47-island-snow-backdrop.md +0 -45
- package/docs/recipes/48-make-material.md +0 -75
- package/docs/recipes/52-look.md +0 -282
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/.threedog/content-index.json +0 -1
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
- package/examples/webgpu-tsl/tslScene.js +0 -75
- package/examples/world/style/index.js +0 -61
- package/examples/world/style/plugins/10-bloom.js +0 -5
- package/modules/sky/cascades.js +0 -186
- package/modules/sky/cascades.tsl.js +0 -82
- package/modules/sky/look.js +0 -54
- package/modules/sky/lookFog.js +0 -76
- package/modules/sky/lookShadow.js +0 -62
- package/modules/sky/lookSky.js +0 -169
- package/modules/sky/shadow.js +0 -98
- package/modules/terrain/look.js +0 -83
- package/modules/terrain/lookGround.js +0 -66
- package/modules/vegetation/look.js +0 -119
- package/modules/vegetation/lookWind.js +0 -98
- package/modules/water/look.js +0 -91
- package/modules/water/surfaceDefaults.js +0 -3
- package/modules/weather/look.js +0 -74
- package/modules/weather/weatherLook.js +0 -135
- package/render/lookGlow.js +0 -139
- package/render/lookSurface.js +0 -224
- package/render/postLook.js +0 -164
- package/render/surface.js +0 -105
- package/types/generated/core/page.d.ts +0 -18
- package/types/generated/modules/weather/weatherLook.d.ts +0 -12
- package/types/style.d.ts +0 -671
- /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/{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
|
@@ -9,10 +9,11 @@ const STRINGS = {
|
|
|
9
9
|
head: '[Game state] running {s} s{flags}',
|
|
10
10
|
actions: 'Can do (engine.ops): {list}',
|
|
11
11
|
error: '[Error, gameplay frozen] {where}: {message}', errorAt: ' ({at})',
|
|
12
|
-
errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled
|
|
13
|
-
|
|
12
|
+
errorHint: ' | Code: {code} | Fix: {fix} Read: {docs}', disabled: 'Disabled picture / ui modules (they threw): {list}',
|
|
13
|
+
halted: ', halted', headless: ', headless', notReady: ', still loading',
|
|
14
14
|
waiting: 'Loading: {waiting} ({pending} pending, {done}/{total} done)', loadFailed: 'Load failed{blocked}: {list}', blocked: ' (start blocked)',
|
|
15
15
|
loadWarn: 'Loaded with missing references: {list}',
|
|
16
|
+
audio: 'Audio: {list}',
|
|
16
17
|
time: 'Time: {clock}, day {day}{season}, {dayNight}',
|
|
17
18
|
day: 'daytime', night: 'night',
|
|
18
19
|
weather: 'Weather: {name}{changing} (rain {rain}, snow {snow}, fog {fog}){shown}',
|
|
@@ -44,25 +45,25 @@ const STRINGS = {
|
|
|
44
45
|
noPath: 'describe() has no "{path}"; top-level keys: {keys}',
|
|
45
46
|
none: 'none',
|
|
46
47
|
state: { idle: 'standing', walk: 'walking', run: 'running', jump: 'jumping', fall: 'falling', swim: 'swimming' },
|
|
47
|
-
kind: { npc: 'NPC', pickup: 'pickup', interactable: 'interactable', trigger: 'trigger' },
|
|
48
|
+
kind: { npc: 'NPC', pickup: 'pickup', interactable: 'interactable', noKey: 'no key bound, the player cannot use it', trigger: 'trigger' },
|
|
48
49
|
dir: { N: 'north', NE: 'northeast', E: 'east', SE: 'southeast', S: 'south', SW: 'southwest', W: 'west', NW: 'northwest' },
|
|
49
50
|
rel: { front: 'ahead', 'front-right': 'ahead right', right: 'right', 'back-right': 'behind right', back: 'behind', 'back-left': 'behind left', left: 'left',
|
|
50
51
|
'front-left': 'ahead left' },
|
|
51
52
|
season: { spring: 'spring', summer: 'summer', autumn: 'autumn', winter: 'winter' },
|
|
52
53
|
camType: { follow: 'follow camera', first: 'first person', fixed: 'fixed camera', rts: 'top-down strategy camera' },
|
|
53
54
|
};
|
|
54
|
-
import { fmt } from '
|
|
55
|
-
import { r1 } from '
|
|
56
|
-
import { getPath } from '
|
|
55
|
+
import { fmt } from '../base/validate.js';
|
|
56
|
+
import { r1 } from '../base/math.js';
|
|
57
|
+
import { getPath } from '../base/util.js';
|
|
57
58
|
|
|
58
59
|
const NEAR_SUMMARY = 5, LINE = 110;
|
|
59
60
|
const tr = (table, k) => (k != null && STRINGS[table][k]) || (k ?? STRINGS.none);
|
|
60
61
|
const n1 = v => (typeof v === 'number' ? r1(v) : v);
|
|
61
62
|
// Standard fields get sentences above; data from other modules is squeezed into one JSON line
|
|
62
|
-
const SHOWN = new Set(['nearbyRadius', 'ready', 'error', 'disabledModules', 'loading', 'time', 'player', 'camera', 'nearby', 'actions', 'ui', 'cutscene',
|
|
63
|
+
const SHOWN = new Set(['nearbyRadius', 'ready', 'error', 'disabledModules', 'loading', 'audio', 'time', 'player', 'camera', 'nearby', 'actions', 'ui', 'cutscene',
|
|
63
64
|
'modules', 'perf', 'weather', 'render', 'threePatches']); // threePatches: page-wide, the same every call; describe() JSON carries it, the text stays short
|
|
64
65
|
// engine bookkeeping in describe(): one count each in the summary, the content one describeText({ path }) away
|
|
65
|
-
const TABLES = new Set(['holds', 'input', 'control', 'shared', 'wraps', 'slots', 'scene', 'owned', '
|
|
66
|
+
const TABLES = new Set(['holds', 'input', 'control', 'shared', 'wraps', 'slots', 'scene', 'owned', 'picture', 'renderer']);
|
|
66
67
|
const argText = a => Object.entries(a || {}).map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(',') : v}`).join(' ');
|
|
67
68
|
|
|
68
69
|
/** One module's data in a line: scalars as k=v, arrays as k[n], objects as k{n keys} (nested data is one describeText({ path }) away) */
|
|
@@ -90,7 +91,7 @@ function atPath(d, path) {
|
|
|
90
91
|
export function describeText(d, { full = false, path, maxLines = 30, game = [] } = {}) {
|
|
91
92
|
if (path) return atPath(d, path);
|
|
92
93
|
const L = [], t = d.time;
|
|
93
|
-
const flags = (t.
|
|
94
|
+
const flags = (t.halted ? STRINGS.halted : '') + (t.headless ? STRINGS.headless : '') + (d.loading.done ? '' : STRINGS.notReady);
|
|
94
95
|
if (d.error) L.push(fmt(STRINGS.error, d.error) + (d.error.at ? fmt(STRINGS.errorAt, d.error) : '')
|
|
95
96
|
+ (d.error.fix ? fmt(STRINGS.errorHint, { code: d.error.code, fix: d.error.fix, docs: d.error.docs.join(', ') }) : ''));
|
|
96
97
|
L.push(fmt(STRINGS.head, { s: t.real, flags }));
|
|
@@ -100,10 +101,14 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
|
|
|
100
101
|
{ blocked: ld.blocked ? STRINGS.blocked : '',
|
|
101
102
|
list: ld.failed.map(f => `${f.kind} "${f.name}" ${f.error.url ?? ''} ${f.error.message}${f.fallback ? ` -> ${f.fallback}` : ''}`).join('; ') }));
|
|
102
103
|
if (ld.warnings.length) L.push(fmt(STRINGS.loadWarn, { list: ld.warnings.map(w => `"${w.name}" missing ${w.missing.join(', ')}`).join('; ') }));
|
|
104
|
+
if (d.audio) { // only present while a bus is ducked or a voice plays; ducks are the target level, so a fade in progress already shows its end
|
|
105
|
+
const low = Object.entries(d.audio.ducks).filter(([, v]) => v !== 1).map(([b, v]) => `${b} ducked to ${v}`), v = Object.entries(d.audio.voices).map(([k, n]) => `${k} x${n}`);
|
|
106
|
+
L.push(fmt(STRINGS.audio, { list: [...low, v.length ? 'playing ' + v.join(', ') : null].filter(Boolean).join('; ') }));
|
|
107
|
+
}
|
|
103
108
|
if (d.disabledModules?.length) L.push(fmt(STRINGS.disabled, { list: d.disabledModules.join(', ') }));
|
|
104
109
|
if (t.clock) L.push(fmt(STRINGS.time, { clock: t.clock, day: t.day, season: t.season ? ', ' + tr('season', t.season) : '', dayNight: t.isDay ? STRINGS.day
|
|
105
110
|
: STRINGS.night }));
|
|
106
|
-
const w = d.weather, wl = d.
|
|
111
|
+
const w = d.weather, wl = d.weatherDraw ?? {}; // weather state, and what of it is drawn (the drawing half)
|
|
107
112
|
if (w) L.push(fmt(STRINGS.weather, { name: w.name, rain: n1(w.rain), snow: n1(w.snow), fog: n1(w.fog),
|
|
108
113
|
changing: w.progress < 1 ? fmt(STRINGS.changing, { pct: Math.round(w.progress * 100) }) : '',
|
|
109
114
|
shown: wl.rainVisible || wl.snowVisible ? fmt(STRINGS.weatherShown,
|
|
@@ -143,7 +148,7 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
|
|
|
143
148
|
return L.join('\n');
|
|
144
149
|
}
|
|
145
150
|
// Summary order: the game's own describe.add sections first (what its author asked to see), then module lines, then the engine's bookkeeping
|
|
146
|
-
// tables folded into one count line. Why: those tables (shared values, slots, owned properties
|
|
151
|
+
// tables folded into one count line. Why: those tables (shared values, slots, owned properties...) took ~10 of the 30 lines and pushed
|
|
147
152
|
// the game's own sections past the cut. A table with something wrong in it (scene conflicts / orphans / unsaved) keeps its own line.
|
|
148
153
|
const rest = Object.keys(d).filter(k => !SHOWN.has(k)), tables = [], mods = [];
|
|
149
154
|
for (const k of rest.filter(k => game.includes(k))) L.push(fmt(STRINGS.extra, { name: k, json: summary(d[k]) }));
|
|
@@ -151,7 +156,7 @@ export function describeText(d, { full = false, path, maxLines = 30, game = [] }
|
|
|
151
156
|
for (const k of rest.filter(k => TABLES.has(k))) {
|
|
152
157
|
const v = d[k];
|
|
153
158
|
if (k === 'scene' && v && ['conflicts', 'orphans', 'unsaved'].some(x => v[x]?.length)) L.push(fmt(STRINGS.extra, { name: k, json: summary(v) }));
|
|
154
|
-
else if (v != null) tables.push(k === 'renderer' ? `renderer ${v.backend ?? v.requested}` : `${k} ${typeof v === 'object' ? Object.keys(v).length : v}`);
|
|
159
|
+
else if (v != null) tables.push(k === 'renderer' ? `renderer ${v.backend ?? v.requested}${v.reason ? ` (asked ${v.requested}: ${v.reason})` : ''}` : `${k} ${typeof v === 'object' ? Object.keys(v).length : v}`);
|
|
155
160
|
}
|
|
156
161
|
// the cut falls on the module lines only: the standard lines, the game's sections and the tables line always stay; the cut ones are named
|
|
157
162
|
const tail = tables.length ? [fmt(STRINGS.tables, { list: tables.join(', ') })] : [], room = Math.max(0, maxLines - 1 - L.length - tail.length);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Dev-only check (called from loop.js after each render once the engine is ready): warn when geometries keep piling up on the renderer that nothing in the scene uses.
|
|
2
|
+
// Why: scene.remove(mesh) without geometry.dispose() leaves the geometry counted by the renderer (and, on WebGLRenderer, its GPU buffers allocated) for good. The WebGPU record
|
|
3
|
+
// sweep (render/recordSweep.js) cannot close this: a geometry off the scene may be parked for reuse, and only the game knows it will not come back.
|
|
4
|
+
// What it compares: renderer.info.memory.geometries minus the distinct geometries reachable in engine.scene. Why not the mesh count: the renderer counts a geometry at its first
|
|
5
|
+
// draw, so a big static world counts up as the camera moves while its meshes stay flat, which is not a leak. Clamped at 0 for the same reason (meshes not drawn yet).
|
|
6
|
+
// False alarms are worse than none, so it speaks only after a sustained rise with no fall: a streaming game that disposes what it unloads stays flat, a load burst is one step.
|
|
7
|
+
// Silent on purpose: leaks slower than MIN_RISE per window. Not told apart: a game that keeps adding to a geometry cache off the scene, or streams through its own second Scene
|
|
8
|
+
// without engine.scene, looks like this too once it passes those limits.
|
|
9
|
+
// Cost: one scene walk every EVERY seconds, in dev only.
|
|
10
|
+
import { warnOnce } from '../base/validate.js';
|
|
11
|
+
import { coded } from '../base/errorHints.js';
|
|
12
|
+
import { memory } from '../../render/backend.js';
|
|
13
|
+
|
|
14
|
+
const EVERY = 10; // seconds between samples
|
|
15
|
+
const WINDOW = 12; // steps looked at together: two minutes
|
|
16
|
+
const RISES = 9; // of those steps, at least this many went up: a steady climb, not a few loads
|
|
17
|
+
const MIN_RISE = 100; // geometries gained over the window
|
|
18
|
+
|
|
19
|
+
/** @param {any} e the engine (dev and ready only: the caller checks) @param {number} dt seconds since the last call */
|
|
20
|
+
export function watchGeometries(e, dt) {
|
|
21
|
+
const w = e._geometryWatch ??= { wait: 0, unused: /** @type {number[]} */ ([]) };
|
|
22
|
+
if ((w.wait += dt) < EVERY) return;
|
|
23
|
+
w.wait = 0;
|
|
24
|
+
const used = new Set();
|
|
25
|
+
e.scene.traverse(/** @param {any} o */ o => { if (o.geometry) used.add(o.geometry); });
|
|
26
|
+
const n = Math.max(0, memory(e.renderer).geometries - used.size), h = w.unused;
|
|
27
|
+
if (h.length && n < h[h.length - 1]) h.length = 0; // the game is disposing: what came before is not this pattern
|
|
28
|
+
h.push(n);
|
|
29
|
+
if (h.length > WINDOW + 1) h.shift();
|
|
30
|
+
if (h.length <= WINDOW) return;
|
|
31
|
+
let rises = 0;
|
|
32
|
+
for (let i = 1; i < h.length; i++) if (h[i] > h[i - 1]) rises++;
|
|
33
|
+
const gained = h[h.length - 1] - h[0];
|
|
34
|
+
if (rises >= RISES && gained >= MIN_RISE) {
|
|
35
|
+
warnOnce(coded('geometry-undisposed', `${gained} geometries that nothing in the scene uses joined the renderer in the last ${WINDOW * EVERY} s (${n} in all). ` +
|
|
36
|
+
'When a mesh is gone for good, call mesh.geometry.dispose() after removing it (engine.remove does it for you)'), 'geometry-undisposed');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// removed or hidden mid-play compiles again and freezes that frame (a dungeon game froze ~450 ms when a torch turned its light on).
|
|
4
4
|
// engine.start() already compiled everything for the startup lights; this names the cause when a game changes them afterwards.
|
|
5
5
|
// Cost: one array-length compare per frame; the scene walk that counts lights runs only in a frame whose program count went up (rare).
|
|
6
|
-
import { warnOnce } from '
|
|
7
|
-
import { coded } from '
|
|
8
|
-
import { programCount } from '
|
|
6
|
+
import { warnOnce, fmt } from '../base/validate.js';
|
|
7
|
+
import { coded } from '../base/errorHints.js';
|
|
8
|
+
import { programCount } from '../../render/backend.js';
|
|
9
9
|
|
|
10
|
-
const MANY = 8; // above this many real-time lights every material's fragment shader loops over all of them: mobile GPUs slow down first
|
|
10
|
+
export const MANY = 8; // above this many real-time lights every material's fragment shader loops over all of them: mobile GPUs slow down first
|
|
11
11
|
|
|
12
12
|
const STRINGS = {
|
|
13
13
|
many: '{n} real-time lights are in the scene (more than {max}, not counting lightPool lights). Every lit material pays for every light in every pixel. ' +
|
|
@@ -15,7 +15,7 @@ const STRINGS = {
|
|
|
15
15
|
changed: 'Shader programs were compiled during play ({from} -> {to}) and, compared with the last observation, the light layout also changed ({was} -> {now}). ' +
|
|
16
16
|
'three.js compiles every material again for a new light setup, so adding, removing or hiding a light mid-game freezes a frame. ' +
|
|
17
17
|
'Use engine.use(lightPool({ point: 8 })) and engine.lightPool.add(torch, {...}) for many lights, or fade a fixed set with intensity ' +
|
|
18
|
-
'(recipes/09-
|
|
18
|
+
'(recipes/09-materials-lights-models.md "Lights and stalls")',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/** Visible lights by the kinds three.js counts in its light setup (ambient and probes do not change programs), as one comparable string */
|
|
@@ -33,7 +33,7 @@ export function lightSetup(scene) {
|
|
|
33
33
|
* each with userData.fixedCount = true; core reads the mark, not a module's naming scheme, so any pool, built-in or the game's, counts the same */
|
|
34
34
|
function countLoose(scene) {
|
|
35
35
|
let c = 0;
|
|
36
|
-
scene.traverseVisible(o => { if (o.isLight && !o.isAmbientLight && !o.isLightProbe && !o.userData.fixedCount) c++; });
|
|
36
|
+
scene.traverseVisible(o => { if (o.isLight && !o.isAmbientLight && !o.isLightProbe && !o.isLightProbeGrid && !o.userData.fixedCount) c++; });
|
|
37
37
|
return c;
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -42,17 +42,19 @@ export function watchLights(e) {
|
|
|
42
42
|
const n = programCount(e.renderer);
|
|
43
43
|
if (n == null) return;
|
|
44
44
|
const first = !e._lightWatch;
|
|
45
|
-
|
|
45
|
+
// changes and setup: the picture check reads them (packages/tools/picture/hints-scene.mjs 'light-layout')
|
|
46
|
+
const w = /** @internal the picture check reads it */ e._lightWatch ??= { n, lights: lightSetup(e.scene), changes: [], setup: () => lightSetup(e.scene) };
|
|
46
47
|
// the scene walk runs on the first observation and when programs grow (a light was added), never on a quiet frame
|
|
47
48
|
if (!w.manyDone && (first || n > w.n)) {
|
|
48
49
|
const c = countLoose(e.scene);
|
|
49
|
-
if (c > MANY) { w.manyDone = true; warnOnce(coded('many-lights', STRINGS.many
|
|
50
|
+
if (c > MANY) { w.manyDone = true; warnOnce(coded('many-lights', fmt(STRINGS.many, { n: String(c), max: String(MANY) }))); }
|
|
50
51
|
}
|
|
51
52
|
if (n <= w.n) { w.n = n; return; } // fewer programs (materials disposed) or none new: nothing to say
|
|
52
53
|
const lights = lightSetup(e.scene);
|
|
53
54
|
if (lights !== w.lights) {
|
|
55
|
+
w.changes.push({ from: w.lights, to: lights, programs: n - w.n });
|
|
54
56
|
// the layout is only reread when programs grow, so we say "since the last observation", never "in this frame"
|
|
55
|
-
warnOnce(coded('light-recompile', STRINGS.changed
|
|
57
|
+
warnOnce(coded('light-recompile', fmt(STRINGS.changed, { from: String(w.n), to: String(n), was: w.lights, now: lights })));
|
|
56
58
|
}
|
|
57
59
|
w.n = n; w.lights = lights;
|
|
58
60
|
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// "Who wrote this picture value": the last file:line that changed a light, the fog, tone, environment, background or a material color, and one warning
|
|
2
|
+
// when two places fight over a value inside one frame. Dev server only (npm run dev, threedog snap): see ON below. It observes; every write goes through.
|
|
3
|
+
//
|
|
4
|
+
// Why accessors and a stack, not per-hook attribution: picture/index.js calls all its parts from one engine.onRender, so "which hook was running" names the
|
|
5
|
+
// wiring file for every value. Only the call stack of the write tells parts apart. Why own accessors on r / g / b and x / y / z: Color and Vector3 are
|
|
6
|
+
// changed in place (fog.color.lerp(...), light.position.copy(...)), so watching light.color alone would see nothing.
|
|
7
|
+
//
|
|
8
|
+
// Why not a stack on every write: a stack costs 10-40 us here, and a picture that moves 100 values would pay milliseconds each frame. So a write that
|
|
9
|
+
// changes nothing is ignored, and a value written every frame is looked at every EVERY frames (staggered). What still gets a stack at once: the first
|
|
10
|
+
// frames, a value that was not written last frame (a one-shot write), and a frame with more writes to a value than its last looked-at frame had (a
|
|
11
|
+
// new writer). So `framesAgo` says how old the answer is, and `writtenSince` says the value moved after that, unseen. An answer is never presented as
|
|
12
|
+
// fresher than it is.
|
|
13
|
+
//
|
|
14
|
+
// Why two places in one function are not a fight: fog.color.copy(a) then fog.color.lerp(b, t) is a value computed in steps. A place is a file plus a
|
|
15
|
+
// function name, plus the part running it. shortcut: outside parts, two anonymous functions or two same-named methods in one file count as one place, so a fight between them goes unwarned;
|
|
16
|
+
// upgrade by comparing function start lines if an agent reports one.
|
|
17
|
+
//
|
|
18
|
+
// Parts (modules, core/scene/pictureSlots.js): a value in a slot a part holds has a declared owner, so a write from anyone else is reported at once, naming the holder and
|
|
19
|
+
// both lines, not only when the two land in one frame (a held value written by a stray in another state would never be a fight). Who wrote it: the module running
|
|
20
|
+
// now (install, its hooks: core/engine/moduleTypes.js ownHook), else any frame in a file that part's code ran from (an event listener, a timer). A file two parts share
|
|
21
|
+
// cannot say which of them it was, so it counts as the holder: a warning that accuses the owner would teach agents to ignore this one.
|
|
22
|
+
// What cannot be seen: a write made before the holder took the slot, and a part added under another object rather than the scene root (see added).
|
|
23
|
+
//
|
|
24
|
+
// Leftovers: three.js objects have no owner, so ctx.track only removes what it was handed. Each root a picture part adds and each post effect is remembered until it
|
|
25
|
+
// leaves; what is still there after the part is gone, and a hook that outlived it, is reported by name. It observes, like the rest: nothing is cleaned up for the part.
|
|
26
|
+
import { warnOnce, fmt } from '../base/validate.js';
|
|
27
|
+
import { coded } from '../base/errorHints.js';
|
|
28
|
+
import { notePatch } from '../scene/threePatches.js';
|
|
29
|
+
import { sceneVisitor, onSceneRoot } from '../scene/sceneDelta.js';
|
|
30
|
+
import { stackFrames, frameText, callerAt, engineFile } from '../ops/stackFrames.js';
|
|
31
|
+
import { slotOfValue, slotHolder } from '../scene/pictureSlots.js';
|
|
32
|
+
|
|
33
|
+
const EVERY = 30; // frames between two looks at a value written every frame: a stale answer is at most half a second old
|
|
34
|
+
const DEPTH = 10; // three's own frames above the writer: setter, Color.copy, lerpColors ... always fewer
|
|
35
|
+
const NOT = {
|
|
36
|
+
before: 'not tracked: set before it entered the scene',
|
|
37
|
+
start: 'not tracked: three.js default or set before the engine was made',
|
|
38
|
+
own: 'not tracked: this object defines the property with its own accessor',
|
|
39
|
+
none: 'not tracked: never written since tracking began',
|
|
40
|
+
noFile: 'not tracked: the last write had no source file (console, eval or the picture check)',
|
|
41
|
+
};
|
|
42
|
+
// three.js and pre-bundled libraries are never "the writer": the line that called them is
|
|
43
|
+
const SKIP = /\/deps\/|\/node_modules\/|\/three(?:\.[a-z]+)*\.js$/;
|
|
44
|
+
const SELF = /core\/inspect\/pictureWriters\.js$/;
|
|
45
|
+
const CORE = /\/(?:core|render)\/(?:[^/]+\/)?[^/]+$/; // with engineFile: core and render (and their folders: core/ops/x.js) write for the engine; modules/ count as parts, they hold slots like any other
|
|
46
|
+
const MATERIALS_MAX = 40; // describe() stays small on a big scene; explain still answers any one of them
|
|
47
|
+
const SHARED_FIX = "make it a shared value: the owner defines it with engine.stacks.define(name, { base: 1 }) and reads it where it writes three.js, the others change it with ctx.mod(name, { mul: 0.5 }); for an amount that moves, take it once, const h = ctx.mod(name, { mul: 1 }), and call h.change(x) each frame (recipes/62-picture-code.md)";
|
|
48
|
+
const STRINGS = {
|
|
49
|
+
conflict: '{value} was written twice in one frame with different results: {first}, then {second}. The later write is what is drawn. Fix, one of: (1) one place keeps the write, delete the other{claim}; (2) if both need a say, ' + SHARED_FIX,
|
|
50
|
+
claim: ", and that part declares it with provides: ['{slot}']",
|
|
51
|
+
held: "{value} is held by part '{holder}' (provides: ['{slot}'], {place}), but {at} ({who}) wrote it too. The later write is what is drawn, so one of them never shows. Fix, one of: (1) delete the write at {at}; " +
|
|
52
|
+
"(2) if that code should own it, give it provides: ['{slot}'] and install it with engine.use(thatPart(), { replaces: '{slot}' }), which unloads '{holder}'; (3) if both need a say, " + SHARED_FIX,
|
|
53
|
+
leftover: "part '{name}' is gone, but what it added is still there: {list}. Fix: in its install, hand each one to ctx.track, e.g. ctx.track({ remove() { e.scene.remove(obj); obj.geometry.dispose(); } }), or undo it in the part's dispose()",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const page = { off: false, nextId: 0 }; // off: threePatches.off('picture-writers'), page-wide like the list
|
|
57
|
+
|
|
58
|
+
/** The writer of the running write: { at: 'picture/sky.js:12', key } or null when no frame names a source file */
|
|
59
|
+
function writerNow() {
|
|
60
|
+
const E = /** @type {ErrorConstructor & { stackTraceLimit?: number }} */ (Error); // stackTraceLimit is V8's (Chrome), not in the DOM typings
|
|
61
|
+
const lim = E.stackTraceLimit; E.stackTraceLimit = DEPTH;
|
|
62
|
+
const stack = new Error().stack; E.stackTraceLimit = lim;
|
|
63
|
+
const all = stackFrames(stack ?? '').filter(x => !SELF.test(x.file)), i = all.findIndex(x => !SKIP.test(x.file));
|
|
64
|
+
if (i < 0) return null;
|
|
65
|
+
const f = all[i];
|
|
66
|
+
// engine: the engine moved it for its own reasons (a debug view, the renderer fallback): no part's business. A frame skipped above can still be the engine's, in a game that has it in node_modules
|
|
67
|
+
return { at: frameText(f), key: `${f.file}|${f.fn}`, file: f.file, frames: all.slice(i), engine: all.slice(0, i + 1).some(x => CORE.test(x.file) && engineFile(x.file)) };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// name: the value's writers name while it can be in a slot (null: a material); ownBy / ownAt: the holder's last write; last: the slot and whether its holder wrote last
|
|
71
|
+
const newRec = (why, name = null) => ({ id: page.nextId++, at: null, why, seen: 0, wrote: -1, f: -1, n: 0, usual: 0, next: 0, sample: true, placeKey: null, placeAt: null, placeBy: null, fought: false, name, ownBy: null, ownAt: null, last: null });
|
|
72
|
+
const who = name => name ? `part '${name}'` : 'code outside any part';
|
|
73
|
+
|
|
74
|
+
class Writers {
|
|
75
|
+
constructor(e) {
|
|
76
|
+
this.e = e;
|
|
77
|
+
this.frame = 0; // 0 = setup: every write gets a stack and nothing can fight yet (a game's setup overrides engine defaults on purpose)
|
|
78
|
+
this.hooksRan = false;
|
|
79
|
+
this.drawing = false; // during the draw the engine swaps background / tone and puts them back: not a write to the picture
|
|
80
|
+
this.stacks = 0; // stacks taken, the whole cost of this file: read it to judge a slow dev frame
|
|
81
|
+
this.fights = [];
|
|
82
|
+
this.held = []; // writes to a value another part holds
|
|
83
|
+
this.leftovers = []; // what removed parts left behind
|
|
84
|
+
this.files = new Map(); // source file -> Set of the picture parts that ran from it
|
|
85
|
+
this.homes = new Map(); // part -> a 'file:line' of its code once known, before that of the engine.use that installed it
|
|
86
|
+
this.adds = new Map(); // part -> Map(thing -> { kind, name, at }), until the thing leaves
|
|
87
|
+
this.addedBy = new WeakMap(); // thing -> part
|
|
88
|
+
this.top = new Map(); // 'fog.far' -> record (scene, fog and renderer values)
|
|
89
|
+
this.parts = new WeakMap(); // light or material -> { intensity: record, ... }
|
|
90
|
+
this.done = new WeakSet(); // a Color or Vector3 already watched (a color shared by two objects answers for the first)
|
|
91
|
+
const s = e.scene, r = e.renderer;
|
|
92
|
+
this.number(r, 'toneMapping', this.named('renderer.toneMapping', NOT.start));
|
|
93
|
+
this.number(r, 'toneMappingExposure', this.named('renderer.toneMappingExposure', NOT.start));
|
|
94
|
+
for (const k of ['environmentIntensity', 'backgroundIntensity']) this.number(s, k, this.named('scene.' + k, NOT.start));
|
|
95
|
+
this.number(s, 'environment', this.named('scene.environment', NOT.none));
|
|
96
|
+
const bg = this.named('scene.background', NOT.start);
|
|
97
|
+
this.slot(s, 'background', bg, c => { if (c?.isColor) this.watch(c, 'rgb', bg); });
|
|
98
|
+
if (s.background?.isColor) this.watch(s.background, 'rgb', bg);
|
|
99
|
+
const fog = this.named('scene.fog', NOT.none);
|
|
100
|
+
this.slot(s, 'fog', fog, f => this.fog(f, fog));
|
|
101
|
+
if (s.fog) this.fog(s.fog, fog);
|
|
102
|
+
this.roots = onSceneRoot(s, o => this.added(/** @type {any} */ (o).isLight ? 'light' : 'object', o, o.name || o.type), o => this.left(o));
|
|
103
|
+
this.view = sceneVisitor(s, { enter: o => {
|
|
104
|
+
if (/** @type {any} */ (o).isLight) this.light(o);
|
|
105
|
+
const m = /** @type {any} */ (o).material;
|
|
106
|
+
if (m) for (const x of [].concat(m)) this.material(x);
|
|
107
|
+
} });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
named(label, why) { const r = newRec(why, () => label); this.top.set(label, r); return r; }
|
|
111
|
+
|
|
112
|
+
/** Own accessor for one plain value; false when the object has none to replace. Reads and writes pass straight through */
|
|
113
|
+
slot(o, key, rec, after) {
|
|
114
|
+
const d = Object.getOwnPropertyDescriptor(o, key);
|
|
115
|
+
if (!d || !('value' in d) || !d.configurable) { if (rec.why !== NOT.none || !d) rec.why = NOT.own; return false; }
|
|
116
|
+
let v = d.value;
|
|
117
|
+
const t = this;
|
|
118
|
+
Object.defineProperty(o, key, { configurable: true, enumerable: d.enumerable, get: () => v,
|
|
119
|
+
set(x) { if (x === v) return; v = x; t.wrote(rec); after?.(x); } });
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
number(o, key, rec) { this.slot(o, key, rec); }
|
|
123
|
+
/** The components of a Color or Vector3, all reporting to one record: to the game it is one value */
|
|
124
|
+
watch(c, keys, rec) {
|
|
125
|
+
if (this.done.has(c)) return;
|
|
126
|
+
this.done.add(c);
|
|
127
|
+
for (const k of keys) this.slot(c, k, rec);
|
|
128
|
+
}
|
|
129
|
+
/** A color held in a property: the components, and the property itself (light.color = other replaces the object the components were on) */
|
|
130
|
+
color(o, key, rec) {
|
|
131
|
+
if (!o[key]?.isColor) return false;
|
|
132
|
+
this.watch(o[key], 'rgb', rec);
|
|
133
|
+
this.slot(o, key, rec, c => { if (c?.isColor) this.watch(c, 'rgb', rec); });
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A fog assigned now: its values were set by whoever wrote scene.fog, so they start with that answer, not with "not tracked" */
|
|
138
|
+
fog(f, slotRec) {
|
|
139
|
+
for (const k of ['near', 'far', 'density', 'color']) this.top.delete('fog.' + k);
|
|
140
|
+
if (!f) return;
|
|
141
|
+
const seed = r => { r.at = slotRec.at; r.why = slotRec.why; r.seen = slotRec.seen; return r; };
|
|
142
|
+
for (const k of f.isFogExp2 ? ['density'] : ['near', 'far']) this.number(f, k, seed(this.named('fog.' + k, NOT.before)));
|
|
143
|
+
this.color(f, 'color', seed(this.named('fog.color', NOT.before)));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
light(l) {
|
|
147
|
+
if (this.parts.has(l) || page.off) return;
|
|
148
|
+
const at = this.e._things?.entryOf(l)?.[0]?.at, why = NOT.before + (at ? ` (added at ${at})` : '');
|
|
149
|
+
const rec = k => newRec(why, () => `light:${l.name}.${k}`); // read at each write: a light can be named after it entered the scene
|
|
150
|
+
const p = { intensity: rec('intensity'), color: rec('color'), position: rec('position') };
|
|
151
|
+
this.parts.set(l, p);
|
|
152
|
+
this.number(l, 'intensity', p.intensity);
|
|
153
|
+
this.color(l, 'color', p.color);
|
|
154
|
+
this.watch(l.position, 'xyz', p.position);
|
|
155
|
+
if (l.groundColor) this.color(l, 'groundColor', p.groundColor = rec('groundColor'));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
material(m) {
|
|
159
|
+
if (this.parts.has(m) || page.off) return;
|
|
160
|
+
const p = {};
|
|
161
|
+
this.parts.set(m, p);
|
|
162
|
+
for (const k of ['color', 'emissive']) if (m[k]?.isColor) this.color(m, k, p[k] = newRec(NOT.before));
|
|
163
|
+
for (const k of ['opacity', 'emissiveIntensity']) if (typeof m[k] === 'number') this.number(m, k, p[k] = newRec(NOT.before));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The hot path: runs on every write that changed a value. No stack unless the header's rules ask for one */
|
|
167
|
+
wrote(rec) {
|
|
168
|
+
if (page.off || this.drawing || this.e._probing) return;
|
|
169
|
+
const fr = this.frame;
|
|
170
|
+
rec.wrote = fr;
|
|
171
|
+
if (rec.f !== fr) {
|
|
172
|
+
const cold = fr - rec.f > 1;
|
|
173
|
+
rec.sample = fr === 0 || cold || fr >= rec.next;
|
|
174
|
+
if (rec.sample) { rec.next = fr + EVERY + (rec.id & 7); rec.usual = 0; } // & 7: values written together do not all come due in one frame
|
|
175
|
+
rec.f = fr; rec.n = 0; rec.placeKey = null;
|
|
176
|
+
}
|
|
177
|
+
rec.n++;
|
|
178
|
+
if (!rec.sample) {
|
|
179
|
+
if (rec.n <= rec.usual) return;
|
|
180
|
+
rec.sample = true; rec.next = fr + 1; // more writes than usual: this one may be a new writer; next frame sees all of them from the first
|
|
181
|
+
}
|
|
182
|
+
rec.usual = rec.n;
|
|
183
|
+
this.stacks++;
|
|
184
|
+
const w = writerNow();
|
|
185
|
+
rec.seen = fr;
|
|
186
|
+
if (!w) { rec.at = null; rec.why = NOT.noFile; rec.placeKey = null; return; }
|
|
187
|
+
const by = this.partsOf(w);
|
|
188
|
+
this.claim(rec, w, by);
|
|
189
|
+
const place = `${w.key}|${by[0] ?? ''}`; // the part too: two parts' anonymous hooks in one file are two places
|
|
190
|
+
if (!w.engine && fr > 0 && rec.placeKey && rec.placeKey !== place && !rec.fought) this.fight(rec, rec.placeAt, rec.placeBy, w.at, by[0]);
|
|
191
|
+
rec.at = w.at; rec.why = null; rec.placeKey = place; rec.placeAt = w.at; rec.placeBy = by[0] ?? null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** The parts this write can be from: the running module alone, else every part that ran from a file on the stack, nearest first */
|
|
195
|
+
partsOf(w) {
|
|
196
|
+
const m = this.e._curModule;
|
|
197
|
+
if (m) { if (m.type === 'picture' && !engineFile(w.file)) this.noteFile(w.file, m.name, w.at); return [m.name]; }
|
|
198
|
+
for (const f of w.frames) { const s = this.files.get(f.file); if (s) return [...s]; }
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
noteFile(file, part, at) {
|
|
202
|
+
let s = this.files.get(file);
|
|
203
|
+
if (!s) this.files.set(file, s = new Set());
|
|
204
|
+
if (!s.has(part)) this.homes.set(part, at);
|
|
205
|
+
s.add(part);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A value in a slot someone holds: a write by the holder is noted, one by anyone else is reported, once per value and place */
|
|
209
|
+
claim(rec, w, by) {
|
|
210
|
+
const label = rec.name?.(), slot = label ? slotOfValue(label) : null, holder = slot && slotHolder(this.e, slot);
|
|
211
|
+
if (!holder) { rec.last = null; return; }
|
|
212
|
+
if (rec.ownBy !== holder) { rec.ownBy = holder; rec.ownAt = null; }
|
|
213
|
+
if (w.engine) return;
|
|
214
|
+
if (by.includes(holder)) { rec.ownAt = w.at; rec.last = { slot, holder, writer: 'holder' }; return; }
|
|
215
|
+
rec.last = { slot, holder, writer: 'stray', by: by[0] ?? null };
|
|
216
|
+
rec.fought = true; // this says more than a fight would, and the holder's next write would raise one
|
|
217
|
+
const key = `${w.key}\0${label}`;
|
|
218
|
+
if (this.held.some(h => h.key === key)) return;
|
|
219
|
+
const place = rec.ownAt ? `last written at ${rec.ownAt}` : `it has not changed this value yet; its code is at ${this.homes.get(holder) ?? 'an unknown line'}`;
|
|
220
|
+
this.held.push({ key, value: label, slot, holder, holderAt: rec.ownAt ?? this.homes.get(holder) ?? null, by: by[0] ?? null, at: w.at });
|
|
221
|
+
warnOnce(coded('picture-held', fmt(STRINGS.held, { value: label, holder, slot, place, at: w.at, who: who(by[0]) })), `picture-held\0${key}`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** engine.use is installing m: where, for a report that has no line of the holder's yet */
|
|
225
|
+
installing(m) { if (m.provides?.length) this.homes.set(m.name, callerAt()); }
|
|
226
|
+
|
|
227
|
+
/** ctx.track called by m's own code: the caller's file is the part's, which is how a timer or a listener of the part gets attributed later */
|
|
228
|
+
learn(m) {
|
|
229
|
+
if (page.off || m.type !== 'picture') return;
|
|
230
|
+
const E = /** @type {ErrorConstructor & { stackTraceLimit?: number }} */ (Error), lim = E.stackTraceLimit;
|
|
231
|
+
E.stackTraceLimit = DEPTH;
|
|
232
|
+
const stack = new Error().stack; E.stackTraceLimit = lim;
|
|
233
|
+
const f = stackFrames(stack ?? '').find(x => !SELF.test(x.file) && !/core\/engine\/modules\.js$/.test(x.file));
|
|
234
|
+
if (f && !engineFile(f.file)) this.noteFile(f.file, m.name, frameText(f));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A scene root or a post effect just added: which picture part it belongs to, if any.
|
|
239
|
+
* shortcut: only scene roots are seen. A light put under the camera or under another part's group is no root and goes unreported; upgrade through the visitor's
|
|
240
|
+
* pending adds in core/scene/sceneDelta.js if an agent reports one.
|
|
241
|
+
*/
|
|
242
|
+
added(kind, thing, name) {
|
|
243
|
+
if (page.off) return;
|
|
244
|
+
const m = this.e._curModule;
|
|
245
|
+
if (m ? m.type !== 'picture' : !this.files.size) return;
|
|
246
|
+
const w = m ? null : writerNow(), part = m?.name ?? (w && this.partsOf(w)[0]);
|
|
247
|
+
if (!part) return;
|
|
248
|
+
let mine = this.adds.get(part);
|
|
249
|
+
if (!mine) this.adds.set(part, mine = new Map());
|
|
250
|
+
mine.set(thing, { kind, name, at: callerAt() });
|
|
251
|
+
this.addedBy.set(thing, part);
|
|
252
|
+
}
|
|
253
|
+
left(thing) { this.adds.get(this.addedBy.get(thing))?.delete(thing); }
|
|
254
|
+
|
|
255
|
+
/** A module was unloaded, its tracked handles and dispose already run: name what stayed. swapping: the newcomer takes over the slots' values */
|
|
256
|
+
partGone(m, swapping) {
|
|
257
|
+
const mine = this.adds.get(m.name);
|
|
258
|
+
this.adds.delete(m.name);
|
|
259
|
+
if (page.off || m.type !== 'picture') return;
|
|
260
|
+
const left = [];
|
|
261
|
+
for (const [thing, r] of mine ?? []) if (!thing._removed) left.push(r); // _removed: a post handle; a scene root that left is already out of the map
|
|
262
|
+
const e = this.e;
|
|
263
|
+
for (const list of [e._onRender.before, e._onRender.after, e._frame, e._animate, e._fixed, e._fixedLate]) for (const f of list) if (f.part === m.name) left.push({ kind: 'hook', name: 'frame callback', at: f.at });
|
|
264
|
+
if (!swapping) for (const [name, on] of [['scene.fog', e.scene], ['scene.environment', e.scene], ['scene.background', e.scene]]) {
|
|
265
|
+
const r = this.top.get(name), key = name.slice(6);
|
|
266
|
+
if (r?.last?.holder === m.name && r.last.writer === 'holder' && on[key] != null) left.push({ kind: 'value', name, at: r.at });
|
|
267
|
+
}
|
|
268
|
+
if (!left.length) return;
|
|
269
|
+
this.leftovers.push({ part: m.name, left });
|
|
270
|
+
const list = left.map(r => `${r.kind} '${r.name}'${r.at ? ` (added at ${r.at})` : ''}`).join(', ');
|
|
271
|
+
warnOnce(coded('picture-leftover', fmt(STRINGS.leftover, { name: m.name, list })), `picture-leftover\0${m.name}\0${list}`);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
fight(rec, first, firstBy, second, secondBy) {
|
|
275
|
+
rec.fought = true;
|
|
276
|
+
const label = this.labelOf(rec) ?? 'a picture value', slot = slotOfValue(label);
|
|
277
|
+
const said = (at, by) => by ? `${at} (part '${by}')` : at;
|
|
278
|
+
this.fights.push({ value: label, first, second, ...(firstBy ? { firstBy } : {}), ...(secondBy ? { secondBy } : {}) });
|
|
279
|
+
warnOnce(coded('picture-conflict', fmt(STRINGS.conflict, { value: label, first: said(first, firstBy), second: said(second, secondBy), claim: slot ? fmt(STRINGS.claim, { slot }) : '' })), `picture-conflict\0${rec.id}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Every value with a name, in one pass: lights and materials are found through the scene, so their names are the current ones */
|
|
283
|
+
everyValue() {
|
|
284
|
+
this.view.sync();
|
|
285
|
+
const out = new Map(this.top), seen = new Map();
|
|
286
|
+
const add = (prefix, o, name) => {
|
|
287
|
+
const p = this.parts.get(o);
|
|
288
|
+
if (!p) return;
|
|
289
|
+
const n = (seen.get(name) ?? 0) + 1;
|
|
290
|
+
seen.set(name, n);
|
|
291
|
+
const id = `${prefix}:${name}${n > 1 ? '#' + n : ''}`;
|
|
292
|
+
for (const k in p) out.set(`${id}.${k}`, p[k]);
|
|
293
|
+
};
|
|
294
|
+
const mats = new Set();
|
|
295
|
+
this.e.scene.traverse(o => {
|
|
296
|
+
const x = /** @type {any} */ (o);
|
|
297
|
+
if (x.isLight) add('light', x, x.name || x.type);
|
|
298
|
+
if (x.material) for (const m of [].concat(x.material)) mats.add(m);
|
|
299
|
+
});
|
|
300
|
+
for (const m of mats) add('material', m, m.name || `${m.type}-${m.uuid.slice(0, 6)}`);
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
303
|
+
labelOf(rec) { for (const [k, r] of this.everyValue()) if (r === rec) return k; return null; }
|
|
304
|
+
|
|
305
|
+
answer(r) {
|
|
306
|
+
if (!r.at) return { at: null, note: r.why };
|
|
307
|
+
return { at: r.at, framesAgo: this.frame - r.seen, ...(r.wrote > r.seen ? { writtenSince: true } : {}), ...(r.last ?? {}) };
|
|
308
|
+
}
|
|
309
|
+
/** describe('picture').writers: materials nobody wrote since they entered the scene are left out (each would say the same "not tracked") */
|
|
310
|
+
list() {
|
|
311
|
+
const values = {};
|
|
312
|
+
let mats = 0, more = 0;
|
|
313
|
+
for (const [k, r] of this.everyValue()) {
|
|
314
|
+
if (k.startsWith('material:')) { if (!r.at) continue; if (++mats > MATERIALS_MAX) { more++; continue; } }
|
|
315
|
+
values[k] = this.answer(r);
|
|
316
|
+
}
|
|
317
|
+
return { tracked: true, frame: this.frame, stacks: this.stacks, values, conflicts: this.fights, held: this.held.map(({ key, ...h }) => h), leftovers: this.leftovers, ...(more ? { moreMaterials: more } : {}) };
|
|
318
|
+
}
|
|
319
|
+
/** One value by its describe name @param {string} label */
|
|
320
|
+
why(label) {
|
|
321
|
+
const all = this.everyValue(), r = all.get(label);
|
|
322
|
+
if (!r) return { ok: false, text: `${label}: not tracked. Tracked names (describe('picture').writers): ${[...all.keys()].filter(k => !k.startsWith('material:')).join(', ')}, material:<name>.color / emissive / opacity / emissiveIntensity`, detail: null };
|
|
323
|
+
const a = this.answer(r), fight = this.fights.find(f => f.value === label);
|
|
324
|
+
const owner = !a.slot ? '' : a.writer === 'holder' ? `, by part '${a.holder}', which holds ${a.slot}` : `, by ${who(a.by)}, a stray write: part '${a.holder}' holds ${a.slot}`;
|
|
325
|
+
const age = a.framesAgo ? `, looked at ${a.framesAgo} frames ago${a.writtenSince ? ' (written since, not looked at)' : ''}` : '';
|
|
326
|
+
return { ok: !!a.at, text: `${label}: ${a.at ? `last changed at ${a.at}${owner}${age}` : a.note}${fight ? `. Two writers in one frame: ${fight.first}, then ${fight.second}` : ''}`, detail: { ...a, ...(fight ? { conflict: fight } : {}) } };
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Top of a frame's hooks. Two frame hooks with no draw between (engine.step many frames, one draw) are two frames: a state change between them is no fight */
|
|
330
|
+
frameStart() { this.view.sync(); if (this.hooksRan) this.frame++; this.hooksRan = true; }
|
|
331
|
+
/** After the draw. The fixed steps before the next hooks count with that next frame, which is what they lead to */
|
|
332
|
+
frameEnd() { this.drawing = false; this.frame++; this.hooksRan = false; }
|
|
333
|
+
dispose() { this.view.remove(); this.roots.remove(); }
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** @param {any} e */
|
|
337
|
+
export function installPictureWriters(e) {
|
|
338
|
+
notePatch('picture-writers', 'dev server only: intensity, color, position of lights, scene.fog and its values, renderer.toneMapping / toneMappingExposure, scene.environment / background and their intensities, material color / emissive / opacity: an own get / set on each, and on the r g b / x y z of the Color or Vector3 (core/inspect/pictureWriters.js)',
|
|
339
|
+
() => { page.off = true; }, // accessors already placed stay and only pass values through; new objects get none
|
|
340
|
+
{ scope: 'objects in the scene', lost: "describe('picture').writers stops answering, and two writers in one frame are no longer warned about" });
|
|
341
|
+
e._picture = new Writers(e);
|
|
342
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// are not evaluated, so it over-counts) plus SAMPLER_WEIGHT per active sampler. A ranking aid, not a GPU timing: use it to find the heaviest
|
|
5
5
|
// materials, then measure with the GPU tools (Spector.js through `threedog capture`).
|
|
6
6
|
// Plain three.js equivalent: renderer.info.programs (the list) and gl.getShaderSource / gl.getActiveUniform on program.program.
|
|
7
|
-
import { isWebGPU, nodeProgram, programList } from '
|
|
7
|
+
import { isWebGPU, nodeProgram, programList } from '../../render/backend.js';
|
|
8
8
|
|
|
9
9
|
const SAMPLER_WEIGHT = 25;
|
|
10
10
|
const SAMPLERS = new Set([0x8B5E, 0x8B60, 0x8B62, 0x8B5F, 0x8DC1, 0x8DD2, 0x8DCA, 0x8DCC, 0x8DCF, 0x8DD7, 0x8DC4]); // GL sampler uniform types
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
// which lands "after step N" and replays the same. Args must be plain data and self-contained (aim direction goes in the args).
|
|
11
11
|
// The guard (ops.guard) backs "don't go around it": in dev, saved gameplay state written outside loading, fixed steps and ops
|
|
12
12
|
// is reported (see recipes/23-ops.md). Dev argument checks live in opsCheck.js.
|
|
13
|
-
import { DEV, missingText, warnOnce } from '
|
|
14
|
-
import { checkTypeRule, asModule } from '
|
|
15
|
-
import { checkDef, checkArgs, devError,
|
|
16
|
-
import { coded, codedError } from '
|
|
13
|
+
import { DEV, fmt, missingText, warnOnce } from '../base/validate.js';
|
|
14
|
+
import { checkTypeRule, asModule } from '../engine/moduleTypes.js';
|
|
15
|
+
import { checkDef, checkArgs, devError, SOURCES } from './opsCheck.js';
|
|
16
|
+
import { coded, codedError } from '../base/errorHints.js';
|
|
17
17
|
import { guardWrite } from './opsGuard.js';
|
|
18
18
|
import { failure, isStructured, opsBlocked } from './opsFail.js';
|
|
19
19
|
import { runOp } from './opsRun.js';
|
|
20
20
|
import { newRing, logEntry, recentEntries } from './opsHistory.js';
|
|
21
|
-
import { defaultsOf, withDefaults } from '
|
|
21
|
+
import { defaultsOf, withDefaults } from '../base/params.js';
|
|
22
22
|
|
|
23
23
|
const STRINGS = {
|
|
24
24
|
dup: "ops.define('{name}'): already defined. To replace it call remove() on the handle define returned first",
|
|
@@ -47,7 +47,7 @@ export class Ops {
|
|
|
47
47
|
/** @internal ctx of the innermost running op (nested ops inherit source and actor) */ this._last = null;
|
|
48
48
|
/** @internal set through route() (net clients): (def, args, opts) => result to return instead of running locally, or null to run here */ this._route = null;
|
|
49
49
|
/** @internal true while route() is held: every write outside allow() is reported, even in fixed steps and ops (own movement, world.move, excepted) */ this._client = false;
|
|
50
|
-
/** Counter
|
|
50
|
+
/** Counter that only goes up: each committed op, undo, load and rollback bumps it (a failed op that changed nothing does not); every run result carries it, so "did anything change since I looked" is one compare */
|
|
51
51
|
this.revision = 0;
|
|
52
52
|
/** @internal depth of atomic runs in progress, and after hooks waiting for the outermost one to commit */ this._txDepth = 0; this._txAfter = [];
|
|
53
53
|
this.historySize = 256;
|
|
@@ -110,7 +110,7 @@ export class Ops {
|
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Run an op now (synchronously): checks args (dev), calls can, then run, and logs it. Returns { ok: true, value, revision } or { ok: false, code, facts, nextActions, revision } (revision = ops.revision, counts committed ops); can may also return { code, facts?, nextActions? }.
|
|
113
|
-
* Pass a fresh args object each call (it is kept in the history; in dev it is frozen). opts.source: 'player' | 'game' | 'bridge' | 'test' | 'replay' | 'net'
|
|
113
|
+
* Pass a fresh args object each call (it is kept in the history; in dev it is frozen). opts.source: 'player' | 'game' | 'bridge' | 'test' | 'replay' | 'net' | 'editor'
|
|
114
114
|
* (default: 'game' inside a fixed step, 'player' between steps); opts.actor: who does it (world record id, default engine.actor, which is 'player' unless the game hands control elsewhere).
|
|
115
115
|
* @param {string} name
|
|
116
116
|
* @param {object} [args]
|
|
@@ -140,8 +140,12 @@ export class Ops {
|
|
|
140
140
|
const d = this._def(name);
|
|
141
141
|
if (!d) return this._res(failure({ code: 'unknownOp', facts: { op: name } }));
|
|
142
142
|
if (typeof d.undo !== 'function') return this._res(failure({ code: 'noUndo', facts: { op: name }, nextActions: [] }));
|
|
143
|
+
const blocked = opsBlocked(this.engine); // as run: a load in progress or a gameplay error
|
|
144
|
+
if (blocked) return this._res(failure(blocked));
|
|
143
145
|
this._allowDepth++;
|
|
144
|
-
|
|
146
|
+
// the op's code is the defining module's, not the caller's (run)
|
|
147
|
+
try { asModule(this.engine, null, () => d.undo(this.engine, args, value, this._ctx(name, args, opts, null))); } finally { this._allowDepth--; }
|
|
148
|
+
this.revision++; // the state changed: "did anything change since I looked" must see it
|
|
145
149
|
return { ok: true };
|
|
146
150
|
}
|
|
147
151
|
|
|
@@ -237,10 +241,11 @@ export class Ops {
|
|
|
237
241
|
* @param {any} args
|
|
238
242
|
* @param {{ reason: string, actor?: string, source?: string }} why source defaults to 'net'
|
|
239
243
|
* @returns {void}
|
|
244
|
+
* @experimental
|
|
240
245
|
*/
|
|
241
|
-
refused(name, args, { reason, actor = '', source = 'net' }) { this._log(name, args, { source, actor, tick: this.engine.tick }, false, reason, 0); }
|
|
246
|
+
refused(name, args, { reason, actor = '', source = 'net' }) { this._log(name, args, { source, actor, tick: this.engine.time.tick }, false, reason, 0); }
|
|
242
247
|
/** @internal A separator in the history (save load): later entries belong to a different world state */
|
|
243
|
-
_mark(label) { this._log(label, null, { tick: this.engine.tick, source: 'game', actor: '' }, true, null, 0); }
|
|
248
|
+
_mark(label) { this._log(label, null, { tick: this.engine.time.tick, source: 'game', actor: '' }, true, null, 0); }
|
|
244
249
|
/**
|
|
245
250
|
* Run fn with guarded writes allowed (loading a save, applying a scenario, net sync); works for an async fn too (allowed until its Promise settles). Returns what fn returns.
|
|
246
251
|
* @experimental
|
|
@@ -274,7 +279,7 @@ export class Ops {
|
|
|
274
279
|
if (!SOURCES.includes(source)) throw devError(fmt(STRINGS.badSource, { name, source }));
|
|
275
280
|
if (args) checkArgs(e, this.defs.get(name), args);
|
|
276
281
|
}
|
|
277
|
-
return { source, actor: opts?.actor ?? parent?.actor ?? e.actor, tick: e.tick, frozen: e.frozen };
|
|
282
|
+
return { source, actor: opts?.actor ?? parent?.actor ?? e.actor, tick: e.time.tick, frozen: e.frozen };
|
|
278
283
|
}
|
|
279
284
|
/** @internal returns true or a reason string */
|
|
280
285
|
_can(d, args, ctx) {
|