LabelCollection
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
Types
Properties
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.
This property is for debugging only; it is not for production use nor is it optimized.
Returns the number of labels in this collection. This is commonly used with LabelCollection.get to iterate over all the labels in the collection.
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.
Functions
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.
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.
Returns true if this object was destroyed; otherwise, false.