Dustin
Dustin

Reputation: 8267

Create an equilateral triangle using three.js

I am trying to create an equilateral triangle using three.js. What I am coming up with appears to be a bit too tall. I am defining my vertices like so:

new THREE.Vector3(0, 0, 0),
new THREE.Vector3(4, 0, 0),
new THREE.Vector3(2, 4, 0)

Here is a fiddle with what I have so far: http://jsfiddle.net/dkrotts/9d79ewff/. How can I modify this so I have a triangle with 3 equal sides?

Upvotes: 0

Views: 1020

Answers (1)

lhoworko
lhoworko

Reputation: 1191

It looks a bit tall because it is. If you want each side to be length 4, the third vertex, the top one, isn't located at (2, 4, 0), it's located at (2, 3.4641, 0), 3.4641 being root 12.

drawTriangle(
  new THREE.Vector3(0, 0, 0),
  new THREE.Vector3(4, 0, 0),
  new THREE.Vector3(2, 3.4641, 0)
);

http://jsfiddle.net/9d79ewff/2/

Upvotes: 1

Related Questions