David Catuhe 7 лет назад
Родитель
Сommit
95ae80cee4
28 измененных файлов с 22118 добавлено и 21962 удалено
  1. 1146 1137
      dist/preview release/babylon.d.ts
  2. 44 44
      dist/preview release/babylon.js
  3. 47 9
      dist/preview release/babylon.max.js
  4. 1146 1137
      dist/preview release/babylon.module.d.ts
  5. 45 45
      dist/preview release/babylon.worker.js
  6. 9627 9618
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  7. 47 47
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  8. 47 9
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  9. 9627 9618
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  10. 3 3
      dist/preview release/gui/babylon.gui.min.js
  11. 263 263
      dist/preview release/inspector/babylon.inspector.bundle.js
  12. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  13. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  14. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  15. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  16. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  17. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  18. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  19. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  20. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  21. 3 3
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  22. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  23. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  24. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  25. 17 2
      src/Engine/babylon.engine.ts
  26. 17 3
      src/Mesh/babylon.geometry.ts
  27. 18 3
      src/Mesh/babylon.mesh.ts
  28. 2 2
      src/Mesh/babylon.mesh.vertexData.ts

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


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


+ 47 - 9
dist/preview release/babylon.max.js

@@ -9169,6 +9169,19 @@ var BABYLON;
             vbo.references = 1;
             return vbo;
         };
+        Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
+            if (offset === void 0) { offset = 0; }
+            this.bindIndexBuffer(indexBuffer);
+            var arrayBuffer;
+            if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
+                arrayBuffer = indices;
+            }
+            else {
+                arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
+            }
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
+            this._resetIndexBufferBinding();
+        };
         Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, offset, count) {
             this.bindArrayBuffer(vertexBuffer);
             if (offset === undefined) {
@@ -9196,7 +9209,7 @@ var BABYLON;
             this.bindIndexBuffer(null);
             this._cachedIndexBuffer = null;
         };
-        Engine.prototype.createIndexBuffer = function (indices) {
+        Engine.prototype.createIndexBuffer = function (indices, updatable) {
             var vbo = this._gl.createBuffer();
             this.bindIndexBuffer(vbo);
             // Check for 32 bits indices
@@ -9228,7 +9241,7 @@ var BABYLON;
                     arrayBuffer = new Uint16Array(indices);
                 }
             }
-            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.STATIC_DRAW);
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
             this._resetIndexBufferBinding();
             vbo.references = 1;
             vbo.is32Bits = need32Bits;
@@ -22310,16 +22323,28 @@ var BABYLON;
          * This method creates a new index buffer each call.
          * Returns the Mesh.
          */
