Kaynağa Gözat

API doc more comments

jbousquie 8 yıl önce
ebeveyn
işleme
2c9c751aad

+ 48 - 11
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -134,6 +134,14 @@
 
 
         private _useFullFloat = true;
         private _useFullFloat = true;
 
 
+        /**
+         * Creates a ShadowGenerator object.  
+         * A ShadowGenerator is the required tool to use the shadows.  
+         * Each light casting shadows needs to use its own ShadowGenerator.  
+         * Required parameters : 
+         * -  `mapSize` (integer), the size of the texture what stores the shadows. Example : 1024.    
+         * - `light` : the light object generating the shadows.  
+         */
         constructor(mapSize: number, light: IShadowLight) {
         constructor(mapSize: number, light: IShadowLight) {
             this._light = light;
             this._light = light;
             this._scene = light.getScene();
             this._scene = light.getScene();
@@ -272,7 +280,9 @@
                 }
                 }
             });
             });
         }
         }
-
+        /**
+         * Boolean : true when the ShadowGenerator is finally computed.  
+         */
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
             var defines = [];
             var defines = [];
 
 
@@ -345,11 +355,15 @@
 
 
             return this._effect.isReady();
             return this._effect.isReady();
         }
         }
-
+        /**
+         * Returns a RenderTargetTexture object : the shadow map texture.  
+         */
         public getShadowMap(): RenderTargetTexture {
         public getShadowMap(): RenderTargetTexture {
             return this._shadowMap;
             return this._shadowMap;
         }
         }
