Skip to main content
The Pascal Editor SDK provides a comprehensive event system for handling user interactions with 3D objects. Events are emitted through a centralized event bus, making it easy to build interactive tools and features.

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 object
  • double-click - User double-clicked on the object
  • move - Mouse moved over the object
  • enter - Mouse entered the object bounds
  • leave - Mouse left the object bounds
  • pointerdown - Mouse button pressed on the object
  • pointerup - Mouse button released on the object
  • context-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

Use stopPropagation() to prevent events from bubbling up:
Always call stopPropagation() when handling object-specific events to prevent unintended grid interactions.

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

Failing to unsubscribe causes memory leaks and duplicate event handlers.

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