threedog 0.0.0-stage → 0.2.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 +5 -0
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/core/Animator.js +268 -0
- package/core/Assets.js +256 -0
- package/core/Audio.js +267 -0
- package/core/Baked.js +72 -0
- package/core/Batching.js +247 -0
- package/core/Budget.js +221 -0
- package/core/Clock.js +94 -0
- package/core/Commits.js +77 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +145 -0
- package/core/Engine.js +184 -0
- package/core/Events.js +153 -0
- package/core/I18n.js +94 -0
- package/core/Input.js +245 -0
- package/core/Inspect.js +77 -0
- package/core/InspectScene.js +191 -0
- package/core/Jobs.js +146 -0
- package/core/Loading.js +149 -0
- package/core/MaterialInfo.js +32 -0
- package/core/Ops.js +256 -0
- package/core/Random.js +52 -0
- package/core/Rays.js +160 -0
- package/core/SaveStore.js +85 -0
- package/core/Saves.js +254 -0
- package/core/Stream.js +279 -0
- package/core/Threads.js +158 -0
- package/core/UrlState.js +94 -0
- package/core/Vars.js +35 -0
- package/core/Views.js +49 -0
- package/core/actor.js +23 -0
- package/core/assetEntry.js +89 -0
- package/core/assetLoad.js +190 -0
- package/core/assetManifest.js +35 -0
- package/core/assetReport.js +83 -0
- package/core/audioRules.js +121 -0
- package/core/audioVoice.js +225 -0
- package/core/batchGroups.js +116 -0
- package/core/canvasBox.js +63 -0
- package/core/catalog.js +169 -0
- package/core/checks.js +67 -0
- package/core/claims.js +51 -0
- package/core/dayTime.js +15 -0
- package/core/debugView.js +76 -0
- package/core/describeRender.js +45 -0
- package/core/describeText.js +143 -0
- package/core/easing.js +34 -0
- package/core/errorCodes.js +205 -0
- package/core/errorHints.js +208 -0
- package/core/errors.js +40 -0
- package/core/events.generated.js +84 -0
- package/core/ground.js +102 -0
- package/core/holds.js +106 -0
- package/core/inputContext.js +69 -0
- package/core/inputDefaults.js +22 -0
- package/core/inputPad.js +35 -0
- package/core/inputPointer.js +48 -0
- package/core/inputTouch.js +48 -0
- package/core/lifecycle.js +69 -0
- package/core/lightWatch.js +56 -0
- package/core/look/coreParts.js +112 -0
- package/core/look/layers.js +136 -0
- package/core/look/part.js +173 -0
- package/core/look/report.js +79 -0
- package/core/look/write.js +86 -0
- package/core/loop.js +200 -0
- package/core/math.js +33 -0
- package/core/modules.js +196 -0
- package/core/movement.js +19 -0
- package/core/mulberry32.js +14 -0
- package/core/opsAtomic.js +31 -0
- package/core/opsCheck.js +97 -0
- package/core/opsFail.js +20 -0
- package/core/opsGuard.js +26 -0
- package/core/opsHistory.js +27 -0
- package/core/opsRun.js +77 -0
- package/core/page.js +78 -0
- package/core/params.js +132 -0
- package/core/pureWorker.js +5 -0
- package/core/renamed.js +21 -0
- package/core/saveApply.js +128 -0
- package/core/saveFiles.js +139 -0
- package/core/saveIds.js +53 -0
- package/core/saveVersions.js +97 -0
- package/core/scatter.js +92 -0
- package/core/sceneMethods.js +100 -0
- package/core/screenToGround.js +39 -0
- package/core/services.js +73 -0
- package/core/session.js +171 -0
- package/core/shadowTypes.js +15 -0
- package/core/skip.js +104 -0
- package/core/startup.js +135 -0
- package/core/streamCells.js +24 -0
- package/core/streamSources.js +73 -0
- package/core/styleParts.js +96 -0
- package/core/targeting.js +64 -0
- package/core/thingExplain.js +68 -0
- package/core/thingOps.js +168 -0
- package/core/things.js +212 -0
- package/core/threadPure.js +120 -0
- package/core/threadServe.js +25 -0
- package/core/tier.js +11 -0
- package/core/util.js +11 -0
- package/core/validate.js +204 -0
- package/docs/AI.md +123 -0
- package/docs/API.md +83 -0
- package/docs/CODEMAP.md +347 -0
- package/docs/COMMANDS.md +108 -0
- package/docs/CONVENTIONS.md +145 -0
- package/docs/PERF.md +217 -0
- package/docs/THREE.md +86 -0
- package/docs/api/ambience.md +15 -0
- package/docs/api/assets.md +62 -0
- package/docs/api/audio.md +53 -0
- package/docs/api/budget.md +40 -0
- package/docs/api/cameraRig.md +120 -0
- package/docs/api/characters.md +144 -0
- package/docs/api/clock.md +7 -0
- package/docs/api/collision.md +39 -0
- package/docs/api/content.md +64 -0
- package/docs/api/dialogue.md +39 -0
- package/docs/api/engine.md +199 -0
- package/docs/api/entities.md +61 -0
- package/docs/api/events.md +95 -0
- package/docs/api/flow.md +27 -0
- package/docs/api/grids.md +11 -0
- package/docs/api/ground.md +16 -0
- package/docs/api/hlod.md +34 -0
- package/docs/api/hud.md +31 -0
- package/docs/api/i18n.md +10 -0
- package/docs/api/input.md +24 -0
- package/docs/api/interactions.md +31 -0
- package/docs/api/inventory.md +66 -0
- package/docs/api/jobs.md +10 -0
- package/docs/api/level.md +41 -0
- package/docs/api/lightPool.md +56 -0
- package/docs/api/music.md +34 -0
- package/docs/api/nav.md +26 -0
- package/docs/api/net.md +14 -0
- package/docs/api/openWorld.md +24 -0
- package/docs/api/particles.md +41 -0
- package/docs/api/photo.md +15 -0
- package/docs/api/post.md +10 -0
- package/docs/api/quests.md +36 -0
- package/docs/api/rays.md +26 -0
- package/docs/api/rigid.md +84 -0
- package/docs/api/saves.md +32 -0
- package/docs/api/settings.md +36 -0
- package/docs/api/sky.md +58 -0
- package/docs/api/stream.md +31 -0
- package/docs/api/style.md +134 -0
- package/docs/api/terrain.md +34 -0
- package/docs/api/timeline.md +39 -0
- package/docs/api/tools.md +57 -0
- package/docs/api/triggers.md +56 -0
- package/docs/api/vars.md +9 -0
- package/docs/api/vegetation.md +52 -0
- package/docs/api/water.md +48 -0
- package/docs/api/weather.md +29 -0
- package/docs/api/world.md +30 -0
- package/docs/recipes/01-new-game.md +148 -0
- package/docs/recipes/02-npc.md +167 -0
- package/docs/recipes/03-items-pickups.md +158 -0
- package/docs/recipes/04-quests.md +83 -0
- package/docs/recipes/05-props-bake.md +159 -0
- package/docs/recipes/06-clock-events.md +117 -0
- package/docs/recipes/07-flow-scenes-pause.md +132 -0
- package/docs/recipes/08-weather-sky.md +74 -0
- package/docs/recipes/09-style-pack.md +234 -0
- package/docs/recipes/10-blender-level.md +67 -0
- package/docs/recipes/11-vehicles.md +55 -0
- package/docs/recipes/12-navmesh.md +79 -0
- package/docs/recipes/13-animation.md +149 -0
- package/docs/recipes/14-custom-module.md +91 -0
- package/docs/recipes/15-perf.md +78 -0
- package/docs/recipes/16-dev-bridge.md +180 -0
- package/docs/recipes/18-world.md +185 -0
- package/docs/recipes/19-shooting-picking.md +76 -0
- package/docs/recipes/20-content-actions-save.md +176 -0
- package/docs/recipes/21-camera.md +153 -0
- package/docs/recipes/22-shop-gold.md +107 -0
- package/docs/recipes/23-ops.md +175 -0
- package/docs/recipes/26-ui-parts.md +138 -0
- package/docs/recipes/27-net.md +96 -0
- package/docs/recipes/28-terrain.md +80 -0
- package/docs/recipes/29-grid.md +87 -0
- package/docs/recipes/30-templates.md +131 -0
- package/docs/recipes/31-audio.md +126 -0
- package/docs/recipes/32-action-game.md +33 -0
- package/docs/recipes/33-stream-sources.md +37 -0
- package/docs/recipes/34-environment-lighting.md +36 -0
- package/docs/recipes/35-style-from-reference.md +89 -0
- package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
- package/docs/recipes/37-terrain-look-hooks.md +97 -0
- package/docs/recipes/38-environment-look-hooks.md +83 -0
- package/docs/recipes/40-scene.md +108 -0
- package/docs/recipes/41-thing-registry.md +93 -0
- package/docs/recipes/42-terrain-shape.md +64 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +120 -0
- package/docs/recipes/44-water-weather-look-hooks.md +135 -0
- package/docs/recipes/45-cascaded-shadows.md +51 -0
- package/docs/recipes/46-blender-art-route.md +114 -0
- package/docs/recipes/47-island-snow-backdrop.md +44 -0
- package/docs/recipes/48-make-material.md +70 -0
- package/docs/recipes/49-game-module-contract.md +71 -0
- package/docs/recipes/50-own-renderer.md +12 -0
- package/docs/recipes/51-capability-catalog.md +63 -0
- package/docs/recipes/52-look.md +108 -0
- package/examples/action/DESIGN.md +3 -0
- package/examples/action/GAMEMAP.md +127 -0
- package/examples/action/content/actions.js +8 -0
- package/examples/action/content/audio.js +9 -0
- package/examples/action/content/index.js +10 -0
- package/examples/action/content/items.js +4 -0
- package/examples/action/content/places.js +4 -0
- package/examples/action/content/props.js +11 -0
- package/examples/action/content/templates.js +10 -0
- package/examples/action/content/views.js +6 -0
- package/examples/action/look.js +5 -0
- package/examples/action/main.js +137 -0
- package/examples/action/models.js +25 -0
- package/examples/sheepisland/GAMEMAP.md +107 -0
- package/examples/sheepisland/content/index.js +6 -0
- package/examples/sheepisland/content/props.js +19 -0
- package/examples/sheepisland/content/templates.js +5 -0
- package/examples/sheepisland/content/vegetation.js +8 -0
- package/examples/sheepisland/main.js +71 -0
- package/examples/sheepisland/params.js +25 -0
- package/examples/sheepisland/style/index.js +79 -0
- package/examples/sheepisland/style/models.js +59 -0
- package/examples/sheepisland/views.js +9 -0
- package/examples/styletest/GAMEMAP.md +135 -0
- package/examples/styletest/content/index.js +9 -0
- package/examples/styletest/content/items.js +8 -0
- package/examples/styletest/content/npcs.js +8 -0
- package/examples/styletest/content/places.js +5 -0
- package/examples/styletest/content/props.js +16 -0
- package/examples/styletest/content/templates.js +9 -0
- package/examples/styletest/content/vegetation.js +31 -0
- package/examples/styletest/look.js +11 -0
- package/examples/styletest/main.js +95 -0
- package/examples/styletest/models.js +87 -0
- package/examples/styletest/overrides.js +33 -0
- package/examples/styletest/panel.js +135 -0
- package/examples/styletest/params.js +32 -0
- package/examples/styletest/views.js +31 -0
- package/examples/world/DESIGN.md +5 -0
- package/examples/world/GAMEMAP.md +171 -0
- package/examples/world/content/actions.js +8 -0
- package/examples/world/content/audio.js +25 -0
- package/examples/world/content/bodies.js +12 -0
- package/examples/world/content/containers.js +4 -0
- package/examples/world/content/dialogues.js +33 -0
- package/examples/world/content/index.js +17 -0
- package/examples/world/content/items.js +10 -0
- package/examples/world/content/npcs.js +14 -0
- package/examples/world/content/pickups.js +11 -0
- package/examples/world/content/places.js +6 -0
- package/examples/world/content/props.js +12 -0
- package/examples/world/content/quests.js +15 -0
- package/examples/world/content/rules.js +23 -0
- package/examples/world/content/templates.js +5 -0
- package/examples/world/content/vegetation.js +32 -0
- package/examples/world/main.js +168 -0
- package/examples/world/models.js +28 -0
- package/index.d.ts +306 -0
- package/index.js +122 -0
- package/llms.txt +61 -0
- package/modules/ambience/Ambience.js +186 -0
- package/modules/camera/FirstPersonCamera.js +131 -0
- package/modules/camera/FixedCamera.js +162 -0
- package/modules/camera/FollowCamera.js +91 -0
- package/modules/camera/RtsCamera.js +132 -0
- package/modules/camera/common.js +182 -0
- package/modules/camera/index.js +11 -0
- package/modules/camera/projection.js +34 -0
- package/modules/characters/Character.js +235 -0
- package/modules/characters/NPC.js +242 -0
- package/modules/characters/assetModel.js +42 -0
- package/modules/characters/astar.js +66 -0
- package/modules/characters/behaviors.js +72 -0
- package/modules/characters/footsteps.js +13 -0
- package/modules/characters/index.js +215 -0
- package/modules/characters/moveHelpers.js +29 -0
- package/modules/characters/movers/common.js +62 -0
- package/modules/characters/movers/rapier.js +74 -0
- package/modules/characters/movers/simple.js +43 -0
- package/modules/characters/npcAvoid.js +129 -0
- package/modules/characters/npcSim.js +150 -0
- package/modules/characters/npcView.js +42 -0
- package/modules/characters/pathAsync.js +113 -0
- package/modules/characters/pathJob.js +62 -0
- package/modules/characters/pathWorker.js +7 -0
- package/modules/characters/playerStrings.js +12 -0
- package/modules/characters/proceduralRig.js +58 -0
- package/modules/characters/useModel.js +22 -0
- package/modules/characters/walkTo.js +58 -0
- package/modules/collision/Collision.js +274 -0
- package/modules/collision/grid.js +63 -0
- package/modules/content/explain.js +13 -0
- package/modules/content/ids.js +95 -0
- package/modules/content/index.js +154 -0
- package/modules/content/loader.js +190 -0
- package/modules/content/models.js +69 -0
- package/modules/content/packs.js +69 -0
- package/modules/content/props.js +89 -0
- package/modules/content/rules.js +134 -0
- package/modules/content/templates.js +189 -0
- package/modules/debug/DebugPanel.js +174 -0
- package/modules/entities/Entities.js +243 -0
- package/modules/entities/build.js +25 -0
- package/modules/entities/index.js +4 -0
- package/modules/flow/index.js +101 -0
- package/modules/gameplay/Container.js +227 -0
- package/modules/gameplay/Containers.js +89 -0
- package/modules/gameplay/Dialogue.js +219 -0
- package/modules/gameplay/Interactions.js +253 -0
- package/modules/gameplay/Inventory.js +224 -0
- package/modules/gameplay/Quests.js +205 -0
- package/modules/gameplay/boxOps.js +60 -0
- package/modules/gameplay/dialogueBox.js +48 -0
- package/modules/gameplay/interactionPrompt.js +28 -0
- package/modules/gameplay/inventoryOps.js +137 -0
- package/modules/gameplay/pickups.js +115 -0
- package/modules/gameplay/questLog.js +54 -0
- package/modules/gameplay/questSave.js +71 -0
- package/modules/grid/Grid.js +184 -0
- package/modules/grid/Layer.js +142 -0
- package/modules/grid/index.js +236 -0
- package/modules/grid/ops.js +73 -0
- package/modules/grid/preview.js +85 -0
- package/modules/grid/tiles.js +79 -0
- package/modules/hlod/index.js +167 -0
- package/modules/hud/index.js +167 -0
- package/modules/hud/parts.js +80 -0
- package/modules/level/geometry.js +46 -0
- package/modules/level/heightfield.js +160 -0
- package/modules/level/index.js +233 -0
- package/modules/level/nodes.js +84 -0
- package/modules/lights/index.js +227 -0
- package/modules/music/Music.js +294 -0
- package/modules/music/index.js +2 -0
- package/modules/music/rules.js +28 -0
- package/modules/nav/index.js +156 -0
- package/modules/nav/navPath.js +17 -0
- package/modules/net/Client.js +137 -0
- package/modules/net/Host.js +117 -0
- package/modules/net/Net.js +49 -0
- package/modules/net/index.js +77 -0
- package/modules/net/sync.js +114 -0
- package/modules/net/transports.js +118 -0
- package/modules/particles/Particles.js +179 -0
- package/modules/particles/effect.js +112 -0
- package/modules/particles/shaders.js +28 -0
- package/modules/photo/Photo.js +146 -0
- package/modules/rigid/RigidBodies.js +265 -0
- package/modules/rigid/Vehicles.js +97 -0
- package/modules/rigid/sync.js +158 -0
- package/modules/settings/Settings.js +297 -0
- package/modules/settings/apply.js +21 -0
- package/modules/settings/index.js +3 -0
- package/modules/settings/sections.js +156 -0
- package/modules/settings/strings.js +53 -0
- package/modules/settings/view.js +65 -0
- package/modules/sky/Sky.js +259 -0
- package/modules/sky/calendar.js +80 -0
- package/modules/sky/cascades.js +125 -0
- package/modules/sky/clouds.js +79 -0
- package/modules/sky/domeLayers.js +33 -0
- package/modules/sky/environment.js +141 -0
- package/modules/sky/fog.js +139 -0
- package/modules/sky/frame.js +77 -0
- package/modules/sky/layers.js +69 -0
- package/modules/sky/look.js +51 -0
- package/modules/sky/lookFog.js +80 -0
- package/modules/sky/lookShadow.js +50 -0
- package/modules/sky/lookSky.js +108 -0
- package/modules/sky/schedule.js +80 -0
- package/modules/sky/shader.js +96 -0
- package/modules/sky/shadow.js +74 -0
- package/modules/sky/skyModule.js +60 -0
- package/modules/terrain/ChunkManager.js +260 -0
- package/modules/terrain/chunkJob.js +19 -0
- package/modules/terrain/chunkLevels.js +40 -0
- package/modules/terrain/chunkQueries.js +42 -0
- package/modules/terrain/chunkWorker.js +5 -0
- package/modules/terrain/index.js +118 -0
- package/modules/terrain/lookGround.js +61 -0
- package/modules/terrain/mountTerrain.js +32 -0
- package/modules/terrain/terrainColorMap.js +41 -0
- package/modules/terrain/terrainDefaults.js +39 -0
- package/modules/terrain/terrainEdit.js +139 -0
- package/modules/terrain/terrainGen.js +155 -0
- package/modules/terrain/terrainIsland.js +131 -0
- package/modules/terrain/terrainMesh.js +92 -0
- package/modules/terrain/terrainShape.js +108 -0
- package/modules/terrain/terrainShapeMain.js +41 -0
- package/modules/terrain/terrainTexture.js +44 -0
- package/modules/timeline/Timeline.js +253 -0
- package/modules/timeline/Tween.js +114 -0
- package/modules/timeline/letterbox.js +24 -0
- package/modules/timeline/shots.js +90 -0
- package/modules/triggers/index.js +268 -0
- package/modules/vegetation/Vegetation.js +256 -0
- package/modules/vegetation/groundChunks.js +177 -0
- package/modules/vegetation/index.js +43 -0
- package/modules/vegetation/lookWind.js +37 -0
- package/modules/vegetation/modelGeometry.js +21 -0
- package/modules/water/Water.js +160 -0
- package/modules/water/look.js +80 -0
- package/modules/water/surface.js +88 -0
- package/modules/weather/Weather.js +242 -0
- package/modules/weather/look.js +75 -0
- package/modules/weather/particles.js +92 -0
- package/modules/weather/shaders.js +49 -0
- package/modules/weather/strings.js +15 -0
- package/modules/world/World.js +231 -0
- package/modules/world/cells.js +42 -0
- package/modules/world/explain.js +11 -0
- package/modules/world/index.js +71 -0
- package/modules/world/persist.js +107 -0
- package/modules/world/pos.js +20 -0
- package/modules/world/records.js +89 -0
- package/modules/world/sim.js +175 -0
- package/modules/world/simFar.js +82 -0
- package/modules/world/state.js +115 -0
- package/modules/world/thingSource.js +44 -0
- package/modules/world/views.js +182 -0
- package/package.json +66 -4
- package/presets.js +96 -0
- package/render/PostFX.js +240 -0
- package/render/detail.js +105 -0
- package/render/effects.js +144 -0
- package/render/engineUniforms.js +23 -0
- package/render/fuse.js +84 -0
- package/render/lighting.js +100 -0
- package/render/lights.js +18 -0
- package/render/lookSurface.js +161 -0
- package/render/materials.js +220 -0
- package/render/patches.js +252 -0
- package/render/postLook.js +86 -0
- package/render/surface.js +69 -0
- package/render/uniformDecl.js +29 -0
- package/types/common.d.ts +34 -0
- package/types/core.d.ts +1965 -0
- package/types/gameplay.d.ts +1822 -0
- package/types/generated/core/Audio.d.ts +200 -0
- package/types/generated/core/Batching.d.ts +47 -0
- package/types/generated/core/Budget.d.ts +90 -0
- package/types/generated/core/Commits.d.ts +31 -0
- package/types/generated/core/DebugOverrides.d.ts +52 -0
- package/types/generated/core/Events.d.ts +89 -0
- package/types/generated/core/I18n.d.ts +30 -0
- package/types/generated/core/Input.d.ts +118 -0
- package/types/generated/core/Jobs.d.ts +41 -0
- package/types/generated/core/Ops.d.ts +203 -0
- package/types/generated/core/Random.d.ts +49 -0
- package/types/generated/core/Rays.d.ts +49 -0
- package/types/generated/core/Saves.d.ts +162 -0
- package/types/generated/core/Stream.d.ts +93 -0
- package/types/generated/core/Threads.d.ts +82 -0
- package/types/generated/core/Views.d.ts +33 -0
- package/types/generated/core/audioVoice.d.ts +47 -0
- package/types/generated/core/page.d.ts +18 -0
- package/types/generated/core/session.d.ts +48 -0
- package/types/generated/modules/ambience/Ambience.d.ts +48 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
- package/types/generated/modules/flow/index.d.ts +10 -0
- package/types/generated/modules/grid/Grid.d.ts +151 -0
- package/types/generated/modules/grid/Layer.d.ts +65 -0
- package/types/generated/modules/grid/index.d.ts +86 -0
- package/types/generated/modules/hlod/index.d.ts +11 -0
- package/types/generated/modules/hud/index.d.ts +10 -0
- package/types/generated/modules/lights/index.d.ts +13 -0
- package/types/generated/modules/music/Music.d.ts +111 -0
- package/types/generated/modules/net/Net.d.ts +34 -0
- package/types/generated/modules/net/index.d.ts +53 -0
- package/types/generated/modules/net/transports.d.ts +58 -0
- package/types/generated/modules/particles/Particles.d.ts +69 -0
- package/types/generated/modules/sky/Sky.d.ts +145 -0
- package/types/generated/modules/sky/skyModule.d.ts +10 -0
- package/types/generated/modules/timeline/Timeline.d.ts +51 -0
- package/types/generated/modules/water/Water.d.ts +29 -0
- package/types/generated/modules/weather/Weather.d.ts +62 -0
- package/types/generated/modules/world/World.d.ts +242 -0
- package/types/generated/modules/world/index.d.ts +15 -0
- package/types/generated/render/PostFX.d.ts +125 -0
- package/types/generated/render/materials.d.ts +100 -0
- package/types/generated/render/patches.d.ts +41 -0
- package/types/generated/ui/Focus.d.ts +11 -0
- package/types/generated/ui/LoadingScreen.d.ts +2 -0
- package/types/generated/ui/UI.d.ts +57 -0
- package/types/nav.d.ts +52 -0
- package/types/physics.d.ts +592 -0
- package/types/style.d.ts +638 -0
- package/types/worker.d.ts +11 -0
- package/types/world.d.ts +772 -0
- package/ui/Focus.js +51 -0
- package/ui/LoadingScreen.js +42 -0
- package/ui/Parts.js +199 -0
- package/ui/UI.js +167 -0
- package/ui/defaults.js +85 -0
- package/ui/theme.js +124 -0
- package/ui/touchPart.js +49 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// Settings menu module: Esc opens it in game (when the UI focus stack is empty: no window, dialogue or cutscene open; see ui/Focus.js); tabs for graphics,
|
|
2
|
+
// audio, keys, language, saves (export / import save files).
|
|
3
|
+
// Changes apply at once and autosave to the browser (localStorage), restored on the next launch.
|
|
4
|
+
//
|
|
5
|
+
// engine.use(settings()); // install after other modules (so it sees terrain, audio, etc.)
|
|
6
|
+
// engine.settings.open() / close() / toggle()
|
|
7
|
+
// engine.settings.set('shadows', false) // change a setting in code (also saved)
|
|
8
|
+
// engine.settings.get('vol.music') // → 0.5
|
|
9
|
+
// engine.settings.preset('low') // graphics preset: 'low' | 'medium' | 'high'
|
|
10
|
+
//
|
|
11
|
+
// Tabs: default graphics, audio, keys, language, saves. Optional built-ins, off unless asked for: 'game' (resume / load / back to title) and
|
|
12
|
+
// 'camera' (mouse sensitivity, invert Y, field of view): settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] }) or addSection('camera').
|
|
13
|
+
// The whole menu is replaceable: skip this module and build your own (register it as the Esc root with uiFocus(engine).setRoot(() => myMenu.open())).
|
|
14
|
+
//
|
|
15
|
+
// A game's own settings page (e.g. "Gameplay"):
|
|
16
|
+
// engine.settings.define('subtitles', true, on => game.subtitles = on); // custom setting: default value + apply function, autosaved
|
|
17
|
+
// engine.settings.addSection('gameplay', {
|
|
18
|
+
// title: e => e.t('my.gameplay'),
|
|
19
|
+
// render: (tools, e, s) => tools.row(tools.t('my.subtitles'), tools.toggle('subtitles', s.get('subtitles'))),
|
|
20
|
+
// bind: (el, e, s) => {}, // optional: called after every redraw, to wire events on custom controls
|
|
21
|
+
// order: 50,
|
|
22
|
+
// });
|
|
23
|
+
//
|
|
24
|
+
// Look:
|
|
25
|
+
// CSS classes .threedog-win-settings .threedog-tabs .threedog-tab .threedog-set-row .threedog-set-label .threedog-set-ctl .threedog-seg .threedog-range
|
|
26
|
+
// .threedog-set-val .threedog-key(.is-waiting/.is-conflict) .threedog-set-note .threedog-set-foot .is-active — override with style.ui.css
|
|
27
|
+
// Replace it whole: style.ui.templates.settings({ sections, current, body, values }, { esc, t, icon }) returns HTML;
|
|
28
|
+
// controls just carry the attributes data-tab / data-set+data-value / data-range / data-rebind / data-reset / data-locale / data-save-export / data-save-import
|
|
29
|
+
// (see sections.js)
|
|
30
|
+
import { makeWindow, injectUICSS, uiFocus } from '../../ui/UI.js';
|
|
31
|
+
import { BUILTIN_SECTIONS } from './sections.js';
|
|
32
|
+
import { STRINGS, CSS } from './strings.js';
|
|
33
|
+
import { SettingsView } from './view.js';
|
|
34
|
+
import { applySetting } from './apply.js';
|
|
35
|
+
import { readParams, keysSchema } from '../../core/params.js';
|
|
36
|
+
|
|
37
|
+
// Graphics presets. Values are performance tiers, not art; a game can override with settings({ presets: { low: {...} } })
|
|
38
|
+
const PRESETS = {
|
|
39
|
+
low: { pixelRatio: 0.75, shadows: false, antialias: false, bloom: false, ao: false, viewChunks: 3, density: 0.5 },
|
|
40
|
+
medium: { pixelRatio: 1, shadows: true, antialias: true, bloom: false, ao: false, viewChunks: 4, density: 0.75 },
|
|
41
|
+
high: { pixelRatio: 1.5, shadows: true, antialias: true, bloom: true, ao: false, viewChunks: 5, density: 1 },
|
|
42
|
+
};
|
|
43
|
+
// Settings keys that switch a style post effect of the same name; a key whose effect the style pack lacks is hidden and ignored
|
|
44
|
+
const POST_KEYS = ['bloom', 'ao'];
|
|
45
|
+
|
|
46
|
+
export class Settings extends SettingsView {
|
|
47
|
+
constructor(engine, { action = 'menu', keys = ['Escape'], storageKey, presets = {}, sections = true, freezeWorld = false } = {}) {
|
|
48
|
+
super();
|
|
49
|
+
this.engine = engine;
|
|
50
|
+
this.action = action;
|
|
51
|
+
this.presets = { ...PRESETS };
|
|
52
|
+
for (const k in presets) this.presets[k] = { ...(this.presets[k] || {}), ...presets[k] };
|
|
53
|
+
// Storage key: shares the game's save prefix ('game-save-' -> 'game-settings') but is kept out of the save list
|
|
54
|
+
const p = engine.saves.prefix;
|
|
55
|
+
this.storageKey = storageKey || p.replace(/save-$/, '') + 'settings';
|
|
56
|
+
this.sections = new Map();
|
|
57
|
+
this.custom = new Map(); // game's custom settings: key -> { def, apply }
|
|
58
|
+
this.defaultBindings = {}; // default keys per action (recorded the first time seen)
|
|
59
|
+
this.capturing = null; // action name waiting for a key press
|
|
60
|
+
this.current = null; // current tab
|
|
61
|
+
this.freezeWorld = freezeWorld;
|
|
62
|
+
this._syncT = 0;
|
|
63
|
+
|
|
64
|
+
engine.i18n.add(STRINGS);
|
|
65
|
+
engine.input.define(action, keys, 'settings.action');
|
|
66
|
+
injectUICSS(CSS);
|
|
67
|
+
|
|
68
|
+
const stored = this._read();
|
|
69
|
+
this.saved = stored; // raw data read back (key bindings apply only after every action is registered)
|
|
70
|
+
this.values = { ...this._currentValues(), ...(stored.values || {}) };
|
|
71
|
+
this._applyAll();
|
|
72
|
+
// Tabs: true = the default set; a list picks built-in and optional tabs by name (optional ones register their own settings in setup)
|
|
73
|
+
if (sections === true) for (const [id, s] of Object.entries(BUILTIN_SECTIONS)) this.sections.set(id, s);
|
|
74
|
+
else if (sections) for (const id of sections) this._builtin(id);
|
|
75
|
+
if (stored.locale && engine.i18n.languages.includes(stored.locale) && stored.locale !== engine.i18n.locale) engine.i18n.setLocale(stored.locale);
|
|
76
|
+
|
|
77
|
+
this.win = makeWindow(engine, {
|
|
78
|
+
id: 'settings', title: () => engine.t('settings.title'), hintAction: action,
|
|
79
|
+
data: () => this._data(),
|
|
80
|
+
render: (d, tools) => this._render(d, tools),
|
|
81
|
+
onCancel: () => this._cancel(),
|
|
82
|
+
});
|
|
83
|
+
const baseRefresh = this.win.refresh;
|
|
84
|
+
this.win.refresh = () => { baseRefresh(); this._afterRefresh(); };
|
|
85
|
+
this._bindDOM(this.win.el);
|
|
86
|
+
|
|
87
|
+
// The back key (Esc) has one entry point: with an empty focus stack it opens the menu; while the menu is open the window's onCancel handles it
|
|
88
|
+
this.focus = uiFocus(engine);
|
|
89
|
+
this.focus.setRoot(() => this.open());
|
|
90
|
+
// The close button, the back key and code close() all go through the window's toggle, emitting ui:open / ui:close
|
|
91
|
+
engine.events.on('ui:open', id => { if (id === 'settings') this._pause(true); });
|
|
92
|
+
engine.events.on('ui:close', id => { if (id === 'settings') this._pause(false); });
|
|
93
|
+
engine.events.on('i18n:change', () => { if (this._ready) this.save(); });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---------- reading and writing settings ----------
|
|
97
|
+
get(key) { return this.values[key]; }
|
|
98
|
+
/** Change a setting: applies at once and saves. Changing a graphics setting turns the preset into "custom" */
|
|
99
|
+
set(key, value, { save = true } = {}) {
|
|
100
|
+
if (key === 'quality') return this.preset(value);
|
|
101
|
+
this.values[key] = value;
|
|
102
|
+
this._apply(key, value);
|
|
103
|
+
if (key in (this.presets.low || {})) this.values.quality = this._matchPreset();
|
|
104
|
+
if (save) this.save();
|
|
105
|
+
this.win.refresh();
|
|
106
|
+
}
|
|
107
|
+
/** Graphics preset */
|
|
108
|
+
preset(name) {
|
|
109
|
+
const p = this.presets[name]; if (!p) return;
|
|
110
|
+
for (const k in p) { this.values[k] = p[k]; this._apply(k, p[k]); }
|
|
111
|
+
this.values.quality = name;
|
|
112
|
+
this.save(); this.win.refresh();
|
|
113
|
+
}
|
|
114
|
+
/** A game's custom setting: default value + apply function (called once at once with the saved value) */
|
|
115
|
+
define(key, def, apply) {
|
|
116
|
+
this.custom.set(key, { def, apply });
|
|
117
|
+
if (!(key in this.values)) this.values[key] = def;
|
|
118
|
+
try { apply?.(this.values[key], this.engine); } catch (err) { console.error(`[settings] ${key}`, err); }
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
/** Add a tab */
|
|
122
|
+
addSection(id, def) {
|
|
123
|
+
if (def === undefined) { this._builtin(id); this.win.refresh(); return this; }
|
|
124
|
+
const { title, render, bind, when, order = 100 } = def;
|
|
125
|
+
this.sections.set(id, { title: typeof title === 'function' ? title : () => title, render, bind, when, order });
|
|
126
|
+
this.win.refresh();
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
removeSection(id) { this.sections.delete(id); if (this.current === id) this.current = null; this.win.refresh(); }
|
|
130
|
+
|
|
131
|
+
get isOpen() { return this.win.open; }
|
|
132
|
+
open() { if (!this.win.open) { this._syncActions(); this.win.toggle(true); } }
|
|
133
|
+
close() { this.capturing = null; if (this.win.open) this.win.toggle(false); }
|
|
134
|
+
toggle(on = !this.win.open) { on ? this.open() : this.close(); }
|
|
135
|
+
|
|
136
|
+
/** Reset all keys to defaults */
|
|
137
|
+
resetBindings() {
|
|
138
|
+
this._syncActions();
|
|
139
|
+
for (const [a, keys] of Object.entries(this.defaultBindings)) Object.assign(this.engine.input.actions.get(a), { keys: [...keys], custom: false });
|
|
140
|
+
this.engine.events.emit('input:rebind', { action: null, keys: null });
|
|
141
|
+
this.save();
|
|
142
|
+
}
|
|
143
|
+
/** Replace an action's first key with code (spare keys are kept) */
|
|
144
|
+
rebind(action, code) {
|
|
145
|
+
const inp = this.engine.input, cur = inp.keysOf(action);
|
|
146
|
+
inp.rebind(action, [code, ...cur.slice(1).filter(k => k !== code)]);
|
|
147
|
+
this.save();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Key list (for the UI): [{ action, name, label, keys, conflict }] */
|
|
151
|
+
actionList() {
|
|
152
|
+
const inp = this.engine.input, all = [...inp.actions];
|
|
153
|
+
const groups = {};
|
|
154
|
+
for (const [, v] of all) groups[v.labelKey] = (groups[v.labelKey] || 0) + 1;
|
|
155
|
+
const seen = {}, owner = {};
|
|
156
|
+
for (const [a, v] of all) for (const k of v.keys) (owner[k] ||= []).push(a);
|
|
157
|
+
// Conflict: one key shared by several actions, and not already so by default (Esc is both "back" and "menu" by default; not a conflict)
|
|
158
|
+
const isDefault = (a, k) => (this.defaultBindings[a] || inp.keysOf(a)).includes(k);
|
|
159
|
+
const conflict = k => owner[k].length > 1 && !owner[k].every(a => isDefault(a, k));
|
|
160
|
+
return all.map(([action, v]) => {
|
|
161
|
+
let name = this.engine.t(v.labelKey);
|
|
162
|
+
if (groups[v.labelKey] > 1) name += ' ' + (seen[v.labelKey] = (seen[v.labelKey] || 0) + 1);
|
|
163
|
+
return { action, name, label: inp.label(action), keys: v.keys, conflict: v.keys.some(conflict) };
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ---------- storage ----------
|
|
168
|
+
_read() {
|
|
169
|
+
try { const d = JSON.parse(localStorage.getItem(this.storageKey)); return d && typeof d === 'object' ? d : {}; } catch { return {}; }
|
|
170
|
+
}
|
|
171
|
+
save() {
|
|
172
|
+
const inp = this.engine.input, bindings = {};
|
|
173
|
+
for (const [a, def] of Object.entries(this.defaultBindings)) {
|
|
174
|
+
const cur = inp.keysOf(a);
|
|
175
|
+
if (cur.join() !== def.join()) bindings[a] = cur;
|
|
176
|
+
}
|
|
177
|
+
// Actions not registered yet (the game defines them later) keep their previously saved binding
|
|
178
|
+
for (const a in this.saved.bindings || {}) if (!(a in this.defaultBindings)) bindings[a] = this.saved.bindings[a];
|
|
179
|
+
const data = { v: 1, values: this.values, bindings, locale: this.engine.i18n.locale };
|
|
180
|
+
this.saved = data;
|
|
181
|
+
try { localStorage.setItem(this.storageKey, JSON.stringify(data)); } catch { return false; }
|
|
182
|
+
this.engine.events.emit('settings:change', this.values);
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ---------- applying ----------
|
|
187
|
+
/**
|
|
188
|
+
* @internal The chunk table that "view distance" and "vegetation density" drive: the terrain's, or vegetation's own over a level / code-built ground; null
|
|
189
|
+
* without either
|
|
190
|
+
*/
|
|
191
|
+
chunkHost() { return this.engine.terrain ?? this.engine.vegetation?.host ?? null; }
|
|
192
|
+
_currentValues() {
|
|
193
|
+
const e = this.engine, v = { pixelRatio: +e.renderer.getPixelRatio().toFixed(2), shadows: !!e.shadows };
|
|
194
|
+
v.antialias = e.post.antialias;
|
|
195
|
+
for (const k of POST_KEYS) if (e.post.get(k)) v[k] = e.post.get(k).enabled;
|
|
196
|
+
if (e.adaptive) v.adaptive = !!e.adaptive.on;
|
|
197
|
+
const H = this.chunkHost();
|
|
198
|
+
if (H) { v.viewChunks = H.viewChunks ?? 4; v.density = H.density ?? 1; }
|
|
199
|
+
for (const [bus, level] of Object.entries(e.audio.levels)) v['vol.' + bus] = level; // one slider per bus, the game's own buses too
|
|
200
|
+
this.values = v;
|
|
201
|
+
v.quality = this._matchPreset();
|
|
202
|
+
return v;
|
|
203
|
+
}
|
|
204
|
+
_matchPreset() {
|
|
205
|
+
const v = this.values, e = this.engine;
|
|
206
|
+
for (const [name, p] of Object.entries(this.presets)) {
|
|
207
|
+
const ok = Object.entries(p).every(([k, val]) => {
|
|
208
|
+
if ((k === 'viewChunks' || k === 'density') && !this.chunkHost()) return true;
|
|
209
|
+
if (POST_KEYS.includes(k) && !e.post.get(k)) return true;
|
|
210
|
+
return v[k] === val;
|
|
211
|
+
});
|
|
212
|
+
if (ok) return name;
|
|
213
|
+
}
|
|
214
|
+
return 'custom';
|
|
215
|
+
}
|
|
216
|
+
_applyAll() { for (const k in this.values) this._apply(k, this.values[k]); }
|
|
217
|
+
_apply(key, val) { applySetting(this, key, val); }
|
|
218
|
+
/** Record the default keys of newly seen actions and apply previously saved bindings */
|
|
219
|
+
_syncActions() {
|
|
220
|
+
const inp = this.engine.input, saved = this.saved.bindings || {};
|
|
221
|
+
let changed = false;
|
|
222
|
+
for (const [a, v] of inp.actions) {
|
|
223
|
+
if (a in this.defaultBindings) continue;
|
|
224
|
+
this.defaultBindings[a] = [...v.keys];
|
|
225
|
+
if (Array.isArray(saved[a]) && saved[a].length) { v.keys = [...saved[a]]; v.custom = true; changed = true; }
|
|
226
|
+
}
|
|
227
|
+
if (changed) this.engine.events.emit('input:rebind', { action: null, keys: null });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ---------- module hooks ----------
|
|
231
|
+
init() {
|
|
232
|
+
// At start() every module is installed: terrain settings and key bindings can only be applied fully now
|
|
233
|
+
this._ready = true;
|
|
234
|
+
const stored = this.saved.values || {};
|
|
235
|
+
for (const k of ['viewChunks', 'density']) {
|
|
236
|
+
const H = this.chunkHost(); if (!H) continue;
|
|
237
|
+
if (k in stored) this._apply(k, stored[k]); else this.values[k] = H[k];
|
|
238
|
+
}
|
|
239
|
+
for (const [key, c] of this.custom) if (!(key in this.values)) this.values[key] = c.def;
|
|
240
|
+
this.values.quality = this._matchPreset();
|
|
241
|
+
this._syncActions();
|
|
242
|
+
}
|
|
243
|
+
frame(dt) {
|
|
244
|
+
const inp = this.engine.input;
|
|
245
|
+
if ((this._syncT -= dt) <= 0) { this._syncT = 1; this._syncActions(); }
|
|
246
|
+
if (this.capturing) {
|
|
247
|
+
const code = [...inp.justPressed][0];
|
|
248
|
+
// The back key is routed to _cancel by the UI focus stack (cancels rebinding); nothing to do here
|
|
249
|
+
if (code && !inp.keysOf('cancel').includes(code)) { const a = this.capturing; this.capturing = null; this.rebind(a, code); }
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
// When the menu key and the back key are the same (default Esc) the UI focus stack handles it all; with another key: close if open, open when the focus
|
|
253
|
+
// stack is empty
|
|
254
|
+
if (!inp.pressedRaw(this.action) || inp.pressedRaw('cancel')) return;
|
|
255
|
+
if (this.win.open) this.close();
|
|
256
|
+
else if (this.focus.top === null) this.open();
|
|
257
|
+
}
|
|
258
|
+
/** Back key: cancel rebinding if one is in progress, otherwise close the menu */
|
|
259
|
+
_cancel() {
|
|
260
|
+
if (this.capturing) { this.capturing = null; this.win.refresh(); return; }
|
|
261
|
+
this.close();
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* freezeWorld: gameplay pauses while the menu is open. Pausing has one entry point: with flow installed it switches to flow's 'paused' state (back to the
|
|
265
|
+
* previous state on close),
|
|
266
|
+
* without flow it calls engine.freeze('settings') directly (rendering continues)
|
|
267
|
+
*/
|
|
268
|
+
_pause(on) {
|
|
269
|
+
if (!this.freezeWorld) return;
|
|
270
|
+
const e = this.engine, f = e.flow;
|
|
271
|
+
if (!f) { on ? e.freeze('settings') : e.unfreeze('settings'); return; }
|
|
272
|
+
if (on) { this._flowBefore = f.state; f.go('paused'); }
|
|
273
|
+
else { if (f.state === 'paused' && this._flowBefore) f.go(this._flowBefore); this._flowBefore = null; }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
const SETTINGS_PARAMS = keysSchema(['action', 'keys', 'storageKey', 'presets', 'sections', 'freezeWorld']);
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Settings menu module. Installs engine.settings. Install it after the other modules.
|
|
283
|
+
* @param opts action/keys action that opens the menu (default 'menu' = Esc); storageKey storage key; presets override graphics presets;
|
|
284
|
+
* sections which tabs: true (default) graphics, audio, controls, language, saves; a list picks by name, including the optional 'game' (resume, load, back to
|
|
285
|
+
* title) and 'camera' (sensitivity, invert Y, field of view); false for none;
|
|
286
|
+
* freezeWorld pause gameplay while the menu is open (with flow it switches to flow's 'paused', otherwise engine.freeze; rendering continues), default false
|
|
287
|
+
*/
|
|
288
|
+
export function settings(opts = {}) {
|
|
289
|
+
readParams('settings', SETTINGS_PARAMS, opts);
|
|
290
|
+
let s = null;
|
|
291
|
+
return {
|
|
292
|
+
name: 'settings', params: SETTINGS_PARAMS, options: opts, label: 'Settings', optional: ['terrain', 'vegetation'], stage: 'presentation',
|
|
293
|
+
install(e) { s = new Settings(e, opts); return s; },
|
|
294
|
+
init() { s.init(); },
|
|
295
|
+
frame(dt) { s.frame(dt); },
|
|
296
|
+
};
|
|
297
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Apply one setting to the engine (helper of Settings.js): the built-in keys (pixel ratio, shadows, post effects, view distance, density, audio buses) and
|
|
2
|
+
// the game's own settings (define). `s` is the Settings instance.
|
|
3
|
+
|
|
4
|
+
export function applySetting(s, key, val) {
|
|
5
|
+
const e = s.engine;
|
|
6
|
+
try {
|
|
7
|
+
switch (key) {
|
|
8
|
+
case 'pixelRatio': if (e.adaptive) e.adaptive.max = val; if (Math.abs(e.renderer.getPixelRatio() - val) > 0.001) e.setPixelRatio(val); break;
|
|
9
|
+
case 'shadows': if (e.shadows !== val) e.setShadows(val); break;
|
|
10
|
+
case 'antialias': e.post.setAntialias(val); break;
|
|
11
|
+
case 'bloom': case 'ao': if (e.post.get(key)) e.look.post.set({ [key + '.enabled']: val }); break; // a style without this effect has nothing to switch (look.post.set would throw on the unknown key)
|
|
12
|
+
case 'adaptive': if (e.adaptive) { e.adaptive.on = val; if (!val && e.adaptive.max) e.setPixelRatio(e.adaptive.max); } break;
|
|
13
|
+
case 'viewChunks': { const H = s.chunkHost(); if (H?.setViewChunks && H.viewChunks !== val) H.setViewChunks(val); break; }
|
|
14
|
+
case 'density': { const H = s.chunkHost(); if (H?.setDensity && H.density !== val) H.setDensity(val); break; }
|
|
15
|
+
default:
|
|
16
|
+
// a saved slider for a bus this build no longer has is skipped, not an error
|
|
17
|
+
if (key.startsWith('vol.')) { if (key.slice(4) in e.audio.levels) e.audio.setVolume(key.slice(4), val); }
|
|
18
|
+
else s.custom.get(key)?.apply?.(val, e);
|
|
19
|
+
}
|
|
20
|
+
} catch (err) { console.error(`[settings] ${key} failed to apply`, err); }
|
|
21
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Built-in tabs of the settings menu: graphics, audio, keys, language.
|
|
2
|
+
// Each tab is { title: engine => text, render: (tools, engine, settings) => HTML, bind?: (element, engine, settings) => void, when?: engine => show or not, order }
|
|
3
|
+
// Controls bind no events directly; they carry data-* attributes that Settings.js handles in one place (a style pack's whole-page template can use the same attributes):
|
|
4
|
+
// data-tab="graphics" switch tab
|
|
5
|
+
// data-set="shadows" data-value="true" click sets the setting shadows to true (value parsed as JSON, falls back to a string)
|
|
6
|
+
// data-range="vol.music" slider <input type="range">; applies live while dragging, saves on release
|
|
7
|
+
// data-rebind="interact" click to enter the "press a key" state
|
|
8
|
+
// data-reset="controls" restore default keys
|
|
9
|
+
// data-locale="en" switch language
|
|
10
|
+
|
|
11
|
+
const pct = v => Math.round(v * 100) + '%';
|
|
12
|
+
/** Value shown beside a slider */
|
|
13
|
+
export const formatValue = (key, v) => key.startsWith('vol.') || key === 'density' ? pct(v)
|
|
14
|
+
: key === 'pixelRatio' || key === 'camera.sensitivity' ? '×' + (+v).toFixed(2) : key === 'camera.fov' ? v + '°' : String(v);
|
|
15
|
+
|
|
16
|
+
/** One row: text on the left, control on the right */
|
|
17
|
+
const row = (label, ctl, esc) => `<div class="threedog-row threedog-set-row"><span class="threedog-set-label">${esc(label)}</span><span class="threedog-set-ctl">${ctl}</span></div>`;
|
|
18
|
+
|
|
19
|
+
/** Toggle button */
|
|
20
|
+
const toggle = (key, on, { esc, t }) =>
|
|
21
|
+
`<button type="button" class="threedog-btn threedog-set-toggle${on ? ' is-active' : ''}" aria-pressed="${!!on}" data-set="${esc(key)}" data-value="${!on}">${esc(t(on ? 'common.on' : 'common.off'))}</button>`;
|
|
22
|
+
|
|
23
|
+
/** Slider */
|
|
24
|
+
const range = (key, v, min, max, step, { esc }) =>
|
|
25
|
+
`<input class="threedog-range" type="range" min="${min}" max="${max}" step="${step}" value="${v}" data-range="${esc(key)}" aria-label="${esc(key)}"><span class="threedog-set-val" data-val="${esc(key)}">${esc(formatValue(key, v))}</span>`;
|
|
26
|
+
|
|
27
|
+
/** A group of mutually exclusive buttons: options = [[value, text], ...]; a disabled value is display-only (e.g. "custom") */
|
|
28
|
+
const segmented = (key, cur, options, { esc }, disabled = []) =>
|
|
29
|
+
`<span class="threedog-seg">${options.map(([v, label]) => {
|
|
30
|
+
const on = v === cur, off = disabled.includes(v);
|
|
31
|
+
return `<button type="button" class="threedog-btn${on ? ' is-active' : ''}" aria-pressed="${on}"${off ? ' disabled' : ` data-set="${esc(key)}" data-value="${esc(JSON.stringify(v))}"`}>${esc(label)}</button>`;
|
|
32
|
+
}).join('')}</span>`;
|
|
33
|
+
|
|
34
|
+
/** The tools argument of a tab's render(tools, e, s): esc / t plus the control helpers, already bound (return HTML) */
|
|
35
|
+
export function settingsTools(engine, esc) {
|
|
36
|
+
const base = { esc, t: (k, p) => engine.t(k, p) };
|
|
37
|
+
return {
|
|
38
|
+
...base,
|
|
39
|
+
row: (label, ctl) => row(label, ctl, esc),
|
|
40
|
+
toggle: (key, on) => toggle(key, on, base),
|
|
41
|
+
range: (key, v, min, max, step) => range(key, v, min, max, step, base),
|
|
42
|
+
segmented: (key, cur, options, disabled = []) => segmented(key, cur, options, base, disabled),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const BUILTIN_SECTIONS = {
|
|
47
|
+
graphics: {
|
|
48
|
+
order: 10, title: e => e.t('settings.graphics'),
|
|
49
|
+
render(tools, e, s) {
|
|
50
|
+
const { esc, t } = tools, v = s.values;
|
|
51
|
+
const opts = ['low', 'medium', 'high', 'custom'].map(k => [k, t('settings.quality.' + k)]);
|
|
52
|
+
let h = row(t('settings.quality'), segmented('quality', v.quality, opts, tools, ['custom']), esc);
|
|
53
|
+
h += row(t('settings.pixelRatio'), range('pixelRatio', v.pixelRatio, 0.5, 2, 0.05, tools), esc);
|
|
54
|
+
h += row(t('settings.shadows'), toggle('shadows', v.shadows, tools), esc);
|
|
55
|
+
h += row(t('settings.antialias'), toggle('antialias', v.antialias, tools), esc);
|
|
56
|
+
if (e.post.get('bloom')) h += row(t('settings.bloom'), toggle('bloom', v.bloom, tools), esc);
|
|
57
|
+
if (e.post.get('ao')) h += row(t('settings.ao'), toggle('ao', v.ao, tools), esc);
|
|
58
|
+
if (e.adaptive) h += row(t('settings.adaptive'), toggle('adaptive', v.adaptive, tools), esc);
|
|
59
|
+
if (s.chunkHost()?.setViewChunks) h += row(t('settings.viewDistance'), range('viewChunks', v.viewChunks, 2, 8, 1, tools), esc);
|
|
60
|
+
if (s.chunkHost()?.setDensity) h += row(t('settings.density'), range('density', v.density, 0.25, 1.5, 0.25, tools), esc);
|
|
61
|
+
return h;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
audio: {
|
|
65
|
+
order: 20, title: e => e.t('settings.audio'), when: () => true,
|
|
66
|
+
render(tools, e, s) {
|
|
67
|
+
const { esc, t } = tools;
|
|
68
|
+
// every bus of engine.audio (master first); a game's own bus is labeled by its key settings.vol.<bus>, else by its name
|
|
69
|
+
return Object.keys(e.audio.levels).map(b => row(e.i18n.has('settings.vol.' + b) ? t('settings.vol.' + b) : b,
|
|
70
|
+
range('vol.' + b, s.values['vol.' + b] ?? 1, 0, 1, 0.05, tools), esc)).join('');
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
controls: {
|
|
74
|
+
order: 30, title: e => e.t('settings.controls'),
|
|
75
|
+
render(tools, e, s) {
|
|
76
|
+
const { esc, t } = tools;
|
|
77
|
+
const rows = s.actionList().map(a => {
|
|
78
|
+
const waiting = s.capturing === a.action;
|
|
79
|
+
const keys = waiting ? t('settings.pressKey') : (a.label || t('settings.unbound'));
|
|
80
|
+
return `<div class="threedog-row threedog-set-row threedog-set-bind"><span class="threedog-set-label">${esc(a.name)}</span>`
|
|
81
|
+
+ `<span class="threedog-set-ctl"><button type="button" class="threedog-btn threedog-key${waiting ? ' is-waiting' : ''}" data-rebind="${esc(a.action)}">${esc(keys)}</button></span></div>`;
|
|
82
|
+
}).join('');
|
|
83
|
+
return `<div class="threedog-list">${rows}</div><p class="threedog-set-note">${esc(t('settings.rebindHint'))}</p>`
|
|
84
|
+
+ `<div class="threedog-set-foot"><button type="button" class="threedog-btn" data-reset="controls">${esc(t('settings.resetKeys'))}</button></div>`;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
language: {
|
|
88
|
+
order: 40, title: e => e.t('settings.language'), when: e => e.i18n.languages.length > 1,
|
|
89
|
+
render(tools, e) {
|
|
90
|
+
const { esc, t } = tools, cur = e.i18n.locale;
|
|
91
|
+
const btns = e.i18n.languages.map(l => {
|
|
92
|
+
const name = e.i18n.has('settings.langName.' + l) ? t('settings.langName.' + l) : l;
|
|
93
|
+
return `<button type="button" class="threedog-btn${l === cur ? ' is-active' : ''}" aria-pressed="${l === cur}" data-locale="${esc(l)}">${esc(name)}</button>`;
|
|
94
|
+
}).join('');
|
|
95
|
+
return row(t('settings.language'), `<span class="threedog-seg">${btns}</span>`, esc);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
// Save backup: an "Export" per save slot (downloads .json, attachments included) and an "Import" at the bottom (pick a file to restore). A safety net for when mobile browsers clear site data
|
|
99
|
+
saves: {
|
|
100
|
+
order: 50, title: e => e.t('settings.saves'),
|
|
101
|
+
render(tools, e) {
|
|
102
|
+
const { esc, t } = tools, list = e.saves.list();
|
|
103
|
+
const rows = list.map(s => row(`${s.slot} ${new Date(s.savedAt).toLocaleString()}`,
|
|
104
|
+
`<button type="button" class="threedog-btn" data-save-export="${esc(s.slot)}">${esc(t('settings.exportSave'))}</button>`, esc)).join('')
|
|
105
|
+
|| `<p class="threedog-set-note">${esc(t('settings.noSaves'))}</p>`;
|
|
106
|
+
return `${rows}<p class="threedog-set-note">${esc(t('settings.saveHint'))}</p>`
|
|
107
|
+
+ `<div class="threedog-set-foot"><button type="button" class="threedog-btn" data-save-import>${esc(t('settings.importSave'))}</button></div>`;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Optional tabs: not in the default menu (a game with no use for them should not show them). Turn on with
|
|
113
|
+
// settings({ sections: ['graphics', 'audio', 'controls', 'game', 'camera'] }) or engine.settings.addSection('camera').
|
|
114
|
+
// setup(s) runs once when the tab is added and registers the tab's own settings (saved like any other).
|
|
115
|
+
export const OPTIONAL_SECTIONS = {
|
|
116
|
+
// Resume / load a slot / back to title (only when the game turned the title part on)
|
|
117
|
+
game: {
|
|
118
|
+
order: 5, title: e => e.t('settings.game'),
|
|
119
|
+
render(tools, e) {
|
|
120
|
+
const { esc, t } = tools;
|
|
121
|
+
const btn = (act, label, extra = '') => `<button type="button" class="threedog-btn" data-game="${act}"${extra}>${esc(label)}</button>`;
|
|
122
|
+
let h = row(t('settings.resume'), btn('resume', t('settings.resume')), esc);
|
|
123
|
+
for (const s of e.saves.list()) {
|
|
124
|
+
h += row(`${s.slot} ${new Date(s.savedAt).toLocaleString()}`, btn('load', t('settings.load'), ` data-slot="${esc(s.slot)}"`), esc);
|
|
125
|
+
}
|
|
126
|
+
if (e.ui.describe().title !== 'off') h += row(t('settings.toTitle'), btn('title', t('settings.toTitle')), esc);
|
|
127
|
+
return h;
|
|
128
|
+
},
|
|
129
|
+
bind(el, e, s) {
|
|
130
|
+
for (const b of el.querySelectorAll('[data-game]')) b.onclick = async () => {
|
|
131
|
+
const act = b.dataset.game;
|
|
132
|
+
s.close();
|
|
133
|
+
if (act === 'load') await e.session.load(b.dataset.slot); // a clean playthrough from the save, not a quick load onto this one
|
|
134
|
+
else if (act === 'title') await e.session.quit();
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
// Mouse sensitivity, invert Y, field of view: written to the current camera (engine.cameraRig)
|
|
139
|
+
camera: {
|
|
140
|
+
order: 25, title: e => e.t('settings.camera'), when: e => !!e.cameraRig,
|
|
141
|
+
setup(s) {
|
|
142
|
+
const e = s.engine, rig = () => e.cameraRig;
|
|
143
|
+
s.define('camera.sensitivity', rig()?.sensitivity ?? 1, v => { if (rig() && 'sensitivity' in rig()) rig().sensitivity = v; });
|
|
144
|
+
s.define('camera.invertY', rig()?.invertY ?? false, v => { if (rig() && 'invertY' in rig()) rig().invertY = v; });
|
|
145
|
+
s.define('camera.fov', e.camera.fov, v => { if (e.camera.fov !== v) { e.camera.fov = v; e.camera.updateProjectionMatrix(); } });
|
|
146
|
+
// a new rig starts from its own defaults (and setCamera resets the fov): put the player's choices back on it
|
|
147
|
+
e.events.on('camera:change', () => { for (const k of ['camera.sensitivity', 'camera.invertY', 'camera.fov']) s.custom.get(k)?.apply(s.values[k], e); });
|
|
148
|
+
},
|
|
149
|
+
render(tools, e, s) {
|
|
150
|
+
const { esc, t } = tools, v = s.values;
|
|
151
|
+
return row(t('settings.sensitivity'), range('camera.sensitivity', v['camera.sensitivity'], 0.2, 3, 0.05, tools), esc)
|
|
152
|
+
+ row(t('settings.invertY'), toggle('camera.invertY', v['camera.invertY'], tools), esc)
|
|
153
|
+
+ row(t('settings.fov'), range('camera.fov', v['camera.fov'], 40, 100, 1, tools), esc);
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Settings menu text (Chinese, English) and layout CSS.
|
|
2
|
+
// CSS uses only var(--threedog-*) variables, no colors or fonts; a style pack overrides these classes with style.ui.css.
|
|
3
|
+
|
|
4
|
+
export const STRINGS = {
|
|
5
|
+
'zh-CN': {
|
|
6
|
+
'settings.title': '设置', 'settings.action': '菜单',
|
|
7
|
+
'settings.graphics': '画质', 'settings.audio': '声音', 'settings.controls': '按键', 'settings.language': '语言',
|
|
8
|
+
'settings.quality': '画质预设', 'settings.quality.low': '低', 'settings.quality.medium': '中', 'settings.quality.high': '高', 'settings.quality.custom': '自定义',
|
|
9
|
+
'settings.pixelRatio': '渲染精度', 'settings.shadows': '阴影', 'settings.antialias': '抗锯齿', 'settings.bloom': '泛光', 'settings.ao': '环境光遮蔽',
|
|
10
|
+
'settings.adaptive': '自动分辨率', 'settings.viewDistance': '视距', 'settings.density': '植被密度',
|
|
11
|
+
'settings.vol.master': '总音量', 'settings.vol.music': '音乐', 'settings.vol.sfx': '音效', 'settings.vol.ambience': '环境音', 'settings.vol.ui': '界面音',
|
|
12
|
+
'settings.pressKey': '请按一个键…', 'settings.unbound': '未绑定', 'settings.rebindHint': '点击按键后按下新键,Esc 取消。',
|
|
13
|
+
'settings.resetKeys': '恢复默认按键',
|
|
14
|
+
'settings.saves': '存档', 'settings.exportSave': '导出存档', 'settings.importSave': '导入存档', 'settings.noSaves': '还没有存档。',
|
|
15
|
+
'settings.saveHint': '导出会下载一个 .json 文件(含附件,如照片);换设备或浏览器数据丢失后,用"导入存档"恢复。',
|
|
16
|
+
'settings.langName.zh-CN': '简体中文', 'settings.langName.en': 'English',
|
|
17
|
+
'settings.game': '游戏', 'settings.resume': '继续游戏', 'settings.load': '读档', 'settings.toTitle': '回到标题',
|
|
18
|
+
'settings.camera': '镜头', 'settings.sensitivity': '鼠标灵敏度', 'settings.invertY': '反转 Y 轴', 'settings.fov': '视野',
|
|
19
|
+
},
|
|
20
|
+
en: {
|
|
21
|
+
'settings.title': 'Settings', 'settings.action': 'Menu',
|
|
22
|
+
'settings.graphics': 'Graphics', 'settings.audio': 'Audio', 'settings.controls': 'Controls', 'settings.language': 'Language',
|
|
23
|
+
'settings.quality': 'Quality preset', 'settings.quality.low': 'Low', 'settings.quality.medium': 'Medium', 'settings.quality.high': 'High', 'settings.quality.custom': 'Custom',
|
|
24
|
+
'settings.pixelRatio': 'Render scale', 'settings.shadows': 'Shadows', 'settings.antialias': 'Anti-aliasing', 'settings.bloom': 'Bloom', 'settings.ao': 'Ambient occlusion',
|
|
25
|
+
'settings.adaptive': 'Adaptive resolution', 'settings.viewDistance': 'View distance', 'settings.density': 'Vegetation density',
|
|
26
|
+
'settings.vol.master': 'Master volume', 'settings.vol.music': 'Music', 'settings.vol.sfx': 'Sound effects', 'settings.vol.ambience': 'Ambience', 'settings.vol.ui': 'Interface',
|
|
27
|
+
'settings.pressKey': 'Press a key…', 'settings.unbound': 'Unbound', 'settings.rebindHint': 'Click a key, then press the new one. Esc cancels.',
|
|
28
|
+
'settings.resetKeys': 'Reset to defaults',
|
|
29
|
+
'settings.saves': 'Saves', 'settings.exportSave': 'Export save', 'settings.importSave': 'Import save', 'settings.noSaves': 'No saves yet.',
|
|
30
|
+
'settings.saveHint': 'Export downloads a .json file (attachments such as photos included). Use "Import save" to restore it on another device or after browser data is lost.',
|
|
31
|
+
'settings.langName.zh-CN': '简体中文', 'settings.langName.en': 'English',
|
|
32
|
+
'settings.game': 'Game', 'settings.resume': 'Resume', 'settings.load': 'Load', 'settings.toTitle': 'Back to title',
|
|
33
|
+
'settings.camera': 'Camera', 'settings.sensitivity': 'Mouse sensitivity', 'settings.invertY': 'Invert Y', 'settings.fov': 'Field of view',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const CSS = `
|
|
38
|
+
.threedog-win-settings{box-sizing:border-box;width:min(560px,calc(100% - 32px));max-height:min(80%,640px)}
|
|
39
|
+
.threedog-tabs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px;padding-bottom:10px;border-bottom:1px solid var(--threedog-line)}
|
|
40
|
+
.threedog-tab.is-active,.threedog-seg .threedog-btn.is-active,.threedog-set-toggle.is-active{border-color:var(--threedog-accent);color:var(--threedog-accent)}
|
|
41
|
+
.threedog-set-row{justify-content:space-between;flex-wrap:wrap;min-height:36px}
|
|
42
|
+
.threedog-set-label{flex:1 1 140px;min-width:0}
|
|
43
|
+
.threedog-set-ctl{display:flex;align-items:center;gap:8px;flex:0 1 auto;justify-content:flex-end;flex-wrap:wrap}
|
|
44
|
+
.threedog-seg{display:inline-flex;flex-wrap:wrap;gap:4px}
|
|
45
|
+
.threedog-seg .threedog-btn:disabled{opacity:.5;cursor:default}
|
|
46
|
+
.threedog-range{width:min(180px,40%);accent-color:var(--threedog-accent)}
|
|
47
|
+
.threedog-set-val{min-width:3.6em;text-align:right;font-variant-numeric:tabular-nums;color:var(--threedog-muted);font-size:12px}
|
|
48
|
+
.threedog-key{min-width:72px;font-variant-numeric:tabular-nums}
|
|
49
|
+
.threedog-key.is-waiting{border-color:var(--threedog-accent);color:var(--threedog-accent)}
|
|
50
|
+
.threedog-key.is-conflict{border-style:dashed}
|
|
51
|
+
.threedog-set-note{color:var(--threedog-muted);font-size:12px;margin:8px 0}
|
|
52
|
+
.threedog-set-foot{display:flex;justify-content:flex-end;margin-top:8px}
|
|
53
|
+
`;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// UI part of the settings menu (tabs, redraw, click/slider events); Settings inherits it.
|
|
2
|
+
import { formatValue, BUILTIN_SECTIONS, OPTIONAL_SECTIONS, settingsTools } from './sections.js';
|
|
3
|
+
import { esc } from '../../ui/UI.js';
|
|
4
|
+
|
|
5
|
+
const CSS_ESC = s => (globalThis.CSS?.escape ? globalThis.CSS.escape(s) : String(s).replace(/["\\]/g, '\\$&'));
|
|
6
|
+
|
|
7
|
+
export class SettingsView {
|
|
8
|
+
/** @internal Add a built-in or optional tab by name; an optional tab registers its own settings once (setup) */
|
|
9
|
+
_builtin(id) {
|
|
10
|
+
const s = BUILTIN_SECTIONS[id] ?? OPTIONAL_SECTIONS[id];
|
|
11
|
+
if (!s) throw new Error(`settings: no built-in tab '${id}'. Built-in: ${Object.keys(BUILTIN_SECTIONS).join(', ')}; optional: ${Object.keys(OPTIONAL_SECTIONS).join(', ')}. A tab of your own: engine.settings.addSection('${id}', { title, render }).`);
|
|
12
|
+
if (this.sections.has(id)) return;
|
|
13
|
+
this.sections.set(id, s);
|
|
14
|
+
s.setup?.(this);
|
|
15
|
+
}
|
|
16
|
+
_visibleSections() {
|
|
17
|
+
return [...this.sections].filter(([, s]) => !s.when || s.when(this.engine)).sort((a, b) => (a[1].order ?? 100) - (b[1].order ?? 100));
|
|
18
|
+
}
|
|
19
|
+
_data() {
|
|
20
|
+
const list = this._visibleSections();
|
|
21
|
+
if (!list.some(([id]) => id === this.current)) this.current = list[0]?.[0] ?? null;
|
|
22
|
+
const tools = this._tools();
|
|
23
|
+
const sec = this.sections.get(this.current);
|
|
24
|
+
let body = '';
|
|
25
|
+
try { body = sec ? sec.render(tools, this.engine, this) : ''; } catch (err) { console.error(`[settings] tab ${this.current} failed to render`, err); }
|
|
26
|
+
return { sections: list.map(([id, s]) => ({ id, title: s.title(this.engine), active: id === this.current })), current: this.current, body, values: { ...this.values } };
|
|
27
|
+
}
|
|
28
|
+
_tools() { return settingsTools(this.engine, esc); }
|
|
29
|
+
_render({ sections, body }, { esc }) {
|
|
30
|
+
const tabs = sections.map(s => `<button type="button" role="tab" class="threedog-btn threedog-tab${s.active ? ' is-active' : ''}" aria-selected="${s.active}" data-tab="${esc(s.id)}">${esc(s.title)}</button>`).join('');
|
|
31
|
+
return `<div class="threedog-tabs" role="tablist">${tabs}</div><div class="threedog-set-body" role="tabpanel">${body}</div>`;
|
|
32
|
+
}
|
|
33
|
+
_afterRefresh() {
|
|
34
|
+
if (!this.win.open) return;
|
|
35
|
+
for (const a of this.actionList()) if (a.conflict) this.win.el.querySelector(`[data-rebind="${CSS_ESC(a.action)}"]`)?.classList.add('is-conflict');
|
|
36
|
+
const sec = this.sections.get(this.current);
|
|
37
|
+
try { sec?.bind?.(this.win.el, this.engine, this); } catch (err) { console.error(`[settings] tab ${this.current}`, err); }
|
|
38
|
+
}
|
|
39
|
+
_bindDOM(el) {
|
|
40
|
+
el.addEventListener('click', ev => {
|
|
41
|
+
const b = ev.target.closest('[data-tab],[data-set],[data-rebind],[data-reset],[data-locale],[data-save-export],[data-save-import]');
|
|
42
|
+
if (!b || !el.contains(b)) return;
|
|
43
|
+
const d = b.dataset;
|
|
44
|
+
if (d.tab) { this.current = d.tab; this.capturing = null; this.win.refresh(); }
|
|
45
|
+
else if (d.set) { let v = d.value; try { v = JSON.parse(v); } catch { /* a string */ } this.set(d.set, v); }
|
|
46
|
+
else if (d.rebind) { this.capturing = d.rebind; this.win.refresh(); }
|
|
47
|
+
else if (d.reset === 'controls') this.resetBindings();
|
|
48
|
+
else if (d.locale) { this.engine.i18n.setLocale(d.locale); }
|
|
49
|
+
else if (d.saveExport) this.engine.saves.exportFile(d.saveExport);
|
|
50
|
+
else if ('saveImport' in d) this.engine.saves.importFile().then(slot => slot && this.win.refresh());
|
|
51
|
+
});
|
|
52
|
+
// Slider: applies live while dragging (no redraw, to avoid interrupting the drag), saves on release
|
|
53
|
+
el.addEventListener('input', ev => {
|
|
54
|
+
const r = ev.target.closest?.('[data-range]'); if (!r) return;
|
|
55
|
+
const key = r.dataset.range, v = +r.value;
|
|
56
|
+
this.values[key] = v;
|
|
57
|
+
if (key !== 'density' && key !== 'viewChunks') this._apply(key, v); // these two rebuild the world, so they apply on release
|
|
58
|
+
const lab = el.querySelector(`[data-val="${CSS_ESC(key)}"]`); if (lab) lab.textContent = formatValue(key, v);
|
|
59
|
+
});
|
|
60
|
+
el.addEventListener('change', ev => {
|
|
61
|
+
const r = ev.target.closest?.('[data-range]'); if (!r) return;
|
|
62
|
+
this.set(r.dataset.range, +r.value);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|