Pascal 에디터 통합은(는) 무엇을 하나요?
개요
Pascal 에디터 (pascalorg/editor)는 React Three Fiber와 WebGPU로 구축된 오픈소스 3D 건물 에디터입니다. 노드 기반 씬 그래프, Zustand 상태 관리, 그리고 AI 기반 건축 생성에 이상적인 시스템 아키텍처를 제공합니다. 이 스킬은 건축 지오메트리를 생성, 조작 및 내보내기 위한 핵심 API를 다룹니다.
지침
빠른 시작
npx create-next-app@latest my-building-app
cd my-building-app
npm install @pascal-app/core @pascal-app/ui @react-three/fiber @react-three/drei three zustand
노드 계층 구조
Pascal은 타입이 지정된 노드 트리를 사용합니다:
사이트(Site) -> 건물(Building) -> 레벨(Level) -> 벽(Wall) -> 개구부(Opening) (문/창)
-> 슬래브(Slab) (바닥/천장)
-> 존(Zone) (방 경계)
-> 아이템(Item) (가구, 설비)
모든 노드는 다음을 가집니다: id (UUID), type, parentId, children (자식 ID 목록), props (타입별 속성), dirty (재구축 표시).
Zustand 스토어
import { useScene, useViewer, useEditor } from '@pascal-app/core'
// useScene -- 씬 그래프 (노드, 관계)
const { nodes, createNode, updateNode, deleteNode } = useScene()
// useViewer -- 뷰포트 상태 (카메라, 선택)
const { selectedIds, camera, setSelection } = useViewer()
// useEditor -- 도구 모드 및 UI 상태
const { activeTool, setTool, history } = useEditor()
개구부가 있는 벽 생성
const scene = useScene.getState()
// 외벽: 길이 4.5m, 두께 200mm, 천장 높이 2.7m
const wall = await scene.createNode({
type: 'wall',
props: {
start: { x: 0, y: 0 }, end: { x: 4.5, y: 0 },
thickness: 0.20, height: 2.7,
isExterior: true, material: 'masonry',
}
}, levelId)
// 창문 추가: 너비 1.2m, 창대 높이 900mm
await scene.createNode({
type: 'item',
props: {
itemType: 'window', wallId: wall.id,
offsetFromStart: 1.5, width: 1.2, height: 1.2, sillHeight: 0.9,
}
}, wall.id)
// 문 추가: 너비 900mm
await scene.createNode({
type: 'item',
props: {
itemType: 'door', wallId: wall.id,
offsetFromStart: 3.0, width: 0.9, height: 2.1, sillHeight: 0,
}
}, wall.id)
레벨 및 방 생성
const level = await scene.createNode({
type: 'level',
props: { name: '1층', elevation: 0, height: 2.7, index: 0 }
}, buildingId)
// 바닥 슬래브
await scene.createNode({
type: 'slab',
props: {
polygon: [{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 10, y: 8 }, { x: 0, y: 8 }],
thickness: 0.25, isRoof: false,
}
}, level.id)
// 라벨링 및 면적 계산을 위한 방 존
await scene.createNode({
type: 'zone',
props: {
name: '거실', roomType: 'living',
polygon: [{ x: 0.1, y: 0.1 }, { x: 5.4, y: 0.1 }, { x: 5.4, y: 7.9 }, { x: 0.1, y: 7.9 }],
}
}, level.id)
씬을 JSON으로 내보내기
function exportScene(): BuildingExport {
const { nodes } = useScene.getState()
const allNodes = Object.values(nodes)
const site = allNodes.find(n => n.type === 'site')
const building = allNodes.find(n => n.type === 'building')
const levels = allNodes
.filter(n => n.type === 'level' && n.parentId === building.id)
.sort((a, b) => a.props.elevation - b.props.elevation)
return {
units: 'meters',
site: { width: site.props.width, depth: site.props.depth },
building: {
levels: levels.map(level => ({
name: level.props.name,
elevation: level.props.elevation,
height: level.props.height,
walls: getChildrenByType(level.id, 'wall', allNodes),
rooms: getChildrenByType(level.id, 'zone', allNodes),
}))
}
}
}
React Three Fiber로 렌더링
import { Canvas } from '@react-three/fiber'
import { PascalScene, PascalCamera, PascalControls } from '@pascal-app/ui'
export function BuildingViewer() {
return (
<Canvas camera={{ position: [0, 20, 20], fov: 45 }}>
<PascalScene />
<PascalCamera />
<PascalControls />
<ambientLight intensity={0.5} />
<directionalLight position={[10, 20, 10]} castShadow />
</Canvas>
)
}
그리드 스냅
Pascal은 기본적으로 100mm(0.1m) 그리드를 사용합니다:
const snapToGrid = (value: number, gridSize = 0.1) =>
Math.round(value / gridSize) * gridSize
예제
예제 1: 10m x 8m 1층 건물 구축
외벽, 거실과 침실을 구분하는 내부 칸막이, 적절한 개구부를 갖춘 완전한 1층을 생성합니다:
- elevation 0, 높이 2.7m의 레벨 노드 생성
- 바닥 슬래브 생성: 10m x 8m 다각형, 두께 0.25m
- 4개의 외벽 생성 (두께 0.20m, 석재): 북쪽(10m), 동쪽(8m), 남쪽(10m), 서쪽(8m)
- x=5.5 위치에 내부 칸막이 추가 (두께 0.10m, 목재), 전체 깊이
- 북쪽 벽에 출입문 추가: 1.0m x 2.1m, 오프셋 3.5m
- 동쪽 벽에 창문 추가: 1.2m x 1.2m 창문 2개, 창대 높이 0.9m, 오프셋 1.2m 및 4.5m
- 존 생성: 거실(5.3m x 7.8m = 41.3m2), 침실 영역(4.3m x 7.8m = 33.5m2)
architectural-dimensions규칙에 대한 검증을 위해 JSON으로 내보내기
예제 2: 사용자 정의 검증 시스템 등록
벽 노드가 변경될 때마다 벽 두께를 확인하는 시스템을 생성합니다:
import { registerSystem, useScene } from '@pascal-app/core'
registerSystem({
name: 'wall-validator',
nodeTypes: ['wall'],
priority: 100,
process(dirtyNodes) {
for (const node of dirtyNodes) {
const { thickness, isExterior, height } = node.props
if (isExterior && thickness < 0.14)
console.warn(`벽 ${node.id}: 외벽 두께 ${thickness}m가 최소 0.14m 미만`)
if (height < 2.1)
console.warn(`벽 ${node.id}: 높이 ${height}m가 최소 2.1m 미만`)
}
}
})
이 시스템은 벽 노드가 더티(dirty)로 표시될 때마다, 지오메트리 시스템이 메시를 재구축하기 전에 자동으로 실행됩니다.
지침
- 모든 치수는 미터 단위입니다 -- Pascal은 내부적으로 미터법을 사용합니다
- 모든 노드 CRUD 작업에는
useScene, 선택/카메라에는useViewer, 도구에는useEditor를 사용하세요 - 깔끔한 지오메트리를 위해 좌표를 0.1m 그리드에 스냅하세요
- 벽 두께: 외벽 0.20m, 내부 칸막이 0.10m
- 문 창대 높이는 항상 0입니다 (바닥 레벨); 창문 창대 높이는 기본값 0.9m
- 지오메트리 재구축(0-50) 전에 실행하려면 우선순위 > 50으로 사용자 정의 시스템을 등록하세요
- 실제 측정값 검증을 위해
architectural-dimensions스킬과 결합하세요 - 주요 패키지:
@pascal-app/core,@pascal-app/ui,@react-three/fiber,three,zustand - GitHub: github.com/pascalorg/editor