MLightCAD
    Preparing search index...

    Three.js scene manager for CAD drawings with hierarchical organization.

    The scene manages the complete visual representation of a CAD drawing using a hierarchical structure that mirrors CAD data organization:

    Scene
    └── Layout (AcTrLayout) - Paper space or model space
    └── Layer (AcTrLayer) - Drawing layers for organization
    └── Entity (AcTrEntity) - Individual CAD entities (lines, arcs, etc.)
    • Layout Management: Handles multiple layouts (model space and paper spaces)
    • Layer Organization: Manages layer visibility and entity grouping
    • Entity Rendering: Provides access to all renderable CAD entities
    • Spatial Queries: Calculates bounding boxes and spatial relationships
    • Three.js Integration: Maintains the underlying Three.js scene

    The scene automatically manages the active layout and provides efficient access to entities for rendering, selection, and spatial operations.

    const scene = new AcTrScene();

    // Set up model space
    scene.modelSpaceBtrId = modelSpaceId;

    // Add entities to layers
    const entity = new AcTrLine(...);
    scene.addEntity(entity, layerName);

    // Get all visible entities for rendering
    const entities = scene.getAllEntities();

    // Get scene bounds for zoom operations
    const bounds = scene.box;
    Index

    Constructors

    Accessors

    Methods

    • Add one empty layout with the specified block table record id as the its key.

      This method is idempotent: when a layout already exists for the given ownerId, the existing instance is returned untouched and no new THREE group is attached to the scene. Re-creating eagerly would leak the previous AcTrLayout.internalObject as an orphan child of _scene (still rendered every frame and still indexed by ray/spatial queries), which manifested as "ghost" entities from previously-visited layouts accumulating on layout switches.

      Parameters

      • ownerId: string

        Input the block table record id associated with this layout

      Returns AcTrLayout

      Return the layout associated with ownerId — newly created when absent, or the pre-existing instance when already registered.

    • Add one persistent entity (stored in the drawing database) into this scene. If the layout associated with this entity doesn't exist, then create one layout, add this layout into this scene, and add the entity into the layout.

      Parameters

      • entity: AcTrEntity

        Input AutoCAD entity to be added into scene.

      • extendBbox: boolean = true

        Input the flag whether to extend the bounding box of this scene by union the bounding box of the specified entity.

      Returns AcTrScene

      Return this scene

    • Hover the specified entities. Propagates the request to every layout in the scene, not just the active one — entities picked through a paper-space viewport (drill-through) live in the model layout while the active layout at pick time is paper, so the hover/select state must reach both. Layouts that don't own the given entity ids no-op gracefully (getLayersByObjectId returns an empty array there).

      Parameters

      • ids: string[]

      Returns boolean

    • Remove the specified persistent entity (stored in the drawing database) from this scene.

      Parameters

      • objectId: string

        Input the object id of the entity to remove

      Returns boolean

      Return true if remove the specified entity successfully. Otherwise, return false.

    • Select the specified entities across all layouts.

      This is what makes drill-through selection visually consistent: a click inside a paper-space viewport resolves to a model entity, but the active layout at that moment is paper. Without propagating to the model layout, the selection would be silently lost — the entity goes into selectionSet but no highlight ever renders. The bug manifested as "I click on a line in the viewport and nothing visibly selects" (debug logs confirmed firstPicked was the correct entity, but the highlight never appeared).

      Cross-layout propagation also restores symmetry of select/unselect: a model entity highlighted via paper drill must un-highlight when the user replaces the selection from any layout, not just the one where it was originally picked.

      Parameters

      • ids: string[]

      Returns boolean

    • Update the specified persistent entity (stored in the drawing database) in this scene.

      Parameters

      • entity: AcTrEntity

      Returns boolean

      Return true if update the specified entity successfully. Otherwise, return false.