[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AVT5HCJZWHVK4D51CH5J6R":3,"skill-same:01M7AVT5HCJZWHVK4D51CH5J6R":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7AVT5HCJZWHVK4D51CH5J6R","geospatial-disaster-simulation",null,"Simulate real-world natural disasters on geospatial map tiles using tile-snapped canvas raster sources, Mercator elevation decoding, and Three.js 3D WebGL building collapse physics. Do not use for non-georeferenced 2D animations, static GIS styling, or purely synthetic particle physics.","SpectreDeath\u002FBrain-Harness","SpectreDeath","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F207463416?v=4","01M7AVGR1D4X8ADT47APKGVH2Z","JL","01M7AVGR2HSGD23BA5DBTJJTVN",0,"MIT","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgeospatial-disaster-simulation\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: geospatial-disaster-simulation\ndescription: Simulate real-world natural disasters on geospatial map tiles using tile-snapped canvas raster sources, Mercator elevation decoding, and Three.js 3D WebGL building collapse physics. Do not use for non-georeferenced 2D animations, static GIS styling, or purely synthetic particle physics.\n---\n\n# Geospatial Disaster Simulation: Real-Map Inundation & 3D Building Collapse Engine\n\n`geospatial-disaster-simulation` is the authoritative simulation engineering skill for executing real-world natural disaster scenarios (tsunamis, riverine floods, and seismic structural collapses) on interactive web maps using Mapbox GL JS \u002F MapLibre GL and Three.js.\n\nDistilled from the engineering breakthroughs of **Alex Oliinyk** on [HazardSim](https:\u002F\u002Fhazardsim.com\u002F), this skill eliminates the **\"Sticker Problem\"** (naive screen-space canvas overlays that float, smear, and desynchronize when the camera tilts) by enforcing a strict **Dual-World Coordinate Architecture**:\n1. **Ground Tier**: Tile-aligned canvas raster sources draped directly onto 3D terrain mesh.\n2. **Height Tier**: Shared WebGL 3D context with `promoteId` feature-state extrusion scaling and Three.js instanced physics.\n\nSee [CARD.md](CARD.md) for the companion summary card, 5-stage progression matrix, and invariants checklist.\nConsult [open-source-gis-architect](..\u002Fopen-source-gis-architect\u002FSKILL.md) for raster GIS tooling, [python-dataclass-architect](..\u002Fpython-dataclass-architect\u002FSKILL.md) for slotted domain models, and [epistemic-isnad-audit](..\u002Fepistemic-isnad-audit\u002FSKILL.md) for primary source provenance.\n\n---\n\n## The 5-Stage Simulation Pipeline\n\n```\n[1. Grid Ingestion & Elevation] ──► [2. Ground Fluid Canvas Draping] ──► [3. Footprint Extraction & Feature Scaling]\n                                                                                           │\n                                                                                           ▼\n[5. Camera Choreography & Defense] ◄── [4. 3D WebGL Custom Layer & Instanced Debris] ◄─────┘\n```\n\n---\n\n## 1. Geospatial Grid Ingestion & Tile Alignment\n\nMap simulations must execute in map coordinates, not screen coordinates. Align computational grids directly to Web Mercator tile pyramids to consume external raster and elevation tiles without resampling:\n\n1. **Web Mercator Coordinate Projection**:\n   - Convert geographic bounds $(\\text{lng}, \\text{lat})$ to tile coordinates $(x, y)$ at zoom $z$:\n     $$x = \\frac{\\text{lon} + 180}{360} \\cdot 2^z$$\n     $$y = \\frac{1 - \\ln(\\tan(\\text{rad}) + \\sec(\\text{rad})) \u002F \\pi}{2} \\cdot 2^z$$\n2. **Automated Budgeted Zoom Selection**:\n   - Step zoom $z$ downward from 15 to 8 until bounding box dimensions satisfy operational budgets ($\\le 780\\text{ px}$ width and $\\le 620,000\\text{ cells}$).\n   - Snap bounding box outward to integer tile coordinates $(x_0, y_0) \\to (x_1, y_1)$ to guarantee exact 1-to-1 mapping with downloaded tiles.\n   - Calculate metric cell resolution: $\\text{cellM} = 156543.03392 \\cdot \\cos(\\text{lat}) \u002F 2^z$.\n3. **Dual Elevation Tile Decoding**:\n   - **AWS Terrarium PNGs** (S3 Open Data):\n     $$\\text{elev}_m = R \\cdot 256 + G + \\frac{B}{256} - 32768$$\n   - **Mapbox Terrain-RGB**:\n     $$\\text{elev}_m = -10000 + (R \\cdot 65536 + G \\cdot 256 + B) \\cdot 0.1$$\n   - Ingest into a contiguous 1D `Float32Array`. Run a $3 \\times 3$ median filter across neighbors differing by $> 8\\text{ m}$ to eliminate single-pixel sensor spikes.\n   - Identify sea cells: cells with $\\text{elev} \\le 0$ connected to the grid boundary via continuous water paths.\n\n> **Completion Criterion**: 1D Float32Array elevation grid loaded, snapped to tile boundaries, spikes filtered, and cell resolution established.\n\n---\n\n## 2. Ground-Tier Fluid & Inundation Simulation\n\nGround fluids (tsunami surges, flood inundations, mudflows) must live on the ground surface, allowing automatic terrain draping, foreshortening, and rotation:\n\n1. **Hydraulic Inundation Propagation**:\n   - Execute breadth-first search (BFS) flood progression from source coastlines or rivers across cell elevation gradients.\n   - Store reach timestamp $T_{\\text{reach}}$ and water depth array per grid cell.\n2. **Canvas Raster Source Attachment**:\n   - Register an offscreen `\u003Ccanvas>` with dimensions $W \\times H$ as a Mapbox `canvas` source:\n     ```javascript\n     map.addSource(\"flood\", {\n       type: \"canvas\", canvas: \"floodcanvas\", coordinates: coords, animate: true\n     });\n     map.addLayer({\n       id: \"flood\", type: \"raster\", source: \"flood\",\n       paint: { \"raster-opacity\": 0.94, \"raster-resampling\": \"linear\", \"raster-fade-duration\": 0 }\n     });\n     ```\n   - Mandatory flags: `animate: true` (forces per-frame texture re-upload), `\"raster-resampling\": \"linear\"` (smooth cell interpolation), `\"raster-fade-duration\": 0` (eliminates ghosting).\n3. **Dual-Mask Video Texture Compositing**:\n   - Avoid baking color into video textures; maintain neutral greyscale water footage.\n   - Tint dynamically in a scratch buffer with time-ramped sediment interpolation (`mud` factor: $0 \\to 1$).\n   - Apply `destination-in` with `landMask` (white on land, transparent on open sea) to confine flood color to dry ground.\n   - Composite onto the main flood canvas via `source-atop`, ensuring water texture is clipped strictly to the simulated flood boundary with zero per-pixel iteration.\n4. **Local Seaward Camera Calculation**:\n   - Locate the nearest coastline cell to the city center.\n   - Average directional offsets to sea cells within a $2.5\\text{ km}$ radius to determine true local seaward bearing $\\theta_{\\text{seaward}}$, preventing curved bay distortion.\n\n> **Completion Criterion**: Dynamic canvas raster draped over terrain, compositing video textures within flood masks, and seaward camera vector computed.\n\n---\n\n## 3. Footprint Extraction & Dynamic Feature-State Scaling\n\nEarthquake destruction requires differentiating between distance-based background buildings and foreground hero structures:\n\n1. **Vector Footprint Extraction & GeoJSON Promotion**:\n   - Ingest building footprints from vector tiles via `map.querySourceFeatures()`.\n   - Deduplicate geometries across tile boundaries.\n   - Copy features into a dedicated GeoJSON source configured with `promoteId: \"i\"` (where `i` is an integer index). Calling `map.setFeatureState()` on vector tile features silently fails because vector buildings lack feature IDs.\n2. **Patterned Facade Extrusion Styling**:\n   - Configure dual `fill-extrusion` layers (`bld-walls` and `bld-roof`).\n   - Drive extrusion heights via feature-state multiplier $k$:\n     ```javascript\n     \"fill-extrusion-height\": [\"*\", [\"get\", \"height\"], [\"feature-state\", \"k\"]]\n     ```\n   - Insert building layers below the first `symbol` layer (`map.getStyle().layers`) so labels remain visible above roofs.\n3. **Seismic Attenuation & Piecewise Fragility**:\n   - Compute hypocentral distance: $R = \\sqrt{r_{\\text{km}}^2 + \\text{depth}^2}$ (default depth: $10\\text{ km}$).\n   - Calculate Modified Mercalli Intensity:\n     $$\\text{MMI} = 1.5 M - 3.0 \\log_{10}(R) - 0.0018 R + 1.6$$\n   - Interpolate collapse probability $P_{\\text{collapse}}$ across piecewise fragility curve:\n     `[[6.5, 0], [7, 0.004], [8, 0.025], [9, 0.08], [10, 0.20], [11, 0.38], [12, 0.55]]`.\n   - Scale probability by structural quality factor $q$ (strict=0.2, avg=1.0, poor=3.0) and height factor $h_f$ (mid-rise 15–35m most vulnerable).\n4. **5-Mode Building Collapse Kinematics**:\n   - Modulate $k(u)$ from $1.0$ down to rubble height $k_f$ across 5 distinct modes:\n     1. *Floor-by-Floor*: Staircase drop and pause per floor level.\n     2. *Soft-Storey*: Ground-floor drop, long pause, then rapid collapse.\n     3. *Crushed Top*: Upper third fails early, pauses, then collapses lower sections.\n     4. *Sideways*: Steady accelerating lean and sink.\n     5. *Pancake*: Accelerating parabolic free fall ($k = k_0 - \\Delta k \\cdot u^2$).\n   - Clamp frame delta time $\\Delta t \\le 40\\text{ ms}$ to eliminate visual jumping during tab stutter.\n\n> **Completion Criterion**: GeoJSON source promoted with IDs, MMI damage assigned per building, and feature-state $k$ animating collapse without layer rebuilds.\n\n---\n\n## 4. Three.js WebGL Custom Layer & Instanced Physics\n\nClose-up buildings near the camera must break into physical objects with shared depth occlusion:\n\n1. **Shared Context Custom 3D Layer**:\n   - Register a custom layer with `renderingMode: \"3d\"` to share Mapbox's WebGL depth buffer:\n     ```javascript\n     const mc = mapboxgl.MercatorCoordinate.fromLngLat([origin.lng, origin.lat], 0);\n     const s = mc.meterInMercatorCoordinateUnits();\n     const toMercator = new THREE.Matrix4()\n       .makeTranslation(mc.x, mc.y, mc.z)\n       .scale(new THREE.Vector3(s, -s, s));\n     ```\n   - In `render(gl, matrix)`: multiply projection matrix `camera.projectionMatrix.fromArray(matrix).multiply(toMercator)`. Call `renderer.resetState()` to restore GL bindings.\n2. **Oriented Bounding Box (OBB) Derivation**:\n   - Find the longest polygon footprint edge to define building yaw angle $\\theta_{\\text{yaw}}$.\n   - Project vertices onto the yaw axis and its normal to extract local dimensions $(L_1, L_2)$ and center offset.\n3. **Multi-Block Rigid Body Tipping Physics**:\n   - Partition building into 2–4 stacked boxes in a `THREE.Group` hinged on the bottom edge.\n   - Integrate angular acceleration: $\\theta'' = \\frac{1.5 g}{h} \\sin \\theta$.\n   - Enforce safety clamps: angular velocity $\\le 2.5\\text{ rad\u002Fs}$, angular step $\\le 0.09\\text{ rad\u002Fframe}$.\n   - Detach upper blocks ballistically when lean exceeds critical threshold; clamp detachment velocity to $\\le 18\\text{ m\u002Fs}$.\n4. **Pre-Allocated InstancedMesh Pools**:\n   - Pool 30,000 slabs, 1,500 walls, 20,000 rebar segments, and 9,000 rubble rocks.\n   - Pre-allocate `instanceColor` attribute for full capacity at initialization (`new Float32Array(capacity * 3).fill(1)`). Lazily sizing to count=0 produces all-black instances.\n   - Set `frustumCulled = false` on all custom layer meshes to bypass Three.js camera culling.\n   - Invoke `map.triggerRepaint()` every frame objects move.\n5. **Event-Driven Dust Particle Plumes**:\n   - Do NOT emit constant ambient dust haze. Emit dust puffs strictly on discrete impact events (floor drops, block landings, soft-storey ground-floor jets).\n   - Draw dust in screen space on an overlay canvas: project ground anchor with `map.project()`, scale vertical height by $z \\cdot \\text{scale} \\cdot \\sin(\\text{pitch})$, sort by screen depth, and fade with age.\n\n> **Completion Criterion**: Three.js custom layer rendering tipping multi-block towers, instanced debris landing as permanent rubble, and event-driven dust plumes.\n\n---\n\n## 5. Cinematic Camera Orchestration & Anti-Pattern Defense\n\n1. **Two-Stage Camera Dive**:\n   - Ease from regional overview to zoom 14.6 at $45^\\circ$ pitch.\n   - Pause until `map.areTilesLoaded()` confirms vector tiles have arrived.\n   - Ease into zoom 16.2 at $62^\\circ$ pitch over epicentre. Skipping the hold renders an empty city.\n2. **CSS DOM Container Shake**:\n   - Never jitter the map camera with `easeTo`; camera movement forces continuous tile re-fetching.\n   - Shake the map DOM container with dynamic CSS transform:\n     $$\\text{amp} = \\min(28, W \\cdot 0.02, \\max(6, (M - 4) \\cdot 4.2))$$\n   - Apply envelope ($0.35$ buildup, $0.65$ decay) with rising frequency chirp $\\omega(t) = 7 \\to 46\\text{ rad\u002Fs}$.\n3. **Zero-Fork Configuration Budget**:\n   - Store baseline operational parameters in `config.default.yaml` (max cells, elevation provider, pool sizes, shake durations).\n\n> **Completion Criterion**: Camera dive and CSS container shake execute smoothly, and all 11 field-tested gotchas pass verification.\n\n---\n\n## The Visual Brief\n\nBefore running high-density disaster simulations or scaling instanced object pools:\n1. **Interactive HTML Diagnostic Brief**: Generate a self-contained visual brief at `%TEMP%\\geospatial-disaster-sim-\u003Ctimestamp>.html`.\n2. **Brief Components**:\n   - Web Mercator snapped grid extents overlaid on bounding coordinates.\n   - Decoded elevation profile heightmap and sea mask boundaries.\n   - Seismic attenuation curves (MMI vs distance) and piecewise fragility distribution.\n   - Three.js instanced pool capacity allocation table.\n\n---\n\n## Mandatory Checkpoint Gates\n\nPrevent browser WebGL crashes and runaway particle allocations:\n1. **Scenario Initialization Gate**: Before downloading vector tiles or allocating Three.js pools, evaluate tile and memory budgets against `config.default.yaml`.\n2. **Execution Gate**: When dispatching automated simulation pipelines, emit an `implementation_plan.md` artifact with `RequestFeedback: true` detailing target epicentre, expected collapse counts, and pool capacities before triggering WebGL draw loops.\n\n\n---\n\n## Diagnostic Coaching & Evaluation Scorecard\n\n| Evaluation Dimension | Pass Criterion (100%) | Failure Mode \u002F Trap |\n| :--- | :--- | :--- |\n| **Coordinate Space** | Grid snapped to Web Mercator tile boundaries; cell resolution computed in map metres. | Drawing simulation on a floating screen-space canvas overlay. |\n| **Elevation Decoding** | Terrarium or Terrain-RGB decoded to 1D Float32Array; median filter removes sensor spikes. | Unfiltered synthetic elevations or non-georeferenced terrain. |\n| **Canvas Source Flags** | `animate: true`, `\"raster-resampling\": \"linear\"`, `\"raster-fade-duration\": 0`. | Missing `animate: true` freezes texture on frame 1; default fade smears fluid. |\n| **Feature Scaling** | Dedicated GeoJSON source with `promoteId: \"i\"` driving feature-state `k` multiplier. | Calling `setFeatureState` directly on vector tiles (silent no-op). |\n| **WebGL 3D Context** | `renderingMode: \"3d\"`, shared depth buffer, `frustumCulled = false`, pre-allocated `instanceColor`. | Debris vanishing when panning, or black instances from count=0 buffer. |\n| **Camera Shake** | CSS container transform with buildup\u002Fdecay envelope and frequency chirp. | Shaking map camera directly, triggering tile re-fetch stutter. |\n\n---\n\n## Anti-Patterns\n\n- **Screen-Space Water Overlays** — Drawing ground fluids onto a separate canvas above the map instead of attaching an offscreen canvas as a native map raster source.\n- **Silent Feature-State Vector Calls** — Calling `map.setFeatureState()` directly against Mapbox Streets vector tile sources without copying to a GeoJSON source with `promoteId`.\n- **Zero-Count Instance Color Allocation** — Allowing Three.js to lazily allocate `instanceColor` when `mesh.count === 0`, causing all instanced debris pieces to render black.\n- **Unchecked Camera Frustum Culling** — Leaving `frustumCulled = true` on Three.js custom layer meshes when using a bare camera injected with Mapbox's projection matrix.\n- **Direct Camera Jitter Shaking** — Shaking the map view via rapid camera `easeTo` calls, causing severe tile thrashing and stutter instead of shaking the DOM container.\n- **Missing Trigger Repaint Invariant** — Updating Three.js objects in memory without calling `map.triggerRepaint()`, leaving the screen unrefreshed when the map is stationary.\n- **Sky Layer Depth Occlusion** — Enabling `map.setSky()` alongside a `renderingMode: \"3d\"` custom layer, causing the sky to write to the depth buffer and occlude 3D objects.\n- **Alpha Channel Palette Quantization** — Quantizing sprite PNGs with palette compression, reducing 256 alpha levels to 24 and creating artificial tile-boundary staircasing.\n- **Continuous Ambient Dust Haze** — Spawning continuous ambient dust clouds instead of event-driven bursts tied strictly to structural impact moments.\n- **Bypassing Vector Tile Load Holds** — Diving the camera directly to zoom 16 without waiting for `map.areTilesLoaded()`, causing buildings to fail to spawn.\n","# Geospatial Disaster Simulation: Real-Map Inundation & 3D Building Collapse Engine\n\n`geospatial-disaster-simulation` is the authoritative simulation engineering skill for executing real-world natural disaster scenarios (tsunamis, riverine floods, and seismic structural collapses) on interactive web maps using Mapbox GL JS \u002F MapLibre GL and Three.js.\n\nDistilled from the engineering breakthroughs of **Alex Oliinyk** on [HazardSim](https:\u002F\u002Fhazardsim.com\u002F), this skill eliminates the **\"Sticker Problem\"** (naive screen-space canvas overlays that float, smear, and desynchronize when the camera tilts) by enforcing a strict **Dual-World Coordinate Architecture**:\n1. **Ground Tier**: Tile-aligned canvas raster sources draped directly onto 3D terrain mesh.\n2. **Height Tier**: Shared WebGL 3D context with `promoteId` feature-state extrusion scaling and Three.js instanced physics.\n\nSee [CARD.md](CARD.md) for the companion summary card, 5-stage progression matrix, and invariants checklist.\nConsult [open-source-gis-architect](..\u002Fopen-source-gis-architect\u002FSKILL.md) for raster GIS tooling, [python-dataclass-architect](..\u002Fpython-dataclass-architect\u002FSKILL.md) for slotted domain models, and [epistemic-isnad-audit](..\u002Fepistemic-isnad-audit\u002FSKILL.md) for primary source provenance.\n\n---\n\n## The 5-Stage Simulation Pipeline\n\n```\n[1. Grid Ingestion & Elevation] ──► [2. Ground Fluid Canvas Draping] ──► [3. Footprint Extraction & Feature Scaling]\n                                                                                           │\n                                                                                           ▼\n[5. Camera Choreography & Defense] ◄── [4. 3D WebGL Custom Layer & Instanced Debris] ◄─────┘\n```\n\n---\n\n## 1. Geospatial Grid Ingestion & Tile Alignment\n\nMap simulations must execute in map coordinates, not screen coordinates. Align computational grids directly to Web Mercator tile pyramids to consume external raster and elevation tiles without resampling:\n\n1. **Web Mercator Coordinate Projection**:\n   - Convert geographic bounds $(\\text{lng}, \\text{lat})$ to tile coordinates $(x, y)$ at zoom $z$:\n     $$x = \\frac{\\text{lon} + 180}{360} \\cdot 2^z$$\n     $$y = \\frac{1 - \\ln(\\tan(\\text{rad}) + \\sec(\\text{rad})) \u002F \\pi}{2} \\cdot 2^z$$\n2. **Automated Budgeted Zoom Selection**:\n   - Step zoom $z$ downward from 15 to 8 until bounding box dimensions satisfy operational budgets ($\\le 780\\text{ px}$ width and $\\le 620,000\\text{ cells}$).\n   - Snap bounding box outward to integer tile coordinates $(x_0, y_0) \\to (x_1, y_1)$ to guarantee exact 1-to-1 mapping with downloaded tiles.\n   - Calculate metric cell resolution: $\\text{cellM} = 156543.03392 \\cdot \\cos(\\text{lat}) \u002F 2^z$.\n3. **Dual Elevation Tile Decoding**:\n   - **AWS Terrarium PNGs** (S3 Open Data):\n     $$\\text{elev}_m = R \\cdot 256 + G + \\frac{B}{256} - 32768$$\n   - **Mapbox Terrain-RGB**:\n     $$\\text{elev}_m = -10000 + (R \\cdot 65536 + G \\cdot 256 + B) \\cdot 0.1$$\n   - Ingest into a contiguous 1D `Float32Array`. Run a $3 \\times 3$ median filter across neighbors differing by $> 8\\text{ m}$ to eliminate single-pixel sensor spikes.\n   - Identify sea cells: cells with $\\text{elev} \\le 0$ connected to the grid boundary via continuous water paths.\n\n> **Completion Criterion**: 1D Float32Array elevation grid loaded, snapped to tile boundaries, spikes filtered, and cell resolution established.\n\n---\n\n## 2. Ground-Tier Fluid & Inundation Simulation\n\nGround fluids (tsunami surges, flood inundations, mudflows) must live on the ground surface, allowing automatic terrain draping, foreshortening, and rotation:\n\n1. **Hydraulic Inundation Propagation**:\n   - Execute breadth-first search (BFS) flood progression from source coastlines or rivers across cell elevation gradients.\n   - Store reach timestamp $T_{\\text{reach}}$ and water depth array per grid cell.\n2. **Canvas Raster Source Attachment**:\n   - Register an offscreen `\u003Ccanvas>` with dimensions $W \\times H$ as a Mapbox `canvas` source:\n     ```javascript\n     map.addSource(\"flood\", {\n       type: \"canvas\", canvas: \"floodcanvas\", coordinates: coords, animate: true\n     });\n     map.addLayer({\n       id: \"flood\", type: \"raster\", source: \"flood\",\n       paint: { \"raster-opacity\": 0.94, \"raster-resampling\": \"linear\", \"raster-fade-duration\": 0 }\n     });\n     ```\n   - Mandatory flags: `animate: true` (forces per-frame texture re-upload), `\"raster-resampling\": \"linear\"` (smooth cell interpolation), `\"raster-fade-duration\": 0` (eliminates ghosting).\n3. **Dual-Mask Video Texture Compositing**:\n   - Avoid baking color into video textures; maintain neutral greyscale water footage.\n   - Tint dynamically in a scratch buffer with time-ramped sediment interpolation (`mud` factor: $0 \\to 1$).\n   - Apply `destination-in` with `landMask` (white on land, transparent on open sea) to confine flood color to dry ground.\n   - Composite onto the main flood canvas via `source-atop`, ensuring water texture is clipped strictly to the simulated flood boundary with zero per-pixel iteration.\n4. **Local Seaward Camera Calculation**:\n   - Locate the nearest coastline cell to the city center.\n   - Average directional offsets to sea cells within a $2.5\\text{ km}$ radius to determine true local seaward bearing $\\theta_{\\text{seaward}}$, preventing curved bay distortion.\n\n> **Completion Criterion**: Dynamic canvas raster draped over terrain, compositing video textures within flood masks, and seaward camera vector computed.\n\n---\n\n## 3. Footprint Extraction & Dynamic Feature-State Scaling\n\nEarthquake destruction requires differentiating between distance-based background buildings and foreground hero structures:\n\n1. **Vector Footprint Extraction & GeoJSON Promotion**:\n   - Ingest building footprints from vector tiles via `map.querySourceFeatures()`.\n   - Deduplicate geometries across tile boundaries.\n   - Copy features into a dedicated GeoJSON source configured with `promoteId: \"i\"` (where `i` is an integer index). Calling `map.setFeatureState()` on vector tile features silently fails because vector buildings lack feature IDs.\n2. **Patterned Facade Extrusion Styling**:\n   - Configure dual `fill-extrusion` layers (`bld-walls` and `bld-roof`).\n   - Drive extrusion heights via feature-state multiplier $k$:\n     ```javascript\n     \"fill-extrusion-height\": [\"*\", [\"get\", \"height\"], [\"feature-state\", \"k\"]]\n     ```\n   - Insert building layers below the first `symbol` layer (`map.getStyle().layers`) so labels remain visible above roofs.\n3. **Seismic Attenuation & Piecewise Fragility**:\n   - Compute hypocentral distance: $R = \\sqrt{r_{\\text{km}}^2 + \\text{depth}^2}$ (default depth: $10\\text{ km}$).\n   - Calculate Modified Mercalli Intensity:\n     $$\\text{MMI} = 1.5 M - 3.0 \\log_{10}(R) - 0.0018 R + 1.6$$\n   - Interpolate collapse probability $P_{\\text{collapse}}$ across piecewise fragility curve:\n     `[[6.5, 0], [7, 0.004], [8, 0.025], [9, 0.08], [10, 0.20], [11, 0.38], [12, 0.55]]`.\n   - Scale probability by structural quality factor $q$ (strict=0.2, avg=1.0, poor=3.0) and height factor $h_f$ (mid-rise 15–35m most vulnerable).\n4. **5-Mode Building Collapse Kinematics**:\n   - Modulate $k(u)$ from $1.0$ down to rubble height $k_f$ across 5 distinct modes:\n     1. *Floor-by-Floor*: Staircase drop and pause per floor level.\n     2. *Soft-Storey*: Ground-floor drop, long pause, then rapid collapse.\n     3. *Crushed Top*: Upper third fails early, pauses, then collapses lower sections.\n     4. *Sideways*: Steady accelerating lean and sink.\n     5. *Pancake*: Accelerating parabolic free fall ($k = k_0 - \\Delta k \\cdot u^2$).\n   - Clamp frame delta time $\\Delta t \\le 40\\text{ ms}$ to eliminate visual jumping during tab stutter.\n\n> **Completion Criterion**: GeoJSON source promoted with IDs, MMI damage assigned per building, and feature-state $k$ animating collapse without layer rebuilds.\n\n---\n\n## 4. Three.js WebGL Custom Layer & Instanced Physics\n\nClose-up buildings near the camera must break into physical objects with shared depth occlusion:\n\n1. **Shared Context Custom 3D Layer**:\n   - Register a custom layer with `renderingMode: \"3d\"` to share Mapbox's WebGL depth buffer:\n     ```javascript\n     const mc = mapboxgl.MercatorCoordinate.fromLngLat([origin.lng, origin.lat], 0);\n     const s = mc.meterInMercatorCoordinateUnits();\n     const toMercator = new THREE.Matrix4()\n       .makeTranslation(mc.x, mc.y, mc.z)\n       .scale(new THREE.Vector3(s, -s, s));\n     ```\n   - In `render(gl, matrix)`: multiply projection matrix `camera.projectionMatrix.fromArray(matrix).multiply(toMercator)`. Call `renderer.resetState()` to restore GL bindings.\n2. **Oriented Bounding Box (OBB) Derivation**:\n   - Find the longest polygon footprint edge to define building yaw angle $\\theta_{\\text{yaw}}$.\n   - Project vertices onto the yaw axis and its normal to extract local dimensions $(L_1, L_2)$ and center offset.\n3. **Multi-Block Rigid Body Tipping Physics**:\n   - Partition building into 2–4 stacked boxes in a `THREE.Group` hinged on the bottom edge.\n   - Integrate angular acceleration: $\\theta'' = \\frac{1.5 g}{h} \\sin \\theta$.\n   - Enforce safety clamps: angular velocity $\\le 2.5\\text{ rad\u002Fs}$, angular step $\\le 0.09\\text{ rad\u002Fframe}$.\n   - Detach upper blocks ballistically when lean exceeds critical threshold; clamp detachment velocity to $\\le 18\\text{ m\u002Fs}$.\n4. **Pre-Allocated InstancedMesh Pools**:\n   - Pool 30,000 slabs, 1,500 walls, 20,000 rebar segments, and 9,000 rubble rocks.\n   - Pre-allocate `instanceColor` attribute for full capacity at initialization (`new Float32Array(capacity * 3).fill(1)`). Lazily sizing to count=0 produces all-black instances.\n   - Set `frustumCulled = false` on all custom layer meshes to bypass Three.js camera culling.\n   - Invoke `map.triggerRepaint()` every frame objects move.\n5. **Event-Driven Dust Particle Plumes**:\n   - Do NOT emit constant ambient dust haze. Emit dust puffs strictly on discrete impact events (floor drops, block landings, soft-storey ground-floor jets).\n   - Draw dust in screen space on an overlay canvas: project ground anchor with `map.project()`, scale vertical height by $z \\cdot \\text{scale} \\cdot \\sin(\\text{pitch})$, sort by screen depth, and fade with age.\n\n> **Completion Criterion**: Three.js custom layer rendering tipping multi-block towers, instanced debris landing as permanent rubble, and event-driven dust plumes.\n\n---\n\n## 5. Cinematic Camera Orchestration & Anti-Pattern Defense\n\n1. **Two-Stage Camera Dive**:\n   - Ease from regional overview to zoom 14.6 at $45^\\circ$ pitch.\n   - Pause until `map.areTilesLoaded()` confirms vector tiles have arrived.\n   - Ease into zoom 16.2 at $62^\\circ$ pitch over epicentre. Skipping the hold renders an empty city.\n2. **CSS DOM Container Shake**:\n   - Never jitter the map camera with `easeTo`; camera movement forces continuous tile re-fetching.\n   - Shake the map DOM container with dynamic CSS transform:\n     $$\\text{amp} = \\min(28, W \\cdot 0.02, \\max(6, (M - 4) \\cdot 4.2))$$\n   - Apply envelope ($0.35$ buildup, $0.65$ decay) with rising frequency chirp $\\omega(t) = 7 \\to 46\\text{ rad\u002Fs}$.\n3. **Zero-Fork Configuration Budget**:\n   - Store baseline operational parameters in `config.default.yaml` (max cells, elevation provider, pool sizes, shake durations).\n\n> **Completion Criterion**: Camera dive and CSS container shake execute smoothly, and all 11 field-tested gotchas pass verification.\n\n---\n\n## The Visual Brief\n\nBefore running high-density disaster simulations or scaling instanced object pools:\n1. **Interactive HTML Diagnostic Brief**: Generate a self-contained visual brief at `%TEMP%\\geospatial-disaster-sim-\u003Ctimestamp>.html`.\n2. **Brief Components**:\n   - Web Mercator snapped grid extents overlaid on bounding coordinates.\n   - Decoded elevation profile heightmap and sea mask boundaries.\n   - Seismic attenuation curves (MMI vs distance) and piecewise fragility distribution.\n   - Three.js instanced pool capacity allocation table.\n\n---\n\n## Mandatory Checkpoint Gates\n\nPrevent browser WebGL crashes and runaway particle allocations:\n1. **Scenario Initialization Gate**: Before downloading vector tiles or allocating Three.js pools, evaluate tile and memory budgets against `config.default.yaml`.\n2. **Execution Gate**: When dispatching automated simulation pipelines, emit an `implementation_plan.md` artifact with `RequestFeedback: true` detailing target epicentre, expected collapse counts, and pool capacities before triggering WebGL draw loops.\n\n\n---\n\n## Diagnostic Coaching & Evaluation Scorecard\n\n| Evaluation Dimension | Pass Criterion (100%) | Failure Mode \u002F Trap |\n| :--- | :--- | :--- |\n| **Coordinate Space** | Grid snapped to Web Mercator tile boundaries; cell resolution computed in map metres. | Drawing simulation on a floating screen-space canvas overlay. |\n| **Elevation Decoding** | Terrarium or Terrain-RGB decoded to 1D Float32Array; median filter removes sensor spikes. | Unfiltered synthetic elevations or non-georeferenced terrain. |\n| **Canvas Source Flags** | `animate: true`, `\"raster-resampling\": \"linear\"`, `\"raster-fade-duration\": 0`. | Missing `animate: true` freezes texture on frame 1; default fade smears fluid. |\n| **Feature Scaling** | Dedicated GeoJSON source with `promoteId: \"i\"` driving feature-state `k` multiplier. | Calling `setFeatureState` directly on vector tiles (silent no-op). |\n| **WebGL 3D Context** | `renderingMode: \"3d\"`, shared depth buffer, `frustumCulled = false`, pre-allocated `instanceColor`. | Debris vanishing when panning, or black instances from count=0 buffer. |\n| **Camera Shake** | CSS container transform with buildup\u002Fdecay envelope and frequency chirp. | Shaking map camera directly, triggering tile re-fetch stutter. |\n\n---\n\n## Anti-Patterns\n\n- **Screen-Space Water Overlays** — Drawing ground fluids onto a separate canvas above the map instead of attaching an offscreen canvas as a native map raster source.\n- **Silent Feature-State Vector Calls** — Calling `map.setFeatureState()` directly against Mapbox Streets vector tile sources without copying to a GeoJSON source with `promoteId`.\n- **Zero-Count Instance Color Allocation** — Allowing Three.js to lazily allocate `instanceColor` when `mesh.count === 0`, causing all instanced debris pieces to render black.\n- **Unchecked Camera Frustum Culling** — Leaving `frustumCulled = true` on Three.js custom layer meshes when using a bare camera injected with Mapbox's projection matrix.\n- **Direct Camera Jitter Shaking** — Shaking the map view via rapid camera `easeTo` calls, causing severe tile thrashing and stutter instead of shaking the DOM container.\n- **Missing Trigger Repaint Invariant** — Updating Three.js objects in memory without calling `map.triggerRepaint()`, leaving the screen unrefreshed when the map is stationary.\n- **Sky Layer Depth Occlusion** — Enabling `map.setSky()` alongside a `renderingMode: \"3d\"` custom layer, causing the sky to write to the depth buffer and occlude 3D objects.\n- **Alpha Channel Palette Quantization** — Quantizing sprite PNGs with palette compression, reducing 256 alpha levels to 24 and creating artificial tile-boundary staircasing.\n- **Continuous Ambient Dust Haze** — Spawning continuous ambient dust clouds instead of event-driven bursts tied strictly to structural impact moments.\n- **Bypassing Vector Tile Load Holds** — Diving the camera directly to zoom 16 without waiting for `map.areTilesLoaded()`, causing buildings to fail to spawn.\n",{"name":5,"description":7},"main","eff3b00e36d1d233ad4a4389605c82fbfa0326d3",".agents\u002Fskills\u002Fgeospatial-disaster-simulation","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness","https:\u002F\u002Fgithub.com\u002FSpectreDeath","I'm here to manage stress so I wouldn't expect earth shattering break throughs I'm just an enthusiast that likes making stuff. ","2026-11-15 05:32:58",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add SpectreDeath\u002FBrain-Harness --skill geospatial-disaster-simulation",{"tool":37,"command":38},"bunx","bunx skills add SpectreDeath\u002FBrain-Harness --skill geospatial-disaster-simulation",{"tool":40,"command":41},"pnpm","pnpm dlx skills add SpectreDeath\u002FBrain-Harness --skill geospatial-disaster-simulation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgeospatial-disaster-simulation\u002FSKILL.md",true,[45,51,55],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"CARD.md","REFERENCE","参考文档",4925,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgeospatial-disaster-simulation\u002FCARD.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"config.default.yaml",1174,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgeospatial-disaster-simulation\u002Fconfig.default.yaml",{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"scripts\u002Fdisaster_sim_engine.py","SCRIPT","脚本",23611,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgeospatial-disaster-simulation\u002Fscripts\u002Fdisaster_sim_engine.py",[62,69,76,83,90,97],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7E0W6FR68J2N9CXCZTAQJFX","ui-behavior-primitive-architect","Architect, audit, and verify zero-dependency headless UI behavior primitives, WebMCP agent bridges, WAI-ARIA\u002FSSR\u002FRTL tri-modal checks, and framework expert routing. Do not use for static CSS theme styling or backend database migrations.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fui-behavior-primitive-architect\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7E0VZ7JQNW34G271DENFGYP","trustgraph-ontology-governor","Govern knowledge graphs, SHACL-AF triple policies, OntologyRAG subclass validation, PROV-O dual named graphs, and Laya entropy decision scoring. Do not use for relational SQL queries or generic web scraping.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftrustgraph-ontology-governor\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7E0VQ6Z7R45Q8QAZ4MT39EK","shim-harness-governor","Govern universal CLI agent loops, 4-tier tool permissions, ancestor-symlink workspace sandboxes, deterministic-first command routing, collision-safe MCP namespacing, and layered skill loading. Do not use for static UI styling or external SQL analytics.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fshim-harness-governor\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7E0VC18NMP1QBSRJ3TPQ7MB","graphiti-zep-memory-governor","Govern bi-temporal knowledge graphs with Graphiti future-edge clamping, MinHash\u002FLSH entity dedup, RRF\u002FMMR reranking, and Zep typed ontologies. Do not use for static SQL joins or generic web crawling.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgraphiti-zep-memory-governor\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7E0V12ABE1RW3ZRCST8VH5Z","agora-mcp-workbench-architect","Architect, audit, and orchestrate Agora Workbench MCP servers, loopback sidecars, unified state graphs, gateway\u002Fdispatcher connectors, and policy-enforced data lakes. Do not use for static frontend CSS styling or non-MCP desktop GUI automation.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fagora-mcp-workbench-architect\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M7BFYG6QT3484VC57TZ19V7P","skill-eval-assurance-runner","Evaluate and assure agent skills using small-N Wilson confidence intervals, unbiased pass^k reliability, deterministic trajectory graders, preflight boundary honesty, and sealed digest verification. Do not use for subjective prose review or unconstrained production deployment.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fskill-eval-assurance-runner\u002FSKILL.md",[],[]]