Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
3371c5c
Move to Luma.gl 9
birkskyum Mar 2, 2026
eaf57cc
fix build
birkskyum Mar 2, 2026
1a4d8ff
checkpoint background layer working
birkskyum Mar 4, 2026
9fe1978
fill and line
birkskyum Mar 4, 2026
c141faa
stencil clipping
birkskyum Mar 4, 2026
4fa7aef
doesn't zoom glitch
birkskyum Mar 5, 2026
0606a82
stencil mask
birkskyum Mar 5, 2026
ffefd9e
fix webgl2
birkskyum Apr 3, 2026
070c29e
drawmode
birkskyum Apr 3, 2026
4797da8
fix background
birkskyum Apr 3, 2026
9df3551
add terrain
birkskyum Apr 3, 2026
c8e0444
fix terrain height
birkskyum Apr 3, 2026
0e58662
cleanup terrain
birkskyum Apr 3, 2026
cebdb12
globe with terrain fixes
birkskyum Apr 3, 2026
c26e63f
globe with terrain
birkskyum Apr 4, 2026
7b1e7b5
fix pixelratio
birkskyum Apr 4, 2026
27fd0f4
add backend opiton to render harness
birkskyum Apr 4, 2026
bb1cc3f
webgpu render harness
birkskyum Apr 4, 2026
234bbc3
improve webgpu harness
birkskyum Apr 4, 2026
f8f3f65
use alphamode for webgpu
birkskyum Apr 4, 2026
f625ad4
fix circle webgpu
birkskyum Apr 4, 2026
59873cc
fill circle
birkskyum Apr 4, 2026
4eb98c5
remove logs, work on stencil clipping
birkskyum Apr 4, 2026
eb51bbe
fix stencil clipping
birkskyum Apr 4, 2026
17e6ffd
webgpu: line drawables
birkskyum Apr 4, 2026
3d1fe97
improve line
birkskyum Apr 4, 2026
659a14a
line layer tweaker for line dash array
birkskyum Apr 4, 2026
474cf65
raster
birkskyum Apr 4, 2026
3435586
webgpu raster
birkskyum Apr 4, 2026
5b4c992
webgpu fill extrusion
birkskyum Apr 4, 2026
a0871f5
depts orderign
birkskyum Apr 4, 2026
70bd988
z-fighting
birkskyum Apr 4, 2026
6d24eb7
reorganize
birkskyum Apr 4, 2026
60b3bd9
remove luma
birkskyum Apr 4, 2026
1829aee
remove luma
birkskyum Apr 4, 2026
e27d524
remove luma model
birkskyum Apr 4, 2026
2a852d8
remove luma
birkskyum Apr 4, 2026
1d275eb
webgl
birkskyum Apr 4, 2026
e7104d8
remove unused
birkskyum Apr 4, 2026
b6d3d6b
fix webgpu
birkskyum Apr 4, 2026
09c0467
cleanup comments
birkskyum Apr 4, 2026
e7dfce7
symbol sdf
birkskyum Apr 4, 2026
a846872
symbol sdf - placeholder
birkskyum Apr 4, 2026
3058701
symbol sdf debug
birkskyum Apr 4, 2026
a2824fc
lables readable
birkskyum Apr 4, 2026
ec8397b
sdf halo
birkskyum Apr 4, 2026
4e85e06
better symbol size
birkskyum Apr 4, 2026
11fc698
sharp text
birkskyum Apr 4, 2026
cadf9a6
symbol on lines
birkskyum Apr 4, 2026
28d093d
streeet labels
birkskyum Apr 4, 2026
b8ce01b
street name
birkskyum Apr 4, 2026
6230ada
add collition
birkskyum Apr 4, 2026
36b332d
opaque lines
birkskyum Apr 4, 2026
39a2882
fix line width
birkskyum Apr 4, 2026
866a133
clip space line sdf
birkskyum Apr 4, 2026
cb69f8f
stencil clippin on lines
birkskyum Apr 4, 2026
37ca57f
fix gamma on equator lines
birkskyum Apr 4, 2026
64ef1b1
white clearvalue
birkskyum Apr 4, 2026
c9f36eb
heatmap layer
birkskyum Apr 4, 2026
05b67bb
render heatmap
birkskyum Apr 4, 2026
d7b71d3
fix heatmap positioning
birkskyum Apr 4, 2026
d40d6aa
hillshade init
birkskyum Apr 4, 2026
87ac8a7
hillshade contour
birkskyum Apr 4, 2026
a4f5cb0
0-255 terrain 3e
birkskyum Apr 4, 2026
454b95b
hillshade fixes
birkskyum Apr 4, 2026
53396fc
fix hillshade tile loading
birkskyum Apr 4, 2026
7839c35
symbol icon
birkskyum Apr 4, 2026
d24cf47
fix antialiasing
birkskyum Apr 4, 2026
d84a359
fix stencil clipping
birkskyum Apr 4, 2026
8d11f47
fill tweaker
birkskyum Apr 5, 2026
2a22db8
fix demotiles
birkskyum Apr 5, 2026
f382795
fix libert
birkskyum Apr 5, 2026
0db95af
fix liberty fill water
birkskyum Apr 5, 2026
ac98f1f
background pattern
birkskyum Apr 5, 2026
7bb771d
fill pattern
birkskyum Apr 5, 2026
5ac199c
fill pattern
birkskyum Apr 5, 2026
8e34378
fill pattern sprite selection
birkskyum Apr 5, 2026
9a542a5
canonical z on fill-pattern
birkskyum Apr 5, 2026
ffcbdba
fill pattern outline
birkskyum Apr 5, 2026
643949d
line pattern
birkskyum Apr 5, 2026
c0c4852
fix line step
birkskyum Apr 5, 2026
095c164
use weakmap
birkskyum Apr 5, 2026
0580dcb
fix map
birkskyum Apr 5, 2026
9cc9c86
work on terrain
birkskyum Apr 5, 2026
73176b3
3d terrain
birkskyum Apr 5, 2026
428a8df
create gfx folder
birkskyum Apr 6, 2026
652e461
webgpu draw folder
birkskyum Apr 6, 2026
f7cb9c0
extract hillshade and heatmap
birkskyum Apr 6, 2026
a6eaf1c
move wgsl to separate folder
birkskyum Apr 6, 2026
cf3d00c
add back wgsl_preprocessor
birkskyum Apr 6, 2026
4423540
remove duplicate shaders
birkskyum Apr 6, 2026
1590055
use glsl directory
birkskyum Apr 6, 2026
3574267
fix glsl imports
birkskyum Apr 6, 2026
4511168
Merge remote-tracking branch 'origin/main' into webgpu-backend
birkskyum Apr 6, 2026
96bcb7f
fix remainin conflicts
birkskyum Apr 6, 2026
2435edc
Merge remote-tracking branch 'origin/main' into webgpu-backend
birkskyum Apr 6, 2026
c39a7e4
cleanup comments
birkskyum Apr 6, 2026
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
32 changes: 20 additions & 12 deletions build/generate-shaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,32 @@ console.log('Generating shaders');
* It will also create a simple package.json file to allow importing this package in webpack
*/