-
+        /**
+         * Returns the most ready computed shadow map as a RenderTargetTexture object.  
+         */
         public getShadowMapForRendering(): RenderTargetTexture {
         public getShadowMapForRendering(): RenderTargetTexture {
             if (this._shadowMap2) {
             if (this._shadowMap2) {
                 return this._shadowMap2;
                 return this._shadowMap2;
@@ -357,12 +371,17 @@
 
 
             return this._shadowMap;
             return this._shadowMap;
         }
         }
-
+        /**
+         * Returns the associated light object.  
+         */
         public getLight(): IShadowLight {
         public getLight(): IShadowLight {
             return this._light;
             return this._light;
         }
         }
 
 
         // Methods
         // Methods
+        /**
+         * Returns a Matrix object : the updated transformation matrix.  
+         */
         public getTransformMatrix(): Matrix {
         public getTransformMatrix(): Matrix {
             var scene = this._scene;
             var scene = this._scene;
             if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
             if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
@@ -398,21 +417,32 @@
             return this._transformMatrix;
             return this._transformMatrix;
         }
         }
 
 
+        /**
+         * Returns the darkness value (float).  
+         */
         public getDarkness(): number {
         public getDarkness(): number {
             return this._darkness;
             return this._darkness;
         }
         }
-
-        public setDarkness(darkness: number): void {
+        /**
+         * Sets the ShadowGenerator darkness value (float <= 1.0).  
+         * Returns the ShadowGenerator.  
+         */
+        public setDarkness(darkness: number): ShadowGenerator {
             if (darkness >= 1.0)
             if (darkness >= 1.0)
                 this._darkness = 1.0;
                 this._darkness = 1.0;
             else if (darkness <= 0.0)
             else if (darkness <= 0.0)
                 this._darkness = 0.0;
                 this._darkness = 0.0;
             else
             else
                 this._darkness = darkness;
                 this._darkness = darkness;
+            return this;
         }
         }
-
-        public setTransparencyShadow(hasShadow: boolean): void {
+        /**
+         * Sets the ability to have transparent shadow (boolean).  
+         * Returns the ShadowGenerator.  
+         */
+        public setTransparencyShadow(hasShadow: boolean): ShadowGenerator {
             this._transparencyShadow = hasShadow;
             this._transparencyShadow = hasShadow;
+            return this;
         }
         }
 
 
         private _packHalf(depth: number): Vector2 {
         private _packHalf(depth: number): Vector2 {
@@ -421,7 +451,10 @@
 
 
             return new Vector2(depth - fract / 255.0, fract);
             return new Vector2(depth - fract / 255.0, fract);
         }
         }
-
+        /**
+         * Disposes the ShadowGenerator.  
+         * Returns nothing.  
+         */
         public dispose(): void {
         public dispose(): void {
             this._shadowMap.dispose();
             this._shadowMap.dispose();
 
 
@@ -439,7 +472,9 @@
 
 
             this._light._shadowGenerator = null;
             this._light._shadowGenerator = null;
         }
         }
-
+        /**
+         * Serializes the ShadowGenerator and returns a serializationObject.  
+         */
         public serialize(): any {
         public serialize(): any {
             var serializationObject: any = {};
             var serializationObject: any = {};
 
 
@@ -458,7 +493,9 @@
 
 
             return serializationObject;
             return serializationObject;
         }
         }
-
+        /**
+         * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.  
+         */
         public static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator {
         public static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator {
             //casting to point light, as light is missing the position attr and typescript complains.
             //casting to point light, as light is missing the position attr and typescript complains.
             var light = <PointLight>scene.getLightByID(parsedShadowGenerator.lightId);
             var light = <PointLight>scene.getLightByID(parsedShadowGenerator.lightId);

+ 48 - 20
src/Lights/babylon.directionalLight.ts

@@ -22,27 +22,42 @@
         private _orthoTop = Number.MIN_VALUE;
         private _orthoTop = Number.MIN_VALUE;
         private _orthoBottom = Number.MAX_VALUE;
         private _orthoBottom = Number.MAX_VALUE;
 
 
+        /**
+         * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).  
+         * The directional light is emitted from everywhere in the given direction.  
+         * It can cast shawdows.  
+         * Documentation : http://doc.babylonjs.com/tutorials/lights  
+         */
         constructor(name: string, direction: Vector3, scene: Scene) {
         constructor(name: string, direction: Vector3, scene: Scene) {
             super(name, scene);
             super(name, scene);
-
-            this.position = direction.scale(-1);
+            this.position = direction.scale(-1.0);
             this.direction = direction;
             this.direction = direction;
         }
         }
-
+        /**
+         * Returns the string "DirectionalLight".  
+         */
         public getClassName(): string {
         public getClassName(): string {
             return "DirectionalLight";
             return "DirectionalLight";
         }           
         }           
-
+        /**
+         * Returns the DirectionalLight absolute position in the World.  
+         */
         public getAbsolutePosition(): Vector3 {
         public getAbsolutePosition(): Vector3 {
             return this.transformedPosition ? this.transformedPosition : this.position;
             return this.transformedPosition ? this.transformedPosition : this.position;
         }
         }
-
+        /**
+         * Sets the DirectionalLight direction toward the passed target (Vector3).  
+         * Returns the updated DirectionalLight direction (Vector3).  
+         */
         public setDirectionToTarget(target: Vector3): Vector3 {
         public setDirectionToTarget(target: Vector3): Vector3 {
             this.direction = Vector3.Normalize(target.subtract(this.position));
             this.direction = Vector3.Normalize(target.subtract(this.position));
             return this.direction;
             return this.direction;
         }
         }
-
-        public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void {
+        /**
+         * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.  
+         * Returns the DirectionalLight.  
+         */
+        public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): DirectionalLight {
             var activeCamera = this.getScene().activeCamera;
             var activeCamera = this.getScene().activeCamera;
 
 
             // Check extends
             // Check extends
@@ -83,6 +98,7 @@
                             this._orthoTop = tempVector3.y;
                             this._orthoTop = tempVector3.y;
                     }
                     }
                 }
                 }
+                return this;
             }
             }
 
 
             var xOffset = this._orthoRight - this._orthoLeft;
             var xOffset = this._orthoRight - this._orthoLeft;
@@ -93,48 +109,58 @@
                 -activeCamera.maxZ, activeCamera.maxZ, matrix);
                 -activeCamera.maxZ, activeCamera.maxZ, matrix);
         }
         }
 
 
+        /**
+         * Boolean : true by default.  
+         */
         public supportsVSM(): boolean {
         public supportsVSM(): boolean {
             return true;
             return true;
         }
         }
