Options
All
  • Public
  • Public/Protected
  • All
Menu

Class 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: alt text

Hierarchy

Index

Accessors

attachmentLineLength

attachmentLineLength: number

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

customData

customData: any

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

drawMode

drawMode: LabelDrawMode

Draw mode for the labels in this part

Readonly labelAppearance

labelAppearance: LabelAppearance

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

labelAttachmentPoint

labelAttachmentPoint: LabelAttachmentPoint

Point where the attachment line meets the label

Readonly labelCount

labelCount: number

The number of labels in the part.

Methods

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

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

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

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

deleteAll

  • deleteAll(): void
  • Deletes all text labels from the part.

    Returns void

deleteLabelAt

  • deleteLabelAt(index: number): void
  • Deletes the text label at the given index.

    Parameters

    • index: number

    Returns void

getLabelOffsetDirection

  • getLabelOffsetDirection(index: number): Vec3
  • Gets the offset direction of the label at the given index.

    Parameters

    • index: number

    Returns Vec3

getLabelOffsetPosition

  • getLabelOffsetPosition(index: number): Vec3
  • Gets the offset position of the label at the given index.

    Parameters

    • index: number

    Returns Vec3

getLabelPosition

  • getLabelPosition(index: number): Vec3
  • Gets the position of the label at the given index.

    Parameters

    • index: number

    Returns Vec3

getLabelText

  • getLabelText(index: number): string
  • Gets the text of the label at the given index.

    Parameters

    • index: number

    Returns string

rayIntersect

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

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

setLabelPosition

  • setLabelPosition(index: number, position: Vec3): void
  • Sets the position of the label at the given index.

    Parameters

    • index: number
    • position: Vec3

    Returns void

setLabelText

  • setLabelText(index: number, text: string): void
  • Sets the text of the label at the given index.

    Parameters

    • index: number
    • text: string

    Returns void

Generated using TypeDoc