Last active
February 6, 2019 10:57
-
-
Save Mamboleoo/c35cd80fba3fb8cbe60fe80c132dd9ee to your computer and use it in GitHub Desktop.
Sort particles [2D-3D]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render(a) { | |
... | |
// Loop through the dots array and project every dot | |
for (let i = 0; i < dots.length; i++) { | |
dots[i].project(); | |
} | |
// Sort dots array based on their projected size | |
dots.sort((dot1, dot2) => { | |
return dot1.sizeProjection - dot2.sizeProjection; | |
}); | |
// Loop through the dots array and draw every dot | |
for (let i = 0; i < dots.length; i++) { | |
dots[i].draw(); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment