threedog 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +196 -1
- package/README.md +6 -9
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +98 -54
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
- package/core/{assetReport.js → assets/assetReport.js} +6 -12
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +26 -23
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +10 -10
- package/core/{Random.js → base/Random.js} +5 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +98 -110
- package/core/{errorHints.js → base/errorHints.js} +5 -9
- package/core/{errors.js → base/errors.js} +6 -6
- package/core/{events.generated.js → base/events.generated.js} +1 -0
- package/core/{math.js → base/math.js} +15 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +28 -7
- package/core/{Engine.js → engine/Engine.js} +80 -77
- package/core/{Loading.js → engine/Loading.js} +4 -2
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
- package/core/{lifecycle.js → engine/lifecycle.js} +14 -12
- package/core/{loop.js → engine/loop.js} +68 -47
- package/core/{moduleSlots.js → engine/moduleSlots.js} +6 -6
- package/core/{moduleTypes.js → engine/moduleTypes.js} +13 -14
- package/core/{modules.js → engine/modules.js} +14 -11
- package/core/{page.js → engine/page.js} +36 -23
- package/core/{plugins.js → engine/plugins.js} +6 -9
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +26 -24
- package/core/{Input.js → input/Input.js} +30 -22
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/{inputPad.js → input/inputPad.js} +1 -1
- package/core/{inputPointer.js → input/inputPointer.js} +8 -2
- package/core/{inputTouch.js → input/inputTouch.js} +1 -1
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +30 -16
- package/core/{Describe.js → inspect/Describe.js} +26 -22
- package/core/{Inspect.js → inspect/Inspect.js} +9 -7
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
- package/core/{UrlState.js → inspect/UrlState.js} +52 -20
- package/core/{catalog.js → inspect/catalog.js} +3 -3
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +4 -4
- package/core/{describeRender.js → inspect/describeRender.js} +21 -20
- package/core/{describeText.js → inspect/describeText.js} +11 -6
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +15 -16
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/{Ops.js → ops/Ops.js} +16 -11
- package/core/{control.js → ops/control.js} +13 -12
- package/core/ops/holds.js +139 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
- package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +7 -4
- package/core/{owned.js → ops/owned.js} +14 -17
- package/core/{sharedPoint.js → ops/sharedPoint.js} +8 -8
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +12 -14
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
- package/core/{Saves.js → saves/Saves.js} +58 -36
- package/core/{saveApply.js → saves/saveApply.js} +13 -9
- package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
- package/core/{saveValues.js → saves/saveValues.js} +20 -3
- package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
- package/core/{session.js → saves/session.js} +31 -17
- package/core/{Rays.js → scene/Rays.js} +23 -25
- package/core/{Views.js → scene/Views.js} +14 -6
- package/core/{adaptive.js → scene/adaptive.js} +15 -8
- package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
- package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
- package/core/{gameLights.js → scene/gameLights.js} +17 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +4 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/{ground.js → scene/ground.js} +9 -9
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/{sceneDelta.js → scene/sceneDelta.js} +2 -2
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -13
- package/core/scene/stepPoses.js +55 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +6 -5
- package/core/{thingOps.js → scene/thingOps.js} +4 -3
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{view.js → scene/view.js} +17 -16
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +60 -30
- package/core/{batchGroups.js → stream/batchGroups.js} +10 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +2 -2
- package/core/{streamSources.js → stream/streamSources.js} +12 -7
- package/core/{Commits.js → threads/Commits.js} +6 -5
- package/core/{Jobs.js → threads/Jobs.js} +12 -10
- package/core/{Threads.js → threads/Threads.js} +16 -16
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +17 -10
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +18 -17
- package/core/{time.js → time/time.js} +18 -12
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +22 -19
- package/docs/API.md +24 -23
- package/docs/CODEMAP.md +76 -183
- package/docs/COMMANDS.md +66 -58
- package/docs/CONVENTIONS.md +54 -14
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +78 -29
- package/docs/api/assets.md +12 -13
- package/docs/api/audio.md +6 -5
- package/docs/api/budget.md +4 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +29 -29
- package/docs/api/characters.md +23 -18
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +45 -43
- package/docs/api/events.md +3 -2
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +7 -7
- package/docs/api/interactions.md +4 -4
- package/docs/api/inventory.md +9 -9
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -7
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +2 -2
- package/docs/api/post.md +20 -3
- package/docs/api/quests.md +3 -3
- package/docs/api/rays.md +5 -7
- package/docs/api/rigid.md +27 -18
- package/docs/api/saves.md +8 -7
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +7 -8
- package/docs/api/terrainDraw.md +1 -1
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +25 -22
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +1 -1
- package/docs/api/water.md +1 -1
- package/docs/api/weather.md +9 -9
- package/docs/api/weatherDraw.md +3 -3
- package/docs/api/world.md +5 -5
- package/docs/recipes/01-new-game.md +25 -40
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +27 -43
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +29 -39
- package/docs/recipes/06-clock-events.md +27 -18
- package/docs/recipes/07-flow-scenes-pause.md +12 -17
- package/docs/recipes/08-weather-sky.md +88 -34
- package/docs/recipes/09-materials-lights-models.md +22 -36
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +30 -22
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +39 -17
- package/docs/recipes/14-custom-module.md +14 -13
- package/docs/recipes/15-perf.md +49 -26
- package/docs/recipes/16-dev-bridge.md +32 -52
- package/docs/recipes/18-world.md +36 -23
- package/docs/recipes/19-shooting-picking.md +4 -2
- package/docs/recipes/20-content-actions-save.md +30 -35
- package/docs/recipes/21-camera.md +33 -5
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +10 -10
- package/docs/recipes/26-ui-parts.md +22 -12
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +117 -21
- package/docs/recipes/29-grid.md +2 -2
- package/docs/recipes/30-templates.md +55 -19
- package/docs/recipes/31-audio.md +5 -5
- package/docs/recipes/32-action-game.md +15 -6
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +67 -19
- package/docs/recipes/35-picture-from-reference.md +10 -17
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +7 -11
- package/docs/recipes/43-shader-patches-surfaces.md +20 -41
- package/docs/recipes/44-water-weather-hooks.md +48 -43
- package/docs/recipes/45-cascaded-shadows.md +39 -17
- package/docs/recipes/46-blender-art-route.md +7 -8
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/52-around-the-picture.md +54 -98
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +12 -16
- package/docs/recipes/56-webgpu-tsl.md +16 -14
- package/docs/recipes/57-control.md +9 -2
- package/docs/recipes/58-input.md +2 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +29 -24
- package/docs/recipes/62-picture-code.md +49 -17
- package/docs/recipes/63-third-person-start.md +17 -4
- package/docs/recipes/64-particles.md +1 -1
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +2 -2
- package/examples/{sheepisland → perf-island}/.threedog/content-index.json +1 -1
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +12 -11
- package/examples/{sheepisland → perf-island}/assets.js +1 -1
- package/examples/{sheepisland → perf-island}/main.js +8 -8
- package/examples/{sheepisland → perf-island}/models.js +1 -1
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/GAMEMAP.md +1 -0
- package/examples/rc2d/GAMEMAP.md +3 -2
- package/examples/rc2d/main.js +1 -3
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +3 -2
- package/examples/techniques/contact-shadows/contactShadows.js +1 -1
- package/examples/techniques/contact-shadows/main.js +1 -1
- package/examples/techniques/interior-light/main.js +1 -1
- package/examples/techniques/modular-building/README.md +7 -6
- package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +1 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +4 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +8 -7
- package/index.js +31 -31
- package/llms.txt +9 -13
- package/modules/ambience/Ambience.js +11 -8
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +13 -13
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +2 -2
- package/modules/camera/FixedCamera.js +14 -15
- package/modules/camera/FollowCamera.js +4 -4
- package/modules/camera/RtsCamera.js +11 -11
- package/modules/camera/common.js +48 -24
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +33 -30
- package/modules/characters/NPC.js +27 -19
- package/modules/characters/assetModel.js +14 -10
- package/modules/characters/astar.js +7 -5
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +168 -214
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +16 -14
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +8 -8
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +23 -17
- package/modules/characters/npcView.js +6 -5
- package/modules/characters/pathAsync.js +12 -10
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +108 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +26 -20
- package/modules/collision/contract.js +15 -0
- package/modules/content/explain.js +1 -2
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +2 -2
- package/modules/content/index.js +61 -99
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +10 -7
- package/modules/content/packs.js +3 -3
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +35 -0
- package/modules/content/props.js +17 -14
- package/modules/content/rules.js +25 -21
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +20 -20
- package/modules/content/words.js +34 -0
- package/modules/debug/DebugPanel.js +10 -43
- package/modules/flow/contract.js +1 -1
- package/modules/flow/index.js +11 -7
- package/modules/gameplay/Container.js +12 -11
- package/modules/gameplay/Containers.js +14 -5
- package/modules/gameplay/Dialogue.js +13 -11
- package/modules/gameplay/Interactions.js +37 -24
- package/modules/gameplay/Inventory.js +8 -9
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +3 -4
- package/modules/gameplay/inventoryOps.js +0 -1
- package/modules/gameplay/pickups.js +22 -23
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +4 -4
- package/modules/grid/index.js +7 -8
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +37 -55
- package/modules/hud/index.js +17 -11
- package/modules/hud/parts.js +4 -4
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +47 -152
- package/modules/level/load.js +79 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +6 -7
- package/modules/lights/index.js +28 -181
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +30 -26
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +14 -0
- package/modules/nav/index.js +11 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +5 -4
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +11 -8
- package/modules/particles/effect.js +7 -5
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +15 -17
- package/modules/rigid/RigidBodies.js +66 -43
- package/modules/rigid/Vehicles.js +2 -3
- package/modules/rigid/ragdoll.js +287 -0
- package/modules/rigid/ragdollBones.js +159 -0
- package/modules/rigid/sync.js +6 -6
- package/modules/settings/Settings.js +108 -39
- package/modules/settings/apply.js +6 -6
- package/modules/settings/sections.js +16 -14
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +29 -22
- package/modules/sky/clouds.js +7 -7
- package/modules/sky/dome.js +33 -20
- package/modules/sky/domeLayers.js +9 -9
- package/modules/sky/environment.js +6 -6
- package/modules/sky/frame.js +19 -10
- package/modules/sky/season.js +7 -1
- package/modules/sky/shader.js +24 -25
- package/modules/sky/skyModule.js +14 -27
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +346 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +70 -52
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +14 -11
- package/modules/terrain/index.js +28 -34
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +17 -12
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +27 -19
- package/modules/timeline/Tween.js +6 -6
- package/modules/timeline/shots.js +5 -7
- package/modules/triggers/index.js +9 -9
- package/modules/vegetation/Vegetation.js +30 -23
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +23 -18
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +8 -6
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +16 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +41 -30
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +22 -18
- package/modules/world/World.js +8 -8
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -12
- package/modules/world/persist.js +73 -25
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +28 -8
- package/modules/world/sim.js +4 -4
- package/modules/world/state.js +12 -5
- package/modules/world/thingSource.js +4 -2
- package/modules/world/views.js +11 -9
- package/package.json +42 -7
- package/presets.js +1 -3
- package/render/PostFX.js +39 -27
- package/render/backend.js +26 -32
- package/render/cascades.js +17 -12
- package/render/cascades.tsl.js +5 -8
- package/render/daylight.js +20 -3
- package/render/detail.js +8 -7
- package/render/effects.js +28 -25
- package/render/fuse.js +3 -3
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +5 -10
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +27 -23
- package/render/fx/sky.tsl.js +15 -17
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +1 -1
- package/render/lighting.js +5 -3
- package/render/lightmap.js +20 -20
- package/render/lights.js +6 -6
- package/render/lit.js +24 -0
- package/render/materials.js +8 -7
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/occlusion.js +20 -4
- package/render/ownFrame.js +4 -4
- package/render/patches.js +13 -13
- package/render/postWebGL.js +12 -10
- package/render/probes.js +16 -19
- package/render/recordSweep.js +117 -0
- package/render/shaderErrors.js +10 -9
- package/render/shadowCache.tsl.js +107 -0
- package/render/shadowTypes.js +9 -0
- package/{core → render}/shadows.js +57 -11
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +200 -153
- package/types/gameplay.d.ts +163 -91
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +12 -8
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +2 -2
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Layer.d.ts +1 -1
- package/types/generated/modules/grid/index.d.ts +3 -3
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/sky/Sky.d.ts +21 -10
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +2 -1
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +16 -12
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +5 -3
- package/types/generated/render/PostFX.d.ts +17 -11
- package/types/generated/render/materials.d.ts +1 -0
- package/types/generated/render/occlusion.d.ts +9 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +11 -11
- package/types/physics.d.ts +99 -70
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +38 -71
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +4 -3
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +5 -3
- package/core/assetEntry.js +0 -109
- package/core/holds.js +0 -134
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -320
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/MIGRATING-0.6.md +0 -126
- package/docs/PERF.md +0 -245
- package/docs/recipes/36-sky-ground-plants.md +0 -158
- package/docs/recipes/37-terrain-hooks.md +0 -115
- package/docs/recipes/38-environment-hooks.md +0 -67
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/47-island-snow-backdrop.md +0 -43
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/plain-picture/FINDINGS.md +0 -53
- /package/core/{Vars.js → base/Vars.js} +0 -0
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsFail.js → ops/opsFail.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{tier.js → scene/tier.js} +0 -0
- /package/core/{cells.js → stream/cells.js} +0 -0
- /package/core/{streamCells.js → stream/streamCells.js} +0 -0
- /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
- /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
package/modules/world/persist.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Loading before content is loaded works too: changes and removals are remembered and applied / skipped when content is added. Things newly added to content after a game update still show up with an old save.
|
|
8
8
|
// Temporary things (data for effects, one-off spawns): add(def, { save: false }) — not saved, cleared on load.
|
|
9
9
|
// Changes are found by comparing JSON against the original content, not by events: fields changed directly inside simulate are saved too.
|
|
10
|
-
// Save format (part 'world', version
|
|
10
|
+
// Save format (part 'world', version 5): every record is keyed by its stable id, and only what play changed is stored:
|
|
11
11
|
// { seq, step, time, records: { id: whole runtime record without id }, changed: { id: { set?: changed fields, del?: [removed fields] } },
|
|
12
12
|
// removed: [ids of removed initial records], owed: { id: simulation seconds owed, only for kinds simulated with far } }
|
|
13
13
|
// Version 1 kept records as an array: migrate step 1 (WORLD_MIGRATE) turns it into the id-keyed object.
|
|
@@ -21,24 +21,33 @@
|
|
|
21
21
|
// Removed fields are recorded separately (not saved as null): after loading it is "no such field", same as in a live run; a field that was null stays null.
|
|
22
22
|
// step / time are the simulation step count and accumulated seconds: far simulation takes turns by step-count buckets, so one save advances the same way every time (see sim.js).
|
|
23
23
|
|
|
24
|
-
import { legacyRuntimeIds, renameIdKeys, renameIdValues } from '../../core/saveIds.js';
|
|
25
|
-
import { codedError } from '../../core/errorHints.js';
|
|
26
|
-
import {
|
|
24
|
+
import { legacyRuntimeIds, renameIdKeys, renameIdValues } from '../../core/saves/saveIds.js';
|
|
25
|
+
import { codedError } from '../../core/base/errorHints.js';
|
|
26
|
+
import { fmt } from '../../core/base/validate.js';
|
|
27
|
+
import { isPlainObject } from '../../core/base/util.js';
|
|
28
|
+
import { refuseSave, saveNumberOk, SAVE_MAX } from '../../core/saves/saveValues.js';
|
|
27
29
|
|
|
28
30
|
const PLAIN_STRINGS = {
|
|
29
|
-
msg:
|
|
30
|
-
fn: 'a function', obj: 'a three.js object', asset: 'a three.js asset', dom: 'a DOM element',
|
|
31
|
+
msg: "saved world data must be plain values (number, string, boolean, array, plain object): {path} is {what}. A model: world.present('crate', { build: rec => mesh }), then world.view(id) gets it; logic: world.simulate(); not saved: world.add(rec, { save: false })",
|
|
32
|
+
fn: 'a function', obj: 'a three.js object', asset: 'a three.js asset', dom: 'a DOM element', instance: 'a {name}, which comes back from a save as a bare object: write {shape}',
|
|
31
33
|
};
|
|
32
|
-
/** Dev-time check: data must not contain three.js objects, functions
|
|
34
|
+
/** Dev-time check: data must not contain three.js objects, functions, DOM elements or class instances (saves can only store plain values) @internal */
|
|
33
35
|
export function checkPlain(v, path, depth = 0) {
|
|
34
|
-
const fail = what => { throw codedError('world-plain', PLAIN_STRINGS.msg
|
|
36
|
+
const fail = what => { throw codedError('world-plain', fmt(PLAIN_STRINGS.msg, { path, what })); };
|
|
35
37
|
if (v == null || typeof v !== 'object') { if (typeof v === 'function') fail(PLAIN_STRINGS.fn); return; }
|
|
36
38
|
const what = v.isObject3D ? PLAIN_STRINGS.obj : v.isMaterial || v.isBufferGeometry || v.isTexture ? PLAIN_STRINGS.asset : typeof Element !== 'undefined' && v instanceof Element ? PLAIN_STRINGS.dom : null;
|
|
37
39
|
if (what) fail(what);
|
|
40
|
+
// a Vector3 or Color passed here and came back from a load as a bare object, so rec.dir.add(...) threw only then
|
|
41
|
+
if (!Array.isArray(v) && !isPlainObject(v)) fail(fmt(PLAIN_STRINGS.instance, { name: v.isVector3 ? 'Vector3' : v.isColor ? 'Color' : 'class instance', shape: v.isVector3 ? '{ x, y, z }' : v.isColor ? 'a number or a string' : 'plain fields' })); // not constructor.name: a build minifies it
|
|
38
42
|
if (depth > 6) return;
|
|
39
43
|
for (const k in v) checkPlain(v[k], `${path}.${k}`, depth + 1);
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
/** Whether a value can go into a save: what checkPlain accepts @internal */
|
|
47
|
+
export function isPlain(v) { try { checkPlain(v, ''); return true; } catch { return false; } }
|
|
48
|
+
|
|
49
|
+
const CHANGES_MAX = 50;
|
|
50
|
+
|
|
42
51
|
/** Compare an initial record with its original: which top-level fields changed, which were removed (null if neither) */
|
|
43
52
|
function diff(rec, base) {
|
|
44
53
|
let set = null, del = null;
|
|
@@ -50,7 +59,9 @@ function diff(rec, base) {
|
|
|
50
59
|
return set || del ? { set: set ?? undefined, del: del ?? undefined } : null;
|
|
51
60
|
}
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
const mapValues = (o, f) => o && typeof o === 'object' ? Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)])) : o;
|
|
63
|
+
|
|
64
|
+
/** Upgrade steps of the world save part (saves.register version 5) @internal */
|
|
54
65
|
export const WORLD_MIGRATE = {
|
|
55
66
|
1: d => ({ ...d, records: Object.fromEntries((d?.records || []).map(({ id, ...r }) => [id, r])) }), // array of records -> keyed by id
|
|
56
67
|
2: d => { // runtime ids `<kind>-<n>` -> `<kind>#<n>`: record keys, owed keys, and field values that name a renamed record
|
|
@@ -61,8 +72,7 @@ export const WORLD_MIGRATE = {
|
|
|
61
72
|
3: d => { // motion coyote -> jump: { coyote, used: 0 } (whole runtime records and changed fields; the player keeps it on the record, NPCs in motion)
|
|
62
73
|
const fix = m => { if (!m || typeof m !== 'object' || !('coyote' in m)) return m; const { coyote, ...rest } = m; return { ...rest, jump: { coyote: coyote ?? 0, used: 0 } }; };
|
|
63
74
|
const rec = r => { const o = fix(r); return o && typeof o === 'object' && o.motion ? { ...o, motion: fix(o.motion) } : o; };
|
|
64
|
-
|
|
65
|
-
return { ...d, records: map(d.records, rec), changed: map(d.changed, c => c?.set ? { ...c, set: rec(c.set) } : c) };
|
|
75
|
+
return { ...d, records: mapValues(d.records, rec), changed: mapValues(d.changed, c => c?.set ? { ...c, set: rec(c.set) } : c) };
|
|
66
76
|
},
|
|
67
77
|
4: d => { // NPC talk / talkLabel / talkRadius -> interact (records of any kind that carry talk: only NPCs had it)
|
|
68
78
|
const fix = r => {
|
|
@@ -70,18 +80,40 @@ export const WORLD_MIGRATE = {
|
|
|
70
80
|
const { talk, talkLabel, talkRadius, ...rest } = r;
|
|
71
81
|
return { ...rest, interact: talk ? { label: talkLabel ?? null, op: 'npc.talk', args: { script: talk }, radius: talkRadius ?? 3.2 } : null };
|
|
72
82
|
};
|
|
73
|
-
const map = (o, f) => o && typeof o === 'object' ? Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)])) : o;
|
|
74
83
|
// a changed entry of an initial NPC: a removed talk means it no longer talks (interact removed). A label / radius alone (set or removed) has no
|
|
75
84
|
// script to build an interact from, so it is dropped and the content's interact stays; a stray key would sit on the record unread
|
|
76
85
|
const OLD = ['talkLabel', 'talkRadius'];
|
|
77
86
|
const strip = s => s && typeof s === 'object' && !('talk' in s) && OLD.some(k => k in s) ? Object.fromEntries(Object.entries(s).filter(([k]) => !OLD.includes(k))) : s;
|
|
78
87
|
const del = l => Array.isArray(l) ? [...new Set(l.filter(k => !OLD.includes(k)).map(k => k === 'talk' ? 'interact' : k))] : l;
|
|
79
88
|
const change = c => c && typeof c === 'object' ? { ...c, ...(c.set && { set: strip(fix(c.set)) }), ...(c.del && { del: del(c.del) }) } : c;
|
|
80
|
-
return { ...d, records:
|
|
89
|
+
return { ...d, records: mapValues(d.records, fix), changed: mapValues(d.changed, change) };
|
|
81
90
|
},
|
|
82
91
|
};
|
|
83
92
|
|
|
84
|
-
|
|
93
|
+
/**
|
|
94
|
+
* What play changed, for describe().world: totals alone said "same" after a prop moved. changed holds one row per record whose fields differ from its content
|
|
95
|
+
* (runtime records report their kind and place), removed the initial records gone. Capped, with the rest counted, because describe runs after every step and goes
|
|
96
|
+
* to the AI. The player's motion and the player record are left out: describe().player already says where it is, and those fields change every step. So is where a
|
|
97
|
+
* record with motion stands (a walking NPC): it is a new row on every step, and the one thing a command really changed would drop off the line that names it.
|
|
98
|
+
* @param {import('./World.js').World} w @internal
|
|
99
|
+
*/
|
|
100
|
+
export function worldChanges(w) {
|
|
101
|
+
const rows = [];
|
|
102
|
+
for (const rec of w.records.values()) {
|
|
103
|
+
if (w._unsaved.has(rec.id) || rec.kind === 'player') continue;
|
|
104
|
+
const base = w._base.get(rec.id);
|
|
105
|
+
if (!base) { rows.push({ id: rec.id, kind: rec.kind, runtime: true, ...(!rec.motion && { position: { ...rec.position } }) }); continue; } // a copy: a kept describe result must not move
|
|
106
|
+
const d = diff(rec, base);
|
|
107
|
+
if (!d) continue;
|
|
108
|
+
const { motion, ...set } = d.set ?? {};
|
|
109
|
+
if (rec.motion) { delete set.position; delete set.rot; }
|
|
110
|
+
if (Object.keys(set).length || d.del) rows.push({ id: rec.id, ...set, ...(d.del && { removedFields: d.del }) });
|
|
111
|
+
}
|
|
112
|
+
rows.sort((a, b) => (a.id < b.id ? -1 : 1));
|
|
113
|
+
const removed = [...w._removed].sort();
|
|
114
|
+
return { ...(rows.length && { changed: rows.slice(0, CHANGES_MAX) }), ...(rows.length > CHANGES_MAX && { changedMore: rows.length - CHANGES_MAX }),
|
|
115
|
+
...(removed.length && { removed: removed.slice(0, CHANGES_MAX) }), ...(removed.length > CHANGES_MAX && { removedMore: removed.length - CHANGES_MAX }) };
|
|
116
|
+
}
|
|
85
117
|
|
|
86
118
|
/** @param {import('./World.js').World} w @internal */
|
|
87
119
|
export function saveWorld(w) {
|
|
@@ -101,17 +133,23 @@ export function saveWorld(w) {
|
|
|
101
133
|
// so a hand-edited or damaged record ({ x: 1e12, y: null, z: 'abc' }) went straight into the records and threw later in a listener / a mover,
|
|
102
134
|
// with the game half-loaded. Refusing throws: saves.apply rolls the whole load back and reports this message (save-bad-record).
|
|
103
135
|
const SHAPE_STRINGS = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
arr: 'must be an array of record ids', count: 'must be a finite number >= 0',
|
|
136
|
+
obj: 'must be a plain object', kind: 'must have kind (a string)', pos: `must be { x, y, z } with finite numbers within ±${SAVE_MAX}`,
|
|
137
|
+
arr: 'must be an array of record ids', motion: 'must be a plain object (the character motion state) or null', nav: 'must be a plain object (the NPC path state)', path: 'must be null or a list of { x, z } with finite numbers', num: 'must be a finite number within ±{max}', count: 'must be a finite number >= 0',
|
|
107
138
|
};
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const bad = (path, why, got) => { throw codedError('save-bad-record', SHAPE_STRINGS.bad.replace('{path}', path).replace('{why}', why.replace('{max}', String(POS_MAX))).replace('{got}', String(JSON.stringify(got)).slice(0, 120))); };
|
|
113
|
-
const pos = (path, p) => { if (!isPlainObject(p) || !['x', 'y', 'z'].every(k => Number.isFinite(p[k]) && Math.abs(p[k]) <= POS_MAX)) bad(path, SHAPE_STRINGS.pos, p); };
|
|
139
|
+
/** Throw save-bad-record for the first malformed core field of a world save (fields of the game's own are not checked); kindOf(id) is the kind of an authored record @internal */
|
|
140
|
+
function checkWorldSave(d, kindOf) {
|
|
141
|
+
const bad = (path, why, got) => refuseSave('world', path, why, got);
|
|
142
|
+
const pos = (path, p) => { if (!isPlainObject(p) || !['x', 'y', 'z'].every(k => saveNumberOk(p[k]))) bad(path, SHAPE_STRINGS.pos, p); };
|
|
114
143
|
const num = (path, v) => { if (v !== undefined && !(Number.isFinite(v) && v >= 0)) bad(path, SHAPE_STRINGS.count, v); };
|
|
144
|
+
// rec.motion is written in place by Character.saveMotion on every fixed step (npcSim): a number there threw "Cannot create property 'vx'" and froze the game
|
|
145
|
+
// and its numbers feed the mover: a wrong one comes back a step later as a NaN position. The player holds them on the record itself
|
|
146
|
+
const speeds = (path, o) => { for (const k of ['vx', 'vy', 'vz', 'facing', 'amount']) if (o[k] != null && !saveNumberOk(o[k])) bad(`${path}.${k}`, SHAPE_STRINGS.num, o[k]); };
|
|
147
|
+
const motion = (path, m) => { if (m == null) return; if (!isPlainObject(m)) bad(path, SHAPE_STRINGS.motion, m); speeds(path, m); };
|
|
148
|
+
// rec.nav of an NPC is written in place the same way, and every NPC has one. Another kind's `nav` is the game's own field
|
|
149
|
+
const nav = (path, v) => {
|
|
150
|
+
if (!isPlainObject(v)) bad(path, SHAPE_STRINGS.nav, v);
|
|
151
|
+
if (v.path != null && !(Array.isArray(v.path) && v.path.every(p => isPlainObject(p) && saveNumberOk(p.x) && saveNumberOk(p.z)))) bad(`${path}.path`, SHAPE_STRINGS.path, v.path);
|
|
152
|
+
};
|
|
115
153
|
if (!isPlainObject(d)) bad('the world part', SHAPE_STRINGS.obj, d);
|
|
116
154
|
num('seq', d.seq); num('step', d.step); num('time', d.time);
|
|
117
155
|
for (const f of ['records', 'changed', 'owed']) if (d[f] !== undefined && !isPlainObject(d[f])) bad(f, SHAPE_STRINGS.obj, d[f]);
|
|
@@ -119,19 +157,29 @@ function checkWorldSave(d) {
|
|
|
119
157
|
for (const [id, r] of Object.entries(d.records ?? {})) {
|
|
120
158
|
if (!isPlainObject(r)) bad(`records.${id}`, SHAPE_STRINGS.obj, r);
|
|
121
159
|
if (typeof r.kind !== 'string') bad(`records.${id}`, SHAPE_STRINGS.kind, r.kind);
|
|
122
|
-
|
|
160
|
+
pos(`records.${id}.position`, r.position); // world.add gives every record one, and the cell index reads it
|
|
161
|
+
motion(`records.${id}.motion`, r.motion);
|
|
162
|
+
if (r.kind === 'npc') nav(`records.${id}.nav`, r.nav);
|
|
163
|
+
if (r.kind === 'player') speeds(`records.${id}`, r);
|
|
123
164
|
}
|
|
124
165
|
for (const [id, c] of Object.entries(d.changed ?? {})) {
|
|
125
166
|
if (!isPlainObject(c) || (c.set !== undefined && !isPlainObject(c.set)) || (c.del !== undefined && !Array.isArray(c.del))) bad(`changed.${id}`, SHAPE_STRINGS.obj, c);
|
|
126
167
|
if (c.set && 'position' in c.set) pos(`changed.${id}.set.position`, c.set.position);
|
|
168
|
+
if (c.del?.includes('position')) pos(`changed.${id}.del`, undefined);
|
|
169
|
+
if (c.set) motion(`changed.${id}.set.motion`, c.set.motion);
|
|
127
170
|
if (c.set && 'kind' in c.set && typeof c.set.kind !== 'string') bad(`changed.${id}.set`, SHAPE_STRINGS.kind, c.set.kind);
|
|
171
|
+
// shortcut: an NPC whose content loads after the save is not known here, so its changed nav goes unchecked; move the check to where a pending change is applied if a fuzz run reaches it
|
|
172
|
+
if ((c.set?.kind ?? kindOf(id)) === 'npc') {
|
|
173
|
+
if (c.set && 'nav' in c.set) nav(`changed.${id}.set.nav`, c.set.nav);
|
|
174
|
+
if (c.del?.includes('nav')) nav(`changed.${id}.del`, undefined);
|
|
175
|
+
}
|
|
128
176
|
}
|
|
129
177
|
for (const [id, v] of Object.entries(d.owed ?? {})) num(`owed.${id}`, v);
|
|
130
178
|
}
|
|
131
179
|
|
|
132
180
|
/** Load: replace runtime records wholesale; loaded initial records go back to the original then get the save's changes; unloaded content waits for its add. Independent of the order of content.load @internal */
|
|
133
181
|
export function loadWorld(w, d) {
|
|
134
|
-
checkWorldSave(d); // before anything is cleared: a refused save leaves the world as it was (the rollback then has nothing to undo here)
|
|
182
|
+
checkWorldSave(d, id => w._base.get(id)?.kind); // before anything is cleared: a refused save leaves the world as it was (the rollback then has nothing to undo here)
|
|
135
183
|
w._v.clear();
|
|
136
184
|
w.records.clear(); w._cells.clear(); w._unsaved.clear();
|
|
137
185
|
for (const id of [...w._origin.keys()]) if (!w._base.has(id)) w._origin.delete(id); // runtime records come from the save now (no op to name)
|
package/modules/world/pos.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Position read / write for world: shared by add / move / query. A wrong position (a Vector3 used as an array, [x, z] with only two numbers) silently becomes NaN and null in the save,
|
|
2
2
|
// so dev builds throw on the spot and say how to fix it.
|
|
3
|
-
import { DEV } from '../../core/validate.js';
|
|
4
|
-
import {
|
|
3
|
+
import { DEV, goodPos, fmt } from '../../core/base/validate.js';
|
|
4
|
+
import { badPosition } from '../../core/base/math.js';
|
|
5
5
|
|
|
6
6
|
const STRINGS = {
|
|
7
7
|
arr: '{fn}: an array position must be [x, y, z] (three numbers); for a horizontal position only, write { x, z }',
|
|
@@ -11,10 +11,10 @@ const STRINGS = {
|
|
|
11
11
|
/** Write position v (Vector3 / object / [x, y, z] / { x, z }) into p; y stays unchanged if omitted @internal */
|
|
12
12
|
export function putPos(fn, v, p) {
|
|
13
13
|
const arr = Array.isArray(v), o = v.isObject3D ? v.position : v;
|
|
14
|
-
if (DEV && arr && v.length !== 3) throw
|
|
14
|
+
if (DEV && arr && v.length !== 3) throw badPosition(fmt(STRINGS.arr, { fn }), v);
|
|
15
15
|
const x = arr ? v[0] : o.x, y = arr ? v[1] : o.y ?? p.y, z = arr ? v[2] : o.z;
|
|
16
16
|
// check before writing: a bad position leaves no half-written NaN in the data
|
|
17
|
-
if (DEV && !(
|
|
17
|
+
if (DEV && !goodPos([x, y, z])) throw badPosition(fmt(STRINGS.nan, { fn, got: JSON.stringify(v) }), v);
|
|
18
18
|
p.x = x; p.y = y; p.z = z;
|
|
19
19
|
}
|
|
20
20
|
/** Query center: objects use position, arrays are [x, y, z], others (Vector3 / { x, z }) are used as is, no allocation @internal */
|
package/modules/world/records.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// World record mutations (add / rest / orphans / set / remove): the bodies behind the World methods of the same names. World.js keeps the public
|
|
2
2
|
// JSDoc and signatures; these functions take the world as `w` and reach its internals the same way sim.js / views.js / persist.js do.
|
|
3
|
-
import { DEV, fmt } from '../../core/validate.js';
|
|
4
|
-
import { readParams, keysSchema } from '../../core/params.js';
|
|
3
|
+
import { DEV, fmt } from '../../core/base/validate.js';
|
|
4
|
+
import { readParams, keysSchema } from '../../core/base/params.js';
|
|
5
5
|
import { checkPlain } from './persist.js';
|
|
6
6
|
import { putPos, centerOf } from './pos.js';
|
|
7
|
-
import { claimId } from '../../core/things.js';
|
|
8
|
-
import { codedError } from '../../core/errorHints.js';
|
|
7
|
+
import { claimId } from '../../core/scene/things.js';
|
|
8
|
+
import { codedError } from '../../core/base/errorHints.js';
|
|
9
9
|
|
|
10
10
|
export const STRINGS = {
|
|
11
11
|
noKind: 'world.add() needs a kind (what sort of thing this is), e.g. world.add({ kind: "crate", position: [0, 0, 0] })',
|
|
@@ -15,10 +15,13 @@ export const STRINGS = {
|
|
|
15
15
|
setKey: 'world.set("{id}", patch): patch must not contain id / kind (they are the identity of the record). To change the kind, remove then add',
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
// { save: false } records never reach a save and are cleared on load, so a mesh on one is harmless. The exception: a kind simulated with worker: true is copied to a thread
|
|
19
|
+
const mustBePlain = (w, kind, saved) => saved || !!w._s.sims.get(kind)?.worker;
|
|
20
|
+
|
|
18
21
|
export function addRecord(w, def, opts) {
|
|
19
22
|
DEV && w.engine.ops.guard('world.add');
|
|
20
23
|
if (!def?.kind) throw codedError('world-add', STRINGS.noKind);
|
|
21
|
-
if (DEV) { readParams('world.add(def, opts)', keysSchema(['initial', 'save']), opts); checkPlain({ ...def, position: undefined }, def.kind); }
|
|
24
|
+
if (DEV) { readParams('world.add(def, opts)', keysSchema(['initial', 'save']), opts); if (mustBePlain(w, def.kind, opts?.save !== false)) checkPlain({ ...def, position: undefined }, def.kind); }
|
|
22
25
|
const { id: given, kind, position, ...rest } = def, initial = !!opts?.initial;
|
|
23
26
|
if (initial && given == null) throw codedError('world-add', fmt(STRINGS.initialId, { kind }));
|
|
24
27
|
const id = given ?? `${kind}#${++w._seq}`, have = w.records.get(id), p = { x: 0, y: 0, z: 0 };
|
|
@@ -26,6 +29,7 @@ export function addRecord(w, def, opts) {
|
|
|
26
29
|
const rec = { id, kind, position: p, ...rest };
|
|
27
30
|
if (initial) {
|
|
28
31
|
if (!w._base.has(id)) w._base.set(id, structuredClone(rec));
|
|
32
|
+
else if (!have || have.kind === kind) repose(w, have, w._base.get(id), rec);
|
|
29
33
|
if (have) return have;
|
|
30
34
|
claimId(w.engine, id);
|
|
31
35
|
if (w._removed.has(id)) return null;
|
|
@@ -34,10 +38,26 @@ export function addRecord(w, def, opts) {
|
|
|
34
38
|
if (have) throw codedError('world-id', fmt(STRINGS.dupId, { id }));
|
|
35
39
|
claimId(w.engine, id);
|
|
36
40
|
if (opts?.save === false) w._unsaved.add(id);
|
|
37
|
-
if (DEV) w._origin.set(id, { spawned: { op: w.engine.ops.running, tick: w.engine.tick } }); // who made it (inspect / pick)
|
|
41
|
+
if (DEV) w._origin.set(id, { spawned: { op: w.engine.ops.running, tick: w.engine.time.tick } }); // who made it (inspect / pick)
|
|
38
42
|
return w._insert(rec, true);
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Content loaded again with another pose for an authored entry (its place moved or turned): the baseline takes the new pose, and so does the live record
|
|
47
|
+
* unless play moved or turned it, because a change the player made stays on top of the content. The presenter sees the new fit and moves model and collision.
|
|
48
|
+
* Only position and rot: they are what a place decides, and a same-id clash on any other field must still reach the caller's check.
|
|
49
|
+
* x and z decide "unmoved": y is settled from the ground when the model is built, so it may differ from the baseline without anyone having moved it.
|
|
50
|
+
* shortcut: a physics body keeps its own place (positionFrom 'view') until the page reloads; teach restBody to teleport if an editor moves such a place live.
|
|
51
|
+
*/
|
|
52
|
+
function repose(w, have, base, rec) {
|
|
53
|
+
const pose = r => `${r.position.x},${r.position.z},${r.rot}`;
|
|
54
|
+
if (pose(base) === pose(rec)) return;
|
|
55
|
+
if (have?.position.x === base.position.x && have.position.z === base.position.z) { Object.assign(have.position, rec.position); w._index(have); }
|
|
56
|
+
if (have && have.rot === base.rot) { if (rec.rot === undefined) delete have.rot; else have.rot = rec.rot; }
|
|
57
|
+
Object.assign(base.position, rec.position);
|
|
58
|
+
if (rec.rot === undefined) delete base.rot; else base.rot = rec.rot;
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
export function restRecord(w, id, position, tolerance) {
|
|
42
62
|
const rec = w.records.get(id), base = w._base.get(id); if (!rec) return;
|
|
43
63
|
const a = rec.position, b = base?.position;
|
|
@@ -50,14 +70,14 @@ export function orphanIds(w) {
|
|
|
50
70
|
const out = [], known = id => w._base.has(id) || w.records.has(id);
|
|
51
71
|
const due = id => { const i = id.indexOf('/'); return i < 0 || w._levels.has(id.slice(0, i)); };
|
|
52
72
|
for (const id of w._pending.keys()) if (!known(id) && due(id)) out.push(id);
|
|
53
|
-
for (const id of w._removed) if (!known(id) &&
|
|
73
|
+
for (const id of w._removed) if (!known(id) && due(id)) out.push(id);
|
|
54
74
|
return out;
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
export function setRecord(w, id, patch) {
|
|
58
78
|
DEV && w.engine.ops.guard('world.set');
|
|
59
79
|
const rec = w._need(id, 'set');
|
|
60
|
-
if (DEV) { if ('id' in patch || 'kind' in patch) throw codedError('world-add', fmt(STRINGS.setKey, { id })); checkPlain({ ...patch, position: undefined }, id); }
|
|
80
|
+
if (DEV) { if ('id' in patch || 'kind' in patch) throw codedError('world-add', fmt(STRINGS.setKey, { id })); if (mustBePlain(w, w.records.get(id).kind, !w._unsaved.has(id))) checkPlain({ ...patch, position: undefined }, id); }
|
|
61
81
|
const { position, ...rest } = patch;
|
|
62
82
|
Object.assign(rec, rest);
|
|
63
83
|
if (position) w.move(id, position);
|
package/modules/world/sim.js
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
// mover cost every step. Buckets follow the hashed id and the step count (both saved), not distances measured on frame boundaries, so a loaded save runs the
|
|
23
23
|
// same records on the same steps as a live run.
|
|
24
24
|
|
|
25
|
-
import { DEV } from '../../core/validate.js';
|
|
26
|
-
import { readParams, keysSchema } from '../../core/params.js';
|
|
25
|
+
import { DEV } from '../../core/base/validate.js';
|
|
26
|
+
import { readParams, keysSchema } from '../../core/base/params.js';
|
|
27
27
|
import { FarFlights } from './simFar.js';
|
|
28
|
-
import { codedError } from '../../core/errorHints.js';
|
|
28
|
+
import { codedError } from '../../core/base/errorHints.js';
|
|
29
29
|
|
|
30
30
|
/** Near simulation order: by id (independent of insertion order and loading) */
|
|
31
31
|
const byId = (a, b) => a.rec.id < b.rec.id ? -1 : 1;
|
|
@@ -52,7 +52,7 @@ export class Sim {
|
|
|
52
52
|
// created once, no closure per step
|
|
53
53
|
this._pick = (rec, d2) => {
|
|
54
54
|
const s = this.sims.get(rec.kind);
|
|
55
|
-
if (s && d2 <= s.r2 && this.w.
|
|
55
|
+
if (s && d2 <= s.r2 && this.w.inZone(rec)) { const e = this.ents.get(rec.id); e.d2 = d2; this.list.push(e); }
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
|
package/modules/world/state.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Internal half of World (World.js copies these onto World.prototype; a mixin, not a base class, so the generated World.d.ts needs no import of this file): state tables, the hooks the engine calls, and the helpers other world files use.
|
|
2
2
|
// Split by responsibility: World.js keeps the public API and its documentation; nothing here is public.
|
|
3
|
-
import { DEV, fmt } from '../../core/validate.js';
|
|
3
|
+
import { DEV, fmt } from '../../core/base/validate.js';
|
|
4
4
|
import { STRINGS as RECORD_STRINGS, restRecord, orphanIds } from './records.js';
|
|
5
|
-
import { saveWorld, loadWorld, renamePending } from './persist.js';
|
|
6
|
-
import { Cells } from '../../core/cells.js';
|
|
5
|
+
import { saveWorld, loadWorld, renamePending, isPlain } from './persist.js';
|
|
6
|
+
import { Cells } from '../../core/stream/cells.js';
|
|
7
7
|
import { centerOf } from './pos.js';
|
|
8
|
-
import { codedError } from '../../core/errorHints.js';
|
|
8
|
+
import { codedError } from '../../core/base/errorHints.js';
|
|
9
9
|
|
|
10
10
|
export function initState(w, cellSize) {
|
|
11
11
|
/** @internal */ w._anchor = null;
|
|
@@ -33,6 +33,11 @@ class Internals {
|
|
|
33
33
|
* moved is left alone.
|
|
34
34
|
*/
|
|
35
35
|
rest(id, position, tolerance = 0) { restRecord(this, id, position, tolerance); }
|
|
36
|
+
/**
|
|
37
|
+
* @internal The dev editor changed the design itself: the entry's old content is gone, not removed in play, so no baseline and no "removed" mark stay behind for
|
|
38
|
+
* the save to pin. The record is already gone (thing.remove); the content loader puts the new one in as an authored record again.
|
|
39
|
+
*/
|
|
40
|
+
forget(id) { this._base.delete(id); this._removed.delete(id); this._origin.delete(id); }
|
|
36
41
|
/** @internal Content / level loaders say where an authored record was defined (dev only; merged into what is there) */
|
|
37
42
|
setOrigin(id, info) {
|
|
38
43
|
if (info?.level != null) this._levels.add(info.level);
|
|
@@ -86,8 +91,10 @@ class Internals {
|
|
|
86
91
|
/** Tear down all models (called by engine.dispose) @internal */
|
|
87
92
|
dispose() { this._v.clear(); }
|
|
88
93
|
|
|
94
|
+
/** @internal whether a value can go into a save, for a module that sorts its options (npcs.add) */
|
|
95
|
+
isPlain(v) { return isPlain(v); }
|
|
89
96
|
/** @internal */
|
|
90
|
-
|
|
97
|
+
inZone(rec) { return this.zone == null || rec.zone == null || rec.zone === this.zone; }
|
|
91
98
|
/** @internal */
|
|
92
99
|
_need(id, fn) { const r = this.records.get(id); if (!r) throw codedError('world-record', fmt(RECORD_STRINGS.noId, { fn, id })); return r; }
|
|
93
100
|
/** Copy the original initial record and apply the changes from the save @internal */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// What the world module tells core about its records: engine._things.addSource(...) at install. Core knows only this shape (has / get / set / remove /
|
|
2
2
|
// explain, plus idOf / view / ids / restore for the model link and undo), never the World class, so engine.thing, thing.set and the shared id space
|
|
3
3
|
// work the same whether or not this module is installed.
|
|
4
|
+
import { fmt } from '../../core/base/validate.js';
|
|
5
|
+
|
|
4
6
|
const SAY = {
|
|
5
7
|
defined: 'defined in {at}: edit it there to change the level for good (ops change only this session), or: threedog content set {id} <field> <json>',
|
|
6
8
|
node: 'level {level} node {node}: change it in the level model',
|
|
@@ -13,8 +15,8 @@ function describeRecord(w, id) {
|
|
|
13
15
|
const rec = w.get(id); if (!rec) return null;
|
|
14
16
|
const o = w.origin(id) ?? {}, fields = {};
|
|
15
17
|
for (const k in rec) if (!NOT_FIELDS.has(k)) fields[k] = rec[k];
|
|
16
|
-
const how = o.definedAt ? SAY.defined
|
|
17
|
-
: o.spawned ? SAY.spawned
|
|
18
|
+
const how = o.definedAt ? fmt(SAY.defined, { at: o.definedAt, id }) : o.node ? fmt(SAY.node, { level: o.level, node: o.node })
|
|
19
|
+
: o.spawned ? fmt(SAY.spawned, { op: o.spawned.op ? ` by op ${o.spawned.op} at tick ${o.spawned.tick}` : '' }) : null;
|
|
18
20
|
return { id, kind: rec.kind, template: o.template ?? null, definedAt: o.definedAt ?? null, ...(o.templateAt && { templateAt: o.templateAt }),
|
|
19
21
|
...(o.node && { level: o.level, node: o.node }), ...(o.spawned && { spawned: o.spawned }), model: o.model ?? rec.model ?? null,
|
|
20
22
|
position: { ...rec.position }, fields, edit: how };
|
package/modules/world/views.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// sync positions, decide ready. The public API is in World.js (present / view / ready / refresh); this is the implementation.
|
|
4
4
|
// It only decides "which records have a model" and never affects gameplay: simulation follows the gameplay anchor (sim.js), and how fast models are built, or
|
|
5
5
|
// whether they are built, does not change simulation results.
|
|
6
|
-
import { reportError } from '../../core/errors.js';
|
|
7
|
-
import { DEV, warnOnce } from '../../core/validate.js';
|
|
8
|
-
import { readParams, keysSchema } from '../../core/params.js';
|
|
9
|
-
import { codedError } from '../../core/errorHints.js';
|
|
6
|
+
import { reportError } from '../../core/base/errors.js';
|
|
7
|
+
import { DEV, warnOnce, fmt } from '../../core/base/validate.js';
|
|
8
|
+
import { readParams, keysSchema } from '../../core/base/params.js';
|
|
9
|
+
import { codedError } from '../../core/base/errorHints.js';
|
|
10
10
|
|
|
11
11
|
const STRINGS = {
|
|
12
12
|
noBuild: 'world.present(\'{kind}\', { build }) needs build: rec => three.js object',
|
|
@@ -18,7 +18,7 @@ const STRINGS = {
|
|
|
18
18
|
};
|
|
19
19
|
/** Dev: code wrote the position of a model world places every frame (positionFrom 'record'): the write is lost next frame */
|
|
20
20
|
const moved = (e, id) => e.thingConflict(`world model of '${id}' was moved by code outside its present update; world puts it back on the record every frame (positionFrom 'record'). Move the record instead: ops.run('thing.set', { id: '${id}', position }) or world.move, or present it with positionFrom: 'view'. Picture-only motion (a leg swing, a stagger) goes in the present's update(rec, obj, dt), which runs right after the placing`);
|
|
21
|
-
const say = (s, kind, id = '', got = '') => s
|
|
21
|
+
const say = (s, kind, id = '', got = '') => fmt(s, { kind, id, got });
|
|
22
22
|
const OPTS = ['build', 'update', 'dispose', 'show', 'radius', 'positionFrom'];
|
|
23
23
|
const FULL = { detail: 'full' };
|
|
24
24
|
|
|
@@ -111,7 +111,7 @@ export class Views {
|
|
|
111
111
|
* so waiting only in frame() would never resolve; builds still owed (per-frame limit) are done right here, like world.refresh() */
|
|
112
112
|
wake() {
|
|
113
113
|
if (!this.waiters.length) return;
|
|
114
|
-
if (this.presenters.size && (this.dirty || this.moved()) && this.w.engine.
|
|
114
|
+
if (this.presenters.size && (this.dirty || this.moved()) && this.w.engine.halted) this.refresh();
|
|
115
115
|
if (this.ready) for (const r of this.waiters.splice(0)) r();
|
|
116
116
|
}
|
|
117
117
|
/** End of fixed step: models that move themselves (positionFrom 'view') copy their position back to the record, so later gameplay in this step and saves read this step's result.
|
|
@@ -121,7 +121,9 @@ export class Views {
|
|
|
121
121
|
for (const id of this.moving) {
|
|
122
122
|
const rec = W.records.get(id), o = this.map.get(id).obj.position;
|
|
123
123
|
if (S.sims.get(rec.kind)?.near && !S.isNear(id)) { o.copy(rec.position); continue; }
|
|
124
|
-
|
|
124
|
+
const r = rec.position;
|
|
125
|
+
if (r.x === o.x && r.y === o.y && r.z === o.z) continue; // the mover wrote it already (Character, npcSim), or it stood still: nothing to file again
|
|
126
|
+
r.x = o.x; r.y = o.y; r.z = o.z; W._index(rec);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
/** Build models that should exist near any full-detail source (at most limit);
|
|
@@ -133,7 +135,7 @@ export class Views {
|
|
|
133
135
|
for (const p of this.presenters.values()) { const r = this.radius(p); this.radii.set(p, r); if (r > maxR) maxR = r; }
|
|
134
136
|
for (const a of this.memo.at) W._cells.forEach(a, a.s.reach(maxR), (rec, d2) => {
|
|
135
137
|
const p = this.presenters.get(rec.kind);
|
|
136
|
-
if (!p || this.map.has(rec.id) || !W.
|
|
138
|
+
if (!p || this.map.has(rec.id) || !W.inZone(rec)) return;
|
|
137
139
|
const r = this.reach(p, a.s);
|
|
138
140
|
if (d2 > r * r || p.show && !p.show(rec)) return;
|
|
139
141
|
if (n >= limit) { this.dirty = true; return; } // enough built this frame: continue next frame, ready still waits
|
|
@@ -142,7 +144,7 @@ export class Views {
|
|
|
142
144
|
for (const [id, v] of this.map) { // teardown distance is widened to 1.25×: walking back and forth on the boundary does not build and tear down repeatedly
|
|
143
145
|
const rec = W.records.get(id);
|
|
144
146
|
const keep = this.near(rec, v.p) <= 1.5625 || v.p.positionFrom === 'view' && W._s.isNear(id); // keep models that near simulation needs
|
|
145
|
-
if (!keep || !W.
|
|
147
|
+
if (!keep || !W.inZone(rec) || v.p.show && !v.p.show(rec)) this.unview(id);
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
/**
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "threedog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Web 3D game engine on three.js: core + optional modules, no built-in art (the picture comes from your own style), built to be driven by an AI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/penstic123-code/
|
|
8
|
+
"url": "git+https://github.com/penstic123-code/Threedog.js-Game-Engine.git",
|
|
9
9
|
"directory": "packages/engine"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/penstic123-code/
|
|
11
|
+
"homepage": "https://github.com/penstic123-code/Threedog.js-Game-Engine#readme",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/penstic123-code/
|
|
13
|
+
"url": "https://github.com/penstic123-code/Threedog.js-Game-Engine/issues"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": "^20.19.0 || >=22.12.0"
|
|
@@ -23,17 +23,19 @@
|
|
|
23
23
|
"types": "./index.d.ts",
|
|
24
24
|
"default": "./index.js"
|
|
25
25
|
},
|
|
26
|
-
"./error-hints": "./core/errorHints.js",
|
|
27
|
-
"./grid": "./core/grid.js",
|
|
26
|
+
"./error-hints": "./core/base/errorHints.js",
|
|
27
|
+
"./grid": "./core/scene/grid.js",
|
|
28
28
|
"./layers": "./render/layers.js",
|
|
29
29
|
"./worker": {
|
|
30
30
|
"types": "./types/worker.d.ts",
|
|
31
|
-
"default": "./core/threadServe.js"
|
|
31
|
+
"default": "./core/threads/threadServe.js"
|
|
32
32
|
},
|
|
33
33
|
"./tsl": {
|
|
34
34
|
"types": "./types/tsl.d.ts",
|
|
35
35
|
"default": "./render/fx/index.js"
|
|
36
36
|
},
|
|
37
|
+
"./modules/*.contract.js": "./modules/*.contract.js",
|
|
38
|
+
"./modules/*/contract.js": "./modules/*/contract.js",
|
|
37
39
|
"./package.json": "./package.json"
|
|
38
40
|
},
|
|
39
41
|
"files": [
|
|
@@ -50,6 +52,39 @@
|
|
|
50
52
|
"CHANGELOG.md",
|
|
51
53
|
"llms.txt"
|
|
52
54
|
],
|
|
55
|
+
"sideEffects": [
|
|
56
|
+
"./core/assets/assetLod.js",
|
|
57
|
+
"./core/stream/Batching.js",
|
|
58
|
+
"./core/engine/Engine.js",
|
|
59
|
+
"./core/scene/gameLights.js",
|
|
60
|
+
"./core/engine/page.js",
|
|
61
|
+
"./core/threads/pureWorker.js",
|
|
62
|
+
"./core/scene/sceneDelta.js",
|
|
63
|
+
"./modules/camera/FirstPersonCamera.js",
|
|
64
|
+
"./modules/camera/FixedCamera.js",
|
|
65
|
+
"./modules/camera/FollowCamera.js",
|
|
66
|
+
"./modules/camera/RtsCamera.js",
|
|
67
|
+
"./modules/characters/pathWorker.js",
|
|
68
|
+
"./modules/sky/Sky.js",
|
|
69
|
+
"./modules/terrain/ChunkManager.js",
|
|
70
|
+
"./modules/terrain/chunkWorker.js",
|
|
71
|
+
"./modules/world/World.js",
|
|
72
|
+
"./render/backend.js",
|
|
73
|
+
"./render/cascades.tsl.js",
|
|
74
|
+
"./render/detail.js",
|
|
75
|
+
"./render/effects.js",
|
|
76
|
+
"./render/fx/index.js",
|
|
77
|
+
"./render/fx/particles.tsl.js",
|
|
78
|
+
"./render/fx/patchNodes.tsl.js",
|
|
79
|
+
"./render/fx/postWebGPU.tsl.js",
|
|
80
|
+
"./render/fx/sky.tsl.js",
|
|
81
|
+
"./render/lighting.js",
|
|
82
|
+
"./render/ownFrame.js",
|
|
83
|
+
"./render/patches.js",
|
|
84
|
+
"./render/postWebGL.js",
|
|
85
|
+
"./render/recordSweep.js",
|
|
86
|
+
"./render/shadowCache.tsl.js"
|
|
87
|
+
],
|
|
53
88
|
"scripts": {
|
|
54
89
|
"dev": "vite",
|
|
55
90
|
"build": "vite build",
|
package/presets.js
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
// engine.use(interactions({ ...presets.interactions.nearest, radius: 3 }));
|
|
7
7
|
// No imports and no engine state: plain data plus small control functions that call public API only.
|
|
8
8
|
|
|
9
|
-
/** @import { WeatherOptions, SkyOptions } from './types/world' */
|
|
10
|
-
|
|
11
9
|
/** A side-scroller moves only along world X (left / right keys); W / S do nothing. Reads input by action like the 'camera' control */
|
|
12
10
|
function sideScroll(p, input) { return { x: (input.autopilot || input.axis).x, z: 0, run: input.actions.has('run') && input.down('run') }; }
|
|
13
11
|
|
|
@@ -43,7 +41,7 @@ export const presets = Object.freeze({
|
|
|
43
41
|
calendar: Object.freeze({
|
|
44
42
|
/** Spring, summer, autumn, winter, 7 days each, with the 360 s day cycle of `cycle` (a cozy life sim; set daysPerSeason: 28 for longer seasons) */
|
|
45
43
|
fourSeasons: Object.freeze({ seasons: Object.freeze(['spring', 'summer', 'autumn', 'winter']), daysPerSeason: 7, dayLength: 360 }),
|
|
46
|
-
/** A day-night cycle, one day = 360
|
|
44
|
+
/** A day-night cycle, one day = 360 calendar seconds (6 minutes at clock.rate 1); calendar() alone keeps a fixed time of day */
|
|
47
45
|
cycle: Object.freeze({ dayLength: 360 }),
|
|
48
46
|
/** One time of day that never moves (dungeon, arena, space station), what calendar() does without a dayLength; pick the hour with time */
|
|
49
47
|
fixedTime: Object.freeze({ dayLength: Infinity }),
|