Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.distanceScales.pixelsPerMeter = new Vector3(this.distanceScales.pixelsPerMeter);
this.position = ZERO_VECTOR;
this.meterOffset = ZERO_VECTOR;
if (position) {
// Apply model matrix if supplied
this.position = position;
this.modelMatrix = modelMatrix;
this.meterOffset = modelMatrix ? modelMatrix.transformVector(position) : position;
}
this.viewMatrixUncentered = viewMatrix;
if (this.isGeospatial) {
// Determine camera center
this.center = getWorldPosition({
longitude,
latitude,
scale: this.scale,
distanceScales: this.distanceScales,
meterOffset: this.meterOffset
});
// Make a centered version of the matrix for projection modes without an offset
this.viewMatrix = new Matrix4()
// Apply the uncentered view matrix
.multiplyRight(this.viewMatrixUncentered)
// The Mercator world coordinate system is upper left,
// but GL expects lower left, so we flip it around the center after all transforms are done
.scale([1, -1, 1])
// And center it
.translate(new Vector3(this.center || ZERO_VECTOR).negate());
});
const distanceScalesInputScale = {
longitude: 1,
latitude: 2,
scale: 1,
};
const { metersPerPixel } = getDistanceScales(distanceScalesInputScale);
const { pixelsPerMeter2 } = getDistanceScales({
...distanceScalesInputScale,
highPrecision: true,
});
const worldPos = getWorldPosition({
longitude: 1,
latitude: 2,
zoom: 10,
scale: 1,
});
const length = worldPos.length;