
变成这样
- this.otherModel.traverse(function (child) {
- if (child instanceof THREE.Mesh && child.name == 'Cylinder240') {
- // 导入纹理
- const textureLoader = new THREE.TextureLoader();
- const floorColor=textureLoader.load(require('../../../public/img/color.jpg'));
- const material = new THREE.MeshPhysicalMaterial({
- map: floorColor
- });
- child.material=material
- }
- });
上面代码就是:遍历模型中的子对象找到你要修改的给他常见一个纹理是你需要的图片或者颜色之类的,使用材质中的map给他赋值 在赋值给这个子项的材质 就OK了~