如何在Three.js中挤出四分之一圆几何(THREE.CircleGeometry)?
我创建了这样的四分之一圈:
var circle = new THREE.Mesh(
new THREE.CircleGeometry( 25, 32, 0, Math.PI/2 ),
new THREE.MeshBasicMaterial({ color: 0xffffff, side: THREE.DoubleSide })
);
scene.add( circle );
但我希望它不仅仅是一架飞机,我只是发现了三个.ExtrudeGeometry但不知道我是否可以将它用于我的目的或如何使用。
答案 0 :(得分:3)
以下是如何挤出形状的示例,在这种情况下是沿直线的三角形。它几乎就是Shape类的用途。 https://jsfiddle.net/wb412ymk/
// Create a 2D triangular shape
// The Shape() class has methods for drawing a 2D shape
var triangleShape = new THREE.Shape();
triangleShape.moveTo(-2, -2);
triangleShape.lineTo(0, 2);
triangleShape.lineTo(2, -2);
triangleShape.lineTo(-2, -2);
// Create a new geometry by extruding the triangleShape
// The option: 'amount' is how far to extrude, 'bevelEnabled: false' prevents beveling
var extrudedGeometry = new THREE.ExtrudeGeometry(triangleShape, {amount: 5, bevelEnabled: false});
// Geometry doesn't do much on its own, we need to create a Mesh from it
var extrudedMesh = new THREE.Mesh(extrudedGeometry, new THREE.MeshPhongMaterial({color: 0xff0000}));
scene.add(extrudedMesh);
这里的关键概念:
阅读有关THREE.js文档的更多信息: