How to translate a polygon geometry along it's normal

I am dynamically creating a polygon geometry from user given coordinates using this code:

this._primitive = new Cesium.Primitive({
  geometryInstances: new Cesium.GeometryInstance({
    geometry: polygonGeometry,
    modelMatrix: Cesium.Matrix4.IDENTITY,
    id: this.id,
  }),
  appearance: this.appearance
});



This code works fine and I can successfully create a polygon. Now, I would like to translate this polygon along it’s normal by some distance. I am guessing that it can be achieved using the model matrix but I am not sure how to go about it. I have tried setting the model matrix to this:
Cesium.Matrix4.multiplyByTranslation(Cesium.Matrix4.IDENTITY, normalCartesian3,new Cesium.Cartesian3())

``

But the polygon disappears. Can someone let me know how to set the model matrix correctly to achieve the desired result?

1 Like