let wheels = [];
let carBody, frontCar, hoodCar, glassCar;
const loader = new GLTFLoader();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath("/roadSter/draco/gltf/");
loader.setDRACOLoader(dracoLoader);
loader.load("/roadSter/model/bmw01.glb", gltf => {
console.log(gltf);
const bmw = gltf.scene;
bmw.traverse(child => {
if (child.isMesh) {
// console.log(child);
}
// 轮毂
if (child.isMesh && child.name.includes("轮毂")) {
child.material = wheelsMaterial;
wheels.push(child);
}
// 车身
if (child.isMesh && child.name.includes("Mesh002")) {
carBody = child;
carBody.material = this.bodyMaterial;
}
// 前脸
if (child.isMesh && child.name.includes("前脸")) {
frontCar = child;
frontCar.material = this.frontMaterial;
}
// 引擎盖
if (child.isMesh && child.name.includes("引擎盖_1")) {
hoodCar = child;
hoodCar.material = this.hoodMaterial;
}
// 挡风玻璃
if (child.isMesh && child.name.includes("挡风玻璃")) {
glassCar = child;
glassCar.material = this.glassMaterial;
}
});
this.scene.add(bmw);
这是模型的代码
这是文件所在的位置
加载模型的时候,控制台报这个错误
麻烦各位大佬,哪里出错了
THREE.DRACOLoader: Unexpected geometry type 错误是因为 DRACO 压缩的模型文件存在问题,或者加载的路径设置不对导致的,你检查一下 DRACO 解码器路径和模型文件路径看看对不对