twgl.js 6.2.0 → 7.0.3

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
@@ -16,7 +16,7 @@ Not including the shaders (which is a simple quad shader) here's the entire code
16
16
 
17
17
  ```html
18
18
  <canvas id="c"></canvas>
19
- <script src="../dist/6.x/twgl-full.min.js"></script>
19
+ <script src="../dist/7.x/twgl-full.min.js"></script>
20
20
  <script>
21
21
  const gl = document.getElementById("c").getContext("webgl");
22
22
  const programInfo = twgl.createProgramInfo(gl, ["vs", "fs"]);
@@ -446,6 +446,7 @@ twgl.setUniforms(progInfo, {
446
446
  * [zoom-around](http://twgljs.org/examples/zoom-around.html)
447
447
  * [text](http://twgljs.org/examples/text.html)
448
448
  * [kaleidoscope](http://twgljs.org/examples/kaleidoscope.html)
449
+ * [stencil](http://twgljs.org/examples/stencil.html)
449
450
  * [tunnel](http://twgljs.org/examples/tunnel.html)
450
451
  * [GPGPU particles](http://twgljs.org/examples/gpgpu-particles.html)
451
452
  * [item list](http://twgljs.org/examples/itemlist.html)
@@ -674,7 +674,7 @@ export type TextureFunc = (gl: WebGLRenderingContext, options: TextureOptions) =
674
674
  * @property {number} [level] the mip level to affect. Defaults to 0. Note, if set auto will be considered false unless explicitly set to true.
675
675
  * @property {number} [width] the width of the texture. Only used if src is an array or typed array or null.
676
676
  * @property {number} [height] the height of a texture. Only used if src is an array or typed array or null.
677
- * @property {number} [depth] the depth of a texture. Only used if src is an array or type array or null and target is `TEXTURE_3D` .
677
+ * @property {number} [depth] the depth of a texture. Only used if src is an array or typed array or null and target is `TEXTURE_3D` .
678
678
  * @property {number} [min] the min filter setting (eg. `gl.LINEAR`). Defaults to `gl.NEAREST_MIPMAP_LINEAR`
679
679
  * or if texture is not a power of 2 on both dimensions then defaults to `gl.LINEAR`.
680
680
  * @property {number} [mag] the mag filter setting (eg. `gl.LINEAR`). Defaults to `gl.LINEAR`
@@ -733,16 +733,25 @@ export type TextureFunc = (gl: WebGLRenderingContext, options: TextureOptions) =
733
733
  * If `TexImageSource` then it wil be used immediately to create the contents of the texture. Examples `HTMLImageElement`,
734
734
  * `HTMLCanvasElement`, `HTMLVideoElement`.
735
735
  *
736
- * If `number[]` or `ArrayBufferView` it's assumed to be data for a texture. If `width` or `height` is
737
- * not specified it is guessed as follows. First the number of elements is computed by `src.length / numComponents`
738
- * where `numComponents` is derived from `format`. If `target` is `gl.TEXTURE_CUBE_MAP` then `numElements` is divided
739
- * by 6. Then
736
+ * If `number[]` or `ArrayBufferView` it's assumed to be data for a texture.
737
+ *
738
+ * * If `width` or `height` is not specified it is guessed as follows.
739
+ *
740
+ * First the number of elements is computed by `src.length / numComponents`
741
+ * where `numComponents` is derived from `format`. If `target` is `gl.TEXTURE_CUBE_MAP` then `numElements` is divided
742
+ * by 6. Then
740
743
  *
741
744
  * * If neither `width` nor `height` are specified and `sqrt(numElements)` is an integer then width and height
742
- * are set to `sqrt(numElements)`. Otherwise `width = numElements` and `height = 1`.
745
+ * are set to `sqrt(numElements)`. Otherwise `width = numElements` and `height = 1`.
743
746
  *
744
747
  * * If only one of `width` or `height` is specified then the other equals `numElements / specifiedDimension`.
745
748
  *
749
+ * * If both `width` and `height` is specified, then, the size of mip levels from `level` will be computed
750
+ * and data for consecutive mip levels will be uploaded until the data runs out.
751
+ *
752
+ * In other words: `{ format: g.RGBA, width: 4, height: 4, src: Uint8Array((4 * 4 + 2 * 2 + 1) * 4) }`
753
+ * uploads 3 mip levels (4x4, 2x2, 1x1) because src is more than the data for the first mip level.
754
+ *
746
755
  * If `number[]` will be converted to `type`.
747
756
  *
748
757
  * If `src` is a function it will be called with a `WebGLRenderingContext` and these options.
@@ -3281,7 +3290,7 @@ export function createVAOFromBufferInfo(gl: WebGLRenderingContext, programInfo:
3281
3290
  [key: string]: (...params: any[]) => any;
3282
3291
  } | ProgramInfo, bufferInfo: BufferInfo, indices?: WebGLBuffer): WebGLVertexArrayObject | null;
3283
3292
 
3284
- declare module v3 {
3293
+ declare namespace v3 {
3285
3294
  /**
3286
3295
  * A JavaScript array with 3 values or a Float32Array with 3 values.
3287
3296
  * When created by the library will create the default type which is `Float32Array`
@@ -3484,7 +3493,7 @@ declare module v3 {
3484
3493
  */
3485
3494
  export function divide(a: v3.Vec3, b: v3.Vec3, dst?: v3.Vec3): v3.Vec3;
3486
3495
  }
3487
- declare module m4 {
3496
+ declare namespace m4 {
3488
3497
  /**
3489
3498
  * A JavaScript array with 16 values or a Float32Array with 16 values.
3490
3499
  * When created by the library will create the default type which is `Float32Array`
@@ -3602,8 +3611,7 @@ declare module m4 {
3602
3611
  * the distances to the near and far clipping planes. Note that near and far
3603
3612
  * are not z coordinates, but rather they are distances along the negative
3604
3613
  * z-axis. The matrix generated sends the viewing frustum to the unit box.
3605
- * We assume a unit box extending from -1 to 1 in the x and y dimensions and
3606
- * from 0 to 1 in the z dimension.
3614
+ * We assume a unit box extending from -1 to 1 in the x, y and z dimensions.
3607
3615
  * @param {number} fieldOfViewYInRadians The camera angle from top to bottom (in radians).
3608
3616
  * @param {number} aspect The aspect ratio width / height.
3609
3617
  * @param {number} zNear The depth (negative z coordinate)
@@ -3639,8 +3647,7 @@ declare module m4 {
3639
3647
  * distances to the near and far clipping planes. Note that near and far are not
3640
3648
  * z coordinates, but rather they are distances along the negative z-axis. The
3641
3649
  * matrix generated sends the viewing frustum to the unit box. We assume a unit
3642
- * box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z
3643
- * dimension.
3650
+ * box extending from -1 to 1 in the x, y and z dimensions.
3644
3651
  * @param {number} left The x coordinate of the left plane of the box.
3645
3652
  * @param {number} right The x coordinate of the right plane of the box.
3646
3653
  * @param {number} bottom The y coordinate of the bottom plane of the box.
@@ -3829,7 +3836,7 @@ declare module m4 {
3829
3836
  */
3830
3837
  export function transformNormal(m: m4.Mat4, v: v3.Vec3, dst?: v3.Vec3): v3.Vec3;
3831
3838
  }
3832
- declare module primitives {
3839
+ declare namespace primitives {
3833
3840
  /**
3834
3841
  * @typedef {(Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array)} TypedArray
3835
3842
  */