New Plugin Multi-Color Triangle

Good Morning Cesium Team,

I wanted to make a new post regarding steps I need to take to get some functionality I've worked on for a project at my lab added to your plugins page. I've mainly reused the percolorinstanceflat shaders and hacked your current polygon library to have the minimal variables needed to make a multicolor triangle. However, I do plan on adding more functionality as time permits (I'm a masters student at Purdue). Here's my library... https://github.com/brianolsen87/cesium-plugins .

I really like the cesium library and would like to contribute when possible. My plugins repo has examples to meet the requirements laid out here...https://cesiumjs.org/2014/01/16/Introducing-Cesium-Plugins/ and here https://github.com/AnalyticalGraphicsInc/cesium-plugins-list.

I was previously discussing with Patrick on this discussion thread about how to do the multi-color polygon shading... https://groups.google.com/forum/embed/?place=forum/cesium-dev&showsearch=true&showpopout=true&hideforumtitle=true&fragments=true&parenturl=http%3A%2F%2Fcesiumjs.org%2Fforum.html%23!msg%2Fcesium-dev%2FULxqzpaQ68s%2FFJBsisdfys0J#!topic/cesium-dev/ULxqzpaQ68s.

I'm not the only one in the community looking for this functionality either...https://groups.google.com/forum/embed/?place=forum/cesium-dev&showsearch=true&showpopout=true&hideforumtitle=true&fragments=true&parenturl=https%3A%2F%2Fcesiumjs.org%2Fforum.html#!topic/cesium-dev/1t-rTVuAI_Y.

Bugs:
1) I am having trouble getting createMultiColorPolygon to work. So currently it's being done synchronously calling createGeometry. When you have a chance could you see if there's something wrong I'm doing? Do I need the pack/unpack methods in my geometry before this will work?

Future Plans:
1) Add in the pack/unpack functions to my geometry class. (This may also be causing some issues with using a web worker)

2) Allow extruded multi-color triangle (1 color per (lat/long))

3) Build off item 2 and do what's being done in ground polygon branch but with multi color triangles so we can render multi-color polygons on a terrain.

4) See about extending functionality to Entity API.

5) I've considered adding a Graph API to specify 3D shapes in space but this my be too complex for a browser.

Any suggestions of what I need to do before you guys can list before listing me on the plugins page? I've been contacted once stating that they couldn't get my implementation running and I believe it's due to the bug I've listed above. More details to come.

Thanks guys! Keep up the great work!

Brian

Hello Brian,

Wow! Great work! We would love to add this to our list of plugins. When you’re ready, fork the cesium-plugins-list repo and create a pull request with your plugin added to the list.

I’m not exactly sure what you mean by your having trouble getting createMultiColorPolygon to work. I didn’t see that in your repo anywhere. Can you give me more information? I’d be happy to take a look.

Thanks!

Hannah

Hi Hannah,

Thanks for the reply. So all of my files are exist outside of the Cesium library except I wasn't sure how to set up a worker without adding it in the Workers directory. So I tried adding createMultiColorPolygon worker in [that directory under the Cesium library](https://github.com/brianolsen87/cesium-plugins/blob/master/www/Lib/Cesium/Workers/createMultiColorTriangleGeometry.js), however when I try to create a triangle asynchronously by calling the worker it doesn't work. As of now this library can only render synchronously.

Also will having the pack/unpack methods result in a speed up or just a space savings?

Also how do you add a link in these forums...I thought perhaps it used markdown.

Implementing the pack/unpack methods aren’t necessary but they will provide both a speed up and space savings.

You will need to create a file similar to all of the create*Geometry files. This is the code that will unpack/create the geometry executed on the web worker. There is an undocumented property on the geometry that tells the worker where to load the file from. It is called _workerName and is the name of the file relative to the Workers directory. It’s a private/undocumented property because we plan to change how the Primitive API uses web workers in the future.

I found the repo for this project and tried to use it, but it crashes with the current way the project is set up. Is this something that Cesium is going to support? If not, is this something that Cesium will ever offer an alternative to?

Any type of feature that would allow users to create contour or heat map overlays would be really useful. Especially if it was something that we could use for time-series data.

Hi Chris,

I am having an issue getting MultiColorTriangle module to work correctly with worker nodes when using this as a plugin. The only way I have gotten my code to work using workers is by forking the cesium repo and adding it to their internal list.

That being said I have expressed interest to the Cesium team about adding this functionality to their internal code but would be a lot more work on my part as I would have to adhere to their protocols to do so and this would take some time.

There are a few things you can do:

1) Instead of creating the geometry asynchronously, you need to call the synchronous version of the call. See www/App/simpleMain.js line 61.
2) I haven't tested my code beyond Cesium version: 1.12 (released 2015-08-03) so if you are doing step 1 already then verify your Cesium version isn't conflicting by trying to use the older version.
3) I believe if a heat map is all you're after there are a few other projects the deal specifically with heat maps. My project is a little more generalized in that it is a component that can build a heat map, kde map, etc...

If you're just using my app and it's not running it may be something on your end but I will try to see if I can get it to run.

While I'm here is there somebody from Cesium who could help me with this issue? Would it be of interest to the team to add this feature? I will be able to work on it in a few months.

Hi Brian,

Here were my steps:
1) downloaded zipped project here: https://github.com/brianolsen87/cesium-plugins
2) unzipped on desktop, tried to open (using chrome both simple.html and stlcrime.html in the www folder.

It looks like it only crashes if I'm using chrome. It works on IE or firefox. However, the earth shows up as see-through. Not a huge deal, but figured you might want to know.

This seems to be the problem: http://stackoverflow.com/questions/24087757/three-js-and-loading-a-cross-domain-image

The exact error message I'm seeing is:
SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at file:MY_USER_HERE/Desktop/cesium-plugins-master%20(1)/cesium-plugins-master/www/Lib/Cesium/Assets/Textures/moonSmall.jpg may not be loaded.

Chris based on your error message it seems like you haven't enabled cross-origin resource sharing.

What kind of web server are you using? IIS, Apache, etc...

I'm not doing any hosting or anything. I'm just trying to open your plugin as is using a web browser. I just downloaded it from the repo, and then double click simple.html to open it. I just had a co-worker reproduce this too. He got the same error for chrome, and then he tried it on his mac and got this with safari:

RuntimeError: Vertex shader failed to compile. COmpile log: error: wrong operand types 'no operation '-' exists that takes a left hand operand of type 'in highp 3-component vector of float' and a right hand operand of type 'uniform lowp samplerCube' (or there is no acceptable conversion)

It's possible this may be something to do with security measures here at work. But that would seem unlikely since I'm running it locally from my machine. However, I'll try to reproduce this at home on a non-work machine tonight.

Cesium needs to be hosted to enable all features.

They have a nice tutorial for this http://cesiumjs.org/tutorials/cesium-up-and-running/

Quoting from this, "In order for the application to actually work, it needs to run within a web server."

If you run my plugin instead of their setup it should work. Let me know what you find.

Sorry I meant we weren't doing anything fancy with an external web server for hosting. It just sits on localhost. If I take the "clicking here" link from your last post's tutorial link, it comes up without any issues.

Hmm...if my version is running on you machine then I believe it is a CORS setting on your localhost or possibly there is a library missing. In my examples I do serve up a few datasets in my Assets folder that may require you to deploy on a remote host. I haven't tested it using the node.js local server yet. Time permitting I'll try to test this. In the mean time if you need to use my library I would suggest setting up a remote host. I wish I could do more at the moment but I'll be busy the rest of the semester until May. After I graduate I plan on putting in some time on this feature if the Cesium team expresses any interest in it.