Skip to content

Commit 820ea77

Browse files
committed
Completed JSDocs
1 parent 248d235 commit 820ea77

1 file changed

Lines changed: 144 additions & 2 deletions

File tree

src/gameobjects/layer3d/Layer3DLight.js

Lines changed: 144 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var Vector3 = require('../../math/Vector3');
1010

1111
/**
1212
* @classdesc
13-
* A Layer3D Ambient Light.
13+
* A Layer3D Light.
1414
*
1515
* @class Layer3DLight
1616
* @memberof Phaser.GameObjects
@@ -23,15 +23,88 @@ var Layer3DLight = new Class({
2323

2424
function Layer3DLight (x, y, z)
2525
{
26+
/**
27+
* The position of the light in 3D space.
28+
*
29+
* You can modify this vector directly, or use the `x`, `y` and `z`
30+
* properties of this class.
31+
*
32+
* @name Phaser.GameObjects.Layer3DLight#position
33+
* @type {Phaser.Math.Vector3}
34+
* @since 3.50.0
35+
*/
2636
this.position = new Vector3(x, y, z);
37+
38+
/**
39+
* The ambient color of the light.
40+
*
41+
* The default ambient color is 1, 1, 1.
42+
*
43+
* You can modify the properties of this RGB object directly, or call
44+
* the `setAmbient` method of this class.
45+
*
46+
* The values in this object are used by the `uLightAmbient` shader uniform.
47+
*
48+
* @name Phaser.GameObjects.Layer3DLight#ambient
49+
* @type {Phaser.Display.RGB}
50+
* @since 3.50.0
51+
*/
2752
this.ambient = new RGB(1, 1, 1);
53+
54+
/**
55+
* The diffuse color of the light.
56+
*
57+
* The default diffuse color is 1, 1, 1.
58+
*
59+
* You can modify the properties of this RGB object directly, or call
60+
* the `setDiffuse` method of this class.
61+
*
62+
* The values in this object are used by the `uLightDiffuse` shader uniform.
63+
*
64+
* @name Phaser.GameObjects.Layer3DLight#diffuse
65+
* @type {Phaser.Display.RGB}
66+
* @since 3.50.0
67+
*/
2868
this.diffuse = new RGB(1, 1, 1);
69+
70+
/**
71+
* The specular color of the light.
72+
*
73+
* The default specular color is 1, 1, 1.
74+
*
75+
* You can modify the properties of this RGB object directly, or call
76+
* the `setSpecular` method of this class.
77+
*
78+
* The values in this object are used by the `uLightSpecular` shader uniform.
79+
*
80+
* @name Phaser.GameObjects.Layer3DLight#specular
81+
* @type {Phaser.Display.RGB}
82+
* @since 3.50.0
83+
*/
2984
this.specular = new RGB(1, 1, 1);
3085

31-
// cache structure = position
86+
/**
87+
* Internal dirty cache array.
88+
*
89+
* @name Phaser.GameObjects.Layer3DLight#dirtyCache
90+
* @type {number[]}
91+
* @private
92+
* @since 3.50.0
93+
*/
3294
this.dirtyCache = [ 0, 0, 0 ];
3395
},
3496

97+
/**
98+
* Checks if the position of this light is dirty.
99+
*
100+
* Called internally by the Mesh Pipeline `onBind` method and if dirty
101+
* is used to set the `uLightPosition` uniform.
102+
*
103+
* @method Phaser.GameObjects.Layer3DLight#isDirty
104+
* @since 3.50.0
105+
*
106+
* @return {boolean} `true` if this light is dirty, otherwise `false`.
107+
*/
35108
isDirty: function ()
36109
{
37110
var position = this.position;
@@ -52,34 +125,89 @@ var Layer3DLight = new Class({
52125
return (xCached !== x || yCached !== y || zCached !== z);
53126
},
54127

128+
/**
129+
* Sets the position of this light.
130+
*
131+
* @method Phaser.GameObjects.Layer3DLight#setPosition
132+
* @since 3.50.0
133+
*
134+
* @param {number} x - The x position of this light.
135+
* @param {number} y - The y position of this light.
136+
* @param {number} z - The z position of this light.
137+
*
138+
* @return {this} This Layer3DLight instance.
139+
*/
55140
setPosition: function (x, y, z)
56141
{
57142
this.position.set(x, y, z);
58143

59144
return this;
60145
},
61146

147+
/**
148+
* Sets the ambient color of this light.
149+
*
150+
* @method Phaser.GameObjects.Layer3DLight#setAmbient
151+
* @since 3.50.0
152+
*
153+
* @param {number} r - The red color value. Between 0 and 1.
154+
* @param {number} g - The green color value. Between 0 and 1.
155+
* @param {number} b - The blue color value. Between 0 and 1.
156+
*
157+
* @return {this} This Layer3DLight instance.
158+
*/
62159
setAmbient: function (r, g, b)
63160
{
64161
this.ambient.set(r, g, b);
65162

66163
return this;
67164
},
68165

166+
/**
167+
* Sets the diffuse color of this light.
168+
*
169+
* @method Phaser.GameObjects.Layer3DLight#setDiffuse
170+
* @since 3.50.0
171+
*
172+
* @param {number} r - The red color value. Between 0 and 1.
173+
* @param {number} g - The green color value. Between 0 and 1.
174+
* @param {number} b - The blue color value. Between 0 and 1.
175+
*
176+
* @return {this} This Layer3DLight instance.
177+
*/
69178
setDiffuse: function (r, g, b)
70179
{
71180
this.diffuse.set(r, g, b);
72181

73182
return this;
74183
},
75184

185+
/**
186+
* Sets the specular color of this light.
187+
*
188+
* @method Phaser.GameObjects.Layer3DLight#setSpecular
189+
* @since 3.50.0
190+
*
191+
* @param {number} r - The red color value. Between 0 and 1.
192+
* @param {number} g - The green color value. Between 0 and 1.
193+
* @param {number} b - The blue color value. Between 0 and 1.
194+
*
195+
* @return {this} This Layer3DLight instance.
196+
*/
76197
setSpecular: function (r, g, b)
77198
{
78199
this.specular.set(r, g, b);
79200

80201
return this;
81202
},
82203

204+
/**
205+
* The x position of the light.
206+
*
207+
* @name Phaser.GameObjects.Layer3DLight#x
208+
* @type {number}
209+
* @since 3.50.0
210+
*/
83211
x: {
84212

85213
get: function ()
@@ -94,6 +222,13 @@ var Layer3DLight = new Class({
94222

95223
},
96224

225+
/**
226+
* The y position of the light.
227+
*
228+
* @name Phaser.GameObjects.Layer3DLight#y
229+
* @type {number}
230+
* @since 3.50.0
231+
*/
97232
y: {
98233

99234
get: function ()
@@ -108,6 +243,13 @@ var Layer3DLight = new Class({
108243

109244
},
110245

246+
/**
247+
* The z position of the light.
248+
*
249+
* @name Phaser.GameObjects.Layer3DLight#z
250+
* @type {number}
251+
* @since 3.50.0
252+
*/
111253
z: {
112254

113255
get: function ()

0 commit comments

Comments
 (0)