Cannot read property '_textureAtlas' of undefined with KML data source & primitives

1. A concise explanation of the problem you’re experiencing.

I have an application that allows users to annotate the map with geometries (i.e., circle, points, polygons, etc). Said geometries are created as Cesium primitives. This works well.

Additionally, within the application we are building in a feature where users can import KML files. This works well so far.

The problem I’ve ran into is when I am viewing a KML and then I attempt to draw or view a previously saved drawn geometry/shape I receive a rendering stopped error stating…

Cannot read property ‘_textureAtlas’ of undefined

However, I have found that if I draw geometries/shapes prior to viewing the KML I do not receive the error. Its only after the KMLDataSource has been added and then I attempt to create or view additional geometry primitives I receive the error…

Any thoughts or help would be great!

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.45.0
Windows 7
Chrome 64.0.3282.167

Hi Jason,

Can you provide a code sample, preferably a Sandcastle example, showing the error? It will make this a lot easier to track down.

Thanks,

Gabby

Hey Gabby

I did a quick Sandcastle where I add a simple billboard to a billboard collection after adding a KML data source layer. To get the below error simply make a different selection from the toolbar menu (i.e., change selection from KML - Global Science Facilities to something else)…

This is a long standing “gotcha” in Cesium, never call “viewer.scene.primitives.removeAll();” (we should fix this with at least a better error message). viewer.scene.primitives.removeAll() shouldn’t even exist, (at the top-level scene.primitives level), it’s just a side effect of it being a PrimitiveCollection.

Instead, put all of your own primitives in a PrimitiveCollection and then add/remove just that collection to viewer.scene.primitives.

Hope that helps.

Thanks Matt! I’ll give that a go and see how things shake out.