Orientation is not working in Models

Hello Developers,
Actually my problem is that the Heading is not showing properly in Cesium sample model. The data which i getting from live broadcast feeds.
if i put that heading to air or ground model its show me the heading or bearing in different direction.
so the orientation part is not working.

i am giving you the some sample coords and those coords i am using like live feeds one by one.
Here is my sample code you can run this code on sandcastle and check:

var demoCoords = [79.052073,21.086057,320.04,324,79.037892,21.10405,373.38,324,79.03595,21.106505,411.48,324,79.034322,21.1086,457.20000000000005,324,79.033101,21.110183,495.3,324,79.031728,21.111998,541.02,324,79.029897,21.114326,571.5,324,79.028254,21.116455,609.6,324,79.026606,21.118607,632.46,324,79.025625,21.119819,647.7,324,79.023285,21.122845,670.5600000000001,324,79.022217,21.124149,678.1800000000001,324,79.0212,21.125499,693.4200000000001,324,79.018366,21.129135,716.2800000000001,324,79.016668,21.131287,731.52,324,79.01487,21.133575,762,324,79.011175,21.138245,784.86,324,79.009145,21.140768,800.1,323,79.005992,21.144725,822.96,323,79.004084,21.147079,822.96,323,79.000588,21.15152,845.82,323,78.996023,21.157247,914.4000000000001,323,78.993988,21.159761,960.12,323,78.988653,21.166397,1059.18,323,78.987528,21.167722,1653.5400000000002,323,78.704357,21.021268,3429,228,78.694769,21.013261,3505.2000000000003,228,78.686387,21.006226,3558.54,228,78.679588,21.000552,3611.88,228,78.675695,20.997253,3657.6000000000004,228,78.670099,20.992592,3672.84,228,78.664365,20.987823,3710.94,228,78.660761,20.984818,3733.8,228,78.658284,20.982742,3756.6600000000003,228,78.651172,20.976837,3802.38,228,78.646778,20.973133,3825.2400000000002,228,78.642134,20.969269,3855.7200000000003,228,78.636691,20.964754,3893.82,228,78.631701,20.960587,4236.72,228];

var viewer = new Cesium.Viewer('cesiumContainer', {
    infoBox : false,
    selectionIndicator : false,
    shadows : false
});
viewer.entities.removeAll();

var position1 = Cesium.Cartesian3.fromDegrees(79.052199,21.085991,0);
    var HPR = new Cesium.HeadingPitchRoll((Cesium.Math.toRadians(270)), 0, 0);
var orientation1 = Cesium.Transforms.headingPitchRollQuaternion(position1, HPR);

var entity = viewer.entities.add({
    id:"ABC",
        name : "ABC",
        position : position1,
        orientation : orientation1,
        model : {
            uri : '../../SampleData/models/CesiumAir/Cesium_Air.glb',
            minimumPixelSize : 128,
            maximumScale : 20000
        }
    });

var counter =0,
    interval;

function startSimulator(){
    var lengthtoLoop = demoCoords.length / 4;
    if(lengthtoLoop !== demoCoords.length){
         
         var _LON = demoCoords[counter],
            _LAT = demoCoords[counter + 1],
            _ALT = demoCoords[counter + 2],
            _HDG = demoCoords[counter + 3];
        
         var EntityToUpdate = viewer.entities.getById("ABC");
        if (EntityToUpdate !== undefined){
         var newCoords = Cesium.Cartesian3.fromDegrees(_LON, _LAT, _ALT);
        var newPosition = new Cesium.ConstantPositionProperty(newCoords);
        EntityToUpdate.position = newPosition;
            
            var newHPR = new Cesium.HeadingPitchRoll((Cesium.Math.toRadians(_HDG)), 0, 0);
             var neworientation = Cesium.Transforms.headingPitchRollQuaternion(newCoords, newHPR);
              EntityToUpdate.orientation =neworientation;
            
        }
          counter += 1;
          interval = setTimeout(startSimulator, 1000);
        
    }else{
      clearTimeout(interval);
    }
}

startSimulator();

viewer.trackedEntity = entity;

i am giving you the some sample coords and those coords i am using like live feeds one by one.
can you please sort me out the problem, it will very help to me.
thank you guys.

Hello,

