Is there is a way to rotate the the 3d-tile model

My model is a little tilted. What can I do to correct it in cesium?
Can I rotate the model ?

Hi there,

Yes, you can control the tile orientation by modifying tileset.modelMatrix, like in this example that modifies the height translation: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Tiles%20Adjust%20Height.html&label=3D%20Tiles

Checkout this method also for creating the new model matrix: http://cesiumjs.org/Cesium/Build/Documentation/Matrix4.html#.fromRotationTranslation

Hope that helps,

• Rachel

When I use the code below to test the rotation function, the 3dtiles model was disappeared ,and then I tested this in http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Tiles%20Adjust%20Height.html&label=3D%20Tiles ,it's ok.
My 3dtiles Model was created by smart3d.

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, 0);
var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
var v = [0.7, -0.7,0, 0.7,0.7, 0, 0, 0,1];
var m = Cesium.Matrix3.fromArray(v);
var rotationTranslationMatrix = Cesium.Matrix4.fromRotationTranslation(m, translation);
tileset.modelMatrix =rotationTranslationMatrix;
console.log(rotationTranslationMatrix);
}).otherwise(function (arg) {
console.log(arg);
});

Rotation is trickier to get right than translation when using the modelMatrix property. That is because many 3D Tiles models have their origin set to the Earth’s center and use the CESIUM_RTC glTF extension to place them on the globe.

So what happens when you rotate is:

To get the modelMatrix right it will first need to translate the opposite of the CESIUM_RTC value, then rotate, then translate back to the CESIUM_RTC value.

Or possibly your tileset is using a transform property in the root tile, in which case setting tileset._root.transform = rotationTranslationMatrix will solve it.

I’m not sure what your case is but I’d be happy to test this idea out further and provide some sample code if you are able to share the tileset.

thanks ,can i have you email address to send the tileset.

Sure, slilley@agi.com.

Hi Sean

I try to rotate the Tileset in Sandcastle, but failed. Here is my code.

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

});

viewer.scene.globe.depthTestAgainstTerrain = true;

var viewModel = {

height: 0

};

Cesium.knockout.track(viewModel);

var toolbar = document.getElementById(‘toolbar’);

Cesium.knockout.applyBindings(viewModel, toolbar);

url : ‘…/…/…/Specs/Data/Cesium3DTiles/Tilesets/Tileset’

}));

var boundingSphere = tileset.boundingSphere;

viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

}).otherwise(function(error) {

throw(error);

});

//Cesium_RTC in one of the .b3dm

var cartesian = new Cesium.Cartesian3(1215020.301129722, -4736341.9686844405, 4081630.311150717);

Cesium.knockout.getObservable(viewModel, ‘height’).subscribe(function(height) {

height = Number(height);

if (isNaN(height)) {

return;

}

var hpr2 = new Cesium.HeadingPitchRoll(height/100, 0, 0);

var rotate = Cesium.Matrix4.fromRotationTranslation(rotation2, new Cesium.Cartesian3(0,0,0), new Cesium.Matrix4());

tileset.modelMatrix = rotate;//Cesium.Matrix4.multiply(tileset.modelMatrix, rotate, new Cesium.Matrix4());

});

``

This tileset is using Cesium_RTC.

I think I didn’t get the right rotation axis.

Can I get some help for rotating this sample tileset?

Thanks

Chris

The more I think about this, I realize it may hard to get right for a few different reasons involving how RTC and axis conversions are taking place in the Model code. So I don’t have a good solution for this yet.

Hi guo,
did u solve the problem?My model is tiled too.

Could u share the issue?

Thanks very much!

Ah I was trying to find this thread before responding to your post in https://groups.google.com/forum/#!topic/cesium-dev/OES72vM5BlY. I’m also curious to know if anyone has solved this.