threedog 0.2.0 → 0.5.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 +290 -0
- package/README.md +9 -8
- package/core/Animator.js +15 -12
- package/core/Assets.js +83 -16
- package/core/Audio.js +45 -38
- package/core/Baked.js +32 -8
- package/core/Batching.js +102 -15
- package/core/Budget.js +39 -18
- package/core/Clock.js +40 -80
- package/core/DebugOverrides.js +45 -10
- package/core/Describe.js +104 -43
- package/core/Engine.js +190 -57
- package/core/Events.js +4 -1
- package/core/I18n.js +25 -13
- package/core/Input.js +168 -79
- package/core/Inspect.js +2 -2
- package/core/InspectMaterials.js +85 -0
- package/core/InspectPerf.js +61 -0
- package/core/InspectScene.js +13 -2
- package/core/Loading.js +2 -1
- package/core/Ops.js +50 -9
- package/core/Random.js +9 -2
- package/core/Rays.js +5 -5
- package/core/SaveStore.js +41 -9
- package/core/Saves.js +71 -15
- package/core/Stream.js +14 -10
- package/core/Threads.js +26 -7
- package/core/UrlState.js +25 -9
- package/core/Views.js +9 -6
- package/core/actor.js +1 -1
- package/core/adaptive.js +93 -0
- package/core/assetEntry.js +22 -5
- package/core/assetHot.js +176 -0
- package/core/assetLoad.js +38 -11
- package/core/assetManifest.js +48 -9
- package/core/assetReport.js +1 -1
- package/core/audioRules.js +13 -11
- package/core/audioVoice.js +69 -42
- package/core/canvasBox.js +1 -2
- package/core/catalog.js +5 -2
- package/core/cells.js +62 -0
- package/core/checks.js +10 -8
- package/core/chunkStream.js +87 -0
- package/core/control.js +149 -0
- package/core/copies.js +32 -0
- package/core/dayTime.js +12 -6
- package/core/debugView.js +82 -15
- package/core/describeRender.js +43 -17
- package/core/describeText.js +41 -21
- package/core/engineCamera.js +32 -0
- package/core/errorCodes.js +438 -19
- package/core/errorHints.js +37 -141
- package/core/errors.js +31 -8
- package/core/events.generated.js +12 -7
- package/core/gameLights.js +62 -0
- package/core/grayMap.js +20 -0
- package/core/grid.js +128 -0
- package/core/gridLoad.js +20 -0
- package/core/ground.js +6 -4
- package/core/headlessLoad.js +55 -0
- package/core/holds.js +78 -50
- package/core/inputContext.js +11 -7
- package/core/inputDefaults.js +24 -21
- package/core/inputPad.js +1 -1
- package/core/inputPointer.js +1 -1
- package/core/inputTouch.js +2 -2
- package/core/lifecycle.js +48 -12
- package/core/lightWatch.js +6 -4
- package/core/look/coreParts.js +137 -30
- package/core/look/part.js +175 -95
- package/core/look/points.js +255 -0
- package/core/look/report.js +34 -17
- package/core/look/shadowPart.js +63 -0
- package/core/look/state.js +45 -0
- package/core/look/write.js +12 -28
- package/core/loop.js +101 -37
- package/core/math.js +11 -3
- package/core/moduleSlots.js +75 -0
- package/core/moduleTypes.js +73 -0
- package/core/modules.js +145 -27
- package/core/movement.js +2 -2
- package/core/namedModel.js +70 -0
- package/core/opsCheck.js +3 -3
- package/core/opsFail.js +15 -6
- package/core/opsGuard.js +4 -4
- package/core/opsRun.js +4 -3
- package/core/owned.js +168 -0
- package/core/page.js +2 -1
- package/core/params.js +30 -8
- package/core/plugins.js +277 -0
- package/core/saveApply.js +99 -17
- package/core/saveFiles.js +8 -6
- package/core/saveValues.js +46 -0
- package/core/saveVersions.js +20 -3
- package/core/scatter.js +48 -19
- package/core/sceneDelta.js +203 -0
- package/core/sceneMethods.js +35 -30
- package/core/screenToGround.js +1 -1
- package/core/services.js +27 -11
- package/core/session.js +28 -25
- package/core/shaderCost.js +78 -0
- package/core/shadowTypes.js +2 -1
- package/core/sharedPoint.js +317 -0
- package/core/skip.js +36 -28
- package/core/stackFrames.js +34 -0
- package/core/stacks.js +166 -0
- package/core/startup.js +153 -11
- package/core/streamSources.js +0 -11
- package/core/styleParts.js +65 -47
- package/core/targeting.js +1 -1
- package/core/textureBytes.js +20 -0
- package/core/thingExplain.js +2 -2
- package/core/thingOps.js +29 -6
- package/core/things.js +21 -11
- package/core/threadPure.js +7 -3
- package/core/threePatches.js +47 -0
- package/core/tier.js +21 -10
- package/core/time.js +236 -0
- package/core/uiClock.js +25 -0
- package/core/util.js +7 -1
- package/core/validate.js +65 -86
- package/core/wrap.js +106 -0
- package/docs/AI.md +89 -97
- package/docs/API.md +32 -28
- package/docs/CODEMAP.md +224 -149
- package/docs/COMMANDS.md +57 -34
- package/docs/CONVENTIONS.md +92 -30
- package/docs/MIGRATING-0.3.md +248 -0
- package/docs/MIGRATING-0.4.md +228 -0
- package/docs/MIGRATING-0.5.md +68 -0
- package/docs/PERF.md +35 -7
- package/docs/THREE.md +79 -27
- package/docs/api/ambience.md +0 -1
- package/docs/api/assets.md +12 -9
- package/docs/api/audio.md +10 -14
- package/docs/api/calendar.md +41 -0
- package/docs/api/cameraRig.md +16 -5
- package/docs/api/characters.md +41 -25
- package/docs/api/clock.md +6 -5
- package/docs/api/collision.md +9 -6
- package/docs/api/content.md +6 -4
- package/docs/api/dialogue.md +9 -9
- package/docs/api/engine.md +65 -62
- package/docs/api/events.md +19 -14
- package/docs/api/grids.md +3 -3
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +1 -1
- package/docs/api/input.md +11 -6
- package/docs/api/interactions.md +7 -5
- package/docs/api/inventory.md +17 -16
- package/docs/api/level.md +0 -1
- package/docs/api/lightPool.md +3 -1
- package/docs/api/music.md +1 -1
- package/docs/api/nav.md +3 -0
- package/docs/api/openWorld.md +2 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +0 -2
- package/docs/api/pickups.md +15 -0
- package/docs/api/post.md +5 -4
- package/docs/api/quests.md +2 -3
- package/docs/api/rigid.md +16 -14
- package/docs/api/saves.md +6 -4
- package/docs/api/settings.md +2 -3
- package/docs/api/sky.md +11 -44
- package/docs/api/stream.md +1 -1
- package/docs/api/style.md +31 -29
- package/docs/api/terrain.md +9 -6
- package/docs/api/terrainLook.md +10 -0
- package/docs/api/timeline.md +3 -4
- package/docs/api/tools.md +30 -13
- package/docs/api/triggers.md +5 -10
- package/docs/api/vegetation.md +12 -8
- package/docs/api/vegetationLook.md +10 -0
- package/docs/api/water.md +4 -20
- package/docs/api/weather.md +5 -15
- package/docs/api/weatherLook.md +10 -0
- package/docs/api/world.md +2 -1
- package/docs/recipes/01-new-game.md +71 -59
- package/docs/recipes/02-npc.md +46 -29
- package/docs/recipes/03-items-pickups.md +38 -24
- package/docs/recipes/04-quests.md +34 -27
- package/docs/recipes/05-props-bake.md +154 -18
- package/docs/recipes/06-clock-events.md +100 -52
- package/docs/recipes/07-flow-scenes-pause.md +41 -10
- package/docs/recipes/08-weather-sky.md +146 -37
- package/docs/recipes/09-style.md +218 -0
- package/docs/recipes/10-blender-level.md +14 -2
- package/docs/recipes/11-vehicles.md +64 -7
- package/docs/recipes/13-animation.md +34 -10
- package/docs/recipes/14-custom-module.md +65 -34
- package/docs/recipes/15-perf.md +35 -6
- package/docs/recipes/16-dev-bridge.md +65 -41
- package/docs/recipes/18-world.md +21 -8
- package/docs/recipes/19-shooting-picking.md +12 -11
- package/docs/recipes/20-content-actions-save.md +63 -25
- package/docs/recipes/21-camera.md +49 -16
- package/docs/recipes/22-shop-gold.md +18 -18
- package/docs/recipes/23-ops.md +17 -11
- package/docs/recipes/26-ui-parts.md +61 -12
- package/docs/recipes/27-net.md +12 -6
- package/docs/recipes/28-terrain.md +35 -2
- package/docs/recipes/29-grid.md +71 -33
- package/docs/recipes/30-templates.md +64 -12
- package/docs/recipes/31-audio.md +20 -12
- package/docs/recipes/32-action-game.md +35 -2
- package/docs/recipes/34-environment-lighting.md +27 -4
- package/docs/recipes/35-style-from-reference.md +115 -51
- package/docs/recipes/36-sky-ground-plant-looks.md +37 -35
- package/docs/recipes/37-terrain-look-hooks.md +37 -15
- package/docs/recipes/38-environment-look-hooks.md +64 -48
- package/docs/recipes/40-scene.md +16 -13
- package/docs/recipes/41-thing-registry.md +11 -7
- package/docs/recipes/42-terrain-shape.md +3 -3
- package/docs/recipes/43-shader-patches-surface-looks.md +171 -74
- package/docs/recipes/44-water-weather-look-hooks.md +30 -21
- package/docs/recipes/45-cascaded-shadows.md +17 -8
- package/docs/recipes/46-blender-art-route.md +4 -4
- package/docs/recipes/47-island-snow-backdrop.md +11 -10
- package/docs/recipes/48-make-material.md +11 -6
- package/docs/recipes/49-game-module-contract.md +46 -33
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/51-capability-catalog.md +4 -4
- package/docs/recipes/52-look.md +228 -54
- package/docs/recipes/53-ground-up-close.md +58 -0
- package/docs/recipes/54-three-idioms.md +88 -0
- package/docs/recipes/55-mods-time-wrap.md +112 -0
- package/docs/recipes/56-webgpu-tsl.md +260 -0
- package/docs/recipes/57-control.md +65 -0
- package/docs/recipes/58-input.md +57 -0
- package/docs/recipes/59-depth-post-effects.md +83 -0
- package/docs/recipes/60-judge-the-picture.md +55 -0
- package/examples/action/.threedog/content-index.json +1 -0
- package/examples/action/GAMEMAP.md +17 -13
- package/examples/action/assets.js +8 -0
- package/examples/action/content/actions.js +1 -1
- package/examples/action/content/audio.js +5 -5
- package/examples/action/look.js +1 -1
- package/examples/action/main.js +10 -13
- package/examples/action/models.js +24 -23
- package/examples/pullable.json +111 -0
- package/examples/rc2d/.threedog/content-index.json +1 -0
- package/examples/rc2d/GAMEMAP.md +83 -0
- package/examples/rc2d/README.md +52 -0
- package/examples/rc2d/main.js +63 -0
- package/examples/rc2d/rc2d.js +197 -0
- package/examples/rc2d/shaders.js +144 -0
- package/examples/sheepisland/.threedog/content-index.json +1 -0
- package/examples/sheepisland/GAMEMAP.md +13 -11
- package/examples/sheepisland/assets.js +5 -0
- package/examples/sheepisland/main.js +17 -12
- package/examples/sheepisland/style/index.js +6 -6
- package/examples/styletest/.threedog/content-index.json +1 -0
- package/examples/styletest/GAMEMAP.md +15 -16
- package/examples/styletest/assets.js +6 -0
- package/examples/styletest/content/npcs.js +1 -1
- package/examples/styletest/content/templates.js +1 -1
- package/examples/styletest/content/vegetation.js +1 -1
- package/examples/styletest/look.js +1 -1
- package/examples/styletest/main.js +18 -17
- package/examples/styletest/models.js +1 -1
- package/examples/styletest/params.js +3 -3
- package/examples/techniques/contact-shadows/README.md +92 -0
- package/examples/techniques/contact-shadows/contactShadows.js +51 -0
- package/examples/techniques/contact-shadows/main.js +53 -0
- package/examples/techniques/day-night-grade/README.md +86 -0
- package/examples/techniques/day-night-grade/dayNightGrade.js +76 -0
- package/examples/techniques/day-night-grade/main.js +51 -0
- package/examples/techniques/interior-light/README.md +103 -0
- package/examples/techniques/interior-light/interiorLight.js +45 -0
- package/examples/techniques/interior-light/main.js +124 -0
- package/examples/techniques/modular-building/README.md +125 -0
- package/examples/techniques/modular-building/kit.js +426 -0
- package/examples/techniques/modular-building/main.js +47 -0
- package/examples/techniques/night-lights/README.md +94 -0
- package/examples/techniques/night-lights/main.js +70 -0
- package/examples/techniques/night-lights/nightLights.js +91 -0
- package/examples/techniques/outlines-and-rim/README.md +59 -0
- package/examples/techniques/outlines-and-rim/main.js +84 -0
- package/examples/techniques/outlines-and-rim/outlines.js +64 -0
- package/examples/techniques/procedural-animation/README.md +77 -0
- package/examples/techniques/procedural-animation/creature.js +44 -0
- package/examples/techniques/procedural-animation/main.js +45 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +118 -0
- package/examples/techniques/procedural-surface/README.md +67 -0
- package/examples/techniques/procedural-surface/main.js +103 -0
- package/examples/techniques/procedural-surface/surface.js +120 -0
- package/examples/techniques/stylized-shading/README.md +75 -0
- package/examples/techniques/stylized-shading/main.js +93 -0
- package/examples/techniques/stylized-shading/shading.js +131 -0
- package/examples/techniques/sun-and-key-light/README.md +135 -0
- package/examples/techniques/sun-and-key-light/keyLight.js +53 -0
- package/examples/techniques/sun-and-key-light/main.js +95 -0
- package/examples/techniques/wet-road/README.md +99 -0
- package/examples/techniques/wet-road/main.js +68 -0
- package/examples/techniques/wet-road/wetRoad.js +209 -0
- package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
- package/examples/webgpu-tsl/GAMEMAP.md +84 -0
- package/examples/webgpu-tsl/README.md +42 -0
- package/examples/webgpu-tsl/main.js +21 -0
- package/examples/webgpu-tsl/tslScene.js +75 -0
- package/examples/world/.threedog/content-index.json +1 -0
- package/examples/world/GAMEMAP.md +22 -15
- package/examples/world/art/humanoid.js +42 -0
- package/examples/world/art/index.js +11 -0
- package/examples/world/art/models.js +58 -0
- package/examples/world/art/shapes.js +9 -0
- package/examples/world/assets.js +6 -0
- package/examples/world/content/audio.js +5 -5
- package/examples/world/content/npcs.js +2 -2
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/rules.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +17 -13
- package/examples/world/style/index.js +61 -0
- package/examples/world/style/plugins/10-bloom.js +5 -0
- package/index.d.ts +50 -45
- package/index.js +27 -22
- package/llms.txt +20 -12
- package/modules/ambience/Ambience.js +34 -23
- package/modules/calendar/Calendar.js +163 -0
- package/modules/calendar/contract.js +21 -0
- package/modules/calendar/index.js +81 -0
- package/modules/{sky → calendar}/schedule.js +17 -16
- package/modules/calendar/seasons.js +55 -0
- package/modules/camera/FirstPersonCamera.js +6 -15
- package/modules/camera/FixedCamera.js +33 -15
- package/modules/camera/FollowCamera.js +90 -16
- package/modules/camera/RtsCamera.js +18 -17
- package/modules/camera/common.js +70 -19
- package/modules/camera/contract.js +17 -0
- package/modules/camera/projection.js +11 -24
- package/modules/characters/Character.js +196 -59
- package/modules/characters/NPC.js +87 -36
- package/modules/characters/assetModel.js +27 -8
- package/modules/characters/behaviors.js +2 -1
- package/modules/characters/contract.js +13 -0
- package/modules/characters/footsteps.js +1 -1
- package/modules/characters/index.js +87 -49
- package/modules/characters/moveHelpers.js +4 -5
- package/modules/characters/movers/common.js +97 -19
- package/modules/characters/movers/manual.js +20 -0
- package/modules/characters/movers/rapier.js +19 -16
- package/modules/characters/movers/simple.js +14 -11
- package/modules/characters/movers/support.js +172 -0
- package/modules/characters/npcAvoid.js +47 -42
- package/modules/characters/npcSim.js +12 -8
- package/modules/characters/npcView.js +44 -16
- package/modules/characters/pathAsync.js +7 -3
- package/modules/characters/playerStrings.js +4 -3
- package/modules/characters/proceduralRig.js +46 -10
- package/modules/characters/useModel.js +1 -1
- package/modules/characters/vehicle.contract.js +21 -0
- package/modules/characters/walkTo.js +21 -7
- package/modules/collision/Collision.js +65 -25
- package/modules/collision/grid.js +8 -6
- package/modules/content/explain.js +2 -2
- package/modules/content/fields.js +102 -0
- package/modules/content/ids.js +8 -6
- package/modules/content/index.js +97 -28
- package/modules/content/loader.js +45 -33
- package/modules/content/models.js +11 -40
- package/modules/content/packs.js +6 -5
- package/modules/content/parts.js +41 -0
- package/modules/content/props.js +16 -9
- package/modules/content/rules.js +58 -0
- package/modules/content/stages.js +80 -0
- package/modules/content/templates.js +121 -30
- package/modules/debug/DebugPanel.js +24 -17
- package/modules/flow/contract.js +16 -0
- package/modules/flow/index.js +21 -15
- package/modules/gameplay/Container.js +41 -32
- package/modules/gameplay/Containers.js +30 -15
- package/modules/gameplay/Dialogue.js +113 -55
- package/modules/gameplay/Interactions.js +193 -67
- package/modules/gameplay/Inventory.js +69 -73
- package/modules/gameplay/Quests.js +75 -39
- package/modules/gameplay/boxOps.js +3 -3
- package/modules/gameplay/dialogue.contract.js +21 -0
- package/modules/gameplay/dialogueBox.js +4 -2
- package/modules/gameplay/dialogueBubbles.js +116 -0
- package/modules/gameplay/interactionPrompt.js +4 -1
- package/modules/gameplay/interactions.contract.js +16 -0
- package/modules/gameplay/inventory.contract.js +23 -0
- package/modules/gameplay/inventoryOps.js +18 -16
- package/modules/gameplay/pickups.js +268 -85
- package/modules/gameplay/questLog.js +4 -4
- package/modules/gameplay/quests.contract.js +17 -0
- package/modules/grid/Grid.js +92 -50
- package/modules/grid/Layer.js +14 -13
- package/modules/grid/index.js +60 -36
- package/modules/grid/ops.js +20 -18
- package/modules/grid/preview.js +15 -16
- package/modules/grid/strings.js +12 -0
- package/modules/grid/tiles.js +6 -5
- package/modules/hlod/index.js +51 -19
- package/modules/hud/index.js +35 -20
- package/modules/hud/parts.js +20 -7
- package/modules/level/heightfield.js +3 -1
- package/modules/level/index.js +45 -20
- package/modules/level/nodes.js +4 -3
- package/modules/lights/index.js +42 -18
- package/modules/music/Music.js +38 -21
- package/modules/music/rules.js +1 -1
- package/modules/nav/index.js +48 -42
- package/modules/net/Client.js +13 -6
- package/modules/net/Host.js +19 -5
- package/modules/net/Net.js +2 -1
- package/modules/net/index.js +13 -8
- package/modules/net/sync.js +9 -8
- package/modules/net/transports.js +77 -27
- package/modules/particles/Particles.js +23 -14
- package/modules/particles/contract.js +17 -0
- package/modules/particles/effect.js +39 -11
- package/modules/photo/Photo.js +53 -36
- package/modules/rigid/RigidBodies.js +194 -32
- package/modules/rigid/Vehicles.js +18 -15
- package/modules/rigid/sync.js +62 -17
- package/modules/settings/Settings.js +57 -52
- package/modules/settings/apply.js +38 -3
- package/modules/settings/sections.js +5 -3
- package/modules/settings/strings.js +3 -2
- package/modules/settings/view.js +5 -3
- package/modules/sky/Sky.js +88 -176
- package/modules/sky/cascades.js +86 -25
- package/modules/sky/cascades.tsl.js +82 -0
- package/modules/sky/clouds.js +34 -19
- package/modules/sky/domeLayers.js +30 -15
- package/modules/sky/environment.js +83 -13
- package/modules/sky/fog.js +140 -95
- package/modules/sky/frame.js +112 -44
- package/modules/sky/look.js +22 -19
- package/modules/sky/lookFog.js +48 -52
- package/modules/sky/lookShadow.js +53 -41
- package/modules/sky/lookSky.js +82 -21
- package/modules/sky/season.js +21 -0
- package/modules/sky/shader.js +41 -19
- package/modules/sky/shadow.js +44 -20
- package/modules/sky/skyModule.js +45 -33
- package/modules/sky/tint.js +61 -0
- package/modules/terrain/ChunkManager.js +175 -108
- package/modules/terrain/chunkJob.js +1 -1
- package/modules/terrain/chunkQueries.js +6 -4
- package/modules/terrain/index.js +105 -50
- package/modules/terrain/look.js +83 -0
- package/modules/terrain/lookGround.js +21 -16
- package/modules/terrain/terrainDefaults.js +1 -1
- package/modules/terrain/terrainEdit.js +18 -20
- package/modules/terrain/terrainGen.js +5 -3
- package/modules/terrain/terrainIsland.js +5 -4
- package/modules/terrain/terrainShape.js +12 -12
- package/modules/terrain/terrainShapeMain.js +8 -7
- package/modules/terrain/terrainTexture.js +21 -19
- package/modules/timeline/Timeline.js +95 -43
- package/modules/timeline/Tween.js +18 -10
- package/modules/timeline/letterbox.js +2 -2
- package/modules/timeline/shots.js +5 -1
- package/modules/triggers/index.js +107 -76
- package/modules/vegetation/Vegetation.js +190 -102
- package/modules/vegetation/densityMap.js +62 -0
- package/modules/vegetation/groundChunks.js +52 -58
- package/modules/vegetation/index.js +31 -10
- package/modules/vegetation/look.js +119 -0
- package/modules/vegetation/lookWind.js +71 -10
- package/modules/vegetation/modelGeometry.js +3 -2
- package/modules/vegetation/nearFade.js +45 -0
- package/modules/water/Water.js +65 -27
- package/modules/water/look.js +29 -18
- package/modules/water/surface.js +64 -25
- package/modules/water/surfaceDefaults.js +3 -0
- package/modules/weather/Weather.js +62 -104
- package/modules/weather/look.js +1 -2
- package/modules/weather/particles.js +24 -9
- package/modules/weather/strings.js +2 -2
- package/modules/weather/weatherLook.js +135 -0
- package/modules/world/World.js +24 -7
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -4
- package/modules/world/persist.js +62 -2
- package/modules/world/pos.js +3 -2
- package/modules/world/records.js +8 -6
- package/modules/world/sim.js +60 -20
- package/modules/world/simFar.js +4 -3
- package/modules/world/state.js +3 -2
- package/modules/world/thingSource.js +1 -1
- package/modules/world/views.js +7 -5
- package/package.json +8 -3
- package/presets.js +41 -27
- package/render/PostFX.js +145 -120
- package/render/backend.js +440 -0
- package/render/detail.js +150 -45
- package/render/effects.js +130 -38
- package/render/engineUniforms.js +10 -1
- package/render/fuse.js +5 -4
- package/render/fx/cloudShadow.tsl.js +16 -0
- package/render/fx/detail.tsl.js +66 -0
- package/render/fx/index.js +26 -0
- package/render/fx/lighting.tsl.js +28 -0
- package/render/fx/nodeErrors.tsl.js +68 -0
- package/render/fx/noise.tsl.js +12 -0
- package/render/fx/objectOrigin.tsl.js +42 -0
- package/render/fx/particles.tsl.js +139 -0
- package/render/fx/patchNodes.tsl.js +403 -0
- package/render/fx/postWebGPU.tsl.js +158 -0
- package/render/fx/season.tsl.js +13 -0
- package/render/fx/sky.tsl.js +260 -0
- package/render/fx/uniforms.tsl.js +67 -0
- package/render/fx/water.tsl.js +53 -0
- package/render/fx/wind.tsl.js +22 -0
- package/render/fxNumbers.js +36 -0
- package/render/hotGlsl.js +24 -0
- package/render/lighting.js +66 -14
- package/render/lights.js +223 -4
- package/render/lookGlow.js +139 -0
- package/render/lookSurface.js +99 -36
- package/render/materials.js +71 -52
- package/render/modeling.js +73 -0
- package/render/ownFrame.js +76 -0
- package/render/patches.js +311 -34
- package/render/postLook.js +124 -46
- package/render/postWebGL.js +197 -0
- package/render/probes.js +231 -0
- package/render/shaderErrors.js +154 -0
- package/render/slots.js +165 -0
- package/render/surface.js +53 -17
- package/render/terms.js +211 -0
- package/render/uniformDecl.js +3 -2
- package/types/common.d.ts +2 -2
- package/types/core.d.ts +620 -244
- package/types/gameplay.d.ts +494 -318
- package/types/generated/core/Audio.d.ts +26 -42
- package/types/generated/core/Batching.d.ts +6 -2
- package/types/generated/core/Budget.d.ts +2 -8
- package/types/generated/core/DebugOverrides.d.ts +44 -3
- package/types/generated/core/I18n.d.ts +2 -2
- package/types/generated/core/Input.d.ts +102 -31
- package/types/generated/core/Ops.d.ts +31 -0
- package/types/generated/core/Random.d.ts +2 -2
- package/types/generated/core/Saves.d.ts +10 -2
- package/types/generated/core/Stream.d.ts +1 -1
- package/types/generated/core/Threads.d.ts +4 -1
- package/types/generated/core/Views.d.ts +0 -1
- package/types/generated/core/audioVoice.d.ts +17 -9
- package/types/generated/core/control.d.ts +55 -0
- package/types/generated/core/session.d.ts +2 -1
- package/types/generated/modules/ambience/Ambience.d.ts +0 -9
- package/types/generated/modules/calendar/Calendar.d.ts +84 -0
- package/types/generated/modules/calendar/index.d.ts +10 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
- package/types/generated/modules/grid/Grid.d.ts +61 -25
- package/types/generated/modules/grid/Layer.d.ts +5 -5
- package/types/generated/modules/grid/index.d.ts +29 -17
- package/types/generated/modules/music/Music.d.ts +5 -3
- package/types/generated/modules/net/index.d.ts +3 -3
- package/types/generated/modules/net/transports.d.ts +12 -3
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/sky/Sky.d.ts +12 -104
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/timeline/Timeline.d.ts +8 -6
- package/types/generated/modules/weather/Weather.d.ts +17 -18
- package/types/generated/modules/weather/weatherLook.d.ts +12 -0
- package/types/generated/modules/world/World.d.ts +18 -3
- package/types/generated/render/PostFX.d.ts +67 -30
- package/types/generated/render/materials.d.ts +26 -20
- package/types/generated/render/modeling.d.ts +30 -0
- package/types/generated/render/patches.d.ts +16 -2
- package/types/generated/ui/UI.d.ts +6 -3
- package/types/nav.d.ts +6 -0
- package/types/physics.d.ts +137 -44
- package/types/style.d.ts +125 -92
- package/types/tsl.d.ts +86 -0
- package/types/world.d.ts +164 -110
- package/ui/Focus.js +25 -14
- package/ui/LoadingScreen.js +1 -1
- package/ui/Parts.js +27 -11
- package/ui/UI.js +20 -10
- package/ui/cursor.js +115 -0
- package/ui/defaults.js +15 -11
- package/ui/theme.js +9 -6
- package/ui/touchPart.js +1 -1
- package/core/claims.js +0 -51
- package/core/look/layers.js +0 -136
- package/core/renamed.js +0 -21
- package/docs/api/entities.md +0 -61
- package/docs/recipes/09-style-pack.md +0 -234
- package/examples/styletest/overrides.js +0 -33
- package/examples/styletest/panel.js +0 -135
- package/modules/entities/Entities.js +0 -243
- package/modules/entities/build.js +0 -25
- package/modules/entities/index.js +0 -4
- package/modules/sky/calendar.js +0 -80
- package/modules/sky/layers.js +0 -69
- package/modules/terrain/chunkLevels.js +0 -40
- package/modules/terrain/mountTerrain.js +0 -32
- package/modules/world/cells.js +0 -42
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Input: modules declare actions, the game binds keys
|
|
2
|
+
|
|
3
|
+
Three roles, one rule each:
|
|
4
|
+
- **A module declares** an action and the context it is read in, never a key: `ctx.input.action('choice1', { context: 'dialog' })`.
|
|
5
|
+
- **The game binds** keys: `createEngine({ bindings })`, `engine.input.bind(...)`, or a ready map from `presets.bindings`.
|
|
6
|
+
- **The player rebinds** in the settings menu, which calls `engine.input.rebind` and saves it.
|
|
7
|
+
|
|
8
|
+
Only the basics have default keys, the one default preset: WASD / arrows move (`moveForward` ...), `confirm` (Space / Enter / pad A),
|
|
9
|
+
`cancel` (Esc / pad B) and the UI cursor (`uiUp` ...). Every other key in your game is a line you wrote.
|
|
10
|
+
|
|
11
|
+
## 1. Bind keys (the game)
|
|
12
|
+
```js
|
|
13
|
+
import { createEngine, presets } from 'threedog';
|
|
14
|
+
const engine = createEngine({ canvas, bindings: {
|
|
15
|
+
attack: ['KeyJ', 'Mouse0', 'PadX'], // keyboard, mouse buttons (Mouse0 / 1 / 2) and gamepad buttons go in one list
|
|
16
|
+
...presets.bindings.dialogNumbers, // 1-9 pick dialogue choices
|
|
17
|
+
...presets.bindings.debug, // F3 debug panel, F4 trigger wireframes
|
|
18
|
+
} });
|
|
19
|
+
engine.input.bind('dodge', ['ShiftLeft']); // later, in code; returns a handle, remove() takes the keys away
|
|
20
|
+
engine.input.bind(presets.bindings.rtsRotate); // a whole map at once: rotateLeft Q, rotateRight R
|
|
21
|
+
engine.input.action('brake', { context: 'vehicle', label: 'Brake', keys: ['KeyB'] }); // your own action with a context and a label for the menu
|
|
22
|
+
engine.onFixed(() => { if (engine.input.pressed('attack')) swing(); }); // gameplay keys are read in the fixed step
|
|
23
|
+
```
|
|
24
|
+
`presets.bindings`: `walk` (run / jump), `interact`, `inventory`, `quests`, `photo`, `gridRotate` (rotate), `brake`, `dialogNumbers` (choice1..9),
|
|
25
|
+
`rtsRotate` (rotateLeft / rotateRight), `cutsceneSkip` (skip: Backspace; cancel always skips), `debug` (debugPanel F3, triggersDebug F4). Spread one
|
|
26
|
+
and override a key like any object: `{ ...presets.bindings.rtsRotate, rotateLeft: ['KeyZ'] }`. No module takes a keys option: a module only declares
|
|
27
|
+
its actions (gone with the module), the game binds them; `[]` is deliberately no key.
|
|
28
|
+
|
|
29
|
+
## 2. Contexts: the top one wins
|
|
30
|
+
Every action belongs to one context. The stack starts with `walk`; a module or the game pushes others: `vehicle` (pass: unrelated `walk` actions
|
|
31
|
+
keep working), `dialog`, `menu`, `cutscene` (opaque: nothing below reads). The top context wins a key both bind.
|
|
32
|
+
```js
|
|
33
|
+
const car = engine.input.push('vehicle', { pass: true, owner: 'car' }); // brake (context vehicle) reads now; car.remove() pops it
|
|
34
|
+
engine.describe().input // { stack: ['walk', 'vehicle(owner: car)'], unbound: [], rebound: { attack: ['KeyK'] } }
|
|
35
|
+
```
|
|
36
|
+
Details of switching (next fixed step, no stuck keys, focus loss): recipe 07 §2b.
|
|
37
|
+
|
|
38
|
+
## 3. In a module: declare, read, leave
|
|
39
|
+
```js
|
|
40
|
+
const sprint = () => ({ name: 'sprint', type: 'rules', install(e, ctx) {
|
|
41
|
+
ctx.input.action('sprint', { label: 'sprint.action' }); // no keys: the game binds 'sprint'
|
|
42
|
+
ctx.input.action('sprintHud', { label: 'sprint.hud', optional: true }); // optional: reading it unbound is silent
|
|
43
|
+
}, fixed(dt, e) { if (e.input.down('sprint')) boost(e.player); } });
|
|
44
|
+
```
|
|
45
|
+
Everything a module declares or binds through `ctx.input` leaves with it (rollback, `replaces`, dispose).
|
|
46
|
+
|
|
47
|
+
## 4. What the engine tells you
|
|
48
|
+
- **`input-unbound`** (dev, once per action): a module needs an action nobody bound. The message names the action, its context and the bind line.
|
|
49
|
+
- **`input-bound-twice`** (dev throws; release: the later wins): two owners bind one action, e.g. the game's `createEngine({ bindings })` and a
|
|
50
|
+
module's `ctx.input.bind` for the same action. Keep one. The same owner binding again only replaces its keys.
|
|
51
|
+
- **`input-action-context`**: two owners declare one action in different contexts. Rename one, or use the same context to share it.
|
|
52
|
+
- `describe().shared['input.keys[attack]']` says who bound the keys now in effect (writer `game`, `settings` for the player's choice, or a module).
|
|
53
|
+
|
|
54
|
+
## 5. Rebinding (the player)
|
|
55
|
+
`engine.input.rebind('attack', ['KeyK'])` is the player's choice, on top of the game's keys; `rebind('attack', null)` gives the game's back.
|
|
56
|
+
`engine.input.rebound()` lists them (the settings menu saves exactly that and restores it at start, even before the module declaring an action is
|
|
57
|
+
installed). The settings menu's key page, its reset button and its save all go through these two calls.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# A post effect that reads depth (volumetric fog, god rays)
|
|
2
|
+
|
|
3
|
+
Fog you march through, light shafts, haze that thickens with distance, edge or focus effects: they all read the scene depth behind each pixel
|
|
4
|
+
and turn it into a distance or a world position. This recipe writes one such effect with both forms, a three.js `Pass` (GLSL) for
|
|
5
|
+
WebGLRenderer and a TSL node for WebGPURenderer, in one effect object. How effects are ordered, switched and tuned is recipe 52's
|
|
6
|
+
[Post effect chain](52-look.md#post-effect-chain); the TSL side in general is [recipe 56](56-webgpu-tsl.md#post-effects-as-nodes).
|
|
7
|
+
For plain distance or height fog on materials, `engine.look.fog` is enough (recipe 38); a post effect is for what fog on materials cannot do.
|
|
8
|
+
|
|
9
|
+
## One effect, both renderers
|
|
10
|
+
`needsDepth: true` gives the WebGL pass the scene depth as `readBuffer.depthTexture`; on WebGPU the same depth is `ctx.scenePass.getTextureNode('depth')`.
|
|
11
|
+
Both turn the stored depth into the view distance with the camera's near and far. Number and color params are live: `look.post.set` writes
|
|
12
|
+
them without a rebuild (WebGL through `update`, WebGPU through the uniforms in `ctx.p`).
|
|
13
|
+
```js
|
|
14
|
+
import * as THREE from 'three';
|
|
15
|
+
import { Pass, FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
|
|
16
|
+
|
|
17
|
+
class DepthHazePass extends Pass {
|
|
18
|
+
constructor(camera) {
|
|
19
|
+
super();
|
|
20
|
+
this.camera = camera;
|
|
21
|
+
this.material = new THREE.ShaderMaterial({
|
|
22
|
+
uniforms: { tDiffuse: { value: null }, tDepth: { value: null }, uNear: { value: 0.1 }, uFar: { value: 1000 },
|
|
23
|
+
uColor: { value: new THREE.Color() }, uDensity: { value: 0.02 } },
|
|
24
|
+
vertexShader: 'varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
|
|
25
|
+
fragmentShader: `uniform sampler2D tDiffuse; uniform sampler2D tDepth; uniform float uNear, uFar, uDensity; uniform vec3 uColor; varying vec2 vUv;
|
|
26
|
+
void main() {
|
|
27
|
+
vec4 base = texture2D(tDiffuse, vUv);
|
|
28
|
+
float z = texture2D(tDepth, vUv).x * 2.0 - 1.0;
|
|
29
|
+
float dist = 2.0 * uNear * uFar / (uFar + uNear - z * (uFar - uNear)); // view distance in world units
|
|
30
|
+
gl_FragColor = vec4(mix(base.rgb, uColor, 1.0 - exp(-uDensity * dist)), base.a);
|
|
31
|
+
}`,
|
|
32
|
+
depthTest: false, depthWrite: false,
|
|
33
|
+
});
|
|
34
|
+
this.quad = new FullScreenQuad(this.material);
|
|
35
|
+
}
|
|
36
|
+
render(renderer, writeBuffer, readBuffer) {
|
|
37
|
+
const u = this.material.uniforms;
|
|
38
|
+
u.tDiffuse.value = readBuffer.texture; u.tDepth.value = readBuffer.depthTexture;
|
|
39
|
+
u.uNear.value = this.camera.near; u.uFar.value = this.camera.far;
|
|
40
|
+
renderer.setRenderTarget(this.renderToScreen ? null : writeBuffer);
|
|
41
|
+
this.quad.render(renderer);
|
|
42
|
+
}
|
|
43
|
+
dispose() { this.material.dispose(); this.quad.dispose(); }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// WebGPU: the same math as a node. onRenderUpdate's callback RETURNS the new value (it is not handed one to edit)
|
|
47
|
+
function depthHazeNode(input, { tsl: T, scenePass, camera, p }) {
|
|
48
|
+
const near = T.uniform(camera.near).onRenderUpdate(() => camera.near), far = T.uniform(camera.far).onRenderUpdate(() => camera.far);
|
|
49
|
+
const depth = scenePass.getTextureNode('depth').sample(T.screenUV).x;
|
|
50
|
+
const dist = T.perspectiveDepthToViewZ(depth, near, far).negate();
|
|
51
|
+
return T.vec4(T.mix(input.rgb, p.color, T.float(1).sub(T.exp(p.density.mul(dist).negate()))), input.a);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const update = (pass, p) => { pass.material.uniforms.uColor.value.copy(p.color); pass.material.uniforms.uDensity.value = p.density; };
|
|
55
|
+
engine.look.post.add({ name: 'depthHaze', slot: 'hdr', needsDepth: true, params: { color: new THREE.Color(0.72, 0.76, 0.82), density: 0.02 },
|
|
56
|
+
create: ({ camera, params }) => { const pass = new DepthHazePass(camera); update(pass, params); return pass; }, update, node: depthHazeNode });
|
|
57
|
+
engine.look.post.set({ 'depthHaze.density': 0.05 }); // live on both renderers
|
|
58
|
+
```
|
|
59
|
+
- Slot `hdr`: the effect works in linear color, before tone mapping, so a bright sun shaft can bloom after it.
|
|
60
|
+
- A world position instead of a distance (height fog, a fog volume): on WebGL multiply the clip-space point by `camera.projectionMatrixInverse`,
|
|
61
|
+
then `camera.matrixWorld` (pass both as uniforms each frame); on WebGPU scale the view ray by the view depth and use `T.cameraWorldMatrix`.
|
|
62
|
+
Both routes must give the same point; compare them with `threedog shot` on each renderer.
|
|
63
|
+
- Depth order: a depth reader runs before any pass that swaps buffers; recipe 52 says how `order` keeps it so and what throws when it does not.
|
|
64
|
+
|
|
65
|
+
## Volumetric fog: march along the ray
|
|
66
|
+
A raymarch adds up fog in steps from the camera to the depth found above. On WebGPU the march is a `Loop`, and a `Loop` (like `If` or
|
|
67
|
+
`.addAssign`) is a statement: it must be written inside an `Fn`, or three drops it with no error and the fog vanishes (the engine warns in dev
|
|
68
|
+
for an effect's node). On WebGL it is a plain `for` loop in the fragment shader.
|
|
69
|
+
```js
|
|
70
|
+
// WebGPU: give it as an effect's node, beside a create() whose GLSL marches with a for loop
|
|
71
|
+
function marchedFogNode(input, { tsl: T, p }) {
|
|
72
|
+
return T.Fn(() => {
|
|
73
|
+
const acc = T.float(0).toVar();
|
|
74
|
+
T.Loop(16, ({ i }) => { acc.addAssign(p.density.mul(T.float(i).add(0.5))); }); // your density per step goes here
|
|
75
|
+
return T.vec4(T.mix(input.rgb, p.color, acc.clamp(0, 1)), input.a);
|
|
76
|
+
})();
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
## God rays
|
|
80
|
+
Light shafts from the sun: sample the color (or a mask: depth at the far plane is sky) along the line from each pixel toward the sun's point on
|
|
81
|
+
screen and add it up with falling weight. The sun's screen point is `engine.uniforms.uSunDir` projected with the camera each frame; when it is
|
|
82
|
+
behind the camera, fade the effect out. The color at other pixels needs the input as a texture: on WebGPU `ctx.display.texture(input)`, on
|
|
83
|
+
WebGL the pass's `readBuffer.texture`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# 60 Make the picture look good: what each knob does and how to judge it
|
|
2
|
+
|
|
3
|
+
A map for visual polish: when you want to tune the picture, make a scene look prettier or closer to what the game wants, this page lists the
|
|
4
|
+
knobs, what each one changes on screen and how to tell it is right. **It is not a list of steps and nothing here is required**: pick the knobs
|
|
5
|
+
your style needs and leave the rest alone. There are no values to copy on purpose; the right value depends on the style, the camera and the
|
|
6
|
+
time of day, so every row says what to look for instead.
|
|
7
|
+
|
|
8
|
+
Where the rest lives (one home each, this page only points there):
|
|
9
|
+
- the calls, their parameters and who writes what: [recipe 52](52-look.md) (the look API, every part);
|
|
10
|
+
- the plain three.js way and how the engine yields to it: [THREE.md](../THREE.md) (a direct write takes the value over; the engine stops writing it);
|
|
11
|
+
- questions about the whole picture (light roles, readability, consistency) and the numbers each shot prints: [recipe 35](35-style-from-reference.md) "Look questions" and "Look check after every shot";
|
|
12
|
+
- a whole look as one package: a style pack ([recipe 09](09-style.md)).
|
|
13
|
+
|
|
14
|
+
## How to judge, in one loop
|
|
15
|
+
Change one knob, take a shot (`threedog shot`, or `threedog snap` on a running page), compare with the one before, keep or undo. Shoot the
|
|
16
|
+
times and weathers the game really shows (`threedog shot --time`), not only noon. A knob is right when the difference you wanted is visible
|
|
17
|
+
and nothing else got worse; when you cannot say what difference a knob should make, leave it at the style's value.
|
|
18
|
+
|
|
19
|
+
## The knobs
|
|
20
|
+
|
|
21
|
+
| Knob | What it changes on screen | It is right when | Engine line (details) | Plain three.js |
|
|
22
|
+
|---|---|---|---|---|
|
|
23
|
+
| Sky gradient, horizon | the color from the top of the sky down to where it meets the ground | the horizon band and the fog agree where they meet; the top-to-horizon change matches the hour and mood; no visible seam | `look.sky.set({ top, horizon })` ([08 §3](08-weather-sky.md#3-changing-sky-colors-sun-stars-style)); own shader: share `engine.uniforms.uSkyHorizon` / `uSkyTop` ([08](08-weather-sky.md#sky-color-for-my-shader-horizon-color-zenith-color)) | `engine.look.sky.replace(mySky)` with three/addons `Sky` or a `ShaderMaterial` dome |
|
|
24
|
+
| Fog near / far | how fast distant things fade | the play space stays clear, the far edge of the world dissolves instead of ending in a line, landmarks you want seen still read | `look.fog.set({ near, far })` ([52 Atmosphere](52-look.md#atmosphere-parts-sky-module-fog-sky-shadow)) | `engine.scene.fog = new THREE.Fog(color, near, far)` |
|
|
25
|
+
| Fog color vs sky | whether the distance melts into the sky or into its own haze | distant hills fade toward the sky behind them; a fog color of its own is a choice you can name (smoke, mist, a dream) | `look.fog.set({ color })` (`'horizon'` follows the sky; [38 Fog](38-environment-look-hooks.md#fog-kind-color-density-your-own-math-or-your-own-fog)) | `engine.scene.fog.color.set(c)` |
|
|
26
|
+
| Exposure | overall brightness after lighting | the brightest things you care about keep detail and the darkest still read; a night is dark because the lights are, not because exposure hides it | `look.tone.set({ exposure })` ([38 Exposure](38-environment-look-hooks.md#exposure-over-time-and-the-tone-curve)) | `engine.renderer.toneMappingExposure = v` |
|
|
27
|
+
| Tone mapping curve | how highlights roll off and how saturated bright colors stay | bright colors keep their hue where the style wants color, highlights soften where it wants film; flat-color styles may want almost no curve | (plain three.js is the route; [52 Who writes it](52-look.md#who-writes-it-the-ownership-table)) | `engine.renderer.toneMapping = THREE.AgXToneMapping` (or ACESFilmic, Neutral, No) |
|
|
28
|
+
| Sun direction | where shadows fall and which faces are lit | shapes read from the camera (lit side and shaded side both visible), shadows point somewhere useful, the hour looks like the hour | time of day (`engine.calendar`, [06](06-clock-events.md)); sun path: `look.sky.set({ orbitTilt })`; fixed: `look.lights.manual('sun.direction')` ([52 table](52-look.md#who-writes-it-the-ownership-table)) | `engine.lights.sun.position.set(x, y, z)` after the manual call, or your own `DirectionalLight` |
|
|
29
|
+
| Sun color, intensity | the key light: color and strength of lit faces | lit and shaded sides separate; whites under the sun are the white the style wants (warm, neutral, cool) | `look.lights.set({ sun: { color, intensity } })` ([52 table](52-look.md#who-writes-it-the-ownership-table)) | `engine.lights.sun.color.set(c)` |
|
|
30
|
+
| Ambient / hemisphere, environment | the fill: how bright and what color the shaded side is | shadows are as deep as the style wants and still show shape; up-facing and down-facing faces differ; metals have something to reflect | `look.lights.set({ hemi: { color, ground, intensity } })`, `look.env.set({ intensity })` ([34](34-environment-lighting.md), [08 brightness](08-weather-sky.md#3-changing-sky-colors-sun-stars-style)) | `engine.lights.hemi.groundColor.set(c)`, `engine.scene.environmentIntensity = v` |
|
|
31
|
+
| Shadow softness | hard or blurred shadow edges | edges match the light (crisp under a clear sun, soft under cloud or for a gentle style); no stair-steps or speckle | `look.shadow.set({ type, radius })` ([52 Atmosphere](52-look.md#atmosphere-parts-sky-module-fog-sky-shadow), [45](45-cascaded-shadows.md)) | `engine.lights.sun.shadow.radius = r` |
|
|
32
|
+
| Shadow distance, detail | how far shadows reach and how sharp small ones are | the area the player looks at has shadows; small props keep theirs; objects touch the ground (no gap under a foot) | `look.shadow.set({ extent, cascades, maxFar, bias })` ([52 Atmosphere](52-look.md#atmosphere-parts-sky-module-fog-sky-shadow)) | `engine.lights.sun.shadow.camera` sides, `engine.lights.sun.shadow.mapSize` |
|
|
33
|
+
| Bloom | light bleeding around bright pixels | the bright things you meant (sun, lamps, magic) glow and nothing else does; the picture does not turn milky | `look.post.add(bloom())` from `@threedog/post-effects`, then `look.post.set({ bloom: { strength } })` ([52 Post chain](52-look.md#post-effect-chain)) | `engine.look.post.add(new UnrealBloomPass(size, strength, radius, threshold))` |
|
|
34
|
+
| Light glow / halo | lamps, windows, signs that read as lit | a glowing object keeps its hue at the center (it is not a white block), has a halo where bloom is on, and lights its surroundings if it should | `look.materials.glow(match, { night })` ([52 Night glow](52-look.md#night-glow-emissive-that-follows-daylight)); many lamps: `lightPool` ([09 §1b](09-style.md#1b-lights-and-stalls)) | `material.emissive` / `material.emissiveIntensity`, an additive `THREE.Sprite` for a halo |
|
|
35
|
+
| Water, sea | color with depth, waves, foam, what it reflects | shallow and deep read differently, the far sea meets the sky without a seam, foam sits where waves break | `look.water.set({ depthColor, foam, waveHeight })` ([44](44-water-weather-look-hooks.md)) | three/addons `Water`, or a `ShaderMaterial` that reads `engine.uniforms.uSkyHorizon` ([44 own material](44-water-weather-look-hooks.md#water-your-own-material-reflections-refraction)) |
|
|
36
|
+
| Wet ground | streets and stone after rain | wet is darker and glossier together, gloss shows reflections of something bright, puddles have soft edges | no engine look: read `engine.weather.current.rain`, then `look.materials.set({ role: { color, roughness } })` ([08 §7](08-weather-sky.md#7-wet-roads-and-puddles-after-rain)) | `material.roughness`, `material.color` on your ground material |
|
|
37
|
+
| Color grading | contrast, saturation and warm / cool shift of the whole frame | the frame has the mood you named; skin, foliage and the player's colors still read | `look.post.add(lut())` from `@threedog/post-effects` ([52 Post chain](52-look.md#post-effect-chain)) | `engine.look.post.add(new LUTPass({ lut }))` |
|
|
38
|
+
| Cloud shadow | moving dark patches on the ground | the patches drift slowly enough to read as clouds, are as dark as the sky is cloudy, and do not hide gameplay | `look.cloudShadow.set({ shadow, scale, speed })`; clouds in the sky: `look.sky.set({ clouds })` ([36](36-sky-ground-plant-looks.md)) | your own patch: `look.cloudShadow.replace(spec)` ([52 Surface](52-look.md#surface-parts-materials-surface-ground-wind)) |
|
|
39
|
+
| Grain, vignette | film noise; darker frame corners | you notice the mood, not the effect; text and the HUD stay clean | `look.post.add(grain())`, `look.post.add(vignette())` ([52 Post chain](52-look.md#post-effect-chain)) | a pixel snippet: `engine.look.post.add({ name, fuse: { glsl }, slot: 'ldr' })` |
|
|
40
|
+
| Ambient occlusion | darker creases and contact corners | objects sit on the ground and corners have weight; no dark halo around thin things | `look.post.add(ao())` ([52 Post chain](52-look.md#post-effect-chain)) | three/addons `GTAOPass` through `engine.look.post.add(pass)` |
|
|
41
|
+
| Outline | lines around shapes | lines help read shapes at play distance and match the style's line weight | `look.post.add(outline())` ([52 Post chain](52-look.md#post-effect-chain)) | three/addons `OutlinePass` through `engine.look.post.add(pass)` |
|
|
42
|
+
| Surface shading | how light falls across a surface (smooth, banded, flat) | materials that should differ (wood, stone, metal, cloth) differ in response, not only in color | `look.surface.set({ lighting })`, `look.materials.set({ role: { ... } })` ([43](43-shader-patches-surface-looks.md), [48](48-make-material.md)) | `new THREE.MeshToonMaterial({ gradientMap })` or any material of yours |
|
|
43
|
+
| God rays, volumetric fog | light shafts, fog thick in the air | shafts come from where the light is and fade when it leaves the screen | your own depth effect ([59](59-depth-post-effects.md)) | a Pass of yours through `engine.look.post.add(pass)` |
|
|
44
|
+
|
|
45
|
+
## Same knob, different styles
|
|
46
|
+
A knob is a direction, not a setting. Three styles, the same three knobs, moved different ways:
|
|
47
|
+
|
|
48
|
+
| Knob | Realistic dusk | Flat cartoon | Gloomy rainy night |
|
|
49
|
+
|---|---|---|---|
|
|
50
|
+
| Key against fill (sun, hemisphere) | a low, warm key against a cool fill: long shadows, faces lit on one side | a soft key and a strong fill, so shadows are a shape of color, not darkness; little warm / cool split | almost no key; the fill is dim and cool, and the light comes from lamps and windows instead |
|
|
51
|
+
| Fog | follows the horizon color; starts far, so the distance turns golden-grey | often light or off, so the bright flat colors stay clean; if on, a pale tint of the sky | close and dark, a color of its own (blue-grey), so lamps are islands in it |
|
|
52
|
+
| Bloom and glow | a gentle bloom on the sun and the first lit windows | little or none; glowing things are a brighter flat color | lamps and signs carry it: saturated glow, a halo through the rain, reflections on the wet ground below |
|
|
53
|
+
|
|
54
|
+
Read the other knobs the same way: ask what the style wants the viewer to notice first, then move the knob toward that and stop when the shot
|
|
55
|
+
shows it.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":1,"files":{"content/actions.js":{"kind":"actions","mtime":1793699847055.6516,"from":0,"count":4,"indexIds":0,"positional":[]},"content/audio.js":{"kind":"audio","mtime":1793627600000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/items.js":{"kind":"items","mtime":1793474271374.5977,"from":0,"count":1,"indexIds":0,"positional":[]},"content/places.js":{"kind":"places","mtime":1793474271377.595,"from":0,"count":1,"indexIds":0,"positional":[]},"content/props.js":{"kind":"props","mtime":1793474271380.606,"from":0,"count":8,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793474271383.605,"from":0,"count":4,"indexIds":0,"positional":[]},"content/views.js":{"kind":"views","mtime":1793530314731.8745,"from":0,"count":2,"indexIds":0,"positional":[]}},"ids":{"attack":[{"file":"content/actions.js","kind":"actions","line":4,"placed":false}],"retry":[{"file":"content/actions.js","kind":"actions","line":5,"placed":false}],"save":[{"file":"content/actions.js","kind":"actions","line":6,"placed":false}],"load":[{"file":"content/actions.js","kind":"actions","line":7,"placed":false}],"sounds":[{"file":"content/audio.js","kind":"audio","line":4,"placed":false}],"gem":[{"file":"content/items.js","kind":"items","line":3,"placed":false}],"room":[{"file":"content/places.js","kind":"places","line":3,"placed":false}],"floor":[{"file":"content/props.js","kind":"props","line":3,"placed":true},{"file":"content/templates.js","kind":"templates","line":4,"placed":false}],"wall-n":[{"file":"content/props.js","kind":"props","line":4,"placed":true}],"wall-s":[{"file":"content/props.js","kind":"props","line":5,"placed":true}],"wall-w":[{"file":"content/props.js","kind":"props","line":6,"placed":true}],"wall-e":[{"file":"content/props.js","kind":"props","line":7,"placed":true}],"pillar-1":[{"file":"content/props.js","kind":"props","line":8,"placed":true}],"pillar-2":[{"file":"content/props.js","kind":"props","line":9,"placed":true}],"slime-1":[{"file":"content/props.js","kind":"props","line":10,"placed":true}],"wall":[{"file":"content/templates.js","kind":"templates","line":5,"placed":false}],"pillar":[{"file":"content/templates.js","kind":"templates","line":6,"placed":false}],"slime":[{"file":"content/templates.js","kind":"templates","line":9,"placed":false}],"corner":[{"file":"content/views.js","kind":"views","line":4,"placed":false}],"door":[{"file":"content/views.js","kind":"views","line":5,"placed":false}]}}
|
|
@@ -13,28 +13,31 @@ Content: actions 4 · audio 1 · items 1 · places 1 · props 8 (from templates
|
|
|
13
13
|
|
|
14
14
|
## Engine modules (engine.use)
|
|
15
15
|
|
|
16
|
-
- createEngine: {
|
|
17
|
-
- openWorld preset ({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetatio…) → world, sky, collision, characters, settings, debug
|
|
16
|
+
- createEngine: { bindings: { ...presets.bindings.walk, ...presets.bindings.interact, ...presets.bindings.inventory, ...prese…
|
|
17
|
+
- openWorld preset ({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetatio…) → world, calendar, sky, collision, characters, settings, debug
|
|
18
18
|
- interactions ({ ...presets.interactions.nearest })
|
|
19
|
-
- inventory
|
|
19
|
+
- inventory
|
|
20
|
+
- pickups
|
|
20
21
|
- content
|
|
21
22
|
- hud
|
|
22
23
|
|
|
23
24
|
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
24
25
|
|
|
25
26
|
- world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
|
|
27
|
+
- calendar: `node_modules/threedog/docs/recipes/06-clock-events.md` · `node_modules/threedog/docs/api/calendar.md`
|
|
26
28
|
- sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
|
|
27
29
|
- collision: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/collision.md`
|
|
28
30
|
- characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
|
|
29
31
|
- settings: `node_modules/threedog/docs/recipes/26-ui-parts.md` · `node_modules/threedog/docs/api/settings.md`
|
|
30
32
|
- interactions: `node_modules/threedog/docs/recipes/20-content-actions-save.md` · `node_modules/threedog/docs/api/interactions.md`
|
|
31
33
|
- inventory: `node_modules/threedog/docs/recipes/03-items-pickups.md` · `node_modules/threedog/docs/api/inventory.md`
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
+
- pickups: `node_modules/threedog/docs/recipes/03-items-pickups.md` · `node_modules/threedog/docs/api/pickups.md`
|
|
35
|
+
- content: `node_modules/threedog/docs/recipes/30-templates.md` · `node_modules/threedog/docs/api/content.md`
|
|
36
|
+
- …1 more modules: their pages are in `node_modules/threedog/docs/api/`
|
|
34
37
|
|
|
35
38
|
Not used yet (check these before writing the system yourself):
|
|
36
39
|
|
|
37
|
-
- quests: goals with steps, conditions and rewards: `quests(
|
|
40
|
+
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
38
41
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
39
42
|
|
|
40
43
|
## Files
|
|
@@ -43,6 +46,7 @@ content/*.js is content data: how to write it in `node_modules/threedog/docs/rec
|
|
|
43
46
|
|
|
44
47
|
| File | Lines | Description |
|
|
45
48
|
|---|---|---|
|
|
49
|
+
| assets.js | 9 | The asset packs this game registers (main.js: engine.assets.manifest(packs)). Kept in their own fil… |
|
|
46
50
|
| content/actions.js | 9 | |
|
|
47
51
|
| content/audio.js | 10 | |
|
|
48
52
|
| content/index.js | 11 | |
|
|
@@ -51,9 +55,9 @@ content/*.js is content data: how to write it in `node_modules/threedog/docs/rec
|
|
|
51
55
|
| content/props.js | 12 | |
|
|
52
56
|
| content/templates.js | 11 | |
|
|
53
57
|
| content/views.js | 7 | |
|
|
54
|
-
| look.js | 6 | This example's look,
|
|
55
|
-
| main.js |
|
|
56
|
-
| models.js |
|
|
58
|
+
| look.js | 6 | This example's look, its whole style (createEngine({ style: look })): the colors models.js reads. L… |
|
|
59
|
+
| main.js | 135 | @ts-check Action example: one room, one player, one slime, one drop. Shows how an action game wires… |
|
|
60
|
+
| models.js | 27 | Models this example builds in code (floor, wall, pillar, enemy), registered by name through assets.… |
|
|
57
61
|
|
|
58
62
|
## NPCs (content/npcs.js)
|
|
59
63
|
|
|
@@ -79,7 +83,7 @@ Starting inventory: empty. Pickups: 0.
|
|
|
79
83
|
|
|
80
84
|
- Place room: the centre of the one room (the origin)
|
|
81
85
|
|
|
82
|
-
## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
|
|
86
|
+
## Object templates (content/templates.js; placed with props { template }, spawned with engine.content.spawn)
|
|
83
87
|
|
|
84
88
|
| Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
|
|
85
89
|
|---|---|---|---|---|---|---|
|
|
@@ -119,9 +123,9 @@ Code that breaks saves or manages world models: none (rule R33).
|
|
|
119
123
|
- Save slots: slot1
|
|
120
124
|
- Save entries the game registers itself: ' +
|
|
121
125
|
'action
|
|
122
|
-
- Saved parts of the engine modules (vars, inventory, quests, timers, world...): `
|
|
126
|
+
- Saved parts of the engine modules (vars, inventory, quests, timers, world...): `threedog catalog` (saves per module)
|
|
123
127
|
|
|
124
|
-
## Style
|
|
128
|
+
## Style keys
|
|
125
129
|
|
|
126
|
-
- Style
|
|
130
|
+
- Style: none (all neutral fallback look)
|
|
127
131
|
- Models (asset names): floor, wall, pillar, enemy
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The asset packs this game registers (main.js: engine.assets.manifest(packs)). Kept in their own file so `npm run check` imports the same
|
|
2
|
+
// objects and checks the model / sound names content uses against them (one source, no scanning of main.js).
|
|
3
|
+
import { models } from './models.js';
|
|
4
|
+
|
|
5
|
+
// blip: a tiny synth content/audio.js names; a sound made in code is registered like a file, by name
|
|
6
|
+
const blip = (a, p, out) => { a.tone({ freq: (p.freq ?? 440) * p.pitch, dur: 0.12, out }); return 0.12; };
|
|
7
|
+
|
|
8
|
+
export default [{ name: 'action', models, sounds: { blip } }];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This example's key actions: name -> keys and label. What a press does lives in main.js (attack in a fixed step, retry / save / load in the frame hook).
|
|
2
|
-
// Move, interact (E,
|
|
2
|
+
// Move, interact (E, presets.bindings.interact) and the bag (I, presets.bindings.inventory) come from their modules.
|
|
3
3
|
export default {
|
|
4
4
|
attack: { keys: ['Mouse0', 'KeyF'], label: 'Attack' },
|
|
5
5
|
retry: { keys: ['KeyR'], label: 'Retry' },
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
// asset-pack sounds
|
|
1
|
+
// How sounds play, as content data (no functions, no paths). 'blip' is a tiny synth main.js registers as a sound asset (assets.manifest({ sounds }));
|
|
2
|
+
// a game with files names its asset-pack sounds the same way ({ hit: ['hit-1', 'hit-2'] }).
|
|
3
3
|
export default {
|
|
4
4
|
sounds: {
|
|
5
|
-
hit: {
|
|
6
|
-
hurt: {
|
|
7
|
-
kill: {
|
|
5
|
+
hit: { src: 'blip', params: { freq: 660 } },
|
|
6
|
+
hurt: { src: 'blip', params: { freq: 170 } },
|
|
7
|
+
kill: { src: 'blip', params: { freq: 990 } },
|
|
8
8
|
},
|
|
9
9
|
};
|
package/examples/action/look.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This example's look,
|
|
1
|
+
// This example's look, its whole style (createEngine({ style: look })): the colors models.js reads. Logic never reads colors; models.js does.
|
|
2
2
|
export default {
|
|
3
3
|
name: 'action', // a part needs at least one Style field (TypeScript rejects an object that shares none), so it names itself
|
|
4
4
|
action: { floor: 0x5b6168, wall: 0x8a8f96, pillar: 0x9a8c78, enemy: 0x6fbf5a, eye: 0x1d2024 },
|
package/examples/action/main.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Action example: one room, one player, one slime, one drop. Shows how an action game wires the engine's systems; the combat rules are this file's own.
|
|
3
3
|
// main.js holds rules only: modules, ops (attack, damage, enemy attack, death), fixed-step logic, presentation. The room, the slime and its stats are
|
|
4
4
|
// content (content/templates.js + props.js, rule R33). The engine has no health, damage or death: all of that is below, as plain game state and ops.
|
|
5
|
-
import { createEngine, openWorld, followCamera, presets, interactions, inventory, content, hud, toast } from '../../index.js';
|
|
6
|
-
import
|
|
7
|
-
import look from './look.js';
|
|
5
|
+
import { createEngine, openWorld, followCamera, presets, interactions, inventory, pickups, content, hud, toast } from '../../index.js';
|
|
6
|
+
import look from './look.js'; // this example's whole look (room and enemy colors); ?style=none runs with the engine's gray placeholders
|
|
8
7
|
import data from './content/index.js';
|
|
9
|
-
import
|
|
8
|
+
import packs from './assets.js';
|
|
10
9
|
|
|
11
10
|
const url = new URLSearchParams(location.search);
|
|
12
11
|
// Tuning of the rules (the slime's own numbers are instance state in content/templates.js)
|
|
@@ -19,18 +18,16 @@ const TUNE = Object.freeze({
|
|
|
19
18
|
onDeath: url.get('death') ?? 'respawn',
|
|
20
19
|
});
|
|
21
20
|
|
|
22
|
-
const style = url.get('style') === 'none' ? undefined :
|
|
23
|
-
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' });
|
|
21
|
+
const style = url.get('style') === 'none' ? undefined : look;
|
|
22
|
+
const engine = createEngine({ bindings: { ...presets.bindings.walk, ...presets.bindings.interact, ...presets.bindings.inventory, ...presets.bindings.debug }, canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' });
|
|
24
23
|
// A room needs no terrain, plants, weather, water or physics; a fixed time of day; an over-the-shoulder camera that locks the mouse on click,
|
|
25
24
|
// starting behind the player looking along +Z into the room (yaw = which side of the player the camera sits on: PI = the -Z side)
|
|
26
25
|
engine.use(openWorld({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetation: false, weather: false, water: false, rigid: false, ambience: false,
|
|
27
|
-
|
|
28
|
-
interactions({ ...presets.interactions.nearest }), inventory(
|
|
26
|
+
calendar: { ...presets.calendar.fixedTime, time: 0.42 }, characters: { npcs: false } }),
|
|
27
|
+
interactions({ ...presets.interactions.nearest }), inventory(), pickups(), content(), hud());
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
engine.
|
|
32
|
-
engine.audio.register('blip', (a, p, out) => { a.tone({ freq: (p.freq ?? 440) * p.pitch, dur: 0.12, out }); return 0.12; }); // content/audio.js names it
|
|
33
|
-
engine.characters.createPlayer({ ...presets.player.aim, spawn: TUNE.spawn }); // face where the camera looks: a swing goes where you aim
|
|
29
|
+
engine.assets.manifest(packs); // assets.js: floor / wall / pillar / enemy (content/templates.js) and the blip synth (content/audio.js)
|
|
30
|
+
engine.characters.createPlayer({ ...presets.player.aim, spawn: TUNE.spawn }); // no body asset: the engine's gray capsule; face where the camera looks: a swing goes where you aim
|
|
34
31
|
engine.content.load(data, { places: { room: { x: 0, z: 0 } } });
|
|
35
32
|
|
|
36
33
|
// ---------- Game state: plain values, described and saved (one player, so it is not keyed by actor) ----------
|
|
@@ -65,7 +62,7 @@ engine.ops.define('enemy.damage', {
|
|
|
65
62
|
const r = e.world.get(id), hp = Math.max(0, r.hp - amount);
|
|
66
63
|
if (hp > 0) { e.world.set(id, { hp }); e.audio.sfx('hit', { at: r.position }); return hp; }
|
|
67
64
|
// Death: the drop is a pickup made during play (inside an op, rule R33); a stable id ties it to this slime so a save keeps it
|
|
68
|
-
e.
|
|
65
|
+
e.pickups.spawn(r.position, { give: r.drop, id: `${id}-drop` });
|
|
69
66
|
e.world.remove(id); // the saved world remembers the slime is gone
|
|
70
67
|
e.vars.bump('kills');
|
|
71
68
|
e.audio.sfx('kill', { at: r.position });
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
// Models this example builds in code (floor, wall, pillar, enemy), registered by name
|
|
2
|
-
// Colors come from the style
|
|
1
|
+
// Models this example builds in code (floor, wall, pillar, enemy), registered by name through assets.js and placed by content/templates.js + props.js.
|
|
2
|
+
// Colors come from the style's `action` key (look.js, merged as a style part); with no style every model is the engine's neutral gray.
|
|
3
|
+
// Written with `function` (not arrows): a generator's `this` is { palette, engine }, so it reads the style without closing over an engine,
|
|
4
|
+
// which keeps this file importable on its own (assets.js, `npm run check`).
|
|
3
5
|
import { THREE, makeMaterial } from '../../index.js';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
7
|
+
const look = ctx => ctx?.engine?.style?.action ?? {};
|
|
8
|
+
const mesh = (geo, role, color) => {
|
|
9
|
+
const m = new THREE.Mesh(geo, makeMaterial(role, color === undefined ? {} : { color, flatShading: true }));
|
|
10
|
+
m.castShadow = m.receiveShadow = true;
|
|
11
|
+
return m;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Model generators that read their colors from engine.style.action (missing = gray) */
|
|
15
|
+
export const models = {
|
|
16
|
+
floor() { return mesh(new THREE.BoxGeometry(16, 0.2, 16).translate(0, -0.1, 0), 'prop', look(this).floor); },
|
|
17
|
+
wall() { return mesh(new THREE.BoxGeometry(16, 2.4, 0.5).translate(0, 1.2, 0), 'prop', look(this).wall); },
|
|
18
|
+
pillar() { return mesh(new THREE.CylinderGeometry(0.5, 0.6, 2.8, 8).translate(0, 1.4, 0), 'prop', look(this).pillar); },
|
|
19
|
+
// A squat body with two eyes: the eyes face +Z, the facing every character uses (CONVENTIONS: characters face +Z)
|
|
20
|
+
enemy() {
|
|
21
|
+
const g = new THREE.Group(), c = look(this);
|
|
22
|
+
g.add(mesh(new THREE.SphereGeometry(0.55, 10, 8).scale(1, 0.75, 1).translate(0, 0.42, 0), 'character', c.enemy));
|
|
23
|
+
for (const x of [-0.2, 0.2]) g.add(mesh(new THREE.SphereGeometry(0.09, 6, 4).translate(x, 0.6, 0.48), 'character', c.eye));
|
|
24
|
+
return g;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Examples `threedog examples list|pull` can copy into a game. The single list: a folder under examples/ is pullable only when it is named here. Summary = the first line of its README.md. files = the game-facing files (the demo page and its main.js stay here). use = the line to print after a pull, paths relative to the pulled folder.",
|
|
3
|
+
"examples": {
|
|
4
|
+
"contact-shadows": {
|
|
5
|
+
"dir": "techniques/contact-shadows",
|
|
6
|
+
"files": [
|
|
7
|
+
"README.md",
|
|
8
|
+
"contactShadows.js"
|
|
9
|
+
],
|
|
10
|
+
"use": "import { applyContactShadows, groundStatic } from './contactShadows.js'; applyContactShadows(engine);"
|
|
11
|
+
},
|
|
12
|
+
"day-night-grade": {
|
|
13
|
+
"dir": "techniques/day-night-grade",
|
|
14
|
+
"files": [
|
|
15
|
+
"README.md",
|
|
16
|
+
"dayNightGrade.js"
|
|
17
|
+
],
|
|
18
|
+
"use": "import { dayNightStyle, followDayNight } from './dayNightGrade.js'; createEngine({ style: [yourStyle, dayNightStyle()] }); followDayNight(engine, { lamps });"
|
|
19
|
+
},
|
|
20
|
+
"interior-light": {
|
|
21
|
+
"dir": "techniques/interior-light",
|
|
22
|
+
"files": [
|
|
23
|
+
"README.md",
|
|
24
|
+
"interiorLight.js"
|
|
25
|
+
],
|
|
26
|
+
"use": "import { exposureZones, windowLight } from './interiorLight.js'; exposureZones(engine, { isInside, exposure, ambient }); windowLight(engine, { position, lookAt, width, height });"
|
|
27
|
+
},
|
|
28
|
+
"modular-building": {
|
|
29
|
+
"dir": "techniques/modular-building",
|
|
30
|
+
"files": [
|
|
31
|
+
"README.md",
|
|
32
|
+
"kit.js"
|
|
33
|
+
],
|
|
34
|
+
"use": "import { createModularKit } from './kit.js'; const kit = createModularKit({ slots: { wall: yourWallMaterial } }); engine.assets.manifest(kit.pack);"
|
|
35
|
+
},
|
|
36
|
+
"night-lights": {
|
|
37
|
+
"dir": "techniques/night-lights",
|
|
38
|
+
"files": [
|
|
39
|
+
"README.md",
|
|
40
|
+
"nightLights.js"
|
|
41
|
+
],
|
|
42
|
+
"use": "import { createNightLights } from './nightLights.js'; createNightLights(engine, { /* lamps, glow names */ });"
|
|
43
|
+
},
|
|
44
|
+
"outlines-and-rim": {
|
|
45
|
+
"dir": "techniques/outlines-and-rim",
|
|
46
|
+
"files": [
|
|
47
|
+
"README.md",
|
|
48
|
+
"outlines.js"
|
|
49
|
+
],
|
|
50
|
+
"use": "import { trackResolution, addHull, rimPatch } from './outlines.js'; // see README for which route fits your DESIGN.md"
|
|
51
|
+
},
|
|
52
|
+
"procedural-animation": {
|
|
53
|
+
"dir": "techniques/procedural-animation",
|
|
54
|
+
"files": [
|
|
55
|
+
"README.md",
|
|
56
|
+
"proceduralAnim.js",
|
|
57
|
+
"creature.js"
|
|
58
|
+
],
|
|
59
|
+
"use": "import { createProceduralAnimator, KNOBS } from './proceduralAnim.js'; const anim = createProceduralAnimator({ body, legs, tail }); // update it in onFrame (README)"
|
|
60
|
+
},
|
|
61
|
+
"procedural-surface": {
|
|
62
|
+
"dir": "techniques/procedural-surface",
|
|
63
|
+
"files": [
|
|
64
|
+
"README.md",
|
|
65
|
+
"surface.js"
|
|
66
|
+
],
|
|
67
|
+
"use": "import { scaleForCamera, worldVariation, brushTexture, cavity } from './surface.js'; // see README for which route fits your DESIGN.md"
|
|
68
|
+
},
|
|
69
|
+
"rc2d": {
|
|
70
|
+
"dir": "rc2d",
|
|
71
|
+
"files": [
|
|
72
|
+
"README.md",
|
|
73
|
+
"rc2d.js",
|
|
74
|
+
"shaders.js"
|
|
75
|
+
],
|
|
76
|
+
"use": "import { createRadianceCascades2D } from './rc2d.js'; createRadianceCascades2D(engine, { layer: 5, ambient: 0.15 });"
|
|
77
|
+
},
|
|
78
|
+
"stylized-shading": {
|
|
79
|
+
"dir": "techniques/stylized-shading",
|
|
80
|
+
"files": [
|
|
81
|
+
"README.md",
|
|
82
|
+
"shading.js"
|
|
83
|
+
],
|
|
84
|
+
"use": "import { rampTexture, toonMaterial, toonPatch, painterlyMaterial } from './shading.js'; // see README for which route fits your DESIGN.md"
|
|
85
|
+
},
|
|
86
|
+
"sun-and-key-light": {
|
|
87
|
+
"dir": "techniques/sun-and-key-light",
|
|
88
|
+
"files": [
|
|
89
|
+
"README.md",
|
|
90
|
+
"keyLight.js"
|
|
91
|
+
],
|
|
92
|
+
"use": "import { applyKeyFill, aimSun, fitSunShadow } from './keyLight.js'; applyKeyFill(engine, route); aimSun(engine, { elevation, azimuth, camera }); fitSunShadow(engine, { extent });"
|
|
93
|
+
},
|
|
94
|
+
"webgpu-tsl": {
|
|
95
|
+
"dir": "webgpu-tsl",
|
|
96
|
+
"files": [
|
|
97
|
+
"README.md",
|
|
98
|
+
"tslScene.js"
|
|
99
|
+
],
|
|
100
|
+
"use": "import 'threedog/tsl'; import { createTslScene } from './tslScene.js'; createEngine({ renderer: 'webgpu' }); createTslScene(engine); // before engine.start()"
|
|
101
|
+
},
|
|
102
|
+
"wet-road": {
|
|
103
|
+
"dir": "techniques/wet-road",
|
|
104
|
+
"files": [
|
|
105
|
+
"README.md",
|
|
106
|
+
"wetRoad.js"
|
|
107
|
+
],
|
|
108
|
+
"use": "import { createWetRoad } from './wetRoad.js'; createWetRoad(engine, { materials: [roadMaterial] });"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":1,"files":{},"ids":{}}
|