Skip to content

Commit 091ef6f

Browse files
committed
Add a way to set optional values later
1 parent edaf085 commit 091ef6f

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

src/effects/GodRaysEffect.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class GodRaysEffect extends Effect {
3131
/**
3232
* Constructs a new god rays effect.
3333
*
34-
* @param {Camera} camera - The main camera.
35-
* @param {Mesh|Points} lightSource - The light source. Must not write depth and has to be flagged as transparent.
34+
* @param {Camera} [camera] - The main camera.
35+
* @param {Mesh|Points} [lightSource] - The light source. Must not write depth and has to be flagged as transparent.
3636
* @param {Object} [options] - The options.
3737
* @param {BlendFunction} [options.blendFunction=BlendFunction.SCREEN] - The blend function of this effect.
3838
* @param {Number} [options.samples=60.0] - The number of samples per pixel.
@@ -91,9 +91,8 @@ export class GodRaysEffect extends Effect {
9191
* @private
9292
*/
9393

94+
this._lightSource = lightSource;
9495
this.lightSource = lightSource;
95-
this.lightSource.material.depthWrite = false;
96-
this.lightSource.material.transparent = true;
9796

9897
/**
9998
* A scene for the light source.
@@ -225,6 +224,31 @@ export class GodRaysEffect extends Effect {
225224

226225
}
227226

227+
/**
228+
* Sets the light source.
229+
*
230+
* @type {Mesh|Points}
231+
*/
232+
233+
get lightSource() {
234+
235+
return this._lightSource;
236+
237+
}
238+
239+
set lightSource(value) {
240+
241+
this._lightSource = value;
242+
243+
if(value !== null) {
244+
245+
value.material.depthWrite = false;
246+
value.material.transparent = true;
247+
248+
}
249+
250+
}
251+
228252
/**
229253
* Returns the blur pass that reduces aliasing artifacts and makes the light softer.
230254
*

src/effects/SSAOEffect.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class SSAOEffect extends Effect {
2828
* Constructs a new SSAO effect.
2929
*
3030
* @todo Move normalBuffer to options.
31-
* @param {Camera} camera - The main camera.
32-
* @param {Texture} normalBuffer - A texture that contains the scene normals.
31+
* @param {Camera} [camera] - The main camera.
32+
* @param {Texture} [normalBuffer] - A texture that contains the scene normals.
3333
* @param {Object} [options] - The options.
3434
* @param {BlendFunction} [options.blendFunction=BlendFunction.MULTIPLY] - The blend function of this effect.
3535
* @param {Boolean} [options.distanceScaling=true] - Deprecated.
@@ -212,6 +212,25 @@ export class SSAOEffect extends Effect {
212212

213213
}
214214

215+
/**
216+
* Sets the normal buffer.
217+
*
218+
* @type {Texture}
219+
*/
220+
221+
get normalBuffer() {
222+
223+
return this.ssaoMaterial.normalBuffer;
224+
225+
}
226+
227+
set normalBuffer(value) {
228+
229+
this.ssaoMaterial.normalBuffer = value;
230+
this.depthDownsamplingPass.fullscreenMaterial.normalBuffer = value;
231+
232+
}
233+
215234
/**
216235
* Returns the resolution settings.
217236
*

0 commit comments

Comments
 (0)