-
+        /**
+         * Boolean : true by default.  
+         */
         public needRefreshPerFrame(): boolean {
         public needRefreshPerFrame(): boolean {
             return true;
             return true;
         }
         }
-
+        /**
+         * Boolean : false by default.  
+         */
         public needCube(): boolean {
         public needCube(): boolean {
             return false;
             return false;
         }
         }
-
+        /**
+         * Returns the light direction (Vector3) for any passed face index.    
+         */
         public getShadowDirection(faceIndex?: number): Vector3 {
         public getShadowDirection(faceIndex?: number): Vector3 {
             return this.direction;
             return this.direction;
         }
         }
-
+        /**
+         * Computes the light transformed position in case the light is parented. Returns true if parented, else false.  
+         */
         public computeTransformedPosition(): boolean {
         public computeTransformedPosition(): boolean {
             if (this.parent && this.parent.getWorldMatrix) {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this.transformedPosition) {
                 if (!this.transformedPosition) {
                     this.transformedPosition = Vector3.Zero();
                     this.transformedPosition = Vector3.Zero();
                 }
                 }
-
                 Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
                 Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
                 return true;
                 return true;
             }
             }
-
             return false;
             return false;
         }
         }
-
-        public transferToEffect(effect: Effect, directionUniformName: string): void {
+        /**
+         * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.  
+         * Returns the DirectionalLight.  
+         */
+        public transferToEffect(effect: Effect, directionUniformName: string): DirectionalLight {
             if (this.parent && this.parent.getWorldMatrix) {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this._transformedDirection) {
                 if (!this._transformedDirection) {
                     this._transformedDirection = Vector3.Zero();
                     this._transformedDirection = Vector3.Zero();
                 }
                 }
-
                 Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
                 Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
                 effect.setFloat4(directionUniformName, this._transformedDirection.x, this._transformedDirection.y, this._transformedDirection.z, 1);
                 effect.setFloat4(directionUniformName, this._transformedDirection.x, this._transformedDirection.y, this._transformedDirection.z, 1);
-
-                return;
+                return this;
             }
             }
-
             effect.setFloat4(directionUniformName, this.direction.x, this.direction.y, this.direction.z, 1);
             effect.setFloat4(directionUniformName, this.direction.x, this.direction.y, this.direction.z, 1);
+            return this;
         }
         }
 
 
         public _getWorldMatrix(): Matrix {
         public _getWorldMatrix(): Matrix {
@@ -146,7 +172,9 @@
 
 
             return this._worldMatrix;
             return this._worldMatrix;
         }
         }
-
+        /**
+         * Returns the integer 1.  
+         */
         public getTypeID(): number {
         public getTypeID(): number {
             return 1;
             return 1;
         }
         }

+ 23 - 9
src/Lights/babylon.hemisphericLight.ts

@@ -8,16 +8,26 @@
 
 
         private _worldMatrix: Matrix;
         private _worldMatrix: Matrix;
 
 
+        /**
+         * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).  
+         * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.  
+         * The HemisphericLight can't cast shadows.  
+         * Documentation : http://doc.babylonjs.com/tutorials/lights  
+         */
         constructor(name: string, direction: Vector3, scene: Scene) {
         constructor(name: string, direction: Vector3, scene: Scene) {
             super(name, scene);
             super(name, scene);
-
             this.direction = direction;
             this.direction = direction;
         }
         }
-        
+        /**
+         * Returns the string "HemisphericLight".  
+         */
         public getClassName(): string {
         public getClassName(): string {
             return "HemisphericLight";
             return "HemisphericLight";
         }          
         }          
-
+        /**
+         * Sets the HemisphericLight direction towards the passed target (Vector3).  
+         * Returns the updated direction.  
+         */
         public setDirectionToTarget(target: Vector3): Vector3 {
         public setDirectionToTarget(target: Vector3): Vector3 {
             this.direction = Vector3.Normalize(target.subtract(Vector3.Zero()));
             this.direction = Vector3.Normalize(target.subtract(Vector3.Zero()));
             return this.direction;
             return this.direction;
@@ -27,26 +37,30 @@
             return null;
             return null;
         }
         }
 
 
