threedog 0.7.0 → 0.8.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 +196 -1
- package/README.md +6 -9
- package/core/{Animator.js → assets/Animator.js} +28 -18
- package/core/{Assets.js → assets/Assets.js} +98 -54
- package/core/{Baked.js → assets/Baked.js} +4 -4
- package/core/assets/assetEntry.js +237 -0
- package/core/{assetHot.js → assets/assetHot.js} +7 -6
- 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} +6 -12
- package/core/{namedModel.js → assets/namedModel.js} +17 -13
- package/core/{Audio.js → audio/Audio.js} +26 -23
- 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} +10 -10
- package/core/{Random.js → base/Random.js} +5 -4
- package/core/{easing.js → base/easing.js} +1 -1
- package/core/{errorCodes.js → base/errorCodes.js} +98 -110
- package/core/{errorHints.js → base/errorHints.js} +5 -9
- package/core/{errors.js → base/errors.js} +6 -6
- package/core/{events.generated.js → base/events.generated.js} +1 -0
- package/core/{math.js → base/math.js} +15 -4
- package/core/{params.js → base/params.js} +3 -4
- package/core/base/util.js +32 -0
- package/core/{validate.js → base/validate.js} +28 -7
- package/core/{Engine.js → engine/Engine.js} +80 -77
- package/core/{Loading.js → engine/Loading.js} +4 -2
- package/core/{copies.js → engine/copies.js} +4 -4
- package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
- package/core/{lifecycle.js → engine/lifecycle.js} +14 -12
- package/core/{loop.js → engine/loop.js} +68 -47
- package/core/{moduleSlots.js → engine/moduleSlots.js} +6 -6
- package/core/{moduleTypes.js → engine/moduleTypes.js} +13 -14
- package/core/{modules.js → engine/modules.js} +14 -11
- package/core/{page.js → engine/page.js} +36 -23
- package/core/{plugins.js → engine/plugins.js} +6 -9
- package/core/{services.js → engine/services.js} +47 -40
- package/core/{startup.js → engine/startup.js} +26 -24
- package/core/{Input.js → input/Input.js} +30 -22
- package/core/{inputContext.js → input/inputContext.js} +14 -5
- package/core/{inputPad.js → input/inputPad.js} +1 -1
- package/core/{inputPointer.js → input/inputPointer.js} +8 -2
- package/core/{inputTouch.js → input/inputTouch.js} +1 -1
- package/core/{Budget.js → inspect/Budget.js} +21 -20
- package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +30 -16
- package/core/{Describe.js → inspect/Describe.js} +26 -22
- package/core/{Inspect.js → inspect/Inspect.js} +9 -7
- 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} +52 -20
- package/core/{catalog.js → inspect/catalog.js} +3 -3
- 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} +21 -20
- package/core/{describeText.js → inspect/describeText.js} +11 -6
- package/core/inspect/geometryWatch.js +38 -0
- package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
- package/core/{pictureWriters.js → inspect/pictureWriters.js} +15 -16
- package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
- package/core/{Ops.js → ops/Ops.js} +16 -11
- package/core/{control.js → ops/control.js} +13 -12
- package/core/ops/holds.js +139 -0
- package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
- package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
- package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
- package/core/{opsRun.js → ops/opsRun.js} +7 -4
- package/core/{owned.js → ops/owned.js} +14 -17
- package/core/{sharedPoint.js → ops/sharedPoint.js} +8 -8
- package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
- package/core/{stacks.js → ops/stacks.js} +12 -14
- package/core/{wrap.js → ops/wrap.js} +8 -6
- package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
- package/core/{Saves.js → saves/Saves.js} +58 -36
- package/core/{saveApply.js → saves/saveApply.js} +13 -9
- package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
- package/core/{saveValues.js → saves/saveValues.js} +20 -3
- package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
- package/core/{session.js → saves/session.js} +31 -17
- package/core/{Rays.js → scene/Rays.js} +23 -25
- package/core/{Views.js → scene/Views.js} +14 -6
- package/core/{adaptive.js → scene/adaptive.js} +15 -8
- package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
- package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
- 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} +4 -4
- package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
- package/core/{ground.js → scene/ground.js} +9 -9
- package/core/{movement.js → scene/movement.js} +3 -3
- package/core/{pictureSlots.js → scene/pictureSlots.js} +2 -2
- package/core/{sceneDelta.js → scene/sceneDelta.js} +2 -2
- package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -13
- package/core/scene/stepPoses.js +55 -0
- package/core/{targeting.js → scene/targeting.js} +4 -5
- package/core/{thingExplain.js → scene/thingExplain.js} +6 -5
- package/core/{thingOps.js → scene/thingOps.js} +4 -3
- package/core/{things.js → scene/things.js} +18 -5
- package/core/{threePatches.js → scene/threePatches.js} +1 -1
- package/core/{view.js → scene/view.js} +17 -16
- package/core/{Batching.js → stream/Batching.js} +85 -27
- package/core/{Stream.js → stream/Stream.js} +60 -30
- package/core/{batchGroups.js → stream/batchGroups.js} +10 -9
- package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
- package/core/{scatter.js → stream/scatter.js} +2 -2
- package/core/{streamSources.js → stream/streamSources.js} +12 -7
- package/core/{Commits.js → threads/Commits.js} +6 -5
- package/core/{Jobs.js → threads/Jobs.js} +12 -10
- package/core/{Threads.js → threads/Threads.js} +16 -16
- 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} +17 -10
- package/core/{dayTime.js → time/dayTime.js} +5 -1
- package/core/{skip.js → time/skip.js} +18 -17
- package/core/{time.js → time/time.js} +18 -12
- package/core/{uiClock.js → time/uiClock.js} +4 -4
- package/docs/AI.md +22 -19
- package/docs/API.md +24 -23
- package/docs/CODEMAP.md +76 -183
- package/docs/COMMANDS.md +66 -58
- package/docs/CONVENTIONS.md +54 -14
- package/docs/MIGRATING-0.8.md +169 -0
- package/docs/THREE.md +78 -29
- 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 +29 -29
- package/docs/api/characters.md +23 -18
- package/docs/api/clock.md +1 -1
- package/docs/api/collision.md +12 -9
- package/docs/api/content.md +6 -6
- package/docs/api/dialogue.md +3 -3
- package/docs/api/engine.md +45 -43
- package/docs/api/events.md +3 -2
- package/docs/api/flow.md +1 -1
- package/docs/api/grids.md +1 -1
- package/docs/api/ground.md +4 -5
- package/docs/api/hud.md +2 -2
- package/docs/api/i18n.md +6 -6
- package/docs/api/input.md +7 -7
- package/docs/api/interactions.md +4 -4
- package/docs/api/inventory.md +9 -9
- package/docs/api/jobs.md +5 -5
- package/docs/api/level.md +7 -7
- package/docs/api/lightPool.md +1 -6
- package/docs/api/music.md +3 -3
- package/docs/api/nav.md +10 -10
- package/docs/api/openWorld.md +1 -1
- package/docs/api/particles.md +2 -2
- package/docs/api/photo.md +4 -2
- package/docs/api/pickups.md +2 -2
- package/docs/api/post.md +20 -3
- package/docs/api/quests.md +3 -3
- package/docs/api/rays.md +5 -7
- package/docs/api/rigid.md +27 -18
- package/docs/api/saves.md +8 -7
- package/docs/api/settings.md +9 -8
- package/docs/api/sky.md +8 -7
- package/docs/api/stream.md +7 -7
- package/docs/api/swarm.md +34 -0
- package/docs/api/terrain.md +7 -8
- package/docs/api/terrainDraw.md +1 -1
- package/docs/api/timeline.md +2 -2
- package/docs/api/tools.md +25 -22
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -3
- package/docs/api/vegetationDraw.md +1 -1
- package/docs/api/water.md +1 -1
- package/docs/api/weather.md +9 -9
- package/docs/api/weatherDraw.md +3 -3
- package/docs/api/world.md +5 -5
- package/docs/recipes/01-new-game.md +25 -40
- package/docs/recipes/02-npc.md +19 -20
- package/docs/recipes/03-items-pickups.md +27 -43
- package/docs/recipes/04-quests.md +3 -4
- package/docs/recipes/05-props-bake.md +29 -39
- package/docs/recipes/06-clock-events.md +27 -18
- package/docs/recipes/07-flow-scenes-pause.md +12 -17
- package/docs/recipes/08-weather-sky.md +88 -34
- package/docs/recipes/09-materials-lights-models.md +22 -36
- package/docs/recipes/10-blender-level.md +6 -7
- package/docs/recipes/11-vehicles.md +30 -22
- package/docs/recipes/12-navmesh.md +9 -8
- package/docs/recipes/13-animation.md +39 -17
- package/docs/recipes/14-custom-module.md +14 -13
- package/docs/recipes/15-perf.md +49 -26
- package/docs/recipes/16-dev-bridge.md +32 -52
- package/docs/recipes/18-world.md +36 -23
- package/docs/recipes/19-shooting-picking.md +4 -2
- package/docs/recipes/20-content-actions-save.md +30 -35
- package/docs/recipes/21-camera.md +33 -5
- package/docs/recipes/22-shop-gold.md +0 -4
- package/docs/recipes/23-ops.md +10 -10
- package/docs/recipes/26-ui-parts.md +22 -12
- package/docs/recipes/27-net.md +0 -2
- package/docs/recipes/28-terrain.md +117 -21
- package/docs/recipes/29-grid.md +2 -2
- package/docs/recipes/30-templates.md +55 -19
- package/docs/recipes/31-audio.md +5 -5
- package/docs/recipes/32-action-game.md +15 -6
- package/docs/recipes/33-stream-sources.md +2 -2
- package/docs/recipes/34-environment-lighting.md +67 -19
- package/docs/recipes/35-picture-from-reference.md +10 -17
- package/docs/recipes/36-ground-plants.md +105 -0
- package/docs/recipes/40-scene.md +7 -11
- package/docs/recipes/43-shader-patches-surfaces.md +20 -41
- package/docs/recipes/44-water-weather-hooks.md +48 -43
- package/docs/recipes/45-cascaded-shadows.md +39 -17
- package/docs/recipes/46-blender-art-route.md +7 -8
- package/docs/recipes/49-game-module-contract.md +5 -5
- package/docs/recipes/50-own-renderer.md +2 -2
- package/docs/recipes/52-around-the-picture.md +54 -98
- package/docs/recipes/53-ground-up-close.md +61 -24
- package/docs/recipes/55-mods-time-wrap.md +12 -16
- package/docs/recipes/56-webgpu-tsl.md +16 -14
- package/docs/recipes/57-control.md +9 -2
- package/docs/recipes/58-input.md +2 -2
- package/docs/recipes/59-depth-post-effects.md +1 -1
- package/docs/recipes/60-judge-the-picture.md +29 -24
- package/docs/recipes/62-picture-code.md +49 -17
- package/docs/recipes/63-third-person-start.md +17 -4
- package/docs/recipes/64-particles.md +1 -1
- package/docs/recipes/65-swarm.md +140 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +2 -2
- package/examples/{sheepisland → perf-island}/.threedog/content-index.json +1 -1
- package/examples/{sheepisland → perf-island}/GAMEMAP.md +12 -11
- 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 +1 -0
- package/examples/rc2d/GAMEMAP.md +3 -2
- package/examples/rc2d/main.js +1 -3
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +3 -2
- 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 +1 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +4 -3
- package/examples/world/picture/sky.js +1 -1
- package/index.d.ts +8 -7
- package/index.js +31 -31
- package/llms.txt +9 -13
- package/modules/ambience/Ambience.js +11 -8
- package/modules/calendar/Calendar.js +19 -19
- package/modules/calendar/index.js +13 -13
- package/modules/calendar/schedule.js +11 -6
- package/modules/calendar/seasons.js +7 -7
- package/modules/camera/FirstPersonCamera.js +2 -2
- package/modules/camera/FixedCamera.js +14 -15
- package/modules/camera/FollowCamera.js +4 -4
- package/modules/camera/RtsCamera.js +11 -11
- package/modules/camera/common.js +48 -24
- package/modules/camera/contract.js +1 -0
- package/modules/camera/projection.js +2 -2
- package/modules/characters/Character.js +33 -30
- package/modules/characters/NPC.js +27 -19
- package/modules/characters/assetModel.js +14 -10
- package/modules/characters/astar.js +7 -5
- package/modules/characters/behaviors.js +4 -5
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +168 -214
- package/modules/characters/moveHelpers.js +14 -3
- package/modules/characters/movers/common.js +16 -14
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +7 -6
- package/modules/characters/movers/simple.js +3 -3
- package/modules/characters/movers/support.js +8 -8
- package/modules/characters/npcAvoid.js +4 -4
- package/modules/characters/npcSim.js +23 -17
- package/modules/characters/npcView.js +6 -5
- package/modules/characters/pathAsync.js +12 -10
- package/modules/characters/pathWorker.js +1 -1
- package/modules/characters/player.js +108 -0
- package/modules/characters/playerStrings.js +2 -2
- package/modules/characters/proceduralRig.js +2 -2
- package/modules/characters/useModel.js +3 -3
- package/modules/characters/walkTo.js +11 -17
- package/modules/collision/Collision.js +26 -20
- package/modules/collision/contract.js +15 -0
- package/modules/content/explain.js +1 -2
- package/modules/content/fields.js +24 -3
- package/modules/content/ids.js +2 -2
- package/modules/content/index.js +61 -99
- package/modules/content/loader.js +14 -17
- package/modules/content/markers.js +25 -0
- package/modules/content/models.js +10 -7
- package/modules/content/packs.js +3 -3
- package/modules/content/parts.js +2 -2
- package/modules/content/places.js +35 -0
- package/modules/content/props.js +17 -14
- package/modules/content/rules.js +25 -21
- package/modules/content/stages.js +7 -7
- package/modules/content/templates.js +20 -20
- package/modules/content/words.js +34 -0
- package/modules/debug/DebugPanel.js +10 -43
- package/modules/flow/contract.js +1 -1
- package/modules/flow/index.js +11 -7
- package/modules/gameplay/Container.js +12 -11
- package/modules/gameplay/Containers.js +14 -5
- package/modules/gameplay/Dialogue.js +13 -11
- package/modules/gameplay/Interactions.js +37 -24
- package/modules/gameplay/Inventory.js +8 -9
- package/modules/gameplay/Quests.js +16 -9
- package/modules/gameplay/boxOps.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +3 -4
- package/modules/gameplay/inventoryOps.js +0 -1
- package/modules/gameplay/pickups.js +22 -23
- package/modules/gameplay/questSave.js +3 -3
- package/modules/grid/Grid.js +1 -1
- package/modules/grid/Layer.js +4 -4
- package/modules/grid/index.js +7 -8
- package/modules/grid/preview.js +7 -7
- package/modules/grid/tiles.js +6 -6
- package/modules/hlod/index.js +37 -55
- package/modules/hud/index.js +17 -11
- package/modules/hud/parts.js +4 -4
- package/modules/level/contract.js +16 -0
- package/modules/level/heightfield.js +12 -10
- package/modules/level/index.js +47 -152
- package/modules/level/load.js +79 -0
- package/modules/level/meshes.js +65 -0
- package/modules/level/nodes.js +6 -7
- package/modules/lights/index.js +28 -181
- package/modules/lights/slots.js +93 -0
- package/modules/lights/sources.js +88 -0
- package/modules/music/Music.js +30 -26
- package/modules/music/rules.js +1 -1
- package/modules/nav/contract.js +14 -0
- package/modules/nav/index.js +11 -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 +5 -4
- package/modules/net/sync.js +2 -2
- package/modules/net/transports.js +2 -2
- package/modules/particles/Particles.js +11 -8
- package/modules/particles/effect.js +7 -5
- package/modules/particles/shaders.js +2 -1
- package/modules/photo/Photo.js +15 -17
- package/modules/rigid/RigidBodies.js +66 -43
- package/modules/rigid/Vehicles.js +2 -3
- package/modules/rigid/ragdoll.js +287 -0
- package/modules/rigid/ragdollBones.js +159 -0
- package/modules/rigid/sync.js +6 -6
- package/modules/settings/Settings.js +108 -39
- package/modules/settings/apply.js +6 -6
- package/modules/settings/sections.js +16 -14
- 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 +14 -27
- package/modules/sky/tint.js +1 -1
- package/modules/swarm/Swarm.js +346 -0
- package/modules/swarm/draw.js +68 -0
- package/modules/swarm/grid.js +63 -0
- package/modules/terrain/ChunkManager.js +70 -52
- 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 +28 -34
- package/modules/terrain/terrainColorMap.js +6 -3
- package/modules/terrain/terrainDefaults.js +2 -1
- package/modules/terrain/terrainEdit.js +32 -27
- package/modules/terrain/terrainGen.js +17 -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 +27 -19
- package/modules/timeline/Tween.js +6 -6
- package/modules/timeline/shots.js +5 -7
- package/modules/triggers/index.js +9 -9
- package/modules/vegetation/Vegetation.js +30 -23
- package/modules/vegetation/densityMap.js +4 -7
- package/modules/vegetation/draw.js +23 -18
- package/modules/vegetation/groundChunks.js +11 -31
- package/modules/vegetation/index.js +8 -6
- package/modules/vegetation/modelGeometry.js +3 -6
- package/modules/vegetation/nearFade.js +1 -1
- package/modules/water/Water.js +16 -16
- package/modules/water/surface.js +3 -3
- package/modules/weather/Weather.js +41 -30
- package/modules/weather/particles.js +8 -8
- package/modules/weather/weatherDraw.js +22 -18
- package/modules/world/World.js +8 -8
- package/modules/world/explain.js +1 -1
- package/modules/world/index.js +18 -12
- package/modules/world/persist.js +73 -25
- package/modules/world/pos.js +4 -4
- package/modules/world/records.js +28 -8
- package/modules/world/sim.js +4 -4
- package/modules/world/state.js +12 -5
- package/modules/world/thingSource.js +4 -2
- package/modules/world/views.js +11 -9
- package/package.json +42 -7
- package/presets.js +1 -3
- package/render/PostFX.js +39 -27
- package/render/backend.js +26 -32
- 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/patchNodes.tsl.js +5 -15
- package/render/fx/postWebGPU.tsl.js +27 -23
- 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 +1 -1
- package/render/lighting.js +5 -3
- package/render/lightmap.js +20 -20
- 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 +20 -4
- package/render/ownFrame.js +4 -4
- package/render/patches.js +13 -13
- package/render/postWebGL.js +12 -10
- package/render/probes.js +16 -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 +57 -11
- package/render/slots.js +7 -7
- package/render/terms.js +22 -24
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +200 -153
- package/types/gameplay.d.ts +163 -91
- 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} +7 -15
- 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} +12 -8
- package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
- package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +2 -2
- package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
- package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
- package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
- package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
- package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
- package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
- package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
- package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
- 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/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 +1 -1
- 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 +2 -1
- package/types/generated/modules/water/Water.d.ts +1 -0
- package/types/generated/modules/weather/Weather.d.ts +16 -12
- package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
- package/types/generated/modules/world/World.d.ts +5 -3
- package/types/generated/render/PostFX.d.ts +17 -11
- 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 +11 -11
- package/types/physics.d.ts +99 -70
- package/types/tsl.d.ts +37 -4
- package/types/world.d.ts +38 -71
- package/ui/Focus.js +10 -9
- package/ui/Parts.js +4 -3
- package/ui/UI.js +7 -7
- package/ui/defaults.js +3 -2
- package/ui/theme.js +5 -3
- package/core/assetEntry.js +0 -109
- package/core/holds.js +0 -134
- package/core/shadowTypes.js +0 -16
- package/core/util.js +0 -17
- 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/core/{Vars.js → base/Vars.js} +0 -0
- /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/{opsFail.js → ops/opsFail.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/{tier.js → scene/tier.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 +1 @@
|
|
|
1
|
-
{"version":1,"files":{"content/actions.js":{"kind":"actions","mtime":
|
|
1
|
+
{"version":1,"files":{"content/actions.js":{"kind":"actions","mtime":1793906610000,"from":0,"count":4,"indexIds":0,"positional":[]},"content/audio.js":{"kind":"audio","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/items.js":{"kind":"items","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/places.js":{"kind":"places","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/props.js":{"kind":"props","mtime":1793906610000,"from":0,"count":8,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793906610000,"from":0,"count":4,"indexIds":0,"positional":[]},"content/views.js":{"kind":"views","mtime":1793906610000,"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}]}}
|
|
@@ -38,6 +38,7 @@ Content: actions 4 · audio 1 · items 1 · places 1 · props 8 (from templates
|
|
|
38
38
|
Not used yet (check these before writing the system yourself):
|
|
39
39
|
|
|
40
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)
|
|
41
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
41
42
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
42
43
|
|
|
43
44
|
## Files
|
|
@@ -124,8 +125,7 @@ Code that breaks saves or manages world models: none (rule R33).
|
|
|
124
125
|
|
|
125
126
|
- Save prefix saveKey: threedog-action
|
|
126
127
|
- Save slots: slot1
|
|
127
|
-
- Save entries the game registers itself:
|
|
128
|
-
'action
|
|
128
|
+
- Save entries the game registers itself: action
|
|
129
129
|
- Saved parts of the engine modules (vars, inventory, quests, timers, world...): `threedog catalog` (saves per module)
|
|
130
130
|
|
|
131
131
|
## Style keys
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"files":{"content/props.js":{"kind":"props","mtime":
|
|
1
|
+
{"version":1,"files":{"content/props.js":{"kind":"props","mtime":1793906610000,"from":0,"count":15,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793906610000,"from":0,"count":2,"indexIds":0,"positional":[]},"content/vegetation.js":{"kind":"vegetation","mtime":1793906610000,"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,6 +1,6 @@
|
|
|
1
|
-
# Game map:
|
|
1
|
+
# Game map: perf-island (generated, do not edit by hand)
|
|
2
2
|
|
|
3
|
-
> Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /
|
|
3
|
+
> Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /perf-island.html, entry `main.js`.
|
|
4
4
|
> Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
|
|
5
5
|
|
|
6
6
|
Content: props 15 (from templates 15) · templates 2 · vegetation 1
|
|
@@ -11,15 +11,15 @@ None yet, write them in `DESIGN.md` (why it is designed this way, what not to ch
|
|
|
11
11
|
|
|
12
12
|
## Engine modules (engine.use)
|
|
13
13
|
|
|
14
|
-
- createEngine: { bindings: { ...presets.bindings.debug }, lights: false, saveKey: 'threedog-
|
|
14
|
+
- createEngine: { bindings: { ...presets.bindings.debug }, lights: false, saveKey: 'threedog-perf-island', ui: { loading: { t…
|
|
15
15
|
- openWorld preset ({ camera: fixedCamera(), terrain: island, water: false, rigid: false, ambience: false, calendar: { …) → world, terrain, vegetation, calendar, sky, weather, collision, characters, settings, debug
|
|
16
16
|
- content
|
|
17
17
|
|
|
18
18
|
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
19
19
|
|
|
20
20
|
- world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
|
|
21
|
-
- terrain: `node_modules/threedog/docs/recipes/
|
|
22
|
-
- vegetation: `node_modules/threedog/docs/recipes/36-
|
|
21
|
+
- terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
|
|
22
|
+
- vegetation: `node_modules/threedog/docs/recipes/36-ground-plants.md` · `node_modules/threedog/docs/api/vegetation.md`
|
|
23
23
|
- calendar: `node_modules/threedog/docs/recipes/06-clock-events.md` · `node_modules/threedog/docs/api/calendar.md`
|
|
24
24
|
- sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
|
|
25
25
|
- weather: `node_modules/threedog/docs/recipes/44-water-weather-hooks.md` · `node_modules/threedog/docs/api/weather.md`
|
|
@@ -34,6 +34,7 @@ Not used yet (check these before writing the system yourself):
|
|
|
34
34
|
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
35
35
|
- interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
|
|
36
36
|
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
37
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
37
38
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
38
39
|
|
|
39
40
|
## Files
|
|
@@ -48,14 +49,14 @@ content/*.js is content data: how to write it in `node_modules/threedog/docs/rec
|
|
|
48
49
|
| content/templates.js | 6 | |
|
|
49
50
|
| content/vegetation.js | 11 | |
|
|
50
51
|
| main.js | 83 | @ts-check This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). On … |
|
|
51
|
-
| models.js | 49 |
|
|
52
|
-
| params.js | 26 | URL parameters of the
|
|
53
|
-
| picture/index.js | 21 | @ts-check The picture of
|
|
52
|
+
| models.js | 49 | perf-island procedural models: a round tree, a sheep, a wheat tuft. Built in code, no files; regist… |
|
|
53
|
+
| params.js | 26 | URL parameters of the perf island page. Import this file first in main.js: it rewrites word values … |
|
|
54
|
+
| picture/index.js | 21 | @ts-check The picture of perf island: wiring only. Each part writes plain three.js from the signals… |
|
|
54
55
|
| picture/lights.js | 35 | @ts-check Sun or moon and ambient, both from the day table in palette.js. |
|
|
55
56
|
| picture/materials.js | 62 | @ts-check Materials by name. All matte Lambert with two shader additions: soft light (the wrap and … |
|
|
56
|
-
| picture/palette.js | 61 | @ts-check
|
|
57
|
+
| picture/palette.js | 61 | @ts-check Perf island palette: every color and key value of the picture, one copy. A soft painted d… |
|
|
57
58
|
| picture/sky.js | 21 | @ts-check A flat painted backdrop: one color at every height, the same as the fog, so the island fl… |
|
|
58
|
-
| views.js | 10 | Named camera positions of the
|
|
59
|
+
| views.js | 10 | Named camera positions of the perf island. Same name = same framing every time, so two screenshots … |
|
|
59
60
|
|
|
60
61
|
## NPCs (content/npcs.js)
|
|
61
62
|
|
|
@@ -103,7 +104,7 @@ Code that breaks saves or manages world models: none (rule R33).
|
|
|
103
104
|
|
|
104
105
|
## Saves
|
|
105
106
|
|
|
106
|
-
- Save prefix saveKey: threedog-
|
|
107
|
+
- Save prefix saveKey: threedog-perf-island
|
|
107
108
|
- Saved parts of the engine modules (vars, inventory, quests, timers, world...): `threedog catalog` (saves per module)
|
|
108
109
|
|
|
109
110
|
## Style keys
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// objects and checks the model / sound names content uses against them (one source, no scanning of main.js).
|
|
3
3
|
import { models } from './models.js'; // roundTree, sheep, wheatTuft
|
|
4
4
|
|
|
5
|
-
export default [{ name: '
|
|
5
|
+
export default [{ name: 'perf-island', models }];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
// This example is written in GLSL: it is the WebGL route (`threedog new-game --webgl`). On the default WebGPU route the same ideas are written in TSL (recipe 56).
|
|
3
|
-
//
|
|
3
|
+
// Perf island: a small floating island built only from the engine's public entry points.
|
|
4
4
|
// A meadow with a river, round trees, a wheat field and a flock of sheep on an island with a ragged rim, over a pale backdrop with no horizon.
|
|
5
5
|
// Parameters (params.js): time day | dusk | night, weather clear | snow, view overview | flock | field | river | rim.
|
|
6
6
|
// main.js holds wiring only: modules, the island's terrain functions, view switching and the snow-to-winter link. Objects are content (rule R33),
|
|
@@ -19,7 +19,7 @@ import { VIEWS } from './views.js';
|
|
|
19
19
|
const island = {
|
|
20
20
|
...GROUND,
|
|
21
21
|
material: mat.ground, effects: /** @type {const} */ (false), // drawn as given: picture/materials.js brings its own snow, and this island has no cloud shadow
|
|
22
|
-
resolution: 48, // 64 m chunk / 48 = 1.33 m cells: the rim is cut along cells, so finer cells give a finer brushed edge (recipe
|
|
22
|
+
resolution: 48, // 64 m chunk / 48 = 1.33 m cells: the rim is cut along cells, so finer cells give a finer brushed edge (recipe 28 §5)
|
|
23
23
|
// the river's centre line z = amp * sin(x * freq) + shift: one set of numbers both functions read (n.params), so the dip and the river
|
|
24
24
|
// ground type cannot drift apart
|
|
25
25
|
params: { river: { amp: 6, freq: 0.09, shift: 2, dip: 3.2, wet: 2.4 } },
|
|
@@ -45,8 +45,8 @@ const island = {
|
|
|
45
45
|
|
|
46
46
|
// ---------- 2. Engine: no placeholder lights, open-world preset with a fixed sky; a two-season calendar so snow can turn the island white ----------
|
|
47
47
|
const WINTER_DAY = 1001; // seasons last 1000 days each, so the season never blends towards the next one (it does over the last 20%)
|
|
48
|
-
const engine = createEngine({ bindings: { ...presets.bindings.debug }, canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, saveKey: 'threedog-
|
|
49
|
-
ui: { loading: { title: '
|
|
48
|
+
const engine = createEngine({ bindings: { ...presets.bindings.debug }, canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, saveKey: 'threedog-perf-island',
|
|
49
|
+
ui: { loading: { title: 'perf island' } } });
|
|
50
50
|
engine.use(openWorld({ camera: fixedCamera(), terrain: island, water: false, rigid: false, ambience: false,
|
|
51
51
|
calendar: { ...presets.calendar.fixedTime, time: 0.5, seasons: ['summer', 'winter'], daysPerSeason: 1000 },
|
|
52
52
|
weather: { ...presets.weather.temperate, start: 'clear' }, autoWeather: false }), content());
|
|
@@ -63,7 +63,7 @@ engine.onFrame(() => {
|
|
|
63
63
|
|
|
64
64
|
// ---------- 4. Views: an op, so the URL, the dev bridge and tests switch the same way ----------
|
|
65
65
|
const state = { view: params.view };
|
|
66
|
-
engine.ops.define('
|
|
66
|
+
engine.ops.define('perf-island.view', {
|
|
67
67
|
desc: 'Move the camera to a named view: overview, flock, field, river, rim', args: { name: 'string' },
|
|
68
68
|
can: (e, { name }) => VIEW_NAMES.includes(name) ? true : 'unknownView',
|
|
69
69
|
run: (e, { name }) => {
|
|
@@ -74,9 +74,9 @@ engine.ops.define('sheepisland.view', {
|
|
|
74
74
|
},
|
|
75
75
|
reasons: { unknownView: 'View names: overview, flock, field, river, rim' },
|
|
76
76
|
});
|
|
77
|
-
engine.describe.add('
|
|
78
|
-
engine.events.on('engine:ready', () => engine.ops.run('
|
|
79
|
-
if (params.badView) console.warn(`
|
|
77
|
+
engine.describe.add('perf-island', () => ({ view: state.view, season: engine.calendar.season, weather: engine.weather?.name }));
|
|
78
|
+
engine.events.on('engine:ready', () => engine.ops.run('perf-island.view', { name: params.view }));
|
|
79
|
+
if (params.badView) console.warn(`perf-island: unknown view '${params.badView}', showing overview. Views: ${VIEW_NAMES.join(', ')}`);
|
|
80
80
|
|
|
81
81
|
engine.start();
|
|
82
82
|
Object.assign(window, { engine, picture }); // handy for debugging in the browser console
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// perf-island procedural models: a round tree, a sheep, a wheat tuft. Built in code, no files; registered as an asset pack (assets.js).
|
|
2
2
|
// Colors and materials come by name from picture/, so a picture change never touches this file.
|
|
3
3
|
// Shapes are clusters of smooth spheres: the reference reads as soft blobs, not facets. Shadow flags are set here (the engine does not guess them).
|
|
4
4
|
import { THREE, mergeColored } from '../../index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// URL parameters of the
|
|
1
|
+
// URL parameters of the perf island page. Import this file first in main.js: it rewrites word values into the forms the engine's own
|
|
2
2
|
// URL state understands (time=dusk -> 18:30, weather=雪 -> snow) before createEngine reads the URL. Same words as the style test page.
|
|
3
3
|
// time day | dusk | night (白天 黄昏 夜晚), or HH:MM weather clear | snow (晴 雪), or any engine weather name
|
|
4
4
|
// view overview | flock | field | river | rim (总览 羊群 麦田 河 边缘)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
// The picture of
|
|
2
|
+
// The picture of perf island: wiring only. Each part writes plain three.js from the signals; one onRender drives them all.
|
|
3
3
|
import { EXPOSURE, TONE_MAPPING } from './palette.js';
|
|
4
4
|
import { createLights } from './lights.js';
|
|
5
5
|
import { createMaterials } from './materials.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
//
|
|
2
|
+
// Perf island palette: every color and key value of the picture, one copy. A soft painted diorama: few flat colors, soft shadows, a pale warm
|
|
3
3
|
// backdrop with no horizon. The other files here read these; the island's shape is the game's terrain() in ../main.js, never here.
|
|
4
4
|
import { THREE } from '../../../index.js';
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ export const COLORS = { leaf: 0x6fa64a, leafLight: 0x8fbf5c, bark: 0x8a6448, woo
|
|
|
8
8
|
|
|
9
9
|
/** How the ground is colored, spread into terrain({...}) in main.js: the workers bake these into the chunks, so they go in at the start */
|
|
10
10
|
export const GROUND = {
|
|
11
|
-
shading: /** @type {const} */ ('texture'), colorResolution: 256, // crisp river bank and field edge without more triangles (recipe
|
|
11
|
+
shading: /** @type {const} */ ('texture'), colorResolution: 256, // crisp river bank and field edge without more triangles (recipe 53); 128 (0.5 m pixels) shows stairs up close
|
|
12
12
|
colors: { grassA: 0x92c062, grassB: 0x86b658, river: 0x6aa6d6, riverDeep: 0x5b97ca, wheatA: 0xdcae48, wheatB: 0xd2a442, earth: 0xb98d64, rock: 0x94705a },
|
|
13
13
|
biomeColors: { grass: ['grassA', 'grassB'], river: ['river', 'riverDeep'], wheat: ['wheatA', 'wheatB'], cliff: ['earth'], rock: ['rock'] },
|
|
14
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Named camera positions of the
|
|
1
|
+
// Named camera positions of the perf island. Same name = same framing every time, so two screenshots differ only by time or weather.
|
|
2
2
|
// The island is centred on (0, 0) and is about 60 m across; positions are [x, y, z] in world space.
|
|
3
3
|
export const VIEWS = {
|
|
4
4
|
overview: { pos: [0, 36, 48], look: [0, -1, 0] }, // the whole island floating on the backdrop, from the south, a little above
|
|
@@ -30,6 +30,7 @@ Not used yet (check these before writing the system yourself):
|
|
|
30
30
|
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
31
31
|
- interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
|
|
32
32
|
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
33
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
33
34
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
34
35
|
- templates: reusable objects placed from content: content/templates.js + props { template } (node_modules/threedog/docs/recipes/30-templates.md)
|
|
35
36
|
|
package/examples/rc2d/GAMEMAP.md
CHANGED
|
@@ -12,7 +12,7 @@ None yet, write them in `DESIGN.md` (why it is designed this way, what not to ch
|
|
|
12
12
|
## Engine modules (engine.use)
|
|
13
13
|
|
|
14
14
|
- createEngine: { lights: false, ui: { loading: false }, saveKey: 'threedog-rc2d' }
|
|
15
|
-
- fixedCamera ({ shots: { top
|
|
15
|
+
- fixedCamera ({ shots: { top: { position: [0, 40, 0.001], lookAt: [0, 0, 0], projection: 'orthographic', size: 30…)
|
|
16
16
|
|
|
17
17
|
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
18
18
|
|
|
@@ -26,6 +26,7 @@ Not used yet (check these before writing the system yourself):
|
|
|
26
26
|
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
27
27
|
- interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
|
|
28
28
|
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
29
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
29
30
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
30
31
|
- templates: reusable objects placed from content: content/templates.js + props { template } (node_modules/threedog/docs/recipes/30-templates.md)
|
|
31
32
|
|
|
@@ -35,7 +36,7 @@ content/*.js is content data: how to write it in `node_modules/threedog/docs/rec
|
|
|
35
36
|
|
|
36
37
|
| File | Lines | Description |
|
|
37
38
|
|---|---|---|
|
|
38
|
-
| main.js |
|
|
39
|
+
| main.js | 54 | @ts-check 2D radiance cascades demo (page /rc2d.html): a top-down street at night. Street lamps, li… |
|
|
39
40
|
| picture/index.js | 19 | @ts-check The picture of the rc2d demo: wiring only. |
|
|
40
41
|
| picture/lights.js | 12 | @ts-check The scene's own light is one dim ambient; everything else on the street is lit by the cas… |
|
|
41
42
|
| picture/materials.js | 19 | @ts-check Materials by name. An emitter is a black surface with an emissive: rc2d.js reads emissive… |
|
package/examples/rc2d/main.js
CHANGED
|
@@ -9,9 +9,7 @@ import { createPicture } from './picture/index.js';
|
|
|
9
9
|
|
|
10
10
|
const url = new URLSearchParams(location.search);
|
|
11
11
|
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), lights: false, ui: { loading: false }, saveKey: 'threedog-rc2d' });
|
|
12
|
-
|
|
13
|
-
const top = /** @type {any} */ ({ position: [0, 40, 0.001], lookAt: [0, 0, 0], projection: 'orthographic', size: 30 });
|
|
14
|
-
engine.use(fixedCamera({ shots: { top }, start: 'top' }));
|
|
12
|
+
engine.use(fixedCamera({ shots: { top: { position: [0, 40, 0.001], lookAt: [0, 0, 0], projection: 'orthographic', size: 30 } }, start: 'top' }));
|
|
15
13
|
|
|
16
14
|
const cascades = url.get('cascades');
|
|
17
15
|
const picture = createPicture(engine, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"files":{"content/items.js":{"kind":"items","mtime":
|
|
1
|
+
{"version":1,"files":{"content/items.js":{"kind":"items","mtime":1793906610000,"from":0,"count":3,"indexIds":0,"positional":[]},"content/npcs.js":{"kind":"npcs","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/places.js":{"kind":"places","mtime":1793906610000,"from":0,"count":2,"indexIds":0,"positional":[]},"content/props.js":{"kind":"props","mtime":1793906610000,"from":0,"count":12,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793906610000,"from":0,"count":6,"indexIds":0,"positional":[]},"content/vegetation.js":{"kind":"vegetation","mtime":1793906610000,"from":0,"count":5,"indexIds":0,"positional":[]}},"ids":{"apple":[{"file":"content/items.js","kind":"items","line":3,"placed":false}],"key":[{"file":"content/items.js","kind":"items","line":4,"placed":false}],"wood":[{"file":"content/items.js","kind":"items","line":5,"placed":false},{"file":"content/props.js","kind":"props","line":10,"placed":true}],"guide":[{"file":"content/npcs.js","kind":"npcs","line":3,"placed":false}],"stage":[{"file":"content/places.js","kind":"places","line":3,"placed":false}],"water":[{"file":"content/places.js","kind":"places","line":4,"placed":false}],"pine":[{"file":"content/props.js","kind":"props","line":4,"placed":true}],"round-tree":[{"file":"content/props.js","kind":"props","line":5,"placed":true}],"rock":[{"file":"content/props.js","kind":"props","line":6,"placed":true}],"flower-a":[{"file":"content/props.js","kind":"props","line":7,"placed":true}],"flower-b":[{"file":"content/props.js","kind":"props","line":8,"placed":true}],"flower-c":[{"file":"content/props.js","kind":"props","line":9,"placed":true}],"stone":[{"file":"content/props.js","kind":"props","line":11,"placed":true}],"metal":[{"file":"content/props.js","kind":"props","line":12,"placed":true}],"glass":[{"file":"content/props.js","kind":"props","line":13,"placed":true}],"shadow-stage":[{"file":"content/props.js","kind":"props","line":14,"placed":true}],"room":[{"file":"content/props.js","kind":"props","line":15,"placed":true},{"file":"content/templates.js","kind":"templates","line":8,"placed":false}],"woodBlock":[{"file":"content/templates.js","kind":"templates","line":3,"placed":false}],"stoneBlock":[{"file":"content/templates.js","kind":"templates","line":4,"placed":false}],"metalBall":[{"file":"content/templates.js","kind":"templates","line":5,"placed":false}],"glassPanes":[{"file":"content/templates.js","kind":"templates","line":6,"placed":false}],"shadowStage":[{"file":"content/templates.js","kind":"templates","line":7,"placed":false}],"松树":[{"file":"content/vegetation.js","kind":"vegetation","line":4,"placed":false}],"圆树":[{"file":"content/vegetation.js","kind":"vegetation","line":10,"placed":false}],"石头":[{"file":"content/vegetation.js","kind":"vegetation","line":16,"placed":false}],"草":[{"file":"content/vegetation.js","kind":"vegetation","line":20,"placed":false}],"野花":[{"file":"content/vegetation.js","kind":"vegetation","line":25,"placed":false}]}}
|
|
@@ -24,8 +24,8 @@ None yet, write them in `DESIGN.md` (why it is designed this way, what not to ch
|
|
|
24
24
|
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
25
25
|
|
|
26
26
|
- world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
|
|
27
|
-
- terrain: `node_modules/threedog/docs/recipes/
|
|
28
|
-
- vegetation: `node_modules/threedog/docs/recipes/36-
|
|
27
|
+
- terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
|
|
28
|
+
- vegetation: `node_modules/threedog/docs/recipes/36-ground-plants.md` · `node_modules/threedog/docs/api/vegetation.md`
|
|
29
29
|
- calendar: `node_modules/threedog/docs/recipes/06-clock-events.md` · `node_modules/threedog/docs/api/calendar.md`
|
|
30
30
|
- sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
|
|
31
31
|
- weather: `node_modules/threedog/docs/recipes/44-water-weather-hooks.md` · `node_modules/threedog/docs/api/weather.md`
|
|
@@ -39,6 +39,7 @@ Not used yet (check these before writing the system yourself):
|
|
|
39
39
|
|
|
40
40
|
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
41
41
|
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
42
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
42
43
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
43
44
|
|
|
44
45
|
## Files
|
|
@@ -43,7 +43,7 @@ export function applyContactShadows(engine, { sun, hemi, ...opts }) {
|
|
|
43
43
|
};
|
|
44
44
|
shadow([-p.extent, p.extent, p.extent, -p.extent], p.mapSize, p.normalBias, p.bias);
|
|
45
45
|
if (hemi) hemi.intensity *= p.fill;
|
|
46
|
-
const aoPass = p.ao ? engine.post.add(ao({
|
|
46
|
+
const aoPass = p.ao ? engine.post.add(ao({ radius: p.aoRadius, intensity: p.aoIntensity }), { name: 'ao' }) : null;
|
|
47
47
|
return {
|
|
48
48
|
remove() {
|
|
49
49
|
shadow(saved.box, saved.mapSize, saved.normalBias, saved.bias);
|
|
@@ -34,7 +34,7 @@ for (const [x, z] of [[-0.55, -0.35], [0.55, -0.35], [-0.55, 0.35], [0.55, 0.35]
|
|
|
34
34
|
const cup = add(new THREE.CylinderGeometry(0.04, 0.035, 0.1, 24), mat.cup, 0.2, 0.75 + 0.05, 0.1);
|
|
35
35
|
add(new THREE.SphereGeometry(0.07, 24, 16), mat.ball, -0.25, 0.75 + 0.07, -0.1);
|
|
36
36
|
// a small object on the ground, where floating is easiest to see
|
|
37
|
-
|
|
37
|
+
add(new THREE.BoxGeometry(0.12, 0.12, 0.12), mat.block, 1.1, 0.06, 0.6);
|
|
38
38
|
// the crate stack: one static merged geometry with baked vertex AO (darker at the floor and between crates). Tessellated boxes: AO is per vertex
|
|
39
39
|
const crate = (/** @type {number} */ s, /** @type {number} */ x, /** @type {number} */ y, /** @type {number} */ z) => new THREE.BoxGeometry(s, s, s, 6, 6, 6).translate(x, y + s / 2, z);
|
|
40
40
|
const stack = mergeGeometries([crate(0.6, 0, 0, 0), crate(0.6, 0.62, 0, 0.05), crate(0.45, 0.3, 0.6, 0)]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Technique example: interior light (page /interior-light.html, README.md next to this file). A neutral gray room (8 x 6 m, 3 m high) with a
|
|
3
3
|
// window in the west wall and a door in the south wall. One skill: lighting a room from outside (sun through the opening, sky light through the
|
|
4
4
|
// window), filling the shadowed side with bounce, the exposure change between outside and inside, and lamps at night.
|
|
5
|
-
// (time and view are the engine's own URL scenario keys, see core/UrlState.js: page params use other names)
|
|
5
|
+
// (time and view are the engine's own URL scenario keys, see core/inspect/UrlState.js: page params use other names)
|
|
6
6
|
// URL: ?night=1 ?cam=inside|doorway|outside ?fill=probes|light|none ?area=0 (no window area light) ?leak=1 (keep outdoor ambient indoors)
|
|
7
7
|
// Test page for tests/specs/techniques-light.mjs: window.interiorTest = { THREE, ready, points, picture }. Shapes only here; the whole picture is picture/.
|
|
8
8
|
import { createEngine, sky, fixedCamera, THREE } from 'threedog';
|
|
@@ -4,8 +4,10 @@ Modular buildings on a grid: parameterized wall / window / door / roof / trim mo
|
|
|
4
4
|
|
|
5
5
|
A kit of building pieces made in code, snapped to a grid and assembled into buildings and whole streets, with the colours and materials left to
|
|
6
6
|
the game. The pieces are plain on purpose: the same kit draws a cozy town, a gray block-out or a cold sci-fi row by swapping one set of
|
|
7
|
-
materials and one set of trim profiles.
|
|
8
|
-
|
|
7
|
+
materials and one set of trim profiles. `threedog examples pull modular-building` copies this README and `kit.js`, the whole technique: import `kit.js` from your game
|
|
8
|
+
and give it your materials (the code below shows how). The engine never imports this folder; change anything. The engine repository also has a demo page next to them,
|
|
9
|
+
which a pull does not copy: `main.js` and `picture/`, opened at `/modular-building.html` with `npm run dev` (`?set=gray|warm|cool`, `seed=1`, `count=10`,
|
|
10
|
+
`view=street|close`, `batch=0|merge`). Nothing in a game depends on it.
|
|
9
11
|
|
|
10
12
|
## The principle
|
|
11
13
|
A town reads from far to near: skyline first, then the rhythm of openings, then trim, then small detail. A grid makes every piece fit every
|
|
@@ -53,9 +55,8 @@ vanish at that distance? Does anything flicker at seams when the camera moves?
|
|
|
53
55
|
- **Merged hero block**: a fixed set piece merged once for the fewest draws, when it never changes.
|
|
54
56
|
|
|
55
57
|
## The engine helper (optional convenience)
|
|
56
|
-
`kit.js` is the kit: modules, assembler, manifest entries; it imports only `three` and `three/addons`.
|
|
57
|
-
picture in plain three.js (lights, tone curve, one Lambert material per slot,
|
|
58
|
-
three ways (gray block-out, warm with soft cove trims, cool with hard stepped trims and faintly emissive frames; the two coloured
|
|
58
|
+
`kit.js` is the kit: modules, assembler, manifest entries; it imports only `three` and `three/addons`. The demo page in the engine repository (not in a pull)
|
|
59
|
+
has its picture in plain three.js (lights, tone curve, one Lambert material per slot) and builds the same seed three ways (gray block-out, warm with soft cove trims, cool with hard stepped trims and faintly emissive frames; the two coloured
|
|
59
60
|
sets are demo values, not advice). In the kit, the block-out stage is `facade` strings of `.` (blank walls) and `roof`. A style is the slot
|
|
60
61
|
materials (`wall`, `trim`, `roof`, `frame`, `glass`, `accent`, `awning`, `sign`) plus `profiles` plus `windows`. The only textures are gray
|
|
61
62
|
masks (awning stripes, sign text) tinted by the slot material's colour, so a material swap recolours them too. `street` mirrors upper floors
|
|
@@ -119,7 +120,7 @@ Limits:
|
|
|
119
120
|
- Footprints are rectangles of cells (`width` x `depth`); an L-shaped building needs `building` extended to take a cell list (two buildings
|
|
120
121
|
with `gap: 0` meet wall to wall, and their corner pilasters then overlap).
|
|
121
122
|
- Gable ridges run along the building's width; hip roofs, dormers and balconies are not in the kit (each is one more module).
|
|
122
|
-
- The test is `
|
|
123
|
+
- The test is `threedog test "modular building"` (tests/specs/modular-building.mjs): determinism per seed, grid snapping without gaps,
|
|
123
124
|
shared geometry, batching under 400 draw calls, params changing shape, the optional AO pass.
|
|
124
125
|
|
|
125
126
|
Sources: written for this example; no code copied. Background: the grid-snapped kit of reusable pieces is common modular level design practice
|
|
@@ -5,6 +5,6 @@ import { LINE, OUTLINE } from './palette.js';
|
|
|
5
5
|
|
|
6
6
|
/** @param {any} engine */
|
|
7
7
|
export function createPost(engine) {
|
|
8
|
-
engine.post.add(outline({
|
|
8
|
+
engine.post.add(outline({ color: LINE, ...OUTLINE, offLayer: OUTLINE_OFF_LAYER }), { name: 'outline', slot: 'hdr' });
|
|
9
9
|
return { offLayer: OUTLINE_OFF_LAYER };
|
|
10
10
|
}
|
|
@@ -69,7 +69,7 @@ Rules (correctness):
|
|
|
69
69
|
- **Leave the character root alone.** The engine owns `ch.root` position and facing; the animator moves only parts under it.
|
|
70
70
|
- The engine's own rig code still bobs `rig.body` before `onPose` runs; writing `body.position.y` and `rotation.x` in `onPose` replaces that.
|
|
71
71
|
|
|
72
|
-
Verify: `
|
|
72
|
+
Verify: `threedog test "procedural animation"` (tests/specs/procedural-animation.mjs): legs swing while moving and cycle faster at a higher
|
|
73
73
|
speed, they return to rest at idle, the body returns to its rest height, the character does not creep, and the `states` hook's `sit` reaches the pose.
|
|
74
74
|
|
|
75
75
|
Sources: written for this example; no code copied. Background: distance-driven gait cycles, springs for secondary motion and squash and
|
|
@@ -28,6 +28,7 @@ Not used yet (check these before writing the system yourself):
|
|
|
28
28
|
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
29
29
|
- interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
|
|
30
30
|
- quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
31
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
31
32
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
32
33
|
- templates: reusable objects placed from content: content/templates.js + props { template } (node_modules/threedog/docs/recipes/30-templates.md)
|
|
33
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"files":{"content/actions.js":{"kind":"actions","mtime":
|
|
1
|
+
{"version":1,"files":{"content/actions.js":{"kind":"actions","mtime":1793906610000,"from":0,"count":4,"indexIds":0,"positional":[]},"content/audio.js":{"kind":"audio","mtime":1793906610000,"from":0,"count":3,"indexIds":0,"positional":[]},"content/bodies.js":{"kind":"bodies","mtime":1793906610000,"from":0,"count":8,"indexIds":0,"positional":[]},"content/containers.js":{"kind":"containers","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/dialogues.js":{"kind":"dialogues","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/items.js":{"kind":"items","mtime":1793906610000,"from":0,"count":4,"indexIds":0,"positional":[]},"content/npcs.js":{"kind":"npcs","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/pickups.js":{"kind":"pickups","mtime":1793906610000,"from":0,"count":8,"indexIds":8,"positional":[0,1,2,3,4,5,6,7]},"content/places.js":{"kind":"places","mtime":1793906610000,"from":0,"count":3,"indexIds":0,"positional":[]},"content/props.js":{"kind":"props","mtime":1793906610000,"from":0,"count":8,"indexIds":0,"positional":[]},"content/quests.js":{"kind":"quests","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793906610000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/vegetation.js":{"kind":"vegetation","mtime":1793906610000,"from":0,"count":5,"indexIds":0,"positional":[]}},"ids":{"save":[{"file":"content/actions.js","kind":"actions","line":4,"placed":false}],"load":[{"file":"content/actions.js","kind":"actions","line":5,"placed":false}],"kick":[{"file":"content/actions.js","kind":"actions","line":6,"placed":false}],"chop":[{"file":"content/actions.js","kind":"actions","line":7,"placed":false}],"sounds":[{"file":"content/audio.js","kind":"audio","line":7,"placed":false}],"ambience":[{"file":"content/audio.js","kind":"audio","line":14,"placed":false}],"footsteps":[{"file":"content/audio.js","kind":"audio","line":23,"placed":false}],"crate-0":[{"file":"content/bodies.js","kind":"bodies","line":4,"placed":false}],"crate-1":[{"file":"content/bodies.js","kind":"bodies","line":5,"placed":false}],"crate-2":[{"file":"content/bodies.js","kind":"bodies","line":6,"placed":false}],"crate-3":[{"file":"content/bodies.js","kind":"bodies","line":7,"placed":false}],"crate-4":[{"file":"content/bodies.js","kind":"bodies","line":8,"placed":false}],"crate-5":[{"file":"content/bodies.js","kind":"bodies","line":9,"placed":false}],"ball":[{"file":"content/bodies.js","kind":"bodies","line":10,"placed":false}],"barrel":[{"file":"content/bodies.js","kind":"bodies","line":11,"placed":false}],"fisher-basket":[{"file":"content/containers.js","kind":"containers","line":3,"placed":false}],"fisher":[{"file":"content/dialogues.js","kind":"dialogues","line":4,"placed":false},{"file":"content/npcs.js","kind":"npcs","line":3,"placed":false}],"film":[{"file":"content/items.js","kind":"items","line":3,"placed":false}],"berry":[{"file":"content/items.js","kind":"items","line":4,"placed":false}],"feather":[{"file":"content/items.js","kind":"items","line":5,"placed":false}],"wood":[{"file":"content/items.js","kind":"items","line":6,"placed":false}],"pickup:feather:0":[{"file":"content/pickups.js","kind":"pickups","line":3,"placed":true}],"pickup:berry:1":[{"file":"content/pickups.js","kind":"pickups","line":4,"placed":true}],"pickup:berry:2":[{"file":"content/pickups.js","kind":"pickups","line":5,"placed":true}],"pickup:feather:3":[{"file":"content/pickups.js","kind":"pickups","line":6,"placed":true}],"pickup:berry:4":[{"file":"content/pickups.js","kind":"pickups","line":7,"placed":true}],"pickup:berry:5":[{"file":"content/pickups.js","kind":"pickups","line":8,"placed":true}],"pickup:feather:6":[{"file":"content/pickups.js","kind":"pickups","line":9,"placed":true}],"pickup:berry:7":[{"file":"content/pickups.js","kind":"pickups","line":10,"placed":true}],"home":[{"file":"content/places.js","kind":"places","line":3,"placed":false}],"river":[{"file":"content/places.js","kind":"places","line":4,"placed":false}],"water":[{"file":"content/places.js","kind":"places","line":5,"placed":false}],"prop:pine:0":[{"file":"content/props.js","kind":"props","line":4,"placed":true}],"prop:pine:1":[{"file":"content/props.js","kind":"props","line":5,"placed":true}],"prop:roundTree:2":[{"file":"content/props.js","kind":"props","line":6,"placed":true}],"prop:rock:3":[{"file":"content/props.js","kind":"props","line":7,"placed":true}],"prop:rock:4":[{"file":"content/props.js","kind":"props","line":8,"placed":true}],"prop:flower:5":[{"file":"content/props.js","kind":"props","line":9,"placed":true}],"prop:flower:6":[{"file":"content/props.js","kind":"props","line":10,"placed":true}],"cabin":[{"file":"content/props.js","kind":"props","line":11,"placed":true},{"file":"content/templates.js","kind":"templates","line":4,"placed":false}],"first-light":[{"file":"content/quests.js","kind":"quests","line":4,"placed":false}],"松树":[{"file":"content/vegetation.js","kind":"vegetation","line":5,"placed":false}],"圆树":[{"file":"content/vegetation.js","kind":"vegetation","line":11,"placed":false}],"石头":[{"file":"content/vegetation.js","kind":"vegetation","line":17,"placed":false}],"草":[{"file":"content/vegetation.js","kind":"vegetation","line":21,"placed":false}],"野花":[{"file":"content/vegetation.js","kind":"vegetation","line":26,"placed":false}]}}
|
|
@@ -30,8 +30,8 @@ Content: actions 4 · audio 3 · containers 1 · dialogues 1 · items 4 · npcs
|
|
|
30
30
|
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
31
31
|
|
|
32
32
|
- world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
|
|
33
|
-
- terrain: `node_modules/threedog/docs/recipes/
|
|
34
|
-
- vegetation: `node_modules/threedog/docs/recipes/36-
|
|
33
|
+
- terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
|
|
34
|
+
- vegetation: `node_modules/threedog/docs/recipes/36-ground-plants.md` · `node_modules/threedog/docs/api/vegetation.md`
|
|
35
35
|
- calendar: `node_modules/threedog/docs/recipes/06-clock-events.md` · `node_modules/threedog/docs/api/calendar.md`
|
|
36
36
|
- sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
|
|
37
37
|
- weather: `node_modules/threedog/docs/recipes/44-water-weather-hooks.md` · `node_modules/threedog/docs/api/weather.md`
|
|
@@ -43,6 +43,7 @@ Content: actions 4 · audio 3 · containers 1 · dialogues 1 · items 4 · npcs
|
|
|
43
43
|
|
|
44
44
|
Not used yet (check these before writing the system yourself):
|
|
45
45
|
|
|
46
|
+
- swarm: many same-kind moving things (shots, crowds, flocks, debris) in typed arrays, drawn as one mesh: `swarm()` (node_modules/threedog/docs/recipes/65-swarm.md)
|
|
46
47
|
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
47
48
|
|
|
48
49
|
## Files
|
|
@@ -119,7 +120,7 @@ Starting inventory: film×12. Pickups: 8: feather×3, berry×5 (respawn after 12
|
|
|
119
120
|
- Place river: nearest riverside to the cabin (found at startup; the old fisherman goes here in the morning)
|
|
120
121
|
- Place water: the water just past that riverside (found at startup; the barrel floats here)
|
|
121
122
|
|
|
122
|
-
## Conditions
|
|
123
|
+
## Conditions the game adds (content/rules.js)
|
|
123
124
|
|
|
124
125
|
- Condition **timeAfter** (clock): the day has passed this clock time
|
|
125
126
|
|
|
@@ -9,7 +9,7 @@ import { AMBIENT_PEAK, CLOUDS, FOG_NEAR, OVERCAST, sampleSky, skyNow } from './p
|
|
|
9
9
|
export function createSky(engine) {
|
|
10
10
|
const { scene, uniforms: E } = engine, U = engine.sky.uniforms, weather = engine.weather;
|
|
11
11
|
const fog = scene.fog = new THREE.Fog(0x000000, 70, 240);
|
|
12
|
-
U.uCloudCover.value = CLOUDS.coverage; U.
|
|
12
|
+
U.uCloudCover.value = CLOUDS.coverage; U.uSkyCloudScale.value = CLOUDS.scale; U.uSkyCloudSpeed.value.set(...CLOUDS.speed);
|
|
13
13
|
U.uCloudColor.value.set(CLOUDS.color); U.uCloudShade.value.set(CLOUDS.shade);
|
|
14
14
|
E.uCloudShadow.value = CLOUDS.groundShadow;
|
|
15
15
|
|
package/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ import type { ambience } from './types/generated/modules/ambience/Ambience';
|
|
|
46
46
|
import type { debug } from './types/generated/modules/debug/DebugPanel';
|
|
47
47
|
|
|
48
48
|
// Types are exported too, so game code can write JSDoc: /** @type {import('threedog').DialogueScript} */
|
|
49
|
-
export
|
|
49
|
+
export type { ColorLike, Vec3Like, PositionLike, XZ, DirXZ, Range, EaseName, Ease, Loose, Handle } from './types/common'; // a list, not *: three.js's own types come from 'three'
|
|
50
50
|
export * from './types/core';
|
|
51
51
|
export * from './types/world';
|
|
52
52
|
export * from './types/physics';
|
|
@@ -60,7 +60,7 @@ export * from './types/nav';
|
|
|
60
60
|
/** three.js itself (the same instance the engine uses; typed by @types/three) */
|
|
61
61
|
export * as THREE from 'three';
|
|
62
62
|
|
|
63
|
-
/** Create an engine (core only). canvas is required
|
|
63
|
+
/** Create an engine (core only). canvas is required */
|
|
64
64
|
export function createEngine(opts: EngineOptions): Engine;
|
|
65
65
|
/** The picture slots: what each one is and which describe('picture').picture.writers names it covers (a name ending in '.' covers everything under it) */
|
|
66
66
|
export const PICTURE_SLOTS: Readonly<Record<PictureSlot, { readonly what: string; readonly values: readonly string[] }>>;
|
|
@@ -82,7 +82,7 @@ export interface OpenWorldOptions {
|
|
|
82
82
|
flatten?: FlattenZone[];
|
|
83
83
|
/** Start time 0-1 */
|
|
84
84
|
time?: number;
|
|
85
|
-
/**
|
|
85
|
+
/** Calendar seconds per day (default 360) */
|
|
86
86
|
dayLength?: number;
|
|
87
87
|
/** Starting weather name, false (no weather module) or weather() options */
|
|
88
88
|
weather?: WeatherName | (string & {}) | Part<typeof weather>;
|
|
@@ -186,6 +186,8 @@ export function level(opts?: LevelOptions): ModuleDef<Level>;
|
|
|
186
186
|
export function triggers(opts?: TriggersOptions): ModuleDef<Triggers>;
|
|
187
187
|
// Migrated: particles() is generated from the JSDoc in modules/particles/Particles.js
|
|
188
188
|
export { particles } from './types/generated/modules/particles/Particles';
|
|
189
|
+
// swarm() and the Swarm class are generated from the JSDoc in modules/swarm/Swarm.js
|
|
190
|
+
export { swarm } from './types/generated/modules/swarm/Swarm';
|
|
189
191
|
/** Settings menu -> engine.settings */
|
|
190
192
|
export function settings(opts?: SettingsOptions): ModuleDef<Settings>;
|
|
191
193
|
// Migrated: music() is generated from the JSDoc in modules/music/Music.js
|
|
@@ -209,8 +211,6 @@ export { hud } from './types/generated/modules/hud/index';
|
|
|
209
211
|
|
|
210
212
|
/** Screen coordinates (-1..1) -> point on the ground; null if the ray misses the ground */
|
|
211
213
|
export function screenToGround(engine: Engine, ndcX: number, ndcY: number, opts?: { maxDistance?: number }): Vector3 | null;
|
|
212
|
-
/** All easing functions: name -> function */
|
|
213
|
-
export const EASINGS: Record<EaseName, (t: number) => number>;
|
|
214
214
|
/**
|
|
215
215
|
* A grid of numbers (height, moisture, density, walkable...) as a function (x, z) -> value. data[j * width + i] sits at origin + (i, j) * cell.
|
|
216
216
|
* interp 'nearest' = flat steps, 'linear' (default) = bilinear, 'cubic' = smooth (clamp: true avoids overshoot). Outside: edge value, or `outside`.
|
|
@@ -223,6 +223,7 @@ export function ease(e: Ease): (t: number) => number;
|
|
|
223
223
|
* Warn once about unknown keys in extensible data (your item / record definitions where players or mods add their own fields), with a
|
|
224
224
|
* "did you mean" hint. Options bags go through readParams instead (an unknown key throws in dev). loose only warns on near-misses.
|
|
225
225
|
* @example checkOptions('crops.define()', def, ['grow', 'yield', 'season'], { loose: true });
|
|
226
|
+
* @experimental
|
|
226
227
|
*/
|
|
227
228
|
export function checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean }): void;
|
|
228
229
|
/**
|
|
@@ -272,10 +273,10 @@ export type { UIPart, UIPartFactory, UIPartValue, UIPartDef, UIParts, UITitleIte
|
|
|
272
273
|
export function parseClock(clock: string | number, hoursPerDay?: number): number;
|
|
273
274
|
/** Fraction of the day -> 'HH:MM': formatClock(0.75) = '18:00' */
|
|
274
275
|
export function formatClock(t: number, hoursPerDay?: number): string;
|
|
275
|
-
/** Is time t (0-1, e.g. calendar.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by calendar.between and the audio rule condition { time: [from, to] } */
|
|
276
|
+
/** Is time t (0-1, e.g. calendar.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by calendar.between and the audio rule condition { time: [from, to] } @experimental */
|
|
276
277
|
export function inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number): boolean;
|
|
277
278
|
|
|
278
|
-
// ---------- Target selection (core/targeting.js, pure functions) ----------
|
|
279
|
+
// ---------- Target selection (core/scene/targeting.js, pure functions) ----------
|
|
279
280
|
/**
|
|
280
281
|
* Options of pickTarget / switchTarget: radius meters (15); cone half-angle in radians (1.4); close meters inside which angle is ignored (2.5);
|
|
281
282
|
* angleWeight meters per radian off the view (6); blocked(c) true skips c (occlusion); at(c) reads a candidate's position (default c.position ?? c)
|