I’ve started using the building models from Open City Model imported into Ion. The building models in Open City are not textured or colored.
I can randomly color individual buildings using this code:
var myrng = new Math.seedrandom(‘hello.’); // always use same random sequence (see seedrandom.js)
for (var i = 0; i < tileID.length; i++) {
tileset[i] = viewer.scene.primitives.add( // add my Open City Model assets
new Cesium.Cesium3DTileset({
shadows: Cesium.ShadowMode.RECEIVE_ONLY, // workaround to avoid shadow z-fighting
url: Cesium.IonResource.fromAssetId(tileID[i]) // tileID[ ] = my Ion assets
})
);
tileset[i].style = new Cesium.Cesium3DTileStyle();
tileset[i].style.color = {
evaluateColor : function(feature, result) {
return Cesium.Color.clone(Cesium.Color.GRAY.darken(myrng()*0.3+0.4, new Cesium.Color()), result); // apply random color
}
}
}
-
Is it possible to color the top plane of each building (like a roof) using .style?
-
Is it possible to texture the buildings using .style?
-
There is way too much z-fighting to make shadows useable in this case except in the RECEIVE_ONLY mode. Any suggestions?