Class: Dimensions

PD. Dimensions


new Dimensions()

Provides tools for handling dimension values and generating dimension lines.

Author:
  • drajmarsh

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
mesh PD.PolyMesh

The mesh to add the dimension to.

pt1 THREE.Vector3

The starting point of the angle line.

pt2 THREE.Vector3

The middle point of the angle line.

pt3 THREE.Vector3

The end point of the angle line.

size number

The size of dimension components, in model units.

click_pt ClickPoint <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
mesh PD.PolyMesh

The mesh to add the dimension to.

box THREE.Box3

The bounding box to add dimensions for.

up THREE.Vector3

The direction of the up vector for this line.

size number

The size of dimension components, in model units.

click_pt ClickPoint <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 addStart and addEnd parameters are used to control the extension of the dimension line beyond its start and and points.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to add the tick line to.

dim object

The dimension data returned from getDimensionData().

addStart boolean

When true, potentially add an overrun line at the start of the line.

addEnd boolean

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
mesh PD.PolyMesh

The mesh to add the text to.

dim object

The dimension data returned from getDimensionData().

text string

The formatted text to add.

up THREE.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
mesh PD.PolyMesh

The mesh to add the tick line to.

dim object

The dimension data returned from getDimensionData().

point THREE.Vector3

The point being dimensioned.

addStart boolean

When true and type is set to arrows, a beginning arrow will be added.

addEnd boolean

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 addStart and addEnd parameters 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
mesh PD.PolyMesh

The mesh to add the tick line to.

dim object

The dimension data returned from getDimensionData().

refPoint THREE.Vector3

The point being dimensioned.

dimPoint THREE.Vector3

The position of the point projected onto the line by its normal.

addStart boolean

When true and type is set to arrows, a beginning arrow will be added.

addEnd boolean

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
mesh PD.PolyMesh

The mesh to add the dimension to.

from THREE.Vector3

The start position of the dimension line.

to THREE.Vector3

The end position of the dimension line.

up THREE.Vector3

The direction of the up vector for this line.

size number

The size of dimension components, in model units.

click_pt ClickPoint <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 points list define the line along which the dimensions will run.

Parameters:
Name Type Argument Description
mesh PD.PolyMesh

The mesh to add the dimensions to.

from THREE.Vector3

The first point on the dimension line.

to THREE.Vector3

The second point on the dimension line.

points Array.<THREE.Vector3>

The list of points along the dimension line.

up THREE.Vector3

The direction of the up vector for this run.

size number

The size of dimension components, in model units.

click_pts Array.<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 points list define the line along which the dimensions will run.

Parameters:
Name Type Argument Description
mesh PD.PolyMesh

The mesh to add the dimensions to.

points Array.<THREE.Vector3>

The list of points along the dimension line.

up THREE.Vector3

The direction of the up vector for this run.

size number

The size of dimension components, in model units.

click_pts Array.<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
mesh PD.PolyMesh

The mesh to add the dimension to.

from THREE.Vector3

The start position of the line to dimension.

to THREE.Vector3

The end position of the line dimension.

up THREE.Vector3

The direction of the up vector for this line.

size number

The size of dimension components, in model units.

click_pt1 ClickPoint <optional>

An optional click point for the horizontal component.

click_pt2 ClickPoint <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
m2 number

The model area value to convert, in metres squared (m2).

units PD.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
value number

The model dimension value to convert, in mm.

units PD.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
value number

The model dimension value to convert, in mm.

units PD.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#formatVector3 method instead.

Parameters:
Name Type Argument Description
pos THREE.Vector3

The {x,y,z} position to convert, with axial components in mm.

tag string <optional>

An optional HTML tag name to wrap the text in (''tt', 'kbd', 'code', etc).

units PD.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#formatPosition method instead.

Parameters:
Name Type Argument Description
vector THREE.Vector3

The 3D vector to convert, with axial components in mm.

tag string <optional>

An optional HTML tag name to wrap the text in (''tt', 'kbd', 'code', etc).

units PD.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
m3 number

The model volume value to convert, in metres cubed (m3).

units PD.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
x number

The X-axis component, in mm.

y number

The Y-axis component, in mm.

tag string <optional>

An optional HTML tag name to wrap the text in (''tt', 'kbd', 'code', etc).

units PD.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
from THREE.Vector3

The start position of the dimension line.

to THREE.Vector3

The end position of the dimension line.

up THREE.Vector3

The direction of the up vector for this line.

size number

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
mm2 number

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
mm3 number

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
mm number

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
string string

The string containing the dimension to parse.

units number <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
value number

The value to snap.

inches number

The number of inches to use if imperial.

mm number <optional>

The number of millimetres if metric, defaults to inches * 25.

Returns:

Returns the snapped value.

Type
number