Skip to content

Commit

Permalink
fix(C3DTilesLayer): updateStyle works with new style API
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinMachado authored and Desplandis committed Oct 11, 2024
1 parent cb96727 commit a4f0d22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
29 changes: 15 additions & 14 deletions src/Layer/C3DTilesLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class C3DTilesLayer extends GeometryLayer {
}

/** @type {Style} */
this._style = config.style || null;
this.style = config.style || null;

/** @type {Map<string, THREE.MeshStandardMaterial>} */
this.#fillColorMaterialsBuffer = new Map();
Expand Down Expand Up @@ -386,21 +386,16 @@ class C3DTilesLayer extends GeometryLayer {
if (c3DTileFeature.object3d != object3d) {
continue;// this feature do not belong to object3d
}

this._style.context.setGeometry({
properties: c3DTileFeature,
});

/** @type {THREE.Color} */
let color = null;
if (typeof this._style.fill.color === 'function') {
color = new THREE.Color(this._style.fill.color(c3DTileFeature));
} else {
color = new THREE.Color(this._style.fill.color);
}
const color = new THREE.Color(this._style.fill.color);

/** @type {number} */
let opacity = null;
if (typeof this._style.fill.opacity === 'function') {
opacity = this._style.fill.opacity(c3DTileFeature);
} else {
opacity = this._style.fill.opacity;
}
const opacity = this._style.fill.opacity;

const materialId = color.getHexString() + opacity;

Expand Down Expand Up @@ -464,7 +459,13 @@ class C3DTilesLayer extends GeometryLayer {
}

set style(value) {
this._style = value;
if (value instanceof Style) {
this._style = value;
} else if (!value) {
this._style = null;
} else {
this._style = new Style(value);
}
this.updateStyle();
}

Expand Down
5 changes: 2 additions & 3 deletions src/Utils/gui/C3DTilesStyle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Style from 'Core/Style';
import { C3DTILES_LAYER_EVENTS } from 'Layer/C3DTilesLayer';
import Widget from './Widget';

Expand Down Expand Up @@ -221,12 +220,12 @@ class C3DTilesStyle extends Widget {
}

// set style
c3DTilesLayer.style = new Style({
c3DTilesLayer.style = {
fill: {
color: fillColorFunction,
opacity: fillOpacityFunction,
},
});
};
});
});

Expand Down

0 comments on commit a4f0d22

Please sign in to comment.