diff --git a/src/geo/lng_lat.js b/src/geo/lng_lat.js index ab91ecd8d94..0be5b59c4e8 100644 --- a/src/geo/lng_lat.js +++ b/src/geo/lng_lat.js @@ -130,8 +130,7 @@ class LngLat { toEcef(altitude: number): [number, number, number] { const altInEcef = globeMetersToEcef(altitude); const radius = GLOBE_RADIUS + altInEcef; - const ecef = latLngToECEF(this.lat, this.lng, radius); - return [ecef[0], ecef[1], ecef[2]]; + return (latLngToECEF(this.lat, this.lng, radius): any); } /** diff --git a/src/geo/projection/globe_util.js b/src/geo/projection/globe_util.js index 406e8584151..8bccd25d49d 100644 --- a/src/geo/projection/globe_util.js +++ b/src/geo/projection/globe_util.js @@ -16,7 +16,7 @@ import {members as globeLayoutAttributes} from '../../terrain/globe_attributes.j import posAttributes from '../../data/pos_attributes.js'; import {TriangleIndexArray, GlobeVertexArray, LineIndexArray, PosArray} from '../../data/array_types.js'; import {Aabb, Ray} from '../../util/primitives.js'; -import LngLat from '../lng_lat.js'; +import LngLat, {earthRadius} from '../lng_lat.js'; import LngLatBounds from '../lng_lat_bounds.js'; import type Painter from '../../render/painter.js'; @@ -68,7 +68,7 @@ const GLOBE_LOW_ZOOM_TILE_AABBS = [ ]; export function globeMetersToEcef(d: number): number { - return d * mercatorZfromAltitude(1, 0.0) * 2.0 * GLOBE_RADIUS * Math.PI; + return d * GLOBE_RADIUS / earthRadius; } export function globePointCoordinate(tr: Transform, x: number, y: number, clampToHorizon: boolean = true): ?MercatorCoordinate { diff --git a/src/render/draw_custom.js b/src/render/draw_custom.js index 96dd4e6bde3..9b13df75beb 100644 --- a/src/render/draw_custom.js +++ b/src/render/draw_custom.js @@ -32,7 +32,6 @@ function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomSty painter.setCustomLayerDefaults(); context.setColorMode(painter.colorModeForRenderPass()); - prerender.call(implementation, context.gl, painter.transform.customLayerMatrix()); if (painter.transform.projection.name === "globe") { prerender.call(implementation, context.gl, painter.transform.customLayerMatrix(), painter.transform.getProjection(), painter.transform.globeToMercatorMatrix(), globeToMercatorTransition(painter.transform.zoom)); } else {