twgl.js 4.24.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -349,8 +349,7 @@ function makeTypedArray(array, name) {
349
349
  * @property {boolean} [normalize] whether or not to normalize the data. Default = false
350
350
  * @property {number} [offset] offset into buffer in bytes. Default = 0
351
351
  * @property {number} [stride] the stride in bytes per element. Default = 0
352
- * @property {number} [divisor] the divisor in instances. Default = undefined. Note: undefined = don't call gl.vertexAttribDivisor
353
- * where as anything else = do call it with this value
352
+ * @property {number} [divisor] the divisor in instances. Default = 0. Requires WebGL2 or the ANGLE_instanced_arrays extension.
354
353
  * @property {WebGLBuffer} buffer the buffer that contains the data for this attribute
355
354
  * @property {number} [drawType] the draw type passed to gl.bufferData. Default = gl.STATIC_DRAW
356
355
  * @memberOf module:twgl
@@ -372,8 +371,7 @@ function makeTypedArray(array, name) {
372
371
  * @property {boolean} [normalize] normalize for `vertexAttribPointer`. Default is true if type is `Int8Array` or `Uint8Array` otherwise false.
373
372
  * @property {number} [stride] stride for `vertexAttribPointer`. Default = 0
374
373
  * @property {number} [offset] offset for `vertexAttribPointer`. Default = 0
375
- * @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = undefined. Note: undefined = don't call gl.vertexAttribDivisor
376
- * where as anything else = do call it with this value
374
+ * @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0. Requires WebGL2 or the ANGLE_instanced_arrays extension.
377
375
  * @property {string} [attrib] name of attribute this array maps to. Defaults to same name as array prefixed by the default attribPrefix.
378
376
  * @property {string} [name] synonym for `attrib`.
379
377
  * @property {string} [attribName] synonym for `attrib`.
@@ -2966,7 +2964,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
2966
2964
  *
2967
2965
  * example:
2968
2966
  *
2969
- * const arrays = twgl.primitives.createPlaneArrays(1);
2967
+ * const arrays = twgl.primitives.createPlaneVertices(1);
2970
2968
  * twgl.primitives.reorientVertices(arrays, m4.rotationX(Math.PI * 0.5));
2971
2969
  * const bufferInfo = twgl.createBufferInfoFromArrays(gl, arrays);
2972
2970
  *
@@ -5350,8 +5348,8 @@ function floatAttribSetter(gl, index) {
5350
5348
  gl.enableVertexAttribArray(index);
5351
5349
  gl.vertexAttribPointer(index, b.numComponents || b.size, b.type || FLOAT, b.normalize || false, b.stride || 0, b.offset || 0);
5352
5350
 
5353
- if (b.divisor !== undefined) {
5354
- gl.vertexAttribDivisor(index, b.divisor);
5351
+ if (gl.vertexAttribDivisor) {
5352
+ gl.vertexAttribDivisor(index, b.divisor || 0);
5355
5353
  }
5356
5354
  }
5357
5355
  };
@@ -5372,8 +5370,8 @@ function intAttribSetter(gl, index) {
5372
5370
  gl.enableVertexAttribArray(index);
5373
5371
  gl.vertexAttribIPointer(index, b.numComponents || b.size, b.type || INT, b.stride || 0, b.offset || 0);
5374
5372
 
5375
- if (b.divisor !== undefined) {
5376
- gl.vertexAttribDivisor(index, b.divisor);
5373
+ if (gl.vertexAttribDivisor) {
5374
+ gl.vertexAttribDivisor(index, b.divisor || 0);
5377
5375
  }
5378
5376
  }
5379
5377
  };
@@ -5394,8 +5392,8 @@ function uintAttribSetter(gl, index) {
5394
5392
  gl.enableVertexAttribArray(index);
5395
5393
  gl.vertexAttribIPointer(index, b.numComponents || b.size, b.type || UNSIGNED_INT, b.stride || 0, b.offset || 0);
5396
5394
 
5397
- if (b.divisor !== undefined) {
5398
- gl.vertexAttribDivisor(index, b.divisor);
5395
+ if (gl.vertexAttribDivisor) {
5396
+ gl.vertexAttribDivisor(index, b.divisor || 0);
5399
5397
  }
5400
5398
  }
5401
5399
  };
@@ -5419,8 +5417,8 @@ function matAttribSetter(gl, index, typeInfo) {
5419
5417
  gl.enableVertexAttribArray(index + i);
5420
5418
  gl.vertexAttribPointer(index + i, size, type, normalize, stride, offset + rowOffset * i);
5421
5419
 
5422
- if (b.divisor !== undefined) {
5423
- gl.vertexAttribDivisor(index + i, b.divisor);
5420
+ if (gl.vertexAttribDivisor) {
5421
+ gl.vertexAttribDivisor(index + i, b.divisor || 0);
5424
5422
  }
5425
5423
  }
5426
5424
  };
@@ -2148,8 +2148,7 @@ function makeTypedArray(array, name) {
2148
2148
  * @property {boolean} [normalize] whether or not to normalize the data. Default = false
2149
2149
  * @property {number} [offset] offset into buffer in bytes. Default = 0
2150
2150
  * @property {number} [stride] the stride in bytes per element. Default = 0
2151
- * @property {number} [divisor] the divisor in instances. Default = undefined. Note: undefined = don't call gl.vertexAttribDivisor
2152
- * where as anything else = do call it with this value
2151
+ * @property {number} [divisor] the divisor in instances. Default = 0. Requires WebGL2 or the ANGLE_instanced_arrays extension.
2153
2152
  * @property {WebGLBuffer} buffer the buffer that contains the data for this attribute
2154
2153
  * @property {number} [drawType] the draw type passed to gl.bufferData. Default = gl.STATIC_DRAW
2155
2154
  * @memberOf module:twgl
@@ -2171,8 +2170,7 @@ function makeTypedArray(array, name) {
2171
2170
  * @property {boolean} [normalize] normalize for `vertexAttribPointer`. Default is true if type is `Int8Array` or `Uint8Array` otherwise false.
2172
2171
  * @property {number} [stride] stride for `vertexAttribPointer`. Default = 0
2173
2172
  * @property {number} [offset] offset for `vertexAttribPointer`. Default = 0
2174
- * @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = undefined. Note: undefined = don't call gl.vertexAttribDivisor
2175
- * where as anything else = do call it with this value
2173
+ * @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0. Requires WebGL2 or the ANGLE_instanced_arrays extension.
2176
2174
  * @property {string} [attrib] name of attribute this array maps to. Defaults to same name as array prefixed by the default attribPrefix.
2177
2175
  * @property {string} [name] synonym for `attrib`.
2178
2176
  * @property {string} [attribName] synonym for `attrib`.
@@ -7141,8 +7139,8 @@ function floatAttribSetter(gl, index) {
7141
7139
  gl.enableVertexAttribArray(index);
7142
7140
  gl.vertexAttribPointer(
7143
7141
  index, b.numComponents || b.size, b.type || FLOAT$3, b.normalize || false, b.stride || 0, b.offset || 0);
7144
- if (b.divisor !== undefined) {
7145
- gl.vertexAttribDivisor(index, b.divisor);
7142
+ if (gl.vertexAttribDivisor) {
7143
+ gl.vertexAttribDivisor(index, b.divisor || 0);
7146
7144
  }
7147
7145
  }
7148
7146
  };
@@ -7162,8 +7160,8 @@ function intAttribSetter(gl, index) {
7162
7160
  gl.enableVertexAttribArray(index);
7163
7161
  gl.vertexAttribIPointer(
7164
7162
  index, b.numComponents || b.size, b.type || INT$3, b.stride || 0, b.offset || 0);
7165
- if (b.divisor !== undefined) {
7166
- gl.vertexAttribDivisor(index, b.divisor);
7163
+ if (gl.vertexAttribDivisor) {
7164
+ gl.vertexAttribDivisor(index, b.divisor || 0);
7167
7165
  }
7168
7166
  }
7169
7167
  };
@@ -7183,8 +7181,8 @@ function uintAttribSetter(gl, index) {
7183
7181
  gl.enableVertexAttribArray(index);
7184
7182
  gl.vertexAttribIPointer(
7185
7183
  index, b.numComponents || b.size, b.type || UNSIGNED_INT$3, b.stride || 0, b.offset || 0);
7186
- if (b.divisor !== undefined) {
7187
- gl.vertexAttribDivisor(index, b.divisor);
7184
+ if (gl.vertexAttribDivisor) {
7185
+ gl.vertexAttribDivisor(index, b.divisor || 0);
7188
7186
  }
7189
7187
  }
7190
7188
  };
@@ -7208,8 +7206,8 @@ function matAttribSetter(gl, index, typeInfo) {
7208
7206
  gl.enableVertexAttribArray(index + i);
7209
7207
  gl.vertexAttribPointer(
7210
7208
  index + i, size, type, normalize, stride, offset + rowOffset * i);
7211
- if (b.divisor !== undefined) {
7212
- gl.vertexAttribDivisor(index + i, b.divisor);
7209
+ if (gl.vertexAttribDivisor) {
7210
+ gl.vertexAttribDivisor(index + i, b.divisor || 0);
7213
7211
  }
7214
7212
  }
7215
7213
  };
package/dist/4.x/twgl.js CHANGED
@@ -349,8 +349,7 @@ function makeTypedArray(array, name) {
349
349
  * @property {boolean} [normalize] whether or not to normalize the data. Default = false
350
350
  * @property {number} [offset] offset into buffer in bytes. Default = 0
351
351
  * @property {number} [stride] the stride in bytes per element. Default = 0
352
- * @property {number} [divisor] the divisor in instances. Default = undefined. Note: undefined = don't call gl.vertexAttribDivisor
353
- * where as anything else = do call it with this value
352
+ * @property {number} [divisor] the divisor in instances. Default = 0. Requires WebGL2 or the ANGLE_instanced_arrays extension.
354
353
  * @property {WebGLBuffer} buffer the buffer that contains the data for this attribute
355
354
  * @property {number} [drawType] the draw type passed to gl.bufferData. Default = gl.STATIC_DRAW
356
355
  * @memberOf module:twgl
@@ -372,8 +371,7 @@ function makeTypedArray(array, name) {
372
371
  * @property {boolean} [normalize] normalize for `vertexAttribPointer`. Default is true if type is `Int8Array` or `Uint8Array` otherwise false.
373
372
  * @property {number} [stride] stride for `vertexAttribPointer`. Default = 0
374
373
  * @property {number} [offset] offset for `vertexAttribPointer`. Default = 0
375
- * @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = undefined. Note: undefined = don't call gl.vertexAttribDivisor
376
- * where as anything else = do call it with this value
374
+ * @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0. Requires WebGL2 or the ANGLE_instanced_arrays extension.
377
375
  * @property {string} [attrib] name of attribute this array maps to. Defaults to same name as array prefixed by the default attribPrefix.
378
376
  * @property {string} [name] synonym for `attrib`.
379
377
  * @property {string} [attribName] synonym for `attrib`.
@@ -2261,8 +2259,8 @@ function floatAttribSetter(gl, index) {
2261
2259
  gl.enableVertexAttribArray(index);
2262
2260
  gl.vertexAttribPointer(index, b.numComponents || b.size, b.type || FLOAT, b.normalize || false, b.stride || 0, b.offset || 0);
2263
2261
 
2264
- if (b.divisor !== undefined) {
2265
- gl.vertexAttribDivisor(index, b.divisor);
2262
+ if (gl.vertexAttribDivisor) {
2263
+ gl.vertexAttribDivisor(index, b.divisor || 0);
2266
2264
  }
2267
2265
  }
2268
2266
  };
@@ -2283,8 +2281,8 @@ function intAttribSetter(gl, index) {
2283
2281
  gl.enableVertexAttribArray(index);
2284
2282
  gl.vertexAttribIPointer(index, b.numComponents || b.size, b.type || INT, b.stride || 0, b.offset || 0);
2285
2283
 
2286
- if (b.divisor !== undefined) {
2287
- gl.vertexAttribDivisor(index, b.divisor);
2284
+ if (gl.vertexAttribDivisor) {
2285
+ gl.vertexAttribDivisor(index, b.divisor || 0);
2288
2286
  }
2289
2287
  }
2290
2288
  };
@@ -2305,8 +2303,8 @@ function uintAttribSetter(gl, index) {
2305
2303
  gl.enableVertexAttribArray(index);
2306
2304
  gl.vertexAttribIPointer(index, b.numComponents || b.size, b.type || UNSIGNED_INT, b.stride || 0, b.offset || 0);
2307
2305
 
2308
- if (b.divisor !== undefined) {
2309
- gl.vertexAttribDivisor(index, b.divisor);
2306
+ if (gl.vertexAttribDivisor) {
2307
+ gl.vertexAttribDivisor(index, b.divisor || 0);
2310
2308
  }
2311
2309
  }
2312
2310
  };
@@ -2330,8 +2328,8 @@ function matAttribSetter(gl, index, typeInfo) {
2330
2328
  gl.enableVertexAttribArray(index + i);
2331
2329
  gl.vertexAttribPointer(index + i, size, type, normalize, stride, offset + rowOffset * i);
2332
2330
 
2333
- if (b.divisor !== undefined) {
2334
- gl.vertexAttribDivisor(index + i, b.divisor);
2331
+ if (gl.vertexAttribDivisor) {
2332
+ gl.vertexAttribDivisor(index + i, b.divisor || 0);
2335
2333
  }
2336
2334
  }
2337
2335
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twgl.js",
3
- "version": "4.24.0",
3
+ "version": "5.0.0",
4
4
  "description": "A Tiny WebGL helper library",
5
5
  "main": "dist/4.x/twgl-full.js",
6
6
  "types": "dist/4.x/twgl-full.d.ts",