# Using Geometry when creating Primitives

**URL:** <https://community.cesium.com/t/using-geometry-when-creating-primitives/2000>\
**Category:** CesiumJS\
**Created:** [February 12, 2015, 5:04am UTC](https://community.cesium.com/t/using-geometry-when-creating-primitives/2000 "2015-02-12T05:04:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brendan\_Studds](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@Brendan\_Studds](https://community.cesium.com/u/Brendan_Studds)\
**Post date:** [February 12, 2015, 5:04am UTC](https://community.cesium.com/t/using-geometry-when-creating-primitives/2000/1 "2015-02-12T05:04:25Z")

</div>

Hi all,

We’ve been using the [Geometry](http://cesiumjs.org/Cesium/Build/Documentation/Geometry.html) 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  
})  
});

``

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [February 12, 2015, 2:35pm UTC](https://community.cesium.com/t/using-geometry-when-creating-primitives/2000/2 "2015-02-12T14:35:48Z")

</div>

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](https://github.com/AnalyticalGraphicsInc/cesium/issues/2488)

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [February 12, 2015, 2:37pm UTC](https://community.cesium.com/t/using-geometry-when-creating-primitives/2000/3 "2015-02-12T14:37:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brendan\_Studds](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@Brendan\_Studds](https://community.cesium.com/u/Brendan_Studds)\
**Post date:** [February 16, 2015, 1:41am UTC](https://community.cesium.com/t/using-geometry-when-creating-primitives/2000/4 "2015-02-16T01:41:31Z")

</div>

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