Hey guys, I have a kml file that contains polygons representing shapes of buildings that have altitude values indicating the height of the rooftops. I wanted to make these render as they do in google earth and draw extra polygons for the sides of the buildings. I am noticing that when I rotate the camera around the buildings now, certain sides start to disappear. Any idea of what could be causing this strangeness?
The polygon is designed for polygons laid on the globe. We have separate primitives planned for walls and boxes like these.
What you are seeing is called backface culling; the backsides of the triangles are being discarded on purpose because when a polygon is laid on the globe, if it is on the other side of the globe, the backfaces can be discarded.
You can use the polygon as a workaround but you’ll run into other minor issues with shading, and occlusion culling at the silhouette of the globe. To turn off backface culling, change lines 745 and 798 in Polygon.js to “enabled : false”
If you’re interested in implementing a wall primitive, I can provide some guidance. It is simpler than the polygon in some ways, but will require some design to share code with the polygon.
Thanks Patrick, that did the trick alright! For now, I just created a flag _cullingEnabled for Polygon so that I can turn it off for building sides. I looked a little while into what it would take to create a box primitive as you described, but it seemed like it would be some major refactoring to implement this way. Does the requirejs library support object inheritence.? It seems like you guys are using static functions inside of psuedo-base class objects to accomplish inheritance. Ideally, it would be nice to implement the box primitive like how the visualizers currently work by building complex objects with the base primitives and adding them to the scene. It seems like all I really need is a polygoncollection and my box object class would accept a list of coordinates parallel to the globe’s surface, and I would do what I am currently doing here by adding the sides and disabling the culling for those sides.
I am kind of under the gun here and have to go with the quick band-aid solution for now. Hopefully we can continue this discussion and find some time in the next few weeks to contribute something that works for the both of us.
That’s OK for now. For the full solution, we don’t just want to turn off culling. We want to use different shaders with different vertex data for normals and texture coordinates. It won’t use inheritance; it will use composition. I can draft up a design when you let me know. In the meantime, I have to keep my attention on 3D models.
To answer your question about RequireJS and object inheritance, RequireJS/AMD doesn’t impact the options for doing inheritance. Normal prototypal inheritance, or Object.create, etc. would all work fine by requiring in the base type. I think our current code simply reflects a preference for composition over inheritance.
I didn't manage to instantiate a perpendicular polygon to the globe.
Is there please an example of code that generate a similar result as your screenshot which work in sandcastle?
Or have I to modify some code to do that?