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

v3.8.0 #13323

Merged
merged 39 commits into from
Nov 12, 2024
Merged

v3.8.0 #13323

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4b99ee4
Bump the vitest-dependencies group with 3 updates (internal-1947)
dependabot[bot] Oct 29, 2024
541112f
Bump @types/jest from 29.5.13 to 29.5.14 (internal-1950)
dependabot[bot] Oct 29, 2024
b661df9
Bump playwright from 1.48.1 to 1.48.2 (internal-1951)
dependabot[bot] Oct 29, 2024
8f5c9cf
Bump st from 3.0.0 to 3.0.1 (internal-1952)
dependabot[bot] Oct 29, 2024
51ef9ad
Bump tsx from 4.19.1 to 4.19.2 (internal-1953)
dependabot[bot] Oct 29, 2024
ba756d0
Don't send sdk version in the dev build (internal-1924)
stepankuzmin Oct 29, 2024
1588523
Bump @types/node from 22.7.7 to 22.8.2 (internal-1949)
dependabot[bot] Oct 29, 2024
b3d1e75
[GLJS-1061] fix WebGL warnings for fill extrusion texture. (internal-…
alexey-romanov Oct 30, 2024
810625e
[MAPS3D-1509] Add fill-elevation-reference layout property (internal-…
lasselammi Oct 30, 2024
5564357
Improve Worker types (internal-1956)
stepankuzmin Oct 30, 2024
96abc46
Added support of usvg_pb 0.6.0 (internal-1958)
underoot Oct 30, 2024
5f8deae
Improve USVG rasterization (internal-1960)
mourner Oct 31, 2024
dc926f2
GLJS-1080 Fixed unit tests (internal-1961)
underoot Oct 31, 2024
a4b03ec
MAPS3D-1482: Port terrain fix and optimisations from gl-native (inter…
nicozink Nov 1, 2024
35b72a5
experimental paint property symbol-elevation-reference set to be layo…
astojilj Nov 4, 2024
36aee31
[MAPS3D-1479] Allow reordering only when layers minzoom is above terr…
astojilj Nov 4, 2024
ac21677
Debug page for IME (internal-1923)
persidskiy Nov 4, 2024
43acf33
Add support for shadows from elevated structures (internal-1921)
speps Nov 5, 2024
6b6caae
Fix access of retainedQueryData with elevated symbols (internal-1970)
endanke Nov 5, 2024
1d42b3e
Prevent re-evaluation of buckets on small brightness change (internal…
endanke Nov 6, 2024
1cefded
Bump tweakpane from 4.0.4 to 4.0.5 (internal-1967)
dependabot[bot] Nov 6, 2024
b569147
Bump @tweakpane/core from 2.0.4 to 2.0.5 (internal-1968)
dependabot[bot] Nov 6, 2024
a8659a1
Bump @types/node from 22.8.2 to 22.8.7 (internal-1965)
dependabot[bot] Nov 6, 2024
2575f19
Vitest tests improvements (internal-1962)
underoot Nov 6, 2024
3e73217
[MAPS3D-1423] Fix elevated lines rendering issue (internal-1969)
lasselammi Nov 6, 2024
c615f3f
Hide patterned fill extrusions with zero opacity alpha (internal-1974)
endanke Nov 6, 2024
59e8a47
[GLJS-1043] Add `$localized=true` to localized features (internal-1959)
stepankuzmin Nov 8, 2024
7251a0d
Fix usage of config expression in filter properties (internal-1975)
endanke Nov 8, 2024
f36d809
Fix QRF for meshopt landmarks (internal-1980)
jtorresfabra Nov 11, 2024
a442052
Add qrf tests for meshopt models (internal-1981)
jtorresfabra Nov 11, 2024
0ebd875
Always evaluate expressions with line-progress (internal-1982)
endanke Nov 11, 2024
8fd8ffa
Fix naming conflict in line shaders (internal-1984)
speps Nov 11, 2024
3558887
[GLJS-1091] Add feature state support in 3D models (internal-1983)
stepankuzmin Nov 11, 2024
4d9801e
[MAPS3D-1498] Add support for line-pattern emissive strength (interna…
lasselammi Nov 11, 2024
1995e3a
Revert "[MAPS3D-1479] Allow reordering only when layers minzoom is ab…
astojilj Nov 11, 2024
11dbf89
Bump postcss from 8.4.47 to 8.4.49 (internal-1991)
dependabot[bot] Nov 11, 2024
c1e8947
Bump @types/node from 22.8.7 to 22.9.0 (internal-1992)
dependabot[bot] Nov 12, 2024
b86a1ab
[GLJS-1062] Improve `queryRenderedFeatures` support in the Interactio…
stepankuzmin Nov 12, 2024
4b358c3
v3.8.0
mourner Nov 12, 2024
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
37 changes: 26 additions & 11 deletions 3d-style/data/bucket/tiled_3d_model_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {Terrain} from '../../../src/terrain/terrain';
import type FeatureIndex from '../../../src/data/feature_index';
import type {GridIndex} from '../../../src/types/grid-index';
import type {TileFootprint} from '../../../3d-style/util/conflation';
import type {FeatureStates} from '../../../src/source/source_state';

const lookup = new Float32Array(512 * 512);
const passLookup = new Uint8Array(512 * 512);
Expand All @@ -48,7 +49,8 @@ function addAABBsToGridIndex(node: Node, key: number, grid: GridIndex) {
if (node.meshes) {
for (const mesh of node.meshes) {
if (mesh.aabb.min[0] === Infinity) continue;
grid.insert(key, mesh.aabb.min[0], mesh.aabb.min[1], mesh.aabb.max[0], mesh.aabb.max[1]);
const meshAabb = Aabb.applyTransform(mesh.aabb, node.matrix);
grid.insert(key, meshAabb.min[0], meshAabb.min[1], meshAabb.max[0], meshAabb.max[1]);
}
}
if (node.children) {
Expand Down Expand Up @@ -138,6 +140,7 @@ class Tiled3dModelBucket implements Bucket {
brightness: number | null | undefined;
needsUpload: boolean;
constructor(
layers: Array<ModelStyleLayer>,
nodes: Array<Node>,
id: OverscaledTileID,
hasMbxMeshFeatures: boolean,
Expand All @@ -146,6 +149,9 @@ class Tiled3dModelBucket implements Bucket {
featureIndex: FeatureIndex,
) {
this.id = id;
this.layers = layers;
this.layerIds = this.layers.map(layer => layer.fqid);
this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);
this.modelTraits |= ModelTraits.CoordinateSpaceTile;
this.uploaded = false;
this.hasPattern = false;
Expand Down Expand Up @@ -185,12 +191,20 @@ class Tiled3dModelBucket implements Bucket {
}
}

update() {
console.log("Update 3D model bucket");
update(states: FeatureStates) {
const withStateUpdates = Object.keys(states).length !== 0;
if (withStateUpdates && !this.stateDependentLayers.length) return;
const layers = withStateUpdates ? this.stateDependentLayers : this.layers;

for (const layer of layers) {
this.evaluate(layer, states);
}
}

populate() {
console.log("populate 3D model bucket");
}

uploadPending(): boolean {
return !this.uploaded || this.needsUpload;
}
Expand Down Expand Up @@ -260,11 +274,12 @@ class Tiled3dModelBucket implements Bucket {
}
}

evaluate(layer: ModelStyleLayer) {
evaluate(layer: ModelStyleLayer, states?: FeatureStates) {
const nodesInfo = this.getNodesInfo();
for (const nodeInfo of nodesInfo) {
if (!nodeInfo.node.meshes) continue;
const evaluationFeature = nodeInfo.feature;
const state = states && states[evaluationFeature.id];
const hasFeatures = nodeInfo.node.meshes && nodeInfo.node.meshes[0].featureData;
const previousDoorColor = nodeInfo.evaluatedColor[PartIndices.door];
const previousDoorRMEA = nodeInfo.evaluatedRMEA[PartIndices.door];
Expand All @@ -278,18 +293,18 @@ class Tiled3dModelBucket implements Bucket {
evaluationFeature.properties['part'] = part;
}

const color = layer.paint.get('model-color').evaluate(evaluationFeature, {}, canonical).toRenderColor(null);
const color = layer.paint.get('model-color').evaluate(evaluationFeature, state, canonical).toRenderColor(null);

const colorMixIntensity = layer.paint.get('model-color-mix-intensity').evaluate(evaluationFeature, {}, canonical);
const colorMixIntensity = layer.paint.get('model-color-mix-intensity').evaluate(evaluationFeature, state, canonical);
nodeInfo.evaluatedColor[i] = [color.r, color.g, color.b, colorMixIntensity];

nodeInfo.evaluatedRMEA[i][0] = layer.paint.get('model-roughness').evaluate(evaluationFeature, {}, canonical);
nodeInfo.evaluatedRMEA[i][0] = layer.paint.get('model-roughness').evaluate(evaluationFeature, state, canonical);
// For the first version metallic is not styled

nodeInfo.evaluatedRMEA[i][2] = layer.paint.get('model-emissive-strength').evaluate(evaluationFeature, {}, canonical);
nodeInfo.evaluatedRMEA[i][2] = layer.paint.get('model-emissive-strength').evaluate(evaluationFeature, state, canonical);
nodeInfo.evaluatedRMEA[i][3] = color.a;

nodeInfo.emissionHeightBasedParams[i] = layer.paint.get('model-height-based-emissive-strength-multiplier').evaluate(evaluationFeature, {}, canonical);
nodeInfo.emissionHeightBasedParams[i] = layer.paint.get('model-height-based-emissive-strength-multiplier').evaluate(evaluationFeature, state, canonical);

if (!nodeInfo.hasTranslucentParts && color.a < 1.0) {
nodeInfo.hasTranslucentParts = true;
Expand All @@ -301,10 +316,10 @@ class Tiled3dModelBucket implements Bucket {
updateNodeFeatureVertices(nodeInfo, doorLightChanged, this.modelTraits);
} else {

nodeInfo.evaluatedRMEA[0][2] = layer.paint.get('model-emissive-strength').evaluate(evaluationFeature, {}, canonical);
nodeInfo.evaluatedRMEA[0][2] = layer.paint.get('model-emissive-strength').evaluate(evaluationFeature, state, canonical);
}

nodeInfo.evaluatedScale = layer.paint.get('model-scale').evaluate(evaluationFeature, {}, canonical);
nodeInfo.evaluatedScale = layer.paint.get('model-scale').evaluate(evaluationFeature, state, canonical);
if (!this.updatePbrBuffer(nodeInfo.node)) {
this.needsUpload = true;
}
Expand Down
21 changes: 15 additions & 6 deletions 3d-style/render/draw_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ function setupMeshDraw(definesValues: Array<string>, dynamicBuffers: Array<Verte
}

definesValues.push('USE_STANDARD_DERIVATIVES');

const shadowRenderer = painter.shadowRenderer;
if (shadowRenderer) {
definesValues.push('RENDER_SHADOWS', 'DEPTH_TEXTURE');
if (shadowRenderer.useNormalOffset) {
definesValues.push('NORMAL_OFFSET');
}
}
}

function drawMesh(sortedMesh: SortedMesh, painter: Painter, layer: ModelStyleLayer, modelParameters: ModelParameters, stencilMode: StencilMode, colorMode: ColorMode) {
Expand Down Expand Up @@ -195,10 +203,11 @@ function drawMesh(sortedMesh: SortedMesh, painter: Painter, layer: ModelStyleLay
// Extra buffers (colors, normals, texCoords)
const dynamicBuffers = [];

setupMeshDraw((programOptions.defines as Array<string>), dynamicBuffers, mesh, painter, layer.lut);
const shadowRenderer = painter.shadowRenderer;
if (shadowRenderer) { shadowRenderer.useNormalOffset = false; }

setupMeshDraw((programOptions.defines as Array<string>), dynamicBuffers, mesh, painter, layer.lut);

let fogMatrixArray = null;
if (fog) {
const fogMatrix = fogMatrixForModel(sortedMesh.nodeModelMatrix, painter.transform);
Expand Down Expand Up @@ -970,6 +979,11 @@ function drawBatchedModels(painter: Painter, source: SourceCache, layer: ModelSt
defines: []
};
const dynamicBuffers = [];

if (!isShadowPass && shadowRenderer) {
shadowRenderer.useNormalOffset = !!mesh.normalBuffer;
}

setupMeshDraw((programOptions.defines as Array<string>), dynamicBuffers, mesh, painter, layer.lut);
if (!hasMapboxFeatures) {
programOptions.defines.push('DIFFUSE_SHADED');
Expand Down Expand Up @@ -1013,11 +1027,6 @@ function drawBatchedModels(painter: Painter, source: SourceCache, layer: ModelSt
programOptions.defines.push('OCCLUSION_TEXTURE_TRANSFORM');
}

if (!isShadowPass && shadowRenderer) {
// Set normal offset before program creation, as it adds/remove necessary defines under the hood
shadowRenderer.useNormalOffset = !!mesh.normalBuffer;
}

const program = painter.getOrCreateProgram('model', programOptions);

if (!isShadowPass && shadowRenderer) {
Expand Down
4 changes: 4 additions & 0 deletions 3d-style/render/shadow_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ export class ShadowRenderer {
if (cutoffParams.shouldRenderCutoff) {
baseDefines.push('RENDER_CUTOFF');
}
baseDefines.push('RENDER_SHADOWS', 'DEPTH_TEXTURE');
if (this.useNormalOffset) {
baseDefines.push('NORMAL_OFFSET');
}

const shadowColor = calculateGroundShadowFactor(style, directionalLight, ambientLight);

Expand Down
4 changes: 4 additions & 0 deletions 3d-style/source/model_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ModelSource extends Evented<SourceEvents> implements ISource {
attribution: string | undefined;
// eslint-disable-next-line camelcase
mapbox_logo: boolean | undefined;
vectorLayers?: never;
vectorLayerIds?: never;
rasterLayers?: never;
rasterLayerIds?: never;
map: Map;
uri: string;
models: Array<Model>;
Expand Down
30 changes: 18 additions & 12 deletions 3d-style/source/tiled_3d_model_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {Cancelable} from '../../src/types/cancelable';
import type {OverscaledTileID} from '../../src/source/tile_id';
import type {ISource, SourceEvents} from '../../src/source/source';
import type {ModelSourceSpecification} from '../../src/style-spec/types';
import type {RequestedTileParameters, WorkerTileResult} from '../../src/source/worker_source';

class Tiled3DModelSource extends Evented<SourceEvents> implements ISource {
type: 'batched-model';
Expand All @@ -35,6 +36,10 @@ class Tiled3DModelSource extends Evented<SourceEvents> implements ISource {
attribution: string | undefined;
// eslint-disable-next-line camelcase
mapbox_logo: boolean | undefined;
vectorLayers?: never;
vectorLayerIds?: never;
rasterLayers?: never;
rasterLayerIds?: never;
tiles: Array<string>;
dispatcher: Dispatcher;
scheme: string;
Expand Down Expand Up @@ -81,7 +86,7 @@ class Tiled3DModelSource extends Evented<SourceEvents> implements ISource {
this._loaded = false;
this.fire(new Event('dataloading', {dataType: 'source'}));
const language = Array.isArray(this.map._language) ? this.map._language.join() : this.map._language;
const worldview = this.map._worldview;
const worldview = this.map.getWorldview();
this._tileJSONRequest = loadTileJSON(this._options, this.map._requestManager, language, worldview, (err, tileJSON) => {
this._tileJSONRequest = null;
this._loaded = true;
Expand Down Expand Up @@ -121,7 +126,7 @@ class Tiled3DModelSource extends Evented<SourceEvents> implements ISource {
loadTile(tile: Tile, callback: Callback<undefined>) {
const url = this.map._requestManager.normalizeTileURL(tile.tileID.canonical.url((this.tiles as any), this.scheme));
const request = this.map._requestManager.transformRequest(url, ResourceType.Tile);
const params = {
const params: RequestedTileParameters = {
request,
data: undefined,
uid: tile.uid,
Expand All @@ -134,8 +139,15 @@ class Tiled3DModelSource extends Evented<SourceEvents> implements ISource {
scope: this.scope,
showCollisionBoxes: this.map.showCollisionBoxes,
isSymbolTile: tile.isSymbolTile,
brightness: this.map.style ? (this.map.style.getBrightness() || 0.0) : 0.0
brightness: this.map.style ? (this.map.style.getBrightness() || 0.0) : 0.0,
// Not supported in 3D models
lut: null,
maxZoom: null,
promoteId: null,
pixelRatio: null,
scaleFactor: null,
};

if (!tile.actor || tile.state === 'expired') {
tile.actor = this.dispatcher.getActor();
tile.request = tile.actor.send('loadTile', params, done.bind(this), undefined, true);
Expand All @@ -155,22 +167,16 @@ class Tiled3DModelSource extends Evented<SourceEvents> implements ISource {
tile.request = tile.actor.send('reloadTile', params, done.bind(this));
}

function done(err: Error | null | undefined, data: any) {
function done(err?: Error | null, data?: WorkerTileResult | null) {
if (tile.aborted) return callback(null);

// @ts-expect-error - TS2339 - Property 'status' does not exist on type 'Error'.
if (err && err.status !== 404) {
return callback(err);
}

if (data) {
if (data.resourceTiming) tile.resourceTiming = data.resourceTiming;
if (this.map._refreshExpiredTiles) tile.setExpiryData(data);
tile.buckets = {...tile.buckets, ...data.buckets};
if (data.featureIndex) {
tile.latestFeatureIndex = data.featureIndex;
}
}
if (this.map._refreshExpiredTiles && data) tile.setExpiryData(data);
tile.loadModelData(data, this.map.painter);

tile.state = 'loaded';
callback(null);
Expand Down
30 changes: 18 additions & 12 deletions 3d-style/source/tiled_3d_model_worker_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import type {
TileParameters,
WorkerTileResult
} from '../../src/source/worker_source';
import type {Bucket} from '../../src/data/bucket';
import type {LoadVectorData} from '../../src/source/load_vector_tile';
import type Projection from '../../src/geo/projection/projection';
import type ModelStyleLayer from '../style/style_layer/model_style_layer';

class Tiled3dWorkerTile {
tileID: OverscaledTileID;
Expand Down Expand Up @@ -59,9 +59,7 @@ class Tiled3dWorkerTile {
): Promise<void> {
this.status = 'parsing';
const tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y);
const buckets: {
[_: string]: Bucket;
} = {};
const buckets: Tiled3dModelBucket[] = [];
const layerFamilies = layerIndex.familiesBySource[params.source];
const featureIndex = new FeatureIndex(tileID, params.promoteId);
featureIndex.bucketLayerIDs = [];
Expand All @@ -78,31 +76,38 @@ class Tiled3dWorkerTile {
const parameters = new EvaluationParameters(this.zoom, {brightness: this.brightness});
for (const sourceLayerId in layerFamilies) {
for (const family of layerFamilies[sourceLayerId]) {
const layer = family[0];
const layer = family[0] as ModelStyleLayer;
featureIndex.bucketLayerIDs.push(family.map((l) => makeFQID(l.id, l.scope)));
layer.recalculate(parameters, []);
const bucket = new Tiled3dModelBucket(nodes, tileID, hasMapboxMeshFeatures, hasMeshoptCompression, this.brightness, featureIndex);
const bucket = new Tiled3dModelBucket(family as Array<ModelStyleLayer>, nodes, tileID, hasMapboxMeshFeatures, hasMeshoptCompression, this.brightness, featureIndex);
// Upload to GPU without waiting for evaluation if we are in diffuse path
if (!hasMapboxMeshFeatures) bucket.needsUpload = true;
buckets[layer.fqid] = bucket;
buckets.push(bucket);
// do the first evaluation in the worker to avoid stuttering
// @ts-expect-error - TS2345 - Argument of type 'TypedStyleLayer' is not assignable to parameter of type 'ModelStyleLayer'.
bucket.evaluate(layer);
}
}

this.status = 'done';
// @ts-expect-error - TS2740 - Type '{ [_: string]: Bucket; }' is missing the following properties from type 'Bucket[]': length, pop, push, concat, and 35 more.
callback(null, {buckets, featureIndex});

callback(null, {
buckets,
featureIndex,
collisionBoxArray: null,
glyphAtlasImage: null,
lineAtlas: null,
imageAtlas: null,
brightness: null,
});
})
.catch((err) => callback(new Error(err.message)));
}
}

// @ts-expect-error - TS2420 - Class 'Tiled3dModelWorkerSource' incorrectly implements interface 'WorkerSource'.
class Tiled3dModelWorkerSource implements WorkerSource {
actor: Actor;
layerIndex: StyleLayerIndex;

availableImages: Array<string>;
loading: {
[_: number]: Tiled3dWorkerTile;
};
Expand All @@ -113,6 +118,7 @@ class Tiled3dModelWorkerSource implements WorkerSource {
constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array<string>, isSpriteLoaded: boolean, loadVectorData?: LoadVectorData, brightness?: number) {
this.actor = actor;
this.layerIndex = layerIndex;
this.availableImages = availableImages;
this.brightness = brightness;
this.loading = {};
this.loaded = {};
Expand Down
Loading
Loading