2015-02-11 83 views
0

我想在ExtrudeGeometry的幫助下畫一個環。three.js中的光滑環3D

Ring3D = function(innerRadius, outerRadius, heigth, Segments) { 

    var extrudeSettings = { 
     amount: heigth, 
     bevelEnabled: false, 
     curveSegments: Segments 
    }; 
    var arcShape = new THREE.Shape(); 
    arcShape.moveTo(outerRadius, 0); 
    arcShape.absarc(0, 0, outerRadius, 0, Math.PI * 2, false); 

    var holePath = new THREE.Path(); 
    holePath.moveTo(innerRadius, 0); 
    holePath.absarc(0, 0, innerRadius, 0, Math.PI * 2, true); 
    arcShape.holes.push(holePath); 

    var geometry = new THREE.ExtrudeGeometry(arcShape, extrudeSettings); 

    var material = new THREE.MeshPhongMaterial({ 
     color: 0x00ffff 
    }); 

    var mesh = new THREE.Mesh(geometry, material); 
    mesh.rotation.x = Math.PI/2; 
    mesh.position.y = heigth/2; 

    var object = new THREE.Object3D; 
    object.add(mesh); 

    return object; 

} 

由此產生的圖有明顯的傷疤。圓柱體和環面這樣的傷疤不是。如何擺脫它們?示例here

enter image description here

geometry.computeVertexNormals();

enter image description here

+0

你找出解決的辦法 – 2016-11-11 17:29:44

+0

貳號使用TorusGeometry – 2016-11-14 09:26:46

回答

-1

您從您的幾何需要.computeVertexNormals()。但似乎有一些問題(與解決方案)在這裏解釋:https://github.com/mrdoob/three.js/issues/323。我不確定它是否適用於你的情況。

+0

沒有...我編輯後,添加了新的屏幕 – 2015-02-11 19:06:53

+0

看待這個問題。 – gaitat 2015-02-11 19:07:18

+0

或者你增加你的細分變量的數量。它看起來不錯,360段。有很多更多的多邊形。 – gaitat 2015-02-11 19:08:24

-1

我發現在ExtrudeGeometry的代碼中的註釋:

this.computeFaceNormals(); 
// can't really use automatic vertex normals 
// as then front and back sides get smoothed too 
// should do separate smoothing just for sides 
//this.computeVertexNormals(); 

如此看來它不支持現在:(

0
 var shape = new THREE.Shape(); 
     shape.moveTo(0, 0); 
     shape.lineTo(0, 10); 
     shape.quadraticCurveTo(35, 30, 0, 50); 
     shape.lineTo(0, 60); 
     shape.quadraticCurveTo(48, 30, 0, 0);   

     var extrudeSettings = { 
      amount : 20, 
      steps : 10, 
      bevelEnabled: false, 
      curveSegments: 8 
     }; 

     var geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings); 
     var mesh = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial({ color: '0x804000' ,transparent: true,opacity: 0.2})); 
     scene.add(mesh); 
+0

或http://embed.plnkr.co/i6TvcXxaqO5jpcOLXCVi/ – 2017-06-08 09:22:56