@math.gl/web-mercator
Advanced tools
Comparing version 3.5.0-beta.1 to 3.5.1
@@ -34,3 +34,3 @@ "use strict"; | ||
var topRight; | ||
var halfFov = Math.atan(0.5 / viewport.altitude); | ||
var halfFov = viewport.fovy ? 0.5 * viewport.fovy * DEGREES_TO_RADIANS : Math.atan(0.5 / viewport.altitude); | ||
var angleToGround = (90 - viewport.pitch) * DEGREES_TO_RADIANS; | ||
@@ -37,0 +37,0 @@ |
// TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE | ||
/** Mapbox default altitude */ | ||
export const DEFAULT_ALTITUDE: number; | ||
/** Util functions **/ | ||
@@ -96,4 +99,3 @@ export function zoomToScale(zoom: number): number; | ||
/** | ||
* Valculates mapbox compatible projection matrix from parameters | ||
// Note: This matrix has variable fov (specified in radians) | ||
* Calculates mapbox compatible projection matrix from parameters | ||
* | ||
@@ -103,3 +105,4 @@ * @param options.width Width of "viewport" or window | ||
* @param options.pitch Camera angle in degrees (0 is straight down) | ||
* @param options.altitude of camera in screen units | ||
* @param options.fovy field of view in degrees | ||
* @param options.altitude if provided, field of view is calculated using `altitudeToFovy()` | ||
* @param options.nearZMultiplier control z buffer | ||
@@ -112,2 +115,3 @@ * @param options.farZMultiplier control z buffer | ||
height: number; | ||
fovy?: number; | ||
altitude?: number; | ||
@@ -130,3 +134,4 @@ pitch?: number; | ||
* @param options.pitch Camera angle in degrees (0 is straight down) | ||
* @param options.altitude of camera in screen units | ||
* @param options.fovy field of view in degrees | ||
* @param options.altitude if provided, field of view is calculated using `altitudeToFovy()` | ||
* @param options.nearZMultiplier control z buffer | ||
@@ -140,3 +145,4 @@ * @param options.farZMultiplier control z buffer | ||
pitch: number; | ||
altitude: number; | ||
fovy?: number; | ||
altitude?: number; | ||
nearZMultiplier: number; | ||
@@ -147,2 +153,22 @@ farZMultiplier: number; | ||
/** | ||
* | ||
* Convert an altitude to field of view such that the | ||
* focal distance is equal to the altitude | ||
* | ||
* @param altitude - altitude of camera in screen units | ||
* @return fovy field of view in degrees | ||
*/ | ||
export function altitudeToFovy(altitude: number): number; | ||
/** | ||
* | ||
* Convert an field of view such that the | ||
* focal distance is equal to the altitude | ||
* | ||
* @param fovy - field of view in degrees | ||
* @return altitude altitude of camera in screen units | ||
*/ | ||
export function fovyToAltitude(fovy: number): number; | ||
/** | ||
* Project flat coordinates to pixels on screen. | ||
@@ -149,0 +175,0 @@ * |
@@ -20,4 +20,7 @@ "use strict"; | ||
exports.getProjectionMatrix = getProjectionMatrix; | ||
exports.altitudeToFovy = altitudeToFovy; | ||
exports.fovyToAltitude = fovyToAltitude; | ||
exports.worldToPixels = worldToPixels; | ||
exports.pixelsToWorld = pixelsToWorld; | ||
exports.DEFAULT_ALTITUDE = void 0; | ||
@@ -47,2 +50,3 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var DEFAULT_ALTITUDE = 1.5; | ||
exports.DEFAULT_ALTITUDE = DEFAULT_ALTITUDE; | ||
@@ -169,4 +173,5 @@ function zoomToScale(zoom) { | ||
height = _ref8.height, | ||
_ref8$altitude = _ref8.altitude, | ||
altitude = _ref8$altitude === void 0 ? DEFAULT_ALTITUDE : _ref8$altitude, | ||
_ref8$fovy = _ref8.fovy, | ||
fovy = _ref8$fovy === void 0 ? altitudeToFovy(DEFAULT_ALTITUDE) : _ref8$fovy, | ||
altitude = _ref8.altitude, | ||
_ref8$pitch = _ref8.pitch, | ||
@@ -178,10 +183,16 @@ pitch = _ref8$pitch === void 0 ? 0 : _ref8$pitch, | ||
farZMultiplier = _ref8$farZMultiplier === void 0 ? 1 : _ref8$farZMultiplier; | ||
if (altitude !== undefined) { | ||
fovy = altitudeToFovy(altitude); | ||
} | ||
var halfFov = 0.5 * fovy * DEGREES_TO_RADIANS; | ||
var focalDistance = fovyToAltitude(fovy); | ||
var pitchRadians = pitch * DEGREES_TO_RADIANS; | ||
var halfFov = Math.atan(0.5 / altitude); | ||
var topHalfSurfaceDistance = Math.sin(halfFov) * altitude / Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01)); | ||
var farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + altitude; | ||
var topHalfSurfaceDistance = Math.sin(halfFov) * focalDistance / Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01)); | ||
var farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + focalDistance; | ||
return { | ||
fov: 2 * halfFov, | ||
aspect: width / height, | ||
focalDistance: altitude, | ||
focalDistance: focalDistance, | ||
near: nearZMultiplier, | ||
@@ -197,2 +208,3 @@ far: farZ * farZMultiplier | ||
altitude = _ref9.altitude, | ||
fovy = _ref9.fovy, | ||
nearZMultiplier = _ref9.nearZMultiplier, | ||
@@ -205,2 +217,3 @@ farZMultiplier = _ref9.farZMultiplier; | ||
altitude: altitude, | ||
fovy: fovy, | ||
pitch: pitch, | ||
@@ -219,2 +232,10 @@ nearZMultiplier: nearZMultiplier, | ||
function altitudeToFovy(altitude) { | ||
return 2 * Math.atan(0.5 / altitude) * RADIANS_TO_DEGREES; | ||
} | ||
function fovyToAltitude(fovy) { | ||
return 0.5 / Math.tan(0.5 * fovy * DEGREES_TO_RADIANS); | ||
} | ||
function worldToPixels(xyz, pixelProjectionMatrix) { | ||
@@ -221,0 +242,0 @@ var _xyz2 = (0, _slicedToArray2.default)(xyz, 3), |
@@ -14,2 +14,3 @@ import { Bounds, FitBoundsOptions } from "./fit-bounds"; | ||
altitude?: number; | ||
fovy?: number; | ||
nearZMultiplier?: number; | ||
@@ -32,2 +33,3 @@ farZMultiplier?: number; | ||
altitude: number; | ||
fovy: number; | ||
@@ -65,3 +67,4 @@ meterOffset: number[]; | ||
* @param [opt.bearing=0] - Map rotation in degrees (0 means north is up) | ||
* @param [opt.altitude=] - Altitude of camera in screen units | ||
* @param [opt.fovy=] - Field of view of camera in degrees | ||
* @param [opt.altitude=] - Altitude of camera in screen units | ||
* | ||
@@ -77,2 +80,3 @@ * Web mercator projection short-hand parameters | ||
* - Altitude has a default value that matches assumptions in mapbox-gl | ||
* - Field of view is independent from altitude, provide `altitudeToFovy(1.5)` (default value) to match assumptions in mapbox-gl | ||
* - width and height are forced to 1 if supplied as 0, to avoid | ||
@@ -79,0 +83,0 @@ * division by zero. This is intended to reduce the burden of apps to |
@@ -57,3 +57,5 @@ "use strict"; | ||
_ref$altitude = _ref.altitude, | ||
altitude = _ref$altitude === void 0 ? 1.5 : _ref$altitude, | ||
altitude = _ref$altitude === void 0 ? null : _ref$altitude, | ||
_ref$fovy = _ref.fovy, | ||
fovy = _ref$fovy === void 0 ? null : _ref$fovy, | ||
_ref$position = _ref.position, | ||
@@ -69,2 +71,12 @@ position = _ref$position === void 0 ? null : _ref$position, | ||
height = height || 1; | ||
if (fovy === null && altitude === null) { | ||
altitude = _webMercatorUtils.DEFAULT_ALTITUDE; | ||
fovy = (0, _webMercatorUtils.altitudeToFovy)(altitude); | ||
} else if (fovy === null) { | ||
fovy = (0, _webMercatorUtils.altitudeToFovy)(altitude); | ||
} else if (altitude === null) { | ||
altitude = (0, _webMercatorUtils.fovyToAltitude)(fovy); | ||
} | ||
var scale = (0, _webMercatorUtils.zoomToScale)(zoom); | ||
@@ -87,3 +99,3 @@ altitude = Math.max(0.75, altitude); | ||
pitch: pitch, | ||
altitude: altitude, | ||
fovy: fovy, | ||
nearZMultiplier: nearZMultiplier, | ||
@@ -109,2 +121,3 @@ farZMultiplier: farZMultiplier | ||
this.altitude = altitude; | ||
this.fovy = fovy; | ||
this.center = center; | ||
@@ -111,0 +124,0 @@ this.meterOffset = position || [0, 0, 0]; |
@@ -18,3 +18,3 @@ import { worldToLngLat } from './web-mercator-utils'; | ||
let topRight; | ||
const halfFov = Math.atan(0.5 / viewport.altitude); | ||
const halfFov = viewport.fovy ? 0.5 * viewport.fovy * DEGREES_TO_RADIANS : Math.atan(0.5 / viewport.altitude); | ||
const angleToGround = (90 - viewport.pitch) * DEGREES_TO_RADIANS; | ||
@@ -21,0 +21,0 @@ |
// TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE | ||
/** Mapbox default altitude */ | ||
export const DEFAULT_ALTITUDE: number; | ||
/** Util functions **/ | ||
@@ -96,4 +99,3 @@ export function zoomToScale(zoom: number): number; | ||
/** | ||
* Valculates mapbox compatible projection matrix from parameters | ||
// Note: This matrix has variable fov (specified in radians) | ||
* Calculates mapbox compatible projection matrix from parameters | ||
* | ||
@@ -103,3 +105,4 @@ * @param options.width Width of "viewport" or window | ||
* @param options.pitch Camera angle in degrees (0 is straight down) | ||
* @param options.altitude of camera in screen units | ||
* @param options.fovy field of view in degrees | ||
* @param options.altitude if provided, field of view is calculated using `altitudeToFovy()` | ||
* @param options.nearZMultiplier control z buffer | ||
@@ -112,2 +115,3 @@ * @param options.farZMultiplier control z buffer | ||
height: number; | ||
fovy?: number; | ||
altitude?: number; | ||
@@ -130,3 +134,4 @@ pitch?: number; | ||
* @param options.pitch Camera angle in degrees (0 is straight down) | ||
* @param options.altitude of camera in screen units | ||
* @param options.fovy field of view in degrees | ||
* @param options.altitude if provided, field of view is calculated using `altitudeToFovy()` | ||
* @param options.nearZMultiplier control z buffer | ||
@@ -140,3 +145,4 @@ * @param options.farZMultiplier control z buffer | ||
pitch: number; | ||
altitude: number; | ||
fovy?: number; | ||
altitude?: number; | ||
nearZMultiplier: number; | ||
@@ -147,2 +153,22 @@ farZMultiplier: number; | ||
/** | ||
* | ||
* Convert an altitude to field of view such that the | ||
* focal distance is equal to the altitude | ||
* | ||
* @param altitude - altitude of camera in screen units | ||
* @return fovy field of view in degrees | ||
*/ | ||
export function altitudeToFovy(altitude: number): number; | ||
/** | ||
* | ||
* Convert an field of view such that the | ||
* focal distance is equal to the altitude | ||
* | ||
* @param fovy - field of view in degrees | ||
* @return altitude altitude of camera in screen units | ||
*/ | ||
export function fovyToAltitude(fovy: number): number; | ||
/** | ||
* Project flat coordinates to pixels on screen. | ||
@@ -149,0 +175,0 @@ * |
@@ -12,3 +12,3 @@ import { createMat4, transformVector, log2 } from './math-utils'; | ||
const EARTH_CIRCUMFERENCE = 40.03e6; | ||
const DEFAULT_ALTITUDE = 1.5; | ||
export const DEFAULT_ALTITUDE = 1.5; | ||
export function zoomToScale(zoom) { | ||
@@ -111,3 +111,4 @@ return Math.pow(2, zoom); | ||
height, | ||
altitude = DEFAULT_ALTITUDE, | ||
fovy = altitudeToFovy(DEFAULT_ALTITUDE), | ||
altitude, | ||
pitch = 0, | ||
@@ -117,10 +118,15 @@ nearZMultiplier = 1, | ||
}) { | ||
if (altitude !== undefined) { | ||
fovy = altitudeToFovy(altitude); | ||
} | ||
const halfFov = 0.5 * fovy * DEGREES_TO_RADIANS; | ||
const focalDistance = fovyToAltitude(fovy); | ||
const pitchRadians = pitch * DEGREES_TO_RADIANS; | ||
const halfFov = Math.atan(0.5 / altitude); | ||
const topHalfSurfaceDistance = Math.sin(halfFov) * altitude / Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01)); | ||
const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + altitude; | ||
const topHalfSurfaceDistance = Math.sin(halfFov) * focalDistance / Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01)); | ||
const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + focalDistance; | ||
return { | ||
fov: 2 * halfFov, | ||
aspect: width / height, | ||
focalDistance: altitude, | ||
focalDistance, | ||
near: nearZMultiplier, | ||
@@ -135,2 +141,3 @@ far: farZ * farZMultiplier | ||
altitude, | ||
fovy, | ||
nearZMultiplier, | ||
@@ -148,2 +155,3 @@ farZMultiplier | ||
altitude, | ||
fovy, | ||
pitch, | ||
@@ -156,2 +164,8 @@ nearZMultiplier, | ||
} | ||
export function altitudeToFovy(altitude) { | ||
return 2 * Math.atan(0.5 / altitude) * RADIANS_TO_DEGREES; | ||
} | ||
export function fovyToAltitude(fovy) { | ||
return 0.5 / Math.tan(0.5 * fovy * DEGREES_TO_RADIANS); | ||
} | ||
export function worldToPixels(xyz, pixelProjectionMatrix) { | ||
@@ -158,0 +172,0 @@ const [x, y, z = 0] = xyz; |
@@ -14,2 +14,3 @@ import { Bounds, FitBoundsOptions } from "./fit-bounds"; | ||
altitude?: number; | ||
fovy?: number; | ||
nearZMultiplier?: number; | ||
@@ -32,2 +33,3 @@ farZMultiplier?: number; | ||
altitude: number; | ||
fovy: number; | ||
@@ -65,3 +67,4 @@ meterOffset: number[]; | ||
* @param [opt.bearing=0] - Map rotation in degrees (0 means north is up) | ||
* @param [opt.altitude=] - Altitude of camera in screen units | ||
* @param [opt.fovy=] - Field of view of camera in degrees | ||
* @param [opt.altitude=] - Altitude of camera in screen units | ||
* | ||
@@ -77,2 +80,3 @@ * Web mercator projection short-hand parameters | ||
* - Altitude has a default value that matches assumptions in mapbox-gl | ||
* - Field of view is independent from altitude, provide `altitudeToFovy(1.5)` (default value) to match assumptions in mapbox-gl | ||
* - width and height are forced to 1 if supplied as 0, to avoid | ||
@@ -79,0 +83,0 @@ * division by zero. This is intended to reduce the burden of apps to |
import { createMat4 } from './math-utils'; | ||
import { zoomToScale, pixelsToWorld, lngLatToWorld, worldToLngLat, worldToPixels, getProjectionMatrix, getDistanceScales, getViewMatrix } from './web-mercator-utils'; | ||
import { zoomToScale, pixelsToWorld, lngLatToWorld, worldToLngLat, worldToPixels, altitudeToFovy, fovyToAltitude, DEFAULT_ALTITUDE, getProjectionMatrix, getDistanceScales, getViewMatrix } from './web-mercator-utils'; | ||
import fitBounds from './fit-bounds'; | ||
@@ -17,3 +17,4 @@ import getBounds from './get-bounds'; | ||
bearing = 0, | ||
altitude = 1.5, | ||
altitude = null, | ||
fovy = null, | ||
position = null, | ||
@@ -28,2 +29,12 @@ nearZMultiplier = 0.02, | ||
height = height || 1; | ||
if (fovy === null && altitude === null) { | ||
altitude = DEFAULT_ALTITUDE; | ||
fovy = altitudeToFovy(altitude); | ||
} else if (fovy === null) { | ||
fovy = altitudeToFovy(altitude); | ||
} else if (altitude === null) { | ||
altitude = fovyToAltitude(fovy); | ||
} | ||
const scale = zoomToScale(zoom); | ||
@@ -46,3 +57,3 @@ altitude = Math.max(0.75, altitude); | ||
pitch, | ||
altitude, | ||
fovy, | ||
nearZMultiplier, | ||
@@ -68,2 +79,3 @@ farZMultiplier | ||
this.altitude = altitude; | ||
this.fovy = fovy; | ||
this.center = center; | ||
@@ -70,0 +82,0 @@ this.meterOffset = position || [0, 0, 0]; |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "3.5.0-beta.1", | ||
"version": "3.5.1", | ||
"keywords": [ | ||
@@ -37,3 +37,3 @@ "webgl", | ||
}, | ||
"gitHead": "193857458219ebd3a605c5c64f3b330ff48dcf02" | ||
"gitHead": "87d3c652ac0d1ac94d27345e50cba755ecf32d92" | ||
} |
@@ -20,3 +20,5 @@ import {worldToLngLat} from './web-mercator-utils'; | ||
const halfFov = Math.atan(0.5 / viewport.altitude); | ||
const halfFov = viewport.fovy | ||
? 0.5 * viewport.fovy * DEGREES_TO_RADIANS | ||
: Math.atan(0.5 / viewport.altitude); | ||
const angleToGround = (90 - viewport.pitch) * DEGREES_TO_RADIANS; | ||
@@ -23,0 +25,0 @@ // The top plane is parallel to the ground if halfFov == angleToGround |
// TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE | ||
/** Mapbox default altitude */ | ||
export const DEFAULT_ALTITUDE: number; | ||
/** Util functions **/ | ||
@@ -96,4 +99,3 @@ export function zoomToScale(zoom: number): number; | ||
/** | ||
* Valculates mapbox compatible projection matrix from parameters | ||
// Note: This matrix has variable fov (specified in radians) | ||
* Calculates mapbox compatible projection matrix from parameters | ||
* | ||
@@ -103,3 +105,4 @@ * @param options.width Width of "viewport" or window | ||
* @param options.pitch Camera angle in degrees (0 is straight down) | ||
* @param options.altitude of camera in screen units | ||
* @param options.fovy field of view in degrees | ||
* @param options.altitude if provided, field of view is calculated using `altitudeToFovy()` | ||
* @param options.nearZMultiplier control z buffer | ||
@@ -112,2 +115,3 @@ * @param options.farZMultiplier control z buffer | ||
height: number; | ||
fovy?: number; | ||
altitude?: number; | ||
@@ -130,3 +134,4 @@ pitch?: number; | ||
* @param options.pitch Camera angle in degrees (0 is straight down) | ||
* @param options.altitude of camera in screen units | ||
* @param options.fovy field of view in degrees | ||
* @param options.altitude if provided, field of view is calculated using `altitudeToFovy()` | ||
* @param options.nearZMultiplier control z buffer | ||
@@ -140,3 +145,4 @@ * @param options.farZMultiplier control z buffer | ||
pitch: number; | ||
altitude: number; | ||
fovy?: number; | ||
altitude?: number; | ||
nearZMultiplier: number; | ||
@@ -147,2 +153,22 @@ farZMultiplier: number; | ||
/** | ||
* | ||
* Convert an altitude to field of view such that the | ||
* focal distance is equal to the altitude | ||
* | ||
* @param altitude - altitude of camera in screen units | ||
* @return fovy field of view in degrees | ||
*/ | ||
export function altitudeToFovy(altitude: number): number; | ||
/** | ||
* | ||
* Convert an field of view such that the | ||
* focal distance is equal to the altitude | ||
* | ||
* @param fovy - field of view in degrees | ||
* @return altitude altitude of camera in screen units | ||
*/ | ||
export function fovyToAltitude(fovy: number): number; | ||
/** | ||
* Project flat coordinates to pixels on screen. | ||
@@ -149,0 +175,0 @@ * |
@@ -20,3 +20,3 @@ // TODO - THE UTILITIES IN THIS FILE SHOULD BE IMPORTED FROM WEB-MERCATOR-VIEWPORT MODULE | ||
// Mapbox default altitude | ||
const DEFAULT_ALTITUDE = 1.5; | ||
export const DEFAULT_ALTITUDE = 1.5; | ||
@@ -198,3 +198,4 @@ /** Util functions **/ | ||
height, | ||
altitude = DEFAULT_ALTITUDE, | ||
fovy = altitudeToFovy(DEFAULT_ALTITUDE), | ||
altitude, | ||
pitch = 0, | ||
@@ -204,12 +205,19 @@ nearZMultiplier = 1, | ||
}) { | ||
// For back-compatibility allow field of view to be | ||
// derived from altitude | ||
if (altitude !== undefined) { | ||
fovy = altitudeToFovy(altitude); | ||
} | ||
const halfFov = 0.5 * fovy * DEGREES_TO_RADIANS; | ||
const focalDistance = fovyToAltitude(fovy); | ||
// Find the distance from the center point to the center top | ||
// in altitude units using law of sines. | ||
// in focal distance units using law of sines. | ||
const pitchRadians = pitch * DEGREES_TO_RADIANS; | ||
const halfFov = Math.atan(0.5 / altitude); | ||
const topHalfSurfaceDistance = | ||
(Math.sin(halfFov) * altitude) / | ||
(Math.sin(halfFov) * focalDistance) / | ||
Math.sin(Math.min(Math.max(Math.PI / 2 - pitchRadians - halfFov, 0.01), Math.PI - 0.01)); | ||
// Calculate z value of the farthest fragment that should be rendered. | ||
const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + altitude; | ||
const farZ = Math.sin(pitchRadians) * topHalfSurfaceDistance + focalDistance; | ||
@@ -219,3 +227,3 @@ return { | ||
aspect: width / height, | ||
focalDistance: altitude, | ||
focalDistance, | ||
near: nearZMultiplier, | ||
@@ -235,2 +243,3 @@ far: farZ * farZMultiplier | ||
altitude, | ||
fovy, | ||
nearZMultiplier, | ||
@@ -243,2 +252,3 @@ farZMultiplier | ||
altitude, | ||
fovy, | ||
pitch, | ||
@@ -260,2 +270,13 @@ nearZMultiplier, | ||
// Utility function to calculate the field of view such that | ||
// the focal distance is equal to the ground distance. This | ||
// is how mapbox's z fov is calculated | ||
export function altitudeToFovy(altitude) { | ||
return 2 * Math.atan(0.5 / altitude) * RADIANS_TO_DEGREES; | ||
} | ||
export function fovyToAltitude(fovy) { | ||
return 0.5 / Math.tan(0.5 * fovy * DEGREES_TO_RADIANS); | ||
} | ||
// Project flat coordinates to pixels on screen. | ||
@@ -262,0 +283,0 @@ export function worldToPixels(xyz, pixelProjectionMatrix) { |
@@ -14,2 +14,3 @@ import { Bounds, FitBoundsOptions } from "./fit-bounds"; | ||
altitude?: number; | ||
fovy?: number; | ||
nearZMultiplier?: number; | ||
@@ -32,2 +33,3 @@ farZMultiplier?: number; | ||
altitude: number; | ||
fovy: number; | ||
@@ -65,3 +67,4 @@ meterOffset: number[]; | ||
* @param [opt.bearing=0] - Map rotation in degrees (0 means north is up) | ||
* @param [opt.altitude=] - Altitude of camera in screen units | ||
* @param [opt.fovy=] - Field of view of camera in degrees | ||
* @param [opt.altitude=] - Altitude of camera in screen units | ||
* | ||
@@ -77,2 +80,3 @@ * Web mercator projection short-hand parameters | ||
* - Altitude has a default value that matches assumptions in mapbox-gl | ||
* - Field of view is independent from altitude, provide `altitudeToFovy(1.5)` (default value) to match assumptions in mapbox-gl | ||
* - width and height are forced to 1 if supplied as 0, to avoid | ||
@@ -79,0 +83,0 @@ * division by zero. This is intended to reduce the burden of apps to |
@@ -10,2 +10,5 @@ // View and Projection Matrix calculations for mapbox-js style map view properties | ||
worldToPixels, | ||
altitudeToFovy, | ||
fovyToAltitude, | ||
DEFAULT_ALTITUDE, | ||
getProjectionMatrix, | ||
@@ -34,3 +37,4 @@ getDistanceScales, | ||
bearing = 0, | ||
altitude = 1.5, | ||
altitude = null, | ||
fovy = null, | ||
position = null, | ||
@@ -45,2 +49,14 @@ nearZMultiplier = 0.02, | ||
// `fovy` & `altitude` are independent parameters, one for the | ||
// projection and the latter for the view matrix. In the past, | ||
// the `fovy` was always derived from the `altitude` | ||
if (fovy === null && altitude === null) { | ||
altitude = DEFAULT_ALTITUDE; | ||
fovy = altitudeToFovy(altitude); | ||
} else if (fovy === null) { | ||
fovy = altitudeToFovy(altitude); | ||
} else if (altitude === null) { | ||
altitude = fovyToAltitude(fovy); | ||
} | ||
const scale = zoomToScale(zoom); | ||
@@ -64,3 +80,3 @@ // Altitude - prevent division by 0 | ||
pitch, | ||
altitude, | ||
fovy, | ||
nearZMultiplier, | ||
@@ -90,2 +106,3 @@ farZMultiplier | ||
this.altitude = altitude; | ||
this.fovy = fovy; | ||
this.center = center; | ||
@@ -92,0 +109,0 @@ this.meterOffset = position || [0, 0, 0]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
278186
3834
1