Understanding Node Creation
All nodes are created usinguseScene.getState().createNode(). Each node type has its own schema definition that validates the data structure.
Nodes automatically appear in the 3D scene when created. The SDK handles registering them in the scene graph and making them visible.
Creating Nodes Step-by-Step
1
Import the required schemas
First, import the node schemas and the scene store:
2
Get the parent ID
Most nodes need a parent. Typically, walls, slabs, zones, and items are children of a Level:
3
Create the node data
Use the schema’s
.parse() method to validate and create the node:4
Add the node to the scene
Call The node will immediately appear in the 3D scene and be registered in the scene graph.
createNode() with the node data and parent ID:Parent-Child Relationships
Nodes form a hierarchy through theparentId property. Understanding this structure is crucial:
Wall-Attached Items
Items can attach to walls using theattachTo property:
For wall-attached items:
position[0]is the distance from the wall start pointposition[1]is the height from the floor- The item will snap to the specified wall side
Batch Node Creation
Create multiple nodes efficiently usingcreateNodes():
Node Visibility
All nodes have avisible property that controls their visibility in the 3D scene:
Common Patterns
Creating a Room with Furniture
Next Steps
Event Handling
Learn how to respond to user interactions with nodes
Spatial Queries
Validate placement and perform collision detection