Skip to content

Commit

Permalink
Merge branch 'main' into sync-to-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jobblefrobble authored Nov 26, 2024
2 parents 8384cc4 + e9a88f0 commit 0880e58
Show file tree
Hide file tree
Showing 1,084 changed files with 46,933 additions and 8,533 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ workflows:
filters:
tags:
only: /.*/
- test-usvg:
requires:
- setup-playwright
filters:
tags:
only: /.*/
- test-csp:
requires:
- setup-playwright
Expand Down Expand Up @@ -365,6 +371,22 @@ jobs:
- store_test_results:
path: test/unit/test-results.xml

test-usvg:
<<: *linux-defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Run usvg tests
command: |
tar xvzf test/usvg/test-suite.tar.gz -C test/usvg/
npm run test-usvg
no_output_timeout: 5m
- store_artifacts:
path: test/usvg/vitest
- store_test_results:
path: test/usvg/test-results.xml

test-query:
<<: *linux-defaults
steps:
Expand Down
32 changes: 24 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"plugin:@typescript-eslint/recommended-type-checked"
],
"parserOptions": {
"EXPERIMENTAL_useProjectService": true
"projectService": {
"defaultProject": "./tsconfig.json",
"allowDefaultProject": ["*.js", "debug/*", "build/*"]
}
},
"plugins": [
"jsdoc",
Expand All @@ -33,26 +36,32 @@
},
"rules": {
// temporarily disabled for easier migration to TypeScript
"no-loss-of-precision": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-loss-of-precision": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/only-throw-error": "off",

// TypeScript specific rules
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/consistent-type-exports": "off",
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/restrict-template-expressions": ["off", { "allowNever": true }],
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unused-vars": ["off", { "argsIgnorePattern": "^_" }],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", {
"args": "none",
"caughtErrors": "none",
"ignoreRestSiblings": true
}],

// Disable those rules since TypeScript provides the same checks as part of standard type checking
// See https://typescript-eslint.io/troubleshooting/performance-troubleshooting/#eslint-plugin-import
Expand All @@ -61,11 +70,17 @@
"import/default": "off",
"import/no-named-as-default-member": "off",
"import/no-unresolved": "off",
"import/no-named-as-default": "off",

// Import plugin rules
"no-duplicate-imports": "off",
"import/no-duplicates": "error",

"import/order": ["error", {
"groups": [["builtin", "external", "internal", "unknown", "parent", "sibling", "index", "object"], "type"],
"newlines-between": "always"
}],

