1. A concise explanation of the problem you're experiencing.
Hi, I have a purpose to put a 3D tiles on a location of cartographic(longitude,latitude), but the 3d tiles is a lit far away the location and also rotated by some angle.
before modelMatrix:
after modelMatrix:
Is there anyone can help me how to solve it?
Thanks
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
<script>
var url = ‘http://192.168.0.147:7777/myApps/Batchedbarrel/tileset.json’;
// var cesiumContainer = 'cesiumContainer';
var viewer = new Cesium.Viewer('cesiumContainer');
var tileset = this.viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: url,
}));
tileset.readyPromise
.then(function() {
let inverse = Cesium.Matrix4.inverse(Cesium.Matrix4.fromArray(tileset.root.transform), new Cesium.Matrix4());
let rotation = Cesium.Matrix4.getRotation(inverse, new Cesium.Matrix3());
var heightOffset = 0;
var boundingSphere = tileset.boundingSphere;
var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
var lon = 175.3050519951;
var lat = -41.1948830262;
var alt = 0;
var height = 0;
var offset = Cesium.Cartesian3.fromDegrees(lon, lat, height);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
var modelMatrix = Cesium.Matrix4.fromTranslation(translation);
tileset.modelMatrix = modelMatrix;
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, 0, 0));
}).otherwise(function(error) {
console.log(eror);
});
</script>
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I am a new cesiumer, I am appreciate someone would like to help me!
4. The Cesium version you're using, your operating system and browser.
Cesium 1.50