Creates a new 2D CAD viewer instance.
Configuration options for the viewer
Options to customize view
Optional
background?: numberBackground color
Optional
calculateSizeCallback?: AcEdCalculateSizeCallbackCallback function used to calculate size of canvas when window resized
Optional
canvas?: HTMLCanvasElementCanvas HTML element used by renderer
Protected
_canvasThe HTML canvas element for rendering
Readonly
eventsEvents fired by the view for various interactions
Fired when mouse hovers over an entity
Fired when mouse moves over the view
Fired when mouse stops hovering over an entity
Fired when the view is resized
The block table record id associated with the active layout
The active layout view
Gets the background color of the view.
The color is represented as a 24-bit hexadecimal RGB number, e.g.,
0x000000
for black.
Sets the background color of the view.
The background color as a 24-bit hexadecimal RGB number
The bounding box to include all entities in this viewer
The canvas HTML element used by this view
Gets the center point of the current view in world coordinates.
The view center point
Gets the center point of the current view in world coordinates.
The view center point
Postion of current mouse in world coordinate system
Postion of current mouse in screen coordinate system
Gets the input manager for handling user interactions.
The editor provides high-level methods for getting user input like point selection, entity selection, and cursor management.
The editor instance
Height of canvas (not height of window) in pixel
Gets whether the view needs to be re-rendered.
True if the view is dirty and needs re-rendering
Sets whether the view needs to be re-rendered.
True to mark the view as needing re-rendering
Gets information about missing data during rendering (fonts and images).
Object containing maps of missing fonts and images
Gets the current view mode.
The view mode determines how the view responds to user interactions:
The current view mode
Sets the view mode (selection or pan).
The view mode to set
The block table record id of the model space
Gets the Three.js renderer wrapper used for CAD rendering.
The renderer instance
Gets the size of the selection box used for entity picking.
This determines how close the mouse needs to be to an entity to select it, measured in screen pixels.
Selection box size in pixels
Sets the size of the selection box used for entity picking.
Selection box size in pixels
The selection set in current view.
The statistics of the current scene
Width of canvas (not width of window) in pixel
Add the specified entity or entities in drawing database into the current scene and draw it or them
Input the entity to add into the current scene
Add the specified layer in drawing database into the current scene
Input the layer to add into the current scene
Add the specified layout in drawing database into the current scene
Input the layout to add into the current scene
Clear the scene
Protected
createConverts a point from client window coordinates to world coordinates.
The client window coordinate system has its origin at the top-left corner of the canvas, with Y increasing downward. World coordinates use the CAD coordinate system with Y typically increasing upward.
Point in client window coordinates
Point in world coordinates
Select the specified entities
Protected
initializeProtected
Initializes the viewer after renderer and camera are created.
This method sets up the initial cursor and can be overridden by child classes to add custom initialization logic.
Protected
onCalled when hovering the specified entity
Protected
onCalled when unhovering the specified entity
Protected
onPick entities intersected with the specified point in the world coordinate system.
Optional
point: AcGeVector2dLikeInput the point to pick objects. If not provided, the position of current cursor is used.
Return ids of entities intersected with the specified point
Remove the specified entity from this view.
Input the object id of the entity to remove
Re-render points with latest point style settings
Input display mode of points
Search entities intersected or contained in the specified bounding box.
Input the query bounding box
Return query results
Select entities intersected with the specified point in the world coordinate system, add them to the current selection set, and highlight them.
Optional
point: AcGeVector2dLikeSelect entities intersected with the specified bounding box in the world coordinate system, add them to the current selection set, and highlight them.
Input one bounding box in the world coordinate system.
Set callback function used to calculate size of canvas when window resized
Input callback function
Unhighlight the specified entities
Update the specified entity or entities
Input the entity or entities to update
Update the specified layer in the current scene
Input the layer to update
Converts a point from world coordinates to client window coordinates.
This is the inverse of cwcs2Wcs()
, converting from the CAD world
coordinate system to screen pixel coordinates.
Point in world coordinates
Point in client window coordinates
Zooms the view to fit the specified bounding box with optional margin.
This method adjusts the view's center and zoom level so that the entire specified bounding box is visible within the viewport. The margin parameter adds extra space around the bounding box to provide visual padding.
The bounding box to zoom to, in world coordinates
Additional margin around the bounding box (in world units)
Zooms the view to fit all visible entities in the current scene.
This method automatically calculates the bounding box of all entities currently displayed in the view and adjusts the view's center and zoom level to show the entire scene. This is useful for getting an overview of the entire drawing or after loading new content.
This function takes effect only if the current view has finished rendering all entities. When opening a file, progressive Rendering is used to render entities incrementally. So this function will wait until all of entities rendered or a timeout occurs.
Maximum time (ms) to wait before executing zoom to fit action. Default: 0 (no timeout).
A 2D CAD viewer component that renders CAD drawings using Three.js.
This class extends AcEdBaseView and provides functionality for:
Example