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.
- The options object takes the following properties
- {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms each label from model to world coordinates.
- {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown.
- {Scene} [options.scene] Must be passed in for labels that use the height reference property or will be depth tested against the globe.
performance For best performance, prefer a few collections, each with many labels, to
many collections with only a few labels each. Avoid having collections where some
labels change every frame and others do not; instead, create one or more collections
for static labels, and one or more collections for dynamic labels.
// Create a label collection with two labels
var labels = scene.primitives.add(new Cesium.LabelCollection());
labels.add({
position : new Cesium.Cartesian3(1.0, 2.0, 3.0),
text : 'A label'
});
labels.add({
position : new Cesium.Cartesian3(4.0, 5.0, 6.0),
text : 'Another label'
});
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.
Example labels
Labels are added and removed from the collection using LabelCollection#add and LabelCollection#remove
alias LabelCollection
- The options object takes the following properties - {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms each label from model to world coordinates. - {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown. - {Scene} [options.scene] Must be passed in for labels that use the height reference property or will be depth tested against the globe.
performance For best performance, prefer a few collections, each with many labels, to many collections with only a few labels each. Avoid having collections where some labels change every frame and others do not; instead, create one or more collections for static labels, and one or more collections for dynamic labels.
// Create a label collection with two labels var labels = scene.primitives.add(new Cesium.LabelCollection()); labels.add({ position : new Cesium.Cartesian3(1.0, 2.0, 3.0), text : 'A label' }); labels.add({ position : new Cesium.Cartesian3(4.0, 5.0, 6.0), text : 'Another label' });
BillboardCollection demo Sandcastle Labels Demo
Label
LabelCollection#remove
LabelCollection#add