简体   繁体   中英

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?

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/

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM