2017-10-20 13 views
0

Three.jsを使用して自分のプライファイルをロードしようとしています。それは働いていますが、ほとんど色が見えません。ここにはいくつかのちらちらがありますが、ほとんど黒です(下の最初の画像)。 MeshLab(下の2番目の画像)で画像が適切に(色付きで)開きます。私はvertexColors: THREE.VertexColorsThree.js - ply files - why colorless?で提案されている)とvertexColors: THREE.FaceColorsを試しましたが、何も役立たないようでした。私は3人です。初心者なので、何が間違っているのか教えてください。Three.js ply colorless(オールブラック)

Three.js MeshLab

と私のコード:

<!doctype html> 
<html lang="en"> 
<head> 
    <title>Icon 7</title> 
    <meta charset="utf-8"> 
</head> 
<body style="margin: 0;"> 

    <script src="js/three.min.js"></script> 
    <script src="js/PLYLoader.js"></script> 
    <script src="js/OrbitControls.js"></script> 

    <script> 

    // Set up the scene, camera, and renderer as global variables. 
    var scene, camera, renderer; 

    init(); 
    animate(); 

    // Sets up the scene. 
    function init() { 

     // Create the scene and set the scene size. 
     scene = new THREE.Scene(); 
     var WIDTH = window.innerWidth, 
      HEIGHT = window.innerHeight; 

     // Create a renderer and add it to the DOM. 
     renderer = new THREE.WebGLRenderer({antialias:true}); 
     renderer.setSize(WIDTH, HEIGHT); 
     document.body.appendChild(renderer.domElement); 

     // Create a camera, zoom it out from the model a bit, and add it to the scene. 
     camera = new THREE.PerspectiveCamera(35, WIDTH/HEIGHT, 0.1, 100); 
     camera.position.set(0,0.15,3); 
    camera.lookAt(new THREE.Vector3(0,0,0)); 
     scene.add(camera); 

     // Create an event listener that resizes the renderer with the browser window. 
     window.addEventListener('resize', function() { 
     var WIDTH = window.innerWidth, 
      HEIGHT = window.innerHeight; 
     renderer.setSize(WIDTH, HEIGHT); 
     camera.aspect = WIDTH/HEIGHT; 
     camera.updateProjectionMatrix(); 
     }); 

     // Set the background color of the scene. 
     renderer.setClearColor(0xd3d3d3, 1); 

     // Create a light, set its position, and add it to the scene. 
     var light = new THREE.PointLight(0xffffff); 
     light.position.set(0,200,100); 
     scene.add(light); 

     // Load in the mesh and add it to the scene. 
    var loader = new THREE.PLYLoader(); 
    loader.load('./models/foot.ply', function (geometry) { 
      geometry.computeVertexNormals(); 
      geometry.center(); 
      var material = new THREE.MeshStandardMaterial   ({ shininess: 1000,vertexColors: THREE.FaceColors }); 
      var mesh = new THREE.Mesh(geometry, material   ); 
      mesh.position.x = 0; 
      mesh.position.y = 0; 
      mesh.position.z = 0; 
      mesh.castShadow = false; 
      mesh.receiveShadow = false; 
      scene.add(mesh); 
    }); 

     // Add OrbitControls so that we can pan around with the mouse. 
     controls = new THREE.OrbitControls(camera, renderer.domElement); 
    controls.userPanSpeed = 0.05; 

    } 


    // Renders the scene and updates the render as needed. 
    function animate() { 

     // Read more about requestAnimationFrame at http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ 
     requestAnimationFrame(animate); 

     // Render the scene. 
     renderer.render(scene, camera); 
     controls.update(); 

    } 

    </script> 

</body> 
</html> 

編集:私は別のテクスチャを持っていないとして、これは重複問題ではありません。

+0

可能な複製をMeshStandardMaterial使用を使用して(https://stackoverflow.com/questions/16109774/using-textures-with-three-js- and-ply-file) – rafaelcastrocouto

+0

は重複していません。この質問はテクスチャとは関係ありません。 – gaitat

答えて

0

の代わりに[Three.jsとPLYファイルとテクスチャを使用する]のMeshBasicMaterial

+0

それは解決策でした、多くのありがとう! –