threejs给3d模型中的物体换肤(修改材质)

threejs给3d模型中的物体换肤(修改材质)_第1张图片

变成这样

threejs给3d模型中的物体换肤(修改材质)_第2张图片 

         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了~

 

你可能感兴趣的:(vue,three.js,3d,材质)