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:

None

Accessors

cee.mrk.PartLabels.attachmentAppearance()
get attachmentAppearance(): LabelAttachmentAppearance

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

Returns: LabelAttachmentAppearance

cee.mrk.PartLabels.customData()

inherited

get customData(): any

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

Returns: any

set customData(data: any): void

Parameters

data: any

Returns: void

cee.mrk.PartLabels.drawMode()
get drawMode(): LabelDrawMode

Draw mode for the labels in this part

Returns: LabelDrawMode

set drawMode(mode: LabelDrawMode): void

Parameters

Returns: void

cee.mrk.PartLabels.labelAppearance()
get labelAppearance(): LabelAppearance

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

Returns: LabelAppearance

cee.mrk.PartLabels.labelAttachmentPoint()
get labelAttachmentPoint(): LabelAttachmentPoint

Point where the attachment line meets the label

Returns: LabelAttachmentPoint

set labelAttachmentPoint(attachmentPoint: LabelAttachmentPoint): void

Parameters

attachmentPoint: LabelAttachmentPoint

Returns: void

cee.mrk.PartLabels.labelCount()
get labelCount(): number

The number of labels in the part.

Returns: number

Methods

cee.mrk.PartLabels.add()
add(text: string, pos: Vec3): number

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

Parameters

text: string

pos: Vec3

Returns: number

cee.mrk.PartLabels.addWithOffsetDirection()
addWithOffsetDirection(text: string, pos: Vec3, offsetDirection: Vec3): number

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

Parameters

text: string

pos: Vec3

offsetDirection: Vec3

Returns: number

cee.mrk.PartLabels.addWithOffsetDirectionFlipTowardEye()
addWithOffsetDirectionFlipTowardEye(text: string, pos: Vec3, offsetDirection: Vec3): number

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.

Parameters

text: string

pos: Vec3

offsetDirection: Vec3

Returns: number

cee.mrk.PartLabels.addWithOffsetPosition()
addWithOffsetPosition(text: string, pos: Vec3, offsetPosition: Vec3): number

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

Parameters

text: string

pos: Vec3

offsetPosition: Vec3

Returns: number

cee.mrk.PartLabels.deleteAll()
deleteAll(): void

Deletes all text labels from the part.

Returns: void

cee.mrk.PartLabels.deleteLabelAt()
deleteLabelAt(index: number): void

Deletes the text label at the given index.

Parameters

index: number

Returns: void

cee.mrk.PartLabels.getLabelOffsetDirection()
getLabelOffsetDirection(index: number): Vec3

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

Parameters

index: number

Returns: Vec3

cee.mrk.PartLabels.getLabelOffsetPosition()
getLabelOffsetPosition(index: number): Vec3

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

Parameters

index: number

Returns: Vec3

cee.mrk.PartLabels.getLabelPosition()
getLabelPosition(index: number): Vec3

Gets the position of the label at the given index.

Parameters

index: number

Returns: Vec3

cee.mrk.PartLabels.getLabelText()
getLabelText(index: number): string

Gets the text of the label at the given index.

Parameters

index: number

Returns: string

cee.mrk.PartLabels.rayIntersect()
rayIntersect(ray: Ray, hitItem: PartHitItem): boolean

Picking

Parameters

ray: Ray

hitItem: PartHitItem

Returns: boolean

cee.mrk.PartLabels.setCustomDrawOntoCanvasCallback()
setCustomDrawOntoCanvasCallback(callback: CustomDrawOntoCanvasCallback): void

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.

Parameters

Returns: void

cee.mrk.PartLabels.setLabelOffsetDirection()
setLabelOffsetDirection(index: number, offsetDirection: Vec3, flipTowardsEye: boolean): void

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

Parameters

index: number

offsetDirection: Vec3

flipTowardsEye: boolean

Returns: void

cee.mrk.PartLabels.setLabelOffsetPosition()
setLabelOffsetPosition(index: number, offsetPosition: Vec3): void

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

Parameters

index: number

offsetPosition: Vec3

Returns: void

cee.mrk.PartLabels.setLabelPosition()
setLabelPosition(index: number, position: Vec3): void

Sets the position of the label at the given index.

Parameters

index: number

position: Vec3

Returns: void

cee.mrk.PartLabels.setLabelText()
setLabelText(index: number, text: string): void

Sets the text of the label at the given index.

Parameters

index: number

text: string

Returns: void

cee.mrk.PartLabels.setOccluderTriMesh()
setOccluderTriMesh(labelIndex: number, vertices: ArrayLike, indices: ArrayLike, options: OccluderOptions): void

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.

Parameters

labelIndex: number

vertices: ArrayLike

indices: ArrayLike

options: OccluderOptions

Returns: void