mns-mini-zabor/utils/material.ts

23 lines
659 B
TypeScript

import { Color, MeshStandardMaterial } from "three"
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_metaril_func(el, material)
})
}
export const set_material = (scene: any, color: any) => {
let c = color
const material = new MeshStandardMaterial({
color: new Color(c || '#9c9c00'),
transparent: true,
opacity: 1,
roughness: 0.3,
metalness: 0.3
})
set_metaril_func(scene, material)
}