A cool way to draw generic triangles efficiently in Javascript. This will let you create 3D objects that can be rotated or scaled. Still a bit slow, but hey, it's Javascript.
"The trick is to take advantage of the beveled edges on a div border to make right triangles. By setting the div height and width to 0px, then setting 3 borders to transparent and 1 border to an opaque color, you can make a right triangle of various sizes by adjusting the border widths.
Using some fancy geometry, you can then cut any type of triangle into a series of successively smaller right triangles. Now, in real life, the right triangles would get infinitely small (and numerous), but in the digital world, they only need to get as small as a single pixel before we don't care anymore."
Submitted by jason - 2007-07-20 08:30:17
Channels - blogcadre
hackszine
webdev
Tags - hack
javascript
3d
modeling
geometry




Please log in to post a comment