twgl.js 4.21.2 → 4.22.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.
package/README.md CHANGED
@@ -427,7 +427,7 @@ If you just want to set the 2nd light in TWGL you can do this
427
427
  const progInfo = twgl.createProgramInfo(gl, [vs, fs]);
428
428
  ...
429
429
  twgl.setUniforms(progInfo, {
430
- lights[1]: { intensity: 5.0, shininess: 100, color: [1, 0, 0, 1] },
430
+ 'lights[1]': { intensity: 5.0, shininess: 100, color: [1, 0, 0, 1] },
431
431
  });
432
432
  ```
433
433
 
@@ -68,6 +68,7 @@ export type AttachmentOptions = TextureOptions & {
68
68
  format?: number;
69
69
  type?: number;
70
70
  target?: number;
71
+ samples?: number;
71
72
  level?: number;
72
73
  layer?: number;
73
74
  attachment?: WebGLRenderbuffer | WebGLTexture;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @license twgl.js 4.21.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
+ * @license twgl.js 4.22.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
3
3
  * Available via the MIT license.
4
4
  * see: http://github.com/greggman/twgl.js for details
5
5
  */
@@ -1197,6 +1197,7 @@ var LINEAR = 0x2601;
1197
1197
  * @property {number} [type] The type. Used for texture. Default = `gl.UNSIGNED_BYTE`.
1198
1198
  * @property {number} [target] The texture target for `gl.framebufferTexture2D`.
1199
1199
  * Defaults to `gl.TEXTURE_2D`. Set to appropriate face for cube maps.
1200
+ * @property {number} [samples] The number of samples. Default = 1
1200
1201
  * @property {number} [level] level for `gl.framebufferTexture2D`. Defaults to 0.
1201
1202
  * @property {number} [layer] layer for `gl.framebufferTextureLayer`. Defaults to undefined.
1202
1203
  * If set then `gl.framebufferTextureLayer` is called, if not then `gl.framebufferTexture2D`
@@ -1305,6 +1306,7 @@ function createFramebufferInfo(gl, attachments, width, height) {
1305
1306
  };
1306
1307
  attachments.forEach(function (attachmentOptions) {
1307
1308
  var attachment = attachmentOptions.attachment;
1309
+ var samples = attachmentOptions.samples;
1308
1310
  var format = attachmentOptions.format;
1309
1311
  var attachmentPoint = attachmentOptions.attachmentPoint || getAttachmentPointForFormat(format, attachmentOptions.internalFormat);
1310
1312
 
@@ -1313,10 +1315,15 @@ function createFramebufferInfo(gl, attachments, width, height) {
1313
1315
  }
1314
1316
 
1315
1317
  if (!attachment) {
1316
- if (isRenderbufferFormat(format)) {
1318
+ if (samples !== undefined || isRenderbufferFormat(format)) {
1317
1319
  attachment = gl.createRenderbuffer();
1318
1320
  gl.bindRenderbuffer(RENDERBUFFER, attachment);
1319
- gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1321
+
1322
+ if (samples > 1) {
1323
+ gl.renderbufferStorageMultisample(RENDERBUFFER, samples, format, width, height);
1324
+ } else {
1325
+ gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1326
+ }
1320
1327
  } else {
1321
1328
  var textureOptions = Object.assign({}, attachmentOptions);
1322
1329
  textureOptions.width = width;
@@ -1404,10 +1411,16 @@ function resizeFramebufferInfo(gl, framebufferInfo, attachments, width, height)
1404
1411
  attachments.forEach(function (attachmentOptions, ndx) {
1405
1412
  var attachment = framebufferInfo.attachments[ndx];
1406
1413
  var format = attachmentOptions.format;
1414
+ var samples = attachmentOptions.samples;
1407
1415
 
1408
- if (helper.isRenderbuffer(gl, attachment)) {
1416
+ if (samples !== undefined || helper.isRenderbuffer(gl, attachment)) {
1409
1417
  gl.bindRenderbuffer(RENDERBUFFER, attachment);
1410
- gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1418
+
1419
+ if (samples > 1) {
1420
+ gl.renderbufferStorageMultisample(RENDERBUFFER, samples, format, width, height);
1421
+ } else {
1422
+ gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1423
+ }
1411
1424
  } else if (helper.isTexture(gl, attachment)) {
1412
1425
  textures.resizeTexture(gl, attachment, attachmentOptions, width, height);
1413
1426
  } else {
@@ -6424,6 +6437,7 @@ function setUniformBlock(gl, programInfo, uniformBlockInfo) {
6424
6437
  * struct Light {
6425
6438
  * float intensity;
6426
6439
  * vec4 color;
6440
+ * float nearFar[2];
6427
6441
  * };
6428
6442
  * uniform Lights {
6429
6443
  * Light lights[2];
@@ -6433,28 +6447,35 @@ function setUniformBlock(gl, programInfo, uniformBlockInfo) {
6433
6447
  *
6434
6448
  * twgl.setBlockUniforms(someBlockInfo, {
6435
6449
  * lights: [
6436
- * { intensity: 5.0, color: [1, 0, 0, 1] },
6437
- * { intensity: 2.0, color: [0, 0, 1, 1] },
6450
+ * { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.1, 10] },
6451
+ * { intensity: 2.0, color: [0, 0, 1, 1], nearFar[0.2, 15] },
6438
6452
  * ],
6439
6453
  * });
6440
6454
  *
6441
- * // or the more traditional way
6455
+ * or the more traditional way
6442
6456
  *
6443
6457
  * twgl.setBlockUniforms(someBlockInfo, {
6444
6458
  * "lights[0].intensity": 5.0,
6445
6459
  * "lights[0].color": [1, 0, 0, 1],
6460
+ * "lights[0].nearFar": [0.1, 10],
6446
6461
  * "lights[1].intensity": 2.0,
6447
6462
  * "lights[1].color": [0, 0, 1, 1],
6463
+ * "lights[1].nearFar": [0.2, 15],
6448
6464
  * });
6449
6465
  *
6450
6466
  * You can also specify partial paths
6451
6467
  *
6452
6468
  * twgl.setBlockUniforms(someBlockInfo, {
6453
- * 'lights[1]: { intensity: 5.0, color: [1, 0, 0, 1] },
6469
+ * 'lights[1]': { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.2, 15] },
6454
6470
  * });
6455
6471
  *
6456
6472
  * But you can not specify leaf array indices.
6457
6473
  *
6474
+ * twgl.setBlockUniforms(someBlockInfo, {
6475
+ * 'lights[1].nearFar[1]': 15, // BAD! nearFar is a leaf
6476
+ * 'lights[1].nearFar': [0.2, 15], // GOOD
6477
+ * });
6478
+ *
6458
6479
  * **IMPORTANT!**, packing in a UniformBlock is unintuitive.
6459
6480
  * For example the actual layout of `someVec3Array` above in memory
6460
6481
  * is `1, 2, 3, unused, 4, 5, 6, unused`. twgl takes in 6 values
@@ -6614,6 +6635,7 @@ function setUniformTree(tree, values) {
6614
6635
  * struct Light {
6615
6636
  * float intensity;
6616
6637
  * vec4 color;
6638
+ * float nearFar[2];
6617
6639
  * };
6618
6640
  * uniform Light lights[2];
6619
6641
  *
@@ -6621,8 +6643,8 @@ function setUniformTree(tree, values) {
6621
6643
  *
6622
6644
  * twgl.setUniforms(programInfo, {
6623
6645
  * lights: [
6624
- * { intensity: 5.0, color: [1, 0, 0, 1] },
6625
- * { intensity: 2.0, color: [0, 0, 1, 1] },
6646
+ * { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.1, 10] },
6647
+ * { intensity: 2.0, color: [0, 0, 1, 1], nearFar[0.2, 15] },
6626
6648
  * ],
6627
6649
  * });
6628
6650
  *
@@ -6631,18 +6653,25 @@ function setUniformTree(tree, values) {
6631
6653
  * twgl.setUniforms(programInfo, {
6632
6654
  * "lights[0].intensity": 5.0,
6633
6655
  * "lights[0].color": [1, 0, 0, 1],
6656
+ * "lights[0].nearFar": [0.1, 10],
6634
6657
  * "lights[1].intensity": 2.0,
6635
6658
  * "lights[1].color": [0, 0, 1, 1],
6659
+ * "lights[1].nearFar": [0.2, 15],
6636
6660
  * });
6637
6661
  *
6638
6662
  * You can also specify partial paths
6639
6663
  *
6640
6664
  * twgl.setUniforms(programInfo, {
6641
- * 'lights[1]: { intensity: 5.0, color: [1, 0, 0, 1] },
6665
+ * 'lights[1]': { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.2, 15] },
6642
6666
  * });
6643
6667
  *
6644
6668
  * But you can not specify leaf array indices
6645
6669
  *
6670
+ * twgl.setUniforms(programInfo, {
6671
+ * 'lights[1].nearFar[1]': 15, // BAD! nearFar is a leaf
6672
+ * 'lights[1].nearFar': [0.2, 15], // GOOD
6673
+ * });
6674
+ *
6646
6675
  * @memberOf module:twgl/programs
6647
6676
  */
6648
6677
 
@@ -1,4 +1,4 @@
1
- /* @license twgl.js 4.21.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
1
+ /* @license twgl.js 4.22.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
2
  Available via the MIT license.
3
3
  see: http://github.com/greggman/twgl.js for details */
4
4
  /*
@@ -8125,6 +8125,7 @@ function setUniformBlock(gl, programInfo, uniformBlockInfo) {
8125
8125
  * struct Light {
8126
8126
  * float intensity;
8127
8127
  * vec4 color;
8128
+ * float nearFar[2];
8128
8129
  * };
8129
8130
  * uniform Lights {
8130
8131
  * Light lights[2];
@@ -8134,28 +8135,35 @@ function setUniformBlock(gl, programInfo, uniformBlockInfo) {
8134
8135
  *
8135
8136
  * twgl.setBlockUniforms(someBlockInfo, {
8136
8137
  * lights: [
8137
- * { intensity: 5.0, color: [1, 0, 0, 1] },
8138
- * { intensity: 2.0, color: [0, 0, 1, 1] },
8138
+ * { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.1, 10] },
8139
+ * { intensity: 2.0, color: [0, 0, 1, 1], nearFar[0.2, 15] },
8139
8140
  * ],
8140
8141
  * });
8141
8142
  *
8142
- * // or the more traditional way
8143
+ * or the more traditional way
8143
8144
  *
8144
8145
  * twgl.setBlockUniforms(someBlockInfo, {
8145
8146
  * "lights[0].intensity": 5.0,
8146
8147
  * "lights[0].color": [1, 0, 0, 1],
8148
+ * "lights[0].nearFar": [0.1, 10],
8147
8149
  * "lights[1].intensity": 2.0,
8148
8150
  * "lights[1].color": [0, 0, 1, 1],
8151
+ * "lights[1].nearFar": [0.2, 15],
8149
8152
  * });
8150
8153
  *
8151
8154
  * You can also specify partial paths
8152
8155
  *
8153
8156
  * twgl.setBlockUniforms(someBlockInfo, {
8154
- * 'lights[1]: { intensity: 5.0, color: [1, 0, 0, 1] },
8157
+ * 'lights[1]': { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.2, 15] },
8155
8158
  * });
8156
8159
  *
8157
8160
  * But you can not specify leaf array indices.
8158
8161
  *
8162
+ * twgl.setBlockUniforms(someBlockInfo, {
8163
+ * 'lights[1].nearFar[1]': 15, // BAD! nearFar is a leaf
8164
+ * 'lights[1].nearFar': [0.2, 15], // GOOD
8165
+ * });
8166
+ *
8159
8167
  * **IMPORTANT!**, packing in a UniformBlock is unintuitive.
8160
8168
  * For example the actual layout of `someVec3Array` above in memory
8161
8169
  * is `1, 2, 3, unused, 4, 5, 6, unused`. twgl takes in 6 values
@@ -8311,6 +8319,7 @@ function setUniformTree(tree, values) {
8311
8319
  * struct Light {
8312
8320
  * float intensity;
8313
8321
  * vec4 color;
8322
+ * float nearFar[2];
8314
8323
  * };
8315
8324
  * uniform Light lights[2];
8316
8325
  *
@@ -8318,8 +8327,8 @@ function setUniformTree(tree, values) {
8318
8327
  *
8319
8328
  * twgl.setUniforms(programInfo, {
8320
8329
  * lights: [
8321
- * { intensity: 5.0, color: [1, 0, 0, 1] },
8322
- * { intensity: 2.0, color: [0, 0, 1, 1] },
8330
+ * { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.1, 10] },
8331
+ * { intensity: 2.0, color: [0, 0, 1, 1], nearFar[0.2, 15] },
8323
8332
  * ],
8324
8333
  * });
8325
8334
  *
@@ -8328,18 +8337,25 @@ function setUniformTree(tree, values) {
8328
8337
  * twgl.setUniforms(programInfo, {
8329
8338
  * "lights[0].intensity": 5.0,
8330
8339
  * "lights[0].color": [1, 0, 0, 1],
8340
+ * "lights[0].nearFar": [0.1, 10],
8331
8341
  * "lights[1].intensity": 2.0,
8332
8342
  * "lights[1].color": [0, 0, 1, 1],
8343
+ * "lights[1].nearFar": [0.2, 15],
8333
8344
  * });
8334
8345
  *
8335
8346
  * You can also specify partial paths
8336
8347
  *
8337
8348
  * twgl.setUniforms(programInfo, {
8338
- * 'lights[1]: { intensity: 5.0, color: [1, 0, 0, 1] },
8349
+ * 'lights[1]': { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.2, 15] },
8339
8350
  * });
8340
8351
  *
8341
8352
  * But you can not specify leaf array indices
8342
8353
  *
8354
+ * twgl.setUniforms(programInfo, {
8355
+ * 'lights[1].nearFar[1]': 15, // BAD! nearFar is a leaf
8356
+ * 'lights[1].nearFar': [0.2, 15], // GOOD
8357
+ * });
8358
+ *
8343
8359
  * @memberOf module:twgl/programs
8344
8360
  */
8345
8361
  function setUniforms(setters, ...args) { // eslint-disable-line
@@ -8882,6 +8898,7 @@ const LINEAR$1 = 0x2601;
8882
8898
  * @property {number} [type] The type. Used for texture. Default = `gl.UNSIGNED_BYTE`.
8883
8899
  * @property {number} [target] The texture target for `gl.framebufferTexture2D`.
8884
8900
  * Defaults to `gl.TEXTURE_2D`. Set to appropriate face for cube maps.
8901
+ * @property {number} [samples] The number of samples. Default = 1
8885
8902
  * @property {number} [level] level for `gl.framebufferTexture2D`. Defaults to 0.
8886
8903
  * @property {number} [layer] layer for `gl.framebufferTextureLayer`. Defaults to undefined.
8887
8904
  * If set then `gl.framebufferTextureLayer` is called, if not then `gl.framebufferTexture2D`
@@ -8986,16 +9003,21 @@ function createFramebufferInfo(gl, attachments, width, height) {
8986
9003
  };
8987
9004
  attachments.forEach(function(attachmentOptions) {
8988
9005
  let attachment = attachmentOptions.attachment;
9006
+ const samples = attachmentOptions.samples;
8989
9007
  const format = attachmentOptions.format;
8990
9008
  let attachmentPoint = attachmentOptions.attachmentPoint || getAttachmentPointForFormat(format, attachmentOptions.internalFormat);
8991
9009
  if (!attachmentPoint) {
8992
9010
  attachmentPoint = COLOR_ATTACHMENT0 + colorAttachmentCount++;
8993
9011
  }
8994
9012
  if (!attachment) {
8995
- if (isRenderbufferFormat(format)) {
9013
+ if (samples !== undefined || isRenderbufferFormat(format)) {
8996
9014
  attachment = gl.createRenderbuffer();
8997
9015
  gl.bindRenderbuffer(RENDERBUFFER, attachment);
8998
- gl.renderbufferStorage(RENDERBUFFER, format, width, height);
9016
+ if (samples > 1) {
9017
+ gl.renderbufferStorageMultisample(RENDERBUFFER, samples, format, width, height);
9018
+ } else {
9019
+ gl.renderbufferStorage(RENDERBUFFER, format, width, height);
9020
+ }
8999
9021
  } else {
9000
9022
  const textureOptions = Object.assign({}, attachmentOptions);
9001
9023
  textureOptions.width = width;
@@ -9088,9 +9110,14 @@ function resizeFramebufferInfo(gl, framebufferInfo, attachments, width, height)
9088
9110
  attachments.forEach(function(attachmentOptions, ndx) {
9089
9111
  const attachment = framebufferInfo.attachments[ndx];
9090
9112
  const format = attachmentOptions.format;
9091
- if (isRenderbuffer(gl, attachment)) {
9113
+ const samples = attachmentOptions.samples;
9114
+ if (samples !== undefined || isRenderbuffer(gl, attachment)) {
9092
9115
  gl.bindRenderbuffer(RENDERBUFFER, attachment);
9093
- gl.renderbufferStorage(RENDERBUFFER, format, width, height);
9116
+ if (samples > 1) {
9117
+ gl.renderbufferStorageMultisample(RENDERBUFFER, samples, format, width, height);
9118
+ } else {
9119
+ gl.renderbufferStorage(RENDERBUFFER, format, width, height);
9120
+ }
9094
9121
  } else if (isTexture(gl, attachment)) {
9095
9122
  resizeTexture(gl, attachment, attachmentOptions, width, height);
9096
9123
  } else {
@@ -68,6 +68,7 @@ export type AttachmentOptions = TextureOptions & {
68
68
  format?: number;
69
69
  type?: number;
70
70
  target?: number;
71
+ samples?: number;
71
72
  level?: number;
72
73
  layer?: number;
73
74
  attachment?: WebGLRenderbuffer | WebGLTexture;
package/dist/4.x/twgl.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @license twgl.js 4.21.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
+ * @license twgl.js 4.22.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
3
3
  * Available via the MIT license.
4
4
  * see: http://github.com/greggman/twgl.js for details
5
5
  */
@@ -1197,6 +1197,7 @@ var LINEAR = 0x2601;
1197
1197
  * @property {number} [type] The type. Used for texture. Default = `gl.UNSIGNED_BYTE`.
1198
1198
  * @property {number} [target] The texture target for `gl.framebufferTexture2D`.
1199
1199
  * Defaults to `gl.TEXTURE_2D`. Set to appropriate face for cube maps.
1200
+ * @property {number} [samples] The number of samples. Default = 1
1200
1201
  * @property {number} [level] level for `gl.framebufferTexture2D`. Defaults to 0.
1201
1202
  * @property {number} [layer] layer for `gl.framebufferTextureLayer`. Defaults to undefined.
1202
1203
  * If set then `gl.framebufferTextureLayer` is called, if not then `gl.framebufferTexture2D`
@@ -1305,6 +1306,7 @@ function createFramebufferInfo(gl, attachments, width, height) {
1305
1306
  };
1306
1307
  attachments.forEach(function (attachmentOptions) {
1307
1308
  var attachment = attachmentOptions.attachment;
1309
+ var samples = attachmentOptions.samples;
1308
1310
  var format = attachmentOptions.format;
1309
1311
  var attachmentPoint = attachmentOptions.attachmentPoint || getAttachmentPointForFormat(format, attachmentOptions.internalFormat);
1310
1312
 
@@ -1313,10 +1315,15 @@ function createFramebufferInfo(gl, attachments, width, height) {
1313
1315
  }
1314
1316
 
1315
1317
  if (!attachment) {
1316
- if (isRenderbufferFormat(format)) {
1318
+ if (samples !== undefined || isRenderbufferFormat(format)) {
1317
1319
  attachment = gl.createRenderbuffer();
1318
1320
  gl.bindRenderbuffer(RENDERBUFFER, attachment);
1319
- gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1321
+
1322
+ if (samples > 1) {
1323
+ gl.renderbufferStorageMultisample(RENDERBUFFER, samples, format, width, height);
1324
+ } else {
1325
+ gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1326
+ }
1320
1327
  } else {
1321
1328
  var textureOptions = Object.assign({}, attachmentOptions);
1322
1329
  textureOptions.width = width;
@@ -1404,10 +1411,16 @@ function resizeFramebufferInfo(gl, framebufferInfo, attachments, width, height)
1404
1411
  attachments.forEach(function (attachmentOptions, ndx) {
1405
1412
  var attachment = framebufferInfo.attachments[ndx];
1406
1413
  var format = attachmentOptions.format;
1414
+ var samples = attachmentOptions.samples;
1407
1415
 
1408
- if (helper.isRenderbuffer(gl, attachment)) {
1416
+ if (samples !== undefined || helper.isRenderbuffer(gl, attachment)) {
1409
1417
  gl.bindRenderbuffer(RENDERBUFFER, attachment);
1410
- gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1418
+
1419
+ if (samples > 1) {
1420
+ gl.renderbufferStorageMultisample(RENDERBUFFER, samples, format, width, height);
1421
+ } else {
1422
+ gl.renderbufferStorage(RENDERBUFFER, format, width, height);
1423
+ }
1411
1424
  } else if (helper.isTexture(gl, attachment)) {
1412
1425
  textures.resizeTexture(gl, attachment, attachmentOptions, width, height);
1413
1426
  } else {
@@ -3346,6 +3359,7 @@ function setUniformBlock(gl, programInfo, uniformBlockInfo) {
3346
3359
  * struct Light {
3347
3360
  * float intensity;
3348
3361
  * vec4 color;
3362
+ * float nearFar[2];
3349
3363
  * };
3350
3364
  * uniform Lights {
3351
3365
  * Light lights[2];
@@ -3355,28 +3369,35 @@ function setUniformBlock(gl, programInfo, uniformBlockInfo) {
3355
3369
  *
3356
3370
  * twgl.setBlockUniforms(someBlockInfo, {
3357
3371
  * lights: [
3358
- * { intensity: 5.0, color: [1, 0, 0, 1] },
3359
- * { intensity: 2.0, color: [0, 0, 1, 1] },
3372
+ * { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.1, 10] },
3373
+ * { intensity: 2.0, color: [0, 0, 1, 1], nearFar[0.2, 15] },
3360
3374
  * ],
3361
3375
  * });
3362
3376
  *
3363
- * // or the more traditional way
3377
+ * or the more traditional way
3364
3378
  *
3365
3379
  * twgl.setBlockUniforms(someBlockInfo, {
3366
3380
  * "lights[0].intensity": 5.0,
3367
3381
  * "lights[0].color": [1, 0, 0, 1],
3382
+ * "lights[0].nearFar": [0.1, 10],
3368
3383
  * "lights[1].intensity": 2.0,
3369
3384
  * "lights[1].color": [0, 0, 1, 1],
3385
+ * "lights[1].nearFar": [0.2, 15],
3370
3386
  * });
3371
3387
  *
3372
3388
  * You can also specify partial paths
3373
3389
  *
3374
3390
  * twgl.setBlockUniforms(someBlockInfo, {
3375
- * 'lights[1]: { intensity: 5.0, color: [1, 0, 0, 1] },
3391
+ * 'lights[1]': { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.2, 15] },
3376
3392
  * });
3377
3393
  *
3378
3394
  * But you can not specify leaf array indices.
3379
3395
  *
3396
+ * twgl.setBlockUniforms(someBlockInfo, {
3397
+ * 'lights[1].nearFar[1]': 15, // BAD! nearFar is a leaf
3398
+ * 'lights[1].nearFar': [0.2, 15], // GOOD
3399
+ * });
3400
+ *
3380
3401
  * **IMPORTANT!**, packing in a UniformBlock is unintuitive.
3381
3402
  * For example the actual layout of `someVec3Array` above in memory
3382
3403
  * is `1, 2, 3, unused, 4, 5, 6, unused`. twgl takes in 6 values
@@ -3536,6 +3557,7 @@ function setUniformTree(tree, values) {
3536
3557
  * struct Light {
3537
3558
  * float intensity;
3538
3559
  * vec4 color;
3560
+ * float nearFar[2];
3539
3561
  * };
3540
3562
  * uniform Light lights[2];
3541
3563
  *
@@ -3543,8 +3565,8 @@ function setUniformTree(tree, values) {
3543
3565
  *
3544
3566
  * twgl.setUniforms(programInfo, {
3545
3567
  * lights: [
3546
- * { intensity: 5.0, color: [1, 0, 0, 1] },
3547
- * { intensity: 2.0, color: [0, 0, 1, 1] },
3568
+ * { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.1, 10] },
3569
+ * { intensity: 2.0, color: [0, 0, 1, 1], nearFar[0.2, 15] },
3548
3570
  * ],
3549
3571
  * });
3550
3572
  *
@@ -3553,18 +3575,25 @@ function setUniformTree(tree, values) {
3553
3575
  * twgl.setUniforms(programInfo, {
3554
3576
  * "lights[0].intensity": 5.0,
3555
3577
  * "lights[0].color": [1, 0, 0, 1],
3578
+ * "lights[0].nearFar": [0.1, 10],
3556
3579
  * "lights[1].intensity": 2.0,
3557
3580
  * "lights[1].color": [0, 0, 1, 1],
3581
+ * "lights[1].nearFar": [0.2, 15],
3558
3582
  * });
3559
3583
  *
3560
3584
  * You can also specify partial paths
3561
3585
  *
3562
3586
  * twgl.setUniforms(programInfo, {
3563
- * 'lights[1]: { intensity: 5.0, color: [1, 0, 0, 1] },
3587
+ * 'lights[1]': { intensity: 5.0, color: [1, 0, 0, 1], nearFar[0.2, 15] },
3564
3588
  * });
3565
3589
  *
3566
3590
  * But you can not specify leaf array indices
3567
3591
  *
3592
+ * twgl.setUniforms(programInfo, {
3593
+ * 'lights[1].nearFar[1]': 15, // BAD! nearFar is a leaf
3594
+ * 'lights[1].nearFar': [0.2, 15], // GOOD
3595
+ * });
3596
+ *
3568
3597
  * @memberOf module:twgl/programs
3569
3598
  */
3570
3599
 
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "twgl.js",
3
- "version": "4.21.2",
3
+ "version": "4.22.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",
7
7
  "module": "dist/4.x/twgl-full.module.js",
8
8
  "scripts": {
9
9
  "check-ci": "npm run lint && npm run build && npm test",
10
- "test": "npm run testjs && npm run testts && npm run testbrowser",
11
- "testjs": "node node_modules/mocha/bin/mocha --recursive 'test/src/js/*-harness.js'",
10
+ "test": "npm run testts && npm run testbrowser",
12
11
  "testts": "tsc --project test/src/ts/",
13
12
  "testbrowser": "node test/puppeteer.js",
14
13
  "pre-push": "grunt eslint",
@@ -73,13 +72,11 @@
73
72
  "load-grunt-tasks": "^5.1.0",
74
73
  "marked": "^1.1.1",
75
74
  "minami": "^1.2.3",
76
- "mocha": "^8.1.3",
77
75
  "puppeteer": "^10.4.0",
78
76
  "requirejs": "^2.3.5",
79
77
  "rollup": "^2.27.1",
80
78
  "semver": "^7.3.2",
81
79
  "servez": "^1.10.0",
82
- "should": "^13.2.0",
83
80
  "terser-webpack-plugin": "^4.2.2",
84
81
  "tsd-jsdoc": "^2.1.2",
85
82
  "typescript": "^3.9.7",