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,7 +1,5 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/sky/Sky.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
/** @import { Object3D, Vector3 } from '../../../common' */
|
|
3
|
-
/** @import { SkyOptions } from '../../../world' */
|
|
4
|
-
/** @import { Handle } from '../../../common' */
|
|
5
3
|
/** engine.sky */
|
|
6
4
|
export class Sky {
|
|
7
5
|
/**
|
|
@@ -26,10 +24,15 @@ export class Sky {
|
|
|
26
24
|
top: any;
|
|
27
25
|
/** Horizon color over the keyframes, any THREE.Color input (null = the keyframes); read each frame. The color drawn: engine.uniforms.uSkyHorizon @type {any} */
|
|
28
26
|
horizon: any;
|
|
27
|
+
/**
|
|
28
|
+
* The dome's { value } objects, live on both renderers: the built-in ones (the same objects as engine.uniforms where the names match) and the uniforms
|
|
29
|
+
* given to engine.sky.clouds() and engine.sky.layer(), which join here once the call has run @type {Record<string, { value: any }>}
|
|
30
|
+
*/
|
|
31
|
+
uniforms: Record<string, {
|
|
32
|
+
value: any;
|
|
33
|
+
}>;
|
|
29
34
|
/** Dome mesh @type {Object3D} */
|
|
30
35
|
dome: THREE.Object3D;
|
|
31
|
-
/** Sun direction (unit vector toward the sun) @type {Vector3} */
|
|
32
|
-
sunDir: THREE.Vector3;
|
|
33
36
|
/**
|
|
34
37
|
* Sun orbit: tilt = north-south tilt, sway = east-west swing, distance = light distance (meters) @type {{ tilt: number, sway: number, distance: number }}
|
|
35
38
|
*/
|
|
@@ -46,6 +49,13 @@ export class Sky {
|
|
|
46
49
|
* @returns {void}
|
|
47
50
|
*/
|
|
48
51
|
keyframes(rows: any[][]): void;
|
|
52
|
+
set sunDir(v: THREE.Vector3);
|
|
53
|
+
/**
|
|
54
|
+
* Sun direction (unit vector toward the sun): the same vector as engine.uniforms.uSunDir. Computed each frame from the time and orbit until a game writes either,
|
|
55
|
+
* then the value is the game's (the sun at a compass direction of your choice); engine.autoView.manual('sunDir', false) gives it back.
|
|
56
|
+
* @type {Vector3}
|
|
57
|
+
*/
|
|
58
|
+
get sunDir(): THREE.Vector3;
|
|
49
59
|
/**
|
|
50
60
|
* Your own cloud function on the dome: glsl defines `vec4 threedogClouds(vec3 dir, float time, vec3 sunDir, float night, vec3 lit, vec3 shade, float cover)`,
|
|
51
61
|
* tsl is its WebGPURenderer form (ctx) => vec4 node; each renderer needs its own form (modules/sky/clouds.js). null gives the built-in kind back.
|
|
@@ -75,24 +85,25 @@ export class Sky {
|
|
|
75
85
|
blend?: "mix" | "add";
|
|
76
86
|
} | null): void;
|
|
77
87
|
/**
|
|
78
|
-
* Replace or hide the dome: a skybox asset name (equirectangular panorama), a THREE.Texture / CubeTexture, or your own THREE.Object3D sky; null gives the dome back
|
|
88
|
+
* Replace or hide the dome: a skybox asset name (equirectangular panorama), a THREE.Texture / CubeTexture, or your own THREE.Object3D sky; null gives the dome back,
|
|
89
|
+
* false draws no sky (the scene shows its base background, the signals keep running).
|
|
79
90
|
* The engine never writes your object: it hides the dome, adds your object to the scene only when it has no parent, puts a plain texture's panorama
|
|
80
91
|
* mapping on a clone, and keeps feeding engine.uniforms (uSunDir, uWind ...).
|
|
81
92
|
* @example engine.sky.replace(new SkyMesh());
|
|
82
93
|
* @example engine.sky.replace(null);
|
|
83
|
-
* @param {string | import('three').Texture | Object3D | null} sky
|
|
94
|
+
* @param {string | import('three').Texture | Object3D | null | false} sky
|
|
84
95
|
* @returns {void}
|
|
85
96
|
*/
|
|
86
|
-
replace(sky: string | import("three").Texture | THREE.Object3D | null): void;
|
|
97
|
+
replace(sky: string | import("three").Texture | THREE.Object3D | null | false): void;
|
|
87
98
|
set backdrop(v: any);
|
|
88
99
|
/**
|
|
89
100
|
* One flat color in place of the dome, a THREE.Color while on, else null (sky({ backdrop }) starts with one). Set any THREE.Color input, null gives the dome back.
|
|
90
101
|
* @type {any}
|
|
91
102
|
*/
|
|
92
103
|
get backdrop(): any;
|
|
93
|
-
/** Time of day being drawn, 0-1: engine.calendar.timeOfDay, or fixedTime without a calendar. Read-only: the time itself is the calendar's */
|
|
104
|
+
/** Time of day being drawn, 0-1: engine.calendar.timeOfDay, or fixedTime without a calendar. Read-only: the time itself is the calendar's @experimental */
|
|
94
105
|
get drawnTime(): any;
|
|
95
|
-
/** Sun elevation -1 (midnight) ... 0 (horizon) ... 1 (noon) of the drawn sun (the calendar's daylight is the gameplay value) */
|
|
106
|
+
/** Sun elevation -1 (midnight) ... 0 (horizon) ... 1 (noon) of the drawn sun (the calendar's daylight is the gameplay value) @experimental */
|
|
96
107
|
get sunHeight(): number;
|
|
97
108
|
/** Whether the drawn sun is above the horizon (picture functions: ({ sky }) => sky.isDay ? ...; gameplay reads engine.calendar.isDay) */
|
|
98
109
|
get isDay(): boolean;
|
|
@@ -100,7 +111,7 @@ export class Sky {
|
|
|
100
111
|
get daylight(): number;
|
|
101
112
|
/**
|
|
102
113
|
* Render the sky into an environment map. Only after this call is anything built: a PMREM target, rebuilt when the sky changed and interval seconds passed
|
|
103
|
-
* (default 1, 4
|
|
114
|
+
* (default 1, 4 on a low-tier device). With into, that object's .environment gets the map at each rebuild (a map you wrote there yourself stays); without it nothing
|
|
104
115
|
* is written anywhere and you read handle.texture. handle.remove() takes the map off and frees it. One at a time. Intensity and rotation are three.js: scene.environmentIntensity.
|
|
105
116
|
* @example const env = engine.sky.environment({ into: engine.scene });
|
|
106
117
|
* @example env.remove();
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/swarm/Swarm.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Module: many same-kind gameplay objects in typed arrays, drawn as one InstancedMesh each. After engine.use(swarm()), engine.swarm(options) makes one and returns a Swarm.
|
|
4
|
+
* Bullets, enemy crowds, pickups, debris. See recipes/65-swarm.md
|
|
5
|
+
* @example engine.use(swarm());
|
|
6
|
+
* const coins = engine.swarm({ name: 'coins', capacity: 500, geometry, material, fields: ['yaw'], save: true });
|
|
7
|
+
* @returns {import('../../../core').ModuleDef}
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
export function swarm(): import("../../../core").ModuleDef;
|
|
11
|
+
/** One swarm: what engine.swarm(options) returns. See the top of modules/swarm/Swarm.js for the handle / row rule */
|
|
12
|
+
export class Swarm {
|
|
13
|
+
/** Name given to engine.swarm @type {string} */ name: string;
|
|
14
|
+
/** Most objects alive at once @type {number} */ capacity: number;
|
|
15
|
+
/** Time channel of the onStep dt @type {string} */ channel: string;
|
|
16
|
+
/** Whether this swarm is kept in saves @type {boolean} */ saved: boolean;
|
|
17
|
+
/** Spawns refused because the swarm was full, since it was made @type {number} */ dropped: number;
|
|
18
|
+
/**
|
|
19
|
+
* The columns: data.x[row], data.y[row], data.z[row] (Float32Array), one Float64Array per field, so a field can hold a handle, and data.id[row], the handle of that row (Float64Array).
|
|
20
|
+
* Rows 0 to count - 1 are live. The same object onStep and near pass as d
|
|
21
|
+
* @type {SwarmData}
|
|
22
|
+
*/
|
|
23
|
+
data: SwarmData;
|
|
24
|
+
/** The swarm's plain THREE.InstancedMesh (null when made without geometry and material); instance index = row. castShadow, layers and the rest are yours @type {THREE.InstancedMesh | null} */
|
|
25
|
+
mesh: THREE.InstancedMesh | null;
|
|
26
|
+
/** Objects alive now @type {number} */
|
|
27
|
+
get count(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Add one object. Fields left out start at 0 (scale at 1, colour at white). Returns its handle, or -1 when the swarm is full: the object is not added,
|
|
30
|
+
* dropped goes up, and one [swarm-full] warning is printed. May be called from onStep and near callbacks; an object spawned there first moves in the next step
|
|
31
|
+
* @example const h = bullets.spawn({ x: 0, y: 1, z: 0, vx: 8, life: 2 });
|
|
32
|
+
* @param {Record<string, number>} [o] x, y, z, the fields, and color (a hex colour, with { color: true })
|
|
33
|
+
* @returns {number}
|
|
34
|
+
*/
|
|
35
|
+
spawn(o?: Record<string, number>): number;
|
|
36
|
+
/**
|
|
37
|
+
* Where a handle's object sits now, or -1 if it is gone. A row is good until the next removal outside a callback: read it, use it, drop it
|
|
38
|
+
* @example const i = enemies.row(target); if (i >= 0) aim(enemies.data.x[i], enemies.data.z[i]);
|
|
39
|
+
* @param {number} handle
|
|
40
|
+
* @returns {number}
|
|
41
|
+
*/
|
|
42
|
+
row(handle: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Remove an object by handle: d.id[i] inside a callback. False if it was already gone (safe to call twice; -1 from a full spawn too). A row passed
|
|
45
|
+
* by mistake throws [swarm-handle]. Inside onStep and near the object counts as gone at once (near and row skip it) and rows only move when the walk ends
|
|
46
|
+
* @example enemies.near(x, z, 2, (d, i) => { enemies.free(d.id[i]); });
|
|
47
|
+
* @param {number} handle
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
free(handle: number): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Set the one function that moves this swarm: fn(d, i, dt) for each live row, every fixed step, dt on the swarm's channel. Return false to remove the object;
|
|
53
|
+
* anything else keeps it. Returns a handle: h.remove() takes it off. Set it once at setup, not every step (a second one while one is set throws [swarm-step])
|
|
54
|
+
* @example bullets.onStep((d, i, dt) => { d.x[i] += d.vx[i] * dt; return (d.life[i] -= dt) > 0; });
|
|
55
|
+
* @param {SwarmRowFn} fn
|
|
56
|
+
* @returns {{ remove(): void }}
|
|
57
|
+
*/
|
|
58
|
+
onStep(fn: SwarmRowFn): {
|
|
59
|
+
remove(): void;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Visit the live objects within r meters of (x, z), height ignored: cb(d, i, dist2) with the row and the squared distance; cb returning false stops early. Returns
|
|
63
|
+
* how many were visited. The grid is built on the first query after things moved, so a swarm nobody queries pays nothing. Order is the same every run. Inside onStep it stays the
|
|
64
|
+
* grid of that step's first query: distances are exact, but a row that crossed a cell line since then can be missed for one step
|
|
65
|
+
* @example const hit = enemies.near(px, pz, 0.5, (d, i) => { enemies.free(d.id[i]); return false; });
|
|
66
|
+
* @param {number} x
|
|
67
|
+
* @param {number} z
|
|
68
|
+
* @param {number} r
|
|
69
|
+
* @param {(d: SwarmData, i: number, dist2: number) => (boolean | void)} cb
|
|
70
|
+
* @returns {number}
|
|
71
|
+
*/
|
|
72
|
+
near(x: number, z: number, r: number, cb: (d: SwarmData, i: number, dist2: number) => (boolean | void)): number;
|
|
73
|
+
/** Remove every object (their handles die for good). Inside a callback it applies when the walk ends */
|
|
74
|
+
clear(): void;
|
|
75
|
+
/** Remove this swarm: its mesh leaves the scene and its GPU buffers go. Geometry and material stay, they are the game's. The name is free again */
|
|
76
|
+
dispose(): void;
|
|
77
|
+
}
|
|
78
|
+
import type { SwarmData } from '../../../gameplay';
|
|
79
|
+
import type { SwarmRowFn } from '../../../gameplay';
|
|
80
|
+
import * as THREE from 'three';
|
|
@@ -9,16 +9,17 @@
|
|
|
9
9
|
export function timeline(opts?: TimelineOptions): ModuleDef<Timeline>;
|
|
10
10
|
/** engine.timeline */
|
|
11
11
|
export class Timeline {
|
|
12
|
-
/** Skip every cutscene immediately (set by scenario param cutscene=skip) @type {boolean} */
|
|
12
|
+
/** Skip every cutscene immediately (set by scenario param cutscene=skip) @type {boolean} @experimental */
|
|
13
13
|
skipAll: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Whether a cutscene is playing
|
|
16
16
|
* @returns {boolean}
|
|
17
|
+
* @experimental
|
|
17
18
|
*/
|
|
18
19
|
get playing(): boolean;
|
|
19
20
|
/**
|
|
20
21
|
* General tween (the only entry point for tweens in the engine): await engine.timeline.tween(mesh, { 'position.y': 2 }, { duration: 1, ease: 'outCubic' }); duration in seconds (default 1), ease default 'inOutCubic'; tween(mesh, to, 1) throws in dev.
|
|
21
|
-
* Returns a Promise (with finish() / remove())
|
|
22
|
+
* Returns a Promise (with finish() / remove()); a write that throws ends the tween and rejects it
|
|
22
23
|
* @param {any} target
|
|
23
24
|
* @param {TweenTo} to
|
|
24
25
|
* @param {{ duration?: number, ease?: Ease }} [opts]
|
|
@@ -29,13 +30,14 @@ export class Timeline {
|
|
|
29
30
|
ease?: Ease;
|
|
30
31
|
}): TweenPromise;
|
|
31
32
|
/**
|
|
32
|
-
* Play a timeline; resolves with {
|
|
33
|
+
* Play a timeline; resolves with { ending, error? } when it ends: 'finished', 'skipped', 'dropped' (a load, a new game or dispose took its state) or 'failed' (a step threw; error says what)
|
|
33
34
|
* @param {TimelineStep | TimelineStep[]} steps
|
|
34
35
|
* @param {TimelinePlayOptions} [opts]
|
|
35
|
-
* @returns {Promise<{
|
|
36
|
+
* @returns {Promise<{ ending: 'finished' | 'skipped' | 'dropped' | 'failed', error?: string }>}
|
|
36
37
|
*/
|
|
37
38
|
play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions): Promise<{
|
|
38
|
-
|
|
39
|
+
ending: "finished" | "skipped" | "dropped" | "failed";
|
|
40
|
+
error?: string;
|
|
39
41
|
}>;
|
|
40
42
|
/**
|
|
41
43
|
* Skip all (or one) playing timelines
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/weather/Weather.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
/**
|
|
3
|
-
* Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its picture (engine.weatherDraw, type 'picture';
|
|
3
|
+
* Weather: two modules for one engine.use: the state (engine.weather, type 'world') and its picture (engine.weatherDraw, type 'picture'; sky optional)
|
|
4
4
|
* @param {WeatherOptions} [opts]
|
|
5
5
|
* @returns {[ModuleDef<Weather>, ModuleDef<import('./weatherDraw.js').WeatherDraw>]}
|
|
6
6
|
* @example engine.use(sky(), weather({ types: presets.weather.temperate.types, start: 'clear' }))
|
|
@@ -17,26 +17,24 @@ export class Weather {
|
|
|
17
17
|
current: WeatherPreset;
|
|
18
18
|
/** Current weather name @type {string} */
|
|
19
19
|
name: string;
|
|
20
|
-
/**
|
|
21
|
-
auto: boolean;
|
|
22
|
-
/** Candidates for automatic weather (repeat a name to make it likelier) @type {string[]} */
|
|
20
|
+
/** Candidates for automatic weather (repeat a name to make it likelier) @type {string[]} @experimental */
|
|
23
21
|
autoPool: string[];
|
|
24
|
-
/** Automatic weather interval [min, max] seconds @type {number[]} */
|
|
22
|
+
/** Automatic weather interval [min, max] seconds @type {number[]} @experimental */
|
|
25
23
|
autoInterval: number[];
|
|
26
|
-
/** Transition seconds for automatic weather @type {number} */
|
|
24
|
+
/** Transition seconds for automatic weather @type {number} @experimental */
|
|
27
25
|
autoTransition: number;
|
|
28
|
-
/** Seconds to the first bolt (also after a load without a saved timer) @type {number} */
|
|
26
|
+
/** Seconds to the first bolt (also after a load without a saved timer) @type {number} @experimental */
|
|
29
27
|
lightningFirst: number;
|
|
30
|
-
/** [min, max] seconds between bolts while a type with lightning > 0.5 holds @type {number[]} */
|
|
28
|
+
/** [min, max] seconds between bolts while a type with lightning > 0.5 holds @type {number[]} @experimental */
|
|
31
29
|
lightningInterval: number[];
|
|
32
|
-
/** Strike picture: flash (1 at the strike, fading in a third of a second) -> sky flash amount. Write it at any time @type {(flash: number, engine: any) => number} */
|
|
30
|
+
/** Strike picture: flash (1 at the strike, fading in a third of a second) -> sky flash amount. Write it at any time @type {(flash: number, engine: any) => number} @experimental */
|
|
33
31
|
lightning: (flash: number, engine: any) => number;
|
|
34
32
|
/** Multiplies the sky flash of every strike; write it at any time @type {number} */
|
|
35
33
|
lightningBrightness: number;
|
|
36
34
|
/** Color the sky turns as a weather type raises grey: a THREE.Color, overcastColor.set(0x667788) changes it live @type {THREE.Color} */
|
|
37
35
|
overcastColor: THREE.Color;
|
|
38
36
|
/**
|
|
39
|
-
* The particle systems drawn now, by field: rain and snow when the table has them, plus what
|
|
37
|
+
* The particle systems drawn now, by field: rain and snow when the table has them, plus what defineField() added. Each has material (the plain three.js
|
|
40
38
|
* material: read it, or set your own, drawn as given; null gives the engine's back), uniforms ({ value } objects the engine writes each frame, a
|
|
41
39
|
* ShaderMaterial of yours shares them; uColor, uLen, uPx, uMaxPx, uSwayAmp are yours to write), spec (opacity, speed, slant, density are read each
|
|
42
40
|
* frame, plain writes), object (the three.js object). Empty when a game replaced the weather drawing
|
|
@@ -50,18 +48,18 @@ export class Weather {
|
|
|
50
48
|
* frame is weather.current[field], so they fade with the weather. spec takes the keys of weather({ rain }), or
|
|
51
49
|
* { create(engine, { area, count }) => { object, update?(amount, { camera, time, wind }) } } for a system of your own; null gives rain / snow back
|
|
52
50
|
* to weather({ rain, snow }) and removes any other field. Defining a field again replaces it. A field no type has throws with the table's fields
|
|
53
|
-
* @example engine.weather.
|
|
51
|
+
* @example engine.weather.defineField('ash', { shape: 'soft', color: 0x555555, size: 14, speed: 0.8, sway: 3 });
|
|
54
52
|
* @param {string} field
|
|
55
53
|
* @param {WeatherParticles | null} spec
|
|
56
54
|
* @returns {WeatherParticleSystem | null}
|
|
57
55
|
*/
|
|
58
|
-
|
|
56
|
+
defineField(field: string, spec: WeatherParticles | null): WeatherParticleSystem | null;
|
|
57
|
+
set auto(on: boolean);
|
|
59
58
|
/**
|
|
60
|
-
* Automatic weather on/off
|
|
61
|
-
* @
|
|
62
|
-
* @returns {void}
|
|
59
|
+
* Automatic weather on/off.
|
|
60
|
+
* @type {boolean}
|
|
63
61
|
*/
|
|
64
|
-
|
|
62
|
+
get auto(): boolean;
|
|
65
63
|
/**
|
|
66
64
|
* Switch weather. seconds: transition seconds, default 15; 0 switches at once (current is the new weather before the next step, so a
|
|
67
65
|
* screenshot or test right after shows all of it). Options in an object like every other engine call: set('rain', 20) throws
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/weather/weatherDraw.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
|
|
3
|
-
/** engine.weatherDraw: particles and picture effects of the current weather */
|
|
3
|
+
/** engine.weatherDraw: particles and picture effects of the current weather @experimental */
|
|
4
4
|
export class WeatherDraw {
|
|
5
5
|
/** Sky flash now, 1 at a strike (the weather:lightning event) fading to 0 @type {number} */
|
|
6
6
|
flash: number;
|
|
7
|
-
/** Default particle count per system (
|
|
7
|
+
/** Default particle count per system: weather({ particles }), else 6000 (3000 on low-tier devices) @type {number} */
|
|
8
8
|
particles: number;
|
|
9
|
-
/** Particle systems drawn now: field -> { field, object, material, uniforms, spec } (rain / snow when the table has them, plus fields engine.weather.
|
|
9
|
+
/** Particle systems drawn now: field -> { field, object, material, uniforms, spec } (rain / snow when the table has them, plus fields engine.weather.defineField adds) @type {Map<string, any>} */
|
|
10
10
|
systems: Map<string, any>;
|
|
11
11
|
}
|
|
@@ -12,7 +12,7 @@ export class World {
|
|
|
12
12
|
farMaxPerTick?: number;
|
|
13
13
|
buildPerFrame?: number;
|
|
14
14
|
});
|
|
15
|
-
/** All records: id → record (read-only; use set to change fields, move to change position) @type {Map<string, WorldRecord>} */
|
|
15
|
+
/** All records: id → record (read-only; use set to change fields, move to change position) @type {Map<string, WorldRecord>} @experimental */
|
|
16
16
|
records: Map<string, WorldRecord>;
|
|
17
17
|
/**
|
|
18
18
|
* Default distance (meters) for building models and counting as near; present / simulate can override it. Changing it at runtime affects those without
|
|
@@ -48,7 +48,7 @@ export class World {
|
|
|
48
48
|
* Add a record and return it (a plain object). kind is required; without id one is numbered automatically (kind#1, kind#2…, saved; `#` never appears in an
|
|
49
49
|
* authored id, so the two can never collide).
|
|
50
50
|
* opts.initial: initial record written in content (needs an id); saves only keep its changes and removal; if the id already exists the existing one is
|
|
51
|
-
* returned (content may load twice);
|
|
51
|
+
* returned (content may load twice), after taking a new position / rot from the content unless play moved it;
|
|
52
52
|
* returns null if the save removed it (it is not added back). opts.save: false: not saved (temporary things).
|
|
53
53
|
* @example engine.world.add({ id: 'shop_owner', kind: 'npc', position: [12, 0, -30], name: '店主', mood: 'calm' }, { initial: true })
|
|
54
54
|
* @param {{ kind: string, id?: string, position?: any, [field: string]: any }} def
|
|
@@ -88,6 +88,7 @@ export class World {
|
|
|
88
88
|
* @example const h = engine.pick(0, 0); const id = h && engine.world.idOf(h.object);
|
|
89
89
|
* @param {any} obj a THREE.Object3D (a mesh of the model is fine)
|
|
90
90
|
* @returns {string | null}
|
|
91
|
+
* @experimental
|
|
91
92
|
*/
|
|
92
93
|
idOf(obj: any): string | null;
|
|
93
94
|
/**
|
|
@@ -107,7 +108,9 @@ export class World {
|
|
|
107
108
|
set(id: string, patch: Record<string, any>): WorldRecord;
|
|
108
109
|
/**
|
|
109
110
|
* Move a record (no event; use it in simulate for things that move every step); still saved (saves diff against content).
|
|
110
|
-
* The model of a positionFrom 'record' (default) record follows this frame; to do something else with the position in presentation, compare in update
|
|
111
|
+
* The model of a positionFrom 'record' (default) record follows this frame; to do something else with the position in presentation, compare in update.
|
|
112
|
+
* On a live character (the player, an NPC with a model) this is its placeAt: the character owns its position, so it goes there and the record says where it stands.
|
|
113
|
+
* A seated rider gets out to go there (placeAt ends a ride); a write equal to where it sits only follows the seat
|
|
111
114
|
* @example engine.world.move(rec.id, { x: rec.position.x + 1, z: rec.position.z })
|
|
112
115
|
* @param {string} id
|
|
113
116
|
* @param {any} position Vector3 / object / [x, y, z] / { x, z } (y stays unchanged if omitted)
|
|
@@ -157,7 +160,7 @@ export class World {
|
|
|
157
160
|
* radius: meters, or a function (for distances that change, like terrain view distance); defaults to world.radius. Registering the same kind again: old
|
|
158
161
|
* models are torn down with the old dispose and rebuilt with the new one.
|
|
159
162
|
* positionFrom: 'record' (default, the model follows the record every frame) or 'view' (the model moves itself, e.g. driven by a character mover; model
|
|
160
|
-
* position is copied back to the record at the end of each fixed step).
|
|
163
|
+
* position is copied back to the record at the end of each fixed step, and a write to the record moves the model and a rigid body on it).
|
|
161
164
|
* @example engine.world.present('chest', { build: rec => new THREE.Mesh(boxGeo, new THREE.MeshStandardMaterial()), dispose: (rec, obj) => engine.remove(obj), show: rec
|
|
162
165
|
* => !rec.looted })
|
|
163
166
|
* @param {string} kind
|
|
@@ -203,8 +206,8 @@ export class World {
|
|
|
203
206
|
* far → near step, far runs first to pay back the owed time.
|
|
204
207
|
* With only far (crops), near also advances via far; with only near, far records are not simulated and owed time is not made up.
|
|
205
208
|
* Both dt are accumulated real (fixed-step) seconds (not multiplied by clock.rate). For things measured in game clock (grows over days) store engine.clock.now
|
|
206
|
-
* and compare. channel: a time channel name (or rec => name) the kind lives on; then both dt are
|
|
207
|
-
* engine.time.local stack), so bullet time on 'enemies' slows near and far records alike (NPCs use it with their own channel).
|
|
209
|
+
* and compare. channel: a time channel name (or rec => name) the kind lives on; then both dt are the channel time the record lived through (its
|
|
210
|
+
* engine.time.local stack too), whatever the speed when far settles, so bullet time on 'enemies' slows near and far records alike (NPCs use it with their own channel).
|
|
208
211
|
* radius defaults to the present radius ('view' widened by 1.25), or world.radius without present; may also be a function.
|
|
209
212
|
* fullRadius + nearEvery (tiers, for crowds): records within fullRadius m (number or function) run near every step; the rest of the near zone runs near
|
|
210
213
|
* once every nearEvery seconds, dt being the seconds since its last turn (deterministic: turns go by hashed id and step count, saved).
|
|
@@ -235,11 +238,12 @@ export class World {
|
|
|
235
238
|
* Stop running simulate() handlers on this machine until remove(): a multiplayer client lets the host simulate and only receives the records.
|
|
236
239
|
* Public so net() needs no world internals.
|
|
237
240
|
* @returns {{ remove(): void }}
|
|
241
|
+
* @experimental
|
|
238
242
|
*/
|
|
239
243
|
pauseSimulation(): {
|
|
240
244
|
remove(): void;
|
|
241
245
|
};
|
|
242
|
-
/** Number of fixed steps simulated */ get steps(): number;
|
|
246
|
+
/** Number of fixed steps simulated @experimental */ get steps(): number;
|
|
243
247
|
}
|
|
244
248
|
/**
|
|
245
249
|
* One world record: id, kind and position are fixed fields, the rest are yours (plain values only)
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/render/PostFX.js (edit the JSDoc in the source, then run npm run map)
|
|
2
2
|
export class PostFX {
|
|
3
|
+
set antialias(on: boolean);
|
|
3
4
|
/**
|
|
4
|
-
* MSAA on
|
|
5
|
-
*
|
|
5
|
+
* MSAA on or off in the post chain's render targets, for what runs through the chain. It is a render setting, not a drawing part. With no effect on nothing runs through the chain:
|
|
6
|
+
* the canvas's own MSAA shows, fixed when the context was made (createEngine({ antialias })).
|
|
7
|
+
* @example engine.post.antialias = false;
|
|
8
|
+
* @type {boolean}
|
|
9
|
+
* @experimental
|
|
6
10
|
*/
|
|
7
11
|
get antialias(): boolean;
|
|
8
12
|
/**
|
|
9
|
-
* Whether the post chain runs: an effect is on
|
|
10
|
-
* runtime switch away from it goes through the chain's targets)
|
|
13
|
+
* Whether the post chain runs: an effect is on
|
|
11
14
|
* @returns {boolean}
|
|
12
15
|
*/
|
|
13
16
|
get active(): boolean;
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* the engine owns it, rebuilds
|
|
18
|
+
* What the chain runs in, for reading, or null while no post work has run yet (built the first time an effect is on; it is not built here, so asking never costs a
|
|
19
|
+
* render target). WebGLRenderer: the three.js EffectComposer (pass list, sizes, its targets). WebGPURenderer: { pipeline, scenePass }, three's RenderPipeline and the scene's pass() node. Read-only by rule, not by lock:
|
|
20
|
+
* the engine owns it, rebuilds the chain whenever the list changes and disposes it with the engine. To add a pass use post.add,
|
|
18
21
|
* to own the whole chain post.own() (recipe 52). Why public: a game reading the chain had to dig into an internal field (review 2026-11-03)
|
|
19
22
|
* @returns {any}
|
|
23
|
+
* @experimental
|
|
20
24
|
*/
|
|
21
25
|
object(): any;
|
|
22
26
|
/**
|
|
23
27
|
* The composer's render targets, for reading (sample the last frame's color or depth in a game pass, check formats / samples), or null while
|
|
24
|
-
* there is no composer. renderTarget1 / renderTarget2 are the ping-pong pair. During the chain readBuffer is a pass's input and writeBuffer its
|
|
28
|
+
* there is no composer, and always on WebGPURenderer (its pass nodes own their targets: post.object().scenePass). renderTarget1 / renderTarget2 are the ping-pong pair. During the chain readBuffer is a pass's input and writeBuffer its
|
|
25
29
|
* output; EffectComposer swaps them after every pass with needsSwap (most passes; the scene RenderPass does not). The last pass draws to the
|
|
26
30
|
* canvas and still swaps, so after the frame (engine.onRender(fn, { when: 'after' })) neither target holds the final picture: writeBuffer holds
|
|
27
31
|
* the input of that last pass (readBuffer when the last pass does not swap) and readBuffer is stale. For the final image, render into a target of your own.
|
|
28
|
-
* Owned by the engine like object(): it resizes them, changes samples
|
|
29
|
-
* do not dispose them or swap their textures. A target of your own: new THREE.WebGLRenderTarget in onRender (
|
|
32
|
+
* Owned by the engine like object(): it resizes them, changes samples when antialias is written and adds a depth texture when an effect needs depth;
|
|
33
|
+
* do not dispose them or swap their textures. A target of your own: new THREE.WebGLRenderTarget in onRender (THREE.md)
|
|
30
34
|
* @returns {{ renderTarget1: any, renderTarget2: any, readBuffer: any, writeBuffer: any } | null}
|
|
35
|
+
* @experimental
|
|
31
36
|
*/
|
|
32
37
|
targets(): {
|
|
33
38
|
renderTarget1: any;
|
|
@@ -68,15 +73,6 @@ export class PostFX {
|
|
|
68
73
|
* @experimental
|
|
69
74
|
*/
|
|
70
75
|
own(on?: boolean): void;
|
|
71
|
-
/**
|
|
72
|
-
* Turn MSAA on or off. It is a render setting, not a drawing part. With no effect on, the start value is the canvas's own MSAA (free: no
|
|
73
|
-
* post chain); the other value, and any effect, draws through the chain, whose render targets carry the MSAA.
|
|
74
|
-
* @example engine.post.setAntialias(false);
|
|
75
|
-
* @param {boolean} on
|
|
76
|
-
* @returns {void}
|
|
77
|
-
* @experimental
|
|
78
|
-
*/
|
|
79
|
-
setAntialias(on: boolean): void;
|
|
80
76
|
/**
|
|
81
77
|
* Effects in render order: [{ name, slot, order, enabled }]
|
|
82
78
|
* @returns {{ name: string, slot: PostSlot, order: number, enabled: boolean }[]}
|
|
@@ -121,7 +117,7 @@ export type PostContext = {
|
|
|
121
117
|
* values(params) returns their current values. reads: true when the snippet samples tDiffuse at other uvs (blur, color fringe):
|
|
122
118
|
* it then starts a new group, so it sees the real input.
|
|
123
119
|
* tsl (WebGPURenderer): (color, uv, t) => color, the same snippet as a TSL expression on the vec4 color node; t holds tsl (three/tsl),
|
|
124
|
-
* p (a uniform node per number / color param, live: set() changes .value, no rebuild), input (the image so far, sample it at other uvs with
|
|
120
|
+
* p (a uniform node per number, boolean (0 / 1), color and vector param, live: set() changes .value, no rebuild), input (the image so far, sample it at other uvs with
|
|
125
121
|
* t.input.sample(uv)), time (s), resolution (device px). Neighbors are chained into one node, so three draws them in one pass.
|
|
126
122
|
*/
|
|
127
123
|
export type PostFuse = {
|
|
@@ -135,7 +131,8 @@ export type PostFuse = {
|
|
|
135
131
|
* when an effect that is on says so in needsBuffers); tsl: three/tsl; display: three's display nodes (bloom, ao from three/addons/tsl/display) plus
|
|
136
132
|
* pass (an extra scene render), texture (the color so far as a texture to sample at other uvs) and own (a node the effect made itself, disposed with the chain),
|
|
137
133
|
* handed in so the main entry of an effect package never imports three/webgpu (its /tsl subpath may, a WebGL game never loads that) and so the nodes they make are disposed with the chain;
|
|
138
|
-
*
|
|
134
|
+
* fx: the threedog/tsl functions (noise, hash ...), handed in for the same reason;
|
|
135
|
+
* p: live uniform nodes of the number, boolean (0 / 1), color and vector params (as in PostFuse tsl), so set() of those never rebuilds the pipeline; a param read from
|
|
139
136
|
* ctx.params while node() runs is a constant in the graph, so set() of it rebuilds the chain (as WebGL rebuilds an effect without update()).
|
|
140
137
|
*/
|
|
141
138
|
export type PostNodeContext = {
|
|
@@ -147,12 +144,13 @@ export type PostNodeContext = {
|
|
|
147
144
|
params: Record<string, any>;
|
|
148
145
|
scenePass: any;
|
|
149
146
|
tsl: any;
|
|
147
|
+
fx: Record<string, Function>;
|
|
150
148
|
display: Record<string, Function>;
|
|
151
149
|
p: Record<string, any>;
|
|
152
150
|
};
|
|
153
151
|
/**
|
|
154
|
-
* node (WebGPURenderer): returns the effect's output color node built on input (the color node so far); called again only when a param
|
|
155
|
-
* that is not a number
|
|
152
|
+
* An effect as data, the form post.add() takes. node (WebGPURenderer): returns the effect's output color node built on input (the color node so far); called again only when a param
|
|
153
|
+
* that is not a number, boolean, color or vector changes (those are live in ctx.p). An effect with only create cannot run on WebGPURenderer (it throws by name).
|
|
156
154
|
* create: builds the implementation the first time the effect is on (WebGL: a three.js postprocessing Pass); optional when fuse is given.
|
|
157
155
|
* fuse: see PostFuse; effects with a fuse in the same slot next to each other are merged (never in slot 'scene'), their params
|
|
158
156
|
* update in place (no update() needed).
|
|
@@ -56,6 +56,7 @@ export function applyEffects(material: THREE.Material, { wind, clouds, season, d
|
|
|
56
56
|
* @param {{ assets: any }} [engine]
|
|
57
57
|
* @param {{ effects?: boolean, detail?: import('../../../render/detail').DetailOptions | null }} [o]
|
|
58
58
|
* @returns {Material}
|
|
59
|
+
* @experimental
|
|
59
60
|
*/
|
|
60
61
|
export function terrainMaterial(base?: THREE.Material | null, engine?: {
|
|
61
62
|
assets: any;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
// Generated by npm run map, do not edit by hand. Source: packages/engine/render/occlusion.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* The mask a mesh goes back to after the engine hid it on one layer. A game's write while hidden stands (hard rule 4): layers.set took the hidden layer
|
|
4
|
+
* away, so the mask is the game's; layers.enable added to it, so the game's bit joins what was there before.
|
|
5
|
+
* @param {number} now the mask now @param {number} bit the hiding layer's bit @param {number} before the mask before hiding @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
export function unhideMask(now: number, bit: number, before: number): number;
|
|
8
|
+
/** The mask bit of the batch layer, where a far original waits (hlod, assets.lod); three keeps layer masks unsigned */
|
|
9
|
+
export const FAR_BIT: number;
|
|
10
|
+
export function noRaycast(): void;
|
|
2
11
|
export class Occlusion {
|
|
3
12
|
set enabled(v: boolean);
|
|
4
13
|
/** Occlusion culling of hlod cells and batched groups; describe().render.occlusion says what it saved @returns {boolean} */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/** @import { UIFocus } from '../../gameplay' */
|
|
4
4
|
/**
|
|
5
5
|
* UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
|
|
6
|
+
* @experimental the stable route for a screen of your own is engine.input.push (recipes/07-flow-scenes-pause.md)
|
|
6
7
|
* @param {Engine} engine
|
|
7
8
|
* @returns {UIFocus}
|
|
8
9
|
*/
|
|
@@ -26,6 +26,7 @@ export function makeWindow(engine: Engine, opts: WindowOptions): UIWindow;
|
|
|
26
26
|
* @param {{ open: boolean, toggle(on?: boolean): void }} win a makeWindow window or any handle with open / toggle
|
|
27
27
|
* @param {string} action
|
|
28
28
|
* @returns {void}
|
|
29
|
+
* @experimental
|
|
29
30
|
*/
|
|
30
31
|
export function toggleOnKey(engine: Engine, win: {
|
|
31
32
|
open: boolean;
|
package/types/nav.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { XZ, PositionLike } from './common';
|
|
|
5
5
|
export interface NavOptions {
|
|
6
6
|
/** Voxel cell size (meters), default 0.3; smaller is more accurate but slower to build */
|
|
7
7
|
cellSize?: number;
|
|
8
|
-
/** Character radius (meters), default reads engine.movement.radius (this is an override) */
|
|
8
|
+
/** Character radius (meters), default reads engine.movement.radius (this is an override). The mesh built at load; a path with another radius gets a mesh of its own, on first ask */
|
|
9
9
|
agentRadius?: number;
|
|
10
10
|
/** Character height (meters), default reads engine.movement.height */
|
|
11
11
|
agentHeight?: number;
|
|
@@ -13,45 +13,77 @@ export interface NavOptions {
|
|
|
13
13
|
maxClimb?: number;
|
|
14
14
|
/** Max walkable slope (degrees), default reads engine.movement.maxSlope */
|
|
15
15
|
maxSlope?: number;
|
|
16
|
-
/** Tile size (in cells), default 32 */
|
|
16
|
+
/** Tile size (in cells), default 32 @experimental */
|
|
17
17
|
tileSize?: number;
|
|
18
18
|
/** NPCs use Recast crowd avoidance, default false */
|
|
19
19
|
crowd?: boolean;
|
|
20
20
|
/** Show the navmesh (debug), default false */
|
|
21
21
|
debug?: boolean;
|
|
22
|
-
/** Most TileCache obstacles (collision boxes are cut into several), default 1024 */
|
|
22
|
+
/** Most TileCache obstacles (collision boxes are cut into several), default 1024 @experimental */
|
|
23
23
|
maxObstacles?: number;
|
|
24
|
-
/** Most crowd agents (with crowd: true), default 128 */
|
|
24
|
+
/** Most crowd agents (with crowd: true), default 128 @experimental */
|
|
25
25
|
maxAgents?: number;
|
|
26
26
|
/** Meters past the character's radius a path may end short of its goal and still count as arrived, default 0.6 */
|
|
27
27
|
arrive?: number;
|
|
28
|
+
/** Places joined by a jump or a climb instead of walking (Recast off-mesh connections); walkers cross them straight unless the game says otherwise @experimental */
|
|
29
|
+
links?: NavLink[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** One link of nav({ links }) @experimental */
|
|
33
|
+
export interface NavLink {
|
|
34
|
+
/** Name in path points and link events; default its index */
|
|
35
|
+
id?: string | number;
|
|
36
|
+
/** One end, on or near walkable ground (no y: the ground there). A link joins neighbouring tiles at most: keep it under tileSize x cellSize meters */
|
|
37
|
+
from: PositionLike;
|
|
38
|
+
/** The other end */
|
|
39
|
+
to: PositionLike;
|
|
40
|
+
/** Only from -> to, default false */
|
|
41
|
+
oneWay?: boolean;
|
|
42
|
+
/** How far (meters) an end may be from the mesh and still attach, default the agent radius + 2 cells */
|
|
43
|
+
radius?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A path point that starts a link: the leg to the next point is the crossing @experimental */
|
|
47
|
+
export interface NavPathPoint extends XZ {
|
|
48
|
+
link?: { id: string | number; from: { x: number; y: number; z: number }; to: { x: number; y: number; z: number } };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A crossing under way: plain data, saved with an NPC. seconds may be set at link:enter @experimental */
|
|
52
|
+
export interface LinkCrossing {
|
|
53
|
+
link: string | number;
|
|
54
|
+
from: { x: number; y: number; z: number };
|
|
55
|
+
to: { x: number; y: number; z: number };
|
|
56
|
+
seconds: number;
|
|
57
|
+
time: number;
|
|
28
58
|
}
|
|
29
59
|
|
|
30
60
|
/**
|
|
31
61
|
* engine.nav: navmesh. Usually not called directly; engine.characters.findPath uses it automatically once ready.
|
|
32
|
-
* The mesh comes from the ground API's
|
|
62
|
+
* The mesh comes from the ground API's staticTrimeshes() (the level's walkable mesh);
|
|
33
63
|
* collision boxes / circles (level col_ walls, those added by collision.addBox) all become dynamic obstacles and update automatically when added or removed.
|
|
34
64
|
*/
|
|
35
65
|
export interface Nav {
|
|
36
66
|
/** The navmesh has been generated */
|
|
37
67
|
readonly ready: boolean;
|
|
38
|
-
/**
|
|
68
|
+
/** The links in effect, ends in 3D, in the order given to nav({ links }); empty until the mesh is built @experimental */
|
|
69
|
+
readonly links: readonly { id: string | number; from: { x: number; y: number; z: number }; to: { x: number; y: number; z: number }; oneWay: boolean; radius: number }[];
|
|
70
|
+
/** Native Recast NavMesh (null until ready) @experimental */
|
|
39
71
|
navMesh: any;
|
|
40
|
-
/** Native Recast NavMeshQuery */
|
|
72
|
+
/** Native Recast NavMeshQuery @experimental */
|
|
41
73
|
query: any;
|
|
42
|
-
/** Native Recast TileCache (for dynamic obstacles) */
|
|
74
|
+
/** Native Recast TileCache (for dynamic obstacles) @experimental */
|
|
43
75
|
tileCache: any;
|
|
44
|
-
/** Native Recast Crowd (only when crowd: true) */
|
|
76
|
+
/** Native Recast Crowd (only when crowd: true) @experimental */
|
|
45
77
|
crowd: any;
|
|
46
|
-
/** three.js object for the debug display (only when debug: true) */
|
|
78
|
+
/** three.js object for the debug display (only when debug: true) @experimental */
|
|
47
79
|
helper: any;
|
|
48
|
-
/** +1 on rebuild / unload: code that cached native objects (crowd agents etc.) must recreate them when it changes */
|
|
80
|
+
/** +1 on rebuild / unload: code that cached native objects (crowd agents etc.) must recreate them when it changes @experimental */
|
|
49
81
|
readonly version: number;
|
|
50
|
-
/** Path from from to to [{ x, z }…] (meters); null if not ready or unreachable. Usually use engine.characters.findPath */
|
|
51
|
-
findPath(from: PositionLike, to: PositionLike, opts?: { radius?: number; detailed?: false }):
|
|
82
|
+
/** Path from from to to [{ x, y, z }…] (meters); null if not ready or unreachable; radius: the body it must fit, default agentRadius. Usually use engine.characters.findPath */
|
|
83
|
+
findPath(from: PositionLike, to: PositionLike, opts?: { radius?: number; detailed?: false }): NavPathPoint[] | null;
|
|
52
84
|
/** Pass detailed: true: returns { status: 'ok' | 'noPath' | 'notReady', path }, telling "unreachable" from "mesh not generated yet" */
|
|
53
|
-
findPath(from: PositionLike, to: PositionLike, opts: { radius?: number; detailed: true }): { status: 'ok' | 'noPath' | 'notReady'; path:
|
|
54
|
-
/** Character size actually in effect (from engine.movement, or the override in nav()) */
|
|
85
|
+
findPath(from: PositionLike, to: PositionLike, opts: { radius?: number; detailed: true }): { status: 'ok' | 'noPath' | 'notReady'; path: NavPathPoint[] | null };
|
|
86
|
+
/** Character size actually in effect (from engine.movement, or the override in nav()) @experimental */
|
|
55
87
|
readonly agent: { radius: number; height: number; maxClimb: number; maxSlope: number } | null;
|
|
56
88
|
/** Unload the navmesh (frees native objects); characters.findPath then falls back to A* */
|
|
57
89
|
dispose(): void;
|