@@ -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 *
0 commit comments