Skip to content

Commit 92b1844

Browse files
authored
Merge pull request #30 from martinRenou/texture_scale
UnderWater: Expose texture scale option
2 parents d271b3a + e11d815 commit 92b1844

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Effects/Water/UnderWater.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ interface UnderWaterOptions extends BlockOptions {
3333

3434
texture?: THREE.Texture;
3535

36+
textureScale?: number;
37+
3638
}
3739

3840

@@ -48,6 +50,7 @@ class UnderWater extends Effect {
4850
if (options) {
4951
this._defaultColor = options.defaultColor !== undefined ? options.defaultColor : this._defaultColor;
5052
this._texture = options.texture !== undefined ? options.texture : this._texture;
53+
this._textureScale = options.textureScale !== undefined ? options.textureScale : this._textureScale;
5154
}
5255

5356
// Shallow copy the meshes (Geometries are not copied, we only create new Materials)
@@ -136,7 +139,7 @@ class UnderWater extends Effect {
136139
// Fragment shader
137140
this.useTexturingNode = new Nodes.FloatNode(0);
138141
this.envTextureNode = new Nodes.TextureNode(new THREE.Texture());
139-
this.textureScaleNode = new Nodes.FloatNode(2);
142+
this.textureScaleNode = new Nodes.FloatNode(this._textureScale);
140143
this.defaultColorNode = new Nodes.ColorNode(this._defaultColor);
141144

142145
const rand2 = new Nodes.FunctionNode(
@@ -300,6 +303,11 @@ class UnderWater extends Effect {
300303
}
301304
}
302305

306+
set textureScale (textureScale: number) {
307+
this._textureScale = textureScale;
308+
this.textureScaleNode.value = this._textureScale;
309+
}
310+
303311
renderEnvMap (renderer: THREE.WebGLRenderer, lightCamera: THREE.Camera) {
304312
for (const nodeMesh of this.envMappingMeshes) {
305313
renderer.render(nodeMesh.mesh, lightCamera);
@@ -343,6 +351,7 @@ class UnderWater extends Effect {
343351

344352
private _defaultColor: THREE.Color = new THREE.Color(0.951, 1., 0.825);
345353
private _texture: THREE.Texture | null = null;
354+
private _textureScale: number = 2;
346355

347356
private initialized: boolean = false;
348357

0 commit comments

Comments
 (0)