Browse Source

More code comments

David Catuhe 7 years ago
parent
commit
0553932288

File diff suppressed because it is too large
+ 15684 - 15276
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 506 - 1303
dist/preview release/typedocValidationBaseline.json


+ 23 - 21
src/Mesh/babylon.mesh.vertexData.ts

@@ -144,7 +144,7 @@
         }
 
         /**
-         * Associates the vertexData to the passed Mesh 
+         * Associates the vertexData to the passed Mesh.
          * Sets it as updatable or not (default `false`) 
          * @param mesh the mesh the vertexData is applied to 
          * @param updatable when used and having the value true allows new data to update the vertexData 
@@ -156,7 +156,7 @@
         }
 
         /**
-         * Associates the vertexData to the passed Geometry 
+         * Associates the vertexData to the passed Geometry.
          * Sets it as updatable or not (default `false`)
          * @param geometry the geometry the vertexData is applied to 
          * @param updatable when used and having the value true allows new data to update the vertexData 
@@ -371,7 +371,7 @@
 
         /**
          * Merges the passed VertexData into the current one
-         * @param other the VetexData to be merged into the current one  
+         * @param other the VertexData to be merged into the current one  
          * @returns the modified VertexData 
          */
         public merge(other: VertexData): VertexData {
@@ -1898,8 +1898,8 @@
          * @param polygon a mesh built from polygonTriangulation.build()
          * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
          * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
-         * @param faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
-         * @param frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
+         * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
+         * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
          * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
          * @returns the VertexData of the Polygon
          */
@@ -2243,22 +2243,22 @@
         // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
         /**
          * Creates the VertexData for a Polyhedron
-         * * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty 
-          * * type provided types are:
-         * -- 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
-         * -- 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
-          * * size the size of the IcoSphere, optional default 1  
-          * * sizeX allows stretching in the x direction, optional, default size
-          * * sizeY allows stretching in the y direction, optional, default size
-          * * sizeZ allows stretching in the z direction, optional, default size
-          * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
-          * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
-          * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
-          * * flat when true creates a flat shaded mesh, optional, default true
-          * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4 
-          * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE     
-          * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
-          * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1) 
+         * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty 
+         * * type provided types are:
+         *  * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
+         *  * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
+         * * size the size of the IcoSphere, optional default 1  
+         * * sizeX allows stretching in the x direction, optional, default size
+         * * sizeY allows stretching in the y direction, optional, default size
+         * * sizeZ allows stretching in the z direction, optional, default size
+         * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
+         * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
+         * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
+         * * flat when true creates a flat shaded mesh, optional, default true
+         * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4 
+         * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE     
+         * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
+         * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1) 
          * @returns the VertexData of the Polyhedron 
          */
         public static CreatePolyhedron(options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
@@ -2499,7 +2499,9 @@
         }
 
         // Tools
+
         /**
+         * Compute normals for given positions and indices
          * @param positions an array of vertex positions, [...., x, y, z, ......]
          * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
          * @param normals an array of vertex normals, [...., x, y, z, ......]

+ 70 - 4
src/Morph/babylon.morphTarget.ts

@@ -1,5 +1,12 @@
 module BABYLON {
-    export class MorphTarget {
+    /**
+     * Defines a target to use with MorphTargetManager
+     * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
+     */
+    export class MorphTarget implements IAnimatable {
+        /**
+         * Gets or sets the list of animations
+         */
         public animations = new Array<Animation>();
 
         private _positions: Nullable<FloatArray> = null;
@@ -7,8 +14,14 @@ module BABYLON {
         private _tangents: Nullable<FloatArray> = null;
         private _influence: number;
 
+        /**
+         * Observable raised when the influence changes
+         */
         public onInfluenceChanged = new Observable<boolean>();
 
+        /**
+         * Gets or sets the influence of this target (ie. its weight in the overall morphing)
+         */
         public get influence(): number {
             return this._influence;
         }
@@ -26,49 +39,89 @@ module BABYLON {
             }
         }
 
-        public constructor(public name: string, influence = 0) {
+        /**
+         * Creates a new MorphTarget
+         * @param name defines the name of the target
+         * @param influence defines the influence to use
+         */
+        public constructor(
+            /** defines the name of the target */
+            public name: string, influence = 0) {
             this.influence = influence;
         }
 
+        /**
+         * Gets a boolean defining if the target contains position data
+         */
         public get hasPositions(): boolean {
             return !!this._positions;
         }
 
+        /**
+         * Gets a boolean defining if the target contains normal data
+         */
         public get hasNormals(): boolean {
             return !!this._normals;
         }
 
+        /**
+         * Gets a boolean defining if the target contains tangent data
+         */        
         public get hasTangents(): boolean {
             return !!this._tangents;
         }
 
+        /**
+         * Affects position data to this target
+         * @param data defines the position data to use
+         */
         public setPositions(data: Nullable<FloatArray>) {
             this._positions = data;
         }
 
+        /**
+         * Gets the position data stored in this target
+         * @returns a FloatArray containing the position data (or null if not present)
+         */
         public getPositions(): Nullable<FloatArray> {
             return this._positions;
         }
 
+        /**
+         * Affects normal data to this target
+         * @param data defines the normal data to use
+         */        
         public setNormals(data: Nullable<FloatArray>) {
             this._normals = data;
         }
 
+        /**
+         * Gets the normal data stored in this target
+         * @returns a FloatArray containing the normal data (or null if not present)
+         */        
         public getNormals(): Nullable<FloatArray> {
             return this._normals;
         }
 
+        /**
+         * Affects tangent data to this target
+         * @param data defines the tangent data to use
+         */        
         public setTangents(data: Nullable<FloatArray>) {
             this._tangents = data;
         }
 
+        /**
+         * Gets the tangent data stored in this target
+         * @returns a FloatArray containing the tangent data (or null if not present)
+         */   
         public getTangents(): Nullable<FloatArray> {
             return this._tangents;
         }
 
         /**
-         * Serializes the current target into a Serialization object.  
-         * Returns the serialized object.  
+         * Serializes the current target into a Serialization object
+         * @returns the serialized object
          */
         public serialize(): any {
             var serializationObject:any = {};
@@ -91,6 +144,12 @@ module BABYLON {
         }
 
         // Statics
+
+        /**
+         * Creates a new target from serialized data
+         * @param serializationObject defines the serialized data to use
+         * @returns a new MorphTarget
+         */
         public static Parse(serializationObject: any): MorphTarget {
             var result = new MorphTarget(serializationObject.name , serializationObject.influence);
 
@@ -115,6 +174,13 @@ module BABYLON {
             return result;
         }
 
+        /**
+         * Creates a MorphTarget from mesh data
+         * @param mesh defines the source mesh
+         * @param name defines the name to use for the new target
+         * @param influence defines the influence to attach to the target
+         * @returns a new MorphTarget
+         */
         public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {
             if (!name) {
                 name = mesh.name;

+ 72 - 8
src/Morph/babylon.morphTargetManager.ts

@@ -1,4 +1,8 @@
 module BABYLON {
+    /**
+     * This class is used to deform meshes using morphing between different targets
+     * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
+     */
     export class MorphTargetManager {
         private _targets = new Array<MorphTarget>();
         private _targetObservable = new Array<Nullable<Observer<boolean>>>();
@@ -11,6 +15,10 @@ module BABYLON {
         private _uniqueId = 0;
         private _tempInfluences = new Array<number>();
 
+        /**
+         * Creates a new MorphTargetManager
+         * @param scene defines the current scene
+         */
         public constructor(scene: Nullable<Scene> = null) {
             if (!scene) {
                 scene = Engine.LastCreatedScene;
@@ -25,42 +33,77 @@ module BABYLON {
             }
         }
 
+        /**
+         * Gets the unique ID of this manager
+         */
         public get uniqueId(): number {
             return this._uniqueId;
         }
 
+        /**
+         * Gets the number of vertices handled by this manager
+         */
         public get vertexCount(): number {
             return this._vertexCount
         }
 
+        /**
+         * Gets a boolean indicating if this manager supports morphing of normals
+         */
         public get supportsNormals(): boolean {
             return this._supportsNormals;
         }
 
+        /**
+         * Gets a boolean indicating if this manager supports morphing of tangents
+         */        
         public get supportsTangents(): boolean {
             return this._supportsTangents;
         }
 
+        /**
+         * Gets the number of targets stored in this manager
+         */
         public get numTargets(): number {
             return this._targets.length;
         }
 
+        /**
+         * Gets the number of influencers (ie. the number of targets with influences > 0)
+         */
         public get numInfluencers(): number {
             return this._activeTargets.length;
         }
 
+        /**
+         * Gets the list of influences (one per target)
+         */
         public get influences(): Float32Array {
             return this._influences;
         }
 
+        /**
+         * Gets the active target at specified index. An active target is a target with an influence > 0
+         * @param index defines the index to check
+         * @returns the requested target
+         */
         public getActiveTarget(index: number): MorphTarget {
             return this._activeTargets.data[index];
         }
 
+        /**
+         * Gets the target at specified index
+         * @param index defines the index to check
+         * @returns the requested target
+         */
         public getTarget(index: number): MorphTarget {
             return this._targets[index];
         }
 
+        /**
+         * Add a new target to this manager
+         * @param target defines the target to add
+         */
         public addTarget(target: MorphTarget): void {
             this._targets.push(target);
             this._targetObservable.push(target.onInfluenceChanged.add(needUpdate => {
@@ -69,6 +112,10 @@ module BABYLON {
             this._syncActiveTargets(true);
         }
 
+        /**
+         * Removes a target from the manager
+         * @param target defines the target to remove
+         */
         public removeTarget(target: MorphTarget): void {
             var index = this._targets.indexOf(target);
             if (index >= 0) {
@@ -80,8 +127,8 @@ module BABYLON {
         }
 
         /**
-         * Serializes the current manager into a Serialization object.  
-         * Returns the serialized object.  
+         * Serializes the current manager into a Serialization object
+         * @returns the serialized object
          */
         public serialize(): any {
             var serializationObject:any = {};
@@ -130,17 +177,34 @@ module BABYLON {
                 this._influences[index] = this._tempInfluences[index];
             }
 
-            if (needUpdate && this._scene) {
-                // Flag meshes as dirty to resync with the active targets
-                for (var mesh of this._scene.meshes) {
-                    if ((<any>mesh).morphTargetManager === this) {
-                        (<Mesh>mesh)._syncGeometryWithMorphTargetManager();
-                    }
+            if (needUpdate) {
+                this.synchronize();
+            }
+        }
+
+        /**
+         * Syncrhonize the targets with all the meshes using this morph target manager
+         */
+        public synchronize(): void {
+            if (!this._scene) {
+                return;
+            }
+            // Flag meshes as dirty to resync with the active targets
+            for (var mesh of this._scene.meshes) {
+                if ((<any>mesh).morphTargetManager === this) {
+                    (<Mesh>mesh)._syncGeometryWithMorphTargetManager();
                 }
             }
         }
 
         // Statics
+
+        /**
+         * Creates a new MorphTargetManager from serialized data
+         * @param serializationObject defines the serialized data
+         * @param scene defines the hosting scene
+         * @returns the new MorphTargetManager
+         */
         public static Parse(serializationObject: any, scene: Scene): MorphTargetManager {
             var result = new MorphTargetManager(scene);