Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename projMatrix to modelViewProjectionMatrix #4215

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- Make `aria-label` configurable for Map, Marker and Popup [#4147](/~https://github.com/maplibre/maplibre-gl-js/pull/4147)
- Map `<canvas>` is focusable only when interactive [#4147](/~https://github.com/maplibre/maplibre-gl-js/pull/4147)
- "Accept" headers set in Request Transformers are not overwritten [#4210](/~https://github.com/maplibre/maplibre-gl-js/pull/4210)

- ⚠️ Rename projMatrix to modelViewProjectionMatrix. Also rename invProjMatrix, alignedProjMatrix accordingly [#4215](/~https://github.com/maplibre/maplibre-gl-js/pull/4215)
- _...Add new stuff here..._

### 🐞 Bug fixes
Expand Down
18 changes: 9 additions & 9 deletions src/geo/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export class Transform {
pixelsToGLUnits: [number, number];
cameraToCenterDistance: number;
mercatorMatrix: mat4;
projMatrix: mat4;
invProjMatrix: mat4;
alignedProjMatrix: mat4;
modelViewProjectionMatrix: mat4;
invModelViewProjectionMatrix: mat4;
alignedModelViewProjectionMatrix: mat4;
pixelMatrix: mat4;
pixelMatrix3D: mat4;
pixelMatrixInverse: mat4;
Expand Down Expand Up @@ -347,7 +347,7 @@ export class Transform {
const numTiles = Math.pow(2, z);
const cameraPoint = [numTiles * cameraCoord.x, numTiles * cameraCoord.y, 0];
const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];
const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invProjMatrix, this.worldSize, z);
const cameraFrustum = Frustum.fromInvProjectionMatrix(this.invModelViewProjectionMatrix, this.worldSize, z);

// No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level
let minZoom = options.minzoom || 0;
Expand Down Expand Up @@ -708,7 +708,7 @@ export class Transform {
const posMatrix = mat4.identity(new Float64Array(16) as any);
mat4.translate(posMatrix, posMatrix, [unwrappedX * scale, canonical.y * scale, 0]);
mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);
mat4.multiply(posMatrix, aligned ? this.alignedProjMatrix : this.projMatrix, posMatrix);
mat4.multiply(posMatrix, aligned ? this.alignedModelViewProjectionMatrix : this.modelViewProjectionMatrix, posMatrix);

cache[posMatrixKey] = new Float32Array(posMatrix);
return cache[posMatrixKey];
Expand Down Expand Up @@ -907,8 +907,8 @@ export class Transform {

// matrix for conversion from world space to clip space (-1 .. 1)
mat4.translate(m, m, [0, 0, -this.elevation]); // elevate camera over terrain
this.projMatrix = m;
this.invProjMatrix = mat4.invert([] as any, m);
this.modelViewProjectionMatrix = m;
this.invModelViewProjectionMatrix = mat4.invert([] as any, m);

// matrix for conversion from world space to screen coordinates in 3D
this.pixelMatrix3D = mat4.multiply(new Float64Array(16) as any, this.labelPlaneMatrix, m);
Expand All @@ -925,7 +925,7 @@ export class Transform {
dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;
const alignedM = new Float64Array(m) as any as mat4;
mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);
this.alignedProjMatrix = alignedM;
this.alignedModelViewProjectionMatrix = alignedM;

// inverse matrix for conversion from screen coordinates to location
m = mat4.invert(new Float64Array(16) as any, this.pixelMatrix);
Expand Down Expand Up @@ -1009,7 +1009,7 @@ export class Transform {
lngLatToCameraDepth(lngLat: LngLat, elevation: number) {
const coord = this.locationCoordinate(lngLat);
const p = [coord.x * this.worldSize, coord.y * this.worldSize, elevation, 1] as vec4;
vec4.transformMat4(p, p, this.projMatrix);
vec4.transformMat4(p, p, this.modelViewProjectionMatrix);
return (p[2] / p[3]);
}
}
2 changes: 1 addition & 1 deletion src/render/painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export class Painter {
return;
}
const prevMatrix = this.terrainFacilitator.matrix;
const currMatrix = this.transform.projMatrix;
const currMatrix = this.transform.modelViewProjectionMatrix;

// Update coords/depth-framebuffer on camera movement, or tile reloading
let doUpdate = this.terrainFacilitator.dirty;
Expand Down