MCPcopy Index your code
hub / github.com/microsoft/SandDance / constructor

Method constructor

docs/app/js/sanddance-app.js:79978–80118  ·  view source on GitHub ↗
(props = {
        width: 1,
        height: 1
    })

Source from the content-addressed store, hash-verified

79976var _vec3 = require("gl-matrix/vec3");
79977class WebMercatorViewport {
79978 constructor(props = {
79979 width: 1,
79980 height: 1
79981 }){
79982 (0, _definePropertyDefault.default)(this, "latitude", void 0);
79983 (0, _definePropertyDefault.default)(this, "longitude", void 0);
79984 (0, _definePropertyDefault.default)(this, "zoom", void 0);
79985 (0, _definePropertyDefault.default)(this, "pitch", void 0);
79986 (0, _definePropertyDefault.default)(this, "bearing", void 0);
79987 (0, _definePropertyDefault.default)(this, "altitude", void 0);
79988 (0, _definePropertyDefault.default)(this, "fovy", void 0);
79989 (0, _definePropertyDefault.default)(this, "meterOffset", void 0);
79990 (0, _definePropertyDefault.default)(this, "center", void 0);
79991 (0, _definePropertyDefault.default)(this, "width", void 0);
79992 (0, _definePropertyDefault.default)(this, "height", void 0);
79993 (0, _definePropertyDefault.default)(this, "scale", void 0);
79994 (0, _definePropertyDefault.default)(this, "distanceScales", void 0);
79995 (0, _definePropertyDefault.default)(this, "viewMatrix", void 0);
79996 (0, _definePropertyDefault.default)(this, "projectionMatrix", void 0);
79997 (0, _definePropertyDefault.default)(this, "viewProjectionMatrix", void 0);
79998 (0, _definePropertyDefault.default)(this, "pixelProjectionMatrix", void 0);
79999 (0, _definePropertyDefault.default)(this, "pixelUnprojectionMatrix", void 0);
80000 (0, _definePropertyDefault.default)(this, "equals", (viewport)=>{
80001 if (!(viewport instanceof WebMercatorViewport)) return false;
80002 return viewport.width === this.width && viewport.height === this.height && _mat4.equals(viewport.projectionMatrix, this.projectionMatrix) && _mat4.equals(viewport.viewMatrix, this.viewMatrix);
80003 });
80004 (0, _definePropertyDefault.default)(this, "project", (lngLatZ, options = {})=>{
80005 const { topLeft =true } = options;
80006 const worldPosition = this.projectPosition(lngLatZ);
80007 const coord = (0, _webMercatorUtils.worldToPixels)(worldPosition, this.pixelProjectionMatrix);
80008 const [x, y] = coord;
80009 const y2 = topLeft ? y : this.height - y;
80010 return lngLatZ.length === 2 ? [
80011 x,
80012 y2
80013 ] : [
80014 x,
80015 y2,
80016 coord[2]
80017 ];
80018 });
80019 (0, _definePropertyDefault.default)(this, "unproject", (xyz, options = {})=>{
80020 const { topLeft =true , targetZ } = options;
80021 const [x, y, z] = xyz;
80022 const y2 = topLeft ? y : this.height - y;
80023 const targetZWorld = targetZ && targetZ * this.distanceScales.unitsPerMeter[2];
80024 const coord = (0, _webMercatorUtils.pixelsToWorld)([
80025 x,
80026 y2,
80027 z
80028 ], this.pixelUnprojectionMatrix, targetZWorld);
80029 const [X, Y, Z] = this.unprojectPosition(coord);
80030 if (Number.isFinite(z)) return [
80031 X,
80032 Y,
80033 Z
80034 ];
80035 return Number.isFinite(targetZ) ? [

Callers

nothing calls this directly

Calls 4

_initMatricesMethod · 0.95
equalsMethod · 0.45
maxMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected