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: image0


Accessors

cee.mrk.PartLabels.attachmentAppearance

Returns an active reference to the attachment appearance settings for this part.

cee.mrk.PartLabels.attachmentLineLength

Length in pixels of the line that attaches the label to its 3D position

Note

attachmentLineLength is deprecated: This property is deprecated and will be removed in a future version. Use attachmentAppearance.lineLength instead.

cee.mrk.PartLabels.customData

Custom data for the part. This field is not used by EnvisionWeb.

cee.mrk.PartLabels.drawMode

Draw mode for the labels in this part

cee.mrk.PartLabels.labelAppearance

Returns an active reference to the appearance settings for the labels in this part.

cee.mrk.PartLabels.labelAttachmentPoint

Point where the attachment line meets the label

cee.mrk.PartLabels.labelCount

The number of labels in the part.

Methods

add

cee.mrk.PartLabels.add(text, pos)

Adds the given text to the part, placing it at the given position. Returns the index of the new label.

Arguments
  • text (string) –

  • pos (cee.Vec3) –

Return type

number

addWithOffsetDirection

cee.mrk.PartLabels.addWithOffsetDirection(text, pos, offsetDirection)

Adds text label with offset direction. Returns the index of the new label.

Arguments
  • text (string) –

  • pos (cee.Vec3) –

  • offsetDirection (cee.Vec3) –

Return type

number

addWithOffsetDirectionFlipTowardEye

cee.mrk.PartLabels.addWithOffsetDirectionFlipTowardEye(text, pos, offsetDirection)

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.

Arguments
  • text (string) –

  • pos (cee.Vec3) –

  • offsetDirection (cee.Vec3) –

Return type

number

addWithOffsetPosition

cee.mrk.PartLabels.addWithOffsetPosition(text, pos, offsetPosition)

Adds text label with offset position. Returns the index of the new label.

Arguments
  • text (string) –

  • pos (cee.Vec3) –

  • offsetPosition (cee.Vec3) –

Return type

number

deleteAll

cee.mrk.PartLabels.deleteAll()

Deletes all text labels from the part.

Return type

void

deleteLabelAt

cee.mrk.PartLabels.deleteLabelAt(index)

Deletes the text label at the given index.

Arguments
  • index (number) –

Return type

void

getLabelOffsetDirection

cee.mrk.PartLabels.getLabelOffsetDirection(index)

Gets the offset direction of the label at the given index.

Arguments
  • index (number) –

Return type

cee.Vec3

getLabelOffsetPosition

cee.mrk.PartLabels.getLabelOffsetPosition(index)

Gets the offset position of the label at the given index.

Arguments
  • index (number) –

Return type

cee.Vec3

getLabelPosition

cee.mrk.PartLabels.getLabelPosition(index)

Gets the position of the label at the given index.

Arguments
  • index (number) –

Return type

cee.Vec3

getLabelText

cee.mrk.PartLabels.getLabelText(index)

Gets the text of the label at the given index.

Arguments
  • index (number) –

Return type

string

rayIntersect

cee.mrk.PartLabels.rayIntersect(ray, hitItem)

Picking

Arguments
Return type

boolean

setCustomDrawOntoCanvasCallback

cee.mrk.PartLabels.setCustomDrawOntoCanvasCallback(callback)

Specify a custom label drawing callback.

Arguments
Return type

void

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.

setLabelOffsetDirection

cee.mrk.PartLabels.setLabelOffsetDirection(index, offsetDirection, flipTowardsEye)

Sets the offset direction of the label at the given index.

Arguments
  • index (number) –

  • offsetDirection (cee.Vec3) –

  • flipTowardsEye (boolean) –

Return type

void

setLabelOffsetPosition

cee.mrk.PartLabels.setLabelOffsetPosition(index, offsetPosition)

Sets the offset position of the label at the given index.

Arguments
  • index (number) –

  • offsetPosition (cee.Vec3) –

Return type

void

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);
  }
}

setLabelPosition

cee.mrk.PartLabels.setLabelPosition(index, position)

Sets the position of the label at the given index.

Arguments
  • index (number) –

  • position (cee.Vec3) –

Return type

void

setLabelText

cee.mrk.PartLabels.setLabelText(index, text)

Sets the text of the label at the given index.

Arguments
  • index (number) –

  • text (string) –

Return type

void