Hi, Im new so Hello everyone
I fight with my code a couple days and I’m very sad because I don’t have result.
Please help me to understand how I can load texture in base64 dynamicly and Why obj is so dark, no shadow. The obj is from tutorial on youtube. Please help.
this is the problem part
function addTape() {
let path = 'model/';
let mtlLoader = new MTLLoader();
mtlLoader.setResourcePath(path);
mtlLoader.setPath(path);
mtlLoader.load('r2-d2.mtl', function (materials) {
materials.preload();
let objLoader = new OBJLoader();
objLoader.setPath(path);
objLoader.setMaterials(materials);
// TODO add texture base64 PNG, not from folder objLoader||tape."textureBase64"('data:image/png;base64,/9j/4AAQSkZ[...]');
// TODO why object is that dark, he dont heve light inside his soul. "Luke, I am Your Father" NOOOO.
objLoader.load('r2-d2.obj', function (mesh) {
tape = mesh; // Do not change 'tape = mesh'. tape will be destroy many times - changes view.
tape.position.y = -1;
tape.scale.x = 0.02;
tape.scale.y = 0.02;
tape.scale.z = 0.02;
scene.add(tape);
});
});
}
EDIT
I added shadow:
but still I can’t change texture, and why the obj is so dark. Please help.
tape.traverse(function (node) {
if (node.isMesh) {
console.log(node.material.map);
//node.material.map = texture;
node.castShadow = true;
}
});