-        public transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void {
+        /**
+         * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).  
+         * Returns the HemisphericLight.  
+         */
+        public transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): HemisphericLight {
             var normalizeDirection = Vector3.Normalize(this.direction);
             var normalizeDirection = Vector3.Normalize(this.direction);
-
             effect.setFloat4(directionUniformName,
             effect.setFloat4(directionUniformName,
                 normalizeDirection.x,
                 normalizeDirection.x,
                 normalizeDirection.y,
                 normalizeDirection.y,
                 normalizeDirection.z,
                 normalizeDirection.z,
-                0);
-
+                0.0);
             effect.setColor3(groundColorUniformName, this.groundColor.scale(this.intensity));
             effect.setColor3(groundColorUniformName, this.groundColor.scale(this.intensity));
+            return this;
         }
         }
 
 
         public _getWorldMatrix(): Matrix {
         public _getWorldMatrix(): Matrix {
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = Matrix.Identity();
                 this._worldMatrix = Matrix.Identity();
             }
             }
-
             return this._worldMatrix;
             return this._worldMatrix;
         }
         }
-
+        /**
+         * Returns the integer 3.  
+         */
         public getTypeID(): number {
         public getTypeID(): number {
             return 3;
             return 3;
         }
         }

+ 1 - 0
src/Lights/babylon.light.ts

