moving 3D model using lat, long, atl, pitch and rol

Hi,
I am very new to Cesium. I was tasked to research find a web tool which will allow us to move a 3D model (airplane) from one point to another using predefined lat, long, alt, pitch and roll. I found some examples allow me to move my airplane but non of them using pitch and roll. Would anybody help me? An example would be appreciated.

Thank you for your help.

Hello,

Take a look at our 3D models demo: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html&label=Showcases
We are using the function Transforms.headingPitchRollQuaternion to get the orientation for the model.

Hope this helps!

-Hannah

Hi Hannah,
Thank you for replying. I looked at the 3D models demo from the link you suggested and they are standing still. Is there a different example to see the 3D model is moving using lat, long, alt, pitch and roll.

Thank you.

All you have to do to get it to move is give new values to entity.orientation and entity.position.
Here’s demo where I’m updating the long/lat position, and the heading and pitch for the orientation.

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

infoBox : false,

selectionIndicator : false

});

viewer.scene.camera.setView({

position: new Cesium.Cartesian3(-2654967.1393059366, -4137274.088087724, 4400287.295814132),

heading: 0.005279793055563253,

pitch: -0.818713136947244,

roll: 0.000025898904649324095

});

var lon = -123.0744619;

var lat = 44.0503706;

var position = Cesium.Cartesian3.fromDegrees(lon, lat, 5000.0);

var heading = Cesium.Math.toRadians(135);

var pitch = 0;

var roll = 0;

var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);

var url = ‘…/…/SampleData/models/CesiumAir/Cesium_Air.bgltf’;

var entity = viewer.entities.add({

name : url,

position : position,

orientation : orientation,

model : {

uri : url,

minimumPixelSize : 128

}

});

var sign = 1;

var count = 0;

var i = setInterval(function(){

var diff = Cesium.Math.toRadians(1)*sign;

heading += diff;

pitch -= diff;

lon -= diff;

lat += diff;

position = Cesium.Cartesian3.fromDegrees(lon, lat, 5000.0);

count++;

if (count%50 === 0){

count = 0;

sign *= -1;

}

entity.orientation = Cesium.Transforms.headingPitchRollQuaternion(position, heading, pitch, roll);

entity.position = position;

}, 30);

``

Thank you very much for you help.

Hi Hannah,
Sorry for another stupid question but when I replaced the value in your example with my values and the plane is not visible. How do you correlate the values of long, lat, pitch, heading, and roll from the setView function with the values in the viewer.entities.add function. I used the same values for both of them.

Thank you.

I would recommend you look at this example: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Interpolation.html&label=Showcases Which is a complete demonstration of animating an entity along a path and tracking it with the camera.

I would also suggest you check out the Visualizing Spatial Data tutorial for general information about working with entities. For example, you would not use setView to track an entity with the camera, you would use viewer.trackedEntity or EntityView directly.

Thank you Mathew. I was able to move my airplane based on the defined Lat and Lon. But I'm still struggling to use correspond roll and pitch when the airplane is flying. the SampledPositionProperty only stores the position of the airplane.

Thanks again.