-        Mesh.prototype.setIndices = function (indices, totalVertices) {
+        Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
             if (!this._geometry) {
                 var vertexData = new BABYLON.VertexData();
                 vertexData.indices = indices;
                 var scene = this.getScene();
-                new BABYLON.Geometry(BABYLON.Geometry.RandomId(), scene, vertexData, false, this);
+                new BABYLON.Geometry(BABYLON.Geometry.RandomId(), scene, vertexData, updatable, this);
             }
             else {
-                this._geometry.setIndices(indices, totalVertices);
+                this._geometry.setIndices(indices, totalVertices, updatable);
+            }
+            return this;
+        };
+        /**
+         * Update the current index buffer
+         * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
+         * Returns the Mesh.
+         */
+        Mesh.prototype.updateIndices = function (indices, offset) {
+            if (!this._geometry) {
+                return;
             }
+            this._geometry.updateIndices(indices, offset);
             return this;
         };
         /**
@@ -27136,7 +27161,7 @@ var BABYLON;
                 meshOrGeometry.setVerticesData(BABYLON.VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
             }
             if (this.indices) {
-                meshOrGeometry.setIndices(this.indices);
+                meshOrGeometry.setIndices(this.indices, null, updatable);
             }
             return this;
         };
@@ -29185,6 +29210,7 @@ var BABYLON;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
             this._totalVertices = 0;
             this._isDisposed = false;
+            this._indexBufferIsUpdatable = false;
             this.id = id;
             this._engine = scene.getEngine();
             this._meshes = [];
@@ -29429,16 +29455,28 @@ var BABYLON;
             }
             return result;
         };
-        Geometry.prototype.setIndices = function (indices, totalVertices) {
+        Geometry.prototype.updateIndices = function (indices, offset) {
+            if (!this._indexBuffer) {
+                return;
+            }
+            if (!this._indexBufferIsUpdatable) {
+                this.setIndices(indices, null, true);
+            }
+            else {
+                this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
+            }
+        };
+        Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
             if (this._indexBuffer) {
                 this._engine._releaseBuffer(this._indexBuffer);
             }
             this._disposeVertexArrayObjects();
             this._indices = indices;
+            this._indexBufferIsUpdatable = updatable;
             if (this._meshes.length !== 0 && this._indices) {
-                this._indexBuffer = this._engine.createIndexBuffer(this._indices);
+                this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
             }
-            if (totalVertices !== undefined) {
+            if (totalVertices != undefined) {
                 this._totalVertices = totalVertices;
             }
             var meshes = this._meshes;

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


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


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


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


+ 47 - 9
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -9169,6 +9169,19 @@ var BABYLON;
             vbo.references = 1;
             return vbo;
         };
+        Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
+            if (offset === void 0) { offset = 0; }
+            this.bindIndexBuffer(indexBuffer);
+            var arrayBuffer;
+            if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
+                arrayBuffer = indices;
+            }
+            else {
+                arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
+            }
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
+            this._resetIndexBufferBinding();
+        };
         Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, offset, count) {
             this.bindArrayBuffer(vertexBuffer);
             if (offset === undefined) {
@@ -9196,7 +9209,7 @@ var BABYLON;
             this.bindIndexBuffer(null);
             this._cachedIndexBuffer = null;
         };
-        Engine.prototype.createIndexBuffer = function (indices) {
+        Engine.prototype.createIndexBuffer = function (indices, updatable) {
             var vbo = this._gl.createBuffer();
             this.bindIndexBuffer(vbo);
             // Check for 32 bits indices
@@ -9228,7 +9241,7 @@ var BABYLON;
                     arrayBuffer = new Uint16Array(indices);
                 }
             }
-            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.STATIC_DRAW);
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
             this._resetIndexBufferBinding();
             vbo.references = 1;
             vbo.is32Bits = need32Bits;
@@ -22310,16 +22323,28 @@ var BABYLON;
          * This method creates a new index buffer each call.
          * Returns the Mesh.
          */
