Understanding the Event System
Events in Pascal Editor follow a predictable pattern:- Event names combine the node type with an action:
wall:click,item:enter,grid:move - Event data includes the node, position, and native Three.js event
- Event propagation can be stopped to prevent parent handlers from firing
All events are typed, providing autocomplete and type safety when subscribing to events.
Available Events
Every node type supports these interaction events:click- User clicked on the objectdouble-click- User double-clicked on the objectmove- Mouse moved over the objectenter- Mouse entered the object boundsleave- Mouse left the object boundspointerdown- Mouse button pressed on the objectpointerup- Mouse button released on the objectcontext-menu- Right-click on the object
Event Types by Node
Subscribing to Events
1
Import the event emitter
2
Subscribe to an event
Use
emitter.on() to listen for events:3
Clean up subscriptions
Always unsubscribe when your component unmounts:
Event Data Structure
Each event provides rich contextual information:NodeEvent Structure
GridEvent Structure
Common Event Patterns
Selecting Items on Click
Hover Highlighting
Context Menu on Right-Click
Grid Click for Placement
Stopping Event Propagation
UsestopPropagation() to prevent events from bubbling up:
Event-Driven Tool Architecture
Build interactive tools using event subscriptions:Camera Control Events
Control the camera programmatically:Typed Event Handlers
TypeScript provides full type safety for event handlers:Best Practices
Always Unsubscribe
Use stopPropagation Wisely
Debounce High-Frequency Events
Next Steps
Creating Nodes
Learn how to create nodes in response to events
Custom Systems
Build systems that react to events