It’s hard to say what’s happening without seeing the sample data, but is it possible you’re running into this problem? https://github.com/AnalyticalGraphicsInc/cesium/issues/3256

Best,

Hannah

Oh nevermind, I completely missed that you did post demoCoords haha.
I’ll take a closer look at this and see if I can figure out what is happening.

Best,

Hannah

For the sample code you posted, you need to change 'counter += 1; ’ to 'counter += 4; ’

But I did notice that the model is traveling sideways. That is definitely related to #3256. At heading: 0, our models point east, so if you expect heading: 0 to be north you’ll need to add 90 degrees to all of your headings as a workaround until we have a better solution for this.

Alternatively, you might want to consider using interpolation and a velocity orientation. This will automatically update your model’s orientation based on the direction it’s moving. You can see an example here: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Interpolation.html&label=Showcases

Best,

Hannah

Hello Hannah,

Thanx for the reply.
Oh sorry, for the code i corrected from my side but not on the question.

So, Apart from that i already check the "using interpolation and a velocity orientation" example in Sandcastle but not get what i want.

This is the same sample code with using "new Cesium.VelocityOrientationProperty()" method.

My mistake. You need to subtract 90 instead of adding it. You can see in the latter example you posted below that the plane is now backwards.

-Hannah

Hello Hannah,
Thanx for the correction, but its working some places and somewhere not so i am not get the proper output which i want.

The above second sample code its working but after that i calculated the heading with subtraction of 90 degrees and generated the new #demoCoords Coordinates for test but still not get the output. you can see from yourself.
Here is the new Coordinates with subtraction of 90 degrees in heading.

Note: its already calculated in the demoCoords not to substract from code in heading.

var demoCoords = [77.711449,13.202019,0,10,77.711792,13.202053,0,10,77.712069,13.202098,0,10,77.712266,13.20211,0,10,77.712644,13.202156,0,10,77.712828,13.202168,0,10,77.713334,13.202145,0,93,77.713651,13.20203,0,110,77.713924,13.201935,0,110,77.714183,13.201927,0,92,77.714397,13.201927,0,90,77.714454,13.202017,0,10,77.714456,13.202007,0,169,77.714466,13.201994,0,143,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714468,13.201996,0,10,77.714466,13.201994,0,-136,77.714124,13.202019,0,-4,77.714129,13.202017,0,112,77.714124,13.202019,0,-22,77.714129,13.202028,0,10,77.714124,13.20203,0,-22,77.714124,13.202019,0,180,77.714117,13.202017,0,-106,77.714124,13.202019,0,10,77.714117,13.202017,0,-106,77.714129,13.202028,0,10,77.714124,13.202019,0,-152,77.714124,13.20203,0,10,77.714124,13.202019,0,180,77.714117,13.202017,0,-106,77.714124,13.202019,0,10,77.714129,13.202017,0,112,77.714124,13.202019,0,-22,77.714117,13.202017,0,-106,77.714124,13.202019,0,10,77.714117,13.202017,0,-106,77.714117,13.202028,0,10,77.714124,13.20203,0,10,77.714117,13.202028,0,-106,77.714117,13.202017,0,180,77.714124,13.202019,0,10,77.714117,13.202028,0,-53,77.714117,13.202017,0,180,77.714112,13.20211,0,-87,77.714278,13.202282,0,10,77.714468,13.202431,0,10,77.714325,13.202534,0,-36,77.714298,13.202529,0,-101,77.71429,13.202534,0,-33,77.714286,13.202541,0,-61,77.71429,13.202534,0,151,77.714298,13.202541,0,10,77.71429,13.202534,0,-132,77.714298,13.202541,0,10,77.71429,13.202545,0,-27,77.714298,13.202541,0,117,77.71429,13.202545,0,-27,77.714053,13.202465,0,-109,77.714006,13.202385,0,-150,77.713994,13.202259,0,-175,77.714018,13.202168,0,166,77.714057,13.202063,0,160,77.714006,13.202007,0,-138,77.713958,13.201996,0,-103,77.713958,13.201984,0,180,77.71396,13.201982,0,136,77.713958,13.201984,0,-46,77.713948,13.201982,0,-102,77.713958,13.201984,0,10,77.71396,13.201982,0,136,77.71396,13.201994,0,10,77.713958,13.201984,0,-169,77.71396,13.201994,0,10,77.713948,13.201994,0,-90,77.713958,13.201996,0,10,77.71396,13.201994,0,136,77.713888,13.202156,0,-67,77.714053,13.202236,0,10,77.714243,13.202271,0,10,77.714442,13.202354,0,10,77.714418,13.202517,0,-82,77.714322,13.202529,0,-7,77.714325,13.202534,0,10,77.714325,13.202522,0,180,77.714322,13.202517,0,-150,77.714325,13.202511,0,154,77.714334,13.202506,0,120,77.714322,13.202506,0,-90,77.714322,13.202517,0,10,77.714325,13.202522,0,10,77.714325,13.202534,0,10,77.714325,13.202522,0,180,77.714325,13.202534,0,10,77.714322,13.202529,0,-150,77.714314,13.202545,0,-64,77.714314,13.202534,0,180,77.714322,13.202529,0,123,77.714322,13.202517,0,180,77.714334,13.202517,0,90,77.714334,13.202529,0,10,77.714322,13.202529,0,-90,77.714325,13.202545,0,10,77.714322,13.202541,0,-144,77.714322,13.202529,0,180,77.714334,13.202541,0,10,77.714325,13.202534,0,-129,77.714322,13.202541,0,-67,77.714322,13.202552,0,10,77.714325,13.202545,0,157,77.714322,13.202541,0,-144,77.714337,13.202534,0,116,77.714334,13.202541,0,-67,77.714337,13.202545,0,10,77.714334,13.202552,0,-67,77.714337,13.202545,0,157,77.714334,13.202541,0,-144,77.714346,13.202541,0,90,77.714349,13.202534,0,157,77.714346,13.202529,0,-150,77.714337,13.202534,0,-30,77.714334,13.202529,0,-150];