@@ -90,6 +90,7 @@
 
 
         /**
         /**
          * Creates a Light object in the scene.  
          * Creates a Light object in the scene.  
+         * Documentation : http://doc.babylonjs.com/tutorials/lights  
          */
          */
         constructor(name: string, scene: Scene) {
         constructor(name: string, scene: Scene) {
             super(name, scene);
             super(name, scene);

+ 57 - 19
src/Lights/babylon.pointLight.ts

@@ -6,20 +6,35 @@
         @serializeAsVector3()
         @serializeAsVector3()
         public position: Vector3;
         public position: Vector3;
 
 
+        /**
+         * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.  
+         * A PointLight emits the light in every direction.  
+         * It can cast shadows.  
+         * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
+         * ```javascript
+         * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
+         * ```
+         * Documentation : http://doc.babylonjs.com/tutorials/lights  
+         */
         constructor(name: string, position: Vector3, scene: Scene) {
         constructor(name: string, position: Vector3, scene: Scene) {
             super(name, scene);
             super(name, scene);
-
             this.position = position;
             this.position = position;
         }
         }
-
+        /**
+         * Returns the string "PointLight"
+         */
         public getClassName(): string {
         public getClassName(): string {
             return "PointLight";
             return "PointLight";
         } 
         } 
-
+        /**
+         * Returns a Vector3, the PointLight absolute position in the World.  
+         */
         public getAbsolutePosition(): Vector3 {
         public getAbsolutePosition(): Vector3 {
             return this.transformedPosition ? this.transformedPosition : this.position;
             return this.transformedPosition ? this.transformedPosition : this.position;
         }
         }
-
+        /**
+         * Computes the PointLight transformed position if parented.  Returns true if ok, false if not parented.  
+         */
         public computeTransformedPosition(): boolean {
         public computeTransformedPosition(): boolean {
             if (this.parent && this.parent.getWorldMatrix) {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this.transformedPosition) {
                 if (!this.transformedPosition) {
@@ -34,7 +49,11 @@
             return false;
             return false;
         }
         }
 
 
-        public transferToEffect(effect: Effect, positionUniformName: string): void {
+        /**
+         * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).  
+         * Returns the PointLight.  
+         */
+        public transferToEffect(effect: Effect, positionUniformName: string): PointLight {
             if (this.parent && this.parent.getWorldMatrix) {
             if (this.parent && this.parent.getWorldMatrix) {
                 this.computeTransformedPosition();
                 this.computeTransformedPosition();
 
 
@@ -42,48 +61,65 @@
                     this.transformedPosition.x,
                     this.transformedPosition.x,
                     this.transformedPosition.y,
                     this.transformedPosition.y,
                     this.transformedPosition.z,
                     this.transformedPosition.z,
-                    0); 
-
-                return;
+                    0.0); 
+                return this;
             }
             }
 
 
             effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
             effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
+            return this;
         }
         }
-
+        /**
+         * Boolean : returns true by default. 
+         */
         public needCube(): boolean {
         public needCube(): boolean {
             return true;
             return true;
         }
         }
-
+        /**
+         * Boolean : returns false by default.  
+         */
         public supportsVSM(): boolean {
         public supportsVSM(): boolean {
             return false;
             return false;
         }
         }
-
+        /**
+         * Boolean : returns false by default.  
+         */
         public needRefreshPerFrame(): boolean {
         public needRefreshPerFrame(): boolean {
             return false;
             return false;
         }
         }
 
 
+        /**
+         * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).  
+         */
         public getShadowDirection(faceIndex?: number): Vector3 {
         public getShadowDirection(faceIndex?: number): Vector3 {
             switch (faceIndex) {
             switch (faceIndex) {
                 case 0:
                 case 0:
-                    return new Vector3(1, 0, 0);
+                    return new Vector3(1.0, 0.0, 0.0);
                 case 1:
                 case 1:
-                    return new Vector3(-1, 0, 0);
+                    return new Vector3(-1.0, 0.0, 0.0);
                 case 2:
                 case 2:
-                    return new Vector3(0, -1, 0);
+                    return new Vector3(0.0, -1.0, 0.0);
                 case 3:
                 case 3:
-                    return new Vector3(0, 1, 0);
+                    return new Vector3(0.0, 1.0, 0.0);
                 case 4:
                 case 4:
-                    return new Vector3(0, 0, 1);
+                    return new Vector3(0.0, 0.0, 1.0);
                 case 5:
                 case 5:
-                    return new Vector3(0, 0, -1);
+                    return new Vector3(0.0, 0.0, -1.0);
             }
             }
 
 
             return Vector3.Zero();
             return Vector3.Zero();
         }
         }
 
 
-        public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void {
+        /**
+         * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings : 
+         * - fov = PI / 2
+         * - aspect ratio : 1.0
+         * - z-near and far equal to the active camera minZ and maxZ.  
+         * Returns the PointLight.  
+         */
+        public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): PointLight {
             var activeCamera = this.getScene().activeCamera;
             var activeCamera = this.getScene().activeCamera;
             Matrix.PerspectiveFovLHToRef(Math.PI / 2, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
             Matrix.PerspectiveFovLHToRef(Math.PI / 2, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+            return this;
         }
         }
 
 
         public _getWorldMatrix(): Matrix {
         public _getWorldMatrix(): Matrix {
@@ -95,7 +131,9 @@
 
 
             return this._worldMatrix;
             return this._worldMatrix;
         }
         }
-
+        /**
+         * Returns the integer 0.  
+         */
         public getTypeID(): number {
         public getTypeID(): number {
             return 0;
             return 0;
         }
         }

+ 53 - 20
src/Lights/babylon.spotLight.ts

@@ -17,6 +17,16 @@
         private _transformedDirection: Vector3;
         private _transformedDirection: Vector3;
         private _worldMatrix: Matrix;
         private _worldMatrix: Matrix;
 
 
+        /**
+         * Creates a SpotLight object in the scene with the passed parameters :   
+         * - `position` (Vector3) is the initial SpotLight position,  
+         * - `direction` (Vector3) is the initial SpotLight direction,  
+         * - `angle` (float, in radians) is the spot light cone angle,
+         * - `exponent` (float) is the light decay speed with the distance from the emission spot.  
+         * A spot light is a simply light oriented cone.   
+         * It can cast shadows.  
+         * Documentation : http://doc.babylonjs.com/tutorials/lights  
+         */
         constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene) {
         constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene) {
             super(name, scene);
             super(name, scene);
 
 
@@ -25,55 +35,77 @@
             this.angle = angle;
             this.angle = angle;
             this.exponent = exponent;
             this.exponent = exponent;
         }
         }
-
+        /**
+         * Returns the string "SpotLight".  
+         */
         public getClassName(): string {
         public getClassName(): string {
             return "SpotLight";
             return "SpotLight";
         }         
         }         
-
+        /**
+         * Returns the SpotLight absolute position in the World (Vector3).  
+         */
         public getAbsolutePosition(): Vector3 {
         public getAbsolutePosition(): Vector3 {
             return this.transformedPosition ? this.transformedPosition : this.position;
             return this.transformedPosition ? this.transformedPosition : this.position;
         }
         }
-
-        public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void {
+        /**
+         * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.  
+         * Returns the SpotLight.  
+         */
+        public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): SpotLight {
             var activeCamera = this.getScene().activeCamera;
             var activeCamera = this.getScene().activeCamera;
             Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
             Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+            return this;
         }
         }
