new Dimensions()
Provides tools for handling dimension values and generating dimension lines.
Members
-
:THREE.Color
defaultColor <static>
-
The default color to display dimensions lines.
Type
- THREE.Color
-
:boolean
dynamicResize <static>
-
A flag used by interactive and dynamic dimensions.
Type
- boolean
-
:number
mmAccuracy <static>
-
The number of decimal points to add to metric values.
Type
- number
Methods
-
addAngleDimensionLine(mesh, pt1, pt2, pt3, size [, click_pt]) <static>
-
Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the dimension to.
pt1THREE.Vector3 The starting point of the angle line.
pt2THREE.Vector3 The middle point of the angle line.
pt3THREE.Vector3 The end point of the angle line.
sizenumber The size of dimension components, in model units.
click_ptClickPoint <optional>
An optional click point to set data for.
Returns:
Returns true if a valid dimension line was added, otherwise false.
- Type
- boolean
-
addBoxDimensionLines(mesh, box, up, size [, click_pt]) <static>
-
Add dimension lines for a box and returns the click points.
Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the dimension to.
boxTHREE.Box3 The bounding box to add dimensions for.
upTHREE.Vector3 The direction of the up vector for this line.
sizenumber The size of dimension components, in model units.
click_ptClickPoint <optional>
An optional click point to set data for.
Returns:
Returns the click point, or a new one if not given.
- Type
- ClickPoint
-
addDimLineSegment(mesh, dim, addStart, addEnd) <static>
-
Adds a dimension line between start and end.
This is just the line component with an optional gap in the middle if the dimension text fits and an optional overlap at start and end as appropriate.
: : : : ###/###### DIM ######/### : :The
addStartandaddEndparameters are used to control the extension of the dimension line beyond its start and and points.Parameters:
Name Type Description meshPD.PolyMesh The mesh to add the tick line to.
dimobject The dimension data returned from
getDimensionData().addStartboolean When true, potentially add an overrun line at the start of the line.
addEndboolean When true, potentially add an overrun line at the end of the line.
-
addDimTextInLine(mesh, dim, text, up) <static>
-
Adds the dimension text in/on the dimension line.
: : : : ---/------ ### ------/--- : :Parameters:
Name Type Description meshPD.PolyMesh The mesh to add the text to.
dimobject The dimension data returned from
getDimensionData().textstring The formatted text to add.
upTHREE.Vector3 The direction of the up vector for this line.
-
addDimTickForProjectedPoint(mesh, dim, point, addStart, addEnd) <static>
-
Projects the point onto the dimension line and adds a tick indicator.
o : | : ---x------ DIM ------/--- | :Parameters:
Name Type Description meshPD.PolyMesh The mesh to add the tick line to.
dimobject The dimension data returned from
getDimensionData().pointTHREE.Vector3 The point being dimensioned.
addStartboolean When true and type is set to arrows, a beginning arrow will be added.
addEndboolean When true and type is set to arrows, a terminating arrow will be added.
-
addDimTickIndicator(mesh, dim, refPoint, dimPoint, addStart, addEnd) <static>
-
Adds a tick indicator to a dimension line.
This is just the tick component with a line normal to the dimension indicating the measurement point and marker to show where that line crosses the actual dimension line.
# : # : ---#------ DIM ------/--- # :The
addStartandaddEndparameters are used when the tick indicator type is set to arrow heads. Unlike the diamond or cross indicators, arrows can occur on both sides of the indicator line, terminating the previous segment and beginning the next. Use these to start a new dimension without terminating a previous one or terminate a segment without starting a new one.Parameters:
Name Type Description meshPD.PolyMesh The mesh to add the tick line to.
dimobject The dimension data returned from
getDimensionData().refPointTHREE.Vector3 The point being dimensioned.
dimPointTHREE.Vector3 The position of the point projected onto the line by its normal.
addStartboolean When true and type is set to arrows, a beginning arrow will be added.
addEndboolean When true and type is set to arrows, a terminating arrow will be added.
-
addDimensionLine(mesh, from, to, up, size [, click_pt]) <static>
-
Adds a dimension line between the two points and returns the click point.
Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the dimension to.
fromTHREE.Vector3 The start position of the dimension line.
toTHREE.Vector3 The end position of the dimension line.
upTHREE.Vector3 The direction of the up vector for this line.
sizenumber The size of dimension components, in model units.
click_ptClickPoint <optional>
An optional click point to set data for.
Returns:
Returns true if a valid dimension line was added, otherwise false.
- Type
- boolean
-
addDimensionLinearRun(mesh, from, to, points, up, size [, click_pts]) <static>
-
Adds a sequence of linear dimension lines between multiple points.
The first and last points in the
pointslist define the line along which the dimensions will run.Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the dimensions to.
fromTHREE.Vector3 The first point on the dimension line.
toTHREE.Vector3 The second point on the dimension line.
pointsArray.<THREE.Vector3> The list of points along the dimension line.
upTHREE.Vector3 The direction of the up vector for this run.
sizenumber The size of dimension components, in model units.
click_ptsArray.<ClickPoint> <optional>
An optional array to add any click points to.
Returns:
Returns an array with the generated click points, or a new one if not given.
- Type
- Array.<ClickPoint>
-
addDimensionRun(mesh, points, up, size [, click_pts]) <static>
-
Adds a sequence of linear dimension lines between multiple points.
The first and last points in the
pointslist define the line along which the dimensions will run.Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the dimensions to.
pointsArray.<THREE.Vector3> The list of points along the dimension line.
upTHREE.Vector3 The direction of the up vector for this run.
sizenumber The size of dimension components, in model units.
click_ptsArray.<ClickPoint> <optional>
An optional array to add any click points to.
Returns:
Returns an array with the generated click points, or a new one if not given.
- Type
- Array.<ClickPoint>
-
addOrthoDimensionLines(mesh, from, to, up, size [, click_pt1] [, click_pt2]) <static>
-
Add dimension lines showing the horizontal and vertical dimensions and returns the click points.
Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the dimension to.
fromTHREE.Vector3 The start position of the line to dimension.
toTHREE.Vector3 The end position of the line dimension.
upTHREE.Vector3 The direction of the up vector for this line.
sizenumber The size of dimension components, in model units.
click_pt1ClickPoint <optional>
An optional click point for the horizontal component.
click_pt2ClickPoint <optional>
An optional click point for the vertical component.
Returns:
Returns true if valid dimension lines were added, otherwise false.
- Type
- boolean
-
createClickPoint() <static>
-
Creates a new click point for use with a dimension line.
Returns:
Returns a new click point.
- Type
- ClickPoint
-
formatArea(m2 [, units]) <static>
-
Formats the given area in metres squared (m2) as a string to match the given units.
Parameters:
Name Type Argument Description m2number The model area value to convert, in metres squared (m2).
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted area string with units.
- Type
- string
-
formatDimension(value [, units]) <static>
-
Formats the given dimension as a string to match the given units.
Parameters:
Name Type Argument Description valuenumber The model dimension value to convert, in mm.
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted string.
- Type
- string
-
formatDimensionWithUnits(value [, units]) <static>
-
Formats the given dimension as a string and includes the units abbreviation.
Parameters:
Name Type Argument Description valuenumber The model dimension value to convert, in mm.
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted string.
- Type
- string
-
formatPosition(pos [, tag] [, units]) <static>
-
Formats the given 3D model position as a string to match the given units.
This method shows the component values of the vector as actual model positions rather than deltas. To display the vectors as a relative delta, use the
PD.Dimensions#formatVector3method instead.Parameters:
Name Type Argument Description posTHREE.Vector3 The {x,y,z} position to convert, with axial components in mm.
tagstring <optional>
An optional HTML tag name to wrap the text in (''tt', 'kbd', 'code', etc).
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted position string.
- Type
- string
-
formatVector3(vector [, tag] [, units]) <static>
-
Formats the given 3D vector as a string to match the given units.
This method shows the component values of the vector as deltas rather than actual model positions. To display the vectors as a model position, use the
PD.Dimensions#formatPositionmethod instead.Parameters:
Name Type Argument Description vectorTHREE.Vector3 The 3D vector to convert, with axial components in mm.
tagstring <optional>
An optional HTML tag name to wrap the text in (''tt', 'kbd', 'code', etc).
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted vector string.
- Type
- string
-
formatVolume(m3 [, units]) <static>
-
Formats the given volume in metres cubed (m3) as a string to match the given units.
Parameters:
Name Type Argument Description m3number The model volume value to convert, in metres cubed (m3).
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted area string with units.
- Type
- string
-
formatXY(x, y [, tag] [, units]) <static>
-
Formats a pair of XY coordinates as a string to match the given units.
Parameters:
Name Type Argument Description xnumber The X-axis component, in mm.
ynumber The Y-axis component, in mm.
tagstring <optional>
An optional HTML tag name to wrap the text in (''tt', 'kbd', 'code', etc).
unitsPD.DIMENSION <optional>
The type of dimension units to format in, defaults to current units.
Returns:
Returns the formatted vector string.
- Type
- string
-
getDimensionData(from, to, up, size) <static>
-
Calculates some basic data required for rendering dimensions.
Parameters:
Name Type Description fromTHREE.Vector3 The start position of the dimension line.
toTHREE.Vector3 The end position of the dimension line.
upTHREE.Vector3 The direction of the up vector for this line.
sizenumber The size of dimension components, in model units.
Returns:
Returns a data object that you can pass to dimension methods.
- Type
- object
-
mm2ToMetres2(mm2) <static>
-
Converts an area in square millimetres to square metres.
Parameters:
Name Type Description mm2number The area given in square millimetres.
Returns:
Returns the value in square metres.
- Type
- number
-
mm3ToMetres3(mm3) <static>
-
Converts a volume in cubic millimetres to cubic metres.
Parameters:
Name Type Description mm3number The volume given in cubic millimetres.
Returns:
Returns the value in cubic metres.
- Type
- number
-
mmToMetres(mm) <static>
-
Converts a distance in millimetres to metres.
Parameters:
Name Type Description mmnumber The value given in millimetres.
Returns:
Returns the value in metres.
- Type
- number
-
parseDimension(string [, units]) <static>
-
Parses a string containing a dimension in the given units.
Parameters:
Name Type Argument Description stringstring The string containing the dimension to parse.
unitsnumber <optional>
The units to use (METRIC_MM|METRIC_SI|IMPERIAL).
Returns:
Returns a dimension value in millimeters.
- Type
- string
-
snapTo(value, inches [, mm]) <static>
-
Snaps a value to the nearest inch or mm, based on the given units.
Parameters:
Name Type Argument Description valuenumber The value to snap.
inchesnumber The number of inches to use if imperial.
mmnumber <optional>
The number of millimetres if metric, defaults to
inches * 25.Returns:
Returns the snapped value.
- Type
- number