The VectorLayerCounterpart class manages the conversion and lifecycle of OpenLayers vector layers into Cesium primitives. It maintains a context that tracks the projection, billboard collections, and a mapping between OpenLayers features and their corresponding Cesium Primitive or Billboard objects.
When initializing a counterpart, it creates a rootCollection_ (a PrimitiveCollection) that contains both a BillboardCollection and a PrimitiveCollection. To render the converted layer in Cesium, you must retrieve this root collection using getRootPrimitive() and add it to your Cesium scene.
To prevent memory leaks, call destroy() to remove all OpenLayers event listeners associated with the counterpart.
// Conceptual usage of VectorLayerCounterpart
const counterpart = new VectorLayerCounterpart(layerProjection, cesiumScene);
const rootPrimitive = counterpart.getRootPrimitive();
// Add the root collection to the Cesium scene
cesiumScene.primitives.add(rootPrimitive);
// Later, clean up listeners
counterpart.destroy();