Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
HARP-15480 Fix colors not being set correctly on custom materials (#2196
Browse files Browse the repository at this point in the history
)

Signed-off-by: Jonathan Stichbury <2533428+nzjony@users.noreply.github.com>
  • Loading branch information
nzjony committed May 25, 2021
1 parent 5356f02 commit 67eaa32
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions @here/harp-mapview/lib/MapMaterialAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class MapMaterialAdapter {

private m_lastUpdateFrameNumber = -1;
private readonly m_dynamicProperties: Array<[string, Expr | StylePropertyEvaluator]>;
private readonly tmpColor = new THREE.Color();

constructor(material: THREE.Material, styledProperties: StyledProperties) {
this.material = material;
Expand Down Expand Up @@ -279,10 +280,13 @@ export class MapMaterialAdapter {
colorValue = parsed;
}
const rgbValue = ColorUtils.removeAlphaFromHex(colorValue);
m[propName].set(rgbValue);
} else {
m[propName] = value;
this.tmpColor.set(rgbValue);
// We set the value, i.e. using =, as opposed to setting the color directly using set
// because the material may be a custom material with a setter.
value = this.tmpColor;
}

m[propName] = value;
}

private applyMaterialBaseColor(color: Value, opacity: number | undefined) {
Expand Down

0 comments on commit 67eaa32

Please sign in to comment.