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
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
// Style pack (style): looks only (render / post, materials and shaders, sky, lighting, environment colors, particle looks, UI look). Every item is optional;
|
|
2
|
+
// the engine ships no art and falls back to neutral gray placeholders for what is omitted. Not here: sounds (createEngine({ audio })), model and texture
|
|
3
|
+
// files or generators (asset packs, engine.assets.manifest), gameplay data (content packs, engine.content.load), and anything that changes the world or
|
|
4
|
+
// the rules: water level / sea / size go to water({ level, sea, size }), terrain shape and size to terrain({...}) (a dev error says so). Swapping the style must
|
|
5
|
+
// never move the map. A style may be a list of parts (StyleInput).
|
|
6
|
+
// Example: the optional @threedog/style-lowpoly package (packages/styles/lowpoly/index.js).
|
|
7
|
+
import type { ColorLike, BufferGeometry, Object3D, Material, Loose } from './common';
|
|
8
|
+
import type { Engine } from './core';
|
|
9
|
+
import type { SteepRule, WeatherPreset, TerrainConfig, Sky } from './world';
|
|
10
|
+
import type { ParticleOptions, CharacterRig } from './gameplay';
|
|
11
|
+
import type { ShaderPatch } from './generated/render/patches';
|
|
12
|
+
|
|
13
|
+
/** Material finish: 'lambert' matte | 'phong' with highlights | 'standard' realistic | 'physical' | 'toon' cel-shaded steps | 'basic' unlit */
|
|
14
|
+
export type MaterialType = Loose<'lambert' | 'phong' | 'standard' | 'physical' | 'toon' | 'basic'>;
|
|
15
|
+
/** Material parameters for one role (other fields are set on the three.js material as is, e.g. roughness, shininess, specular) */
|
|
16
|
+
export interface MaterialSpec {
|
|
17
|
+
/** Material type, default 'lambert' */
|
|
18
|
+
type?: MaterialType;
|
|
19
|
+
/** Number of light/dark steps for the toon type, default 3 */
|
|
20
|
+
steps?: number;
|
|
21
|
+
/** toon only: the light ramp, dark to light: grays 0-1 (light strength in the band) or colors (tint the band). Replaces steps */
|
|
22
|
+
ramp?: (number | ColorLike)[];
|
|
23
|
+
/** toon only, with ramp: 0 = hard bands, up to 1 = the bands melt into each other */
|
|
24
|
+
soften?: number;
|
|
25
|
+
color?: ColorLike;
|
|
26
|
+
/**
|
|
27
|
+
* Texture slots take an asset name: map, emissiveMap (sRGB), normalMap, roughnessMap, metalnessMap, aoMap, bumpMap, alphaMap, displacementMap... (linear).
|
|
28
|
+
* Loaded through engine.assets.texture, a neutral stand-in until the image arrives; the key must be a slot the type has (roughnessMap needs 'standard').
|
|
29
|
+
* A THREE.Texture also works. Example: { type: 'standard', map: 'rock.png', normalMap: 'rock_n.png', repeat: 4 }
|
|
30
|
+
*/
|
|
31
|
+
map?: string | import('three').Texture;
|
|
32
|
+
normalMap?: string | import('three').Texture;
|
|
33
|
+
roughnessMap?: string | import('three').Texture;
|
|
34
|
+
/** How many times the textures of this material repeat (a number, or [x, y]); default 1 */
|
|
35
|
+
repeat?: number | [number, number];
|
|
36
|
+
/** Texture wrapping: 'repeat' (default) | 'clamp' | 'mirror' */
|
|
37
|
+
wrap?: Loose<'repeat' | 'clamp' | 'mirror'>;
|
|
38
|
+
/** Grain, paper, strokes or a texture laid over the surface in world space (no UVs needed); off unless given */
|
|
39
|
+
detail?: MaterialDetail;
|
|
40
|
+
/** Extra light shaping (shadow tint, rim, wrap, your own GLSL); merged over style.lighting, false opts out */
|
|
41
|
+
lighting?: MaterialLighting | false;
|
|
42
|
+
[prop: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The `detail` surface patch. Source: texture (asset name) or noise ('grain' | 'paper' | 'stroke', default grain) or glsl (your own sampler
|
|
47
|
+
* function). Effects: color (strength, mode), normal (relief height in meters), roughness (amount). Every number is a uniform, so many materials
|
|
48
|
+
* with different values share one shader program. Channels (color / normal / roughness) are fixed when the material is made.
|
|
49
|
+
*/
|
|
50
|
+
export interface MaterialDetail {
|
|
51
|
+
texture?: string | import('three').Texture;
|
|
52
|
+
noise?: Loose<'grain' | 'paper' | 'stroke'>;
|
|
53
|
+
/** Replaces the noise: `vec4 threedogDetailSample(vec2 p)` returns vec4(color rgb, height 0-1); p is scaled, turned, stretched */
|
|
54
|
+
glsl?: string;
|
|
55
|
+
/** Uniforms for glsl: numbers, colors, [x, y(, z, w)] arrays or textures */
|
|
56
|
+
uniforms?: Record<string, any>;
|
|
57
|
+
/** 'world' (default, looks straight down) | 'triplanar' (three axis planes blended by the surface normal; for walls and rocks) */
|
|
58
|
+
projection?: Loose<'world' | 'triplanar'>;
|
|
59
|
+
/** Repeats per meter, default 0.25 */
|
|
60
|
+
scale?: number;
|
|
61
|
+
/** Color effect 0-1, default 0.35 (0 turns the color part off) */
|
|
62
|
+
strength?: number;
|
|
63
|
+
/** How the color is applied: 'multiply' (default) | 'add' (lighter and darker) | 'mix' (towards the sample color) */
|
|
64
|
+
mode?: Loose<'multiply' | 'add' | 'mix'>;
|
|
65
|
+
/** Colors the sample (default white) */
|
|
66
|
+
tint?: ColorLike;
|
|
67
|
+
/** Degrees; turns the pattern (strokes run along it) */
|
|
68
|
+
direction?: number;
|
|
69
|
+
/** Stretches the pattern along direction (default 1, strokes 6) */
|
|
70
|
+
stretch?: number;
|
|
71
|
+
/** Noise layers 1-4, default 2 */
|
|
72
|
+
octaves?: number;
|
|
73
|
+
/** Relief height in meters (bumps the normal); needs a lit material */
|
|
74
|
+
normal?: number;
|
|
75
|
+
/** How much the sample moves roughness (standard / physical only) */
|
|
76
|
+
roughness?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The `lighting` surface patch, on a spec (materials.x.lighting) or for all lit materials (style.lighting). three has no shadow color: a shadow only
|
|
81
|
+
* removes the sun's light. These shape the summed light afterwards, from the first directional light (the sun) and its shadow for this pixel.
|
|
82
|
+
* Limits: one directional light; point / spot lights are untouched; cloud shadows are not 'shadow' here. Values are uniforms (shared program).
|
|
83
|
+
*/
|
|
84
|
+
export interface MaterialLighting {
|
|
85
|
+
/** Half-lambert: diffuse = (n.l + wrap) / (1 + wrap) from the sun; 0 = off, 0.5 soft, 1 full half-lambert. Ignores a toon ramp */
|
|
86
|
+
wrap?: number;
|
|
87
|
+
/** Shadowed (or sun-averted) parts shift hue towards this color at the same brightness: strength 0-1 (default 0.5),
|
|
88
|
+
* soft = terminator width in n.l (default 0.3) */
|
|
89
|
+
shadowTint?: { color: ColorLike; strength?: number; soft?: number };
|
|
90
|
+
/** Fresnel edge light added to the ambient part: strength (0.4), power (3, higher = thinner rim),
|
|
91
|
+
* shadowSide 0-1 (1 = only on the side away from the sun) */
|
|
92
|
+
rim?: { color: ColorLike; strength?: number; power?: number; shadowSide?: number };
|
|
93
|
+
/**
|
|
94
|
+
* Your own shaping, replaces wrap / shadowTint / rim:
|
|
95
|
+
* `void threedogLighting(inout ReflectedLight light, vec3 normal, vec3 viewDir, vec3 sunDir, float sunShadow, vec3 albedo)`
|
|
96
|
+
*/
|
|
97
|
+
glsl?: string;
|
|
98
|
+
uniforms?: Record<string, any>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Sky keyframe: [time 0–1, zenith color, horizon color (= fog color), sun color, sun intensity, ambient intensity] */
|
|
102
|
+
export type SkyKeyframe = (number | ColorLike)[];
|
|
103
|
+
|
|
104
|
+
export interface StyleSeasons {
|
|
105
|
+
mode?: Loose<'multiply' | 'mix'>;
|
|
106
|
+
strength?: number;
|
|
107
|
+
[season: string]: any;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface StyleSky {
|
|
111
|
+
/** Colors and light intensities at each time of day */
|
|
112
|
+
keyframes?: SkyKeyframe[];
|
|
113
|
+
/**
|
|
114
|
+
* A flat background color in place of the dome (no gradient, horizon line, sun / moon disk, stars or clouds), or (sky) => color per
|
|
115
|
+
* frame. Drawn as written (no tone mapping); the keyframes still light the world; fog in its default horizon color follows it (a
|
|
116
|
+
* fog.color of your own still wins). Leave out for the dome. Not with skybox. recipes/47
|
|
117
|
+
* @example backdrop: sky => sky.isDay ? 0xefebe4 : 0x2c3346
|
|
118
|
+
*/
|
|
119
|
+
backdrop?: ColorLike | ((sky: Sky) => ColorLike);
|
|
120
|
+
/** Larger means a smaller sun, default 900 */
|
|
121
|
+
sunSize?: number;
|
|
122
|
+
/** Sun glow, default 0.18 */
|
|
123
|
+
sunGlow?: number;
|
|
124
|
+
/** Sun brightness, default 6 */
|
|
125
|
+
sunBrightness?: number;
|
|
126
|
+
/** Larger means a smaller moon */
|
|
127
|
+
moonSize?: number;
|
|
128
|
+
moonColor?: ColorLike;
|
|
129
|
+
moonBrightness?: number;
|
|
130
|
+
/** North-south tilt of the sun path */
|
|
131
|
+
orbitTilt?: number;
|
|
132
|
+
/** East-west swing of the sun path */
|
|
133
|
+
orbitSway?: number;
|
|
134
|
+
/** Star density */
|
|
135
|
+
starDensity?: number;
|
|
136
|
+
/** Larger means smaller and more numerous stars */
|
|
137
|
+
starScale?: number;
|
|
138
|
+
/** Gradient curve from zenith to horizon */
|
|
139
|
+
gradientCurve?: number;
|
|
140
|
+
/** Ground bounce color of the ambient light */
|
|
141
|
+
groundTint?: ColorLike;
|
|
142
|
+
/** Clouds in the sky (cloud cover follows the weather); see StyleSkyClouds */
|
|
143
|
+
clouds?: StyleSkyClouds;
|
|
144
|
+
/** Panorama (equirectangular) replacing the gradient sky, asset name or path */
|
|
145
|
+
skybox?: string;
|
|
146
|
+
/** Shadows: mapSize resolution (pixels), extent coverage (meters), etc., see StyleShadow */
|
|
147
|
+
shadow?: StyleShadow;
|
|
148
|
+
/** Environment lighting (scene.environment), off unless a source is given; see Sky.setEnvironment. A pack can give defaults, sky({ environment }) overrides */
|
|
149
|
+
environment?: StyleEnvironment;
|
|
150
|
+
/** Fog model and color (default: linear fog in the horizon color); see StyleFog */
|
|
151
|
+
fog?: StyleFog;
|
|
152
|
+
/** Extra dome layers drawn after the clouds and stars (rainbow, aurora), default none; see StyleSkyLayer */
|
|
153
|
+
layers?: StyleSkyLayer[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Fog (modules/sky/fog.js). Defaults draw three's linear fog in the dome's horizon color, exactly as before.
|
|
158
|
+
* @example fog: { kind: 'height', height: 2, falloff: 0.08, density: 0.02 } // valley mist, thin above
|
|
159
|
+
* @example fog: { kind: 'exp2', color: 0xb8c4d0 } // own color: the dome's lower band fades to it so the horizon line does not show
|
|
160
|
+
*/
|
|
161
|
+
export interface StyleFog {
|
|
162
|
+
/** 'linear' (default, near = 0.3 x far) | 'exp' | 'exp2' | 'height' (thick below `height`, thinning above it) */
|
|
163
|
+
kind?: Loose<'linear' | 'exp' | 'exp2' | 'height'>;
|
|
164
|
+
/** 'horizon' (default: the dome's horizon color) | a color | (sky) => color (e.g. to darken it at night) */
|
|
165
|
+
color?: 'horizon' | ColorLike | ((sky: any) => ColorLike);
|
|
166
|
+
/** Per meter, exp / exp2 / height (default: derived from engine.fogFar, so fog reaches the same distance as linear); weather fog divides it */
|
|
167
|
+
density?: number;
|
|
168
|
+
/** 'height': world y of the fog floor, default 0 */
|
|
169
|
+
height?: number;
|
|
170
|
+
/** 'height': how fast the fog thins above the floor, per meter, default 0.05 */
|
|
171
|
+
falloff?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Replace the fog math in every material (three's fog chunks, set at install):
|
|
174
|
+
* `vec4 threedogFog(vec3 color, float depth, vec3 worldPos)` returns (fog rgb, amount 0..1). In scope: fogColor, cameraPosition,
|
|
175
|
+
* fogNear / fogFar (kind 'linear') or fogDensity (other kinds), THREEDOG_FOG_HEIGHT, THREEDOG_FOG_FALLOFF. No custom uniforms (write constants)
|
|
176
|
+
* @example glsl: `vec4 threedogFog(vec3 c, float depth, vec3 p){ float f = 1.0 - exp(-fogDensity * depth); return vec4(mix(c, vec3(1.0, 0.8, 0.6), f * 0.3), f); }`
|
|
177
|
+
*/
|
|
178
|
+
glsl?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* One extra sky layer (modules/sky/domeLayers.js)
|
|
183
|
+
* @example layers: [{ blend: 'add', uniforms: { uAurora: [0.2, 1, 0.6] }, glsl: `vec4 threedogSkyLayer(vec3 d, float time, vec3 sunDir, float night){
|
|
184
|
+
* float band = smoothstep(0.25, 0.45, d.y) * (1.0 - smoothstep(0.55, 0.8, d.y)) * threedogNoise(vec2(d.x * 4.0 + time * 0.05, d.z * 2.0));
|
|
185
|
+
* return vec4(uAurora, band * night); }` }]
|
|
186
|
+
*/
|
|
187
|
+
export interface StyleSkyLayer {
|
|
188
|
+
/** Defines `vec4 threedogSkyLayer(vec3 dir, float time, vec3 sunDir, float night)` returning (rgb, amount 0..1); renamed per layer, so layers never clash */
|
|
189
|
+
glsl: string;
|
|
190
|
+
/** Custom uniforms (numbers, THREE.Color, [x, y(, z, w)], THREE.Texture), live in engine.sky.dome.material.uniforms */
|
|
191
|
+
uniforms?: Record<string, any>;
|
|
192
|
+
/** Draw order among the layers, smaller first (default 0) */
|
|
193
|
+
order?: number;
|
|
194
|
+
/** 'mix' (default: mix(sky, rgb, amount)) | 'add' (sky + rgb * amount, for glows) */
|
|
195
|
+
blend?: Loose<'mix' | 'add'>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Environment lighting parameters */
|
|
199
|
+
export interface StyleEnvironment {
|
|
200
|
+
/** 'sky' (built from the procedural sky) or an HDR / panorama asset name or path; omitted or null = off */
|
|
201
|
+
source?: string | null;
|
|
202
|
+
/** Light scale, default 1 */
|
|
203
|
+
intensity?: number;
|
|
204
|
+
/** Turn around Y, radians, default 0 */
|
|
205
|
+
rotation?: number;
|
|
206
|
+
/** Seconds between rebuilds of a 'sky' source (only when the sky changed), default 1 */
|
|
207
|
+
interval?: number;
|
|
208
|
+
/** Low-tier override: fields to replace there (a 'sky' source already rebuilds 4 times less often), or false to turn it off */
|
|
209
|
+
low?: Omit<StyleEnvironment, 'low'> | false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Sun shadow parameters (defaults are the current look) */
|
|
213
|
+
/**
|
|
214
|
+
* Sky cloud layer. The defaults are the original look ('plane': one plane projected onto the sky, 3 noise layers), so a style
|
|
215
|
+
* that sets nothing here draws what it always drew. Values below marked (plane) are the defaults of kind 'plane'.
|
|
216
|
+
* @example clouds: { kind: 'cumulus', coverage: 1, scale: 0.5, color: 0xfff6ea, shade: 0x8fa0b8 } // full-sky billowy clouds with sun-side light
|
|
217
|
+
* @example clouds: { glsl: `vec4 threedogClouds(vec3 d, float time, vec3 sunDir, float night, vec3 lit, vec3 shade, float cover){
|
|
218
|
+
* return vec4(lit, 0.5); }`, uniforms: { uBrush: 0.4 } }
|
|
219
|
+
*/
|
|
220
|
+
export interface StyleSkyClouds {
|
|
221
|
+
color?: ColorLike; shade?: ColorLike;
|
|
222
|
+
/** 0-1+, multiplies the weather cloud amount (default 1) */
|
|
223
|
+
coverage?: number;
|
|
224
|
+
/** Cloud cell size: larger = smaller clouds (plane 0.35) */
|
|
225
|
+
scale?: number;
|
|
226
|
+
/** Drift per second [x, z] (plane [0.004, 0.002]) */
|
|
227
|
+
speed?: number[];
|
|
228
|
+
/**
|
|
229
|
+
* 'plane' (default): cheap, 3 noise samples, cells shrink and crowd towards the horizon.
|
|
230
|
+
* 'cumulus': 8 noise samples per cloudy pixel, flatter projection (clouds fill the whole sky), sun-side light and shaded undersides.
|
|
231
|
+
* Both are one 2D pass, no ray marching.
|
|
232
|
+
*/
|
|
233
|
+
kind?: Loose<'plane' | 'cumulus'>;
|
|
234
|
+
/** Added to dir.y in the plane projection: smaller = stronger crowding at the horizon (plane 0.08, cumulus 0.5) */
|
|
235
|
+
horizon?: number;
|
|
236
|
+
/** Horizon fade [from, to] in dir.y: clouds are invisible below `from` and full above `to` (plane [0, 0.18], cumulus [0, 0.12]) */
|
|
237
|
+
fade?: number[];
|
|
238
|
+
/** Cloud opacity 0-1 (plane 0.9, cumulus 0.95) */
|
|
239
|
+
opacity?: number;
|
|
240
|
+
/** Width of the cloud edge in noise units: larger = softer edge (plane 0.3, cumulus 0.35) */
|
|
241
|
+
softness?: number;
|
|
242
|
+
/** 'plane' only: the 3 noise layers. scales = frequency multipliers of layers 2 and 3 (default [2.7, 6.1]), weights = their mix (default [0.6, 0.3, 0.1]) */
|
|
243
|
+
noise?: { scales?: number[]; weights?: number[] };
|
|
244
|
+
/** 'cumulus' only: contrast of the sun-side light (default 5) */
|
|
245
|
+
relief?: number;
|
|
246
|
+
/**
|
|
247
|
+
* Replace the cloud function with your own GLSL; overrides `kind`. Must define
|
|
248
|
+
* `vec4 threedogClouds(vec3 dir, float time, vec3 sunDir, float night, vec3 lit, vec3 shade, float cover)` returning (rgb, alpha).
|
|
249
|
+
* See modules/sky/clouds.js for what is in scope.
|
|
250
|
+
*/
|
|
251
|
+
glsl?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Extra uniforms for `glsl`, declared for you: number, THREE.Color, THREE.Vector2/3/4, [x, y(, z, w)] array or THREE.Texture.
|
|
254
|
+
* Change them later via engine.sky.dome.material.uniforms.<name>.value
|
|
255
|
+
*/
|
|
256
|
+
uniforms?: Record<string, number | number[] | object>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Wind look. frequency multiplies the sway speed. glsl replaces the sway shape of every swaying material made through
|
|
261
|
+
* vegetation.add (or applyEffects with the same object): define `void threedogWind(inout vec3 transformed, vec3 ip, vec3 position)` that moves
|
|
262
|
+
* `transformed` (object space); ip = world position of this instance's origin (own phase per plant), position = the vertex. In scope: uTime, uWind
|
|
263
|
+
* (weather multiplier), uWindFreq, THREEDOG_WIND_AMP (the species' amplitude), your `uniforms`. The shadow sways with it. The default is in
|
|
264
|
+
* render/effects.js (threedog_wind_vertex): two sines, height-weighted, a lean with the wind strength.
|
|
265
|
+
* @example wind: { glsl: `void threedogWind(inout vec3 t, vec3 ip, vec3 p){ float s = floor(sin(uTime * uWindFreq + ip.x) * 3.0) / 3.0; t.x += s * max(p.y, 0.0) * THREEDOG_WIND_AMP * uWind; }` }
|
|
266
|
+
*/
|
|
267
|
+
export interface StyleWind {
|
|
268
|
+
frequency?: number;
|
|
269
|
+
glsl?: string;
|
|
270
|
+
/** Extra uniforms for glsl: number, THREE.Color, THREE.Vector2/3/4, [x, y(, z, w)] array or THREE.Texture */
|
|
271
|
+
uniforms?: Record<string, number | number[] | object>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** engine.sky.shadow: the shadow params in use (Sky.setShadow changes them); field meanings as in StyleShadow */
|
|
275
|
+
export interface SkyShadowParams {
|
|
276
|
+
bias: number; normalBias: number; updateEvery: number; snap: number | 'texel'; ahead: number; type: 'basic' | 'pcf' | 'vsm'; radius: number; blurSamples: number;
|
|
277
|
+
cascades: number; maxFar: number; fade: boolean; lightMargin: number; split: StyleShadow['split'];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface StyleShadow {
|
|
281
|
+
/** Shadow resolution (pixels), default 2048 */
|
|
282
|
+
mapSize?: number;
|
|
283
|
+
/** Coverage radius (meters), default 70 */
|
|
284
|
+
extent?: number;
|
|
285
|
+
/** Distance of the light from the shadow center (meters), default 160 */
|
|
286
|
+
distance?: number;
|
|
287
|
+
/** Anti shadow-acne bias, default -0.0006 */
|
|
288
|
+
bias?: number;
|
|
289
|
+
/** Normal-offset anti-acne, default 0.04 */
|
|
290
|
+
normalBias?: number;
|
|
291
|
+
/** Update shadows every N frames, default 1 (every frame); larger saves more, still updates promptly when the focus moves */
|
|
292
|
+
updateEvery?: number;
|
|
293
|
+
/** Shadow center snapping grid (meters), default 0.5; 'texel' snaps to shadow pixels (shadow edges do not shimmer while moving) */
|
|
294
|
+
snap?: number | 'texel';
|
|
295
|
+
/** How far ahead of the view direction the shadow center is shifted (meters), default 0 */
|
|
296
|
+
ahead?: number;
|
|
297
|
+
/** Shadow filter: 'basic' (hard edge, cheapest) | 'pcf' (default, soft edge) | 'vsm' (softest, costliest). Default: the engine's shadowType option */
|
|
298
|
+
type?: Loose<'basic' | 'pcf' | 'vsm'>;
|
|
299
|
+
/** Edge softness for 'pcf' and 'vsm' (no effect on 'basic'), default 1 */
|
|
300
|
+
radius?: number;
|
|
301
|
+
/** Blur sample count, 'vsm' only, default 8 */
|
|
302
|
+
blurSamples?: number;
|
|
303
|
+
/**
|
|
304
|
+
* Cascaded shadows (recipes/45): 1 (default) = one shadow map around the focus, the plain path; 2-4 split the sun's shadow along the view,
|
|
305
|
+
* sharp near the camera and wide far away. Each cascade draws the casters once more. Low-tier devices stay at 1 unless low.cascades says so.
|
|
306
|
+
* Switching recompiles every lit material once (the light count changes); extent / snap / ahead do not apply while cascades are on
|
|
307
|
+
* @example shadow: { cascades: 3, maxFar: 150, low: { cascades: 2, fade: false } } // low-tier devices: 2 cascades instead of one map
|
|
308
|
+
*/
|
|
309
|
+
cascades?: number;
|
|
310
|
+
/** Cascades: meters from the camera they cover (no sun shadow beyond), default 120 */
|
|
311
|
+
maxFar?: number;
|
|
312
|
+
/** Cascades: cross-fade at each border so no seam shows (two shadow lookups there), default true */
|
|
313
|
+
fade?: boolean;
|
|
314
|
+
/** Cascades: meters behind each cascade box toward the light still caught as casters (tall things outside the view), default 100 */
|
|
315
|
+
lightMargin?: number;
|
|
316
|
+
/** Cascades: where borders fall, 'practical' (default) | 'uniform' | 'logarithmic' | (count, near, far, out: number[]) => void (three CSM customSplitsCallback) */
|
|
317
|
+
split?: Loose<'practical' | 'uniform' | 'logarithmic'> | ((count: number, near: number, far: number, out: number[]) => void);
|
|
318
|
+
/**
|
|
319
|
+
* Overrides used on low-tier devices (engine.tier 'low'), default { mapSize: 1024, cascades: 1 }. updateEvery above 1 saves more but makes
|
|
320
|
+
* wind-swayed shadows step visibly. sky({ shadow }) options replace the whole shadow block, low included.
|
|
321
|
+
*/
|
|
322
|
+
low?: Omit<StyleShadow, 'low'>;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface StyleWeather {
|
|
326
|
+
/** Rain / snow coverage (meters, centered on the camera) */
|
|
327
|
+
area?: number;
|
|
328
|
+
/** Target color the sky turns to when overcast */
|
|
329
|
+
overcastColor?: ColorLike;
|
|
330
|
+
/** Lightning brightness multiplier */
|
|
331
|
+
lightningBrightness?: number;
|
|
332
|
+
/**
|
|
333
|
+
* Lightning look: flash (1 at the strike, fading in a third of a second) -> sky flash amount; default flickers. Return 0 and draw your own bolt
|
|
334
|
+
* on the weather:lightning event for a whole replacement
|
|
335
|
+
* @example lightning: f => f * f * 0.8
|
|
336
|
+
*/
|
|
337
|
+
lightning?: (flash: number, engine: Engine) => number;
|
|
338
|
+
/** Rain particles (default streaks: color 0xc8c8c8, opacity 0.55, length 0.7 m, speed 22 m/s, slant 1); a texture or a sprite shape draws drops */
|
|
339
|
+
rain?: StyleWeatherParticles;
|
|
340
|
+
/** Snow particles (default round sprites: color 0xffffff, opacity 0.9, size 20, maxSize 5 px, speed 1.6 m/s, sway 1.5 m) */
|
|
341
|
+
snow?: StyleWeatherSnow;
|
|
342
|
+
/** Retune the look of weather types the game has (e.g. a darker storm); never adds a type: the list is the game's weather({ types }) */
|
|
343
|
+
types?: Record<string, Partial<WeatherPreset>>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Falling weather particles: style.weather.rain / snow and engine.weather.define(field, spec). See recipes/44-water-weather-look-hooks.md */
|
|
347
|
+
/** style.weather.snow: the snow particles' look plus the cover it leaves */
|
|
348
|
+
export interface StyleWeatherSnow extends StyleWeatherParticles {
|
|
349
|
+
/** Snow lying on foliage / ground while it snows (StyleSnowCover); leave out for particles only */
|
|
350
|
+
cover?: StyleSnowCover;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Snow cover (style.weather.snow.cover): the season tint of foliage / ground (vegetation, terrain, materials with season) moves toward
|
|
355
|
+
* these colors as the weather's snow amount rises, `strength` of the way at full snow, and melts back as it falls. Rides the season
|
|
356
|
+
* patch (mix over style.seasons; a 'multiply' season gives way while snow lies). Leave it out and snow only draws particles.
|
|
357
|
+
* The same cover for anything else (ash, frost): engine.sky.modify('ash', { groundCover: 0x555555, coverAmount: 0.6 }). recipes/47
|
|
358
|
+
* @example cover: { foliage: 0xf2f4f6, ground: 0xeef0f2, strength: 0.8 }
|
|
359
|
+
*/
|
|
360
|
+
export interface StyleSnowCover {
|
|
361
|
+
/** Snow color on foliage (leave out: foliage keeps its season color) */
|
|
362
|
+
foliage?: ColorLike;
|
|
363
|
+
/** Snow color on the ground (leave out: ground keeps its season color) */
|
|
364
|
+
ground?: ColorLike;
|
|
365
|
+
/** How far toward the color at full snow, 0-1, default 0.8 */
|
|
366
|
+
strength?: number;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface StyleWeatherParticles {
|
|
370
|
+
/** 'line' streaks slant with the wind; 'round' | 'soft' | 'square' sprites drift (sway) */
|
|
371
|
+
shape?: Loose<'line' | 'round' | 'soft' | 'square'>;
|
|
372
|
+
/** Sprite image (asset name), replaces the shape */
|
|
373
|
+
texture?: string | null;
|
|
374
|
+
color?: ColorLike;
|
|
375
|
+
opacity?: number;
|
|
376
|
+
/** Sprite size (pixels at 3 m) and its pixel cap */
|
|
377
|
+
size?: number;
|
|
378
|
+
maxSize?: number;
|
|
379
|
+
/** Streak length (meters, lines) */
|
|
380
|
+
length?: number;
|
|
381
|
+
/** Fall speed (m/s) */
|
|
382
|
+
speed?: number;
|
|
383
|
+
/** Streak lean per unit of wind (lines) */
|
|
384
|
+
slant?: number;
|
|
385
|
+
/** Sprite drift (meters) */
|
|
386
|
+
sway?: number;
|
|
387
|
+
/** Particle count (default weather({ particles }); halved on low-tier devices) */
|
|
388
|
+
count?: number;
|
|
389
|
+
/** Weather amount 0..1 -> share of particles drawn (rain default a => min(1, a * 1.2), snow () => 1; opacity follows the amount too) */
|
|
390
|
+
density?: (amount: number) => number;
|
|
391
|
+
/**
|
|
392
|
+
* Whole shader text (copy modules/weather/shaders.js). In scope: uCam uSize uFallOff uOpacity uColor, lines uWindDir uLen (attribute aEnd),
|
|
393
|
+
* sprites uPx uMaxPx uSway uSwayAmp uMap uUseMap, and your uniforms (declared for you)
|
|
394
|
+
*/
|
|
395
|
+
glsl?: { vertex?: string; fragment?: string };
|
|
396
|
+
/** Uniforms for your glsl: numbers, colors, [x, y(, z, w)] arrays, textures; live in engine.weather.systems.get(field).uniforms */
|
|
397
|
+
uniforms?: Record<string, any>;
|
|
398
|
+
/** A system of your own instead (engine.weather.define only): the engine adds object, shows it while the amount is above 0.02, calls update */
|
|
399
|
+
create?: (engine: Engine, ctx: { area: number; count: number }) => {
|
|
400
|
+
object: Object3D; update?: (amount: number, ctx: { camera: any; time: number; wind: number }) => void };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export interface StyleWater {
|
|
404
|
+
/**
|
|
405
|
+
* Replace the whole water surface material (the built-in role 'water', waves and fresnel are skipped). Receives the shared
|
|
406
|
+
* uniforms (uTime, uWave, uWaveScale, uWaveSpeed), the built-in wave patch, the surface patch (depthColor / foam / glsl.surface; null
|
|
407
|
+
* without them; put it after waves) and the scrolling normal map (null without one). Reflections: recipes/44-water-weather-look-hooks.md
|
|
408
|
+
* @example material: (engine, { waves }) => applyEffects(new THREE.MeshToonMaterial({ color: 0x3a8acf }), { clouds: false, patches: [waves] })
|
|
409
|
+
*/
|
|
410
|
+
material?: (engine: Engine, ctx: { uniforms: Record<string, { value: any }>; waves: ShaderPatch; surface: ShaderPatch | null;
|
|
411
|
+
normalMap: import('three').Texture | null }) => Material;
|
|
412
|
+
/**
|
|
413
|
+
* Water color from the view angle (by 'view', default: shallow looking down, deep at grazing angles) or the wave height (by 'wave': shallow on
|
|
414
|
+
* crests); replaces color. curve shapes the blend (default 1)
|
|
415
|
+
*/
|
|
416
|
+
depthColor?: StyleWaterDepth;
|
|
417
|
+
/**
|
|
418
|
+
* Crest foam from the wave height (start / end: fraction of glsl.waveMax where foam begins / is full, default 0.55 / 0.85); true = defaults.
|
|
419
|
+
* Shore foam needs depth: recipes/44
|
|
420
|
+
*/
|
|
421
|
+
foam?: StyleWaterFoam | true;
|
|
422
|
+
/**
|
|
423
|
+
* Your own GLSL. wave: `float threedogWaterWave(vec3 p, float t)` (p = world position * waveScale, t = time * waveSpeed) returns the height
|
|
424
|
+
* before waveHeight; waveMax = its peak (default 0.29), which foam and depthColor 'wave' divide by. surface: `vec4 threedogWaterSurface(vec4
|
|
425
|
+
* base, float wave, float facing, vec3 worldPos, float time)` returns the color and opacity lighting starts from (facing 1 = straight down)
|
|
426
|
+
*/
|
|
427
|
+
glsl?: { wave?: string; surface?: string; waveMax?: number };
|
|
428
|
+
/** Uniforms for your glsl, in both stages: numbers, colors, [x, y(, z, w)] arrays or textures; live in engine.water.material.uniforms */
|
|
429
|
+
uniforms?: Record<string, any>;
|
|
430
|
+
color?: ColorLike;
|
|
431
|
+
/** Opacity 0–1 */
|
|
432
|
+
opacity?: number;
|
|
433
|
+
/** Flat shading (low poly) */
|
|
434
|
+
flat?: boolean;
|
|
435
|
+
/** Wave height multiplier */
|
|
436
|
+
waveHeight?: number;
|
|
437
|
+
waveScale?: number;
|
|
438
|
+
waveSpeed?: number;
|
|
439
|
+
/** Grazing-angle reflection strength 0–1 */
|
|
440
|
+
fresnel?: number;
|
|
441
|
+
/** Normal map (asset name or path) */
|
|
442
|
+
normalMap?: string;
|
|
443
|
+
normalScale?: number;
|
|
444
|
+
normalRepeat?: number;
|
|
445
|
+
/** Normal map flow speed [x, z] */
|
|
446
|
+
normalSpeed?: number[];
|
|
447
|
+
shininess?: number;
|
|
448
|
+
specular?: ColorLike;
|
|
449
|
+
/** Mesh subdivision of the global water (quality, not the world; default 150) */
|
|
450
|
+
segments?: number;
|
|
451
|
+
// level, sea and size are not style: water({ level, sea, size }) (WaterOptions)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface StyleWaterDepth {
|
|
455
|
+
shallow?: ColorLike;
|
|
456
|
+
deep?: ColorLike;
|
|
457
|
+
by?: Loose<'view' | 'wave'>;
|
|
458
|
+
curve?: number;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface StyleWaterFoam {
|
|
462
|
+
color?: ColorLike;
|
|
463
|
+
start?: number;
|
|
464
|
+
end?: number;
|
|
465
|
+
/** 0-1, foam opacity on top of the water (default 1) */
|
|
466
|
+
opacity?: number;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export interface StyleTerrain {
|
|
470
|
+
/** Palette: color name → color (e.g. sand, meadowA, rock) */
|
|
471
|
+
colors?: Record<string, ColorLike>;
|
|
472
|
+
/** Landform → palette color name (two names are blended by noise) */
|
|
473
|
+
biomeColors?: Record<string, string[]>;
|
|
474
|
+
/** Color rule for steep slopes */
|
|
475
|
+
steep?: SteepRule[];
|
|
476
|
+
/**
|
|
477
|
+
* How ground colors vary (plain data, sent to the terrain workers). Every default is the original look; set only what you want to change.
|
|
478
|
+
* blend: the two-color noise (size = wavelength in meters, default 33; strength = contrast, default 1). jitter: per-cell brightness grain
|
|
479
|
+
* (size = cell in meters, default 0.33; min = darkest multiplier 0.92; range = how much brighter it gets 0.12). patches: a second, much larger
|
|
480
|
+
* layer for painted color blocks (size in meters, default 90; strength 0-1, default 0.15; levels > 0 snaps it to flat blocks; tint = pull
|
|
481
|
+
* towards this color instead of lighten/darken).
|
|
482
|
+
* @example variation: { blend: { size: 14 }, jitter: { range: 0.04 }, patches: { size: 60, strength: 0.25, levels: 4, tint: 0xb59a5a } }
|
|
483
|
+
*/
|
|
484
|
+
variation?: {
|
|
485
|
+
blend?: { size?: number; strength?: number };
|
|
486
|
+
jitter?: { size?: number; min?: number; range?: number };
|
|
487
|
+
patches?: { size?: number; strength?: number; levels?: number; tint?: number };
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Looks of the ground mesh only. shading: 'flat' one color and normal per triangle (facets) | 'smooth' (engine default) | 'texture' (per-chunk color
|
|
491
|
+
* map, colors independent of the mesh); colorResolution: color map pixels per chunk edge; normals: 'smooth' | 'flat' lighting in texture mode;
|
|
492
|
+
* normalFn: custom grid-point normal. Shape, size, seed, water level, resolution, diagonal: terrain({...}). See recipes/37-terrain-look-hooks.md
|
|
493
|
+
*/
|
|
494
|
+
config?: { shading?: Loose<'flat' | 'smooth' | 'texture'>; colorResolution?: number; normals?: Loose<'smooth' | 'flat'>; normalFn?: TerrainConfig['normalFn'] };
|
|
495
|
+
/** Whole ground material: a Material or (engine) => Material (uv = world xz / chunk size; terrain({ material }) wins) */
|
|
496
|
+
material?: Material | ((engine: Engine) => Material);
|
|
497
|
+
/** Ground detail texture: texture asset name, scale repeats per meter, strength 0–1 */
|
|
498
|
+
detail?: { texture: string; scale?: number; strength?: number };
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** UI template function: (data, helpers) => HTML string */
|
|
502
|
+
export type UITemplate = (data: any, tools: { esc: (s: any) => string; t: (key: string, params?: Record<string, any>) => string; icon?: (def: any) => string }) => string;
|
|
503
|
+
|
|
504
|
+
export interface StyleUI {
|
|
505
|
+
/** Background color */
|
|
506
|
+
bg?: string;
|
|
507
|
+
/** Text color */
|
|
508
|
+
fg?: string;
|
|
509
|
+
/** Secondary text color */
|
|
510
|
+
muted?: string;
|
|
511
|
+
/** Accent color */
|
|
512
|
+
accent?: string;
|
|
513
|
+
/** Color for good news such as "done" */
|
|
514
|
+
good?: string;
|
|
515
|
+
/** Divider color */
|
|
516
|
+
line?: string;
|
|
517
|
+
/** Font (CSS font-family) */
|
|
518
|
+
font?: string;
|
|
519
|
+
/** Corner radius (CSS, e.g. '12px') */
|
|
520
|
+
radius?: string;
|
|
521
|
+
/** Loading screen background */
|
|
522
|
+
loadingBg?: string;
|
|
523
|
+
/** Window shadow (CSS) */
|
|
524
|
+
shadow?: string;
|
|
525
|
+
/** Height of the interaction prompt above the object (meters) */
|
|
526
|
+
promptHeight?: number;
|
|
527
|
+
/** Fade color for scene transitions (CSS), default '#000' */
|
|
528
|
+
fadeBg?: string;
|
|
529
|
+
/** Background / text / accent colors of objective markers, counters and progress bars (CSS) */
|
|
530
|
+
hudBg?: string;
|
|
531
|
+
hudFg?: string;
|
|
532
|
+
hudAccent?: string;
|
|
533
|
+
/**
|
|
534
|
+
* Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in font: '"pixel", system-ui'. A style never holds
|
|
535
|
+
* a font file path
|
|
536
|
+
*/
|
|
537
|
+
fonts?: string[];
|
|
538
|
+
/** Extra CSS (overrides .threedog-* classes) */
|
|
539
|
+
css?: string;
|
|
540
|
+
/** Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar… */
|
|
541
|
+
templates?: Record<string, UITemplate>;
|
|
542
|
+
/** Other CSS variables (become --threedog-name) */
|
|
543
|
+
[cssVar: string]: any;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export interface Style {
|
|
547
|
+
/** Style pack name */
|
|
548
|
+
name?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Exposure, default 1 (lowpoly: 1.05): a number, or over the day [[time 0-1, exposure], ...] (sorted, wraps across midnight) or (sky) => number,
|
|
551
|
+
* evaluated by the sky module every frame. engine.setExposure changes it at run time
|
|
552
|
+
* @example exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // brighter nights
|
|
553
|
+
*/
|
|
554
|
+
exposure?: number | number[][] | ((sky: any) => number);
|
|
555
|
+
/** Tone mapping, default 'neutral' (lowpoly: 'aces') */
|
|
556
|
+
toneMapping?: Loose<'aces' | 'agx' | 'neutral' | 'none'>;
|
|
557
|
+
/** Background color (when there is no sky module) */
|
|
558
|
+
background?: ColorLike;
|
|
559
|
+
/**
|
|
560
|
+
* Post effects registered at startup, in any order (slot and order decide where each runs), e.g. [outline({ enabled: true }), bloom()] from
|
|
561
|
+
* '@threedog/post-effects'
|
|
562
|
+
*/
|
|
563
|
+
post?: (Omit<import('./generated/render/PostFX').PostEffect, 'slot'> & { slot?: Loose<import('./generated/render/PostFX').PostSlot> })[];
|
|
564
|
+
/**
|
|
565
|
+
* Material per role (default, terrain, vegetation, character, water, building, pickup…): a spec, a three.js Material instance (cloned per use), or a
|
|
566
|
+
* function (params, purpose) => Material
|
|
567
|
+
*/
|
|
568
|
+
materials?: Record<string, MaterialSpec | import('three').Material
|
|
569
|
+
| ((params: Record<string, any>, purpose: string, engine: Engine) => import('three').Material)>;
|
|
570
|
+
/**
|
|
571
|
+
* Anti-aliasing: true = MSAA (also inside post-processing), false = off (pixel art, sharp edges). Default: on for desktop, off for low tier;
|
|
572
|
+
* createEngine({ antialias }) wins
|
|
573
|
+
*/
|
|
574
|
+
antialias?: boolean;
|
|
575
|
+
/** Light shaping for every lit material of the pack (shadow tint, rim, wrap, glsl); a material's `lighting` wins, `lighting: false` opts out */
|
|
576
|
+
lighting?: MaterialLighting;
|
|
577
|
+
/**
|
|
578
|
+
* Seasonal tint: { spring: { foliage, ground }, ... }. mode 'multiply' (default) multiplies the color onto the surface
|
|
579
|
+
* (pick tints near white: orange times green is muddy); 'mix' moves the surface `strength` (0-1, default 0.5) of the
|
|
580
|
+
* way to the color. Season names are the other keys, so none can be called mode or strength
|
|
581
|
+
*/
|
|
582
|
+
seasons?: StyleSeasons;
|
|
583
|
+
/** Cloud shadow: shadow darkest level 0–1 (default 0 = no cloud shadows; lowpoly 0.55), scale cloud size (smaller means bigger clouds), speed [x, z] */
|
|
584
|
+
clouds?: { shadow?: number; scale?: number; speed?: number[] };
|
|
585
|
+
/**
|
|
586
|
+
* Named colors the procedural model generators read (trees, rocks, grass: a generator written with `function` gets them as this.palette; lowpoly keys:
|
|
587
|
+
* bark, pine, leaf, rock, grassTip...). One place to retint all of them, e.g. style: [lowpoly, { palette: { leaf: 0xd98a3a } }]; keys left out keep the pack's values
|
|
588
|
+
*/
|
|
589
|
+
palette?: Record<string, ColorLike>;
|
|
590
|
+
/** Wind: frequency sway frequency multiplier */
|
|
591
|
+
wind?: StyleWind;
|
|
592
|
+
/** Terrain colors etc. */
|
|
593
|
+
terrain?: StyleTerrain;
|
|
594
|
+
/** Sky */
|
|
595
|
+
sky?: StyleSky;
|
|
596
|
+
/** Weather look */
|
|
597
|
+
weather?: StyleWeather;
|
|
598
|
+
/** Water look */
|
|
599
|
+
water?: StyleWater;
|
|
600
|
+
/**
|
|
601
|
+
* Default look of pickups on the ground: color (the item's own color wins), size (meters), lift height above ground (meters), model(item, { color,
|
|
602
|
+
* size }, engine) builds the shape (a geometry gets materials.pickup; make materials with engine.makeMaterial; without model a plain box)
|
|
603
|
+
*/
|
|
604
|
+
pickup?: { color?: ColorLike; size?: number; lift?: number; model?: (item: any, o: { color: ColorLike; size: number }, engine: Engine) => Object3D | BufferGeometry };
|
|
605
|
+
/**
|
|
606
|
+
* Default character: colors palette; create(engine, colors) returns the procedural character (without it a gray capsule); model names a registered
|
|
607
|
+
* model asset every character uses unless it passes its own model (the procedural body shows until it loads); animation.fade skeletal animation
|
|
608
|
+
* transition seconds
|
|
609
|
+
*/
|
|
610
|
+
character?: { model?: string; colors?: { body?: ColorLike; skin?: ColorLike; legs?: ColorLike; hair?: ColorLike }; create?: (engine: Engine, colors: Record<string, ColorLike>) => CharacterRig | null | undefined; animation?: { fade?: number } };
|
|
611
|
+
/** UI colors, fonts, templates */
|
|
612
|
+
ui?: StyleUI;
|
|
613
|
+
/** Particle presets: name → parameters; default is the fallback for all effects */
|
|
614
|
+
particles?: Record<string, ParticleOptions>;
|
|
615
|
+
/** Trigger zone debug wireframe */
|
|
616
|
+
triggers?: { debugColor?: ColorLike; debugOpacity?: number };
|
|
617
|
+
/**
|
|
618
|
+
* Grid placement (grids() module): preview ok / bad colors and opacity, tile lift (m), and per-layer tile colors { layer: { field: color } } (first
|
|
619
|
+
* truthy field of a cell's data wins)
|
|
620
|
+
*/
|
|
621
|
+
grid?: { ok?: ColorLike; bad?: ColorLike; previewOpacity?: number; previewHeight?: number; tileLift?: number; tiles?: Record<string, Record<string, ColorLike>> };
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* What createEngine({ style }) takes: one style object, or a list of parts deep-merged left to right (plain objects merge, everything else replaces,
|
|
625
|
+
* null removes; core/styleParts.js)
|
|
626
|
+
*/
|
|
627
|
+
export type StyleInput = Style | null | undefined | false | StyleInput[];
|
|
628
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// threedog/worker: the worker-safe entry for a lane's worker file (no three.js, no DOM). See engine.threads.lane in recipes/15-perf.md.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Start answering lane messages in a worker. handler is the same function the lane's local() returns on the main thread.
|
|
5
|
+
* @example
|
|
6
|
+
* // myWorker.js
|
|
7
|
+
* import { serve } from 'threedog/worker';
|
|
8
|
+
* import { makeHandler } from './handler.js';
|
|
9
|
+
* serve(makeHandler());
|
|
10
|
+
*/
|
|
11
|
+
export function serve(handler: (msg: any) => any): void;
|