twgl.js 5.0.0 → 5.0.2
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/
|
|
19
|
+
<script src="../dist/5.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"]);
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license twgl.js
|
|
2
|
+
* @license twgl.js 5.0.2 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
|
*/
|
|
@@ -349,7 +349,9 @@ 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 = 0.
|
|
352
|
+
* @property {number} [divisor] the divisor in instances. Default = 0.
|
|
353
|
+
* Requires WebGL2 or the ANGLE_instanced_arrays extension.
|
|
354
|
+
* and, if you using WebGL1 you must have called {@link module:twgl.addExtensionsToContext}
|
|
353
355
|
* @property {WebGLBuffer} buffer the buffer that contains the data for this attribute
|
|
354
356
|
* @property {number} [drawType] the draw type passed to gl.bufferData. Default = gl.STATIC_DRAW
|
|
355
357
|
* @memberOf module:twgl
|
|
@@ -371,7 +373,9 @@ function makeTypedArray(array, name) {
|
|
|
371
373
|
* @property {boolean} [normalize] normalize for `vertexAttribPointer`. Default is true if type is `Int8Array` or `Uint8Array` otherwise false.
|
|
372
374
|
* @property {number} [stride] stride for `vertexAttribPointer`. Default = 0
|
|
373
375
|
* @property {number} [offset] offset for `vertexAttribPointer`. Default = 0
|
|
374
|
-
* @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0.
|
|
376
|
+
* @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0.
|
|
377
|
+
* Requires WebGL2 or the ANGLE_instanced_arrays extension.
|
|
378
|
+
* and, if you using WebGL1 you must have called {@link module:twgl.addExtensionsToContext}
|
|
375
379
|
* @property {string} [attrib] name of attribute this array maps to. Defaults to same name as array prefixed by the default attribPrefix.
|
|
376
380
|
* @property {string} [name] synonym for `attrib`.
|
|
377
381
|
* @property {string} [attribName] synonym for `attrib`.
|
|
@@ -1581,24 +1585,45 @@ function warn() {
|
|
|
1581
1585
|
(_console2 = console).warn.apply(_console2, arguments);
|
|
1582
1586
|
}
|
|
1583
1587
|
|
|
1588
|
+
var isTypeWeakMaps = new Map();
|
|
1589
|
+
|
|
1590
|
+
function isType(object, type) {
|
|
1591
|
+
var weakMap = isTypeWeakMaps.get(type);
|
|
1592
|
+
|
|
1593
|
+
if (!weakMap) {
|
|
1594
|
+
weakMap = new WeakMap();
|
|
1595
|
+
isTypeWeakMaps.set(type, weakMap);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
var isOfType = weakMap.get(object);
|
|
1599
|
+
|
|
1600
|
+
if (isOfType === undefined) {
|
|
1601
|
+
var s = Object.prototype.toString.call(object);
|
|
1602
|
+
isOfType = s.substring(8, s.length - 1) === type;
|
|
1603
|
+
weakMap.set(object, isOfType);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
return isOfType;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1584
1609
|
function isBuffer(gl, t) {
|
|
1585
|
-
return typeof WebGLBuffer !== 'undefined' && t
|
|
1610
|
+
return typeof WebGLBuffer !== 'undefined' && isType(t, 'WebGLBuffer');
|
|
1586
1611
|
}
|
|
1587
1612
|
|
|
1588
1613
|
function isRenderbuffer(gl, t) {
|
|
1589
|
-
return typeof WebGLRenderbuffer !== 'undefined' && t
|
|
1614
|
+
return typeof WebGLRenderbuffer !== 'undefined' && isType(t, 'WebGLRenderbuffer');
|
|
1590
1615
|
}
|
|
1591
1616
|
|
|
1592
1617
|
function isShader(gl, t) {
|
|
1593
|
-
return typeof WebGLShader !== 'undefined' && t
|
|
1618
|
+
return typeof WebGLShader !== 'undefined' && isType(t, 'WebGLShader');
|
|
1594
1619
|
}
|
|
1595
1620
|
|
|
1596
1621
|
function isTexture(gl, t) {
|
|
1597
|
-
return typeof WebGLTexture !== 'undefined' && t
|
|
1622
|
+
return typeof WebGLTexture !== 'undefined' && isType(t, 'WebGLTexture');
|
|
1598
1623
|
}
|
|
1599
1624
|
|
|
1600
1625
|
function isSampler(gl, t) {
|
|
1601
|
-
return typeof WebGLSampler !== 'undefined' && t
|
|
1626
|
+
return typeof WebGLSampler !== 'undefined' && isType(t, 'WebGLSampler');
|
|
1602
1627
|
}
|
|
1603
1628
|
|
|
1604
1629
|
/***/ }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @license twgl.js
|
|
1
|
+
/* @license twgl.js 5.0.2 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
|
/*
|
|
@@ -1949,24 +1949,41 @@ function warn(...args) {
|
|
|
1949
1949
|
console.warn(...args);
|
|
1950
1950
|
}
|
|
1951
1951
|
|
|
1952
|
+
const isTypeWeakMaps = new Map();
|
|
1953
|
+
|
|
1954
|
+
function isType(object, type) {
|
|
1955
|
+
let weakMap = isTypeWeakMaps.get(type);
|
|
1956
|
+
if (!weakMap) {
|
|
1957
|
+
weakMap = new WeakMap();
|
|
1958
|
+
isTypeWeakMaps.set(type, weakMap);
|
|
1959
|
+
}
|
|
1960
|
+
let isOfType = weakMap.get(object);
|
|
1961
|
+
if (isOfType === undefined) {
|
|
1962
|
+
const s = Object.prototype.toString.call(object);
|
|
1963
|
+
isOfType = s.substring(8, s.length - 1) === type;
|
|
1964
|
+
weakMap.set(object, isOfType);
|
|
1965
|
+
}
|
|
1966
|
+
return isOfType;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1952
1969
|
function isBuffer(gl, t) {
|
|
1953
|
-
return typeof WebGLBuffer !== 'undefined' && t
|
|
1970
|
+
return typeof WebGLBuffer !== 'undefined' && isType(t, 'WebGLBuffer');
|
|
1954
1971
|
}
|
|
1955
1972
|
|
|
1956
1973
|
function isRenderbuffer(gl, t) {
|
|
1957
|
-
return typeof WebGLRenderbuffer !== 'undefined' && t
|
|
1974
|
+
return typeof WebGLRenderbuffer !== 'undefined' && isType(t, 'WebGLRenderbuffer');
|
|
1958
1975
|
}
|
|
1959
1976
|
|
|
1960
1977
|
function isShader(gl, t) {
|
|
1961
|
-
return typeof WebGLShader !== 'undefined' && t
|
|
1978
|
+
return typeof WebGLShader !== 'undefined' && isType(t, 'WebGLShader');
|
|
1962
1979
|
}
|
|
1963
1980
|
|
|
1964
1981
|
function isTexture(gl, t) {
|
|
1965
|
-
return typeof WebGLTexture !== 'undefined' && t
|
|
1982
|
+
return typeof WebGLTexture !== 'undefined' && isType(t, 'WebGLTexture');
|
|
1966
1983
|
}
|
|
1967
1984
|
|
|
1968
1985
|
function isSampler(gl, t) {
|
|
1969
|
-
return typeof WebGLSampler !== 'undefined' && t
|
|
1986
|
+
return typeof WebGLSampler !== 'undefined' && isType(t, 'WebGLSampler');
|
|
1970
1987
|
}
|
|
1971
1988
|
|
|
1972
1989
|
/*
|
|
@@ -2148,7 +2165,9 @@ function makeTypedArray(array, name) {
|
|
|
2148
2165
|
* @property {boolean} [normalize] whether or not to normalize the data. Default = false
|
|
2149
2166
|
* @property {number} [offset] offset into buffer in bytes. Default = 0
|
|
2150
2167
|
* @property {number} [stride] the stride in bytes per element. Default = 0
|
|
2151
|
-
* @property {number} [divisor] the divisor in instances. Default = 0.
|
|
2168
|
+
* @property {number} [divisor] the divisor in instances. Default = 0.
|
|
2169
|
+
* Requires WebGL2 or the ANGLE_instanced_arrays extension.
|
|
2170
|
+
* and, if you using WebGL1 you must have called {@link module:twgl.addExtensionsToContext}
|
|
2152
2171
|
* @property {WebGLBuffer} buffer the buffer that contains the data for this attribute
|
|
2153
2172
|
* @property {number} [drawType] the draw type passed to gl.bufferData. Default = gl.STATIC_DRAW
|
|
2154
2173
|
* @memberOf module:twgl
|
|
@@ -2170,7 +2189,9 @@ function makeTypedArray(array, name) {
|
|
|
2170
2189
|
* @property {boolean} [normalize] normalize for `vertexAttribPointer`. Default is true if type is `Int8Array` or `Uint8Array` otherwise false.
|
|
2171
2190
|
* @property {number} [stride] stride for `vertexAttribPointer`. Default = 0
|
|
2172
2191
|
* @property {number} [offset] offset for `vertexAttribPointer`. Default = 0
|
|
2173
|
-
* @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0.
|
|
2192
|
+
* @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0.
|
|
2193
|
+
* Requires WebGL2 or the ANGLE_instanced_arrays extension.
|
|
2194
|
+
* and, if you using WebGL1 you must have called {@link module:twgl.addExtensionsToContext}
|
|
2174
2195
|
* @property {string} [attrib] name of attribute this array maps to. Defaults to same name as array prefixed by the default attribPrefix.
|
|
2175
2196
|
* @property {string} [name] synonym for `attrib`.
|
|
2176
2197
|
* @property {string} [attribName] synonym for `attrib`.
|
|
File without changes
|
package/dist/{4.x → 5.x}/twgl.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license twgl.js
|
|
2
|
+
* @license twgl.js 5.0.2 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
|
*/
|
|
@@ -349,7 +349,9 @@ 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 = 0.
|
|
352
|
+
* @property {number} [divisor] the divisor in instances. Default = 0.
|
|
353
|
+
* Requires WebGL2 or the ANGLE_instanced_arrays extension.
|
|
354
|
+
* and, if you using WebGL1 you must have called {@link module:twgl.addExtensionsToContext}
|
|
353
355
|
* @property {WebGLBuffer} buffer the buffer that contains the data for this attribute
|
|
354
356
|
* @property {number} [drawType] the draw type passed to gl.bufferData. Default = gl.STATIC_DRAW
|
|
355
357
|
* @memberOf module:twgl
|
|
@@ -371,7 +373,9 @@ function makeTypedArray(array, name) {
|
|
|
371
373
|
* @property {boolean} [normalize] normalize for `vertexAttribPointer`. Default is true if type is `Int8Array` or `Uint8Array` otherwise false.
|
|
372
374
|
* @property {number} [stride] stride for `vertexAttribPointer`. Default = 0
|
|
373
375
|
* @property {number} [offset] offset for `vertexAttribPointer`. Default = 0
|
|
374
|
-
* @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0.
|
|
376
|
+
* @property {number} [divisor] divisor for `vertexAttribDivisor`. Default = 0.
|
|
377
|
+
* Requires WebGL2 or the ANGLE_instanced_arrays extension.
|
|
378
|
+
* and, if you using WebGL1 you must have called {@link module:twgl.addExtensionsToContext}
|
|
375
379
|
* @property {string} [attrib] name of attribute this array maps to. Defaults to same name as array prefixed by the default attribPrefix.
|
|
376
380
|
* @property {string} [name] synonym for `attrib`.
|
|
377
381
|
* @property {string} [attribName] synonym for `attrib`.
|
|
@@ -1581,24 +1585,45 @@ function warn() {
|
|
|
1581
1585
|
(_console2 = console).warn.apply(_console2, arguments);
|
|
1582
1586
|
}
|
|
1583
1587
|
|
|
1588
|
+
var isTypeWeakMaps = new Map();
|
|
1589
|
+
|
|
1590
|
+
function isType(object, type) {
|
|
1591
|
+
var weakMap = isTypeWeakMaps.get(type);
|
|
1592
|
+
|
|
1593
|
+
if (!weakMap) {
|
|
1594
|
+
weakMap = new WeakMap();
|
|
1595
|
+
isTypeWeakMaps.set(type, weakMap);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
var isOfType = weakMap.get(object);
|
|
1599
|
+
|
|
1600
|
+
if (isOfType === undefined) {
|
|
1601
|
+
var s = Object.prototype.toString.call(object);
|
|
1602
|
+
isOfType = s.substring(8, s.length - 1) === type;
|
|
1603
|
+
weakMap.set(object, isOfType);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
return isOfType;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1584
1609
|
function isBuffer(gl, t) {
|
|
1585
|
-
return typeof WebGLBuffer !== 'undefined' && t
|
|
1610
|
+
return typeof WebGLBuffer !== 'undefined' && isType(t, 'WebGLBuffer');
|
|
1586
1611
|
}
|
|
1587
1612
|
|
|
1588
1613
|
function isRenderbuffer(gl, t) {
|
|
1589
|
-
return typeof WebGLRenderbuffer !== 'undefined' && t
|
|
1614
|
+
return typeof WebGLRenderbuffer !== 'undefined' && isType(t, 'WebGLRenderbuffer');
|
|
1590
1615
|
}
|
|
1591
1616
|
|
|
1592
1617
|
function isShader(gl, t) {
|
|
1593
|
-
return typeof WebGLShader !== 'undefined' && t
|
|
1618
|
+
return typeof WebGLShader !== 'undefined' && isType(t, 'WebGLShader');
|
|
1594
1619
|
}
|
|
1595
1620
|
|
|
1596
1621
|
function isTexture(gl, t) {
|
|
1597
|
-
return typeof WebGLTexture !== 'undefined' && t
|
|
1622
|
+
return typeof WebGLTexture !== 'undefined' && isType(t, 'WebGLTexture');
|
|
1598
1623
|
}
|
|
1599
1624
|
|
|
1600
1625
|
function isSampler(gl, t) {
|
|
1601
|
-
return typeof WebGLSampler !== 'undefined' && t
|
|
1626
|
+
return typeof WebGLSampler !== 'undefined' && isType(t, 'WebGLSampler');
|
|
1602
1627
|
}
|
|
1603
1628
|
|
|
1604
1629
|
/***/ }),
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twgl.js",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "A Tiny WebGL helper library",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"types": "dist/
|
|
7
|
-
"module": "dist/
|
|
5
|
+
"main": "dist/5.x/twgl-full.js",
|
|
6
|
+
"types": "dist/5.x/twgl-full.d.ts",
|
|
7
|
+
"module": "dist/5.x/twgl-full.module.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"check-ci": "npm run lint && npm run build && npm test",
|
|
10
10
|
"test": "npm run testts && npm run testbrowser",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/greggman/twgl.js",
|
|
40
40
|
"files": [
|
|
41
|
-
"dist/
|
|
42
|
-
"dist/
|
|
43
|
-
"dist/
|
|
44
|
-
"dist/
|
|
45
|
-
"dist/
|
|
41
|
+
"dist/5.x/twgl-full.js",
|
|
42
|
+
"dist/5.x/twgl.js",
|
|
43
|
+
"dist/5.x/twgl-full.d.ts",
|
|
44
|
+
"dist/5.x/twgl.d.ts",
|
|
45
|
+
"dist/5.x/twgl-full.module.js"
|
|
46
46
|
],
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/core": "^7.11.6",
|