Make my application faster

I have an application which generates 3d terrain using perlin noise. I have controls which change the way the perlin noise is generated. Every time the noise is changed the app has to loop two for cycles , for num of points y and num of points x , and has to calculate the y position and color for every vertex after that it applies the positions and colors to a bufferGeometry . All of that takes a lot of time if the num of points is high. My question is is there a way to speed up the process of doing these calculations so the app can become more interactive.

Have you tried profiling it to see what is taking time? If you could share relevant parts of your code, then that would make it easier to spot the problem.

I know what the problem is , i just don’t know the way to fix it.
The problem begins in the folowing code

for(i=0;i<numPointsY;i++) {
for(j=0;j<numPointsX;j++){
//do calculations here for positions and colors
//this part here takes a lot of time
}
}

the thing is when i have for example 500 points by Y and 500 points by X i have to loop all of them to calculate the nesecery variables

It would be helpful if you shared the code that takes a lot of time. My guess is that you are creating new objects for every position and color. Is that correct?