1
- import { lerp2 } from "deepslate" ;
1
+ import { lerp2 , TerrainShaper } from "deepslate" ;
2
2
import * as L from "leaflet" ;
3
3
import { BiomeBuilder } from "../BuilderData/BiomeBuilder" ;
4
4
import { LayoutElementUnassigned } from "../BuilderData/LayoutElementUnassigned" ;
5
5
import { BiomeLayer } from "../Visualization/BiomeLayer" ;
6
+ import { ContourLayer } from "../Visualization/ContourLayer" ;
6
7
import { GridMultiNoise } from "../Visualization/GridMultiNoise" ;
7
8
import { GridMultiNoiseIndicesManager } from "../Visualization/GridMultiNoiseIndicesManager" ;
8
9
import { MenuManager } from "./MenuManager" ;
@@ -83,9 +84,12 @@ export class VisualizationManger{
83
84
private map : L . Map
84
85
private biomeSource : GridMultiNoise
85
86
private biomeLayer : BiomeLayer
87
+ private contourLayer : ContourLayer
88
+
86
89
private indicesManger : GridMultiNoiseIndicesManager
87
90
88
91
private closeContainer : HTMLElement
92
+ private toggleIsolinesButton : HTMLElement
89
93
90
94
constructor ( builder : BiomeBuilder ) {
91
95
this . builder = builder
@@ -95,6 +99,7 @@ export class VisualizationManger{
95
99
this . biomeLayer . redraw ( )
96
100
}
97
101
102
+
98
103
this . biomeSource = new GridMultiNoise ( BigInt ( "0" ) , builder , noises . temperature , noises . humidity , noises . continentalness , noises . erosion , noises . weirdness , noises . shift )
99
104
100
105
this . map = L . map ( 'visualization_map' )
@@ -107,6 +112,22 @@ export class VisualizationManger{
107
112
this . biomeLayer = new BiomeLayer ( this . builder , this . indicesManger ) ;
108
113
this . biomeLayer . addTo ( this . map )
109
114
115
+ this . contourLayer = new ContourLayer ( this . builder , this . indicesManger ) ;
116
+ this . contourLayer . addTo ( this . map )
117
+
118
+ this . toggleIsolinesButton = document . getElementById ( 'toggleIsolinesButton' )
119
+
120
+ this . toggleIsolinesButton . onclick = ( evt : MouseEvent ) => {
121
+ if ( this . map . hasLayer ( this . contourLayer ) ) {
122
+ this . map . removeLayer ( this . contourLayer )
123
+ this . toggleIsolinesButton . classList . remove ( "enabled" )
124
+ } else {
125
+ this . map . addLayer ( this . contourLayer )
126
+ this . toggleIsolinesButton . classList . add ( "enabled" )
127
+ }
128
+ }
129
+
130
+
110
131
const tooltip = document . getElementById ( "visualizationTooltip" )
111
132
const tooltip_position = tooltip . getElementsByClassName ( "position" ) [ 0 ] as HTMLElement
112
133
const tooltip_slice = tooltip . getElementsByClassName ( "slice" ) [ 0 ] as HTMLElement
@@ -143,7 +164,8 @@ export class VisualizationManger{
143
164
tooltip_mode . src = "mode_" + lookup ?. mode + ".png"
144
165
145
166
const pos = this . getPos ( evt . latlng ) ;
146
- tooltip_position . innerHTML = "X: " + pos . x . toFixed ( 0 ) + ", Z: " + pos . y . toFixed ( 0 )
167
+ const y = ( TerrainShaper . offset ( TerrainShaper . point ( idxs . values . continentalness , idxs . values . erosion , idxs . values . weirdness ) ) * 128 + 64 ) . toFixed ( 0 )
168
+ tooltip_position . innerHTML = "X: " + pos . x . toFixed ( 0 ) + ", Z: " + pos . y . toFixed ( 0 ) + " -> Y: " + y
147
169
tooltip_slice . innerHTML = "↵ " + lookup ?. slice ?. name + " (Slice)"
148
170
tooltip_layout . innerHTML = "↵ " + lookup ?. layout ?. name + " (Layout)"
149
171
tooltip_biome . innerHTML = lookup ?. biome ?. name
@@ -198,7 +220,9 @@ export class VisualizationManger{
198
220
}
199
221
200
222
async refresh ( ) {
201
- if ( ! this . closeContainer . classList . contains ( "closed" ) )
223
+ if ( ! this . closeContainer . classList . contains ( "closed" ) ) {
202
224
this . biomeLayer . redraw ( )
225
+ //this.contourLayer.redraw()
226
+ }
203
227
}
204
228
}
0 commit comments