From 00631f498c302078f4fc789fe872b30702695dd2 Mon Sep 17 00:00:00 2001 From: Lamache Date: Mon, 7 Oct 2024 11:40:42 +0200 Subject: [PATCH] fix(C3DTilesLayer): updateStyle works with new style API --- src/Layer/C3DTilesLayer.js | 29 +++++++++++++++-------------- src/Utils/gui/C3DTilesStyle.js | 5 ++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Layer/C3DTilesLayer.js b/src/Layer/C3DTilesLayer.js index d8fd1d43f8..83ab6d2f33 100644 --- a/src/Layer/C3DTilesLayer.js +++ b/src/Layer/C3DTilesLayer.js @@ -143,7 +143,7 @@ class C3DTilesLayer extends GeometryLayer { } /** @type {Style} */ - this._style = config.style || null; + this.style = config.style || null; /** @type {Map} */ this.#fillColorMaterialsBuffer = new Map(); @@ -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; @@ -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(); } diff --git a/src/Utils/gui/C3DTilesStyle.js b/src/Utils/gui/C3DTilesStyle.js index a0c077eb29..6fabf4f72a 100644 --- a/src/Utils/gui/C3DTilesStyle.js +++ b/src/Utils/gui/C3DTilesStyle.js @@ -1,4 +1,3 @@ -import Style from 'Core/Style'; import { C3DTILES_LAYER_EVENTS } from 'Layer/C3DTilesLayer'; import Widget from './Widget'; @@ -221,12 +220,12 @@ class C3DTilesStyle extends Widget { } // set style - c3DTilesLayer.style = new Style({ + c3DTilesLayer.style = { fill: { color: fillColorFunction, opacity: fillOpacityFunction, }, - }); + }; }); });