-
+        /**
+         * Boolean : false by default.  
+         */
         public needCube(): boolean {
         public needCube(): boolean {
             return false;
             return false;
         }
         }
-
+        /**
+         * Boolean : true by default.  
+         */
         public supportsVSM(): boolean {
         public supportsVSM(): boolean {
             return true;
             return true;
         }
         }
-
+        /**
+         * Boolean : false by default.  
+         */
         public needRefreshPerFrame(): boolean {
         public needRefreshPerFrame(): boolean {
             return false;
             return false;
         }
         }
-
+        /**
+         * Returns the SpotLight direction (Vector3) for any passed face index.  
+         */
         public getShadowDirection(faceIndex?: number): Vector3 {
         public getShadowDirection(faceIndex?: number): Vector3 {
             return this.direction;
             return this.direction;
         }
         }
-        
+        /**
+         * Updates the SpotLight direction towards the passed target (Vector3).  
+         * Returns the updated direction.  
+         */
         public setDirectionToTarget(target: Vector3): Vector3 {
         public setDirectionToTarget(target: Vector3): Vector3 {
             this.direction = Vector3.Normalize(target.subtract(this.position));
             this.direction = Vector3.Normalize(target.subtract(this.position));
             return this.direction;
             return this.direction;
         }
         }
-
+        /**
+         * Computes the SpotLight transformed position if parented.  Returns true if parented, else false. 
+         */
         public computeTransformedPosition(): boolean {
         public computeTransformedPosition(): boolean {
             if (this.parent && this.parent.getWorldMatrix) {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this.transformedPosition) {
                 if (!this.transformedPosition) {
                     this.transformedPosition = Vector3.Zero();
                     this.transformedPosition = Vector3.Zero();
                 }
                 }
-
                 Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
                 Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
                 return true;
                 return true;
             }
             }
-
             return false;
             return false;
         }
         }
-
-        public transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void {
+        /**
+         * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.  
+         * Return the SpotLight.   
+         */
+        public transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): SpotLight {
             var normalizeDirection;
             var normalizeDirection;
 
 
             if (this.parent && this.parent.getWorldMatrix) {
             if (this.parent && this.parent.getWorldMatrix) {
@@ -107,6 +139,7 @@
                 normalizeDirection.y,
                 normalizeDirection.y,
                 normalizeDirection.z,
                 normalizeDirection.z,
                 Math.cos(this.angle * 0.5));
                 Math.cos(this.angle * 0.5));
+            return this;
         }
         }
 
 
         public _getWorldMatrix(): Matrix {
         public _getWorldMatrix(): Matrix {
@@ -118,20 +151,20 @@
 
 
             return this._worldMatrix;
             return this._worldMatrix;
         }
         }
-
+        /**
+         * Returns the integer 2.  
+         */
         public getTypeID(): number {
         public getTypeID(): number {
             return 2;
             return 2;
         }
         }
-
+        /**
+         * Returns the SpotLight rotation (Vector3).  
+         */
         public getRotation(): Vector3 {
         public getRotation(): Vector3 {
-
             this.direction.normalize();
             this.direction.normalize();
-
             var xaxis = BABYLON.Vector3.Cross(this.direction, BABYLON.Axis.Y);
             var xaxis = BABYLON.Vector3.Cross(this.direction, BABYLON.Axis.Y);
             var yaxis = BABYLON.Vector3.Cross(xaxis, this.direction);
             var yaxis = BABYLON.Vector3.Cross(xaxis, this.direction);
-
             return Vector3.RotationFromAxis(xaxis, yaxis, this.direction);
             return Vector3.RotationFromAxis(xaxis, yaxis, this.direction);
-
         }
         }
     }
     }
 }
 }

