File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed
Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ import {Physics} from "use-cannon"
88
99
1010export default function Terrain ( ) {
11- var pointsSize = 512 / 8 ; //256 // wielkość mapy przed skalowaniem jej ( czyli tak jakby jakość erozji)
12- var iterations = 30 ; //300 ilość iteracji erozji
11+ var pointsSize = 512 / 2 ; //256 // wielkość mapy przed skalowaniem jej ( czyli tak jakby jakość erozji)
12+ var iterations = 300 ; //300 ilość iteracji erozji
1313 var scaleMultiplier = 1 ; // wszystkie multiplier - domyślnie 1 - przedziały od 1 do powiedzmy 10 w sliderach ale w sumie 10 to przesada
1414 var erosionMultiplier = 1 ;
1515 var depositionMultiplier = 1 ;
Original file line number Diff line number Diff line change @@ -92,18 +92,30 @@ function colorVertices(vertices) {
9292 return array
9393 }
9494
95- function getMinY ( ) {
96- return Math . min ( ...getYs ( ) ) ;
95+ function getMax ( arr ) {
96+ let len = arr . length ;
97+ let max = - 2 ;
98+
99+ while ( len -- ) {
100+ max = arr [ len ] > max ? arr [ len ] : max ;
101+ }
102+ return max ;
97103 }
104+ function getMin ( arr ) {
105+ let len = arr . length ;
106+ let min = 2 ;
98107
99- function getMaxY ( ) {
100- return Math . max ( ...getYs ( ) ) ;
108+ while ( len -- ) {
109+ min = arr [ len ] < min ? arr [ len ] : min ;
110+ }
111+ return min ;
101112 }
102113
103- let colors = new Float32Array ( vertices . length ) ;
104114
105- let minHeight = getMinY ( )
106- let maxHeight = getMaxY ( )
115+ let colors = new Float32Array ( vertices . length ) ;
116+ let heightArray = getYs ( )
117+ let minHeight = getMin ( heightArray )
118+ let maxHeight = getMax ( heightArray )
107119 let heightDiff = Math . abs ( maxHeight - minHeight )
108120
109121 let waterHeight = minHeight + heightDiff * 0.2
You can’t perform that action at this time.
0 commit comments