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,11 @@
|
|
|
1
|
+
// Ground pickups: press E nearby to pick up; they regrow after respawn seconds. Positions are relative to the cabin (home).
|
|
2
|
+
export default [
|
|
3
|
+
{ item: 'feather', place: 'home', x: 14.0, z: 0.0, respawn: 120 },
|
|
4
|
+
{ item: 'berry', place: 'home', x: 13.9, z: 14.3, respawn: 120 },
|
|
5
|
+
{ item: 'berry', place: 'home', x: -0.8, z: 26.0, respawn: 120 },
|
|
6
|
+
{ item: 'feather', place: 'home', x: -23.6, z: 21.6, respawn: 120 },
|
|
7
|
+
{ item: 'berry', place: 'home', x: -37.9, z: -2.2, respawn: 120 },
|
|
8
|
+
{ item: 'berry', place: 'home', x: -28.8, z: -33.3, respawn: 120 },
|
|
9
|
+
{ item: 'feather', place: 'home', x: 4.4, z: -49.8, respawn: 120 },
|
|
10
|
+
{ item: 'berry', place: 'home', x: 43.4, z: -35.4, respawn: 120 },
|
|
11
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Place names: main.js computes the coordinates at startup (terrain is procedural, so they cannot be hard-coded). Other content files place things relative to these with { place: 'name', x, z }.
|
|
2
|
+
export default {
|
|
3
|
+
home: 'cabin (a flat spot found on the terrain at startup; the cabin stands here)',
|
|
4
|
+
river: 'nearest riverside to the cabin (found at startup; the old fisherman goes here in the morning)',
|
|
5
|
+
water: 'the water just past that riverside (found at startup; the barrel floats here)',
|
|
6
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Props: decorations around the cabin. model is an asset name (the lowpoly asset pack registered in main.js; use an array for parameters), position is relative to the cabin (home), rot is facing (radians).
|
|
2
|
+
// collide sets collision ('box', 'circle' cylinder; omit for none). Only registered, not built at once: built when the player gets near (data lives in engine.world; id rules in modules/content/props.js).
|
|
3
|
+
export default [
|
|
4
|
+
{ model: 'pine', place: 'home', x: -8, z: -6, scale: 1.2, collide: 'circle' },
|
|
5
|
+
{ model: 'pine', place: 'home', x: -10, z: -1, collide: 'circle' },
|
|
6
|
+
{ model: 'roundTree', place: 'home', x: 8, z: -7, collide: 'circle' },
|
|
7
|
+
{ model: 'rock', place: 'home', x: 5, z: 5, rot: 0.6, scale: 0.8, collide: 'box' },
|
|
8
|
+
{ model: 'rock', place: 'home', x: -5, z: 6, rot: 2.1, scale: 0.6 },
|
|
9
|
+
{ model: ['flower', 0xf2d16b], place: 'home', x: 1.6, z: 3.4 },
|
|
10
|
+
{ model: ['flower', 0xe08aa0], place: 'home', x: -1.6, z: 3.4 },
|
|
11
|
+
{ id: 'cabin', template: 'cabin', place: 'home', x: 0, z: 0, y: -0.05 }, // a template instance (templates.js); new entries go at the end so index ids above stay stable
|
|
12
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Quests: steps complete in order, done is the completion condition; startOn is the event that starts the quest automatically; reward is the completion reward.
|
|
2
|
+
// target is the step's goal (place name, { place, x, z } or { npc: 'id' }); the screen shows a marker and distance.
|
|
3
|
+
export default {
|
|
4
|
+
'first-light': {
|
|
5
|
+
title: '第一缕光',
|
|
6
|
+
desc: '老渔夫说傍晚的光最好看。',
|
|
7
|
+
startOn: 'engine:ready',
|
|
8
|
+
steps: [
|
|
9
|
+
{ text: '和老渔夫聊聊(靠近按 E)', done: { flag: 'metFisher' }, target: { npc: 'fisher' } },
|
|
10
|
+
{ text: '收集 3 个野莓', done: { has: { berry: 3 } } },
|
|
11
|
+
{ text: '在 17:00–19:00 之间拍一张照片(按 P)', done: { counter: { sunsetPhotos: 1 } } }, // main.js bumps this counter when a photo is taken
|
|
12
|
+
],
|
|
13
|
+
reward: { give: { film: 12 } },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Condition/effect words and data kinds this game adds (built-in words are in packages/engine/modules/content/rules.js). Registered automatically on content.load; the validator and game map read this too.
|
|
2
|
+
// ref is how the value is written: 'clock' means 'HH:MM', and test receives the fraction of the day 0-1.
|
|
3
|
+
const SHAPES = ['crate', 'ball', 'barrel'];
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
conditions: {
|
|
7
|
+
timeAfter: { ref: 'clock', desc: 'the day has passed this clock time', describe: v => `after ${v}`, test: (e, t) => (e.sky?.timeOfDay ?? 0) >= t },
|
|
8
|
+
},
|
|
9
|
+
kinds: {
|
|
10
|
+
bodies: {
|
|
11
|
+
desc: 'physics props (id -> { shape: crate | ball | barrel, place, x, z, float? }): world records of kind body, given a rigid body in main.js',
|
|
12
|
+
// authored world data: initial records, so a save keeps only what play changed (a pushed crate's position)
|
|
13
|
+
load: (e, data, api) => {
|
|
14
|
+
for (const [id, b] of Object.entries(data)) {
|
|
15
|
+
const { x, z } = api.where(b), ground = e.surface(x, z);
|
|
16
|
+
const y = b.float ? Math.max(ground, e.waterLevel ?? ground) + 1.5 : ground + 0.45;
|
|
17
|
+
e.world.add({ id, kind: 'body', shape: b.shape, position: { x, y, z } }, { initial: true });
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
check: (data, { err }) => { for (const [id, b] of Object.entries(data)) if (!SHAPES.includes(b?.shape)) err(`body ${id}: shape must be one of ${SHAPES.join(', ')}`); },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Templates: one reusable object = model + collision (+ interaction, container, state). Each placement in props.js is a world record whose kind is the template name.
|
|
2
|
+
// Model 'cabin' is registered by name in main.js (engine.assets.manifest); other model names come from the style pack. Recipe: docs/recipes/30-templates.md.
|
|
3
|
+
export default {
|
|
4
|
+
cabin: { model: 'cabin', collide: 'box' }, // the riverside cabin; its lamp and chimney smoke follow the clock in main.js (presentation only)
|
|
5
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Vegetation: name -> model (an asset name from the lowpoly asset pack; use an array for parameters) and growth rule.
|
|
2
|
+
// rule.biomes lists the biomes it grows in, values are spawn probabilities; rule cannot hold functions (it is sent to a worker thread).
|
|
3
|
+
// Note: main.js tree chopping uses these names (松树, 圆树); after changing rules or density, trees chopped in old saves map to different trees.
|
|
4
|
+
export default {
|
|
5
|
+
松树: {
|
|
6
|
+
model: 'pine', lod: 'pineLow', wind: 0.022,
|
|
7
|
+
rule: { perChunk: 130, minHeight: 1.6, maxHeight: 40, maxSlope: 0.6, cluster: 'forest', scale: [0.75, 1.6], stretch: [0.85, 1.2], sink: 0.15,
|
|
8
|
+
biomes: { forest: 1, meadow: 0.35, snow: 0.6, wetland: 0.3, riverbank: 0.3 }, collider: 0.35,
|
|
9
|
+
tints: [{ color: [1.35, 1.05, 0.55], chance: 0.06 }] },
|
|
10
|
+
},
|
|
11
|
+
圆树: {
|
|
12
|
+
model: 'roundTree', lod: 'roundTreeLow', wind: 0.03,
|
|
13
|
+
rule: { perChunk: 50, minHeight: 1.6, maxHeight: 22, maxSlope: 0.45, scale: [0.8, 1.3], collider: 0.3,
|
|
14
|
+
biomes: { meadow: 0.8, savanna: 0.35, riverbank: 0.9, forest: 0.3 },
|
|
15
|
+
tints: [{ color: [1.4, 1.0, 0.5], chance: 0.15 }] },
|
|
16
|
+
},
|
|
17
|
+
石头: {
|
|
18
|
+
model: 'rock', maxRing: 3,
|
|
19
|
+
rule: { perChunk: 14, chance: 0.6, minHeight: 0.5, maxHeight: 70, maxSlope: 2, scale: [0.4, 1.6], stretch: [0.5, 0.8], sink: 0.2, tintJitter: 0.15, collider: 0.6 },
|
|
20
|
+
},
|
|
21
|
+
草: {
|
|
22
|
+
model: 'grass', nearOnly: true, maxRing: 1, wind: 0.3,
|
|
23
|
+
rule: { perChunk: 1800, chance: 0.75, minHeight: 1.4, maxHeight: 20, maxSlope: 0.42, scale: [0.7, 1.4], sink: 0.05, avoidFlat: false,
|
|
24
|
+
biomes: { meadow: 1, forest: 0.6, riverbank: 1, wetland: 1, savanna: 0.8 } },
|
|
25
|
+
},
|
|
26
|
+
野花: {
|
|
27
|
+
model: ['flower', 0xf2d16b], nearOnly: true, maxRing: 1, wind: 0.25,
|
|
28
|
+
rule: { perChunk: 260, minHeight: 1.5, maxHeight: 14, maxSlope: 0.35, scale: [0.8, 1.3], sink: 0,
|
|
29
|
+
biomes: { meadow: 1, riverbank: 0.6 },
|
|
30
|
+
tints: [{ color: [1.6, 0.6, 0.7], chance: 0.35 }, { color: [0.8, 0.9, 1.6], chance: 0.25 }] },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Open-world example (slow photography life): riverside cabin + an old fisherman who walks by the clock + pickups, quests, weather, photos, saves.
|
|
2
|
+
// This file only holds rules: installing engine modules, computing place coordinates, handing content/ to the engine, ops and presentation.
|
|
3
|
+
// The level is content: the cabin, props, physics props, items, NPCs, dialogues, quests and vegetation all live in content/ (rule R33).
|
|
4
|
+
import { createEngine, openWorld, presets, content, interactions, dialogue, inventory, quests, photo, timeline, triggers, entities, particles, music, hud, createTerrain, toast } from '../../index.js';
|
|
5
|
+
import lowpoly, { assets as lowpolyAssets } from '@threedog/style-lowpoly'; // optional package: a style pack (looks) and an asset pack (procedural models)
|
|
6
|
+
import { terrainPreset, riverAt, terrainStrings } from '@threedog/terrain-noise'; // optional package: the terrain generator (world shape, not a look)
|
|
7
|
+
import data from './content/index.js';
|
|
8
|
+
import { cabin, BODIES } from './models.js';
|
|
9
|
+
|
|
10
|
+
// ---------- 0. Pick a flat spot as home ----------
|
|
11
|
+
// Preview the terrain with the same seed, find a good spot, then tell the engine to flatten it
|
|
12
|
+
const SEED = 1337;
|
|
13
|
+
const preview = createTerrain({ seed: SEED, ...terrainPreset() });
|
|
14
|
+
let home = { x: 0, z: 0 };
|
|
15
|
+
for (let r = 0; r < 3000; r += 10) {
|
|
16
|
+
const a = r * 0.37, x = Math.cos(a) * r, z = Math.sin(a) * r, h = preview.surface(x, z);
|
|
17
|
+
if (h > 4 && h < 10 && preview.slope(x, z) < 0.2 && riverAt(x, z, preview.noise) === 0) { home = { x, z }; break; }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// core + style pack + open-world preset (world and environment: terrain, vegetation, sky, weather, water, collision, physics, camera, characters, ambience, settings, debug) + the gameplay modules this game needs
|
|
21
|
+
const engine = createEngine({ canvas: document.getElementById('view'), style: lowpoly, strings: terrainStrings, ui: { loading: { title: '慢慢走' } } });
|
|
22
|
+
// opt-in presets: four seasons and temperate weather (the engine assumes neither)
|
|
23
|
+
engine.use(openWorld({ camera: 'follow', seed: SEED, terrain: terrainPreset(), flatten: [{ x: home.x, z: home.z, radius: 22 }], time: 0.3, autoWeather: true, sky: presets.calendar.fourSeasons, weather: presets.weather.temperate }),
|
|
24
|
+
interactions({ ...presets.interactions.nearest }), dialogue(), inventory({ ...presets.keys.inventory }), quests({ ...presets.keys.quests }), photo({ ...presets.keys.photo }), timeline(), triggers(), entities(), particles(), music({ duckDialogue: 0.35 }), hud(), // gameplay modules: not in the preset, this game uses them all
|
|
25
|
+
content());
|
|
26
|
+
|
|
27
|
+
// ---------- 1. Places: nearest riverside to the cabin (fisherman goes there in the morning, barrel floats there) ----------
|
|
28
|
+
let river = { x: home.x + 30, z: home.z }, waterSpot = { x: home.x + 34, z: home.z };
|
|
29
|
+
search: for (let r = 10; r < 400; r += 4) {
|
|
30
|
+
for (let a = 0; a < 6.28; a += 0.3) {
|
|
31
|
+
const x = home.x + Math.cos(a) * r, z = home.z + Math.sin(a) * r;
|
|
32
|
+
if (engine.surface(x, z) < engine.waterLevel - 1.2) { river = { x: home.x + Math.cos(a) * (r - 8), z: home.z + Math.sin(a) * (r - 8) }; waterSpot = { x, z }; break search; }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ---------- 2. Cabin: placed by content/props.js (template 'cabin'); its model is built in code and registered by name ----------
|
|
37
|
+
engine.assets.manifest(lowpolyAssets); // asset pack: the trees, rocks and flowers content names (pine, rock, ['flower', color])
|
|
38
|
+
engine.assets.manifest({ name: 'world', models: { cabin } });
|
|
39
|
+
// Presentation that follows the clock: chimney smoke while the cabin's model is built, doorway lamp on 18:00-06:00
|
|
40
|
+
// (sky.between re-aligns after start, load, applying a scenario, or rewinding time)
|
|
41
|
+
let lampOn = false, smoke = null, smokeOn = null;
|
|
42
|
+
engine.sky.between('18:00', '06:00', { on: () => { lampOn = true; }, off: () => { lampOn = false; } });
|
|
43
|
+
engine.onFrame(() => {
|
|
44
|
+
const view = engine.world.view('cabin');
|
|
45
|
+
if (smokeOn !== view) { smoke?.remove(); smoke = view && engine.particles.attach('smoke', view.getObjectByName('chimney')); smokeOn = view; }
|
|
46
|
+
const lamp = /** @type {import('three').Mesh<any, import('three').MeshLambertMaterial> | undefined} */ (view?.getObjectByName('lamp'));
|
|
47
|
+
if (lamp) lamp.material.emissiveIntensity = lampOn ? 1.6 : 0;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// ---------- 3. Player + content (vegetation, items, pickups, NPCs, dialogues, quests, key actions, templates, props, physics props, custom conditions) ----------
|
|
51
|
+
engine.characters.createPlayer({ ...presets.player.thirdPerson, spawn: { x: home.x + 4, z: home.z + 7 } });
|
|
52
|
+
engine.content.load(data, { places: { home, river, water: waterSpot } }); // content names models only; the asset packs above resolve them
|
|
53
|
+
|
|
54
|
+
// Show the film count at the top left (hud counter)
|
|
55
|
+
const showFilm = () => engine.hud.counter('film', { icon: '🎞', label: '胶卷', value: engine.inventory.count('film') });
|
|
56
|
+
for (const ev of ['item:add', 'item:remove', 'save:loaded']) engine.events.on(ev, showFilm);
|
|
57
|
+
showFilm();
|
|
58
|
+
|
|
59
|
+
// Barter: the fisher's basket (content/containers.js) sells goods for film. An op, so the dialogue choice, the dev bridge and scenario tests share one rule
|
|
60
|
+
const PRICE = { berry: 1, feather: 2 }; // film per item
|
|
61
|
+
engine.ops.define('barter.buy', {
|
|
62
|
+
desc: 'Buy from a basket, paying in film', args: { shop: 'string', item: 'string' },
|
|
63
|
+
can(e, { shop, item }, ctx) {
|
|
64
|
+
if (!e.inventory.container(shop).has(item)) return 'soldOut';
|
|
65
|
+
return e.inventory.container(ctx.actor).has('film', PRICE[item] ?? 1) ? true : 'noFilm';
|
|
66
|
+
},
|
|
67
|
+
run(e, { shop, item }, ctx) {
|
|
68
|
+
const got = e.inventory.transfer(shop, ctx.actor, item, 1);
|
|
69
|
+
e.inventory.transfer(ctx.actor, shop, 'film', (PRICE[item] ?? 1) * got);
|
|
70
|
+
return got;
|
|
71
|
+
},
|
|
72
|
+
offers: () => Object.keys(PRICE).map(item => ({ shop: 'fisher-basket', item })),
|
|
73
|
+
reasons: { soldOut: 'The basket has none left', noFilm: 'Not enough film' },
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ---------- 4. Photos: use film; evening shots count toward quest progress; album strip ----------
|
|
77
|
+
engine.photo.canTake = () => engine.inventory.has('film') || 'noFilm'; // the op photo.take's can: no film, no photo (the P key runs the op)
|
|
78
|
+
engine.events.on('photo:denied', () => toast(engine, '没有胶卷了'));
|
|
79
|
+
engine.events.on('photo:taken', () => {
|
|
80
|
+
engine.inventory.remove('film');
|
|
81
|
+
const t = engine.sky.timeOfDay;
|
|
82
|
+
if (t > 17 / 24 && t < 19 / 24) engine.vars.bump('sunsetPhotos');
|
|
83
|
+
});
|
|
84
|
+
const strip = document.getElementById('strip');
|
|
85
|
+
engine.events.on('photo:taken', shot => {
|
|
86
|
+
const img = new Image(); img.src = shot.url; img.alt = `${shot.time} 拍摄`; img.title = shot.time;
|
|
87
|
+
img.onclick = () => { /** @type {HTMLImageElement} */ (document.getElementById('viewerImg')).src = shot.url; document.getElementById('viewer').hidden = false; };
|
|
88
|
+
strip.prepend(img);
|
|
89
|
+
while (strip.children.length > 8) strip.lastChild.remove();
|
|
90
|
+
const fl = document.getElementById('flash'); fl.style.transition = 'none'; fl.style.opacity = '0.8';
|
|
91
|
+
requestAnimationFrame(() => { fl.style.transition = ''; fl.style.opacity = '0'; });
|
|
92
|
+
});
|
|
93
|
+
document.getElementById('shoot').onclick = () => { if (!engine.ops.run('photo.take').ok) toast(engine, '没有胶卷了'); };
|
|
94
|
+
document.getElementById('viewerClose').onclick = () => { document.getElementById('viewer').hidden = true; };
|
|
95
|
+
|
|
96
|
+
// ---------- 5. Save / load (keys in content/actions.js) ----------
|
|
97
|
+
engine.onFrame(() => {
|
|
98
|
+
if (engine.input.pressed('save')) { engine.saves.save('slot1').then(ok => { if (ok) toast(engine, '已存档'); }); } // on false the engine already said why
|
|
99
|
+
if (engine.input.pressed('load')) engine.saves.load('slot1').then(ok => toast(engine, ok ? '已读档' : '还没有存档'));
|
|
100
|
+
});
|
|
101
|
+
engine.saves.autosave(3);
|
|
102
|
+
|
|
103
|
+
// ---------- 6. Real physics: crates, a ball and a barrel floating by the river (placed in content/bodies.js); press F to push/kick ----------
|
|
104
|
+
// The records come from content; this presenter gives each one a mesh and a rigid body while it is near. positionFrom 'view': the body moves
|
|
105
|
+
// the mesh and the record follows, so a pushed crate's position is saved. Physics is ready at engine:ready, so the presenter is registered then.
|
|
106
|
+
engine.events.on('engine:ready', () => {
|
|
107
|
+
if (!engine.rigid?.ready) return;
|
|
108
|
+
engine.world.present('body', {
|
|
109
|
+
positionFrom: 'view',
|
|
110
|
+
build(rec) {
|
|
111
|
+
const [mesh, add, opts] = BODIES[rec.shape]();
|
|
112
|
+
mesh.position.copy(rec.position);
|
|
113
|
+
mesh.castShadow = mesh.receiveShadow = true; // rigid bodies do not change the model's shadow settings
|
|
114
|
+
mesh.userData.body = engine.rigid[add](mesh, opts);
|
|
115
|
+
return mesh;
|
|
116
|
+
},
|
|
117
|
+
dispose(rec, mesh) { if (engine.rigid.world) mesh.userData.body?.remove(); engine.remove(mesh); }, // after engine.dispose the physics world is already gone
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
engine.onFrame(() => {
|
|
121
|
+
if (!engine.rigid?.ready || !engine.input.pressed('kick')) return;
|
|
122
|
+
const p = engine.player.position, f = engine.player.facing;
|
|
123
|
+
const dir = { x: Math.sin(f), z: Math.cos(f) };
|
|
124
|
+
let best = null, bestD = 2.6;
|
|
125
|
+
for (const b of engine.rigid.bodies) {
|
|
126
|
+
const t = b.body.translation(), d = Math.hypot(t.x - p.x, t.z - p.z);
|
|
127
|
+
if (d < bestD && (t.x - p.x) * dir.x + (t.z - p.z) * dir.z > 0) { best = b; bestD = d; }
|
|
128
|
+
}
|
|
129
|
+
if (best) { const m = best.body.mass(); engine.rigid.impulse(best, [dir.x * 6 * m, 2.5 * m, dir.z * 6 * m]); }
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// ---------- 7. Chop trees (world-change record: chopped trees are saved and regrow after 2 minutes) ----------
|
|
133
|
+
// An op, so the key, the dev bridge and tests share it and the wood lands in a fixed step, not a frame callback
|
|
134
|
+
const nearTree = (e, ctx) => {
|
|
135
|
+
const p = e.world?.get(ctx.actor)?.position ?? e.player.position;
|
|
136
|
+
return e.vegetation.instanceAt(p, { radius: 2.5, species: '松树' }) || e.vegetation.instanceAt(p, { radius: 2.5, species: '圆树' });
|
|
137
|
+
};
|
|
138
|
+
engine.ops.define('tree.chop', {
|
|
139
|
+
desc: 'Chop the nearest tree for wood',
|
|
140
|
+
can: (e, a, ctx) => nearTree(e, ctx) ? true : 'noTree',
|
|
141
|
+
run(e, a, ctx) {
|
|
142
|
+
const tree = nearTree(e, ctx);
|
|
143
|
+
e.vegetation.removeInstance(tree.species, tree.cx, tree.cz, tree.id, { regrowSeconds: 120 });
|
|
144
|
+
e.particles.emit('leaves', { x: tree.position.x, y: tree.position.y + 3, z: tree.position.z }, { count: 30 });
|
|
145
|
+
e.inventory.add('wood', 2);
|
|
146
|
+
},
|
|
147
|
+
reasons: { noTree: 'No tree within 2.5 m' },
|
|
148
|
+
});
|
|
149
|
+
engine.onFixed(() => {
|
|
150
|
+
if (engine.input.pressed('chop') && !engine.ops.run('tree.chop', {}, { source: 'player' }).ok) toast(engine, '附近没有树');
|
|
151
|
+
});
|
|
152
|
+
// Landing dust
|
|
153
|
+
engine.events.on('character:land', ({ character, impact }) => {
|
|
154
|
+
if (impact > 4) engine.particles.emit('dust', character.position, { count: Math.min(40, Math.round(impact * 4)) });
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// ---------- 8. Intro camera (circles the cabin, Esc skips) ----------
|
|
158
|
+
engine.events.on('engine:ready', () => {
|
|
159
|
+
const h = engine.surface(home.x, home.z);
|
|
160
|
+
engine.timeline.play([
|
|
161
|
+
{ camera: { to: { position: [home.x + 30, h + 18, home.z + 30], lookAt: [home.x, h + 2, home.z] }, duration: 0.01 } },
|
|
162
|
+
{ camera: { to: { position: [home.x - 20, h + 10, home.z + 25], lookAt: [home.x, h + 2, home.z] }, duration: 5, ease: 'inOutSine' } },
|
|
163
|
+
{ camera: { release: true } },
|
|
164
|
+
], { letterbox: true });
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
engine.start();
|
|
168
|
+
window.engine = engine; // handy for debugging in the browser console
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Models this game builds in code: the cabin (registered by name in main.js, placed by content/props.js) and the physics prop meshes (content/bodies.js).
|
|
2
|
+
import { THREE, mergeColored, makeMaterial } from '../../index.js';
|
|
3
|
+
|
|
4
|
+
/** Low-poly cabin: one merged mesh, plus a 'lamp' mesh and a 'chimney' point that main.js animates by name */
|
|
5
|
+
export function cabin() {
|
|
6
|
+
const g = mergeColored([
|
|
7
|
+
[new THREE.BoxGeometry(6, 3, 5).translate(0, 1.5, 0), 0xe8dcc4],
|
|
8
|
+
[new THREE.ConeGeometry(4.8, 2.6, 4).rotateY(Math.PI / 4).scale(1.05, 1, 0.9).translate(0, 4.3, 0), 0xa4553c],
|
|
9
|
+
[new THREE.BoxGeometry(1.1, 2, 0.12).translate(0, 1, 2.52), 0x6b4a32],
|
|
10
|
+
[new THREE.BoxGeometry(1, 0.9, 0.1).translate(-1.8, 1.7, 2.52), 0x9cc6d6],
|
|
11
|
+
[new THREE.BoxGeometry(0.6, 1.6, 0.6).translate(1.8, 5, -0.8), 0x7d736a],
|
|
12
|
+
]);
|
|
13
|
+
const house = new THREE.Mesh(g, makeMaterial('building', { vertexColors: true }));
|
|
14
|
+
house.castShadow = true; house.receiveShadow = true;
|
|
15
|
+
const lamp = new THREE.Mesh(new THREE.BoxGeometry(0.3, 0.4, 0.3), makeMaterial('lamp', { color: 0x6b5a40, emissive: 0xffc070, emissiveIntensity: 0 }));
|
|
16
|
+
lamp.name = 'lamp'; lamp.position.set(0.9, 2.3, 2.7);
|
|
17
|
+
const chimney = new THREE.Object3D(); chimney.name = 'chimney'; chimney.position.set(1.8, 6, -0.8);
|
|
18
|
+
const root = new THREE.Group(); root.add(house, lamp, chimney);
|
|
19
|
+
return root;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const crateGeo = mergeColored([[new THREE.BoxGeometry(0.8, 0.8, 0.8), 0xb08850]]);
|
|
23
|
+
/** Mesh and rigid-body options of a physics prop shape (crate, ball, barrel) */
|
|
24
|
+
export const BODIES = {
|
|
25
|
+
crate: () => [new THREE.Mesh(crateGeo, makeMaterial('prop', { vertexColors: true })), 'addBox', { mass: 4 }],
|
|
26
|
+
ball: () => [new THREE.Mesh(new THREE.IcosahedronGeometry(0.35, 1), makeMaterial('prop', { color: 0xe8c25a, flatShading: true })), 'addBall', { radius: 0.35, mass: 1, restitution: 0.55, angularDamping: 0.3 }],
|
|
27
|
+
barrel: () => [new THREE.Mesh(new THREE.CylinderGeometry(0.4, 0.4, 0.9, 8), makeMaterial('prop', { color: 0x8a5a36, flatShading: true })), 'addHull', { mass: 3 }],
|
|
28
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// Type declarations for the engine API (hand-written).
|
|
2
|
+
//
|
|
3
|
+
// Why: when game code does import ... from 'threedog', TypeScript reads this file instead of index.js,
|
|
4
|
+
// so `npm run types` reports a wrong parameter name, a misspelled module name or a call to a missing method on the spot.
|
|
5
|
+
// No runtime effect (browsers and Vite use only .js).
|
|
6
|
+
//
|
|
7
|
+
// File layout:
|
|
8
|
+
// packages/engine/types/common.d.ts shared small types (position, color, easing names)
|
|
9
|
+
// packages/engine/types/core.d.ts Engine class, event map EventMap, input, i18n, saves, assets, audio, module definition
|
|
10
|
+
// packages/engine/types/style.d.ts style pack Style
|
|
11
|
+
// packages/engine/types/world.d.ts terrain, vegetation, sky, weather, water
|
|
12
|
+
// packages/engine/types/physics.d.ts collision, Rapier physics, the four cameras
|
|
13
|
+
// packages/engine/types/gameplay.d.ts timeline, level, trigger zones, entities, particles, settings, music, character/NPC, interactions, dialogue, inventory, quests, photo mode,
|
|
14
|
+
// clock, story variables, content, flow, objective markers...
|
|
15
|
+
// packages/engine/types/nav.d.ts navmesh
|
|
16
|
+
// packages/engine/types/generated/ generated from the JSDoc in the JS sources (npm run map, do not edit by hand): ui/UI.js Focus.js Parts.js, render/materials.js PostFX.js, modules/ water sky weather particles ambience music timeline debug hlod hud flow; re-exported below with export { ... } from
|
|
17
|
+
// three.js types come from @types/three (a dependency of this package, version-locked to three), so THREE.* is fully checked.
|
|
18
|
+
//
|
|
19
|
+
// When the engine's public API changes (new export, changed parameter), update this file too; `npm run types` checks that every export of index.js is declared.
|
|
20
|
+
|
|
21
|
+
import type { Engine, EngineOptions, ModuleDef, ModuleInput } from './types/core';
|
|
22
|
+
import type { Ease, EaseName, BufferGeometry, ColorLike, Material, Vector3, PositionLike } from './types/common';
|
|
23
|
+
import type {
|
|
24
|
+
TerrainOptions, TerrainConfig, TerrainGen, Terrain, Vegetation, VegetationModuleOptions, Sky, SkyOptions, Weather, WeatherOptions, WeatherPreset,
|
|
25
|
+
WeatherName, Water, WaterOptions, FlattenZone, Hlod, HlodOptions,
|
|
26
|
+
} from './types/world';
|
|
27
|
+
import type { Nav, NavOptions } from './types/nav';
|
|
28
|
+
import type {
|
|
29
|
+
CollisionOptions, Collision, RigidOptions, RigidBodies, CameraRig, FollowCameraOptions, FirstPersonCameraOptions,
|
|
30
|
+
FixedCameraOptions, RtsCameraOptions,
|
|
31
|
+
} from './types/physics';
|
|
32
|
+
import type {
|
|
33
|
+
CharactersApi, CharactersOptions, Interactions, InteractionsOptions, Dialogue, DialogueOptions, Inventory, InventoryOptions,
|
|
34
|
+
Quests, QuestsOptions, Photo, PhotoOptions, Ambience, AmbienceOptions, DebugPanel, Level, LevelOptions, Triggers, TriggersOptions,
|
|
35
|
+
Entities, Particles, Settings, SettingsOptions, SettingsTools, Music, MusicOptions,
|
|
36
|
+
Timeline, TimelineOptions, Character, NPC, UIWindow, WindowOptions,
|
|
37
|
+
Content, Flow, FlowOptions, Hud, HudOptions, ScreenPoint, UIFocus, FocusHandle,
|
|
38
|
+
} from './types/gameplay';
|
|
39
|
+
import type { Style, StyleUI } from './types/style';
|
|
40
|
+
import type { PostEffect } from './types/generated/render/PostFX';
|
|
41
|
+
// Local bindings for the generated module factories (export { x } from re-exports below do not create them), used by OpenWorldOptions
|
|
42
|
+
import type { sky } from './types/generated/modules/sky/skyModule';
|
|
43
|
+
import type { weather } from './types/generated/modules/weather/Weather';
|
|
44
|
+
import type { water } from './types/generated/modules/water/Water';
|
|
45
|
+
import type { world } from './types/generated/modules/world/index';
|
|
46
|
+
import type { ambience } from './types/generated/modules/ambience/Ambience';
|
|
47
|
+
import type { debug } from './types/generated/modules/debug/DebugPanel';
|
|
48
|
+
|
|
49
|
+
// Types are exported too, so game code can write JSDoc: /** @type {import('threedog').DialogueScript} */
|
|
50
|
+
export * from './types/common';
|
|
51
|
+
export * from './types/core';
|
|
52
|
+
export * from './types/style';
|
|
53
|
+
export * from './types/world';
|
|
54
|
+
export * from './types/physics';
|
|
55
|
+
export * from './types/gameplay';
|
|
56
|
+
export * from './types/nav';
|
|
57
|
+
|
|
58
|
+
// ======================================================================
|
|
59
|
+
// Core
|
|
60
|
+
// ======================================================================
|
|
61
|
+
|
|
62
|
+
/** three.js itself (the same instance the engine uses; typed by @types/three) */
|
|
63
|
+
export * as THREE from 'three';
|
|
64
|
+
|
|
65
|
+
/** Create an engine (core only). canvas is required; style is the style pack */
|
|
66
|
+
export function createEngine(opts: EngineOptions): Engine;
|
|
67
|
+
/**
|
|
68
|
+
* A style part that adds post effects to the ones before it (a plain { post: [...] } would replace the whole list); an effect with the same name
|
|
69
|
+
* replaces that one in place. Style parts with it: createEngine({ style: [lowpoly, postAdd(myGrain, bloom({ strength: 0.6 }))] })
|
|
70
|
+
*/
|
|
71
|
+
export function postAdd(...effects: PostEffect[]): Style;
|
|
72
|
+
/** A style part that removes post effects by name from the ones before it: createEngine({ style: [lowpoly, postRemove('ao', 'outline')] }) */
|
|
73
|
+
export function postRemove(...names: string[]): Style;
|
|
74
|
+
|
|
75
|
+
/** One openWorld part: false leaves the module out, true / omitted uses defaults, an object is that module's own options */
|
|
76
|
+
type Part<F extends (...a: any) => any> = boolean | NonNullable<Parameters<F>[0]>;
|
|
77
|
+
/**
|
|
78
|
+
* openWorld() options: shorthands (seed... go to terrain, time / dayLength to sky, weather / autoWeather to weather) and one entry per part.
|
|
79
|
+
* Gameplay modules (dialogue, inventory, quests, photo mode...) are not in the preset; engine.use them yourself
|
|
80
|
+
*/
|
|
81
|
+
export interface OpenWorldOptions {
|
|
82
|
+
/** Terrain random seed */
|
|
83
|
+
seed?: number;
|
|
84
|
+
/** View distance (in chunks) */
|
|
85
|
+
viewChunks?: number;
|
|
86
|
+
/** Vegetation density multiplier */
|
|
87
|
+
density?: number;
|
|
88
|
+
/** Flatten a plot (for a house) */
|
|
89
|
+
flatten?: FlattenZone[];
|
|
90
|
+
/** Start time 0-1 */
|
|
91
|
+
time?: number;
|
|
92
|
+
/** Game seconds per day (default 360) */
|
|
93
|
+
dayLength?: number;
|
|
94
|
+
/** Starting weather name, false (no weather module) or weather() options */
|
|
95
|
+
weather?: WeatherName | (string & {}) | Part<typeof weather>;
|
|
96
|
+
/** Automatic weather changes */
|
|
97
|
+
autoWeather?: boolean;
|
|
98
|
+
/** Required, no default: 'follow' / 'firstPerson' / 'rts' / 'fixed', a camera module with options (e.g. followCamera(presets.camera.overShoulder)), or false */
|
|
99
|
+
camera: 'follow' | 'firstPerson' | 'rts' | 'fixed' | ModuleDef | false;
|
|
100
|
+
world?: Part<typeof world>;
|
|
101
|
+
terrain?: Part<typeof terrain>;
|
|
102
|
+
vegetation?: Part<typeof vegetation>;
|
|
103
|
+
sky?: Part<typeof sky>;
|
|
104
|
+
water?: Part<typeof water>;
|
|
105
|
+
collision?: Part<typeof collision>;
|
|
106
|
+
rigid?: Part<typeof rigid>;
|
|
107
|
+
characters?: Part<typeof characters>;
|
|
108
|
+
ambience?: Part<typeof ambience>;
|
|
109
|
+
settings?: Part<typeof settings>;
|
|
110
|
+
/** Default: installed in dev builds only; true also in release builds */
|
|
111
|
+
debug?: Part<typeof debug>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Open-world preset: world, terrain, vegetation, sky, weather, water, collision, physics, camera, characters, ambience, settings, debug (dev only).
|
|
115
|
+
* 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
|
|
116
|
+
*/
|
|
117
|
+
export function openWorld(opts: OpenWorldOptions): ModuleDef[];
|
|
118
|
+
|
|
119
|
+
// ======================================================================
|
|
120
|
+
// Modules (each function returns a module for engine.use())
|
|
121
|
+
// ======================================================================
|
|
122
|
+
|
|
123
|
+
/** Procedural terrain -> engine.terrain */
|
|
124
|
+
export function terrain(opts?: TerrainOptions): ModuleDef<Terrain>;
|
|
125
|
+
/** Vegetation -> engine.vegetation: on terrain chunks when terrain() is installed first (no options), else on its own chunks over any ground (a level, setGround) */
|
|
126
|
+
export function vegetation(opts?: VegetationModuleOptions): ModuleDef<Vegetation>;
|
|
127
|
+
// Migrated: sky() is generated from the JSDoc in modules/sky/skyModule.js
|
|
128
|
+
export { sky } from './types/generated/modules/sky/skyModule';
|
|
129
|
+
// Migrated: weather() is generated from the JSDoc in modules/weather/Weather.js
|
|
130
|
+
export { weather } from './types/generated/modules/weather/Weather';
|
|
131
|
+
/**
|
|
132
|
+
* Opt-in gameplay presets: named option objects a game picks on purpose (the engine never applies one itself). Each only bundles options
|
|
133
|
+
* the game could write; spread and override: weather({ ...presets.weather.temperate, autoPool: ['clear', 'rain'] })
|
|
134
|
+
*/
|
|
135
|
+
export const presets: {
|
|
136
|
+
readonly weather: { readonly temperate: WeatherOptions & Required<Pick<WeatherOptions, 'types' | 'autoPool'>> };
|
|
137
|
+
readonly calendar: { readonly fourSeasons: SkyOptions; readonly cycle: SkyOptions; readonly fixedTime: SkyOptions };
|
|
138
|
+
readonly player: { readonly [K in 'none' | 'thirdPerson' | 'lockOn' | 'aim' | 'sideScroller']: Pick<import('./types/gameplay').PlayerOptions, 'control' | 'faceMode' | 'runKeys' | 'jumpKeys' | 'cameraFollow'> };
|
|
139
|
+
readonly interactions: { readonly [K in 'nearest' | 'facing' | 'aim']: import('./types/gameplay').InteractionsOptions };
|
|
140
|
+
readonly keys: {
|
|
141
|
+
readonly inventory: Pick<import('./types/gameplay').InventoryOptions, 'keys' | 'pad'>;
|
|
142
|
+
readonly quests: Pick<import('./types/gameplay').QuestsOptions, 'keys' | 'pad'>;
|
|
143
|
+
readonly photo: Pick<import('./types/gameplay').PhotoOptions, 'keys' | 'pad'>;
|
|
144
|
+
readonly brake: Pick<import('./types/gameplay').CharactersOptions, 'brakeKeys' | 'brakePad'>;
|
|
145
|
+
};
|
|
146
|
+
readonly camera: { readonly follow: import('./types/physics').FollowCameraOptions; readonly overShoulder: import('./types/physics').FollowCameraOptions };
|
|
147
|
+
};
|
|
148
|
+
// Migrated: water() is generated from the JSDoc in modules/water/Water.js
|
|
149
|
+
export { water } from './types/generated/modules/water/Water';
|
|
150
|
+
// Migrated: world() is generated from the JSDoc in modules/world/index.js
|
|
151
|
+
export { world } from './types/generated/modules/world/index';
|
|
152
|
+
export type { World, WorldRecord } from './types/generated/modules/world/World';
|
|
153
|
+
// Migrated: net() and its transports are generated from the JSDoc in modules/net/
|
|
154
|
+
export { net, fakeNetwork, webSocket } from './types/generated/modules/net/index';
|
|
155
|
+
export type { Net } from './types/generated/modules/net/Net';
|
|
156
|
+
// grids() is generated from the JSDoc in modules/grid/index.js
|
|
157
|
+
export { grids } from './types/generated/modules/grid/index';
|
|
158
|
+
export type { Grids } from './types/generated/modules/grid/index';
|
|
159
|
+
export type { Grid, GridRule } from './types/generated/modules/grid/Grid';
|
|
160
|
+
export type { Layer } from './types/generated/modules/grid/Layer';
|
|
161
|
+
/** Lightweight collision -> engine.collision */
|
|
162
|
+
export function collision(opts?: CollisionOptions): ModuleDef<Collision>;
|
|
163
|
+
/** Real physics (Rapier) -> engine.rigid (install collision first) */
|
|
164
|
+
export function rigid(opts?: RigidOptions): ModuleDef<RigidBodies>;
|
|
165
|
+
/** Third-person follow camera -> engine.cameraRig */
|
|
166
|
+
export function followCamera(opts?: FollowCameraOptions): ModuleDef<CameraRig>;
|
|
167
|
+
/** First-person camera -> engine.cameraRig */
|
|
168
|
+
export function firstPersonCamera(opts?: FirstPersonCameraOptions): ModuleDef<CameraRig>;
|
|
169
|
+
/** Fixed-shot camera -> engine.cameraRig */
|
|
170
|
+
export function fixedCamera(opts?: FixedCameraOptions): ModuleDef<CameraRig>;
|
|
171
|
+
/** Strategy top-down camera -> engine.cameraRig */
|
|
172
|
+
export function rtsCamera(opts?: RtsCameraOptions): ModuleDef<CameraRig>;
|
|
173
|
+
/** Characters: player engine.characters, NPCs engine.npcs */
|
|
174
|
+
export function characters(opts?: CharactersOptions): ModuleDef<CharactersApi>;
|
|
175
|
+
/** Interaction prompts -> engine.interactions */
|
|
176
|
+
export function interactions(opts: InteractionsOptions): ModuleDef<Interactions>;
|
|
177
|
+
/** Dialogue -> engine.dialogue */
|
|
178
|
+
export function dialogue(opts?: DialogueOptions): ModuleDef<Dialogue>;
|
|
179
|
+
/** Inventory -> engine.inventory */
|
|
180
|
+
export function inventory(opts?: InventoryOptions): ModuleDef<Inventory>;
|
|
181
|
+
/** Quests -> engine.quests */
|
|
182
|
+
export function quests(opts?: QuestsOptions): ModuleDef<Quests>;
|
|
183
|
+
/** Photo mode -> engine.photo */
|
|
184
|
+
export function photo(opts?: PhotoOptions): ModuleDef<Photo>;
|
|
185
|
+
// Migrated: ambience() is generated from the JSDoc in modules/ambience/Ambience.js
|
|
186
|
+
export { ambience } from './types/generated/modules/ambience/Ambience';
|
|
187
|
+
// Migrated: debug() is generated from the JSDoc in modules/debug/DebugPanel.js
|
|
188
|
+
export { debug } from './types/generated/modules/debug/DebugPanel';
|
|
189
|
+
/** Hand-built level -> engine.level */
|
|
190
|
+
export function level(opts?: LevelOptions): ModuleDef<Level>;
|
|
191
|
+
/** Trigger zones -> engine.triggers */
|
|
192
|
+
export function triggers(opts?: TriggersOptions): ModuleDef<Triggers>;
|
|
193
|
+
/** Entities -> engine.entities */
|
|
194
|
+
export function entities(): ModuleDef<Entities>;
|
|
195
|
+
// Migrated: particles() is generated from the JSDoc in modules/particles/Particles.js
|
|
196
|
+
export { particles } from './types/generated/modules/particles/Particles';
|
|
197
|
+
/** Settings menu -> engine.settings */
|
|
198
|
+
export function settings(opts?: SettingsOptions): ModuleDef<Settings>;
|
|
199
|
+
// Migrated: music() is generated from the JSDoc in modules/music/Music.js
|
|
200
|
+
export { music } from './types/generated/modules/music/Music';
|
|
201
|
+
// Migrated: timeline() is generated from the JSDoc in modules/timeline/Timeline.js
|
|
202
|
+
export { timeline } from './types/generated/modules/timeline/Timeline';
|
|
203
|
+
/** Navmesh (Recast, for levels) -> engine.nav; once installed, characters.findPath uses it automatically */
|
|
204
|
+
export function nav(opts?: NavOptions): ModuleDef<Nav>;
|
|
205
|
+
/** Content loading (the game's pure-data content/*.js) -> engine.content */
|
|
206
|
+
export function content(): ModuleDef<Content>;
|
|
207
|
+
// Migrated: hlod(), flow() and hud() are generated from the JSDoc in modules/hlod/index.js, flow/index.js, hud/index.js
|
|
208
|
+
export { hlod } from './types/generated/modules/hlod/index';
|
|
209
|
+
// Migrated: lightPool() is generated from the JSDoc in modules/lights/index.js
|
|
210
|
+
export { lightPool } from './types/generated/modules/lights/index';
|
|
211
|
+
export { flow } from './types/generated/modules/flow/index';
|
|
212
|
+
export { hud } from './types/generated/modules/hud/index';
|
|
213
|
+
|
|
214
|
+
// ======================================================================
|
|
215
|
+
// Utilities
|
|
216
|
+
// ======================================================================
|
|
217
|
+
|
|
218
|
+
/** Screen coordinates (-1..1) -> point on the ground; null if the ray misses the ground */
|
|
219
|
+
export function screenToGround(engine: Engine, ndcX: number, ndcY: number, opts?: { maxDistance?: number }): Vector3 | null;
|
|
220
|
+
/** All easing functions: name -> function */
|
|
221
|
+
export const EASINGS: Record<EaseName, (t: number) => number>;
|
|
222
|
+
/** Name or function -> easing function */
|
|
223
|
+
export function ease(e: Ease): (t: number) => number;
|
|
224
|
+
/**
|
|
225
|
+
* Warn (once, in development) about unknown keys in an options object, with a "did you mean" hint. For your own modules.
|
|
226
|
+
* where names the call ('stamina()'); known lists the keys your code reads; loose only warns on near-misses (data with game-specific fields).
|
|
227
|
+
* @example checkOptions('stamina()', opts, ['max', 'drain', 'regen']);
|
|
228
|
+
*/
|
|
229
|
+
export function checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean }): void;
|
|
230
|
+
/** One field of a params / op args schema: 'int?' or the full form (default implies optional) */
|
|
231
|
+
export type ParamSpec = string | { type: string, default?: any, min?: number, max?: number, values?: any[], desc?: string, optional?: boolean };
|
|
232
|
+
/**
|
|
233
|
+
* Module options read through a params schema: unknown keys and wrong types throw in dev with the fix, defaults are filled in.
|
|
234
|
+
* Also put params / options on the module definition so engine.catalog(name) shows them (recipes/51-capability-catalog.md).
|
|
235
|
+
* @example const o = readParams('magnet', { radius: { type: 'number', default: 2, min: 0 } }, opts);
|
|
236
|
+
*/
|
|
237
|
+
export function readParams<T extends object = any>(where: string, schema: Record<string, ParamSpec>, opts?: object): T;
|
|
238
|
+
/** One look part: engine.look.<id>. set changes parameters for an owner, patch swaps a named GLSL hook, replace takes the whole part over (recipes/52-look.md) */
|
|
239
|
+
export interface LookPart {
|
|
240
|
+
readonly id: string;
|
|
241
|
+
readonly object: any;
|
|
242
|
+
set(params: Record<string, any>, o?: { owner?: string }): { remove(): void };
|
|
243
|
+
patch(name: string, glsl: any, o?: { owner?: string }): { remove(): void };
|
|
244
|
+
replace(impl: any, o?: { owner?: string }): { remove(): void };
|
|
245
|
+
clear(owner: string): void;
|
|
246
|
+
value(key: string): any;
|
|
247
|
+
top(key: string): any;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Register a module's own look part: engine.look.<id> with set / patch / replace, engine.catalog('look.<id>') and describe().look (recipes/52-look.md).
|
|
251
|
+
* Every param needs a default; a default that changes the picture also needs why and off (or neutral: true).
|
|
252
|
+
*/
|
|
253
|
+
export function defineLookPart(engine: any, spec: { id: string, group?: string, module?: string, object?: () => any, params?: Record<string, any>,
|
|
254
|
+
style?: () => object, read?: () => object, apply?: (values: any, changed: Set<string>) => void, applyAtStart?: boolean,
|
|
255
|
+
hooks?: Record<string, { signature?: string, scope?: string[], example?: string }>, applyHook?: (name: string, glsl: any) => void, noPatch?: string,
|
|
256
|
+
replace?: { accepts: string, loses?: string[] }, applyReplace?: (impl: any) => void, noReplace?: string, docs?: string[] }): LookPart;
|
|
257
|
+
// The Character, NPC and Engine classes are exported by the export * above (tweens use engine.timeline.tween, pathfinding uses engine.characters.findPath)
|
|
258
|
+
|
|
259
|
+
/** Pure terrain computation (no engine needed), for previewing heights before start: createTerrain({ seed, ...terrainPreset() }).surface(x, z) */
|
|
260
|
+
export function createTerrain(cfg?: Partial<TerrainConfig>): TerrainGen;
|
|
261
|
+
|
|
262
|
+
// ---------- Materials ----------
|
|
263
|
+
// Migrated: declarations are generated from the JSDoc in packages/engine/render/materials.js (npm run map), not written by hand here
|
|
264
|
+
export { terrainMaterial, mergeColored, applyEffects, MATERIAL_PURPOSES, makeMaterial } from './types/generated/render/materials';
|
|
265
|
+
export { materialPatches } from './types/generated/render/patches';
|
|
266
|
+
|
|
267
|
+
// ---------- UI ----------
|
|
268
|
+
// Migrated: declarations are generated from the JSDoc in packages/engine/ui/UI.js and Focus.js (npm run map), not written by hand here
|
|
269
|
+
export { toast, makeWindow, worldToScreen, fadeScreen, uiFocus, toggleOnKey } from './types/generated/ui/UI';
|
|
270
|
+
// Type PostFX (class in render/PostFX.js): used by engine.post in Engine, and exported publicly
|
|
271
|
+
export type { PostFX, PostEffect } from './types/generated/render/PostFX';
|
|
272
|
+
export type { UIPart, UIPartFactory, UIPartValue, UIPartDef, UIParts, UITitleItem } from './types/core';
|
|
273
|
+
|
|
274
|
+
// ---------- Clock ----------
|
|
275
|
+
/** Clock time -> fraction of the day: parseClock('18:30') = 0.77; a number or numeric string ('0.25') is converted as is. hoursPerDay is hours per day, default 24 */
|
|
276
|
+
export function parseClock(clock: string | number, hoursPerDay?: number): number;
|
|
277
|
+
/** Fraction of the day -> 'HH:MM': formatClock(0.75) = '18:00' */
|
|
278
|
+
export function formatClock(t: number, hoursPerDay?: number): string;
|
|
279
|
+
/** Is time t (0-1, e.g. sky.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by sky.between and the audio rule condition { time: [from, to] } */
|
|
280
|
+
export function inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number): boolean;
|
|
281
|
+
|
|
282
|
+
// ---------- Target selection (core/targeting.js, pure functions) ----------
|
|
283
|
+
/**
|
|
284
|
+
* Options of pickTarget / switchTarget: radius meters (15); cone half-angle in radians (1.4); close meters inside which angle is ignored (2.5);
|
|
285
|
+
* angleWeight meters per radian off the view (6); blocked(c) true skips c (occlusion); at(c) reads a candidate's position (default c.position ?? c)
|
|
286
|
+
*/
|
|
287
|
+
export interface TargetOptions<T> { radius?: number; cone?: number; close?: number; angleWeight?: number; blocked?: (c: T) => boolean; at?: (c: T) => PositionLike }
|
|
288
|
+
/**
|
|
289
|
+
* Best target in front: lowest "distance + angle off view × angleWeight" inside radius and cone.
|
|
290
|
+
* view is a direction { x, z } (cameraRig.forward()) or a facing angle. Returns the candidate or null
|
|
291
|
+
*/
|
|
292
|
+
export function pickTarget<T>(from: PositionLike, view: { x: number; z: number } | number, candidates: Iterable<T>, opts?: TargetOptions<T>): T | null;
|
|
293
|
+
/** Next target to the right (side 1) or left (-1) of current as seen along view, wrapping; current missing → the leftmost. Returns a candidate or null */
|
|
294
|
+
export function switchTarget<T>(from: PositionLike, view: { x: number; z: number } | number, current: T | null, candidates: Iterable<T>, side: 1 | -1,
|
|
295
|
+
opts?: Pick<TargetOptions<T>, 'radius' | 'blocked' | 'at'>): T | null;
|
|
296
|
+
|
|
297
|
+
// ======================================================================
|
|
298
|
+
// Globals
|
|
299
|
+
// ======================================================================
|
|
300
|
+
declare global {
|
|
301
|
+
interface Window {
|
|
302
|
+
/** Convention in the examples: window.engine = engine, for debugging in the browser console */
|
|
303
|
+
engine?: any;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|