Skip to content

Commit

Permalink
rename projMatrix to modelViewProjectionMatrix (#4215)
Browse files Browse the repository at this point in the history
* rename projMatrix to modelViewProjectionMatrix

* changelog

* Update CHANGELOG.md

---------

Co-authored-by: Harel M <harel.mazor@gmail.com>
  • Loading branch information
birkskyum and HarelM committed Jun 5, 2024
1 parent 0292546 commit d919ba3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
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

0 comments on commit d919ba3

Please sign in to comment.