Prechádzať zdrojové kódy

Pass useBytes in updateVerticesDataDirectly in Geometry & VertexBuffer

Alexandre Carvallo 7 rokov pred
rodič
commit
30f976a137

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

@@ -123,13 +123,13 @@
          * @param vertexCount the vertex count (optional)
          * @param useBytes set to true if the offset is in bytes
          */
-        public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes = false): void {
+        public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {
             if (!this._buffer) {
                 return;
             }
 
             if (this._updatable) { // update buffer
-                this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * 4, (vertexCount ? vertexCount * this.byteStride : undefined));
+                this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * this.byteStride, (vertexCount ? vertexCount * this.byteStride : undefined));
                 this._data = null;
             }
         }

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

@@ -271,15 +271,16 @@
          * @param kind defines the data kind (Position, normal, etc...)
          * @param data defines the data to use 
          * @param offset defines the offset in the target buffer where to store the data
+         * @param useBytes set to true if the offset is in bytes
          */
-        public updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void {
+        public updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes: boolean = false): void {
             var vertexBuffer = this.getVertexBuffer(kind);
 
             if (!vertexBuffer) {
                 return;
             }
 
-            vertexBuffer.updateDirectly(data, offset);
+            vertexBuffer.updateDirectly(data, offset, useBytes);
             this.notifyUpdate(kind);
         }
 

+ 6 - 3
src/Mesh/babylon.vertexBuffer.ts

@@ -232,10 +232,13 @@
 
         /**
          * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.  
-         * Returns the directly updated WebGLBuffer. 
+         * Returns the directly updated WebGLBuffer.
+         * @param data the new data
+         * @param offset the new offset
+         * @param useBytes set to true if the offset is in bytes
          */
-        public updateDirectly(data: DataArray, offset: number): void {
-            return this._buffer.updateDirectly(data, offset);
+        public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {
+            return this._buffer.updateDirectly(data, offset, undefined, useBytes);
         }
 
         /**