function glslToTs(code: string): string {
code = code
.trim() // strip whitespace at the start/end
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
.replace(/\n+/g, '\n') // collapse multi line breaks
.replace(/\n\s+/g, '\n') // strip indentation
.replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
.replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
function glslToTs(code: string, isWgsl: boolean = false): string {
if (!isWgsl) {
code = code
.trim() // strip whitespace at the start/end
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
.replace(/\n+/g, '\n') // collapse multi line breaks
.replace(/\n\s+/g, '\n') // strip indentation
.replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
.replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
} else {
code = code.trim().replace(/\s*\/\/[^\n]*\n/g, '\n');
// For WGSL, be less aggressive with space stripping to avoid breaking parsers.
}

return `// This file is generated. Edit build/generate-shaders.ts, then run \`npm run codegen\`.
export default ${JSON.stringify(code).replaceAll('"', '\'')};\n`;
}

const shaderFiles = globSync('./src/shaders/glsl/*.glsl');
const shaderFiles = [...globSync('./src/shaders/glsl/*.glsl'), ...globSync('./src/shaders/wgsl/*.wgsl')];
for (const file of shaderFiles) {
const glslFile = fs.readFileSync(file, 'utf8');
const tsSource = glslToTs(glslFile);
const fileName = path.join('.', 'src', 'shaders', 'glsl', `${file.split(path.sep).splice(-1)}.g.ts`);
const shaderSource = fs.readFileSync(file, 'utf8');
const isWgsl = file.endsWith('.wgsl');
const tsSource = glslToTs(shaderSource, isWgsl);
// Output .g.ts files alongside the sources: glsl/ for GLSL, wgsl/ for WGSL
const outDir = path.dirname(file);
const fileName = path.join(outDir, `${path.basename(file)}.g.ts`);
fs.writeFileSync(fileName, tsSource);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"generate-docs": "typedoc && node --no-warnings --loader ts-node/esm build/generate-docs.ts",
"generate-images": "node --no-warnings --loader ts-node/esm build/generate-doc-images.ts",
"build-dist": "npm run build-css && npm run generate-unicode-data && npm run generate-typings && npm run generate-shaders && npm run build-dev && npm run build-csp-dev && npm run build-prod && npm run build-csp",
"build-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev",
"build-dev": "npm run generate-shaders && rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev",
"watch-dev": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:dev --watch",
"build-prod": "rollup --configPlugin @rollup/plugin-typescript -c --environment BUILD:production",
"build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:production",
Expand Down
3 changes: 3 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
minifyInternalExports: production
},
onwarn: (message) => {
if (message.code === 'CIRCULAR_DEPENDENCY' && message.ids && message.ids.some(id => id.includes('@luma.gl'))) {

Check failure on line 32 in rollup.config.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Prefer using an optional chain expression instead, as it's more concise and easier to read
return;
}
console.error(message);
throw message;
},
Expand Down
10 changes: 9 additions & 1 deletion src/geo/projection/covering_tiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,22 @@
* @returns A list of tile coordinates, ordered by ascending distance from camera.
*/
export function coveringTiles(transform: IReadonlyTransform, options: CoveringTilesOptionsInternal): OverscaledTileID[] {
if (!transform.width || !transform.height) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like debug leftovers...?

console.log(`[coveringTiles] width or height is 0: ${transform.width}x${transform.height}`);
return [];
}
const frustum = transform.getCameraFrustum();
if (!frustum) {
console.log(`[coveringTiles] no frustum`);

Check failure on line 190 in src/geo/projection/covering_tiles.ts

View workflow job for this annotation

GitHub Actions / Code Hygiene

Strings must use singlequote
return [];
}
const plane = transform.getClippingPlane();
const cameraCoord = transform.screenPointToMercatorCoordinate(transform.getCameraPoint());
const centerCoord = MercatorCoordinate.fromLngLat(transform.center, transform.elevation);
cameraCoord.z = centerCoord.z + Math.cos(transform.pitchInRadians) * transform.cameraToCenterDistance / transform.worldSize;
const detailsProvider = transform.getCoveringTilesDetailsProvider();
const allowVariableZoom = detailsProvider.allowVariableZoom(transform, options);

const desiredZ = coveringZoomLevel(transform, options);
const minZoom = options.minzoom || 0;
const maxZoom = options.maxzoom !== undefined ? options.maxzoom : transform.maxZoom;
Expand Down
2 changes: 1 addition & 1 deletion src/geo/projection/globe_projection_error_measurement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class ProjectionErrorMeasurement {
program.draw(context, gl.TRIANGLES,
DepthMode.disabled, StencilMode.disabled,
ColorMode.unblended, CullFaceMode.disabled,
projectionErrorMeasurementUniformValues(input, outputExpected), null, null,
projectionErrorMeasurementUniformValues(input, outputExpected) as any, null, null,
'$clipping', this._fullscreenTriangle.vertexBuffer, this._fullscreenTriangle.indexBuffer,
this._fullscreenTriangle.segments);

Expand Down
7 changes: 6 additions & 1 deletion src/geo/projection/mercator_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export class MercatorTransform implements ITransform {
}

getCameraFrustum(): Frustum {
if (!this._invViewProjMatrix) return null;
return Frustum.fromInvProjectionMatrix(this._invViewProjMatrix, this.worldSize);
}
getClippingPlane(): vec4 | null {
Expand Down Expand Up @@ -350,6 +351,10 @@ export class MercatorTransform implements ITransform {
// unproject two points to get a line and then find the point on that
// line with z=0

if (!this._pixelMatrixInverse) {
return new MercatorCoordinate(0, 0, 0);
}

const coord0 = [p.x, p.y, 0, 1] as vec4;
const coord1 = [p.x, p.y, 1, 1] as vec4;

Expand Down Expand Up @@ -598,10 +603,10 @@ export class MercatorTransform implements ITransform {
const offset = this.centerOffset;
const point = projectToWorldCoordinates(this.worldSize, this.center);
const x = point.x, y = point.y;
this._helper._pixelPerMeter = mercatorZfromAltitude(1, this.center.lat) * this.worldSize;

// Calculate the camera to sea-level distance in pixel in respect of terrain
const limitedPitchRadians = degreesToRadians(Math.min(this.pitch, maxMercatorHorizonAngle));
this._helper._pixelPerMeter = mercatorZfromAltitude(1, this.center.lat) * this.worldSize;
const cameraToSeaLevelDistance = Math.max(this._helper.cameraToCenterDistance / 2, this._helper.cameraToCenterDistance + this._helper._elevation * this._helper._pixelPerMeter / Math.cos(limitedPitchRadians));

this._calculateNearFarZIfNeeded(cameraToSeaLevelDistance, limitedPitchRadians, offset);
Expand Down
4 changes: 4 additions & 0 deletions src/geo/projection/vertical_perspective_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ export class VerticalPerspectiveTransform implements ITransform {
* and returns its coordinates on screen in pixels.
*/
private _projectSurfacePointToScreen(pos: vec3): Point {
if (!this.width || !this.height) return new Point(0, 0);
const projected = createVec4f64();
vec4.transformMat4(projected, [...pos, 1] as vec4, this._globeViewProjMatrixNoCorrection);
projected[0] /= projected[3];
Expand Down Expand Up @@ -917,6 +918,9 @@ export class VerticalPerspectiveTransform implements ITransform {
* @param terrain - Optional terrain.
*/
private unprojectScreenPoint(p: Point): LngLat {
if (!this.width || !this.height) {
return new LngLat(0, 0);
}
// Here we compute the intersection of the ray towards the pixel at `p` and the planet sphere.
// As always, we assume that the planet is centered at 0,0,0 and has radius 1.
// Ray origin is `_cameraPosition` and direction is `rayNormalized`.
Expand Down
6 changes: 4 additions & 2 deletions src/geo/transform_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ export class TransformHelper implements ITransformGetters {
this._pixelsToClipSpaceMatrix = m;
const halfFov = this.fovInRadians / 2;
this._cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this._height;
} else {
this._cameraToCenterDistance = 1;
}
this._callbacks.calcMatrices();
}
Expand All @@ -579,7 +581,7 @@ export class TransformHelper implements ITransformGetters {

const {distanceToCenter, clampedElevation} = this._distanceToCenterFromAltElevationPitch(alt, this.elevation, cameraPitch);
const {x, y} = cameraDirectionFromPitchBearing(cameraPitch, cameraBearing);

// The mercator transform scale changes with latitude. At high latitudes, there are more "Merc units" per meter
// than at the equator. We treat the center point as our fundamental quantity. This means we want to convert
// elevation to Mercator Z using the scale factor at the center point (not the camera point). Since the center point is
Expand Down Expand Up @@ -622,7 +624,7 @@ export class TransformHelper implements ITransformGetters {
const originalCenterPixelX = originalCenterMercator.x / mercUnitsPerPixel;
const originalCenterPixelY = originalCenterMercator.y / mercUnitsPerPixel;
const originalCenterPixelZ = originalCenterMercator.z / mercUnitsPerPixel;

const cameraPitch = this.pitch;
const cameraBearing = this.bearing;
const {x, y, z} = cameraDirectionFromPitchBearing(cameraPitch, cameraBearing);
Expand Down
Loading
Loading