I’ve got how Entity transform to Primitive, which can be found in private Batch class:
Batch.prototype.update = function () {
// ...
if (this.createPrimitive) {
const geometries = this.geometry.values;
const geometriesLength = geometries.length;
if (geometriesLength > 0) {
primitive = new Primitive({
/* ... */
});
primitives.add(primitive);
isUpdated = false;
}
}
// ...
}
And I know the rendering process of scene object render a frame. Scene obj need update primitiveCollection that hold by itself to create DrawCommand.
My question is, since that Batch create and push new Primitive for Entity into PrimitiveCollection that passed from DataSourceDisplay:
function DataSourceDisplay(/* ... */) {
// ...
const defaultDataSource = new CustomDataSource();
this._onDataSourceAdded(undefined, defaultDataSource);
// ...
}
DataSourceDisplay.prototype._onDataSourceAdded = function (
dataSourceCollection,
dataSource
) {
// ...
const displayPrimitives = this._primitives;
// ...
const primitives = displayPrimitives.add(new PrimitiveCollection());
// ...
dataSource._primitives = primitives; // here will set DataSourceDisplay's PrimitiveCollection to CustomDataSource who hold the Viewer's entityCollection
// ...
}
where scene object will update this PrimitiveCollection (not scene’s default PrimitiveCollection)?
I search all source code but only found one case that Scene object update primitiveCollection:
// Scene.js
function updateAndRenderPrimitives(scene) {
const frameState = scene._frameState;
scene._groundPrimitives.update(frameState);
scene._primitives.update(frameState); // here
updateDebugFrustumPlanes(scene);
updateShadowMaps(scene);
if (scene._globe) {
scene._globe.render(frameState);
}
}