Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js Ellipse

Tags:

three.js

How does one go about creating an ellipse in three.js?

I've looked at this: Drawing an ellipse in THREE.js

But it would be cool if someone could provide a working example.

I've tried this:

ellipse = new THREE.EllipseCurve(0,0,200,400,45,45,10);

but that's not working for me. I have no idea what the parameters mean so I'm just blindly going about it.

edit: I am getting the error "defined is not a function" when I try to create an ellipse curve.

edit2: Figured out I had to include Curves.js for it to work but having a working example somewhere would still be really nice for me and other people since the stackoverflow link I pasted earlier doesn't have an example.

like image 995
Recur Avatar asked Oct 07 '22 00:10

Recur


2 Answers

I am unfamiliar with THREE.js, but looking at the code the parameters seem to be
(Center_Xpos, Center_Ypos, Xradius, Yradius, StartAngle, EndAngle, isClockwise) so a reason your definition isn't working is because you're setting the start and end angles both to the same thing.

like image 154
SamYonnou Avatar answered Oct 12 '22 12:10

SamYonnou


There is an example here, and below is my example:

var scene = new THREE.Scene();
var material = new THREE.LineBasicMaterial({color:0x000000, opacity:1});
var ellipse = new THREE.EllipseCurve(0, 0, 1, 5, 0, 2.0 * Math.PI, false);
var ellipsePath = new THREE.CurvePath();
ellipsePath.add(ellipse);
var ellipseGeometry = ellipsePath.createPointsGeometry(100);
ellipseGeometry.computeTangents();
var line = new THREE.Line(ellipseGeometry, material);
scene.add( line );

Notice: this is not a complete example, you should add the rest code like <script src="js/three.min.js"></script> if you want to view the result.

like image 30
openxxs Avatar answered Oct 12 '22 10:10

openxxs