+ 40 - 12
src/Math/babylon.math.ts

@@ -3695,12 +3695,17 @@
                 ex, ey, ez, 1, result);
                 ex, ey, ez, 1, result);
         }
         }
 
 
+        /**
+         * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.  
+         */
         public static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix {
         public static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix {
             var matrix = Matrix.Zero();
             var matrix = Matrix.Zero();
             Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
             Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
             return matrix;
             return matrix;
         }
         }
-
+        /**
+         * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.  
+         */
         public static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void {
         public static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void {
             let n = znear;
             let n = znear;
             let f = zfar;
             let f = zfar;
@@ -3718,7 +3723,9 @@
                 result
                 result
             );
             );
         }
         }
-
+        /**
+         * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.  
+         */
         public static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix {
         public static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix {
             var matrix = Matrix.Zero();
             var matrix = Matrix.Zero();
 
 
@@ -3726,8 +3733,10 @@
 
 
             return matrix;
             return matrix;
         }
         }
-
-        public static OrthoOffCenterLHToRef(left: number, right, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void {
+        /**
+         * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.  
+         */
+        public static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void {
             let n = znear;
             let n = znear;
             let f = zfar;
             let f = zfar;
 
 
@@ -3746,18 +3755,24 @@
                 result
                 result
             );
             );
         }
         }
-
+        /**
+         * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.  
+         */
         public static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix {
         public static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix {
             var matrix = Matrix.Zero();
             var matrix = Matrix.Zero();
             Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
             Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
             return matrix;
             return matrix;
         }
         }
-
+        /**
+         * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.  
+         */
         public static OrthoOffCenterRHToRef(left: number, right, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void {
         public static OrthoOffCenterRHToRef(left: number, right, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void {
             Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
             Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
             result.m[10] *= -1.0;
             result.m[10] *= -1.0;
         }
         }
-
+        /**
+         * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.  
+         */
         public static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix {
         public static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix {
             var matrix = Matrix.Zero();
             var matrix = Matrix.Zero();
 
 
@@ -3779,13 +3794,17 @@
 
 
             return matrix;
             return matrix;
         }
         }
-
+        /**
+         * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.  
+         */
         public static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix {
         public static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix {
             var matrix = Matrix.Zero();
             var matrix = Matrix.Zero();
             Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
             Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
             return matrix;
             return matrix;
         }
         }
-
+        /**
+         * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.  
+         */
         public static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
         public static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
             let n = znear;
             let n = znear;
             let f = zfar;
             let f = zfar;
@@ -3804,13 +3823,17 @@
                 result
                 result
             );
             );
         }
         }
-
+        /**
+         * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.  
+         */
         public static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix {
         public static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix {
             var matrix = Matrix.Zero();
             var matrix = Matrix.Zero();
             Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
             Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
             return matrix;
             return matrix;
         }
         }
-
+        /**
+         * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.  
+         */
         public static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
         public static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
             //alternatively this could be expressed as:
             //alternatively this could be expressed as:
             //    m = PerspectiveFovLHToRef
             //    m = PerspectiveFovLHToRef
@@ -3834,7 +3857,9 @@
                 result
                 result
             );
             );
         }
         }
-
+        /**
+         * Sets the passed matrix "result" as a left-handed perspective projection matrix  for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.  
+         */
         public static PerspectiveFovWebVRToRef(fov, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
         public static PerspectiveFovWebVRToRef(fov, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
             //left handed
             //left handed
             var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
             var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
@@ -3962,6 +3987,9 @@
             result.m[15] = 1.0;
             result.m[15] = 1.0;
         }
         }
 
 
+        /**
+         * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed  left handed axis.  
+         */
         public static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, mat: Matrix) {
         public static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, mat: Matrix) {
             
             
             mat.m[0] = xaxis.x;
             mat.m[0] = xaxis.x;