three.js 笔记 --- 渲染图片 和 渲染obj,mtl文件
程序员文章站
2024-03-16 19:38:22
...
- 渲染图片
let textureLoader = new THREE.TextureLoader();
let textureLoaderRes = function (url) {
return textureLoader.load(url, function (map) {
map.wrapS = THREE.RepeatWrapping;
map.wrapT = THREE.RepeatWrapping;
return map
});
}
- 渲染obj mtl材质
let mtlLoader = new THREE.MTLLoader();
mtlLoader.setTexturePath(文件夹路径);
mtlLoader.load(mtl文件路径, function (materials) {
materials.preload();
let objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.load(obj文件路径, function (object) {
console.log(object)
});
});