Hi how are you, Im new to Cesium, Im importing a czml file as a datasource and then Im trying to apply this position and orientation arrays to a 3D model hosted in my ION account but the position of the model does not agree with the path the positions are reflecting. Im doing the transform between icrf to fixed and I dont know to to manage this functions working together, could you kindly guide me?
Loading the position and orientation from czml:
viewer.scene.postUpdate.addEventListener(icrf);
// load data
viewer.dataSources.add(Cesium.CzmlDataSource.load(‘SampleData/simpleexample.czml’));
Importing the gltf from ion:
(async () => {
try {
const resource = await Cesium.IonResource.fromAssetId(XXXX);
const entity = viewer.entities.add({
position: Cesium.Cartesian3(“#position”),
orientation: Cesium.Quaternion(“#orientation”), / had to do this because I received object type error, expecting quaternion but string.
model: {
uri: resource,
minimumPixelSize: 1280,
maximumScale : 20000
},
});
viewer.trackedEntity = entity;
} catch (error) {
console.log(error);
}
})();
The icrf function is available in various q&a:
function icrf(scene, time) {
if (scene.mode !== Cesium.SceneMode.SCENE3D) {
return;
}
var icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(time);
if (Cesium.defined(icrfToFixed)) {
var camera = viewer.camera;
var offset = Cesium.Cartesian3.clone(camera.position);
var transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed);
camera.lookAtTransform(transform, offset);
}
}