Hi,
I would like to adjust height of 3D PointCloud Tiles.
I tried it as follows:
var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, height);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
I could adjust height of point cloud, but I could not do bounding volume.
And Tile culling is not performed normally.
How to adjust height of 3D PointCloud Tiles?
All of the sample code is below.
It is a partial modification of following Cesium code examples:
https://cesiumjs.org/Cesium/Apps/Sandcastle/?src=3D%20Tiles%20Adjust%20Height.html&label=3D%20Tiles
https://cesiumjs.org/Cesium/Apps/Sandcastle/?src=3D%20Tiles%20Point%20Cloud.html&label=3D%20Tiles
var viewer = new Cesium.Viewer('cesiumContainer', {
shadows : true
});
viewer.scene.globe.depthTestAgainstTerrain = true;
var viewModel = {
height: 0
};
Cesium.knockout.track(viewModel);
var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : ‘https://beta.cesium.com/api/assets/1460?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMzk2YzJiOS1jZGFmLTRlZmYtYmQ4MS00NTA3NjEwMzViZTkiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjBdLCJpYXQiOjE0OTkyNjQ3NTV9.oWjvN52CRQ-dk3xtvD4e8ZnOHZhoWSpJLlw115mbQJM’,
debugShowBoundingVolume: true
}))
tileset.readyPromise.then(function() {
var boundingSphere = tileset.boundingSphere;
viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius * 2));
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}).otherwise(function(error) {
throw(error);
});
Cesium.knockout.getObservable(viewModel, 'height').subscribe(function(height) {
height = Number(height);
if (isNaN(height)) {
return;
}
var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, height);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
});
(Cesium version is 1.39)