How to obtain the position of each child node after loading 3dtiles?

How to obtain the position of each child node after loading 3dtiles?
What I want to do is to modify the height of the 3dtiles sub item to achieve ground contact based on uneven terrain. Do you have any good ideas or methods?

Thank you

            tileset.tileLoad.addEventListener( ( tile ) => {
                const tileLength = tile.content.featuresLength;
                for ( let i = 0; i < tileLength; i++ ) {
                    const feature = tile.content.getFeature( i );
                    console.log(feature)
                    const batchTable = feature._content.batchTable;
                    if (feature) {
                        const modelMatrix = feature.content._model.modelMatrix

                        const position = Cesium.Matrix4.getTranslation(modelMatrix, new Cesium.Cartesian3());
                        const cartographic = Cesium.Cartographic.fromCartesian(position);
                        const lon = Cesium.Math.toDegrees(cartographic.longitude);
                        const lat = Cesium.Math.toDegrees(cartographic.latitude);
                        const height = cartographic.height;

                        console.log(`Feature [${i}] Position: Lon ${lon}, Lat ${lat}, Height ${height}`);
                    }
                }

            })

Hi, i don’t think this is really feasible to do while trying to visualize some 3D Tiles in CesiumJS, just for individual tiles you would probably have to modify tileset modelMatrix and boundingVolume before its being parsed . If you would want to also modify geometry of each tile feature that is baked in the glTF that would require even more work and compute.

Consider modifying or creating 3D Tiles that would match the terrain you want instead, but be aware you might be breaking ToS of whoever is providing the data.

Thank you, but I still want to do it. Today I tried using customShader, but it didn’t achieve the effect I wanted. Do you have any good ideas or feasible strategies?

(I moved this into the CesiumJS section - it’s a better fit, and might get more attention here).

While it might theoretically be possible to modify the “height” of a certain tile content at runtime, this may always affect the state space in a way that can cause unpredictable side effects.

However, if this was the goal, then one approach could be to set the tile.transform accordingly. This would be some sort of “one-time clamping”. The following is a tileset that just consists of a “grid” of tiles:

gridOfTiles.zip (103.3 KB)

When serving this on localhost and running the follwing sandcaslte, the result will look like this:

Cesium Tile Clamping

For each tile that is loaded, the terrain height is computed, and the tile transform is adjusted to move the tile on the terrain.

The sandcastle is shown here. This should be considered as a “proof of concept”, and will certainly require certain adjustments for other data sets. And it should be considered as a demo, without warranty:

1 Like

nice!
it’s great showcase on tile matrix transformation or matrix transformation with cesiumJS in general.

I will add that one obvious side effect is that tiles will disappear when bounding volume is out of the view.

Yes. One could try to avoid that, by also updating the bounding volume of the parent tile or so. But that would have to be re-computed for the whole hierarchy (up to the root), and still cause other side-effects. The preferred solution would be to make sure that the heights/transforms are correct right from the beginning in the tileset JSON.