mns-mini-zabor/utils/material.ts

32 lines
965 B
TypeScript

import { Color, MeshStandardMaterial } from "three"
import { getColorHexFromRal } from "~/components/ral"
const lamelle_color = use_lamelle_color()
const pillar_color = use_pillar_color()
const set_metaril_func = (scene: any, material: any) => {
scene.children.forEach((el: any) => {
if (el.isMesh) {
el.castShadow = true
el.receiveShadow = true
}
if (el.material) el.material = material
set_material(el, material)
})
}
export const set_material = (scene: any, color: any) => {
let c = color
if (color == 'lamelle') {
c = getColorHexFromRal(lamelle_color.value)
}
if (color == 'pillar') {
c = getColorHexFromRal(pillar_color.value)
}
const material = new MeshStandardMaterial({
color: new Color(c || '#9c9c00'),
transparent: true,
opacity: 1,
roughness: 0.3,
metalness: 0.3
})
set_metaril_func(scene, material)
}