twgl.js 5.5.3 → 6.1.1

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @license twgl.js 5.5.3 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
+ * @license twgl.js 6.1.1 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
  */
@@ -12,106 +12,20 @@
12
12
  exports["twgl"] = factory();
13
13
  else
14
14
  root["twgl"] = factory();
15
- })(typeof self !== 'undefined' ? self : this, function() {
16
- return /******/ (function(modules) { // webpackBootstrap
17
- /******/ // The module cache
18
- /******/ var installedModules = {};
19
- /******/
20
- /******/ // The require function
21
- /******/ function __webpack_require__(moduleId) {
22
- /******/
23
- /******/ // Check if module is in cache
24
- /******/ if(installedModules[moduleId]) {
25
- /******/ return installedModules[moduleId].exports;
26
- /******/ }
27
- /******/ // Create a new module (and put it into the cache)
28
- /******/ var module = installedModules[moduleId] = {
29
- /******/ i: moduleId,
30
- /******/ l: false,
31
- /******/ exports: {}
32
- /******/ };
33
- /******/
34
- /******/ // Execute the module function
35
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
36
- /******/
37
- /******/ // Flag the module as loaded
38
- /******/ module.l = true;
39
- /******/
40
- /******/ // Return the exports of the module
41
- /******/ return module.exports;
42
- /******/ }
43
- /******/
44
- /******/
45
- /******/ // expose the modules object (__webpack_modules__)
46
- /******/ __webpack_require__.m = modules;
47
- /******/
48
- /******/ // expose the module cache
49
- /******/ __webpack_require__.c = installedModules;
50
- /******/
51
- /******/ // define getter function for harmony exports
52
- /******/ __webpack_require__.d = function(exports, name, getter) {
53
- /******/ if(!__webpack_require__.o(exports, name)) {
54
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
55
- /******/ }
56
- /******/ };
57
- /******/
58
- /******/ // define __esModule on exports
59
- /******/ __webpack_require__.r = function(exports) {
60
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
61
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
62
- /******/ }
63
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
64
- /******/ };
65
- /******/
66
- /******/ // create a fake namespace object
67
- /******/ // mode & 1: value is a module id, require it
68
- /******/ // mode & 2: merge all properties of value into the ns
69
- /******/ // mode & 4: return value when already ns object
70
- /******/ // mode & 8|1: behave like require
71
- /******/ __webpack_require__.t = function(value, mode) {
72
- /******/ if(mode & 1) value = __webpack_require__(value);
73
- /******/ if(mode & 8) return value;
74
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
75
- /******/ var ns = Object.create(null);
76
- /******/ __webpack_require__.r(ns);
77
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
78
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
79
- /******/ return ns;
80
- /******/ };
81
- /******/
82
- /******/ // getDefaultExport function for compatibility with non-harmony modules
83
- /******/ __webpack_require__.n = function(module) {
84
- /******/ var getter = module && module.__esModule ?
85
- /******/ function getDefault() { return module['default']; } :
86
- /******/ function getModuleExports() { return module; };
87
- /******/ __webpack_require__.d(getter, 'a', getter);
88
- /******/ return getter;
89
- /******/ };
90
- /******/
91
- /******/ // Object.prototype.hasOwnProperty.call
92
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
93
- /******/
94
- /******/ // __webpack_public_path__
95
- /******/ __webpack_require__.p = "";
96
- /******/
97
- /******/
98
- /******/ // Load entry module and return exports
99
- /******/ return __webpack_require__(__webpack_require__.s = "./src/twgl-base.js");
100
- /******/ })
101
- /************************************************************************/
102
- /******/ ({
15
+ })(typeof self !== 'undefined' ? self : this, () => {
16
+ return /******/ (() => { // webpackBootstrap
17
+ /******/ "use strict";
18
+ /******/ var __webpack_modules__ = ({
103
19
 
104
20
  /***/ "./src/attributes.js":
105
21
  /*!***************************!*\
106
22
  !*** ./src/attributes.js ***!
107
23
  \***************************/
108
- /*! no static exports found */
109
- /***/ (function(module, exports, __webpack_require__) {
24
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
110
25
 
111
- "use strict";
112
26
 
113
27
 
114
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
28
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
115
29
  exports.__esModule = true;
116
30
  exports.createAttribsFromArrays = createAttribsFromArrays;
117
31
  exports.createBufferFromArray = createBufferFromArray;
@@ -125,8 +39,8 @@ exports.setAttributeDefaults_ = setDefaults;
125
39
  exports.setAttributePrefix = setAttributePrefix;
126
40
  var typedArrays = _interopRequireWildcard(__webpack_require__(/*! ./typedarrays.js */ "./src/typedarrays.js"));
127
41
  var helper = _interopRequireWildcard(__webpack_require__(/*! ./helper.js */ "./src/helper.js"));
128
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
129
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
42
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
43
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
130
44
  /*
131
45
  * Copyright 2019 Gregg Tavares
132
46
  *
@@ -262,7 +176,6 @@ function guessNumComponentsFromName(name, length) {
262
176
  } else {
263
177
  numComponents = 3; // position, normals, indices ...
264
178
  }
265
-
266
179
  if (length % numComponents > 0) {
267
180
  throw new Error("Can not guess numComponents for attribute '".concat(name, "'. Tried ").concat(numComponents, " but ").concat(length, " values is not evenly divisible by ").concat(numComponents, ". You should specify it."));
268
181
  }
@@ -626,7 +539,6 @@ function getNumElementsFromNonIndexedArrays(arrays) {
626
539
  if (length === undefined) {
627
540
  return 1; // There's no arrays
628
541
  }
629
-
630
542
  var numComponents = getNumComponents(array, key);
631
543
  var numElements = length / numComponents;
632
544
  if (length % numComponents > 0) {
@@ -654,7 +566,6 @@ function getNumElementsFromAttributes(gl, attribs) {
654
566
  if (!attrib.buffer) {
655
567
  return 1; // There's no buffer
656
568
  }
657
-
658
569
  gl.bindBuffer(ARRAY_BUFFER, attrib.buffer);
659
570
  var numBytes = gl.getBufferParameter(ARRAY_BUFFER, BUFFER_SIZE);
660
571
  gl.bindBuffer(ARRAY_BUFFER, null);
@@ -868,19 +779,17 @@ function createBuffersFromArrays(gl, arrays) {
868
779
  /*!*********************!*\
869
780
  !*** ./src/draw.js ***!
870
781
  \*********************/
871
- /*! no static exports found */
872
- /***/ (function(module, exports, __webpack_require__) {
782
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
873
783
 
874
- "use strict";
875
784
 
876
785
 
877
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
786
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
878
787
  exports.__esModule = true;
879
788
  exports.drawBufferInfo = drawBufferInfo;
880
789
  exports.drawObjectList = drawObjectList;
881
790
  var programs = _interopRequireWildcard(__webpack_require__(/*! ./programs.js */ "./src/programs.js"));
882
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
883
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
791
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
792
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
884
793
  /*
885
794
  * Copyright 2019 Gregg Tavares
886
795
  *
@@ -1044,21 +953,19 @@ function drawObjectList(gl, objectsToDraw) {
1044
953
  /*!*****************************!*\
1045
954
  !*** ./src/framebuffers.js ***!
1046
955
  \*****************************/
1047
- /*! no static exports found */
1048
- /***/ (function(module, exports, __webpack_require__) {
956
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1049
957
 
1050
- "use strict";
1051
958
 
1052
959
 
1053
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
960
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1054
961
  exports.__esModule = true;
1055
962
  exports.bindFramebufferInfo = bindFramebufferInfo;
1056
963
  exports.createFramebufferInfo = createFramebufferInfo;
1057
964
  exports.resizeFramebufferInfo = resizeFramebufferInfo;
1058
965
  var textures = _interopRequireWildcard(__webpack_require__(/*! ./textures.js */ "./src/textures.js"));
1059
966
  var helper = _interopRequireWildcard(__webpack_require__(/*! ./helper.js */ "./src/helper.js"));
1060
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
1061
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
967
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
968
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
1062
969
  /*
1063
970
  * Copyright 2019 Gregg Tavares
1064
971
  *
@@ -1417,10 +1324,8 @@ function bindFramebufferInfo(gl, framebufferInfo, target) {
1417
1324
  /*!***********************!*\
1418
1325
  !*** ./src/helper.js ***!
1419
1326
  \***********************/
1420
- /*! no static exports found */
1421
- /***/ (function(module, exports, __webpack_require__) {
1327
+ /***/ ((__unused_webpack_module, exports) => {
1422
1328
 
1423
- "use strict";
1424
1329
 
1425
1330
 
1426
1331
  exports.__esModule = true;
@@ -1433,7 +1338,7 @@ exports.isSampler = isSampler;
1433
1338
  exports.isShader = isShader;
1434
1339
  exports.isTexture = isTexture;
1435
1340
  exports.warn = warn;
1436
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1341
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1437
1342
  /*
1438
1343
  * Copyright 2019 Gregg Tavares
1439
1344
  *
@@ -1538,13 +1443,11 @@ function isSampler(gl, t) {
1538
1443
  /*!*************************!*\
1539
1444
  !*** ./src/programs.js ***!
1540
1445
  \*************************/
1541
- /*! no static exports found */
1542
- /***/ (function(module, exports, __webpack_require__) {
1446
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1543
1447
 
1544
- "use strict";
1545
1448
 
1546
1449
 
1547
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1450
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1548
1451
  exports.__esModule = true;
1549
1452
  exports.bindTransformFeedbackInfo = bindTransformFeedbackInfo;
1550
1453
  exports.bindUniformBlock = bindUniformBlock;
@@ -1574,25 +1477,47 @@ exports.setUniforms = setUniforms;
1574
1477
  exports.setUniformsAndBindTextures = void 0;
1575
1478
  var utils = _interopRequireWildcard(__webpack_require__(/*! ./utils.js */ "./src/utils.js"));
1576
1479
  var helper = _interopRequireWildcard(__webpack_require__(/*! ./helper.js */ "./src/helper.js"));
1577
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
1578
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1579
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1580
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1581
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1582
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1480
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
1481
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
1482
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
1483
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1484
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1485
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1486
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
1487
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1583
1488
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
1584
1489
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1585
1490
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1586
1491
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1587
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
1492
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
1588
1493
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1589
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
1494
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
1590
1495
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1591
1496
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1592
1497
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1593
1498
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1594
1499
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1595
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1500
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /*
1501
+ * Copyright 2019 Gregg Tavares
1502
+ *
1503
+ * Permission is hereby granted, free of charge, to any person obtaining a
1504
+ * copy of this software and associated documentation files (the "Software"),
1505
+ * to deal in the Software without restriction, including without limitation
1506
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1507
+ * and/or sell copies of the Software, and to permit persons to whom the
1508
+ * Software is furnished to do so, subject to the following conditions:
1509
+ *
1510
+ * The above copyright notice and this permission notice shall be included in
1511
+ * all copies or substantial portions of the Software.
1512
+ *
1513
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1514
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1515
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1516
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1517
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1518
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1519
+ * DEALINGS IN THE SOFTWARE.
1520
+ */
1596
1521
  /**
1597
1522
  * Low level shader program related functions
1598
1523
  *
@@ -2508,7 +2433,7 @@ function deleteProgramAndShaders(gl, program, notThese) {
2508
2433
  try {
2509
2434
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2510
2435
  var shader = _step.value;
2511
- if (notThese.has(shader)) {
2436
+ if (!notThese.has(shader)) {
2512
2437
  gl.deleteShader(shader);
2513
2438
  }
2514
2439
  }
@@ -2543,8 +2468,8 @@ function createProgramNoCheck(gl, shaders, programOptions) {
2543
2468
  shader = gl.createShader(type);
2544
2469
  gl.shaderSource(shader, prepShaderSource(src).shaderSource);
2545
2470
  gl.compileShader(shader);
2546
- gl.attachShader(program, shader);
2547
2471
  }
2472
+ gl.attachShader(program, shader);
2548
2473
  }
2549
2474
  Object.entries(attribLocations).forEach(function (_ref) {
2550
2475
  var _ref2 = _slicedToArray(_ref, 2),
@@ -2582,7 +2507,7 @@ function createProgramNoCheck(gl, shaders, programOptions) {
2582
2507
  * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
2583
2508
  * @param {WebGLShader[]|string[]} shaders The shaders to attach, or element ids for their source, or strings that contain their source
2584
2509
  * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
2585
- * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2510
+ * @param {number[]|module:twgl.ErrorCallback} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2586
2511
  * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
2587
2512
  * on error. If you want something else pass an callback. It's passed an error message.
2588
2513
  * @return {WebGLProgram?} the created program or null if error of a callback was provided.
@@ -2649,13 +2574,13 @@ function wrapCallbackFnToAsyncFn(fn) {
2649
2574
  * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
2650
2575
  * @param {WebGLShader[]|string[]} shaders The shaders to attach, or element ids for their source, or strings that contain their source
2651
2576
  * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
2652
- * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2577
+ * @param {number[]|module:twgl.ErrorCallback} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2653
2578
  * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
2654
2579
  * on error. If you want something else pass an callback. It's passed an error message.
2655
2580
  * @return {Promise<WebGLProgram>} The created program
2656
2581
  * @memberOf module:twgl/programs
2657
2582
  */
2658
- var createProgramAsync = wrapCallbackFnToAsyncFn(createProgram);
2583
+ var createProgramAsync = exports.createProgramAsync = wrapCallbackFnToAsyncFn(createProgram);
2659
2584
 
2660
2585
  /**
2661
2586
  * Same as createProgramInfo but returns a promise
@@ -2666,15 +2591,13 @@ var createProgramAsync = wrapCallbackFnToAsyncFn(createProgram);
2666
2591
  * shaders or ids. The first is assumed to be the vertex shader,
2667
2592
  * the second the fragment shader.
2668
2593
  * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
2669
- * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2594
+ * @param {number[]|module:twgl.ErrorCallback} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2670
2595
  * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
2671
2596
  * on error. If you want something else pass an callback. It's passed an error message.
2672
2597
  * @return {Promise<module:twgl.ProgramInfo>} The created ProgramInfo
2673
2598
  * @memberOf module:twgl/programs
2674
2599
  */
2675
- exports.createProgramAsync = createProgramAsync;
2676
- var createProgramInfoAsync = wrapCallbackFnToAsyncFn(createProgramInfo);
2677
- exports.createProgramInfoAsync = createProgramInfoAsync;
2600
+ var createProgramInfoAsync = exports.createProgramInfoAsync = wrapCallbackFnToAsyncFn(createProgramInfo);
2678
2601
  function waitForProgramLinkCompletionAsync(_x, _x2) {
2679
2602
  return _waitForProgramLinkCompletionAsync.apply(this, arguments);
2680
2603
  }
@@ -2682,31 +2605,29 @@ function _waitForProgramLinkCompletionAsync() {
2682
2605
  _waitForProgramLinkCompletionAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(gl, program) {
2683
2606
  var ext, checkFn, waitTime;
2684
2607
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2685
- while (1) {
2686
- switch (_context.prev = _context.next) {
2687
- case 0:
2688
- ext = gl.getExtension('KHR_parallel_shader_compile');
2689
- checkFn = ext ? function (gl, program) {
2690
- return gl.getProgramParameter(program, ext.COMPLETION_STATUS_KHR);
2691
- } : function () {
2692
- return true;
2693
- };
2694
- waitTime = 0;
2695
- case 3:
2696
- _context.next = 5;
2697
- return wait(waitTime);
2698
- case 5:
2699
- // must wait at least once
2700
- waitTime = 1000 / 60;
2701
- case 6:
2702
- if (!checkFn(gl, program)) {
2703
- _context.next = 3;
2704
- break;
2705
- }
2706
- case 7:
2707
- case "end":
2708
- return _context.stop();
2709
- }
2608
+ while (1) switch (_context.prev = _context.next) {
2609
+ case 0:
2610
+ ext = gl.getExtension('KHR_parallel_shader_compile');
2611
+ checkFn = ext ? function (gl, program) {
2612
+ return gl.getProgramParameter(program, ext.COMPLETION_STATUS_KHR);
2613
+ } : function () {
2614
+ return true;
2615
+ };
2616
+ waitTime = 0;
2617
+ case 3:
2618
+ _context.next = 5;
2619
+ return wait(waitTime);
2620
+ case 5:
2621
+ // must wait at least once
2622
+ waitTime = 1000 / 60;
2623
+ case 6:
2624
+ if (!checkFn(gl, program)) {
2625
+ _context.next = 3;
2626
+ break;
2627
+ }
2628
+ case 7:
2629
+ case "end":
2630
+ return _context.stop();
2710
2631
  }
2711
2632
  }, _callee);
2712
2633
  }));
@@ -2714,38 +2635,37 @@ function _waitForProgramLinkCompletionAsync() {
2714
2635
  }
2715
2636
  function waitForAllProgramsLinkCompletionAsync(_x3, _x4) {
2716
2637
  return _waitForAllProgramsLinkCompletionAsync.apply(this, arguments);
2717
- } /**
2718
- * Check a program's link status
2719
- * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
2720
- * @param {WebGLProgram} program Program to check
2721
- * @param {ErrorCallback} [errFn] func for errors
2722
- * @return {string?} errors if program is failed, else undefined
2723
- * @private
2724
- */
2638
+ }
2639
+ /**
2640
+ * Check a program's link status
2641
+ * @param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
2642
+ * @param {WebGLProgram} program Program to check
2643
+ * @param {ErrorCallback} [errFn] func for errors
2644
+ * @return {string?} errors if program is failed, else undefined
2645
+ * @private
2646
+ */
2725
2647
  function _waitForAllProgramsLinkCompletionAsync() {
2726
2648
  _waitForAllProgramsLinkCompletionAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(gl, programs) {
2727
- var _i4, _Object$values2, program;
2649
+ var _i3, _Object$values2, program;
2728
2650
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2729
- while (1) {
2730
- switch (_context2.prev = _context2.next) {
2731
- case 0:
2732
- _i4 = 0, _Object$values2 = Object.values(programs);
2733
- case 1:
2734
- if (!(_i4 < _Object$values2.length)) {
2735
- _context2.next = 8;
2736
- break;
2737
- }
2738
- program = _Object$values2[_i4];
2739
- _context2.next = 5;
2740
- return waitForProgramLinkCompletionAsync(gl, program);
2741
- case 5:
2742
- _i4++;
2743
- _context2.next = 1;
2651
+ while (1) switch (_context2.prev = _context2.next) {
2652
+ case 0:
2653
+ _i3 = 0, _Object$values2 = Object.values(programs);
2654
+ case 1:
2655
+ if (!(_i3 < _Object$values2.length)) {
2656
+ _context2.next = 8;
2744
2657
  break;
2745
- case 8:
2746
- case "end":
2747
- return _context2.stop();
2748
- }
2658
+ }
2659
+ program = _Object$values2[_i3];
2660
+ _context2.next = 5;
2661
+ return waitForProgramLinkCompletionAsync(gl, program);
2662
+ case 5:
2663
+ _i3++;
2664
+ _context2.next = 1;
2665
+ break;
2666
+ case 8:
2667
+ case "end":
2668
+ return _context2.stop();
2749
2669
  }
2750
2670
  }, _callee2);
2751
2671
  }));
@@ -2787,7 +2707,7 @@ function getProgramErrors(gl, program, errFn) {
2787
2707
  * tags for the shaders. The first is assumed to be the
2788
2708
  * vertex shader, the second the fragment shader.
2789
2709
  * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
2790
- * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2710
+ * @param {number[]|module:twgl.ErrorCallback} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2791
2711
  * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
2792
2712
  * on error. If you want something else pass an callback. It's passed an error message.
2793
2713
  * @return {WebGLProgram?} the created program or null if error or a callback was provided.
@@ -2831,7 +2751,7 @@ function createProgramFromScripts(gl, shaderScriptIds, opt_attribs, opt_location
2831
2751
  * shaders. The first is assumed to be the vertex shader,
2832
2752
  * the second the fragment shader.
2833
2753
  * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
2834
- * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2754
+ * @param {number[]|module:twgl.ErrorCallback} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
2835
2755
  * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
2836
2756
  * on error. If you want something else pass an callback. It's passed an error message.
2837
2757
  * @return {WebGLProgram?} the created program or null if error or a callback was provided.
@@ -2880,7 +2800,6 @@ function addSetterToUniformTree(fullPath, setter, node, uniformSetters) {
2880
2800
  if (isArrayIndex) {
2881
2801
  path += tokens[tokenNdx++]; // skip ']'
2882
2802
  }
2883
-
2884
2803
  var isLastToken = tokenNdx === tokens.length;
2885
2804
  if (isLastToken) {
2886
2805
  node[accessor] = setter;
@@ -2929,7 +2848,6 @@ function createUniformSetters(gl, program) {
2929
2848
  if (!typeInfo) {
2930
2849
  throw new Error("unknown type: 0x".concat(type.toString(16))); // we should never get here.
2931
2850
  }
2932
-
2933
2851
  var setter;
2934
2852
  if (typeInfo.bindPoint) {
2935
2853
  // it's a sampler
@@ -3171,6 +3089,7 @@ function createUniformBlockUniformSetter(view, isArray, rows, cols) {
3171
3089
  * @property {ArrayBuffer} array The array buffer that contains the uniform values
3172
3090
  * @property {Float32Array} asFloat A float view on the array buffer. This is useful
3173
3091
  * inspecting the contents of the buffer in the debugger.
3092
+ * @property {Uint8Array} asUint8t A uint8 view on the array buffer.
3174
3093
  * @property {WebGLBuffer} buffer A WebGL buffer that will hold a copy of the uniform values for rendering.
3175
3094
  * @property {number} [offset] offset into buffer
3176
3095
  * @property {Object<string, ArrayBufferView>} uniforms A uniform name to ArrayBufferView map.
@@ -3189,6 +3108,15 @@ function createUniformBlockUniformSetter(view, isArray, rows, cols) {
3189
3108
  * @memberOf module:twgl
3190
3109
  */
3191
3110
 
3111
+ /**
3112
+ * Options to allow createUniformBlockInfo to use an existing buffer and arrayBuffer at an offset
3113
+ * @typedef {Object} UniformBlockInfoOptions
3114
+ * @property {ArrayBuffer} [array] an existing array buffer to use for values
3115
+ * @property {number} [offset] the offset in bytes to use in the array buffer (default = 0)
3116
+ * @property {WebGLBuffer} [buffer] the buffer to use for this uniform block info
3117
+ * @property {number} [bufferOffset] the offset in bytes in the buffer to use (default = use offset above)
3118
+ */
3119
+
3192
3120
  /**
3193
3121
  * Creates a `UniformBlockInfo` for the specified block
3194
3122
  *
@@ -3203,10 +3131,13 @@ function createUniformBlockUniformSetter(view, isArray, rows, cols) {
3203
3131
  * @param {module:twgl.UniformBlockSpec} uniformBlockSpec. A UniformBlockSpec as returned
3204
3132
  * from {@link module:twgl.createUniformBlockSpecFromProgram}.
3205
3133
  * @param {string} blockName The name of the block.
3134
+ * @param {module:twgl.UniformBlockInfoOptions} [options] Optional options for using existing an existing buffer and arrayBuffer
3206
3135
  * @return {module:twgl.UniformBlockInfo} The created UniformBlockInfo
3207
3136
  * @memberOf module:twgl/programs
3208
3137
  */
3209
3138
  function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockName) {
3139
+ var _options$offset, _options$array, _options$buffer, _options$bufferOffset;
3140
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
3210
3141
  var blockSpecs = uniformBlockSpec.blockSpecs;
3211
3142
  var uniformData = uniformBlockSpec.uniformData;
3212
3143
  var blockSpec = blockSpecs[blockName];
@@ -3217,10 +3148,14 @@ function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockN
3217
3148
  uniforms: {}
3218
3149
  };
3219
3150
  }
3220
- var array = new ArrayBuffer(blockSpec.size);
3221
- var buffer = gl.createBuffer();
3151
+ var offset = (_options$offset = options.offset) !== null && _options$offset !== void 0 ? _options$offset : 0;
3152
+ var array = (_options$array = options.array) !== null && _options$array !== void 0 ? _options$array : new ArrayBuffer(blockSpec.size);
3153
+ var buffer = (_options$buffer = options.buffer) !== null && _options$buffer !== void 0 ? _options$buffer : gl.createBuffer();
3222
3154
  var uniformBufferIndex = blockSpec.index;
3223
3155
  gl.bindBuffer(UNIFORM_BUFFER, buffer);
3156
+ if (!options.buffer) {
3157
+ gl.bufferData(UNIFORM_BUFFER, array.byteLength, DYNAMIC_DRAW);
3158
+ }
3224
3159
  gl.uniformBlockBinding(program, blockSpec.index, uniformBufferIndex);
3225
3160
  var prefix = blockName + ".";
3226
3161
  if (arraySuffixRE.test(prefix)) {
@@ -3242,7 +3177,7 @@ function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockN
3242
3177
  var typeInfo = typeMap[data.type];
3243
3178
  var Type = typeInfo.Type;
3244
3179
  var byteLength = isArray ? pad(typeInfo.size, 16) * data.size : typeInfo.size * data.size;
3245
- var uniformView = new Type(array, data.offset, byteLength / Type.BYTES_PER_ELEMENT);
3180
+ var uniformView = new Type(array, offset + data.offset, byteLength / Type.BYTES_PER_ELEMENT);
3246
3181
  uniforms[name] = uniformView;
3247
3182
  // Note: I'm not sure what to do here. The original
3248
3183
  // idea was to create TypedArray views into each part
@@ -3278,9 +3213,13 @@ function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockN
3278
3213
  array: array,
3279
3214
  asFloat: new Float32Array(array),
3280
3215
  // for debugging
3216
+ asUint8: new Uint8Array(array),
3217
+ // needed for gl.bufferSubData because it doesn't take an array buffer
3281
3218
  buffer: buffer,
3282
3219
  uniforms: uniforms,
3283
- setters: setters
3220
+ setters: setters,
3221
+ offset: (_options$bufferOffset = options.bufferOffset) !== null && _options$bufferOffset !== void 0 ? _options$bufferOffset : offset,
3222
+ size: blockSpec.size
3284
3223
  };
3285
3224
  }
3286
3225
 
@@ -3297,11 +3236,13 @@ function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockN
3297
3236
  * @param {module:twgl.ProgramInfo} programInfo a `ProgramInfo`
3298
3237
  * as returned from {@link module:twgl.createProgramInfo}
3299
3238
  * @param {string} blockName The name of the block.
3239
+ * @param {module:twgl.UniformBlockInfoOptions} [options] Optional options for using existing an existing buffer and arrayBuffer
3300
3240
  * @return {module:twgl.UniformBlockInfo} The created UniformBlockInfo
3301
3241
  * @memberOf module:twgl/programs
3302
3242
  */
3303
3243
  function createUniformBlockInfo(gl, programInfo, blockName) {
3304
- return createUniformBlockInfoFromProgram(gl, programInfo.program, programInfo.uniformBlockSpec, blockName);
3244
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3245
+ return createUniformBlockInfoFromProgram(gl, programInfo.program, programInfo.uniformBlockSpec, blockName, options);
3305
3246
  }
3306
3247
 
3307
3248
  /**
@@ -3326,8 +3267,9 @@ function bindUniformBlock(gl, programInfo, uniformBlockInfo) {
3326
3267
  var uniformBlockSpec = programInfo.uniformBlockSpec || programInfo;
3327
3268
  var blockSpec = uniformBlockSpec.blockSpecs[uniformBlockInfo.name];
3328
3269
  if (blockSpec) {
3270
+ var _uniformBlockInfo$siz;
3329
3271
  var bufferBindIndex = blockSpec.index;
3330
- gl.bindBufferRange(UNIFORM_BUFFER, bufferBindIndex, uniformBlockInfo.buffer, uniformBlockInfo.offset || 0, uniformBlockInfo.array.byteLength);
3272
+ gl.bindBufferRange(UNIFORM_BUFFER, bufferBindIndex, uniformBlockInfo.buffer, uniformBlockInfo.offset || 0, (_uniformBlockInfo$siz = uniformBlockInfo.size) !== null && _uniformBlockInfo$siz !== void 0 ? _uniformBlockInfo$siz : uniformBlockInfo.array.byteLength);
3331
3273
  return true;
3332
3274
  }
3333
3275
  return false;
@@ -3350,7 +3292,7 @@ function bindUniformBlock(gl, programInfo, uniformBlockInfo) {
3350
3292
  */
3351
3293
  function setUniformBlock(gl, programInfo, uniformBlockInfo) {
3352
3294
  if (bindUniformBlock(gl, programInfo, uniformBlockInfo)) {
3353
- gl.bufferData(UNIFORM_BUFFER, uniformBlockInfo.array, DYNAMIC_DRAW);
3295
+ gl.bufferSubData(UNIFORM_BUFFER, 0, uniformBlockInfo.asUint8, uniformBlockInfo.offset || 0, uniformBlockInfo.size || 0);
3354
3296
  }
3355
3297
  }
3356
3298
 
@@ -3648,7 +3590,7 @@ function setUniforms(setters) {
3648
3590
  * @param {Object.<string, ?>} values an object with values for the
3649
3591
  * @memberOf module:twgl/programs
3650
3592
  */
3651
- var setUniformsAndBindTextures = setUniforms;
3593
+ var setUniformsAndBindTextures = exports.setUniformsAndBindTextures = setUniforms;
3652
3594
 
3653
3595
  /**
3654
3596
  * Creates setter functions for all attributes of a shader
@@ -3660,7 +3602,6 @@ var setUniformsAndBindTextures = setUniforms;
3660
3602
  * @return {Object.<string, function>} an object with a setter for each attribute by name.
3661
3603
  * @memberOf module:twgl/programs
3662
3604
  */
3663
- exports.setUniformsAndBindTextures = setUniformsAndBindTextures;
3664
3605
  function createAttributeSetters(gl, program) {
3665
3606
  var attribSetters = {};
3666
3607
  var numAttribs = gl.getProgramParameter(program, ACTIVE_ATTRIBUTES);
@@ -3793,6 +3734,8 @@ function setBuffersAndAttributes(gl, programInfo, buffers) {
3793
3734
  /**
3794
3735
  * @typedef {Object} ProgramInfo
3795
3736
  * @property {WebGLProgram} program A shader program
3737
+ * @property {Object<string, WebGLUniformLocation>} uniformLocations The uniform locations of each uniform
3738
+ * @property {Object<string, number>} attribLocations The locations of each attribute
3796
3739
  * @property {Object<string, function>} uniformSetters object of setters as returned from createUniformSetters,
3797
3740
  * @property {Object<string, function>} attribSetters object of setters as returned from createAttribSetters,
3798
3741
  * @property {module:twgl.UniformBlockSpec} [uniformBlockSpec] a uniform block spec for making UniformBlockInfos with createUniformBlockInfo etc..
@@ -3823,7 +3766,19 @@ function createProgramInfoFromProgram(gl, program) {
3823
3766
  var programInfo = {
3824
3767
  program: program,
3825
3768
  uniformSetters: uniformSetters,
3826
- attribSetters: attribSetters
3769
+ attribSetters: attribSetters,
3770
+ uniformLocations: Object.fromEntries(Object.entries(uniformSetters).map(function (_ref3) {
3771
+ var _ref4 = _slicedToArray(_ref3, 2),
3772
+ k = _ref4[0],
3773
+ v = _ref4[1];
3774
+ return [k, v.location];
3775
+ })),
3776
+ attribLocations: Object.fromEntries(Object.entries(attribSetters).map(function (_ref5) {
3777
+ var _ref6 = _slicedToArray(_ref5, 2),
3778
+ k = _ref6[0],
3779
+ v = _ref6[1];
3780
+ return [k, v.location];
3781
+ }))
3827
3782
  };
3828
3783
  if (utils.isWebGL2(gl)) {
3829
3784
  programInfo.uniformBlockSpec = createUniformBlockSpecFromProgram(gl, program);
@@ -3857,7 +3812,7 @@ var notIdRE = /\s|{|}|;/;
3857
3812
  * shaders or ids. The first is assumed to be the vertex shader,
3858
3813
  * the second the fragment shader.
3859
3814
  * @param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
3860
- * @param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
3815
+ * @param {number[]|module:twgl.ErrorCallback} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
3861
3816
  * @param {module:twgl.ErrorCallback} [opt_errorCallback] callback for errors. By default it just prints an error to the console
3862
3817
  * on error. If you want something else pass an callback. It's passed an error message.
3863
3818
  * @return {module:twgl.ProgramInfo?} The created ProgramInfo or null if it failed to link or compile
@@ -3897,8 +3852,8 @@ function createProgramInfo(gl, shaderSources, opt_attribs, opt_locations, opt_er
3897
3852
  }
3898
3853
  function checkAllPrograms(gl, programs, programSpecs, noDeleteShadersSet, programOptions) {
3899
3854
  // check errors for everything.
3900
- for (var _i2 = 0, _Object$entries = Object.entries(programs); _i2 < _Object$entries.length; _i2++) {
3901
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
3855
+ for (var _i = 0, _Object$entries = Object.entries(programs); _i < _Object$entries.length; _i++) {
3856
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
3902
3857
  name = _Object$entries$_i[0],
3903
3858
  program = _Object$entries$_i[1];
3904
3859
  var options = _objectSpread({}, programOptions);
@@ -3909,8 +3864,8 @@ function checkAllPrograms(gl, programs, programSpecs, noDeleteShadersSet, progra
3909
3864
  var errors = getProgramErrors(gl, program, options.errorCallback);
3910
3865
  if (errors) {
3911
3866
  // delete everything we created
3912
- for (var _i3 = 0, _Object$values = Object.values(programs); _i3 < _Object$values.length; _i3++) {
3913
- var _program = _Object$values[_i3];
3867
+ for (var _i2 = 0, _Object$values = Object.values(programs); _i2 < _Object$values.length; _i2++) {
3868
+ var _program = _Object$values[_i2];
3914
3869
  var shaders = gl.getAttachedShaders(_program);
3915
3870
  gl.deleteProgram(_program);
3916
3871
  var _iterator3 = _createForOfIteratorHelper(shaders),
@@ -3966,10 +3921,10 @@ function createPrograms(gl, programSpecs) {
3966
3921
  var noDeleteShadersSet = new Set();
3967
3922
 
3968
3923
  // compile and link everything
3969
- var programs = Object.fromEntries(Object.entries(programSpecs).map(function (_ref3) {
3970
- var _ref4 = _slicedToArray(_ref3, 2),
3971
- name = _ref4[0],
3972
- spec = _ref4[1];
3924
+ var programs = Object.fromEntries(Object.entries(programSpecs).map(function (_ref7) {
3925
+ var _ref8 = _slicedToArray(_ref7, 2),
3926
+ name = _ref8[0],
3927
+ spec = _ref8[1];
3973
3928
  var options = _objectSpread({}, programOptions);
3974
3929
  var shaders = Array.isArray(spec) ? spec : spec.shaders;
3975
3930
  if (!Array.isArray(spec)) {
@@ -4029,10 +3984,10 @@ function createPrograms(gl, programSpecs) {
4029
3984
  function createProgramInfos(gl, programSpecs, programOptions) {
4030
3985
  programOptions = getProgramOptions(programOptions);
4031
3986
  function createProgramInfosForPrograms(gl, programs) {
4032
- return Object.fromEntries(Object.entries(programs).map(function (_ref5) {
4033
- var _ref6 = _slicedToArray(_ref5, 2),
4034
- name = _ref6[0],
4035
- program = _ref6[1];
3987
+ return Object.fromEntries(Object.entries(programs).map(function (_ref9) {
3988
+ var _ref10 = _slicedToArray(_ref9, 2),
3989
+ name = _ref10[0],
3990
+ program = _ref10[1];
4036
3991
  return [name, createProgramInfoFromProgram(gl, program)];
4037
3992
  }));
4038
3993
  }
@@ -4071,7 +4026,7 @@ function createProgramInfos(gl, programSpecs, programOptions) {
4071
4026
  * @param {module:twgl.ProgramOptions} [programOptions] options to apply to all programs
4072
4027
  * @return {Object.<string, WebGLProgram>?} the created programInfos by name
4073
4028
  */
4074
- var createProgramsAsync = wrapCallbackFnToAsyncFn(createPrograms);
4029
+ var createProgramsAsync = exports.createProgramsAsync = wrapCallbackFnToAsyncFn(createPrograms);
4075
4030
 
4076
4031
  /**
4077
4032
  * Creates multiple programInfos asynchronously
@@ -4095,9 +4050,7 @@ var createProgramsAsync = wrapCallbackFnToAsyncFn(createPrograms);
4095
4050
  * @param {module:twgl.ProgramOptions} [programOptions] options to apply to all programs
4096
4051
  * @return {Promise<Object.<string, module:twgl.ProgramInfo>>} the created programInfos by name
4097
4052
  */
4098
- exports.createProgramsAsync = createProgramsAsync;
4099
- var createProgramInfosAsync = wrapCallbackFnToAsyncFn(createProgramInfos);
4100
- exports.createProgramInfosAsync = createProgramInfosAsync;
4053
+ var createProgramInfosAsync = exports.createProgramInfosAsync = wrapCallbackFnToAsyncFn(createProgramInfos);
4101
4054
 
4102
4055
  /***/ }),
4103
4056
 
@@ -4105,20 +4058,19 @@ exports.createProgramInfosAsync = createProgramInfosAsync;
4105
4058
  /*!*************************!*\
4106
4059
  !*** ./src/textures.js ***!
4107
4060
  \*************************/
4108
- /*! no static exports found */
4109
- /***/ (function(module, exports, __webpack_require__) {
4061
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4110
4062
 
4111
- "use strict";
4112
4063
 
4113
4064
 
4114
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4115
4065
  exports.__esModule = true;
4116
4066
  exports.canFilter = canFilter;
4117
4067
  exports.canGenerateMipmap = canGenerateMipmap;
4118
4068
  exports.createSampler = createSampler;
4119
4069
  exports.createSamplers = createSamplers;
4120
4070
  exports.createTexture = createTexture;
4071
+ exports.createTextureAsync = createTextureAsync;
4121
4072
  exports.createTextures = createTextures;
4073
+ exports.createTexturesAsync = createTexturesAsync;
4122
4074
  exports.getBytesPerElementForInternalFormat = getBytesPerElementForInternalFormat;
4123
4075
  exports.getFormatAndTypeForInternalFormat = getFormatAndTypeForInternalFormat;
4124
4076
  exports.getNumComponentsForFormat = getNumComponentsForFormat;
@@ -4135,9 +4087,14 @@ exports.setTextureParameters = setTextureParameters;
4135
4087
  var utils = _interopRequireWildcard(__webpack_require__(/*! ./utils.js */ "./src/utils.js"));
4136
4088
  var typedArrays = _interopRequireWildcard(__webpack_require__(/*! ./typedarrays.js */ "./src/typedarrays.js"));
4137
4089
  var helper = _interopRequireWildcard(__webpack_require__(/*! ./helper.js */ "./src/helper.js"));
4138
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
4139
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4140
- /*
4090
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
4091
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
4092
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4093
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4094
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4095
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4096
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4097
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
4141
4098
  * Copyright 2019 Gregg Tavares
4142
4099
  *
4143
4100
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -4158,7 +4115,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
4158
4115
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
4159
4116
  * DEALINGS IN THE SOFTWARE.
4160
4117
  */
4161
-
4162
4118
  /**
4163
4119
  * Low level texture related functions
4164
4120
  *
@@ -5125,21 +5081,62 @@ function setDefaults(newDefaults) {
5125
5081
  */
5126
5082
 
5127
5083
  /**
5128
- * Sets any packing state that will be set based on the options.
5129
- * @param {module:twgl.TextureOptions} options A TextureOptions object with whatever parameters you want set.
5084
+ * Saves the current packing state, sets the packing state as specified
5085
+ * then calls a function, after which the packing state will be restored.
5130
5086
  * @param {WebGLRenderingContext} gl the WebGLRenderingContext
5087
+ * @param {module:twgl.TextureOptions} options A TextureOptions object with whatever parameters you want set.
5088
+ * @param {function():void} [fn] A function to call, after which the packing state will be restored.
5131
5089
  * @private
5132
5090
  */
5133
- function setPackState(gl, options) {
5091
+ function scopedSetPackState(gl, options, fn) {
5092
+ var colorspaceConversion;
5093
+ var premultiplyAlpha;
5094
+ var flipY;
5134
5095
  if (options.colorspaceConversion !== undefined) {
5096
+ colorspaceConversion = gl.getParameter(UNPACK_COLORSPACE_CONVERSION_WEBGL);
5135
5097
  gl.pixelStorei(UNPACK_COLORSPACE_CONVERSION_WEBGL, options.colorspaceConversion);
5136
5098
  }
5137
5099
  if (options.premultiplyAlpha !== undefined) {
5100
+ premultiplyAlpha = gl.getParameter(UNPACK_PREMULTIPLY_ALPHA_WEBGL);
5138
5101
  gl.pixelStorei(UNPACK_PREMULTIPLY_ALPHA_WEBGL, options.premultiplyAlpha);
5139
5102
  }
5140
5103
  if (options.flipY !== undefined) {
5104
+ flipY = gl.getParameter(UNPACK_FLIP_Y_WEBGL);
5141
5105
  gl.pixelStorei(UNPACK_FLIP_Y_WEBGL, options.flipY);
5142
5106
  }
5107
+ fn();
5108
+ if (colorspaceConversion !== undefined) {
5109
+ gl.pixelStorei(UNPACK_COLORSPACE_CONVERSION_WEBGL, colorspaceConversion);
5110
+ }
5111
+ if (premultiplyAlpha !== undefined) {
5112
+ gl.pixelStorei(UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha);
5113
+ }
5114
+ if (flipY !== undefined) {
5115
+ gl.pixelStorei(UNPACK_FLIP_Y_WEBGL, flipY);
5116
+ }
5117
+ }
5118
+
5119
+ /**
5120
+ * returns the property if set or the corresponding state if undefined
5121
+ * @param {WebGLRenderingContext} gl the WebGLRenderingContext
5122
+ * @param {module:twgl.TextureOptions} options
5123
+ * @param {string} property the name of the property to copy
5124
+ * @param {number} pname
5125
+ * @return {module:twgl.TextureOptions}
5126
+ */
5127
+ function getPackStateOption(gl, options, property, pname) {
5128
+ var v = options[property];
5129
+ return _defineProperty({}, property, v === undefined ? gl.getParameter(pname) : v);
5130
+ }
5131
+
5132
+ /**
5133
+ * Copy the options object and apply pack state
5134
+ * @param {WebGLRenderingContext} gl the WebGLRenderingContext
5135
+ * @param {module:twgl.TextureOptions} options
5136
+ * @return {module:twgl.TextureOptions}
5137
+ */
5138
+ function copyOptionsAndApplyPackState(gl, options) {
5139
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, options), getPackStateOption(gl, options, 'flipY', UNPACK_FLIP_Y_WEBGL)), getPackStateOption(gl, options, 'premultiplyAlpha', UNPACK_PREMULTIPLY_ALPHA_WEBGL)), getPackStateOption(gl, options, 'colorspaceConversion', UNPACK_COLORSPACE_CONVERSION_WEBGL));
5143
5140
  }
5144
5141
 
5145
5142
  /**
@@ -5423,7 +5420,6 @@ function setTextureFromElement(gl, tex, element, options) {
5423
5420
  var formatType = getFormatAndTypeForInternalFormat(internalFormat);
5424
5421
  var format = options.format || formatType.format;
5425
5422
  var type = options.type || formatType.type;
5426
- setPackState(gl, options);
5427
5423
  gl.bindTexture(target, tex);
5428
5424
  if (target === TEXTURE_CUBE_MAP) {
5429
5425
  // guess the parts
@@ -5456,15 +5452,17 @@ function setTextureFromElement(gl, tex, element, options) {
5456
5452
  ctx.canvas.height = size;
5457
5453
  width = size;
5458
5454
  height = size;
5459
- getCubeFacesWithNdx(gl, options).forEach(function (f) {
5460
- var xOffset = slices[f.ndx * 2 + 0] * size;
5461
- var yOffset = slices[f.ndx * 2 + 1] * size;
5462
- ctx.drawImage(element, xOffset, yOffset, size, size, 0, 0, size, size);
5463
- gl.texImage2D(f.face, level, internalFormat, format, type, ctx.canvas);
5455
+ scopedSetPackState(gl, options, function () {
5456
+ getCubeFacesWithNdx(gl, options).forEach(function (f) {
5457
+ var xOffset = slices[f.ndx * 2 + 0] * size;
5458
+ var yOffset = slices[f.ndx * 2 + 1] * size;
5459
+ ctx.drawImage(element, xOffset, yOffset, size, size, 0, 0, size, size);
5460
+ gl.texImage2D(f.face, level, internalFormat, format, type, ctx.canvas);
5461
+ });
5462
+ // Free up the canvas memory
5463
+ ctx.canvas.width = 1;
5464
+ ctx.canvas.height = 1;
5464
5465
  });
5465
- // Free up the canvas memory
5466
- ctx.canvas.width = 1;
5467
- ctx.canvas.height = 1;
5468
5466
  } else if (typeof createImageBitmap !== 'undefined') {
5469
5467
  // NOTE: It seems like we should prefer ImageBitmap because unlike canvas it's
5470
5468
  // note lossy? (alpha is not premultiplied? although I'm not sure what
@@ -5483,39 +5481,44 @@ function setTextureFromElement(gl, tex, element, options) {
5483
5481
  premultiplyAlpha: 'none',
5484
5482
  colorSpaceConversion: 'none'
5485
5483
  }).then(function (imageBitmap) {
5486
- setPackState(gl, options);
5487
- gl.bindTexture(target, tex);
5488
- gl.texImage2D(f.face, level, internalFormat, format, type, imageBitmap);
5489
- if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5490
- setTextureFilteringForSize(gl, tex, options, width, height, internalFormat);
5491
- }
5484
+ scopedSetPackState(gl, options, function () {
5485
+ gl.bindTexture(target, tex);
5486
+ gl.texImage2D(f.face, level, internalFormat, format, type, imageBitmap);
5487
+ if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5488
+ setTextureFilteringForSize(gl, tex, options, width, height, internalFormat);
5489
+ }
5490
+ });
5492
5491
  });
5493
5492
  });
5494
5493
  }
5495
5494
  } else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
5496
- var smallest = Math.min(element.width, element.height);
5497
- var largest = Math.max(element.width, element.height);
5498
- var depth = largest / smallest;
5499
- if (depth % 1 !== 0) {
5500
- throw "can not compute 3D dimensions of element";
5501
- }
5502
- var xMult = element.width === largest ? 1 : 0;
5503
- var yMult = element.height === largest ? 1 : 0;
5504
- gl.pixelStorei(UNPACK_ALIGNMENT, 1);
5505
- gl.pixelStorei(UNPACK_ROW_LENGTH, element.width);
5506
- gl.pixelStorei(UNPACK_IMAGE_HEIGHT, 0);
5507
- gl.pixelStorei(UNPACK_SKIP_IMAGES, 0);
5508
- gl.texImage3D(target, level, internalFormat, smallest, smallest, smallest, 0, format, type, null);
5509
- for (var d = 0; d < depth; ++d) {
5510
- var srcX = d * smallest * xMult;
5511
- var srcY = d * smallest * yMult;
5512
- gl.pixelStorei(UNPACK_SKIP_PIXELS, srcX);
5513
- gl.pixelStorei(UNPACK_SKIP_ROWS, srcY);
5514
- gl.texSubImage3D(target, level, 0, 0, d, smallest, smallest, 1, format, type, element);
5515
- }
5516
- setSkipStateToDefault(gl);
5495
+ scopedSetPackState(gl, options, function () {
5496
+ var smallest = Math.min(element.width, element.height);
5497
+ var largest = Math.max(element.width, element.height);
5498
+ var depth = largest / smallest;
5499
+ if (depth % 1 !== 0) {
5500
+ throw "can not compute 3D dimensions of element";
5501
+ }
5502
+ var xMult = element.width === largest ? 1 : 0;
5503
+ var yMult = element.height === largest ? 1 : 0;
5504
+ gl.pixelStorei(UNPACK_ALIGNMENT, 1);
5505
+ gl.pixelStorei(UNPACK_ROW_LENGTH, element.width);
5506
+ gl.pixelStorei(UNPACK_IMAGE_HEIGHT, 0);
5507
+ gl.pixelStorei(UNPACK_SKIP_IMAGES, 0);
5508
+ gl.texImage3D(target, level, internalFormat, smallest, smallest, smallest, 0, format, type, null);
5509
+ for (var d = 0; d < depth; ++d) {
5510
+ var srcX = d * smallest * xMult;
5511
+ var srcY = d * smallest * yMult;
5512
+ gl.pixelStorei(UNPACK_SKIP_PIXELS, srcX);
5513
+ gl.pixelStorei(UNPACK_SKIP_ROWS, srcY);
5514
+ gl.texSubImage3D(target, level, 0, 0, d, smallest, smallest, 1, format, type, element);
5515
+ }
5516
+ setSkipStateToDefault(gl);
5517
+ });
5517
5518
  } else {
5518
- gl.texImage2D(target, level, internalFormat, format, type, element);
5519
+ scopedSetPackState(gl, options, function () {
5520
+ gl.texImage2D(target, level, internalFormat, format, type, element);
5521
+ });
5519
5522
  }
5520
5523
  if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5521
5524
  setTextureFilteringForSize(gl, tex, options, width, height, internalFormat);
@@ -5594,7 +5597,6 @@ function loadImage(url, crossOrigin, callback) {
5594
5597
  if (crossOrigin) {
5595
5598
  options.mode = 'cors'; // TODO: not sure how to translate image.crossOrigin
5596
5599
  }
5597
-
5598
5600
  fetch(url, options).then(function (response) {
5599
5601
  if (!response.ok) {
5600
5602
  throw response;
@@ -5750,7 +5752,7 @@ function loadTextureFromUrl(gl, tex, options, callback) {
5750
5752
  options = options || defaults.textureOptions;
5751
5753
  setTextureTo1PixelColor(gl, tex, options);
5752
5754
  // Because it's async we need to copy the options.
5753
- options = Object.assign({}, options);
5755
+ options = copyOptionsAndApplyPackState(gl, options);
5754
5756
  var img = loadAndUseImage(options.src, options.crossOrigin, function (err, img) {
5755
5757
  if (err) {
5756
5758
  callback(err, tex, img);
@@ -5790,7 +5792,7 @@ function loadCubemapFromUrls(gl, tex, options, callback) {
5790
5792
  }
5791
5793
  setTextureTo1PixelColor(gl, tex, options);
5792
5794
  // Because it's async we need to copy the options.
5793
- options = Object.assign({}, options);
5795
+ options = copyOptionsAndApplyPackState(gl, options);
5794
5796
  var numToLoad = 6;
5795
5797
  var errors = [];
5796
5798
  var faces = getCubeFaceOrder(gl, options);
@@ -5805,23 +5807,24 @@ function loadCubemapFromUrls(gl, tex, options, callback) {
5805
5807
  if (img.width !== img.height) {
5806
5808
  errors.push("cubemap face img is not a square: " + img.src);
5807
5809
  } else {
5808
- setPackState(gl, options);
5809
- gl.bindTexture(target, tex);
5810
-
5811
- // So assuming this is the first image we now have one face that's img sized
5812
- // and 5 faces that are 1x1 pixel so size the other faces
5813
- if (numToLoad === 5) {
5814
- // use the default order
5815
- getCubeFaceOrder(gl).forEach(function (otherTarget) {
5816
- // Should we re-use the same face or a color?
5817
- gl.texImage2D(otherTarget, level, internalFormat, format, type, img);
5818
- });
5819
- } else {
5820
- gl.texImage2D(faceTarget, level, internalFormat, format, type, img);
5821
- }
5822
- if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5823
- gl.generateMipmap(target);
5824
- }
5810
+ scopedSetPackState(gl, options, function () {
5811
+ gl.bindTexture(target, tex);
5812
+
5813
+ // So assuming this is the first image we now have one face that's img sized
5814
+ // and 5 faces that are 1x1 pixel so size the other faces
5815
+ if (numToLoad === 5) {
5816
+ // use the default order
5817
+ getCubeFaceOrder(gl).forEach(function (otherTarget) {
5818
+ // Should we re-use the same face or a color?
5819
+ gl.texImage2D(otherTarget, level, internalFormat, format, type, img);
5820
+ });
5821
+ } else {
5822
+ gl.texImage2D(faceTarget, level, internalFormat, format, type, img);
5823
+ }
5824
+ if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5825
+ gl.generateMipmap(target);
5826
+ }
5827
+ });
5825
5828
  }
5826
5829
  }
5827
5830
  if (numToLoad === 0) {
@@ -5867,7 +5870,7 @@ function loadSlicesFromUrls(gl, tex, options, callback) {
5867
5870
  }
5868
5871
  setTextureTo1PixelColor(gl, tex, options);
5869
5872
  // Because it's async we need to copy the options.
5870
- options = Object.assign({}, options);
5873
+ options = copyOptionsAndApplyPackState(gl, options);
5871
5874
  var numToLoad = urls.length;
5872
5875
  var errors = [];
5873
5876
  var imgs; // eslint-disable-line
@@ -5882,40 +5885,41 @@ function loadSlicesFromUrls(gl, tex, options, callback) {
5882
5885
  if (err) {
5883
5886
  errors.push(err);
5884
5887
  } else {
5885
- setPackState(gl, options);
5886
- gl.bindTexture(target, tex);
5887
- if (firstImage) {
5888
- firstImage = false;
5889
- width = options.width || img.width;
5890
- height = options.height || img.height;
5891
- gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, null);
5892
-
5893
- // put it in every slice otherwise some slices will be 0,0,0,0
5894
- for (var s = 0; s < depth; ++s) {
5895
- gl.texSubImage3D(target, level, 0, 0, s, width, height, 1, format, type, img);
5896
- }
5897
- } else {
5898
- var src = img;
5899
- var ctx;
5900
- if (img.width !== width || img.height !== height) {
5901
- // Size the image to fix
5902
- ctx = getShared2DContext();
5903
- src = ctx.canvas;
5904
- ctx.canvas.width = width;
5905
- ctx.canvas.height = height;
5906
- ctx.drawImage(img, 0, 0, width, height);
5907
- }
5908
- gl.texSubImage3D(target, level, 0, 0, slice, width, height, 1, format, type, src);
5888
+ scopedSetPackState(gl, options, function () {
5889
+ gl.bindTexture(target, tex);
5890
+ if (firstImage) {
5891
+ firstImage = false;
5892
+ width = options.width || img.width;
5893
+ height = options.height || img.height;
5894
+ gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, null);
5895
+
5896
+ // put it in every slice otherwise some slices will be 0,0,0,0
5897
+ for (var s = 0; s < depth; ++s) {
5898
+ gl.texSubImage3D(target, level, 0, 0, s, width, height, 1, format, type, img);
5899
+ }
5900
+ } else {
5901
+ var src = img;
5902
+ var ctx;
5903
+ if (img.width !== width || img.height !== height) {
5904
+ // Size the image to fix
5905
+ ctx = getShared2DContext();
5906
+ src = ctx.canvas;
5907
+ ctx.canvas.width = width;
5908
+ ctx.canvas.height = height;
5909
+ ctx.drawImage(img, 0, 0, width, height);
5910
+ }
5911
+ gl.texSubImage3D(target, level, 0, 0, slice, width, height, 1, format, type, src);
5909
5912
 
5910
- // free the canvas memory
5911
- if (ctx && src === ctx.canvas) {
5912
- ctx.canvas.width = 0;
5913
- ctx.canvas.height = 0;
5913
+ // free the canvas memory
5914
+ if (ctx && src === ctx.canvas) {
5915
+ ctx.canvas.width = 0;
5916
+ ctx.canvas.height = 0;
5917
+ }
5914
5918
  }
5915
- }
5916
- if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5917
- gl.generateMipmap(target);
5918
- }
5919
+ if (shouldAutomaticallySetTextureFilteringForSize(options)) {
5920
+ gl.generateMipmap(target);
5921
+ }
5922
+ });
5919
5923
  }
5920
5924
  if (numToLoad === 0) {
5921
5925
  callback(errors.length ? errors : undefined, tex, imgs);
@@ -5990,20 +5994,21 @@ function setTextureFromArray(gl, tex, src, options) {
5990
5994
  }
5991
5995
  setSkipStateToDefault(gl);
5992
5996
  gl.pixelStorei(UNPACK_ALIGNMENT, options.unpackAlignment || 1);
5993
- setPackState(gl, options);
5994
- if (target === TEXTURE_CUBE_MAP) {
5995
- var elementsPerElement = bytesPerElement / src.BYTES_PER_ELEMENT;
5996
- var faceSize = numElements / 6 * elementsPerElement;
5997
- getCubeFacesWithNdx(gl, options).forEach(function (f) {
5998
- var offset = faceSize * f.ndx;
5999
- var data = src.subarray(offset, offset + faceSize);
6000
- gl.texImage2D(f.face, level, internalFormat, width, height, 0, format, type, data);
6001
- });
6002
- } else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
6003
- gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
6004
- } else {
6005
- gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, src);
6006
- }
5997
+ scopedSetPackState(gl, options, function () {
5998
+ if (target === TEXTURE_CUBE_MAP) {
5999
+ var elementsPerElement = bytesPerElement / src.BYTES_PER_ELEMENT;
6000
+ var faceSize = numElements / 6 * elementsPerElement;
6001
+ getCubeFacesWithNdx(gl, options).forEach(function (f) {
6002
+ var offset = faceSize * f.ndx;
6003
+ var data = src.subarray(offset, offset + faceSize);
6004
+ gl.texImage2D(f.face, level, internalFormat, width, height, 0, format, type, data);
6005
+ });
6006
+ } else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
6007
+ gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
6008
+ } else {
6009
+ gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, src);
6010
+ }
6011
+ });
6007
6012
  return {
6008
6013
  width: width,
6009
6014
  height: height,
@@ -6028,24 +6033,46 @@ function setEmptyTexture(gl, tex, options) {
6028
6033
  var formatType = getFormatAndTypeForInternalFormat(internalFormat);
6029
6034
  var format = options.format || formatType.format;
6030
6035
  var type = options.type || formatType.type;
6031
- setPackState(gl, options);
6032
- if (target === TEXTURE_CUBE_MAP) {
6033
- for (var ii = 0; ii < 6; ++ii) {
6034
- gl.texImage2D(TEXTURE_CUBE_MAP_POSITIVE_X + ii, level, internalFormat, options.width, options.height, 0, format, type, null);
6036
+ scopedSetPackState(gl, options, function () {
6037
+ if (target === TEXTURE_CUBE_MAP) {
6038
+ for (var ii = 0; ii < 6; ++ii) {
6039
+ gl.texImage2D(TEXTURE_CUBE_MAP_POSITIVE_X + ii, level, internalFormat, options.width, options.height, 0, format, type, null);
6040
+ }
6041
+ } else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
6042
+ gl.texImage3D(target, level, internalFormat, options.width, options.height, options.depth, 0, format, type, null);
6043
+ } else {
6044
+ gl.texImage2D(target, level, internalFormat, options.width, options.height, 0, format, type, null);
6035
6045
  }
6036
- } else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
6037
- gl.texImage3D(target, level, internalFormat, options.width, options.height, options.depth, 0, format, type, null);
6038
- } else {
6039
- gl.texImage2D(target, level, internalFormat, options.width, options.height, 0, format, type, null);
6040
- }
6046
+ });
6041
6047
  }
6042
6048
 
6043
6049
  /**
6044
6050
  * Creates a texture based on the options passed in.
6045
6051
  *
6052
+ * See {@link module:twgl.TextureOptions}
6053
+ *
6046
6054
  * Note: may reset UNPACK_ALIGNMENT, UNPACK_ROW_LENGTH, UNPACK_IMAGE_HEIGHT, UNPACK_SKIP_IMAGES
6047
6055
  * UNPACK_SKIP_PIXELS, and UNPACK_SKIP_ROWS
6048
6056
  *
6057
+ * UNPACK_FLIP_Y_WEBGL, UNPACK_PREMULTIPLY_ALPHA_WEBGL, UNPACK_COLORSPACE_CONVERSION_WEBGL
6058
+ * are left as is though you can pass in options for flipY, premultiplyAlpha, and colorspaceConversion
6059
+ * to override them.
6060
+ *
6061
+ * As for the behavior of these settings
6062
+ *
6063
+ * ```js
6064
+ * gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
6065
+ * t1 = twgl.createTexture({src: someImage }); // flipped
6066
+ * t2 = twgl.createTexture({src: someImage, flipY: true }); // flipped
6067
+ * t3 = twgl.createTexture({src: someImage, flipY: false }); // not flipped
6068
+ * t4 = twgl.createTexture({src: someImage }); // flipped
6069
+ * ```
6070
+ *
6071
+ * * t1 is flipped because UNPACK_FLIP_Y_WEBGL is true
6072
+ * * t2 is flipped because it was requested
6073
+ * * t3 is not flipped because it was requested
6074
+ * * t4 is flipped because UNPACK_FLIP_Y_WEBGL has been restored to true
6075
+ *
6049
6076
  * @param {WebGLRenderingContext} gl the WebGLRenderingContext
6050
6077
  * @param {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
6051
6078
  * @param {module:twgl.TextureReadyCallback} [callback] A callback called when an image has been downloaded and uploaded to the texture.
@@ -6099,6 +6126,45 @@ function createTexture(gl, options, callback) {
6099
6126
  return tex;
6100
6127
  }
6101
6128
 
6129
+ /**
6130
+ * Value returned by createTextureAsync
6131
+ *
6132
+ * @typedef {Object} CreateTextureInfo
6133
+ * @param {WebGLTexture} texture the texture.
6134
+ * @param {module:twgl.TextureSrc} source image(s) used to as the src for the texture
6135
+ * @memberOf module:twgl
6136
+ */
6137
+
6138
+ /**
6139
+ * Creates a texture based on the options passed in.
6140
+ *
6141
+ * see {@link module:twgl/textures.createTexture}.
6142
+ * The only difference is this function returns a promise
6143
+ * where as the other returns a texture and takes a callback.
6144
+ *
6145
+ * Note: this is here for completeness. It is probably better to use
6146
+ * the non-async version as it returns a usable texture immediately
6147
+ * where as this one you have to wait for it to load.
6148
+ *
6149
+ * @param {WebGLRenderingContext} gl the WebGLRenderingContext
6150
+ * @param {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
6151
+ * @return {Promise<CreateTextureInfo>} The created texture and source.
6152
+ */
6153
+ function createTextureAsync(gl, options) {
6154
+ return new Promise(function (resolve, reject) {
6155
+ createTexture(gl, options, function (err, texture, source) {
6156
+ if (err) {
6157
+ reject(err);
6158
+ } else {
6159
+ resolve({
6160
+ texture: texture,
6161
+ source: source
6162
+ });
6163
+ }
6164
+ });
6165
+ });
6166
+ }
6167
+
6102
6168
  /**
6103
6169
  * Resizes a texture based on the options passed in.
6104
6170
  *
@@ -6271,16 +6337,53 @@ function createTextures(gl, textureOptions, callback) {
6271
6337
  return textures;
6272
6338
  }
6273
6339
 
6340
+ /**
6341
+ * Value returned by createTextureAsync
6342
+ *
6343
+ * @typedef {Object} CreateTexturesInfo
6344
+ * @param {Object.<string, WebGLTexture>} textures the created textures by name. Same as returned by {@link module:twgl.createTextures}.
6345
+ * @param {Object.<string, module:twgl.TextureSrc>} sources the image(s) used for the texture by name.
6346
+ * @memberOf module:twgl
6347
+ */
6348
+
6349
+ /**
6350
+ * Creates textures based on the options passed in.
6351
+ *
6352
+ * see {@link module:twgl/textures.createTextures}.
6353
+ * The only difference is this function returns a promise
6354
+ * where as the other returns a texture and takes a callback.
6355
+ *
6356
+ * Note: this is here for completeness. It is probably better to use
6357
+ * the non-async version as it returns usable textures immediately
6358
+ * where as this one you have to wait for them to load.
6359
+ *
6360
+ * @param {WebGLRenderingContext} gl the WebGLRenderingContext
6361
+ * @param {Object.<string,module:twgl.TextureOptions>} options A object of TextureOptions one per texture.
6362
+ * @return {Promise<CreateTexturesInfo>} The created textures and sources.
6363
+ */
6364
+ function createTexturesAsync(gl, options) {
6365
+ return new Promise(function (resolve, reject) {
6366
+ createTexture(gl, options, function (err, textures, sources) {
6367
+ if (err) {
6368
+ reject(err);
6369
+ } else {
6370
+ resolve({
6371
+ textures: textures,
6372
+ sources: sources
6373
+ });
6374
+ }
6375
+ });
6376
+ });
6377
+ }
6378
+
6274
6379
  /***/ }),
6275
6380
 
6276
6381
  /***/ "./src/twgl-base.js":
6277
6382
  /*!**************************!*\
6278
6383
  !*** ./src/twgl-base.js ***!
6279
6384
  \**************************/
6280
- /*! no static exports found */
6281
- /***/ (function(module, exports, __webpack_require__) {
6385
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6282
6386
 
6283
- "use strict";
6284
6387
 
6285
6388
 
6286
6389
  exports.__esModule = true;
@@ -6297,13 +6400,11 @@ Object.keys(_twgl).forEach(function (key) {
6297
6400
  /*!*********************!*\
6298
6401
  !*** ./src/twgl.js ***!
6299
6402
  \*********************/
6300
- /*! no static exports found */
6301
- /***/ (function(module, exports, __webpack_require__) {
6403
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6302
6404
 
6303
- "use strict";
6304
6405
 
6305
6406
 
6306
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
6407
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6307
6408
  exports.__esModule = true;
6308
6409
  var _exportNames = {
6309
6410
  addExtensionsToContext: true,
@@ -6393,8 +6494,8 @@ Object.keys(vertexArrays).forEach(function (key) {
6393
6494
  if (key in exports && exports[key] === vertexArrays[key]) return;
6394
6495
  exports[key] = vertexArrays[key];
6395
6496
  });
6396
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
6397
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6497
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
6498
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
6398
6499
  /*
6399
6500
  * Copyright 2019 Gregg Tavares
6400
6501
  *
@@ -6527,7 +6628,6 @@ function setDefaults(newDefaults) {
6527
6628
  attributes.setAttributeDefaults_(newDefaults); // eslint-disable-line
6528
6629
  textures.setTextureDefaults_(newDefaults); // eslint-disable-line
6529
6630
  }
6530
-
6531
6631
  var prefixRE = /^(.*?)_/;
6532
6632
  function addExtensionToContext(gl, extensionName) {
6533
6633
  utils.glEnumToString(gl, 0);
@@ -6750,16 +6850,25 @@ function resizeCanvasToDisplaySize(canvas, multiplier) {
6750
6850
  return false;
6751
6851
  }
6752
6852
 
6853
+ // function notPrivate(name) {
6854
+ // return name[name.length - 1] !== '_';
6855
+ // }
6856
+ //
6857
+ // function copyPublicProperties(src, dst) {
6858
+ // Object.keys(src).filter(notPrivate).forEach(function(key) {
6859
+ // dst[key] = src[key];
6860
+ // });
6861
+ // return dst;
6862
+ // }
6863
+
6753
6864
  /***/ }),
6754
6865
 
6755
6866
  /***/ "./src/typedarrays.js":
6756
6867
  /*!****************************!*\
6757
6868
  !*** ./src/typedarrays.js ***!
6758
6869
  \****************************/
6759
- /*! no static exports found */
6760
- /***/ (function(module, exports, __webpack_require__) {
6870
+ /***/ ((__unused_webpack_module, exports) => {
6761
6871
 
6762
- "use strict";
6763
6872
 
6764
6873
 
6765
6874
  exports.__esModule = true;
@@ -6928,12 +7037,11 @@ function getTypedArrayTypeForGLType(type) {
6928
7037
  }
6929
7038
  return CTOR;
6930
7039
  }
6931
- var isArrayBuffer = typeof SharedArrayBuffer !== 'undefined' ? function isArrayBufferOrSharedArrayBuffer(a) {
7040
+ var isArrayBuffer = exports.isArrayBuffer = typeof SharedArrayBuffer !== 'undefined' ? function isArrayBufferOrSharedArrayBuffer(a) {
6932
7041
  return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);
6933
7042
  } : function isArrayBuffer(a) {
6934
7043
  return a && a.buffer && a.buffer instanceof ArrayBuffer;
6935
7044
  };
6936
- exports.isArrayBuffer = isArrayBuffer;
6937
7045
 
6938
7046
  /***/ }),
6939
7047
 
@@ -6941,10 +7049,8 @@ exports.isArrayBuffer = isArrayBuffer;
6941
7049
  /*!**********************!*\
6942
7050
  !*** ./src/utils.js ***!
6943
7051
  \**********************/
6944
- /*! no static exports found */
6945
- /***/ (function(module, exports, __webpack_require__) {
7052
+ /***/ ((__unused_webpack_module, exports) => {
6946
7053
 
6947
- "use strict";
6948
7054
 
6949
7055
 
6950
7056
  exports.__esModule = true;
@@ -7060,7 +7166,7 @@ function isWebGL1(gl) {
7060
7166
  * @memberOf module:twgl
7061
7167
  * @function glEnumToString
7062
7168
  */
7063
- var glEnumToString = function () {
7169
+ var glEnumToString = exports.glEnumToString = function () {
7064
7170
  var haveEnumsForType = {};
7065
7171
  var enums = {};
7066
7172
  function addEnums(gl) {
@@ -7080,7 +7186,6 @@ var glEnumToString = function () {
7080
7186
  return enums[value] || (typeof value === 'number' ? "0x".concat(value.toString(16)) : value);
7081
7187
  };
7082
7188
  }();
7083
- exports.glEnumToString = glEnumToString;
7084
7189
 
7085
7190
  /***/ }),
7086
7191
 
@@ -7088,20 +7193,18 @@ exports.glEnumToString = glEnumToString;
7088
7193
  /*!******************************!*\
7089
7194
  !*** ./src/vertex-arrays.js ***!
7090
7195
  \******************************/
7091
- /*! no static exports found */
7092
- /***/ (function(module, exports, __webpack_require__) {
7196
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7093
7197
 
7094
- "use strict";
7095
7198
 
7096
7199
 
7097
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
7200
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7098
7201
  exports.__esModule = true;
7099
7202
  exports.createVAOAndSetAttributes = createVAOAndSetAttributes;
7100
7203
  exports.createVAOFromBufferInfo = createVAOFromBufferInfo;
7101
7204
  exports.createVertexArrayInfo = createVertexArrayInfo;
7102
7205
  var programs = _interopRequireWildcard(__webpack_require__(/*! ./programs.js */ "./src/programs.js"));
7103
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
7104
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
7206
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
7207
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
7105
7208
  /*
7106
7209
  * Copyright 2019 Gregg Tavares
7107
7210
  *
@@ -7247,6 +7350,41 @@ function createVAOFromBufferInfo(gl, programInfo, bufferInfo) {
7247
7350
 
7248
7351
  /***/ })
7249
7352
 
7250
- /******/ });
7353
+ /******/ });
7354
+ /************************************************************************/
7355
+ /******/ // The module cache
7356
+ /******/ var __webpack_module_cache__ = {};
7357
+ /******/
7358
+ /******/ // The require function
7359
+ /******/ function __webpack_require__(moduleId) {
7360
+ /******/ // Check if module is in cache
7361
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
7362
+ /******/ if (cachedModule !== undefined) {
7363
+ /******/ return cachedModule.exports;
7364
+ /******/ }
7365
+ /******/ // Create a new module (and put it into the cache)
7366
+ /******/ var module = __webpack_module_cache__[moduleId] = {
7367
+ /******/ // no module.id needed
7368
+ /******/ // no module.loaded needed
7369
+ /******/ exports: {}
7370
+ /******/ };
7371
+ /******/
7372
+ /******/ // Execute the module function
7373
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
7374
+ /******/
7375
+ /******/ // Return the exports of the module
7376
+ /******/ return module.exports;
7377
+ /******/ }
7378
+ /******/
7379
+ /************************************************************************/
7380
+ /******/
7381
+ /******/ // startup
7382
+ /******/ // Load entry module and return exports
7383
+ /******/ // This entry module is referenced by other modules so it can't be inlined
7384
+ /******/ var __webpack_exports__ = __webpack_require__("./src/twgl-base.js");
7385
+ /******/
7386
+ /******/ return __webpack_exports__;
7387
+ /******/ })()
7388
+ ;
7251
7389
  });
7252
7390
  //# sourceMappingURL=twgl.js.map