// Restrict imports outside of the style-spec
"import/no-restricted-paths": ["error", {
"zones": [{
Expand Down Expand Up @@ -124,7 +139,7 @@
}],
"no-multiple-empty-lines": ["error", {
"max": 1
}],
}]
},
"overrides": [
{
Expand Down Expand Up @@ -256,6 +271,7 @@
"es6": true
},
"ignorePatterns": [
"dist/**/*"
"dist/**/*",
"src/style-spec/bin/*"
]
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ vitest.config.js.*

tsconfig.tsbuildinfo
bundle-analysis.html

# tmp usvg ignores
test/usvg/vitest/
test/usvg/test-suite/
test/usvg/test-results.xml
src/data/usvg/usvg_pb_renderer.js
38 changes: 17 additions & 21 deletions 3d-style/data/bucket/model_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import {register} from '../../../src/util/web_worker_transfer';
import loadGeometry from '../../../src/data/load_geometry';
import toEvaluationFeature from '../../../src/data/evaluation_feature';
import EvaluationParameters from '../../../src/style/evaluation_parameters';
import Point from '@mapbox/point-geometry';
import {vec3} from 'gl-matrix';
import {InstanceVertexArray} from '../../../src/data/array_types';
import assert from 'assert';
import {warnOnce} from '../../../src/util/util';
import {rotationScaleYZFlipMatrix} from '../../util/model_util';
import {tileToMeter} from '../../../src/geo/mercator_coordinate';
import {instanceAttributes} from '../model_attributes';
import {ReplacementSource, regionsEquals, transformPointToTile, pointInFootprint} from '../../../3d-style/source/replacement_source';
import {regionsEquals, transformPointToTile, pointInFootprint, skipClipping} from '../../../3d-style/source/replacement_source';
import {LayerTypeMask} from '../../../3d-style/util/conflation';
import {isValidUrl} from '../../../src/style-spec/validate/validate_model';

import type ModelStyleLayer from '../../style/style_layer/model_style_layer';
import {isValidUrl} from '../../../src/style-spec/validate/validate_model';
import type {ReplacementSource} from '../../../3d-style/source/replacement_source';
import type Point from '@mapbox/point-geometry';
import type {EvaluationFeature} from '../../../src/data/evaluation_feature';
import type {mat4} from 'gl-matrix';
import type {CanonicalTileID, OverscaledTileID, UnwrappedTileID} from '../../../src/source/tile_id';
Expand All @@ -26,7 +27,6 @@ import type {
IndexedFeature,
PopulateParameters
} from '../../../src/data/bucket';

import type Context from '../../../src/gl/context';
import type VertexBuffer from '../../../src/gl/vertex_buffer';
import type {FeatureState} from '../../../src/style-spec/expression/index';
Expand All @@ -39,12 +39,13 @@ import type {TileFootprint} from '../../../3d-style/util/conflation';

class ModelFeature {
feature: EvaluationFeature;
featureStates: FeatureState;
instancedDataOffset: number;
instancedDataCount: number;

rotation: Array<number>;
scale: Array<number>;
translation: Array<number>;
rotation: vec3;
scale: vec3;
translation: vec3;

constructor(feature: EvaluationFeature, offset: number) {
this.feature = feature;
Expand Down Expand Up @@ -83,9 +84,7 @@ class ModelBucket implements Bucket {
stateDependentLayerIds: Array<string>;
hasPattern: boolean;

instancesPerModel: {
string: PerModelAttributes;
};
instancesPerModel: Record<string, PerModelAttributes>;

uploaded: boolean;

Expand Down Expand Up @@ -128,7 +127,6 @@ class ModelBucket implements Bucket {

this.stateDependentLayerIds = this.layers.filter((l) => l.isStateDependent()).map((l) => l.id);
this.hasPattern = false;
// @ts-expect-error - TS2741 - Property 'string' is missing in type '{}' but required in type '{ string: PerModelAttributes; }'.
this.instancesPerModel = {};
this.validForExaggeration = 0;
this.maxVerticalOffset = 0;
Expand Down Expand Up @@ -169,10 +167,8 @@ class ModelBucket implements Bucket {
id: featureId,
sourceLayerIndex,
index,
// @ts-expect-error - TS2345 - Argument of type 'VectorTileFeature' is not assignable to parameter of type 'FeatureWithGeometry'.
geometry: needGeometry ? evaluationFeature.geometry : loadGeometry(feature, canonical, tileTransform),
properties: feature.properties,
// @ts-expect-error - TS2322 - Type '0 | 2 | 1 | 3' is not assignable to type '2 | 1 | 3'.
type: feature.type,
patterns: {}
};
Expand Down Expand Up @@ -237,7 +233,7 @@ class ModelBucket implements Bucket {
return reuploadNeeded;
}

updateReplacement(coord: OverscaledTileID, source: ReplacementSource, layerIndex: number): boolean {
updateReplacement(coord: OverscaledTileID, source: ReplacementSource, layerIndex: number, scope: string): boolean {
// Replacement has to be re-checked if the source has been updated since last time
if (source.updateTime === this.replacementUpdateTime) {
return false;
Expand All @@ -249,10 +245,10 @@ class ModelBucket implements Bucket {
if (regionsEquals(this.activeReplacements, newReplacements)) {
return false;
}

this.activeReplacements = newReplacements;

let reuploadNeeded = false;

for (const modelId in this.instancesPerModel) {
const perModelVertexArray: PerModelAttributes = this.instancesPerModel[modelId];
const va = perModelVertexArray.instancedDataArray;
Expand All @@ -265,26 +261,27 @@ class ModelBucket implements Bucket {
const i16 = (i + offset) * 16;

let x_ = va.float32[i16 + 0];
x_ = x_ > EXTENT ? x_ - EXTENT : x_;
const wasHidden = x_ > EXTENT;
x_ = wasHidden ? x_ - EXTENT : x_;
const x = Math.floor(x_);
const y = va.float32[i16 + 1];

let hidden = false;
for (const region of this.activeReplacements) {
if (region.order < layerIndex || region.order === Infinity || !(region.clipMask & LayerTypeMask.Model)) continue;
if (skipClipping(region, layerIndex, LayerTypeMask.Model, scope)) continue;

if (region.min.x > x || x > region.max.x || region.min.y > y || y > region.max.y) {
continue;
}

const p = transformPointToTile(x, y, coord.canonical, region.footprintTileId.canonical);
hidden = pointInFootprint(p, region);
hidden = pointInFootprint(p, region.footprint);

if (hidden) break;
}

va.float32[i16] = hidden ? x_ + EXTENT : x_;
reuploadNeeded = reuploadNeeded || hidden;
reuploadNeeded = reuploadNeeded || (hidden !== wasHidden);
}
}
}
Expand Down Expand Up @@ -420,8 +417,7 @@ class ModelBucket implements Bucket {
const color = layer.paint.get('model-color').evaluate(evaluationFeature, featureState, canonical);

color.a = layer.paint.get('model-color-mix-intensity').evaluate(evaluationFeature, featureState, canonical);
// @ts-expect-error - TS2322 - Type '[]' is not assignable to type 'mat4'.
const rotationScaleYZFlip: mat4 = [];
const rotationScaleYZFlip = [] as unknown as mat4;
if (this.maxVerticalOffset < translation[2]) this.maxVerticalOffset = translation[2];
this.maxScale = Math.max(Math.max(this.maxScale, scale[0]), Math.max(scale[1], scale[2]));

Expand Down
Loading

0 comments on commit 0880e58

Please sign in to comment.