Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Perlin Noise Negative Coordinates
noise: function (x, y, z) {
// Find unit cube that contains point
var xFloor = ~~x;
var yFloor = ~~y;
var zFloor = ~~z;
var iX = xFloor & 255;
var iY = yFloor & 255;
var iZ = zFloor & 255;
...
noise: function (x, y, z) {
// Find unit cube that contains point
var xFloor = ~~x;
var yFloor = ~~y;
var zFloor = ~~z;
var iX = xFloor & 255;
var iY = yFloor & 255;
var iZ = zFloor & 255;
// Find relative x, y, z of the point in the cube.
x -= xFloor;
y -= yFloor;
z -= zFloor;
if (x < 0) { x += 1; iX = (iX + 255) & 255; }
if (y < 0) { y += 1; iY = (iY + 255) & 255; }
if (z < 0) { z += 1; iZ = (iZ + 255) & 255; }
@stephen-uac

This comment has been minimized.

Copy link

commented Feb 14, 2013

Is there a full version of this script in Javascript available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.