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

Sync v3.0.0 with the release branch #12989

Merged
merged 44 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
abbc512
Fix small spec inconsistencies with model types (#12968)
tristen Nov 13, 2023
d699447
Fix a typo in videoSource documentation (#12957)
stampyzfanz Nov 13, 2023
e511f22
remove stats collection CI job (#12969)
mourner Nov 13, 2023
c45f38f
Downgrade rollup to fix CodeBuild (#12962) (#12970)
mourner Nov 13, 2023
d92ba58
[GLJS-559][GLJS-560] Group Worker sources by scope (internal-922)
stepankuzmin Nov 8, 2023
1a56264
[MAPS3D-1124] fix inconsistency in 3d light properties specs and vers…
akoylasar Nov 8, 2023
9b18213
Add Standard Style debug page (internal-909)
stepankuzmin Nov 9, 2023
d27ecfd
[MAPS3D-1159] avoid elevating symbols on fill extrusions they have 0 …
akoylasar Nov 9, 2023
99ad400
[GLJS-566] Use proper fragment when updating workers (internal-925)
stepankuzmin Nov 9, 2023
2946825
Validate import id (internal-927)
stepankuzmin Nov 10, 2023
32f8c25
Validate unknown 3D Lights properties (internal-928)
stepankuzmin Nov 10, 2023
5bc8a20
[MAPS3D-1137] Do not reparse tiles and recreate buckets when terrain …
astojilj Nov 13, 2023
c289fa1
add sdk version to Mapbox style URLs (internal-929)
mourner Nov 13, 2023
d1abb3a
Use Mapbox-hosted Draco decoder (internal-934)
stepankuzmin Nov 13, 2023
37624d4
v3.0.0-rc.2
mourner Nov 13, 2023
a921d73
Use dynamic style by default in Standard Style debug page (internal-930)
stepankuzmin Nov 13, 2023
b482654
[MAPS3D-1124] Consistent docs (internal-935)
akoylasar Nov 13, 2023
31aa370
Apply operations in render-test.html (internal-945)
stepankuzmin Nov 15, 2023
456467e
[GLJS-559] Clear source caches in imports on projection change (inter…
stepankuzmin Nov 15, 2023
c0bebe4
[GLJS-578] Don't reset shared style changes when creating fragments (…
stepankuzmin Nov 15, 2023
38432e7
[MAPS3D-1044] Fix breakage of ground effect that occurs when edges cr…
akoylasar Nov 15, 2023
a2ef613
[GLJS-579] Fix adding first import (internal-947)
stepankuzmin Nov 15, 2023
ed3be18
[GLJS-580] Ignore layer slot in style diffs (internal-949)
stepankuzmin Nov 15, 2023
1380a73
v3.0.0-rc.3 (internal-951)
stepankuzmin Nov 15, 2023
04a8ce3
[GLJS-584] Fix missing condition for circle layer depth occlusion (in…
akoylasar Nov 16, 2023
2a0e16d
[GLJS-493] Diff configs on setStyle (internal-952)
stepankuzmin Nov 20, 2023
c51898b
[GLJS-587] Fix Style.mergeAll when removing all imports (internal-954)
stepankuzmin Nov 20, 2023
20182c9
v3.0.0-rc.4 (internal-955)
mourner Nov 20, 2023
60512ff
Update terrain tile fixtures (internal-961)
stepankuzmin Nov 21, 2023
75e4c0b
[GLJS-589] Diff slots on setStyle (internal-959)
stepankuzmin Nov 21, 2023
de3bc82
Rewrite 3D Style async/await functions to Promises (internal-960)
stepankuzmin Nov 21, 2023
5f7d20a
v3.0.0-rc.5 (internal-962)
stepankuzmin Nov 21, 2023
6b68894
Bump testem from 3.10.1 to 3.11.0 (internal-958)
dependabot[bot] Nov 22, 2023
f64de0f
Update terrain tiles used in gl-native tests (internal-964)
woodroof Nov 22, 2023
6cde33f
Remove unneeded terrain tiles (internal-965)
woodroof Nov 22, 2023
52e6384
Ignore QRF in Model Layer (internal-967)
stepankuzmin Nov 22, 2023
23bd82f
Update v8.json (internal-968)
astojilj Nov 22, 2023
ccd60c9
Update Documentation (internal-969)
stepankuzmin Nov 22, 2023
709e33f
Check 3D light type when merging imports (internal-971)
stepankuzmin Nov 23, 2023
f174204
[GLJS-593] Fix source name collision between imports in symbol layers…
mourner Nov 24, 2023
a2b3344
remove duplicate frag precision qualifiers (internal-973)
mourner Nov 24, 2023
7102f06
v3.0.0-rc.6 (internal-974)
stepankuzmin Nov 24, 2023
3030405
v3.0.0
stepankuzmin Nov 28, 2023
118e87d
Update MIGRATION_GUIDE_v3.md
stepankuzmin Nov 29, 2023
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
23 changes: 0 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ workflows:
filters:
tags:
only: /.*/
- collect-stats:
requires:
- build
- install-mbx-ci
filters:
tags:
ignore: /.*/
branches:
only: main
- deploy-release:
requires:
- install-mbx-ci
Expand Down Expand Up @@ -336,20 +327,6 @@ jobs:
yarn run codegen
git add -A && git diff --staged --exit-code | tee check.patch

collect-stats:
<<: *linux-defaults
steps:
- attach_workspace:
at: ~/
- browser-tools/install-chrome
- run:
name: Collect performance stats
command: node bench/gl-stats.js
- aws-cli/install
- run:
name: Upload performance stats
command: aws s3 cp data.json.gz s3://mapbox-loading-dock/raw/gl_js.perf_metrics_staging/ci/`git show -s --date=short --format=%cd-%h HEAD`.json.gz

test-browser:
<<: *linux-defaults
steps:
Expand Down
35 changes: 32 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"no-duplicate-imports": "off",
"import/no-duplicates": "error",

// prevent issues with esbuild/vite https://github.com/mapbox/mapbox-gl-js/issues/12656
"no-restricted-syntax": ["error", "ClassProperty[value]"],

// ensure compatibility with Node's native ESM
"import/extensions": ["error", {
"js": "always",
Expand Down Expand Up @@ -176,6 +173,38 @@
"jsdoc/require-property-type": "error",
"jsdoc/require-returns-type": "error",
}
},
{
"files": [
"src/**/*",
"3d-style/**/*"
],
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "AwaitExpression",
"message": "Async/await syntax is not allowed."
},
{
"selector": "FunctionDeclaration[async=true]",
"message": "Async function declarations are not allowed."
},
{
"selector": "FunctionExpression[async=true]",
"message": "Async function expressions are not allowed."
},
{
"selector": "ArrowFunctionExpression[async=true]",
"message": "Async arrow functions are not allowed."
},
// prevent issues with esbuild/vite https://github.com/mapbox/mapbox-gl-js/issues/12656
{
"selector": "ClassProperty[value]",
"message": "ClassProperty values are not allowed."
}
]
}
}
],
"globals": {
Expand Down
49 changes: 27 additions & 22 deletions 3d-style/render/model_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@
this.numModelsLoading = {};
}

async loadModel(id: string, url: string): Promise<?Model> {
const gltf = await loadGLTF(this.requestManager.transformRequest(url, ResourceType.Model).url).catch((err) => {
this.fire(new ErrorEvent(new Error(`Could not load model ${id} from ${url}: ${err.message}`)));
});

if (!gltf) return;

const nodes = convertModel(gltf);
const model = new Model(id, undefined, undefined, nodes);
model.computeBoundsAndApplyParent();
return model;
loadModel(id: string, url: string): Promise<?Model> {
return loadGLTF(this.requestManager.transformRequest(url, ResourceType.Model).url)
.then(gltf => {
if (!gltf) return;

const nodes = convertModel(gltf);
const model = new Model(id, undefined, undefined, nodes);
model.computeBoundsAndApplyParent();
return model;
})
.catch((err) => {
this.fire(new ErrorEvent(new Error(`Could not load model ${id} from ${url}: ${err.message}`)));
});
}

async load(modelUris: {[string]: string}, scope: string) {
load(modelUris: {[string]: string}, scope: string) {
if (!this.models[scope]) this.models[scope] = {};

const modelIds = Object.keys(modelUris);
Expand All @@ -50,15 +52,18 @@
modelLoads.push(this.loadModel(modelId, modelUris[modelId]));
}

const results = await Promise.allSettled(modelLoads);

for (let i = 0; i < results.length; i++) {
const {status, value} = results[i];
if (status === 'fulfilled' && value) this.models[scope][modelIds[i]] = value;
}
this.numModelsLoading[scope] -= modelIds.length;

this.fire(new Event('data', {dataType: 'style'}));
Promise.allSettled(modelLoads)
.then(results => {
for (let i = 0; i < results.length; i++) {
const {status, value} = results[i];
if (status === 'fulfilled' && value) this.models[scope][modelIds[i]] = value;

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.
}
this.numModelsLoading[scope] -= modelIds.length;
this.fire(new Event('data', {dataType: 'style'}));
})
.catch((err) => {
this.fire(new ErrorEvent(new Error(`Could not load models: ${err.message}`)));
});
}

isLoaded(): boolean {
Expand All @@ -77,7 +82,7 @@
return this.models[scope][id];
}

async addModel(id: string, url: string, scope: string) {
addModel(id: string, url: string, scope: string) {
if (!this.models[scope]) this.models[scope] = {};
// Destroy model if it exists
if (this.hasModel(id, scope)) {
Expand Down
31 changes: 20 additions & 11 deletions 3d-style/source/model_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,32 @@ class ModelSource extends Evented implements Source {
this._options = options;
}

async load() {
/* $FlowIgnore[prop-missing] we don't need the full spec of model_source as it's only used for testing*/
load(): Promise<void> {
const modelPromises = [];

/* $FlowIgnore[prop-missing] we don't need the full spec of model_source as it's only used for testing */
for (const modelId in this._options.models) {
const modelSpec = this._options.models[modelId];
const gltf = await loadGLTF(this.map._requestManager.transformRequest(modelSpec.uri, ResourceType.Model).url).catch((err) => {

const modelPromise = loadGLTF(this.map._requestManager.transformRequest(modelSpec.uri, ResourceType.Model).url).then(gltf => {
if (!gltf) return;
const nodes = convertModel(gltf);
const model = new Model(modelId, modelSpec.position, modelSpec.orientation, nodes);
model.computeBoundsAndApplyParent();
this.models.push(model);
}).catch((err) => {
this.fire(new ErrorEvent(new Error(`Could not load model ${modelId} from ${modelSpec.uri}: ${err.message}`)));
});

if (!gltf) continue;

const nodes = convertModel(gltf);
const model = new Model(modelId, modelSpec.position, modelSpec.orientation, nodes);
model.computeBoundsAndApplyParent();
this.models.push(model);
modelPromises.push(modelPromise);
}
this._loaded = true;
this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));

return Promise.allSettled(modelPromises).then(() => {
this._loaded = true;
this.fire(new Event('data', {dataType: 'source', sourceDataType: 'metadata'}));
}).catch((err) => {
this.fire(new ErrorEvent(new Error(`Could not load models: ${err.message}`)));
});
}

// $FlowFixMe[method-unbinding]
Expand Down
53 changes: 27 additions & 26 deletions 3d-style/source/tiled_3d_model_worker_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Tiled3dWorkerTile {
tileSize: number;
source: string;
overscaling: number;
enableTerrain: boolean;
projection: Projection;
status: 'parsing' | 'done';
reloadCallback: ?WorkerTileCallback;
Expand All @@ -46,40 +45,43 @@ class Tiled3dWorkerTile {
this.tileSize = params.tileSize;
this.source = params.source;
this.overscaling = this.tileID.overscaleFactor();
this.enableTerrain = !!params.enableTerrain;
this.projection = params.projection;
this.brightness = brightness;
}

async parse(data: ArrayBuffer, layerIndex: StyleLayerIndex, params: WorkerTileParameters, callback: WorkerTileCallback): Promise<void> {
parse(data: ArrayBuffer, layerIndex: StyleLayerIndex, params: WorkerTileParameters, callback: WorkerTileCallback): 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 layerFamilies = layerIndex.familiesBySource[params.source];
const featureIndex = new FeatureIndex(tileID, params.promoteId);
featureIndex.bucketLayerIDs = [];
const gltf = await load3DTile(data).catch((err) => callback(new Error(err.message)));
if (!gltf) return callback(new Error('Could not parse tile'));
const nodes = process3DTile(gltf, 1.0 / tileToMeter(params.tileID.canonical));
const hasMapboxMeshFeatures = gltf.json.extensionsUsed && gltf.json.extensionsUsed.includes('MAPBOX_mesh_features');
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 extensions = gltf.json.extensionsUsed;
layer.recalculate(parameters, []);
const bucket = new Tiled3dModelBucket(nodes, tileID, extensions && extensions.includes("MAPBOX_mesh_features"), this.brightness);
// Upload to GPU without waiting for evaluation if we are in diffuse path
if (!hasMapboxMeshFeatures) bucket.needsUpload = true;
buckets[layer.fqid] = bucket;
// do the first evaluation in the worker to avoid stuttering
// $FlowIgnore[incompatible-call] layer here is always a ModelStyleLayer
bucket.evaluate(layer);
}
}
this.status = 'done';
// $FlowFixMe flow is complaining about missing properties and buckets not being of type Array
callback(null, {buckets, featureIndex});

return load3DTile(data)
.then(gltf => {
if (!gltf) return callback(new Error('Could not parse tile'));
const nodes = process3DTile(gltf, 1.0 / tileToMeter(params.tileID.canonical));
const hasMapboxMeshFeatures = gltf.json.extensionsUsed && gltf.json.extensionsUsed.includes('MAPBOX_mesh_features');
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 extensions = gltf.json.extensionsUsed;
layer.recalculate(parameters, []);
const bucket = new Tiled3dModelBucket(nodes, tileID, extensions && extensions.includes("MAPBOX_mesh_features"), this.brightness);
// Upload to GPU without waiting for evaluation if we are in diffuse path
if (!hasMapboxMeshFeatures) bucket.needsUpload = true;
buckets[layer.fqid] = bucket;
// do the first evaluation in the worker to avoid stuttering
// $FlowIgnore[incompatible-call] layer here is always a ModelStyleLayer
bucket.evaluate(layer);
}
}
this.status = 'done';
// $FlowFixMe flow is complaining about missing properties and buckets not being of type Array
callback(null, {buckets, featureIndex});
})
.catch((err) => callback(new Error(err.message)));
}
}

Expand Down Expand Up @@ -141,7 +143,6 @@ class Tiled3dModelWorkerSource implements WorkerSource {
const uid = params.uid;
if (loaded && loaded[uid]) {
const workerTile = loaded[uid];
workerTile.enableTerrain = !!params.enableTerrain;
workerTile.projection = params.projection;
workerTile.brightness = params.brightness;

Expand Down
5 changes: 5 additions & 0 deletions 3d-style/style/style_layer/model_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class ModelStyleLayer extends StyleLayer {
return 0;
}

// $FlowFixMe[method-unbinding]
queryIntersectsFeature(): boolean {
return false;
}

_handleOverridablePaintPropertyUpdate<T, R>(name: string, oldValue: PropertyValue<T, R>, newValue: PropertyValue<T, R>): boolean {
if (!this.layout || oldValue.isDataDriven() || newValue.isDataDriven()) {
return false;
Expand Down
Loading