@@ -33,6 +33,8 @@ interface UnderWaterOptions extends BlockOptions {
33
33
34
34
texture ?: THREE . Texture ;
35
35
36
+ textureScale ?: number ;
37
+
36
38
}
37
39
38
40
@@ -48,6 +50,7 @@ class UnderWater extends Effect {
48
50
if ( options ) {
49
51
this . _defaultColor = options . defaultColor !== undefined ? options . defaultColor : this . _defaultColor ;
50
52
this . _texture = options . texture !== undefined ? options . texture : this . _texture ;
53
+ this . _textureScale = options . textureScale !== undefined ? options . textureScale : this . _textureScale ;
51
54
}
52
55
53
56
// Shallow copy the meshes (Geometries are not copied, we only create new Materials)
@@ -136,7 +139,7 @@ class UnderWater extends Effect {
136
139
// Fragment shader
137
140
this . useTexturingNode = new Nodes . FloatNode ( 0 ) ;
138
141
this . envTextureNode = new Nodes . TextureNode ( new THREE . Texture ( ) ) ;
139
- this . textureScaleNode = new Nodes . FloatNode ( 2 ) ;
142
+ this . textureScaleNode = new Nodes . FloatNode ( this . _textureScale ) ;
140
143
this . defaultColorNode = new Nodes . ColorNode ( this . _defaultColor ) ;
141
144
142
145
const rand2 = new Nodes . FunctionNode (
@@ -300,6 +303,11 @@ class UnderWater extends Effect {
300
303
}
301
304
}
302
305
306
+ set textureScale ( textureScale : number ) {
307
+ this . _textureScale = textureScale ;
308
+ this . textureScaleNode . value = this . _textureScale ;
309
+ }
310
+
303
311
renderEnvMap ( renderer : THREE . WebGLRenderer , lightCamera : THREE . Camera ) {
304
312
for ( const nodeMesh of this . envMappingMeshes ) {
305
313
renderer . render ( nodeMesh . mesh , lightCamera ) ;
@@ -343,6 +351,7 @@ class UnderWater extends Effect {
343
351
344
352
private _defaultColor : THREE . Color = new THREE . Color ( 0.951 , 1. , 0.825 ) ;
345
353
private _texture : THREE . Texture | null = null ;
354
+ private _textureScale : number = 2 ;
346
355
347
356
private initialized : boolean = false ;
348
357
0 commit comments