API to access 3D tiles

Hi,

I have app which generates 3D tiles from models stored in database and was wondering if it is possible whith current API in Cesiumto:

- Get all (downloaded) tiles in a tileset. I'd like to be able to e.g. hide some buildings whenever 3d tile is loaded (tiles use batched 3d models with ids)
- Force client to reload specific tile. This way I would be able to reload tiles on the fly whenever model in database changes

I was looking through documentation and sandcastle exmaples but only found how to get 3d tile when user clicks on it. I'm using latest Cesium build from branch '3d-tiles'.

thanks

See if these idea work for you:

  1. Cesium3DTileset has a tileVisible event which you can subscribe to. This may be good enough for use case. Otherwise it is possible to get the root of the tileset with tileset._root and then recursively get children with tile.children. This second approach is not part of the public API though.

  2. To force a tile to expire and reload, you can set tile.expireDate = Cesium.JulianData.now().

Dne sobota 3. června 2017 1:33:01 UTC+2 Sean Lilley napsal(a):

See if these idea work for you:

1. Cesium3DTileset has a tileVisible event which you can subscribe to. This may be good enough for use case. Otherwise it is possible to get the root of the tileset with tileset._root and then recursively get children with tile.children. This second approach is not part of the public API though.

2. To force a tile to expire and reload, you can set tile.expireDate = Cesium.JulianData.now().

thanks for the reply,

tileVisible seems to work fine to access tiles (although I would prefer some event called only when tile is loaded, checking some conditions on every frame seems a bit excessive).

But I'm still having trouble with reloading the tile since I'm not sure how the expireDate should work. I've put the following code into tileVisible callback, expecting to see the browser requesting the tiles again after 10s:

if (!tile.expireDate) {
   let date = Cesium.JulianDate.now();
   Cesium.JulianDate.addSeconds(date, 10, date);
   tile.expireDate = date;
}

But even after scrolling the tile out of view and back won't make the browser request the tile again.

The only thing I've found to force reload is to call trimLoadedTiles() on tileset but it won't let me specify tiles to reload.

This case uncovered a Cesium bug which I opened here: https://github.com/AnalyticalGraphicsInc/cesium/pull/5428. Hopefully it works for you with that fix.

Dne úterý 6. června 2017 2:20:33 UTC+2 Sean Lilley napsal(a):

This case uncovered a Cesium bug which I opened here: Fix tile continually expiring when expireDate is set by lilleyse · Pull Request #5428 · CesiumGS/cesium · GitHub. Hopefully it works for you with that fix.

Thanks, I've checked out branch 'expire-date-fix' and rebuilt cesium but still can't seem to get it working.

I've noticed that documentation states that 'expireDate' property is read only. I've checked the code and it seems like the only way to set it is by having "expire.date" value inside tileset.json, which does not work for my use case.

I need some way to force cesium to reload any tile after tileset was loaded. For example app receives message from server that tile XX has changed, and I need to force cesium to reload only that tile. I don't want to set expire date on each tile since they won't change very often. Is there any way to do that?

Try the branch again, there was an issue where the timestamp was not appended to the url so the new request would probably get back a cached result.

The property is marked as read only but can be set as well. I just changed the documentation in that PR. This is still the best way to go for your case.

Dne středa 7. června 2017 2:09:26 UTC+2 Sean Lilley napsal(a):

Try the branch again, there was an issue where the timestamp was not appended to the url so the new request would probably get back a cached result.

This time I've tried it in cesium sandcastle and it seems to be working as expected, I can see browser make requests to download expired tiles.

Still can't get it working in my app (which is written in typescript) but it seems to be some other problem on my end, so I think we can consider this resolved.

Thanks again for your help

Dne středa 7. června 2017 2:09:26 UTC+2 Sean Lilley napsal(a):
> Try the branch again, there was an issue where the timestamp was not appended to the url so the new request would probably get back a cached result.
>

This time I've tried it in cesium sandcastle and it seems to be working as expected, I can see browser make requests to download expired tiles.

Still can't get it working in my app (which is written in typescript) but it seems to be some other problem on my end, so I think we can consider this resolved.

Thanks again for your help

Hello! I'm stuck with the same issue, could you please show your sandcastle demo or the code you use to reload the tiles?

I try to do the following:

t = tileset._root.children[0]
t.expireDate = Cesium.JulianDate.now()
t.contentExpired = true

but there are no new requests in the network tab of the Chrome's developer tools.
I'm on the master Cesium branch with this latest commit
commit 9d0e6b7b52783b6c8fed4d84c4072597266d9bca
Merge: 4c8dbca84 c56ad0319
Author: Patrick Cozzi <pjcozzi@gmail.com>

Dne čtvrtek 22. června 2017 12:32:53 UTC+2 scyth...@gmail.com napsal(a):

> Dne středa 7. června 2017 2:09:26 UTC+2 Sean Lilley napsal(a):
> > Try the branch again, there was an issue where the timestamp was not appended to the url so the new request would probably get back a cached result.
> >
>
> This time I've tried it in cesium sandcastle and it seems to be working as expected, I can see browser make requests to download expired tiles.
>
> Still can't get it working in my app (which is written in typescript) but it seems to be some other problem on my end, so I think we can consider this resolved.
>
> Thanks again for your help

Hello! I'm stuck with the same issue, could you please show your sandcastle demo or the code you use to reload the tiles?

I try to do the following:

t = tileset._root.children[0]
t.expireDate = Cesium.JulianDate.now()
t.contentExpired = true

but there are no new requests in the network tab of the Chrome's developer tools.
I'm on the master Cesium branch with this latest commit
commit 9d0e6b7b52783b6c8fed4d84c4072597266d9bca
Merge: 4c8dbca84 c56ad0319
Author: Patrick Cozzi <pjc...@gmail.com>
Date: Mon Jun 19 20:14:06 2017 -0400

Hello,

try putting this somewhere around line 93 (so it's inside tileset.readypromise) in the sancastle 3D tiles demo (the one with colored models):

tileset.tileVisible.addEventListener(function (tile) {
                    if (!tile.expireDate && tile.hasRenderableContent) {
                        var date = Cesium.JulianDate.addSeconds(Cesium.JulianDate.now(), 10, Cesium.JulianDate.now());
                        tile.expireDate = date;
                    }
                });

You should see the tiles reloading every 10s.

BTW there seems to be a bug where colored styles aren't applied to the tiles after they expire and are reloaded, when they expire they are white colored until you hover over them.

Yeah the expiration should work with code like below. On the right is showing the re-requested tile.

Also thanks for noticing that the style is not reapplied. There should be a fix for that soon.

Thanks again for the report. Sean fixed this in #5529, which was just merged.

Patrick