colors
This commit is contained in:
parent
e05319c556
commit
049ed81ba2
|
@ -22,34 +22,9 @@ const { scene: osnova_stolba } = await useGLTF('/models/osnova_stolba.glb', { dr
|
|||
const { scene: planki } = await useGLTF('/models/planki.glb', { draco: true })
|
||||
const { scene: stolb } = await useGLTF('/models/stolb.glb', { draco: true })
|
||||
const { scene: verh } = await useGLTF('/models/verh.glb', { draco: true })
|
||||
function set_material(scene: any, material: any) {
|
||||
scene.children.forEach((el: any) => {
|
||||
if (el.material) el.material = material
|
||||
set_material(el, material)
|
||||
})
|
||||
}
|
||||
|
||||
const lamelle_color = use_lamelle_color()
|
||||
const lcolor = getColorHexFromRal(lamelle_color.value)
|
||||
const lamelle_material = new MeshStandardMaterial({
|
||||
color: new Color(lcolor || '#9c9c9c'),
|
||||
transparent: true,
|
||||
opacity: 1,
|
||||
roughness: 0.3,
|
||||
metalness: 0.3
|
||||
})
|
||||
set_material(planki, lamelle_material)
|
||||
|
||||
const pillar_color = use_pillar_color()
|
||||
const pcolor = getColorHexFromRal(pillar_color.value)
|
||||
const pillar_material = new MeshStandardMaterial({
|
||||
color: new Color(pcolor || '#9c9c9c'),
|
||||
transparent: true,
|
||||
opacity: 1,
|
||||
roughness: 0.3,
|
||||
metalness: 0.3
|
||||
});
|
||||
[stolb, verh, krepleniye_planok].map(el => set_material(el, pillar_material))
|
||||
set_material(planki, 'lamelle');
|
||||
[stolb, verh, krepleniye_planok].map(el => set_material(el, 'pillar'))
|
||||
</script>
|
||||
<template>
|
||||
<TresGroup :translate-y="-2" :scale="1.25">
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import { Color, MeshStandardMaterial } from "three"
|
||||
import { getColorHexFromRal } from "~/components/ral"
|
||||
|
||||
const lamelle_color = use_lamelle_color()
|
||||
const pillar_color = use_pillar_color()
|
||||
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
|
||||
})
|
||||
scene.children.forEach((el: any) => {
|
||||
if (el.isMesh) {
|
||||
el.castShadow = true
|
||||
el.receiveShadow = true
|
||||
}
|
||||
if (el.material) el.material = material
|
||||
set_material(el, color)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue