Normal vector for plane entity

Hi there,

I would like to ask how to get the normal vector correctly that is orthogonal to the line entity at the Z=0.

The normal vector will be given to the the plane entity.

This is what I want to make.

The code and result from my own trial,


addPlane(twoPositions) {

        let mid = Cesium.Cartesian3.midpoint(twoPositions[0], twoPositions[1], new Cesium.Cartesian3());

        let p1 = Cesium.Cartesian3.normalize(twoPositions[0], new Cesium.Cartesian3());
        let p2 = Cesium.Cartesian3.normalize(twoPositions[1], new Cesium.Cartesian3());

        let lineVec = Cesium.Cartesian3.subtract(p2, p1, new Cesium.Cartesian3());

        let normal = Cesium.Cartesian3.cross(lineVec, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());

        normal = Cesium.Cartesian3.normalize(normal.clone(), new Cesium.Cartesian3());

        let entity = new Cesium.Entity();
        entity.position = mid;
        entity.plane = {
            dimensions: new Cesium.Cartesian2(200, 200),
            plane: new Cesium.Plane(normal, 0),
            material: Cesium.Color.WHITE.withAlpha(0.5),
            outlineColor: Cesium.Color.BLACK,
            outlineWidth : 1


I tried to get the orthogonal vector from the vector that is along with the line by using cross product calculation.
The plane should be parallel with the line as it should be given the orthogonal vector for normal.
What might be missing here?


A very quick guess: Try adding

entity.orientation = Cesium.Quaternion.IDENTITY;

before passing the entity to the viewer.entities.

(Disclaimer: I have not tried it out, and would need to create a Sandcastle with your code first. But there seems to be some confusion about the plane orientation, and the symptoms that you described reminded me of another question about plane orientations…)

Thanks for the reply!
It is deepening my grasp of the reference frame(orientations etc).

Just quick report about testing your suggestion.
The plane aligned with the line entity, however, the Z axis orientation seems tilting to about 45 degrees from vertical line.


I will be digging it on my end as well but I’d be great if you can give some advices.

Hi @Marco13 ,

Just to let you know my updates,
I have found a way without using plane which is using the wall entity.


    const wall= this._viewer.entities.add({
        name: "Cross profile",
        wall: {
            positions: twoPositions,
            material: Cesium.Color.SKYBLUE.withAlpha(0.3),
            outline: false,
            outlineColor: Cesium.Color.WHITE,
            outlineWidth: 1,
            minimumHeights: [hMin, hMin],
            maximumHeights: [hMax, hMax]

Thanks for helping me out.
Nonetheless, I still want to know the solution when using the Plane entity for my further understanding of mathematics in cesium, so if you’d like to please give me the solution you come up with.

Hi @Marco13 ,

I actually confront to another issue that I need to get the orthogonal vector.

I hope I can get some advice from you.

The new issue is I need to crop the tileset using clippingPlane.
I need to pass the normal vector to the clippingPlane

However, the outcome is similar to what I have described above.

Sorry, there are a few things mixed here. I’m not sure whether the question now is about a Plane entity and its orientation. Or whether it is about a Wall entity a orthogonal (normal?) vector for that. Or whether it is about “clipping planes” (and I assume that this is not related to the clipping plane example sandcastle , but … it might be). I’m also not sooo deeply familiar with CesiumJS in particular, but would try to help finding answers to specific technical questions when I understand the intention or goal more clearly.

Sorry @Marco13 , I will give you the example code I’m working on.

So I pass four normal vector that has different directions to the ClippingPlaneCollection to clip the tileset.

    let lineVec = Cesium.Cartesian3.subtract(this.linePoints[1], this.linePoints[0], new Cesium.Cartesian3());
    let normalVec1 = Cesium.Cartesian3.cross(lineVec, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
    let normalVec2 = Cesium.Cartesian3.cross(normalVec1, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());

    normalVec1 = Cesium.Cartesian3.normalize(normalVec1, new Cesium.Cartesian3());
    normalVec2 = Cesium.Cartesian3.normalize(normalVec2, new Cesium.Cartesian3());
    let centerPosition = Cesium.Cartesian3.midpoint(this.linePoints[0], this.linePoints[1], new Cesium.Cartesian3());

    let clippingPlane = new Cesium.ClippingPlaneCollection({
        planes: [
            new Cesium.ClippingPlane(
            new Cesium.ClippingPlane(
                Cesium.Cartesian3.negate(normalVec1, new Cesium.Cartesian3()),
                5                ),
            new Cesium.ClippingPlane(
            new Cesium.ClippingPlane(
                Cesium.Cartesian3.negate(normalVec2, new Cesium.Cartesian3()),
        enabled: true,
        unionClippingRegions: true,
        edgeWidth: 1.0,
        edgeColor: Cesium.Color.RED,
        modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(centerPosition)



It is somewhat same issue as the first problem which is unsolved,


I see a short code snippet and two small images. Can you carve out the actual question and create a Sandcastle for that? Maybe this will make the intention clearer.

If there is a question about clipping planes, then this should probably be a separate question.

(The only thing that these questions seem to have in common is that there is some confusion about the coordinate systems, but it’s hard to make a more specific statement than that…)

I created a sandcastle (based on the ‘Sample Height from 3D Tiles’ Sandcastle) :

It takes the two points of the polyline, and creates a plane that is aligned with the plane that is created from these points. Comparing that to the first image that you posted, this could be roughly what you want to achieve:

(Aligning the plane and its size perfectly with the exact polyline is trickier than it looks at the first glance. But maybe the code helps to solve the original question about the “Normal vector for plane entity”, at least…)

1 Like

Hi @Marco13 and thank you so much for the help.

the plane that is parallel to the line has solved.

However, I faced another issue again.

I have created another topic for this.