# VoxelPrimitive

#### new Cesium.VoxelPrimitive(options)
engine/Source/Scene/VoxelPrimitive.js 52

A primitive that renders voxel data from a `VoxelProvider`.

Name | Type | Description
--- | --- | ---
`options` | object | optional Object with the following properties:
Name | Type | Default | Description
--- | --- | --- | ---
`provider` | VoxelProvider |  | optional The voxel provider that supplies the primitive with tile data.
`modelMatrix` | Matrix4 | `Matrix4.IDENTITY` | optional The model matrix used to transform the primitive.
`customShader` | CustomShader |  | optional The custom shader used to style the primitive.
`clock` | Clock |  | optional The clock used to control time dynamic behavior.
`calculateStatistics` | boolean |  | optional Generate statistics for performance profile.

##### Experimental

This feature is not final and is subject to change without Cesium's standard deprecation policy.

##### See:

- VoxelProvider
- Cesium3DTilesVoxelProvider
- VoxelShapeType
- Custom Shader Guide

### Members

#### allTilesLoaded : Event
engine/Source/Scene/VoxelPrimitive.js 549

The event fired to indicate that all tiles that meet the screen space error this frame are loaded. The voxel primitive is completely loaded for this view.

This event is fired at the end of the frame after the scene is rendered.

##### Example:

    voxelPrimitive.allTilesLoaded.addEventListener(function() {
        console.log('All tiles are loaded');
    });

#### readonly boundingSphere : BoundingSphere
engine/Source/Scene/VoxelPrimitive.js 629

Gets the bounding sphere.

#### clippingPlanes : ClippingPlaneCollection
engine/Source/Scene/VoxelPrimitive.js 1015

The `ClippingPlaneCollection` used to selectively disable rendering the primitive.

#### customShader : CustomShader
engine/Source/Scene/VoxelPrimitive.js 1032

Gets or sets the custom shader. If undefined, `VoxelPrimitive.DefaultCustomShader` is set.

##### See:

- Custom Shader Guide

#### readonly customShaderCompilationEvent : Event
engine/Source/Scene/VoxelPrimitive.js 1069

Gets an event that is raised whenever a custom shader is compiled.

#### debugDraw : boolean
engine/Source/Scene/VoxelPrimitive.js 804

Gets or sets whether or not to render debug visualizations.

#### depthTest : boolean
engine/Source/Scene/VoxelPrimitive.js 823

Gets or sets whether or not to test against depth when rendering.

#### readonly dimensions : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 689

Gets the dimensions of each voxel tile, in z-up orientation. Does not include padding.

#### disableUpdate : boolean
engine/Source/Scene/VoxelPrimitive.js 785

Gets or sets whether or not the primitive should update when the view changes.

#### initialTilesLoaded : Event
engine/Source/Scene/VoxelPrimitive.js 567

The event fired to indicate that all tiles that meet the screen space error this frame are loaded. This event is fired once when all tiles in the initial view are loaded.

This event is fired at the end of the frame after the scene is rendered.

##### Example:

    voxelPrimitive.initialTilesLoaded.addEventListener(function() {
        console.log('Initial tiles are loaded');
    });

##### See:

- Cesium3DTileset#allTilesLoaded

#### readonly inputDimensions : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 702

Gets the dimensions of one tile of the input voxel data, in the input orientation. Includes padding.

#### loadProgress : Event
engine/Source/Scene/VoxelPrimitive.js 533

The event fired to indicate progress of loading new tiles. This event is fired when a new tile is requested, when a requested tile is finished downloading, and when a downloaded tile has been processed and is ready to render.

The number of pending tile requests, `numberOfPendingRequests`, and number of tiles processing, `numberOfTilesProcessing` are passed to the event listener.

This event is fired at the end of the frame after the scene is rendered.

##### Example:

    voxelPrimitive.loadProgress.addEventListener(function(numberOfPendingRequests, numberOfTilesProcessing) {
        if ((numberOfPendingRequests === 0) && (numberOfTilesProcessing === 0)) {
            console.log('Finished loading');
            return;
        }

        console.log(`Loading: requests: ${numberOfPendingRequests}, processing: ${numberOfTilesProcessing}`);
    });

#### maxBounds : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 950

