Skip to main content

Overview

The BuildingNode represents a building structure within a site. It defines the building’s position and rotation in the site coordinate system and contains references to level nodes. Key features:
  • Positioned and rotated within the site
  • Contains multiple levels (floors)
  • Each level contains walls, slabs, zones, and other elements

Type Signature

import { z } from 'zod'
import { BaseNode, nodeType, objectId } from '../base'
import { LevelNode } from './level'

const BuildingNode = BaseNode.extend({
  id: objectId('building'),
  type: nodeType('building'),
  children: z.array(LevelNode.shape.id).default([]),
  position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
  rotation: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
})

type BuildingNode = z.infer<typeof BuildingNode>
Source: /home/daytona/workspace/source/packages/core/src/schema/nodes/building.ts

Fields

Inherited from BaseNode

id
string
required
Unique building identifier.Format: building_{randomString}Example: "building_x9y8z7w6v5u4t3s2"
type
string
required
Always set to "building".Default: "building"
name
string
Optional name for the building.Example: "North Tower", "Main Building"
parentId
string | null
required
Reference to the parent site’s ID.Example: "site_abc123"Default: null
visible
boolean
Controls building visibility.Default: true
camera
CameraSchema
Optional camera viewpoint for the building.
metadata
any
Custom metadata for the building.Default: {}

Building-Specific Fields

position
[number, number, number]
required
Position of the building in the site coordinate system.Format: [x, y, z] in metersDefault: [0, 0, 0]Example: [10.5, 0, -5.2]The position is typically set with y=0 (ground level), with x and z defining the horizontal placement within the site.
rotation
[number, number, number]
required
Rotation of the building in the site coordinate system.Format: [x, y, z] in radians (Euler angles)Default: [0, 0, 0]Example: [0, Math.PI / 4, 0] (45-degree rotation around Y axis)Most commonly, only the Y rotation is used to orient the building on the site.
children
Array<string>
required
Array of level node IDs belonging to this building.Default: []Example: ["level_aaa111", "level_bbb222", "level_ccc333"]Each level ID references a LevelNode that contains the walls, slabs, and zones for that floor.

Example

import { BuildingNode } from '@pascal/core/schema/nodes/building'

const building: BuildingNode = {
  object: 'node',
  id: 'building_xyz789',
  type: 'building',
  name: 'East Wing',
  parentId: 'site_abc123',
  visible: true,
  position: [15, 0, -10],
  rotation: [0, Math.PI / 6, 0], // 30-degree rotation
  children: [
    'level_ground_floor',
    'level_first_floor',
    'level_second_floor',
  ],
  metadata: {
    buildingType: 'residential',
    floors: 3,
  },
}

Usage

Creating a Building

import { BuildingNode } from '@pascal/core/schema/nodes/building'

// Parse with defaults
const building = BuildingNode.parse({
  name: 'Main Building',
})
// Result: Building at origin [0,0,0] with no rotation

Positioning a Building

const building = BuildingNode.parse({
  name: 'North Building',
  position: [20, 0, -15],
  rotation: [0, Math.PI / 2, 0], // 90-degree rotation
})

Adding Levels

import { LevelNode } from '@pascal/core/schema/nodes/level'
import { generateId } from '@pascal/core/schema/base'

// Create level nodes
const groundFloor = LevelNode.parse({
  name: 'Ground Floor',
  level: 0,
})

const firstFloor = LevelNode.parse({
  name: 'First Floor',
  level: 1,
})

// Reference them in the building
const building = BuildingNode.parse({
  name: 'Two-Story Building',
  children: [groundFloor.id, firstFloor.id],
})

Coordinate System

The building defines its own local coordinate system:
  • Origin is at the building’s position
  • Axes are rotated according to the rotation field
  • Child levels use this coordinate system for their elements
Site Coordinate System

  └─ Building Position + Rotation

       └─ Building Local Coordinate System

            └─ Level Elements (walls, slabs, etc.)

Hierarchy

SiteNode
└── BuildingNode
    ├── LevelNode (Ground Floor)
    │   ├── WallNode
    │   ├── SlabNode
    │   └── ZoneNode
    ├── LevelNode (First Floor)
    │   ├── WallNode
    │   └── SlabNode
    └── LevelNode (Second Floor)
        └── ...

Build docs developers (and LLMs) love