Entity Path vector

Hello,

So simple question I have a super long entity path. I need an arrow showing which why my model is traveling. I tried changing to arrow material for path , but line is too long don’t see the arrow at the end.

Have tried creating a vector call back where I get my entities position at now and a couple of seconds in the future but the arrow moves off the line. is there an entity.path.position.getValue(time)??

Help

Devon

Hi Devon,

Are you able to send over a code sample of what you are working on?

private createVelocityVectorProperty(): Cesium.CallbackProperty {

    return new Cesium.CallbackProperty(

        (time: Cesium.JulianDate) => {

            const endPos = new Cesium.Cartesian3()

            const direction = new Cesium.Cartesian3()

            const p0 = new Cesium.Cartesian3()

            const p1 = new Cesium.Cartesian3()

            const endTime = new Cesium.JulianDate()

            Cesium.JulianDate.clone(time, endTime)

            Cesium.JulianDate.addDays(endTime, 1, endTime)

            const zeros = new Cesium.Cartesian3(

                0,

                0,

                0

            )

            const velocityVector = this.ovtVectorsEntities?.velocityVector

            if (this.rootEntity) {

                this.rootEntity.position.getValue(

                    time,

                    p0

                )

                this.rootEntity.position.getValue(

                    endTime,

                    endPos

                )

                Cesium.Cartesian3.subtract(

                    endPos,

                    p0,

                    direction

                )

                if (direction !== 0) {

                    Cesium.Cartesian3.normalize(

                        direction,

                        direction

                    )

                }

                Cesium.Cartesian3.multiplyByScalar(

                    direction,

                    15,

                    direction

                )

                Cesium.Cartesian3.add(

                    direction,

                    p0,

                    p1

                )

            }

            if (velocityVector) {

                if (p0.toString() === zeros.toString()) {

                    velocityVector.polyline.show = false

                } else {

                    velocityVector.polyline.show = this.vectorControlBindings.displayVelocityVector

                }

            }

            return [

                p0,

                p1

            ]

        },

        false

    )

}

const entityOptions = {

        polyline: {

            positions: createVelocityVectorProperty,

            width,

            material: new Cesium.PolylineArrowMaterialProperty(color),

            distanceDisplayCondition,

            show

        }

    }

    const entity = new Cesium.Entity(entityOptions)

this is after ingesting position data for our root entitiy

This post may help you in getting the velocity vector: how to get velocity of entity?

The Sandcastle linked in the response is using the entity’s position to compute the velocity vector over time. Once you get the velocity vector, you could normalize it to get the direction and input that into your arrow polyline. The input will be of unit length, so you can adjust the length as you wish.

@dzung I will try that but specifically is there a way to possibly show arrows along an entity.path? the need is that the path line is so long we don’t know which direction we are going?

@dzung you were correct about using the velocity vector now we realize there is a problem with your entity.path property (see attached picture). The velocity line is correct because the teal line/circles are plotting the path as we go using point graphics. The white line is the entity.path property. We have ingested position values using the same method as → Cesium Sandcastle

I guess the problem now is we want the entity.path line to be the same as the plotted path from all the points we ingested.

Just Figured out why we are seeing this @dzung Your entity.path property is always in the reference frame FIXED while we ingested our data in INERTIAL reference frame. That means you need to support an entity path that is in INERTIAL reference frame.

I try to change the property material in the code below.
I try to use Cesium.PolylineArrowMaterialProperty(color) but I can’t do it.
My goal is to create an arrow instead of a line.
The cesium version is 1.78.0.

Can anyone help me
?

This is my code:

------------viewer.entities.add({
availability: new Cesium.TimeIntervalCollection([
new Cesium.TimeInterval({ start: start, stop: stop }),
]),
position: positionProperties[i],
model: {
uri: airplaneUri,
minimumPixelSize: 250,
maximumScale: 10,
},
// Automatically compute the orientation from the position.
orientation: new Cesium.VelocityOrientationProperty(
positionProperties[i]
),
path: new Cesium.PathGraphics({
width: 3,
material: Cesium.Color.YELLOW,
leadTime: 20,
trailTime: 0,
}),
})

@antoniaggo
you material has to be a new Cesium.PolylineArrowMaterialProperty(color)

Thanks a lot!!

devondespain

@ devondespain