Jump to content

[THREEJS] scrolling 2d/3d noise terrain


Stanleys_Stoop
 Share

Recommended Posts

Hi everyone. I've been toying around with using perlin and simplex noise to generate height values for a terrain mesh with threejs.

My aim is to create something visually similar to Populous.

pop2new.png

 

 

So far I have something that looks like this.
terrain.png
 

At the moment I have custom plane mesh subdivided horizontally and vertically by 10. Each of the mesh's vertices y value is determined by using a noise function. This all works fine enough it seems, though I am running into issues when trying to implement a scrolling effect, again similar to Populous.

First I declare and init some variables.

//globalvar mesh_width = 10, mesh_height = 10;var tile_width = 1;var xpos = 0, zpos = 0;var x = xpos, z = zpos;//initialize terrain data arrayvar terrain_data = new Array(mesh_height);for(var i = 0; i < terrain_data.length; i++){    terrain_data[i] = new Array(mesh_width);}noise.seed(Math.random());

I then define the terrain_data object using the noise functions.
 

for(var j = 0; j < 10; j++){    for(var i = 0; i < 10; i++){                        var value = noise.simplex3(x, z, 0);        value *= quality;        //console.log(Math.abs(noise.simplex2(x, z)));        terrain[i][j] = Math.abs(value);        x += 1;    }z += 1;}

EDIT: This was a mis-post. I'm sorry. It can be deleted.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...