is there a cesium API to get the surface normal vector of a picked position on a 3D model?

Does cesium provide an API to get the surface normal vector a picked position on the 3D model?

I created the following based on the sandcastle examples:

https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/#c=nVZtc9o4EP4rKh+KfaUC0reZALmmCb1kJimZwuW+eOZGsdeg1pY8kuyE3OS/38pv2A5c2/MHkFbPPrvsrh+RMUUyDvegyIwIuCdnoHka09vc5vT9fHsmhWFcgOoPyD+eIPgYUApNN0pmPAB1XDn6CpiBv6SKglUBcVxPPLkTT3giw2iGR6DBtMMVX2/OV8WhUwZJVVQTX0rxFbRMlQ80VDI+1Qi8DJz3ow9vGxHyvKn2QQBNFI+54RloyoLAKSNbYAl7lDJeyeZBkWPE7iCaC8PNFvMswWD3vOQqE8yB5Lgqin30Rt6jJWSRhkHb/In539dKpiJAgFFp8zzEEqO1P36bPJBYCqkT5kO/gdhIxR9tI6KF4msuSF2ai84JvZp/XjU8M1CG+8/9blt2ulrcNJwS/gDRIgxtr45bvWLK4IqJI2f8bkBGbuHz1Oryhokg6g7VEocDxNL+sHmG5bwoQE6raT5DAm2ZSg5q+yyS1Jz6hkvhhKkoFrHMIEYa15a/SMKGDm2Bb6TmFoQJ5J2YNBF5oF1j8+2kOOYhcYo8YhkAeTGb7ZJH6zUa6fXi683F5Zc/3GbbLW/C/e8QLO6+gW/nuxxCNNap4hDVqbmTnfcurIVXiGWaJBKLHZCXL6s0AgjxRQycZiy3lUmVjV/1qfNLWyEOZtbms/l1Eqjpn0dvZiDXiiUb7pNZc34qa/4m1wPV4JzsZ4ykWHOTBrA0iov1jvSamQ018hzWOGLaaUamtZOLiM841oFzdDAAM7/OX/r8BP0G+HpjavIWTXHW5njO0pAmmuyGvK7c5L9d8jXNNWqWS9BP4Q084EA/R9qnfyUF6hZ5RZy+3eKi0yWX6oj74Lz+4OJh3/PS0ejTCIEHCD1PXDHT5Ww15n9QnkZdymYzOoRx/4fFLyoDWyg1crZXI984IzpCkbQfr/e0m/zW0pvZPr1Zns2/zI/Oye9kTN+hFo/pyN0/HF3p29Pgp932qRbunfa9aFG03uyDY1QJbHULDA7p/WqbWPX8czn/+3pxO3cnvUFvqs02gpPC+yOPreDZe9+hdGggTrDvoId3Kaqdob7OL4bpsHKaBjwjPJh5vc4fFa9H/IhpjSdhGkVL/ghe72Q6RHzLLZIswPYv8IqM2NZCNuOTq8JIKZ0OcVt5/Qs

Is there a way to calculate and display the normal vector instead of lat, lon and alt ?

Can it be caclulated from the viewer.camera.position and the viewer.scene.pickPosition(movement.endPosition)?

Does the following return a normal of a picked position?

// assume picked Position is given by the handler

var pickedPosition = …;

// create a new Cartesian 3 placeholder for the normalized position

var normalForPickedPosition = new Cesium.Cartesian3();

// get the normalized position using the cesium API

Cesium.Cartesian3.normalize(pickedPosition, normalForPickedPosition);

// Is this correct???

console.log(normalizedPosition):

Can one of the Cesium expers please help answer this question?

-DC

Omar or Mathew or Gaby or Anyone,

Can one of you please suggest a way to get the surface normal of a point obtained using scene.pickPosition ?

Sorry I missed this. The normalize function just divides or scales a vector so that its magnitude is 1.

I’m pretty sure the ion SDK (which is a commercial add-on to CesiumJS) has an API for this:

Although this isn’t available in the open source CesiumJS. I think you’d have to sample more points around the original point, and then use a cross product to get a vector perpendicular to two vectors that line in the plane.

What do you need the surface normal for?

Omar,

We are trying to use the surface normal of the picked position to create an algorithm that returns a set of images that are visible around the picked position and that are in the direction of normal. (i.e., a better way to filtering out images that are associated with points that are occluded).

-DC

Omar,

Can I use something like this?

var normal = ellipsoid.geodeticSurfaceNormal(pickedPosition, new Cesium.Cartesian3())

-DC

The documentation is a good resource for describing what these functions do:

https://cesiumjs.org/Cesium/Build/Documentation/Ellipsoid.html?classFilter=Ellipsoid#geodeticSurfaceNormal

Note the description:

Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.

So if you need the surface normal of the globe (as opposed to buildings/3d tiles) then yes that’ll give you a vector pointing in the correct direction.

I’m pretty sure the ion SDK (which is a commercial add-on to CesiumJS) has an API for this:

Can you please tell me the function name to get the surface normal in the Cesium ion SDK?