How can i set the default height of the 3Dtile layer to Underground

i tried setting height = -30 but when the page loads it stays above the ground

You initialize the height and add a listener for it but the listener doesn’t execute at the first time. Maybe it is due to the feature of knockout itself (not sure, I don’t know about knockout)? So why not set the height explicitly at the first time?

i tried setting the initial height to -30 but it still doesn’t work

oh i found it, i put `

var heightOffset = -30.0;

tileset.readyPromise.then(function(tileset) {
    var boundingSphere = tileset.boundingSphere;
    viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0, -2.0, 0));
    viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
    // Position tileset
    var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
    var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
    var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
    var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
    tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    console.log(tileset.modelMatrix);
});

`

Yes that is what I mean, you may need to manually trigger the listener or call it directly.

tileset.readyPromise.then(() => (viewModel1.height = -30))

// Or
tileset.readyPromise.then(() => listener())

thank you very much!!

1 Like