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,142 @@
|
|
|
1
|
+
// A named per-cell data layer on a grid (grid.layer('soil')): plain data per cell, only non-empty cells stored.
|
|
2
|
+
// Why a layer and not world records: a farm has hundreds of tilled / watered cells that are state, not things;
|
|
3
|
+
// one record per cell would cost a model slot, a sim entry and a save entry each. A layer is one Map.
|
|
4
|
+
// Save (part 'grids' version 2): only cells that differ from the authored baseline (content/grids.js layers, like world records diff against content):
|
|
5
|
+
// { set: [[i, j, data], ...] changed or new cells, clear: [[i, j], ...] authored cells the player emptied }. A layer with no baseline saves every cell in set.
|
|
6
|
+
// Version 1 saved every cell whole; its step turns that into { set, whole: true } (cells not listed are empty, whatever content authors now).
|
|
7
|
+
// Writes are saved gameplay state, so they pass the ops guard like world.set (write inside an op or a fixed step).
|
|
8
|
+
// _ver counts changes so views (tiles) rebuild only when something changed, without events.
|
|
9
|
+
import { DEV } from '../../core/validate.js';
|
|
10
|
+
|
|
11
|
+
const key = (i, j) => i + ',' + j;
|
|
12
|
+
const plainErr = (where, v) => `${where}: layer data must be plain values (numbers, strings, booleans, arrays, plain objects); got ${v?.constructor?.name ?? typeof v}. Keep models in tiles / world.present`;
|
|
13
|
+
function checkPlain(where, v) {
|
|
14
|
+
if (v == null || typeof v !== 'object') { if (typeof v === 'function' || typeof v === 'symbol') throw new Error(plainErr(where, v)); return; }
|
|
15
|
+
const proto = Object.getPrototypeOf(v);
|
|
16
|
+
if (!Array.isArray(v) && proto !== Object.prototype && proto !== null) throw new Error(plainErr(where, v));
|
|
17
|
+
for (const x of Object.values(v)) checkPlain(where, x);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Per-cell plain data on a grid. Create with grid.layer(name). Change it inside an op (it is saved gameplay state).
|
|
22
|
+
* @example
|
|
23
|
+
* engine.ops.define('farm.till', { args: { cell: 'any' },
|
|
24
|
+
* can: (e, { cell }) => farm.inside(cell) && !farm.at(cell) || 'blocked',
|
|
25
|
+
* run: (e, { cell }) => farm.layer('soil').set(cell, { tilled: true }) });
|
|
26
|
+
* engine.ops.define('farm.dryAll', { run: () => farm.layer('soil').updateAll(d => { delete d.watered; }) }); // e.g. from sky.daily at 06:00
|
|
27
|
+
*/
|
|
28
|
+
/** Stored cell data is never edited in place (writes go through set / updateAll, which the ops guard and the tile redraw see); dev builds freeze it so a stray write throws */
|
|
29
|
+
const seal = d => DEV ? Object.freeze(d) : d;
|
|
30
|
+
|
|
31
|
+
/** @experimental */
|
|
32
|
+
export class Layer {
|
|
33
|
+
/** @internal */
|
|
34
|
+
constructor(grid, name, opts = {}) {
|
|
35
|
+
/** @internal */ this.grid = grid;
|
|
36
|
+
/** Layer name @type {string} */
|
|
37
|
+
this.name = name;
|
|
38
|
+
/** @internal */ this.opts = opts;
|
|
39
|
+
/** @internal 'i,j' -> data */ this._cells = new Map();
|
|
40
|
+
/** @internal bumped on every change */ this._ver = 0;
|
|
41
|
+
/** @internal 'i,j' -> authored data (content/grids.js layers): what the save diffs against */ this._base = new Map();
|
|
42
|
+
/** @internal the last save diff applied, so a baseline set after the load (content after the save) still gets it */ this._diff = null;
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
_guard(what) { DEV && this.grid.engine.ops.guard(`grid layer ${this.grid.name}.${this.name}.${what}`); }
|
|
46
|
+
/**
|
|
47
|
+
* Data of a cell, or undefined. Read only (frozen in dev builds): change it with set / clear / updateAll
|
|
48
|
+
* @example farm.layer('soil').get([3, 5])?.watered
|
|
49
|
+
* @param {[number, number]} cell
|
|
50
|
+
* @returns {Record<string, any> | undefined}
|
|
51
|
+
*/
|
|
52
|
+
get([i, j]) { return this._cells.get(key(i, j)); }
|
|
53
|
+
/**
|
|
54
|
+
* 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
|
|
55
|
+
* @example farm.layer('soil').set([3, 5], { tilled: true, watered: true })
|
|
56
|
+
* @example farm.layer('soil').set([3, 5], { watered: null }) // dry this one cell
|
|
57
|
+
* @param {[number, number]} cell
|
|
58
|
+
* @param {Record<string, any>} patch
|
|
59
|
+
* @returns {Record<string, any> | undefined}
|
|
60
|
+
*/
|
|
61
|
+
set([i, j], patch) {
|
|
62
|
+
this._guard('set');
|
|
63
|
+
if (DEV) checkPlain(`layer ${this.name}.set`, patch);
|
|
64
|
+
const k = key(i, j), d = { ...this._cells.get(k) };
|
|
65
|
+
for (const [f, v] of Object.entries(patch)) { if (v == null) delete d[f]; else d[f] = v; }
|
|
66
|
+
if (Object.keys(d).length) this._cells.set(k, seal(d)); else this._cells.delete(k);
|
|
67
|
+
this._ver++;
|
|
68
|
+
return this._cells.get(k);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Empty a cell
|
|
72
|
+
* @param {[number, number]} cell
|
|
73
|
+
* @returns {void}
|
|
74
|
+
*/
|
|
75
|
+
clear([i, j]) { this._guard('clear'); if (this._cells.delete(key(i, j))) this._ver++; }
|
|
76
|
+
/**
|
|
77
|
+
* Non-empty cells, optionally only those in an area (min corner + size), in i then j order
|
|
78
|
+
* @example farm.layer('soil').query([0, 0], [4, 4]).filter(c => c.data.watered).length
|
|
79
|
+
* @param {[number, number]} [cell]
|
|
80
|
+
* @param {[number, number]} [size]
|
|
81
|
+
* @returns {{ cell: [number, number], data: Record<string, any> }[]}
|
|
82
|
+
*/
|
|
83
|
+
query(cell, size = [1, 1]) {
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const [k, data] of this._cells) {
|
|
86
|
+
const c = /** @type {[number, number]} */ (k.split(',').map(Number));
|
|
87
|
+
if (!cell || (c[0] >= cell[0] && c[1] >= cell[1] && c[0] < cell[0] + size[0] && c[1] < cell[1] + size[1])) out.push({ cell: c, data });
|
|
88
|
+
}
|
|
89
|
+
return out.sort((a, b) => a.cell[0] - b.cell[0] || a.cell[1] - b.cell[1]);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 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;
|
|
93
|
+
* returning null clears the cell, returning an object replaces the data. A cell left with no fields is cleared
|
|
94
|
+
* @example farm.layer('soil').updateAll(d => { delete d.watered; })
|
|
95
|
+
* @param {(data: Record<string, any>, cell: [number, number]) => any} fn
|
|
96
|
+
* @returns {number} cells left
|
|
97
|
+
*/
|
|
98
|
+
updateAll(fn) {
|
|
99
|
+
this._guard('updateAll');
|
|
100
|
+
for (const [k, d] of [...this._cells]) {
|
|
101
|
+
const copy = { ...d }, r = fn(copy, /** @type {[number, number]} */ (k.split(',').map(Number)));
|
|
102
|
+
const v = r === undefined ? copy : r;
|
|
103
|
+
if (v == null || !Object.keys(v).length) this._cells.delete(k);
|
|
104
|
+
else { if (DEV) checkPlain(`layer ${this.name}.updateAll`, v); this._cells.set(k, seal(v === d ? { ...v } : v)); }
|
|
105
|
+
}
|
|
106
|
+
this._ver++;
|
|
107
|
+
return this._cells.size;
|
|
108
|
+
}
|
|
109
|
+
/** Number of non-empty cells @returns {number} */
|
|
110
|
+
get count() { return this._cells.size; }
|
|
111
|
+
/** @internal save form: the diff against the authored baseline */
|
|
112
|
+
toJSON() {
|
|
113
|
+
const set = [], clear = [];
|
|
114
|
+
for (const { cell, data } of this.query()) {
|
|
115
|
+
const b = this._base.get(key(cell[0], cell[1]));
|
|
116
|
+
if (!b || JSON.stringify(b) !== JSON.stringify(data)) set.push([cell[0], cell[1], structuredClone(data)]);
|
|
117
|
+
}
|
|
118
|
+
for (const k of this._base.keys()) if (!this._cells.has(k)) clear.push(/** @type {[number, number]} */ (k.split(',').map(Number)));
|
|
119
|
+
return clear.length ? { set, clear } : { set };
|
|
120
|
+
}
|
|
121
|
+
/** @internal true when the layer equals its baseline (nothing to save) */
|
|
122
|
+
get _same() { const d = this.toJSON(); return !d.set.length && !d.clear; }
|
|
123
|
+
/** @internal a save diff (or null = none): baseline first, then the diff */
|
|
124
|
+
fromJSON(d) {
|
|
125
|
+
this._diff = d ?? null;
|
|
126
|
+
this._cells = new Map(d?.whole ? [] : this._base);
|
|
127
|
+
for (const [i, j, v] of d?.set ?? []) this._cells.set(key(i, j), seal(v));
|
|
128
|
+
for (const [i, j] of d?.clear ?? []) this._cells.delete(key(i, j));
|
|
129
|
+
this._ver++;
|
|
130
|
+
}
|
|
131
|
+
/** @internal authored cells ([[i, j, data], ...] from content/grids.js): the baseline; the last loaded diff is applied on top again */
|
|
132
|
+
_setBase(rows) {
|
|
133
|
+
for (const [i, j, v] of rows ?? []) { if (DEV) checkPlain(`content grids layer ${this.name}`, v); this._base.set(key(i, j), seal(structuredClone(v))); }
|
|
134
|
+
this.fromJSON(this._diff);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Options of grid.layer(name, opts)
|
|
140
|
+
* @typedef {{ tiles?: boolean | { look?: (data: Record<string, any>, cell: [number, number]) => any, colors?: Record<string, number | string>, lift?: number }
|
|
141
|
+
* | ((engine: any, layer: Layer) => { update?: (cells: { cell: [number, number], data: Record<string, any> }[]) => void, dispose?: () => void }) }} LayerOptions
|
|
142
|
+
*/
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// grids() module: placement grids for anything placed on cells (furniture, building, crops, crates, tactics tiles). Installed as engine.grids; costs nothing when not installed.
|
|
2
|
+
// engine.use(world(), grids());
|
|
3
|
+
// const room = engine.grids.add('room', { cell: 1, origin: [0, 0], size: [16, 12] });
|
|
4
|
+
// engine.grids.define('table', { size: [2, 1], layer: { floor: 'wood' } });
|
|
5
|
+
// engine.ops.run('grid.place', { grid: 'room', item: 'table', cell: [3, 5] });
|
|
6
|
+
// Where state lives (nothing is stored twice):
|
|
7
|
+
// placed things -> world records with a `grid` field (saved by world); occupancy is an index rebuilt from them (world:add / change / remove / load)
|
|
8
|
+
// per-cell layers -> Layer maps, saved here under the save key 'grids' (version 2) as a per-cell diff against the authored cells (Layer.js)
|
|
9
|
+
// The index is the "don't go around it" check: in dev a record's grid field is frozen (editing it in place throws), writes outside ops
|
|
10
|
+
// trigger the ops guard, and a record whose footprint overlaps another one is reported with the fix.
|
|
11
|
+
import { Grid } from './Grid.js';
|
|
12
|
+
import { layerTiles } from './tiles.js';
|
|
13
|
+
import { makePreview } from './preview.js';
|
|
14
|
+
import { defineGridOps, placed } from './ops.js';
|
|
15
|
+
|
|
16
|
+
/** Grids save part: version 1 stored every cell of a layer whole ([[i, j, data]]); version 2 stores a diff against the authored cells (Layer.js) */
|
|
17
|
+
const GRIDS_MIGRATE = { 1: d => Object.fromEntries(Object.entries(d || {}).map(([g, ls]) => [g, Object.fromEntries(Object.entries(ls || {}).map(([n, rows]) => [n, { set: rows, whole: true }]))])) };
|
|
18
|
+
import { checkOptions, closest, DEV } from '../../core/validate.js';
|
|
19
|
+
|
|
20
|
+
const STRINGS = {
|
|
21
|
+
dup: "grids.add('{name}'): a grid with this name exists",
|
|
22
|
+
noGrid: "grid '{name}': no such grid{hint}. Grids: {list}",
|
|
23
|
+
noItem: "grid item '{name}' is not defined{hint}: engine.grids.define('{name}', { size: [1, 1] }). Defined: {list}",
|
|
24
|
+
overlap: "[engine] grid '{grid}': {id} overlaps {other} at cell {cell}; the cell stays with {other}. Place things with engine.ops.run('grid.place', ...) / 'grid.move', which check can() first",
|
|
25
|
+
};
|
|
26
|
+
const fmt = (s, v) => s.replace(/\{(\w+)\}/g, (_, k) => v[k] ?? '');
|
|
27
|
+
const hint = (n, list) => { const c = closest(n, list); return c ? ` (did you mean '${c}'?)` : ''; };
|
|
28
|
+
const freeze = p => { Object.freeze(p.cell); Object.freeze(p.size); return Object.freeze(p); };
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* engine.grids: every placement grid, the item rules, previews and the occupancy index
|
|
32
|
+
* @example
|
|
33
|
+
* const farm = engine.grids.add('farm', { cell: 1, origin: [0, 0], size: [16, 12] });
|
|
34
|
+
* engine.grids.define('bed', { size: [2, 1], kind: 'furniture', fields: { model: 'bed' } });
|
|
35
|
+
* engine.ops.run('grid.place', { grid: 'farm', item: 'bed', cell: [4, 4], rotation: 1 });
|
|
36
|
+
* @experimental
|
|
37
|
+
*/
|
|
38
|
+
export class Grids {
|
|
39
|
+
/** @internal */
|
|
40
|
+
constructor(e) {
|
|
41
|
+
/** @internal */ this.engine = e;
|
|
42
|
+
/** @internal */ this._grids = new Map();
|
|
43
|
+
/** @internal */ this._defs = new Map();
|
|
44
|
+
/** @internal id -> { g, keys } */ this._byId = new Map();
|
|
45
|
+
/** @internal */ this._tiles = new Map();
|
|
46
|
+
/** @internal */ this._previews = new Set();
|
|
47
|
+
/** @internal layer data from a save, for layers created after the load */ this._loaded = null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 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);
|
|
51
|
+
* zone: level name (tiles only show there); flat: max height difference under a footprint (m, default 0.5);
|
|
52
|
+
* layers: authored cells { soil: [[i, j, { tilled: true }], ...] } (content/grids.js): the baseline a save diffs against, so a save keeps only changed cells
|
|
53
|
+
* @example const room = engine.grids.add('room', { cell: 0.5, origin: [-3, -3], size: [12, 12], zone: 'house' })
|
|
54
|
+
* @param {string} name
|
|
55
|
+
* @param {{ cell?: number, origin?: any, size?: [number, number], zone?: string, flat?: number, layers?: Record<string, [number, number, Record<string, any>][]> }} [opts]
|
|
56
|
+
* @returns {Grid}
|
|
57
|
+
*/
|
|
58
|
+
add(name, opts = {}) {
|
|
59
|
+
checkOptions(`grids.add('${name}')`, opts, ['cell', 'origin', 'size', 'zone', 'flat', 'layers']);
|
|
60
|
+
if (this._grids.has(name)) throw new Error(fmt(STRINGS.dup, { name }));
|
|
61
|
+
const g = new Grid(this.engine, this, name, opts);
|
|
62
|
+
this._grids.set(name, g);
|
|
63
|
+
for (const [ln, rows] of Object.entries(opts.layers ?? {})) { const l = g.layer(ln); l._byContent = true; l._setBase(rows); }
|
|
64
|
+
this._rebuild(); // records placed on it before it existed (content, a loaded save) now count
|
|
65
|
+
return g;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A grid by name, or null when there is none
|
|
69
|
+
* @param {string} name
|
|
70
|
+
* @returns {Grid | null}
|
|
71
|
+
*/
|
|
72
|
+
get(name) { return this._grids.get(name) ?? null; }
|
|
73
|
+
/** @internal A grid by name; throws with the names that exist */
|
|
74
|
+
_must(name) {
|
|
75
|
+
const g = this._grids.get(name);
|
|
76
|
+
if (!g) throw new Error(fmt(STRINGS.noGrid, { name, hint: hint(name, [...this._grids.keys()]), list: [...this._grids.keys()].join(', ') || 'none' }));
|
|
77
|
+
return g;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @internal The record a placement makes (kind + fields), the same math as the grid.place op; content uses it for pre-placed grid items (props entries with grid)
|
|
81
|
+
* @param {string} grid @param {string} item @param {[number, number]} cell @param {number} rotation
|
|
82
|
+
*/
|
|
83
|
+
placement(grid, item, cell, rotation) {
|
|
84
|
+
const g = this._must(grid), rule = this._rule(item);
|
|
85
|
+
return { kind: rule.kind ?? item, fields: { ...structuredClone(rule.fields ?? {}), ...placed(g, rule, item, cell, rotation) } };
|
|
86
|
+
}
|
|
87
|
+
/** All grids (a new array) @returns {Grid[]} */
|
|
88
|
+
list() { return [...this._grids.values()]; }
|
|
89
|
+
/**
|
|
90
|
+
* 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);
|
|
91
|
+
* ground: allowed engine.groundType values; layer: { layerName: field } that must be truthy on every cell (reason 'not' + Field, e.g. notTilled);
|
|
92
|
+
* flat: max height difference (overrides the grid's); fields: copied into the record; can(e, { grid, cell, rotation, cells }): your own rule
|
|
93
|
+
* @example engine.grids.define('crop', { size: [1, 1], layer: { soil: 'tilled' }, fields: { plantedAt: 0 } })
|
|
94
|
+
* @example engine.grids.define('shed', { size: [3, 2], ground: ['grass', 'dirt'], flat: 0.2 })
|
|
95
|
+
* @param {string} name
|
|
96
|
+
* @param {import('./Grid.js').GridRule} rule
|
|
97
|
+
* @returns {void}
|
|
98
|
+
*/
|
|
99
|
+
define(name, rule) {
|
|
100
|
+
checkOptions(`grids.define('${name}')`, rule, ['size', 'kind', 'ground', 'layer', 'flat', 'fields', 'can']);
|
|
101
|
+
this._defs.set(name, { size: [1, 1], ...rule });
|
|
102
|
+
}
|
|
103
|
+
/** @internal item name / size / inline rule -> rule */
|
|
104
|
+
_rule(what) {
|
|
105
|
+
if (typeof what === 'string') {
|
|
106
|
+
const r = this._defs.get(what);
|
|
107
|
+
if (!r) throw new Error(fmt(STRINGS.noItem, { name: what, hint: hint(what, [...this._defs.keys()]), list: [...this._defs.keys()].join(', ') || 'none' }));
|
|
108
|
+
return r;
|
|
109
|
+
}
|
|
110
|
+
return Array.isArray(what) ? { size: what } : { size: [1, 1], ...what };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Show where an item would go: the target cell under the pointer ('pointer', default), in front of the player ('front') or from your
|
|
114
|
+
* 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).
|
|
115
|
+
* look: false = no visual; (engine) => ({ update(view), hide(), dispose() }) = your own. place() runs grid.place with what is shown
|
|
116
|
+
* @example engine.input.define('place', ['Mouse0']); // the game's own binding
|
|
117
|
+
* const pv = engine.grids.preview({ grid: 'farm', item: 'crop', ...presets.keys.gridRotate });
|
|
118
|
+
* engine.onFrame(() => { if (engine.input.pressed('place')) { const r = pv.place(); if (!r.ok) toast(engine, engine.t('grid.' + r.reason)); } });
|
|
119
|
+
* @param {{ grid: string, item: string, from?: 'pointer' | 'front' | ((e: any) => any), rotate?: string | false, rotateKeys?: string[], rotation?: number, look?: false | ((e: any) => any) }} opts
|
|
120
|
+
* @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 }}
|
|
121
|
+
*/
|
|
122
|
+
preview(opts) {
|
|
123
|
+
checkOptions('grids.preview()', opts, ['grid', 'item', 'from', 'rotate', 'rotateKeys', 'rotation', 'look']);
|
|
124
|
+
return makePreview(this.engine, this, opts);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @internal a layer was created: load saved data waiting for it, build its tiles */
|
|
128
|
+
_layerAdded(l) {
|
|
129
|
+
const d = this._loaded?.[l.grid.name]?.[l.name];
|
|
130
|
+
if (d) l.fromJSON(d);
|
|
131
|
+
const t = layerTiles(this.engine, l);
|
|
132
|
+
if (t) this._tiles.set(l, t);
|
|
133
|
+
}
|
|
134
|
+
/** @internal a layer's options changed after content created it: rebuild its tiles */
|
|
135
|
+
_retile(l) { this._tiles.get(l)?.dispose(); this._tiles.delete(l); const t = layerTiles(this.engine, l); if (t) this._tiles.set(l, t); }
|
|
136
|
+
/** @internal */
|
|
137
|
+
_index(rec) {
|
|
138
|
+
const p = rec.grid, g = this._grids.get(p.id);
|
|
139
|
+
if (DEV && !Object.isFrozen(p)) freeze(p);
|
|
140
|
+
if (!g) return;
|
|
141
|
+
const keys = [];
|
|
142
|
+
for (const [i, j] of g.footprint(p.cell, p.size, p.rotation)) {
|
|
143
|
+
const k = i + ',' + j, other = g._occ.get(k);
|
|
144
|
+
if (other && other !== rec.id) { if (DEV) console.warn(fmt(STRINGS.overlap, { grid: g.name, id: rec.id, other, cell: k })); continue; }
|
|
145
|
+
g._occ.set(k, rec.id); keys.push(k);
|
|
146
|
+
}
|
|
147
|
+
this._byId.set(rec.id, { g, keys });
|
|
148
|
+
}
|
|
149
|
+
/** @internal */
|
|
150
|
+
_unindex(id) {
|
|
151
|
+
const x = this._byId.get(id); if (!x) return;
|
|
152
|
+
for (const k of x.keys) if (x.g._occ.get(k) === id) x.g._occ.delete(k);
|
|
153
|
+
this._byId.delete(id);
|
|
154
|
+
}
|
|
155
|
+
/** @internal */
|
|
156
|
+
_reindex(id) { this._unindex(id); const r = this.engine.world.get(id); if (r?.grid) this._index(r); }
|
|
157
|
+
/** @internal whole index from world records, by id so overlaps resolve the same way every time */
|
|
158
|
+
_rebuild() {
|
|
159
|
+
for (const g of this._grids.values()) g._occ.clear();
|
|
160
|
+
this._byId.clear();
|
|
161
|
+
const recs = [...this.engine.world.records.values()].filter(r => r.grid).sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
162
|
+
for (const r of recs) this._index(r);
|
|
163
|
+
}
|
|
164
|
+
/** @internal */
|
|
165
|
+
toJSON() {
|
|
166
|
+
// orphans kept: a loaded diff for a grid or layer that does not exist (yet) this run is written back as it was, so nothing is lost
|
|
167
|
+
const out = structuredClone(this._loaded ?? {});
|
|
168
|
+
for (const g of this._grids.values()) for (const l of g._layers.values()) {
|
|
169
|
+
if (l._same) { if (out[g.name]) delete out[g.name][l.name]; } else (out[g.name] ??= {})[l.name] = l.toJSON();
|
|
170
|
+
}
|
|
171
|
+
for (const k of Object.keys(out)) if (!Object.keys(out[k]).length) delete out[k];
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
/** @internal */
|
|
175
|
+
fromJSON(d) {
|
|
176
|
+
this._loaded = d ?? {};
|
|
177
|
+
for (const g of this._grids.values()) for (const l of g._layers.values()) l.fromJSON(this._loaded[g.name]?.[l.name]);
|
|
178
|
+
}
|
|
179
|
+
/** @internal one line per grid for describe() */
|
|
180
|
+
_describe() {
|
|
181
|
+
const out = {};
|
|
182
|
+
for (const g of this._grids.values()) {
|
|
183
|
+
const items = {};
|
|
184
|
+
for (const [id, x] of this._byId) if (x.g === g) { const it = this.engine.world.get(id)?.grid?.item ?? 'other'; items[it] = (items[it] || 0) + 1; }
|
|
185
|
+
const layers = {};
|
|
186
|
+
for (const l of g._layers.values()) layers[l.name] = l.count;
|
|
187
|
+
out[g.name] = { cell: g.cell, size: g.size, occupied: g.occupied, items, layers };
|
|
188
|
+
}
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
/** @internal engine.explain({ grid: { grid, item, cell, rotation } }) */
|
|
192
|
+
_explain(q) {
|
|
193
|
+
const g = this.get(q?.grid);
|
|
194
|
+
if (!g) return { ok: false, text: `no grid '${q?.grid}' (grids: ${[...this._grids.keys()].join(', ') || 'none'})` };
|
|
195
|
+
const r = g.check(q.item, q.cell, { rotation: q.rotation ?? 0 });
|
|
196
|
+
const head = `${q.item} at ${g.name} [${q.cell}] rotation ${q.rotation ?? 0}`;
|
|
197
|
+
if (!r.reason) return { ok: true, text: `${head} can be placed` };
|
|
198
|
+
const by = r.by ? ` by ${r.by} (${this.engine.world.get(r.by)?.grid?.item ?? this.engine.world.get(r.by)?.kind})` : '';
|
|
199
|
+
return { ok: false, reason: r.reason, text: `${head} cannot be placed: ${r.reason}${r.cell ? ` at cell [${r.cell}]` : ''}${by}${r.text ? ` (${r.text})` : ''}` };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers).
|
|
205
|
+
* @example engine.use(world(), grids())
|
|
206
|
+
* @returns {import('../../types/core').ModuleDef<Grids>}
|
|
207
|
+
* @experimental
|
|
208
|
+
*/
|
|
209
|
+
export function grids() {
|
|
210
|
+
let G = null, offOps = null;
|
|
211
|
+
const subs = [];
|
|
212
|
+
return {
|
|
213
|
+
name: 'grids', label: 'Grid placement', stage: 'gameplay', requires: ['world'],
|
|
214
|
+
install(e) {
|
|
215
|
+
G = new Grids(e);
|
|
216
|
+
e.saves.register('grids', { atomic: true, version: 2, migrate: GRIDS_MIGRATE, save: () => G.toJSON(), load: d => G.fromJSON(d) });
|
|
217
|
+
offOps = defineGridOps(e, G);
|
|
218
|
+
subs.push(
|
|
219
|
+
e.events.on('world:add', ({ id }) => G._reindex(id)),
|
|
220
|
+
e.events.on('world:remove', ({ id }) => G._unindex(id)),
|
|
221
|
+
e.events.on('world:change', ({ id, keys }) => { if (keys.includes('grid')) G._reindex(id); }),
|
|
222
|
+
e.events.on('world:load', () => G._rebuild()),
|
|
223
|
+
);
|
|
224
|
+
return G;
|
|
225
|
+
},
|
|
226
|
+
frame() { for (const t of G._tiles.values()) t.frame(); for (const p of G._previews) p.frame(); },
|
|
227
|
+
explain: { grid: (e, q) => G._explain(q) },
|
|
228
|
+
describe() { return G._describe(); },
|
|
229
|
+
dispose() {
|
|
230
|
+
for (const s of subs) s.remove();
|
|
231
|
+
offOps?.();
|
|
232
|
+
for (const t of G._tiles.values()) t.dispose();
|
|
233
|
+
for (const p of [...G._previews]) p.remove();
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// grid.place / grid.remove / grid.move: placing on a grid is a player (or NPC) decision, so it is an op.
|
|
2
|
+
// can() is exactly Grid.can, so a button can grey out, the preview can turn red and the dev bridge can list reasons from one rule.
|
|
3
|
+
// A placed thing is one world record: { kind, position (footprint center), rot (yaw, for presenters), grid: { id, cell, size, rotation, item } }.
|
|
4
|
+
// Occupancy is derived from rec.grid by the index in index.js; nothing else stores it.
|
|
5
|
+
const REASONS = {
|
|
6
|
+
noGrid: 'No grid with that name (engine.grids.add)',
|
|
7
|
+
outOfBounds: 'Part of the footprint is outside the grid',
|
|
8
|
+
occupied: 'A cell is already taken (grid.at(cell) says by what)',
|
|
9
|
+
wrongGround: 'Ground type (engine.groundType) is not one the item allows',
|
|
10
|
+
notFlat: 'Ground under the footprint is too uneven',
|
|
11
|
+
unknown: 'No world record with that id',
|
|
12
|
+
notPlaced: 'That record is not on a grid',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Record fields the placement owns: fields passed to grid.place may not set them */
|
|
16
|
+
const RESERVED = ['id', 'kind', 'grid', 'position', 'rot'];
|
|
17
|
+
|
|
18
|
+
/** The placed-record fields for a footprint @internal */
|
|
19
|
+
export function placed(g, rule, item, cell, rotation) {
|
|
20
|
+
return {
|
|
21
|
+
position: g.toWorld(cell, rule.size, rotation), rot: rotation * Math.PI / 2,
|
|
22
|
+
grid: { id: g.name, cell: [cell[0], cell[1]], size: [rule.size[0], rule.size[1]], rotation, ...(item ? { item } : {}) },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Define the grid ops (once per install) @internal */
|
|
27
|
+
export function defineGridOps(e, grids) {
|
|
28
|
+
const handles = [
|
|
29
|
+
e.ops.define('grid.place', {
|
|
30
|
+
desc: 'Place an item on a grid: creates a world record whose footprint occupies cells. item = name from engine.grids.define; rotation = quarter turns',
|
|
31
|
+
args: { grid: 'string', item: 'string', cell: 'any', rotation: 'int?', fields: 'any?', id: 'string?' },
|
|
32
|
+
can(e, { grid, item, cell, rotation = 0, id, fields }) {
|
|
33
|
+
const g = grids.get(grid);
|
|
34
|
+
if (fields && RESERVED.some(k => k in fields)) return 'badFields';
|
|
35
|
+
if (!g) return 'noGrid';
|
|
36
|
+
if (id && e.world.get(id)) return 'idTaken';
|
|
37
|
+
return g.can(item, cell, { rotation });
|
|
38
|
+
},
|
|
39
|
+
run(e, { grid, item, cell, rotation = 0, fields, id }) {
|
|
40
|
+
const g = grids._must(grid), rule = grids._rule(item);
|
|
41
|
+
const rec = e.world.add({ ...(id ? { id } : {}), kind: rule.kind ?? item, ...structuredClone(rule.fields ?? {}), ...fields, ...placed(g, rule, item, cell, rotation) });
|
|
42
|
+
return rec.id;
|
|
43
|
+
},
|
|
44
|
+
reasons: { ...REASONS, idTaken: 'A world record with that id exists', badFields: 'fields may not set id / kind / grid / position / rot: the placement owns them (pass id as its own argument)' },
|
|
45
|
+
}),
|
|
46
|
+
e.ops.define('grid.remove', {
|
|
47
|
+
desc: 'Pick up a placed thing: removes its world record and frees its cells',
|
|
48
|
+
args: { id: 'string' },
|
|
49
|
+
can(e, { id }) { const r = e.world.get(id); return !r ? 'unknown' : !r.grid ? 'notPlaced' : true; },
|
|
50
|
+
run(e, { id }) { const r = e.world.get(id), out = { item: r.grid.item ?? r.kind, kind: r.kind }; e.world.remove(id); return out; },
|
|
51
|
+
reasons: REASONS,
|
|
52
|
+
}),
|
|
53
|
+
e.ops.define('grid.move', {
|
|
54
|
+
desc: 'Move / turn a placed thing to another cell (or another grid); its own cells do not block it',
|
|
55
|
+
args: { id: 'string', cell: 'any', rotation: 'int?', grid: 'string?' },
|
|
56
|
+
can(e, { id, cell, rotation, grid }) {
|
|
57
|
+
const r = e.world.get(id);
|
|
58
|
+
if (!r) return 'unknown';
|
|
59
|
+
if (!r.grid) return 'notPlaced';
|
|
60
|
+
const g = grids.get(grid ?? r.grid.id);
|
|
61
|
+
if (!g) return 'noGrid';
|
|
62
|
+
return g.can(r.grid.item ?? r.grid.size, cell, { rotation: rotation ?? r.grid.rotation, ignore: id });
|
|
63
|
+
},
|
|
64
|
+
run(e, { id, cell, rotation, grid }) {
|
|
65
|
+
const r = e.world.get(id), g = grids._must(grid ?? r.grid.id), rule = { size: r.grid.size };
|
|
66
|
+
e.world.set(id, placed(g, rule, r.grid.item, cell, rotation ?? r.grid.rotation));
|
|
67
|
+
return id;
|
|
68
|
+
},
|
|
69
|
+
reasons: REASONS,
|
|
70
|
+
}),
|
|
71
|
+
];
|
|
72
|
+
return () => { for (const h of handles) h.remove(); };
|
|
73
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Placement preview (engine.grids.preview): picks the target cell every frame (under the pointer, in front of the player, or from
|
|
2
|
+
// your function), keeps a rotation turned by an input action, asks can(), and shows a see-through footprint
|
|
3
|
+
// (style.grid.ok / bad colors). It never changes gameplay state: place() runs the grid.place op with what it shows.
|
|
4
|
+
// The look is a replaceable part: look: false (no visual, the handle still answers), or (engine) => ({ update(view), hide(), dispose() }).
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
import { makeMaterial } from '../../render/materials.js';
|
|
7
|
+
import { screenToGround } from '../../core/screenToGround.js';
|
|
8
|
+
import { warnOnce } from '../../core/validate.js';
|
|
9
|
+
|
|
10
|
+
// tool colors, not art: neutral defaults that still tell the two apart (light = can place, dark = cannot); a style pack may override them
|
|
11
|
+
const OK = 0xe0e0e0, BAD = 0x3a3a3a;
|
|
12
|
+
const STRINGS = { 'zh-CN': { 'grid.rotate': '旋转' }, en: { 'grid.rotate': 'Rotate' } };
|
|
13
|
+
const NO_KEY = 'grids.preview(): the action "{a}" has no keys, so the preview cannot be turned by input. Bind it yourself (engine.input.define("{a}", ["KeyR"])), pass rotateKeys: ["KeyR"] / ...presets.keys.gridRotate, or pass rotate: false and call pv.rotate() from your own control';
|
|
14
|
+
|
|
15
|
+
/** Default look: a flat translucent box over the footprint @internal */
|
|
16
|
+
function boxLook(e) {
|
|
17
|
+
const st = e.style.grid ?? {}, opacity = st.previewOpacity ?? 0.45;
|
|
18
|
+
const mat = makeMaterial('decal', { transparent: true, opacity, depthWrite: false }, e);
|
|
19
|
+
const mesh = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), mat);
|
|
20
|
+
mesh.name = 'grid:preview'; mesh.visible = false; mesh.renderOrder = 2;
|
|
21
|
+
e.add(mesh, { owner: 'engine:grid' });
|
|
22
|
+
const ok = new THREE.Color(st.ok ?? OK), bad = new THREE.Color(st.bad ?? BAD), h = st.previewHeight ?? 0.08;
|
|
23
|
+
return {
|
|
24
|
+
update(v) {
|
|
25
|
+
mesh.visible = true;
|
|
26
|
+
mesh.scale.set(v.size[0] - 0.04, h, v.size[1] - 0.04);
|
|
27
|
+
mesh.position.set(v.center.x, v.center.y + h / 2, v.center.z);
|
|
28
|
+
mat.color.copy(v.ok ? ok : bad);
|
|
29
|
+
},
|
|
30
|
+
hide() { mesh.visible = false; },
|
|
31
|
+
dispose() { e.remove(mesh); mesh.geometry.dispose(); mat.dispose(); },
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Where the target is this frame (world position) or null @internal */
|
|
36
|
+
function target(e, from, g) {
|
|
37
|
+
if (typeof from === 'function') return from(e);
|
|
38
|
+
if (from === 'front') {
|
|
39
|
+
const p = e.actorPosition(); if (!p) return null; // whoever the user controls (engine.actor)
|
|
40
|
+
const body = e.actor === 'player' ? e.player : null, f = body?.facing ?? e.world?.get(e.actor)?.facing ?? 0, d = g.cell;
|
|
41
|
+
return { x: p.x + Math.sin(f) * d, z: p.z + Math.cos(f) * d };
|
|
42
|
+
}
|
|
43
|
+
const ptr = e.input.pointer;
|
|
44
|
+
return screenToGround(e, ptr.ndcX, ptr.ndcY);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Create a preview handle @internal */
|
|
48
|
+
export function makePreview(e, grids, opts) {
|
|
49
|
+
const { grid, item, from = 'pointer', rotate = 'rotate', rotateKeys, look } = opts;
|
|
50
|
+
const g = grids._must(grid), rule = grids._rule(item);
|
|
51
|
+
// the engine binds no key itself: the rotate action comes from the game (input.define / bindings) or from rotateKeys (e.g. presets.keys.gridRotate)
|
|
52
|
+
if (rotate && !e.input.actions.has(rotate)) {
|
|
53
|
+
if (rotateKeys?.length) { e.i18n.add(STRINGS); e.input.define(rotate, rotateKeys, 'grid.rotate'); }
|
|
54
|
+
else warnOnce(NO_KEY.replaceAll('{a}', rotate));
|
|
55
|
+
}
|
|
56
|
+
const part = look === false ? null : typeof look === 'function' ? look(e) : boxLook(e);
|
|
57
|
+
const h = {
|
|
58
|
+
/** target cell or null (nothing under the pointer) */ cell: null,
|
|
59
|
+
rotation: opts.rotation ?? 0,
|
|
60
|
+
ok: false, reason: 'noTarget',
|
|
61
|
+
/** Turn by quarter turns (the rotate action does this too) */
|
|
62
|
+
rotate(n = 1) { h.rotation = (((h.rotation + n) % 4) + 4) % 4; },
|
|
63
|
+
/** Run grid.place with the shown cell and rotation; returns the op result */
|
|
64
|
+
place(fields) {
|
|
65
|
+
if (!h.cell) return { ok: false, reason: 'noTarget' };
|
|
66
|
+
return e.ops.run('grid.place', { grid, item, cell: h.cell, rotation: h.rotation, ...(fields ? { fields } : {}) });
|
|
67
|
+
},
|
|
68
|
+
/** Remove the preview (cancel convention: safe to call again) */
|
|
69
|
+
remove() { grids._previews.delete(h); part?.dispose?.(); },
|
|
70
|
+
/** @internal */
|
|
71
|
+
frame() {
|
|
72
|
+
if (rotate && e.input.actions.has(rotate) && e.input.pressed(rotate)) h.rotate(1);
|
|
73
|
+
const p = target(e, from, g);
|
|
74
|
+
h.cell = p ? g.toCell(p) : null;
|
|
75
|
+
if (!h.cell) { h.ok = false; h.reason = 'noTarget'; part?.hide?.(); return; }
|
|
76
|
+
const r = g.can(item, h.cell, { rotation: h.rotation });
|
|
77
|
+
h.ok = r === true; h.reason = r === true ? null : r;
|
|
78
|
+
const [w, d] = h.rotation & 1 ? [rule.size[1], rule.size[0]] : rule.size;
|
|
79
|
+
part?.update?.({ grid, item, cell: h.cell, rotation: h.rotation, cells: g.footprint(h.cell, rule.size, h.rotation),
|
|
80
|
+
center: g.toWorld(h.cell, rule.size, h.rotation), size: [w * g.cell, d * g.cell], ok: h.ok, reason: h.reason });
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
grids._previews.add(h);
|
|
84
|
+
return h;
|
|
85
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Crisp per-cell tiles for a layer (tilled soil, wet soil, a painted floor): one mesh per layer, each non-empty cell a quad
|
|
2
|
+
// whose four corners sit on engine.surface + lift, so tiles hug a ramp or terrain and work on any ground provider
|
|
3
|
+
// (procedural terrain, a Blender level, a flat greenhouse floor). One merged mesh = one draw call; it is rebuilt only when
|
|
4
|
+
// the layer version or the ground (level:loaded) changes.
|
|
5
|
+
// Look: layer option tiles.look(data, cell) -> color | null, else tiles.colors = { field: color } (call site, same shape as the style table), else the style pack table style.grid.tiles[layer] = { field: color }
|
|
6
|
+
// (first truthy field in the table's order wins), else neutral gray. tiles: false = off; a function = your own part.
|
|
7
|
+
import * as THREE from 'three';
|
|
8
|
+
import { makeMaterial } from '../../render/materials.js';
|
|
9
|
+
import { surfaceOr } from '../../core/ground.js';
|
|
10
|
+
|
|
11
|
+
const GAP = 0.03; // fraction of a cell left between tiles: keeps tiles visibly separate (crisp edges)
|
|
12
|
+
const FALLBACK = 0x9a9a9a;
|
|
13
|
+
|
|
14
|
+
/** Look function from a { field: color } table: the first truthy field in the table's order wins (same table shape as style.grid.tiles[layer]; the call-site option tiles.colors wins over the style) @internal */
|
|
15
|
+
function tableLook(table) {
|
|
16
|
+
if (!table) return null;
|
|
17
|
+
const order = Object.entries(table);
|
|
18
|
+
return d => { for (const [f, c] of order) if (d[f]) return c; return null; };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Look function from the style pack table (null if the style has none for this layer) @internal */
|
|
22
|
+
function styleLook(e, name) {
|
|
23
|
+
return tableLook(e.style.grid?.tiles?.[name]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Build the tile view of a layer, or null when off. Returns { frame(), dispose() } @internal */
|
|
27
|
+
export function layerTiles(e, layer) {
|
|
28
|
+
const t = layer.opts.tiles, name = layer.name;
|
|
29
|
+
if (t === false) return null;
|
|
30
|
+
if (typeof t === 'function') return customTiles(e, layer, t(e, layer));
|
|
31
|
+
const look = (t && typeof t === 'object' && (t.look || tableLook(t.colors))) || styleLook(e, name) || (t ? () => FALLBACK : null);
|
|
32
|
+
if (!look) return null; // no style table and not asked for: a pure data layer
|
|
33
|
+
const lift = (t && typeof t === 'object' && t.lift) ?? e.style.grid?.tileLift ?? 0.03;
|
|
34
|
+
const mat = makeMaterial('decal', { vertexColors: true }, e);
|
|
35
|
+
// drawn over the ground it lies on: depth offset instead of a big lift keeps it glued to slopes
|
|
36
|
+
mat.polygonOffset = true; mat.polygonOffsetFactor = -2; mat.polygonOffsetUnits = -2;
|
|
37
|
+
const geo = new THREE.BufferGeometry(), mesh = new THREE.Mesh(geo, mat);
|
|
38
|
+
mesh.name = `grid:${layer.grid.name}.${name}`; mesh.receiveShadow = true; mesh.frustumCulled = false;
|
|
39
|
+
e.add(mesh, { owner: 'engine:grid' });
|
|
40
|
+
let ver = -1, ground = 0, built = -1;
|
|
41
|
+
const off = e.events.on('level:loaded', () => { ground++; }); // a new level = new ground heights
|
|
42
|
+
const col = new THREE.Color(), g = layer.grid;
|
|
43
|
+
function rebuild() {
|
|
44
|
+
const cells = layer.query(), pos = [], clr = [], idx = [];
|
|
45
|
+
let last = 0; // height of the previous corner: a corner beyond the island borrows it instead of -Infinity
|
|
46
|
+
for (const { cell, data } of cells) {
|
|
47
|
+
const c = look(data, cell);
|
|
48
|
+
if (c == null) continue;
|
|
49
|
+
col.set(c);
|
|
50
|
+
const x0 = g.origin.x + (cell[0] + GAP) * g.cell, z0 = g.origin.z + (cell[1] + GAP) * g.cell, s = g.cell * (1 - 2 * GAP), n = pos.length / 3;
|
|
51
|
+
for (const [x, z] of [[x0, z0], [x0, z0 + s], [x0 + s, z0 + s], [x0 + s, z0]]) { pos.push(x, (last = surfaceOr(e, x, z, undefined, last)) + lift, z); clr.push(col.r, col.g, col.b); }
|
|
52
|
+
idx.push(n, n + 1, n + 2, n, n + 2, n + 3);
|
|
53
|
+
}
|
|
54
|
+
geo.dispose(); // frees the old GPU buffers now (new attributes are uploaded on the next draw) instead of leaving them to GC
|
|
55
|
+
geo.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));
|
|
56
|
+
geo.setAttribute('color', new THREE.Float32BufferAttribute(clr, 3));
|
|
57
|
+
geo.setIndex(idx);
|
|
58
|
+
geo.computeVertexNormals();
|
|
59
|
+
mesh.userData.tiles = idx.length / 6;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
mesh,
|
|
63
|
+
frame() {
|
|
64
|
+
mesh.visible = g.zone == null || e.world?.zone == null || e.world.zone === g.zone;
|
|
65
|
+
if (layer._ver !== ver || ground !== built) { ver = layer._ver; built = ground; rebuild(); }
|
|
66
|
+
},
|
|
67
|
+
dispose() { off.remove(); e.remove(mesh); geo.dispose(); mat.dispose(); },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A game-made tile part: called with the cell list whenever the layer changes @internal */
|
|
72
|
+
function customTiles(e, layer, part) {
|
|
73
|
+
let ver = -1;
|
|
74
|
+
return {
|
|
75
|
+
mesh: null,
|
|
76
|
+
frame() { if (layer._ver !== ver) { ver = layer._ver; part?.update?.(layer.query()); } },
|
|
77
|
+
dispose() { part?.dispose?.(); },
|
|
78
|
+
};
|
|
79
|
+
}
|