LabelCollection

external class LabelCollection(options: LabelCollection.ConstructorOptions? = definedExternally)(source)

A renderable collection of labels. Labels are viewport-aligned text positioned in the 3D scene. Each label can have a different font, color, scale, etc.

Labels are added and removed from the collection using LabelCollection.add and LabelCollection.remove.

// Create a label collection with two labels
const labels = scene.primitives.add(new LabelCollection());
labels.add({
position : new Cartesian3(1.0, 2.0, 3.0),
text : 'A label'
});
labels.add({
position : new Cartesian3(4.0, 5.0, 6.0),
text : 'Another label'
});

See also

Constructors

Link copied to clipboard
constructor(options: LabelCollection.ConstructorOptions? = definedExternally)

Types

Link copied to clipboard

Properties

Link copied to clipboard

The label blending option. The default is used for rendering both opaque and translucent labels. However, if either all of the labels are completely opaque or all are completely translucent, setting the technique to BlendOption.OPAQUE or BlendOption.TRANSLUCENT can improve performance by up to 2x.

Link copied to clipboard

The distance from the camera, beyond which, labels are depth-tested against an approximation of the globe ellipsoid rather than against the full globe depth buffer. When set to 0, the approximate depth test is always applied. When set to Number.POSITIVE_INFINITY, the approximate depth test is never applied.

This setting only applies when a label's Label.disableDepthTestDistance value would otherwise allow depth testing—i.e., distance from the camera to the label is less than the label's Label.disableDepthTestDistance value.

Link copied to clipboard

This property is for debugging only; it is not for production use nor is it optimized.

Link copied to clipboard
val length: Int

Returns the number of labels in this collection. This is commonly used with LabelCollection.get to iterate over all the labels in the collection.

Link copied to clipboard

The 4x4 transformation matrix that transforms each label in this collection from model to world coordinates. When this is the identity matrix, the labels are drawn in world coordinates, i.e., Earth's WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by Transforms.eastNorthUpToFixedFrame.

Link copied to clipboard

Determines if labels in this collection will be shown.

Link copied to clipboard

The distance from the camera, within which, labels with a Label.heightReference value of HeightReference.CLAMP_TO_GROUND or HeightReference.CLAMP_TO_TERRAIN are depth tested against three key points. This ensures that if any key point of the label is visible, the whole label will be visible. When set to 0, this feature is disabled and portions of a label behind terrain be clipped.

This setting only applies when a labels's Label.disableDepthTestDistance value would otherwise allow depth testing—i.e., distance from the camera to the label is less than the labels's Label.disableDepthTestDistance value.

Functions

Link copied to clipboard
fun add(options: Label.ConstructorOptions? = definedExternally): Label

Creates and adds a label with the specified initial properties to the collection. The added label is returned so it can be modified or removed from the collection later.

Link copied to clipboard
fun contains(label: Label): Boolean

Check whether this collection contains a given label.

Link copied to clipboard
fun destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Link copied to clipboard
fun get(index: Int): Label

Returns the label in the collection at the specified index. Indices are zero-based and increase as labels are added. Removing a label shifts all labels after it to the left, changing their indices. This function is commonly used with LabelCollection.length to iterate over all the labels in the collection.

Link copied to clipboard

Returns true if this object was destroyed; otherwise, false.

Link copied to clipboard
fun remove(label: Label): Boolean

Removes a label from the collection. Once removed, a label is no longer usable.

Link copied to clipboard
fun removeAll()

Removes all labels from the collection.