From d919ba3b329ea749a41ba839a9b1b54031b24e9e Mon Sep 17 00:00:00 2001 From: Birk Skyum <74932975+birkskyum@users.noreply.github.com> Date: Wed, 5 Jun 2024 07:22:14 +0200 Subject: [PATCH] rename projMatrix to modelViewProjectionMatrix (#4215) * rename projMatrix to modelViewProjectionMatrix * changelog * Update CHANGELOG.md --------- Co-authored-by: Harel M --- CHANGELOG.md | 2 +- src/geo/transform.ts | 18 +++++++++--------- src/render/painter.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb7d60db6..807227bb34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - Make `aria-label` configurable for Map, Marker and Popup [#4147](https://github.com/maplibre/maplibre-gl-js/pull/4147) - Map `` 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 diff --git a/src/geo/transform.ts b/src/geo/transform.ts index bf9e83ad22..388a0189d7 100644 --- a/src/geo/transform.ts +++ b/src/geo/transform.ts @@ -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; @@ -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; @@ -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]; @@ -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); @@ -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); @@ -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]); } } diff --git a/src/render/painter.ts b/src/render/painter.ts index 39d8979241..55c28328e9 100644 --- a/src/render/painter.ts +++ b/src/render/painter.ts @@ -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;