I have the following gltf : https://drive.google.com/file/d/1zpl_V0ghFi_Mn8sLuu4nWsjsRUVBJluN/view?usp=sharing.
I would like to use it in cesium directly, without passing in ions, so I uploaded it on a server, get the data of the model, then do this :
(this code is working, and is not the part I need help with, it’s just here for background on the question)
type IModel {
data: any,
position: {logintude: number; latitude: number: height: number;}
}
private loadModels(model: IModel) {
let modelInitialPosition = new Cesium.Cartographic((model.position.longitude || 0), (model.position.latitude || 0), (model.position.height || 0))
this.altimeterService.getElevation(modelInitialPosition).subscribe(elevation => {
const position = {
...model.position,
height: model.position.height + elevation
};
const cModel = new Cesium.Model({
id: model.id,
gltf: modelData,
modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Ellipsoid.WGS84.cartographicToCartesian(MissionUtils.toCesiumCartographic(position))),
scale : 1.0
});
this.viewer.scene.primitives.add(cModel);
});
}
getElevation(pos: Cesium.Cartographic): Observable {
return new Observable(observer => {
const promise = Cesium.sampleTerrainMostDetailed(this.terrainProvider, [new Cesium.Cartographic(pos.longitude, pos.latitude, 0)]);
Cesium.when(promise, (updatedPositions) => {
this.ngZone.run(() => {
observer.next(updatedPositions[0].height);
observer.complete();
});
});
});
}
``
**So sorry for the long block but basically, the model has a default longitude, latitude and height. But the height is relative to the ground. Since I am using Cesium World Terrain, I am adding the terrain elevation to the model height, and then I draw it.
The problem I face with the method above tho, is the center point of the model. I do not know what Cesium consider the center of a model, and where does he put the axis.
Exemple :
If you open the model with gltf reader, or with windows built in gltf reader, the model will be placed correctly like this : **
**But if I put the same model in cesium I end up with the following :**so when I apply my change, now the model will be in the hair and not on the ground (but the center point where the axis are drawn is correctly on the ground) .
So my question is, how is this “anchor point” calculated ?
I don’t know if you need more help.