# ClassificationPrimitive

#### new Cesium.ClassificationPrimitive(options)
engine/Source/Scene/ClassificationPrimitive.js 72

A classification primitive represents a volume enclosing geometry in the `Scene` to be highlighted.

A primitive combines geometry instances with an `Appearance` that describes the full shading, including `Material` and `RenderState`. Roughly, the geometry instance defines the structure and placement, and the appearance defines the visual characteristics. Decoupling geometry and appearance allows us to mix and match most of them and add a new geometry or appearance independently of each other. Only `PerInstanceColorAppearance` with the same color across all instances is supported at this time when using ClassificationPrimitive directly. For full `Appearance` support when classifying terrain or 3D Tiles use `GroundPrimitive` instead.

For correct rendering, this feature requires the EXT_frag_depth WebGL extension. For hardware that do not support this extension, there will be rendering artifacts for some viewing angles.

Valid geometries are `BoxGeometry`, `CylinderGeometry`, `EllipsoidGeometry`, `PolylineVolumeGeometry`, and `SphereGeometry`.

Geometries that follow the surface of the ellipsoid, such as `CircleGeometry`, `CorridorGeometry`, `EllipseGeometry`, `PolygonGeometry`, and `RectangleGeometry`, are also valid if they are extruded volumes; otherwise, they will not be rendered.

Name | Type | Description
--- | --- | ---
`options` | object | optional Object with the following properties:
Name | Type | Default | Description
--- | --- | --- | ---
`geometryInstances` | Array | GeometryInstance |  | optional The geometry instances to render. This can either be a single instance or an array of length one.
`appearance` | Appearance |  | optional The appearance used to render the primitive. Defaults to PerInstanceColorAppearance when GeometryInstances have a color attribute.
`show` | boolean | `true` | optional Determines if this primitive will be shown.
`vertexCacheOptimize` | boolean | `false` | optional When `true`, geometry vertices are optimized for the pre and post-vertex-shader caches.
`interleave` | boolean | `false` | optional When `true`, geometry vertex attributes are interleaved, which can slightly improve rendering performance but increases load time.
`compressVertices` | boolean | `true` | optional When `true`, the geometry vertices are compressed, which will save memory.
`releaseGeometryInstances` | boolean | `true` | optional When `true`, the primitive does not keep a reference to the input `geometryInstances` to save memory.
`allowPicking` | boolean | `true` | optional When `true`, each geometry instance will only be pickable with `Scene#pick`. When `false`, GPU memory is saved.
`asynchronous` | boolean | `true` | optional Determines if the primitive will be created asynchronously or block until ready. If false initializeTerrainHeights() must be called first.
`classificationType` | ClassificationType | `ClassificationType.BOTH` | optional Determines whether terrain, 3D Tiles or both will be classified.
`debugShowBoundingVolume` | boolean | `false` | optional For debugging only. Determines if this primitive's commands' bounding spheres are shown.
`debugShowShadowVolume` | boolean | `false` | optional For debugging only. Determines if the shadow volume for each geometry in the primitive is drawn. Must be `true` on creation for the volumes to be created before the geometry is released or options.releaseGeometryInstance must be `false`.

##### See:

- Primitive
- GroundPrimitive
- GeometryInstance
- Appearance

### Members

#### readonly allowPicking : boolean
engine/Source/Scene/ClassificationPrimitive.js 261

When `true`, each geometry instance will only be pickable with `Scene#pick`. When `false`, GPU memory is saved.

Default Value: `true`

#### readonly asynchronous : boolean
engine/Source/Scene/ClassificationPrimitive.js 277

Determines if the geometry instances will be created and batched on a web worker.

Default Value: `true`

#### classificationType : ClassificationType
engine/Source/Scene/ClassificationPrimitive.js 111

Determines whether terrain, 3D Tiles or both will be classified.

Default Value: `ClassificationType.BOTH`

#### readonly compressVertices : boolean
engine/Source/Scene/ClassificationPrimitive.js 293

