three.js形状孔高度

时间:2017-02-24 20:03:59

标签: javascript three.js

我尝试使用原始Shape和ExtrudedGeometry构建一个带有孔的Mesh。问题是我添加的孔总是通过所得到的网格的整个高度。有没有办法让这些洞的高度更短,所以最后这些不会穿过整个形状?

要挤出的形状的参考代码:

var heartShape = new THREE.Shape();

heartShape.moveTo( 25, 25 );
heartShape.bezierCurveTo( 25, 25, 20, 0, 0, 0 );
blah

var innerCircle = new THREE.Path();
innerCircle.moveTo(blah);
heartShape.holes.push(innerCircle);

var extrudeSettings = { amount: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 };

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

var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );

谢谢!

1 个答案:

答案 0 :(得分:1)

THREE.ExtrudeGeometry中的孔深度没有单独的参数。您将需要两个单独的操作来解决它。

一种解决方案可能是"插入"它与另一个基于内圆路径的拉伸(首先转换为Shape)。

var extrudeSettingsForPlug = { amount: 4, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 }; 

var geometry = new THREE.ExtrudeGeometry( innerCircleShape, extrudeSettingsForPlug );