{ "pandav:/dist/gltf-loader.es.js": { "cubeCode": "Cube(\"pandav:/npm/@maptalks/gltf-loader/0.102.5/dist/gltf-loader.es\", [], function (module, exports, require, load, process, global) {\n\n Object.defineProperty(exports, \"__esModule\", {\n value: true });\n\n exports.GLTFLoader = exports.Ajax = void 0;\n function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}\n 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.\");}\n 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;}}\n function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}\n function _toConsumableArray(r) {return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();}\n 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.\");}\n function _unsupportedIterableToArray(r, a) {if (r) {if (\"string\" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}\n function _iterableToArray(r) {if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r);}\n function _arrayWithoutHoles(r) {if (Array.isArray(r)) return _arrayLikeToArray(r);}\n function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}\n function _callSuper(t, o, e) {return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));}\n function _possibleConstructorReturn(t, e) {if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e;if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\");return _assertThisInitialized(t);}\n function _assertThisInitialized(e) {if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e;}\n function _isNativeReflectConstruct() {try {var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));} catch (t) {}return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {return !!t;})();}\n function _getPrototypeOf(t) {return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {return t.__proto__ || Object.getPrototypeOf(t);}, _getPrototypeOf(t);}\n function _inherits(t, e) {if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\");t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e);}\n function _setPrototypeOf(t, e) {return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {return t.__proto__ = e, t;}, _setPrototypeOf(t, e);}\n 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);}\n function _classCallCheck(a, n) {if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\");}\n function _defineProperties(e, r) {for (var t = 0; t < r.length; t++) {var o = r[t];o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);}}\n function _createClass(e, r, t) {return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e;}\n function _toPropertyKey(t) {var i = _toPrimitive(t, \"string\");return \"symbol\" == _typeof(i) ? i : i + \"\";}\n 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);}\n var e = \"undefined\" != typeof Float32Array ? Float32Array : Array;\n function t(e, t, s) {\n var r = t[0],\n n = t[1],\n i = t[2],\n a = t[3],\n o = t[4],\n f = t[5],\n u = t[6],\n h = t[7],\n c = t[8],\n l = t[9],\n d = t[10],\n m = t[11],\n g = t[12],\n p = t[13],\n b = t[14],\n _ = t[15],\n y = s[0],\n x = s[1],\n w = s[2],\n T = s[3];\n return e[0] = y * r + x * o + w * c + T * g, e[1] = y * n + x * f + w * l + T * p, e[2] = y * i + x * u + w * d + T * b, e[3] = y * a + x * h + w * m + T * _, y = s[4], x = s[5], w = s[6], T = s[7], e[4] = y * r + x * o + w * c + T * g, e[5] = y * n + x * f + w * l + T * p, e[6] = y * i + x * u + w * d + T * b, e[7] = y * a + x * h + w * m + T * _, y = s[8], x = s[9], w = s[10], T = s[11], e[8] = y * r + x * o + w * c + T * g, e[9] = y * n + x * f + w * l + T * p, e[10] = y * i + x * u + w * d + T * b, e[11] = y * a + x * h + w * m + T * _, y = s[12], x = s[13], w = s[14], T = s[15], e[12] = y * r + x * o + w * c + T * g, e[13] = y * n + x * f + w * l + T * p, e[14] = y * i + x * u + w * d + T * b, e[15] = y * a + x * h + w * m + T * _, e;\n }\n function s() {\n var t = new e(3);\n return e != Float32Array && (t[0] = 0, t[1] = 0, t[2] = 0), t;\n }\n function r(t, s, r) {\n var n = new e(3);\n return n[0] = t, n[1] = s, n[2] = r, n;\n }\n function n(e, t) {\n return e[0] = t[0], e[1] = t[1], e[2] = t[2], e;\n }\n function i(e, t, s, r) {\n return e[0] = t, e[1] = s, e[2] = r, e;\n }\n function a(e, t, s) {\n return e[0] = t[0] + s[0], e[1] = t[1] + s[1], e[2] = t[2] + s[2], e;\n }\n function o(e, t, s) {\n return e[0] = t[0] * s, e[1] = t[1] * s, e[2] = t[2] * s, e;\n }\n Math.hypot || (Math.hypot = function () {\n for (var e = 0, t = arguments.length; t--;) e += arguments[t] * arguments[t];\n return Math.sqrt(e);\n });\n function f(e, t, s, r, n) {\n return e[0] = t, e[1] = s, e[2] = r, e[3] = n, e;\n }\n function u(e, t, s) {\n var r = t[0],\n n = t[1],\n i = t[2],\n a = t[3];\n return e[0] = s[0] * r + s[4] * n + s[8] * i + s[12] * a, e[1] = s[1] * r + s[5] * n + s[9] * i + s[13] * a, e[2] = s[2] * r + s[6] * n + s[10] * i + s[14] * a, e[3] = s[3] * r + s[7] * n + s[11] * i + s[15] * a, e;\n }\n function h() {\n var t = new e(4);\n return e != Float32Array && (t[0] = 0, t[1] = 0, t[2] = 0), t[3] = 1, t;\n }\n function c(e, t, s, r) {\n var n,\n i,\n a,\n o,\n f,\n u = t[0],\n h = t[1],\n c = t[2],\n l = t[3],\n d = s[0],\n m = s[1],\n g = s[2],\n p = s[3];\n return (i = u * d + h * m + c * g + l * p) < 0 && (i = -i, d = -d, m = -m, g = -g, p = -p), 1 - i > 1e-6 ? (n = Math.acos(i), a = Math.sin(n), o = Math.sin((1 - r) * n) / a, f = Math.sin(r * n) / a) : (o = 1 - r, f = r), e[0] = o * u + f * d, e[1] = o * h + f * m, e[2] = o * c + f * g, e[3] = o * l + f * p, e;\n }\n s(), function () {\n var t,\n s = (t = new e(4), e != Float32Array && (t[0] = 0, t[1] = 0, t[2] = 0, t[3] = 0), t);\n }();\n var l,\n d = function d(e, t) {\n return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e;\n };\n s(), r(1, 0, 0), r(0, 1, 0), h(), h(), l = new e(9), e != Float32Array && (l[1] = 0, l[2] = 0, l[3] = 0, l[5] = 0, l[6] = 0, l[7] = 0), l[0] = 1, l[4] = 1, l[8] = 1;\n var m = 0;\n function g(e) {\n return null == e;\n }\n function p(e) {\n return !g(e);\n }\n function b(e) {\n return !g(e) && (\"string\" == typeof e || null !== e.constructor && e.constructor === String);\n }\n function _(e) {\n for (var _t = 1; _t < arguments.length; _t++) {\n var _s = arguments[_t];\n for (var _t2 in _s) e[_t2] = _s[_t2];\n }\n return e;\n }\n function y(e) {\n switch (e) {\n case 5120:\n return Int8Array;\n case 5121:\n return Uint8Array;\n case 5122:\n return Int16Array;\n case 5123:\n return Uint16Array;\n case 5124:\n return Int32Array;\n case 5125:\n return Uint32Array;\n case 5126:\n return Float32Array;}\n\n throw new Error(\"unsupported bufferView's component type: \" + e);\n }\n function x(e) {\n return 0 === e.indexOf(\"data:\") && e.indexOf(\"base64,\") > 0;\n }\n function w(e) {\n var t = function (e) {\n return \"undefined\" != typeof self ? self.atob(e) : window.atob(e);\n }(e.substring(e.indexOf(\",\") + 1)),\n s = t.length,\n r = new Uint8Array(s);\n for (var _e = 0; _e < s; _e++) r[_e] = t.charCodeAt(_e);\n return r.buffer;\n }\n var T = [],\n E = [],\n O = [],\n I = [0, 0, 0],\n R = function (e) {\n return e[0] = 0, e[1] = 0, e[2] = 0, e[3] = 1, e;\n }([]),\n A = [1, 1, 1];\n function q(e, t, s, r, n, i, a) {\n var o = y(a),\n f = o.BYTES_PER_ELEMENT;\n if ((0 === n || n === r * f) && i % f == 0) {\n var _n = new o(t, i, s * r);\n return e.set(_n), e;\n }\n 0 === n && (n = r * f);\n var u = new Uint8Array(r * f);\n for (var _a = 0; _a < s; _a++) {\n var _s2 = null;\n var _h = new Uint8Array(t, n * _a + i, r * f);\n u.set(_h), _s2 = new o(u.buffer, 0, r);\n for (var _t3 = 0; _t3 < r; _t3++) e[_a * r + _t3] = _s2[_t3];\n }\n return e;\n }\n var B = \"undefined\" != typeof TextDecoder ? new TextDecoder(\"utf-8\") : null;\n function N(e, t, s) {\n var r = new Uint8Array(e, t, s);\n return B.decode(r);\n }\n var v = exports.Ajax = {\n get: function get(e) {\n var _this = this;\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var s = arguments.length > 2 ? arguments[2] : undefined;\n t || (t = {});\n var r = new AbortController(),\n n = r.signal,\n i = _({}, t);\n i.signal = n, i.method || (i.method = \"GET\"), i.referrerPolicy = i.referrerPolicy || \"origin\", \"undefined\" == typeof window || i.referrer || (i.referrer = window.location.href), s && (e = s(e));\n var a = fetch(e, i).then(function (e) {\n var s = _this._parseResponse(e, t.responseType);\n return s.message ? s : s.then(function (s) {\n return \"arraybuffer\" === t.responseType ? {\n data: s,\n cacheControl: e.headers.get(\"Cache-Control\"),\n expires: e.headers.get(\"Expires\"),\n contentType: e.headers.get(\"Content-Type\") } :\n s;\n }).catch(function (e) {\n if (!e.code || e.code !== DOMException.ABORT_ERR) throw e;\n });\n }).catch(function (e) {\n if (!e.code || e.code !== DOMException.ABORT_ERR) throw e;\n });\n return a.xhr = r, a;\n },\n _parseResponse: function _parseResponse(e, t) {\n return 200 !== e.status ? {\n status: e.status,\n statusText: e.statusText,\n message: \"incorrect http request with status code(\".concat(e.status, \"): \").concat(e.statusText) } :\n \"arraybuffer\" === t ? e.arrayBuffer() : \"json\" === t ? e.json() : e.text();\n },\n getArrayBuffer: function getArrayBuffer(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var s = arguments.length > 2 ? arguments[2] : undefined;\n return t || (t = {}), t.responseType = \"arraybuffer\", v.get(e, t, s);\n },\n getJSON: function getJSON(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var s = arguments.length > 2 ? arguments[2] : undefined;\n return t && t.jsonp ? v.jsonp(e) : ((t = t || {}).responseType = \"json\", v.get(e, t, s));\n } };\n\n v.jsonp = function (e) {\n var t = \"_maptalks_jsonp_\" + m++;\n e.match(/\\?/) ? e += \"&callback=\" + t : e += \"?callback=\" + t;\n var s = document.createElement(\"script\");\n return s.type = \"text/javascript\", s.src = e, new Promise(function (e) {\n window[t] = function (r) {\n document.getElementsByTagName(\"head\")[0].removeChild(s), s = null, delete window[t], e(r);\n }, document.getElementsByTagName(\"head\")[0].appendChild(s);\n });\n };\n var P = function () {\n function P(e, t, s, r, n) {\n _classCallCheck(this, P);\n this._requestImage = e, this.decoders = t, this._supportedFormats = s, this.images = {}, this._imgRequests = {}, this._fetchOptions = r || {}, this._urlModifier = n;\n }\n return _createClass(P, [{\n key: \"requestImageFromBufferURI\",\n value: function requestImageFromBufferURI(e, t, s) {\n var _this2 = this;\n if (this.buffers[e.id]) {\n var _r = this.buffers[e.id],\n _n2 = this._createDataView(t, _r);\n return this.getImageByBuffer(_n2, s);\n }\n if (this._imgRequests[e.id]) return this._imgRequests[e.id].then(function () {\n var r = _this2.buffers[e.id],\n n = _this2._createDataView(t, r);\n return _this2.getImageByBuffer(n, s);\n });\n if (x(e.uri)) {\n var _r2 = this.buffers[e.id] = w(e.uri),\n _n3 = this._createDataView(t, _r2);\n return this.getImageByBuffer(_n3, s);\n }\n var r;\n var n = e.uri.indexOf(\"blob:\") >= 0;\n r = e.uri.indexOf(\"://\") > 0 || n ? e.uri : this.rootPath + \"/\" + e.uri;\n return this._imgRequests[e.id] = v.getArrayBuffer(r, this._fetchOptions, this._urlModifier).then(function (r) {\n var n = _this2.buffers[e.id] = r.data,\n i = _this2._createDataView(t, n);\n return _this2.getImageByBuffer(i, s);\n });\n } },\n {\n key: \"getImageByBuffer\",\n value: function getImageByBuffer(e, t) {\n if (this.images[t.id]) return Promise.resolve(this.images[t.id]);\n var s = this.decoders;\n if (s[t.mimeType]) return s[t.mimeType](e, {\n supportedFormats: this._supportedFormats });\n\n if (\"image/crn\" === t.mimeType || \"image/ktx2\" === t.mimeType || \"image/cttf\" === t.mimeType) throw new Error(\"missing transcoder for \" + t.mimeType, \"\");\n return this._getImageInfo(t.id, e);\n } },\n {\n key: \"requestExternalImage\",\n value: function requestExternalImage(e) {\n var _this3 = this;\n if (this.images[e.id]) return Promise.resolve(this.images[e.id]);\n var t = 0 === e.uri.indexOf(\"data:image/\") ? e.uri : this.rootPath + \"/\" + e.uri;\n if (this._imgRequests[e.id]) return this._imgRequests[e.id].then(function () {\n return _this3.images[e.id];\n });\n return this._imgRequests[e.id] = this._getImageInfo(e.id, t);\n } },\n {\n key: \"_getImageInfo\",\n value: function _getImageInfo(e, t) {\n var _this4 = this;\n return new Promise(function (s, r) {\n var n = t;\n _this4._urlModifier && (n = _this4._urlModifier(t)), _this4._requestImage(n, _this4._fetchOptions, function (n, i) {\n n ? r(n) : (URL.revokeObjectURL(t), _this4.images[e] = i, s(_this4.images[e]));\n });\n });\n } }]);\n\n }();\n var M = [\"SCALAR\", 1, \"VEC2\", 2, \"VEC3\", 3, \"VEC4\", 4, \"MAT2\", 4, \"MAT3\", 9, \"MAT4\", 16],\n S = [];\n var V = function () {\n function V(e, t, s, r, n) {\n _classCallCheck(this, V);\n this.rootPath = e, this.gltf = t, this._enableInterleave = !1, this.glbBuffer = s, this.buffers = {}, this.requests = {}, this.accessors = {}, this._compareAccessor(), this._fetchOptions = r, this._urlModifier = n;\n }\n return _createClass(V, [{\n key: \"_requestData\",\n value: function _requestData(e, t) {\n var _this5 = this;\n var s = this.gltf,\n r = s.accessors[t];\n if (void 0 === r.bufferView) return this.accessors[r.id] = this._toBufferData(e, t, null, 0), Promise.resolve(this.accessors[r.id]);\n if (r && this.accessors[r.id]) return Promise.resolve(this.accessors[r.id]);\n var n = s.bufferViews[r.bufferView];\n return this._requestBufferOfBufferView(n).then(function (s) {\n var n = s.buffer,\n i = s.byteOffset;\n return _this5.accessors[r.id] = _this5._toBufferData(e, t, n, i);\n });\n } },\n {\n key: \"_requestBufferOfBufferView\",\n value: function _requestBufferOfBufferView(e) {\n var _this6 = this;\n var t = this.gltf.buffers[e.buffer];\n if (this.buffers[t.id]) {\n var _e2 = this.buffers[t.id];\n return Promise.resolve({\n buffer: _e2,\n byteOffset: 0 });\n\n }\n if (this.requests[t.id]) return this.requests[t.id].then(function () {\n var e = _this6.buffers[t.id];\n return Promise.resolve({\n buffer: e,\n byteOffset: 0 });\n\n });\n if (\"binary_glTF\" !== e.buffer && \"KHR_binary_glTF\" !== e.buffer && t.uri) {\n if (x(t.uri)) {\n var _e3 = this.buffers[t.id] = w(t.uri);\n return Promise.resolve({\n buffer: _e3,\n byteOffset: 0 });\n\n }\n var _e4;\n var _s3 = t.uri.indexOf(\"blob:\") >= 0;\n _e4 = t.uri.indexOf(\"://\") > 0 || _s3 ? t.uri : this.rootPath + \"/\" + t.uri;\n return this.requests[t.id] = v.getArrayBuffer(_e4, this._fetchOptions, !_s3 && this._urlModifier).then(function (r) {\n _s3 && URL.revokeObjectURL(_e4);\n return {\n buffer: _this6.buffers[t.id] = r.data,\n byteOffset: 0 };\n\n });\n }\n return Promise.resolve({\n buffer: this.glbBuffer.buffer,\n byteOffset: this.glbBuffer.byteOffset });\n\n } },\n {\n key: \"_toBufferData\",\n value: function _toBufferData(e, t, s) {\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n var n = this.gltf,\n i = n.accessors[t],\n a = void 0 !== i.bufferView ? n.bufferViews[i.bufferView] : {},\n o = (a.byteOffset || 0) + r,\n f = this._getTypeItemSize(i.type),\n h = y(i.componentType),\n c = a.byteStride || 0;\n var l = {\n array: undefined,\n name: e,\n accessorName: t,\n byteLength: i.count * f * h.BYTES_PER_ELEMENT,\n componentType: i.componentType,\n count: i.count,\n type: i.type,\n itemSize: f,\n max: i.max,\n min: i.min,\n extensions: i.extensions };\n\n if (i.min && (l.min = i.min), i.max && (l.max = i.max), s) {\n if (this._enableInterleave) l.byteStride = c, l.byteOffset = o + (i.byteOffset || 0), !c || c === f * h.BYTES_PER_ELEMENT || \"indices\" === e || \"input\" === e || \"output\" === e || e.indexOf(\"morph\") >= 0 ? (l.array = this._typedArray(s, i.count, f, o + (i.byteOffset || 0), h), l.array.buffer.byteLength === l.byteLength && (l.byteOffset = 0)) : l.array = new Uint8Array(s, o, a.byteLength);else if (i.interleaved) {\n l.byteStride = 0, l.byteOffset = 0;\n var _e5 = new h(i.count * f);\n if (l.array = q(_e5, s, i.count, f, c, o + (i.byteOffset || 0), i.componentType), l.extensions && l.extensions.WEB3D_quantized_attributes && f > 2) {\n var _e6 = new Float32Array(l.array.length),\n _t4 = l.extensions.WEB3D_quantized_attributes.decodeMatrix;\n for (var _s4 = 0; _s4 < l.array.length; _s4 += f) {\n S[0] = l.array[_s4], S[1] = l.array[_s4 + 1], S[2] = l.array[_s4 + 2], S[3] = 1;\n var _r3 = u(S, S, _t4);\n _e6[_s4] = _r3[0], _e6[_s4 + 1] = _r3[1], _e6[_s4 + 2] = _r3[2];\n }\n l.componentType = 5126, l.array = _e6;\n }\n } else l.byteStride = 0, l.array = this._typedArray(s, i.count, f, o + (i.byteOffset || 0), h), l.byteOffset = l.array.byteOffset;\n } else {\n l.array = new h(i.count);\n var _e7 = l.min || l.max;\n _e7 && (l.array[0] = _e7[0], l.array[1] = _e7[1], l.array[2] = _e7[2]);\n }\n return l;\n } },\n {\n key: \"_compareAccessor\",\n value: function _compareAccessor() {\n var e = this.gltf.accessors;\n if (Array.isArray(e)) for (var _t5 = 0; _t5 < e.length; _t5++) for (var _s5 = 0; _s5 < e.length; _s5++) _t5 !== _s5 && e[_t5].bufferView === e[_s5].bufferView && (e[_t5].interleaved = e[_s5].interleaved = !0);else for (var _t6 in e) for (var _s6 in e) _t6 !== _s6 && e[_t6].bufferView === e[_s6].bufferView && (e[_t6].interleaved = e[_s6].interleaved = !0);\n } },\n {\n key: \"_typedArray\",\n value: function _typedArray(e, t, s, r, n) {\n return r % n.BYTES_PER_ELEMENT != 0 && (e = e.slice(r, r + t * s * n.BYTES_PER_ELEMENT), r = 0), new n(e, r, s * t);\n } },\n {\n key: \"_getTypeItemSize\",\n value: function _getTypeItemSize(e) {\n var t = M.indexOf(e);\n return M[t + 1];\n } },\n {\n key: \"requestKHRTechniquesWebgl\",\n value: function requestKHRTechniquesWebgl(e) {\n var _this7 = this;\n var t = e.shaders,\n s = t.map(function (e) {\n if (void 0 !== e.bufferView) {\n var _t7 = _this7.gltf.bufferViews[e.bufferView],\n _s7 = _t7.byteLength;\n return _this7._requestBufferOfBufferView(_t7).then(function (r) {\n var n = r.buffer,\n i = r.byteOffset,\n a = N(n, i + (_t7.byteOffset || 0), _s7);\n return e.content = a, e;\n });\n }\n if (e.uri) {\n if (x(e.uri)) {\n var _t8 = w(e.uri),\n _s8 = N(_t8, 0, _t8.byteLength);\n return e.content = _s8, Promise.resolve(e);\n }\n {\n var _t9 = _this7.rootPath + \"/\" + e.uri;\n return v.get(_t9, _this7._fetchOptions, _this7._urlModifier).then(function (t) {\n return e.content = t, e;\n });\n }\n }\n return Promise.resolve(e);\n });\n return Promise.all(s).then(function () {\n return e;\n });\n } }]);\n\n }();\n var D = function (_P) {\n function D(e, t, s, r, n, i, a, o) {\n var _this8;\n _classCallCheck(this, D);\n _this8 = _callSuper(this, D, [r, n, i, a, o]), _this8.rootPath = e, _this8.gltf = t, _this8.requests = {}, _this8.buffers = {}, _this8.glbBuffer = s, _this8.accessor = new V(e, t, s, a, o);\n return _this8;\n }\n _inherits(D, _P);\n return _createClass(D, [{\n key: \"iterate\",\n value: function iterate(e, t) {\n var s = this.gltf[t];\n if (!s) return;\n var r = 0;\n for (var _t10 in s) e(_t10, s[_t10], r++);\n } },\n {\n key: \"createNode\",\n value: function createNode(e) {\n var s = {};\n if (p(e.name) && (s.name = e.name), p(e.children) && (s.children = e.children), p(e.jointName) && (s.jointName = e.jointName), p(e.matrix) && (s.matrix = e.matrix), p(e.rotation) && (s.rotation = e.rotation), p(e.scale) && (s.scale = e.scale), p(e.translation) && (s.translation = e.translation), p(e.extras) && (s.extras = e.extras), p(e.meshes) && (s.mesh = e.meshes[0]), s.translation || s.rotation || s.scale) {\n var _e8 = function (e, s) {\n if (s.matrix) return s.matrix;\n if (s.translation || s.scale || s.rotation) {\n var _r4 = function (e, t) {\n return e[0] = 1, e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 0, e[5] = 1, e[6] = 0, e[7] = 0, e[8] = 0, e[9] = 0, e[10] = 1, e[11] = 0, e[12] = t[0], e[13] = t[1], e[14] = t[2], e[15] = 1, e;\n }(T, s.translation || I),\n _n4 = function (e, t) {\n var s = t[0],\n r = t[1],\n n = t[2],\n i = t[3],\n a = s + s,\n o = r + r,\n f = n + n,\n u = s * a,\n h = r * a,\n c = r * o,\n l = n * a,\n d = n * o,\n m = n * f,\n g = i * a,\n p = i * o,\n b = i * f;\n return e[0] = 1 - c - m, e[1] = h + b, e[2] = l - p, e[3] = 0, e[4] = h - b, e[5] = 1 - u - m, e[6] = d + g, e[7] = 0, e[8] = l + p, e[9] = d - g, e[10] = 1 - u - c, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, e;\n }(E, s.rotation || R),\n _i = function (e, t) {\n return e[0] = t[0], e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 0, e[5] = t[1], e[6] = 0, e[7] = 0, e[8] = 0, e[9] = 0, e[10] = t[2], e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, e;\n }(O, s.scale || A);\n return t(_i, _n4, _i), t(e, _r4, _i);\n }\n return function (e) {\n return e[0] = 1, e[1] = 0, e[2] = 0, e[3] = 0, e[4] = 0, e[5] = 1, e[6] = 0, e[7] = 0, e[8] = 0, e[9] = 0, e[10] = 1, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, e;\n }(e);\n }([], s);\n delete s.translation, delete s.rotation, delete s.scale, s.matrix = _e8;\n }\n return s;\n } },\n {\n key: \"_loadMaterials\",\n value: function _loadMaterials(e) {\n var t = {};\n for (var _s9 in e) {\n var _r5 = e[_s9];\n var _n5 = void 0,\n _i2 = void 0;\n _r5.instanceTechnique && _r5.instanceTechnique.values ? (_n5 = _r5.instanceTechnique, _i2 = _n5.values.diffuse) : (_n5 = _r5, _i2 = _n5.values.tex || _n5.values.diffuseTex || _n5.values.diffuse);\n var _a2 = {\n baseColorTexture: {\n index: _i2 } };\n\n\n _r5.name && (_a2.name = _r5.name), _r5.extensions && (_a2.extensions = _r5.extensions), _r5.extras && (_a2.extras = _r5.extras), t[_s9] = _a2;\n }\n return t;\n } },\n {\n key: \"_loadImage\",\n value: function _loadImage(e) {\n if (e.bufferView || e.extensions && (e.extensions.KHR_binary_glTF || e.extensions.binary_glTF)) {\n var _t11 = e.bufferView ? e : e.extensions.KHR_binary_glTF || e.extensions.binary_glTF;\n e.extensions && (e.mimeType = _t11.mimeType, e.width = _t11.width, e.height = _t11.height);\n var _s10 = this.gltf.bufferViews[_t11.bufferView],\n _r6 = (_s10.byteOffset || 0) + this.glbBuffer.byteOffset,\n _n6 = _s10.byteLength,\n _i3 = this.buffers[_t11.bufferView] = new Uint8Array(this.glbBuffer.buffer, _r6, _n6);\n return this.getImageByBuffer(_i3, e);\n }\n return this.requestExternalImage(e);\n } },\n {\n key: \"_getTexture\",\n value: function _getTexture(e) {\n var _this9 = this;\n var t = this.gltf.textures[e];\n if (!t) return null;\n var s = this.gltf.images[t.source];\n return this._loadImage(s).then(function (e) {\n var r = _this9.gltf.samplers[t.sampler];\n return {\n image: {\n array: e.data,\n width: e.width,\n height: e.height,\n index: t.source,\n mimeType: s.mimeType,\n name: s.name,\n extras: s.extras },\n\n sampler: r };\n\n });\n } },\n {\n key: \"getBaseColorTexture\",\n value: function getBaseColorTexture(e) {\n var t = this.gltf.materials[e];\n var s, r;\n if (t.instanceTechnique && t.instanceTechnique.values ? (s = t.instanceTechnique, r = s.values.diffuse) : (s = t, r = s.values.tex || s.values.diffuseTex || s.values.diffuse), void 0 === r || void 0 === this.gltf.textures) return null;\n var n = this.gltf.textures[r];\n if (!n) return null;\n var i = this.gltf.samplers[n.sampler];\n return {\n format: n.format || 6408,\n internalFormat: n.internalFormat || 6408,\n type: n.type || 5121,\n sampler: i,\n source: this.gltf.images[n.source] };\n\n } },\n {\n key: \"getMaterial\",\n value: function getMaterial() {\n return null;\n } },\n {\n key: \"getAnimations\",\n value: function getAnimations() {\n return null;\n } }]);\n\n }(P);\n var L = 9729;\n var U = function (_P2) {\n function U(e, t, s, r, n, i, a, o) {\n var _this10;\n _classCallCheck(this, U);\n _this10 = _callSuper(this, U, [r, n, i, a, o]), _this10.rootPath = e, _this10.gltf = t, _this10.glbBuffer = s, _this10.buffers = {}, _this10.requests = {}, _this10.accessor = new V(e, t, s, a, o);\n return _this10;\n }\n _inherits(U, _P2);\n return _createClass(U, [{\n key: \"iterate\",\n value: function iterate(e, t) {\n var s = this.gltf[t];\n if (s) for (var _t12 = 0; _t12 < s.length; _t12++) e(_t12, s[_t12], _t12);\n } },\n {\n key: \"createNode\",\n value: function createNode(e) {\n var t = {};\n return _(t, e), !p(e.weights) && this.gltf.meshes && p(t.mesh) ? t.weights = this.gltf.meshes[t.mesh].weights : e.weights && (t.weights = e.weights), t;\n } },\n {\n key: \"_getTexture\",\n value: function _getTexture(e) {\n var _this11 = this;\n var t = this.gltf.textures[e];\n if (!t) return null;\n var s = t.source;\n if (t.extensions && t.extensions.EXT_texture_webp ? s = t.extensions.EXT_texture_webp.source : t.extensions && t.extensions.KHR_texture_basisu && (s = t.extensions.KHR_texture_basisu.source), !p(s)) return null;\n var r = this.gltf.images[s];\n return this._loadImage(r).then(function (e) {\n if (!e) return null;\n var s = {\n image: {\n array: e.data,\n mipmap: e.mipmap,\n width: e.width,\n height: e.height,\n index: t.source,\n mimeType: r.mimeType,\n name: r.name,\n extensions: r.extensions,\n extras: r.extras } };\n\n\n _(s, t);\n var n = p(t.sampler) ? _this11.gltf.samplers[t.sampler] : void 0;\n if (n && (s.sampler = n, s.sampler.magFilter = n.magFilter || L, s.sampler.minFilter = n.minFilter || 9987, s.sampler.wrapS = n.wrapS || 10497, s.sampler.wrapT = n.wrapT || 10497), \"image/ktx2\" === s.image.mimeType && !s.image.mipmap && s.sampler && s.sampler.minFilter !== L && 9728 !== s.sampler.minFilter) {\n var _e9 = s.sampler.minFilter;\n s.sampler.minFilter = 9984 === _e9 || 9986 === _e9 ? 9728 : L;\n }\n return e.format && (s.format = e.format), s;\n });\n } },\n {\n key: \"_loadImage\",\n value: function _loadImage(e) {\n if (!p(e.bufferView)) return this.requestExternalImage(e);\n {\n var _t13 = this.gltf.bufferViews[e.bufferView],\n _s11 = this.gltf.buffers[_t13.buffer];\n if (_s11.uri) return this.requestImageFromBufferURI(_s11, _t13, e);\n if (this.glbBuffer) return this._requestFromGlbBuffer(_t13, e);\n }\n return null;\n } },\n {\n key: \"_requestFromGlbBuffer\",\n value: function _requestFromGlbBuffer(e, t) {\n var s = this._createDataView(e, this.glbBuffer.buffer, this.glbBuffer.byteOffset);\n return this.getImageByBuffer(s, t);\n } },\n {\n key: \"_createDataView\",\n value: function _createDataView(e, t, s) {\n s = s || 0;\n var r = (e.byteOffset || 0) + s,\n n = e.byteLength;\n return new Uint8Array(t, r, n);\n } },\n {\n key: \"_transformArrayBufferToBase64\",\n value: function _transformArrayBufferToBase64(e, t) {\n var s = new Array(e.byteLength);\n for (var _t14 = 0; _t14 < e.byteLength; _t14++) s[_t14] = String.fromCharCode(e[_t14]);\n s.join(\"\");\n var r = \"data:\" + (t = t || \"image/png\") + \";base64,\" + function (e) {\n return \"undefined\" != typeof self ? self.btoa(e) : window.btoa(e);\n }(unescape(encodeURIComponent(s)));\n return r;\n } },\n {\n key: \"getAnimations\",\n value: function getAnimations(e) {\n var _this12 = this;\n var t = [];\n return e.forEach(function (e) {\n t.push(_this12.getSamplers(e.samplers));\n }), Promise.all(t).then(function (t) {\n for (var _s12 = 0; _s12 < t.length; _s12++) e[_s12].samplers = t[_s12];\n return e;\n });\n } },\n {\n key: \"getSamplers\",\n value: function getSamplers(e) {\n var t = [];\n for (var _s13 = 0; _s13 < e.length; _s13++) (p(e[_s13].input) || p(e[_s13].output)) && (t.push(this.accessor._requestData(\"input\", e[_s13].input)), t.push(this.accessor._requestData(\"output\", e[_s13].output)));\n return Promise.all(t).then(function (t) {\n for (var _s14 = 0; _s14 < t.length / 2; _s14++) e[_s14].input = t[2 * _s14], e[_s14].output = t[2 * _s14 + 1], e[_s14].interpolation || (e[_s14].interpolation = \"LINEAR\");\n return e;\n });\n } }]);\n\n }(P);\n var C = \"undefined\" != typeof TextDecoder ? new TextDecoder(\"utf-8\") : null,\n F = 1313821514,\n k = 5130562;\n var X = function () {\n function X() {\n _classCallCheck(this, X);\n }\n return _createClass(X, null, [{\n key: \"read\",\n value: function read(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var s = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n s || (s = e.byteLength);\n var r = new DataView(e, t, s),\n n = r.getUint32(4, !0);\n if (1 === n) return X.readV1(r, t);\n if (2 === n) return X.readV2(e, t);\n throw new Error(\"Unsupported glb version : \" + n);\n } },\n {\n key: \"readV1\",\n value: function readV1(e, t) {\n var s = e.getUint32(8, !0),\n r = e.getUint32(12, !0);\n if (s !== e.byteLength) throw new Error(\"Length in GLB header is inconsistent with glb's byte length.\");\n var n = K(e.buffer, 20 + t, r);\n return {\n json: JSON.parse(n),\n glbBuffer: {\n byteOffset: 20 + t + r,\n buffer: e.buffer,\n byteLength: s } };\n\n\n } },\n {\n key: \"readV2\",\n value: function readV2(e, t) {\n var s, r, n;\n var i = new DataView(e, t + 12);\n var a = 0;\n for (; a + 8 < i.byteLength;) {\n var _o = i.getUint32(a, !0);\n a += 4;\n var _f = i.getUint32(a, !0);\n if (a += 4, _f === F) s = K(e, t + 12 + a, _o);else if (_f === k) {\n n = t + 12 + a, r = _o;\n break;\n }\n a += _o;\n }\n return {\n json: JSON.parse(s),\n glbBuffer: {\n byteOffset: n,\n buffer: e,\n byteLength: r } };\n\n\n } }]);\n\n }();\n function K(e, t, s) {\n if (C) {\n var _r7 = new Uint8Array(e, t, s);\n return C.decode(_r7);\n }\n return function (e) {\n var t = e.length;\n var s = \"\";\n for (var _r8 = 0; _r8 < t;) {\n var _n7 = e[_r8++];\n if (128 & _n7) {\n var _s15 = H[_n7 >> 3 & 7];\n if (!(64 & _n7) || !_s15 || _r8 + _s15 > t) return null;\n for (_n7 &= 63 >> _s15; _s15 > 0; _s15 -= 1) {\n var _t15 = e[_r8++];\n if (128 != (192 & _t15)) return null;\n _n7 = _n7 << 6 | 63 & _t15;\n }\n }\n s += String.fromCharCode(_n7);\n }\n return s;\n }(new Uint8Array(e, t, s));\n }\n var H = [1, 1, 1, 1, 2, 2, 3, 0];\n var j = [0, 0, 0],\n z = [0, 0, 0, 1],\n W = [1, 1, 1],\n Y = {\n TRANSLATION: [0, 0, 0],\n ROTATION: [0, 0, 0, 1],\n SCALE: [1, 1, 1] },\n\n G = {\n PREVIOUS: null,\n NEXT: null,\n PREINDEX: null,\n NEXTINDEX: null,\n INTERPOLATION: null },\n\n $ = {\n _getTRSW: function _getTRSW(e, t, s, r, i, a, o, f) {\n var u = p(e) ? t.animations : [t.animations[0]],\n h = {};\n for (var _t16 = 0; _t16 < u.length; _t16++) {\n var _c = u[_t16],\n _l = _c.name || _t16;\n if (p(e) && _l !== e) continue;\n var _m = _c.channelsMap[s];\n if (_m) for (var _e10 = 0; _e10 < _m.length; _e10++) {\n var _t17 = _m[_e10];\n \"translation\" === _t17.target.path ? (this._getAnimateData(i, _c.samplers[_t17.sampler], r, 1), h.translation = n(j, i)) : \"rotation\" === _t17.target.path ? (this._getQuaternion(a, _c.samplers[_t17.sampler], r, 1), h.rotation = d(z, a)) : \"scale\" === _t17.target.path ? (this._getAnimateData(o, _c.samplers[_t17.sampler], r, 1), h.scale = n(W, o)) : \"weights\" === _t17.target.path && f && (this._getAnimateData(f, _c.samplers[_t17.sampler], r, f.length), h.weights = f);\n }\n }\n return h;\n },\n _getAnimateData: function _getAnimateData(e, t, s, r) {\n switch (t.interpolation) {\n case \"LINEAR\":\n {\n var _n8 = this._getPreNext(G, t, s, 1 * r);\n _n8 && (e = function (e, t, s, r) {\n for (var _n9 = 0; _n9 < e.length; _n9++) e[_n9] = t[_n9] + r * (s[_n9] - t[_n9]);\n return e;\n }(e, _n8.PREVIOUS, _n8.NEXT, _n8.INTERPOLATION));\n break;\n }\n case \"STEP\":\n {\n var _n10 = this._getPreNext(G, t, s, 1 * r);\n _n10 && (e = function (e, t) {\n for (var _s16 = 0; _s16 < e.length; _s16++) e[_s16] = t[_s16];\n return e;\n }.apply(undefined, [e].concat(_toConsumableArray(_n10.PREVIOUS))));\n break;\n }\n case \"CUBICSPLINE\":\n {\n var _n11 = this._getPreNext(G, t, s, 3 * r);\n _n11 && (e = this._getCubicSpline(e, _n11, t.input.array, 3 * r));\n break;\n }}\n\n return e;\n },\n _getQuaternion: function _getQuaternion(e, t, s) {\n switch (t.interpolation) {\n case \"LINEAR\":\n {\n var _r9 = this._getPreNext(G, t, s, 1);\n _r9 && c(e, _r9.PREVIOUS, _r9.NEXT, _r9.INTERPOLATION);\n break;\n }\n case \"STEP\":\n {\n var _r10 = this._getPreNext(G, t, s, 1);\n _r10 && (e = f.apply(undefined, [e].concat(_toConsumableArray(_r10.PREVIOUS))));\n break;\n }\n case \"CUBICSPLINE\":\n {\n var _r11 = this._getPreNext(G, t, s, 3);\n if (_r11) {\n for (var _e11 = 0; _e11 < _r11.PREVIOUS.length; _e11++) _r11.PREVIOUS[_e11] = Math.acos(_r11.PREVIOUS[_e11]), _r11.NEXT[_e11] = Math.acos(_r11.NEXT[_e11]);\n e = this._getCubicSpline(e, _r11, t.input.array, 3);\n for (var _t18 = 0; _t18 < e.length; _t18++) e[_t18] = Math.cos(e[_t18]);\n }\n break;\n }}\n\n return e;\n },\n _search: function _search(e, t) {\n var s = e.length;\n var r,\n n,\n i,\n a = 0,\n o = s - 1,\n f = Math.floor((a + o) / 2);\n for (; a <= s - 1 && o >= 0;) {\n if (a === o) return null;\n if (e[f] <= t && t <= e[f + 1]) {\n var _s17 = e[f];\n return r = f, n = f + 1, i = (t - _s17) / (e[f + 1] - _s17), {\n preIndx: r,\n nextIndex: n,\n interpolation: i };\n\n }\n t < e[f] ? (o = f, f = Math.floor((a + o) / 2)) : e[f + 1] < t && (a = f, f = Math.floor((a + o) / 2));\n }\n return null;\n },\n _getPreNext: function _getPreNext(e, t, s, r) {\n var n = t.input.array,\n i = t.output.array,\n a = t.output.itemSize;\n (s < n[0] || s > n[n.length - 1]) && (s = Math.max(n[0], Math.min(n[n.length - 1], s))), s === n[n.length - 1] && (s = n[0]);\n var o = this._search(n, s);\n if (!o || !o.nextIndex) return null;\n var f = o.preIndx,\n u = o.nextIndex,\n h = o.interpolation;\n e.PREINDEX = f, e.NEXTINDEX = u, e.INTERPOLATION = h;\n var c = a * r;\n return e.PREVIOUS = i.subarray(e.PREINDEX * c, (e.PREINDEX + 1) * c), e.NEXT = i.subarray(e.NEXTINDEX * c, (e.NEXTINDEX + 1) * c), e;\n },\n _getCubicSpline: function _getCubicSpline(e, t, s, r) {\n var n = t.INTERPOLATION,\n i = s[t.PREINDEX],\n a = s[t.NEXTINDEX];\n for (var _s18 = 0; _s18 < 3; _s18++) {\n var _o2 = t.PREVIOUS[r + _s18],\n _f2 = (a - i) * t.PREVIOUS[2 * r + _s18],\n _u = t.NEXT[3 + _s18],\n _h2 = (a - i) * t.NEXT[_s18],\n _c2 = (2 * Math.pow(n, 3) - 3 * Math.pow(n, 2) + 1) * _o2 + (Math.pow(n, 3) - 2 * Math.pow(n, 2) + n) * _f2 + (2 * -Math.pow(n, 3) + 3 * Math.pow(n, 2)) * _u + (Math.pow(n, 3) - Math.pow(n, 2)) * _h2;\n e[_s18] = _c2;\n }\n return e;\n },\n getAnimationClip: function getAnimationClip(e, t, s, r) {\n var n = e.nodes[t] && e.nodes[t].weights;\n i.apply(undefined, [j].concat(_toConsumableArray(Y.TRANSLATION))), f.apply(undefined, [z].concat(_toConsumableArray(Y.ROTATION))), i.apply(undefined, [W].concat(_toConsumableArray(Y.SCALE)));\n return this._getTRSW(r, e, t, s, j, z, W, n);\n },\n getTimeSpan: function getTimeSpan(e) {\n if (!e.animations) return null;\n if (e.timeSpan) return e.timeSpan;\n var t = e.animations;\n return e.timeSpan = {}, t.forEach(function (t, s) {\n var r = -1 / 0,\n n = 1 / 0;\n var i = t.channels;\n for (var _e12 = 0; _e12 < i.length; _e12++) {\n var _s19 = i[_e12],\n _a3 = t.samplers[_s19.sampler].input.array;\n _a3[_a3.length - 1] > r && (r = _a3[_a3.length - 1]), _a3[0] < n && (n = _a3[0]);\n }\n var a = t.name || s;\n e.timeSpan[a] = {\n max: r,\n min: n };\n\n }), e.timeSpan;\n },\n getTimeSpanByName: function getTimeSpanByName(e, t) {\n var s = this.getTimeSpan(e);\n return s ? p(t) ? s[t] : s[Object.keys(s)[0]] : null;\n } };\n\n var J = !1;\n if (\"undefined\" != typeof OffscreenCanvas) {\n var _e13;\n try {\n _e13 = new OffscreenCanvas(2, 2).getContext(\"2d\");\n } catch (e) {}\n _e13 && \"undefined\" != typeof createImageBitmap && (J = !0);\n }\n var Q = \"undefined\" == typeof document ? null : document.createElement(\"canvas\");\n var Z = exports.GLTFLoader = function () {\n function Z(e, t, s) {\n _classCallCheck(this, Z);\n if (this.options = s || {}, this.options.decoders || (this.options.decoders = {}), this._fetchOptions = this.options.fetchOptions || {}, t.buffer instanceof ArrayBuffer) {\n var _X$read = X.read(t.buffer, t.byteOffset, t.byteLength),\n _s20 = _X$read.json,\n _r12 = _X$read.glbBuffer;\n this._init(e, _s20, _r12);\n } else this._init(e, t);\n this._accessor = new V(this.rootPath, this.gltf, this.glbBuffer, this._fetchOptions, this.options.urlModifier), this._checkExtensions();\n }\n return _createClass(Z, [{\n key: \"_checkExtensions\",\n value: function _checkExtensions() {\n var e = this.gltf.extensionsRequired;\n if (e) {\n if (e.indexOf(\"KHR_draco_mesh_compression\") >= 0 && !this.options.decoders.draco) throw new Error(\"KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded\");\n if (e.indexOf(\"KHR_texture_basisu\") >= 0 && !this.options.decoders[\"image/ktx2\"]) throw new Error(\"KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded\");\n if (e.indexOf(\"EXT_meshopt_compression\") >= 0) throw new Error(\"EXT_meshopt_compression extension is not supported yet.\");\n }\n } },\n {\n key: \"_loadExtensions\",\n value: function _loadExtensions() {\n var e = this.gltf.extensions;\n return e && e.KHR_techniques_webgl ? this._accessor.requestKHRTechniquesWebgl(e.KHR_techniques_webgl).then(function (t) {\n return e.KHR_techniques_webgl = t, e;\n }) : Promise.resolve(e);\n } },\n {\n key: \"_convertKhrTechiqueToTechiques\",\n value: function _convertKhrTechiqueToTechiques() {\n if (!Array.isArray(this.gltf.programs)) return;\n var e = this.gltf.materials;\n for (var _t19 = 0; _t19 < e.length; _t19++) e[_t19] && e[_t19].extensions && e[_t19].extensions.KHR_technique_webgl && (e[_t19].extensions.KHR_techniques_webgl = e[_t19].extensions.KHR_technique_webgl, delete e[_t19].extensions.KHR_technique_webgl);\n var t = this.gltf.extensions || {},\n s = this.gltf.techniques;\n t.KHR_techniques_webgl = {\n programs: this.gltf.programs,\n shaders: this.gltf.shaders,\n techniques: s };\n\n for (var _t20 = 0; _t20 < e.length; _t20++) {\n var _n12 = (r = e[_t20]) && r.extensions && r.extensions.KHR_techniques_webgl;\n if (_n12) {\n var _e14 = _n12.values,\n _t21 = _n12.technique,\n _r13 = s[_t21];\n if (!_r13 || !_e14) continue;\n var _i4 = _r13.uniforms,\n _a4 = _r13.parameters,\n _o3 = {};\n for (var _t22 in _e14) {\n var _s21 = ce(_i4, _t22);\n _o3[_s21] = _e14[_t22], _a4[_t22] && 35678 === _a4[_t22].type && (_o3[_s21] = {\n index: _e14[_t22] });\n\n }\n _n12.values = _o3;\n }\n }\n var r;\n for (var _e15 = 0; _e15 < s.length; _e15++) {\n var _t23 = s[_e15];\n if (!_t23) continue;\n var _r14 = _t23.attributes,\n _n13 = _t23.uniforms,\n _i5 = _t23.parameters;\n if (_r14) for (var _e16 in _r14) {\n var _t24 = _r14[_e16];\n _r14[_e16] = _i5[_t24];\n }\n if (_n13) for (var _e17 in _n13) {\n var _t25 = _n13[_e17];\n _n13[_e17] = _i5[_t25];\n }\n delete _t23.parameters;\n }\n return delete this.gltf.programs, delete this.gltf.shaders, delete this.gltf.techniques, this.gltf.extensions = t, t;\n } },\n {\n key: \"load\",\n value: function load(e) {\n var _this13 = this;\n e = e || {}, this._convertKhrTechiqueToTechiques();\n var t = this._loadScene(e),\n s = this._loadAnimations(),\n r = this._loadTextures(),\n n = this._loadExtensions();\n return Promise.all([t, s, r, n]).then(function (e) {\n return e[0].animations = e[1], e[0].textures = e[2], e[0].extensions = e[3], e[0].transferables = _this13.transferables || [], _this13.createChannelsMap(e[0]), e[0];\n });\n } },\n {\n key: \"createChannelsMap\",\n value: function createChannelsMap(e) {\n var t = e.animations;\n if (t) for (var _e18 = 0; _e18 < t.length; _e18++) {\n var _s22 = t[_e18];\n _s22.channelsMap = {};\n for (var _e19 = 0; _e19 < _s22.channels.length; _e19++) {\n var _t26 = _s22.channels[_e19];\n _s22.channelsMap[_t26.target.node] || (_s22.channelsMap[_t26.target.node] = []), _s22.channelsMap[_t26.target.node].push(_t26);\n }\n }\n } },\n {\n key: \"getExternalResources\",\n value: function getExternalResources() {\n var e = [];\n if (this.gltf) {\n var _this$gltf = this.gltf,\n _t27 = _this$gltf.buffers,\n _s23 = _this$gltf.images;\n for (var _s24 = 0; _s24 < _t27.length; _s24++) _t27[_s24].uri && _t27[_s24].uri.indexOf(\"data:application/octet-stream;base64\") < 0 && e.push({\n type: \"buffer\",\n uri: _t27[_s24].uri });\n\n for (var _t28 = 0; _t28 < _s23.length; _t28++) _s23[_t28].uri && _s23[_t28].uri.indexOf(\"data:image/\") < 0 && e.push({\n type: \"image\",\n uri: _s23[_t28].uri });\n\n }\n return e;\n } },\n {\n key: \"_init\",\n value: function _init(e, t, s) {\n this.gltf = t, this.glbBuffer = s, this.version = t.asset ? +t.asset.version : 1, this.rootPath = e, this.buffers = {}, this.requests = {}, this.options.requestImage = J ? ae.bind(this) : this.options.requestImage || ee, this.options.transferable && (this.transferables = []), 2 === this.version ? (this.adapter = new U(e, t, s, this.options.requestImage, this.options.decoders || {}, this.options.supportedFormats || {}, this._fetchOptions, this.options.urlModifier), this.adapter.iterate(function (e, t, s) {\n t.id = \"buffer_\" + s;\n }, \"buffers\"), this.adapter.iterate(function (e, t, s) {\n t.id = \"image_\" + s;\n }, \"images\"), this.adapter.iterate(function (e, t, s) {\n t.id = \"accessor_\" + s;\n }, \"accessors\")) : (this.adapter = new D(e, t, s, this.options.requestImage, this.options.decoders || {}, this.options.supportedFormats || {}, this._fetchOptions, this.options.urlModifier), this.adapter.iterate(function (e, t, s) {\n t.id = \"accessor_\" + s;\n }, \"accessors\"), this.adapter.iterate(function (e, t, s) {\n t.id = \"image_\" + s;\n }, \"images\"));\n } },\n {\n key: \"_parseNodes\",\n value: function _parseNodes(e, t) {\n var _this14 = this;\n if (e.children && e.children.length > 0) {\n if (!(s = e.children[0], \"number\" == typeof s && isFinite(s) || b(e.children[0]))) return e;\n var _r15 = e.children.map(function (e) {\n var s = t[e];\n return s.nodeIndex = e, _this14._parseNodes(s, t);\n });\n e.children = _r15;\n }\n var s;\n return e;\n } },\n {\n key: \"_loadScene\",\n value: function _loadScene(e) {\n var _this15 = this;\n return this._loadNodes(e).then(function (e) {\n var t = _this15.scenes = [];\n var s;\n for (var _t29 in e) e[_t29] = _this15._parseNodes(e[_t29], e), e[_t29].nodeIndex = Number(_t29) ? Number(_t29) : _t29;\n _this15.adapter.iterate(function (r, n, i) {\n var a = {};\n n.name && (a.name = n.name), n.nodes && (a.nodes = n.nodes.map(function (t) {\n return e[t];\n })), _this15.gltf.scene === r && (s = i), t.push(a);\n }, \"scenes\");\n var r = {\n textures: _this15.gltf.textures,\n asset: _this15.gltf.asset,\n scene: s,\n scenes: t,\n nodes: e,\n meshes: _this15.meshes,\n materials: _this15.gltf.materials,\n skins: _this15.skins,\n extensionsRequired: _this15.gltf.extensionsRequired,\n extensionsUsed: _this15.gltf.extensionsUsed };\n\n if (_this15.gltf.extensions && (r.extensions = _this15.gltf.extensions), 1 === _this15.version) {\n var _e20 = _this15.adapter._loadMaterials(_this15.gltf.materials);\n r.materials = _e20;\n }\n return delete _this15.gltf.buffers, r.json = _this15.gltf, r;\n });\n } },\n {\n key: \"_loadNodes\",\n value: function _loadNodes(e) {\n var _this16 = this;\n return this._loadMeshes(e).then(function () {\n var e = _this16.nodes = {};\n return _this16.adapter.iterate(function (t, s) {\n var r = _this16.adapter.createNode(s, _this16.meshes, _this16.skins);\n e[t] = r;\n }, \"nodes\"), e;\n });\n } },\n {\n key: \"_loadSkins\",\n value: function _loadSkins() {\n var _this17 = this;\n this.skins = [];\n var e = [];\n return this.adapter.iterate(function (t, s, r) {\n e.push(_this17._loadSkin(s).then(function (e) {\n e.index = r, _this17.skins.push(e);\n }));\n }, \"skins\"), e;\n } },\n {\n key: \"_loadSkin\",\n value: function _loadSkin(e) {\n var _this18 = this;\n var t = e.inverseBindMatrices;\n return this.adapter.accessor._requestData(\"inverseBindMatrices\", t).then(function (t) {\n return e.inverseBindMatrices = t, t && t.buffer && _this18.transferables && _this18.transferables.indexOf(t.buffer) < 0 && _this18.transferables.push(t.buffer), e;\n });\n } },\n {\n key: \"_loadAnimations\",\n value: function _loadAnimations() {\n var e = this.gltf.animations;\n return p(e) ? this.adapter.getAnimations(e) : null;\n } },\n {\n key: \"_loadMeshes\",\n value: function _loadMeshes(e) {\n var _this19 = this;\n this.meshes = {};\n var t = [];\n return this.adapter.iterate(function (s, r, n) {\n t.push(_this19._loadMesh(r, e).then(function (e) {\n e.index = n, _this19.meshes[s] = e;\n }));\n }, \"meshes\"), t = t.concat(this._loadSkins()), Promise.all(t);\n } },\n {\n key: \"_loadMesh\",\n value: function _loadMesh(e, t) {\n var _this20 = this;\n var s = e.primitives.map(function (e) {\n return _this20._loadPrimitive(e, t);\n }).filter(function (e) {\n return !!e;\n });\n return Promise.all(s).then(function (t) {\n var s = {};\n return _(s, e), s.primitives = t, s;\n });\n } },\n {\n key: \"_loadTextures\",\n value: function _loadTextures() {\n var _this21 = this;\n var e = this.gltf.textures;\n if (!e) return null;\n var t = [];\n for (var _s25 in e) t.push(this.adapter._getTexture(_s25));\n return Promise.all(t).then(function (t) {\n if (_this21.transferables) for (var _e21 = 0; _e21 < t.length; _e21++) {\n var _s26 = t[_e21] && t[_e21].image.array;\n if (_s26) {\n var _e22 = void 0;\n _e22 = _s26 instanceof ImageBitmap ? _s26 : _s26.buffer, _e22 && _this21.transferables.indexOf(_e22) < 0 && _this21.transferables.push(_e22);\n }\n }\n if (!Array.isArray(e)) {\n var _s27 = {},\n _r16 = Object.keys(e);\n for (var _e23 = 0; _e23 < t.length; _e23++) t[_e23] && (_s27[_r16[_e23]] = t[_e23]);\n return _s27;\n }\n return t;\n });\n } },\n {\n key: \"_loadPrimitive\",\n value: function _loadPrimitive(e, t) {\n var _this22 = this;\n var s;\n var r = [],\n n = e.extensions;\n if (p(e.targets)) for (var _t30 = 0; _t30 < e.targets.length; _t30++) {\n var _s28 = e.targets[_t30];\n for (var _e24 in _s28) {\n var _n14 = this.adapter.accessor._requestData(\"morphTargets_\".concat(_e24, \"_\").concat(_t30), _s28[_e24]);\n _n14 && r.push(_n14);\n }\n }\n if (n && n.KHR_draco_mesh_compression) {\n if (!this.options.decoders.draco && (!this.gltf.extensionsRequired || !this.gltf.extensionsRequired.indexOf(\"KHR_draco_mesh_compression\") < 0)) return null;\n var _e25 = this.options.decoders.draco,\n _n$KHR_draco_mesh_com = n.KHR_draco_mesh_compression,\n _i6 = _n$KHR_draco_mesh_com.bufferView,\n _a5 = _n$KHR_draco_mesh_com.attributes,\n _o4 = this.gltf.bufferViews[_i6],\n _f3 = this._accessor._requestBufferOfBufferView(_o4).then(function (s) {\n var r = s.buffer,\n n = s.byteOffset;\n var i = _o4.byteOffset;\n var f = _o4.byteLength;\n i || (i = 0);\n var u = new DataView(r, n + i, f),\n h = {\n attributes: _a5,\n useUniqueIDs: !1,\n skipAttributeTransform: t.skipAttributeTransform };\n\n return _e25(u, h).then(function (e) {\n var t = Object.values(e.attributes);\n return e.indices && t.push(e.indices), t;\n });\n });\n r.push(_f3), s = Promise.all(r);\n } else {\n var _t31 = e.attributes;\n for (var _e26 in _t31) {\n var _s29 = this.adapter.accessor._requestData(_e26, _t31[_e26]);\n _s29 && r.push(_s29);\n }\n if (p(e.indices)) {\n var _t32 = this.adapter.accessor._requestData(\"indices\", e.indices);\n _t32 && r.push(_t32);\n }\n s = Promise.all(r);\n }\n return s.then(function (t) {\n if (n && n.KHR_draco_mesh_compression) {\n var _s30 = e.targets ? e.targets.length : 0;\n t[_s30] = t[_s30].concat(t.slice(0, _s30)), t = t[_s30];\n }\n var s, r;\n var i = {\n attributes: t.reduce(function (e, t) {\n if (\"indices\" === t.name) s = t;else if (t.name.indexOf(\"morphTargets_\") > -1) r = r || {}, r[t.name.slice(13)] = t;else {\n if (!(\"POSITION\" !== t.name || t.min && t.max)) {\n var _e27 = [1 / 0, 1 / 0, 1 / 0],\n _s31 = [-1 / 0, -1 / 0, -1 / 0],\n _r17 = t.itemSize,\n _n15 = t.array,\n _i7 = _n15.length / _r17;\n for (var _t33 = 0; _t33 < _i7; _t33++) for (var _i8 = 0; _i8 < _r17; _i8++) {\n var _a6 = _t33 * _r17 + _i8;\n _n15[_a6] < _e27[_i8] && (_e27[_i8] = _n15[_a6]), _n15[_a6] > _s31[_i8] && (_s31[_i8] = _n15[_a6]);\n }\n if (t.quantization) {\n var _r18 = t.quantization,\n _n16 = _r18.range / (1 << _r18.quantizationBits),\n _i9 = _r18.minValues;\n o(_e27, _e27, _n16), a(_e27, _e27, _i9), o(_s31, _s31, _n16), a(_s31, _s31, _i9);\n }\n t.min = _e27, t.max = _s31;\n }\n e[t.name] = t;\n }\n return _this22.transferables && t.array.buffer && _this22.transferables.indexOf(t.array.buffer) < 0 && _this22.transferables.push(t.array.buffer), e;\n }, {}),\n material: e.material };\n\n return s && (i.indices = s), r && (i.morphTargets = r), i.mode = p(e.mode) ? e.mode : 4, p(e.extras) && (i.extras = e.extras), i;\n });\n } }],\n [{\n key: \"getAnimationClip\",\n value: function getAnimationClip(e, t, s, r) {\n return $.getAnimationClip(e, t, s, r);\n } },\n {\n key: \"getAnimationTimeSpan\",\n value: function getAnimationTimeSpan(e, t) {\n return $.getTimeSpanByName(e, t);\n } },\n {\n key: \"getTypedArrayCtor\",\n value: function getTypedArrayCtor(e) {\n return y(e);\n } },\n {\n key: \"readInterleavedArray\",\n value: function readInterleavedArray(e, t, s, r, n, i, a) {\n return q(e, t, s, r, n, i, a);\n } }]);\n\n }();\n function ee(e, t, s) {\n var r = new Image();\n r.crossOrigin = \"\", r.onload = function () {\n if (!Q) return void s(new Error(\"There is no canvas to draw image!\"));\n Q.width = r.width, Q.height = r.height;\n var e = Q.getContext(\"2d\", {\n willReadFrequently: !0 });\n\n e.drawImage(r, 0, 0, r.width, r.height);\n var t = e.getImageData(0, 0, r.width, r.height),\n n = {\n width: r.width,\n height: r.height,\n data: new Uint8Array(t.data) };\n\n s(null, n);\n }, r.onerror = function (e) {\n s(e);\n }, r.src = e;\n }\n var te = [],\n se = [],\n re = 30;\n var ne, ie;\n function ae(e, t, s) {\n ne || (ne = new OffscreenCanvas(2, 2), ie = ne.getContext(\"2d\", {\n willReadFrequently: !0 }));\n\n var r = null;\n if (b(e)) this.options.urlModifier && (e = this.options.urlModifier(e)), te.push([e, t, s, this]), oe();else {\n var _t34 = new Blob([e]);\n r = createImageBitmap(_t34), r.then(fe.bind(this)).then(function (e) {\n s(null, e);\n }).catch(function (e) {\n console.warn(e), s(e);\n });\n }\n }\n function oe() {\n if (!te.length || se.length > re) return;\n var e = te.shift(),\n _e28 = _slicedToArray(e, 4),\n t = _e28[0],\n s = _e28[1],\n r = _e28[2],\n n = _e28[3];\n se.push(e), fetch(t, s).then(function (e) {\n return e.arrayBuffer();\n }).then(function (e) {\n var t = new Blob([new Uint8Array(e)]);\n return createImageBitmap(t);\n }).then(fe.bind(n)).then(function (t) {\n r.call(n, null, t);\n var s = se.indexOf(e);\n se.splice(s, 1), oe();\n }).catch(function (t) {\n console.warn(t), r.call(n, t);\n var s = se.indexOf(e);\n se.splice(s, 1), oe();\n });\n }\n function fe(e) {\n var t = e.width,\n s = e.height;\n ue(t) || (t = he(t)), ue(s) || (s = he(s));\n var r = this.options.maxTextureSize;\n r && (t = Math.min(r, t), s = Math.min(r, s)), ne.width = t, ne.height = s, ie.drawImage(e, 0, 0, t, s), e.close();\n var n = ie.getImageData(0, 0, t, s);\n return {\n width: t,\n height: s,\n data: new Uint8Array(n.data) };\n\n }\n function ue(e) {\n return !(e & e - 1) && 0 !== e;\n }\n function he(e) {\n return Math.pow(2, Math.floor(Math.log(e) / Math.LN2));\n }\n function ce(e, t) {\n for (var _s32 in e) if (e[_s32] === t) return _s32;\n return t;\n }return module.exports;});", "requires": [], "buildLevel": 0, "fileName": "/dist/gltf-loader.es.js" } }