threedog 0.7.0 → 1.0.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 +411 -1
- package/README.md +8 -11
- package/core/{Animator.js → assets/Animator.js} +30 -18
- package/core/{Assets.js → assets/Assets.js} +131 -56
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +302 -0
- package/core/{assetHot.js → assets/assetHot.js} +9 -7
- 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} +7 -14
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +47 -25
- 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} +15 -12
- package/core/{Random.js → base/Random.js} +7 -4
- package/core/{Vars.js → base/Vars.js} +14 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +151 -125
- package/core/{errorHints.js → base/errorHints.js} +17 -10
- package/core/{errors.js → base/errors.js} +12 -10
- package/core/{events.generated.js → base/events.generated.js} +11 -0
- package/core/base/follows.js +26 -0
- package/core/base/math.js +66 -0
- package/core/{params.js → base/params.js} +5 -6
- package/core/base/saveValues.js +81 -0
- package/core/base/sections.js +97 -0
- package/core/base/spelling.js +32 -0
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +34 -34
- package/core/{Engine.js → engine/Engine.js} +137 -91
- package/core/{Loading.js → engine/Loading.js} +34 -5
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +32 -15
- package/core/{lifecycle.js → engine/lifecycle.js} +41 -34
- package/core/{loop.js → engine/loop.js} +88 -49
- package/core/engine/moduleSlots.js +176 -0
- package/core/{moduleTypes.js → engine/moduleTypes.js} +26 -14
- package/core/engine/modules.js +503 -0
- package/core/{page.js → engine/page.js} +59 -29
- package/core/{plugins.js → engine/plugins.js} +21 -12
- package/core/{services.js → engine/services.js} +50 -40
- package/core/{startup.js → engine/startup.js} +66 -54
- package/core/{Input.js → input/Input.js} +67 -39
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/input/inputKeyboard.js +39 -0
- package/core/{inputPad.js → input/inputPad.js} +24 -3
- package/core/{inputPointer.js → input/inputPointer.js} +11 -3
- package/core/input/inputSeat.js +66 -0
- package/core/{inputTouch.js → input/inputTouch.js} +24 -7
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +43 -18
- package/core/{Describe.js → inspect/Describe.js} +34 -26
- package/core/{Inspect.js → inspect/Inspect.js} +39 -10
- 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} +60 -24
- package/core/{catalog.js → inspect/catalog.js} +15 -8
- 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} +24 -22
- package/core/{describeText.js → inspect/describeText.js} +17 -8
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/inspect/metadata.generated.js +4140 -0
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +130 -47
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/inspect/toolDoor.js +21 -0
- package/core/inspect/valueHistory.js +35 -0
- package/core/{Ops.js → ops/Ops.js} +44 -14
- package/core/{control.js → ops/control.js} +57 -31
- package/core/ops/holds.js +140 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +18 -5
- package/core/{opsCheck.js → ops/opsCheck.js} +11 -10
- package/core/{opsFail.js → ops/opsFail.js} +5 -7
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +9 -6
- package/core/{owned.js → ops/owned.js} +33 -19
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -16
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +34 -15
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +53 -27
- package/core/{Saves.js → saves/Saves.js} +171 -54
- package/core/saves/saveApply.js +312 -0
- package/core/{saveFiles.js → saves/saveFiles.js} +45 -38
- package/core/{saveVersions.js → saves/saveVersions.js} +24 -23
- package/core/saves/session.js +231 -0
- package/core/saves/stateReplace.js +184 -0
- package/core/{Rays.js → scene/Rays.js} +44 -30
- package/core/{Views.js → scene/Views.js} +16 -8
- package/core/{adaptive.js → scene/adaptive.js} +19 -9
- package/core/{canvasBox.js → scene/canvasBox.js} +4 -3
- package/core/scene/compositeGround.js +72 -0
- package/core/scene/floor.js +17 -0
- 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} +6 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/scene/ground.contract.js +14 -0
- package/core/scene/ground.js +139 -0
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/scene/pixel.js +154 -0
- package/core/scene/pixelRatio.js +167 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +5 -5
- package/core/{sceneMethods.js → scene/sceneMethods.js} +43 -15
- package/core/scene/stepPoses.js +60 -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} +25 -16
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +10 -0
- package/core/scene/view.js +161 -0
- package/core/{Batching.js → stream/Batching.js} +85 -28
- package/core/{Stream.js → stream/Stream.js} +80 -38
- package/core/{batchGroups.js → stream/batchGroups.js} +11 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +7 -4
- package/core/{streamSources.js → stream/streamSources.js} +14 -8
- package/core/{Commits.js → threads/Commits.js} +17 -11
- package/core/{Jobs.js → threads/Jobs.js} +25 -13
- package/core/{Threads.js → threads/Threads.js} +21 -18
- 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} +20 -11
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +28 -21
- package/core/{time.js → time/time.js} +32 -20
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +92 -72
- package/docs/API.md +33 -28
- package/docs/CODEMAP.md +121 -200
- package/docs/COMMANDS.md +77 -70
- package/docs/CONVENTIONS.md +167 -24
- package/docs/MIGRATING-0.8.md +171 -0
- package/docs/MIGRATING-1.0.md +101 -0
- package/docs/THREE.md +140 -38
- 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 +32 -29
- package/docs/api/characters.md +35 -24
- package/docs/api/clock.md +1 -1
- package/docs/api/collider3d.md +9 -0
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +18 -17
- package/docs/api/dialogue.md +5 -4
- package/docs/api/engine.md +58 -54
- package/docs/api/events.md +17 -6
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +6 -7
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +9 -8
- package/docs/api/interactions.md +5 -5
- package/docs/api/inventory.md +10 -10
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +10 -9
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +14 -12
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +10 -7
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +3 -3
- package/docs/api/post.md +21 -5
- package/docs/api/quests.md +7 -5
- package/docs/api/rays.md +7 -7
- package/docs/api/rigid.md +29 -19
- package/docs/api/saves.md +13 -11
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +8 -9
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +6 -8
- package/docs/api/terrainDraw.md +2 -2
- package/docs/api/timeline.md +4 -4
- package/docs/api/tools.md +27 -22
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +2 -2
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +27 -12
- package/docs/api/weatherDraw.md +4 -4
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +28 -43
- package/docs/recipes/02-npc.md +21 -23
- package/docs/recipes/03-items-pickups.md +37 -53
- package/docs/recipes/04-quests.md +5 -4
- package/docs/recipes/05-props-bake.md +34 -44
- package/docs/recipes/06-clock-events.md +31 -22
- package/docs/recipes/07-flow-scenes-pause.md +30 -32
- package/docs/recipes/08-weather-sky.md +91 -37
- package/docs/recipes/09-materials-lights-models.md +25 -39
- package/docs/recipes/10-blender-level.md +22 -11
- package/docs/recipes/11-vehicles.md +44 -24
- package/docs/recipes/12-navmesh.md +60 -15
- package/docs/recipes/13-animation.md +70 -22
- package/docs/recipes/14-custom-module.md +33 -20
- package/docs/recipes/15-perf.md +51 -28
- package/docs/recipes/16-dev-bridge.md +39 -58
- package/docs/recipes/18-world.md +49 -28
- package/docs/recipes/19-shooting-picking.md +7 -4
- package/docs/recipes/20-content-actions-save.md +55 -40
- package/docs/recipes/21-camera.md +47 -25
- package/docs/recipes/22-shop-gold.md +21 -16
- package/docs/recipes/23-ops.md +28 -24
- package/docs/recipes/26-ui-parts.md +25 -14
- package/docs/recipes/27-net.md +3 -5
- package/docs/recipes/28-terrain.md +119 -23
- package/docs/recipes/29-grid.md +3 -3
- package/docs/recipes/30-templates.md +63 -30
- package/docs/recipes/31-audio.md +7 -7
- package/docs/recipes/32-action-game.md +21 -11
- package/docs/recipes/33-stream-sources.md +6 -3
- package/docs/recipes/34-environment-lighting.md +72 -25
- package/docs/recipes/35-picture-from-reference.md +20 -23
- package/docs/recipes/36-ground-plants.md +106 -0
- package/docs/recipes/40-scene.md +18 -21
- package/docs/recipes/43-shader-patches-surfaces.md +27 -48
- package/docs/recipes/44-water-weather-hooks.md +56 -50
- package/docs/recipes/45-cascaded-shadows.md +41 -20
- package/docs/recipes/46-blender-art-route.md +9 -10
- package/docs/recipes/49-game-module-contract.md +7 -6
- package/docs/recipes/50-own-renderer.md +3 -2
- package/docs/recipes/51-capability-catalog.md +14 -8
- package/docs/recipes/52-around-the-picture.md +56 -100
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +17 -20
- package/docs/recipes/56-webgpu-tsl.md +28 -15
- package/docs/recipes/57-control.md +39 -12
- package/docs/recipes/58-input.md +15 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +30 -25
- package/docs/recipes/62-picture-code.md +129 -39
- package/docs/recipes/63-third-person-start.md +19 -5
- package/docs/recipes/64-particles.md +54 -5
- package/docs/recipes/65-swarm.md +140 -0
- package/docs/recipes/66-common-tasks.md +313 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +5 -5
- package/examples/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +15 -14
- 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 +4 -1
- package/examples/rc2d/GAMEMAP.md +4 -3
- package/examples/rc2d/main.js +1 -3
- package/examples/rc2d/rc2d.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +6 -5
- 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 +2 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +9 -7
- package/examples/world/main.js +3 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +16 -12
- package/index.js +53 -32
- package/llms.txt +11 -14
- package/modules/ambience/Ambience.js +16 -11
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +18 -16
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +5 -5
- package/modules/camera/FixedCamera.js +43 -30
- package/modules/camera/FollowCamera.js +24 -15
- package/modules/camera/RtsCamera.js +12 -11
- package/modules/camera/common.js +72 -37
- package/modules/camera/contract.js +1 -0
- package/modules/camera/pixelSnap.js +62 -0
- package/modules/characters/Character.js +166 -70
- package/modules/characters/NPC.js +84 -44
- package/modules/characters/assetModel.js +16 -12
- package/modules/characters/astar.js +48 -27
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/character.contract.js +21 -0
- package/modules/characters/contract.js +17 -3
- package/modules/characters/index.js +240 -226
- package/modules/characters/moveHelpers.js +88 -12
- package/modules/characters/mover.contract.js +14 -0
- package/modules/characters/movers/common.js +22 -18
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +18 -10
- package/modules/characters/movers/simple.js +26 -13
- package/modules/characters/movers/support.js +24 -13
- package/modules/characters/npcAvoid.js +19 -16
- package/modules/characters/npcSim.js +88 -32
- package/modules/characters/npcView.js +19 -11
- package/modules/characters/pathAsync.js +81 -29
- package/modules/characters/pathJob.js +38 -21
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +120 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/seat.js +56 -0
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/vehicle.contract.js +8 -5
- package/modules/characters/walkTo.js +40 -33
- package/modules/collision/Collision.js +69 -45
- package/modules/collision/contract.js +15 -0
- package/modules/collision/grid.js +6 -1
- package/modules/content/explain.js +2 -3
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +5 -3
- package/modules/content/index.js +132 -114
- package/modules/content/loader.js +117 -140
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +54 -17
- package/modules/content/packs.js +5 -4
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +36 -0
- package/modules/content/props.js +22 -17
- package/modules/content/rules.js +47 -61
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +80 -49
- package/modules/content/words.js +47 -0
- package/modules/debug/DebugPanel.js +14 -45
- package/modules/flow/contract.js +2 -1
- package/modules/flow/index.js +30 -16
- package/modules/gameplay/Container.js +17 -13
- package/modules/gameplay/Containers.js +23 -6
- package/modules/gameplay/Dialogue.js +93 -34
- package/modules/gameplay/Interactions.js +93 -51
- package/modules/gameplay/Inventory.js +64 -22
- package/modules/gameplay/Quests.js +146 -30
- package/modules/gameplay/boxOps.js +8 -1
- package/modules/gameplay/dialogueBubbles.js +16 -12
- package/modules/gameplay/inventoryOps.js +11 -8
- package/modules/gameplay/pickups.js +63 -37
- package/modules/gameplay/questLog.js +4 -2
- package/modules/gameplay/questSave.js +9 -4
- package/modules/gameplay/quests.contract.js +1 -1
- package/modules/grid/Grid.js +2 -2
- package/modules/grid/Layer.js +12 -8
- package/modules/grid/index.js +28 -23
- package/modules/grid/ops.js +43 -46
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +42 -57
- package/modules/hud/index.js +22 -14
- package/modules/hud/parts.js +8 -8
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +29 -31
- package/modules/level/index.js +113 -161
- package/modules/level/load.js +196 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +40 -23
- package/modules/lights/index.js +33 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +90 -0
- package/modules/music/Music.js +34 -28
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +16 -0
- package/modules/nav/index.js +180 -49
- package/modules/nav/navPath.js +45 -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 +6 -5
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +95 -29
- package/modules/particles/effect.js +86 -32
- package/modules/particles/shaders.js +19 -1
- package/modules/photo/Photo.js +23 -23
- package/modules/rigid/RigidBodies.js +255 -89
- package/modules/rigid/Vehicles.js +17 -8
- package/modules/rigid/collider3d.contract.js +26 -0
- package/modules/rigid/ragdoll.js +298 -0
- package/modules/rigid/ragdollBones.js +209 -0
- package/modules/rigid/refresh.js +10 -0
- package/modules/rigid/sync.js +51 -20
- package/modules/settings/Settings.js +177 -61
- package/modules/settings/apply.js +20 -13
- package/modules/settings/sections.js +19 -14
- package/modules/settings/strings.js +2 -2
- 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 +17 -28
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +356 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +71 -59
- 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 +42 -42
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +45 -29
- package/modules/terrain/terrainGen.js +19 -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 +83 -43
- package/modules/timeline/Tween.js +25 -19
- package/modules/timeline/shots.js +24 -17
- package/modules/triggers/index.js +95 -28
- package/modules/vegetation/Vegetation.js +34 -26
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +39 -18
- package/modules/vegetation/groundChunks.js +21 -38
- package/modules/vegetation/index.js +37 -12
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +20 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +52 -40
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +28 -23
- package/modules/world/World.js +28 -15
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +30 -17
- package/modules/world/persist.js +90 -27
- package/modules/world/pos.js +5 -5
- package/modules/world/records.js +37 -11
- package/modules/world/sim.js +78 -27
- package/modules/world/simFar.js +2 -2
- package/modules/world/state.js +43 -11
- package/modules/world/thingSource.js +20 -5
- package/modules/world/views.js +27 -14
- package/package.json +48 -7
- package/presets.js +1 -3
- package/render/PostFX.js +83 -53
- package/render/backend.js +31 -33
- 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/particles.tsl.js +8 -6
- package/render/fx/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +30 -26
- 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 +2 -2
- package/render/lighting.js +5 -3
- package/render/lightmap.js +41 -21
- 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 +62 -15
- package/render/ownFrame.js +4 -4
- package/render/patches.js +15 -15
- package/render/postWebGL.js +15 -12
- package/render/probes.js +41 -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 +59 -13
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +336 -202
- package/types/gameplay.d.ts +254 -130
- 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} +8 -16
- 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} +28 -10
- package/types/generated/core/input/inputSeat.d.ts +26 -0
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +17 -3
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +6 -4
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +14 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +62 -18
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +3 -2
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +2 -2
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +22 -18
- 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/Grid.d.ts +1 -0
- 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 +5 -4
- 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 +7 -5
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +14 -16
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +11 -7
- package/types/generated/render/PostFX.d.ts +21 -23
- 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 +47 -15
- package/types/physics.d.ts +150 -73
- package/types/pixel.d.ts +75 -0
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +48 -75
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +13 -5
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +7 -5
- package/core/assetEntry.js +0 -109
- package/core/engineCamera.js +0 -32
- package/core/ground.js +0 -104
- package/core/holds.js +0 -134
- package/core/math.js +0 -48
- package/core/moduleSlots.js +0 -100
- package/core/modules.js +0 -314
- package/core/saveApply.js +0 -210
- package/core/saveValues.js +0 -46
- package/core/session.js +0 -174
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- package/core/view.js +0 -43
- 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/examples/sheepisland/.threedog/content-index.json +0 -1
- package/modules/camera/projection.js +0 -21
- /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/{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
- /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/types/world.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface TerrainEditOptions {
|
|
|
42
42
|
* World outline, terrain({ shape }): ground only where mask > 0, cut along straight lines through the cells where it crosses 0, with walls
|
|
43
43
|
* down the rim (side) and optionally a hanging underside (bottom). Off it engine.surface is -Infinity, engine.ground.has false, slope 0,
|
|
44
44
|
* groundType 'void'; nothing grows there; a fall below voidY emits terrain:void. Without shape the terrain is unchanged.
|
|
45
|
-
* Depth and mask functions are pure like height (they run in workers). See recipes/
|
|
45
|
+
* Depth and mask functions are pure like height (they run in workers). See recipes/28-terrain.md.
|
|
46
46
|
* @example terrain({ height: (x, z, n) => 6 * n.fbm(x * 0.02, z * 0.02), shape: { mask: (x, z) => 40 - Math.hypot(x, z),
|
|
47
47
|
* edge: { noise: 5, size: 14 }, side: { depth: 2, ground: 'cliff' }, bottom: { depth: (x, z, n, m) => 4 + m * 0.6, ground: 'rock' } } })
|
|
48
48
|
*/
|
|
@@ -111,7 +111,7 @@ export interface TerrainConfig {
|
|
|
111
111
|
/**
|
|
112
112
|
* How the ground gets its color: 'smooth' (default) blended per grid point | 'flat' one color and normal per triangle (low poly) |
|
|
113
113
|
* 'texture' per-chunk color map sampled per pixel, so color borders (a river bank) are not confined to triangle edges and the mesh can stay coarse.
|
|
114
|
-
* See recipes/
|
|
114
|
+
* See recipes/53-ground-up-close.md.
|
|
115
115
|
*/
|
|
116
116
|
shading: 'flat' | 'smooth' | 'texture';
|
|
117
117
|
/** Texture shading: color map pixels per chunk edge (default 128, 64 on low-tier devices; independent of `resolution`) */
|
|
@@ -145,6 +145,8 @@ export interface TerrainOptions extends Partial<TerrainConfig> {
|
|
|
145
145
|
density?: number;
|
|
146
146
|
/** true: the signal engine.uniforms.uViewDistance follows the view distance, so a game's fog can read it and fade the far chunk edge out (openWorld() sets true) */
|
|
147
147
|
viewFog?: boolean;
|
|
148
|
+
/** true: do not take the ground slot; compositeGround({ parts: [{ of: 'terrain' }] }) does and reads terrain.ground (so a terrain and a level can both run) */
|
|
149
|
+
part?: boolean;
|
|
148
150
|
/** Ground material (default neutral gray with vertex colors); chunks have position, normal, color and uv = world xz / chunk size. Cloud shadows, season tint and detail are added */
|
|
149
151
|
material?: Material | ((engine: Engine) => Material);
|
|
150
152
|
/** With material: false = draw it exactly as given, no cloud shadow / season / detail patch */
|
|
@@ -221,7 +223,7 @@ export interface TerrainChunk {
|
|
|
221
223
|
/** One species' placement in one chunk: n plants, m = 16 floats per plant (chunk-local matrix), c = 3 colors per plant, ids = stable ids */
|
|
222
224
|
export interface VegetationPlants { n: number; m: Float32Array; c: Float32Array; ids?: Uint32Array; k?: Float32Array }
|
|
223
225
|
|
|
224
|
-
/** engine.terrainDraw: draws the terrain chunks (slot 'terrain-draw'; engine.use(mine, { replaces: 'terrain-draw' }) swaps it) */
|
|
226
|
+
/** engine.terrainDraw: draws the terrain chunks (slot 'terrain-draw'; engine.use(mine, { replaces: 'terrain-draw' }) swaps it) @experimental */
|
|
225
227
|
export interface TerrainDraw {
|
|
226
228
|
/** The ground material every chunk draws with; setting swaps it on every loaded chunk as given (same as engine.terrain.material). Nothing is regenerated, collision is untouched */
|
|
227
229
|
material: Material;
|
|
@@ -235,7 +237,7 @@ export interface TerrainDraw {
|
|
|
235
237
|
meshes: Map<TerrainChunk, { group: Object3D; mesh: Mesh; colorTex: any; colorMat: any }>;
|
|
236
238
|
}
|
|
237
239
|
|
|
238
|
-
/** engine.vegetationDraw: draws the plants (slot 'vegetation-draw'; engine.use(mine, { replaces: 'vegetation-draw' }) swaps it) */
|
|
240
|
+
/** engine.vegetationDraw: draws the plants (slot 'vegetation-draw'; engine.use(mine, { replaces: 'vegetation-draw' }) swaps it) @experimental */
|
|
239
241
|
export interface VegetationDraw {
|
|
240
242
|
/** The InstancedMesh drawing one species in one chunk, null when none */
|
|
241
243
|
mesh(c: TerrainChunk, name: string): InstancedMesh | null;
|
|
@@ -247,8 +249,8 @@ export interface VegetationDraw {
|
|
|
247
249
|
|
|
248
250
|
/** engine.terrain: the terrain data part (chunks, heights, edits, collision); engine.terrainDraw draws it */
|
|
249
251
|
export interface Terrain {
|
|
250
|
-
/** Pure-computation terrain (height, landform) */
|
|
251
|
-
|
|
252
|
+
/** Pure-computation terrain (height, landform), what createTerrain() returns */
|
|
253
|
+
generator: TerrainGen;
|
|
252
254
|
/**
|
|
253
255
|
* The plain three.js material every chunk draws with (null under a draw part that replaced 'terrain-draw'). The neutral one takes direct writes; setting one swaps it on every
|
|
254
256
|
* loaded chunk and draws it as given. Nothing is regenerated, collision is untouched. Chunks carry position, normal, color and uv (world xz / chunk size)
|
|
@@ -265,8 +267,8 @@ export interface Terrain {
|
|
|
265
267
|
* @example engine.terrain.recolor({ colors: { grass: 0x6a8a3a }, biomeColors: { meadow: ['grass'] } });
|
|
266
268
|
*/
|
|
267
269
|
recolor(o?: TerrainRecolor): void;
|
|
268
|
-
/** Chunk edge length (meters) */
|
|
269
|
-
readonly
|
|
270
|
+
/** Chunk edge length (meters), the same value as the chunkSize option and ground.chunkSize */
|
|
271
|
+
readonly chunkSize: number;
|
|
270
272
|
/**
|
|
271
273
|
* terrain({ shape }) only: below this height the player or a moving rigid body has fallen out of the world (one terrain:void per fall).
|
|
272
274
|
* shape.voidY, else 50 m under the lowest island chunk loaded so far; -Infinity without a shape
|
|
@@ -275,21 +277,17 @@ export interface Terrain {
|
|
|
275
277
|
readonly voidY: number;
|
|
276
278
|
/** Loaded chunks: 'cx,cz' → chunk */
|
|
277
279
|
chunks: Map<string, TerrainChunk>;
|
|
278
|
-
/** View distance (in chunks) */
|
|
280
|
+
/** View distance (in chunks). Writing it moves the camera far plane out too, and with viewFog uViewDistance @experimental */
|
|
279
281
|
viewChunks: number;
|
|
280
|
-
/** Vegetation density multiplier */
|
|
282
|
+
/** Vegetation density multiplier. Writing it places plants again on the loaded chunks: it thins plants without a collider, blocking plants stand at every density, so collision does not change */
|
|
281
283
|
density: number;
|
|
282
284
|
/** Time budget (milliseconds) for uploading chunks per frame */
|
|
283
285
|
applyBudgetMs: number;
|
|
284
286
|
/** Statistics (for the debug panel); failed = chunks that failed every try (terrain:chunkFailed) */
|
|
285
287
|
stats: { builtThisFrame: number; applyMs: number; queued: number; failed: number; visible?: number; loaded?: number; instances?: number };
|
|
286
|
-
/** Change the view distance (in chunks); camera far plane and, with viewFog, uViewDistance adjust too */
|
|
287
|
-
setViewChunks(n: number): void;
|
|
288
|
-
/** Change the vegetation density: plants are placed again on the loaded chunks; the ground and its collision stay */
|
|
289
|
-
setDensity(d: number): void;
|
|
290
288
|
/**
|
|
291
289
|
* Draw these chunks: the hooks a draw part that replaces 'terrain-draw' uses. add(c): generated (c.data holds pos / nor / col / uv / tex arrays,
|
|
292
|
-
* c.cx / c.cz the chunk); change(c): an edit rewrote c.data (
|
|
290
|
+
* c.cx / c.cz the chunk); change(c): an edit rewrote c.data (the vertex count can differ on the rim of a shape with diagonal 'adaptive'); remove(c): released; show(c, visible): in view or not.
|
|
293
291
|
* Chunks already loaded are added at once. Returns { remove() } (ctx.track it).
|
|
294
292
|
* @example ctx.track(engine.terrain.view({ add(c) { draw(c) }, remove(c) { undraw(c) } }))
|
|
295
293
|
*/
|
|
@@ -309,8 +307,6 @@ export interface Terrain {
|
|
|
309
307
|
* @experimental
|
|
310
308
|
*/
|
|
311
309
|
edit(position: PositionLike, opts: TerrainEditOptions): { heights: number; cells: number };
|
|
312
|
-
/** Whether the chunks within rings rings (default 1) around position are all loaded */
|
|
313
|
-
isReadyAround(position: PositionLike, opts?: { rings?: number }): boolean;
|
|
314
310
|
}
|
|
315
311
|
|
|
316
312
|
// ======================================================================
|
|
@@ -469,13 +465,13 @@ export interface Vegetation {
|
|
|
469
465
|
define(name: string, opts: VegetationOptions): Species | Promise<Species>;
|
|
470
466
|
get(name: string): Species | undefined;
|
|
471
467
|
list(): Species[];
|
|
472
|
-
isRemoved(species: string, cx: number, cz: number, id: number): boolean;
|
|
468
|
+
/** @experimental */ isRemoved(species: string, cx: number, cz: number, id: number): boolean;
|
|
473
469
|
/**
|
|
474
|
-
* Remove one (chop a tree). regrowSeconds: grows back after this many
|
|
470
|
+
* Remove one (chop a tree). regrowSeconds: grows back after this many calendar seconds, 0 = permanent. The record is saved with the save (save key
|
|
475
471
|
* 'vegetation'). Returns the entry name
|
|
476
472
|
*/
|
|
477
473
|
removeInstance(species: string, cx: number, cz: number, id: number, opts?: { regrowSeconds?: number }): string;
|
|
478
|
-
/** Restore one */
|
|
474
|
+
/** Restore one @experimental */
|
|
479
475
|
restoreInstance(species: string, cx: number, cz: number, id: number): void;
|
|
480
476
|
/** The one nearest to position within radius meters (default 2) (species restricts to one kind), null if none */
|
|
481
477
|
instanceAt(position: PositionLike, opts?: { radius?: number; species?: string | null }): VegetationHit | null;
|
|
@@ -488,9 +484,9 @@ export interface Vegetation {
|
|
|
488
484
|
/** What engine.sky.environment reports */
|
|
489
485
|
export interface SkyEnvironmentInfo { source: string, intensity: number, rotation: number, interval: number, builds: number }
|
|
490
486
|
|
|
491
|
-
/** Parameters of sky({...}). The sky computes signals and draws the dome; lights and fog are the game's
|
|
487
|
+
/** Parameters of sky({...}). The sky computes signals and draws the dome; lights and fog are the game's. Picture values are start values here:
|
|
492
488
|
* after install the numbers are engine.uniforms (write .value), the rest engine.sky fields and calls (keyframes, clouds, layer, replace, backdrop, top, horizon, orbit, dim) */
|
|
493
|
-
export interface SkyOptions extends Pick<SkyPictureOptions, 'clouds' | 'backdrop' | 'keyframes' | 'sunSize' | 'sunGlow' | 'sunBrightness' | '
|
|
489
|
+
export interface SkyOptions extends Pick<SkyPictureOptions, 'clouds' | 'backdrop' | 'keyframes' | 'sunSize' | 'sunGlow' | 'sunBrightness' | 'moonColor' | 'moonBrightness' | 'starDensity' | 'dim'> {
|
|
494
490
|
/**
|
|
495
491
|
* The fixed time of day drawn while no calendar() is installed: 'HH:MM' or 0–1 (0.5 noon), default 0.33 (a sunset arena: sky({ time: '18:30' })).
|
|
496
492
|
* With calendar() the sky draws engine.calendar.timeOfDay and this option throws (start the day with calendar({ time }))
|
|
@@ -522,30 +518,22 @@ export interface SkyPictureOptions {
|
|
|
522
518
|
*/
|
|
523
519
|
keyframes?: SkyKeyframe[];
|
|
524
520
|
/**
|
|
525
|
-
* A flat background color in place of the dome (no gradient, horizon line, sun / moon disk, stars or clouds)
|
|
526
|
-
*
|
|
527
|
-
* fog.color of your own still wins). Leave out for the dome.
|
|
528
|
-
* @example backdrop:
|
|
521
|
+
* A flat background color in place of the dome (no gradient, horizon line, sun / moon disk, stars or clouds).
|
|
522
|
+
* Drawn as written (no tone mapping); a fog asked for in the default horizon color takes it (a
|
|
523
|
+
* fog.color of your own still wins). Leave out for the dome. recipes/08
|
|
524
|
+
* @example backdrop: 0xefebe4
|
|
529
525
|
*/
|
|
530
526
|
backdrop?: ColorLike;
|
|
531
527
|
/** Sharpness exponent of the sun disk, default 900 (about 2 deg); larger = smaller. Not a size in degrees: 10 is ~20 deg, under ~3 the "disk" washes most of the sky toward the sun color */
|
|
532
528
|
sunSize?: number;
|
|
533
529
|
/** Sun glow, default 0.18 */
|
|
534
530
|
sunGlow?: number;
|
|
535
|
-
/** Sun brightness, default 6 */
|
|
531
|
+
/** Sun brightness, default 6 @experimental */
|
|
536
532
|
sunBrightness?: number;
|
|
537
|
-
/**
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
moonBrightness?: number;
|
|
541
|
-
/** North-south tilt of the sun path */
|
|
542
|
-
orbitTilt?: number;
|
|
543
|
-
/** East-west swing of the sun path */
|
|
544
|
-
orbitSway?: number;
|
|
545
|
-
/** Share of the sky grid cells (0-1) that hold a star at night, default 0.0025 (0 = no stars). A probability, not a brightness: near 1 every cell is lit and the upper sky turns into a white sheet. The cell size is starScale */
|
|
533
|
+
/** @experimental */ moonColor?: ColorLike;
|
|
534
|
+
/** @experimental */ moonBrightness?: number;
|
|
535
|
+
/** Share of the sky grid cells (0-1) that hold a star at night, default 0.0025 (0 = no stars). A probability, not a brightness: near 1 every cell is lit and the upper sky turns into a white sheet. */
|
|
546
536
|
starDensity?: number;
|
|
547
|
-
/** Star grid resolution (cells per unit of view direction), default 260: larger means smaller and more numerous stars */
|
|
548
|
-
starScale?: number;
|
|
549
537
|
/**
|
|
550
538
|
* What the sky dims for every game unless the style says no (each default true; false turns that one off, the rest stay). The one place these
|
|
551
539
|
* picture decisions are switched:
|
|
@@ -555,36 +543,24 @@ export interface SkyPictureOptions {
|
|
|
555
543
|
* @example sky({ dim: { stars: false } }) // live: engine.sky.dim.tint = false
|
|
556
544
|
*/
|
|
557
545
|
dim?: { tint?: boolean; stars?: boolean };
|
|
558
|
-
/**
|
|
559
|
-
* Gradient curve from horizon to zenith, default 0.55 (color = mix(horizon, zenith, elevation^curve), mixed in linear light, then tone mapped
|
|
560
|
-
* and exposed like the scene). The keyframe zenith shows only high up: a level camera (55 deg fov) sees the lowest ~25 deg, where a warm
|
|
561
|
-
* horizon and a deep-blue zenith mix to a gray-lavender (desert R4: e8d4a8 / 1858c8 read as #9b99bd at the frame's top). Lower curve = more
|
|
562
|
-
* zenith color near the horizon; or bring the horizon color closer to the zenith hue. toneMapping 'aces' also turns a saturated blue toward
|
|
563
|
-
* violet ('agx' / 'neutral' keep the hue closer). Check with threedog shot
|
|
564
|
-
*/
|
|
565
|
-
gradientCurve?: number;
|
|
566
546
|
/** Clouds in the sky (cloud cover follows the weather); see SkyCloudOptions */
|
|
567
547
|
clouds?: SkyCloudOptions;
|
|
568
|
-
/** Panorama (equirectangular) replacing the gradient sky, asset name or path (at run time engine.sky.replace(name)) */
|
|
569
|
-
skybox?: string;
|
|
570
|
-
/** Extra dome layers drawn after the clouds and stars (rainbow, aurora), default none; see SkyLayerOptions */
|
|
571
|
-
layers?: SkyLayerOptions[];
|
|
572
548
|
}
|
|
573
549
|
|
|
574
550
|
/**
|
|
575
551
|
* One extra sky layer (modules/sky/domeLayers.js)
|
|
576
|
-
* @example
|
|
552
|
+
* @example engine.sky.layer('aurora', { blend: 'add', uniforms: { uAurora: [0.2, 1, 0.6] }, glsl: `vec4 threedogSkyLayer(vec3 d, float time, vec3 sunDir, float night){
|
|
577
553
|
* float band = smoothstep(0.25, 0.45, d.y) * (1.0 - smoothstep(0.55, 0.8, d.y)) * threedogNoise(vec2(d.x * 4.0 + time * 0.05, d.z * 2.0));
|
|
578
|
-
* return vec4(uAurora, band * night); }` }
|
|
554
|
+
* return vec4(uAurora, band * night); }` })
|
|
579
555
|
*/
|
|
580
556
|
export interface SkyLayerOptions {
|
|
581
|
-
/**
|
|
557
|
+
/** Not read: the layer's name is the first argument of engine.sky.layer(name, spec) */
|
|
582
558
|
name?: string;
|
|
583
559
|
/** Defines `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returning (rgb, amount 0..1); renamed per layer, so layers never clash. WebGLRenderer draws it */
|
|
584
560
|
glsl?: string;
|
|
585
561
|
/** WebGPURenderer form: (ctx) => vec4 node (rgb, amount); ctx = { dir, time, sunDir, night, color (sky so far), uniforms, fx: { noise, hash }, tsl } (recipe 52 'tsl forms') */
|
|
586
562
|
tsl?: (ctx: any) => any;
|
|
587
|
-
/** Custom uniforms (numbers, THREE.Color, [x, y(, z, w)], THREE.Texture), live in engine.sky.
|
|
563
|
+
/** Custom uniforms (numbers, THREE.Color, [x, y(, z, w)], THREE.Texture), live in engine.sky.uniforms on both renderers */
|
|
588
564
|
uniforms?: Record<string, any>;
|
|
589
565
|
/** Draw order among the layers, smaller first (default 0) */
|
|
590
566
|
order?: number;
|
|
@@ -676,7 +652,7 @@ export interface MaterialDetail {
|
|
|
676
652
|
export interface CalendarOptions {
|
|
677
653
|
/** Time of day at start: 'HH:MM' or fraction of a day 0–1 (0.5 noon), default 0.33 (afterwards read / write engine.calendar.timeOfDay) */
|
|
678
654
|
time?: string | number;
|
|
679
|
-
/**
|
|
655
|
+
/** Calendar seconds per day, default Infinity: the time of day never moves until the game sets a length (presets.calendar.cycle has 360) (one hour = dayLength / hoursPerDay calendar seconds; with clock.rate 1 calendar seconds are real seconds) */
|
|
680
656
|
dayLength?: number;
|
|
681
657
|
/** Hours per day of the displayed clock and of clock notation ('18:30'), default 24 */
|
|
682
658
|
hoursPerDay?: number;
|
|
@@ -780,7 +756,7 @@ export interface WeatherOptions {
|
|
|
780
756
|
/**
|
|
781
757
|
* Snow cover (weather({ snow: { cover } })): the season tint of foliage / ground (vegetation, terrain, materials with season) moves toward these colors
|
|
782
758
|
* as the weather's snow amount rises, `strength` of the way at full snow, and melts back as it falls. Leave it out and snow only draws particles.
|
|
783
|
-
* The same cover for anything else (ash, frost): engine.mod('ground.cover', { owner: 'ash', value: { ground: 0x555555, amount: 0.6 } }). recipes/
|
|
759
|
+
* The same cover for anything else (ash, frost): engine.mod('ground.cover', { owner: 'ash', value: { ground: 0x555555, amount: 0.6 } }). recipes/44
|
|
784
760
|
* @example cover: { foliage: 0xf2f4f6, ground: 0xeef0f2, strength: 0.8 }
|
|
785
761
|
*/
|
|
786
762
|
export interface SnowCover {
|
|
@@ -792,7 +768,7 @@ export interface SnowCover {
|
|
|
792
768
|
strength?: number;
|
|
793
769
|
}
|
|
794
770
|
|
|
795
|
-
/** Falling weather particles: weather({ rain, snow }) and engine.weather.
|
|
771
|
+
/** Falling weather particles: weather({ rain, snow }) and engine.weather.defineField(field, spec). See recipes/44-water-weather-hooks.md */
|
|
796
772
|
export interface WeatherParticles {
|
|
797
773
|
/** 'line' streaks slant with the wind; 'round' | 'soft' | 'square' sprites drift (sway) */
|
|
798
774
|
shape?: Loose<'line' | 'round' | 'soft' | 'square'>;
|
|
@@ -811,7 +787,7 @@ export interface WeatherParticles {
|
|
|
811
787
|
slant?: number;
|
|
812
788
|
/** Sprite drift (meters) */
|
|
813
789
|
sway?: number;
|
|
814
|
-
/** Particle count (default weather({ particles })
|
|
790
|
+
/** Particle count (default weather({ particles }), else 6000, 3000 on low-tier devices; a number the game gives stands) */
|
|
815
791
|
count?: number;
|
|
816
792
|
/** Weather amount 0..1 -> share of particles drawn (rain default a => min(1, a * 1.2), snow () => 1; opacity follows the amount too) */
|
|
817
793
|
density?: (amount: number) => number;
|
|
@@ -822,7 +798,7 @@ export interface WeatherParticles {
|
|
|
822
798
|
glsl?: { vertex?: string; fragment?: string };
|
|
823
799
|
/** Uniforms for your glsl: numbers, colors, [x, y(, z, w)] arrays, textures; live in engine.weather.particles[field].uniforms */
|
|
824
800
|
uniforms?: Record<string, any>;
|
|
825
|
-
/** A system of your own instead (engine.weather.
|
|
801
|
+
/** A system of your own instead (engine.weather.defineField only): the engine adds object, shows it while the amount is above 0.02, calls update */
|
|
826
802
|
create?: (engine: Engine, ctx: { area: number; count: number }) => {
|
|
827
803
|
object: Object3D; update?: (amount: number, ctx: { camera: any; time: number; wind: number }) => void };
|
|
828
804
|
}
|
|
@@ -857,8 +833,16 @@ export type { WeatherDraw };
|
|
|
857
833
|
* rectangle
|
|
858
834
|
*/
|
|
859
835
|
export interface WaterBodyOptions {
|
|
860
|
-
position
|
|
861
|
-
level
|
|
836
|
+
position?: PositionLike;
|
|
837
|
+
level?: number;
|
|
838
|
+
/** Your own water (the engine draws nothing): level at (x, z) for a body at height y, or null where this body has none */
|
|
839
|
+
query?: (x: number, z: number, y?: number) => number | null;
|
|
840
|
+
/** Box3-like { min, max } that lets waterAt skip the query outside it */
|
|
841
|
+
bounds?: { min: { x: number; y: number; z: number }; max: { x: number; y: number; z: number } };
|
|
842
|
+
/** The mesh you draw for it (kept for reference; add it to the scene yourself) */
|
|
843
|
+
mesh?: Object3D;
|
|
844
|
+
/** A plain volume with contains({ x, y, z }); with level it is water inside the volume */
|
|
845
|
+
volume?: { contains(p: { x: number; y: number; z: number }): boolean; bounds?: WaterBodyOptions['bounds'] };
|
|
862
846
|
radius?: number;
|
|
863
847
|
halfWidth?: number;
|
|
864
848
|
halfDepth?: number;
|
|
@@ -996,7 +980,7 @@ export interface LightPoolOptions {
|
|
|
996
980
|
}
|
|
997
981
|
/** Options of lightPool.add(position, opts): one light source (a torch, lamp, campfire, muzzle flash...) */
|
|
998
982
|
export interface LightSourceOptions {
|
|
999
|
-
/** Name shown in
|
|
983
|
+
/** Name shown in describe().lightPool */
|
|
1000
984
|
name?: string;
|
|
1001
985
|
/** 'point' (default) or 'spot' (needs lightPool({ spot: n })) */
|
|
1002
986
|
type?: 'point' | 'spot';
|
|
@@ -1059,15 +1043,6 @@ export interface LightSource {
|
|
|
1059
1043
|
/** Unregister: its light fades out and moves on, the stand-in is put back (safe to call twice) */
|
|
1060
1044
|
remove(): void;
|
|
1061
1045
|
}
|
|
1062
|
-
/** lightPool.usage(): what the pool is doing now */
|
|
1063
|
-
export interface LightPoolUsage {
|
|
1064
|
-
/** Registered sources */
|
|
1065
|
-
sources: number;
|
|
1066
|
-
/** Real lights lighting a source now */
|
|
1067
|
-
lit: number;
|
|
1068
|
-
/** One per real light: its kind, whether it casts shadows, the source it holds (name or number, null = idle) and its fade 0-1 */
|
|
1069
|
-
slots: { type: 'point' | 'spot'; shadow: boolean; source: string | number | null; weight: number }[];
|
|
1070
|
-
}
|
|
1071
1046
|
/** engine.lightPool: register any number of light sources; a fixed set of real lights moves to the most relevant ones */
|
|
1072
1047
|
export interface LightPool {
|
|
1073
1048
|
/** The real three.js lights, created once at install and never added, removed or hidden (the pool sets their position, color, intensity) */
|
|
@@ -1081,8 +1056,6 @@ export interface LightPool {
|
|
|
1081
1056
|
* torch.set({ intensity: 0 }); // put out: its light goes to another torch
|
|
1082
1057
|
*/
|
|
1083
1058
|
add(position: PositionLike, opts?: LightSourceOptions): LightSource;
|
|
1084
|
-
/** What the pool is doing now (also in describe().lightPool) */
|
|
1085
|
-
usage(): LightPoolUsage;
|
|
1086
1059
|
}
|
|
1087
1060
|
|
|
1088
1061
|
// ======================================================================
|
|
@@ -1134,8 +1107,8 @@ export interface BudgetOver { category: string; value: number; limit: number; to
|
|
|
1134
1107
|
export interface BudgetTagStat { tag: string; drawCalls: number; triangles: number }
|
|
1135
1108
|
/** Budget report: ok means everything is within budget */
|
|
1136
1109
|
export interface BudgetReport { ok: boolean; over: BudgetOver[] }
|
|
1137
|
-
// Budget (engine.budget) is generated from the JSDoc in core/Budget.js (npm run map); only the types are re-exported here
|
|
1138
|
-
import type { Budget } from './generated/core/Budget';
|
|
1110
|
+
// Budget (engine.budget) is generated from the JSDoc in core/inspect/Budget.js (npm run map); only the types are re-exported here
|
|
1111
|
+
import type { Budget } from './generated/core/inspect/Budget';
|
|
1139
1112
|
export type { Budget };
|
|
1140
1113
|
|
|
1141
1114
|
export type TerrainModule = ModuleDef<Terrain>;
|
package/ui/Focus.js
CHANGED
|
@@ -21,6 +21,7 @@ const stacks = new WeakMap(); // engine -> UI focus stack
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
|
|
24
|
+
* @experimental the stable route for a screen of your own is engine.input.push (recipes/07-flow-scenes-pause.md)
|
|
24
25
|
* @param {Engine} engine
|
|
25
26
|
* @returns {UIFocus}
|
|
26
27
|
*/
|
|
@@ -28,7 +29,8 @@ export function uiFocus(engine) {
|
|
|
28
29
|
let f = stacks.get(engine);
|
|
29
30
|
if (f) return f;
|
|
30
31
|
const entries = [], stick = { key: '', t: 0 };
|
|
31
|
-
let
|
|
32
|
+
let root = null;
|
|
33
|
+
const frame = () => engine.input.frameCount;
|
|
32
34
|
// One place for every window, menu and choice list: under a lock the cursor is gone and a click lands on the canvas. The engine's own release, so it is not read as Esc
|
|
33
35
|
const freeMouse = () => engine.page.releaseLock();
|
|
34
36
|
f = {
|
|
@@ -38,9 +40,9 @@ export function uiFocus(engine) {
|
|
|
38
40
|
/** Push: { cancel, nav }. Returns a handle { id, fresh, index, consumed, setNav(nav), remove() } */
|
|
39
41
|
push(id, { cancel = null, nav = null } = {}) {
|
|
40
42
|
const h = {
|
|
41
|
-
id, cancel, nav, index: null, at: frame, used: -1,
|
|
42
|
-
get fresh() { return h.at === frame; },
|
|
43
|
-
get consumed() { return h.used === frame; },
|
|
43
|
+
id, cancel, nav, index: null, at: frame(), used: -1,
|
|
44
|
+
get fresh() { return h.at === frame(); },
|
|
45
|
+
get consumed() { return h.used === frame(); },
|
|
44
46
|
setNav(n) { forgetNav(h); h.nav = n; h.index = null; if (n) freeMouse(); },
|
|
45
47
|
remove() { forgetNav(h); const i = entries.indexOf(h); if (i >= 0) entries.splice(i, 1); },
|
|
46
48
|
};
|
|
@@ -51,18 +53,17 @@ export function uiFocus(engine) {
|
|
|
51
53
|
/** Who gets the back key when the stack is empty (only one; a later registration replaces the earlier) */
|
|
52
54
|
setRoot(fn) { root = fn; return { remove: () => { if (root === fn) root = null; } }; },
|
|
53
55
|
};
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
+
// Each frame (the onFrame callback runs before module frame hooks): the back key dispatches once, and
|
|
57
|
+
// the cursor of the top entry moves / presses (before the dialogue's own confirm check, which reads h.consumed)
|
|
56
58
|
f.hook = engine.onFrame(dt => {
|
|
57
|
-
frame++;
|
|
58
59
|
const top = entries.at(-1);
|
|
59
|
-
if (top?.nav && stepCursor(engine, top, stick, dt)) top.used = frame;
|
|
60
|
+
if (top?.nav && stepCursor(engine, top, stick, dt)) top.used = frame();
|
|
60
61
|
if (!engine.input.pressedRaw('cancel')) return;
|
|
61
62
|
if (entries.at(-1)) entries.at(-1).cancel?.();
|
|
62
63
|
else root?.();
|
|
63
64
|
});
|
|
64
65
|
// Esc under pointer lock never reaches the page: the browser keeps the key and ends the lock, so the first Esc of a mouse-look game would pause nothing.
|
|
65
|
-
// Only the empty stack in running play. A game ending the lock itself (engine.page.releaseLock(), or document.exitPointerLock(): core/page.js marks both as byEngine)
|
|
66
|
+
// Only the empty stack in running play. A game ending the lock itself (engine.page.releaseLock(), or document.exitPointerLock(): core/engine/page.js marks both as byEngine)
|
|
66
67
|
// to show its own window or screen must not have it closed or covered.
|
|
67
68
|
f.unlock = engine.events.on('page:pointerlock', ({ locked, byEngine }) => {
|
|
68
69
|
if (!locked && !byEngine && !entries.length && !engine.page.away && engine.runState.state === 'running') root?.();
|
package/ui/Parts.js
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
// The same option holds the picture of every default part: createEngine({ ui: { theme: { bg, accent }, css, fonts, templates, toast: false } }) (ui/theme.js).
|
|
15
15
|
// Names and the data each part receives are listed in `engine.ui.describe()` and in recipes/26-ui-parts.md.
|
|
16
16
|
import { uiFocus } from './Focus.js';
|
|
17
|
-
import { codedError } from '../core/errorHints.js';
|
|
17
|
+
import { codedError } from '../core/base/errorHints.js';
|
|
18
|
+
import { fmt } from '../core/base/validate.js';
|
|
18
19
|
/** @import { Engine } from '../types/core' */
|
|
19
20
|
/** @import { UIPart, UIPartFactory, UIPartValue, UIPartDef } from '../types/core' */
|
|
20
21
|
|
|
@@ -27,7 +28,6 @@ const DEV = {
|
|
|
27
28
|
unknown: "engine.ui.set('{name}'): no UI part has that name. Known parts: {known}. (A module's parts exist only after engine.use(module).)",
|
|
28
29
|
notModal: "engine.ui.open('{name}'): only full-screen parts can be opened ({known}).",
|
|
29
30
|
};
|
|
30
|
-
const fmt = (s, p) => s.replace(/\{(\w+)\}/g, (_, k) => p[k]);
|
|
31
31
|
const kind = v => v === null ? 'null' : Array.isArray(v) ? 'array' : typeof v;
|
|
32
32
|
|
|
33
33
|
/** @internal Fill missing verbs with no-ops so callers never write ?. */
|
|
@@ -79,11 +79,18 @@ export class UIParts {
|
|
|
79
79
|
* @param {string} name
|
|
80
80
|
* @param {UIPartFactory} factory default implementation (engine, options) => part
|
|
81
81
|
* @param {UIPartDef} [def] on: shown unless the game asks (default true); multi: one part per item (markers, counters); modal: full-screen, opened with ui.open
|
|
82
|
-
* @returns {void}
|
|
82
|
+
* @returns {{ remove(): void }} remove() closes the part, disposes its live copy and takes the definition out (what a module's ctx.ui.define does when it leaves)
|
|
83
83
|
* @example engine.ui.define('hud.ammo', (e, o) => ({ update: d => {...} }), { multi: true })
|
|
84
84
|
*/
|
|
85
85
|
define(name, factory, { on = true, multi = false, modal = null } = {}) {
|
|
86
|
-
|
|
86
|
+
const d = { factory, on, multi, modal };
|
|
87
|
+
this.defs.set(name, d);
|
|
88
|
+
return { remove: () => {
|
|
89
|
+
if (this.defs.get(name) !== d) return;
|
|
90
|
+
this.close(name);
|
|
91
|
+
this.live.get(name)?.dispose?.();
|
|
92
|
+
this.live.delete(name); this.defs.delete(name);
|
|
93
|
+
} };
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
/**
|
|
@@ -163,13 +170,14 @@ export class UIParts {
|
|
|
163
170
|
if (!p) return false;
|
|
164
171
|
if (this.opened.has(name)) return true;
|
|
165
172
|
const e = this.engine, m = d.modal;
|
|
173
|
+
const shown = { ...m.data?.(e, this._resolve(name).options), ...data }; // before the holds below: a title list that throws must not leave the game frozen behind nothing
|
|
166
174
|
// Each modal part owns its own freeze ('ui-<name>') and its own input context, so closing help releases only help's hold, never a player pause or another part's.
|
|
167
175
|
// m.freeze may be a function (inventory: pauseGame is switchable at runtime)
|
|
168
176
|
// a string names the freeze kind engine.runState reads ('title' = waiting for start), so core never matches part names
|
|
169
177
|
const fr = typeof m.freeze === 'function' ? m.freeze(e) : m.freeze;
|
|
170
178
|
const freeze = fr ? e.freeze('ui-' + name, { kind: typeof fr === 'string' ? fr : undefined }) : null;
|
|
171
179
|
this.opened.set(name, { freeze, focus: uiFocus(e).push('ui-' + name, { cancel: m.cancel ? () => m.cancel(e) : null, nav: () => p.el ?? null }), ctx: e.input.push('ui-' + name) }); // own opaque context: gameplay actions stop responding
|
|
172
|
-
p.show(
|
|
180
|
+
try { p.show(shown); } catch (err) { this.close(name); throw err; }
|
|
173
181
|
e.events.emit('ui:open', name);
|
|
174
182
|
return true;
|
|
175
183
|
}
|
package/ui/UI.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Every window and component uses classes (no inline styles), so option 2 always takes effect.
|
|
7
7
|
import * as THREE from 'three';
|
|
8
|
-
import { vec3 } from '../core/math.js';
|
|
8
|
+
import { vec3 } from '../core/base/math.js';
|
|
9
9
|
import { uiFocus } from './Focus.js';
|
|
10
10
|
import { injectUICSS } from './theme.js';
|
|
11
|
-
import { codedError } from '../core/errorHints.js';
|
|
12
|
-
import { uiAfter } from '../core/uiClock.js';
|
|
13
|
-
import { readParams, keysSchema } from '../core/params.js';
|
|
11
|
+
import { codedError } from '../core/base/errorHints.js';
|
|
12
|
+
import { uiAfter } from '../core/time/uiClock.js';
|
|
13
|
+
import { readParams, keysSchema } from '../core/base/params.js';
|
|
14
14
|
const FADE_SCREEN_KEYS = ['seconds'];
|
|
15
15
|
/** @import { Engine } from '../types/core' */
|
|
16
16
|
/** @import { PositionLike, Object3D } from '../types/common' */
|
|
@@ -19,7 +19,6 @@ export { uiFocus, injectUICSS };
|
|
|
19
19
|
|
|
20
20
|
/** @internal */
|
|
21
21
|
export function esc(s) { return String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); }
|
|
22
|
-
/** Icon: def.iconUrl is an image, def.icon is text/emoji */
|
|
23
22
|
/** @internal icon markup of an item / thing definition (image when it has iconUrl, else its icon text) */
|
|
24
23
|
export const iconHTML = def => def?.iconUrl ? `<img src="${esc(def.iconUrl)}" alt="">` : esc(def?.icon ?? '·');
|
|
25
24
|
|
|
@@ -50,7 +49,7 @@ export function toastPart(engine) {
|
|
|
50
49
|
show({ text, ms = 2600 }) {
|
|
51
50
|
if (!box) { box = document.createElement('div'); box.className = 'threedog-ui threedog-toasts'; engine.uiRoot.appendChild(box); }
|
|
52
51
|
const t = document.createElement('div'); t.className = 'threedog-toast'; t.textContent = text; box.appendChild(t);
|
|
53
|
-
// the page's own time (core/uiClock.js): wall clock in the game, so it goes away while gameplay is paused; the stepped time on a headless
|
|
52
|
+
// the page's own time (core/time/uiClock.js): wall clock in the game, so it goes away while gameplay is paused; the stepped time on a headless
|
|
54
53
|
// page. The 400 ms is the CSS fade; removal is on the same clock, so a stepped page never captures a half-faded message
|
|
55
54
|
uiAfter(engine, ms, () => { t.style.opacity = '0'; });
|
|
56
55
|
uiAfter(engine, ms + 400, () => t.remove());
|
|
@@ -106,6 +105,7 @@ export function makeWindow(engine, opts) {
|
|
|
106
105
|
* @param {{ open: boolean, toggle(on?: boolean): void }} win a makeWindow window or any handle with open / toggle
|
|
107
106
|
* @param {string} action
|
|
108
107
|
* @returns {void}
|
|
108
|
+
* @experimental
|
|
109
109
|
*/
|
|
110
110
|
export function toggleOnKey(engine, win, action) {
|
|
111
111
|
const inp = engine.input;
|
|
@@ -143,7 +143,7 @@ export function placeAt(el, x, y) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
const fades = new WeakMap(); // engine → { el, value, from, to, t, d, done }
|
|
146
|
-
// color --threedog-fade-bg. Follows engine frames (step() advances it too; stops while
|
|
146
|
+
// color --threedog-fade-bg. Follows engine frames (step() advances it too; stops while the loop is halted). A new fade interrupts the old (the old Promise resolves at once).
|
|
147
147
|
// Scene transitions use engine.flow.transition and cutscenes use the timeline's { fade: seconds, to } step; both go through here.
|
|
148
148
|
/**
|
|
149
149
|
* Fade the whole screen to `to` (0 clear ... 1 fully covered) over `seconds` (default 0.5); the Promise resolves when the fade ends.
|
package/ui/defaults.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { injectUICSS, toastPart, esc } from './UI.js';
|
|
4
4
|
import { loadingScreen } from './LoadingScreen.js';
|
|
5
5
|
import { touchPart } from './touchPart.js';
|
|
6
|
-
import { codedError } from '../core/errorHints.js';
|
|
6
|
+
import { codedError } from '../core/base/errorHints.js';
|
|
7
|
+
import { fmt } from '../core/base/validate.js';
|
|
7
8
|
/** @import { Engine, UIPart, UITitleItem } from '../types/core' */
|
|
8
9
|
|
|
9
10
|
const STRINGS = {
|
|
@@ -40,7 +41,7 @@ function titleItems(e, items) {
|
|
|
40
41
|
if (typeof it === 'string' && BUILTIN[it]) { const b = BUILTIN[it]; if (!b.when || b.when(e)) out.push({ id: it, label: e.t('title.' + it), run: () => b.run(e) }); }
|
|
41
42
|
else if (typeof it === 'string' && e.ui.titleItems.has(it)) out.push(own(e, { id: it, ...e.ui.titleItems.get(it) }));
|
|
42
43
|
else if (it && typeof it.run === 'function') out.push(own(e, it));
|
|
43
|
-
else throw codedError('ui-misuse', DEV.badItem
|
|
44
|
+
else throw codedError('ui-misuse', fmt(DEV.badItem, { added: [...e.ui.titleItems.keys()].join(', ') || 'none', got: String(JSON.stringify(it)) }));
|
|
44
45
|
}
|
|
45
46
|
return out;
|
|
46
47
|
}
|
package/ui/theme.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { codedError } from '../core/errorHints.js';
|
|
1
|
+
import { coded, codedError } from '../core/base/errorHints.js';
|
|
2
|
+
import { DEV, warnOnce } from '../core/base/validate.js';
|
|
3
|
+
import { isObject } from '../core/base/util.js';
|
|
2
4
|
// UI theme and default CSS in <head> (part of ui/UI.js): the --threedog-* variables from createEngine({ ui: { theme } }), the engine's base classes, module
|
|
3
5
|
// defaults, the game's css. The classes use only var(--threedog-*), never a color of their own.
|
|
4
6
|
/** @import { UIOptions } from '../types/core' */
|
|
@@ -15,7 +17,7 @@ const DEFAULT_UI = {
|
|
|
15
17
|
const BASE_CSS = `
|
|
16
18
|
:where(.threedog-root > *){pointer-events:auto}
|
|
17
19
|
.threedog-ui{font:14px/1.55 var(--threedog-font);color:var(--threedog-fg)}
|
|
18
|
-
.threedog-win{box-sizing:border-box;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:min(480px,calc(100% - 32px));
|
|
20
|
+
.threedog-win{box-sizing:border-box;overflow-wrap:anywhere;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:min(480px,calc(100% - 32px));
|
|
19
21
|
max-height:min(70%,560px);overflow:auto;
|
|
20
22
|
background:var(--threedog-bg);border:1px solid var(--threedog-line);border-radius:var(--threedog-radius);padding:16px 18px;z-index:25;
|
|
21
23
|
box-shadow:var(--threedog-shadow)}
|
|
@@ -43,7 +45,7 @@ const BASE_CSS = `
|
|
|
43
45
|
.threedog-prompt{position:fixed;left:0;top:0;transform:translate(-50%,-100%);padding:6px 10px;border-radius:var(--threedog-radius-small);background:var(--threedog-bg);
|
|
44
46
|
color:var(--threedog-fg);font:13px var(--threedog-font);cursor:pointer;z-index:15;white-space:nowrap}
|
|
45
47
|
.threedog-prompt-hold{background:linear-gradient(90deg,var(--threedog-accent) calc(var(--progress,0)*100%),var(--threedog-bg) 0)}
|
|
46
|
-
.threedog-dlg{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(24px + env(safe-area-inset-bottom,0px));
|
|
48
|
+
.threedog-dlg{box-sizing:border-box;overflow-wrap:anywhere;position:fixed;left:50%;transform:translateX(-50%);bottom:calc(24px + env(safe-area-inset-bottom,0px));
|
|
47
49
|
width:min(640px,calc(100% - 32px));
|
|
48
50
|
background:var(--threedog-bg);color:var(--threedog-fg);border:1px solid var(--threedog-line);border-radius:var(--threedog-radius);
|
|
49
51
|
padding:14px 18px 16px;font:15px/1.6 var(--threedog-font);z-index:20;cursor:pointer}
|
|
@@ -121,9 +123,9 @@ export function applyUITheme(engine, ui = {}) {
|
|
|
121
123
|
// The picture keys sit beside the part names in createEngine({ ui }), so a wrong shape would otherwise do nothing or reach a part: refuse it with the right form.
|
|
122
124
|
/** @param {UIOptions} ui */
|
|
123
125
|
function checkUiOptions({ theme, css, fonts, templates }) {
|
|
124
|
-
const plain = v => v == null || (
|
|
126
|
+
const plain = v => v == null || isObject(v);
|
|
125
127
|
if (!plain(theme)) throw codedError('ui-misuse', `ui.theme is an object of CSS values, got ${JSON.stringify(theme)}. Example: ui: { theme: { bg: '#1c140e', accent: '#e8a13a' } }`);
|
|
126
|
-
if (theme?.promptHeight != null)
|
|
128
|
+
if (DEV && theme?.promptHeight != null) warnOnce(coded('ui-misuse', `ui.theme.promptHeight moves nothing: the interaction prompt's height is interactions({ promptHeight: ${theme.promptHeight} })`));
|
|
127
129
|
if (css != null && typeof css !== 'string') throw codedError('ui-misuse', `ui.css is CSS text placed after every default, got ${typeof css}`);
|
|
128
130
|
if (!plain(templates)) throw codedError('ui-misuse', 'ui.templates is { windowName: (data, { esc, t, icon }) => html }');
|
|
129
131
|
// a font file is an asset, so the game names it here: a path would load nothing
|