var viewer = new Cesium.Viewer('cesiumContainer', {
    infoBox : false,
    selectionIndicator : false,
    shadows : false
});
viewer.entities.removeAll();

var position1 = Cesium.Cartesian3.fromDegrees(77.711262,13.201994,0);
    var HPR = new Cesium.HeadingPitchRoll((Cesium.Math.toRadians(10)), 0, 0);
var orientation1 = Cesium.Transforms.headingPitchRollQuaternion(position1, HPR);

var PositionFOR = new Cesium.ConstantPositionProperty(position1);

var entity = viewer.entities.add({
    id:"ABC",
        name : "ABC",
        position : position1,
        orientation : new Cesium.VelocityOrientationProperty(PositionFOR),//orientation1,
        model : {
            uri : '../../SampleData/models/CesiumGround/Cesium_Ground.gltf',
            minimumPixelSize : 100,
            maximumScale : 20000
        }
    });

var counter = 0,
    interval;

function startSimulator(){
    var lengthtoLoop = demoCoords.length / 4;
    if(counter != demoCoords.length){
         
        var _LON = Number(demoCoords[counter]),
            _LAT = demoCoords[counter + 1],
            _ALT = demoCoords[counter + 2],
            _HDG = demoCoords[counter + 3];
        
        var EntityToUpdate = viewer.entities.getById("ABC");
        if (EntityToUpdate != undefined){
            var newCoords = Cesium.Cartesian3.fromDegrees(_LON, _LAT, _ALT);
            var newPosition = new Cesium.ConstantPositionProperty(newCoords);
            EntityToUpdate.position = newPosition;
            
            var newHPR = new Cesium.HeadingPitchRoll((Cesium.Math.toRadians(_HDG)), 0, 0);
            var neworientation = Cesium.Transforms.headingPitchRollQuaternion(newCoords, newHPR);
            EntityToUpdate.orientation = new Cesium.VelocityOrientationProperty(newPosition);//neworientation;
        }
          counter += 4;
          interval = setTimeout(startSimulator, 1000);
        //console.log(demoCoords.length + " : " + counter);
        
    }else{
      clearTimeout(interval);
    }
}

startSimulator();

viewer.trackedEntity = entity;

//////////////////////////////////////////
So Hannah is it in #WIP or development from your side on this #3256 issue.

Sorry I don’t have a better workaround for now. It is not something our core team is working on right now, but @kaktus40 said he might be working on a pull request.

-Hannah

Hello Hannah,

Thx for the answers and support. But what am i do now ? i have been stuck on this level.

Can you update me when this issue will resolved.