When `true`, geometry vertices are compressed, which will save memory.

Default Value: `true`

#### debugShowBoundingVolume : boolean
engine/Source/Scene/ClassificationPrimitive.js 125

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

Draws the bounding sphere for each draw command in the primitive.

Default Value: `false`

#### debugShowShadowVolume : boolean
engine/Source/Scene/ClassificationPrimitive.js 139

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

Draws the shadow volume for each geometry in the primitive.

Default Value: `false`

#### readonly geometryInstances : Array|GeometryInstance
engine/Source/Scene/ClassificationPrimitive.js 94

The geometry instance rendered with this primitive. This may be `undefined` if `options.releaseGeometryInstances` is `true` when the primitive is constructed.

Changing this property after the primitive is rendered has no effect.

Because of the rendering technique used, all geometry instances must be the same color. If there is an instance with a differing color, a `DeveloperError` will be thrown on the first attempt to render.

Default Value: `undefined`

#### readonly interleave : boolean
engine/Source/Scene/ClassificationPrimitive.js 229

Determines if geometry vertex attributes are interleaved, which can slightly improve rendering performance.

Default Value: `false`

#### readonly ready : boolean
engine/Source/Scene/ClassificationPrimitive.js 309

Determines if the primitive is complete and ready to render. If this property is true, the primitive will be rendered the next time that `ClassificationPrimitive#update` is called.

#### readonly releaseGeometryInstances : boolean
engine/Source/Scene/ClassificationPrimitive.js 245

When `true`, the primitive does not keep a reference to the input `geometryInstances` to save memory.

Default Value: `true`

#### show : boolean
engine/Source/Scene/ClassificationPrimitive.js 103

Determines if the primitive will be shown. This affects all geometry instances in the primitive.

Default Value: `true`

#### readonly vertexCacheOptimize : boolean
engine/Source/Scene/ClassificationPrimitive.js 213

When `true`, geometry vertices are optimized for the pre and post-vertex-shader caches.

Default Value: `true`

### Methods

#### static Cesium.ClassificationPrimitive.isSupported(scene) → boolean
engine/Source/Scene/ClassificationPrimitive.js 339

Determines if ClassificationPrimitive rendering is supported.

Name | Type | Description
--- | --- | ---
`scene` | Scene | The scene.

##### Returns:

`true` if ClassificationPrimitives are supported; otherwise, returns `false`

#### destroy()
engine/Source/Scene/ClassificationPrimitive.js 1386

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.

Once an object is destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception. Therefore, assign the return value (`undefined`) to the object as done in the example.

##### Throws:

- DeveloperError : This object was destroyed, i.e., destroy() was called.

##### Example:

    e = e && e.destroy();

##### See:

- ClassificationPrimitive#isDestroyed

#### getGeometryInstanceAttributes(id) → object
engine/Source/Scene/ClassificationPrimitive.js 1342

Returns the modifiable per-instance attributes for a `GeometryInstance`.

Name | Type | Description
--- | --- | ---
`id` | * | The id of the `GeometryInstance`.

##### Returns:

The typed array in the attribute's format or undefined if the is no instance with id.

##### Throws:

- DeveloperError : must call update before calling getGeometryInstanceAttributes.

##### Example:

    const attributes = primitive.getGeometryInstanceAttributes('an id');
    attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
    attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);

#### isDestroyed() → boolean
engine/Source/Scene/ClassificationPrimitive.js 1366

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

If this object was destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception.

##### Returns:

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

##### See:

- ClassificationPrimitive#destroy

#### update()
engine/Source/Scene/ClassificationPrimitive.js 1050

Called when `Viewer` or `CesiumWidget` render the scene to get the draw commands needed to render this primitive.

Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:

##### Throws:

- DeveloperError : All instance geometries must have the same primitiveType.
- DeveloperError : Appearance and material have a uniform with the same name.
- DeveloperError : Not all of the geometry instances have the same color attribute.

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.