瀏覽代碼

Merge pull request #5208 from sebavan/master

Doc
sebavan 7 年之前
父節點
當前提交
1751100ac5

+ 7 - 4
loaders/src/glTF/1.0/babylon.glTFLoader.ts

@@ -1416,9 +1416,9 @@ module BABYLON.GLTF1 {
             var pixelTokenizer = new Tokenizer(pixelShader);
 
             var unTreatedUniforms: { [key: string]: IGLTFTechniqueParameter } = {};
-            var uniforms = [];
-            var attributes = [];
-            var samplers = [];
+            var uniforms: string[] = [];
+            var attributes: string[] = [];
+            var samplers: string[] = [];
 
             // Fill uniform, sampler2D and attributes
             for (var unif in technique.uniforms) {
@@ -1450,7 +1450,10 @@ module BABYLON.GLTF1 {
                 var attributeParameter: IGLTFTechniqueParameter = technique.parameters[attribute];
 
                 if (attributeParameter.semantic) {
-                    attributes.push(getAttribute(attributeParameter));
+                    let name = getAttribute(attributeParameter);
+                    if (name) {
+                        attributes.push(name);
+                    }
                 }
             }
 

+ 1 - 1
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -286,7 +286,7 @@
         protected _roughness: Nullable<number>;
 
         /**
-         * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
+         * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
          * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
          */
         protected _microSurfaceTexture: BaseTexture;

+ 6 - 0
src/Materials/PBR/babylon.pbrBaseSimpleMaterial.ts

@@ -103,10 +103,16 @@
             this._markAllSubMeshesAsTexturesDirty();
         }
 
+        /**
+         * Stores the pre-calculated light information of a mesh in a texture.
+         */
         @serializeAsTexture()
         @expandToProperty("_markAllSubMeshesAsTexturesDirty", null)
         public lightmapTexture: BaseTexture;
 
+        /**
+         * If true, the light map contains occlusion information instead of lighting info.
+         */
         @serialize()
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useLightmapAsShadowmap = false;

+ 5 - 2
src/Materials/PBR/babylon.pbrMaterial.ts

@@ -155,7 +155,7 @@
         public roughness: Nullable<number>;
 
         /**
-         * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
+         * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
          * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
          */
         @serializeAsTexture()
@@ -247,6 +247,9 @@
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public linkRefractionWithTransparency = false;
 
+        /**
+         * If true, the light map contains occlusion information instead of lighting info.
+         */
         @serialize()
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useLightmapAsShadowmap = false;
@@ -273,7 +276,7 @@
         public alphaCutOff = 0.4;
 
         /**
-         * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
+         * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
          * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
          */
         @serialize()

+ 35 - 0
src/Materials/babylon.fresnelParameters.ts

@@ -1,6 +1,13 @@
 module BABYLON {
+    /**
+     * This represents all the required information to add a fresnel effect on a material:
+     * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+     */
     export class FresnelParameters {
         private _isEnabled = true;
+        /**
+         * Define if the fresnel effect is enable or not.
+         */
         public get isEnabled(): boolean {
             return this._isEnabled;
         }
@@ -13,11 +20,30 @@
             Engine.MarkAllMaterialsAsDirty(Material.FresnelDirtyFlag | Material.MiscDirtyFlag);
         }   
 
+        /**
+         * Define the color used on edges (grazing angle)
+         */
         public leftColor = Color3.White();
+
+        /**
+         * Define the color used on center
+         */
         public rightColor = Color3.Black();
+
+        /**
+         * Define bias applied to computed fresnel term
+         */
         public bias = 0;
+
+        /**
+         * Defined the power exponent applied to fresnel term
+         */
         public power = 1;
 
+        /**
+         * Clones the current fresnel and its valuues
+         * @returns a clone fresnel configuration
+         */
         public clone(): FresnelParameters {
             var newFresnelParameters = new FresnelParameters();
 
@@ -26,6 +52,10 @@
             return newFresnelParameters;
         }
 
+        /**
+         * Serializes the current fresnel parameters to a JSON representation.
+         * @return the JSON serialization
+         */
         public serialize(): any {
             var serializationObject: any = {};
 
@@ -38,6 +68,11 @@
             return serializationObject;
         }
 
+        /**
+         * Parse a JSON object and deserialize it to a new Fresnel parameter object.
+         * @param parsedFresnelParameters Define the JSON representation
+         * @returns the parsed parameters
+         */
         public static Parse(parsedFresnelParameters: any): FresnelParameters {
             var fresnelParameters = new FresnelParameters();
 

+ 9 - 2
src/Materials/babylon.imageProcessingConfiguration.ts

@@ -366,13 +366,17 @@ module BABYLON {
             this.onUpdateParameters.notifyObservers(this);
         }
 
+        /**
+         * Gets the current class name.
+         * @return "ImageProcessingConfiguration"
+         */
         public getClassName(): string {
             return "ImageProcessingConfiguration";
         }
 
         /**
          * Prepare the list of uniforms associated with the Image Processing effects.
-         * @param uniformsList The list of uniforms used in the effect
+         * @param uniforms The list of uniforms used in the effect
          * @param defines the list of defines currently in use
          */
         public static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void {
@@ -397,7 +401,7 @@ module BABYLON {
 
         /**
          * Prepare the list of samplers associated with the Image Processing effects.
-         * @param uniformsList The list of uniforms used in the effect
+         * @param samplersList The list of uniforms used in the effect
          * @param defines the list of defines currently in use
          */
         public static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void {
@@ -409,6 +413,7 @@ module BABYLON {
         /**
          * Prepare the list of defines associated to the shader.
          * @param defines the list of defines to complete
+         * @param forPostProcess Define if we are currently in post process mode or not
          */
         public prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess: boolean = false): void {
             if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
@@ -453,6 +458,7 @@ module BABYLON {
 
         /**
          * Returns true if all the image processing information are ready.
+         * @returns True if ready, otherwise, false
          */
         public isReady() {
             // Color Grading texure can not be none blocking.
@@ -462,6 +468,7 @@ module BABYLON {
         /**
          * Binds the image processing to the shader.
          * @param effect The effect to bind to
+         * @param aspectRatio Define the current aspect ratio of the effect
          */
         public bind(effect: Effect, aspectRatio = 1): void {
             // Color Curves

+ 3 - 3
src/Materials/babylon.materialHelper.ts

@@ -24,10 +24,10 @@ module BABYLON {
 
         /**
          * Helps preparing the defines values about the UVs in used in the effect.
-         * UVs are shared as much as we can accross chanels in the shaders.
+         * UVs are shared as much as we can accross channels in the shaders.
          * @param texture The texture we are preparing the UVs for
          * @param defines The defines to update
-         * @param key The chanel key "diffuse", "specular"... used in the shader
+         * @param key The channel key "diffuse", "specular"... used in the shader
          */
         public static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void {
             defines._needUVs = true;
@@ -48,7 +48,7 @@ module BABYLON {
          * Binds a texture matrix value to its corrsponding uniform
          * @param texture The texture to bind the matrix for 
          * @param uniformBuffer The uniform buffer receivin the data
-         * @param key The chanel key "diffuse", "specular"... used in the shader
+         * @param key The channel key "diffuse", "specular"... used in the shader
          */
         public static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void {
             var matrix = texture.getTextureMatrix();

+ 54 - 2
src/Materials/babylon.multiMaterial.ts

@@ -1,6 +1,16 @@
 module BABYLON {
+    /**
+     * A multi-material is used to apply different materials to different parts of the same object without the need of 
+     * separate meshes. This can be use to improve performances.
+     * @see http://doc.babylonjs.com/how_to/multi_materials
+     */
     export class MultiMaterial extends Material {
         private _subMaterials: Nullable<Material>[];
+
+        /**
+         * Gets or Sets the list of Materials used within the multi material.
+         * They need to be ordered according to the submeshes order in the associated mesh
+         */
         public get subMaterials(): Nullable<Material>[] {
             return this._subMaterials;
         }
@@ -10,6 +20,14 @@
             this._hookArray(value);
         }
 
+        /**
+         * Instantiates a new Multi Material
+         * A multi-material is used to apply different materials to different parts of the same object without the need of 
+         * separate meshes. This can be use to improve performances.
+         * @see http://doc.babylonjs.com/how_to/multi_materials
+         * @param name Define the name in the scene
+         * @param scene Define the scene the material belongs to
+         */
         constructor(name: string, scene: Scene) {
             super(name, scene, true);
 
@@ -40,7 +58,11 @@
             }
         }
 
-        // Properties
+        /**
+         * Get one of the submaterial by its index in the submaterials array
+         * @param index The index to look the sub material at
+         * @returns The Material if the index has been defined
+         */
         public getSubMaterial(index: number): Nullable<Material> {
             if (index < 0 || index >= this.subMaterials.length) {
                 return this.getScene().defaultMaterial;
@@ -49,6 +71,10 @@
             return this.subMaterials[index];
         }
 
+        /**
+         * Get the list of active textures for the whole sub materials list.
+         * @returns All the textures that will be used during the rendering
+         */
         public getActiveTextures(): BaseTexture[] {
             return super.getActiveTextures().concat(...this.subMaterials.map(subMaterial => {
                 if (subMaterial) {
@@ -59,11 +85,22 @@
             }));
         }
 
-        // Methods
+        /**
+         * Gets the current class name of the material e.g. "MultiMaterial"
+         * Mainly use in serialization.
+         * @returns the class name
+         */
         public getClassName(): string {
             return "MultiMaterial";
         }
 
+        /**
+         * Checks if the material is ready to render the requested sub mesh
+         * @param mesh Define the mesh the submesh belongs to 
+         * @param subMesh Define the sub mesh to look readyness for
+         * @param useInstances Define whether or not the material is used with instances
+         * @returns true if ready, otherwise false
+         */
         public isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean {
             for (var index = 0; index < this.subMaterials.length; index++) {
                 var subMaterial = this.subMaterials[index];
@@ -84,6 +121,12 @@
             return true;
         }
 
+        /**
+         * Clones the current material and its related sub materials
+         * @param name Define the name of the newly cloned material
+         * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
+         * @returns the cloned material
+         */
         public clone(name: string, cloneChildren?: boolean): MultiMaterial {
             var newMultiMaterial = new MultiMaterial(name, this.getScene());
 
@@ -101,6 +144,10 @@
             return newMultiMaterial;
         }
 
+        /**
+         * Serializes the materials into a JSON representation.
+         * @returns the JSON representation
+         */
         public serialize(): any {
             var serializationObject: any = {};
 
@@ -124,6 +171,11 @@
             return serializationObject;
         }
 
+        /**
+         * Dispose the material and release its associated resources
+         * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
+         * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
+         */
         public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
             var scene = this.getScene();
             if (!scene) {

+ 4 - 0
src/Materials/babylon.pushMaterial.ts

@@ -1,4 +1,8 @@
 module BABYLON {
+    /**
+     * Base class of materials working in push mode in babylon JS
+     * @hidden
+     */
     export class PushMaterial extends Material {
 
         protected _activeEffect: Effect;

+ 228 - 12
src/Materials/babylon.shaderMaterial.ts

@@ -1,7 +1,54 @@
 module BABYLON {
+    /**
+     * Defines the options associated with the creation of a shader material.
+     */
+    export interface IShaderMaterialOptions {
+        /**
+         * Does the material work in alpha blend mode
+         */
+        needAlphaBlending: boolean;
+
+        /**
+         * Does the material work in alpha test mode
+         */
+        needAlphaTesting: boolean;
+        
+        /**
+         * The list of attribute names used in the shader
+         */
+        attributes: string[];
+
+        /**
+         * The list of unifrom names used in the shader
+         */
+        uniforms: string[];
+
+        /**
+         * The list of UBO names used in the shader
+         */
+        uniformBuffers: string[];
+
+        /**
+         * The list of sampler names used in the shader
+         */
+        samplers: string[];
+
+        /**
+         * The list of defines used in the shader
+         */
+        defines: string[];
+    }
+
+    /**
+     * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
+     *
+     * This returned material effects how the mesh will look based on the code in the shaders.
+     *
+     * @see http://doc.babylonjs.com/how_to/shader_material
+     */
     export class ShaderMaterial extends Material {
         private _shaderPath: any;
-        private _options: any;
+        private _options: IShaderMaterialOptions;
         private _textures: { [name: string]: Texture } = {};
         private _textureArrays: { [name: string]: Texture[] } = {};
         private _floats: { [name: string]: number } = {};
@@ -21,29 +68,56 @@
         private _cachedWorldViewMatrix = new Matrix();
         private _renderId: number;
 
-        constructor(name: string, scene: Scene, shaderPath: any, options: any) {
+        /**
+         * Instantiate a new shader material.
+         * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
+         * This returned material effects how the mesh will look based on the code in the shaders.
+         * @see http://doc.babylonjs.com/how_to/shader_material
+         * @param name Define the name of the material in the scene
+         * @param scene Define the scene the material belongs to
+         * @param shaderPath Defines  the route to the shader code in one of three ways:
+         *     - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
+         *     - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
+         *     - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
+         * @param options Define the options used to create the shader
+         */
+        constructor(name: string, scene: Scene, shaderPath: any, options: Partial<IShaderMaterialOptions> = {}) {
             super(name, scene);
             this._shaderPath = shaderPath;
 
-            options.needAlphaBlending = options.needAlphaBlending || false;
-            options.needAlphaTesting = options.needAlphaTesting || false;
-            options.attributes = options.attributes || ["position", "normal", "uv"];
-            options.uniforms = options.uniforms || ["worldViewProjection"];
-            options.uniformBuffers = options.uniformBuffers || [];
-            options.samplers = options.samplers || [];
-            options.defines = options.defines || [];
-
-            this._options = options;
+            this._options = {
+                needAlphaBlending: false,
+                needAlphaTesting: false,
+                attributes: ["position", "normal", "uv"],
+                uniforms: ["worldViewProjection"],
+                uniformBuffers: [],
+                samplers: [],
+                defines: [],
+                ...options
+            };
         }
 
+        /**
+         * Gets the current class name of the material e.g. "ShaderMaterial"
+         * Mainly use in serialization.
+         * @returns the class name
+         */
         public getClassName(): string {
             return "ShaderMaterial";
         }
 
+        /**
+         * Specifies if the material will require alpha blending
+         * @returns a boolean specifying if alpha blending is needed
+         */
         public needAlphaBlending(): boolean {
-            return this._options.needAlphaBlending;
+            return (this.alpha < 1.0);
         }
 
+        /**
+         * Specifies if this material should be rendered in alpha test mode
+         * @returns a boolean specifying if an alpha test is needed.
+         */
         public needAlphaTesting(): boolean {
             return this._options.needAlphaTesting;
         }
@@ -54,6 +128,12 @@
             }
         }
 
+        /**
+         * Set a texture in the shader.
+         * @param name Define the name of the uniform samplers as defined in the shader
+         * @param texture Define the texture to bind to this sampler
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setTexture(name: string, texture: Texture): ShaderMaterial {
             if (this._options.samplers.indexOf(name) === -1) {
                 this._options.samplers.push(name);
@@ -63,6 +143,12 @@
             return this;
         }
 
+        /**
+         * Set a texture array in the shader.
+         * @param name Define the name of the uniform sampler array as defined in the shader
+         * @param textures Define the list of textures to bind to this sampler
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setTextureArray(name: string, textures: Texture[]): ShaderMaterial {
             if (this._options.samplers.indexOf(name) === -1) {
                 this._options.samplers.push(name);
@@ -75,6 +161,12 @@
             return this;
         }
 
+        /**
+         * Set a float in the shader.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setFloat(name: string, value: number): ShaderMaterial {
             this._checkUniform(name);
             this._floats[name] = value;
@@ -82,6 +174,12 @@
             return this;
         }
 
+        /**
+         * Set a int in the shader.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setInt(name: string, value: number): ShaderMaterial {
             this._checkUniform(name);
             this._ints[name] = value;
@@ -89,6 +187,12 @@
             return this;
         }
 
+        /**
+         * Set an array of floats in the shader.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setFloats(name: string, value: number[]): ShaderMaterial {
             this._checkUniform(name);
             this._floatsArrays[name] = value;
@@ -96,12 +200,25 @@
             return this;
         }
 
+        /**
+         * Set a vec3 in the shader from a Color3.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setColor3(name: string, value: Color3): ShaderMaterial {
             this._checkUniform(name);
             this._colors3[name] = value;
 
             return this;
         }
+
+        /**
+         * Set a vec3 array in the shader from a Color3 array.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setColor3Array(name: string, value: Color3[]): ShaderMaterial {
             this._checkUniform(name);
             this._colors3Arrays[name] = value.reduce((arr, color) => {
@@ -111,6 +228,12 @@
             return this;
         }
 
+        /**
+         * Set a vec4 in the shader from a Color4.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setColor4(name: string, value: Color4): ShaderMaterial {
             this._checkUniform(name);
             this._colors4[name] = value;
@@ -118,6 +241,12 @@
             return this;
         }
 
+        /**
+         * Set a vec2 in the shader from a Vector2.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setVector2(name: string, value: Vector2): ShaderMaterial {
             this._checkUniform(name);
             this._vectors2[name] = value;
@@ -125,6 +254,12 @@
             return this;
         }
 
+        /**
+         * Set a vec3 in the shader from a Vector3.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setVector3(name: string, value: Vector3): ShaderMaterial {
             this._checkUniform(name);
             this._vectors3[name] = value;
@@ -132,6 +267,12 @@
             return this;
         }
 
+        /**
+         * Set a vec4 in the shader from a Vector4.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setVector4(name: string, value: Vector4): ShaderMaterial {
             this._checkUniform(name);
             this._vectors4[name] = value;
@@ -139,6 +280,12 @@
             return this;
         }
 
+        /**
+         * Set a mat4 in the shader from a Matrix.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setMatrix(name: string, value: Matrix): ShaderMaterial {
             this._checkUniform(name);
             this._matrices[name] = value;
@@ -146,6 +293,12 @@
             return this;
         }
 
+        /**
+         * Set a mat3 in the shader from a Float32Array.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setMatrix3x3(name: string, value: Float32Array): ShaderMaterial {
             this._checkUniform(name);
             this._matrices3x3[name] = value;
@@ -153,6 +306,12 @@
             return this;
         }
 
+        /**
+         * Set a mat2 in the shader from a Float32Array.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setMatrix2x2(name: string, value: Float32Array): ShaderMaterial {
             this._checkUniform(name);
             this._matrices2x2[name] = value;
@@ -160,6 +319,12 @@
             return this;
         }
 
+        /**
+         * Set a vec2 array in the shader from a number array.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setArray2(name: string, value: number[]): ShaderMaterial {
             this._checkUniform(name);
             this._vectors2Arrays[name] = value;
@@ -167,6 +332,12 @@
             return this;
         }
 
+        /**
+         * Set a vec3 array in the shader from a number array.
+         * @param name Define the name of the uniform as defined in the shader
+         * @param value Define the value to give to the uniform
+         * @return the material itself allowing "fluent" like uniform updates
+         */
         public setArray3(name: string, value: number[]): ShaderMaterial {
             this._checkUniform(name);
             this._vectors3Arrays[name] = value;
@@ -186,6 +357,12 @@
             return false;
         }
 
+        /**
+         * Checks if the material is ready to render the requested mesh
+         * @param mesh Define the mesh to render
+         * @param useInstances Define whether or not the material is used with instances
+         * @returns true if ready, otherwise false
+         */
         public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
             var scene = this.getScene();
             var engine = scene.getEngine();
@@ -280,6 +457,10 @@
             return true;
         }
 
+        /**
+         * Binds the world matrix to the material
+         * @param world defines the world transformation matrix
+         */
         public bindOnlyWorldMatrix(world: Matrix): void {
             var scene = this.getScene();
 
@@ -301,6 +482,11 @@
             }
         }
 
+        /**
+         * Binds the material to the mesh
+         * @param world defines the world transformation matrix
+         * @param mesh defines the mesh to bind the material to
+         */
         public bind(world: Matrix, mesh?: Mesh): void {
             // Std values
             this.bindOnlyWorldMatrix(world);
@@ -406,6 +592,10 @@
             this._afterBind(mesh);
         }
 
+        /**
+         * Gets the active textures from the material
+         * @returns an array of textures
+         */
         public getActiveTextures(): BaseTexture[] {
             var activeTextures = super.getActiveTextures();
 
@@ -423,6 +613,11 @@
             return activeTextures;
         }
 
+        /**
+         * Specifies if the material uses a texture
+         * @param texture defines the texture to check against the material
+         * @returns a boolean specifying if the material uses the texture
+         */
         public hasTexture(texture: BaseTexture): boolean {
             if (super.hasTexture(texture)) {
                 return true;
@@ -446,12 +641,22 @@
             return false;
         }
 
+        /**
+         * Makes a duplicate of the material, and gives it a new name
+         * @param name defines the new name for the duplicated material
+         * @returns the cloned material
+         */
         public clone(name: string): ShaderMaterial {
             var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
 
             return newShaderMaterial;
         }
 
+        /**
+         * Disposes the material
+         * @param forceDisposeEffect specifies if effects should be forcefully disposed
+         * @param forceDisposeTextures specifies if textures should be forcefully disposed
+         */
         public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
 
             if (forceDisposeTextures) {
@@ -473,6 +678,10 @@
             super.dispose(forceDisposeEffect, forceDisposeTextures);
         }
 
+        /**
+         * Serializes this material in a JSON representation
+         * @returns the serialized material object
+         */
         public serialize(): any {
             var serializationObject = SerializationHelper.Serialize(this);
             serializationObject.customType = "BABYLON.ShaderMaterial";
@@ -579,6 +788,13 @@
             return serializationObject;
         }
 
+        /**
+         * Creates a shader material from parsed shader material data
+         * @param source defines the JSON represnetation of the material
+         * @param scene defines the hosting scene
+         * @param rootUrl defines the root URL to use to load textures and relative dependencies
+         * @returns a new material
+         */
         public static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial {
             var material = SerializationHelper.Parse(() => new ShaderMaterial(source.name, scene, source.shaderPath, source.options), source, scene, rootUrl);
 

+ 277 - 24
src/Materials/babylon.standardMaterial.ts

@@ -123,94 +123,176 @@ module BABYLON {
         }
     }
 
+    /**
+     * This is the default material used in Babylon. It is the best trade off between quality
+     * and performances.
+     * @see http://doc.babylonjs.com/babylon101/materials
+     */
     export class StandardMaterial extends PushMaterial {
         @serializeAsTexture("diffuseTexture")
         private _diffuseTexture: Nullable<BaseTexture>;
+        /**
+         * The basic texture of the material as viewed under a light.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public diffuseTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("ambientTexture")
         private _ambientTexture: Nullable<BaseTexture>;
+        /**
+         * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public ambientTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("opacityTexture")
         private _opacityTexture: Nullable<BaseTexture>;
+        /**
+         * Define the transparency of the material from a texture.
+         * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
+         * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")
         public opacityTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("reflectionTexture")
         private _reflectionTexture: Nullable<BaseTexture>;
+        /**
+         * Define the texture used to display the reflection.
+         * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public reflectionTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("emissiveTexture")
         private _emissiveTexture: Nullable<BaseTexture>;
+        /**
+         * Define texture of the material as if self lit.
+         * This will be mixed in the final result even in the absence of light.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public emissiveTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("specularTexture")
         private _specularTexture: Nullable<BaseTexture>;
+        /**
+         * Define how the color and intensity of the highlight given by the light in the material.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public specularTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("bumpTexture")
         private _bumpTexture: Nullable<BaseTexture>;
+        /**
+         * Bump mapping is a technique to simulate bump and dents on a rendered surface. 
+         * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
+         * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public bumpTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("lightmapTexture")
         private _lightmapTexture: Nullable<BaseTexture>;
+        /**
+         * Complex lighting can be computationally expensive to compute at runtime. 
+         * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
+         * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public lightmapTexture: Nullable<BaseTexture>;
 
         @serializeAsTexture("refractionTexture")
         private _refractionTexture: Nullable<BaseTexture>;
+        /**
+         * Define the texture used to display the refraction.
+         * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public refractionTexture: Nullable<BaseTexture>;
 
+        /**
+         * The color of the material lit by the environmental background lighting.
+         * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
+         */
         @serializeAsColor3("ambient")
         public ambientColor = new Color3(0, 0, 0);
 
+        /**
+         * The basic color of the material as viewed under a light.
+         */
         @serializeAsColor3("diffuse")
         public diffuseColor = new Color3(1, 1, 1);
 
+        /**
+         * Define how the color and intensity of the highlight given by the light in the material.
+         */
         @serializeAsColor3("specular")
         public specularColor = new Color3(1, 1, 1);
 
+        /**
+         * Define the color of the material as if self lit.
+         * This will be mixed in the final result even in the absence of light.
+         */
         @serializeAsColor3("emissive")
         public emissiveColor = new Color3(0, 0, 0);
 
+        /**
+         * Defines how sharp are the highlights in the material.
+         * The bigger the value the sharper giving a more glossy feeling to the result.
+         * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
+         */
         @serialize()
         public specularPower = 64;
 
         @serialize("useAlphaFromDiffuseTexture")
         private _useAlphaFromDiffuseTexture = false;
+        /**
+         * Does the transparency come from the diffuse texture alpha channel.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useAlphaFromDiffuseTexture: boolean;
 
         @serialize("useEmissiveAsIllumination")
         private _useEmissiveAsIllumination = false;
+        /**
+         * If true, the emissive value is added into the end result, otherwise it is multiplied in.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useEmissiveAsIllumination: boolean;
 
         @serialize("linkEmissiveWithDiffuse")
         private _linkEmissiveWithDiffuse = false;
+        /**
+         * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
+         * the emissive level when the final color is close to one.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public linkEmissiveWithDiffuse: boolean;
 
         @serialize("useSpecularOverAlpha")
         private _useSpecularOverAlpha = false;
+        /**
+         * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
+         * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useSpecularOverAlpha: boolean;
 
         @serialize("useReflectionOverAlpha")
         private _useReflectionOverAlpha = false;
+        /**
+         * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
+         * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useReflectionOverAlpha: boolean;
 
         @serialize("disableLighting")
         private _disableLighting = false;
+        /**
+         * Does lights from the scene impacts this material.
+         * It can be a nice trick for performance to disable lighting on a fully emissive material.
+         */
         @expandToProperty("_markAllSubMeshesAsLightsDirty")
         public disableLighting: boolean;
 
@@ -224,102 +306,158 @@ module BABYLON {
 
         @serialize("useParallax")
         private _useParallax = false;
+        /**
+         * Is parallax enabled or not.
+         * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useParallax: boolean;
 
         @serialize("useParallaxOcclusion")
         private _useParallaxOcclusion = false;
+        /**
+         * Is parallax occlusion enabled or not.
+         * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
+         * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useParallaxOcclusion: boolean;
 
+        /**
+         * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
+         */
         @serialize()
         public parallaxScaleBias = 0.05;
 
         @serialize("roughness")
         private _roughness = 0;
+        /**
+         * Helps to define how blurry the reflections should appears in the material.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public roughness: number;
 
+        /**
+         * In case of refraction, define the value of the indice of refraction.
+         * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
+         */
         @serialize()
         public indexOfRefraction = 0.98;
 
+        /**
+         * Invert the refraction texture alongside the y axis.
+         * It can be usefull with procedural textures or probe for instance.
+         * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
+         */
         @serialize()
         public invertRefractionY = true;
 
         /**
-         * Defines the alpha limits in alpha test mode
+         * Defines the alpha limits in alpha test mode.
          */
         @serialize()
-        public alphaCutOff = 0.4;        
+        public alphaCutOff = 0.4;
 
         @serialize("useLightmapAsShadowmap")
         private _useLightmapAsShadowmap = false;
+        /**
+         * In case of light mapping, define whether the map contains light or shadow informations.
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useLightmapAsShadowmap: boolean;
 
         // Fresnel
         @serializeAsFresnelParameters("diffuseFresnelParameters")
         private _diffuseFresnelParameters: FresnelParameters;
+        /**
+         * Define the diffuse fresnel parameters of the material.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+         */
         @expandToProperty("_markAllSubMeshesAsFresnelDirty")
         public diffuseFresnelParameters: FresnelParameters;
 
         @serializeAsFresnelParameters("opacityFresnelParameters")
         private _opacityFresnelParameters: FresnelParameters;
+        /**
+         * Define the opacity fresnel parameters of the material.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+         */
         @expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")
         public opacityFresnelParameters: FresnelParameters;
 
-
         @serializeAsFresnelParameters("reflectionFresnelParameters")
         private _reflectionFresnelParameters: FresnelParameters;
+        /**
+         * Define the reflection fresnel parameters of the material.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+         */
         @expandToProperty("_markAllSubMeshesAsFresnelDirty")
         public reflectionFresnelParameters: FresnelParameters;
 
         @serializeAsFresnelParameters("refractionFresnelParameters")
         private _refractionFresnelParameters: FresnelParameters;
+        /**
+         * Define the refraction fresnel parameters of the material.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+         */
         @expandToProperty("_markAllSubMeshesAsFresnelDirty")
         public refractionFresnelParameters: FresnelParameters;
 
         @serializeAsFresnelParameters("emissiveFresnelParameters")
         private _emissiveFresnelParameters: FresnelParameters;
+        /**
+         * Define the emissive fresnel parameters of the material.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+         */
         @expandToProperty("_markAllSubMeshesAsFresnelDirty")
         public emissiveFresnelParameters: FresnelParameters;
 
         @serialize("useReflectionFresnelFromSpecular")
         private _useReflectionFresnelFromSpecular = false;
+        /**
+         * If true automatically deducts the fresnels values from the material specularity.
+         * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
+         */
         @expandToProperty("_markAllSubMeshesAsFresnelDirty")
         public useReflectionFresnelFromSpecular: boolean;
 
         @serialize("useGlossinessFromSpecularMapAlpha")
         private _useGlossinessFromSpecularMapAlpha = false;
+        /**
+         * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
+         */
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public useGlossinessFromSpecularMapAlpha: boolean;
 
         @serialize("maxSimultaneousLights")
         private _maxSimultaneousLights = 4;
+        /**
+         * Defines the maximum number of lights that can be used in the material
+         */
         @expandToProperty("_markAllSubMeshesAsLightsDirty")
         public maxSimultaneousLights: number;
 
+        @serialize("invertNormalMapX")
+        private _invertNormalMapX = false;
         /**
          * If sets to true, x component of normal map value will invert (x = 1.0 - x).
          */
-        @serialize("invertNormalMapX")
-        private _invertNormalMapX = false;
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public invertNormalMapX: boolean;
 
+        @serialize("invertNormalMapY")
+        private _invertNormalMapY = false;
         /**
          * If sets to true, y component of normal map value will invert (y = 1.0 - y).
          */
-        @serialize("invertNormalMapY")
-        private _invertNormalMapY = false;
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public invertNormalMapY: boolean;
 
+        @serialize("twoSidedLighting")
+        private _twoSidedLighting = false;
         /**
          * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
          */
-        @serialize("twoSidedLighting")
-        private _twoSidedLighting = false;
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public twoSidedLighting: boolean;
 
@@ -484,14 +622,24 @@ module BABYLON {
             this._imageProcessingConfiguration.colorCurves = value;
         }
 
+        /**
+         * Custom callback helping to override the default shader used in the material.
+         */
         public customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
 
         protected _renderTargets = new SmartArray<RenderTargetTexture>(16);
         protected _worldViewProjectionMatrix = Matrix.Zero();
         protected _globalAmbientColor = new Color3(0, 0, 0);
-
         protected _useLogarithmicDepth: boolean;
 
+        /**
+         * Instantiates a new standard material.
+         * This is the default material used in Babylon. It is the best trade off between quality
+         * and performances.
+         * @see http://doc.babylonjs.com/babylon101/materials
+         * @param name Define the name of the material in the scene
+         * @param scene Define the scene the material belong to
+         */
         constructor(name: string, scene: Scene) {
             super(name, scene);
 
@@ -515,7 +663,7 @@ module BABYLON {
 
         /**
          * Gets a boolean indicating that current material needs to register RTT
-         */               
+         */
         public get hasRenderTargetTextures(): boolean {
             if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
                 return true;
@@ -528,10 +676,20 @@ module BABYLON {
             return false;
         }
 
+        /**
+         * Gets the current class name of the material e.g. "StandardMaterial"
+         * Mainly use in serialization.
+         * @returns the class name
+         */
         public getClassName(): string {
             return "StandardMaterial";
         }
 
+        /**
+         * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
+         * You can try switching to logarithmic depth.
+         * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
+         */
         @serialize()
         public get useLogarithmicDepth(): boolean {
             return this._useLogarithmicDepth;
@@ -543,10 +701,18 @@ module BABYLON {
             this._markAllSubMeshesAsMiscDirty();
         }
 
+        /**
+         * Specifies if the material will require alpha blending
+         * @returns a boolean specifying if alpha blending is needed
+         */
         public needAlphaBlending(): boolean {
             return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
         }
 
+        /**
+         * Specifies if this material should be rendered in alpha test mode
+         * @returns a boolean specifying if an alpha test is needed.
+         */
         public needAlphaTesting(): boolean {
             return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
         }
@@ -555,12 +721,21 @@ module BABYLON {
             return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
         }
 
+        /**
+         * Get the texture used for alpha test purpose.
+         * @returns the diffuse texture in case of the standard material.
+         */
         public getAlphaTestTexture(): Nullable<BaseTexture> {
             return this._diffuseTexture;
         }
 
         /**
+         * Get if the submesh is ready to be used and all its information available.
          * Child classes can use it to update shaders
+         * @param mesh defines the mesh to check
+         * @param subMesh defines which submesh to check
+         * @param useInstances specifies that instances should be used
+         * @returns a boolean indicating that the submesh is ready or not
          */
         public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances: boolean = false): boolean {
             if (subMesh.effect && this.isFrozen) {
@@ -956,6 +1131,10 @@ module BABYLON {
             return true;
         }
 
+        /**
+         * Builds the material UBO layouts.
+         * Used internally during the effect preparation.
+         */
         public buildUniformLayout(): void {
             // Order is important !
             this._uniformBuffer.addUniform("diffuseLeftColor", 4);
@@ -998,6 +1177,9 @@ module BABYLON {
             this._uniformBuffer.create();
         }
 
+        /**
+         * Unbinds the material from the mesh
+         */
         public unbind(): void {
             if (this._activeEffect) {
                 let needFlag = false;
@@ -1019,6 +1201,12 @@ module BABYLON {
             super.unbind();
         }
 
+        /**
+         * Binds the submesh to this material by preparing the effect and shader to draw
+         * @param world defines the world transformation matrix
+         * @param mesh defines the mesh containing the submesh
+         * @param subMesh defines the submesh to bind the material to
+         */
         public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {
             var scene = this.getScene();
 
@@ -1257,6 +1445,10 @@ module BABYLON {
             this._afterBind(mesh, this._activeEffect);
         }
 
+        /**
+         * Get the list of animatables in the material.
+         * @returns the list of animatables object used in the material
+         */
         public getAnimatables(): IAnimatable[] {
             var results = [];
 
@@ -1299,6 +1491,10 @@ module BABYLON {
             return results;
         }
 
+        /**
+         * Gets the active textures from the material
+         * @returns an array of textures
+         */
         public getActiveTextures(): BaseTexture[] {
             var activeTextures = super.getActiveTextures();
 
@@ -1341,6 +1537,11 @@ module BABYLON {
             return activeTextures;
         }
 
+        /**
+         * Specifies if the material uses a texture
+         * @param texture defines the texture to check against the material
+         * @returns a boolean specifying if the material uses the texture
+         */
         public hasTexture(texture: BaseTexture): boolean {
             if (super.hasTexture(texture)) {
                 return true;
@@ -1385,6 +1586,11 @@ module BABYLON {
             return false;
         }
 
+        /**
+         * Disposes the material
+         * @param forceDisposeEffect specifies if effects should be forcefully disposed
+         * @param forceDisposeTextures specifies if textures should be forcefully disposed
+         */
         public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
             if (forceDisposeTextures) {
                 if (this._diffuseTexture) {
@@ -1431,6 +1637,11 @@ module BABYLON {
             super.dispose(forceDisposeEffect, forceDisposeTextures);
         }
 
+        /**
+         * Makes a duplicate of the material, and gives it a new name
+         * @param name defines the new name for the duplicated material
+         * @returns the cloned material
+         */
         public clone(name: string): StandardMaterial {
             var result = SerializationHelper.Clone(() => new StandardMaterial(name, this.getScene()), this);
 
@@ -1440,17 +1651,30 @@ module BABYLON {
             return result;
         }
 
+        /**
+         * Serializes this material in a JSON representation
+         * @returns the serialized material object
+         */
         public serialize(): any {
             return SerializationHelper.Serialize(this);
         }
 
-        // Statics
+        /**
+         * Creates a standard material from parsed material data
+         * @param source defines the JSON represnetation of the material
+         * @param scene defines the hosting scene
+         * @param rootUrl defines the root URL to use to load textures and relative dependencies
+         * @returns a new material
+         */
         public static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial {
             return SerializationHelper.Parse(() => new StandardMaterial(source.name, scene), source, scene, rootUrl);
         }
 
         // Flags used to enable or disable a type of texture for all Standard Materials
-        static _DiffuseTextureEnabled = true;
+        private static _DiffuseTextureEnabled = true;
+        /**
+         * Are diffuse textures enabled in the application.
+         */
         public static get DiffuseTextureEnabled(): boolean {
             return StandardMaterial._DiffuseTextureEnabled;
         }
@@ -1463,8 +1687,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-
-        static _AmbientTextureEnabled = true;
+        private static _AmbientTextureEnabled = true;
+        /**
+         * Are ambient textures enabled in the application.
+         */
         public static get AmbientTextureEnabled(): boolean {
             return StandardMaterial._AmbientTextureEnabled;
         }
@@ -1477,7 +1703,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _OpacityTextureEnabled = true;
+        private static _OpacityTextureEnabled = true;
+        /**
+         * Are opacity textures enabled in the application.
+         */
         public static get OpacityTextureEnabled(): boolean {
             return StandardMaterial._OpacityTextureEnabled;
         }
@@ -1490,7 +1719,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _ReflectionTextureEnabled = true;
+        private static _ReflectionTextureEnabled = true;
+        /**
+         * Are reflection textures enabled in the application.
+         */
         public static get ReflectionTextureEnabled(): boolean {
             return StandardMaterial._ReflectionTextureEnabled;
         }
@@ -1503,7 +1735,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _EmissiveTextureEnabled = true;
+        private static _EmissiveTextureEnabled = true;
+        /**
+         * Are emissive textures enabled in the application.
+         */
         public static get EmissiveTextureEnabled(): boolean {
             return StandardMaterial._EmissiveTextureEnabled;
         }
@@ -1516,7 +1751,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _SpecularTextureEnabled = true;
+        private static _SpecularTextureEnabled = true;
+        /**
+         * Are specular textures enabled in the application.
+         */
         public static get SpecularTextureEnabled(): boolean {
             return StandardMaterial._SpecularTextureEnabled;
         }
@@ -1529,7 +1767,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _BumpTextureEnabled = true;
+        private static _BumpTextureEnabled = true;
+        /**
+         * Are bump textures enabled in the application.
+         */
         public static get BumpTextureEnabled(): boolean {
             return StandardMaterial._BumpTextureEnabled;
         }
@@ -1542,7 +1783,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _LightmapTextureEnabled = true;
+        private static _LightmapTextureEnabled = true;
+        /**
+         * Are lightmap textures enabled in the application.
+         */
         public static get LightmapTextureEnabled(): boolean {
             return StandardMaterial._LightmapTextureEnabled;
         }
@@ -1555,7 +1799,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _RefractionTextureEnabled = true;
+        private static _RefractionTextureEnabled = true;
+        /**
+         * Are refraction textures enabled in the application.
+         */
         public static get RefractionTextureEnabled(): boolean {
             return StandardMaterial._RefractionTextureEnabled;
         }
@@ -1568,7 +1815,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _ColorGradingTextureEnabled = true;
+        private static _ColorGradingTextureEnabled = true;
+        /**
+         * Are color grading textures enabled in the application.
+         */
         public static get ColorGradingTextureEnabled(): boolean {
             return StandardMaterial._ColorGradingTextureEnabled;
         }
@@ -1581,7 +1831,10 @@ module BABYLON {
             Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
         }
 
-        static _FresnelEnabled = true;
+        private static _FresnelEnabled = true;
+        /**
+         * Are fresnels enabled in the application.
+         */
         public static get FresnelEnabled(): boolean {
             return StandardMaterial._FresnelEnabled;
         }

+ 88 - 86
src/Materials/babylon.uniformBuffer.ts

@@ -1,5 +1,15 @@
 module BABYLON {
 
+    /**
+     * Uniform buffer objects.
+     * 
+     * Handles blocks of uniform on the GPU.
+     *
+     * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
+     *
+     * For more information, please refer to : 
+     * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
+     */
     export class UniformBuffer {
         private _engine: Engine;
         private _buffer: Nullable<WebGLBuffer>;
@@ -18,104 +28,94 @@ module BABYLON {
         private static _tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
 
         /**
-         * Wrapper for updateUniform.
-         * @method updateMatrix3x3 
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Float32Array} matrix
+         * Lambda to Update a 3x3 Matrix in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateMatrix3x3: (name: string, matrix: Float32Array) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Float32Array} matrix
+         * Lambda to Update a 2x2 Matrix in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateMatrix2x2: (name: string, matrix: Float32Array) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
+         * Lambda to Update a single float in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateFloat: (name: string, x: number) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         * @param {string} [suffix] Suffix to add to the uniform name.
+         * Lambda to Update a vec2 of float in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         * @param {number} z
-         * @param {string} [suffix] Suffix to add to the uniform name.
+         * Lambda to Update a vec3 of float in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         * @param {number} z
-         * @param {number} w
-         * @param {string} [suffix] Suffix to add to the uniform name.
+         * Lambda to Update a vec4 of float in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Matrix} A 4x4 matrix.
+         * Lambda to Update a 4x4 Matrix in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateMatrix: (name: string, mat: Matrix) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Vector3} vector
+         * Lambda to Update vec3 of float from a Vector in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateVector3: (name: string, vector: Vector3) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Vector4} vector
+         * Lambda to Update vec4 of float from a Vector in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateVector4: (name: string, vector: Vector4) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Color3} color
-         * @param {string} [suffix] Suffix to add to the uniform name.
+         * Lambda to Update vec3 of float from a Color in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateColor3: (name: string, color: Color3, suffix?: string) => void;
 
         /**
-         * Wrapper for updateUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Color3} color
-         * @param {number} alpha
-         * @param {string} [suffix] Suffix to add to the uniform name.
+         * Lambda to Update vec4 of float from a Color in a uniform buffer.
+         * This is dynamic to allow compat with webgl 1 and 2.
+         * You will need to pass the name of the uniform as well as the value.
          */
         public updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
 
         /**
-         * Uniform buffer objects.
+         * Instantiates a new Uniform buffer objects.
          * 
          * Handles blocks of uniform on the GPU.
          *
          * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
          *
          * For more information, please refer to : 
-         * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
+         * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
+         * @param engine Define the engine the buffer is associated with
+         * @param data Define the data contained in the buffer
+         * @param dynamic Define if the buffer is updatable 
          */
         constructor(engine: Engine, data?: number[], dynamic?: boolean) {
             this._engine = engine;
@@ -159,7 +159,6 @@ module BABYLON {
 
         }
 
-        // Properties
         /**
          * Indicates if the buffer is using the WebGL2 UBO implementation,
          * or just falling back on setUniformXXX calls.
@@ -180,6 +179,7 @@ module BABYLON {
          * Indicates if the WebGL underlying uniform buffer is dynamic.
          * Also, a dynamic UniformBuffer will disable cache verification and always 
          * update the underlying WebGL uniform buffer to the GPU.
+         * @returns if Dynamic, otherwise false
          */
         public isDynamic(): boolean {
             return this._dynamic !== undefined;
@@ -187,6 +187,7 @@ module BABYLON {
 
         /**
          * The data cache on JS side.
+         * @returns the underlying data as a float array
          */
         public getData(): Float32Array {
             return this._bufferData;
@@ -194,6 +195,7 @@ module BABYLON {
 
         /**
          * The underlying WebGL Uniform buffer.
+         * @returns the webgl buffer
          */
         public getBuffer(): Nullable<WebGLBuffer> {
             return this._buffer;
@@ -231,8 +233,8 @@ module BABYLON {
          * Adds an uniform in the buffer.
          * Warning : the subsequents calls of this function must be in the same order as declared in the shader
          * for the layout to be correct !
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number|number[]} size Data size, or data directly.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param size Data size, or data directly.
          */
         public addUniform(name: string, size: number | number[]) {
             if (this._noUBO) {
@@ -274,19 +276,19 @@ module BABYLON {
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Matrix} mat A 4x4 matrix.
+         * Adds a Matrix 4x4 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param mat A 4x4 matrix.
          */
         public addMatrix(name: string, mat: Matrix) {
             this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
+         * Adds a vec2 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param x Define the x component value of the vec2
+         * @param y Define the y component value of the vec2
          */
         public addFloat2(name: string, x: number, y: number) {
             var temp = [x, y];
@@ -294,11 +296,11 @@ module BABYLON {
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {number} x
-         * @param {number} y
-         * @param {number} z
+         * Adds a vec3 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param x Define the x component value of the vec3
+         * @param y Define the y component value of the vec3
+         * @param z Define the z component value of the vec3
          */
         public addFloat3(name: string, x: number, y: number, z: number) {
             var temp = [x, y, z];
@@ -306,9 +308,9 @@ module BABYLON {
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Color3} color
+         * Adds a vec3 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param color Define the vec3 from a Color
          */
         public addColor3(name: string, color: Color3) {
             var temp = new Array<number>();
@@ -317,10 +319,10 @@ module BABYLON {
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Color3} color
-         * @param {number} alpha
+         * Adds a vec4 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param color Define the rgb components from a Color
+         * @param alpha Define the a component of the vec4
          */
         public addColor4(name: string, color: Color3, alpha: number) {
             var temp = new Array<number>();
@@ -330,9 +332,9 @@ module BABYLON {
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
-         * @param {Vector3} vector
+         * Adds a vec3 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
+         * @param vector Define the vec3 components from a Vector
          */
         public addVector3(name: string, vector: Vector3) {
             var temp = new Array<number>();
@@ -341,16 +343,16 @@ module BABYLON {
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * Adds a Matrix 3x3 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
          */
         public addMatrix3x3(name: string) {
             this.addUniform(name, 12);
         }
 
         /**
-         * Wrapper for addUniform.
-         * @param {string} name Name of the uniform, as used in the uniform block in the shader.
+         * Adds a Matrix 2x2 to the uniform buffer.
+         * @param name Name of the uniform, as used in the uniform block in the shader.
          */
         public addMatrix2x2(name: string) {
             this.addUniform(name, 8);
@@ -411,9 +413,9 @@ module BABYLON {
 
         /**
          * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
-         * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
-         * @param {number[]|Float32Array} data Flattened data
-         * @param {number} size Size of the data.
+         * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
+         * @param data Define the flattened data
+         * @param size Define the size of the data.
          */
         public updateUniform(uniformName: string, data: FloatArray, size: number) {
 
@@ -575,8 +577,8 @@ module BABYLON {
 
         /**
          * Sets a sampler uniform on the effect.
-         * @param {string} name Name of the sampler.
-         * @param {Texture} texture
+         * @param name Define the name of the sampler.
+         * @param texture Define the texture to set in the sampler
          */
         public setTexture(name: string, texture: Nullable<BaseTexture>) {
             this._currentEffect.setTexture(name, texture);
@@ -584,8 +586,8 @@ module BABYLON {
 
         /**
          * Directly updates the value of the uniform in the cache AND on the GPU.
-         * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
-         * @param {number[]|Float32Array} data Flattened data
+         * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
+         * @param data Define the flattened data
          */
         public updateUniformDirectly(uniformName: string, data: FloatArray) {
             this.updateUniform(uniformName, data, data.length);
@@ -595,8 +597,8 @@ module BABYLON {
 
         /**
          * Binds this uniform buffer to an effect.
-         * @param {Effect} effect
-         * @param {string} name Name of the uniform block in the shader.
+         * @param effect Define the effect to bind the buffer to
+         * @param name Name of the uniform block in the shader.
          */
         public bindToEffect(effect: Effect, name: string): void {
             this._currentEffect = effect;

+ 1 - 1
src/Mesh/babylon.linesMesh.ts

@@ -44,7 +44,7 @@
 
             this._intersectionThreshold = 0.1;
 
-            var defines: String[] = [];
+            var defines: string[] = [];
             var options = {
                 attributes: [VertexBuffer.PositionKind, "world0", "world1", "world2", "world3"],
                 uniforms: ["world", "viewProjection"],