Hi there,
I want to load an obj image with texture but the texture doesn’t load.
Here’s my code:
let materialLoader = new MTLLoader();
let objectLoader = new OBJLoader();
materialLoader.setPath(‘rose/’)
materialLoader.load(‘rose.mtl’, function(materials){
materials.preload();
objectLoader.setMaterials(materials);
objectLoader.setPath(‘rose/’);
objectLoader.load(‘rose.obj’, function(mesh){
scene.add(mesh);
document.querySelector(‘h1’).style.display = ‘none’;
});
});
and also I set the alpha: true for transparent background.
Here’s the result:
I’ll be grateful for your help
hofk
June 11, 2020, 6:48pm
2
When I set my image, the default example doesn’t work though.
hofk
June 11, 2020, 7:23pm
4
yes, I run the default example and everything works fine.
but when I change the image, the texture doesn’t load.
hofk
June 11, 2020, 7:40pm
6
Hm, not judging by this.
Can you make a live example ( jsfiddle, codepen, … )
Yes of course, Here’s my code:
https://jsfiddle.net/amir04lm26/w2dj4Lk8/
But I couldn’t upload the assets because of the large size. So if you want them, I’ll upload them on an upload center.
And this is the iamge:
https://free3d.com/3d-model/rose-31675.html
I added the files from the image folder that contains the image’s file and texture, to a local folder by the name of rose.
hofk
June 12, 2020, 8:26am
9
I downloaded the rose and used it in my example. Result - black rose.
Correct in Win 10 3D viewer.
From there - tried to open 3D with Paint - error/selection necessary for texture.
I am not at all an expert in creating and loading models. Maybe someone else can help?
**[quote=“Amir_zare, post:1, topic:16131, full:true”]
Hi there,
I want to load an obj image with texture but the texture doesn’t load.
Here’s my code:
let materialLoader = new MTLLoader();
let objectLoader = new OBJLoader();
materialLoader.setPath(‘rose/’)
materialLoader.load(‘rose.mtl’, function(materials){
materials.preload();
objectLoader.setMaterials(materials);
objectLoader.setPath(‘rose/’);
objectLoader.load(‘rose.obj’, function(mesh){
scene.add(mesh);
document.querySelector(‘h1’).style.display = ‘none’;
});
});
and also I set the alpha: true for transparent background.
Here’s the result:
I’ll be grateful for your help
[/quote]
**
Can anyone help???