How to get the features

I just want to hightlight some part in tileset data, so I think I have to use the method Cesium3DTileContent(),however this is private function,I could not directly use it .According to the documents, I have only found a way like this :
1.var tileset = new Cesium.Cesium3DTileset({)};
2.tileset.tileLoad.addEventListener(function(tile) {
let connt = tile.content;})
so now I could get the content, but is there only way to the the content by this way because I do not want to trigger the viewer and then get the content, I mean I do not want to use the event .

Any ideas???

No, the event is the only way, and it’s not that great either, as it starts streaming the whole file which can be quite large. But on the event you can a) look at properties, and b) look through the feature table and pull out all the values. I sometimes have to do this if I’m color mapping a tileset.

If you can pre-process your tileset data, I would recommend to pull the feature data out into a separate file that you’ll load, and then associate with the tileset. If you’re not doing your own tiling, then the event method is the only way, apart from …

… well, apart from downloading the CesiumJS code, and make modifications to it to enable things and to make private public, and so on, but then you’re on your own. Actually, come to think of it, I’d pop over to TerriaJS to see if they’ve got anything around this, they’ve done some smart stuff wrapping around Cesium for years and I know it was on their list of things to look into a couple of years back.

Cheers,

Alex

tileset.root.children will have a list of tiles associated with a given tileset, depending on your tileset structure some of them will have content (tile._content), others might have children of their own. Tile content is loaded on demand, depending on camera position and tileset geometric error settings.

thanks, I think so ,maybe I have to consider the data itself

No,I have to access the data itself not only the seperate tileset.Because I want to get the part(for example it is aprt of b3dm data) via batchId and then hightlight it . so your idea works?

I think it can be used, if I understood your problem correctly.
A tileset object contains the data (Cesium3DTileset contains Cesium3DTiles objects accesible via tileset.root.children, which in turn can contain Cesium3DTileContent accesible via tile.content/_content, which can contain Cesium3DTileFeature objects with a batchId accesible via either content._features or content.getFeature). You can traverse this structure and find required object and highlight it.
The way you navigate this tree depends on the structure of your data.
I add specific attribute (guid) to associate 3d model/tile with semantic objects/entities (like a specific door or pump), I also create tilesets based on the type of objects inside them (layers, like a layer of walls, a layer of doors and etc).
If I need to programatically highlight an object (for example from a table of objects) I can easily find the right one by traversing the tileset tree and looking for a specific guid. It’s more compliacted with instancedTiles, but there is also a way to do that.
If you can describe your data structure and the way you want to interact with it (when and on what condition you want to highlight a specific object) I can try to give you more concrete advice.

for my data,I found I could not access the content part via :
1.tileset=new Cesium.Cesium3DTileset()
2.content=tileset.content/._content( this part is invalid)
According to Document,
1.Cesium3DTileContent() : Derived classes of this interface provide access to individual features in the tile. Access derived objects through Cesium3DTile#content .This type describes an interface and is not intended to be instantiated directly.
2.Cesium3DTile(): Do not construct this directly, instead access tiles through Cesium3DTileset#tileVisible .

I want to generate a tree to show more details of my model after the model has been loaded, the tree should contain not only the tileset tree but also the parts which are identified the batchId( for example: I have a city model, the model is divided into a sequence of tiles and each tile corresponds a tileset.json. However, in the tile there are a lot of batches( each batch stands for a seperate building) ,there is no tileset.json file for each building but only can get it from its ID, I can select the building and hightlight it via the tree)
So like the documents, only the event could access the content, but it will cause a lot of problems when trigger the event for example, the content is based on the event and could not get the whole ones( some not triggered yet)

I hope I describe it clearly!! Thanks

tileset is a Cesium3DTileset object, it doesnt have content.
Cesium3DTile objects do have content. tileset have a list of tiles, accesible via tileset.root.children path. Each tile will have a content accesible via tile.content path.

But documents says :Do not construct this directly, instead access tiles through Cesium3DTileset#tileVisible .

so is there another way to get new Cesium.Cesium3DTile()

You don’t need to construct Cesium3DTile directly in order to acces them.
Cesium3DTiles objects are constructed automatically when you load you tileset by creating a Cesium3DTileset object and providing it a link to tileset.json file containing tileset description like this:

tileset = new Cesium.Cesium3DTileset({
  url: "../SampleData/Cesium3DTiles/Tilesets/Tileset/tileset.json",
});

Sorry if I was a bit too thick Alex. Since content is loaded on demand, you won’t be able to use the method I proposed until you actually visited the neccesary tile (before that tile.content will be undefined). The other way to color content of a tile which havent been loaded yet is to use style.

yes,I know Cesium3DTiles could be automatically constructed.But I want to access the features of the model, my idea is :
var tileset = new Cesium.Cesium3DTileset({
url: “./tileset.json”,
});
tileset.tileLoad.addEventListener(function(tile)
{
let con = tile.content;
var featuresLength = con.featuresLength;

});
through this way, I could get the content,but I would not like to use Event
and another problem is :
A tile in a Cesium3DTileset . When a tile is first created, its content is not loaded; the content is loaded on-demand when needed based on the view.
the content could not be loaded at once instead base on the demand.

Sorry for misunderstanding.
I think you can use Cesium3DTileStyle in order to do that.
I am using it to set up rules for coloring features/content of tiles before they actually load, maybe it can also be used to highlight objects.
cesium style.color has a property evaluateColor, which is a function which returns a color and is applied to all features of said tile as they load.

var style = new Cesium.Cesium3DTileStyle();
// Override color expression with a custom function
style.color = {
    evaluateColor : function(feature, result) {
        return Cesium.Color.clone(Cesium.Color.WHITE, result);
    }
};

You can put some conditions inside evaluateColor to apply different color to your feature based on some of the feature properties (like batchId).

You then will have to apply this custom style to your tileset.

thanks, maybe I think Cesium3DTileStyle() is not proper for my desire.I could not use it to access the bachId seperately.
Maybe this is the limitation for 3dtileset data in cesiumJS itself,I have to consider it on the data itself to get more details I could use.

Thanks again

Have you tried using breakpoints to study attributes of feature objects passed to evaluateColor function?
I am pretty sure all of them should be of type Cesium3DTileFeature and have a _batchId attribute.

thanks for your tips,YES I will have a try.