PartLabels
- class cee.mrk.PartLabels()
Defines positioned text labels that can be shown in a
MarkupModel
.Use
MarkupModel.addLabelsPart
to create a new instance of this class.Some examples of different label styles:
Accessors
attachmentAppearance
customData
drawMode
labelAppearance
labelAttachmentPoint
labelCount
Methods
Accessors
- cee.mrk.attachmentAppearance()
Returns an active reference to the attachment appearance settings for this part.
- Return type:
LabelAttachmentAppearance
- cee.mrk.customData()
Custom data for the part. This field is not used by EnvisionWeb.
- Return type:
any
- cee.mrk.customData(data)
- Arguments:
data (
any
) – None
- Return type:
void
- cee.mrk.drawMode()
Draw mode for the labels in this part
- Return type:
LabelDrawMode
- cee.mrk.drawMode(mode)
- Arguments:
mode (
LabelDrawMode
) – None
- Return type:
void
- cee.mrk.labelAppearance()
Returns an active reference to the appearance settings for the labels in this part.
- Return type:
LabelAppearance
- cee.mrk.labelAttachmentPoint()
Point where the attachment line meets the label
- Return type:
LabelAttachmentPoint
- cee.mrk.labelAttachmentPoint(attachmentPoint)
- Arguments:
attachmentPoint (
LabelAttachmentPoint
) – None
- Return type:
void
- cee.mrk.labelCount()
The number of labels in the part.
- Return type:
number
Methods
add
- PartLabels.add(text, pos)
- Arguments:
text (
string
) – Nonepos (
Vec3
) – None
Adds the given text to the part, placing it at the given position. Returns the index of the new label.
- Return type:
number
addWithOffsetDirection
- PartLabels.addWithOffsetDirection(text, pos, offsetDirection)
- Arguments:
text (
string
) – Nonepos (
Vec3
) – NoneoffsetDirection (
Vec3
) – None
Adds text label with offset direction. Returns the index of the new label.
- Return type:
number
addWithOffsetDirectionFlipTowardEye
- PartLabels.addWithOffsetDirectionFlipTowardEye(text, pos, offsetDirection)
- Arguments:
text (
string
) – Nonepos (
Vec3
) – NoneoffsetDirection (
Vec3
) – None
Adds text with offset direction where the offset direction will be flipped so that it always points towards the viewpoint. Returns the index of the new label.
- Return type:
number
addWithOffsetPosition
- PartLabels.addWithOffsetPosition(text, pos, offsetPosition)
- Arguments:
text (
string
) – Nonepos (
Vec3
) – NoneoffsetPosition (
Vec3
) – None
Adds text label with offset position. Returns the index of the new label.
- Return type:
number
deleteAll
- PartLabels.deleteAll()
Deletes all text labels from the part.
- Return type:
void
deleteLabelAt
- PartLabels.deleteLabelAt(index)
- Arguments:
index (
number
) – None
Deletes the text label at the given index.
- Return type:
void
getLabelOffsetDirection
- PartLabels.getLabelOffsetDirection(index)
- Arguments:
index (
number
) – None
Gets the offset direction of the label at the given index.
- Return type:
Vec3
getLabelOffsetPosition
- PartLabels.getLabelOffsetPosition(index)
- Arguments:
index (
number
) – None
Gets the offset position of the label at the given index.
- Return type:
Vec3
getLabelPosition
- PartLabels.getLabelPosition(index)
- Arguments:
index (
number
) – None
Gets the position of the label at the given index.
- Return type:
Vec3
getLabelText
- PartLabels.getLabelText(index)
- Arguments:
index (
number
) – None
Gets the text of the label at the given index.
- Return type:
string
rayIntersect
- PartLabels.rayIntersect(ray, hitItem)
- Arguments:
ray (
Ray
) – NonehitItem (
PartHitItem
) – None
Picking
- Return type:
boolean
setCustomDrawOntoCanvasCallback
- PartLabels.setCustomDrawOntoCanvasCallback(callback)
- Arguments:
callback (
CustomDrawOntoCanvasCallback
) – None
Specify a custom label drawing callback.
The callback will be called for each label in the part, and can be used to draw the label in a custom way.
Note that this callback does not consider the label appearance settings. The callback will only receive the text to draw. If you return false from the callback, the label will be drawn as default.
- Return type:
void
setLabelOffsetDirection
- PartLabels.setLabelOffsetDirection(index, offsetDirection, flipTowardsEye)
- Arguments:
index (
number
) – NoneoffsetDirection (
Vec3
) – NoneflipTowardsEye (
boolean
) – None
Sets the offset direction of the label at the given index.
- Return type:
void
setLabelOffsetPosition
- PartLabels.setLabelOffsetPosition(index, offsetPosition)
- Arguments:
index (
number
) – NoneoffsetPosition (
Vec3
) – None
Sets the offset position of the label at the given index.
Example: Move a label with the mouse
private onMouseMove(event: MouseEvent) { const label = this.m_pickingLabelPart; if (label && event.ctrlKey) { const view = this.m_viewer.getViewAt(0); const labelPos = label.getLabelPosition(0); // Keep label in the same distance from the camera const labelDepth = view.camera.project(labelPos).z; const oglWinPos = this.m_viewer.oglWinPosFromClientCoord(event.x, event.y); const labelOffsetPos = view.camera.unproject( {x: oglWinPos.x, y: oglWinPos.y, z: labelDepth}); label.setLabelOffsetPosition(0, labelOffsetPos); } }
- Return type:
void
setLabelPosition
- PartLabels.setLabelPosition(index, position)
- Arguments:
index (
number
) – Noneposition (
Vec3
) – None
Sets the position of the label at the given index.
- Return type:
void
setLabelText
- PartLabels.setLabelText(index, text)
- Arguments:
index (
number
) – Nonetext (
string
) – None
Sets the text of the label at the given index.
- Return type:
void
setOccluderTriMesh
- PartLabels.setOccluderTriMesh(labelIndex, vertices, indices[, options])
- Arguments:
labelIndex (
number
) – Nonevertices (
ArrayLike
) – Noneindices (
ArrayLike
) – Noneoptions (
OccluderOptions
) – optional None
Sets the occluder tri-mesh to use for testing the visibility of the label at the specified index.
The specified occluder mesh is used to test if the label should be visible or not. If the mesh is visible, the label will be visible. If the mesh is occluded, the label will be hidden.
- Return type:
void