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,66 @@
|
|
|
1
|
+
# engine.inventory — inventory(opts?: InventoryOptions)
|
|
2
|
+
|
|
3
|
+
Inventory (inventory() module)
|
|
4
|
+
|
|
5
|
+
- Options `InventoryOptions`:
|
|
6
|
+
- `action?: string` Action name that opens the inventory, default 'inventory'
|
|
7
|
+
- `keys?: string[]` Keys that open the bag: required unless createEngine({ bindings }) binds the action ([] = no key); presets.keys.inventory has ['KeyI']
|
|
8
|
+
- `pad?: string[]` Gamepad button, none by default; presets.keys.inventory has ['PadY']
|
|
9
|
+
- `pauseGame?: boolean` true: gameplay freezes (engine.freeze) while the inventory window is open, default false. Also settable at runtime: engine.inventory.pauseGame
|
|
10
|
+
- `bobDistance?: number` Pickups float and spin only within this distance (meters) of the focus, default 60
|
|
11
|
+
- `capacity?: number` Slot limit of the player inventory, default Infinity (no limit)
|
|
12
|
+
- `maxWeight?: number` Weight limit of the player inventory, default Infinity
|
|
13
|
+
- `pickupRadius?: number` Reach of pickups that do not set their own radius (meters), default 2
|
|
14
|
+
- `defaultStack?: number` Default stack limit, default 99
|
|
15
|
+
|
|
16
|
+
## Methods and properties
|
|
17
|
+
- `inventory.define(id: string, def: ItemDef)` — Define an item (chainable)
|
|
18
|
+
- `inventory.item(id: string) → ItemDef` — Get an item definition
|
|
19
|
+
- `inventory.count(x: string) → number` — How many of an item, or of one entry key
|
|
20
|
+
- `inventory.has(x: string, n?: number) → boolean` — Whether there are at least n (default 1)
|
|
21
|
+
- `inventory.list() → ItemEntry[]` — Player inventory entries (for custom UI)
|
|
22
|
+
- `inventory.get(key: string) → ItemEntry | null` — One player inventory entry by key, or null
|
|
23
|
+
- `inventory.add(id: string, n?: number, opts?: { data?, silent? }) → string | false` — Add n to the player inventory (default 1), opts { data, silent }; returns the entry key, false if it does not fit
|
|
24
|
+
- `inventory.remove(x: string, n?: number) → boolean` — Remove n (default 1) of an item or entry key, returns false if there are not enough
|
|
25
|
+
- `inventory.trade(take: string, give: string, opts?: { takeN?, giveN?, data?, silent? }) → { ok, reason?, took?, gave?, giveId?, giveN? }` — Atomic trade: take A (id or entry key) and give B in one all-or-nothing step; reason 'notEnough' / 'full'. Ops: inventory.trade, engine.ops.undo reverses it
|
|
26
|
+
- `inventory.setData(key: string, data: Record<string, any> | null, n?: number) → string` — Replace a player inventory entry's data for n pieces (default all); returns the key now holding them
|
|
27
|
+
- `inventory.container(id: string, opts?: { capacity?, maxWeight?, items? }) → Container` — Get or create a container (chest, corpse, shelf...); the id can be the id of a world record, and the contents are saved. A second call returns the same one; deleting the world record does not delete the container automatically
|
|
28
|
+
- `inventory.transfer(from: Container | string, to: Container | string, item: string, n?: number) → number` — Move n (default 1) of an item or one entry key between containers (pieces keep data and key); moves fewer if the target cannot hold them all, returns how many were actually moved
|
|
29
|
+
- `inventory.removeContainer(id: string) → boolean` — Delete a container together with its contents ('player' cannot be deleted), returns whether one was deleted
|
|
30
|
+
- `inventory.spawnPickup(id: string, position: PositionLike, opts?: PickupOptions) → PickupHandle` — Place a pickup on the ground at position; its y, if any, is the reference height on multi-layer ground (needs the interactions module unless auto): spawnPickup('berry', v, { count: 2 }). Returns a handle, remove() deletes it
|
|
31
|
+
- `inventory.nearestPickup(id: string, from?: PositionLike) → WorldRecord | null` — The data of the nearest pickup of an item still on the ground to from (default the player) (a world record of kind 'pickup'), null if none
|
|
32
|
+
- Properties:
|
|
33
|
+
- `pauseGame: boolean` true: gameplay freezes while the inventory window is open (set from inventory({ pauseGame }) or at runtime)
|
|
34
|
+
- `defs: Map<string, ItemDef>` Item definitions
|
|
35
|
+
- `capacity: number` Slot limit of the player inventory
|
|
36
|
+
- `bag: Container` Player inventory (= container('player'))
|
|
37
|
+
- `pickupRadius: number` Reach of pickups that do not set their own (meters)
|
|
38
|
+
- `slotsUsed: number` Slots used
|
|
39
|
+
|
|
40
|
+
## Data structures
|
|
41
|
+
- **ItemDef** Item definition
|
|
42
|
+
- `name?: string` Display name
|
|
43
|
+
- `icon?: string` Icon (text or emoji)
|
|
44
|
+
- `iconUrl?: string` Icon image path
|
|
45
|
+
- `desc?: string` Description
|
|
46
|
+
- `stack?: number` Pieces per slot, default 99 (an entry of 150 uses 2 slots); 1 = every piece with data is its own entry
|
|
47
|
+
- `weight?: number` Weight of one piece, counted against a container's maxWeight (default 0)
|
|
48
|
+
- `use?: (e: any, info: ItemUseEvent) => void` Makes the item usable with the inventory.use op
|
|
49
|
+
- `canUse?: (e: any, info: ItemUseEvent) => true | string` Whether it can be used now: true or a reason string (checked by the op's can)
|
|
50
|
+
- `consume?: boolean` inventory.use removes one piece before calling use
|
|
51
|
+
- `color?: ColorLike` Color of the pickup on the ground
|
|
52
|
+
- **PickupOptions** Parameters of spawnPickup()
|
|
53
|
+
- `id?: string` Stable id of this record in world (saves recognize it by this); numbered automatically pickup#1... if omitted, and an existing record with the same id is reused
|
|
54
|
+
- `count?: number` How many you get when picking up, default 1
|
|
55
|
+
- `data?: Record<string, any>` The piece's own data (a dropped sword keeps its durability)
|
|
56
|
+
- `radius?: number` Reach in meters, default inventory pickupRadius (2)
|
|
57
|
+
- `auto?: boolean` Taken by walking into it (no key press, no prompt)
|
|
58
|
+
- `mesh?: Object3D | null` Custom model (the style pack's style.pickup is used if omitted)
|
|
59
|
+
- `respawnSeconds?: number` Game seconds until it reappears, 0 = never reappears
|
|
60
|
+
- `bob?: boolean` Bob up and down and rotate, default true
|
|
61
|
+
- `initial?: boolean` Pickup authored in content (needs an id): the initial record of world; saves record only being picked up / waiting to respawn, with identical results whether the load comes before or after this spawn
|
|
62
|
+
- `zone?: string | null` Which zone it belongs to (a level name, see world.zone): the data stays across level changes (a picked-up one stays picked up)
|
|
63
|
+
- **PickupHandle** (extends Handle) Handle returned by spawnPickup(): id is the item, worldId is the id of this record in engine.world, object is the current model (null when far away); remove() deletes the pickup (data and model; a model passed in through opts.mesh is only taken off)
|
|
64
|
+
- `id: string`
|
|
65
|
+
- `worldId: string`
|
|
66
|
+
- `object: Object3D | null`
|
package/docs/api/jobs.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# engine.jobs (Jobs) — engine.jobs queues build work in a binary heap (higher priority first, FIFO within a priority)
|
|
2
|
+
|
|
3
|
+
- `jobs.add(work: (() => T) | (() => Generator<any, T, a…) | Generator<any, T, any> | …, opts?: { priority?, apply?, lag?, valid? }) → Promise<T>` — Add a job: a plain function runs in one go, a generator may pause at each yield until the next frame; higher priority runs first; returns the job's result. A job that changes gameplay state passes apply: the result takes effect on a fixed tick via engine.commits (lag fixed steps later, default 30), and is finished on the spot if not done by then, so machine speed does not affect gameplay. Such a job must be a plain function or generator (it cannot return a Promise). With apply, the returned Promise resolves when the work finishes, before apply may have run; put logic that needs "state already changed" inside apply. A step over slowStepMs warns in dev to slice it with yield. Example: `await engine.jobs.add(function* () { for (const p of props) { place(p); yield; } }, { priority: 10 });`
|
|
4
|
+
- `jobs.run(opts?: { deterministic?: boolean })` — Run the queue (the engine calls this each frame): by millisecond budget by default; deterministic: true ignores real time and drains it (used by step)
|
|
5
|
+
- Properties:
|
|
6
|
+
- `budgetMs: number` Milliseconds allowed per frame, default 3
|
|
7
|
+
- `loadingMs: number` Milliseconds allowed per frame while the loading screen is up, default 12
|
|
8
|
+
- `maxSteps: number` Max steps per deterministic run (stops jobs that keep adding jobs from hanging), default 100000
|
|
9
|
+
- `slowStepMs: number` A step slower than this many ms warns in dev (default 8)
|
|
10
|
+
- `pending: number` Number of jobs not yet finished
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# engine.level — level(opts?: LevelOptions)
|
|
2
|
+
|
|
3
|
+
Hand-built level (level() module)
|
|
4
|
+
|
|
5
|
+
- Options `LevelOptions`:
|
|
6
|
+
- `url?: string | null` glTF path (or asset name); pick one of this and scene
|
|
7
|
+
- `scene?: Object3D | null` THREE.Object3D built in code; pick one of this and url
|
|
8
|
+
- `walkable?: ((mesh: Object3D) => boolean) | null` Decide yourself which meshes are walkable
|
|
9
|
+
- `colliders?: 'named' | 'auto' | false` 'named' only col_ meshes block the player / 'auto' every tall mesh that is not walkable blocks / false
|
|
10
|
+
- `cellSize?: number` Heightfield cell size (meters), default 0.5
|
|
11
|
+
- `outside?: number` Ground height outside the level (meters), default 0
|
|
12
|
+
- `waterLevel?: number` Water surface height (meters), default no water
|
|
13
|
+
- `colliderPad?: number` Expand the collision box outward by this much (meters)
|
|
14
|
+
- `colliderHeight?: number` Minimum height of the collision box (meters)
|
|
15
|
+
- `sharpEdge?: number` Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6
|
|
16
|
+
- `hideMarkers?: boolean` Hide the marker placeholder meshes, default true
|
|
17
|
+
- `addToScene?: boolean` Add the scene to engine.scene, default true
|
|
18
|
+
|
|
19
|
+
## Methods and properties
|
|
20
|
+
- `level.marker(name: string) → LevelMarker | null` — Get a marker, null if none
|
|
21
|
+
- `level.markersWith(prefix: string) → LevelMarker[]` — Get all markers whose names start with prefix, e.g. markersWith('npc_')
|
|
22
|
+
- `level.unload()` — Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together)
|
|
23
|
+
- `level.load(urlOrScene: string | Object3D) → Promise<void>` — Change level: unload the current one, load the new one (glTF path/asset name, or a THREE object), and emit level:loaded when done. When a load changes level, the save system waits for it
|
|
24
|
+
- `level.track(handle: T) → T` — Register things that belong to the current level and need not be kept (the { remove() } handles of triggers...); they are deleted automatically on level change / unload; returns the same handle. world data that keeps state (NPCs, pickups, props) needs no registration: with a zone, a level change only tears down the model
|
|
25
|
+
- Properties:
|
|
26
|
+
- `root: Object3D | null` Scene root node
|
|
27
|
+
- `object: Object3D | null` Same as root (the name consistent with player.object and ent.object)
|
|
28
|
+
- `markers: Record<string, LevelMarker>` All markers: name -> marker
|
|
29
|
+
- `spawn: Vector3` Spawn point position
|
|
30
|
+
- `heightfield: any` Heightfield (for debugging)
|
|
31
|
+
- `buildMs?: number` Milliseconds spent building the heightfield
|
|
32
|
+
- `ready: boolean` Whether loading is finished
|
|
33
|
+
|
|
34
|
+
## Data structures
|
|
35
|
+
- **LevelMarker** Markers in the level (spawn, npc_*, trigger_*, marker_*), in world coordinates
|
|
36
|
+
- `name: string`
|
|
37
|
+
- `position: Vector3`
|
|
38
|
+
- `quaternion: Quaternion`
|
|
39
|
+
- `scale: Vector3`
|
|
40
|
+
- `userData: Record<string, any>`
|
|
41
|
+
- `object: Object3D`
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# engine.lightPool — lightPool(opts?: LightPoolOptions)
|
|
2
|
+
|
|
3
|
+
Light pool: many light sources, a fixed number of real lights (lightPool() module)
|
|
4
|
+
|
|
5
|
+
- Options `LightPoolOptions`:
|
|
6
|
+
- `point?: number` Real PointLights, default 8
|
|
7
|
+
- `spot?: number` Real SpotLights, default 0 (sources added with type: 'spot' use them)
|
|
8
|
+
- `shadows?: number` How many of the point lights cast shadows, default 0; only sources added with castShadow: true get them
|
|
9
|
+
- `every?: number` Seconds between choosing which sources get the lights, default 0.1 (fading and following run every frame)
|
|
10
|
+
- `fade?: number` Seconds a light takes to fade in or out when it moves to another source, default 0.3
|
|
11
|
+
- `focus?: PositionLike | null` Measure distance from this object / position instead of the camera (e.g. the player in a top-down game)
|
|
12
|
+
|
|
13
|
+
## Methods and properties
|
|
14
|
+
- `lightPool.add(position: PositionLike, opts?: LightSourceOptions) → LightSource` — Register a light source at a position (an Object3D: it follows that object every frame). Example: `const torch = engine.lightPool.add(torchMesh, { color: 0xffa040, intensity: 4, distance: 8, glow: haloSprite }); torch.set({ intensity: 0 }); // put out: its light goes to another torch`
|
|
15
|
+
- `lightPool.usage() → LightPoolUsage` — What the pool is doing now (also in describe().lightPool)
|
|
16
|
+
- Properties:
|
|
17
|
+
- `lights: Object3D[]` The real three.js lights, created once at install and never added, removed or hidden (the pool sets their position, color, intensity)
|
|
18
|
+
- `focus: PositionLike | null` Distance is measured from this object / position; null = the camera
|
|
19
|
+
|
|
20
|
+
## Data structures
|
|
21
|
+
- **LightSourceOptions** Options of lightPool.add(position, opts): one light source (a torch, lamp, campfire, muzzle flash...)
|
|
22
|
+
- `name?: string` Name shown in lightPool.usage()
|
|
23
|
+
- `type?: 'point' | 'spot'` 'point' (default) or 'spot' (needs lightPool({ spot: n }))
|
|
24
|
+
- `color?: ColorLike` Light color, default white
|
|
25
|
+
- `intensity?: number` three.js intensity at full strength, default 1; 0 = off (it gives its light away)
|
|
26
|
+
- `distance?: number` three.js light distance (range, meters), default 10; also the scale of the distance score
|
|
27
|
+
- `decay?: number` three.js decay, default 2
|
|
28
|
+
- `priority?: number` Weight in the choice, default 1: 3 = picked over a 1 three times as bright at the same distance (a quest lamp, a muzzle flash)
|
|
29
|
+
- `castShadow?: boolean` May take one of the shadow-casting lights (lightPool({ shadows })), default false; fixed when added
|
|
30
|
+
- `angle?: number` Spot cone half-angle (radians), default PI / 4
|
|
31
|
+
- `penumbra?: number` Spot penumbra 0-1, default 0.3
|
|
32
|
+
- `target?: PositionLike | null` Spot aim: a position or an Object3D it follows; default straight down
|
|
33
|
+
- `flicker?: ((time: number, index: number) => number) | null` Brightness factor each frame (time = presentation seconds, index = the source's number): (t, i) => 0.85 + 0.15 * Math.sin(t * 13 + i)
|
|
34
|
+
- `glow?: Material | Object3D | null` Stand-in shown while the source has no real light: a halo Sprite / Mesh (its material's opacity) or an emissive material (emissiveIntensity) scaled from its value at add() down to 0 as the real light fades in. Give each source its own material
|
|
35
|
+
- **LightSourcePatch** What lightPool.add().set(patch) can change (type and castShadow are fixed when added)
|
|
36
|
+
- `position?: PositionLike` New position, or an Object3D to follow
|
|
37
|
+
- `name?: string`
|
|
38
|
+
- `color?: ColorLike`
|
|
39
|
+
- `intensity?: number`
|
|
40
|
+
- `distance?: number`
|
|
41
|
+
- `decay?: number`
|
|
42
|
+
- `priority?: number`
|
|
43
|
+
- `angle?: number`
|
|
44
|
+
- `penumbra?: number`
|
|
45
|
+
- `target?: PositionLike | null`
|
|
46
|
+
- `flicker?: ((time: number, index: number) => number) | null`
|
|
47
|
+
- `glow?: Material | Object3D | null`
|
|
48
|
+
- **LightSource** Handle returned by lightPool.add()
|
|
49
|
+
- `light: Object3D | null` The real light lighting this source now, null while it has none
|
|
50
|
+
- `weight: number` How much of its light it has now, 0-1
|
|
51
|
+
- `set(patch: LightSourcePatch) → LightSource` — Change the source; returns the same handle
|
|
52
|
+
- `remove()` — Unregister: its light fades out and moves on, the stand-in is put back (safe to call twice)
|
|
53
|
+
- **LightPoolUsage** lightPool.usage(): what the pool is doing now
|
|
54
|
+
- `sources: number` Registered sources
|
|
55
|
+
- `lit: number` Real lights lighting a source now
|
|
56
|
+
- `slots: { type, shadow, source, weight }[]` One per real light: its kind, whether it casts shadows, the source it holds (name or number, null = idle) and its fade 0-1
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# engine.music — music(opts?: MusicOptions)
|
|
2
|
+
|
|
3
|
+
Background music (music() module)
|
|
4
|
+
|
|
5
|
+
- Options `MusicOptions`:
|
|
6
|
+
- `tracks?: Record<string, MusicTrack>` Tracks: name -> path or { url, volume, loop, stems }
|
|
7
|
+
- `rules?: MusicRule[]` Auto track rules (same as engine.music.rules(list))
|
|
8
|
+
- `fade?: number` Default crossfade seconds, default 2
|
|
9
|
+
- `duckDialogue?: number | false` Duck the music bus during dialogue to this (0-1, e.g. 0.35); default false = no duck (the game opts in)
|
|
10
|
+
- `duckFade?: number` Fade seconds for the ducking
|
|
11
|
+
- `hold?: number` Rule debounce seconds, default 2
|
|
12
|
+
- `interval?: number` Rule check interval (seconds), default 1
|
|
13
|
+
|
|
14
|
+
## Methods and properties
|
|
15
|
+
- `music.addTracks(map: Record<string, MusicTrack>)` — Register tracks: { name: url / { url, volume, loop, stems } }
|
|
16
|
+
- `music.play(name: string | null, opts?: { fade?: number; force?: boolean })` — Play a track (cross-fade over fade seconds). Does nothing if it is already playing; force replays it
|
|
17
|
+
- `music.stop(fade?: number)` — Fade out and stop (fade over fade seconds)
|
|
18
|
+
- `music.stinger(name: string, opts?: { duck?: number; volume?: number })` — Layer a one-shot piece (victory, discovered place...); the background dips to `duck` while it plays
|
|
19
|
+
- `music.rules(list: MusicRule[] | null, opts?: { hold?, fade?, interval? })` — Set the auto track rules (null turns them off). opts: hold how many seconds a new result must be stable before switching, fade switch fade seconds, interval check interval
|
|
20
|
+
- `music.override(name: string | null, opts?: { fade?: number; force?: boolean })` — Pick a track by hand, pausing the rules; override(null) hands control back
|
|
21
|
+
- `music.pick() → string | null | undefined` — Which track the current rules would pick (without switching)
|
|
22
|
+
- Properties:
|
|
23
|
+
- `tracks: Map<string, { url?: string; volume?: number; loop?: boolean…` Registered tracks
|
|
24
|
+
- `current: string | null` Name of the track playing (or wanted)
|
|
25
|
+
- `intensity: number` 0-1: how loud each stem of the playing track is (see the stems `at` range); fades in about half a second
|
|
26
|
+
- `ready: boolean` Whether audio is usable
|
|
27
|
+
- `ruled: boolean` Auto track rules are in use
|
|
28
|
+
- `state: { current, playing, pending, override, intensity, gain, … }` State (for debugging and tests): gain is the playing track's fade level, stems each stem's level
|
|
29
|
+
|
|
30
|
+
## Data structures
|
|
31
|
+
- **MusicRule** Auto-selection rule: when the condition holds play track (null = silence), higher priority wins; no `when` = always (a fallback)
|
|
32
|
+
- `track: string | null`
|
|
33
|
+
- `when?: MusicCondition`
|
|
34
|
+
- `priority?: number`
|
package/docs/api/nav.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# engine.nav — nav(opts?: NavOptions)
|
|
2
|
+
|
|
3
|
+
Navmesh (nav() module)
|
|
4
|
+
|
|
5
|
+
- Options `NavOptions`:
|
|
6
|
+
- `cellSize?: number` Voxel cell size (meters), default 0.3; smaller is more accurate but slower to build
|
|
7
|
+
- `agentRadius?: number` Character radius (meters), default reads engine.movement.radius (this is an override)
|
|
8
|
+
- `agentHeight?: number` Character height (meters), default reads engine.movement.height
|
|
9
|
+
- `maxClimb?: number` Step height that can be climbed (meters), default reads engine.movement.stepHeight
|
|
10
|
+
- `maxSlope?: number` Max walkable slope (degrees), default reads engine.movement.maxSlope
|
|
11
|
+
- `tileSize?: number` Tile size (in cells), default 32
|
|
12
|
+
- `crowd?: boolean` NPCs use Recast crowd avoidance, default false
|
|
13
|
+
- `debug?: boolean` Show the navmesh (debug), default false
|
|
14
|
+
|
|
15
|
+
## Methods and properties
|
|
16
|
+
- `nav.findPath(from: PositionLike, to: PositionLike, opts?: { radius?, detailed? }) → XZ[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: { radius?: number; detailed: true }) → { status, path }` — Path from from to to [{ x, z }…] (meters); null if not ready or unreachable. Usually use engine.characters.findPath
|
|
17
|
+
- `nav.dispose()` — Unload the navmesh (frees native objects); characters.findPath then falls back to A*
|
|
18
|
+
- Properties:
|
|
19
|
+
- `ready: boolean` The navmesh has been generated
|
|
20
|
+
- `navMesh: any` Native Recast NavMesh (null until ready)
|
|
21
|
+
- `query: any` Native Recast NavMeshQuery
|
|
22
|
+
- `tileCache: any` Native Recast TileCache (for dynamic obstacles)
|
|
23
|
+
- `crowd: any` Native Recast Crowd (only when crowd: true)
|
|
24
|
+
- `helper: any` three.js object for the debug display (only when debug: true)
|
|
25
|
+
- `version: number` +1 on rebuild / unload: code that cached native objects (crowd agents etc.) must recreate them when it changes
|
|
26
|
+
- `agent: { radius, height, maxClimb, maxSlope } | null` Character size actually in effect (from engine.movement, or the override in nav())
|
package/docs/api/net.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# engine.net — net()
|
|
2
|
+
|
|
3
|
+
(experimental) Co-op multiplayer (net() module): host authority, clients mirror the state and request ops; see recipes/27-net.md
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `net.reconnect(transport: any)` — Client: attach a new transport after the connection dropped; the host answers with a full snapshot. Pass the old key to keep the same actor (and bag). Example: `engine.events.on('net:close', () => setTimeout(() => engine.net.reconnect(webSocket(url, { key: oldKey })), 2000));`
|
|
8
|
+
- Properties:
|
|
9
|
+
- `role: "host" | "client"` 'host' or 'client'
|
|
10
|
+
- `actor: string | null` This machine's actor id on the host: 'player' on the host, e.g. 'guest-1' on a client (null until the first snapshot). A client calls itself 'player' locally (own avatar record, own bag), so game code rarely needs this; it is for showing names and for logs.
|
|
11
|
+
- `connected: boolean` Client: has a connection and an up-to-date mirror. Host: always true
|
|
12
|
+
- `peers: { id: number; actor: string }[]` Host: connected peers [{ id, actor }] (id from the transport, actor = world record / container id of that player). Client: []
|
|
13
|
+
- `pending: Map<number, string>` Client: requests sent and not answered yet (seq -> op name). Host: empty
|
|
14
|
+
- `stats: Record<string, number>` Message counters: in / out, plus diffs, snapshots, rejected (host) or gaps (client: lost diffs that forced a snapshot)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# openWorld() preset — installs the open-world world and environment modules in one go
|
|
2
|
+
|
|
3
|
+
- `openWorld(opts: OpenWorldOptions) → ModuleDef[]` — Open-world preset: world, terrain, vegetation, sky, weather, water, collision, physics, camera, characters, ambience, settings, debug (dev only). camera is required (the bundle picks no camera feel). Every part takes false or its own options: openWorld({ seed: 7, camera: 'follow', rigid: false }). Add gameplay modules yourself
|
|
4
|
+
- Options `OpenWorldOptions`:
|
|
5
|
+
- `seed?: number` Terrain random seed
|
|
6
|
+
- `viewChunks?: number` View distance (in chunks)
|
|
7
|
+
- `density?: number` Vegetation density multiplier
|
|
8
|
+
- `flatten?: FlattenZone[]` Flatten a plot (for a house)
|
|
9
|
+
- `time?: number` Start time 0-1
|
|
10
|
+
- `dayLength?: number` Game seconds per day (default 360)
|
|
11
|
+
- `weather?: WeatherName | (string & {}) | Part<typeof weather>` Starting weather name, false (no weather module) or weather() options
|
|
12
|
+
- `autoWeather?: boolean` Automatic weather changes
|
|
13
|
+
- `camera: 'follow' | 'firstPerson' | 'rts' | 'fixed' | ModuleDef | false` Required, no default: 'follow' / 'firstPerson' / 'rts' / 'fixed', a camera module with options (e.g. followCamera(presets.camera.overShoulder)), or false
|
|
14
|
+
- `world?: Part<typeof world>`
|
|
15
|
+
- `terrain?: Part<typeof terrain>`
|
|
16
|
+
- `vegetation?: Part<typeof vegetation>`
|
|
17
|
+
- `sky?: Part<typeof sky>`
|
|
18
|
+
- `water?: Part<typeof water>`
|
|
19
|
+
- `collision?: Part<typeof collision>`
|
|
20
|
+
- `rigid?: Part<typeof rigid>`
|
|
21
|
+
- `characters?: Part<typeof characters>`
|
|
22
|
+
- `ambience?: Part<typeof ambience>`
|
|
23
|
+
- `settings?: Part<typeof settings>`
|
|
24
|
+
- `debug?: Part<typeof debug>` Default: installed in dev builds only; true also in release builds
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# engine.particles — particles()
|
|
2
|
+
|
|
3
|
+
Particles (particles() module)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Methods and properties
|
|
7
|
+
- `particles.define(name: string, opts?: ParticleOptions) → ParticleEffect` — Define an effect (same name replaces it, and emitters attached to it move to the new definition); params sit on top of the style pack preset. Returns the effect object: .points is its THREE.Points, .material is the shader material
|
|
8
|
+
- `particles.has(name: string) → boolean` — Whether this effect has been defined
|
|
9
|
+
- `particles.emit(name: string, position: PositionLike, opts?: { count?, overrides? })` — Burst: emit count particles at once (default 10) at position (Vector3 / Object3D / [x, y, z] / {x, y, z}). overrides affect this batch only (color, speed, direction...; max/texture/blending cannot be changed temporarily)
|
|
10
|
+
- `particles.attach(name: string, object3d: THREE.Object3D, opts?: { rate?, offset?, overrides? }) → ParticleEmitter` — Keep emitting while following an object: rate per second, offset in the object's local coordinates [x, y, z] (meters). Returns a handle { remove(), rate, active } (active = false pauses)
|
|
11
|
+
- `particles.count(name?: string) → number` — Live particle count (no name = all)
|
|
12
|
+
- `particles.clear(name?: string)` — Clear one effect's (or all) particles
|
|
13
|
+
- Properties:
|
|
14
|
+
- `effects: Map<string, ParticleEffect>` Defined effects
|
|
15
|
+
|
|
16
|
+
## Data structures
|
|
17
|
+
- **ParticleOptions** Particle effect parameters (style.particles[name] of the style pack uses the same format too). All optional
|
|
18
|
+
- `max?: number` Maximum alive at once, default 120 (halved on low-end devices)
|
|
19
|
+
- `lifetime?: Range` Seconds each particle lives [min, max]
|
|
20
|
+
- `rate?: number` Default particles per second for attach
|
|
21
|
+
- `speed?: Range` Initial speed (m/s) [min, max]
|
|
22
|
+
- `direction?: number[]` Emission direction [x, y, z]
|
|
23
|
+
- `spread?: number` Maximum angle away from the direction (radians, π = all directions)
|
|
24
|
+
- `area?: number | number[]` Radius of random spread around the spawn point (meters), or a box [x, y, z]
|
|
25
|
+
- `gravity?: number` Vertical acceleration (m/s², negative falls)
|
|
26
|
+
- `drag?: number` Air drag (fraction of speed lost per second)
|
|
27
|
+
- `wind?: number` How much wind affects it
|
|
28
|
+
- `windDir?: number[]` Wind direction [x, y, z]
|
|
29
|
+
- `size?: Range` Size at birth / at death (meters)
|
|
30
|
+
- `color?: ColorLike | ColorLike[]` Color at birth / at death (one color, or [birth, death]; an array, not a tuple, so a plain JS literal [0xffffff, 0xdddddd] type-checks)
|
|
31
|
+
- `opacity?: Range` Opacity at birth / at death, 0–1
|
|
32
|
+
- `texture?: string | Texture | null` Texture (asset name, path or THREE.Texture); a soft round dot if omitted
|
|
33
|
+
- `blending?: Loose<'normal' | 'additive'>` 'normal' / 'additive' (glowing blend, for sparks)
|
|
34
|
+
- `spin?: number` Texture rotation speed (radians/second)
|
|
35
|
+
- `worldSpace?: boolean` With attach, whether particles stay in the world (true) or the emission direction rotates with the object (false)
|
|
36
|
+
- `fog?: boolean` Affected by fog, default true
|
|
37
|
+
- `maxPixels?: number` Largest on-screen size of one particle in pixels (smoke drifting past the camera stays bounded), default 512
|
|
38
|
+
- **ParticleEmitter** (extends Handle) Continuous emitter returned by attach() (a handle)
|
|
39
|
+
- `rate: number` Particles per second (can be changed at any time)
|
|
40
|
+
- `active: boolean` false pauses
|
|
41
|
+
- `remove()` — Stop and remove (also removed automatically when the object leaves the scene)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# engine.photo — photo(opts?: PhotoOptions)
|
|
2
|
+
|
|
3
|
+
Photo mode (photo() module)
|
|
4
|
+
|
|
5
|
+
- Options `PhotoOptions` (also includes the fields of PhotoTakeOptions):
|
|
6
|
+
- `keys?: string[]` Photo key: required unless createEngine({ bindings }) binds 'photo' ([] = no key); presets.keys.photo has ['KeyP']
|
|
7
|
+
- `pad?: string[]` Gamepad button for taking a photo, none by default; presets.keys.photo has ['PadRB']
|
|
8
|
+
- `maxAlbum?: number` How many photos the album keeps at most, default 50
|
|
9
|
+
|
|
10
|
+
## Methods and properties
|
|
11
|
+
- `photo.take(opts?: PhotoTakeOptions) → PhotoShot` — Capture a photo now without checks. Gameplay takes photos through the op: engine.ops.run('photo.take') (checks canTake, logged)
|
|
12
|
+
- `photo.subject() → { name, kind, distance } | null` — What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take()
|
|
13
|
+
- Properties:
|
|
14
|
+
- `album: PhotoShot[]` Album (newest first)
|
|
15
|
+
- `canTake: () => boolean | string` The op photo.take's can: return true, or false / a reason string to refuse (e.g. () => engine.inventory.has('film') // 'noFilm')
|
package/docs/api/post.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# engine.post (PostFX)
|
|
2
|
+
|
|
3
|
+
- `post.add(_effect: PostEffect, _opts?: { slot?, order?, enabled? }) → never` — (experimental) Renamed in 0.2: throws and names the new call (engine.look.post.patch / engine.look.post.replace, recipes/52-look.md)
|
|
4
|
+
- `post.get(name: string) → PostHandle | undefined` — (experimental) Read-only record of an added effect (name, slot, order, enabled, params), or undefined. Change one with engine.look.post.set({ 'bloom.strength': 0.6 })
|
|
5
|
+
- `post.enable(_name: string, _on: boolean) → never` — (experimental) Renamed in 0.2: throws and names the new call (engine.look.post.set({ 'bloom.enabled': on }); MSAA: engine.post.setAntialias(on))
|
|
6
|
+
- `post.setAntialias(on: boolean)` — (experimental) Turn MSAA (antialiasing of the post chain) on or off. It is a render target setting, not a look part. Example: `engine.post.setAntialias(false);`
|
|
7
|
+
- `post.list() → { name, slot, order, enabled }[]` — (experimental) Effects in render order: [{ name, slot, order, enabled }]
|
|
8
|
+
- Properties:
|
|
9
|
+
- `antialias: boolean` MSAA on (read-only; switch with post.setAntialias(on))
|
|
10
|
+
- `active: boolean` Whether any post work runs (antialias or an enabled effect)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# engine.quests — quests(opts?: QuestsOptions)
|
|
2
|
+
|
|
3
|
+
Quests (quests() module)
|
|
4
|
+
|
|
5
|
+
- Options `QuestsOptions`:
|
|
6
|
+
- `action?: string` Action name that opens the quest log, default 'quests'
|
|
7
|
+
- `keys?: string[]` Keys that open the quest log: required unless createEngine({ bindings }) binds the action ([] = no key); presets.keys.quests has ['KeyJ']
|
|
8
|
+
- `pad?: string[]` Gamepad button, none by default; presets.keys.quests has ['PadSelect']
|
|
9
|
+
- `checkInterval?: number` Check interval (game seconds, checked in the fixed step; not checked while frozen / paused), default 0.5
|
|
10
|
+
- `notify?: boolean | ((msg) => void)` Messages on quest start / step / done: true a toast with kind 'quest' (default) · false none · a function to show them your way. Example: `quests({ notify: false }) quests({ notify: ({ type, text }) => type === 'done' && myBanner(text) })`
|
|
11
|
+
|
|
12
|
+
## Methods and properties
|
|
13
|
+
- `quests.define(id: string, def: QuestDef)` — Define a quest (chainable)
|
|
14
|
+
- `quests.start(id: string)` — Start a quest
|
|
15
|
+
- `quests.isActive(id: string) → boolean` — Started, not done and not failed
|
|
16
|
+
- `quests.isFailed(id: string) → boolean` — Its fail condition held (start(id) begins it again)
|
|
17
|
+
- `quests.check()` — Check completion conditions once immediately
|
|
18
|
+
- `quests.list() → { id, title, desc?, done, failed, steps }[]` — Quest list (for custom UI)
|
|
19
|
+
- Also: `quests.isDone(id: string) → boolean`
|
|
20
|
+
- Properties:
|
|
21
|
+
- `state: Record<string, { step: number; done: boolean; failed?: bool…` Quests in progress / completed / failed: id -> { step (current step), done, failed?, parts? }
|
|
22
|
+
- `win: { open, toggle, refresh }` The quest log (UI part 'questLog'): open, toggle(on?), refresh()
|
|
23
|
+
|
|
24
|
+
## Data structures
|
|
25
|
+
- **QuestDef** Quest definition
|
|
26
|
+
- `title: string` Title
|
|
27
|
+
- `desc?: string` Description
|
|
28
|
+
- `steps: (QuestStep | QuestParallelStep)[]` Steps (completed in order); a step may be parallel goals { all: [...] }
|
|
29
|
+
- `reward?: (e: Engine) => void` Called on completion (give rewards)
|
|
30
|
+
- `fail?: (e: Engine) => boolean` Checked while active; true fails the quest (quest:fail; start(id) can begin it again). Example: `fail: e => e.vars.flag('caravanLost')`
|
|
31
|
+
- `onFail?: (e: Engine) => void` Called when the quest fails
|
|
32
|
+
- **QuestStep** One quest step: text is the displayed text, done the completion condition (checked every half second), target the objective (a marker is shown when hud is installed)
|
|
33
|
+
- `id?: string` Stable id: saves store progress by it, so steps can be inserted or reordered later (default: the step's position)
|
|
34
|
+
- `text: string`
|
|
35
|
+
- `done: (e: Engine) => boolean`
|
|
36
|
+
- `target?: HudTarget` Objective: a place name (content.place), object, character, { x, z }, { nearest: itemId } or a function returning an objective; with the hud module the current step shows a marker automatically
|
package/docs/api/rays.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# engine.rays (Rays) — engine.rays is the ray registry (engine.raycast hits whatever is registered here)
|
|
2
|
+
|
|
3
|
+
- `rays.addStatic(obj: THREE.Object3D | THREE.Object3D[], opts?: { occluder?: boolean }) → Handle` — Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }. Only visible objects are hit; hiding that just swaps in something else on screen (such as the far-away hlod original) is marked userData.rayVisible = true and is still hit. Unregisters automatically on geometry dispose or engine.remove. Example: `engine.rays.addStatic(house, { occluder: true });`
|
|
4
|
+
- `rays.forget(obj: THREE.Object3D)` — Unregister every mesh under the object (engine.remove calls this automatically)
|
|
5
|
+
- `rays.addProvider(fn: RayProvider) → Handle` — A module merges its own hits (rigid adds rigid bodies; asked only when targets is 'all'). Returns a handle { remove() }
|
|
6
|
+
- `rays.cast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Cast a ray from origin along dir and return the nearest hit or null (same as engine.raycast).
|
|
7
|
+
- `rays.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Cast from screen coordinates (-1..1) through the camera (same as engine.pick).
|
|
8
|
+
- Properties:
|
|
9
|
+
- `statics: Map<THREE.Object3D, { refs: number; occ: number }>` Registered mesh -> { refs: registration count, occ: camera-blocker registration count }
|
|
10
|
+
- `ray: any` The three.js Raycaster (firstHitOnly is on)
|
|
11
|
+
|
|
12
|
+
## Data structures
|
|
13
|
+
- **RaycastOptions** Parameters of engine.raycast()
|
|
14
|
+
- `far?: number` Maximum distance (meters), default unlimited
|
|
15
|
+
- `targets?: 'static' | 'all' | Object3D[]` What to hit: 'static' registered static objects (default) / 'all' plus what modules merge in (with rigid installed this includes rigid bodies, hits carry entry and kind: 'rigid') / an array of objects
|
|
16
|
+
- `filter?: (hit: RayHit) => boolean` Hits for which this returns false are skipped
|
|
17
|
+
- `occluders?: boolean` Hit only meshes that block the camera (level buildings, hidden col_ collision meshes); used by collision's cameraOcclusion
|
|
18
|
+
- **RayHit** Ray hit: point is the hit point, distance in meters, normal the surface direction, object the mesh hit; entry/kind come from the module that merged the hit in (e.g. a rigid body)
|
|
19
|
+
- `point: Vector3`
|
|
20
|
+
- `distance: number`
|
|
21
|
+
- `normal: Vector3 | null`
|
|
22
|
+
- `object: Object3D | null`
|
|
23
|
+
- `face: any`
|
|
24
|
+
- `entry?: any`
|
|
25
|
+
- `kind?: string`
|
|
26
|
+
- `thing?: HitThing` Point -> thing, computed when read: the world record the hit belongs to (a batched instance resolves to its original), where it was authored and what to edit. Example: `const t = engine.pick(0, 0)?.thing; // { id: 'chest-home', kind: 'chest', template: 'chest', definedAt: 'content/props.js:14', ... }`
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# engine.rigid — rigid(opts?: RigidOptions)
|
|
2
|
+
|
|
3
|
+
Real physics, Rapier (rigid() module, needs collision)
|
|
4
|
+
|
|
5
|
+
- Options `RigidOptions`:
|
|
6
|
+
- `gravity?: number` Gravity (m/s², negative points down), default -9.81
|
|
7
|
+
- `terrainRing?: number` How many rings of chunks around the player get terrain colliders, default 1
|
|
8
|
+
- `buoyancy?: boolean` Whether there is buoyancy, default true
|
|
9
|
+
- `buoyancyForce?: number` Buoyancy strength (1 = just floats), default 1.6
|
|
10
|
+
- `waterDrag?: number` Drag in water, default 2.5
|
|
11
|
+
- `floatLine?: number` Buoyancy "waterline": an object starts floating when its center is this many meters below the water surface, default 0.3
|
|
12
|
+
- `floatDepth?: number` Buoyancy reaches its maximum this many meters further down, default 0.8
|
|
13
|
+
- `treeColliderHeight?: number` Height (meters) of vegetation collision pillars (tree trunks), default 6
|
|
14
|
+
- `treeRadius?: number` Trunks get collision cylinders only in chunks within this many meters of the player or a moving rigid body (the rest are covered by engine.collision for characters), default 16
|
|
15
|
+
- `playerCapsule?: { halfHeight: number; radius: number }` Player capsule size (meters), default computed from engine.movement radius / height
|
|
16
|
+
|
|
17
|
+
## Methods and properties
|
|
18
|
+
- `rigid.addBox(mesh: Object3D, opts?: RigidBoxOptions) → RigidEntry | null` — Add a box (crate). Returns null if not ready
|
|
19
|
+
- `rigid.addBall(mesh: Object3D, opts?: RigidBallOptions) → RigidEntry | null` — Add a ball
|
|
20
|
+
- `rigid.addHull(mesh: Object3D, opts?: RigidBodyOptions) → RigidEntry | null` — Add a convex hull (irregular objects such as rocks and barrels)
|
|
21
|
+
- `rigid.impulse(entry: RigidEntry, impulse: Vec3Like)` — Give it a push: impulse vector impulse (Vector3 / [x, y, z] / { x, y, z }), e.g. impulse(ball, [0, 3, 5])
|
|
22
|
+
- `rigid.setPosition(entry: RigidEntry, position: PositionLike)` — Teleport to position (velocity is zeroed)
|
|
23
|
+
- `rigid.groundReady(position: PositionLike) → boolean` — Is the physics ground under position built (always true without chunked terrain; with mover: 'rapier' and not yet built, 'simple' is used temporarily)
|
|
24
|
+
- `rigid.addVehicle(mesh: Object3D, opts: VehicleOptions) → Vehicle | null` — Turn a model into a drivable car (Rapier vehicle controller); remove it with vehicle.remove() (anyone inside gets out first). Returns null if not ready
|
|
25
|
+
- Properties:
|
|
26
|
+
- `ready: boolean` Is the physics engine ready (downloaded and initialized at start())
|
|
27
|
+
- `bodies: RigidEntry[]` All physics bodies
|
|
28
|
+
- `R: any` Rapier library
|
|
29
|
+
- `world: any` Rapier world
|
|
30
|
+
- `playerBody: any` The player's Rapier kinematic body and capsule collider (follow the player position every step; used for collision when mover: 'rapier'; the capsule is off while driving)
|
|
31
|
+
- `playerCapsule: { halfHeight: number; radius: number }` Player capsule size (meters)
|
|
32
|
+
- `vehicles: Vehicle[]` All vehicles
|
|
33
|
+
- `stats: { bodies: number; active: number; colliders: number }` Statistics
|
|
34
|
+
|
|
35
|
+
## Data structures
|
|
36
|
+
- **RigidBodyOptions** Parameters for adding a physics body
|
|
37
|
+
- `mass?: number` Mass (kilograms), default 1
|
|
38
|
+
- `friction?: number` Friction, default 0.7
|
|
39
|
+
- `restitution?: number` Restitution 0–1, default 0.1
|
|
40
|
+
- `damping?: number` Linear damping, default 0.05
|
|
41
|
+
- `angularDamping?: number` Angular damping, default 0.1
|
|
42
|
+
- `fixed?: boolean` Fixed in place (only blocks other things)
|
|
43
|
+
- **RigidEntry** (extends Handle) A physics body (the handle returned by addBox / addBall / addHull)
|
|
44
|
+
- `body: any` Rapier rigid body (translation(), mass(), setLinvel()…)
|
|
45
|
+
- `collider: any` Rapier collider
|
|
46
|
+
- `mesh: Object3D` The matching three.js model (position is written by physics every step)
|
|
47
|
+
- `object: Object3D` Same as mesh (the name consistent with player.object, ent.object)
|
|
48
|
+
- `enabled: boolean` Whether it is being simulated (frozen when too far from the player)
|
|
49
|
+
- `volume: number` Volume (cubic meters, used for buoyancy)
|
|
50
|
+
- `damping: number`
|
|
51
|
+
- `angularDamping: number`
|
|
52
|
+
- `wet?: boolean`
|
|
53
|
+
- `remove()` — Remove this rigid body (the model was passed in by you and is not deleted; call engine.remove(entry.object) when done). Casting / receiving shadows follows the model's own castShadow / receiveShadow
|
|
54
|
+
- **VehicleOptions** Parameters of rigid.addVehicle()
|
|
55
|
+
- `id?: string` Stable id (default 'vehicle1', 'vehicle2'... in creation order): saves name the player's vehicle by it; give one when the creation order varies
|
|
56
|
+
- `wheels: VehicleWheel[]` Wheels (at least 3)
|
|
57
|
+
- `mass?: number` Mass (kilograms)
|
|
58
|
+
- `engineForce?: number` Throttle force, default 800
|
|
59
|
+
- `brakeForce?: number` Brake force, default 20
|
|
60
|
+
- `maxSteer?: number` Max steering angle (radians), default 0.5
|
|
61
|
+
- `suspension?: { rest?: number; stiffness?: number; damping?: number }` Suspension: rest natural length (meters), stiffness, damping
|
|
62
|
+
- `seat?: Vec3Like` Seat (relative to the body, meters): the player gets out beside it
|
|
63
|
+
- `camera?: { distance?: number; height?: number }` Camera distance and height while driving (meters)
|
|
64
|
+
- `size?: number[]` Body collision box size [width, height, depth] (meters); if omitted, taken from the model's bounding box (wheels excluded)
|
|
65
|
+
- `friction?: number` Tire grip, default 1.5
|
|
66
|
+
- `exitOffset?: number` Distance from the side of the body when getting out (meters), default 0.8
|
|
67
|
+
- **VehicleWheel** A wheel: position relative to the body (meters), radius (meters), steer can steer, drive is powered, object is the wheel model that spins
|
|
68
|
+
- `position: Vec3Like`
|
|
69
|
+
- `radius: number`
|
|
70
|
+
- `steer?: boolean`
|
|
71
|
+
- `drive?: boolean`
|
|
72
|
+
- `object?: Object3D`
|
|
73
|
+
- **Vehicle** (extends RigidEntry) A vehicle (returned by rigid.addVehicle, faces the model's +Z). player.enter(vehicle) gets in; with interactions installed, press the interact key nearby to get in / out
|
|
74
|
+
- `id: string` Stable id (rigid.addVehicle({ id })); saves name the player's vehicle by it
|
|
75
|
+
- `object: Object3D` Body model (the mesh you passed in)
|
|
76
|
+
- `body: any` Rapier rigid body
|
|
77
|
+
- `controller: any` Rapier vehicle controller (DynamicRayCastVehicleController)
|
|
78
|
+
- `wheels: VehicleWheel[]`
|
|
79
|
+
- `speed: number` Current speed (m/s)
|
|
80
|
+
- `driver: Character | null` Who is driving (null if nobody)
|
|
81
|
+
- `camera?: { distance?: number; height?: number }` Camera parameters while driving
|
|
82
|
+
- `drive(throttle: number, steer: number, brake?: number)` — Controls: throttle -1..1, steer -1..1 (right is positive), brake 0–1
|
|
83
|
+
- `seatPosition() → Vector3` — World position of the seat
|
|
84
|
+
- `exitPosition() → Vector3` — Where to get out (outside the door on the driver's side, world coordinates)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# engine.saves (Saves) — engine.saves handles saving
|
|
2
|
+
|
|
3
|
+
- `saves.register(key: string, provider: SaveProvider)` — Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later parts wait. version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current shape. A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept). A part registered after a save was loaded (a module installed later) is handed its data from that save at once. atomic: true joins this part to atomic ops: it is copied before an atomic op runs and put back if the op fails (plain data only; afterLoad does not run on rollback). Example: `engine.saves.register('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) }); // later the format gains beds: version 2, and a step that upgrades version-1 data engine.saves.register('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });`
|
|
4
|
+
- `saves.queue(fn: () => Promise<T>) → Promise<T>` — Queue a disk write (runs in call order once storage is ready; flush waits for it; used by attachments such as photos).
|
|
5
|
+
- `saves.flush() → Promise<void>` — Wait for all queued disk writes to finish (for tests and before the page closes)
|
|
6
|
+
- `saves.collect() → { format, savedAt, versions, parts }` — Collect the data of every part (does not write to the browser): { format, savedAt, versions, parts }. A part whose save() throws is left out and reported (engine.error in dev); save() instead refuses to write such a save.
|
|
7
|
+
- `saves.check(slot?: string) → null | "missing" | "corrupt" | "tooNew" | "migrate"` — Can this slot be loaded? null when it can, else why not (checked without touching the game): 'missing' / 'corrupt' (unreadable) / 'tooNew' (a newer save format or part) / 'migrate' (an upgrade step is missing or throws). Example: `if (engine.saves.check('slot1') === 'tooNew') showUpdateHint();`
|
|
8
|
+
- `saves.apply(data: any, slot?: string) → Promise<boolean>` — Apply a save's data (an object from collect(), or save text) onto the running game. Resolves true when every part loaded. Refused before anything changes (false, toast) when the data is corrupt, from a newer build or cannot be migrated. After every part loaded it runs the modules' afterLoad hooks (gameplay frozen until they resolve), for saves.load, session.newGame / quit and direct calls alike. If a part's load throws, the game is rolled back to how it was before (every part reloads its pre-load state) and it resolves false; the error goes through the error tiers. The state changes synchronously unless a part's load is async; only the result is a Promise.
|
|
9
|
+
- `saves.save(slot?: string) → Promise<boolean>` — Save into a slot (default 'auto'). Returns Promise<boolean> (resolves after the write to IndexedDB: true on success, false with a toast and console error on failure). The in-memory save updates immediately, so a following load / list / export sees it at once; the 'save:written' event fires only after the write succeeds. If any part's save() throws, nothing is written and the slot keeps its previous save (false). A failed write keeps the previous save too. Show "saved" only after the result is true. Example: `if (await engine.saves.save('slot1')) toast(engine, 'Saved'); // on false the engine already showed why`
|
|
10
|
+
- `saves.load(slot?: string) → Promise<boolean>` — Load a slot onto the running playthrough (a quick load: what the game added during play stays) and resolve true on success; the 'save:loaded' event fires on success. A missing slot resolves false; a corrupt / too new / unmigratable save resolves false with a toast and changes nothing; a part whose load throws rolls the game back. To continue or retry with nothing of the current playthrough left over, use engine.session.load(slot). Example: `if (!(await engine.saves.load('quick'))) toast(engine, 'No quick save');`
|
|
11
|
+
- `saves.list() → { slot: string; savedAt: number }[]` — All slots, newest first (synchronous, reads the in-memory index)
|
|
12
|
+
- `saves.remove(slot: string) → Promise<void>` — Delete a slot. Returns a Promise (disk write done); awaiting is optional
|
|
13
|
+
- `saves.export(slot?: string) → string` — Export as a piece of text (can be copied as a backup; synchronous, without binary attachments)
|
|
14
|
+
- `saves.import(text: string, slot?: string) → Promise<boolean>` — Import text from export() into a slot (default 'imported'); checked like importFile and written before it resolves. Resolves true once stored (save:imported fires), false when the text is not a save or the write failed. It does not load the slot.
|
|
15
|
+
- `saves.exportFile(slot?: string, opts?: { files?: boolean }) → Promise<boolean>` — Download a save file (.json): the save plus every binary attachment (as data: text, so the file is larger; { files: false } exports the save only). Restores everything when browser data is wiped on a phone. Returns Promise<boolean>. Example: `engine.saves.exportFile('slot1');`
|
|
16
|
+
- `saves.importFile(file?: Blob, slot?: string) → Promise<string | null>` — Restore from a save file into slot (default 'imported', so a shared file never overwrites 'auto'). file is a File / Blob; omit it to open a file picker. Everything is checked first (file marker and format, the save inside, attachments must be data: URLs: nothing is fetched). Returns the slot name on success, and null if cancelled, the file is invalid or the write failed (a toast was already shown). It restores the slot only and does not load it.
|
|
17
|
+
- `saves.autosave(minutes?: number) → { remove(): void }` — Autosave into 'auto' every `minutes` minutes of play: counted in fixed seconds, so it waits while paused, frozen or in a menu that freezes the game, and it never saves while no playthrough runs (the title screen, during newGame / load / quit) or after a gameplay error. Returns a handle; remove() stops it. Calling it again replaces the previous autosave. Example: `engine.saves.autosave(3); // once at boot: it waits by itself while no playthrough runs`
|
|
18
|
+
- Properties:
|
|
19
|
+
- `prefix: string` Save name prefix (start of the key names in the localStorage fallback, and of the IndexedDB database name)
|
|
20
|
+
- `store: { mode, blobs, putBlob, deleteBlob }` Storage layer: saves in the IndexedDB slots store, attachments (by group, e.g. 'photo') in the blobs store; mode 'localStorage' without IndexedDB.
|
|
21
|
+
- `ready: boolean` Has the save index been read into memory? (start() waits for it; game code rarely needs to care)
|
|
22
|
+
- `whenReady: Promise<void>` Resolves once the save index is in memory; await it only to list / load before start()
|
|
23
|
+
- `versions: Record<string, number>` The save versions this build reads, per part: { world: 1, clock: 1, ... }. A save whose part is newer is refused; an older one is migrated.
|
|
24
|
+
|
|
25
|
+
## Data structures
|
|
26
|
+
- **SaveProvider** Save provider: save() returns JSON-able data, load(data) reads it back (may return a Promise, e.g. for changing level; later parts wait for it to finish before loading). first: true providers load first (parts such as the level, where the rest only makes sense after it is loaded)
|
|
27
|
+
- `save: () => any`
|
|
28
|
+
- `load: (data: any) => void | Promise<void>`
|
|
29
|
+
- `first?: boolean` Load before the other parts (such as the level)
|
|
30
|
+
- `atomic?: boolean` Join atomic ops: copied before an atomic op runs, put back if it fails (plain data; afterLoad does not run on rollback)
|
|
31
|
+
- `version?: number` This part's format version, default 1: raise it by 1 when what save() returns changes shape. A save with a newer version is refused
|
|
32
|
+
- `migrate?: Record<number, (data: any, save: { parts: Record<string, an…` Upgrade steps: old version -> data => data in the next version's shape, e.g. { 1: d => ({ ...d, beds: [] }) }. The second argument is the whole save as read ({ parts, versions }, read only), for a step that depends on another part
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# engine.settings — settings(opts?: SettingsOptions)
|
|
2
|
+
|
|
3
|
+
Settings menu (settings() module)
|
|
4
|
+
|
|
5
|
+
- Options `SettingsOptions`:
|
|
6
|
+
- `action?: string` Action name that opens the menu, default 'menu'
|
|
7
|
+
- `keys?: string[]` Key that opens the menu, default ['Escape']
|
|
8
|
+
- `storageKey?: string` Browser storage key
|
|
9
|
+
- `presets?: Record<string, QualityPreset>` Override the graphics presets: { low: {...}, medium: {...}, high: {...} }
|
|
10
|
+
- `sections?: boolean | string[]` Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY / camera.fov). Example: `settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })`
|
|
11
|
+
- `freezeWorld?: boolean` Pause gameplay while the menu is open (with flow installed it switches to flow's 'paused' and returns to the previous state on close; without flow it uses engine.freeze); the picture keeps running, default false
|
|
12
|
+
|
|
13
|
+
## Methods and properties
|
|
14
|
+
- `settings.get(key: string) → any` — Read a setting, e.g. get('vol.music')
|
|
15
|
+
- `settings.set(key: string, value: any, opts?: { save?: boolean })` — Change a setting (takes effect immediately + saved)
|
|
16
|
+
- `settings.preset(name: 'low' | 'medium' | 'high' | (string & {}))` — Graphics preset: 'low' / 'medium' / 'high'
|
|
17
|
+
- `settings.define(key: string, def: T, apply?: (value: T, e: Engine) => void)` — Game-defined setting: default value + apply function (saved automatically)
|
|
18
|
+
- `settings.addSection(id: string, section?: SettingsSection)` — Add a tab of your own, or a built-in / optional one by name: addSection('camera')
|
|
19
|
+
- `settings.resetBindings()` — Restore all keys to defaults
|
|
20
|
+
- `settings.rebind(action: string, code: string)` — Change the first key of an action to code
|
|
21
|
+
- `settings.actionList() → any[]` — Key list (for the UI)
|
|
22
|
+
- `settings.save()` — Save to the browser
|
|
23
|
+
- Also: `settings.removeSection(id: string)`, `settings.open()`, `settings.close()`, `settings.toggle(on?: boolean)`
|
|
24
|
+
- Properties:
|
|
25
|
+
- `values: Record<string, any>` All current setting values
|
|
26
|
+
- `presets: Record<string, QualityPreset>` Graphics presets
|
|
27
|
+
- `sections: Map<string, any>` Tabs
|
|
28
|
+
- `isOpen: boolean` Whether the menu is open
|
|
29
|
+
|
|
30
|
+
## Data structures
|
|
31
|
+
- **SettingsSection** One settings tab
|
|
32
|
+
- `title: string | ((e: Engine) => string)` Title: text or engine => text
|
|
33
|
+
- `render: (tools: SettingsTools, e: Engine, s: Settings) => string` Generate the content HTML
|
|
34
|
+
- `bind?: (el: HTMLElement, e: Engine, s: Settings) => void` Called after every redraw, to bind events to custom controls
|
|
35
|
+
- `when?: (e: Engine) => boolean` When this returns false the tab is not shown
|
|
36
|
+
- `order?: number` Sort order, smaller first, default 100
|