77 EndorheicSeaBasin ,
88 EndorheicLakeBasin ,
99 ExorheicRiverBasin ,
10- OceanicBasin ,
1110 Basin ,
1211 EMPTY ,
1312} from './data'
@@ -47,19 +46,19 @@ class BasinGridFill extends ConcurrentFill {
4746 const { typeMap} = fill . context
4847 const survey = surveyNeighbors ( fill . context , neighbors , fillPoint )
4948 // set type on init
50- const type = buildBasinType ( fillPoint , { ... fill . context , survey} )
49+ const type = buildBasinType ( fill . context . layers , survey )
5150 typeMap . set ( fill . id , type . id )
5251 // the basin opposite border is the parentPoint
5352 // update erosion path
5453 this . _fillBasin ( fill , fillPoint , survey . oppositeBorder )
5554 }
5655
5756 getChance ( fill ) { return FILL_CHANCE }
57+
5858 getGrowth ( fill ) {
5959 const { typeMap} = fill . context
6060 const basin = Basin . parse ( typeMap . get ( fill . id ) )
61- if ( basin . isEndorheic ) return 1
62- return FILL_GROWTH
61+ return basin . isEndorheic ? 1 : FILL_GROWTH
6362 }
6463
6564 getSkip ( fill ) {
@@ -127,10 +126,8 @@ function surveyNeighbors(context, neighbors, point) {
127126}
128127
129128
130- function buildBasinType ( point , context ) {
131- const { layers, survey} = context
132- const isLand = layers . surface . isLand ( point )
133- let type = isLand ? ExorheicRiverBasin : OceanicBasin
129+ function buildBasinType ( layers , survey ) {
130+ let type = ExorheicRiverBasin
134131 if ( layers . surface . isLake ( survey . oppositeBorder ) ) {
135132 type = EndorheicLakeBasin
136133 }
@@ -141,12 +138,10 @@ function buildBasinType(point, context) {
141138}
142139
143140
144- function buildMidpoint ( direction ) {
145- // direction axis ([-1, 0], [1, 1], etc)
146- const rand = ( coordAxis ) => {
141+ function buildMidpoint ( ) {
142+ const rand = ( ) => {
147143 const offset = Random . int ( ...ZONE_OFFSET_RANGE )
148- const axisToggle = coordAxis === 0 ? Random . choice ( - 1 , 1 ) : coordAxis
149- return ZONE_MIDDLE + ( offset * axisToggle )
144+ return ZONE_MIDDLE + ( offset * Random . choice ( - 1 , 1 ) )
150145 }
151- return direction . axis . map ( coord => rand ( coord ) )
146+ return [ rand ( ) , rand ( ) ]
152147}
0 commit comments