From c4b8a25f9750e48406f1d4f47afd5e04d5890bb0 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 18 May 2026 16:06:56 +0200 Subject: [PATCH] Enhance material configuration to support custom physical material properties --- src/viewport-three/viewport-host.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index d82a4c91..e614a668 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -7724,19 +7724,30 @@ export class ViewportHost { } const textureSet = this.getOrCreateTextureSet(materialDef); + const isCustomMaterial = materialDef.kind === "custom"; + const materialTransparent = + isCustomMaterial && + (materialDef.opacity < 0.999 || textureSet.albedoHasAlpha); return this.configureRoadSurfaceMaterial( new MeshPhysicalMaterial({ - color: 0xffffff, + color: isCustomMaterial ? materialDef.albedoColorHex : 0xffffff, map: textureSet.baseColor, normalMap: textureSet.normal, roughnessMap: textureSet.roughness, - roughness: 1, + roughness: isCustomMaterial ? materialDef.roughness : 1, metalnessMap: textureSet.metallic, - metalness: textureSet.metallic === null ? 0.03 : 1, + metalness: isCustomMaterial + ? materialDef.metallic + : textureSet.metallic === null + ? 0.03 + : 1, specularColorMap: textureSet.specular, specularColor: new Color(0xffffff), specularIntensity: textureSet.specular === null ? 0.2 : 1, + transparent: materialTransparent, + opacity: isCustomMaterial ? materialDef.opacity : 1, + depthWrite: !materialTransparent, side: DoubleSide }) );