material.shaderSource is undefined

Hi all!

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

I am trying to draw a PolyLineCollection of about 30 lines to a 2D Scene with a WebMercatorProjection, and getting the following error:

Cesium.js:221938 An error occurred while rendering. Rendering has stopped.
undefined
TypeError: Cannot read property 'search' of undefined
TypeError: Cannot read property 'search' of undefined
    at PolylineBucket.updateShader (http://localhost:8080/js/lib/cesium/Build/CesiumUnminified/Cesium.js:141653:39)
    at createVertexArrays (http://localhost:8080/js/lib/cesium/Build/CesiumUnminified/Cesium.js:141300:24)
    at PolylineCollection.update (http://localhost:8080/js/lib/cesium/Build/CesiumUnminified/Cesium.js:140947:13) ... trace continues

The problem is the material's shaderSource property is undefined. The error occurs after the lines have been added, upon the next render call.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I am trying to implement a dynamic graticule for our web app. Since it uses the 2D mode exclusively, it is reasonably easy to pick the correct scale based on what the camera's frustum can see. (3D support may come someday).

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

I'm using Cesium version 1.36, Chrome Version 60.0.3112.90 (Official Build) (32-bit), and Windows 10 64-bit.

Hi Jay,

Can you provide us with a code snippet or Sandcastle example so we can track down exactly what’s going wrong here?

Thanks!

Gabby

Let me know if that sandbox works. I managed to get the error.

Note that if you comment out the line specifying material, it would work and draw the grid of white lines.

I was able to reproduce the error.

The material property is expecting a material object, not a color object.

Create a new red material:

var material = Cesium.Material.fromType(‘Color’);

material.uniforms.color = Cesium.Color.RED;

Then set the polyline material property to that object instead of Cesium.Color.RED.

Thanks!

Gabby

Thanks Gabby! I suspected it was something like that, but I didn't figure out how to use the Material to fix it. Note that the Polyline example in the sandbox also uses a Cesium.Color directly in the 'material' option when it constructs it's polylines, as well as Cesium.Material

That it does! It’s actually a distinction between the constructors for Polyline and PolylineGraphics objects. When you add to a PolylineCollection, you use a Polyline object, but when you add to an EntityCollection, you use a PolylineGraphics object. A subtle but important distinction as it turns out!