Skip to content

Commit

Permalink
added missing LineFactory changes, related to c381f20
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Deubler <[email protected]>
  • Loading branch information
TerminalTim committed Nov 24, 2023
1 parent c381f20 commit 24a6f42
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions packages/display/src/displays/webgl/buffer/LineFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const DEFAULT_MIN_REPEAT = 256;
let UNDEF;

enum DIR {
MID_TO_END = 1,
MID_TO_START = -1
MID_TO_END = 1,
MID_TO_START = -1
}

type PlacePointCallback = (x: number, y: number, z: number | null, rotZ: number, rotY: number, collisionData?: CollisionData) => void;
Expand Down Expand Up @@ -81,9 +81,9 @@ export class LineFactory {
z = coord[2] || 0;

if (!c ||
(Math.round(_x * decimals) - Math.round(x * decimals)) ||
(Math.round(_y * decimals) - Math.round(y * decimals)) ||
(hasZ && z != _z)
(Math.round(_x * decimals) - Math.round(x * decimals)) ||
(Math.round(_y * decimals) - Math.round(y * decimals)) ||
(hasZ && z != _z)
) {
pixels[t++] = x;
pixels[t++] = y;
Expand Down Expand Up @@ -128,11 +128,11 @@ export class LineFactory {
for (let id in repeat) {
repeat[id].clear();
}
// this.repeat.clear();
// this.repeat.clear();
}

initFeature(zoom: number, tileSize: number, distanceGroup?: string) {
// allow more precision in case tiles are getting zoomed very close (zoomlevel 20+)
// allow more precision in case tiles are getting zoomed very close (zoomlevel 20+)
this.decimals = zoom >= 20 - Number(tileSize == 512) ? 1e2 : 1;
// clear projected coordinate cache
this.length = 0;
Expand All @@ -153,7 +153,7 @@ export class LineFactory {
tile: Tile,
tileSize: number,
removeTileBounds: boolean,
strokeDasharray: { pattern: [number, number, number?], units: number[] },
strokeDasharray: { pattern: number[], units: string[] },
strokeLinecap: Cap,
strokeLinejoin: Join,
strokeWidth: number,
Expand All @@ -169,15 +169,17 @@ export class LineFactory {
const groupBuffer: LineBuffer = group.buffer;

if (strokeDasharray) {
const texture = this.dashes.get(strokeDasharray.pattern);
groupBuffer.addUniform('u_pattern', texture);

groupBuffer.addUniform('u_dashSize', [
texture.width,
1 / this.dashes.scale,
strokeDasharray.pattern[0],
strokeDasharray.pattern[1]
]);
const {units} = strokeDasharray;
const mixedUnits = units.some((e) => e != units[0]);

// Multiple dash/gap combinations are exclusively supported within the same unit due to the utilization of a pattern texture.
if (strokeDasharray.pattern.length > 2 && !mixedUnits) {
const dashPatternTexture = this.dashes.get(strokeDasharray.pattern);
groupBuffer.addUniform('u_dashPattern', dashPatternTexture.texture);
groupBuffer.addUniform('u_dashSize', [dashPatternTexture.texture.width / dashPatternTexture.scale, 0]);
} else {
groupBuffer.addUniform('u_dashSize', [strokeDasharray.pattern[0], strokeDasharray.pattern[1]]);
}
}

this.projectLine(coordinates, tile, tileSize);
Expand Down

0 comments on commit 24a6f42

Please sign in to comment.