1
votes

You can help, why the texture does not load

I tried to load the texture on a separate mesh in obj but for some reason it does not load and gives an error can anyone tell what the reason is material is applied but the texture is why there is no

var manager = new THREE.LoadingManager();
var loader = new THREE.ImageLoader(manager);

var textureBody = new THREE.Texture();

loader.load('tex/Base4.png', function(image) {
  textureBody.image = image;
  textureBody.needsUpdate = true;
});

var meshes = [];    
var objLoader = new THREE.OBJLoader();

objLoader.load('models/bas.obj', function(object) {
  console.log(object);

  object.traverse(function(child) {
    if (child instanceof THREE.Mesh) {
      meshes.push(child);
    }
  });

  var body = meshes[2];

  body.position.y = 2;

  scene.add(body);

  var bumpMapBody = new THREE.TextureLoader().load('tex/untitled2-NM_u0_v0.tif');

  body.material = new THREE.MeshPhonglMaterial({

    map: textureBody
  });
});

This gives an error message:

Uncaught TypeError: THREE.MeshPhonglMaterial is not a constructor at mucode.js:77 "body.material = new THREE.MeshPhonglMaterial({"at Object.onLoad (OBJLoader.js:385) at XMLHttpRequest. (three.js:32008)

ps Does anyone know how to shrink the window and move the canvas to a separate div

1
Please ask separate questions in separate posts.Luca Kiebel
"MeshPhonglMaterial" should probably be "MeshPhongMaterial"Nicholas Pipitone

1 Answers

1
votes

You have a typo in your code. It's not MeshPhonglMaterial but MeshPhongMaterial.