Skip to content

Commit

Permalink
refactor(Style): supp collection.style and delete notion of style.parent
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Dec 13, 2023
1 parent 5f22009 commit 40f83b3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 35 deletions.
10 changes: 1 addition & 9 deletions src/Core/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export class FeatureCollection extends THREE.Object3D {
/**
* Updates the global transform of the object and its descendants.
*
* @param {booolean} force The force
* @param {boolean} force The force
*/
updateMatrixWorld(force) {
super.updateMatrixWorld(force);
Expand Down Expand Up @@ -498,12 +498,4 @@ export class FeatureCollection extends THREE.Object3D {
this.features.push(ref);
return ref;
}

setParentStyle(style) {
if (style) {
this.features.forEach((f) => {
f.style.parent = style;
});
}
}
}
21 changes: 2 additions & 19 deletions src/Core/Style.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,7 @@ function defineStyleProperty(style, category, name, value, defaultValue) {
name,
{
enumerable: true,
get: () => {
if (property === undefined) {
return style.parent[category][name] || defaultValue;
} else {
return property;
}
},
get: () => property ?? defaultValue,
set: (v) => {
property = v;
},
Expand Down Expand Up @@ -548,24 +542,13 @@ class Style {
* @param {StyleOptions} [params={}] An object that contain any properties
* (order, zoom, fill, stroke, point, text or/and icon)
* and sub properties of a Style (@see {@link StyleOptions}).
* @param {Style} [parent] The parent style, that is looked onto if a value
* is missing.
* @constructor
*/
constructor(params = {}, parent) {
constructor(params = {}) {
this.isStyle = true;

this.order = params.order || 0;

this.parent = parent || {
zoom: {},
fill: {},
stroke: {},
point: {},
text: {},
icon: {},
};

params.zoom = params.zoom || {};
params.fill = params.fill || {};
params.stroke = params.stroke || {};
Expand Down
4 changes: 0 additions & 4 deletions src/Source/FileSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ class FileSource extends Source {
this.extent.applyMatrix4(data.matrixWorld);
}
}

if (data.isFeatureCollection) {
data.setParentStyle(options.out.style);
}
});
}

Expand Down
3 changes: 0 additions & 3 deletions src/Source/VectorTilesSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ class VectorTilesSource extends TMSSource {
console.warn('With VectorTilesSource and FeatureGeometryLayer, the accurate option is always false');
options.out.accurate = false;
}
const keys = Object.keys(this.styles);

keys.forEach((k) => { this.styles[k].parent = options.out.style; });
}
}
}
Expand Down

0 comments on commit 40f83b3

Please sign in to comment.