Reference·JavaScript · @bimworks/viewer3dJavaScript

AreaMeasurement

Class in @bimworks/viewer3d.

API catalogue · @bimworks/viewer3d · Class

TypeScript#
class AreaMeasurement

Inheritance and interfaces#

Members#

Member Kind Description
constructor Method inheritedFrom: Measurement.constructor
applicableAreaModes Method
area Method
areaMode Method Which figure this measurement reports and draws: "gross" (the polygon as it stands), "net" (the openings of the face it was taken from drawn and subtracted) …
coordinates Method
editable Method Whether the points of this measurement can be dragged to a new position after it has been finalized (default true). Supported for area, path and point measur…
editable Method inheritedFrom: Measurement.editable
editState Method The point being dragged (see editable): its index, whether it moved yet, and the measurement's value before the drag as its label shows it. Null when no poin…
finished Method inheritedFrom: Measurement.finished
holes Method The openings of the face this measurement was taken from, empty for a measurement drawn by hand. Each is a closed ring with the same convention as coordinate…
hull Method The convex hull of the outer ring, empty unless this is a hull measurement. Read-only geometry like the openings: the drag handles stay on the ring the user …
hullArea Method Whether the convex hull of the ring is drawn and measured instead of the ring itself. Shorthand for areaMode == "hull"
id Method Get the unique identifier of this measurement inheritedFrom: Measurement.id
netArea Method Whether the openings are drawn and subtracted from the area. Shorthand for areaMode == "net"
normal Method
pointCount Method inheritedFrom: Measurement.pointCount
preferredAreaMode Method The mode as chosen, which may not be in force (areaMode is the one in force)
snapsToVertices Method inheritedFrom: Measurement.snapsToVertices
canFinish Method inheritedFrom: Measurement.canFinish
cycleAreaMode Method Advance to the next mode that applies here, in the order gross, net, hull. This is what the "toggleAreaHoles" key does
getViewFitPoints Method inheritedFrom: Measurement.getViewFitPoints
isHovered Method inheritedFrom: Measurement.isHovered
isSelected Method inheritedFrom: Measurement.isSelected
preferAreaMode Method While the measurement is being taken: choose the mode, also one that does not apply yet. It takes effect on the face that is clicked, or once a ring drawn by…
remove Method inheritedFrom: Measurement.remove
selfIntersects Method
setAreaMode Method Put this measurement in one of the three modes
setNetArea Method Switch between gross and net. Predates the third mode, setAreaMode is the general form
undoPoint Method Remove the last placed point while this measurement is being taken, see Measuring.undoLastPoint inheritedFrom: Measurement.undoPoint

constructor#

TypeScript#
constructor()

inheritedFrom: Measurement.constructor

applicableAreaModes#

TypeScript#
public applicableAreaModes(): (AreaMode)[]

Returns#

The modes that change something for this measurement right now, "gross" always among them

area#

TypeScript#
public area(): number

Returns#

The enclosed area of the polygon, always in square millimeters. For self-intersecting polygons this is the net (shoelace) area. What is measured follows the mode (see areaMode): the openings are subtracted for a net measurement, the convex hull of the ring is measured for a hull one

areaMode#

TypeScript#
public areaMode(): AreaMode

Which figure this measurement reports and draws: "gross" (the polygon as it stands), "net" (the openings of the face it was taken from drawn and subtracted) or "hull" (the convex hull of the ring, every concave feature filled in, openings ignored). The setting belongs to this measurement, not to the viewer. It can be cycled with the "toggleAreaHoles" key binding (O by default) while this measurement is being created or while it is the selected one.

The value is what is actually in force: a mode this polygon cannot honour - "net" without openings, "hull" over an already convex ring - reads back as "gross"

Returns#

The mode in force

coordinates#

TypeScript#
public coordinates(): (vec3)[]

Returns#

An array of the polygon coordinates. The closing edge is implied, the first coordinate is not repeated at the end. This is the outer ring only, the openings are reported separately by holes

editable#

TypeScript#
public editable(): boolean

Whether the points of this measurement can be dragged to a new position after it has been finalized (default true). Supported for area, path and point measurements, and for the laser, which is dragged as a whole by its instrument (a click on it selects it instead); the other types have no draggable points. The points show a pointer cursor on hover; while dragging, vertex snapping applies as during measuring (Shift temporarily disables it) and the label (area/length/position) is updated in realtime. Dropping the point fires the committed listener event, Escape cancels the drag

inheritedFrom: Measurement.editable

editable#

TypeScript#
public editable(editable: boolean): void

inheritedFrom: Measurement.editable

Parameters#

Name Type Description
editable boolean

editState#

TypeScript#
public editState(): { index: number | null; moved: boolean; originalText: string | null } | null

