spatial-monorepo / core/src / applyExplodedView
Function: applyExplodedView()
applyExplodedView(
map,levels,opts):void
Defined in: packages/core/src/layers/IMDFFloorLayer.ts:410
Apply (or reset) exploded-view vertical offsets to fill-extrusion layers.
In 3D exploded mode each floor's imdf-walls-<levelId> layer receives fill-extrusion-base = ['+', ['get','base_height'], offset] where offset = ordinal × (wallHeightCm + gapCm) / 100 metres, so all floors are visible simultaneously from an oblique angle.
When explodedView is false (or offset is 0), the base resets to the bare ['get','base_height'] expression — NOT a literal 0.
Issue #609 — the per-feature base_height expression MUST be preserved, never overwritten with a scalar. generateWallBands (#481 doorLintels) writes ~2.1m base_height on wallKind:'lintel' features so doorways render as openings under a header slab. A scalar base here used to collapse every lintel's base to the floor slab (exploded on) or to 0 (exploded off), welding doorways shut until the layer was recreated — the same paint-state corruption pattern called out in the #480 comment on buildWallExtrusionPaint.
In 2D mode (mode === '2d'), this function is a no-op.
Issue #454 — Floors idle-unloaded by the FloorUnloader (see setupFloorUnloader) no longer have an imdf-walls-<levelId> layer on the map. Each level is guarded with map.getLayer(...) and skipped when the layer is missing, so toggling exploded view never throws or logs MapLibre "layer not found" errors for unloaded floors. When an unloaded floor is later re-added (FloorUnloader's reloadFloor callback), the caller re-applies the correct base offset for that floor — see SpatialMap's reloadFloor wiring, which calls this function again for the reloaded level immediately after addIMDFLayers.
Issue #474 — Targets imdf-walls-<levelId> (was imdf-units-3d-<levelId>, removed in favour of the thin wall-band layer). The #454 getLayer guard above already covers the "floor unloaded" case for the renamed layer id — no behavioural change beyond the id itself.
Parameters
map
Map$1
levels
opts
explodedView
boolean
gapCm?
number
mode?
"2d" | "3d"
wallHeightCm?
number
Returns
void
