Select to view content in your preferred language

toScreen seems to be ignoring z value

09-07-2023 04:10 AM
New Contributor

The problem I'm facing by the moments is that the toScreen operation seems to be ignoring the z value in a determined map point, in which are being passed of course x, y and z values. 

After running toScreen the 'flattened' x and y values seem to point to an object at sea level (with elevation 0). Unfortunately in this case, we would need the screen point to work with elevated coordinates (on top of a mountain). 

Here's a sample of the code: 

const translatedPoint = {
    x: htmlDef.point.x,
    y: htmlDef.point.y,
    z: htmlDef.point.z,
const convertedPoint = _scnview.toScreen(translatedPoint)

The behaviour: 

Screenshot 2023-09-07 at 11.57.07.png

The z value of this point is 2000, which corresponds with what I have found from the sceneView camera.


Is this functionality actually being covered by the toScreen option?. If not, is there any alternative function that could handle this?. 

Many thanks, 



0 Kudos
2 Replies
Esri Regular Contributor

Hi @JulioPereira, thanks for the question. It looks like the SceneView.toScreen() method

takes a point geometry and returns a ScreenPoint

which does not have a z-value. So it seems like the current behavior is by design.


0 Kudos
New Contributor

Hello @noah, thanks for the reply. 

Probably I didn't make myself clear. It's clear the 'toScreen' operation should produce only a x and y values to represent in a flat screen some 3d coordinates in the sceneView. Nonetheless, if I passed a point with elevation (z higher than 0), the 'toScreen' function will produce x and y values at sea level (ignoring elevation). 

In the picture I shared in the post you can see some html point element overlaying on top of the viewer. The position of this html has been determined using 'toScreen'. The point is having a z value of 2000, nonetheless if I put the camera with 'tilt' near 90 (seeing the mountain in front) I can see the point seems to be 'below' the mountain. 


0 Kudos