Understanding the game world structure, grid-based building system, NPC definitions, and spatial organization. Use when working with maps, buildings, spawns, or world layout.
Babylon FP uses a grid-based world system where buildings, NPCs, and spawns are placed on a precise coordinate grid. The world is designed in a top-down 2D grid that translates to 3D space in Babylon.js.
// Grid coordinates (2D editor view)
gridX: number // Horizontal position (0-99 default)
gridY: number // Vertical position (0-99 default)
// World coordinates (3D game space)
worldX: number // X position in 3D (gridX - gridSize/2)
worldZ: number // Z position in 3D (gridY - gridSize/2)
worldY: number // Height (usually 0 for ground level)
// Conversion formulas
worldX = (gridX - gridSize / 2) * CELL_SIZE
worldZ = (gridY - gridSize / 2) * CELL_SIZE
GRID_CELL_SIZE = 1.0 // Each cell = 1 unit in world space
DEFAULT_GRID_SIZE = 100 // 100x100 grid
WORLD_SIZE = 100 // 100x100 units in 3D space
Grid (50, 50) = World (0, 0, 0)
Grid origin (0, 0) = World (-50, 0, -50)
Grid max (99, 99) = World (49, 0, 49)
type: "wall")Properties:
Placement:
{
"type": "wall",
"position": {"x": 10, "y": 0, "z": 5},
"gridPosition": {"x": 60, "y": 55},
"rotation": 0
}
type: "floor")Properties:
Purpose: Define walkable areas, rooms, paths
type: "door")Properties:
Door System (src/systems/doorSystem.ts):
- Proximity detection (1.5 unit range)
- Automatic open when player approaches
- Smooth animation (pivot rotation)
- Collision updates (passable when open)
type: "window")Properties:
Purpose: Visual detail, natural light, line of sight
type: "player-spawn")Properties:
Default Spawn: Center of map (gridX: 50, gridY: 50)
type: "npc-spawn")Properties:
npcId propertyschedule propertyNPC Colors: