threedog 0.0.0-stage → 0.1.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 +267 -0
- package/core/Assets.js +240 -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/Describe.js +134 -0
- package/core/Engine.js +221 -0
- package/core/Events.js +95 -0
- package/core/I18n.js +94 -0
- package/core/Input.js +245 -0
- package/core/Inspect.js +97 -0
- package/core/InspectScene.js +187 -0
- package/core/Jobs.js +146 -0
- package/core/Loading.js +149 -0
- package/core/Ops.js +272 -0
- package/core/Random.js +52 -0
- package/core/Rays.js +160 -0
- package/core/SaveStore.js +85 -0
- package/core/Saves.js +253 -0
- package/core/Stream.js +279 -0
- package/core/Threads.js +158 -0
- package/core/UrlState.js +93 -0
- package/core/Vars.js +34 -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/audioRules.js +121 -0
- package/core/audioVoice.js +225 -0
- package/core/batchGroups.js +116 -0
- package/core/canvasBox.js +63 -0
- package/core/dayTime.js +15 -0
- package/core/describeText.js +136 -0
- package/core/easing.js +34 -0
- package/core/errorCodes.js +172 -0
- package/core/errorHints.js +203 -0
- package/core/errors.js +40 -0
- package/core/events.generated.js +84 -0
- package/core/ground.js +102 -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 +68 -0
- package/core/lightWatch.js +36 -0
- package/core/loop.js +199 -0
- package/core/math.js +33 -0
- package/core/modules.js +182 -0
- package/core/movement.js +19 -0
- package/core/mulberry32.js +14 -0
- package/core/opsCheck.js +86 -0
- package/core/opsGuard.js +26 -0
- package/core/opsHistory.js +27 -0
- package/core/page.js +78 -0
- package/core/pureWorker.js +5 -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 +125 -0
- package/core/screenToGround.js +39 -0
- package/core/session.js +171 -0
- package/core/shadowTypes.js +15 -0
- package/core/skip.js +104 -0
- package/core/startup.js +133 -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/thingOps.js +157 -0
- package/core/things.js +198 -0
- package/core/threadPure.js +120 -0
- package/core/threadServe.js +25 -0
- package/core/tier.js +11 -0
- package/core/validate.js +188 -0
- package/docs/AI.md +149 -0
- package/docs/API.md +84 -0
- package/docs/CODEMAP.md +335 -0
- package/docs/COMMANDS.md +96 -0
- package/docs/CONVENTIONS.md +134 -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 +60 -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 +142 -0
- package/docs/api/clock.md +7 -0
- package/docs/api/collision.md +35 -0
- package/docs/api/content.md +63 -0
- package/docs/api/debug.md +10 -0
- package/docs/api/dialogue.md +39 -0
- package/docs/api/engine.md +190 -0
- package/docs/api/entities.md +61 -0
- package/docs/api/events.md +91 -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 +9 -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 +31 -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 +55 -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 +151 -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 +104 -0
- package/docs/recipes/07-flow-scenes-pause.md +128 -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 +57 -0
- package/docs/recipes/13-animation.md +146 -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 +146 -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 +104 -0
- package/docs/recipes/22-shop-gold.md +107 -0
- package/docs/recipes/23-ops.md +139 -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 +35 -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 +81 -0
- package/docs/recipes/40-scene.md +79 -0
- package/docs/recipes/41-thing-registry.md +64 -0
- package/docs/recipes/42-terrain-shape.md +64 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +118 -0
- package/docs/recipes/44-water-weather-look-hooks.md +133 -0
- package/docs/recipes/45-cascaded-shadows.md +51 -0
- package/docs/recipes/46-blender-art-route.md +92 -0
- package/docs/recipes/47-island-snow-backdrop.md +44 -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 +9 -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/look.js +5 -0
- package/examples/action/main.js +137 -0
- package/examples/action/models.js +25 -0
- package/examples/sheepisland/GAMEMAP.md +108 -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 +279 -0
- package/index.js +120 -0
- package/llms.txt +56 -0
- package/modules/ambience/Ambience.js +183 -0
- package/modules/camera/FirstPersonCamera.js +133 -0
- package/modules/camera/FixedCamera.js +155 -0
- package/modules/camera/FollowCamera.js +85 -0
- package/modules/camera/RtsCamera.js +134 -0
- package/modules/camera/common.js +152 -0
- package/modules/camera/index.js +11 -0
- package/modules/characters/Character.js +223 -0
- package/modules/characters/NPC.js +242 -0
- package/modules/characters/assetModel.js +42 -0
- package/modules/characters/astar.js +59 -0
- package/modules/characters/behaviors.js +72 -0
- package/modules/characters/footsteps.js +13 -0
- package/modules/characters/index.js +212 -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 +38 -0
- package/modules/characters/npcAvoid.js +129 -0
- package/modules/characters/npcSim.js +144 -0
- package/modules/characters/npcView.js +42 -0
- package/modules/characters/pathAsync.js +107 -0
- package/modules/characters/pathJob.js +61 -0
- package/modules/characters/pathWorker.js +7 -0
- package/modules/characters/playerStrings.js +12 -0
- package/modules/characters/proceduralRig.js +54 -0
- package/modules/collision/Collision.js +176 -0
- package/modules/collision/grid.js +63 -0
- package/modules/content/ids.js +95 -0
- package/modules/content/index.js +152 -0
- package/modules/content/loader.js +187 -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 +133 -0
- package/modules/content/templates.js +189 -0
- package/modules/debug/DebugPanel.js +168 -0
- package/modules/entities/Entities.js +239 -0
- package/modules/entities/build.js +25 -0
- package/modules/entities/index.js +4 -0
- package/modules/flow/index.js +98 -0
- package/modules/gameplay/Container.js +227 -0
- package/modules/gameplay/Containers.js +89 -0
- package/modules/gameplay/Dialogue.js +216 -0
- package/modules/gameplay/Interactions.js +243 -0
- package/modules/gameplay/Inventory.js +214 -0
- package/modules/gameplay/Quests.js +195 -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 +113 -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 +75 -0
- package/modules/hlod/index.js +164 -0
- package/modules/hud/index.js +164 -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 +231 -0
- package/modules/level/nodes.js +84 -0
- package/modules/lights/index.js +224 -0
- package/modules/music/Music.js +290 -0
- package/modules/music/index.js +2 -0
- package/modules/music/rules.js +28 -0
- package/modules/nav/index.js +154 -0
- package/modules/nav/navPath.js +17 -0
- package/modules/net/Client.js +136 -0
- package/modules/net/Host.js +117 -0
- package/modules/net/Net.js +49 -0
- package/modules/net/index.js +75 -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 +143 -0
- package/modules/rigid/RigidBodies.js +262 -0
- package/modules/rigid/Vehicles.js +97 -0
- package/modules/rigid/sync.js +158 -0
- package/modules/settings/Settings.js +294 -0
- package/modules/settings/apply.js +20 -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 +257 -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 +115 -0
- package/modules/sky/fog.js +136 -0
- package/modules/sky/frame.js +76 -0
- package/modules/sky/layers.js +69 -0
- package/modules/sky/look.js +50 -0
- package/modules/sky/schedule.js +80 -0
- package/modules/sky/shader.js +96 -0
- package/modules/sky/shadow.js +80 -0
- package/modules/sky/skyModule.js +59 -0
- package/modules/terrain/ChunkManager.js +291 -0
- package/modules/terrain/chunkJob.js +19 -0
- package/modules/terrain/chunkQueries.js +42 -0
- package/modules/terrain/chunkWorker.js +5 -0
- package/modules/terrain/index.js +110 -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 +249 -0
- package/modules/timeline/Tween.js +118 -0
- package/modules/timeline/letterbox.js +24 -0
- package/modules/timeline/shots.js +88 -0
- package/modules/triggers/index.js +261 -0
- package/modules/vegetation/Vegetation.js +255 -0
- package/modules/vegetation/groundChunks.js +177 -0
- package/modules/vegetation/index.js +40 -0
- package/modules/vegetation/modelGeometry.js +21 -0
- package/modules/water/Water.js +144 -0
- package/modules/water/surface.js +88 -0
- package/modules/weather/Weather.js +251 -0
- package/modules/weather/particles.js +92 -0
- package/modules/weather/shaders.js +49 -0
- package/modules/world/World.js +231 -0
- package/modules/world/cells.js +42 -0
- package/modules/world/index.js +64 -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/views.js +182 -0
- package/package.json +66 -4
- package/presets.js +96 -0
- package/render/PostFX.js +243 -0
- package/render/detail.js +105 -0
- package/render/effects.js +142 -0
- package/render/engineUniforms.js +23 -0
- package/render/fuse.js +72 -0
- package/render/lighting.js +100 -0
- package/render/lights.js +16 -0
- package/render/materials.js +203 -0
- package/render/patches.js +252 -0
- package/render/surface.js +67 -0
- package/render/uniformDecl.js +29 -0
- package/types/common.d.ts +34 -0
- package/types/core.d.ts +1773 -0
- package/types/gameplay.d.ts +1812 -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/Events.d.ts +46 -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 +162 -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 +161 -0
- package/types/generated/core/Stream.d.ts +93 -0
- package/types/generated/core/Threads.d.ts +82 -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 +64 -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 +152 -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 +72 -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 +128 -0
- package/types/generated/render/materials.d.ts +90 -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 +584 -0
- package/types/style.d.ts +628 -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 +195 -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,135 @@
|
|
|
1
|
+
# Game map: styletest (generated, do not edit by hand)
|
|
2
|
+
|
|
3
|
+
> Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /styletest.html, entry `main.js`.
|
|
4
|
+
> Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
|
|
5
|
+
|
|
6
|
+
Content: items 3 · npcs 1 · places 2 · props 12 (from templates 6) · templates 6 · vegetation 5
|
|
7
|
+
|
|
8
|
+
## Design decisions (hand-written, from DESIGN.md)
|
|
9
|
+
|
|
10
|
+
None yet, write them in `DESIGN.md` (why it is designed this way, what not to change).
|
|
11
|
+
|
|
12
|
+
## Engine modules (engine.use)
|
|
13
|
+
|
|
14
|
+
- createEngine: { style: parts.length ? parts : undefined, strings: terrainStrings, saveKey: 'threedog-styletest', ui: { load…
|
|
15
|
+
- openWorld preset ({ camera: fixedCamera(), seed: SEED, terrain: terrainPreset(), flatten: [{ x: stage.x, z: stage.z, …) → world, terrain, vegetation, sky, weather, water, collision, rigid, characters, ambience, settings, debug
|
|
16
|
+
- interactions ({ ...presets.interactions.nearest })
|
|
17
|
+
- dialogue ({ holdSeconds: 1e6 })
|
|
18
|
+
- inventory ({ ...presets.keys.inventory })
|
|
19
|
+
- hud
|
|
20
|
+
- lightPool ({ point: 2 })
|
|
21
|
+
- content
|
|
22
|
+
|
|
23
|
+
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
24
|
+
|
|
25
|
+
- world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
|
|
26
|
+
- terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
|
|
27
|
+
- vegetation: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/vegetation.md`
|
|
28
|
+
- sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
|
|
29
|
+
- weather: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/weather.md`
|
|
30
|
+
- water: `node_modules/threedog/docs/recipes/44-water-weather-look-hooks.md` · `node_modules/threedog/docs/api/water.md`
|
|
31
|
+
- collision: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/collision.md`
|
|
32
|
+
- rigid: `node_modules/threedog/docs/recipes/11-vehicles.md` · `node_modules/threedog/docs/api/rigid.md`
|
|
33
|
+
- characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
|
|
34
|
+
- ambience: `node_modules/threedog/docs/recipes/31-audio.md` · `node_modules/threedog/docs/api/ambience.md`
|
|
35
|
+
- …8 more modules: their pages are in `node_modules/threedog/docs/api/`
|
|
36
|
+
|
|
37
|
+
Not used yet (check these before writing the system yourself):
|
|
38
|
+
|
|
39
|
+
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
40
|
+
- quests: goals with steps, conditions and rewards: `quests({ ...presets.keys.quests })` (keys required), content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
41
|
+
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
42
|
+
|
|
43
|
+
## Files
|
|
44
|
+
|
|
45
|
+
content/*.js is content data: how to write it in `node_modules/threedog/docs/recipes/` (02-npc, 03-items-pickups, 04-quests, 20-content-actions-save…).
|
|
46
|
+
|
|
47
|
+
| File | Lines | Description |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| content/index.js | 10 | |
|
|
50
|
+
| content/items.js | 9 | |
|
|
51
|
+
| content/npcs.js | 9 | |
|
|
52
|
+
| content/places.js | 6 | |
|
|
53
|
+
| content/props.js | 17 | |
|
|
54
|
+
| content/templates.js | 10 | |
|
|
55
|
+
| content/vegetation.js | 32 | |
|
|
56
|
+
| look.js | 12 | This example's look, a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, loo… |
|
|
57
|
+
| main.js | 96 | @ts-check Style test: one fixed scene to judge a style pack by (and the check an AI runs after turn… |
|
|
58
|
+
| models.js | 88 | The exhibits that are not in the lowpoly asset pack, built in code and registered by name in main.j… |
|
|
59
|
+
| overrides.js | 34 | What the style workbench exports: the values the user changed, as a plain object literal to paste i… |
|
|
60
|
+
| panel.js | 136 | Style workbench (?panel=1): sliders and color pickers over the running style test, plus an export o… |
|
|
61
|
+
| params.js | 33 | URL parameters of the style test page. Import this file first in main.js: it rewrites word values i… |
|
|
62
|
+
| views.js | 32 | Named camera positions of the style test. Same name = same framing every time, so two screenshots d… |
|
|
63
|
+
|
|
64
|
+
## NPCs (content/npcs.js)
|
|
65
|
+
|
|
66
|
+
| id | Name | Schedule | Dialogue entry |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| guide | Guide | wander | — |
|
|
69
|
+
|
|
70
|
+
## Dialogues (content/dialogues.js, node → destination)
|
|
71
|
+
|
|
72
|
+
(none)
|
|
73
|
+
|
|
74
|
+
## Items (content/items.js)
|
|
75
|
+
|
|
76
|
+
| id | Name | Description | Stack |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| apple | 🍎 Apple | Crisp and a little sour | 20 |
|
|
79
|
+
| key | 🗝 Brass key | Opens nothing in particular | 1 |
|
|
80
|
+
| wood | 🪵 Wood | Dry and light | 99 |
|
|
81
|
+
|
|
82
|
+
Starting inventory: apple×5, key×1, wood×12. Pickups: 0.
|
|
83
|
+
|
|
84
|
+
## Quests (content/quests.js)
|
|
85
|
+
|
|
86
|
+
(none)
|
|
87
|
+
|
|
88
|
+
## Trigger zones, level markers, places
|
|
89
|
+
|
|
90
|
+
- Place stage: a flat spot near water (found at startup); all exhibits are placed relative to it
|
|
91
|
+
- Place water: the nearest water to the stage (found at startup)
|
|
92
|
+
|
|
93
|
+
## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
|
|
94
|
+
|
|
95
|
+
| Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
|
|
96
|
+
|---|---|---|---|---|---|---|
|
|
97
|
+
| woodBlock | woodBlock | — | — | — | — | 1 placed (stage) |
|
|
98
|
+
| stoneBlock | stoneBlock | — | — | — | — | 1 placed (stage) |
|
|
99
|
+
| metalBall | metalBall | — | — | — | — | 1 placed (stage) |
|
|
100
|
+
| glassPanes | glassPanes | — | — | — | — | 1 placed (stage) |
|
|
101
|
+
| shadowStage | shadowStage | — | — | — | — | 1 placed (stage) |
|
|
102
|
+
| room | room | — | — | — | — | 1 placed (stage) |
|
|
103
|
+
|
|
104
|
+
## Placements (the level is content; counts per content file)
|
|
105
|
+
|
|
106
|
+
- content/props.js: 12 (pine×1, roundTree×1, rock×1, flower×3, template woodBlock×1, template stoneBlock×1, template metalBall×1, template glassPanes×1, template shadowStage×1, template room×1); 12 with an explicit id, places: stage
|
|
107
|
+
- content/npcs.js: 1 (guide)
|
|
108
|
+
- content/vegetation.js: 5 rules (instances generated from each rule)
|
|
109
|
+
|
|
110
|
+
Code that breaks saves or manages world models: none (rule R33).
|
|
111
|
+
|
|
112
|
+
## Timed events (engine.clock, engine.sky)
|
|
113
|
+
|
|
114
|
+
- between('18:00', '06:00') — main.js
|
|
115
|
+
|
|
116
|
+
## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
|
|
117
|
+
|
|
118
|
+
(none)
|
|
119
|
+
|
|
120
|
+
## Events the game emits / listens to
|
|
121
|
+
|
|
122
|
+
| Event | Emitted by the game | Listened to by the game |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| engine:ready | — | main.js |
|
|
125
|
+
|
|
126
|
+
## Saves
|
|
127
|
+
|
|
128
|
+
- Save prefix saveKey: threedog-styletest
|
|
129
|
+
- Content-related saves handled by the engine: story flags and counters (engine.vars), inventory, quest progress, timers (clock, after registered by event name), pickups (world), felled trees (vegetation)
|
|
130
|
+
|
|
131
|
+
## Style pack keys
|
|
132
|
+
|
|
133
|
+
- Style pack: parts
|
|
134
|
+
- Models (asset names): pine, pineLow, roundTree, roundTreeLow, rock, grass, flower, woodBlock, stoneBlock, metalBall, glassPanes, shadowStage, room
|
|
135
|
+
- Vegetation (content/vegetation.js): 松树, 圆树, 石头, 草, 野花
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Merge every content file in content/ into one object that main.js passes to engine.content.load(). Add a line here for each new content file.
|
|
2
|
+
import places from './places.js';
|
|
3
|
+
import items, { startItems } from './items.js';
|
|
4
|
+
import npcs from './npcs.js';
|
|
5
|
+
import vegetation from './vegetation.js';
|
|
6
|
+
import templates from './templates.js';
|
|
7
|
+
import props from './props.js';
|
|
8
|
+
|
|
9
|
+
export default { places, items, startItems, npcs, vegetation, templates, props };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Items for the bag window of the ui view. stack is the max per slot; color is the color when dropped on the ground.
|
|
2
|
+
export default {
|
|
3
|
+
apple: { name: 'Apple', icon: '🍎', desc: 'Crisp and a little sour', stack: 20 },
|
|
4
|
+
key: { name: 'Brass key', icon: '🗝', desc: 'Opens nothing in particular', stack: 1, color: 0xc8a850 },
|
|
5
|
+
wood: { name: 'Wood', icon: '🪵', desc: 'Dry and light', color: 0x8a5a36 },
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const startItems = { apple: 5, key: 1, wood: 12 };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// One character for the close-up view: wander with radius 0 keeps it standing where it starts (a behavior without a schedule).
|
|
2
|
+
export default {
|
|
3
|
+
guide: {
|
|
4
|
+
name: 'Guide',
|
|
5
|
+
colors: { body: 0x4f6d8f, legs: 0x5b4a3a, hair: 0xd8d4cc },
|
|
6
|
+
start: { place: 'stage', x: 2.5, z: 4 }, behavior: 'wander', mind: { radius: 0 },
|
|
7
|
+
},
|
|
8
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Place names: main.js finds a flat spot near water at startup (terrain is procedural). `stage` is where every exhibit stands; `water` is a point on the nearest water.
|
|
2
|
+
export default {
|
|
3
|
+
stage: 'a flat spot near water (found at startup); all exhibits are placed relative to it',
|
|
4
|
+
water: 'the nearest water to the stage (found at startup)',
|
|
5
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The exhibits, relative to the stage (x right, z toward the overview camera, which stands at z = +24).
|
|
2
|
+
// Back row: trees, rock, flowers. Middle row: wood / stone / metal, glass, shadow receiver. Right: the room (interior and exterior in one piece).
|
|
3
|
+
export default [
|
|
4
|
+
{ id: 'pine', model: 'pine', place: 'stage', x: -14, z: -8, scale: 1.2 },
|
|
5
|
+
{ id: 'round-tree', model: 'roundTree', place: 'stage', x: -9, z: -8 },
|
|
6
|
+
{ id: 'rock', model: 'rock', place: 'stage', x: -5, z: -7, rot: 0.6, scale: 1.4 },
|
|
7
|
+
{ id: 'flower-a', model: ['flower', 0xf2d16b], place: 'stage', x: -2.4, z: -5 },
|
|
8
|
+
{ id: 'flower-b', model: ['flower', 0xe08aa0], place: 'stage', x: -1.4, z: -5.4 },
|
|
9
|
+
{ id: 'flower-c', model: ['flower', 0xa8c8f0], place: 'stage', x: -0.6, z: -4.8 },
|
|
10
|
+
{ id: 'wood', template: 'woodBlock', place: 'stage', x: 1.5, z: -3 },
|
|
11
|
+
{ id: 'stone', template: 'stoneBlock', place: 'stage', x: 4, z: -3 },
|
|
12
|
+
{ id: 'metal', template: 'metalBall', place: 'stage', x: 6.5, z: -3 },
|
|
13
|
+
{ id: 'glass', template: 'glassPanes', place: 'stage', x: -6, z: 2.5 },
|
|
14
|
+
{ id: 'shadow-stage', template: 'shadowStage', place: 'stage', x: -1.5, z: 3 },
|
|
15
|
+
{ id: 'room', template: 'room', place: 'stage', x: 14, z: -2, y: 0.02 },
|
|
16
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Templates: the exhibits. Model names are registered in main.js (models.js); trees, rocks and flowers come from the lowpoly asset pack.
|
|
2
|
+
export default {
|
|
3
|
+
woodBlock: { model: 'woodBlock' },
|
|
4
|
+
stoneBlock: { model: 'stoneBlock' },
|
|
5
|
+
metalBall: { model: 'metalBall' },
|
|
6
|
+
glassPanes: { model: 'glassPanes' },
|
|
7
|
+
shadowStage: { model: 'shadowStage' },
|
|
8
|
+
room: { model: 'room' },
|
|
9
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Vegetation: name -> model (an asset name from the lowpoly asset pack; use an array for parameters) and growth rule.
|
|
2
|
+
// rule.biomes lists the biomes it grows in, values are spawn probabilities; rule cannot hold functions (it is sent to a worker thread).
|
|
3
|
+
export default {
|
|
4
|
+
松树: {
|
|
5
|
+
model: 'pine', lod: 'pineLow', wind: 0.022,
|
|
6
|
+
rule: { perChunk: 130, minHeight: 1.6, maxHeight: 40, maxSlope: 0.6, cluster: 'forest', scale: [0.75, 1.6], stretch: [0.85, 1.2], sink: 0.15,
|
|
7
|
+
biomes: { forest: 1, meadow: 0.35, snow: 0.6, wetland: 0.3, riverbank: 0.3 }, collider: 0.35,
|
|
8
|
+
tints: [{ color: [1.35, 1.05, 0.55], chance: 0.06 }] },
|
|
9
|
+
},
|
|
10
|
+
圆树: {
|
|
11
|
+
model: 'roundTree', lod: 'roundTreeLow', wind: 0.03,
|
|
12
|
+
rule: { perChunk: 50, minHeight: 1.6, maxHeight: 22, maxSlope: 0.45, scale: [0.8, 1.3], collider: 0.3,
|
|
13
|
+
biomes: { meadow: 0.8, savanna: 0.35, riverbank: 0.9, forest: 0.3 },
|
|
14
|
+
tints: [{ color: [1.4, 1.0, 0.5], chance: 0.15 }] },
|
|
15
|
+
},
|
|
16
|
+
石头: {
|
|
17
|
+
model: 'rock', maxRing: 3,
|
|
18
|
+
rule: { perChunk: 14, chance: 0.6, minHeight: 0.5, maxHeight: 70, maxSlope: 2, scale: [0.4, 1.6], stretch: [0.5, 0.8], sink: 0.2, tintJitter: 0.15, collider: 0.6 },
|
|
19
|
+
},
|
|
20
|
+
草: {
|
|
21
|
+
model: 'grass', nearOnly: true, maxRing: 1, wind: 0.3,
|
|
22
|
+
rule: { perChunk: 1800, chance: 0.75, minHeight: 1.4, maxHeight: 20, maxSlope: 0.42, scale: [0.7, 1.4], sink: 0.05, avoidFlat: false,
|
|
23
|
+
biomes: { meadow: 1, forest: 0.6, riverbank: 1, wetland: 1, savanna: 0.8 } },
|
|
24
|
+
},
|
|
25
|
+
野花: {
|
|
26
|
+
model: ['flower', 0xf2d16b], nearOnly: true, maxRing: 1, wind: 0.25,
|
|
27
|
+
rule: { perChunk: 260, minHeight: 1.5, maxHeight: 14, maxSlope: 0.35, scale: [0.8, 1.3], sink: 0,
|
|
28
|
+
biomes: { meadow: 1, riverbank: 0.6 },
|
|
29
|
+
tints: [{ color: [1.6, 0.6, 0.7], chance: 0.35 }, { color: [0.8, 0.9, 1.6], chance: 0.25 }] },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This example's look, a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, look] })): how the test surfaces feel.
|
|
2
|
+
// The exhibits ask for roles wood / stone / metal / glass; a style that does not define them falls back to materials.default.
|
|
3
|
+
export default {
|
|
4
|
+
name: 'styletest',
|
|
5
|
+
materials: {
|
|
6
|
+
wood: { type: 'lambert' },
|
|
7
|
+
stone: { type: 'lambert', flatShading: true },
|
|
8
|
+
metal: { type: 'standard', metalness: 0.9, roughness: 0.3 }, // only looks like metal with environment light: ?env=1
|
|
9
|
+
glass: { type: 'phong', shininess: 100 },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Style test: one fixed scene to judge a style pack by (and the check an AI runs after turning a reference picture into a style).
|
|
3
|
+
// Exhibits (content/): character, trees, rock, grass, flowers, water, terrain, glass, a shadow receiver, wood / stone / metal, a lit room (outside and inside),
|
|
4
|
+
// and the UI parts (HUD, dialogue, bag) on the `ui` view. Parameters (params.js): time, weather, style, env, view, panel. Camera views: views.js.
|
|
5
|
+
// main.js holds wiring only: modules, finding the stage, view switching, the lamp. The exhibits are content (rule R33).
|
|
6
|
+
import { params } from './params.js'; // first: rewrites ?time=dusk style words before the engine reads the URL
|
|
7
|
+
import { createEngine, openWorld, presets, content, interactions, dialogue, inventory, fixedCamera, hud, lightPool, createTerrain } from '../../index.js';
|
|
8
|
+
import lowpoly, { assets as lowpolyAssets } from '@threedog/style-lowpoly'; // optional package: the style under test, and the procedural trees / rocks
|
|
9
|
+
import { terrainPreset, riverAt, terrainStrings } from '@threedog/terrain-noise';
|
|
10
|
+
import look from './look.js';
|
|
11
|
+
import data from './content/index.js';
|
|
12
|
+
import { woodBlock, stoneBlock, metalBall, glassPanes, shadowStage, room } from './models.js';
|
|
13
|
+
import { makeViews, pathAt } from './views.js';
|
|
14
|
+
|
|
15
|
+
// ---------- 0. The stage: a flat spot with water close by (same seed = same place every run) ----------
|
|
16
|
+
const SEED = 1337, preview = createTerrain({ seed: SEED, ...terrainPreset() });
|
|
17
|
+
/** Nearest point under water within maxR of (x, z), or null */
|
|
18
|
+
function waterNear(x, z, maxR) {
|
|
19
|
+
for (let r = 8; r <= maxR; r += 3) for (let a = 0; a < 6.28; a += 0.3) {
|
|
20
|
+
const wx = x + Math.cos(a) * r, wz = z + Math.sin(a) * r;
|
|
21
|
+
if (preview.surface(wx, wz) < preview.waterLevel - 1.2) return { x: wx, z: wz };
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
let stage = { x: 0, z: 0 }, water = { x: 30, z: 0 };
|
|
26
|
+
for (let r = 0, found = false; r < 3000 && !found; r += 10) {
|
|
27
|
+
const a = r * 0.37, x = Math.cos(a) * r, z = Math.sin(a) * r, h = preview.surface(x, z);
|
|
28
|
+
if (h > 4 && h < 10 && preview.slope(x, z) < 0.2 && riverAt(x, z, preview.noise) === 0) {
|
|
29
|
+
const w = waterNear(x, z, 60);
|
|
30
|
+
if (w) { stage = { x, z }; water = w; found = true; }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---------- 1. Engine: style under test + open-world preset with a fixed sky (no clock drift between screenshots) ----------
|
|
35
|
+
const parts = params.style === 'none' ? [] : [lowpoly, look];
|
|
36
|
+
if (params.overrides) parts.push(params.overrides); // the workbench's "rebuild preview" values
|
|
37
|
+
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style: parts.length ? parts : undefined, strings: terrainStrings, saveKey: 'threedog-styletest',
|
|
38
|
+
ui: { loading: { title: 'style test' } } });
|
|
39
|
+
engine.use(openWorld({ camera: fixedCamera(), seed: SEED, terrain: terrainPreset(), flatten: [{ x: stage.x, z: stage.z, radius: 30 }], sky: { ...presets.calendar.fixedTime, time: 0.5 },
|
|
40
|
+
weather: presets.weather.temperate, autoWeather: false }),
|
|
41
|
+
interactions({ ...presets.interactions.nearest }), dialogue({ holdSeconds: 1e6 }), inventory({ ...presets.keys.inventory }), hud(), lightPool({ point: 2 }), content());
|
|
42
|
+
|
|
43
|
+
engine.assets.manifest(lowpolyAssets);
|
|
44
|
+
engine.assets.manifest({ name: 'styletest', models: { woodBlock, stoneBlock, metalBall, glassPanes, shadowStage, room } }); // the names content/templates.js uses
|
|
45
|
+
engine.characters.createPlayer({ ...presets.player.thirdPerson, spawn: { x: stage.x + 0.5, z: stage.z + 6 } });
|
|
46
|
+
engine.content.load(data, { places: { stage, water } });
|
|
47
|
+
if (params.env) { engine.sky.setEnvironment({ source: 'sky', intensity: 0.8 }); engine.sky.modify('env', { ambient: 0.6 }); } // soft ambient from the sky: lower the hemisphere ambient so shadows stay
|
|
48
|
+
|
|
49
|
+
// ---------- 2. The room's lamp: emissive plus one pooled light, on from 18:00 to 06:00 ----------
|
|
50
|
+
const lampPos = [stage.x + 14, engine.surface(stage.x + 14, stage.z - 2) + 2.7, stage.z - 2];
|
|
51
|
+
const lampLight = engine.lightPool.add({ x: lampPos[0], y: lampPos[1], z: lampPos[2] }, { color: 0xffc070, intensity: 0, distance: 9 });
|
|
52
|
+
let lampOn = false;
|
|
53
|
+
engine.sky.between('18:00', '06:00', { on: () => { lampOn = true; }, off: () => { lampOn = false; } });
|
|
54
|
+
engine.onFrame(() => {
|
|
55
|
+
const lamp = /** @type {import('three').Mesh<any, import('three').MeshLambertMaterial> | undefined} */ (engine.world.view('room')?.getObjectByName('lamp'));
|
|
56
|
+
if (lamp) lamp.material.emissiveIntensity = lampOn ? 1.6 : 0;
|
|
57
|
+
lampLight.set({ intensity: lampOn ? 5 : 0 });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// ---------- 3. Views: an op, so the URL, the dev bridge and tests switch the same way ----------
|
|
61
|
+
/** @type {{ view: string, since: number, views: ReturnType<typeof makeViews> }} */
|
|
62
|
+
const state = { view: params.view, since: 0, views: /** @type {any} */ (null) };
|
|
63
|
+
/** Show the UI exhibits only on the ui view; close them when leaving it */
|
|
64
|
+
function showUi(on) {
|
|
65
|
+
if (on) {
|
|
66
|
+
engine.dialogue.say('The light is best just before dusk. Mind the step.', { speaker: 'Guide', lock: false });
|
|
67
|
+
engine.ui.open('inventory');
|
|
68
|
+
} else { engine.dialogue.end(); engine.ui.close('inventory'); }
|
|
69
|
+
}
|
|
70
|
+
/** Fixed camera (views.js shots): a view is a shot, cut to at once. The path shot is moved along its line every frame, from the moment it is chosen */
|
|
71
|
+
function setView(name) {
|
|
72
|
+
const cam = /** @type {any} */ (engine.cameraRig), views = makeViews(engine, stage, water);
|
|
73
|
+
for (const [n, v] of Object.entries(views)) cam.add(n, { position: v.pos, lookAt: v.look });
|
|
74
|
+
state.view = name; state.since = engine.elapsed; state.views = views;
|
|
75
|
+
showUi(name === 'ui');
|
|
76
|
+
cam.cut(name);
|
|
77
|
+
}
|
|
78
|
+
engine.onFrame(() => {
|
|
79
|
+
if (state.view === 'path' && state.views) /** @type {any} */ (engine.cameraRig).shots.path.position.fromArray(pathAt(state.views.path, engine.elapsed - state.since));
|
|
80
|
+
});
|
|
81
|
+
engine.ops.define('styletest.view', {
|
|
82
|
+
desc: 'Move the camera to a named view: overview, character, water, room, path, ui', args: { name: 'string' },
|
|
83
|
+
can: (e, { name }) => ['overview', 'character', 'water', 'room', 'path', 'ui'].includes(name) ? true : 'unknownView',
|
|
84
|
+
run: (e, { name }) => { setView(name); return name; },
|
|
85
|
+
reasons: { unknownView: 'View names: overview, character, water, room, path, ui' },
|
|
86
|
+
});
|
|
87
|
+
engine.describe.add('styletest', () => ({ view: state.view, style: params.style, env: params.env, panel: params.panel, stage: { x: +stage.x.toFixed(1), z: +stage.z.toFixed(1) } }));
|
|
88
|
+
engine.events.on('engine:ready', () => engine.ops.run('styletest.view', { name: params.view }));
|
|
89
|
+
if (params.badView) console.warn(`styletest: unknown view '${params.badView}', showing overview. Views: overview, character, water, room, path, ui`);
|
|
90
|
+
|
|
91
|
+
// The workbench is a dev tool loaded only on ?panel=1 (its package may be missing: panel.js then says so in the page)
|
|
92
|
+
if (params.panel) import('./panel.js').then(m => m.openPanel(engine, params.overrides));
|
|
93
|
+
|
|
94
|
+
engine.start();
|
|
95
|
+
window.engine = engine; // handy for debugging in the browser console
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// The exhibits that are not in the lowpoly asset pack, built in code and registered by name in main.js (content/templates.js places them).
|
|
2
|
+
// Every surface goes through makeMaterial(role), so the style decides the feel: roles wood, stone, metal, glass, building.
|
|
3
|
+
// Shadow flags are set here, on the model (the engine does not guess them).
|
|
4
|
+
import { THREE, mergeColored, makeMaterial } from '../../index.js';
|
|
5
|
+
|
|
6
|
+
const mesh = (geo, role, params = {}) => {
|
|
7
|
+
const m = new THREE.Mesh(geo, makeMaterial(role, params));
|
|
8
|
+
m.castShadow = m.receiveShadow = true;
|
|
9
|
+
return m;
|
|
10
|
+
};
|
|
11
|
+
const box = (w, h, d, x, y, z, color) => [new THREE.BoxGeometry(w, h, d).translate(x, y, z), color];
|
|
12
|
+
|
|
13
|
+
/** A wooden crate: planks on a frame */
|
|
14
|
+
export function woodBlock() {
|
|
15
|
+
const g = new THREE.Group();
|
|
16
|
+
g.add(mesh(new THREE.BoxGeometry(1.6, 1.6, 1.6).translate(0, 0.8, 0), 'wood', { color: 0xb08850 }));
|
|
17
|
+
for (const y of [0.35, 0.8, 1.25]) g.add(mesh(new THREE.BoxGeometry(1.64, 0.06, 1.64).translate(0, y, 0), 'wood', { color: 0x8a6a3c }));
|
|
18
|
+
return g;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A rough stone block (faceted) */
|
|
22
|
+
export function stoneBlock() {
|
|
23
|
+
const geo = new THREE.DodecahedronGeometry(1, 0).scale(1.1, 0.95, 1).translate(0, 0.85, 0);
|
|
24
|
+
return mesh(geo, 'stone', { color: 0x8f897d, flatShading: true });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A metal ball on a plinth: the surface that needs environment light to look like metal */
|
|
28
|
+
export function metalBall() {
|
|
29
|
+
const g = new THREE.Group();
|
|
30
|
+
g.add(mesh(new THREE.CylinderGeometry(0.7, 0.8, 0.3, 12).translate(0, 0.15, 0), 'stone', { color: 0x7a766e }));
|
|
31
|
+
g.add(mesh(new THREE.SphereGeometry(0.85, 24, 16).translate(0, 1.2, 0), 'metal', { color: 0xc8ccd2 }));
|
|
32
|
+
return g;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Two glass panes in front of a colored block: shows transparency, sorting and what is seen through it */
|
|
36
|
+
export function glassPanes() {
|
|
37
|
+
const g = new THREE.Group();
|
|
38
|
+
g.add(mesh(new THREE.BoxGeometry(1.4, 1.4, 0.4).translate(0, 0.9, -0.9), 'building', { color: 0xd8604a }));
|
|
39
|
+
for (const [x, z, color] of [[-0.4, 0, 0xbfe3f0], [0.5, 0.5, 0xf0d8a8]]) {
|
|
40
|
+
const pane = mesh(new THREE.BoxGeometry(1.5, 2, 0.06).translate(x, 1, z), 'glass', { color, transparent: true, opacity: 0.35, depthWrite: false });
|
|
41
|
+
pane.castShadow = false;
|
|
42
|
+
g.add(pane);
|
|
43
|
+
}
|
|
44
|
+
return g;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A pale slab with a pillar and a ball standing on it: the shadow receiver (edge softness, shadow darkness, acne) */
|
|
48
|
+
export function shadowStage() {
|
|
49
|
+
const g = new THREE.Group();
|
|
50
|
+
g.add(mesh(new THREE.BoxGeometry(5, 0.15, 5).translate(0, 0.075, 0), 'building', { color: 0xf0ece4 }));
|
|
51
|
+
g.add(mesh(new THREE.BoxGeometry(0.7, 2.4, 0.7).translate(-1, 1.35, -0.6), 'building', { color: 0xe8e2d6 }));
|
|
52
|
+
g.add(mesh(new THREE.IcosahedronGeometry(0.6, 1).translate(1, 0.75, 0.4), 'building', { color: 0xe8e2d6 }));
|
|
53
|
+
return g;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A small room, 6 x 5 m, front (+z) toward the overview camera. Walls with a window and a door, a flat roof, a table, a bed and a lamp named 'lamp'
|
|
58
|
+
* (main.js lights it at night). Outside it shows the walls in sun; inside, the window light against the dark corners.
|
|
59
|
+
*/
|
|
60
|
+
export function room() {
|
|
61
|
+
const g = new THREE.Group();
|
|
62
|
+
const WALL = 0xe8dcc4, TRIM = 0x6b4a32;
|
|
63
|
+
const parts = [
|
|
64
|
+
box(6.4, 0.2, 5.4, 0, 0.1, 0, 0x9a8468), // floor slab
|
|
65
|
+
box(6, 3, 0.2, 0, 1.6, -2.4, WALL), box(0.2, 3, 5, -2.9, 1.6, 0, WALL), box(0.2, 3, 5, 2.9, 1.6, 0, WALL), // back, left, right walls
|
|
66
|
+
// front wall (z = +2.4) with a window (x -2.2..-0.8, y 1..2.2) and a door (x 1.4..2.4)
|
|
67
|
+
box(0.8, 3, 0.2, -2.6, 1.6, 2.4, WALL), box(1.4, 0.8, 0.2, -1.5, 0.7 + 0.2, 2.4, WALL), box(1.4, 0.8, 0.2, -1.5, 2.6 + 0.2, 2.4, WALL),
|
|
68
|
+
box(2.2, 3, 0.2, 0.3, 1.6, 2.4, WALL), box(1, 0.8, 0.2, 1.9, 2.6 + 0.2, 2.4, WALL), box(0.6, 3, 0.2, 2.7, 1.6, 2.4, WALL),
|
|
69
|
+
box(1.6, 0.08, 0.3, -1.5, 1.04 + 0.2, 2.5, TRIM), // window sill
|
|
70
|
+
box(6.8, 0.25, 5.8, 0, 3.3, 0, 0xa4553c), // flat roof
|
|
71
|
+
];
|
|
72
|
+
const shell = mesh(mergeColored(/** @type {any} */ (parts)), 'building', { vertexColors: true });
|
|
73
|
+
g.add(shell);
|
|
74
|
+
// furniture: a table and a bed in the dark half of the room
|
|
75
|
+
g.add(mesh(new THREE.BoxGeometry(1.4, 0.1, 0.8).translate(1.2, 0.85, -1.2), 'wood', { color: 0x8a6a3c }));
|
|
76
|
+
for (const [x, z] of [[0.6, -1.5], [1.8, -1.5], [0.6, -0.9], [1.8, -0.9]]) g.add(mesh(new THREE.BoxGeometry(0.08, 0.7, 0.08).translate(x, 0.5, z), 'wood', { color: 0x6b4a32 }));
|
|
77
|
+
g.add(mesh(new THREE.BoxGeometry(1.2, 0.4, 2).translate(-2, 0.5, -1.2), 'wood', { color: 0x9a7a52 }));
|
|
78
|
+
g.add(mesh(new THREE.BoxGeometry(1.1, 0.15, 1.2).translate(-2, 0.78, -1.6), 'building', { color: 0xd8d4cc }));
|
|
79
|
+
// window glass and the lamp
|
|
80
|
+
const glass = mesh(new THREE.BoxGeometry(1.4, 1.2, 0.04).translate(-1.5, 1.6, 2.4), 'glass', { color: 0xbfe3f0, transparent: true, opacity: 0.3, depthWrite: false });
|
|
81
|
+
glass.castShadow = false;
|
|
82
|
+
g.add(glass);
|
|
83
|
+
const lamp = mesh(new THREE.BoxGeometry(0.3, 0.3, 0.3).translate(0, 2.8, 0), 'lamp', { color: 0x6b5a40, emissive: 0xffc070, emissiveIntensity: 0 });
|
|
84
|
+
lamp.name = 'lamp';
|
|
85
|
+
g.add(lamp);
|
|
86
|
+
return g;
|
|
87
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// What the style workbench exports: the values the user changed, as a plain object literal to paste into `style: [lowpoly, { ... }]`.
|
|
2
|
+
// Pure functions (no DOM, no engine) so a test can run them on their own.
|
|
3
|
+
|
|
4
|
+
/** Set a value at a path of keys inside a nested plain object, creating the objects on the way */
|
|
5
|
+
export function putAt(obj, path, value) {
|
|
6
|
+
let o = obj;
|
|
7
|
+
for (const k of path.slice(0, -1)) o = o[k] ??= {};
|
|
8
|
+
o[path.at(-1)] = value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** '#rrggbb' <-> 0xrrggbb (the pack's color form); other strings (rgba(...)) pass through */
|
|
12
|
+
export const hexOf = n => '#' + n.toString(16).padStart(6, '0');
|
|
13
|
+
export const numOf = s => (/^#[0-9a-f]{6}$/i.test(s) ? parseInt(s.slice(1), 16) : s);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Object literal source of the changes. A number under a key listed in `colors` (dotted paths such as 'palette.pine') prints as 0xrrggbb,
|
|
17
|
+
* other numbers as they are rounded to 3 decimals, strings quoted.
|
|
18
|
+
* @param {Record<string, any>} obj @param {Set<string>} [colors] @param {string} [prefix] @param {number} [depth]
|
|
19
|
+
*/
|
|
20
|
+
export function literal(obj, colors = new Set(), prefix = '', depth = 0) {
|
|
21
|
+
const pad = ' '.repeat(depth + 1), keys = Object.keys(obj);
|
|
22
|
+
if (!keys.length) return '{}';
|
|
23
|
+
const rows = keys.map(k => {
|
|
24
|
+
const v = obj[k], path = prefix ? `${prefix}.${k}` : k, name = /^[A-Za-z_$][\w$]*$/.test(k) ? k : JSON.stringify(k);
|
|
25
|
+
let src;
|
|
26
|
+
if (v === null) src = 'null';
|
|
27
|
+
else if (typeof v === 'object') src = literal(v, colors, path, depth + 1);
|
|
28
|
+
else if (typeof v === 'number') src = colors.has(path) ? '0x' + v.toString(16).padStart(6, '0') : String(+v.toFixed(3));
|
|
29
|
+
else src = JSON.stringify(v);
|
|
30
|
+
return `${pad}${name}: ${src},`;
|
|
31
|
+
});
|
|
32
|
+
return `{\n${rows.join('\n')}\n${' '.repeat(depth)}}`;
|
|
33
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Style workbench (?panel=1): sliders and color pickers over the running style test, plus an export of what changed.
|
|
2
|
+
// Tweakpane is a dev tool, not an engine dependency: it is a devDependency of the repo and found at build time by the glob below.
|
|
3
|
+
// If it is not installed the page says so and runs on without the panel.
|
|
4
|
+
//
|
|
5
|
+
// Two kinds of values, never mixed up in the panel:
|
|
6
|
+
// live the engine has an API that changes it while running: renderer exposure, sky time, environment lighting, water color, fog,
|
|
7
|
+
// post effects, UI colors (CSS variables). The picture changes at once.
|
|
8
|
+
// rebuild values read once at startup (the procedural models' palette, terrain colors, wave shape). The panel keeps them and
|
|
9
|
+
// "apply and rebuild" reloads the page with them as an extra style part (?ov=...). The picture does NOT change until then.
|
|
10
|
+
// The exported object holds style fields only (what `style: [lowpoly, {...}]` accepts); the running engine.style and the pack are never written.
|
|
11
|
+
import { putAt, hexOf, numOf, literal } from './overrides.js';
|
|
12
|
+
|
|
13
|
+
// @ts-ignore Vite's import.meta.glob (not in ImportMeta outside Vite); empty when the package is not installed
|
|
14
|
+
const loaders = import.meta.glob('../../../../node_modules/tweakpane/dist/tweakpane.js');
|
|
15
|
+
const UI_KEYS = ['bg', 'fg', 'muted', 'accent', 'good', 'line'];
|
|
16
|
+
const LIVE = 'live', REBUILD = ' [needs rebuild]';
|
|
17
|
+
const HOW = 'Run `npm install` in the repository root (tweakpane is a devDependency), then reload. 风格工作台需要 tweakpane:先运行 npm install。';
|
|
18
|
+
|
|
19
|
+
/** Show why there is no panel, in the page (not only the console) */
|
|
20
|
+
function note(text) {
|
|
21
|
+
const el = document.getElementById('panel-note');
|
|
22
|
+
if (el) { el.textContent = text; el.hidden = false; }
|
|
23
|
+
console.warn('styletest panel: ' + text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {any} engine
|
|
28
|
+
* @param {Record<string, any> | null} base overrides already in the URL (?ov=), kept and extended
|
|
29
|
+
* @returns {Promise<boolean>} whether the panel is open
|
|
30
|
+
*/
|
|
31
|
+
export async function openPanel(engine, base) {
|
|
32
|
+
const load = Object.values(loaders)[0];
|
|
33
|
+
if (!load) { note('Style workbench needs the dev package "tweakpane", which is not installed. ' + HOW); return false; }
|
|
34
|
+
/** @type {any} */ let Pane;
|
|
35
|
+
try { ({ Pane } = await load()); } catch (e) { note(`Style workbench could not load tweakpane (${String(e).slice(0, 100)}). ` + HOW); return false; }
|
|
36
|
+
const changes = structuredClone(base ?? {}), colors = new Set();
|
|
37
|
+
const notes = new Map(); // post effect -> changed params (an effect list cannot be written as a style literal)
|
|
38
|
+
const put = (path, v, isColor = false) => { putAt(changes, path, v); if (isColor) colors.add(path.join('.')); };
|
|
39
|
+
const host = document.createElement('div');
|
|
40
|
+
host.style.cssText = 'position:fixed;top:8px;right:8px;width:310px;max-height:calc(100vh - 16px);overflow:auto;z-index:1000';
|
|
41
|
+
document.body.appendChild(host);
|
|
42
|
+
const pane = new Pane({ title: 'Style workbench', container: host });
|
|
43
|
+
|
|
44
|
+
// ---- live: exposure, sky time, light multipliers (preview aids: not style fields, never exported) ----
|
|
45
|
+
const sky = pane.addFolder({ title: `Light (${LIVE})` });
|
|
46
|
+
const light = { exposure: engine.renderer.toneMappingExposure, time: engine.sky.timeOfDay * 24, sun: 1, ambient: 1, fog: 1 };
|
|
47
|
+
sky.addBinding(light, 'exposure', { min: 0.2, max: 3, step: 0.01, label: '曝光 exposure' })
|
|
48
|
+
.on('change', e => { engine.renderer.toneMappingExposure = e.value; put(['exposure'], e.value); });
|
|
49
|
+
sky.addBinding(light, 'time', { min: 0, max: 24, step: 0.1, label: '天空时间 hour (preview)' })
|
|
50
|
+
.on('change', e => { engine.sky.timeOfDay = e.value / 24 % 1; });
|
|
51
|
+
const layer = () => engine.sky.modify('workbench', { sun: light.sun, ambient: light.ambient, fog: light.fog });
|
|
52
|
+
for (const [k, label] of [['sun', '阳光倍率 sun x (preview)'], ['ambient', '环境光倍率 ambient x (preview)'], ['fog', '雾距离倍率 fog x (preview)']]) {
|
|
53
|
+
sky.addBinding(light, k, { min: 0.1, max: 3, step: 0.05, label }).on('change', layer);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---- live: environment lighting ----
|
|
57
|
+
const envState = { on: !!engine.sky.environment, intensity: engine.sky.environment?.intensity ?? 0.8 };
|
|
58
|
+
const env = pane.addFolder({ title: `环境照明 (${LIVE})` });
|
|
59
|
+
const applyEnv = () => {
|
|
60
|
+
const on = envState.on, opts = { source: 'sky', intensity: envState.intensity };
|
|
61
|
+
engine.sky.setEnvironment(on ? opts : null);
|
|
62
|
+
put(['sky', 'environment'], on ? opts : null);
|
|
63
|
+
};
|
|
64
|
+
env.addBinding(envState, 'on', { label: '开 on' }).on('change', applyEnv);
|
|
65
|
+
env.addBinding(envState, 'intensity', { min: 0, max: 2, step: 0.05, label: '强度 intensity' }).on('change', () => { if (envState.on) applyEnv(); });
|
|
66
|
+
|
|
67
|
+
// ---- live: water color (the shared water material) ----
|
|
68
|
+
const wm = engine.water?.material;
|
|
69
|
+
if (wm?.color) {
|
|
70
|
+
const water = { color: hexOf(wm.color.getHex()) };
|
|
71
|
+
pane.addFolder({ title: `水 (${LIVE})` }).addBinding(water, 'color', { label: '颜色 color' })
|
|
72
|
+
.on('change', e => { wm.color.set(e.value); put(['water', 'color'], numOf(e.value), true); });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ---- live: post effects, from engine.post.list() / get() / set() ----
|
|
76
|
+
const post = pane.addFolder({ title: `后期 post (${LIVE})`, expanded: false });
|
|
77
|
+
for (const { name, enabled } of engine.post.list()) {
|
|
78
|
+
const h = engine.post.get(name), f = post.addFolder({ title: name, expanded: false });
|
|
79
|
+
const noteOf = () => notes.get(name) ?? notes.set(name, {}).get(name);
|
|
80
|
+
f.addBinding({ enabled }, 'enabled', { label: '开 on' }).on('change', e => { engine.post.enable(name, e.value); noteOf().enabled = e.value; });
|
|
81
|
+
for (const [k, v] of Object.entries(h.params)) {
|
|
82
|
+
if (typeof v !== 'number' && typeof v !== 'boolean') continue; // lut textures, functions...: not editable here
|
|
83
|
+
const range = typeof v === 'number' ? { step: Math.abs(v) >= 10 ? 1 : 0.01, min: Math.min(0, v * 2), max: Math.max(1, v * 3) } : {};
|
|
84
|
+
f.addBinding({ [k]: v }, k, range).on('change', e => { h.set({ [k]: e.value }); noteOf()[k] = e.value; });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---- live: UI colors, CSS variables on engine.uiRoot ----
|
|
89
|
+
const css = getComputedStyle(engine.uiRoot), uiVals = {};
|
|
90
|
+
for (const k of UI_KEYS) { const v = css.getPropertyValue('--threedog-' + k).trim(); if (v) uiVals[k] = v; }
|
|
91
|
+
const ui = pane.addFolder({ title: `界面颜色 ui (${LIVE})`, expanded: false });
|
|
92
|
+
for (const k of Object.keys(uiVals)) ui.addBinding(uiVals, k).on('change', e => { engine.uiRoot.style.setProperty('--threedog-' + k, e.value); put(['ui', k], e.value); });
|
|
93
|
+
|
|
94
|
+
// ---- rebuild: values the engine reads at startup ----
|
|
95
|
+
const rb = pane.addFolder({ title: 'Needs rebuild (press "apply and rebuild")', expanded: false });
|
|
96
|
+
const style = engine.style ?? {};
|
|
97
|
+
for (const [path, src, title] of [['palette', style.palette, '材质用途/模型色 palette'], ['terrain.colors', style.terrain?.colors, '地形色 terrain.colors']]) {
|
|
98
|
+
if (!src) continue;
|
|
99
|
+
const f = rb.addFolder({ title: title + REBUILD, expanded: false }), vals = {};
|
|
100
|
+
for (const [k, v] of Object.entries(src)) if (typeof v === 'number') vals[k] = hexOf(v);
|
|
101
|
+
for (const k of Object.keys(vals)) f.addBinding(vals, k).on('change', e => put([...path.split('.'), k], numOf(e.value), true));
|
|
102
|
+
}
|
|
103
|
+
if (style.water) {
|
|
104
|
+
const f = rb.addFolder({ title: '水波 water' + REBUILD, expanded: false }), vals = {};
|
|
105
|
+
for (const k of ['waveHeight', 'waveScale', 'waveSpeed', 'fresnel']) if (typeof style.water[k] === 'number') vals[k] = style.water[k];
|
|
106
|
+
for (const k of Object.keys(vals)) f.addBinding(vals, k, { step: 0.01 }).on('change', e => put(['water', k], e.value));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ---- export / rebuild ----
|
|
110
|
+
const out = { text: '' };
|
|
111
|
+
const exportText = () => {
|
|
112
|
+
let s = `// paste into createEngine({ style: [lowpoly, { ... }] }):\n${literal(changes, colors)}`;
|
|
113
|
+
const posts = [...notes].filter(([, v]) => Object.keys(v).length);
|
|
114
|
+
if (posts.length) {
|
|
115
|
+
s += '\n// post effects are a list, not a literal: call the factory again with these (postAdd(bloom({ strength: 0.6 }))):\n';
|
|
116
|
+
s += posts.map(([n, v]) => `// ${n}: ${JSON.stringify(v)}`).join('\n');
|
|
117
|
+
}
|
|
118
|
+
return s;
|
|
119
|
+
};
|
|
120
|
+
const ex = pane.addFolder({ title: '导出 / 重建' });
|
|
121
|
+
const mon = ex.addBinding(out, 'text', { readonly: true, multiline: true, rows: 8, label: '' });
|
|
122
|
+
const show = () => { out.text = exportText(); mon.refresh(); return out.text; };
|
|
123
|
+
ex.addButton({ title: '导出覆盖配置 export overrides' }).on('click', () => { navigator.clipboard?.writeText(show()).catch(() => {}); });
|
|
124
|
+
const reload = ov => {
|
|
125
|
+
const u = new URL(location.href);
|
|
126
|
+
if (ov) u.searchParams.set('ov', JSON.stringify(ov)); else u.searchParams.delete('ov');
|
|
127
|
+
location.href = u.href;
|
|
128
|
+
};
|
|
129
|
+
ex.addButton({ title: '应用并重建预览 apply and rebuild' }).on('click', () => reload(changes));
|
|
130
|
+
ex.addButton({ title: '清除覆盖 clear overrides' }).on('click', () => reload(null));
|
|
131
|
+
|
|
132
|
+
engine.describe.add('stylePanel', () => ({ open: true, changes: JSON.parse(JSON.stringify(changes)) }));
|
|
133
|
+
/** @type {any} */ (engine).styleWorkbench = { pane, export: show, changes }; // for tests and the dev bridge
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// URL parameters of the style test page. Import this file first in main.js: it rewrites word values into the forms the engine's own
|
|
2
|
+
// URL state understands (time=dusk -> 18:30, weather=雨 -> rain) before createEngine reads the URL.
|
|
3
|
+
// time day | dusk | night, or HH:MM weather clear | rain | snow (晴 雨 雪), or any engine weather name
|
|
4
|
+
// style lowpoly | none env 1 = environment lighting from the sky (default 0)
|
|
5
|
+
// view overview | character | water | room | path | ui (总览 角色特写 水面 室内 移动镜头路径 界面)
|
|
6
|
+
// panel 1 = the style workbench (needs the tweakpane dev package)
|
|
7
|
+
// ov style overrides the workbench exports for "rebuild preview" (JSON, URL-encoded)
|
|
8
|
+
/** @type {Record<string, string>} */
|
|
9
|
+
const TIME = { day: '12:00', 白天: '12:00', dusk: '18:30', 黄昏: '18:30', night: '23:00', 夜晚: '23:00' };
|
|
10
|
+
/** @type {Record<string, string>} */
|
|
11
|
+
const WEATHER = { 晴: 'clear', 雨: 'rain', 雪: 'snow' };
|
|
12
|
+
/** @type {Record<string, string>} */
|
|
13
|
+
export const VIEWS = { 总览: 'overview', 角色特写: 'character', 水面: 'water', 室内: 'room', 移动镜头路径: 'path', 界面: 'ui' };
|
|
14
|
+
export const VIEW_NAMES = ['overview', 'character', 'water', 'room', 'path', 'ui'];
|
|
15
|
+
|
|
16
|
+
const url = new URL(location.href), q = url.searchParams;
|
|
17
|
+
let changed = false;
|
|
18
|
+
for (const [key, map] of /** @type {[string, Record<string, string>][]} */ ([['time', TIME], ['weather', WEATHER]])) {
|
|
19
|
+
const v = q.get(key);
|
|
20
|
+
if (v && map[v]) { q.set(key, map[v]); changed = true; }
|
|
21
|
+
}
|
|
22
|
+
if (changed) history.replaceState(null, '', url);
|
|
23
|
+
|
|
24
|
+
const view = VIEWS[q.get('view')] ?? q.get('view') ?? 'overview';
|
|
25
|
+
export const params = Object.freeze({
|
|
26
|
+
view: VIEW_NAMES.includes(view) ? view : 'overview',
|
|
27
|
+
style: q.get('style') === 'none' ? 'none' : 'lowpoly',
|
|
28
|
+
env: q.get('env') === '1',
|
|
29
|
+
panel: q.get('panel') === '1',
|
|
30
|
+
overrides: q.get('ov') ? JSON.parse(q.get('ov')) : null,
|
|
31
|
+
badView: q.has('view') && !VIEW_NAMES.includes(view) ? q.get('view') : null,
|
|
32
|
+
});
|