Skip to main content
This guide will help you create a working 3D building editor with Pascal Editor. You’ll learn how to set up the viewer, create nodes, and interact with the scene.

Prerequisites

Make sure you’ve completed the installation steps and have both @pascal-app/core and @pascal-app/viewer installed.

Create your first scene

1

Set up the Viewer component

The Viewer component provides a complete 3D rendering environment with WebGPU, camera controls, lighting, and systems. It fills its parent container, so make sure to set width and height.
App.tsx
When you run this, you’ll see an empty 3D scene with a default Site → Building → Level hierarchy. The camera can be controlled with mouse drag (orbit) and scroll (zoom).
2

Create a wall

Let’s add a wall to the scene. We’ll use the useScene store to create nodes and the WallNode schema to validate our data.
App.tsx
You should now see a 3D wall rendered in the scene! The wall is 5 meters long, 0.15 meters thick, and 3 meters high.
The WallSystem automatically generates geometry for the wall based on the start/end points, thickness, and height. The geometry is created in the render loop after the node is marked dirty.
3

Add multiple walls to create a room

Let’s create a simple rectangular room by adding four walls:
App.tsx
You now have a complete room with four walls! Notice how the walls automatically miter at the corners - this is handled by the WallSystem.
4

Add a floor slab

Let’s add a floor to our room using a SlabNode:
App.tsx
Your room now has a floor! The SlabSystem generates geometry from the polygon points.
5

Update nodes reactively

Pascal Editor’s state management is reactive. Let’s add a button to change wall height:
App.tsx
Click the button and watch the walls grow! The WallSystem automatically regenerates geometry when nodes are updated.
Changes to nodes are automatically persisted to IndexedDB. Refresh the page and your scene will be restored. Use Cmd+Z / Ctrl+Z to undo changes (50-step history).

Understanding the code

Node creation pattern

All nodes follow this pattern:
  1. Parse with schema - WallNode.parse({ ... }) validates the data and generates an ID
  2. Create in store - scene.createNode(node, parentId) adds it to the scene
  3. System generates geometry - WallSystem detects the dirty node and creates Three.js geometry

Accessing state

There are two ways to access state: In React components (subscribes to changes):
Outside React (callbacks, systems):

Scene hierarchy

Nodes are stored flat but organized hierarchically:
This flat structure enables O(1) lookups while maintaining parent-child relationships.

Next steps

Core concepts

Deep dive into nodes, systems, and state management

Node types

Explore all available node types and their properties

Event handling

Learn how to handle user interactions with the event bus

Custom systems

Build your own geometry systems

Common patterns

Finding nodes by type

Listening to node events

Changing viewer settings

Batch node updates

Batch operations are more efficient than individual updates as they trigger a single state update.