mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Is calculation of the topHalfSurfaceDistance wrong at 691 line in transform.js?

Open wlfei0502 opened this issue 6 years ago • 5 comments

mapbox-gl-js version: v12.1.0 browser: chrome

source code:

const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * this.cameraToCenterDistance / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));

The cameraToCenterDistance should't be used here, because it is not the distance from the camera to [width/2, height/2 + offset.y].

I drew an image:

QQ图片20201004210459

Is it wrong?

Looking forward to reply!

wlfei0502 avatar Oct 05 '20 02:10 wlfei0502

@ansis any thoughts on this?

mourner avatar Oct 05 '20 11:10 mourner

I don't think its incorrect, the points you've labelled as centerOffset and center actually overlap. This is a more accurate representation Screen Shot 2020-10-06 at 4 46 47 PM the cameraToCenterDistance stays the same, because the center doesn't move. The padding options are used to calculate a asymmetric fov, and update the projection matrix accordingly.

arindam1993 avatar Oct 06 '20 23:10 arindam1993

@arindam1993 Thanks a lot. I understand.

wlfei0502 avatar Oct 07 '20 02:10 wlfei0502

It took me a long time to understand the meaning of the topHalfSurfaceDistance variable, can you give me some guidance, something like the above picture, thanks a lot.

altermancdx avatar Jun 28 '22 09:06 altermancdx

qq:651303647

wlfei0502 avatar Jul 07 '22 03:07 wlfei0502