From 820ea7799c83fa3c76c781656c2494fe1709ab53 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 22 Sep 2020 11:12:32 +0100 Subject: [PATCH] Completed JSDocs --- src/gameobjects/layer3d/Layer3DLight.js | 146 +++++++++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-) diff --git a/src/gameobjects/layer3d/Layer3DLight.js b/src/gameobjects/layer3d/Layer3DLight.js index ea78819e1..891c53799 100644 --- a/src/gameobjects/layer3d/Layer3DLight.js +++ b/src/gameobjects/layer3d/Layer3DLight.js @@ -10,7 +10,7 @@ var Vector3 = require('../../math/Vector3'); /** * @classdesc - * A Layer3D Ambient Light. + * A Layer3D Light. * * @class Layer3DLight * @memberof Phaser.GameObjects @@ -23,15 +23,88 @@ var Layer3DLight = new Class({ function Layer3DLight (x, y, z) { + /** + * The position of the light in 3D space. + * + * You can modify this vector directly, or use the `x`, `y` and `z` + * properties of this class. + * + * @name Phaser.GameObjects.Layer3DLight#position + * @type {Phaser.Math.Vector3} + * @since 3.50.0 + */ this.position = new Vector3(x, y, z); + + /** + * The ambient color of the light. + * + * The default ambient color is 1, 1, 1. + * + * You can modify the properties of this RGB object directly, or call + * the `setAmbient` method of this class. + * + * The values in this object are used by the `uLightAmbient` shader uniform. + * + * @name Phaser.GameObjects.Layer3DLight#ambient + * @type {Phaser.Display.RGB} + * @since 3.50.0 + */ this.ambient = new RGB(1, 1, 1); + + /** + * The diffuse color of the light. + * + * The default diffuse color is 1, 1, 1. + * + * You can modify the properties of this RGB object directly, or call + * the `setDiffuse` method of this class. + * + * The values in this object are used by the `uLightDiffuse` shader uniform. + * + * @name Phaser.GameObjects.Layer3DLight#diffuse + * @type {Phaser.Display.RGB} + * @since 3.50.0 + */ this.diffuse = new RGB(1, 1, 1); + + /** + * The specular color of the light. + * + * The default specular color is 1, 1, 1. + * + * You can modify the properties of this RGB object directly, or call + * the `setSpecular` method of this class. + * + * The values in this object are used by the `uLightSpecular` shader uniform. + * + * @name Phaser.GameObjects.Layer3DLight#specular + * @type {Phaser.Display.RGB} + * @since 3.50.0 + */ this.specular = new RGB(1, 1, 1); - // cache structure = position + /** + * Internal dirty cache array. + * + * @name Phaser.GameObjects.Layer3DLight#dirtyCache + * @type {number[]} + * @private + * @since 3.50.0 + */ this.dirtyCache = [ 0, 0, 0 ]; }, + /** + * Checks if the position of this light is dirty. + * + * Called internally by the Mesh Pipeline `onBind` method and if dirty + * is used to set the `uLightPosition` uniform. + * + * @method Phaser.GameObjects.Layer3DLight#isDirty + * @since 3.50.0 + * + * @return {boolean} `true` if this light is dirty, otherwise `false`. + */ isDirty: function () { var position = this.position; @@ -52,6 +125,18 @@ var Layer3DLight = new Class({ return (xCached !== x || yCached !== y || zCached !== z); }, + /** + * Sets the position of this light. + * + * @method Phaser.GameObjects.Layer3DLight#setPosition + * @since 3.50.0 + * + * @param {number} x - The x position of this light. + * @param {number} y - The y position of this light. + * @param {number} z - The z position of this light. + * + * @return {this} This Layer3DLight instance. + */ setPosition: function (x, y, z) { this.position.set(x, y, z); @@ -59,6 +144,18 @@ var Layer3DLight = new Class({ return this; }, + /** + * Sets the ambient color of this light. + * + * @method Phaser.GameObjects.Layer3DLight#setAmbient + * @since 3.50.0 + * + * @param {number} r - The red color value. Between 0 and 1. + * @param {number} g - The green color value. Between 0 and 1. + * @param {number} b - The blue color value. Between 0 and 1. + * + * @return {this} This Layer3DLight instance. + */ setAmbient: function (r, g, b) { this.ambient.set(r, g, b); @@ -66,6 +163,18 @@ var Layer3DLight = new Class({ return this; }, + /** + * Sets the diffuse color of this light. + * + * @method Phaser.GameObjects.Layer3DLight#setDiffuse + * @since 3.50.0 + * + * @param {number} r - The red color value. Between 0 and 1. + * @param {number} g - The green color value. Between 0 and 1. + * @param {number} b - The blue color value. Between 0 and 1. + * + * @return {this} This Layer3DLight instance. + */ setDiffuse: function (r, g, b) { this.diffuse.set(r, g, b); @@ -73,6 +182,18 @@ var Layer3DLight = new Class({ return this; }, + /** + * Sets the specular color of this light. + * + * @method Phaser.GameObjects.Layer3DLight#setSpecular + * @since 3.50.0 + * + * @param {number} r - The red color value. Between 0 and 1. + * @param {number} g - The green color value. Between 0 and 1. + * @param {number} b - The blue color value. Between 0 and 1. + * + * @return {this} This Layer3DLight instance. + */ setSpecular: function (r, g, b) { this.specular.set(r, g, b); @@ -80,6 +201,13 @@ var Layer3DLight = new Class({ return this; }, + /** + * The x position of the light. + * + * @name Phaser.GameObjects.Layer3DLight#x + * @type {number} + * @since 3.50.0 + */ x: { get: function () @@ -94,6 +222,13 @@ var Layer3DLight = new Class({ }, + /** + * The y position of the light. + * + * @name Phaser.GameObjects.Layer3DLight#y + * @type {number} + * @since 3.50.0 + */ y: { get: function () @@ -108,6 +243,13 @@ var Layer3DLight = new Class({ }, + /** + * The z position of the light. + * + * @name Phaser.GameObjects.Layer3DLight#z + * @type {number} + * @since 3.50.0 + */ z: { get: function ()