UNPKG

@animech-public/playcanvas

Version:
1,585 lines (1,553 loc) 3.15 MB
/** * @license * PlayCanvas Engine v1.78.0-animech revision e1c6c734d (PROFILE) * Copyright 2011-2025 PlayCanvas Ltd. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pc = {})); })(this, (function (exports) { 'use strict'; var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function defineProtoFunc(cls, name, func) { if (!cls.prototype[name]) { Object.defineProperty(cls.prototype, name, { value: func, configurable: true, enumerable: false, writable: true }); } } defineProtoFunc(Array, 'fill', function (value) { if (this == null) { throw new TypeError('this is null or not defined'); } var O = Object(this); var len = O.length >>> 0; var start = arguments[1]; var relativeStart = start >> 0; var k = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len); var end = arguments[2]; var relativeEnd = end === undefined ? len : end >> 0; var finalValue = relativeEnd < 0 ? Math.max(len + relativeEnd, 0) : Math.min(relativeEnd, len); while (k < finalValue) { O[k] = value; k++; } return O; }); defineProtoFunc(Array, 'find', function (predicate) { if (this == null) { throw TypeError('"this" is null or not defined'); } var o = Object(this); var len = o.length >>> 0; if (typeof predicate !== 'function') { throw TypeError('predicate must be a function'); } var thisArg = arguments[1]; var k = 0; while (k < len) { var kValue = o[k]; if (predicate.call(thisArg, kValue, k, o)) { return kValue; } k++; } return undefined; }); defineProtoFunc(Array, 'findIndex', function (predicate) { if (this == null) { throw new TypeError('"this" is null or not defined'); } var o = Object(this); var len = o.length >>> 0; if (typeof predicate !== 'function') { throw new TypeError('predicate must be a function'); } var thisArg = arguments[1]; var k = 0; while (k < len) { var kValue = o[k]; if (predicate.call(thisArg, kValue, k, o)) { return k; } k++; } return -1; }); Math.log2 = Math.log2 || function (x) { return Math.log(x) * Math.LOG2E; }; if (!Math.sign) { Math.sign = function (x) { return (x > 0) - (x < 0) || +x; }; } if (Number.isFinite === undefined) Number.isFinite = function (value) { return typeof value === 'number' && isFinite(value); }; if (typeof Object.assign != 'function') { Object.defineProperty(Object, "assign", { value: function assign(target, varArgs) { 'use strict'; if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } var to = Object(target); for (var index = 1; index < arguments.length; index++) { var nextSource = arguments[index]; if (nextSource != null) { for (var nextKey in nextSource) { if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { to[nextKey] = nextSource[nextKey]; } } } } return to; }, writable: true, configurable: true }); } Object.fromEntries = Object.fromEntries || function fromEntries(entries) { if (!entries || !entries[Symbol.iterator]) { throw new Error('Object.fromEntries() requires a single iterable argument'); } var res = {}; for (var i = 0; i < entries.length; i++) { res[entries[i][0]] = entries[i][1]; } return res; }; Object.entries = Object.entries || function (obj) { var ownProps = Object.keys(obj), i = ownProps.length, resArray = new Array(i); while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]]; return resArray; }; Object.values = Object.values || function (object) { return Object.keys(object).map(function (key) { return object[key]; }); }; (function () { if (typeof navigator === 'undefined' || typeof document === 'undefined') { return; } navigator.pointer = navigator.pointer || navigator.webkitPointer || navigator.mozPointer; var pointerlockchange = function pointerlockchange() { var e = document.createEvent('CustomEvent'); e.initCustomEvent('pointerlockchange', true, false, null); document.dispatchEvent(e); }; var pointerlockerror = function pointerlockerror() { var e = document.createEvent('CustomEvent'); e.initCustomEvent('pointerlockerror', true, false, null); document.dispatchEvent(e); }; document.addEventListener('webkitpointerlockchange', pointerlockchange, false); document.addEventListener('webkitpointerlocklost', pointerlockchange, false); document.addEventListener('mozpointerlockchange', pointerlockchange, false); document.addEventListener('mozpointerlocklost', pointerlockchange, false); document.addEventListener('webkitpointerlockerror', pointerlockerror, false); document.addEventListener('mozpointerlockerror', pointerlockerror, false); if (Element.prototype.mozRequestPointerLock) { Element.prototype.requestPointerLock = function () { this.mozRequestPointerLock(); }; } else { Element.prototype.requestPointerLock = Element.prototype.requestPointerLock || Element.prototype.webkitRequestPointerLock || Element.prototype.mozRequestPointerLock; } if (!Element.prototype.requestPointerLock && navigator.pointer) { Element.prototype.requestPointerLock = function () { var el = this; document.pointerLockElement = el; navigator.pointer.lock(el, pointerlockchange, pointerlockerror); }; } document.exitPointerLock = document.exitPointerLock || document.webkitExitPointerLock || document.mozExitPointerLock; if (!document.exitPointerLock) { document.exitPointerLock = function () { if (navigator.pointer) { document.pointerLockElement = null; navigator.pointer.unlock(); } }; } })(); defineProtoFunc(String, 'endsWith', function (search, this_len) { if (this_len === undefined || this_len > this.length) { this_len = this.length; } return this.substring(this_len - search.length, this_len) === search; }); defineProtoFunc(String, 'includes', function (search, start) { 'use strict'; if (typeof start !== 'number') { start = 0; } if (start + search.length > this.length) { return false; } else { return this.indexOf(search, start) !== -1; } }); defineProtoFunc(String, 'startsWith', function (search, rawPos) { var pos = rawPos > 0 ? rawPos | 0 : 0; return this.substring(pos, pos + search.length) === search; }); defineProtoFunc(String, 'trimEnd', function () { return this.replace(new RegExp(/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/.source + '$', 'g'), ''); }); var typedArrays = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array]; for (var _i = 0, _typedArrays = typedArrays; _i < _typedArrays.length; _i++) { var typedArray = _typedArrays[_i]; defineProtoFunc(typedArray, "fill", Array.prototype.fill); defineProtoFunc(typedArray, "join", Array.prototype.join); } var TRACEID_RENDER_FRAME = 'RenderFrame'; var TRACEID_RENDER_FRAME_TIME = 'RenderFrameTime'; var TRACEID_RENDER_PASS = 'RenderPass'; var TRACEID_RENDER_PASS_DETAIL = 'RenderPassDetail'; var TRACEID_RENDER_ACTION = 'RenderAction'; var TRACEID_RENDER_TARGET_ALLOC = 'RenderTargetAlloc'; var TRACEID_TEXTURE_ALLOC = 'TextureAlloc'; var TRACEID_SHADER_ALLOC = 'ShaderAlloc'; var TRACEID_SHADER_COMPILE = 'ShaderCompile'; var TRACEID_VRAM_TEXTURE = 'VRAM.Texture'; var TRACEID_VRAM_VB = 'VRAM.Vb'; var TRACEID_VRAM_IB = 'VRAM.Ib'; var TRACEID_VRAM_SB = 'VRAM.Sb'; var TRACEID_BINDGROUP_ALLOC = 'BindGroupAlloc'; var TRACEID_BINDGROUPFORMAT_ALLOC = 'BindGroupFormatAlloc'; var TRACEID_RENDERPIPELINE_ALLOC = 'RenderPipelineAlloc'; var TRACEID_COMPUTEPIPELINE_ALLOC = 'ComputePipelineAlloc'; var TRACEID_PIPELINELAYOUT_ALLOC = 'PipelineLayoutAlloc'; var TRACE_ID_ELEMENT = 'Element'; var TRACEID_TEXTURES = 'Textures'; var TRACEID_RENDER_QUEUE = 'RenderQueue'; var TRACEID_GPU_TIMINGS = 'GpuTimings'; var version = '1.78.0-animech'; var revision = 'e1c6c734d'; var config = {}; var common = {}; var apps = {}; var data$1 = {}; var typeofs = ['undefined', 'number', 'string', 'boolean']; var objectTypes = { '[object Array]': 'array', '[object Object]': 'object', '[object Function]': 'function', '[object Date]': 'date', '[object RegExp]': 'regexp', '[object Float32Array]': 'float32array' }; function type$1(obj) { if (obj === null) { return 'null'; } var typeString = typeof obj; if (typeofs.includes(typeString)) { return typeString; } return objectTypes[Object.prototype.toString.call(obj)]; } function extend(target, ex) { for (var prop in ex) { var copy = ex[prop]; if (type$1(copy) === 'object') { target[prop] = extend({}, copy); } else if (type$1(copy) === 'array') { target[prop] = extend([], copy); } else { target[prop] = copy; } } return target; } 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; } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } 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); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); } function _regeneratorRuntime() { _regeneratorRuntime = function () { 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 (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 (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 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 (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 () { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function (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 Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function (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 (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 (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 (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 Error("illegal catch attempt"); }, delegateYield: function (e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } 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); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return (String )(t); } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } 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; } } var Tracing = function () { function Tracing() {} Tracing.set = function set(channel, enabled) { }; Tracing.get = function get(channel) { return Tracing._traceChannels.has(channel); }; return Tracing; }(); Tracing._traceChannels = new Set(); Tracing.stack = false; var EventHandle = function () { function EventHandle(handler, name, callback, scope, once) { if (once === void 0) { once = false; } this.handler = void 0; this.name = void 0; this.callback = void 0; this.scope = void 0; this._once = void 0; this._removed = false; this.handler = handler; this.name = name; this.callback = callback; this.scope = scope; this._once = once; } var _proto = EventHandle.prototype; _proto.off = function off() { if (this._removed) return; this.handler.offByHandle(this); }; _proto.on = function on(name, callback, scope) { if (scope === void 0) { scope = this; } return this.handler._addCallback(name, callback, scope, false); }; _proto.once = function once(name, callback, scope) { if (scope === void 0) { scope = this; } return this.handler._addCallback(name, callback, scope, true); }; return _createClass(EventHandle, [{ key: "removed", get: function get() { return this._removed; }, set: function set(value) { if (!value) return; this._removed = true; } }]); }(); var EventHandler = function () { function EventHandler() { this._callbacks = new Map(); this._callbackActive = new Map(); } var _proto = EventHandler.prototype; _proto.initEventHandler = function initEventHandler() { this._callbacks = new Map(); this._callbackActive = new Map(); }; _proto._addCallback = function _addCallback(name, callback, scope, once) { if (!this._callbacks.has(name)) { this._callbacks.set(name, []); } if (this._callbackActive.has(name)) { var callbackActive = this._callbackActive.get(name); if (callbackActive && callbackActive === this._callbacks.get(name)) { this._callbackActive.set(name, callbackActive.slice()); } } var evt = new EventHandle(this, name, callback, scope, once); this._callbacks.get(name).push(evt); return evt; }; _proto.on = function on(name, callback, scope) { if (scope === void 0) { scope = this; } return this._addCallback(name, callback, scope, false); }; _proto.once = function once(name, callback, scope) { if (scope === void 0) { scope = this; } return this._addCallback(name, callback, scope, true); }; _proto.off = function off(name, callback, scope) { if (name) { if (this._callbackActive.has(name) && this._callbackActive.get(name) === this._callbacks.get(name)) { this._callbackActive.set(name, this._callbackActive.get(name).slice()); } } else { for (var _iterator = _createForOfIteratorHelperLoose(this._callbackActive), _step; !(_step = _iterator()).done;) { var _step$value = _step.value, key = _step$value[0], callbacks = _step$value[1]; if (!this._callbacks.has(key)) { continue; } if (this._callbacks.get(key) !== callbacks) { continue; } this._callbackActive.set(key, callbacks.slice()); } } if (!name) { for (var _iterator2 = _createForOfIteratorHelperLoose(this._callbacks.values()), _step2; !(_step2 = _iterator2()).done;) { var _callbacks = _step2.value; for (var i = 0; i < _callbacks.length; i++) { _callbacks[i].removed = true; } } this._callbacks.clear(); } else if (!callback) { var _callbacks2 = this._callbacks.get(name); if (_callbacks2) { for (var _i = 0; _i < _callbacks2.length; _i++) { _callbacks2[_i].removed = true; } this._callbacks.delete(name); } } else { var _callbacks3 = this._callbacks.get(name); if (!_callbacks3) { return this; } for (var _i2 = 0; _i2 < _callbacks3.length; _i2++) { if (_callbacks3[_i2].callback !== callback) { continue; } if (scope && _callbacks3[_i2].scope !== scope) { continue; } _callbacks3[_i2].removed = true; _callbacks3.splice(_i2, 1); _i2--; } if (_callbacks3.length === 0) { this._callbacks.delete(name); } } return this; }; _proto.offByHandle = function offByHandle(handle) { var name = handle.name; handle.removed = true; if (this._callbackActive.has(name) && this._callbackActive.get(name) === this._callbacks.get(name)) { this._callbackActive.set(name, this._callbackActive.get(name).slice()); } var callbacks = this._callbacks.get(name); if (!callbacks) { return this; } var ind = callbacks.indexOf(handle); if (ind !== -1) { callbacks.splice(ind, 1); if (callbacks.length === 0) { this._callbacks.delete(name); } } return this; }; _proto.fire = function fire(name, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) { if (!name) { return this; } var callbacksInitial = this._callbacks.get(name); if (!callbacksInitial) { return this; } var callbacks; if (!this._callbackActive.has(name)) { this._callbackActive.set(name, callbacksInitial); } else if (this._callbackActive.get(name) !== callbacksInitial) { callbacks = callbacksInitial.slice(); } for (var i = 0; (callbacks || this._callbackActive.get(name)) && i < (callbacks || this._callbackActive.get(name)).length; i++) { var evt = (callbacks || this._callbackActive.get(name))[i]; if (!evt.callback) continue; evt.callback.call(evt.scope, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); if (evt._once) { var existingCallback = this._callbacks.get(name); var ind = existingCallback ? existingCallback.indexOf(evt) : -1; if (ind !== -1) { if (this._callbackActive.get(name) === existingCallback) { this._callbackActive.set(name, this._callbackActive.get(name).slice()); } var _callbacks4 = this._callbacks.get(name); if (!_callbacks4) continue; _callbacks4[ind].removed = true; _callbacks4.splice(ind, 1); if (_callbacks4.length === 0) { this._callbacks.delete(name); } } } } if (!callbacks) { this._callbackActive.delete(name); } return this; }; _proto.hasEvent = function hasEvent(name) { var _this$_callbacks$get; return !!((_this$_callbacks$get = this._callbacks.get(name)) != null && _this$_callbacks$get.length); }; return EventHandler; }(); var events = { attach: function attach(target) { var ev = events; target._addCallback = ev._addCallback; target.on = ev.on; target.off = ev.off; target.fire = ev.fire; target.once = ev.once; target.hasEvent = ev.hasEvent; EventHandler.prototype.initEventHandler.call(target); return target; }, _addCallback: EventHandler.prototype._addCallback, on: EventHandler.prototype.on, off: EventHandler.prototype.off, fire: EventHandler.prototype.fire, once: EventHandler.prototype.once, hasEvent: EventHandler.prototype.hasEvent }; var guid = { create: function create() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0; var v = c === 'x' ? r : r & 0x3 | 0x8; return v.toString(16); }); } }; var path = { delimiter: '/', join: function join() { var result = arguments.length <= 0 ? undefined : arguments[0]; for (var i = 0; i < arguments.length - 1; i++) { var one = i < 0 || arguments.length <= i ? undefined : arguments[i]; var two = i + 1 < 0 || arguments.length <= i + 1 ? undefined : arguments[i + 1]; if (two[0] === path.delimiter) { result = two; continue; } if (one && two && one[one.length - 1] !== path.delimiter && two[0] !== path.delimiter) { result += path.delimiter + two; } else { result += two; } } return result; }, normalize: function normalize(pathname) { var lead = pathname.startsWith(path.delimiter); var trail = pathname.endsWith(path.delimiter); var parts = pathname.split('/'); var result = ''; var cleaned = []; for (var i = 0; i < parts.length; i++) { if (parts[i] === '') continue; if (parts[i] === '.') continue; if (parts[i] === '..' && cleaned.length > 0) { cleaned = cleaned.slice(0, cleaned.length - 2); continue; } if (i > 0) cleaned.push(path.delimiter); cleaned.push(parts[i]); } result = cleaned.join(''); if (!lead && result[0] === path.delimiter) { result = result.slice(1); } if (trail && result[result.length - 1] !== path.delimiter) { result += path.delimiter; } return result; }, split: function split(pathname) { var lastDelimiterIndex = pathname.lastIndexOf(path.delimiter); if (lastDelimiterIndex !== -1) { return [pathname.substring(0, lastDelimiterIndex), pathname.substring(lastDelimiterIndex + 1)]; } return ['', pathname]; }, getBasename: function getBasename(pathname) { return path.split(pathname)[1]; }, getDirectory: function getDirectory(pathname) { return path.split(pathname)[0]; }, getExtension: function getExtension(pathname) { var ext = pathname.split('?')[0].split('.').pop(); if (ext !== pathname) { return "." + ext; } return ''; }, isRelativePath: function isRelativePath(pathname) { return pathname.charAt(0) !== '/' && pathname.match(/:\/\//) === null; }, extractPath: function extractPath(pathname) { var result = ''; var parts = pathname.split('/'); var i = 0; if (parts.length > 1) { if (path.isRelativePath(pathname)) { if (parts[0] === '.') { for (i = 0; i < parts.length - 1; ++i) { result += i === 0 ? parts[i] : "/" + parts[i]; } } else if (parts[0] === '..') { for (i = 0; i < parts.length - 1; ++i) { result += i === 0 ? parts[i] : "/" + parts[i]; } } else { result = '.'; for (i = 0; i < parts.length - 1; ++i) { result += "/" + parts[i]; } } } else { for (i = 0; i < parts.length - 1; ++i) { result += i === 0 ? parts[i] : "/" + parts[i]; } } } return result; } }; var _ref, _ref2, _ref3; var detectPassiveEvents = function detectPassiveEvents() { var result = false; try { var opts = Object.defineProperty({}, 'passive', { get: function get() { result = true; return false; } }); window.addEventListener('testpassive', null, opts); window.removeEventListener('testpassive', null, opts); } catch (e) {} return result; }; var ua = typeof navigator !== 'undefined' ? navigator.userAgent : ''; var environment = typeof window !== 'undefined' ? 'browser' : typeof global !== 'undefined' ? 'node' : 'worker'; var platformName = /android/i.test(ua) ? 'android' : /ip(?:[ao]d|hone)/i.test(ua) ? 'ios' : /windows/i.test(ua) ? 'windows' : /mac os/i.test(ua) ? 'osx' : /linux/i.test(ua) ? 'linux' : /cros/i.test(ua) ? 'cros' : null; var browserName = environment !== 'browser' ? null : /Chrome\/|Chromium\/|Edg.*\//.test(ua) ? 'chrome' : /Safari\//.test(ua) ? 'safari' : /Firefox\//.test(ua) ? 'firefox' : 'other'; var xbox = /xbox/i.test(ua); var touch = environment === 'browser' && ('ontouchstart' in window || 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0); var gamepads = environment === 'browser' && (!!navigator.getGamepads || !!navigator.webkitGetGamepads); var workers = typeof Worker !== 'undefined'; var passiveEvents = detectPassiveEvents(); var platform = { name: platformName, environment: environment, global: (_ref = (_ref2 = (_ref3 = typeof globalThis !== 'undefined' && globalThis) != null ? _ref3 : environment === 'browser' && window) != null ? _ref2 : environment === 'node' && global) != null ? _ref : environment === 'worker' && self, browser: environment === 'browser', worker: environment === 'worker', desktop: ['windows', 'osx', 'linux', 'cros'].includes(platformName), mobile: ['android', 'ios'].includes(platformName), ios: platformName === 'ios', android: platformName === 'android', xbox: xbox, gamepads: gamepads, touch: touch, workers: workers, passiveEvents: passiveEvents, browserName: browserName }; var ASCII_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'; var ASCII_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var ASCII_LETTERS = ASCII_LOWERCASE + ASCII_UPPERCASE; var HIGH_SURROGATE_BEGIN = 0xD800; var HIGH_SURROGATE_END = 0xDBFF; var LOW_SURROGATE_BEGIN = 0xDC00; var LOW_SURROGATE_END = 0xDFFF; var ZERO_WIDTH_JOINER = 0x200D; var REGIONAL_INDICATOR_BEGIN = 0x1F1E6; var REGIONAL_INDICATOR_END = 0x1F1FF; var FITZPATRICK_MODIFIER_BEGIN = 0x1F3FB; var FITZPATRICK_MODIFIER_END = 0x1F3FF; var DIACRITICAL_MARKS_BEGIN = 0x20D0; var DIACRITICAL_MARKS_END = 0x20FF; var VARIATION_MODIFIER_BEGIN = 0xFE00; var VARIATION_MODIFIER_END = 0xFE0F; function getCodePointData(string, i) { if (i === void 0) { i = 0; } var size = string.length; if (i < 0 || i >= size) { return null; } var first = string.charCodeAt(i); if (size > 1 && first >= HIGH_SURROGATE_BEGIN && first <= HIGH_SURROGATE_END) { var second = string.charCodeAt(i + 1); if (second >= LOW_SURROGATE_BEGIN && second <= LOW_SURROGATE_END) { return { code: (first - HIGH_SURROGATE_BEGIN) * 0x400 + second - LOW_SURROGATE_BEGIN + 0x10000, long: true }; } } return { code: first, long: false }; } function isCodeBetween(string, begin, end) { if (!string) { return false; } var codeData = getCodePointData(string); if (codeData) { var code = codeData.code; return code >= begin && code <= end; } return false; } function numCharsToTakeForNextSymbol(string, index) { if (index === string.length - 1) { return 1; } if (isCodeBetween(string[index], HIGH_SURROGATE_BEGIN, HIGH_SURROGATE_END)) { var first = string.substring(index, index + 2); var second = string.substring(index + 2, index + 4); if (isCodeBetween(second, FITZPATRICK_MODIFIER_BEGIN, FITZPATRICK_MODIFIER_END) || isCodeBetween(first, REGIONAL_INDICATOR_BEGIN, REGIONAL_INDICATOR_END) && isCodeBetween(second, REGIONAL_INDICATOR_BEGIN, REGIONAL_INDICATOR_END)) { return 4; } if (isCodeBetween(second, VARIATION_MODIFIER_BEGIN, VARIATION_MODIFIER_END)) { return 3; } return 2; } if (isCodeBetween(string[index + 1], VARIATION_MODIFIER_BEGIN, VARIATION_MODIFIER_END)) { return 2; } return 1; } var string = { ASCII_LOWERCASE: ASCII_LOWERCASE, ASCII_UPPERCASE: ASCII_UPPERCASE, ASCII_LETTERS: ASCII_LETTERS, format: function format(s) { for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) { s = s.replace("{" + i + "}", i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]); } return s; }, getCodePoint: function getCodePoint(string, i) { var codePointData = getCodePointData(string, i); return codePointData && codePointData.code; }, getCodePoints: function getCodePoints(string) { if (typeof string !== 'string') { throw new TypeError('Not a string'); } var i = 0; var arr = []; var codePoint; while (!!(codePoint = getCodePointData(string, i))) { arr.push(codePoint.code); i += codePoint.long ? 2 : 1; } return arr; }, getSymbols: function getSymbols(string) { if (typeof string !== 'string') { throw new TypeError('Not a string'); } var index = 0; var length = string.length; var output = []; var take = 0; var ch; while (index < length) { take += numCharsToTakeForNextSymbol(string, index + take); ch = string[index + take]; if (isCodeBetween(ch, DIACRITICAL_MARKS_BEGIN, DIACRITICAL_MARKS_END)) { ch = string[index + take++]; } if (isCodeBetween(ch, VARIATION_MODIFIER_BEGIN, VARIATION_MODIFIER_END)) { ch = string[index + take++]; } if (ch && ch.charCodeAt(0) === ZERO_WIDTH_JOINER) { ch = string[index + take++]; continue; } var _char = string.substring(index, index + take); output.push(_char); index += take; take = 0; } return output; }, fromCodePoint: function fromCodePoint() { var chars = []; var current; var codePoint; var units; for (var i = 0; i < arguments.length; ++i) { current = Number(arguments[i]); codePoint = current - 0x10000; units = current > 0xFFFF ? [(codePoint >> 10) + 0xD800, codePoint % 0x400 + 0xDC00] : [current]; chars.push(String.fromCharCode.apply(null, units)); } return chars.join(''); } }; var IndexedList = function () { function IndexedList() { this._list = []; this._index = {}; } var _proto = IndexedList.prototype; _proto.push = function push(key, item) { if (this._index[key]) { throw Error("Key already in index " + key); } var location = this._list.push(item) - 1; this._index[key] = location; }; _proto.has = function has(key) { return this._index[key] !== undefined; }; _proto.get = function get(key) { var location = this._index[key]; if (location !== undefined) { return this._list[location]; } return null; }; _proto.remove = function remove(key) { var location = this._index[key]; if (location !== undefined) { this._list.splice(location, 1); delete this._index[key]; for (key in this._index) { var idx = this._index[key]; if (idx > location) { this._index[key] = idx - 1; } } return true; } return false; }; _proto.list = function list() { return this._list; }; _proto.clear = function clear() { this._list.length = 0; for (var prop in this._index) { delete this._index[prop]; } }; return IndexedList; }(); var cachedResult = function cachedResult(func) { var uninitToken = {}; var result = uninitToken; return function () { if (result === uninitToken) { result = func(); } return result; }; }; var Impl = function () { function Impl() {} Impl.loadScript = function loadScript(url, callback) { var s = document.createElement('script'); s.setAttribute('src', url); s.onload = function () { callback(null); }; s.onerror = function () { callback("Failed to load script='" + url + "'"); }; document.body.appendChild(s); }; Impl.loadWasm = function loadWasm(moduleName, config, callback) { var loadUrl = Impl.wasmSupported() && config.glueUrl && config.wasmUrl ? config.glueUrl : config.fallbackUrl; if (loadUrl) { Impl.loadScript(loadUrl, function (err) { if (err) { callback(err, null); } else { var module = window[moduleName]; window[moduleName] = undefined; module({ locateFile: function locateFile() { return config.wasmUrl; }, onAbort: function onAbort() { callback('wasm module aborted.'); } }).then(function (instance) { callback(null, instance); }); } }); } else { callback('No supported wasm modules found.', null); } }; Impl.getModule = function getModule(name) { if (!Impl.modules.hasOwnProperty(name)) { Impl.modules[name] = { config: null, initializing: false, instance: null, callbacks: [] }; } return Impl.modules[name]; }; Impl.initialize = function initialize(moduleName, module) { if (module.initializing) { return; } var config = module.config; if (config.glueUrl || config.wasmUrl || config.fallbackUrl) { module.initializing = true; Impl.loadWasm(moduleName, config, function (err, instance) { if (err) { if (config.errorHandler) { config.errorHandler(err); } else { console.error("failed to initialize module=" + moduleName + " error=" + err); } } else { module.instance = instance; module.callbacks.forEach(function (callback) { callback(instance); }); } }); } }; return Impl; }(); Impl.modules = {}; Impl.wasmSupported = cachedResult(function () { try { if (typeof WebAssembly === 'object' && typeof WebAssembly.instantiate === 'function') { var module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)); if (module instanceof WebAssembly.Module) { return new WebAssembly.Instance(module) instanceof WebAssembly.Instance; } } } catch (e) {} return false; }); var WasmModule = function () { function WasmModule() {} WasmModule.setConfig = function setConfig(moduleName, config) { var module = Impl.getModule(moduleName); module.config = config; if (module.callbacks.length > 0) { Impl.initialize(moduleName, module); } }; WasmModule.getConfig = function getConfig(moduleName) { var _Impl$modules; return (_Impl$modules = Impl.modules) == null || (_Impl$modules = _Impl$modules[moduleName]) == null ? void 0 : _Impl$modules.config; }; WasmModule.getInstance = function getInstance(moduleName, callback) { var module = Impl.getModule(moduleName); if (module.instance) { callback(module.instance); } else { module.callbacks.push(callback); if (module.config) { Impl.initialize(moduleName, module); } } }; return WasmModule; }(); var ReadStream = function () { function ReadStream(arraybuffer) { this.arraybuffer = void 0; this.dataView = void 0; this.offset = 0; this.arraybuffer = arraybuffer; this.dataView = new DataView(arraybuffer); } var _proto = ReadStream.prototype; _proto.reset = function reset(offset) { if (offset === void 0) { offset = 0; } this.offset = offset; }; _proto.skip = function skip(bytes) { this.offset += bytes; }; _proto.align = function align(bytes) { this.offset = this.offset + bytes - 1 & ~(bytes - 1); }; _proto._inc = function _inc(amount) { this.offset += amount; return this.offset - amount; }; _proto.readChar = function readChar() { return String.fromCharCode(this.dataView.getUint8(this.offset++)); }; _proto.readChars = function readChars(numChars) { var result = ''; for (var i = 0; i < numChars; ++i) { result += this.readChar(); } return result; }; _proto.readU8 = function readU8() { return this.dataView.getUint8(this.offset++); }; _proto.readU16 = function readU16() { return this.dataView.getUint16(this._inc(2), true); }; _proto.readU32 = function readU32() { return this.dataView.getUint32(this._inc(4), true); }; _proto.readU64 = function readU64() { return this.readU32() + Math.pow(2, 32) * this.readU32(); }; _proto.readU32be = function readU32be() { return this.dataView.getUint32(this._inc(4), false); }; _proto.readArray = function readArray(result) { for (var i = 0; i < result.length; ++i) { result[i] = this.readU8(); } }; _proto.readLine = function readLine() { var view = this.dataView; var result = ''; while (true) { if (this.offset >= view.byteLength) { break; } var c = String.fromCharCode(this.readU8()); if (c === '\n') { break; } result += c; } return result; }; return _createClass(ReadStream, [{ key: "remainingBytes", get: function get() { return this.dataView.byteLength - this.offset; } }]); }(); var SortedLoopArray = function () { function SortedLoopArray(args) { this.items = []; this.length = 0; this.loopIndex = -1; this._sortBy = void 0; this._sortHandler = void 0; this._sortBy = args.sortBy; this._sortHandler = this._doSort.bind(this); } var _proto = SortedLoopArray.prototype; _proto._binarySearch = function _binarySearch(item) { var left = 0; var right = this.items.length - 1; var search = item[this._sortBy]; var middle; var current; while (left <= right) { middle = Math.floor((left + right) / 2); current = this.items[middle][this._sortBy]; if (current <= search) { left = middle + 1; } else if (current > search) { right = middle - 1; } } return left; }; _proto._doSort = function _doSort(a, b) { var sortBy = this._sortBy; return a[sortBy] - b[sortBy]; }; _proto.insert = function insert(item) { var index = this._binarySearch(item); this.items.splice(index, 0, item); this.length++; if (this.loopIndex >= index) { this.loopIndex++; } }; _proto.append = function append(item) { this.items.push(item); this.length++; }; _proto.remove = function remove(item) { var idx = this.items.indexOf(item); if (idx < 0) return; this.items.splice(idx, 1); this.length--; if (this.loopIndex >= idx) { this.loopIndex--; } }; _proto.sort = function sort() { var current = this.loopIndex >= 0 ? this.items[this.loopIndex] : null; this.items.sort(this._sortHandler); if (current !== null) { this.loopIndex = this.items.indexOf(current); } }; return SortedLoopArray; }(); var Tags = function (_EventHandler) { function Tags(parent) { var _this; _this = _EventHandler.call(this) || this; _this._index = {}; _this._list = []; _this._parent = parent; return _this; } _inheritsLoose(Tags, _EventHandler); var _proto = Tags.prototype; _proto.add = function add() { var changed = false; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var tags = this._processArguments(args, true); if (!tags.length) { return changed; } for (var i = 0; i < tags.length; i++) { if (this._index[tags[i]]) { continue; } changed = true; this._index[tags[i]] = true; this._list.push(tags[i]); this.fire('add', tags[i], this._parent); } if (changed) { this.fire('change', this._parent); } return changed; }; _proto.remove = function remove() { var changed = false; if (!this._list.length) { return changed; } for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } var tags = this._processArguments(args, true); if (!tags.length) { return changed; } for (var i = 0; i < tags.length; i++) { if (!this._index[tags[i]]) { continue; } changed = true; delete this._index[tags[i]]; this._list.splice(this._list.indexOf(tags[i]), 1);