Using Geometry when creating Primitives

Hi all,

We’ve been using the Geometry object directly (see snippet below) to make custom 3D primitives. Recently we’ve upgraded from cesium version 1.0 to 1.6 and this causes Primitive.update to throw an error that “_workerName is not defined” on rendering.

Looking into this, I think there meant to be a worker defined to convert the specific type of geometry (eg. createBoxGeometry for BoxGeometry ) to the Geometry object type. As we are not using one of the specific Geometry types, there is no worker to convert it.

I can fix this by not using the workers and rendering the primitives synchronously, which would not be a good option. Alternatively, I’ve modified Geometry to have a _workerName and created a corresponding worker in Cesium, but this seems a temporary solution. Does anyone have any suggestions for a more permanent solution?

Thanks,
Brendan Studds

Current code;
var attributes = new GeometryAttributes({
position: new GeometryAttribute({
componentDatatype: ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: this._positions
})
});
var geometry = new Geometry({
attributes: attributes,
indices: this._indices,
primitiveType: PrimitiveType.TRIANGLES,
boundingSphere: BoundingSphere.fromVertices(this._positions)
});
var instance = new GeometryInstance({
id: id,
geometry: geometry,
attributes: {
color: color
}
});
var primitive = new Primitive({
geometryInstances: instance,
appearance: new PerInstanceColorAppearance({
flat: false,
translucent: false
})
});

``

Can you try adding asynchronous : false to the Primitive constructor. Since your geometry is already created, it shouldn’t affect behavior but will avoid the issue. This is a bug either way because we should recognize already created geometry. I created this issue so we fix it either way: https://github.com/AnalyticalGraphicsInc/cesium/issues/2488

Just to clarify, Primitives are always rendered synchronously, setting asynchronous to false controls geometry creation, not rendering. Since you have a Primitive with a single geometry that is already created, it won’t change performance at all.

I see, clearly had a flawed understanding of that. Adding ‘asynchronous: false’ does solve the problem. Thanks for clarifying that.