The point being dragged (see editable): its index, whether it moved yet, and the measurement's value before the drag as its label shows it. Null when no point is dragged. A right-click during the drag puts the point back, like Escape. For a laser, index is the beam end dragged along its beam (0-2 the ends along the axes, 3-5 those opposite), null while it moves as a whole by its instrument; originalText is null

inheritedFrom: Measurement.editState

finished#

TypeScript#
public finished(): boolean

inheritedFrom: Measurement.finished

Returns#

Whether this measurement is finished

holes#

TypeScript#
public holes(): ((vec3)[])[]

The openings of the face this measurement was taken from, empty for a measurement drawn by hand. Each is a closed ring with the same convention as coordinates. They have no drag handles: only the outer ring can be edited

Returns#

An array of rings

hull#

TypeScript#
public hull(): (vec3)[]

The convex hull of the outer ring, empty unless this is a hull measurement. Read-only geometry like the openings: the drag handles stay on the ring the user authored

Returns#

The hull as a closed ring, with the same convention as coordinates

hullArea#

TypeScript#
public hullArea(): boolean

Whether the convex hull of the ring is drawn and measured instead of the ring itself. Shorthand for areaMode == "hull"

Returns#

Whether this is a hull area measurement

id#

TypeScript#
public id(): number

Get the unique identifier of this measurement

inheritedFrom: Measurement.id

netArea#

TypeScript#
public netArea(): boolean

Whether the openings are drawn and subtracted from the area. Shorthand for areaMode == "net"

Returns#

Whether this is a net area measurement

normal#

TypeScript#
public normal(): vec3 | null

Returns#

A copy of the unit normal of the plane the polygon lies in (the face's own normal for a measurement seeded from a face), or null while fewer than 3 non-collinear points have been committed

pointCount#

TypeScript#
public pointCount(): number

inheritedFrom: Measurement.pointCount

Returns#

The points placed so far while this measurement is being taken (objects picked, for an object distance)

preferredAreaMode#

TypeScript#
public preferredAreaMode(): AreaMode

The mode as chosen, which may not be in force (areaMode is the one in force)

snapsToVertices#

TypeScript#
public snapsToVertices(): boolean

inheritedFrom: Measurement.snapsToVertices

Returns#

Whether the points of this measurement snap to vertices and edges (point, length, area, angle)

canFinish#

TypeScript#
public canFinish(): boolean

inheritedFrom: Measurement.canFinish

Returns#

Whether finish() would complete this measurement now (enough points for a length or an area)

cycleAreaMode#

TypeScript#
public cycleAreaMode(): AreaMode

Advance to the next mode that applies here, in the order gross, net, hull. This is what the "toggleAreaHoles" key does

Returns#

The mode now in force, or null when this measurement has neither openings nor a concave ring and there was nothing to switch to

getViewFitPoints#

TypeScript#
public getViewFitPoints(): (vec3)[] | null

inheritedFrom: Measurement.getViewFitPoints

Returns#

The points (viewer measurement coordinates) a camera fit on this measurement encloses, or null when it has none yet

isHovered#

TypeScript#
public isHovered(): boolean

inheritedFrom: Measurement.isHovered

Returns#

Whether this measurement is hovered

isSelected#

TypeScript#
public isSelected(): boolean

inheritedFrom: Measurement.isSelected

Returns#

Whether this measurement is selected

preferAreaMode#

TypeScript#
public preferAreaMode(mode: AreaMode): boolean

While the measurement is being taken: choose the mode, also one that does not apply yet. It takes effect on the face that is clicked, or once a ring drawn by hand turns concave (hull)

Parameters#

Name Type Description
mode AreaMode

Returns#

False for a finished measurement (use setAreaMode) or a value that is not a mode

remove#

TypeScript#
public remove(): void

inheritedFrom: Measurement.remove

Returns#

Remove this Measurement

selfIntersects#

TypeScript#
public selfIntersects(): boolean

Returns#

Whether the polygon self-intersects. The area label is hidden in the 3D view while this is the case

setAreaMode#

TypeScript#
public setAreaMode(mode: boolean | AreaMode): boolean

Put this measurement in one of the three modes

Parameters#

Name Type Description
mode boolean | AreaMode The mode, or the boolean that predates the third one (true meaning "net")

Returns#

False when the mode does not apply here: "net" without openings to subtract, or "hull" over an already convex ring

setNetArea#

TypeScript#
public setNetArea(net: boolean): boolean

Switch between gross and net. Predates the third mode, setAreaMode is the general form

Parameters#

Name Type Description
net boolean Whether the openings should be subtracted

Returns#

False when there is nothing to subtract, i.e. the face has no openings or the polygon was drawn by hand

undoPoint#

TypeScript#
public undoPoint(): boolean

Remove the last placed point while this measurement is being taken, see Measuring.undoLastPoint

inheritedFrom: Measurement.undoPoint

Returns#

Whether a point was taken back