@@ -101,25 +101,29 @@ export class BufferRecorder extends BaseRecorder<WebGLBuffer> {
101
101
102
102
protected getLength ( functionInformation : IFunctionInformation ) : number {
103
103
/* tslint:disable */
104
- let length = - 1 ;
105
- let offset = 0 ;
106
- if ( functionInformation . arguments . length === 5 ) {
107
- length = functionInformation . arguments [ 4 ] ;
108
- offset = functionInformation . arguments [ 3 ] ;
109
- }
110
-
111
- if ( length <= 0 ) {
112
- if ( typeof functionInformation . arguments [ 1 ] === "number" ) {
113
- length = functionInformation . arguments [ 1 ] ;
114
- }
115
- else if ( functionInformation . arguments [ 1 ] ) {
116
- length = functionInformation . arguments [ 1 ] . byteLength || functionInformation . arguments [ 1 ] . length || 0 ;
117
- }
118
- else {
119
- length = 0 ;
120
- }
121
- }
122
-
123
- return length - offset ;
104
+ const sizeOrData = functionInformation . arguments [ 1 ] ;
105
+ const offset = functionInformation . arguments [ 3 ] ;
106
+ const length = functionInformation . arguments [ 4 ] ;
107
+
108
+ // bufferData(target, size, usage)
109
+ if ( typeof sizeOrData === 'number' ) {
110
+ return sizeOrData ;
111
+ }
112
+
113
+ // bufferData(target, srcData, usage, srcOffset, length)
114
+ if ( typeof length === 'number' && length > 0 ) {
115
+ return length ;
116
+ }
117
+
118
+ const dataLength = sizeOrData . byteLength || sizeOrData . length || 0 ;
119
+
120
+ // bufferData(target, srcData, usage, srcOffset)
121
+ if ( typeof offset === 'number' && offset > 0 ) {
122
+ return dataLength - offset ;
123
+ }
124
+ // bufferData(target, srcData, usage)
125
+ else {
126
+ return dataLength ;
127
+ }
124
128
}
125
129
}
0 commit comments