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,82 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/Threads.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* engine.threads: worker pool behind createEngine({ threads }). Lanes start their workers lazily; size 0 means everything runs on the main thread.
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
6
|
+
export class Threads {
|
|
7
|
+
/** Workers per lane (0 = main thread only) */
|
|
8
|
+
size: number;
|
|
9
|
+
/** True when SharedArrayBuffer can be shared with workers (page is cross-origin isolated) */
|
|
10
|
+
shared: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A lane of workers running one script. create must contain the literal new Worker(new URL('./file.js', import.meta.url), { type: 'module' }) so bundlers find the file.
|
|
13
|
+
* local builds the same handler on the main thread (used when there are no workers).
|
|
14
|
+
* @param {{ create: () => Worker, local: () => (msg: any) => any, max?: number }} opts
|
|
15
|
+
* @returns {Lane}
|
|
16
|
+
* @example
|
|
17
|
+
* const lane = engine.threads.lane({ create: () => new Worker(new URL('./chunkWorker.js', import.meta.url), { type: 'module' }), local: chunkHandler });
|
|
18
|
+
* lane.run({ cx: 0, cz: 0 }).then(r => engine.commits ...);
|
|
19
|
+
*/
|
|
20
|
+
lane(opts: {
|
|
21
|
+
create: () => Worker;
|
|
22
|
+
local: () => (msg: any) => any;
|
|
23
|
+
max?: number;
|
|
24
|
+
}): Lane;
|
|
25
|
+
/**
|
|
26
|
+
* A typed array other threads can read without a copy: on a SharedArrayBuffer when shared, else an ordinary one (postMessage then copies it).
|
|
27
|
+
* @template {Float32ArrayConstructor | Int32ArrayConstructor | Uint8ArrayConstructor | Uint16ArrayConstructor | Float64ArrayConstructor} T
|
|
28
|
+
* @param {T} Type
|
|
29
|
+
* @param {number} length
|
|
30
|
+
* @returns {InstanceType<T>}
|
|
31
|
+
* @example const heights = engine.threads.array(Float32Array, 256 * 256);
|
|
32
|
+
*/
|
|
33
|
+
array<T extends Float32ArrayConstructor | Int32ArrayConstructor | Uint8ArrayConstructor | Uint16ArrayConstructor | Float64ArrayConstructor>(Type: T, length: number): InstanceType<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Turn a self-contained function into one that can run in a worker. It is recompiled from its source text, so it sees only its parameters and globals like Math:
|
|
36
|
+
* a closure variable fails with a ReferenceError naming it, on the main thread too (threads on or off behave the same). Used by world.simulate(kind, { far, worker: true }).
|
|
37
|
+
* @param {Function} fn
|
|
38
|
+
* @param {string} label where it came from, used in error messages
|
|
39
|
+
* @returns {{ fn: Function, src: string, label: string }}
|
|
40
|
+
* @example const grow = engine.threads.pure((rec, dt) => { rec.growth = Math.min(1, rec.growth + dt / 600); }, "world.simulate('crop') far");
|
|
41
|
+
*/
|
|
42
|
+
pure(fn: Function, label: string): {
|
|
43
|
+
fn: Function;
|
|
44
|
+
src: string;
|
|
45
|
+
label: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One kind of worker (one script), up to engine.threads.size instances. run() goes to the least busy one; with no workers the local handler answers on a microtask.
|
|
50
|
+
*/
|
|
51
|
+
declare class Lane {
|
|
52
|
+
threads: any;
|
|
53
|
+
create: any;
|
|
54
|
+
local: any;
|
|
55
|
+
max: number;
|
|
56
|
+
/** @type {{ w: Worker, busy: number }[]} */ workers: {
|
|
57
|
+
w: Worker;
|
|
58
|
+
busy: number;
|
|
59
|
+
}[];
|
|
60
|
+
handler: any;
|
|
61
|
+
tasks: Map<any, any>;
|
|
62
|
+
bcast: Map<any, any>;
|
|
63
|
+
/** Workers actually running in this lane (0 = main thread) @returns {number} */
|
|
64
|
+
get size(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Send a task; resolves with the handler's reply. Typed arrays you list in transfer move to the worker (unusable here afterwards);
|
|
67
|
+
* if that worker then crashes, the task rejects (code threads-transfer) instead of rerunning on the main thread with emptied buffers.
|
|
68
|
+
* @param {any} msg plain data
|
|
69
|
+
* @param {Transferable[]} [transfer]
|
|
70
|
+
* @returns {Promise<any>}
|
|
71
|
+
*/
|
|
72
|
+
run(msg: any, transfer?: Transferable[]): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* Send setup data to every worker (no reply). With a key, a later broadcast of the same key replaces it for workers started afterwards.
|
|
75
|
+
* @param {any} msg
|
|
76
|
+
* @param {string} [key]
|
|
77
|
+
*/
|
|
78
|
+
broadcast(msg: any, key?: string): void;
|
|
79
|
+
/** Stop the workers; open tasks never settle */
|
|
80
|
+
dispose(): void;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/Views.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
export class Views {
|
|
3
|
+
/** @param {any} engine */
|
|
4
|
+
constructor(engine: any);
|
|
5
|
+
engine: any;
|
|
6
|
+
map: Map<any, any>;
|
|
7
|
+
current: string;
|
|
8
|
+
/**
|
|
9
|
+
* Declare a view. position and target are [x, y, z]; fov (degrees) is optional (the camera's own when left out). Returns { remove() } (undeclares it).
|
|
10
|
+
* @param {string} name @param {{ position: number[], target?: number[], fov?: number }} v
|
|
11
|
+
* @returns {{ remove(): void }}
|
|
12
|
+
*/
|
|
13
|
+
define(name: string, v: {
|
|
14
|
+
position: number[];
|
|
15
|
+
target?: number[];
|
|
16
|
+
fov?: number;
|
|
17
|
+
}): {
|
|
18
|
+
remove(): void;
|
|
19
|
+
};
|
|
20
|
+
/** @param {string} name */
|
|
21
|
+
has(name: string): boolean;
|
|
22
|
+
/** @returns {string[]} the declared view names */
|
|
23
|
+
list(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Put the camera on a view and keep it there (the camera rigs leave it alone) until release() or the returned handle's remove(); null for an unknown name
|
|
26
|
+
* @param {string} name @returns {{ remove(): void } | null}
|
|
27
|
+
*/
|
|
28
|
+
show(name: string): {
|
|
29
|
+
remove(): void;
|
|
30
|
+
} | null;
|
|
31
|
+
/** Give the camera back (to the previous holder, e.g. a running cutscene, or to the rig) */
|
|
32
|
+
release(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/audioVoice.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/** Point the Web Audio listener where the camera is (only called while positional voices exist: zero cost otherwise) */
|
|
3
|
+
export function placeListener(ctx: any, camera: any): void;
|
|
4
|
+
/** Synth building block behind audio.noiseBurst: a burst of filtered noise */
|
|
5
|
+
export function synthNoise(audio: any, opts: any): void;
|
|
6
|
+
/** Synth building block behind audio.tone: a short enveloped tone */
|
|
7
|
+
export function synthTone(audio: any, opts: any): void;
|
|
8
|
+
/** audio.load body: decode a file once (cached), or load a sound name from an asset pack through engine.assets */
|
|
9
|
+
export function loadSound(audio: any, url: any): Promise<any>;
|
|
10
|
+
/** audio.play body: a file by path or asset name, no sounds entry needed */
|
|
11
|
+
export function playFile(audio: any, url: any, opts: any): Promise<SoundHandle>;
|
|
12
|
+
/** audio.sfx body: cooldown, voice limit, variant pick, jitter, then start the source */
|
|
13
|
+
export function playSound(audio: any, name: any, opts: any): SoundHandle;
|
|
14
|
+
/** A playing sound. engine.audio.sfx / play return one; the game keeps it to stop, fade or move the sound */
|
|
15
|
+
export class SoundHandle {
|
|
16
|
+
/** Sound name (sfx) or file path (play) */
|
|
17
|
+
name: any;
|
|
18
|
+
/** The voice's GainNode (volume of this one sound) @type {any} */
|
|
19
|
+
gain: any;
|
|
20
|
+
/** The PannerNode of a positional sound, else null @type {any} */
|
|
21
|
+
panner: any;
|
|
22
|
+
/** The AudioBufferSourceNode once a file started (null for synths and while loading) @type {any} */
|
|
23
|
+
source: any;
|
|
24
|
+
/** Still sounding (not stopped and not finished)? @returns {boolean} */
|
|
25
|
+
get playing(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Move a positional sound: a position, or an Object3D to follow every frame (no effect on a non-positional sound)
|
|
28
|
+
* @param {any} at
|
|
29
|
+
* @returns {this}
|
|
30
|
+
*/
|
|
31
|
+
setPosition(at: any): this;
|
|
32
|
+
/**
|
|
33
|
+
* Fade this sound's volume to `to` (0-1) over `seconds`; it keeps playing (use stop to end it)
|
|
34
|
+
* @param {number} to
|
|
35
|
+
* @param {number} [seconds]
|
|
36
|
+
* @returns {this}
|
|
37
|
+
* @example h.fade(0.2, 1.5);
|
|
38
|
+
*/
|
|
39
|
+
fade(to: number, seconds?: number): this;
|
|
40
|
+
/**
|
|
41
|
+
* Stop, fading out over `fade` seconds (0 = at once)
|
|
42
|
+
* @param {number} [fade]
|
|
43
|
+
* @returns {void}
|
|
44
|
+
* @example const h = engine.audio.sfx('engine-hum', { loop: true }); h.stop(1);
|
|
45
|
+
*/
|
|
46
|
+
stop(fade?: number): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/page.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/** engine.page: window focus, tab visibility, mouse lock and WebGL context, all handled here. */
|
|
3
|
+
export class Page {
|
|
4
|
+
/** Wait (no fixed steps) while the page is away; default true. Settable at runtime @type {boolean} */
|
|
5
|
+
pauseOnBlur: boolean;
|
|
6
|
+
/** The window has keyboard focus @type {boolean} */
|
|
7
|
+
focused: boolean;
|
|
8
|
+
/** The tab is visible @type {boolean} */
|
|
9
|
+
visible: boolean;
|
|
10
|
+
/** The mouse is locked to the canvas (first-person / shoulder cameras lock on click) @type {boolean} */
|
|
11
|
+
pointerLocked: boolean;
|
|
12
|
+
/** The WebGL context is lost and not yet restored @type {boolean} */
|
|
13
|
+
contextLost: boolean;
|
|
14
|
+
/** The page is away: the window lost focus or the tab is hidden @type {boolean} */
|
|
15
|
+
get away(): boolean;
|
|
16
|
+
/** The real-time loop holds gameplay now (away with pauseOnBlur, or the WebGL context is lost) @type {boolean} */
|
|
17
|
+
get held(): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/core/session.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
|
|
3
|
+
/** engine.session: new game / continue / back to title, each from a clean slate. */
|
|
4
|
+
export class Session {
|
|
5
|
+
/**
|
|
6
|
+
* True while a playthrough runs: start() has finished, no newGame / load / quit is replacing the state, and the title screen is not up.
|
|
7
|
+
* Autosave and other "only during play" work check it.
|
|
8
|
+
* @type {boolean}
|
|
9
|
+
*/
|
|
10
|
+
get playing(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Keep a handle only for this playthrough: newGame / load / quit call handle.remove(). Returns the handle.
|
|
13
|
+
* @template {{ remove(): void }} H
|
|
14
|
+
* @param {H} handle
|
|
15
|
+
* @returns {H}
|
|
16
|
+
* @example
|
|
17
|
+
* // a quest's helper listener lives only as long as this playthrough
|
|
18
|
+
* engine.session.track(engine.events.on('npc:talk', ({ id }) => { if (id === 'baker') engine.vars.setFlag('metBaker'); }));
|
|
19
|
+
*/
|
|
20
|
+
track<H extends {
|
|
21
|
+
remove(): void;
|
|
22
|
+
}>(handle: H): H;
|
|
23
|
+
/**
|
|
24
|
+
* Start a new playthrough from the state the game had right after start(). Returns Promise<boolean> (false only if a save part failed to load; the game is then rolled back).
|
|
25
|
+
* @returns {Promise<boolean>}
|
|
26
|
+
* @example
|
|
27
|
+
* // a "Restart" button in a game-over screen
|
|
28
|
+
* restartBtn.onclick = () => engine.session.newGame();
|
|
29
|
+
*/
|
|
30
|
+
newGame(): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Continue from a save (or retry from a checkpoint) with nothing of the current playthrough left over: the new-game state with the save on top,
|
|
33
|
+
* so a part the save does not have (a module added in a later version of the game) starts from its new-game state.
|
|
34
|
+
* A save that cannot be read (missing, corrupt, from a newer build) is refused before anything changes: returns false, the current game and the save stay as they were.
|
|
35
|
+
* @param {string} [slot]
|
|
36
|
+
* @returns {Promise<boolean>}
|
|
37
|
+
* @example
|
|
38
|
+
* engine.events.on('player:dead', () => engine.session.load('checkpoint')); // retry; the checkpoint was saved with engine.saves.save('checkpoint')
|
|
39
|
+
*/
|
|
40
|
+
load(slot?: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* End the playthrough and show the title screen (the title part when the game turned it on; flow returns to its start state).
|
|
43
|
+
* The state behind the title is the new-game state, so nothing from the old playthrough runs while the title is up.
|
|
44
|
+
* @returns {Promise<boolean>}
|
|
45
|
+
* @example settingsBackToTitle.onclick = () => engine.session.quit();
|
|
46
|
+
*/
|
|
47
|
+
quit(): Promise<boolean>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/ambience/Ambience.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Ambience -> engine.ambience. Rules come from createEngine({ audio: { ambience: [...] } }) plus opts.rules
|
|
4
|
+
* @param {AmbienceOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Ambience>}
|
|
6
|
+
* @example engine.use(ambience({ rules: [{ sound: 'hum', when: { zone: 'lab' }, volume: 0.4 }] }));
|
|
7
|
+
*/
|
|
8
|
+
export function ambience(opts?: AmbienceOptions): ModuleDef<Ambience>;
|
|
9
|
+
/** engine.ambience: the rule table of background sounds */
|
|
10
|
+
export class Ambience {
|
|
11
|
+
/** Where the sounds are heard from: whoever the player controls (engine.actor), else the camera focus @type {THREE.Vector3} */
|
|
12
|
+
position: THREE.Vector3;
|
|
13
|
+
/**
|
|
14
|
+
* Add one rule; returns a handle whose remove() fades the sound out and drops the rule
|
|
15
|
+
* @param {AmbienceRule} rule
|
|
16
|
+
* @returns {{ remove(): void }}
|
|
17
|
+
* @example const h = engine.ambience.add({ sound: 'storm-wind', when: { weather: 'storm' }, volume: 0.5 });
|
|
18
|
+
*/
|
|
19
|
+
add(rule: AmbienceRule): {
|
|
20
|
+
remove(): void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Replace the whole rule table (null or [] = silence)
|
|
24
|
+
* @param {AmbienceRule[] | null} list
|
|
25
|
+
* @returns {this}
|
|
26
|
+
*/
|
|
27
|
+
rules(list: AmbienceRule[] | null): this;
|
|
28
|
+
/**
|
|
29
|
+
* How much of the ground within `radius` meters of the listener is water (0-1), sampled at 6 points: for a water rule's volume
|
|
30
|
+
* @param {number} [radius]
|
|
31
|
+
* @returns {number}
|
|
32
|
+
* @example { sound: 'river', volume: (e, a) => a.nearWater(20) * 0.12 } // in data: volume: { add: { nearWater: 0.12 } } (12 m)
|
|
33
|
+
*/
|
|
34
|
+
nearWater(radius?: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* What each rule is doing (debug, tests): sound name, whether its condition holds, its current target volume
|
|
37
|
+
* @returns {{ sound: string, on: boolean, volume: number }[]}
|
|
38
|
+
*/
|
|
39
|
+
get info(): {
|
|
40
|
+
sound: string;
|
|
41
|
+
on: boolean;
|
|
42
|
+
volume: number;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
45
|
+
import type { AmbienceOptions } from '../../../gameplay';
|
|
46
|
+
import type { ModuleDef } from '../../../core';
|
|
47
|
+
import type { AmbienceRule } from '../../../core';
|
|
48
|
+
import * as THREE from 'three';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/debug/DebugPanel.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* F3 debug panel -> engine.debug.panel: performance panel, settings, stress test. Collapsed by default; F3 shows/hides it; open: true shows it at start. Just do not install it in a release
|
|
4
|
+
* @param {{ open?: boolean }} [opts]
|
|
5
|
+
* @returns {ModuleDef<DebugPanel>}
|
|
6
|
+
*/
|
|
7
|
+
export function debug(opts?: {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
}): ModuleDef<DebugPanel>;
|
|
10
|
+
/** @import { ModuleDef } from '../../../core' */
|
|
11
|
+
/** engine.debug.panel (F3 panel) */
|
|
12
|
+
export class DebugPanel {
|
|
13
|
+
/** Stress test running (player auto-runs fast) @type {boolean} */
|
|
14
|
+
benchmarking: boolean;
|
|
15
|
+
/** Panel root element @type {HTMLElement} */
|
|
16
|
+
el: HTMLElement;
|
|
17
|
+
/**
|
|
18
|
+
* Start the stress test (seconds, default 20): the character auto-runs fast, continuously loading new chunks, and a report is shown in the panel at the end
|
|
19
|
+
* @param {number} [seconds]
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
startBench(seconds?: number): void;
|
|
23
|
+
}
|
|
24
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/flow/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Game flow and scene transitions → engine.flow
|
|
4
|
+
* @param {FlowOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Flow>}
|
|
6
|
+
*/
|
|
7
|
+
export function flow(opts?: FlowOptions): ModuleDef<Flow>;
|
|
8
|
+
import type { FlowOptions } from '../../../gameplay';
|
|
9
|
+
import type { Flow } from '../../../gameplay';
|
|
10
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/Grid.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* A placement grid. Several can exist at once (a yard outdoors, a room indoors); each has its own cell size, origin and bounds.
|
|
4
|
+
* @example
|
|
5
|
+
* const room = engine.grids.add('room', { cell: 1, origin: [0, 0], size: [16, 12] });
|
|
6
|
+
* room.toCell(engine.player.position); // [3, 5]
|
|
7
|
+
* room.can('table', [3, 5]); // true or a reason: 'occupied' 'outOfBounds' 'notFlat' 'wrongGround' or a layer reason ...
|
|
8
|
+
* engine.ops.run('grid.place', { grid: 'room', item: 'table', cell: [3, 5] });
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
|
+
export class Grid {
|
|
12
|
+
/** Grid name (the `grid` arg of the grid.* ops) @type {string} */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Cell edge length (meters) @type {number} */
|
|
15
|
+
cell: number;
|
|
16
|
+
/** World position of the min corner of cell [0, 0] @type {{ x: number, z: number }} */
|
|
17
|
+
origin: {
|
|
18
|
+
x: number;
|
|
19
|
+
z: number;
|
|
20
|
+
};
|
|
21
|
+
/** Cell count [width, depth]; null = unbounded @type {[number, number] | null} */
|
|
22
|
+
size: [number, number] | null;
|
|
23
|
+
/** Level name this grid belongs to (null = everywhere); its tiles show only while engine.world.zone matches @type {string | null} */
|
|
24
|
+
zone: string | null;
|
|
25
|
+
/** Max height difference (m) allowed under a footprint before can() says 'notFlat' @type {number} */
|
|
26
|
+
flat: number;
|
|
27
|
+
/**
|
|
28
|
+
* World position (Vector3 / object / [x, z] / [x, y, z] / (x, z)) -> cell [i, j]
|
|
29
|
+
* @example farm.toCell(engine.player.position)
|
|
30
|
+
* @param {any} x
|
|
31
|
+
* @param {number} [z]
|
|
32
|
+
* @returns {[number, number]}
|
|
33
|
+
*/
|
|
34
|
+
toCell(x: any, z?: number): [number, number];
|
|
35
|
+
/**
|
|
36
|
+
* Center of a footprint in world space, y on the ground (engine.surface). Without size it is the center of one cell
|
|
37
|
+
* @example obj.position.copy(farm.toWorld([3, 5]))
|
|
38
|
+
* @param {[number, number]} cell
|
|
39
|
+
* @param {[number, number]} [size]
|
|
40
|
+
* @param {number} [rotation] quarter turns
|
|
41
|
+
* @returns {{ x: number, y: number, z: number }}
|
|
42
|
+
*/
|
|
43
|
+
toWorld(cell: [number, number], size?: [number, number], rotation?: number): {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
z: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Snap a world position to the center of the cell it is in
|
|
50
|
+
* @example mesh.position.copy(farm.snap(hit.point))
|
|
51
|
+
* @param {any} pos
|
|
52
|
+
* @returns {{ x: number, y: number, z: number }}
|
|
53
|
+
*/
|
|
54
|
+
snap(pos: any): {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
z: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Is the cell inside the grid bounds (always true for an unbounded grid)
|
|
61
|
+
* @param {[number, number]} cell
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
inside([i, j]: [number, number]): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Cells covered by a footprint anchored at cell (min corner)
|
|
67
|
+
* @example farm.footprint([2, 2], [2, 1], 1) // [[2,2],[2,3]]: a 2x1 bed turned a quarter covers two cells along z
|
|
68
|
+
* @param {[number, number]} cell
|
|
69
|
+
* @param {[number, number]} [size]
|
|
70
|
+
* @param {number} [rotation] quarter turns
|
|
71
|
+
* @returns {[number, number][]}
|
|
72
|
+
*/
|
|
73
|
+
footprint(cell: [number, number], size?: [number, number], rotation?: number): [number, number][];
|
|
74
|
+
/**
|
|
75
|
+
* Id of the world record occupying a cell, or null
|
|
76
|
+
* @example engine.world.get(farm.at([3, 5]))
|
|
77
|
+
* @param {[number, number]} cell
|
|
78
|
+
* @returns {string | null}
|
|
79
|
+
*/
|
|
80
|
+
at([i, j]: [number, number]): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Ids of the records occupying any cell of an area (each once)
|
|
83
|
+
* @example farm.area([0, 0], [4, 4])
|
|
84
|
+
* @param {[number, number]} cell min corner
|
|
85
|
+
* @param {[number, number]} [size]
|
|
86
|
+
* @returns {string[]}
|
|
87
|
+
*/
|
|
88
|
+
area(cell: [number, number], size?: [number, number]): string[];
|
|
89
|
+
/**
|
|
90
|
+
* Can this go here? Returns true or a reason: outOfBounds, occupied, wrongGround, not<Field> (a layer rule such as notTilled), notFlat, or the item's own can reason.
|
|
91
|
+
* what is an item name registered with engine.grids.define, a size [w, d], or an inline rule { size, ground, layer, flat, can }.
|
|
92
|
+
* @example farm.can('crop', [3, 5]) // 'notTilled' until the soil layer says tilled
|
|
93
|
+
* @example farm.can([2, 1], [0, 0], { rotation: 1 }) // only bounds, occupancy and flatness
|
|
94
|
+
* @param {string | [number, number] | GridRule} what
|
|
95
|
+
* @param {[number, number]} cell
|
|
96
|
+
* @param {{ rotation?: number, ignore?: string }} [opts] ignore: a record id to skip (moving a thing over its own cells)
|
|
97
|
+
* @returns {true | string}
|
|
98
|
+
*/
|
|
99
|
+
can(what: string | [number, number] | GridRule, cell: [number, number], opts?: {
|
|
100
|
+
rotation?: number;
|
|
101
|
+
ignore?: string;
|
|
102
|
+
}): true | string;
|
|
103
|
+
/**
|
|
104
|
+
* can() with the details behind the answer (used by engine.explain): { reason, cell, by } where by is the occupying record id
|
|
105
|
+
* @param {string | [number, number] | GridRule} what
|
|
106
|
+
* @param {[number, number]} cell
|
|
107
|
+
* @param {{ rotation?: number, ignore?: string }} [opts]
|
|
108
|
+
* @returns {{ reason: string | null, cell?: [number, number], by?: string, text?: string }}
|
|
109
|
+
*/
|
|
110
|
+
check(what: string | [number, number] | GridRule, cell: [number, number], { rotation, ignore }?: {
|
|
111
|
+
rotation?: number;
|
|
112
|
+
ignore?: string;
|
|
113
|
+
}): {
|
|
114
|
+
reason: string | null;
|
|
115
|
+
cell?: [number, number];
|
|
116
|
+
by?: string;
|
|
117
|
+
text?: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* A named per-cell data layer on this grid (created on first use): soil state, wetness, ownership, anything plain.
|
|
121
|
+
* Writes go through ops like other saved gameplay state; the data is saved with the game (only non-empty cells).
|
|
122
|
+
* @example const soil = farm.layer('soil'); // in an op: soil.set([3, 5], { tilled: true })
|
|
123
|
+
* @example farm.layer('soil', { tiles: false }) // no tile visuals for this layer
|
|
124
|
+
* @param {string} name
|
|
125
|
+
* @param {import('./Layer.js').LayerOptions} [opts] only read on creation
|
|
126
|
+
* @returns {Layer}
|
|
127
|
+
*/
|
|
128
|
+
layer(name: string, opts?: import("./Layer.js").LayerOptions): Layer;
|
|
129
|
+
/** Layers created so far @returns {Layer[]} */
|
|
130
|
+
get layers(): Layer[];
|
|
131
|
+
/** Number of occupied cells @returns {number} */
|
|
132
|
+
get occupied(): number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Placement rule: what engine.grids.define registers, or an inline rule for can()
|
|
136
|
+
*/
|
|
137
|
+
export type GridRule = {
|
|
138
|
+
size?: [number, number];
|
|
139
|
+
kind?: string;
|
|
140
|
+
ground?: string | string[];
|
|
141
|
+
layer?: Record<string, string>;
|
|
142
|
+
flat?: number;
|
|
143
|
+
fields?: Record<string, any>;
|
|
144
|
+
can?: (e: any, info: {
|
|
145
|
+
grid: Grid;
|
|
146
|
+
cell: [number, number];
|
|
147
|
+
rotation: number;
|
|
148
|
+
cells: [number, number][];
|
|
149
|
+
}) => true | string;
|
|
150
|
+
};
|
|
151
|
+
import { Layer } from './Layer.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/Layer.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/** @experimental */
|
|
3
|
+
export class Layer {
|
|
4
|
+
/** Layer name @type {string} */
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* Data of a cell, or undefined. Read only (frozen in dev builds): change it with set / clear / updateAll
|
|
8
|
+
* @example farm.layer('soil').get([3, 5])?.watered
|
|
9
|
+
* @param {[number, number]} cell
|
|
10
|
+
* @returns {Record<string, any> | undefined}
|
|
11
|
+
*/
|
|
12
|
+
get([i, j]: [number, number]): Record<string, any> | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Merge fields into a cell's data (created if empty); a field set to null / undefined is deleted, and a cell left with no fields is cleared. Returns the data
|
|
15
|
+
* @example farm.layer('soil').set([3, 5], { tilled: true, watered: true })
|
|
16
|
+
* @example farm.layer('soil').set([3, 5], { watered: null }) // dry this one cell
|
|
17
|
+
* @param {[number, number]} cell
|
|
18
|
+
* @param {Record<string, any>} patch
|
|
19
|
+
* @returns {Record<string, any> | undefined}
|
|
20
|
+
*/
|
|
21
|
+
set([i, j]: [number, number], patch: Record<string, any>): Record<string, any> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Empty a cell
|
|
24
|
+
* @param {[number, number]} cell
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
clear([i, j]: [number, number]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Non-empty cells, optionally only those in an area (min corner + size), in i then j order
|
|
30
|
+
* @example farm.layer('soil').query([0, 0], [4, 4]).filter(c => c.data.watered).length
|
|
31
|
+
* @param {[number, number]} [cell]
|
|
32
|
+
* @param {[number, number]} [size]
|
|
33
|
+
* @returns {{ cell: [number, number], data: Record<string, any> }[]}
|
|
34
|
+
*/
|
|
35
|
+
query(cell?: [number, number], size?: [number, number]): {
|
|
36
|
+
cell: [number, number];
|
|
37
|
+
data: Record<string, any>;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* Change every non-empty cell at once (call it inside an op, e.g. a daily reset). fn may edit the data it gets (a copy) in place;
|
|
41
|
+
* returning null clears the cell, returning an object replaces the data. A cell left with no fields is cleared
|
|
42
|
+
* @example farm.layer('soil').updateAll(d => { delete d.watered; })
|
|
43
|
+
* @param {(data: Record<string, any>, cell: [number, number]) => any} fn
|
|
44
|
+
* @returns {number} cells left
|
|
45
|
+
*/
|
|
46
|
+
updateAll(fn: (data: Record<string, any>, cell: [number, number]) => any): number;
|
|
47
|
+
/** Number of non-empty cells @returns {number} */
|
|
48
|
+
get count(): number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options of grid.layer(name, opts)
|
|
52
|
+
*/
|
|
53
|
+
export type LayerOptions = {
|
|
54
|
+
tiles?: boolean | {
|
|
55
|
+
look?: (data: Record<string, any>, cell: [number, number]) => any;
|
|
56
|
+
colors?: Record<string, number | string>;
|
|
57
|
+
lift?: number;
|
|
58
|
+
} | ((engine: any, layer: Layer) => {
|
|
59
|
+
update?: (cells: {
|
|
60
|
+
cell: [number, number];
|
|
61
|
+
data: Record<string, any>;
|
|
62
|
+
}[]) => void;
|
|
63
|
+
dispose?: () => void;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/grid/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers).
|
|
4
|
+
* @example engine.use(world(), grids())
|
|
5
|
+
* @returns {import('../../../core').ModuleDef<Grids>}
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export function grids(): import("../../../core").ModuleDef<Grids>;
|
|
9
|
+
/**
|
|
10
|
+
* engine.grids: every placement grid, the item rules, previews and the occupancy index
|
|
11
|
+
* @example
|
|
12
|
+
* const farm = engine.grids.add('farm', { cell: 1, origin: [0, 0], size: [16, 12] });
|
|
13
|
+
* engine.grids.define('bed', { size: [2, 1], kind: 'furniture', fields: { model: 'bed' } });
|
|
14
|
+
* engine.ops.run('grid.place', { grid: 'farm', item: 'bed', cell: [4, 4], rotation: 1 });
|
|
15
|
+
* @experimental
|
|
16
|
+
*/
|
|
17
|
+
export class Grids {
|
|
18
|
+
/**
|
|
19
|
+
* Create a grid. cell: edge length (m, default 1); origin: world [x, z] of the min corner of cell [0, 0]; size: [cells wide, cells deep] (omit = unbounded);
|
|
20
|
+
* zone: level name (tiles only show there); flat: max height difference under a footprint (m, default 0.5);
|
|
21
|
+
* layers: authored cells { soil: [[i, j, { tilled: true }], ...] } (content/grids.js): the baseline a save diffs against, so a save keeps only changed cells
|
|
22
|
+
* @example const room = engine.grids.add('room', { cell: 0.5, origin: [-3, -3], size: [12, 12], zone: 'house' })
|
|
23
|
+
* @param {string} name
|
|
24
|
+
* @param {{ cell?: number, origin?: any, size?: [number, number], zone?: string, flat?: number, layers?: Record<string, [number, number, Record<string, any>][]> }} [opts]
|
|
25
|
+
* @returns {Grid}
|
|
26
|
+
*/
|
|
27
|
+
add(name: string, opts?: {
|
|
28
|
+
cell?: number;
|
|
29
|
+
origin?: any;
|
|
30
|
+
size?: [number, number];
|
|
31
|
+
zone?: string;
|
|
32
|
+
flat?: number;
|
|
33
|
+
layers?: Record<string, [number, number, Record<string, any>][]>;
|
|
34
|
+
}): Grid;
|
|
35
|
+
/**
|
|
36
|
+
* A grid by name, or null when there is none
|
|
37
|
+
* @param {string} name
|
|
38
|
+
* @returns {Grid | null}
|
|
39
|
+
*/
|
|
40
|
+
get(name: string): Grid | null;
|
|
41
|
+
/** All grids (a new array) @returns {Grid[]} */
|
|
42
|
+
list(): Grid[];
|
|
43
|
+
/**
|
|
44
|
+
* Register what can be placed and its rules. size [w, d] in cells (default [1, 1]); kind of the world record (default the item name);
|
|
45
|
+
* ground: allowed engine.groundType values; layer: { layerName: field } that must be truthy on every cell (reason 'not' + Field, e.g. notTilled);
|
|
46
|
+
* flat: max height difference (overrides the grid's); fields: copied into the record; can(e, { grid, cell, rotation, cells }): your own rule
|
|
47
|
+
* @example engine.grids.define('crop', { size: [1, 1], layer: { soil: 'tilled' }, fields: { plantedAt: 0 } })
|
|
48
|
+
* @example engine.grids.define('shed', { size: [3, 2], ground: ['grass', 'dirt'], flat: 0.2 })
|
|
49
|
+
* @param {string} name
|
|
50
|
+
* @param {import('./Grid.js').GridRule} rule
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
define(name: string, rule: import("./Grid.js").GridRule): void;
|
|
54
|
+
/**
|
|
55
|
+
* Show where an item would go: the target cell under the pointer ('pointer', default), in front of the player ('front') or from your
|
|
56
|
+
* function, turned by the input action rotate (default name 'rotate'; the game binds it, or pass rotateKeys / ...presets.keys.gridRotate, the engine binds no key itself), light when can() passes, dark otherwise (neutral tool colors; style.grid.ok / bad override them).
|
|
57
|
+
* look: false = no visual; (engine) => ({ update(view), hide(), dispose() }) = your own. place() runs grid.place with what is shown
|
|
58
|
+
* @example engine.input.define('place', ['Mouse0']); // the game's own binding
|
|
59
|
+
* const pv = engine.grids.preview({ grid: 'farm', item: 'crop', ...presets.keys.gridRotate });
|
|
60
|
+
* engine.onFrame(() => { if (engine.input.pressed('place')) { const r = pv.place(); if (!r.ok) toast(engine, engine.t('grid.' + r.reason)); } });
|
|
61
|
+
* @param {{ grid: string, item: string, from?: 'pointer' | 'front' | ((e: any) => any), rotate?: string | false, rotateKeys?: string[], rotation?: number, look?: false | ((e: any) => any) }} opts
|
|
62
|
+
* @returns {{ cell: [number, number] | null, rotation: number, ok: boolean, reason: string | null, rotate(n?: number): void, place(fields?: object): { ok: boolean, value?: any, reason?: string }, remove(): void }}
|
|
63
|
+
*/
|
|
64
|
+
preview(opts: {
|
|
65
|
+
grid: string;
|
|
66
|
+
item: string;
|
|
67
|
+
from?: "pointer" | "front" | ((e: any) => any);
|
|
68
|
+
rotate?: string | false;
|
|
69
|
+
rotateKeys?: string[];
|
|
70
|
+
rotation?: number;
|
|
71
|
+
look?: false | ((e: any) => any);
|
|
72
|
+
}): {
|
|
73
|
+
cell: [number, number] | null;
|
|
74
|
+
rotation: number;
|
|
75
|
+
ok: boolean;
|
|
76
|
+
reason: string | null;
|
|
77
|
+
rotate(n?: number): void;
|
|
78
|
+
place(fields?: object): {
|
|
79
|
+
ok: boolean;
|
|
80
|
+
value?: any;
|
|
81
|
+
reason?: string;
|
|
82
|
+
};
|
|
83
|
+
remove(): void;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
import { Grid } from './Grid.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/hlod/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* HLOD (merge far buildings into a few meshes) -> engine.hlod
|
|
4
|
+
* @param {HlodOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Hlod>}
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export function hlod(opts?: HlodOptions): ModuleDef<Hlod>;
|
|
9
|
+
import type { HlodOptions } from '../../../world';
|
|
10
|
+
import type { Hlod } from '../../../world';
|
|
11
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/hud/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Objective markers, counters, progress bars -> engine.hud
|
|
4
|
+
* @param {HudOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<Hud>}
|
|
6
|
+
*/
|
|
7
|
+
export function hud(opts?: HudOptions): ModuleDef<Hud>;
|
|
8
|
+
import type { HudOptions } from '../../../gameplay';
|
|
9
|
+
import type { Hud } from '../../../gameplay';
|
|
10
|
+
import type { ModuleDef } from '../../../core';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Generated by npm run map, do not edit by hand. Source: packages/engine/modules/lights/index.js (edit the JSDoc in the source, then run npm run map)
|
|
2
|
+
/**
|
|
3
|
+
* Light pool (many light sources, a fixed number of real lights) -> engine.lightPool
|
|
4
|
+
* @param {LightPoolOptions} [opts]
|
|
5
|
+
* @returns {ModuleDef<LightPool>}
|
|
6
|
+
* @example
|
|
7
|
+
* engine.use(lightPool({ point: 8 })); // before engine.start(), so the startup compile covers these lights
|
|
8
|
+
* for (const t of torchMeshes) engine.lightPool.add(t, { color: 0xffa040, intensity: 4, distance: 8, flicker: (time, i) => 0.85 + 0.15 * Math.sin(time * 13 + i) });
|
|
9
|
+
*/
|
|
10
|
+
export function lightPool(opts?: LightPoolOptions): ModuleDef<LightPool>;
|
|
11
|
+
import type { LightPoolOptions } from '../../../world';
|
|
12
|
+
import type { LightPool } from '../../../world';
|
|
13
|
+
import type { ModuleDef } from '../../../core';
|