home / skills / bbeierle12 / skill-mcp-claude / terrain-integration
This skill helps you integrate terrain-aware foundations and slope handling in Three.js builds, auto-leveling and pillar generation for stable ground contact.
npx playbooks add skill bbeierle12/skill-mcp-claude --skill terrain-integrationReview the files below or copy the command above to add this skill to your agents.
---
name: terrain-integration
description: Terrain interaction systems for Three.js building games. Use when implementing slope handling, foundation anchoring (Valheim pattern), terrain modification, auto-leveling, or pillar/support generation. Integrates with structural-physics for ground-based stability.
---
# Terrain Integration
Foundation placement, slope handling, and terrain modification for building systems.
## Quick Start
```javascript
import { TerrainAnalyzer } from './scripts/terrain-analyzer.js';
import { FoundationPlacer } from './scripts/foundation-placer.js';
// Analyze terrain at build location
const analyzer = new TerrainAnalyzer(terrainMesh);
const slopeData = analyzer.analyzeSlope(position, { radius: 4 });
// slopeData: { angle: 15, normal: Vector3, canBuild: true }
// Place foundation with auto-leveling
const placer = new FoundationPlacer({
mode: 'valheim', // or 'rust', 'ark'
maxSlope: 30,
autoLevel: true
});
const result = placer.place(foundationPiece, position, analyzer);
// result: { valid: true, height: 2.3, pillarsNeeded: 2 }
```
## Reference
See `references/terrain-integration-advanced.md` for:
- Slope analysis algorithms and thresholds
- Foundation anchoring patterns (Valheim ground contact rule)
- Auto-leveling strategies
- Terrain modification networking
- Pillar generation for uneven terrain
## Scripts
- `scripts/terrain-analyzer.js` - Slope detection, buildability checks, terrain sampling
- `scripts/foundation-placer.js` - Foundation placement with Valheim/Rust/ARK modes
- `scripts/terrain-modifier.js` - Flatten, raise, lower terrain operations
- `scripts/pillar-generator.js` - Auto-generate support pillars for slopes
## Foundation Modes
- **Valheim**: Ground contact = 100% stability, foundations must touch terrain
- **Rust**: Foundations snap to grid, terrain ignored after placement
- **ARK**: Flexible placement with auto-pillars, moderate slope tolerance
## Integration
Works with `structural-physics` for stability calculations. Grounded foundations feed into the support graph as root nodes with maximum stability.
```javascript
// Integration example
const grounded = placer.place(foundation, pos, analyzer);
if (grounded.valid) {
foundation.isGrounded = true;
foundation.stability = 1.0; // Feed to structural-physics
validator.addPiece(foundation);
}
```
This skill provides terrain interaction systems for Three.js building games, handling slope detection, foundation anchoring, terrain modification, auto-leveling, and pillar/support generation. It integrates with structural-physics to feed grounded foundations into stability calculations and supports multiple foundation placement modes inspired by common survival builders.
The system analyzes terrain samples and normals around a placement point to compute slope, buildability, and ideal contact height. A foundation placer applies placement rules (Valheim/Rust/ARK styles), performs auto-leveling, and decides if pillars or terrain edits are required. Generated grounding information can be passed into structural-physics as root stability inputs.
How does Valheim-style grounding differ from Rust or ARK modes?
Valheim mode requires full ground contact for maximum stability; Rust enforces grid snaps and ignores terrain after placement; ARK balances placement flexibility with auto-pillars and moderate slope tolerance.
Can this system modify terrain at runtime?
Yes—terrain modifier operations include flatten, raise, and lower, but modifications should be coordinated through authoritative networking to keep clients consistent.