Hello there,
I'm encountering an issue with the way a texture is being rendered on an imported OBJ model.
Below is an image showing how the texture currently appears:
And here is how the texture should actually look when mapped to the object:
Here is the code snippet I am using:
loader = new THREE.ImageLoader();
loader.load('./tex/Stuhl1-vorn.jpg', function (image) {
var imageObj = new Image();
imageObj.src = $(image).prop('src');
var canvas = document.createElement("canvas");
canvas.width = imageObj.width;
canvas.height = imageObj.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(imageObj, 0, 0, imageObj.width, imageObj.height, 0, 0, canvas.width, canvas.height);
texture.image = canvas;
texture.needsUpdate = true;
});
var material = new THREE.MeshLambertMaterial({
map: texture,
needsUpdate: true
});
var loader = new THREE.OBJLoader(manager);
loader.load('obj/sitz.obj', function (object) {
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material = material;
child.side = THREE.FrontSide;
}
});
object.position.y = -400;
scene.add(object);
}, onProgress, onError);