Gets or sets the maximum bounds in the shape's local coordinate system. Voxel data is stretched or squashed to fit the bounds.

#### maxClippingBounds : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 993

Gets or sets the maximum clipping location in the shape's local coordinate system. Any voxel content outside the range is clipped.

#### readonly maximumValues : Array.<Array.<number>>
engine/Source/Scene/VoxelPrimitive.js 754

Gets the maximum value per channel of the voxel data.

#### minBounds : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 930

Gets or sets the minimum bounds in the shape's local coordinate system. Voxel data is stretched or squashed to fit the bounds.

#### minClippingBounds : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 970

Gets or sets the minimum clipping location in the shape's local coordinate system. Any voxel content outside the range is clipped.

#### readonly minimumValues : Array.<Array.<number>>
engine/Source/Scene/VoxelPrimitive.js 741

Gets the minimum value per channel of the voxel data.

#### readonly modelMatrix : Matrix4
engine/Source/Scene/VoxelPrimitive.js 655

Gets the model matrix.

#### nearestSampling : boolean
engine/Source/Scene/VoxelPrimitive.js 845

Gets or sets the nearest sampling.

#### readonly orientedBoundingBox : OrientedBoundingBox
engine/Source/Scene/VoxelPrimitive.js 642

Gets the oriented bounding box.

#### readonly paddingAfter : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 728

Gets the padding after the voxel data.

#### readonly paddingBefore : Cartesian3
engine/Source/Scene/VoxelPrimitive.js 715

Gets the padding before the voxel data.

#### readonly provider : VoxelProvider
engine/Source/Scene/VoxelPrimitive.js 616

Gets the `VoxelProvider` associated with this primitive.

#### readonly ready : boolean
engine/Source/Scene/VoxelPrimitive.js 603

Gets a value indicating whether or not the primitive is ready for use.

#### screenSpaceError : number
engine/Source/Scene/VoxelPrimitive.js 889

Gets or sets the screen space error in pixels. If the screen space size of a voxel is greater than the screen space error, the tile is subdivided. Lower screen space error corresponds with higher detail rendering, but could result in worse performance and higher memory consumption.

#### readonly shape : VoxelShapeType
engine/Source/Scene/VoxelPrimitive.js 675

Gets the shape type.

#### show : boolean
engine/Source/Scene/VoxelPrimitive.js 766

Gets or sets whether or not this primitive should be displayed.

#### stepSize : number
engine/Source/Scene/VoxelPrimitive.js 910

Gets or sets the step size multiplier used during raymarching. The lower the value, the higher the rendering quality, but also the worse the performance.

#### tileFailed : Event
engine/Source/Scene/VoxelPrimitive.js 494

The event fired to indicate that a tile's content failed to load.

##### Example:

    voxelPrimitive.tileFailed.addEventListener(function() {
        console.log('An error occurred loading tile.');
    });

#### tileLoad : Event
engine/Source/Scene/VoxelPrimitive.js 467

The event fired to indicate that a tile's content was loaded.

This event is fired during the tileset traversal while the frame is being rendered so that updates to the tile take effect in the same frame. Do not create or modify Cesium entities or primitives during the event listener.

##### Example:

    voxelPrimitive.tileLoad.addEventListener(function() {
        console.log('A tile was loaded.');
    });

#### tileUnload : Event
engine/Source/Scene/VoxelPrimitive.js 507

The event fired to indicate that a tile's content was unloaded.

##### Example:

    voxelPrimitive.tileUnload.addEventListener(function() {
        console.log('A tile was unloaded from the cache.');
    });

#### tileVisible : Event
engine/Source/Scene/VoxelPrimitive.js 482

This event fires once for each visible tile in a frame.

This event is fired during the traversal while the frame is being rendered.

##### Example:

    voxelPrimitive.tileVisible.addEventListener(function() {
        console.log('A tile is visible.');
    });

### Methods

#### destroy()
engine/Source/Scene/VoxelPrimitive.js 1850

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:

    voxelPrimitive = voxelPrimitive && voxelPrimitive.destroy();

##### See:

- VoxelPrimitive#isDestroyed

#### isDestroyed() → boolean
engine/Source/Scene/VoxelPrimitive.js 1831

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:

- VoxelPrimitive#destroy

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