David Catuhe 7 лет назад
Родитель
Сommit
581d5053c9

Разница между файлами не показана из-за своего большого размера
+ 8675 - 8117
Playground/babylon.d.txt


Разница между файлами не показана из-за своего большого размера
+ 5207 - 5084
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/babylon.js


Разница между файлами не показана из-за своего большого размера
+ 657 - 251
dist/preview release/babylon.max.js


Разница между файлами не показана из-за своего большого размера
+ 657 - 251
dist/preview release/babylon.no-module.max.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/babylon.worker.js


Разница между файлами не показана из-за своего большого размера
+ 659 - 253
dist/preview release/es6.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
dist/preview release/serializers/babylonjs.serializers.min.js


Разница между файлами не показана из-за своего большого размера
+ 144 - 1125
dist/preview release/typedocValidationBaseline.json


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 2 - 2
src/Mesh/babylon.mesh.ts

@@ -1238,7 +1238,7 @@
                         indexToBind = null;
                         break;
                     case Material.WireFrameFillMode:
-                        indexToBind = subMesh.getLinesIndexBuffer(<IndicesArray>this.getIndices(), engine);
+                        indexToBind = subMesh._getLinesIndexBuffer(<IndicesArray>this.getIndices(), engine);
                         break;
                     default:
                     case Material.TriangleFillMode:
@@ -1270,7 +1270,7 @@
                 engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
             } else if (fillMode == Material.WireFrameFillMode) {
                 // Triangles as wireframe
-                engine.drawElementsType(fillMode, 0, subMesh.linesIndexCount, instancesCount);
+                engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
             } else {
                 engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
             }

+ 77 - 8
src/Mesh/babylon.meshSimplification.ts

