threedog 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/core/Animator.js +268 -0
- package/core/Assets.js +256 -0
- package/core/Audio.js +267 -0
- package/core/Baked.js +72 -0
- package/core/Batching.js +247 -0
- package/core/Budget.js +221 -0
- package/core/Clock.js +94 -0
- package/core/Commits.js +77 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +145 -0
- package/core/Engine.js +184 -0
- package/core/Events.js +153 -0
- package/core/I18n.js +94 -0
- package/core/Input.js +245 -0
- package/core/Inspect.js +77 -0
- package/core/InspectScene.js +191 -0
- package/core/Jobs.js +146 -0
- package/core/Loading.js +149 -0
- package/core/MaterialInfo.js +32 -0
- package/core/Ops.js +256 -0
- package/core/Random.js +52 -0
- package/core/Rays.js +160 -0
- package/core/SaveStore.js +85 -0
- package/core/Saves.js +254 -0
- package/core/Stream.js +279 -0
- package/core/Threads.js +158 -0
- package/core/UrlState.js +94 -0
- package/core/Vars.js +35 -0
- package/core/Views.js +49 -0
- package/core/actor.js +23 -0
- package/core/assetEntry.js +89 -0
- package/core/assetLoad.js +190 -0
- package/core/assetManifest.js +35 -0
- package/core/assetReport.js +83 -0
- package/core/audioRules.js +121 -0
- package/core/audioVoice.js +225 -0
- package/core/batchGroups.js +116 -0
- package/core/canvasBox.js +63 -0
- package/core/catalog.js +169 -0
- package/core/checks.js +67 -0
- package/core/claims.js +51 -0
- package/core/dayTime.js +15 -0
- package/core/debugView.js +76 -0
- package/core/describeRender.js +45 -0
- package/core/describeText.js +143 -0
- package/core/easing.js +34 -0
- package/core/errorCodes.js +205 -0
- package/core/errorHints.js +208 -0
- package/core/errors.js +40 -0
- package/core/events.generated.js +84 -0
- package/core/ground.js +102 -0
- package/core/holds.js +106 -0
- package/core/inputContext.js +69 -0
- package/core/inputDefaults.js +22 -0
- package/core/inputPad.js +35 -0
- package/core/inputPointer.js +48 -0
- package/core/inputTouch.js +48 -0
- package/core/lifecycle.js +69 -0
- package/core/lightWatch.js +56 -0
- package/core/look/coreParts.js +112 -0
- package/core/look/layers.js +136 -0
- package/core/look/part.js +173 -0
- package/core/look/report.js +79 -0
- package/core/look/write.js +86 -0
- package/core/loop.js +200 -0
- package/core/math.js +33 -0
- package/core/modules.js +196 -0
- package/core/movement.js +19 -0
- package/core/mulberry32.js +14 -0
- package/core/opsAtomic.js +31 -0
- package/core/opsCheck.js +97 -0
- package/core/opsFail.js +20 -0
- package/core/opsGuard.js +26 -0
- package/core/opsHistory.js +27 -0
- package/core/opsRun.js +77 -0
- package/core/page.js +78 -0
- package/core/params.js +132 -0
- package/core/pureWorker.js +5 -0
- package/core/renamed.js +21 -0
- package/core/saveApply.js +128 -0
- package/core/saveFiles.js +139 -0
- package/core/saveIds.js +53 -0
- package/core/saveVersions.js +97 -0
- package/core/scatter.js +92 -0
- package/core/sceneMethods.js +100 -0
- package/core/screenToGround.js +39 -0
- package/core/services.js +73 -0
- package/core/session.js +171 -0
- package/core/shadowTypes.js +15 -0
- package/core/skip.js +104 -0
- package/core/startup.js +135 -0
- package/core/streamCells.js +24 -0
- package/core/streamSources.js +73 -0
- package/core/styleParts.js +96 -0
- package/core/targeting.js +64 -0
- package/core/thingExplain.js +68 -0
- package/core/thingOps.js +168 -0
- package/core/things.js +212 -0
- package/core/threadPure.js +120 -0
- package/core/threadServe.js +25 -0
- package/core/tier.js +11 -0
- package/core/util.js +11 -0
- package/core/validate.js +204 -0
- package/docs/AI.md +123 -0
- package/docs/API.md +83 -0
- package/docs/CODEMAP.md +347 -0
- package/docs/COMMANDS.md +108 -0
- package/docs/CONVENTIONS.md +145 -0
- package/docs/PERF.md +217 -0
- package/docs/THREE.md +86 -0
- package/docs/api/ambience.md +15 -0
- package/docs/api/assets.md +62 -0
- package/docs/api/audio.md +53 -0
- package/docs/api/budget.md +40 -0
- package/docs/api/cameraRig.md +120 -0
- package/docs/api/characters.md +144 -0
- package/docs/api/clock.md +7 -0
- package/docs/api/collision.md +39 -0
- package/docs/api/content.md +64 -0
- package/docs/api/dialogue.md +39 -0
- package/docs/api/engine.md +199 -0
- package/docs/api/entities.md +61 -0
- package/docs/api/events.md +95 -0
- package/docs/api/flow.md +27 -0
- package/docs/api/grids.md +11 -0
- package/docs/api/ground.md +16 -0
- package/docs/api/hlod.md +34 -0
- package/docs/api/hud.md +31 -0
- package/docs/api/i18n.md +10 -0
- package/docs/api/input.md +24 -0
- package/docs/api/interactions.md +31 -0
- package/docs/api/inventory.md +66 -0
- package/docs/api/jobs.md +10 -0
- package/docs/api/level.md +41 -0
- package/docs/api/lightPool.md +56 -0
- package/docs/api/music.md +34 -0
- package/docs/api/nav.md +26 -0
- package/docs/api/net.md +14 -0
- package/docs/api/openWorld.md +24 -0
- package/docs/api/particles.md +41 -0
- package/docs/api/photo.md +15 -0
- package/docs/api/post.md +10 -0
- package/docs/api/quests.md +36 -0
- package/docs/api/rays.md +26 -0
- package/docs/api/rigid.md +84 -0
- package/docs/api/saves.md +32 -0
- package/docs/api/settings.md +36 -0
- package/docs/api/sky.md +58 -0
- package/docs/api/stream.md +31 -0
- package/docs/api/style.md +134 -0
- package/docs/api/terrain.md +34 -0
- package/docs/api/timeline.md +39 -0
- package/docs/api/tools.md +57 -0
- package/docs/api/triggers.md +56 -0
- package/docs/api/vars.md +9 -0
- package/docs/api/vegetation.md +52 -0
- package/docs/api/water.md +48 -0
- package/docs/api/weather.md +29 -0
- package/docs/api/world.md +30 -0
- package/docs/recipes/01-new-game.md +148 -0
- package/docs/recipes/02-npc.md +167 -0
- package/docs/recipes/03-items-pickups.md +158 -0
- package/docs/recipes/04-quests.md +83 -0
- package/docs/recipes/05-props-bake.md +159 -0
- package/docs/recipes/06-clock-events.md +117 -0
- package/docs/recipes/07-flow-scenes-pause.md +132 -0
- package/docs/recipes/08-weather-sky.md +74 -0
- package/docs/recipes/09-style-pack.md +234 -0
- package/docs/recipes/10-blender-level.md +67 -0
- package/docs/recipes/11-vehicles.md +55 -0
- package/docs/recipes/12-navmesh.md +79 -0
- package/docs/recipes/13-animation.md +149 -0
- package/docs/recipes/14-custom-module.md +91 -0
- package/docs/recipes/15-perf.md +78 -0
- package/docs/recipes/16-dev-bridge.md +180 -0
- package/docs/recipes/18-world.md +185 -0
- package/docs/recipes/19-shooting-picking.md +76 -0
- package/docs/recipes/20-content-actions-save.md +176 -0
- package/docs/recipes/21-camera.md +153 -0
- package/docs/recipes/22-shop-gold.md +107 -0
- package/docs/recipes/23-ops.md +175 -0
- package/docs/recipes/26-ui-parts.md +138 -0
- package/docs/recipes/27-net.md +96 -0
- package/docs/recipes/28-terrain.md +80 -0
- package/docs/recipes/29-grid.md +87 -0
- package/docs/recipes/30-templates.md +131 -0
- package/docs/recipes/31-audio.md +126 -0
- package/docs/recipes/32-action-game.md +33 -0
- package/docs/recipes/33-stream-sources.md +37 -0
- package/docs/recipes/34-environment-lighting.md +36 -0
- package/docs/recipes/35-style-from-reference.md +89 -0
- package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
- package/docs/recipes/37-terrain-look-hooks.md +97 -0
- package/docs/recipes/38-environment-look-hooks.md +83 -0
- package/docs/recipes/40-scene.md +108 -0
- package/docs/recipes/41-thing-registry.md +93 -0
- package/docs/recipes/42-terrain-shape.md +64 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +120 -0
- package/docs/recipes/44-water-weather-look-hooks.md +135 -0
- package/docs/recipes/45-cascaded-shadows.md +51 -0
- package/docs/recipes/46-blender-art-route.md +114 -0
- package/docs/recipes/47-island-snow-backdrop.md +44 -0
- package/docs/recipes/48-make-material.md +70 -0
- package/docs/recipes/49-game-module-contract.md +71 -0
- package/docs/recipes/50-own-renderer.md +12 -0
- package/docs/recipes/51-capability-catalog.md +63 -0
- package/docs/recipes/52-look.md +108 -0
- package/examples/action/DESIGN.md +3 -0
- package/examples/action/GAMEMAP.md +127 -0
- package/examples/action/content/actions.js +8 -0
- package/examples/action/content/audio.js +9 -0
- package/examples/action/content/index.js +10 -0
- package/examples/action/content/items.js +4 -0
- package/examples/action/content/places.js +4 -0
- package/examples/action/content/props.js +11 -0
- package/examples/action/content/templates.js +10 -0
- package/examples/action/content/views.js +6 -0
- package/examples/action/look.js +5 -0
- package/examples/action/main.js +137 -0
- package/examples/action/models.js +25 -0
- package/examples/sheepisland/GAMEMAP.md +107 -0
- package/examples/sheepisland/content/index.js +6 -0
- package/examples/sheepisland/content/props.js +19 -0
- package/examples/sheepisland/content/templates.js +5 -0
- package/examples/sheepisland/content/vegetation.js +8 -0
- package/examples/sheepisland/main.js +71 -0
- package/examples/sheepisland/params.js +25 -0
- package/examples/sheepisland/style/index.js +79 -0
- package/examples/sheepisland/style/models.js +59 -0
- package/examples/sheepisland/views.js +9 -0
- package/examples/styletest/GAMEMAP.md +135 -0
- package/examples/styletest/content/index.js +9 -0
- package/examples/styletest/content/items.js +8 -0
- package/examples/styletest/content/npcs.js +8 -0
- package/examples/styletest/content/places.js +5 -0
- package/examples/styletest/content/props.js +16 -0
- package/examples/styletest/content/templates.js +9 -0
- package/examples/styletest/content/vegetation.js +31 -0
- package/examples/styletest/look.js +11 -0
- package/examples/styletest/main.js +95 -0
- package/examples/styletest/models.js +87 -0
- package/examples/styletest/overrides.js +33 -0
- package/examples/styletest/panel.js +135 -0
- package/examples/styletest/params.js +32 -0
- package/examples/styletest/views.js +31 -0
- package/examples/world/DESIGN.md +5 -0
- package/examples/world/GAMEMAP.md +171 -0
- package/examples/world/content/actions.js +8 -0
- package/examples/world/content/audio.js +25 -0
- package/examples/world/content/bodies.js +12 -0
- package/examples/world/content/containers.js +4 -0
- package/examples/world/content/dialogues.js +33 -0
- package/examples/world/content/index.js +17 -0
- package/examples/world/content/items.js +10 -0
- package/examples/world/content/npcs.js +14 -0
- package/examples/world/content/pickups.js +11 -0
- package/examples/world/content/places.js +6 -0
- package/examples/world/content/props.js +12 -0
- package/examples/world/content/quests.js +15 -0
- package/examples/world/content/rules.js +23 -0
- package/examples/world/content/templates.js +5 -0
- package/examples/world/content/vegetation.js +32 -0
- package/examples/world/main.js +168 -0
- package/examples/world/models.js +28 -0
- package/index.d.ts +306 -0
- package/index.js +122 -0
- package/llms.txt +61 -0
- package/modules/ambience/Ambience.js +186 -0
- package/modules/camera/FirstPersonCamera.js +131 -0
- package/modules/camera/FixedCamera.js +162 -0
- package/modules/camera/FollowCamera.js +91 -0
- package/modules/camera/RtsCamera.js +132 -0
- package/modules/camera/common.js +182 -0
- package/modules/camera/index.js +11 -0
- package/modules/camera/projection.js +34 -0
- package/modules/characters/Character.js +235 -0
- package/modules/characters/NPC.js +242 -0
- package/modules/characters/assetModel.js +42 -0
- package/modules/characters/astar.js +66 -0
- package/modules/characters/behaviors.js +72 -0
- package/modules/characters/footsteps.js +13 -0
- package/modules/characters/index.js +215 -0
- package/modules/characters/moveHelpers.js +29 -0
- package/modules/characters/movers/common.js +62 -0
- package/modules/characters/movers/rapier.js +74 -0
- package/modules/characters/movers/simple.js +43 -0
- package/modules/characters/npcAvoid.js +129 -0
- package/modules/characters/npcSim.js +150 -0
- package/modules/characters/npcView.js +42 -0
- package/modules/characters/pathAsync.js +113 -0
- package/modules/characters/pathJob.js +62 -0
- package/modules/characters/pathWorker.js +7 -0
- package/modules/characters/playerStrings.js +12 -0
- package/modules/characters/proceduralRig.js +58 -0
- package/modules/characters/useModel.js +22 -0
- package/modules/characters/walkTo.js +58 -0
- package/modules/collision/Collision.js +274 -0
- package/modules/collision/grid.js +63 -0
- package/modules/content/explain.js +13 -0
- package/modules/content/ids.js +95 -0
- package/modules/content/index.js +154 -0
- package/modules/content/loader.js +190 -0
- package/modules/content/models.js +69 -0
- package/modules/content/packs.js +69 -0
- package/modules/content/props.js +89 -0
- package/modules/content/rules.js +134 -0
- package/modules/content/templates.js +189 -0
- package/modules/debug/DebugPanel.js +174 -0
- package/modules/entities/Entities.js +243 -0
- package/modules/entities/build.js +25 -0
- package/modules/entities/index.js +4 -0
- package/modules/flow/index.js +101 -0
- package/modules/gameplay/Container.js +227 -0
- package/modules/gameplay/Containers.js +89 -0
- package/modules/gameplay/Dialogue.js +219 -0
- package/modules/gameplay/Interactions.js +253 -0
- package/modules/gameplay/Inventory.js +224 -0
- package/modules/gameplay/Quests.js +205 -0
- package/modules/gameplay/boxOps.js +60 -0
- package/modules/gameplay/dialogueBox.js +48 -0
- package/modules/gameplay/interactionPrompt.js +28 -0
- package/modules/gameplay/inventoryOps.js +137 -0
- package/modules/gameplay/pickups.js +115 -0
- package/modules/gameplay/questLog.js +54 -0
- package/modules/gameplay/questSave.js +71 -0
- package/modules/grid/Grid.js +184 -0
- package/modules/grid/Layer.js +142 -0
- package/modules/grid/index.js +236 -0
- package/modules/grid/ops.js +73 -0
- package/modules/grid/preview.js +85 -0
- package/modules/grid/tiles.js +79 -0
- package/modules/hlod/index.js +167 -0
- package/modules/hud/index.js +167 -0
- package/modules/hud/parts.js +80 -0
- package/modules/level/geometry.js +46 -0
- package/modules/level/heightfield.js +160 -0
- package/modules/level/index.js +233 -0
- package/modules/level/nodes.js +84 -0
- package/modules/lights/index.js +227 -0
- package/modules/music/Music.js +294 -0
- package/modules/music/index.js +2 -0
- package/modules/music/rules.js +28 -0
- package/modules/nav/index.js +156 -0
- package/modules/nav/navPath.js +17 -0
- package/modules/net/Client.js +137 -0
- package/modules/net/Host.js +117 -0
- package/modules/net/Net.js +49 -0
- package/modules/net/index.js +77 -0
- package/modules/net/sync.js +114 -0
- package/modules/net/transports.js +118 -0
- package/modules/particles/Particles.js +179 -0
- package/modules/particles/effect.js +112 -0
- package/modules/particles/shaders.js +28 -0
- package/modules/photo/Photo.js +146 -0
- package/modules/rigid/RigidBodies.js +265 -0
- package/modules/rigid/Vehicles.js +97 -0
- package/modules/rigid/sync.js +158 -0
- package/modules/settings/Settings.js +297 -0
- package/modules/settings/apply.js +21 -0
- package/modules/settings/index.js +3 -0
- package/modules/settings/sections.js +156 -0
- package/modules/settings/strings.js +53 -0
- package/modules/settings/view.js +65 -0
- package/modules/sky/Sky.js +259 -0
- package/modules/sky/calendar.js +80 -0
- package/modules/sky/cascades.js +125 -0
- package/modules/sky/clouds.js +79 -0
- package/modules/sky/domeLayers.js +33 -0
- package/modules/sky/environment.js +141 -0
- package/modules/sky/fog.js +139 -0
- package/modules/sky/frame.js +77 -0
- package/modules/sky/layers.js +69 -0
- package/modules/sky/look.js +51 -0
- package/modules/sky/lookFog.js +80 -0
- package/modules/sky/lookShadow.js +50 -0
- package/modules/sky/lookSky.js +108 -0
- package/modules/sky/schedule.js +80 -0
- package/modules/sky/shader.js +96 -0
- package/modules/sky/shadow.js +74 -0
- package/modules/sky/skyModule.js +60 -0
- package/modules/terrain/ChunkManager.js +260 -0
- package/modules/terrain/chunkJob.js +19 -0
- package/modules/terrain/chunkLevels.js +40 -0
- package/modules/terrain/chunkQueries.js +42 -0
- package/modules/terrain/chunkWorker.js +5 -0
- package/modules/terrain/index.js +118 -0
- package/modules/terrain/lookGround.js +61 -0
- package/modules/terrain/mountTerrain.js +32 -0
- package/modules/terrain/terrainColorMap.js +41 -0
- package/modules/terrain/terrainDefaults.js +39 -0
- package/modules/terrain/terrainEdit.js +139 -0
- package/modules/terrain/terrainGen.js +155 -0
- package/modules/terrain/terrainIsland.js +131 -0
- package/modules/terrain/terrainMesh.js +92 -0
- package/modules/terrain/terrainShape.js +108 -0
- package/modules/terrain/terrainShapeMain.js +41 -0
- package/modules/terrain/terrainTexture.js +44 -0
- package/modules/timeline/Timeline.js +253 -0
- package/modules/timeline/Tween.js +114 -0
- package/modules/timeline/letterbox.js +24 -0
- package/modules/timeline/shots.js +90 -0
- package/modules/triggers/index.js +268 -0
- package/modules/vegetation/Vegetation.js +256 -0
- package/modules/vegetation/groundChunks.js +177 -0
- package/modules/vegetation/index.js +43 -0
- package/modules/vegetation/lookWind.js +37 -0
- package/modules/vegetation/modelGeometry.js +21 -0
- package/modules/water/Water.js +160 -0
- package/modules/water/look.js +80 -0
- package/modules/water/surface.js +88 -0
- package/modules/weather/Weather.js +242 -0
- package/modules/weather/look.js +75 -0
- package/modules/weather/particles.js +92 -0
- package/modules/weather/shaders.js +49 -0
- package/modules/weather/strings.js +15 -0
- package/modules/world/World.js +231 -0
- package/modules/world/cells.js +42 -0
- package/modules/world/explain.js +11 -0
- package/modules/world/index.js +71 -0
- package/modules/world/persist.js +107 -0
- package/modules/world/pos.js +20 -0
- package/modules/world/records.js +89 -0
- package/modules/world/sim.js +175 -0
- package/modules/world/simFar.js +82 -0
- package/modules/world/state.js +115 -0
- package/modules/world/thingSource.js +44 -0
- package/modules/world/views.js +182 -0
- package/package.json +66 -4
- package/presets.js +96 -0
- package/render/PostFX.js +240 -0
- package/render/detail.js +105 -0
- package/render/effects.js +144 -0
- package/render/engineUniforms.js +23 -0
- package/render/fuse.js +84 -0
- package/render/lighting.js +100 -0
- package/render/lights.js +18 -0
- package/render/lookSurface.js +161 -0
- package/render/materials.js +220 -0
- package/render/patches.js +252 -0
- package/render/postLook.js +86 -0
- package/render/surface.js +69 -0
- package/render/uniformDecl.js +29 -0
- package/types/common.d.ts +34 -0
- package/types/core.d.ts +1965 -0
- package/types/gameplay.d.ts +1822 -0
- package/types/generated/core/Audio.d.ts +200 -0
- package/types/generated/core/Batching.d.ts +47 -0
- package/types/generated/core/Budget.d.ts +90 -0
- package/types/generated/core/Commits.d.ts +31 -0
- package/types/generated/core/DebugOverrides.d.ts +52 -0
- package/types/generated/core/Events.d.ts +89 -0
- package/types/generated/core/I18n.d.ts +30 -0
- package/types/generated/core/Input.d.ts +118 -0
- package/types/generated/core/Jobs.d.ts +41 -0
- package/types/generated/core/Ops.d.ts +203 -0
- package/types/generated/core/Random.d.ts +49 -0
- package/types/generated/core/Rays.d.ts +49 -0
- package/types/generated/core/Saves.d.ts +162 -0
- package/types/generated/core/Stream.d.ts +93 -0
- package/types/generated/core/Threads.d.ts +82 -0
- package/types/generated/core/Views.d.ts +33 -0
- package/types/generated/core/audioVoice.d.ts +47 -0
- package/types/generated/core/page.d.ts +18 -0
- package/types/generated/core/session.d.ts +48 -0
- package/types/generated/modules/ambience/Ambience.d.ts +48 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
- package/types/generated/modules/flow/index.d.ts +10 -0
- package/types/generated/modules/grid/Grid.d.ts +151 -0
- package/types/generated/modules/grid/Layer.d.ts +65 -0
- package/types/generated/modules/grid/index.d.ts +86 -0
- package/types/generated/modules/hlod/index.d.ts +11 -0
- package/types/generated/modules/hud/index.d.ts +10 -0
- package/types/generated/modules/lights/index.d.ts +13 -0
- package/types/generated/modules/music/Music.d.ts +111 -0
- package/types/generated/modules/net/Net.d.ts +34 -0
- package/types/generated/modules/net/index.d.ts +53 -0
- package/types/generated/modules/net/transports.d.ts +58 -0
- package/types/generated/modules/particles/Particles.d.ts +69 -0
- package/types/generated/modules/sky/Sky.d.ts +145 -0
- package/types/generated/modules/sky/skyModule.d.ts +10 -0
- package/types/generated/modules/timeline/Timeline.d.ts +51 -0
- package/types/generated/modules/water/Water.d.ts +29 -0
- package/types/generated/modules/weather/Weather.d.ts +62 -0
- package/types/generated/modules/world/World.d.ts +242 -0
- package/types/generated/modules/world/index.d.ts +15 -0
- package/types/generated/render/PostFX.d.ts +125 -0
- package/types/generated/render/materials.d.ts +100 -0
- package/types/generated/render/patches.d.ts +41 -0
- package/types/generated/ui/Focus.d.ts +11 -0
- package/types/generated/ui/LoadingScreen.d.ts +2 -0
- package/types/generated/ui/UI.d.ts +57 -0
- package/types/nav.d.ts +52 -0
- package/types/physics.d.ts +592 -0
- package/types/style.d.ts +638 -0
- package/types/worker.d.ts +11 -0
- package/types/world.d.ts +772 -0
- package/ui/Focus.js +51 -0
- package/ui/LoadingScreen.js +42 -0
- package/ui/Parts.js +199 -0
- package/ui/UI.js +167 -0
- package/ui/defaults.js +85 -0
- package/ui/theme.js +124 -0
- package/ui/touchPart.js +49 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# engine.assets (Assets)
|
|
2
|
+
|
|
3
|
+
- `assets.manifest(m: AssetManifest)` — Register an asset manifest or asset pack (can be called several times; a later entry with the same name replaces the earlier one). Its name labels it in engine.loading, base resolves its relative paths
|
|
4
|
+
- `assets.builder(name: string) → ((...args: any[]) => any) | null` — The generator function registered under a model name, null for a file model or an unknown name (content builds [name, ...params] models with it)
|
|
5
|
+
- `assets.preload(onProgress?: (p: number, name: string) => void, opts?: { onlyMarked?: boolean }) → Promise<{ loaded: number; failed:…` — Preload (onProgress(0–1, current name)). Code-generated models and fonts are only loaded up front if marked preload. failed includes entries now showing their fallback
|
|
6
|
+
- `assets.font(name: string) → Promise<FontFace | null>` — A font from an asset pack by name: downloaded once, added to document.fonts; null when the file failed and it is not critical. style.ui.fonts calls it at start()
|
|
7
|
+
- `assets.model(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Promise<Object3D>` — Get a model copy (name or path; geometry and materials are shared with other copies). static: true registers it in engine.rays (builds ray acceleration)
|
|
8
|
+
- `assets.modelNow(nameOrUrl: string, opts?: { castShadow?, receiveShadow?, static? }) → Object3D | null` — A model copy right now if it has already loaded, else null (never starts a load, never waits): lets code that rebuilds often skip the frame an await costs. Example: `const m = engine.assets.modelNow('villager') ?? await engine.assets.model('villager');`
|
|
9
|
+
- `assets.geometry(nameOrUrl: string) → Promise<BufferGeometry>` — Get the geometry of the first mesh in a model
|
|
10
|
+
- `assets.texture(nameOrUrl: string, opts?: { color?, pixelated?, repeat? }) → Promise<Texture>` — Get a texture (.ktx2 compressed textures also work)
|
|
11
|
+
- `assets.release(name: string)` — Release a resource and return GPU memory. Not released while copies of the model are still in the scene; it is released when the last copy is removed with engine.remove
|
|
12
|
+
- `assets.trim() → string[]` — Release every model that has no copy in use (called automatically after level changes). Models whose shared geometry was taken by geometry() / cached() are not released automatically. Returns the released names
|
|
13
|
+
- `assets.users(name: string) → number` — How many copies of this model are in use now (taken with model() and not yet removed with engine.remove)
|
|
14
|
+
- `assets.forget(obj: Object3D)` — Called when an object is fully removed (engine.remove already calls it, normally you don't need to): decrements the use count of the model copies under it
|
|
15
|
+
- `assets.cached(name: string, build: (params?: any) => T | Promise<T>, params?: any) → Promise<T>` — Code-generated model: generated only once per name + params, returns a copy (for geometry, the same one). Order: files baked by npm run bake (public/models/baked/) -> automatic dev cache (.threedog/cache, invalidated automatically when the generator or a file it imports changes) -> compute now. When the generator is newer than the baked file during development, it computes now and prints a one-time hint "run npm run bake once it is final"
|
|
16
|
+
- `assets.animate(root: Object3D, config?: AnimatorOptions) → Animator` — Create an animation state machine for a skinned model (without config it is simple play-by-name). A copy of a manifest model whose entry has `animation` starts from that mapping; config wins per state
|
|
17
|
+
- `assets.mapping(root: Object3D) → AnimatorOptions | null` — The manifest entry's animation mapping for a model copy, or null (not a manifest copy, or no mapping)
|
|
18
|
+
- `assets.report(nameOrRoot: string | Object3D) → AssetReport` — Import report of a loaded model (by name, or a copy from model()): materials, textures with colorSpace, clips, colliders, templates, and issues for what the file has but the scene lost
|
|
19
|
+
- `assets.reportText(nameOrRoot: string | Object3D) → string` — assets.report as text for the console / describe
|
|
20
|
+
- Properties:
|
|
21
|
+
- `cacheMinMs: number` Generations faster than this many milliseconds are not written to the automatic cache (reading the file would be slower), default 20
|
|
22
|
+
- `shared: WeakSet<object>` Geometry and materials shared by model copies (engine.remove does not release them, use release)
|
|
23
|
+
- `memory: { geometries: number; textures: number }` Current GPU memory usage (number of geometries and textures)
|
|
24
|
+
- `gltf: any` three.js GLTFLoader (Meshopt installed; Draco and KTX2 are installed the first time they are needed)
|
|
25
|
+
- `draco: any` three.js DRACOLoader (created only the first time Draco compression is met, null before; the decoder defaults to the one bundled with three, vite packs it automatically)
|
|
26
|
+
- `ktx2: any` three.js KTX2Loader (created only the first time a KTX2 texture is met, null before)
|
|
27
|
+
|
|
28
|
+
## Data structures
|
|
29
|
+
- **AssetManifest** An asset manifest, also the shape of an asset pack (a folder or npm package exporting one): names -> files or generators; content and code use the names only
|
|
30
|
+
- `name?: string` Label shown as the source manifest in engine.loading (default 'manifest#1', '#2'...)
|
|
31
|
+
- `base?: string | URL` Folder that this manifest's relative paths resolve against: '/packs/forest/', a CDN URL, or new URL('./files/', import.meta.url) in an npm pack. '/x' and full URLs stay as written
|
|
32
|
+
- `models?: Record<string, AssetEntry>` Models (.glb / .gltf, Draco/Meshopt compression also works): name -> path or generator function
|
|
33
|
+
- `textures?: Record<string, AssetEntry>` Textures: name -> path
|
|
34
|
+
- `sounds?: Record<string, AssetEntry>` Sounds: name -> path
|
|
35
|
+
- `fonts?: Record<string, string | FontAssetEntry>` Fonts: name -> file, or { url, family, weight, style, ... } (family defaults to the name). style.ui.fonts lists the names the UI uses
|
|
36
|
+
- **AnimatorOptions** Animation state machine parameters
|
|
37
|
+
- `fade?: number` Default transition seconds, default 0.25 (style pack style.character.animation.fade)
|
|
38
|
+
- `states?: Record<string, AnimatorState>` States: name → state
|
|
39
|
+
- `transitions?: Record<string, number>` Transition seconds for specific pairs: { 'jump>fall': 0.1, '*>idle': 0.3 }
|
|
40
|
+
- `params?: Record<string, number>` Initial parameter values
|
|
41
|
+
- **AnimatorState** An animation state: clip is the clip name; or blend is a blend tree (blends several clips by the param parameter); loop: false is a one-shot clip
|
|
42
|
+
- `clip?: string` Clip name (the clip name in the glTF)
|
|
43
|
+
- `blend?: { clip: string; at: number }[]` Blend tree: at the parameter value at it is fully this clip, in between they blend proportionally, e.g. [{ clip: 'Walk', at: 1.5 }, { clip: 'Run', at: 6 }]
|
|
44
|
+
- `param?: string` Which parameter the blend tree reads (set by anim.set), default 'speed'
|
|
45
|
+
- `sync?: boolean` Align the strides of blended clips, default true
|
|
46
|
+
- `loop?: boolean` Loop, default true; with false the anim:end event fires when it finishes
|
|
47
|
+
- `then?: string` Which state a one-shot clip goes to when it finishes
|
|
48
|
+
- `lock?: boolean` go() cannot interrupt it while playing
|
|
49
|
+
- `timing?: number | [number, number][]` For sync(): gameplay seconds -> clip seconds. A number = the gameplay length the whole clip is stretched over; [[gameT, clipT], ...] = piecewise linear (land the swing on the hit phase). Without it clip seconds = t
|
|
50
|
+
- **Animator** Skeletal animation state machine (returned by engine.assets.animate(model, config))
|
|
51
|
+
- `mixer: any` three.js AnimationMixer
|
|
52
|
+
- `actions: Map<string, any>` clip name → three.js AnimationAction
|
|
53
|
+
- `state: string | null` Current state name
|
|
54
|
+
- `states: Record<string, AnimatorState>` State configuration (states can be added directly)
|
|
55
|
+
- `params: Record<string, number>` Parameters (used by blend trees)
|
|
56
|
+
- `set(param: string, value: number)` — Set a parameter, e.g. set('speed', 3)
|
|
57
|
+
- `go(state: string, fade?: number) → any` — Switch to a state (fade is the transition seconds); null (dev warning) if there is no such state / clip; ignored while sync() drives a state
|
|
58
|
+
- `action(name: string, fade?: number) → any` — One-shot clip: state name or clip name, returns to then or the previous state when done; go() cannot interrupt it while playing
|
|
59
|
+
- `sync(state: string | null, t?: number) → any` — Gameplay drives the clock: show state at gameplay time t (fixed-step seconds) through its timing. The clip never advances or ends by itself and go() leaves it alone; sync(null) hands control back
|
|
60
|
+
- `describe() → AnimatorInfo` — What is showing: state, clip, clip time, progress, driven, weights
|
|
61
|
+
- `check(actions?: string[]) → string[]` — Check the mapping against the action names the game plays: each problem as text with its fix ([] = all will play). Example: `anim.check(['idle', 'walk', 'attack', 'hurt'])`
|
|
62
|
+
- `dispose()` — Stop the per-frame update when no longer needed
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# engine.audio (Audio) — engine.audio: buses, sounds by name, ducking
|
|
2
|
+
|
|
3
|
+
- `audio.addBus(name: string, level?: number)` — Add a bus of your own (routed to master). It gets a settings slider like the others (label key settings.vol.<name>). Example: `engine.audio.addBus('voice', 1); engine.audio.sfx('line-01', { bus: 'voice' });`
|
|
4
|
+
- `audio.setVolume(bus: string, v: number)` — Set a bus volume 0-1 ('master' for the total). Example: `engine.audio.setVolume('music', 0.3);`
|
|
5
|
+
- `audio.duck(levels: Record<string, number>, opts?: { fade?: number }) → { remove(fade?: number): void }` — Lower buses until the handle is removed (dialogue, pause menu, a cutscene). Several ducks stack (their levels multiply). Example: `const d = engine.audio.duck({ music: 0.3, ambience: 0.5 }); engine.events.once('dialogue:end', () => d.remove());`
|
|
6
|
+
- `audio.register(name: string, synthFn: SynthFn, opts?: { builtIn?, bus?, params? })` — Register a synthesized sound: synthFn(audio, params, out) connects its nodes to `out` and returns its length in seconds (or { stop(time) } for a loop). Plays for sounds entries that name it ('synth' or { synth: name }); a name with no sounds entry plays it too unless builtIn (engine modules pass builtIn: true so their synths stay silent until the game asks). Example: `engine.audio.register('ding', (a, p, out) => { a.tone({ freq: 880 * p.pitch, dur: 0.2, out }); return 0.2; });`
|
|
7
|
+
- `audio.condition(name: string, test: (value: any, e: any) => boolean) → { remove(): void }` — Add a condition key for music / ambience rule lists: `when: { [name]: value }` calls test(value, engine). Modules add theirs (sky: time, weather: weather, triggers: zone); the engine has `state` (engine.audio.state). Example: `engine.audio.condition('inside', v => engine.vars.flag('indoors') === v);`
|
|
8
|
+
- `audio.measure(name: string, fn: (e: any) => number) → { remove(): void }` — Add a measure: a number rule data compares (`when: { daylight: { gt: 0.15 } }`; gt / gte / lt / lte) and adds up (`volume: { add: { wind: 0.08 } }`). sky adds daylight, weather rain / snow / wind, ambience nearWater / altitude. A name is a condition or a measure, not both. Example: `engine.audio.measure('danger', e => e.vars.counter('alarm') / 10); // data: when: { danger: { gt: 0.5 } }`
|
|
9
|
+
- `audio.value(name: string) → number | undefined` — The current value of a measure (debug, tests); undefined when none is registered under that name
|
|
10
|
+
- `audio.matches(when: AudioCondition | undefined, ...extra: any[]) → boolean` — Does a rule's `when` hold now? An object needs every key to hold (condition keys, or measure comparisons); a function gets (engine, ...extra); missing = always. Example: `engine.audio.matches({ time: 'night', zone: 'forest', rain: { lt: 0.2 } });`
|
|
11
|
+
- `audio.volumeOf(volume: AudioVolume | undefined, ...extra: any[]) → number` — A rule's volume now: a number, a function (engine, ...extra), or data { base, add: { measure: factor }, min, max }; missing = 1. Example: `engine.audio.volumeOf({ base: 0, add: { rain: 0.22 } }); // 0.22 in full rain`
|
|
12
|
+
- `audio.sfx(name: string, opts?: { volume?, pitch?, at?, bus?, loop?, params?, … }) → SoundHandle | null` — Play a sound by name from audio.sounds (file, variants, or a synth). Returns a SoundHandle (stop, fade, setPosition), or null when it is silent: not configured, audio still locked, or held back by the sound's cooldown. Over its `voices` limit the oldest voice stops. Example: `engine.audio.sfx('hit', { at: enemy.root, volume: 0.8 });`
|
|
13
|
+
- `audio.noiseBurst(opts?: { dur?, type?, freq?, vol?, bus?, out?, … })` — Synth building block: a burst of filtered noise (footsteps, shutter, rain, thunder). dur seconds, freq Hz, vol 0-1; out: the node to connect to (a synth's `out`), else the named bus
|
|
14
|
+
- `audio.tone(opts?: { freq?, to?, dur?, vol?, type?, bus?, … })` — Synth building block: a short tone (bird call, notification). freq/to Hz, dur seconds, pan -1..1; out as in noiseBurst. Example: `engine.audio.tone({ freq: 660, to: 880, dur: 0.15, bus: 'ui' });`
|
|
15
|
+
- `audio.load(url: string) → Promise<any>` — Download and decode an audio file (cached). A sound name registered in an asset pack (manifest sounds) loads that file as an engine.loading task, so sounds entries and music tracks may name assets instead of paths
|
|
16
|
+
- `audio.play(url: string, opts?: { bus?, volume?, loop?, fadeIn?, pitch?, at? }) → Promise<SoundHandle | null>` — Play an audio file by path (no sounds entry needed); resolves to a SoundHandle once the file is decoded. Example: `const h = await engine.audio.play('/sfx/door.ogg', { bus: 'ui' }); h.stop(0.5);`
|
|
17
|
+
- Properties:
|
|
18
|
+
- `ctx: any` The browser AudioContext (exists only after the first click)
|
|
19
|
+
- `levels: Record<string, number>` Volume per bus 0-1 ('master' is the total). Every key is a bus: levels: { voice: 1 } adds a 'voice' bus
|
|
20
|
+
- `config: import("../../core").AudioConfig` The game's sound config from createEngine({ audio }); sounds and footsteps also hold content packs' (copies: the game's object is never changed). Content packs' ambience / music rules go to ambience() / music(), not here
|
|
21
|
+
- `buses: Record<string, any>` Bus input GainNodes by name (connect your own nodes here); empty until audio unlocks
|
|
22
|
+
- `state: string | null` The game's current mode for rule lists, e.g. 'combat' / 'explore' (condition `state` in music and ambience rules)
|
|
23
|
+
- `master: any` The master GainNode (every bus ends here)
|
|
24
|
+
- `noise: any` 2 s of white noise, reused by synthesized sounds
|
|
25
|
+
- `running: boolean` Is audio usable (the player has clicked/pressed a key)?
|
|
26
|
+
- `info: { running, state, levels, ducks, voices }` What is playing (for describe and tests): bus levels, the duck multiplier per bus, live voices per sound name
|
|
27
|
+
|
|
28
|
+
## Data structures
|
|
29
|
+
- **AudioConfig** The game's sound config: createEngine({ audio }), read back as engine.audio.config (merged with content packs' ContentAudio). Not part of a style pack
|
|
30
|
+
- `sounds?: Record<string, SoundSource>` Sound name -> file / variants / 'synth' / SoundDef
|
|
31
|
+
- `ambience?: AmbienceRule[]` ambience() rule table
|
|
32
|
+
- `music?: { tracks?, rules?, fade?, duckDialogue?, duckFade?, hold?, … }` music() defaults: tracks, rules, fade seconds, duckDialogue (how low the music bus ducks during dialogue; default false = no duck)
|
|
33
|
+
- `footsteps?: Record<string, string>` Ground type (terrain groundType or level material name) -> sound name; 'water' while swimming; default for unmapped types (else 'footstep')
|
|
34
|
+
- `levels?: Record<string, number>` Volume per bus 0-1, default { master: 0.8, music: 0.5, sfx: 0.8, ambience: 0.7, ui: 0.8 }; an extra key adds a bus
|
|
35
|
+
- **SoundDef** One sounds entry in full form. src: a file or variants (random, no immediate repeat); synth: a registered synth name (default: the entry's own name)
|
|
36
|
+
- `src?: string | string[]`
|
|
37
|
+
- `synth?: string`
|
|
38
|
+
- `params?: Record<string, any>` Passed to the synth (merged over its registered defaults)
|
|
39
|
+
- `bus?: AudioBus` Bus it plays on (default 'sfx', or the synth's registered bus)
|
|
40
|
+
- `volume?: number`
|
|
41
|
+
- `pitch?: number` Playback rate multiplier (1 = as recorded); synths get it as params.pitch
|
|
42
|
+
- `jitter?: { volume?: number; pitch?: number }` Random spread per play, as a fraction: { pitch: 0.08 } = +-8%
|
|
43
|
+
- `cooldown?: number` Seconds before the same sound can start again (calls inside it return null)
|
|
44
|
+
- `voices?: number` Most voices of this sound at once; the oldest stops for a new one (default unlimited)
|
|
45
|
+
- `loop?: boolean`
|
|
46
|
+
- `distance?: { ref?: number; max?: number; rolloff?: number }` 3D falloff for sfx(name, { at }): ref meters at full volume (2), max meters (60), rolloff (1)
|
|
47
|
+
- **AmbienceRule** One ambience rule: while `when` holds, `sound` plays at `volume`. With `every` it is a one-shot repeated at random gaps, else a loop
|
|
48
|
+
- `sound: string`
|
|
49
|
+
- `when?: AudioCondition`
|
|
50
|
+
- `volume?: number | AudioVolumeData | ((e, ambience) => number)` 0-1, data { base, add: { measure: factor }, min, max }, or a function of the moment (e, ambience) => 0-1 (code only)
|
|
51
|
+
- `fade?: number` Fade seconds when the rule turns on / off (1)
|
|
52
|
+
- `every?: number[]` One-shot: [shortest, longest] seconds between plays
|
|
53
|
+
- `bus?: AudioBus` Bus (default 'ambience')
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# engine.budget (Budget) — engine.budget: performance budget (turned on by createEngine({ budget }) or enable(); off by default, costs nothing)
|
|
2
|
+
|
|
3
|
+
- `budget.enable(limits?: BudgetLimits)` — Turn on and set limits (only categories given are checked). Example: `engine.budget.enable({ drawCalls: 250, fps: 55 });`
|
|
4
|
+
- `budget.disable()` — Turn off
|
|
5
|
+
- `budget.metric(name: string, read: () => number, opts?: { limit?: number }) → Handle` — Module-defined category: read() returns the current value, opts.limit is the limit (the game's enable() takes precedence). Returns a handle { remove() }
|
|
6
|
+
- `budget.limitOf(name: string) → number | undefined` — Limit of a category; undefined if none was given (not checked)
|
|
7
|
+
- `budget.report() → BudgetReport | null` — Budget report; null when off. In the real-time loop it returns the last second's result; in step() mode it is computed on demand
|
|
8
|
+
- `budget.checkStartup(s: { totalMs, modules }) → { category, value, limit, top }[]` — Called by the engine when startup finishes: warns if startupMs / moduleMs is exceeded and returns the offenders (empty array if none)
|
|
9
|
+
- `budget.values() → Record<string, number>` — Current value per category (fps/low1/cpuMs exist only once there are frame times)
|
|
10
|
+
- `budget.byTag() → BudgetTagStat[]` — Estimate draw calls and triangles by userData.budgetTag (visible meshes inside the frustum; shadow casters count a second shadow draw). Returns [{ tag, drawCalls, triangles }], largest first. Called only on overrun (at most once a second) or when debugging
|
|
11
|
+
- Properties:
|
|
12
|
+
- `enabled: boolean` Is it on?
|
|
13
|
+
- `limits: BudgetLimits` Current limits
|
|
14
|
+
- `cost: ApplyCost` Cost of applying background results, split in stages (see ApplyCost)
|
|
15
|
+
|
|
16
|
+
## Data structures
|
|
17
|
+
- **BudgetLimits** Budget limits: only the given categories are checked. fps/low1 are lower bounds (frame rate must not drop below), the rest are upper bounds
|
|
18
|
+
- `drawCalls?: number` Draw calls
|
|
19
|
+
- `fps?: number` Average frame rate (lower bound)
|
|
20
|
+
- `low1?: number` Worst 1% frame rate (lower bound)
|
|
21
|
+
- `cpuMs?: number` CPU milliseconds per frame
|
|
22
|
+
- `triangles?: number` Triangle count
|
|
23
|
+
- `textures?: number` Texture count
|
|
24
|
+
- `chunkApplyMs?: number` Terrain chunk upload milliseconds per frame
|
|
25
|
+
- `rigidBodies?: number` Rigid body count
|
|
26
|
+
- `applyTransitMs?: number` Per-frame cost of applying background results, by stage (engine.budget.cost): worker transit (approximate), creating three.js objects, colliders, GPU upload (approximate), stream build()
|
|
27
|
+
- `applyBuildMs?: number`
|
|
28
|
+
- `applyColliderMs?: number`
|
|
29
|
+
- `applyUploadMs?: number`
|
|
30
|
+
- `applyStreamMs?: number`
|
|
31
|
+
- `startupMs?: number` Time from opening to playable (milliseconds); when exceeded, the slowest module is named
|
|
32
|
+
- `moduleMs?: number` Single module startup (init + wait for ready, milliseconds); when exceeded, that module is named
|
|
33
|
+
- **BudgetReport** Budget report: ok means everything is within budget
|
|
34
|
+
- `ok: boolean`
|
|
35
|
+
- `over: BudgetOver[]`
|
|
36
|
+
- **BudgetOver** One overrun: top is the biggest draw-call contributors grouped by userData.budgetTag
|
|
37
|
+
- `category: string`
|
|
38
|
+
- `value: number`
|
|
39
|
+
- `limit: number`
|
|
40
|
+
- `top: BudgetTagStat[]`
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# engine.cameraRig — followCamera(opts?: FollowCameraOptions) / firstPersonCamera(opts?: FirstPersonCameraOptions) / fixedCamera(opts?: FixedCameraOptions) / rtsCamera(opts?: RtsCameraOptions)
|
|
2
|
+
|
|
3
|
+
Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamera)
|
|
4
|
+
|
|
5
|
+
- followCamera options `FollowCameraOptions`:
|
|
6
|
+
- `yaw?: number` Which side of the focus the camera sits on (radians), default 0.8: camera = focus + (sin yaw, cos yaw) × distance, it looks along forward() = -(sin yaw, cos yaw). Behind a character facing f: yaw = f + PI
|
|
7
|
+
- `pitch?: number` Pitch angle (radians), default 0.42
|
|
8
|
+
- `distance?: number` Distance (meters), default 13
|
|
9
|
+
- `minDistance?: number` Zoom range (meters)
|
|
10
|
+
- `maxDistance?: number`
|
|
11
|
+
- `height?: number` How high above the character to look at (meters), default 1.4
|
|
12
|
+
- `smoothing?: number` Follow smoothing, default 10
|
|
13
|
+
- `sensitivity?: number` Drag sensitivity, default 1
|
|
14
|
+
- `minPitch?: number` Pitch range (radians)
|
|
15
|
+
- `maxPitch?: number`
|
|
16
|
+
- `zoomStep?: number` Zoom ratio per wheel notch, default 0.1
|
|
17
|
+
- `groundClearance?: number` Minimum camera height above the ground (meters), default 1.2
|
|
18
|
+
- `invertY?: boolean` Invert vertical
|
|
19
|
+
- `lockPitch?: boolean` Lock the pitch angle (top-down games)
|
|
20
|
+
- `shoulder?: number` Over-the-shoulder offset: meters to the right of the target the camera aims (negative = left shoulder), default 0
|
|
21
|
+
- `pointerLock?: boolean` Click locks the mouse; mouse motion turns the view without dragging (Esc releases), default false
|
|
22
|
+
- `swallowLockClick?: boolean` The press that locks the mouse is not delivered as Mouse0 / a click (default true); false delivers it too
|
|
23
|
+
- firstPersonCamera options `FirstPersonCameraOptions`:
|
|
24
|
+
- `height?: number` Eye height above the feet (meters), default 1.6
|
|
25
|
+
- `sensitivity?: number` Mouse sensitivity, default 1
|
|
26
|
+
- `fov?: number | null` Field of view (degrees); unchanged if omitted
|
|
27
|
+
- `headBob?: number` Walking bob amplitude (meters), 0 off, default 0.04
|
|
28
|
+
- `bobFrequency?: number` Bobs per meter
|
|
29
|
+
- `hideTarget?: boolean` Hide the character itself (its shadow remains), default true
|
|
30
|
+
- `hideLayer?: number` Layer number used for hiding 0–31
|
|
31
|
+
- `pointerLock?: boolean` Click to lock the mouse, default true
|
|
32
|
+
- `swallowLockClick?: boolean` The press that locks the mouse is not delivered as Mouse0 / a click (default true); false delivers it too
|
|
33
|
+
- `yaw?: number` Initial heading (radians)
|
|
34
|
+
- `pitch?: number`
|
|
35
|
+
- `minPitch?: number` Look down / up limit (radians)
|
|
36
|
+
- `maxPitch?: number`
|
|
37
|
+
- `yawLimits?: number[] | null` Turn range left / right [min, max] (radians), unlimited by default
|
|
38
|
+
- `smoothing?: number` Smoothing of the camera following the body
|
|
39
|
+
- `invertY?: boolean` Invert vertical
|
|
40
|
+
- fixedCamera options `FixedCameraOptions`:
|
|
41
|
+
- `shots?: Record<string, CameraShot>` Shots: name → shot
|
|
42
|
+
- `start?: string | null` Initial shot name
|
|
43
|
+
- `auto?: false | 'nearest'` Automatic switching: false / 'nearest' (pick the one nearest to the player)
|
|
44
|
+
- `autoInterval?: number` Check interval for automatic switching (seconds)
|
|
45
|
+
- `hysteresis?: number` How many meters closer a new shot must be to switch (prevents flipping back and forth)
|
|
46
|
+
- `triggerBlend?: number` Transition seconds for trigger-zone switches (0 = hard cut)
|
|
47
|
+
- `trackHeight?: number` How high above the character a track shot looks (meters)
|
|
48
|
+
- `trackSmoothing?: number` Head-follow smoothing
|
|
49
|
+
- `holdDirection?: boolean` Keep the direction when switching shots until the direction key is released
|
|
50
|
+
- `ease?: Ease` Transition easing
|
|
51
|
+
- rtsCamera options `RtsCameraOptions`:
|
|
52
|
+
- `height?: number` Camera height above the focus (meters), default 30
|
|
53
|
+
- `minHeight?: number` Zoom range (meters)
|
|
54
|
+
- `maxHeight?: number`
|
|
55
|
+
- `angle?: number` Pitch down angle (radians, π/2 = straight down), default 0.95
|
|
56
|
+
- `yaw?: number` Initial horizontal heading (radians)
|
|
57
|
+
- `panSpeed?: number` Pan speed multiplier
|
|
58
|
+
- `dragPan?: boolean` Drag with the mouse to pan, default true
|
|
59
|
+
- `edgePan?: boolean` Pan at the screen edge, default false
|
|
60
|
+
- `edgeSize?: number` Edge width (fraction of the screen)
|
|
61
|
+
- `bounds?: { minX?, maxX?, minZ?, maxZ? } | null` Focus range (meters)
|
|
62
|
+
- `rotateKeys?: { left?: string[]; right?: string[] } | false` Rotate keys, false turns rotation off
|
|
63
|
+
- `rotateSpeed?: number` Rotation speed (radians/second)
|
|
64
|
+
- `zoomStep?: number` Zoom ratio per wheel notch
|
|
65
|
+
- `smoothing?: number` Smoothing
|
|
66
|
+
- `fov?: number | null` Field of view (degrees); unchanged if omitted
|
|
67
|
+
- `followLock?: boolean` Manual panning is not allowed while following
|
|
68
|
+
- `start?: PositionLike | null` Initial focus (position)
|
|
69
|
+
|
|
70
|
+
## Methods and properties
|
|
71
|
+
- `cam.follow(obj: Object3D | null, opts?: { distance?, height? })` — Follow someone (called automatically when the player is created), null to cancel. opts temporarily changes distance / height (used while driving), restored when the target changes
|
|
72
|
+
- `cam.forward() → DirXZ` — The "forward" direction on the horizontal plane (player movement is relative to it)
|
|
73
|
+
- `cam.right() → DirXZ` — The "right" direction on the horizontal plane
|
|
74
|
+
- `cam.focusPoint() → Vector3` — Where the world loads around
|
|
75
|
+
- `cam.update(dt: number, input: Input)` — Update the camera every frame
|
|
76
|
+
- `cam.onOverride(on: boolean)` — Called when a cutscene takeover starts / ends
|
|
77
|
+
- `cam.onEnter(switched?: boolean)` — Called when this camera is switched in (switched: switched at runtime)
|
|
78
|
+
- `cam.onExit()` — Called when this camera is switched out
|
|
79
|
+
- Properties:
|
|
80
|
+
- `kind: CameraKind` Current kind (the first argument of engine.setCamera)
|
|
81
|
+
- `target: Object3D | null` The object being followed
|
|
82
|
+
- followCamera only: every item of the options (the options of `followCamera`) can be read and written at runtime, e.g. `engine.cameraRig.yaw = 1.2`, `pitch`
|
|
83
|
+
- `cam.frame(target: Object3D | Vec3Like | null, opts?: { strength?: number })` — Lock-on framing: turn yaw each frame toward "behind the followed object, looking at target"; mouse yaw is ignored meanwhile; null hands yaw back. strength default 6 (1/s)
|
|
84
|
+
- `focus: Vector3` Smoothed follow point
|
|
85
|
+
- `lockPitch?: boolean`
|
|
86
|
+
- `avoidOcclusion?: boolean` false: no occlusion handling
|
|
87
|
+
- `framing: { target: Object3D | Vec3Like; strength: number } | null` Lock-on framing set by frame()
|
|
88
|
+
- firstPersonCamera only: every item of the options (the options of `firstPersonCamera`) can be read and written at runtime, e.g. `engine.cameraRig.yaw = 1.2`, `pitch`
|
|
89
|
+
- `cam.lookAt(position: PositionLike)` — Turn toward a world position (Vector3 / object / [x, y, z] / { x, y, z })
|
|
90
|
+
- `eye: Vector3` Eye position
|
|
91
|
+
- fixedCamera only:
|
|
92
|
+
- `cam.add(name: string, shot: CameraShot)` — Add / replace a shot
|
|
93
|
+
- `cam.cut(name: string)` — Cut to a shot immediately
|
|
94
|
+
- `cam.blend(name: string, seconds?: number, ease?: Ease) → Promise<void>` — Transition smoothly to a shot (over seconds seconds); the Promise resolves when done
|
|
95
|
+
- `cam.nearest(p: Vector3) → string | null` — Name of the shot nearest to a point
|
|
96
|
+
- `shots: Record<string, any>` All shots
|
|
97
|
+
- `current: string | null` Current shot name
|
|
98
|
+
- `auto: false | 'nearest'`
|
|
99
|
+
- `autoInterval: number`
|
|
100
|
+
- `hysteresis: number`
|
|
101
|
+
- `triggerBlend: number`
|
|
102
|
+
- `trackHeight: number`
|
|
103
|
+
- `trackSmoothing: number`
|
|
104
|
+
- `holdDirection: boolean`
|
|
105
|
+
- `ease: Ease`
|
|
106
|
+
- rtsCamera only: every item of the options (the options of `rtsCamera`) can be read and written at runtime, e.g. `engine.cameraRig.yaw = 1.2`, `pitch`
|
|
107
|
+
- `cam.moveTo(position: PositionLike, opts?: { instant?: boolean })` — Move the view to position (instant: true skips smoothing)
|
|
108
|
+
- `cam.screenToGround(ndcX: number, ndcY: number) → Vector3 | null` — Screen coordinates (-1..1) → a point on the ground, null if nothing is hit
|
|
109
|
+
- `following: boolean` Is it following target
|
|
110
|
+
- `focus: Vector3` Focus (on the ground)
|
|
111
|
+
- `rotate: boolean` Can it rotate
|
|
112
|
+
|
|
113
|
+
## Data structures
|
|
114
|
+
- **CameraShot** Fixed shot
|
|
115
|
+
- `position: Vec3Like` Camera position
|
|
116
|
+
- `lookAt?: Vec3Like` Fixed point to look at (if omitted, it turns its head with the player)
|
|
117
|
+
- `track?: boolean` Turn its head with the player
|
|
118
|
+
- `fov?: number` Field of view (degrees)
|
|
119
|
+
- `at?: Vec3Like` Position used to judge the "nearest shot", defaults to position
|
|
120
|
+
- `trackHeight?: number` How high above the character to look at (meters)
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# engine.characters — characters(opts?: CharactersOptions)
|
|
2
|
+
|
|
3
|
+
Characters: createPlayer() (characters() module)
|
|
4
|
+
|
|
5
|
+
- Options `CharactersOptions`:
|
|
6
|
+
- `npcs?: boolean` Whether to enable NPCs (engine.npcs), default true
|
|
7
|
+
- `brakeKeys?: string[]` Brake key when driving (action brake, registered when rigid is installed), none by default (no brake while driving; one warning names the fix); presets.keys.brake has ['KeyB'] (so it doesn't fight with Space for jump)
|
|
8
|
+
- `brakePad?: string[]` Gamepad button for braking, none by default; presets.keys.brake has ['PadLT']
|
|
9
|
+
|
|
10
|
+
## Methods and properties
|
|
11
|
+
- `characters.findSpawn(position?: PositionLike, opts?: FindSpawnOptions) → Vector3` — Find a spawn point: searches outward from position (default origin) for walkable (not steep, no obstacle), non-water ground, without assuming terrain height; e.g. findSpawn(v, { minH: 3, maxH: 20 }). Returns a Vector3 (y is the ground height)
|
|
12
|
+
- `characters.createPlayer(opts: PlayerOptions) → Character` — Create the player and set engine.player; control is required (no default feel), e.g. createPlayer({ ...presets.player.thirdPerson, spawn }). An existing player is deleted first
|
|
13
|
+
- `characters.moveInput() → { x, z, run, speed? }` — The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it inside your own control function to wrap it
|
|
14
|
+
- `characters.removePlayer()` — Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
|
|
15
|
+
- `characters.findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }) → XZ[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: FindPathOptions & { detailed: true }) → PathResult` — Pathfinding (the single entry point): uses the navmesh when nav is installed and ready, otherwise the A* fallback. Returns a path [{ x, z }...], or null if unreachable
|
|
16
|
+
- `characters.findPathAsync(from: PositionLike, to: PositionLike, done: (path, status) => void, opts?: { radius?, step?, maxNodes? }) → { remove(): void }` — findPath for many callers (NPC crowds, AI squads): solved in engine.threads workers; done(path, status) runs on a fixed step a few steps later (same paths with threads on or off). Recipe 12 section 4
|
|
17
|
+
- Properties:
|
|
18
|
+
- `pathsPerStep: number` How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps
|
|
19
|
+
|
|
20
|
+
## Character (engine.player / NPC are both Character)
|
|
21
|
+
- `player.push(vx: number, vz: number, seconds: number)` — Move at a fixed velocity (m/s) for seconds, ignoring move()'s direction and without turning (knockback, dodge roll); gravity and collision still apply
|
|
22
|
+
- `player.enter(vehicle: Vehicle)` — Board a vehicle (the vehicle returned by rigid.addVehicle)
|
|
23
|
+
- `player.exit()` — Exit the vehicle
|
|
24
|
+
- `player.playAction(name: string)` — Play a one-shot action (e.g. 'wave'); skipped if the model has no such clip
|
|
25
|
+
- `player.onPose(fn: (character, dt) => void) → { remove(): void }` — Run fn(character, dt) every frame right after the animation pose is applied (model clips or procedural rig): attach things to bones or adjust bones. h.remove() stops it. Presentation only. Example: `const h = player.onPose(() => sword.position.copy(hand.getWorldPosition(v)));`
|
|
26
|
+
- `player.dispose()` — Fully delete this character: exits the vehicle first, releases animation and movement, removes it from the scene and releases geometry and materials (used by npcs.remove / removePlayer)
|
|
27
|
+
- `player.jump()` — Request a jump
|
|
28
|
+
- `player.addTo(scene?: any)` — Add to the scene
|
|
29
|
+
- `player.placeAt(position: PositionLike)` — Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z })
|
|
30
|
+
- `player.syncRecord()` — After moving root yourself (a cutscene path, a scripted pose): write position and motion back to its world record (the player's), so a save right after has it
|
|
31
|
+
- `player.walkTo(target: Vector3 | { x: number; z: number } | [number, number, number] | …, opts?: { speed?, arrive?, turnRate?, stuckSeconds?, maxRepaths?, run? }) → Promise<{ status: 'arri… & { remove(): void }` — Walk to a point along characters.findPath on fixed steps; never rejects. One walk per character: a new walkTo, dispose() or a save load ends the old one with 'cancelled'. Transient: not saved, not fast-forwarded by engine.skip
|
|
32
|
+
- `player.move(dirX: number, dirZ: number, run: boolean, dt: number, speedOverride?: number)` — Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1), run to run, dt in seconds
|
|
33
|
+
- `player.groundType() → string` — Ground type underfoot ('water' while swimming)
|
|
34
|
+
- `player.face(target: PositionLike | number)` — Turn at once to a position, or to an angle in radians (0 = +Z)
|
|
35
|
+
- `player.saveMotion(out?: CharacterMotion) → CharacterMotion` — Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
|
|
36
|
+
- `player.loadMotion(m: CharacterMotion | null | undefined)` — Restore the motion state from the plain object of saveMotion
|
|
37
|
+
- Properties:
|
|
38
|
+
- `root: Object3D` Root node (this is what gets added to the scene)
|
|
39
|
+
- `object: Object3D` Same as root: add children, change visible and scale on it
|
|
40
|
+
- `position: Vector3` Position (= root.position)
|
|
41
|
+
- `velocity: Vector2` Horizontal velocity (x, y map to world x, z)
|
|
42
|
+
- `facing: number` Heading (radians): 0 faces +Z, forward = (sin facing, cos facing); increasing turns toward +X (rotation about the Y axis, consistent with root.rotation.y)
|
|
43
|
+
- `vy: number` Vertical velocity (m/s)
|
|
44
|
+
- `grounded: boolean` Whether standing on the ground
|
|
45
|
+
- `swimming: boolean` Whether swimming
|
|
46
|
+
- `state: CharacterState` Current action state
|
|
47
|
+
- `moveAmount: number` Current movement speed (m/s)
|
|
48
|
+
- `faceMode: FaceMode` Facing mode, change at any time; see CharacterOptions.faceMode
|
|
49
|
+
- `faceTarget: PositionLike | null` What faceMode 'target' faces
|
|
50
|
+
- `control?: PlayerControl` Player only: who moves it each fixed step (see PlayerOptions.control)
|
|
51
|
+
- `cameraFollow?: boolean` Player only: whether the camera module follows it (see PlayerOptions.cameraFollow)
|
|
52
|
+
- `onStep: ((groundType: string) => void) | null` Called when a foot lands (the argument is the ground type underfoot)
|
|
53
|
+
- `onLand: ((impact: number) => void) | null` Called on landing (the argument is the landing speed)
|
|
54
|
+
- `mover: { name, controller?, body?, collider?, move, dispose? }` Movement method; name is 'simple' / 'rapier', controller is the native Rapier character controller (when rapier)
|
|
55
|
+
- `anim: Animator | null` Skeletal animation state machine (when there is a glTF model; null while a model named by asset is still loading)
|
|
56
|
+
- `ready: boolean` false while a model named by asset is loading (the placeholder body shows); true otherwise, also after a failed load (placeholder kept)
|
|
57
|
+
- `whenReady: Promise<void>` Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise. Example: `const npc = new Character(engine, { model: 'villager' }).addTo(); // import { Character } from 'threedog' await npc.whenReady; npc.playAction('Wave');`
|
|
58
|
+
- `vehicle: Vehicle | null` The vehicle being driven (null when not driving)
|
|
59
|
+
|
|
60
|
+
## NPC (engine.npcs.add() returns an NPC (extends Character))
|
|
61
|
+
- `npc.setBehavior(name: string, mind?: Record<string, any>)` — Change behavior (stored in the data, restored by saves). mind is the new behavior's parameters / memory (plain values), cleared if omitted. E.g. npc.setBehavior('wander', { radius: 12 })
|
|
62
|
+
- `npc.currentStop() → ScheduleEntry | null` — The stop it should be heading to now
|
|
63
|
+
- `npc.placeAt(position: PositionLike)` — Teleport to the ground at a position (handed to the mover when there is a model, otherwise the data is changed) and re-pathfind
|
|
64
|
+
- `npc.face(position: PositionLike)` — Face a position (when there is a model)
|
|
65
|
+
- `npc.remove() → boolean` — Delete this NPC (data and model together)
|
|
66
|
+
- Properties:
|
|
67
|
+
- `id: string` Stable id
|
|
68
|
+
- `data: WorldRecord | undefined` The record in world (a plain object; undefined after deletion). Change fields with engine.world.set(npc.id, {...})
|
|
69
|
+
- `schedule: ScheduleEntry[]` Schedule (at converted to 0–1, sorted by time)
|
|
70
|
+
- `behavior: string` Current behavior name
|
|
71
|
+
- `talk: string | null` Dialogue id
|
|
72
|
+
- `state: string` Animation state ('idle' / 'walk'...)
|
|
73
|
+
- `busy: boolean` In dialogue (stopped, not walking)
|
|
74
|
+
- `character: Character | null` The current character model: exists only when nearby; null when far away, in another level, or not yet built
|
|
75
|
+
- `root: Object3D | null` Root object of the current model (= character.root), null when there is no model
|
|
76
|
+
- `object: Object3D | null` Same as root
|
|
77
|
+
- `position: Vector3` Position: the model's position when there is a model (use it read-only, move with placeAt), a copy of the record's position when there is none
|
|
78
|
+
|
|
79
|
+
## Data structures
|
|
80
|
+
- **NPCOptions** (extends CharacterOptions) Parameters of engine.npcs.add({...})
|
|
81
|
+
- `id?: string` Stable id (used by saves, quest targets { npc } and npcs.get); falls back to name if omitted (two NPCs with the same name and no id throw an error). Calling add again with the same id updates the definition and keeps position and state
|
|
82
|
+
- `initial?: boolean` NPC authored in content (everything added by content): the initial record of world; saves only record changes such as position and state, the schedule follows the content; deleted ones do not reappear after loading
|
|
83
|
+
- `name?: string` Name
|
|
84
|
+
- `zone?: string | null` Which zone it belongs to (a level name, see world.zone): when not in this zone only the model is torn down and the data stays; null (default) means it is present everywhere
|
|
85
|
+
- `schedule?: ScheduleStop[]` Schedule (needs the sky module; without it the first entry is always used)
|
|
86
|
+
- `behavior?: string` Behavior name: 'schedule' (default, follows the schedule), 'wander' (roams around home) or a name registered with npcs.behavior()
|
|
87
|
+
- `mind?: Record<string, any>` Behavior parameters and memory (plain values, saved). wander: { radius in meters (8), pause [min, max] seconds ([2, 6]), home { x, z } (defaults to the position when wandering started) }
|
|
88
|
+
- `talk?: string | null` Dialogue script name (needs the dialogue and interactions modules), triggered by pressing the interact key when close
|
|
89
|
+
- `talkLabel?: string | (() => string)` Prompt text (text is stored in the data; a function stays in memory only)
|
|
90
|
+
- `talkRadius?: number` Dialogue distance (meters), default 3.2
|
|
91
|
+
- `pathStep?: number` Pathfinding grid size (meters), default 2
|
|
92
|
+
- `repath?: number` Seconds before re-pathfinding after getting stuck, default 2
|
|
93
|
+
- `arriveDistance?: number` Arrival distance (meters), default 1.2: within 1.2 m of the schedule stop / target counts as arrived and stops, it does not step exactly on the point (call placeAt yourself for an exact spot)
|
|
94
|
+
- `position?: PositionLike` Initial position (Vector3 / object / [x, y, z] / { x, z }); the current schedule stop is used if omitted
|
|
95
|
+
- **ScheduleStop** One schedule stop (the npcs.add form): at is when to set off, position the destination
|
|
96
|
+
- `at: number | string` When to set off: clock time 'HH:MM' (e.g. '18:30'), or a time of day 0–1 (0.25 = 6 am)
|
|
97
|
+
- `position: PositionLike` Destination (Vector3 / object / [x, y, z] / { x, z })
|
|
98
|
+
- **ScheduleEntry** One schedule stop (as stored in npc.schedule after install): at has been converted to 0–1, x/z is the destination (meters)
|
|
99
|
+
- `at: number`
|
|
100
|
+
- `x: number`
|
|
101
|
+
- `z: number`
|
|
102
|
+
- **PlayerOptions** (extends CharacterOptions) Parameters of createPlayer()
|
|
103
|
+
- `spawn?: PositionLike` Spawn point (meters, { x, z } / Vector3 / object); flat ground is found automatically if omitted
|
|
104
|
+
- `jumpKeys?: string[]` Keys of the 'jump' action; none bound when omitted (player.jump() still works). presets.player.* use ['Space', 'PadA']
|
|
105
|
+
- `runKeys?: string[]` Keys of the 'run' action read by control 'camera' / moveInput(); none bound when omitted. presets.player.* use Shift / gamepad LB
|
|
106
|
+
- `control: PlayerControl` Required, no default: 'camera' (keys relative to the camera) / 'none' (call player.move() yourself in onFixed) / (player, input, dt) => ({ x, z, run?, speed? }). Also the runtime property player.control. presets.player.* fill it
|
|
107
|
+
- `cameraFollow?: boolean` true: the camera module follows the player (and back after a vehicle, and on a new session). Omitted with a camera installed warns in dev
|
|
108
|
+
- **CharacterOptions** Character parameters (shared by the player and NPCs)
|
|
109
|
+
- `colors?: { body?, skin?, legs?, hair? }` Colors (default from the style pack's style.character.colors)
|
|
110
|
+
- `speed?: number` Walking speed (m/s), default 4.5
|
|
111
|
+
- `runSpeed?: number` Running speed (m/s), default 7
|
|
112
|
+
- `radius?: number` Collision radius (meters), default 0.4
|
|
113
|
+
- `canSwim?: boolean` Whether it can swim, default true
|
|
114
|
+
- `swimDepth?: number` Water depth (meters) at which swimming starts, default 1
|
|
115
|
+
- `swimSpeed?: number` Swimming speed multiplier, default 0.45
|
|
116
|
+
- `turnSpeed?: number` How fast it turns, default 10
|
|
117
|
+
- `acceleration?: number` How fast it starts / stops, default 12
|
|
118
|
+
- `gravity?: number` Gravity (m/s², negative), default -24
|
|
119
|
+
- `jumpSpeed?: number` Jump speed (m/s), default 8
|
|
120
|
+
- `stepHeight?: number` Step height it can climb directly (meters), default 0.45
|
|
121
|
+
- `airControl?: number` Air control, 0–1
|
|
122
|
+
- `coyoteTime?: number` How long after walking off an edge a jump is still allowed (seconds)
|
|
123
|
+
- `canJump?: boolean` Whether it can jump, default true
|
|
124
|
+
- `model?: Object3D | string | null` glTF model: what engine.assets.model() returned, or the name of a registered model asset (default style.character.model). A name builds the character at once with the placeholder body and swaps in a copy of the asset when it loads (see Character.ready / whenReady, event 'character:model'). Example: `engine.characters.createPlayer({ model: 'hero' }) // after engine.assets.manifest({ models: { hero: '/models/hero.glb' } })`
|
|
125
|
+
- `clips?: { idle?, walk?, run?, swim?, jump?, fall?, … } | null` Action name mapping { idle, walk, run, swim, jump, fall } (shorthand for animation)
|
|
126
|
+
- `animation?: AnimatorOptions | null` Skeletal animation state machine config (states, blend trees, one-shot actions), see AnimatorOptions
|
|
127
|
+
- `mover?: 'simple' | 'rapier'` Movement method: 'simple' built into the engine (default) / 'rapier' Rapier character controller (needs the rigid module)
|
|
128
|
+
- `faceMode?: FaceMode` Which way it turns each move: 'move' (default, toward its velocity) / 'camera' (along cameraRig.forward()) / 'target' (toward faceTarget) / 'manual' (only face() turns it)
|
|
129
|
+
- `faceTarget?: PositionLike | null` What faceMode 'target' faces (lock-on)
|
|
130
|
+
- **FindSpawnOptions** Parameters of findSpawn(): minH/maxH height range (meters, default unlimited), maxSlope maximum slope (default 0.3), waterMargin minimum meters above the water (default 0.5)
|
|
131
|
+
- `minH?: number`
|
|
132
|
+
- `maxH?: number`
|
|
133
|
+
- `maxSlope?: number`
|
|
134
|
+
- `waterMargin?: number`
|
|
135
|
+
|
|
136
|
+
## engine.npcs (installed together with characters())
|
|
137
|
+
- `npcs.list() → NPC[]` — All NPCs (including far ones and ones in other levels)
|
|
138
|
+
- `npcs.add(opts: NPCOptions) → NPC` — Add an NPC, returns a handle
|
|
139
|
+
- `npcs.remove(npc: NPC | string) → boolean` — Delete an NPC (pass a handle, id or name): the data is deleted, and the model and dialogue interaction are torn down together. Returns false if not found
|
|
140
|
+
- `npcs.behavior(name: string, impl: { near?, far? })` — Register an NPC behavior: near(rec, dt, npc) once per fixed step when nearby, far(rec, dt) simulated from the data when far (dt is accumulated seconds); selected through behavior in the data
|
|
141
|
+
- `npcs.get(idOrName: string) → NPC | undefined` — Find by id or name (id first)
|
|
142
|
+
- `npcs.character(id: string) → Character | null` — The current character model of an NPC, null if none
|
|
143
|
+
- Properties:
|
|
144
|
+
- `avoid: { on, radius, strength, set, push }` Nearby NPCs avoid each other (on by default): pushed apart to no less than the sum of their radii, the player counts as an obstacle (NPCs yield to the player), then constrained back to walkable places by engine.collision; deterministic and cheap, with identical results after loading. With nav({ crowd: true }) crowd takes over. Example: `engine.npcs.avoid.set({ radius: 0.6, strength: 2 }); // set(false) turns it off`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# engine.clock (Clock) — engine.clock: game seconds and "after how long / every how long"
|
|
2
|
+
|
|
3
|
+
- `clock.after(seconds: number, fnOrEvent: (() => void) | string, data?: any) → Handle` — Call fn after seconds game seconds; if an event name is passed, the event is emitted when due (with data, can be saved)
|
|
4
|
+
- `clock.every(seconds: number, fn: () => void) → Handle` — Call once every seconds game seconds
|
|
5
|
+
- Properties:
|
|
6
|
+
- `now: number` Game seconds = fixed-step seconds x clock.timeScale (the time scale is 1 without sky), does not advance while paused / frozen, saved with the game; one sky day = sky.dayLength game seconds
|
|
7
|
+
- `timeScale: number` Game-time speed: game seconds per fixed-step second (default 1; the sky's time of day follows it). `engine.clock.timeScale = 60` makes a minute pass per second
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# engine.collision — collision(opts?: CollisionOptions)
|
|
2
|
+
|
|
3
|
+
Lightweight collision (collision() module): no clipping while walking, the camera is not blocked
|
|
4
|
+
|
|
5
|
+
- Options `CollisionOptions`:
|
|
6
|
+
- `maxClimb?: number` Max walkable slope (height difference / horizontal distance), default 1.1
|
|
7
|
+
- `canopyHeight?: number` A camera above this height (meters) is not considered blocked by trees, default 5
|
|
8
|
+
- `cameraPad?: number` Margin between the camera and obstacles (meters), default 0.5
|
|
9
|
+
- `cameraMin?: number` Nearest camera distance (meters), default 1.5
|
|
10
|
+
- `walkableWaterMargin?: number` Height above the water surface (meters) at which it counts as walkable, default 0.2
|
|
11
|
+
- `cameraOcclusion?: 'colliders' | 'meshes' | 'both'` What camera occlusion checks: 'colliders' (default) / 'meshes' registered static meshes (engine.rays) / 'both'
|
|
12
|
+
|
|
13
|
+
## Methods and properties
|
|
14
|
+
- `collision.addCircle(position: PositionLike, opts?: CircleColliderOptions) → Handle` — Add a circle collider (pillar, campfire): position is the center, e.g. addCircle(mesh, { radius: 1 }). Returns a handle { remove() }
|
|
15
|
+
- `collision.addBox(position: PositionLike, opts?: BoxColliderOptions) → Handle` — Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() }
|
|
16
|
+
- `collision.addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?, height?, y? }) → Handle` — Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y. A gap between segments is a gate. Returns a handle { remove() }
|
|
17
|
+
- `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure. bounds skips fn outside it. Returns a handle { remove() }
|
|
18
|
+
- `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — Is a character of this radius touching addBlocked ground at (x, z)
|
|
19
|
+
- `collision.addObject(obj: Object3D, opts?: { pad?: number }) → Handle` — Add a collider from an object's bounding box, pad expands outward (meters). Returns a handle { remove() }
|
|
20
|
+
- `collision.forEachStatic(fn: (type, data) => void)` — Iterate all static colliders added by hand
|
|
21
|
+
- `collision.walkable(position: PositionLike, opts?: { radius?: number }) → boolean` — Whether someone can stand at this position (for pathfinding): not in water, not too steep, not inside an obstacle. radius is the character radius (meters, default engine.movement.radius)
|
|
22
|
+
- `collision.walkableAt(x: number, z: number, radius?: number) → boolean` — walkable with plain numbers, allocating nothing (A* inner loops); radius defaults to engine.movement.radius
|
|
23
|
+
- `collision.lineClear(a: PositionLike, b: PositionLike, opts?: { radius?: number }) → boolean` — Line of sight with height: is the 3D segment a -> b free of boxes, circles and terrain trees? radius fattens the line; addBlocked water is ignored. Give eye heights in a / b
|
|
24
|
+
- Properties:
|
|
25
|
+
- `cameraOcclusion: 'colliders' | 'meshes' | 'both'` What camera occlusion checks (see CollisionOptions.cameraOcclusion)
|
|
26
|
+
- `circles: CircleCollider[]` Circle colliders added by hand
|
|
27
|
+
- `boxes: BoxCollider[]` Box colliders added by hand
|
|
28
|
+
- `version: number` +1 each time a static collider is added or removed
|
|
29
|
+
|
|
30
|
+
## Data structures
|
|
31
|
+
- **CircleColliderOptions** Parameters of addCircle() (meters)
|
|
32
|
+
- `radius?: number` Radius, default 0.5
|
|
33
|
+
- `height?: number` Height, default 6
|
|
34
|
+
- **BoxColliderOptions** Parameters of addBox() (meters, radians)
|
|
35
|
+
- `halfWidth?: number` Half width (X direction), default 1
|
|
36
|
+
- `halfDepth?: number` Half depth (Z direction), default 1
|
|
37
|
+
- `rotation?: number` Rotation around the Y axis (radians), default 0
|
|
38
|
+
- `height?: number` Height, default 6
|
|
39
|
+
- `y?: number` Bottom height of the box; if omitted it sits on the ground (give it for walls placed on platforms in a level)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# engine.content — content()
|
|
2
|
+
|
|
3
|
+
Content loading (content() module)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `content.load(data: ContentPack | ContentPack[], opts?: ContentLoadOptions)` — Load content (items, pickups, vegetation, NPCs, dialogue, quests, keys, trigger zones, props, the game vocabulary rules): one pack, or a list of packs loaded together in order; an id defined by two packs of one call is an error naming both (a later separate load overrides by name instead). Example: `engine.content.load([baseContent, forestDlc], { places: { home } })`
|
|
8
|
+
- `content.condition(name: string, def: ContentConditionDef)` — Register a custom condition, e.g. condition('timeAfter', { ref: 'clock', test: (e, t) => e.sky.timeOfDay >= t })
|
|
9
|
+
- `content.test(cond: any) → boolean` — Whether a condition holds (object, array or function)
|
|
10
|
+
- `content.run(effect: any) → any` — Run an effect (object, array or function)
|
|
11
|
+
- `content.place(name: string) → XZ | null` — Place name -> position (load's places first, then level markers), null if none
|
|
12
|
+
- `content.where(p: { place?, x?, z? }) → XZ` — Position form in content { place?, x?, z? } -> world coordinates
|
|
13
|
+
- `content.template(name: string) → Readonly<ContentTemplate>` — The shared, frozen definition of a content template (content/templates.js); instance state lives on the world record. e.g. template('chest').container.capacity
|
|
14
|
+
- Properties:
|
|
15
|
+
- `ready: boolean` All vegetation models are fetched and the models of world data such as nearby props are built (world.ready)
|
|
16
|
+
- `markers: Map<string, HudMarker | undefined>` Markers added by the marker effect: id -> marker
|
|
17
|
+
|
|
18
|
+
## Data structures
|
|
19
|
+
- **ContentConditionDef** Custom condition: test(e, value) says whether it holds; ref/desc/describe are for the validator and the game map
|
|
20
|
+
- `ref?: ContentRef` How the value is written, e.g. 'clock'
|
|
21
|
+
- `desc?: string` One-line description
|
|
22
|
+
- `test(e: Engine, value: any, raw?: any) → boolean` — Whether it holds: value is the value converted by ref, raw is the form written in the content
|
|
23
|
+
- `describe(value: any) → string` — Write the value as human-readable text (for the game map)
|
|
24
|
+
|
|
25
|
+
## Condition words / effect words in content files (generated from modules/content/rules.js)
|
|
26
|
+
Conditions are used in quest step done, dialogue option if and line variant if; effects in dialogue do, quest reward and trigger zone onEnter / onExit. Several entries in one object = all must hold / run in order; an array works too. A game's own condition words go in content/rules.js (or content.condition); a game's own actions are ops, called with { op: [...] } (recipes/23-ops.md). The format of actions.js and how to write loading are in recipes/20-content-actions-save.md.
|
|
27
|
+
- Condition words:
|
|
28
|
+
- `flag` value is a flag name, e.g. 'metFisher': story flag is set
|
|
29
|
+
- `notFlag` value is a flag name, e.g. 'metFisher': story flag is not set
|
|
30
|
+
- `has` value is { itemId: count }, e.g. { berry: 3 }: inventory has at least
|
|
31
|
+
- `lacks` value is { itemId: count }, e.g. { berry: 3 }: inventory has fewer than
|
|
32
|
+
- `counter` value is { counterName: count }, e.g. { sunsetPhotos: 1 }: counter is at least
|
|
33
|
+
- `can` value is ['noun.verb', { args }], e.g. ['shop.buy', { shop: 'bakery', item: 'bread' }]: an op would succeed now (engine.ops.can)
|
|
34
|
+
- Effect words:
|
|
35
|
+
- `setFlag` value is a flag name, e.g. 'metFisher': set a story flag
|
|
36
|
+
- `give` value is { itemId: count }, e.g. { berry: 3 }: give items
|
|
37
|
+
- `take` value is { itemId: count }, e.g. { berry: 3 }: take items
|
|
38
|
+
- `bump` value is a counter name, e.g. 'sunsetPhotos': counter +1
|
|
39
|
+
- `startQuest` value is a quest id: start a quest
|
|
40
|
+
- `toast` value is text: show a toast
|
|
41
|
+
- `particles` value is { name, at: [x, y, z], count }: play particles
|
|
42
|
+
- `marker` value is a place name, or { place, x, z } / { x, z }: add an objective marker (hud module)
|
|
43
|
+
- `clearMarker` value is a place name, or { place, x, z } / { x, z }: remove an objective marker
|
|
44
|
+
- `op` value is ['noun.verb', { args }], e.g. ['shop.buy', { shop: 'bakery', item: 'bread' }]: run a game op (engine.ops.run); the game's own actions are ops
|
|
45
|
+
- Files content/ recognizes:
|
|
46
|
+
- `items.js` items (id -> name, icon, description); also export startItems for starting items
|
|
47
|
+
- `pickups.js` pickups on the ground (list)
|
|
48
|
+
- `containers.js` chests / shelves (container id -> { capacity, items: starting goods }; starting goods are placed only the first time, then saved)
|
|
49
|
+
- `npcs.js` NPCs (id -> name, schedule, dialogue)
|
|
50
|
+
- `dialogues.js` dialogues (id -> speaker, nodes)
|
|
51
|
+
- `quests.js` quests (id -> title, steps, reward; a step can have a target position)
|
|
52
|
+
- `actions.js` own key actions of the game (action name -> default key, label)
|
|
53
|
+
- `places.js` place names (coordinates computed at runtime in main.js)
|
|
54
|
+
- `triggers.js` trigger zones (tag -> position / from level, enter/exit effects)
|
|
55
|
+
- `level.js` level markers (spawn point, NPCs, trigger zones)
|
|
56
|
+
- `vegetation.js` vegetation (name -> model, growth rule)
|
|
57
|
+
- `props.js` props (list: model, position, facing, collision; or { template, x, z } = an instance of a template; or { id, grid, item, cell } = a grid item), streamed in on demand
|
|
58
|
+
- `templates.js` reusable objects (name -> model, collide, interact, container, sound, animate, state defaults, physics body); shared read-only definitions
|
|
59
|
+
- `audio.js` sounds by asset name, ambience and music rules as data, footsteps (sounds, ambience, music: { tracks, rules }, footsteps)
|
|
60
|
+
- `views.js` named fixed camera views (name -> { position: [x, y, z], target?: [x, y, z], fov? }); engine.views.show(name), ?view=name, npm run shot -- -w game --view name
|
|
61
|
+
- `grids.js` placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved
|
|
62
|
+
- `renames.js` renamed or deleted authored ids (old id -> new id, or null = deleted on purpose): the player's saved changes follow the new id
|
|
63
|
+
- `rules.js` condition words added by the game ({ conditions }); actions are ops, not effect words
|
|
64
|
+
- any other `<name>.js` the game registers in content/rules.js as kinds: { name: { desc, load(e, data), check?, map? } } (enemies, recipes, loot tables…)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# engine.dialogue — dialogue(opts?: DialogueOptions)
|
|
2
|
+
|
|
3
|
+
Dialogue (dialogue() module)
|
|
4
|
+
|
|
5
|
+
- Options `DialogueOptions`:
|
|
6
|
+
- `charsPerSecond?: number` Typing speed (characters/second, game time: advanced by engine.step), default 40
|
|
7
|
+
- `advanceActions?: string[]` Actions that advance the dialogue, default ['confirm', 'interact'] (interact only when the game bound it)
|
|
8
|
+
- `choiceKeys?: boolean` Number keys 1-9 pick choices (read only while a locking dialogue runs; rebind them as actions choice1...choice9), false = click / op only. Default true
|
|
9
|
+
- `holdSeconds?: number` A non-locking line (lock: false) moves on this many seconds after it is fully typed, default 2
|
|
10
|
+
|
|
11
|
+
## Methods and properties
|
|
12
|
+
- `dialogue.define(speaker: string, nodes: DialogueScript)` — Define a dialogue (the name is usually the speaker)
|
|
13
|
+
- `dialogue.start(speaker: string, nodeId?: string, onEnd?: (() => void) | null, opts?: { lock?, onCancel? })` — Start a dialogue: from node nodeId (default 'start'), onEnd is called when it ends. lock (default true) locks game input and takes Esc; lock: false lets the player keep playing (lines move on by themselves) and never cuts into a locking dialogue. onCancel: what the back key (Esc) does while this locking dialogue is on top of the UI focus stack (default: nothing). Ending the playthrough (engine.session newGame / load / quit) closes the dialogue without calling onEnd. Example: `engine.dialogue.start('guard', 'start', null, { lock: false })`
|
|
14
|
+
- `dialogue.say(text: string | DialogueScript, opts?: { speaker?, node?, lock?, onCancel? }) → SayPromise` — Say a one-off line (no need to define first); the Promise resolves when it is done. lock: false = said while the player keeps playing (barks, radio chatter). When the playthrough ends (engine.session) the line is dropped and the Promise never resolves, so code awaiting it does not run in the next playthrough. Example: `await engine.dialogue.say('Reloading!', { speaker: 'Mira', lock: false })`
|
|
15
|
+
- `dialogue.end()` — End the current dialogue
|
|
16
|
+
- Properties:
|
|
17
|
+
- `state: DialogueState` Story state: state.flags is engine.vars.flags (autosaved)
|
|
18
|
+
- `scripts: Map<string, DialogueScript>` All scripts
|
|
19
|
+
- `active: { speaker, nodes, node?, onEnd, lock } | null` The dialogue in progress (null when none)
|
|
20
|
+
- `speaking: string | null` The script currently speaking
|
|
21
|
+
- `cps: number` Typing speed (characters/second)
|
|
22
|
+
|
|
23
|
+
## Data structures
|
|
24
|
+
- **DialogueScript** = `Record<string, DialogueNode>` — Dialogue script: node name -> node, starting from 'start'
|
|
25
|
+
- **DialogueNode** Dialogue node
|
|
26
|
+
- `text: string | ((state: DialogueState, engine: Engine) => string)` Line of dialogue, or a function returning one
|
|
27
|
+
- `speaker?: string` Change the speaker (the script name by default)
|
|
28
|
+
- `next?: string` Next node (omit = end; 'end' also means end)
|
|
29
|
+
- `choices?: DialogueChoice[]` Choices (next has no effect when there are choices)
|
|
30
|
+
- `do?: (state: DialogueState, engine: Engine) => void` Run when this line is shown (change story flags, give items...)
|
|
31
|
+
- `data?: Record<string, any>` The game's own fields (portrait, mood, voice clip, camera shot...): handed to the 'dialogue' UI part and the 'dialogue:line' event. Other unknown keys are reported as typos, so a misspelled next does not silently end the dialogue. Example: `{ text: 'Hm.', data: { portrait: 'fisher', mood: 'tired', voice: 'fisher_03.mp3' } }`
|
|
32
|
+
- **DialogueChoice** Dialogue choice
|
|
33
|
+
- `text: string | ((state: DialogueState, engine: Engine) => string)` Choice text
|
|
34
|
+
- `next?: string` Which node to go to after choosing (omit = end)
|
|
35
|
+
- `if?: (state: DialogueState, engine: Engine) => boolean` Condition: when it returns false this choice is not shown
|
|
36
|
+
- `do?: (state: DialogueState, engine: Engine) => void` Run after choosing
|
|
37
|
+
- `data?: Record<string, any>` The game's own fields (icon, tone...): handed to the UI part as choices[i].data. Other unknown keys are reported as typos
|
|
38
|
+
- **DialogueState** Story state: flags are story flags (this is engine.vars.flags, autosaved)
|
|
39
|
+
- `flags: Record<string, any>`
|