Skip to content

Commit

Permalink
Merge pull request supermedium#70 from MakingSpiderSense/master
Browse files Browse the repository at this point in the history
Fix ground types 'hills' & 'canyon' not using seed
  • Loading branch information
dmarcos authored Oct 8, 2021
2 parents d886909 + 869870c commit 092e768
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ AFRAME.registerComponent('environment', {
if (!this.groundGeometry) {
this.groundGeometry = new THREE.PlaneGeometry(this.STAGE_SIZE + 2, this.STAGE_SIZE + 2, resolution - 1, resolution - 1);
}
var perlin = new PerlinNoise();
var perlin = new PerlinNoise(this.environmentData.seed);
var verts = this.groundGeometry.attributes.position.array;
var numVerts = verts.length;
var frequency = 10;
Expand Down Expand Up @@ -1205,13 +1205,14 @@ AFRAME.registerShader('gradientshader', {
// perlin noise generator
// from https://gist.github.com/banksean/304522

var PerlinNoise = function(r) {
if (r == undefined) r = Math;
var PerlinNoise = function(seed) {
var randomWithSeed;
this.grad3 = [[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]];
this.p = [];
var i;
for (i=0; i<256; i++) {
this.p[i] = Math.floor(r.random(666)*256);
randomWithSeed = parseFloat('0.' + Math.sin(seed * 9999 * i).toString().substr(7));
this.p[i] = Math.floor(randomWithSeed * 256);
}
// To remove the need for index wrapping, double the permutation table length
this.perm = [];
Expand Down

0 comments on commit 092e768

Please sign in to comment.