Enhance material configuration to support custom physical material properties
This commit is contained in:
@@ -7724,19 +7724,30 @@ export class ViewportHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const textureSet = this.getOrCreateTextureSet(materialDef);
|
const textureSet = this.getOrCreateTextureSet(materialDef);
|
||||||
|
const isCustomMaterial = materialDef.kind === "custom";
|
||||||
|
const materialTransparent =
|
||||||
|
isCustomMaterial &&
|
||||||
|
(materialDef.opacity < 0.999 || textureSet.albedoHasAlpha);
|
||||||
|
|
||||||
return this.configureRoadSurfaceMaterial(
|
return this.configureRoadSurfaceMaterial(
|
||||||
new MeshPhysicalMaterial({
|
new MeshPhysicalMaterial({
|
||||||
color: 0xffffff,
|
color: isCustomMaterial ? materialDef.albedoColorHex : 0xffffff,
|
||||||
map: textureSet.baseColor,
|
map: textureSet.baseColor,
|
||||||
normalMap: textureSet.normal,
|
normalMap: textureSet.normal,
|
||||||
roughnessMap: textureSet.roughness,
|
roughnessMap: textureSet.roughness,
|
||||||
roughness: 1,
|
roughness: isCustomMaterial ? materialDef.roughness : 1,
|
||||||
metalnessMap: textureSet.metallic,
|
metalnessMap: textureSet.metallic,
|
||||||
metalness: textureSet.metallic === null ? 0.03 : 1,
|
metalness: isCustomMaterial
|
||||||
|
? materialDef.metallic
|
||||||
|
: textureSet.metallic === null
|
||||||
|
? 0.03
|
||||||
|
: 1,
|
||||||
specularColorMap: textureSet.specular,
|
specularColorMap: textureSet.specular,
|
||||||
specularColor: new Color(0xffffff),
|
specularColor: new Color(0xffffff),
|
||||||
specularIntensity: textureSet.specular === null ? 0.2 : 1,
|
specularIntensity: textureSet.specular === null ? 0.2 : 1,
|
||||||
|
transparent: materialTransparent,
|
||||||
|
opacity: isCustomMaterial ? materialDef.opacity : 1,
|
||||||
|
depthWrite: !materialTransparent,
|
||||||
side: DoubleSide
|
side: DoubleSide
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user