Skip to content

Commit

Permalink
Better pseudorandom numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Nov 7, 2019
1 parent eb4a332 commit 6048cc8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/utils/index.js
@@ -1,7 +1,14 @@
// Create a deterministic pseudorandom number generator
export function getRandom() {
let i = 0;
let s = 1;
let c = 1;
return () => {
return Math.abs(Math.sin(i++ * 17.23) * Math.cos(i++ * 27.92));
s = Math.sin(c * 17.23);
c = Math.cos(s * 27.92);
return fract(Math.abs(s * c) * 1432.71);
};
}

function fract(n) {
return n - Math.floor(n);
}
Binary file modified test/render/golden-images/instancing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/render/golden-images/persistence.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/render/golden-images/transform.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6048cc8

Please sign in to comment.