How to extrude a quarter Circle Geometry (THREE.CircleGeometry) in Three.js?
I create the quarter circle like this:
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 );
But I want it extruded not just a plane, I just found THREE.ExtrudeGeometry but don't know if I can use it for my purposes or how.
Here's an example of how to extrude a shape, in this case a triangle along a straight line. It's pretty much what the Shape class is meant for. 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);
The key concepts here:
Read more on the THREE.js documentation:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.