@@ -1,6 +1,7 @@
 module BABYLON {
     /**
-     * A simplifier interface for future simplification implementations.
+     * A simplifier interface for future simplification implementations
+     * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
      */
     export interface ISimplifier {
         /**
@@ -16,40 +17,102 @@
 
     /**
      * Expected simplification settings.
-     * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
+     * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
+     * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
      */
     export interface ISimplificationSettings {
+        /**
+         * Gets or sets the expected quality
+         */
         quality: number;
+        /**
+         * Gets or sets the distance when this optimized version should be used
+         */
         distance: number;
+        /**
+         * Gets an already optimized mesh
+         */
         optimizeMesh?: boolean;
     }
 
+    /**
+     * Class used to specify simplification options
+     * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
+     */
     export class SimplificationSettings implements ISimplificationSettings {
-        constructor(public quality: number, public distance: number, public optimizeMesh?: boolean) {
+        /**
+         * Creates a SimplificationSettings
+         * @param quality expected quality
+         * @param distance distance when this optimized version should be used
+         * @param optimizeMesh already optimized mesh
+         */
+        constructor(
+            /** expected quality */
+            public quality: number, 
+            /** distance when this optimized version should be used */
+            public distance: number, 
+            /** already optimized mesh  */
+            public optimizeMesh?: boolean) {
         }
     }
 
+    /**
+     * Interface used to define a simplification task
+     */
     export interface ISimplificationTask {
+        /**
+         * Array of settings
+         */
         settings: Array<ISimplificationSettings>;
+        /**
+         * Simplification type
+         */
         simplificationType: SimplificationType;
+        /**
+         * Mesh to simplify
+         */
         mesh: Mesh;
+        /**
+         * Callback called on success
+         */
         successCallback?: () => void;
+        /**
+         * Defines if parallel processing can be used
+         */
         parallelProcessing: boolean;
     }
 
+    /**
+     * Queue used to order the simplification tasks
+     * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
+     */
     export class SimplificationQueue {
         private _simplificationArray: Array<ISimplificationTask>;
+
+        /**
+         * Gets a boolean indicating that the process is still running
+         */
         public running: boolean;
 
+        /**
+         * Creates a new queue
+         */
         constructor() {
             this.running = false;
             this._simplificationArray = [];
         }
 
+        /**
+         * Adds a new simplification task
+         * @param task defines a task to add
+         */
         public addTask(task: ISimplificationTask) {
             this._simplificationArray.push(task);
         }
 
+        /**
+         * Execute next task
+         */
         public executeNext() {
             var task = this._simplificationArray.pop();
             if (task) {
@@ -60,6 +123,10 @@
             }
         }
 
+        /**
+         * Execute a simplification task
+         * @param task defines the task to run
+         */
         public runSimplification(task: ISimplificationTask) {
             if (task.parallelProcessing) {
                 //parallel simplifier
@@ -115,13 +182,14 @@
     /**
      * The implemented types of simplification
      * At the moment only Quadratic Error Decimation is implemented
+     * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
      */
     export enum SimplificationType {
         /** Quadratic error decimation */
         QUADRATIC
     }
 
-    export class DecimationTriangle {
+     class DecimationTriangle {
         public normal: Vector3;
         public error: Array<number>;
         public deleted: boolean;
@@ -140,7 +208,7 @@
         }
     }
 
-    export class DecimationVertex {
+    class DecimationVertex {
         public q: QuadraticMatrix;
         public isBorder: boolean;
 
@@ -162,7 +230,7 @@
         }
     }
 
-    export class QuadraticMatrix {
+    class QuadraticMatrix {
         public data: Array<number>;
 
         constructor(data?: Array<number>) {
@@ -213,7 +281,7 @@
         }
     }
 
-    export class Reference {
+    class Reference {
         constructor(public vertexId: number, public triangleId: number) { }
     }
 
@@ -222,8 +290,9 @@
      * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
      * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
      * @author RaananW
+     * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
      */
-    export class QuadraticErrorSimplification implements ISimplifier {
+    class QuadraticErrorSimplification implements ISimplifier {
 
         private triangles: Array<DecimationTriangle>;
         private vertices: Array<DecimationVertex>;

+ 104 - 34
src/Mesh/babylon.subMesh.ts

@@ -1,14 +1,25 @@
 module BABYLON {
+    /**
+     * Base class for submeshes
+     */
     export class BaseSubMesh {
         /** @hidden */
         public _materialDefines: Nullable<MaterialDefines>;
         /** @hidden */
         public _materialEffect: Nullable<Effect>;
 
+        /**
+         * Gets associated effect
+         */
         public get effect(): Nullable<Effect> {
             return this._materialEffect;
         }
 
+        /**
+         * Sets associated effect (effect used to render this submesh)
+         * @param effect defines the effect to associate with
+         * @param defines defines the set of defines used to compile this effect
+         */
         public setEffect(effect: Nullable<Effect>, defines: Nullable<MaterialDefines> = null) {
             if (this._materialEffect === effect) {
                 if (!effect) {
@@ -21,9 +32,12 @@
         }
     }
 
+    /**
+     * Defines a subdivision inside a mesh
+     */
     export class SubMesh extends BaseSubMesh implements ICullable {
-        public linesIndexCount: number;
-
+        /** @hidden */
+        public _linesIndexCount: number;
         private _mesh: AbstractMesh;
         private _renderingMesh: Mesh;
         private _boundingInfo: BoundingInfo;
@@ -46,11 +60,44 @@
 
         private _currentMaterial: Nullable<Material>;
 
+        /**
+         * Add a new submesh to a mesh
+         * @param materialIndex defines the material index to use
+         * @param verticesStart defines vertex index start
+         * @param verticesCount defines vertices count
+         * @param indexStart defines index start
+         * @param indexCount defines indices count
+         * @param mesh defines the parent mesh
+         * @param renderingMesh defines an optional rendering mesh
+         * @param createBoundingBox defines if bounding box should be created for this submesh
+         * @returns the new submesh
+         */
         public static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox: boolean = true): SubMesh {
             return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
         }
 
-        constructor(public materialIndex: number, public verticesStart: number, public verticesCount: number, public indexStart: number, public indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox: boolean = true) {
+        /**
+         * Creates a new submesh
+         * @param materialIndex defines the material index to use
+         * @param verticesStart defines vertex index start
+         * @param verticesCount defines vertices count
+         * @param indexStart defines index start
+         * @param indexCount defines indices count
+         * @param mesh defines the parent mesh
+         * @param renderingMesh defines an optional rendering mesh
+         * @param createBoundingBox defines if bounding box should be created for this submesh
+         */
+        constructor(
+            /** the material index to use */
+            public materialIndex: number, 
+            /** vertex index start */
+            public verticesStart: number, 
+            /** vertices count */
+            public verticesCount: number, 
+            /** index start */
+            public indexStart: number, 
+            /** indices count */
+            public indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox: boolean = true) {
             super();
             this._mesh = mesh;
             this._renderingMesh = renderingMesh || <Mesh>mesh;
@@ -66,12 +113,17 @@
             }
         }
 
+        /**
+         * Returns true if this submesh covers the entire parent mesh
+         * @ignorenaming
+         */
         public get IsGlobal(): boolean {
             return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
         }
 
         /**
-         * Returns the submesh BoudingInfo object.  
+         * Returns the submesh BoudingInfo object
+         * @returns current bounding info (or mesh's one if the submesh is global)
          */
         public getBoundingInfo(): BoundingInfo {
             if (this.IsGlobal) {
@@ -82,8 +134,9 @@
         }
 
         /**
-         * Sets the submesh BoundingInfo.  
-         * Return the SubMesh.  
+         * Sets the submesh BoundingInfo  
+         * @param boundingInfo defines the new bounding info to use
+         * @returns the SubMesh
          */
         public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {
             this._boundingInfo = boundingInfo;
@@ -91,21 +144,24 @@
         }
 
         /** 
-         * Returns the mesh of the current submesh.  
+         * Returns the mesh of the current submesh
+         * @return the parent mesh
          */
         public getMesh(): AbstractMesh {
             return this._mesh;
         }
 
         /**
-         * Returns the rendering mesh of the submesh.  
+         * Returns the rendering mesh of the submesh
+         * @returns the rendering mesh (could be different from parent mesh)
          */
         public getRenderingMesh(): Mesh {
             return this._renderingMesh;
         }
 
         /**
-         * Returns the submesh material.  
+         * Returns the submesh material
+         * @returns null or the current material
          */
         public getMaterial(): Nullable<Material> {
             var rootMaterial = this._renderingMesh.material;
@@ -128,9 +184,10 @@
         }
 
         // Methods
+
         /**
-         * Sets a new updated BoundingInfo object to the submesh.  
-         * Returns the SubMesh.  
+         * Sets a new updated BoundingInfo object to the submesh
+         * @returns the SubMesh 
          */
         public refreshBoundingInfo(): SubMesh {
             this._lastColliderWorldVertices = null;
@@ -169,8 +226,9 @@
         }
 
         /**
-         * Updates the submesh BoundingInfo.  
-         * Returns the Submesh.  
+         * Updates the submesh BoundingInfo
+         * @param world defines the world matrix to use to update the bounding info
+         * @returns the submesh
          */
         public updateBoundingInfo(world: Matrix): SubMesh {
             let boundingInfo = this.getBoundingInfo();
@@ -185,7 +243,8 @@
 
         /**
          * True is the submesh bounding box intersects the frustum defined by the passed array of planes.  
-         * Boolean returned.  
+         * @param frustumPlanes defines the frustum planes
+         * @returns true if the submesh is intersecting with the frustum  
          */
         public isInFrustum(frustumPlanes: Plane[]): boolean {
             let boundingInfo = this.getBoundingInfo();
@@ -197,8 +256,9 @@
         }
 
         /**
-         * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.  
-         * Boolean returned.  
+         * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
+         * @param frustumPlanes defines the frustum planes
+         * @returns true if the submesh is inside the frustum  
          */
         public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {
             let boundingInfo = this.getBoundingInfo();
@@ -210,8 +270,9 @@
         }
 
         /**
-         * Renders the submesh.  
-         * Returns it.  
+         * Renders the submesh  
+         * @param enableAlphaMode defines if alpha needs to be used
+         * @returns the submesh
          */
         public render(enableAlphaMode: boolean): SubMesh {
             this._renderingMesh.render(this, enableAlphaMode);
@@ -219,10 +280,9 @@
         }
 
         /**
-         * Returns a new Index Buffer.  
-         * Type returned : WebGLBuffer.  
+         * @hidden 
          */
-        public getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer {
+        public _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer {
             if (!this._linesIndexBuffer) {
                 var linesIndices = [];
 
@@ -233,14 +293,15 @@
                 }
 
                 this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
-                this.linesIndexCount = linesIndices.length;
+                this._linesIndexCount = linesIndices.length;
             }
             return this._linesIndexBuffer;
         }
 
         /**
-         * True is the passed Ray intersects the submesh bounding box.  
-         * Boolean returned.  
+         * Checks if the submesh intersects with a ray
+         * @param ray defines the ray to test
+         * @returns true is the passed ray intersects the submesh bounding box
          */
         public canIntersects(ray: Ray): boolean {
             let boundingInfo = this.getBoundingInfo();
@@ -252,7 +313,12 @@
         }
 
         /**
-         * Returns an object IntersectionInfo.  
+         * Intersects current submesh with a ray
+         * @param ray defines the ray to test
+         * @param positions defines mesh's positions array
+         * @param indices defines mesh's indices array
+         * @param fastCheck defines if only bounding info should be used
+         * @returns intersection info or null if no intersection
          */
         public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo> {
             var intersectInfo: Nullable<IntersectionInfo> = null;
@@ -333,7 +399,10 @@
 
         // Clone    
         /**
-         * Creates a new Submesh from the passed Mesh.  
+         * Creates a new submesh from the passed mesh
+         * @param newMesh defines the new hosting mesh
+         * @param newRenderingMesh defines an optional rendering mesh
+         * @returns the new submesh
          */
         public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {
             var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
@@ -352,9 +421,9 @@
         }
 
         // Dispose
+
         /**
-         * Disposes the Submesh.  
-         * Returns nothing.  
+         * Release associated resources
          */
         public dispose(): void {
             if (this._linesIndexBuffer) {
@@ -369,12 +438,13 @@
 
         // Statics
         /**
-         * Creates a new Submesh from the passed parameters : 
-         * - materialIndex (integer) : the index of the main mesh material.  
-         * - startIndex (integer) : the index where to start the copy in the mesh indices array.  
-         * - indexCount (integer) : the number of indices to copy then from the startIndex.  
-         * - mesh (Mesh) : the main mesh to create the submesh from.  
-         * - renderingMesh (optional Mesh) : rendering mesh.  
+         * Creates a new submesh from indices data
+         * @param materialIndex the index of the main mesh material
+         * @param startIndex the index where to start the copy in the mesh indices array
+         * @param indexCount the number of indices to copy then from the startIndex
+         * @param mesh the main mesh to create the submesh from
+         * @param renderingMesh the optional rendering mesh
+         * @returns a new submesh
          */
         public static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh {
             var minVertexIndex = Number.MAX_VALUE;