Skip to content

usePrimitiveCollection

Similar to useEntityCollection, but returns a PrimitiveCollection.

Usage

In default, it synchronizes with viewer.scene.primitives in the context:

js
const primitives = usePrimitiveCollection()
// Automatically clear `primitives` while the component unmounted

You can pass in a PrimitiveCollection manually as a target synchronized with:

js
const collection = new Cesium.PrimitiveCollection()
usePrimitiveCollection(collection)

demo

Type Declarations

Details
ts
/**
 * Create a PrimitiveCollection, which synchronizes with the `viewer.scene.primitives`.
 * It will be cleared when the component is unmounted.
 *
 * @returns Will be cleared when the scope disposed
 */
export declare function usePrimitiveCollection(
  source?: Cesium.PrimitiveCollection,
): Cesium.PrimitiveCollection

Source

sourcedemo