What is the simplest way to draw a cylinder with a slice cut out of it with three.js?

廉价感情. 提交于 2019-12-20 05:36:09

问题


I was wondering how you would draw a cylinder with a slice cut out of it using three.js i.e. something like this: Image

All replies are much appreciated.


回答1:


Probably the easiest way to get the shape you want is to extrude a THREE.Shape like so:

var settings = {
    amount: 2,
    steps : 1,
    bevelEnabled: false,
    curveSegments: 24
};

var shape = new THREE.Shape();
shape.moveTo( 0, 0 );
shape.absarc( 0, 0, 10, 0, Math.PI * 1.75, false );
shape.moveTo( 0, 0 );

var geometry = new THREE.ExtrudeGeometry( shape, settings );

fiddle: http://jsfiddle.net/0yyg5ese/

three.js r.73




回答2:


Use a THREE.CylinderGeometry and set the thetaLength-parameter. The default is 2 * Pi, which makes for a complete cylinder. I have built a fiddle that looks like your Image: http://jsfiddle.net/hvgropoa/.

Downside: the slice´s faces ar missing, so you can see inside the cylinder when looking inside the cut :( However this is the simplest way, if you need a closed Cylinder I suggest doing it with THREE.CSG.



来源:https://stackoverflow.com/questions/34208786/what-is-the-simplest-way-to-draw-a-cylinder-with-a-slice-cut-out-of-it-with-thre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!