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

393 views
Skip to first unread message

lelo...@gmail.com

unread,
Jul 22, 2015, 8:48:24 AM7/22/15
to cesium-dev
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.

Hannah Pinkos

unread,
Jul 22, 2015, 10:26:31 AM7/22/15
to cesium-dev
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

lelo...@gmail.com

unread,
Jul 23, 2015, 10:41:27 AM7/23/15
to cesium-dev, lelo...@gmail.com

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.

Hannah Pinkos

unread,
Jul 23, 2015, 1:29:31 PM7/23/15
to cesium-dev, lelo...@gmail.com
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);

lelo...@gmail.com

unread,
Jul 24, 2015, 9:08:28 AM7/24/15
to cesium-dev, lelo...@gmail.com
On Wednesday, July 22, 2015 at 8:48:24 AM UTC-4, lelo...@gmail.com wrote:

Thank you very much for you help.

lelo...@gmail.com

unread,
Jul 24, 2015, 1:30:40 PM7/24/15
to cesium-dev, pinkos...@gmail.com
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.

Matthew Amato

unread,
Jul 24, 2015, 1:53:41 PM7/24/15
to cesiu...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

lelo...@gmail.com

unread,
Jul 28, 2015, 10:25:23 AM7/28/15
to cesium-dev, matt....@gmail.com
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.
Reply all
Reply to author
Forward
0 new messages