threedog 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +411 -1
- package/README.md +8 -11
- package/core/{Animator.js → assets/Animator.js} +30 -18
- package/core/{Assets.js → assets/Assets.js} +131 -56
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +302 -0
- package/core/{assetHot.js → assets/assetHot.js} +9 -7
- package/core/{assetLoad.js → assets/assetLoad.js} +55 -16
- package/core/assets/assetLod.js +113 -0
- package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
- package/core/{assetReport.js → assets/assetReport.js} +7 -14
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +47 -25
- package/core/{audioRules.js → audio/audioRules.js} +8 -5
- package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
- package/core/{Events.js → base/Events.js} +3 -3
- package/core/{I18n.js → base/I18n.js} +15 -12
- package/core/{Random.js → base/Random.js} +7 -4
- package/core/{Vars.js → base/Vars.js} +14 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +151 -125
- package/core/{errorHints.js → base/errorHints.js} +17 -10
- package/core/{errors.js → base/errors.js} +12 -10
- package/core/{events.generated.js → base/events.generated.js} +11 -0
- package/core/base/follows.js +26 -0
- package/core/base/math.js +66 -0
- package/core/{params.js → base/params.js} +5 -6
- package/core/base/saveValues.js +81 -0
- package/core/base/sections.js +97 -0
- package/core/base/spelling.js +32 -0
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +34 -34
- package/core/{Engine.js → engine/Engine.js} +137 -91
- package/core/{Loading.js → engine/Loading.js} +34 -5
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +32 -15
- package/core/{lifecycle.js → engine/lifecycle.js} +41 -34
- package/core/{loop.js → engine/loop.js} +88 -49
- package/core/engine/moduleSlots.js +176 -0
- package/core/{moduleTypes.js → engine/moduleTypes.js} +26 -14
- package/core/engine/modules.js +503 -0
- package/core/{page.js → engine/page.js} +59 -29
- package/core/{plugins.js → engine/plugins.js} +21 -12
- package/core/{services.js → engine/services.js} +50 -40
- package/core/{startup.js → engine/startup.js} +66 -54
- package/core/{Input.js → input/Input.js} +67 -39
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/input/inputKeyboard.js +39 -0
- package/core/{inputPad.js → input/inputPad.js} +24 -3
- package/core/{inputPointer.js → input/inputPointer.js} +11 -3
- package/core/input/inputSeat.js +66 -0
- package/core/{inputTouch.js → input/inputTouch.js} +24 -7
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +43 -18
- package/core/{Describe.js → inspect/Describe.js} +34 -26
- package/core/{Inspect.js → inspect/Inspect.js} +39 -10
- package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
- package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
- package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
- package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
- package/core/{UrlState.js → inspect/UrlState.js} +60 -24
- package/core/{catalog.js → inspect/catalog.js} +15 -8
- package/core/{checks.js → inspect/checks.js} +7 -5
- package/core/{debugView.js → inspect/debugView.js} +4 -4
- package/core/{describeRender.js → inspect/describeRender.js} +24 -22
- package/core/{describeText.js → inspect/describeText.js} +17 -8
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/inspect/metadata.generated.js +4140 -0
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +130 -47
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/inspect/toolDoor.js +21 -0
- package/core/inspect/valueHistory.js +35 -0
- package/core/{Ops.js → ops/Ops.js} +44 -14
- package/core/{control.js → ops/control.js} +57 -31
- package/core/ops/holds.js +140 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +18 -5
- package/core/{opsCheck.js → ops/opsCheck.js} +11 -10
- package/core/{opsFail.js → ops/opsFail.js} +5 -7
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +9 -6
- package/core/{owned.js → ops/owned.js} +33 -19
- package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -16
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +34 -15
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +53 -27
- package/core/{Saves.js → saves/Saves.js} +171 -54
- package/core/saves/saveApply.js +312 -0
- package/core/{saveFiles.js → saves/saveFiles.js} +45 -38
- package/core/{saveVersions.js → saves/saveVersions.js} +24 -23
- package/core/saves/session.js +231 -0
- package/core/saves/stateReplace.js +184 -0
- package/core/{Rays.js → scene/Rays.js} +44 -30
- package/core/{Views.js → scene/Views.js} +16 -8
- package/core/{adaptive.js → scene/adaptive.js} +19 -9
- package/core/{canvasBox.js → scene/canvasBox.js} +4 -3
- package/core/scene/compositeGround.js +72 -0
- package/core/scene/floor.js +17 -0
- package/core/{gameLights.js → scene/gameLights.js} +17 -7
- package/core/{grayMap.js → scene/grayMap.js} +8 -2
- package/core/{grid.js → scene/grid.js} +6 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/scene/ground.contract.js +14 -0
- package/core/scene/ground.js +139 -0
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/scene/pixel.js +154 -0
- package/core/scene/pixelRatio.js +167 -0
- package/core/{sceneDelta.js → scene/sceneDelta.js} +5 -5
- package/core/{sceneMethods.js → scene/sceneMethods.js} +43 -15
- package/core/scene/stepPoses.js +60 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
- package/core/{thingOps.js → scene/thingOps.js} +25 -16
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{tier.js → scene/tier.js} +10 -0
- package/core/scene/view.js +161 -0
- package/core/{Batching.js → stream/Batching.js} +85 -28
- package/core/{Stream.js → stream/Stream.js} +80 -38
- package/core/{batchGroups.js → stream/batchGroups.js} +11 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +7 -4
- package/core/{streamSources.js → stream/streamSources.js} +14 -8
- package/core/{Commits.js → threads/Commits.js} +17 -11
- package/core/{Jobs.js → threads/Jobs.js} +25 -13
- package/core/{Threads.js → threads/Threads.js} +21 -18
- package/core/{threadPure.js → threads/threadPure.js} +7 -5
- package/core/{threadServe.js → threads/threadServe.js} +3 -3
- package/core/{Clock.js → time/Clock.js} +20 -11
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +28 -21
- package/core/{time.js → time/time.js} +32 -20
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +92 -72
- package/docs/API.md +33 -28
- package/docs/CODEMAP.md +121 -200
- package/docs/COMMANDS.md +77 -70
- package/docs/CONVENTIONS.md +167 -24
- package/docs/MIGRATING-0.8.md +171 -0
- package/docs/MIGRATING-1.0.md +101 -0
- package/docs/THREE.md +140 -38
- package/docs/api/assets.md +12 -13
- package/docs/api/audio.md +6 -5
- package/docs/api/budget.md +4 -4
- package/docs/api/calendar.md +10 -11
- package/docs/api/cameraRig.md +32 -29
- package/docs/api/characters.md +35 -24
- package/docs/api/clock.md +1 -1
- package/docs/api/collider3d.md +9 -0
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +18 -17
- package/docs/api/dialogue.md +5 -4
- package/docs/api/engine.md +58 -54
- package/docs/api/events.md +17 -6
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +6 -7
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +9 -8
- package/docs/api/interactions.md +5 -5
- package/docs/api/inventory.md +10 -10
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +10 -9
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +14 -12
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +10 -7
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +3 -3
- package/docs/api/post.md +21 -5
- package/docs/api/quests.md +7 -5
- package/docs/api/rays.md +7 -7
- package/docs/api/rigid.md +29 -19
- package/docs/api/saves.md +13 -11
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +8 -9
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +6 -8
- package/docs/api/terrainDraw.md +2 -2
- package/docs/api/timeline.md +4 -4
- package/docs/api/tools.md +27 -22
- package/docs/api/triggers.md +2 -0
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +2 -2
- package/docs/api/water.md +7 -3
- package/docs/api/weather.md +27 -12
- package/docs/api/weatherDraw.md +4 -4
- package/docs/api/world.md +6 -6
- package/docs/recipes/01-new-game.md +28 -43
- package/docs/recipes/02-npc.md +21 -23
- package/docs/recipes/03-items-pickups.md +37 -53
- package/docs/recipes/04-quests.md +5 -4
- package/docs/recipes/05-props-bake.md +34 -44
- package/docs/recipes/06-clock-events.md +31 -22
- package/docs/recipes/07-flow-scenes-pause.md +30 -32
- package/docs/recipes/08-weather-sky.md +91 -37
- package/docs/recipes/09-materials-lights-models.md +25 -39
- package/docs/recipes/10-blender-level.md +22 -11
- package/docs/recipes/11-vehicles.md +44 -24
- package/docs/recipes/12-navmesh.md +60 -15
- package/docs/recipes/13-animation.md +70 -22
- package/docs/recipes/14-custom-module.md +33 -20
- package/docs/recipes/15-perf.md +51 -28
- package/docs/recipes/16-dev-bridge.md +39 -58
- package/docs/recipes/18-world.md +49 -28
- package/docs/recipes/19-shooting-picking.md +7 -4
- package/docs/recipes/20-content-actions-save.md +55 -40
- package/docs/recipes/21-camera.md +47 -25
- package/docs/recipes/22-shop-gold.md +21 -16
- package/docs/recipes/23-ops.md +28 -24
- package/docs/recipes/26-ui-parts.md +25 -14
- package/docs/recipes/27-net.md +3 -5
- package/docs/recipes/28-terrain.md +119 -23
- package/docs/recipes/29-grid.md +3 -3
- package/docs/recipes/30-templates.md +63 -30
- package/docs/recipes/31-audio.md +7 -7
- package/docs/recipes/32-action-game.md +21 -11
- package/docs/recipes/33-stream-sources.md +6 -3
- package/docs/recipes/34-environment-lighting.md +72 -25
- package/docs/recipes/35-picture-from-reference.md +20 -23
- package/docs/recipes/36-ground-plants.md +106 -0
- package/docs/recipes/40-scene.md +18 -21
- package/docs/recipes/43-shader-patches-surfaces.md +27 -48
- package/docs/recipes/44-water-weather-hooks.md +56 -50
- package/docs/recipes/45-cascaded-shadows.md +41 -20
- package/docs/recipes/46-blender-art-route.md +9 -10
- package/docs/recipes/49-game-module-contract.md +7 -6
- package/docs/recipes/50-own-renderer.md +3 -2
- package/docs/recipes/51-capability-catalog.md +14 -8
- package/docs/recipes/52-around-the-picture.md +56 -100
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +17 -20
- package/docs/recipes/56-webgpu-tsl.md +28 -15
- package/docs/recipes/57-control.md +39 -12
- package/docs/recipes/58-input.md +15 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +30 -25
- package/docs/recipes/62-picture-code.md +129 -39
- package/docs/recipes/63-third-person-start.md +19 -5
- package/docs/recipes/64-particles.md +54 -5
- package/docs/recipes/65-swarm.md +140 -0
- package/docs/recipes/66-common-tasks.md +313 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +5 -5
- package/examples/perf-island/.threedog/content-index.json +1 -0
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +15 -14
- package/examples/{sheepisland → perf-island}/assets.js +1 -1
- package/examples/{sheepisland → perf-island}/main.js +8 -8
- package/examples/{sheepisland → perf-island}/models.js +1 -1
- package/examples/{sheepisland → perf-island}/params.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
- package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
- package/examples/{sheepisland → perf-island}/views.js +1 -1
- package/examples/plain-picture/GAMEMAP.md +4 -1
- package/examples/rc2d/GAMEMAP.md +4 -3
- package/examples/rc2d/main.js +1 -3
- package/examples/rc2d/rc2d.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +6 -5
- package/examples/techniques/contact-shadows/contactShadows.js +1 -1
- package/examples/techniques/contact-shadows/main.js +1 -1
- package/examples/techniques/interior-light/main.js +1 -1
- package/examples/techniques/modular-building/README.md +7 -6
- package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +2 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +9 -7
- package/examples/world/main.js +3 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +16 -12
- package/index.js +53 -32
- package/llms.txt +11 -14
- package/modules/ambience/Ambience.js +16 -11
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +18 -16
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +5 -5
- package/modules/camera/FixedCamera.js +43 -30
- package/modules/camera/FollowCamera.js +24 -15
- package/modules/camera/RtsCamera.js +12 -11
- package/modules/camera/common.js +72 -37
- package/modules/camera/contract.js +1 -0
- package/modules/camera/pixelSnap.js +62 -0
- package/modules/characters/Character.js +166 -70
- package/modules/characters/NPC.js +84 -44
- package/modules/characters/assetModel.js +16 -12
- package/modules/characters/astar.js +48 -27
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/character.contract.js +21 -0
- package/modules/characters/contract.js +17 -3
- package/modules/characters/index.js +240 -226
- package/modules/characters/moveHelpers.js +88 -12
- package/modules/characters/mover.contract.js +14 -0
- package/modules/characters/movers/common.js +22 -18
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +18 -10
- package/modules/characters/movers/simple.js +26 -13
- package/modules/characters/movers/support.js +24 -13
- package/modules/characters/npcAvoid.js +19 -16
- package/modules/characters/npcSim.js +88 -32
- package/modules/characters/npcView.js +19 -11
- package/modules/characters/pathAsync.js +81 -29
- package/modules/characters/pathJob.js +38 -21
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +120 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/seat.js +56 -0
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/vehicle.contract.js +8 -5
- package/modules/characters/walkTo.js +40 -33
- package/modules/collision/Collision.js +69 -45
- package/modules/collision/contract.js +15 -0
- package/modules/collision/grid.js +6 -1
- package/modules/content/explain.js +2 -3
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +5 -3
- package/modules/content/index.js +132 -114
- package/modules/content/loader.js +117 -140
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +54 -17
- package/modules/content/packs.js +5 -4
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +36 -0
- package/modules/content/props.js +22 -17
- package/modules/content/rules.js +47 -61
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +80 -49
- package/modules/content/words.js +47 -0
- package/modules/debug/DebugPanel.js +14 -45
- package/modules/flow/contract.js +2 -1
- package/modules/flow/index.js +30 -16
- package/modules/gameplay/Container.js +17 -13
- package/modules/gameplay/Containers.js +23 -6
- package/modules/gameplay/Dialogue.js +93 -34
- package/modules/gameplay/Interactions.js +93 -51
- package/modules/gameplay/Inventory.js +64 -22
- package/modules/gameplay/Quests.js +146 -30
- package/modules/gameplay/boxOps.js +8 -1
- package/modules/gameplay/dialogueBubbles.js +16 -12
- package/modules/gameplay/inventoryOps.js +11 -8
- package/modules/gameplay/pickups.js +63 -37
- package/modules/gameplay/questLog.js +4 -2
- package/modules/gameplay/questSave.js +9 -4
- package/modules/gameplay/quests.contract.js +1 -1
- package/modules/grid/Grid.js +2 -2
- package/modules/grid/Layer.js +12 -8
- package/modules/grid/index.js +28 -23
- package/modules/grid/ops.js +43 -46
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +42 -57
- package/modules/hud/index.js +22 -14
- package/modules/hud/parts.js +8 -8
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +29 -31
- package/modules/level/index.js +113 -161
- package/modules/level/load.js +196 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +40 -23
- package/modules/lights/index.js +33 -183
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +90 -0
- package/modules/music/Music.js +34 -28
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +16 -0
- package/modules/nav/index.js +180 -49
- package/modules/nav/navPath.js +45 -10
- package/modules/net/Client.js +7 -7
- package/modules/net/Host.js +7 -7
- package/modules/net/Net.js +1 -1
- package/modules/net/index.js +6 -5
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +95 -29
- package/modules/particles/effect.js +86 -32
- package/modules/particles/shaders.js +19 -1
- package/modules/photo/Photo.js +23 -23
- package/modules/rigid/RigidBodies.js +255 -89
- package/modules/rigid/Vehicles.js +17 -8
- package/modules/rigid/collider3d.contract.js +26 -0
- package/modules/rigid/ragdoll.js +298 -0
- package/modules/rigid/ragdollBones.js +209 -0
- package/modules/rigid/refresh.js +10 -0
- package/modules/rigid/sync.js +51 -20
- package/modules/settings/Settings.js +177 -61
- package/modules/settings/apply.js +20 -13
- package/modules/settings/sections.js +19 -14
- package/modules/settings/strings.js +2 -2
- package/modules/settings/view.js +3 -3
- package/modules/sky/Sky.js +29 -22
- package/modules/sky/clouds.js +7 -7
- package/modules/sky/dome.js +33 -20
- package/modules/sky/domeLayers.js +9 -9
- package/modules/sky/environment.js +6 -6
- package/modules/sky/frame.js +19 -10
- package/modules/sky/season.js +7 -1
- package/modules/sky/shader.js +24 -25
- package/modules/sky/skyModule.js +17 -28
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +356 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +71 -59
- package/modules/terrain/chunkQueries.js +7 -24
- package/modules/terrain/chunkWorker.js +1 -1
- package/modules/terrain/draw.js +14 -11
- package/modules/terrain/index.js +42 -42
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +45 -29
- package/modules/terrain/terrainGen.js +19 -12
- package/modules/terrain/terrainIsland.js +2 -2
- package/modules/terrain/terrainMesh.js +7 -6
- package/modules/terrain/terrainShape.js +8 -10
- package/modules/terrain/terrainShapeMain.js +3 -3
- package/modules/timeline/Timeline.js +83 -43
- package/modules/timeline/Tween.js +25 -19
- package/modules/timeline/shots.js +24 -17
- package/modules/triggers/index.js +95 -28
- package/modules/vegetation/Vegetation.js +34 -26
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +39 -18
- package/modules/vegetation/groundChunks.js +21 -38
- package/modules/vegetation/index.js +37 -12
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +20 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +52 -40
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +28 -23
- package/modules/world/World.js +28 -15
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +30 -17
- package/modules/world/persist.js +90 -27
- package/modules/world/pos.js +5 -5
- package/modules/world/records.js +37 -11
- package/modules/world/sim.js +78 -27
- package/modules/world/simFar.js +2 -2
- package/modules/world/state.js +43 -11
- package/modules/world/thingSource.js +20 -5
- package/modules/world/views.js +27 -14
- package/package.json +48 -7
- package/presets.js +1 -3
- package/render/PostFX.js +83 -53
- package/render/backend.js +31 -33
- package/render/cascades.js +17 -12
- package/render/cascades.tsl.js +5 -8
- package/render/daylight.js +20 -3
- package/render/detail.js +8 -7
- package/render/effects.js +28 -25
- package/render/fuse.js +3 -3
- package/render/fx/cloudShadow.tsl.js +3 -3
- package/render/fx/detail.tsl.js +1 -1
- package/render/fx/index.js +5 -10
- package/render/fx/library.tsl.js +11 -0
- package/render/fx/lighting.tsl.js +2 -1
- package/render/fx/nodeErrors.tsl.js +2 -2
- package/render/fx/objectOrigin.tsl.js +1 -2
- package/render/fx/particles.tsl.js +8 -6
- package/render/fx/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +30 -26
- package/render/fx/sky.tsl.js +15 -17
- package/render/fx/uniforms.tsl.js +4 -4
- package/render/fx/wind.tsl.js +1 -1
- package/render/fxNumbers.js +3 -0
- package/render/layers.js +2 -2
- package/render/lighting.js +5 -3
- package/render/lightmap.js +41 -21
- package/render/lights.js +6 -6
- package/render/lit.js +24 -0
- package/render/materials.js +8 -7
- package/render/mergeCommon.js +22 -0
- package/render/modeling.js +2 -2
- package/render/occlusion.js +62 -15
- package/render/ownFrame.js +4 -4
- package/render/patches.js +15 -15
- package/render/postWebGL.js +15 -12
- package/render/probes.js +41 -19
- package/render/recordSweep.js +117 -0
- package/render/shaderErrors.js +10 -9
- package/render/shadowCache.tsl.js +107 -0
- package/render/shadowTypes.js +9 -0
- package/{core → render}/shadows.js +59 -13
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +336 -202
- package/types/gameplay.d.ts +254 -130
- package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
- package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
- package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
- package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +8 -16
- package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
- package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
- package/types/generated/core/{Input.d.ts → input/Input.d.ts} +28 -10
- package/types/generated/core/input/inputSeat.d.ts +26 -0
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +17 -3
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +6 -4
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +14 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +62 -18
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +3 -2
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +2 -2
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +22 -18
- package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
- package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
- package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
- package/types/generated/modules/calendar/Calendar.d.ts +10 -11
- package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
- package/types/generated/modules/grid/Grid.d.ts +1 -0
- package/types/generated/modules/grid/Layer.d.ts +1 -1
- package/types/generated/modules/grid/index.d.ts +3 -3
- package/types/generated/modules/music/Music.d.ts +7 -5
- package/types/generated/modules/particles/Particles.d.ts +5 -4
- package/types/generated/modules/sky/Sky.d.ts +21 -10
- package/types/generated/modules/swarm/Swarm.d.ts +80 -0
- package/types/generated/modules/timeline/Timeline.d.ts +7 -5
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +14 -16
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +11 -7
- package/types/generated/render/PostFX.d.ts +21 -23
- package/types/generated/render/materials.d.ts +1 -0
- package/types/generated/render/occlusion.d.ts +9 -0
- package/types/generated/render/patches.d.ts +1 -0
- package/types/generated/ui/Focus.d.ts +1 -0
- package/types/generated/ui/UI.d.ts +1 -0
- package/types/nav.d.ts +47 -15
- package/types/physics.d.ts +150 -73
- package/types/pixel.d.ts +75 -0
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +48 -75
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +13 -5
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +7 -5
- package/core/assetEntry.js +0 -109
- package/core/engineCamera.js +0 -32
- package/core/ground.js +0 -104
- package/core/holds.js +0 -134
- package/core/math.js +0 -48
- package/core/moduleSlots.js +0 -100
- package/core/modules.js +0 -314
- package/core/saveApply.js +0 -210
- package/core/saveValues.js +0 -46
- package/core/session.js +0 -174
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- package/core/view.js +0 -43
- package/docs/MIGRATING-0.3.md +0 -248
- package/docs/MIGRATING-0.4.md +0 -320
- package/docs/MIGRATING-0.5.md +0 -68
- package/docs/MIGRATING-0.6.md +0 -126
- package/docs/PERF.md +0 -245
- package/docs/recipes/36-sky-ground-plants.md +0 -158
- package/docs/recipes/37-terrain-hooks.md +0 -115
- package/docs/recipes/38-environment-hooks.md +0 -67
- package/docs/recipes/42-terrain-shape.md +0 -64
- package/docs/recipes/47-island-snow-backdrop.md +0 -43
- package/docs/recipes/54-three-idioms.md +0 -88
- package/examples/plain-picture/FINDINGS.md +0 -53
- package/examples/sheepisland/.threedog/content-index.json +0 -1
- package/modules/camera/projection.js +0 -21
- /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
- /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
- /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
- /package/core/{actor.js → ops/actor.js} +0 -0
- /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
- /package/core/{saveIds.js → saves/saveIds.js} +0 -0
- /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
- /package/core/{cells.js → stream/cells.js} +0 -0
- /package/core/{streamCells.js → stream/streamCells.js} +0 -0
- /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
- /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
- /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
- /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Terrain outline: islands, floating rocks, a world that ends
|
|
2
|
-
|
|
3
|
-
`terrain({ shape })` decides where there is ground at all. Without it (the default) the ground goes on forever. With it, ground exists only
|
|
4
|
-
where `mask > 0`; the rim is cut through the cells in straight lines, walls hang down from it, and an optional underside closes it.
|
|
5
|
-
|
|
6
|
-
## 1. A floating island with a ragged rim (copy this)
|
|
7
|
-
|
|
8
|
-
```js
|
|
9
|
-
import { createEngine, openWorld } from 'threedog';
|
|
10
|
-
|
|
11
|
-
const engine = createEngine({ canvas: document.querySelector('canvas') });
|
|
12
|
-
engine.use(openWorld({ camera: 'follow', water: false, terrain: { // water: false -- a floating island has no sea under it
|
|
13
|
-
height: (x, z, n) => 4 + 6 * n.fbm(x * 0.02, z * 0.02),
|
|
14
|
-
shape: {
|
|
15
|
-
mask: (x, z) => 60 - Math.hypot(x, z), // > 0 ground: a 60 m disc (meters read best)
|
|
16
|
-
edge: { noise: 8, size: 20, jitter: 0.6, round: 1.5 }, // ragged outline, jagged rim, top bends down 1.5 m at the edge
|
|
17
|
-
side: { depth: 3, ground: 'cliff' }, // 3 m of cliff band, colored by biomeColors.cliff
|
|
18
|
-
bottom: { depth: (x, z, n, m) => 2 + m * 0.5 + 4 * n.fbm(x * 0.1, z * 0.1), ground: 'rock' }, // hangs lower inland (m grows inward)
|
|
19
|
-
},
|
|
20
|
-
} }));
|
|
21
|
-
await engine.start();
|
|
22
|
-
|
|
23
|
-
const home = { x: 0, z: 0 };
|
|
24
|
-
engine.events.on('terrain:void', ({ who }) => { // fell off: the game decides (the engine never respawns)
|
|
25
|
-
if (who === engine.player) engine.player.placeAt(home);
|
|
26
|
-
});
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Colors come from `terrain({ biomeColors })` as usual: add `cliff` and `rock` (a name without a color is neutral gray).
|
|
30
|
-
|
|
31
|
-
## 2. The keys
|
|
32
|
-
|
|
33
|
-
| key | what | default |
|
|
34
|
-
|---|---|---|
|
|
35
|
-
| `mask` | `(x, z, n) => number`, > 0 is ground; pure like `height` (runs in workers, settings through `n.params`). Or a gray image `{ url, size: [w, l], center, threshold }`: whiter is ground, value = gray − threshold, outside the image is void | required |
|
|
36
|
-
| `edge.noise` / `edge.size` | meters of fbm added to the mask, and its wavelength in meters | 0 / 16 |
|
|
37
|
-
| `edge.jitter` | meters of random offset per grid point: a jagged, chipped rim | 0 |
|
|
38
|
-
| `edge.round` | meters the top bends down towards the rim; 0 is a hard cliff edge | 0 |
|
|
39
|
-
| `side.depth` | wall height below the rim: meters or `(x, z, n) => meters` | 2 |
|
|
40
|
-
| `side.ground` / `side.material` | wall color (`biomeColors[ground]`), or a Material / `(engine) => Material` for sides and bottom | `'cliff'` / none |
|
|
41
|
-
| `bottom.depth` | underside below the side band: meters or `(x, z, n, m) => meters` (`m` = mask there) | 4 (only with `bottom`) |
|
|
42
|
-
| `bottom.ground` | underside color | `'rock'` |
|
|
43
|
-
| `voidY` | fall height for `terrain:void` | 50 m under the lowest island chunk loaded |
|
|
44
|
-
|
|
45
|
-
Without `bottom` the island is open underneath (the cheapest choice when the camera never looks up at it).
|
|
46
|
-
|
|
47
|
-
## 3. What the rest of the engine does off the outline
|
|
48
|
-
|
|
49
|
-
- `engine.surface(x, z)` is `-Infinity`, `engine.ground.has(x, z)` is `false`, `engine.slope` is 0, `engine.groundType` is `'void'`.
|
|
50
|
-
Check `has` before placing things: `engine.snapToGround` over the void throws in development instead of writing an infinite y.
|
|
51
|
-
The same holds for every place-it-here entry (`engine.content.spawn`, content props, pickups, npcs, `character.placeAt`): in development they throw with this advice, in a release build they keep the caller's y (or 0), never `-Infinity` (a save would turn it into NaN). Camera starts, HUD anchors, grid tiles and shot paths fall back to y 0 / the last height and do not throw.
|
|
52
|
-
- Characters walk off the rim and fall; pathfinding and spawn search treat the void as not walkable.
|
|
53
|
-
- Physics: the top and the walls collide (a rolling barrel stops at a wall, a ball falls off the edge); the underside does not.
|
|
54
|
-
- Vegetation never grows off the outline. `engine.terrain.edit` off it does nothing (returns `{ heights: 0, cells: 0 }`); near the rim it
|
|
55
|
-
still digs, and painting works. The outline itself cannot be edited.
|
|
56
|
-
- The player and every moving rigid body that drops below `engine.terrain.voidY` get one `terrain:void { who, position }` per fall.
|
|
57
|
-
- Global water still draws at its level: a floating island usually turns water off (`water: false` above).
|
|
58
|
-
|
|
59
|
-
## 4. Limits
|
|
60
|
-
|
|
61
|
-
- The cut follows cell edges, so detail finer than a cell (`chunkSize / resolution`, 4 m by default) is lost. Keep `edge.size` above a cell,
|
|
62
|
-
or raise `resolution`.
|
|
63
|
-
- `shading: 'texture'`: the color map covers the top only (void pixels have alpha 0); sides and bottom use vertex colors or `side.material`.
|
|
64
|
-
- The mask is fixed at start; a game that wants the outline to change while playing builds that itself.
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Snow cover, flat backdrop, rounded terrain rim
|
|
2
|
-
|
|
3
|
-
Three independent settings, each for its own situation: a **rounded rim** for terrain with a visible edge (an island, a diorama board, a floating
|
|
4
|
-
level; recipe 42 for the outline), **snow cover** for any outdoor scene where it snows, and a **flat backdrop** for a scene that should have no
|
|
5
|
-
horizon (a menu stage, a board game, a diorama). All are style or scenario settings; none needs a shader of your own.
|
|
6
|
-
|
|
7
|
-
## Round rim
|
|
8
|
-
`terrain({ shape: { edge: { round: 1.2 } } })` bends the top down by up to 1.2 m toward the rim. The side wall follows every bend of the
|
|
9
|
-
top (it is split where the rim crosses a cell diagonal), so there is no slit between top and wall at any `round`.
|
|
10
|
-
|
|
11
|
-
## Season tint on a textured top
|
|
12
|
-
With `shading: 'texture'` the color map is applied before the vertex colors, so every patch after `color_fragment` sees the mapped color.
|
|
13
|
-
`engine.sky.seasonTints = { mode: 'mix', winter: { ground: 0xeef0f2 } }` therefore whitens the textured top like the side walls (recipe 43).
|
|
14
|
-
|
|
15
|
-
## Snow that settles: `weather({ snow: { cover } })`
|
|
16
|
-
```js
|
|
17
|
-
weather({ types, snow: { size: 18, cover: { foliage: 0xf2f4f6, ground: 0xeef0f2, strength: 0.8 } } });
|
|
18
|
-
```
|
|
19
|
-
- While the weather's `snow` amount rises (any type with `snow > 0`), the foliage / ground season tint moves `strength` of the way toward
|
|
20
|
-
these colors, and melts back as it falls. It reuses the season patch uniforms (`uFoliageTint/Mix`, `uGroundTint/Mix`): vegetation, terrain
|
|
21
|
-
and any material with `applyEffects(m, { season: 'ground' })` follow; no extra shader pass.
|
|
22
|
-
- Over a `mode: 'mix'` season the two blend into one mix; a `'multiply'` season gives way while snow lies (use `'mix'` for smooth fades).
|
|
23
|
-
- Leave a part out to keep its season color (`cover: { foliage: 0xffffff }` whitens trees only). Leave `cover` out and snow is particles only.
|
|
24
|
-
- Ash, frost or anything else: `engine.mod('ground.cover', { owner: 'ash', value: { ground: 0x555555, amount: 0.6 } })` (one entry per owner, the handle's `remove()` ends it).
|
|
25
|
-
|
|
26
|
-
## Weather changes and seasons in scenarios
|
|
27
|
-
- `engine.events.on('weather:change', ({ from, to }) => ...)`: once per change of name, when the blend starts (`weather.set` with the same name
|
|
28
|
-
again does not fire).
|
|
29
|
-
- `engine.applyState({ season: 'winter' })` (or `?season=winter`): jumps `calendar.day` to that season's first day, time of day kept. Needs
|
|
30
|
-
`calendar({ seasons })`; a wrong name throws with the calendar's list.
|
|
31
|
-
|
|
32
|
-
## Flat backdrop: `sky({ backdrop })`
|
|
33
|
-
```js fragment
|
|
34
|
-
sky: { backdrop: 0xefebe4 }, // one color
|
|
35
|
-
engine.sky.backdrop = engine.sky.isDay ? 0xefebe4 : 0x2c3346; // live, from your own frame code; null gives the dome back
|
|
36
|
-
```
|
|
37
|
-
- Hides the dome (no gradient, horizon line, sun / moon disk, stars or clouds) and sets `scene.background` to the color. A plain background
|
|
38
|
-
color is not tone mapped, so what you write is what shows. `scene.background` stays the color when there is no sky module.
|
|
39
|
-
- The keyframes still drive the signals (`uSunDir`, `uDaylight`, `uSkyHorizon`). They light nothing: the lights are your `picture/` code reading those signals (recipe 62).
|
|
40
|
-
- Fog is `scene.fog`, yours: copy `engine.uniforms.uSkyHorizon` into its color in `engine.onRender` and far things fade into the backdrop.
|
|
41
|
-
- Not together with `skybox` (both replace the dome).
|
|
42
|
-
- To fade the backdrop toward gray in snow, read the weather in the function: `() => new THREE.Color(0xefebe4).lerp(gray, engine.weather.current.snow * 0.3)`
|
|
43
|
-
(reuse the Color objects; it runs every frame).
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# Plain three.js in this engine
|
|
2
|
-
|
|
3
|
-
```js
|
|
4
|
-
engine.scene.add(new THREE.PointLight(0xffaa55, 2, 8)); // anything the engine does not write: just do it
|
|
5
|
-
engine.lights.sun.intensity = 3; // the placeholder lights too: nothing else writes them
|
|
6
|
-
const mySky = new THREE.Mesh(skyGeometry, skyMaterial);
|
|
7
|
-
engine.sky.replace(mySky); // your sky: skybox name, Texture or Object3D; null gives the dome back
|
|
8
|
-
engine.onRender(({ renderer, scene, camera }) => { /* render into your own target */ });
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
The engine is three.js underneath: `engine.renderer`, `engine.scene` and `engine.camera` are the real objects, and plain three.js code works on them.
|
|
12
|
-
What you need to know is which values the engine **writes on its own** (every frame or on a timer) and how to take those over. A direct write to
|
|
13
|
-
one of them hands it to you (the engine stops writing it and warns once with the explicit call); the full list is recipe 52 "Who writes it".
|
|
14
|
-
Everything else: just do it.
|
|
15
|
-
|
|
16
|
-
Rule of thumb: write the three.js first; it works (auto-yield: the engine stops writing a value you wrote, warns once). `renderer.toneMapping =
|
|
17
|
-
THREE.ACESFilmicToneMapping` is a complete answer. The engine route is optional on top: `engine.mod(point, ...)` adds owners and layers
|
|
18
|
-
where several systems share a value (recipe 55); `engine.view.manual(key)` takes a value without the warning (`manual(key, false)` gives it back);
|
|
19
|
-
`engine.describe('picture').picture` says what three.js holds now; `describe().owned` who writes each
|
|
20
|
-
engine-driven value now.
|
|
21
|
-
|
|
22
|
-
| three.js idiom | Where it goes in the engine | Engine overwrites it? | How to take it over |
|
|
23
|
-
|---|---|---|---|
|
|
24
|
-
| `renderer.toneMapping` | Just set it: `engine.renderer.toneMapping = THREE.ACESFilmicToneMapping` (any three mapping). A curve of your own: a post stage in the `'tone'` slot, `engine.post.add({ name, slot: 'tone', create, node })`, which runs on both renderers (a `ShaderChunk` edit is page-wide and reaches only the default renderer) | Once, at `createEngine` (`style.toneMapping`, else AgX), never again | Nothing to take: your write stays; `describe().render.toneMapping.writer` says `game` |
|
|
25
|
-
| `renderer.toneMappingExposure` | Just set it | Never on its own | Your direct write stays. Own the whole renderer: `createEngine({ renderer })` (recipe 50) |
|
|
26
|
-
| `renderer.outputColorSpace` | Leave it at `SRGBColorSpace` (three's default) | No | Changing it makes every color wrong; `assets.report` flags it |
|
|
27
|
-
| `renderer.shadowMap` | `engine.shadows.enabled`; `type` is yours | `enabled` when the switch changes | Write it: the engine yields; or `createEngine({ renderer })` and run your own |
|
|
28
|
-
| `scene.environment` | None by default. The sky as a map: `engine.sky.environment({ into: engine.scene })` | Never written unless you call that; a map you write stays | Write it; recipe 34 |
|
|
29
|
-
| `scene.background` | Style `background`, or `engine.sky.replace(name \| Texture \| Object3D)` with a sky | The sky dome draws over it; a backdrop / skybox writes it every frame | Assign it: the dome hides and the sky stops writing it, or `engine.sky.replace(yourTexture)` |
|
|
30
|
-
| `scene.fog` | Assign it: `scene.fog = new THREE.Fog(...)` | Never on its own | Your write stays |
|
|
31
|
-
| Your own sky (three/addons `Sky`, a ShaderMaterial dome, a skybox) | `engine.sky.replace(mySky)`; feed it from `engine.uniforms` (`uSunDir`, `uDaylight`, `uTimeOfDay`, `uWind`, `uCloud`) | Never: the engine only hides its dome and adds `mySky` to the scene when it has no parent; time, lights, fog and weather keep running | `engine.sky.replace(null)` gives the dome back. Per key instead of whole: write `engine.sky.top` and friends in your frame code |
|
|
32
|
-
| Lights (`DirectionalLight`, `PointLight`, ...) | Add them with `engine.scene.add(light)` before `engine.start()` (a light count change mid-play recompiles shaders; `lightPool()` for many) | Never on its own; `engine.lights.sun` / `.hemi` are still placeholders | Write them directly; `createEngine({ lights: false })` leaves the placeholders out |
|
|
33
|
-
| Shadow camera (`light.shadow.camera`, `mapSize`, `bias`) | Your own lights: just do it. Engine sun: the same, and `engine.shadows.box(engine.lights.sun, ...)` (sky) | The engine sun's shadow box follows `engine.focus` every frame | `engine.shadows.box(sun, { follow: 'focus' \| 'camera' \| object3D \| fn \| false, extent })`, or place `sun.target` yourself (the box stops following). With cascades built-in lit materials get the `csm` patch; a lit ShaderMaterial of yours joins with `engine.shadows.include(mat)` |
|
|
34
|
-
| Materials (`new MeshStandardMaterial(...)`) | Just do it | No | - |
|
|
35
|
-
| `onBeforeCompile`, `customProgramCacheKey` | Just assign them, on any material: `m.onBeforeCompile = s => { ... }`. A named, checked patch: `applyEffects(m, { patches: [...] })` | Nothing: on a material the engine patched (wind, clouds, season), your function runs first and the patches after it; your cache key is joined in front of theirs | - |
|
|
36
|
-
| Textures, `CanvasTexture`, `DataTexture` | Just do it; set `colorSpace = SRGBColorSpace` on color textures. File textures by name: `engine.assets.manifest({ textures })` then `assets.texture(name)` | No | A texture made in code gets a name too: `assets.manifest({ textures: { brick: () => makeBrick(), sign: mySignTexture } })`, then `map: 'brick'`; it keeps its own repeat / wrap / colorSpace. Baking: see recipe 05 |
|
|
37
|
-
| `EffectComposer` passes | `const h = engine.post.add(pass)` (`composer.addPass`; `{ order }` for `insertPass`; `h.remove()` for `removePass`): the pass joins the engine chain after the scene render, before tone mapping (FXAA / SMAA last; a pass that renders the scene replaces the scene render); a settings toggle: `add(pass, { name: 'glow' })`, then `engine.post.get('glow').enabled = false` | The engine renders the main frame through its own composer; a composer of your own rendered to the canvas takes the frame over (the engine stops drawing, warns `[own-frame]`; delete the call to hand it back) | `engine.post.own()` for the whole chain. To read them: `engine.post.object()` (the EffectComposer, null until post first runs) and `engine.post.targets()` (`renderTarget1 / 2`, `readBuffer`, `writeBuffer`; read in `onRender(fn, { when: 'after' })`). Read-only: the engine rebuilds `passes`, resizes and disposes them |
|
|
38
|
-
| Render targets (mirror, minimap, portal, picking) | `engine.onRender(({ renderer, scene, camera, dt }) => { renderer.setRenderTarget(rt); renderer.render(scene, cam); })`; runs after the camera and batching, before the frame (`{ when: 'after' }` after it) | No; the render target is reset to the screen after each `before` callback | The main frame render itself stays the engine's |
|
|
39
|
-
| Loaders (`GLTFLoader`, `TextureLoader`, `EXRLoader`, `FBXLoader`, `FontLoader`, exporters) | glTF and png / jpg / ktx2 / hdr textures: `engine.assets.manifest(...)` gives them names, the loading screen and `describe` | No | A hand-made `GLTFLoader` / `TextureLoader` works (rule R21 warns: the asset gets no name). Formats the manifest cannot load (EXR, FBX, OBJ, typeface fonts) and exporters: just use the three.js addon |
|
|
40
|
-
| Camera (`fov`, `position`, `far`) | Camera modules (`followCamera()`, ...) or `engine.camera` with none installed | An installed camera module writes position / fov every frame; terrain view distance rewrites `camera.far` | `engine.takeCamera('me')` (gives it back on `remove()`), or just write `camera.position` (the rig stops; `engine.view.manual('camera', false)` resumes). `camera.far` / `fov`: `engine.view.manual('far' \| 'fov')`. Not yet: no slot to swap in a different camera object |
|
|
41
|
-
| Meshes (`scene.add(mesh)`) | `engine.add(mesh, { id })` (tracked, saveable) or plain `engine.scene.add(mesh)` | No: auto-batching only merges what the engine places (world records, stream builds, level files); your own meshes stay as you made them | Many static copies of your own mesh: `mesh.userData.batch = true` before adding (recipe 05, 2b) |
|
|
42
|
-
| `requestAnimationFrame` loop | `engine.onFrame(dt => ...)`, `engine.onFixed(dt => ...)` | The engine runs the only loop | Do not start a second loop |
|
|
43
|
-
|
|
44
|
-
Also not yet: contact shadows. WebGPU and TSL: recipe 56.
|
|
45
|
-
|
|
46
|
-
## Procedural modeling: what three.js already has
|
|
47
|
-
|
|
48
|
-
Models written in code (recipe 05, 2a) mostly need helpers three.js already ships: import them from `three` or `three/addons/...` inside the
|
|
49
|
-
model generator, so the result is cached and baked with the model. The engine adds only what three lacks (last row).
|
|
50
|
-
|
|
51
|
-
```js
|
|
52
|
-
import * as THREE from 'three';
|
|
53
|
-
import { mergeGeometries, mergeVertices } from 'three/addons/utils/BufferGeometryUtils.js';
|
|
54
|
-
import { MeshSurfaceSampler } from 'three/addons/math/MeshSurfaceSampler.js';
|
|
55
|
-
import { SimplexNoise } from 'three/addons/math/SimplexNoise.js';
|
|
56
|
-
import { bakeVertexAO } from 'threedog';
|
|
57
|
-
|
|
58
|
-
const rng = engine.random.seeded(7), simplex = new SimplexNoise({ random: () => rng.next() }); // seeded noise: the same shape every load
|
|
59
|
-
// weld first, or the noise opens cracks; mergeVertices compares every attribute, so drop normal and uv (their seams would stay unwelded)
|
|
60
|
-
const rock = mergeVertices(new THREE.IcosahedronGeometry(1, 3).deleteAttribute('normal').deleteAttribute('uv'));
|
|
61
|
-
const p = rock.attributes.position, v = new THREE.Vector3();
|
|
62
|
-
for (let i = 0; i < p.count; i++) { v.fromBufferAttribute(p, i); v.multiplyScalar(1 + 0.25 * simplex.noise3d(v.x, v.y, v.z)); p.setXYZ(i, v.x, v.y, v.z); }
|
|
63
|
-
rock.computeVertexNormals();
|
|
64
|
-
const slab = new THREE.CylinderGeometry(1.2, 1.4, 0.3).translate(0, -0.9, 0).deleteAttribute('uv');
|
|
65
|
-
const model = mergeGeometries([rock, slab]); // same attributes (position, normal), both indexed
|
|
66
|
-
bakeVertexAO(model, { samples: 32, strength: 0.7, occluders: [new THREE.PlaneGeometry(6, 6).rotateX(-Math.PI / 2).translate(0, -1.05, 0)] });
|
|
67
|
-
const sampler = new MeshSurfaceSampler(new THREE.Mesh(model)).setRandomGenerator(() => rng.next()).build();
|
|
68
|
-
const at = new THREE.Vector3(), up = new THREE.Vector3();
|
|
69
|
-
sampler.sample(at, up); // a point and its normal on the surface: where a tuft or stud goes
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
| Need | three.js answer | Engine |
|
|
73
|
-
|---|---|---|
|
|
74
|
-
| Parts into one geometry / one draw call | `BufferGeometryUtils.mergeGeometries(list, useGroups)` (same attributes on every part, all indexed or none); `BufferGeometryUtils.mergeVertices(g, tolerance)` welds; `BufferGeometryUtils.toCreasedNormals(g, angle)` keeps hard edges with smooth faces; `mergeGroups` | `mergeColored([[g, color], ...])` when each part is one flat color (vertex colors) |
|
|
75
|
-
| Revolve a profile (vase, bottle, shade) | `new LatheGeometry(points, segments)` | - |
|
|
76
|
-
| Sweep along a path (pipe, rope, rail, vine) | `new TubeGeometry(curve, ...)`; a `Shape` along a path: `new ExtrudeGeometry(shape, { extrudePath: curve, steps })`; sections that change: `new LoftGeometry(sections)` (three/addons geometries); bend a finished mesh along a curve: `Flow` (three/addons CurveModifier) | - |
|
|
77
|
-
| A 2D outline into a slab (sign, cutout, wall with holes) | `Shape` with `shape.holes`, `new ExtrudeGeometry(shape, { depth, bevelEnabled })`; flat: `ShapeGeometry` | - |
|
|
78
|
-
| Rounded box, parametric surface, 3D text | `RoundedBoxGeometry`, `ParametricGeometry`, `TextGeometry` with `FontLoader` (addons) | - |
|
|
79
|
-
| Points spread over a mesh (moss, studs, spikes, ornaments) | `new MeshSurfaceSampler(mesh).setWeightAttribute(name).setRandomGenerator(fn).build()`, then `.sample(position, normal, color, uv)` | Over the ground by height, slope and biome rules: `engine.vegetation.define(name, { rule })` (recipe 10) |
|
|
80
|
-
| A decal projected onto a mesh (stain, sticker, scorch) | `new DecalGeometry(mesh, position, orientation, size)`, material with `polygonOffset` | - |
|
|
81
|
-
| Convex hull of points (pebble, crystal, collision proxy) | `new ConvexGeometry(points)`; `ConvexHull` for the faces as data | - |
|
|
82
|
-
| Fewer triangles (a far copy of one model) | `await new SimplifyModifier().modify(geometry, count)` (async in this three version) | Far copies of whole areas: `hlod` (recipe 15) |
|
|
83
|
-
| More triangles (before noise or vertex AO) | `new TessellateModifier(maxEdge, iterations).modify(g)`, or more segments in the primitive | - |
|
|
84
|
-
| Hard edges on a smooth mesh | `new EdgeSplitModifier().modify(g, angle)` or `BufferGeometryUtils.toCreasedNormals` | - |
|
|
85
|
-
| Noise (lumpy rock, wobbly edge, color variation) | `new SimplexNoise({ random })` (2D, 3D, 4D; seeded as above); `ImprovedNoise` (3D Perlin, one fixed permutation) | Terrain heights: `@threedog/terrain-noise` (recipe 28) |
|
|
86
|
-
| A texture drawn in code (labels, stripes, gradients, pixel art) | `new CanvasTexture(canvas)` with `colorSpace = SRGBColorSpace`; `DataTexture` | Give it a name: `assets.manifest({ textures })` (table above) |
|
|
87
|
-
| Many copies | `new InstancedMesh(g, m, count)` with `setMatrixAt`; `BatchedMesh` for different geometries | Auto-batching for copies the engine places, `userData.batch` for yours (recipe 05, 2b) |
|
|
88
|
-
| Ambient occlusion in a code-built model | Not in three: `aoMap` needs a baked texture | `bakeVertexAO(geometry, { samples, radius, strength, occluders })`: hemisphere rays per vertex (three-mesh-bvh), multiplied into the vertex colors; detail is per vertex, so tessellate big faces first |
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Plain-picture findings (phase 1 of docs/plans/2026-11-04-visuals-signals-in.md)
|
|
2
|
-
|
|
3
|
-
What was built: a night street in a flat-illustration look. `main.js` (47 lines) places shapes; `picture/` (~110 lines in one file at the time, a folder since) is the whole
|
|
4
|
-
picture in plain three.js: its own HemisphereLight, DirectionalLight, six PointLights, `THREE.Fog`, a gradient sky sphere
|
|
5
|
-
(`ShaderMaterial`), MeshLambert materials with an emissive copy of their own color that rises at night, painted lamp pools (additive
|
|
6
|
-
discs). Engine setup: `createEngine({ lights: false })`, `sky({ sun: false, hemisphere: false, fog: false })`, `calendar`, `weather`
|
|
7
|
-
(clear / rain), `fixedCamera`. Signals read: `uDaylight`, `uSunDir`, `uSkyHorizon` (15 % only), `engine.weather.current.rain`.
|
|
8
|
-
|
|
9
|
-
Shots (from packages/engine): `npx threedog shot plain-picture --time 22:00 | 12:00 [--weather rain]`. Three rounds of tuning;
|
|
10
|
-
`npm run check` passes with no opt-out comment.
|
|
11
|
-
|
|
12
|
-
Each finding is marked with what became of it (phase 2 is in the plan).
|
|
13
|
-
|
|
14
|
-
## Where the engine got in the way
|
|
15
|
-
|
|
16
|
-
1. **onFrame reads last frame's signals, and noon on the first frame.** `onFrame` callbacks run before module frame hooks
|
|
17
|
-
(`core/loop.js`), so the sky writes `uDaylight` etc. after picture code read them; on frame 1 the picture reads the defaults
|
|
18
|
-
(`render/effects.js`, `uDaylight: 1` = noon). Worked around with `engine.onRender`. Phase 2: one documented hook that runs after
|
|
19
|
-
all signals are final for this frame, and uniform defaults that do not claim noon.
|
|
20
|
-
2. **The picture check's light probes are undone by picture code that runs in onRender.** The probe zeroes `light.intensity`, then calls
|
|
21
|
-
`e._render(0)`, which runs `onRender` hooks, and the picture code writes the intensities back before the draw. So every shot reported
|
|
22
|
-
"light ... changes no pixel" for exactly the pattern the plan recommends. Phase 2: probe renders do not run game hooks.
|
|
23
|
-
3. **The picture check still describes the engine's lights, not the game's.** With `lights: false` the `time-flat` hint named
|
|
24
|
-
`sun.intensity 2, hemi.intensity 0.6`, the engine's lights that are not in the scene (`describe().look.lights`).
|
|
25
|
-
4. **Things the engine still writes with everything switched off:** `scene.environment` (the room map, `environmentIntensity` driven by
|
|
26
|
-
the sky); `scene.background` gray `0x8c8c8c` (`core/Engine.js`); `renderer.shadowMap.enabled = true` though no light casts; plain
|
|
27
|
-
Lambert / Phong / Standard / Toon materials get the cloud-shadow `onBeforeCompile` patch on entering the scene (strength 0; opt-out
|
|
28
|
-
`material.userData.cloudShadow = false`, which nobody would know); page-wide patches in `describe().threePatches`. Hiding the
|
|
29
|
-
engine's sky dome needs `engine.sky.dome.visible = false` (documented route is `look.sky.replace`).
|
|
30
|
-
5. **`describe()` disagrees with itself about tone mapping.** After `renderer.toneMapping = NoToneMapping`, `describe().render.toneMapping`
|
|
31
|
-
says `writer: game`, `describe().owned.toneMapping` still says `writer: engine` (`core/describeRender.js`).
|
|
32
|
-
6. **The sky colors are the engine's look, not signals.** `uSkyTop / uSkyHorizon` come from the neutral keyframes (`#161616 / #2a2a2a`
|
|
33
|
-
at 22:00). A styled game cannot use them as-is. Phase 2: signals are physical (sun, moon, cloud, rain, wetness); sky colors belong to
|
|
34
|
-
the picture file.
|
|
35
|
-
7. **Weather signals are not in `engine.uniforms`.** Rain amount is only `engine.weather.current.rain` (JS); no wetness signal; a
|
|
36
|
-
weather type's `fog: 0.6` / `sun` fields only mean something to the sky's drivers. Rain streaks are drawn by the engine's weather
|
|
37
|
-
look (restyle only through `look.weather.replace`).
|
|
38
|
-
8. **Light count / quality caps are not a signal.** The engine knows a light budget (`core/gameLights.js`, `engine.tier`), but there is
|
|
39
|
-
no "how many lights this tier can afford" value to read.
|
|
40
|
-
9. **Docs: the switch-off options are scattered** (`createEngine({ lights: false })` in a comment in `render/lights.js`; `sky({ sun,
|
|
41
|
-
hemisphere, fog })` in `modules/sky/look.js`); nothing says which hook picture code should use.
|
|
42
|
-
10. **Example folders are treated as games by check:** a new `examples/` folder needs `npm run map` (GAMEMAP.md) before check passes.
|
|
43
|
-
|
|
44
|
-
## What was pleasant
|
|
45
|
-
|
|
46
|
-
- `lights: false` + `sky({ sun: false, hemisphere: false, fog: false })` worked on the first try; plain `scene.add` of lights, fog and
|
|
47
|
-
materials was respected (`describe().render.lights` lists them as `writer: game`).
|
|
48
|
-
- `renderer.toneMapping = NoToneMapping` was respected for rendering.
|
|
49
|
-
- `engine.uniforms.uDaylight / uSunDir` are exactly the right shape for picture code: one number, one vector.
|
|
50
|
-
- `threedog shot` is fast (~5 s); the picture-level facts are useful apart from findings 2 and 3.
|
|
51
|
-
- No lint rule blocked plain three.js materials in an example.
|
|
52
|
-
- The flat look itself was easy in plain three.js: Lambert + emissive copy of the base color, a warm hemisphere light at night, painted
|
|
53
|
-
lamp pools. Total picture code ~110 lines, all in one file.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":1,"files":{"content/props.js":{"kind":"props","mtime":1793829782000,"from":0,"count":15,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793829782000,"from":0,"count":2,"indexIds":0,"positional":[]},"content/vegetation.js":{"kind":"vegetation","mtime":1793829782000,"from":0,"count":1,"indexIds":0,"positional":[]}},"ids":{"tree-1":[{"file":"content/props.js","kind":"props","line":4,"placed":true}],"tree-2":[{"file":"content/props.js","kind":"props","line":5,"placed":true}],"tree-3":[{"file":"content/props.js","kind":"props","line":6,"placed":true}],"tree-4":[{"file":"content/props.js","kind":"props","line":7,"placed":true}],"tree-5":[{"file":"content/props.js","kind":"props","line":8,"placed":true}],"tree-6":[{"file":"content/props.js","kind":"props","line":9,"placed":true}],"tree-7":[{"file":"content/props.js","kind":"props","line":10,"placed":true}],"sheep-1":[{"file":"content/props.js","kind":"props","line":11,"placed":true}],"sheep-2":[{"file":"content/props.js","kind":"props","line":12,"placed":true}],"sheep-3":[{"file":"content/props.js","kind":"props","line":13,"placed":true}],"sheep-4":[{"file":"content/props.js","kind":"props","line":14,"placed":true}],"sheep-5":[{"file":"content/props.js","kind":"props","line":15,"placed":true}],"sheep-6":[{"file":"content/props.js","kind":"props","line":16,"placed":true}],"sheep-7":[{"file":"content/props.js","kind":"props","line":17,"placed":true}],"sheep-8":[{"file":"content/props.js","kind":"props","line":18,"placed":true}],"tree":[{"file":"content/templates.js","kind":"templates","line":3,"placed":false}],"sheep":[{"file":"content/templates.js","kind":"templates","line":4,"placed":false}],"wheat":[{"file":"content/vegetation.js","kind":"vegetation","line":6,"placed":false}]}}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { codedError } from '../../core/errorHints.js';
|
|
2
|
-
// Orthographic projection for engine.camera, without replacing the camera object: engine.camera is an EngineCamera (core/engineCamera.js), whose
|
|
3
|
-
// own updateProjectionMatrix draws orthographic while orthoSize is set. Nothing is patched on the instance; describe().camera.projection reports it.
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Switch engine.camera between perspective and orthographic.
|
|
7
|
-
* @param {import('three').PerspectiveCamera} cam engine.camera
|
|
8
|
-
* @param {'perspective' | 'orthographic'} projection
|
|
9
|
-
* @param {number} [size] orthographic only: world units covered by the view height (before camera.zoom)
|
|
10
|
-
*/
|
|
11
|
-
export function setProjection(cam, projection = 'perspective', size = 20) {
|
|
12
|
-
if (projection !== 'perspective' && projection !== 'orthographic') throw codedError('camera-option', `projection must be 'perspective' or 'orthographic', got '${projection}'`);
|
|
13
|
-
if (projection === 'orthographic' && !(size > 0)) throw codedError('camera-option', `orthographic projection needs size > 0 (world units of view height), got ${size}`);
|
|
14
|
-
const c = /** @type {any} */ (cam);
|
|
15
|
-
if (!('orthoSize' in c)) throw codedError('camera-option', "orthographic projection needs engine.camera (an EngineCamera); a camera you made yourself is plain three.js: use a THREE.OrthographicCamera and render with it");
|
|
16
|
-
const ortho = projection === 'orthographic';
|
|
17
|
-
if (ortho ? c.orthoSize === size : !c.orthoSize) return;
|
|
18
|
-
c.orthoSize = ortho ? size : 0;
|
|
19
|
-
c.isOrthographicCamera = ortho; c.isPerspectiveCamera = !ortho;
|
|
20
|
-
c.updateProjectionMatrix();
|
|
21
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|