如何解决如何为从glb文件加载的模型添加颜色或纹理?
我正在努力使自己的模特脱颖而出,并在我的场景中更加知名。 I found this glb
file在我要使用的汽车上,但是它显得很暗而且很难看见。
我只是在尝试为它添加一些明亮的颜色,可能还会添加一些阴影,以便可以清楚地将其识别为汽车。
这是Creators3D Online Viewer中的样子。
到目前为止,这是我的代码(无需应用材料)
var loader = new THREE.GLTFLoader();
loader.load(
'https://srv-file19.gofile.io/download/FXLEpw/99-low-poly-cars-free_fbx.glb',function(gltf) {
console.log('gltf',gltf);
scene.add(gltf.scene);
var model = gltf.scene;
model.position.set(0,2);
model.rotation.set(0,90,0);
// How do I apply this texture to the car?
var material = new THREE.MeshBasicMaterial({
color: 0x00ff00,vertexColors: THREE.FaceColors
});
},function(xhr) {
console.log('xhr',(xhr.loaded / xhr.total * 100) + '% loaded');
},function(error) {
console.log('An error happened',error);
}
);
解决方法
只需使用mesh.material = yourMat
//Material
var mat001 = new THREE.MeshPhysicalMaterial();
mat001.color = new THREE.Color("gold");
mat001.reflectivity = 1.0;
mat001.roughness = 0.0;
mat001.envMapIntensity = 1.0;
//MODEL from loader
var mesh01;
loader.scene.traverse(function (child) {
if (child.isMesh) {
mesh01 = child;
child.material = mat001; // This is
scene.add(mesh01);
mesh01.scale.set(1,1,1);
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。