-        Mesh.prototype.setIndices = function (indices, totalVertices) {
+        Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
             if (!this._geometry) {
                 var vertexData = new BABYLON.VertexData();
                 vertexData.indices = indices;
                 var scene = this.getScene();
-                new BABYLON.Geometry(BABYLON.Geometry.RandomId(), scene, vertexData, false, this);
+                new BABYLON.Geometry(BABYLON.Geometry.RandomId(), scene, vertexData, updatable, this);
             }
             else {
-                this._geometry.setIndices(indices, totalVertices);
+                this._geometry.setIndices(indices, totalVertices, updatable);
+            }
+            return this;
+        };
+        /**
+         * Update the current index buffer
+         * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
+         * Returns the Mesh.
+         */
+        Mesh.prototype.updateIndices = function (indices, offset) {
+            if (!this._geometry) {
+                return;
             }
+            this._geometry.updateIndices(indices, offset);
             return this;
         };
         /**
@@ -27136,7 +27161,7 @@ var BABYLON;
                 meshOrGeometry.setVerticesData(BABYLON.VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
             }
             if (this.indices) {
-                meshOrGeometry.setIndices(this.indices);
+                meshOrGeometry.setIndices(this.indices, null, updatable);
             }
             return this;
         };
@@ -29185,6 +29210,7 @@ var BABYLON;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
             this._totalVertices = 0;
             this._isDisposed = false;
+            this._indexBufferIsUpdatable = false;
             this.id = id;
             this._engine = scene.getEngine();
             this._meshes = [];
@@ -29429,16 +29455,28 @@ var BABYLON;
             }
             return result;
         };
-        Geometry.prototype.setIndices = function (indices, totalVertices) {
+        Geometry.prototype.updateIndices = function (indices, offset) {
+            if (!this._indexBuffer) {
+                return;
+            }
+            if (!this._indexBufferIsUpdatable) {
+                this.setIndices(indices, null, true);
+            }
+            else {
+                this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
+            }
+        };
+        Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
             if (this._indexBuffer) {
                 this._engine._releaseBuffer(this._indexBuffer);
             }
             this._disposeVertexArrayObjects();
             this._indices = indices;
+            this._indexBufferIsUpdatable = updatable;
             if (this._meshes.length !== 0 && this._indices) {
-                this._indexBuffer = this._engine.createIndexBuffer(this._indices);
+                this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
             }
-            if (totalVertices !== undefined) {
+            if (totalVertices != undefined) {
                 this._totalVertices = totalVertices;
             }
             var meshes = this._meshes;

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


+ 17 - 2
src/Engine/babylon.engine.ts

@@ -1879,6 +1879,21 @@
             return vbo;
         }
 
+        public updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset: number = 0): void {
+            this.bindIndexBuffer(indexBuffer);
+            var arrayBuffer;
+
+            if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
+                arrayBuffer = indices;
+            } else {
+                arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
+            }
+
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
+            
+            this._resetIndexBufferBinding();
+        }
+
         public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: number[] | Float32Array, offset?: number, count?: number): void {
             this.bindArrayBuffer(vertexBuffer);
 
@@ -1908,7 +1923,7 @@
             this._cachedIndexBuffer = null;
         }
 
-        public createIndexBuffer(indices: IndicesArray): WebGLBuffer {
+        public createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer {
             var vbo = this._gl.createBuffer();
             this.bindIndexBuffer(vbo);
 
@@ -1941,7 +1956,7 @@
                 }
             }
 
-            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.STATIC_DRAW);
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
             this._resetIndexBufferBinding();
             vbo.references = 1;
             vbo.is32Bits = need32Bits;

+ 17 - 3
src/Mesh/babylon.geometry.ts

@@ -18,6 +18,7 @@
         private _boundingBias: Vector2;
         public _delayInfo: Array<string>;
         private _indexBuffer: WebGLBuffer;
+        private _indexBufferIsUpdatable = false;
         public _boundingInfo: BoundingInfo;
         public _delayLoadingFunction: (any: any, geometry: Geometry) => void;
         public _softwareSkinningRenderId: number;
@@ -314,7 +315,19 @@
             return result;
         }
 
-        public setIndices(indices: IndicesArray, totalVertices?: number): void {
+        public updateIndices(indices: IndicesArray, offset?: number): void {
+            if (!this._indexBuffer) {
+                return;
+            }
+
+            if (!this._indexBufferIsUpdatable) {
+                this.setIndices(indices, null, true);
+            } else {
+                this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
+            }
+        }
+
+        public setIndices(indices: IndicesArray, totalVertices?: number, updatable?: boolean): void {
             if (this._indexBuffer) {
                 this._engine._releaseBuffer(this._indexBuffer);
             }
@@ -322,11 +335,12 @@
             this._disposeVertexArrayObjects();
 
             this._indices = indices;
+            this._indexBufferIsUpdatable = updatable;
             if (this._meshes.length !== 0 && this._indices) {
-                this._indexBuffer = this._engine.createIndexBuffer(this._indices);
+                this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
             }
 
-            if (totalVertices !== undefined) {
+            if (totalVertices != undefined) { // including null and undefined
                 this._totalVertices = totalVertices;
             }
 

+ 18 - 3
src/Mesh/babylon.mesh.ts

@@ -840,20 +840,35 @@
          * This method creates a new index buffer each call.  
          * Returns the Mesh.  
          */
-        public setIndices(indices: IndicesArray, totalVertices?: number): Mesh {
+        public setIndices(indices: IndicesArray, totalVertices?: number, updatable?: boolean): Mesh {
             if (!this._geometry) {
                 var vertexData = new VertexData();
                 vertexData.indices = indices;
 
                 var scene = this.getScene();
 
-                new Geometry(Geometry.RandomId(), scene, vertexData, false, this);
+                new Geometry(Geometry.RandomId(), scene, vertexData, updatable, this);
             }
             else {
-                this._geometry.setIndices(indices, totalVertices);
+                this._geometry.setIndices(indices, totalVertices, updatable);
+            }
+            return this;
+        }
+
+        /**
+         * Update the current index buffer
+         * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
+         * Returns the Mesh. 
+         */
+        public updateIndices(indices: IndicesArray, offset?: number): Mesh {
+            if (!this._geometry) {
+                return;
             }
+
+            this._geometry.updateIndices(indices, offset);
             return this;
         }
+        
 
         /**
          * Invert the geometry to move from a right handed system to a left handed one.  

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

@@ -8,7 +8,7 @@
         getIndices(copyWhenShared?: boolean): IndicesArray;
         setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean): void;
         updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean, makeItUnique?: boolean): void;
-        setIndices(indices: IndicesArray): void;
+        setIndices(indices: IndicesArray, totalVertices?: number, updatable?: boolean): void;
     }
 
     export class VertexData {
@@ -171,7 +171,7 @@
             }
 
             if (this.indices) {
-                meshOrGeometry.setIndices(this.indices);
+                meshOrGeometry.setIndices(this.indices, null, updatable);
             }
             return this;
         }