Moving 3D glb Entity from PointA to PointB

Hello all and, thank you Omar for the kind reception.

As the subject describes, I am simply trying to move a 3D entity from one coordinate to another.

Data arrives via web sockets and I parse the needed values (lat,lng, etc).

This is my current situation; I can get my entities to move properly OR I can update their orientation but not both.

I’m limited in what code I share and I apologize profusely. Most of my work deals with government related matters and is sensitive in nature.

Thank you very much! (It feels weird being a noob again LOL!)

Don

This is how I add an entity (Entity is placed in the correct location and with correct initial orientation):

function addEntity(data) {
    console.log("addEntity");
    //console.log(data);
    var height;
    var positions = [
        Cesium.Cartographic.fromDegrees(data.longitude, data.latitude),
    ];
    var promise = Cesium.sampleTerrainMostDetailed(worldTerrain, positions);
    Cesium.when(promise, function(updatedPositions) {
        var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
            Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude, positions[0].height));
        var position = Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude, positions[0].height);
        var heading = Cesium.Math.toRadians(data.heading);
        var pitch = Cesium.Math.toRadians(15.0);
        var roll = Cesium.Math.toRadians(0.0);
        var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new   Cesium.HeadingPitchRoll(heading, pitch, roll));

         var entity = viewer.entities.add({
            id: data.guid,
            position : position,
            orientation : orientation,
            model : {
                uri : 'models/policecrownvic.glb',
                modelMatrix : modelMatrix,
                scale : 100.0
            }
        });
    }); 
};

How is the orientation specified in your source data? The easiest thing would be to have CesiumJS automatically compute the orientation from the direction the vehicle is moving in. This has an example of doing this: Cesium Sandcastle. It’s specifically this line:

orientation: new Cesium.VelocityOrientationProperty(position)

Here position isn’t a single position, but a SampledPositionProperty, which has a list of positions with timestamps. You add samples to it like this position.addSample(time, location);.

That example takes a list of positions up front and makes the car move on that path, but if your positions are coming in real time, you would simply call addSample as you get new positions. You can either use forward extrapolation to get a real time view, or make the clock a few seconds behind so there’s always one more packet of data being visualized before the next one comes in.

Let me know if this helps!

Ah. That makes sense. Thank you for the prompt reply!