Skip to main content

Overview

The scene management system provides a way to organize multiple geometry entities, manage their lifecycle, and apply operations to entire collections. The OGScene class represents a collection of geometry entities, while OGSceneManager provides high-level scene operations.

OGScene

Structure

A scene is a named collection of geometry entities, each with a unique ID and associated BRep representation.

Creating a Scene

Creates a new empty scene with a generated UUID. Example:

Managing Entities

upsert_entity

Inserts or updates an entity in the scene. If an entity with the same ID exists, it will be replaced; otherwise, the entity is added. Example:

remove_entity

Removes an entity from the scene by ID. Returns true if the entity was found and removed. Example:

Projection

project_to_2d

Projects all entities in the scene to 2D using the specified camera parameters and hidden line removal options. Example:

SceneEntity

Structure

Each entity in a scene has:
  • id: Unique identifier for the entity
  • kind: Type descriptor (e.g., “OGCuboid”, “OGSphere”)
  • brep: The boundary representation of the geometry

OGSceneManager

The scene manager provides a high-level API for managing multiple scenes and adding various geometry types.

Scene Operations

createScene

Creates a new scene and sets it as the current scene.

removeScene

Removes a scene by ID. If it was the current scene, another scene becomes current.

setCurrentScene

Sets the active scene for operations that don’t specify a scene ID.

listScenes

Returns a JSON array of scene summaries containing ID, name, and entity count.

Adding Entities

The manager provides methods to add various geometry types to scenes:

Complete Example: Multi-Entity Scene

Scene Summary

Provides lightweight metadata about a scene without loading all geometry data.

Best Practices

Entity IDs

  • Use descriptive IDs that indicate purpose: "wall-north", "column-A1"
  • Keep IDs unique within a scene
  • Use consistent naming conventions for entity groups

Performance

  • Scenes can contain thousands of entities efficiently
  • Use upsert_entity for batch updates without removing/re-adding
  • Remove entities when no longer needed to reduce memory

Scene Organization

Live Demo

Scene Management Demo

Try Scene Management in the browser
Last modified on March 14, 2026