0

My problem is about the loading of the .MTL file in the script. It opens nice my OBJ file but the .MTL file doesn´t upload in the page, it only shows in grey or black. You can see the files in this link if you want to try: OBJ: https://github.com/carva28/ntc25anos/blob/testing/models/cat.obj MTL: https://github.com/carva28/ntc25anos/blob/testing/models/cat.mtl

My THREE version is 97

function init() {
    var scene = new THREE.Scene();
    var camera = new THREE.PerspectiveCamera(5, window.innerWidth / window.innerHeight, 0.5, 1000);
    var webGLRenderer = new THREE.WebGLRenderer();
    webGLRenderer.setClearColor(new THREE.Color(0xfabbff));
    webGLRenderer.setSize(window.innerWidth, window.innerHeight);
    webGLRenderer.shadowMap.enabled = true;
    camera.position.x = 0.5;
    camera.position.y = 10;
    camera.position.z = 60;
    camera.lookAt(new THREE.Vector3(0, 0, 0));
    var spotLight = new THREE.SpotLight(0xffffff);
    spotLight.position.set(0, 40, 30);
    spotLight.intensity = 2.5;
    scene.add(spotLight);
    document.getElementById("WebGL-output").appendChild(webGLRenderer.domElement);
    var step = 0;
    var mesh;
   var mtlLoader = new THREE.MTLLoader();
    mtlLoader.setPath("models/");
    mtlLoader.load('cat.mtl', function(materials) {
        materials.preload();
        var objLoader = new THREE.OBJLoader();
        objLoader.setMaterials(materials);
        objLoader.setPath("models/");
        objLoader.load('cat.obj', function(object) {
          object.scale.set(1, 1, 1);
          mesh = object;
          scene.add(mesh);
          object.rotation.x = 0;
          object.rotation.y = -1.3;
        });
    });

    render();
Dicarva
  • 75
  • 9

0 Answers0