Created
February 21, 2019 19:38
-
-
Save hellos3b/e1ff33e4f95134f638b5a7c91f2e135e to your computer and use it in GitHub Desktop.
This file contains 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
for (var i = 0; i < nodeCount; i++) { | |
let rng = Math.random() | |
let rx = Math.random()*width | |
let ry = Math.random()*height | |
let node = new Node({ id: i, x: rx, y: ry}) | |
while (!isValidDistance(nodeList, node) || simplexPoint(rx, ry) > rng) { | |
rx = Math.random()*width | |
ry = Math.random()*height | |
node = new Node({ id: i, x: rx, y: ry}) | |
breakCount++ | |
if (breakCount >= 500000) { | |
throw new Error("Max loop count reached, breaking early") | |
} | |
} | |
node.noise = getSimplexPoint(simplex, { width, height, x: rx, y: ry }) | |
nodeList.push(node) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment