I’m trying to load a .obj file of a lot of differents ways but all of them fail. I have proved each example that i have found on the internet but any of them work for me.
I have proved with a lot of differents obj files too.
var material = new THREE.MeshBasicMaterial({ color: 0x444444 });
var loader = new THREE.OBJLoader();
loader.load('diceLow.obj',
function (obj) {
obj.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material = material;
obj.material = child.material;
child.castShadow = true;
child.receiveShadow = true;
}
});
scene.add(obj);
},
function (xhr) {
console.log((xhr.loaded / xhr.total * 100) + "% loaded")
},
function (err) {
console.error("Error loading")
}
);
This line can be removed since OBJLoader always returns an instance of THREE.Group. And a group does not have a material property (since it is non-renderable 3D object used for grouping other 3D objects together).
I found the solution, I need to test the web in a server, using xampp it works. In Glitch i need write the http files direction, no the local direction.