Quicker Algorithm

Started by
2 comments, last by Awoken 6 years, 12 months ago

[attachment=35686:Screenshot from 2017-04-21 20-46-12.png]

I can't believe my lucky stars, I never thought I'd see the day, but believe it or not I wrote a function that is faster than what is shipped with THREE.js.

I suppose I shouldn't celebrate too much, but this is a big achievement for me. The function is THREE.IcosahedronGeometry() with a radius of 1 and detail level of 7. The resulting shape is 327680 faces, a big big ball. The code packed with THREE.js r85 takes longer than 5000 milliseconds. My alg(s) take just over 1700. Then to boot, THREE.js r85 breaks in my chrome browser trying to churn out a shape of detail 8, which is 1310720 faces, after 2 minutes of trying. My alg(s) pump one out in just over 6300 milliseconds. :cool: Haha, I feel so proud and corny!

Advertisement

What techniques did you use to make it faster?

You should submit it as a pull request to three.js. They are happy to have contributors.

phil_t I mentioned the basic idea behind the approach in my blog, scroll down to where you see an Icosahedron.

https://www.gamedev.net/blog/1989/entry-2262494-weekly-update-1/

rkwright, I thought about that, but it's convoluted and bulky, it eats up enormous memory upon generation and then at the very end ditches all the memory it no longer needs and spits out a shape. The THREE.js function is rather simple and clean and takes up few lines of code whereas mine does not. Another thing, I believe the three.js function assigns UV values for all the faces, this could contribute to a slow down. I normalize the faces.

[edit: just tested it while computing vertex normals as well, that added 700 milliseconds. ]

This topic is closed to new replies.

Advertisement