23 lines
680 B
TypeScript
23 lines
680 B
TypeScript
import { Color, MeshStandardMaterial } from "three"
|
|
|
|
const set_metaril_func = (scene: any, material: any) => {
|
|
scene.children.forEach((el: any) => {
|
|
if (el.isMesh && !el.isInstancedMesh) {
|
|
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.5,
|
|
metalness: 0
|
|
})
|
|
set_metaril_func(scene, material)
|
|
} |