I'm trying to load a 3d Model in Three js and I'm seeing this error message. No info in the web... Anyone can help please?
I verified the mtl and obj lib are called on the right place just after threejs and before the model script.
This is the code
'use strict';
var scene6, camera6, renderer6, light, model, shipMtl, shipObj;
function init() {
scene6 = new THREE.Scene();
camera6 = new THREE.PerspectiveCamera(35, 1, 1, 1000);
camera6.position.z = 400;
//LIGHTS
light = new THREE.PointLight(0xffffff, 2, 0);
light.position.set(200, 100, 300);
scene6.add(light);
renderer6 = new THREE.WebGLRenderer({ canvas: document.getElementById('model'), antialias: true });
renderer6.setClearColor(0x000000);
renderer6.setPixelRatio(window.devicePixelRatio);
model = new THREE.Mesh(
new THREE.BoxGeometry(100, 100, 100, 50),
new THREE.MeshPhongMaterial({
color: 0xffffff,
wireframe: true
})
);
scene6.add(model);
//MODEL
shipMtl = new THREE.MTLLoader();
shipMtl.load('../models/spaceCraft1.mtl', function(materials) {
materials.preload();
shipObj = new THREE.OBJLoader();
shipObj.setMaterials(materials);
shipObj.load('../models/spaceCraft1.obj', function(object) {
scene6.add(object);
object.rotation.y += .01;
});
});
animate6();
}
function animate6() {
model.rotation.y += .01;
model.rotation.x -= .01;
requestAnimationFrame(animate6);
renderer6.render(scene6, camera6);
}
window.onload = init;
And this the error message:
OBJLoader.js:530 Uncaught Error: Unexpected line: 'usemap _defaultMat'
at THREE.OBJLoader.parse (OBJLoader.js:530)
at OBJLoader.js:51
at XMLHttpRequest.<anonymous> (three.js:30090)
Thank you in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…