// 模型引入obj模型引入
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader.js';
// 模型引入obj模型的纹理引入
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader.js';
function initOBJ() {//OBJ模型加载
var mtlLoader = new MTLLoader()// mtl材加载器
//--------------------
// mtlLoader.setTexturePath('/data/tex/')// 材质加载路径
mtlLoader.load('/img/objTest.mtl', materials => {
materials.preload()
var objLoader = new OBJLoader()
objLoader.setMaterials(materials)
objLoader.load('/img/objTest.obj', (obj) => {
obj.traverse((child) => {
if (child instanceof THREE.Mesh) {
child.material.side = THREE.DoubleSide
child.scale.set(30, 30, 30)
}
})
scene.add(obj)
})
})
}