A
A
Artur Aralin2015-05-26 00:26:43
three.js
Artur Aralin, 2015-05-26 00:26:43

Why does three.js only render the silhouette of the model?

Own code

function init(container,path) {
      camera = new THREE.PerspectiveCamera( 20, window.innerWidth / window.innerHeight, 0.2, 2000 );
      camera.position.z = 1100;

      scene = new THREE.Scene();

      var ambient = new THREE.AmbientLight( 0xffffff );
      scene.add( ambient );

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

      var texture = THREE.ImageUtils.loadTexture('/public/texture.png');
      // texture.wrapS = THREE.RepeatWrapping;
      // texture.wrapT = THREE.RepeatWrapping;

      var sphereMaterial = new THREE.MeshLambertMaterial({
        map: texture
      });

      

      var loader = new THREE.OBJLoader();
      loader.load(path, function(object) {
        window.z = object;
        object.children[0].material = sphereMaterial;
        scene.add( object );
        animate();
      });

      renderer = new THREE.WebGLRenderer();
      renderer.setSize( 800, 600 );
      container.appendChild( renderer.domElement );

    }

function animate() {

  requestAnimationFrame( animate );
  render();

}

function render() {

  renderer.render( scene, camera );

}

And what he draws
8d25d95c351c4ff8bf842f3b9a03067f.PNG

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question