Overview
TheDimensionTool is a singleton utility for creating and managing dimension annotations in your OpenPlans scenes. It provides a centralized way to add visual measurements like length dimensions with labels.
Getting Started
The DimensionTool is automatically initialized when you callsetupOpenGeometry() on your OpenPlans instance:
DimensionTool
Properties
Reference to the Three.js scene where dimensions will be rendered. This is automatically set during OpenPlans initialization.
Methods
Creates a new dimension and adds it to the scene.Parameters:
key(string): Unique identifier for the dimensiontype(DimensionType): Type of dimension to create
'length': Linear distance measurement'angle': Angular measurement (coming soon)'area': Area measurement (coming soon)'radius': Radius measurement (coming soon)'diameter': Diameter measurement (coming soon)'volume': Volume measurement (coming soon)'custom': Custom dimension type (coming soon)
Retrieves a dimension by its unique identifier.Parameters:
key(string): The unique identifier of the dimension
LineDimension
TheLineDimension class creates visual dimension annotations for linear measurements between two points.
Constructor
Configuration object for the dimension line.Properties:
start(Vector3): Starting point of the dimensionend(Vector3): Ending point of the dimensioncolor(number): Color of the dimension line (hex value)
Methods
Updates the text label displayed on the dimension.Parameters:
label(string): The text to display (typically the measured distance)
Updates the dimension’s position and length.Parameters:
data(ILineOptions): New start and end pointslength(number): The measured length to display
Gets the current dimension label text.Returns: String containing the current label.
Usage Example
Styling
Dimension labels are rendered using CSS2D and can be customized through CSS:Notes
- Dimensions are automatically added to the scene when created via
DimensionTool.createDimension() - The dimension line includes perpendicular tick marks at both ends
- Labels are positioned at the midpoint of the dimension line
- Currently, only ‘length’ dimension type is fully implemented