twgl.js 6.2.0 → 7.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.
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"]);
@@ -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.