Initial commit
This commit is contained in:
25
js/materials.js
Normal file
25
js/materials.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// materials.js
|
||||
import * as THREE from 'three';
|
||||
|
||||
/**
|
||||
* Применяет стандартный матовый материал ко всем мешам объекта
|
||||
* @param {THREE.Object3D} object - объект сцены или room
|
||||
* @param {Object} options - {color, roughness, metalness}
|
||||
*/
|
||||
export function applyMatteMaterial(object, options = {}) {
|
||||
const color = options.color !== undefined ? options.color : 0xffffff;
|
||||
const roughness = options.roughness !== undefined ? options.roughness : 1;
|
||||
const metalness = options.metalness !== undefined ? options.metalness : 0;
|
||||
|
||||
object.traverse((child) => {
|
||||
if (child.isMesh) {
|
||||
child.material = new THREE.MeshStandardMaterial({
|
||||
color,
|
||||
roughness,
|
||||
metalness
|
||||
});
|
||||
child.castShadow = true;
|
||||
child.receiveShadow = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user