-1

i will enumerate what i did until now:

  1. I have a file "pre.obj" converted to "pre.js" using convert_obj_three.py script
    "pre.obj" uses "pre.mtl" because it has material of image "specular.jpg"

    "pre.obj" ,"pre.mtl" and "specular.jpg" can be looked at here respectivily

    xsportfit.com/threejs/pre.obj

    xsportfit.com/threejs/pre.mtl

    xsportfit.com/threejs/specular.jpg

  2. I have tried to load "pre.js" file using three.js library of this way:

    var scene = new THREE.Scene();
    var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 100);
    camera.position.z = 3;
    var renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(renderer.domElement);
    var jsonLoader = new THREE.JSONLoader();
    var mesh;
    jsonLoader.load('pre.js',function (geometry, materials) {
                        var material = new THREE.MeshFaceMaterial(materials);
                        mesh = new THREE.Mesh(geometry, material);
                        scene.add(mesh);
                    }
            );
    
    var render = function () {
    requestAnimationFrame(render);
    renderer.render(scene, camera);
    };
    
    render();
    

Like you can see here http://xsportfit.com/threejs/ nothing is being showed, I am getting these warnings in console:

THREE.WebGLRenderer: OES_texture_float_linear extension not supported. three.js:11611 THREE.Loader: transparency has been renamed to opacity

Any help would be great, thanks!

WestLangley
  • 102,557
  • 10
  • 276
  • 276

1 Answers1

1

Your materials array contains an instance of MeshLambertMaterial. MeshLambertMaterial requires lights in the scene.

One option is to do this:

var light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.set( 10, 10, 10 );
scene.add( light );

three.js r.71

WestLangley
  • 102,557
  • 10
  • 276
  • 276
  • Thanks a lot for the help until now, i have made some changes to the code using `code`MeshLambertMaterial`code` instead of `code`MeshFaceMaterial`code`, i added light to scene and added some rotation in render function , but my cube still without showing 'specular.jpg' image as texture of my cube, do you have any idea why? you can look at live here http://xsportfit.com/threejs/ – Silvestre Alejandro Terrazas M Aug 21 '15 at 20:37
  • Welcome to stackoverflow. _Do not_ change the question after it has been answered. Accept the answer by clicking on the check mark and make a new post if you have further questions. – WestLangley Aug 21 '15 at 21:28
  • `MeshLambertMaterial` does not take a materials array as an argument. Study the three.js examples and documentation. – WestLangley Aug 21 '15 at 21:34