Improve road surface material creation to support custom material properties

This commit is contained in:
2026-05-18 16:07:07 +02:00
parent c4b8a25f97
commit a86261dd4c

View File

@@ -4309,22 +4309,39 @@ export class RuntimeHost {
} }
const textureSet = this.getOrCreateTextureSet(material); const textureSet = this.getOrCreateTextureSet(material);
const isCustomMaterial = material.kind === "custom";
const materialTransparent =
isCustomMaterial &&
(material.opacity < 0.999 || textureSet.albedoHasAlpha);
const roadMaterial = new MeshPhysicalMaterial({
color: isCustomMaterial ? material.albedoColorHex : 0xffffff,
map: textureSet.baseColor,
normalMap: textureSet.normal,
roughnessMap: textureSet.roughness,
roughness: isCustomMaterial ? material.roughness : 1,
metalnessMap: textureSet.metallic,
metalness: isCustomMaterial
? material.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 ? material.opacity : 1,
depthWrite: !materialTransparent,
side: DoubleSide
});
return this.configureRoadSurfaceMaterial( if (isCustomMaterial && textureSet.normal !== null) {
new MeshPhysicalMaterial({ roadMaterial.normalScale.set(
color: 0xffffff, material.normalStrength,
map: textureSet.baseColor, material.normalStrength
normalMap: textureSet.normal, );
roughnessMap: textureSet.roughness, }
roughness: 1,
metalnessMap: textureSet.metallic, return this.configureRoadSurfaceMaterial(roadMaterial);
metalness: textureSet.metallic === null ? 0.03 : 1,
specularColorMap: textureSet.specular,
specularColor: new Color(0xffffff),
specularIntensity: textureSet.specular === null ? 0.2 : 1,
side: DoubleSide
})
);
} }
private createRuntimeRoadSurfaceMaterial(path: RuntimePath): Material { private createRuntimeRoadSurfaceMaterial(path: RuntimePath): Material {