|
2 | 2 | // SPDX-License-Identifier: MIT |
3 | 3 | // Copyright (c) vis.gl contributors |
4 | 4 |
|
5 | | -import {Matrix4} from '@math.gl/core'; |
| 5 | +import {Matrix4, vec3, vec4} from '@math.gl/core'; |
| 6 | +import {altitudeToFovy, fovyToAltitude, MAX_LATITUDE} from '@math.gl/web-mercator'; |
6 | 7 | import Viewport from './viewport'; |
7 | 8 | import {PROJECTION_MODE} from '../lib/constants'; |
8 | | -import {altitudeToFovy, fovyToAltitude} from '@math.gl/web-mercator'; |
9 | | - |
10 | | -import {vec3, vec4} from '@math.gl/core'; |
11 | 9 |
|
12 | 10 | const DEGREES_TO_RADIANS = Math.PI / 180; |
13 | 11 | const RADIANS_TO_DEGREES = 180 / Math.PI; |
14 | 12 | const EARTH_RADIUS = 6370972; |
15 | 13 | export const GLOBE_RADIUS = 256; |
| 14 | +// Where along the screen-pixel-to-globe-center distance ratio the anchored |
| 15 | +// zoom starts losing strength. Below this ratio the anchor pins exactly; from |
| 16 | +// here to the limb (ratio = 1) the anchor blends toward MIN_STRENGTH so a |
| 17 | +// near-edge pixel doesn't snap the camera across the globe. |
16 | 18 | const GLOBE_ZOOM_ANCHOR_DAMPING_START_RATIO = 0.75; |
17 | 19 | const GLOBE_ZOOM_ANCHOR_MIN_STRENGTH = 0.35; |
18 | | -import {MAX_LATITUDE} from '@math.gl/web-mercator'; |
19 | 20 |
|
20 | 21 | function getDistanceScales() { |
21 | 22 | const unitsPerMeter = GLOBE_RADIUS / EARTH_RADIUS; |
@@ -193,6 +194,12 @@ export default class GlobeViewport extends Viewport { |
193 | 194 | ]; |
194 | 195 | } |
195 | 196 |
|
| 197 | + /** |
| 198 | + * Builds the screen-pixel → globe-center ray and the intermediate ray/sphere |
| 199 | + * math reused by `unproject` (intersection point) and the public hit-test |
| 200 | + * helpers (`isPointOnGlobe`, `panByGlobeAnchor`). One function so the same |
| 201 | + * pixelUnprojectionMatrix work isn't duplicated. |
| 202 | + */ |
196 | 203 | private _getRayToGlobe( |
197 | 204 | xy: number[], |
198 | 205 | {topLeft = true, targetZ}: {topLeft?: boolean; targetZ?: number} = {} |
|
0 commit comments