I’m uploading building and waterbodies 3D models as CityGML to Cesium Ion.
The models have colors associated with them (i.e the buildings have red roofs, grey walls, the waterbodies are blue).
However, when uploaded to CesiumIon, these colors disappear. Whenever I download the uploaded files from
I’ve looked on this forum but couldn’t find an explanation.
I’m trying to find a solution for:
EITHER: Having the appearances from the GML being visible the Cesium ION Asset directly.
(Asset ID, buildings: 636787 - Asset ID, waterbodies: 636784)
OR: Maybe setting the colors within the .html file that is used to view the Assets. So far, I haven’t been able to do so, but I have zero experience with it. The example code I’ve found online is more complex then I need, such as code for conditional styling (I just want to give all buildings the same color).
Code such as below doesn’t have the desired effect:
//Color the objects
var defaultStyle = new Cesium.Cesium3DTileStyle({
color: “rgba (255, 255, 255, 1)”,
show: true
});
newBuildingsTileset.style = defaultStyle;
// Move the camera to buildings.
viewer.flyTo(newBuildingTileset);
I spent some time trying to troubleshoot your data, but I haven’t been able to determine why the tiler seems to be ignoring the <diffuseColor> tags. We’ve opened a ticket to investigate this further, but as a short-term fix, if all you want to do is give all buildings the same color, this code should work:
var viewer = new Cesium.Viewer("cesiumContainer");
var tileset = viewer.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: Cesium.IonResource.fromAssetId(<your-asset-ID>),
})
);
tileset.readyPromise
.then(function () {
viewer.zoomTo(tileset);
tileset.style = new Cesium.Cesium3DTileStyle({
color: "rgb(0, 255, 255)"
});
})
.otherwise(function (error) {
console.log(error);
});
You can paste this into a Sandcastle and substitute in the ion asset ID of your data to see it work.
This is similar to what you posted above, though. When you say the code you posted doesn’t have the desired effect, do you mean that you want different colors for different building elements as in the source data (roof, etc.)?
To help us investigate the tiler issue, would it be possible for you to export a .gml file with just one building from the data and just one material? A simplified case like that could let us find the problem more quickly, if you can send it to us.
Hi - has this been resolved? We have models exported via FME which have diffuse colours as well as textures with neither displaying correctly in Cesium Ion