retrieving data from 3D tiles

Hi,

I've been working with Cesium for a while, but I just started with 3D Tiles now.

So I need to call a function that goes into the 3D tiles attributes and fetch the data under a certain name for example ${population} and then put them into a loop and find me the max and min values.

I do that simply with GeoJSONs and CZMLs... but no idea how it's done with 3D tiles..

Thanks

The most basic approach is to put the min and max properties in the tileset.json itself. These are stored in the “properties” section: https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/README.md#tilesetjson.

But if you need to do something more complex than that you’ll need to loop over the features of loaded tiles.

One difference from GeoJSON and CZML is that not all the tiles will be loaded right away so the min/max of a property may change as tiles stream in. You can listen to the tileset.tileLoad and tileset.tileUnload events, and from there do something like:

*tileset.tileLoad.addEventListener(function(tile) {
    var content = tile.content;
    for (var i = 0; i < content.featuresLength; ++i) {
        var feature = content.getFeature(i);
        var value = feature.getProperty('population');
        // Do min and max here
    }
});*

``

Thanks Sean,

It looks easy enough
but turns out my problem is when I converted my data into 3D Tiles...
and try a simple styling function for a given attribute I get the following error
"An error occurred while rendering. Rendering has stopped.
undefined
RuntimeError: Operator ">=" requires number arguments. Arguments are 0 and 1."

Which I figure is due to double quotations around the attribute values.
is there a way to hack it?

and another question,
how do I remove the tiles from the scene?
I mean with other data sources you use: viewer.dataSources.removeAll();
is there a similar function for the tiles?

Thanks again

To fix the style error you could convert the strings to numbers with Number(${property}). https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling#type-conversions

To remove the tileset call viewer.entities.remove(tileset)

That is just perfect.
Thanks a bunch for your help

Hi,

How can I disable the shadow effect, I have tried:

shadows: Cesium.ShadowMode.DISABLE
and
shadows : false

But I still have a very dark surfaces against the sun position
I need the colors to be visible as they are chosen and not altered by the sun effect

Is it possible ?

The dark shading is controlled by the shaders and materials inside the glTF models. There are a few different ways to edit the glTFs to get different lighting effects, if you send over a b3dm tile I could try seeing what’s best for your case.

https://github.com/Ayah93/Testing/blob/master/data8.b3dm

Thank you
Here is a tile...

Changing the line vec3 l = normalize(czm_sunDirectionEC); to vec3(0.0,0.0,1.0); in the fragment shader would probably do the trick. Just curious, what converters are you using? There may be options to output shaders that don’t use the cesium sun direction.

I'm using the FME 2017.1 Oracle edition
it doesn't offer much setting, only the number of features per tile

Should the change be applied in all the b3dm, manually?

If you can’t control it from the FME side then it does sound like you’ll have to fix it manually or write a script to batch process the b3dms. I have seen tilesets exported from FME that don’t have the shaders built-in though, so there might be a hidden setting somewhere or supported in a different version of FME. You might have more luck contacting them. Ask about exporting b3dms with the KHR_materials_common extension.

Great... thank you