Hi,
I’m loading two ojb & mtl files that are supposed to be planets. Each of these will work fine individually, but when I try to load them both the texture is only showing for one of them. The other will just be a gray sphere. And LoadingManager said they all loaded in the console.
Here’s the snippet from the script:
var loader = new THREE.OBJLoader(manager);
var mtlLoader = new THREE.MTLLoader(manager);
function moonOBJ() {
mtlLoader
.setPath('assets/img/moon/')
.load(
'Moon-2K-smooth.mtl',
(materials) => {
materials.preload();
loader.setMaterials(materials)
.setPath('assets/img/moon/')
.load(
'Moon-2K-smooth.obj',
(object) => {
scene.add(object);
object.scale.set(13, 13, 13);
object.rotateX(-1.1);
object.rotateY(2.9);
object.rotateZ(2);
}
);
}
);
}
function earthOBJ() {
mtlLoader
.setPath('assets/img/earth/')
.load(
'Earth-2K.mtl',
(materials) => {
materials.preload();
loader.setMaterials(materials)
.setPath('assets/img/earth/')
.load(
'Earth-2K.obj',
(object) => {
scene.add(object);
object.scale.set(30, 30, 30);
object.position.y = -100;
object.rotateY(0.25);
object.rotateZ(-0.3);
}
);
}
);
}
Both of these are from a stock site and created through blender. And they didn’t include the png sources in the mtl so I added those myself. I also changed a couple of other things in the mtl’s, such as opacities.
Moon:
newmtl Moon
Ns 0.000000
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_kd moon-diffuse_2K.png
Earth:
newmtl Atmosphere
Ns 0.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 0.000000
illum 2
bump Bump_2K.png
newmtl Clouds
Ns 0.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 0.000000
illum 2
map_kd Clouds_2K.png
newmtl Earth
Ns 0.000000
Ka 1.000000 1.000000 1.000000
Kd 0.940000 0.940000 0.940000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_kd Diffuse_2K.png
I’m lost on this. They’re coming from different directories so I don’t think they’re overwriting each other. Please let me know if anything else is needed and thank you for taking look.