Skip to content

Instantly share code, notes, and snippets.

@hellos3b
Created February 21, 2019 19:38
Show Gist options
  • Save hellos3b/e1ff33e4f95134f638b5a7c91f2e135e to your computer and use it in GitHub Desktop.
Save hellos3b/e1ff33e4f95134f638b5a7c91f2e135e to your computer and use it in GitHub Desktop.
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