# 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: .. image:: ../../images/MrkLabels.png

Accessors

- `attachmentAppearance`
- `customData`
- `drawMode`
- `labelAppearance`
- `labelAttachmentPoint`
- `labelCount`

Methods

- `add`
- `addWithOffsetDirection`
- `addWithOffsetDirectionFlipTowardEye`
- `addWithOffsetPosition`
- `deleteAll`
- `deleteLabelAt`
- `getLabelOffsetDirection`
- `getLabelOffsetPosition`
- `getLabelPosition`
- `getLabelText`
- `rayIntersect`
- `setCustomDrawOntoCanvasCallback`
- `setLabelOffsetDirection`
- `setLabelOffsetPosition`
- `setLabelPosition`
- `setLabelText`
- `setOccluderTriMesh`

## Accessors

`PartLabels.``attachmentAppearance`()

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

  Return type: | LabelAttachmentAppearance

`PartLabels.``customData`()

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

  Return type: | any

`PartLabels.``customData`(data)

  Arguments: | data (`any`) – None
  Return type: | void

`PartLabels.``drawMode`()

  Draw mode for the labels in this part

  Return type: | LabelDrawMode

`PartLabels.``drawMode`(mode)

  Arguments: | mode (`LabelDrawMode`) – None
  Return type: | void

`PartLabels.``labelAppearance`()

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

  Return type: | LabelAppearance

`PartLabels.``labelAttachmentPoint`()

  Point where the attachment line meets the label

  Return type: | LabelAttachmentPoint

`PartLabels.``labelAttachmentPoint`(attachmentPoint)

  Arguments: | attachmentPoint (`LabelAttachmentPoint`) – None
  Return type: | void

`PartLabels.``labelCount`()

  The number of labels in the part.

  Return type: | number

## Methods

### add

`PartLabels.``add`(text, pos)

  Arguments: | text (`string`) – None pos (`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`) – None pos (`Vec3`) – None offsetDirection (`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`) – None pos (`Vec3`) – None offsetDirection (`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`) – None pos (`Vec3`) – None offsetPosition (`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`) – None hitItem (`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`) – None offsetDirection (`Vec3`) – None flipTowardsEye (`boolean`) – None

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

  Return type: | void

### setLabelOffsetPosition

`PartLabels.``setLabelOffsetPosition`(index, offsetPosition)

  Arguments: | index (`number`) – None offsetPosition (`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`) – None position (`Vec3`) – None

  Sets the position of the label at the given index.

  Return type: | void

### setLabelText

`PartLabels.``setLabelText`(index, text)

  Arguments: | index (`number`) – None text (`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`) – None vertices (`ArrayLike`) – None indices (`ArrayLike`) – None options (`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

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your Docs generative AI assistant. Ask me anything about HOOPS Envision for Web or choose a sample question below to start a conversation:

What is HOOPS Envision for Web?
What are the latest release notes for HOOPS Envision for Web?
How do I start evaluating HOOPS Envision for Web?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...